Apple Pay Hosted Checkout Objects Reference (Request)

For complete sample code please refer here

Available dictionary objects


iStatus

const iStatus = {
    success: 100,
    unsupported: -100,
    error: -200
}

Use: iStatus.success

APButtonColor

const APButtonColor = {
    black: "black",
    white: "white",
    whiteOutline: "white-outline"
}    

Use: APButtonColor.black

APButtonType

Use: APButtonType.buy

APRequiredFeatures

Use: APRequiredFeatures.address_validation

APErrorCode

Use: APErrorCode.addressUnserviceable

APErrorContactField

Use: APErrorContactField.administrativeArea

Request objects


ApplePayRequest

The Main object that contains all the information necessary to communicate with Apple Pay API.

Name

Type

Required

Description

merchantIdentifier

String

Yes

For merchants integrating their own Apple Developer account must be Merchant Identifier from the account, otherwise must be merchant.cardknox.com

buttonOptions

No

Provides Apple Pay button customization options. For more information please click the link.

requiredFeatures

No

Features required by Merchant. Each Feature is available with the certain iOS version. Therefore if device doesn’t support that version (Feature) - Apple Pay Button won’t be displayed.

requiredBillingContactFields

No

List of field names used for requesting contact information in a payment request.

requiredShippingContactFields

No

List of field names used for requesting contact information in a payment request.

onAPButtonLoaded

String

Yes

Name of a callback function to be called when Apple Pay button is loaded. Accepts an object of type APButtonLoadedResultarrow-up-right Please click herearrow-up-right for the sample code.

onGetTransactionInfo

String

Yes

Name of a callback function to be called that returns the final price and tax calculations. Please click herearrow-up-right for the sample code.

onGetShippingMethods

String

Yes

Name of a callback function to be called that returns a list of available Shipping Methods. Please click herearrow-up-right for the sample code.

onShippingContactSelected

String

Yes

Name of a callback function to be called when Shipping Contact is selected/changed. Accepts a parameter PaymentContactarrow-up-right. Returns ShippingContactResponsearrow-up-right. If address_validation is part of requiredFeaturesarrow-up-right in your ApplePay Request object you can return an Error as part of ShippingContactResponse. Please click here for the sample code.

onShippingMethodSelected

String

Yes

Name of a callback function to be called when Shipping Method is selected/changed. Accepts a parameter ShippingMethodarrow-up-right. Please click herearrow-up-right for the sample code.

onPaymentMethodSelected

String

Yes

Name of a callback function to be called when Payment Method is selected/changed. Accepts a parameter PaymentMethodarrow-up-right. Please click herearrow-up-right for the sample code.

onBeforeProcessPayment

String

Yes

Name of a callback function to be called when consumer clicked the button but before Apple Pay sheet is loaded. Usually used to make validations before the payment. Please click herearrow-up-right for the sample code.

onValidateMerchant

String

Yes

Name of a callback function to be called to validate the Merchant. This functions accepts a parameter validationUrl. Please click herearrow-up-right for the sample code.

onPaymentAuthorize

String

Yes

Name of a callback function to be called when Apple Payment is authorized for the completion of the transaction. This function accepts a parameter of PaymentResponse. Please click herearrow-up-right for the sample code.

onPaymentComplete

String

Yes

Name of a callback function to be called when Apple confirms the completion of the transaction. This function accepts a parameter of PaymentComplete. Please click herearrow-up-right for the sample code.

onError

String

Yes

Name of a callback function to be called when Error occurs. Please click here for the sample code. Make sure to assign onError in initAP function like below.

onCancel

String

Yes

Name of a callback function to be called when user cancels. Please click herearrow-up-right for the sample code.

Request Examples

Payment Request example

onAPButtonLoaded callback example

onGetTransactionInfo callback example

onGetShippingMethods callback example

onShippingContactSelected callback example

onShippingMethodSelected callback example

onPaymentMethodSelected callback example

onBeforeProcessPayment callback example

onValidateMerchant callback example

onPaymentAuthorize callback example

onPaymentComplete callback example

onError callback example

onCancel callback example


ButtonOptions Object

Name

Type

Required

Description

buttonContainer

String

Yes

Name of the <div> where Apple Pay Button will be loaded

