Skip to main content
Payrails SDKs provide building blocks to create a checkout experience for your customers. They exist for iOS, Android, web, and React Native. Regardless of the platform, they follow the same principles. You can integrate with the SDK in three ways.
  • Drop-in: an all-in-one payment form to accept payments on your website.
  • Elements: modular payment UI components you can assemble to build a modular payment form.
  • Secure fields: secure input fields for PCI-compliant cardholder data collection.
Explanation of drop-in structure The Drop-in contains one-to-many Elements (depending on how many active payment methods you have). Some Elements dealing with cardholder data collection include Secure Fields. All three options are included in our SDK.

Get started with the SDK

Regardless of which SDK components you want, it starts with the same initialization process.
The Payrails SDK requires a secure context (HTTPS). If testing locally, ensure your development server uses HTTPS.

Include the SDK

You can install the SDK with your favorite package manager (e.g.,npm):
JavaScript
iOS
React Native

Initialize the SDK

Use the init() method to initialize a Payrails client as shown below, with configuration:
JavaScript
iOS
React Native
Your backend should call the Initialize a client SDK endpoint. You simply forward the response to SDK. Once your SDK is initialized, it can interact directly with Payrails from your client.

Example authorization flow

Here’s a simple authorization flow with the surface covered by the SDK: Dropin authorization flow diagram To ensure your frontend can communicate securely with Payrails, you must first fetch configurations from your server-side application. See the detailed endpoint reference to Initialize a client SDK.

Example for web

Learn more

After the SDK is initialized, you can leverage the SDK features to customize the user experience:
  • custom field validation and errors
  • subscribe and react to events happening inside the form
  • customize the style with JSS
  • save your tokenized card and get a payment instrument for future references

Payment amount update

Our SDK supports the possibility of updating the amount. To achieve that, 2 things have to be done:
  • Merchant backend must call the lookup action on the execution used for that payment session.
  • Merchant client has to update the SDK with the new amount. Moreover, if installments are enabled, the merchant client must also update the installment configuration along with the amount.
Example:
JavaScript
In case of a mismatch between the authorized amount, which is set on execution on the backend, and what’s set on the SDK client, requests will be rejected with 401 HTTP error.

Refresh Client Session

Our SDK allows merchants to pass the function which contains their implementation of client init as part of the onSessionExpired event. This then can be used to automatically reinitialize the client when the client session is expired instead of merchants having to do this themselves. Example:

BIN lookup

Our SDK supports using our BIN lookup service to fetch card information. This feature is not enabled by default, so please reach out to your account manager to enable. Example:
JavaScript
In case complete BIN lookup is not enabled your environment, the API returns the first 8 digits of the PAN. If the BIN Lookup is enabled then the complete API response is returned.

Example on how to allow only credit cards

Installment payments for cards in MX and BR

In certain countries or regions, it’s common for shoppers to pay for purchases in installments using credit cards. This allows them to receive their items right away while spreading the cost over multiple months. The installment payments are automatically charged to the shopper’s credit card every 30 days until the full balance is settled. Our SDK supports collecting installment plan information from the end-user and passing it through to downstream processors. Please contact us if you would like to enable this feature. Installment payments dropdown

Config options for installments dropdown


Accept Customer Address

With dropin it is possible to show address component to the end user. You can use it for collecting billing address which may be needed to tax purposes. Please contact us if you would like to enable this feature. Image of address selector dropin

Example code for billing address config

Performance optimizations

  • Preloading all card form assets before users reach the payment page is possible. This could improve the end-user experience, as secure fields will appear on the page instantly.
  • The browser will de-prioritize these assets and not slow down the page load, which will not hurt the user experience.
  • You can check how preload works on MDN

Return Info

You can pass custom return URLs to SDK configuration. This controls the redirect behavior after authorization. This is specifically useful for payment methods needing full-page redirection or 3DS processes.

Content security policy

If you have deployed a content security policy, please contact your account manager for the list of directives required by our SDKs.

Report a Vulnerability

If you discover a potential security issue in this project, please get in touch with us at security@payrails.com.
Last modified on September 30, 2026