Affirm.js is Affirm's JavaScript library. To use it on your website, for example to show Affirm promotional messaging, you need your Affirm public API key. You do not need this key to process Affirm payments with Adyen.
You can get the key using the Management API. The API returns the key for the environment that you send the request to. The test environment returns your Affirm sandbox key, and the live environment returns your live key.
Requirements
Before you begin, take into account the following requirements and preparations.
| Requirement | Description |
|---|---|
| Integration type | Make sure that you have built your Affirm integration. |
| API credentials | Your Management API credential must have the following role:
|
| Setup steps | Before you begin, add Affirm in your Customer Area. |
Get your Affirm public API key
To get your Affirm public API key:
- Make a GET /merchants/{merchantId}/paymentMethodSettings request with your merchant account ID in the path, and the
pageSizequery parameter set to 100. -
In the response, find the payment method with
typeaffirm, and get the key from itsaffirm.publicApiKeyfield.If the response does not include Affirm, make a GET request to the URL in
_links.next.hrefto get the next page. Repeat until you find Affirm, or until the response does not include_links.next.