buttonColor

No

From Google documentation:

  • default: A Google-selected default value. Currently black but it may change over time (default).

  • black: A black button suitable for use on white or light backgrounds.

  • white: A white button suitable for use on colorful backgrounds.

buttonType

No

From Google documentation:

  • buy: "Buy with Google Pay" button (default).

  • donate: "Donate with Google Pay" button.

  • plain: Google Pay button without additional text.

Button Options example


APButtonLoadedResult Object

Name

Type

Description

status

iStatus

There are 3 possible cases:

  • Apple Pay Button loaded successfully: status = iStatus.success

  • Apple Pay not supported: status = iStatus.unsupported

  • An error occurred while loading Apple Pay Button: status = iStatus.error

reason

String

If Apple Pay Button failed to load this field will be populated with the reason.


ApplePayContactField

Field names used for requesting contact information in a payment request.

Available fields:

  • name

  • email

  • phone

  • postalAddress

ApplePay Contact Field example

PaymentContact Object

Name

Type

Description

phoneNumber

String

A phone number for the contact

emailAddress

String

An email address for the contact

givenName

String

The contact’s given name

familyName

String

The contact’s family name

addressLines

String[]

The street portion of the address for the contact

subLocality

String

Additional information associated with the location, typically defined at the city or town level (such as district or neighborhood), in a postal address

locality

String

The city for the contact

postalCode

String

The zip code or postal code, where applicable, for the contact

subAdministrativeArea

String

The subadministrative area (such as a county or other region) in a postal address

administrativeArea

String

The state for the contact

country

String

The name of the country or region for the contact

countryCode

String

The contact’s two-letter ISO 3166 country code

ShippingContactResponse Object

Name

Type

Description

lineItems

A set of line items that explain recurring payments and additional charges and discounts.

total

A line item that represents the total for the payment.

shippingMethods

A list of Shipping Methods

error

Error code

LineItem Object

circle-info

We’re now supporting Recurring and Deferred Payments as well as Subscriptions. These features are supported starting iOS 15.4.

These features are available if support_recurring and/or support_subscription is part of requiredFeaturesarrow-up-right list.

Name
Type
Description

type

ApplePayLineItemType

A value that indicates whether the line item is final or pending

label

String

A required value that’s a short, description of the line item

amount

String

A required value that’s the monetary amount of the line item.

Recurring and Subscription

paymentTiming

ApplePayPaymentTiming object

The time that the payment occurs as part of a successful transaction

recurringPaymentStartDate

Date

The date of the first payment

recurringPaymentEndDate

Date

The date of the final payment

recurringPaymentIntervalUnit

ApplePayRecurringPaymentDateUnit

The amount of time — in calendar units, such as day, month, or year — that represents a fraction of the total payment interval

recurringPaymentIntervalCount

Long

The number of interval units that make up the total payment interval

deferredPaymentDate

Date

The date, in the future, of the payment

automaticReloadPaymentThresholdAmount

String

The balance an account reaches before the merchant applies the automatic reload amount

ApplePayLineItemType

  • final - A line item representing the known, final cost.

  • pending - A line item representing an estimated or unknown cost.

ApplePayRecurringPaymentDateUnit

  • year

  • month

  • day

  • hour

  • minute

Recurring Line Item Example (Charging $20 starting today for the next year)

ShippingMethod Object

Name

Type

Description

label

String

Label for this Shipping Method

amount

String

Price for this shipping option

detail

String

Description for this Shipping Method

identifier

String

Identifier for this Shipping Method

ShippingMethod example


PaymentMethod Object

Name

Type

Description

displayName

String

A string, suitable for display, that describes the card

network

String

Name of the payment network backing the card

type

PaymentMethodType

The card's type of payment

billingContact

PaymentContact

The billing contact associated with the card


PaymentMethodType

A payment card’s type of payment.

The payment method type value is one of:

  • debit

  • credit

  • prepaid

  • store

Error Object

Note: Supported starting iOS 11. Available when address_validation is part of requiredFeaturesarrow-up-right list.

Name

Type

Description

code

One of Apple Pay Error Codes

contactField

One of Apple Pay Error Contact fields

message

String

Error message displayed to the customer

Last updated

Was this helpful?