Class: TranspayrentApplePayHelper

TranspayrentApplePayHelper(environment, config, transaction)

The Transpayrent Helper SDK for Apple PayTM abstracts the Apple Pay Javascript Client into 2 simple methods:

The Transpayrent SDK handles the secure communication with Transpayrent's Payment Gateway and transmits the Google encrypted payment data and transaction data provided by the Transpayrent Helper SDK for Apple Pay.
Generally direct interaction with the helper SDK is unnecessary and the equivalent methods from the Transpayrent SDK called be instead.
Please refer to the following resources for additional details in regard to implementing Apple Pay:

Configuration of Apple Pay is done dynamically using data provided by the Transpayrent Payment Gateway to automatically handle the following scenarios:

  • Strong consumer authentication (SCA) using 3D Secure for PAN_ONLY authorizations if required
  • Passing the correct gateway and gatewayMerchantId to Apple Pay
  • Dynamically enable supported card networks (MasterCard, VISA etc.) for Apple Pay based on the configured country


new TranspayrentApplePayHelper(environment, config, transaction)

Creates a new instance of the Transpayrent SDK, which uses the Transpayrent Helper SDK for Apple Pay internally to abstract the Apple Pay Javascript Client.

Name Type Description
environment String

The Apple Pay environment, either PRODUCTION or TEST, that will be used by the helper SDK

config ApplePayConfig

The base configuration for Apple Pay.

transaction ApplePayTransaction

The details for the payment transaction that will be authorized using Apple Pay

  • 1.0.1
  • Common Transpayrent API license

Instantiate the Transpayrent SDK and display the "Buy with Apple Pay" button

 <script src="[ENVIRONMENT]"></script>
 <script src="[ENVIRONMENT]"></script>
     // SDK configuration
     var transpayrentConfig = {
         sessionId: [ID IN THE RESPONSE FROM "Create Payment Session"],
         accessToken: '[x-transpayrent-access-token HTTP HEADER IN THE RESPONSE FROM "Create Payment Session"]'
     var url = 'https://generator.[ENVIRONMENT]'+ transpayrentConfig.merchantId +'/system/PAYMENT_GATEWAY/sdk/CLIENT';

     // Instantiate SDK
     var sdk = new Transpayrent(url, transpayrentConfig);

     // List of payment methods supported by Apple Pay as returned in the response from "Create Payment Session"
     const paymentMethodIds = [ 103,   // VISA Dankort
                                107,   // Maestro
                                108,   // MasterCard
                                109,   // VISA
                                110    // VISA Electron
     // Display the Payment Sheet for Apple Pay 
     var config = { buttonstyle : 'black',
                    type : 'pay',
                    locale : 'en',
                    onClick : () => {
                         const paymentMethodId = 204;                                       // Apple Pay
                         var paymentSheetDetails = { merchant_id : transpayrentConfig.merchantId,
                                                     merchant_name : '[MY MERCHANT]',
                                                     country : 208,                         // Denmark
                                                     payment_method_ids : paymentMethodIds,
                                                     amount : { currency : 208,             // DKK
                                                                value : 1000 },
                                                     save : false };
                          sdk.displayPaymentSheet(paymentMethodId, paymentSheetDetails)
                             .then(token => completePayment(paymentMethodId) )
                             .catch(reason => {
                                 document.getElementById('container').style.visibility = 'hidden';
                                 alert('API: '+ reason.api +' failed with HTTP Status Code: '+ reason.status +' and error: '+ reason.messages[0].message +'('+ reason.messages[0].code +')');
                  } };
     // Display the "Buy with Apple Pay" button
     sdk.displayPaymentButton(204, document.getElementById('apple-pay-button-container'), paymentMethodIds, config);


displayPaymentButton(container, paymentMethodIds, config, …args)

Displays the Apple Pay payment button after confirmation of the viewer's ability to pay.
It is strongly recommended to use Transpayrent#displayPaymentButton.

Name Type Attributes Description
container *
paymentMethodIds Array.<PAYMENT_METHOD_ID>

List of Payment IDs returned by the Transpayrent Gateway upon initializing the payment transaction

config *
args any <repeatable>

displayPaymentSheet(sdk, resolver, rejecter)

Show Apple Pay payment sheet when Apple Pay payment button is clicked.
It is strongly recommended to use Transpayrent#displayPaymentSheet.

Name Type Description
sdk Transpayrent

An instance of the Transpayrent Browser SDK, which may be used to interact with the Transpayrent Payment Gateway

resolver function

The resolver function for a promise

rejecter function

The rejecter function for a promise