Installing and Initializing

Installing the Paysafe Library

These installation and initialization steps are applicable to both Apple Pay and non–Apple Pay, unless specified.

Install the Paysafe Library Using CocoaPods (recommended)

CocoaPods is the recommended way of integrating our iOS SDK. It allows you to easily keep your application's dependencies up to date.

If you have not yet set up CocoaPods, go to http://cocoapods.org/ for installation instructions. After installation, you need to set up pods for your application.

  1. Open the terminal and navigate to the application folder.
  2. Create an empty Podfile.

    $ touch podfile

  3. Open the Podfile.

    $ open -a xcode podfile

  4. Add the Paysafe iOS SDK pod to your Podfile. You can specify which version you want – if you do not mention a specific version, it will take the latest version of the SDK.

    pod 'Paysafe'

  5. Install the Paysafe iOS SDK pod in your application.

    $ pod install

Once the pod is installed in your application, you have to use workspace to use the installed SDK along with your application.

From this point on, be sure to use the .xcworkspace file to open your project in Xcode, and not the .xcodeproj file.

Install the Paysafe Library Using git

This is the alternative method for installing the Paysafe iOS SDK, as opposed to using the CocoaPods integration. You can clone the Paysafe iOS library repository directly.

git clone https://github.com/paysafegroup/paysafe_sdk_ios.git

Add the iOS_SDK to Your Xcode Project

  1. In the Xcode menu bar, click File > Add Files to Project.
  2. Select the iOS_SDK directory from the downloaded repository.
  3. Make sure the Copy items into destination group's folder (if needed) check box is selected.
  4. Click Add.
  5. In your project settings, go to the Build Phases tab, and make sure Foundation. framework, Security. framework, and PassKit framework are included in the Link Binary With Libraries section.

Initialize the Payment Authorization Process

The application must pass the following parameters to the framework during initialization:

  • Merchant identifier (registered in the Apple development portal) – note that this parameter is required only for Apple Pay transactions.
  • Merchant Paysafe User ID (registered Paysafe API Key ID)
  • Merchant Paysafe Password (registered Paysafe API Key Password)
  • Merchant Country Code (currently US)
  • Merchant Currency code (currently USD)

You need to import PaysafePaymentAuthorizationProcess.h for initialization.

Objective-C for Apple Pay

#import "PaysafePaymentAuthorizationProcess.h"
@interface MyViewController : UIViewController <PaysafePaymentAuthorizationProcessDelegate>
@property (nonatomic, strong) PaysafePaymentAuthorizationProcess *PaysafepaymentObj;
@end
@implementation MyViewController
- (void)viewDidLoad {
    ----------------
self.PaysafeAuthController = [[PaysafePaymentAuthorizationProcess alloc] initWithMerchantIdentifier:appleMerchantIdentifier withMerchantID:merchantUserID withMerchantPwd:merchantPassword withMerchantCountry:merchantCountryCode withMerchantCurrency:merchantCurrencyCode];
    -----------------
}

For Objective-C for Non–Apple Pay, please pass the merchant identifier as a blank value.

Swift for Apple Pay

Because the SDK is developed in Objective-C, you need to create and use the Bridging file in the Swift project to use the Objective-C files and then import the file below to communicate with the SDK. Please refer here for more details.

First, open the Bridging file and do the following import:

#import "PaysafePaymentAuthorizationProcess.h"

Here is the initialization code for Swift for Apple Pay:

PaysafeAuthController = PaysafePaymentAuthorizationProcess(merchantIdentifier: plistDataDictionary!["merchantIdentifier"]!  as? String, withMerchantID: plistDataDictionary!["MerchantID"]!  as? String, withMerchantPwd: plistDataDictionary!["MerchantPassword"]!  as? String, withMerchantCountry: plistDataDictionary!["countryCode"]!  as? String, withMerchantCurrency: plistDataDictionary!["CurrencyCode"]!  as? String)

For Swift for Non–Apple Pay, please pass the merchant identifier as a blank value.

Did you find this page useful?