Code Samples

Apple Pay Code Samples

ApplePay inside of Pay SDK uses two transaction methods at the moment.

The first method is processing a Sales Transaction. We call this method with the following:

Example: processSaleTransaction

// Transaction Methods  

+ (NSError *)processSaleTransaction:(EAPCredentials *)credentials payment:(PKPayment *)payment callWhenComplete:(processingCompleted)complete;

If we look at this method broken out, we learn how it functions:

Example: processSaleTransaction Breakdown

    + (NSError *)processSaleTransaction:(EAPCredentials *)credentials payment:(PKPayment *)payment callWhenComplete:(processingCompleted)complete {
    if (credentials == nil || payment.token.paymentData == nil)
           return [EAPError error:EAPErrorCode_InvalidParameters];
    }
    ConvergeApplePayTransactionRequest *request = [[ConvergeApplePayTransactionRequest alloc] init:credentials paymentData:payment.token.paymentData transactionType:CONVERGE_APITRANSACTIONTYPE_SALE_CREDITCARD billingCycle:nil];
          return [self processTransaction:credentials request:request payment:payment callWhenComplete:complete];

The second supported method is performing an Auth-Only transaction, namely to ensure the proper credit exists before a transaction is performed. This transaction is called with the following method:

Example: processSaleTransaction

    // Transaction Methods  

    + (NSError *)processAuthOnlyTransaction:(EAPCredentials *)credentials payment:(PKPayment *)payment callWhenComplete:(processingCompleted)complete;

Here’s a breakout of this method:

Example: processAuthOnlyTransaction Breakdown

     + (NSError *)processAuthOnlyTransaction:(EAPCredentials *)credentials payment:(PKPayment *)payment callWhenComplete:(processingCompleted)complete {
     if (credentials == nil || payment.token.paymentData == nil) {
           return [EAPError error:EAPErrorCode_InvalidParameters]; 
     }

     ConvergeApplePayTransactionRequest *request = [[ConvergeApplePayTransactionRequest alloc] init:credentials paymentData:payment.token.paymentData transactionType:CONVERGE_APITRANSACTIONTYPE_PREAUTH_CREDITCARD billingCycle:nil]; 
     return [self processTransaction:credentials request:request payment:payment callWhenComplete:complete];

     }