---
title: oncouponcodechanged
framework: applepayontheweb
role: symbol
role_heading: Instance Property
path: applepayontheweb/applepaysession/oncouponcodechanged
---

# oncouponcodechanged

An event handler called by the system when the user enters or updates a coupon code.

## Declaration

```data
attribute EventHandler oncouponcodechanged;
```

## Discussion

Discussion Set this attribute to a function with one parameter that contains an ApplePayCouponCodeChangedEvent. This function processes the coupon code update, and then calls completeCouponCodeChange with the results. The code below shows adding a listener for the coupon code changed event to the Apple Pay session: // Add a listener for the couponcodechanged event to the Apple Pay session. session.addEventListener("couponcodechanged", function(event) {     var newCode = event.couponCode;

// Process the coupon code.     ...

// Call the Apple Pay session completion method for this event.     session.completeCouponCodeChange({         // Update the payment request with any changed information.         newTotal: ...     }); }); note: Call completeCouponCodeChange within 30 seconds to prevent the system ending the payment request.

## See Also

### Handling coupons

- [completeCouponCodeChange](applepayontheweb/applepaysession/completecouponcodechange.md)
- [ApplePayCouponCodeChangedEvent](applepayontheweb/applepaycouponcodechangedevent.md)
- [ApplePayCouponCodeUpdate](applepayontheweb/applepaycouponcodeupdate.md)
