Configure Apple Pay

To enable Apple Pay, you need to update the SDK files. Below you can find examples for Swift and Objective-C.

SDK can be configured both ways on each language.

// Store all merchant details in .plist file and read all relevant information from there
- (PaysafeSDKApplePayMerchantConfiguration *)getPaysafeSDKApplePayMerchantConfigurationFromPlist:(NSString *)plistName {
        NSString *path = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
        NSDictionary *myDictionary = [[NSDictionary alloc] initWithContentsOfFile:path];

        NSString *countryCode = [myDictionary objectForKey:@"countryCode"];
        NSString *currencyCode = [myDictionary objectForKey:@"CurrencyCode"];
        NSString *appleMerchantIdentifier = [myDictionary objectForKey:@"merchantIdentifier"];

        PaysafeSDKApplePayMerchantConfiguration *result = [[PaysafeSDKApplePayMerchantConfiguration alloc]
                                                                                                    initWithApplePayMerchantId:appleMerchantIdentifier
                                                                                                    countryCode:countryCode
                                                                                                    currencyCode:currencyCode];
        return result;
}


PaysafeSDK.applePayMerchantConfiguration = [self getPaysafeSDKApplePayMerchantConfigurationFromPlist:@"PaysafeSDK_ApplePay-Info"];

// Before / After reading the configuration you have to setup ApplePayService
self.applePayService = [[ApplePayService alloc] init];
PaysafeSDK.applePayMerchantConfiguration = PaysafeSDK.ApplePayMerchantConfiguration(applePayMerchantId: "<Your Generated Merchant Id>",
                                                                                           countryCode: "<Merchant country code>",
                                                                                          currencyCode: "<Merchant currency code>")


// Create ApplePayService instance only once
    private lazy var applePayService = {
        return ApplePayService()
    }()

Paysafe SDK needs applePayMerchantConfiguration, and ApplePayService set to work appropriately.

Did you find this page useful?