<!--
{
  "availability" : [

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

# oncancel

An event handler that is automatically called when the payment UI is dismissed.

```
attribute EventHandler oncancel;
```

## Discussion

This function can be called even after an [`onpaymentauthorized`](/documentation/ApplePayontheWeb/ApplePaySession/onpaymentauthorized) event has been dispatched. Both the user and the web page can dismiss the payment sheet and abandon 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)