## Token event

`paymentRequest.on(event: string, handler: function)`

Stripe.js automatically creates a [Token](https://docs.stripe.com/api/tokens.md) after the customer is done interacting with the browser’s payment interface. To access the created `Token`, listen for this event.

*   `event` The name of the event. In this case, `token`.
*   `handler` A callback function that will be called with a [PaymentResponse](https://docs.stripe.com/js/appendix/payment_response.md) object when the event is fired. The `PaymentResponse` object will contain a `token` field.

### Example

```javascript
paymentRequest.on('token', (event) => {
  // Use the token to create a charge or save it to a customer.
  // For example:
  // stripe.createCharge({
  //   source: event.token,
  // });

  // Report to the browser that the payment was successful,
  // and that it can close any active payment interface.
  event.complete('success');
});
```