<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "ApplePayontheWeb",
  "identifier" : "/documentation/ApplePayontheWeb/ApplePaySession/onshippingcontactselected",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Apple Pay on the Web"
    ],
    "preciseIdentifier" : "instp/ApplePaySession/onshippingcontactselected"
  },
  "title" : "onshippingcontactselected"
}
-->

# onshippingcontactselected

An event handler to call when the user selects a shipping contact in the payment sheet.

```
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`](/documentation/ApplePayontheWeb/ApplePayShippingContactSelectedEvent/shippingContact) attribute. Access this attribute using the `event` parameter, for example,

`var myShippingContact = event.shippingContact;`

The [`onshippingcontactselected`](/documentation/ApplePayontheWeb/ApplePaySession/onshippingcontactselected) function must respond by calling [`completeShippingContactSelection`](/documentation/ApplePayontheWeb/ApplePaySession/completeShippingContactSelection) before the 30 second timeout, after which a message appears stating that the payment could not be completed.

The [`shippingContact`](/documentation/ApplePayontheWeb/ApplePayPayment/shippingContact) attribute contains the information you requested by specifying [`requiredShippingContactFields`](/documentation/ApplePayontheWeb/ApplePayPaymentRequest/requiredShippingContactFields) in [`ApplePayPaymentRequest`](/documentation/ApplePayontheWeb/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

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

> Note:
> The data returned may differ based on the user’s geographic region. For Canada and United Kingdom, a redacted shipping address excludes the  last three characters of the postal code.  For US addresses, the redacted zip code contains the first five digits.
> 
> The full postal code is provided after the user authorizes the transaction.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)