PaymentSDK
Mobile payment SDK
Example

WDPayPalPayment example

  1. Initialize WDClient instance
    1 - (void)makePayPalPayment
    2 {
    3  // it is better to keep client as property to keep reference
    4  WDClient *client = [[WDClient alloc] initWithEnvironment:WDEnvironmentTEST];
  2. Initialize WDPayPalPayment instance
    1 WDPayPalPayment *payment = [[WDPayPalPayment alloc] initWithAmount:[NSDecimalNumber decimalNumberWithMantissa:1275 exponent:-2 isNegative:NO]
    2  currency:WDCurrencyEUR];
    3 payment.transactionType = WDTransactionTypeDebit;
  3. Generate requestID, requestTimestamp and requestSignature on your server and assign them to WDPayPalPayment object
    1 payment.merchantAccountID = merchantAccountID; // provided by support
    2 payment.requestID = [[NSUUID UUID] UUIDString]; // generated on server unique to merchant
    3 payment.requestTimestamp = [NSDate date]; // generated on server
    4 payment.requestSignature = signature; // generated on server
  4. Create WDCompletionBlock to handle response
    1 WDCompletionBlock completionBlock = ^(WDPaymentResponse *_Nullable response, NSError *_Nullable error) {
    2  if (error) {
    3  IPLogError(@"error: %@", error);
    4  UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
    5  message:error.localizedDescription
    6  delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    7  [alertView show];
    8  return;
    9  }
    10  // handle successful response
    11 };
  5. Trigger the payment
    1  [client makePayment:payment withCompletion:completionBlock];
    2 }