<!--
{
  "availability" : [

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

# onpaymentmethodselected

An event handler to call when the user selects a new payment method.

```
attribute EventHandler onpaymentmethodselected;
```

## Discussion

This attribute must be set to a function that accepts an `events` argument; for example, `session.onpaymentmethodselected = function(event) {}`.

The event parameter contains the [`paymentMethod`](/documentation/ApplePayontheWeb/ApplePayPaymentMethodSelectedEvent/paymentMethod) attribute. Access it like this:

`var myPaymentMethod = event.paymentMethod;`

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

---

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)