Supported transaction type is purchase only and there are 2 flows based on users requirements:
- If a merchant requires a full control over PKPaymentRequest (dynamic shipping methods and pricing) then use WDApplePayPayment.
- If the purchase is simple with fix shipping price use WDApplePayManagedPayment to handle PKPaymentRequest by SDK.
- Initialize WDClient instance
1 - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
2 didAuthorizePayment:(PKPayment *)payment
3 completion:(void (^)(PKPaymentAuthorizationStatus status))completion
5 // it is better to keep client as property to keep reference
6 WDClient *client = [[WDClient alloc] initWithEnvironment:WDEnvironmentTEST];
- Initialize WDApplePayPayment instance
1 WDApplePayPayment *applePayPayment = [[WDApplePayPayment alloc] initWithPayment:payment
2 summaryItems:self.sumaryItems
- Generate requestID, requestTimestamp and requestSignature on your server and assign them to WDApplePayPayment object
1 applePayPayment.merchantAccountID = merchantAccountID; // provided by support
2 applePayPayment.requestID = [[NSUUID UUID] UUIDString]; // generated on server unique to merchant
3 applePayPayment.requestTimestamp = [NSDate date]; // generated on server
4 applePayPayment.requestSignature = signature; // generated on server
- Create completionBlock to handle response and call PKPaymentAuthorizationViewController completion block provided to delegate
1 WDCompletionBlock completionBlock = ^(WDPaymentResponse *_Nullable response, NSError *_Nullable error) {
3 IPLogError(@"error: %@", error);
4 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
5 message:error.localizedDescription
6 delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
8 completion(PKPaymentAuthorizationStatusFailure);
11 completion(PKPaymentAuthorizationStatusSuccess);
- Trigger the payment
1 [client makePayment:applePayPayment withCompletion:completionBlock];
- Initialize WDClient instance
1 - (void)makeApplePayManaged
3 // it is better to keep client as property to keep reference
4 WDClient *client = [[WDClient alloc] initWithEnvironment:WDEnvironmentTEST];
- Initialize WDApplePayManagedPayment instance
1 WDApplePayManagedPayment *applePayPayment = [[WDApplePayManagedPayment alloc] initWithMerchant:kAppleMerchantID
2 andCountry:WDCountryGB];
3 applePayPayment.amount = [NSDecimalNumber decimalNumberWithMantissa:1275 exponent:-2 isNegative:NO];
4 applePayPayment.amountCurrency = WDCurrencyGBP;
- Generate requestID, requestTimestamp and requestSignature on your server and assign them to request WDApplePayManagedPayment
1 applePayPayment.merchantAccountID = merchantAccountID; // provided by support
2 applePayPayment.requestID = [[NSUUID UUID] UUIDString]; // generated on server unique to merchant
3 applePayPayment.requestTimestamp = [NSDate date]; // generated on server; UTC
4 applePayPayment.requestSignature = signature; // generated on server
- Create WDCompletionBlock to handle response
1 WDCompletionBlock completionBlock = ^(WDPaymentResponse *_Nullable response, NSError *_Nullable error) {
3 IPLogError(@"error: %@", error);
4 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
5 message:error.localizedDescription
6 delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
10 // handle successful response
- Trigger the payment
1 [client makePayment:applePayPayment withCompletion:completionBlock];