Customizations

There are some additional options for handling payments within the PPH SDK. This page, outlines the various options along with the relevant code samples.

Capturing authorizations

During the payment, if you set the isAuthCapture payment option to true to run the payment as an authorization, then you may need the option to capture the funds from within the integrating app. Alternatively, if you will be capturing from the server-side, you can use the Capture API.

In order to capture an authorization in-app, you need the following parameters:

  • authorization ID
  • PayPal invoice ID
  • total amount
  • a gratuity amount
  • currency

The total amount is the total amount that's needed to be captured, including any gratuity. The gratuity amount is separate for reporting purposes. Therefore, if you have an authorization for $10, and want to capture $12 total after a tip, then you'd submit the total amount as $12 and the gratuity amount as $2 accordingly. Also note that the capture currency has to match the currency of the original authorization.

PayPalRetailSDK.transactionManager().captureAuthorization(authId, invoiceId: invoice.payPalId, totalAmount: amountToCapture, gratuityAmount: 0, currency: invoice.currency) { (error, captureId) in

    // code to handle success or failure
    // if error, check error and handle accordingly
    // if success, record the capture ID for future reference

}
[PayPalRetailSDK captureAuthorizedTransaction:authorizationId invoiceId:paypalInvId totalAmount:amountToCapture gratuityAmount:0 currency:invoiceCurrency completionHandler:^(PPRetailError *error, PPRetailCaptureResponse *response) {
    if (error == NULL) {

    // code to handle success or failure
    // if error, check error and handle accordingly
    // if success, record the capture ID for future reference
    
}];
RetailSDK.getTransactionManager().captureAuthorization(authId, transactionRecord.getInvoiceId(), amountToCapture, gratuityAmount, invoice.getCurrency, new TransactionManager.CaptureAuthorizedTransactionCallback()
{
  @Override
  public void captureAuthorizedTransaction(RetailSDKException error, String captureId)
  {
    // code to handle success or failure
    // if error, check error and handle accordingly
    // if success, record the capture ID for future reference
  }
});

Voiding authorizations

During the payment, if you set the isAuthCapture payment option to true to run the payment as an authorization, then you may need the option to void the auth from within the integrating App. Alternatively, if you are voiding from the server-side, you can use the Void API.

PayPalRetailSDK.transactionManager().voidAuthorization(authTransactionNumber) { (error) in
    
    // code to handle success or failure
    // if error, check error and handle accordingly

}
[PayPalRetailSDK voidAuthorization:authorizationId completionHandler:^(PPRetailError *error) {
    
    // code to handle success or failure
    // if error, check error and handle accordingly   

}];
RetailSDK.getTransactionManager().voidAuthorization(authId, new TransactionManager.VoidAuthorizationCallback()
{
  @Override
  public void voidAuthorization(RetailSDKException error)
  {
    // code to handle success or failure
    // if error, check error and handle accordingly
  }
});

Manual entry

You can also enter a customer's credit card manually if needed. Follow the traditional route for processing a payment, except instead of creating transaction options and calling beginPayment(options), build a PPRetailManuallyEnteredCard instance and then pass that into the continue() method of the transaction context.

let cardInfo = PPRetailManuallyEnteredCard.init()
cardInfo.setCardNumber("1234123412341234")
cardInfo.setExpiration("MMYYYY")
cardInfo.setCVV("123")
cardInfo.setPostalCode("12345")

tc.continue(with: cardInfo)
PPRetailManuallyEnteredCard *cardInfo = [[PPRetailManuallyEnteredCard alloc] init];
cardInfo.setCardNumber = @"1234123412341234";
cardInfo.setExpiration = @"MMYYYY";
cardInfo.setCVV = @"123";
cardInfo.setPostalCode = @"12345";

[self.transactionContext continue:cardInfo];
ManuallyEnteredCard card = new ManuallyEnteredCard();
card.setCardNumber("1234123412341234");
card.setCVV("123");
card.setExpiration("MMYYYY");
card.setPostalCode("12345");

currentTransaction.continueWithCard(card);

Next: Going live

Feedback