Configure the SDK – Swift + Obj-C 2017-03-03T15:18:55+00:00

gure_The

iOS – Configure the SDK

Configuring Required Settings

1. At a minimum, before your app can use the SDK, you must set a number of configuration options. This task is performed through the JPConfiguration object and normally done once-only by your AppDelegate object. However, these settings can be changed at any time.

2. At a minimum, you will need to set your developer account details and the Jetpay payment environment to be used (TEST or PRODUCTION for example).

For further details, please see the JetPay Full iOS SDK Reference

Below, is some example code which performs this task:

import Jetpay

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

   func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

      JPConfiguration.sharedConfiguration.setEnvironmentType(.Test)
      JPConfiguration.sharedConfiguration.setAccount( visaDeveloperID: “Your Visa Developer ID”, developerID: “Your DeveloperID”, terminalID: “Your TerminalID” )

      return true
   }
}

@import Jetpay

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[[JPConfiguration sharedConfiguration] setEnvironmentType:JPEnvironmentTypeTest];

[[JPConfiguration sharedConfiguration] setAccountWithVisaDeveloperID:@“Your Visa Developer ID” developerID:@“Your DeveloperID” terminalID:@“Your TerminalID”];

return YES;

}

@end



Configuring Optional Settings

1. Further to the required configuration settings, there are a number of optional settings.  For example, a JPTheme object can be added to JPConfiguration which dictates the visible nature (fonts, colours, borders, etc) of your SDK UI components when displayed.

2. All optional settings have default values. The global theme and required address fields are have default values for example.

For further details, please see the JetPay Full iOS SDK Reference

Below is some example code which sets the theme and required address fields:

import Jetpay

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

   func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

      JPConfiguration.sharedConfiguration.setTheme(globalTheme: JPTheme.defaultTheme())
      JPConfiguration.sharedConfiguration.requiredAddressFields = .Full

      return true
   }
}

@import Jetpay

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

	[[JPConfiguration sharedConfiguration] setTheme:[JPTheme defaultTheme]];
	[JPConfiguration sharedConfiguration].requiredAddressFields = JPRequiredAddressFieldsFull;

	return YES;
}

@end