Skip to content

A server to power the iOS and Android SDK example applications.

License

Notifications You must be signed in to change notification settings

afterpay/sdk-example-server

Repository files navigation

Afterpay SDK Example Server

Build and Lint Code Style: Prettier

A server to power the iOS and Android SDK example projects.

Contents

Requirements

Getting Started

Region

The region is specified with the AFTERPAY_REGION environment variable in the format of an IETF language four-letter hyphen separated language code and country code. (ie en-NZ)

Supported regions are: en-AU, en-CA, en-CA, es-ES, fr-FR, it-IT, en-NZ and en-US.

NOTE: The example server will fallback to the en-US region if the environment variable is not set.

Authentication

A Merchant ID and Secret Key are required for access to the Afterpay sandbox API in the selected region. These must be defined in the AFTERPAY_MERCHANT_ID and AFTERPAY_SECRET_KEY environment variables, respectively.

This can be done a number of ways:

  1. Exporting before starting the server
export AFTERPAY_MERCHANT_ID="#####" && \
export AFTERPAY_SECRET_KEY="************"
  1. Copy the .env.example to .env and modify the values

Note: If an environment variable is set with both methods, the .env file will take precedence.

Running the Server

Install dependencies:

npm install

Build the server:

npm run build

Run the server:

npm run start

View the server response at http://localhost:3000.

Linting

Our workflows run a linting step, but you should also run it locally while developing:

npm run lint

Contributing

Contributions are welcome! Please read our contributing guidelines.

License

This project is licensed under the terms of the Apache 2.0 license. See the LICENSE file for more information.