> This page is for Afterpay Online Developer, version v1.
> For other versions, use one of these documentation indexes:
> - Main (default): https://developers.afterpay.com/afterpay-online-developer/main/llms.txt
> - v1: https://developers.afterpay.com/afterpay-online-developer/v-1/llms.txt
> - Chinese: https://developers.afterpay.com/afterpay-online-developer/chinese/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.afterpay.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.afterpay.com/_mcp/server.

# JavaScript afterpay.js

## Production- All Regions

```
https://portal.afterpay.com/afterpay.js
```

## Sandbox - All Regions

```
https://portal.sandbox.afterpay.com/afterpay.js
```

The `afterpay.js` is used to launch the Afterpay screenflow, where the consumer logs in (or registers) then confirms their payment schedule.

> **Info**
>
> Before this JavaScript can be used, the merchant must call [Create Order](../../../reference/orders/Create-Order.v1.yaml/paths/~1v1~1orders~1environment:\{environment}/post) from their server backend and retrieve an order token. The token is then used in conjunction with this JavaScript to launch the Afterpay screenflow.
>
> It is only after the consumer completes the Afterpay screenflow and returns to the merchant's website that a subsequent [Capture Payment](../../../reference/payments/Capture-Payment.v1.yaml/paths/~1v1~1payments~1capture~1environment:\{environment}/post) call can be completed.