Instance Property

onshippingcontactselected

An event handler that is called when a shipping contact is selected in the payment sheet.

Declaration

attribute EventHandler onshippingcontactselected;

Discussion

This attribute must be set to a function that accepts an events argument; for example,

session.onshippingcontactselected = function(event) {}.

The event parameter contains the shippingContact attribute. Access this attribute using the event parameter, for example,

var myShippingContact = event.shippingContact;

The onshippingcontactselected function must respond by calling completeShippingContactSelection before the 30 second timeout, after which a message appears stating that the payment could not be completed.

The shippingContact attribute contains the information you requested by specifying requiredShippingContactFields in ApplePayPaymentRequest.

Before the user authorizes the transaction, you receive redacted shipping contact information in a callback event. The redacted information includes only the necessary data for completing transaction tasks, such as calculating taxes or shipping costs.

Listing 1

An example of redacted shipping contact information

{
    "locality": "Cupertino",
    "country": "United States",
    "postalCode": "95014",
    "administrativeArea": "CA",
    "countryCode": "us"
}

See Also

Handling Shipping Contact Updates

completeShippingContactSelection

Completes the selection of a shipping contact with an update.

ApplePayShippingContactSelectedEvent

An event object that contains the shipping address selected by the user.

ApplePayShippingContactUpdate

Updated transaction details resulting from a change in shipping contact, including any errors.