Use your own certificate
Airwallex allows you to use your own certificate to decrypt payment token received from Apple Pay. This is especially useful when you have an active integration with multiple gateways and would like to manage the token decryption by yourself.
Before you begin
- Create a developer account on Apple Pay developer portal. Ensure you have an active email address linked to the account to be able to receive notifications on certificate expiry.
- Enable Apple Pay payment method for the merchant account at Airwallex. You are not required to add additional domain information on the Airwallex web app when using your own certificate.
- Create a merchant identifier on the Apple Pay developer portal, which uniquely identifies you as a Apple Pay merchant. Note that this merchant id never expires.
- Create a payment processing certificate that will be used to encrypt the payment token returned from the Apple Server. This certificate is linked to the merchant identifier created in Step 3. This step requires creation of Certificate Signing Request (CSR), covered in the above link, post which a certificate will be issued by Apple.
- (Optional) Enable Apple Pay on the developer portal for your mobile application. This step is optional and required only if you would like to support mobile applications. It is not required if you wish to process web-based transactions only.
- Validate your merchant domain so that a secure connection can be established between your domain and the Apple servers.
- Create a merchant identity certificate that will enable you to request a Apple Pay payment session . Ensure you select the merchant identifier created in Step #3 while creating a merchant identity certificate. You will also be required to generate a CSR file to be able to receive a merchant identity certificate.
Step 1: Create a PaymentIntent
Create a PaymentIntent using the Airwallex API API. This step lists the available payment methods for the merchant account, and should ideally return Apple Pay as an available payment method.
Step 2: Request a payment session
Request Payment session for each Apple Pay transaction and complete merchant validation using the output received from the Payment session response.
Step 3: Decrypt the payment data
Decrypt the payment data using the payment processing certificate based on the event OnPaymentAuthorized
Step 4: Confirm the PaymentIntent
Confirm the PaymentIntent using the Airwallex API API using the decrypted payment token information.
Example code
Subscription payments
Save payment details for future payments
Airwallex allows you to create a PaymentConsent with the shopper to initiate future payments using shopper’s saved payments details. For more information, see Save payment details for future payments . You need to add additional information about the order & terms of the payment to display this information on the payment sheet.
Save payment details without payment
Create customer - You need to create customer API if it is a new customer
Get available payment method types - If applepay payment method is active with recurring transaction mode, the merchant can choose Apple Pay as payment methods for subscriptions. Refer sample response below
Endpoint : GET /api/v1/pa/config/payment_method_types
- Apple Pay payment request - As explained at the start of this page, you need to create ApplePayPaymentRequest and include the information about subscription payment along with lineitem details. See below samples :
Fixed Subscription Payment with deferred start
Variable Subscription Payment with deferred start
- Create a Payment Method - Create a Payment method through the Airwallex API - see full details here API. Sample below:
Create a Payment consent - Create a Payment consent through the Airwallex API - see full details here API. See sample request below:
JSONVerify Payment consent - Verify the Payment consent through the Airwallex API - see full details here API. See sample below:
Save payment details with payment
Create customer - You need to create customer API if it is a new customer
Get available payment method types - If applepay payment method is active with recurring transaction mode, the merchant can choose Apple Pay as payment methods for subscriptions. Refer sample response below
Endpoint : GET /api/v1/pa/config/payment_method_types
- Apple Pay payment request - As explained at the start of this page, you need to create ApplePayPaymentRequest and include the information about subscription payment along with lineitem details. See below samples :
Fixed Subscription Payment with immediate start
Variable Subscription Payment with immediate start
- Create a Payment Method - Create a Payment method through the Airwallex API - see full details here API. Sample below:
Create a Payment consent - Create a Payment consent through the Airwallex API - see full details here API. See sample request below:
JSONCreate a Payment Intent - for the order with the customer ID. This step is only needed for shopper wishes to pay for the first order in the payment method binding process.
Confirm Payment Intent - Confirm the Payment intent through the Airwallex API - see full details here API. This request should refer to PaymentConsent ID created in Step#5, see sample request below: