@nest25/banksy-sdk
v1.0.50
Published
The Banksy Payment SDK is a unified payment gateway solution designed to simplify the integration of multiple payment methods into applications. It offers developers a comprehensive set of tools and APIs for seamless payment processing while ensuring secu
Readme
BANKSY PAYMENT SDK
The Banksy Payment SDK is a unified payment gateway solution designed to simplify the integration of multiple payment methods into applications. It offers developers a comprehensive set of tools and APIs for seamless payment processing while ensuring security, compliance, and scalability.
[[TOC]]
FEATURES
- Unified Integration: Easily incorporate multiple payment methods into applications using a single set of APIs and tools.
- Multi-Payment Method Support: Accept payments through various methods including credit/debit cards, PayPal, cryptocurrencies, digital wallets, and bank transfers.
- Country-Specific Configuration: Dynamically enable/disable payment methods based on the user's country to comply with regional regulations and optimize the payment experience.
- Security and Compliance: Adheres to industry-standard encryption protocols and compliance requirements (such as PCI-DSS) to ensure secure transactions and safeguard sensitive payment data.
- Developer-Friendly: Clear documentation, code samples, and resources to streamline the integration process for developers of all skill levels.
- Customization Options: Customize the payment flow, user interface, and error handling mechanisms to meet specific application requirements.
CONFIGURATION
To use the SDK, you need:
- CLIENT_KEY
- CLIENT_SECRET
Follow these steps:
i. Go to the BANKSY-DASHBOARD portal to generate an API Key.
ii. Install the SDK in your frontend application:
npm install @nest25/banksy-sdk --saveiii. Initialize the SDK with your CLIENT_KEY:
import { Banksy } from "@nest25/banksy-sdk";
const banksy = new Banksy("YOUR_CLIENT_KEY");
export default banksy;(Note: To prevent multiple initializations, create a separate helper file.)
DATA FLOW
The SDK provides useful methods for processing payments across multiple providers.
Create Payment with KYC
- The diagram below illustrates the payment flow with KYC:
5

- The code below demonstrate the payment flow with KYC
- Select the product/service user want to purchase with proper
amount: numberandcurrency: string - Create a payment
const paymentPayload = { amount: 100, currency: 'USD', successCallback: 'https://your-success-url.com', failureCallback: 'https://your-failure-url.com', isKycOptional: false, externalClientId: 'client123', currencyType: "fiat" // or "crypto", crypto: { tokenName: "MATIC", blockchainSymbol: "MATIC" } }; const paymentData = await banksy.createPayment(payload: JsonObject<PAYLOAD>); - Will return a payment link, open it to perform the payment.
- After successful payment the successCallback will be redirected automatically with
paymentId: stringon query parameter - Same thing will happen on failure.
- After receiving the
paymentIdvalidate the statusconst paymentData = await banksy.getPayment(paymentId);
PAYLOAD
amount: numberrequired | Amount to be chargedcurrency: stringrequired | Currency in which the amount to be chargedsuccessCallback: stringrequired | On payment success portal will be redirected to this urlfailureCallback: stringrequired | On payment failure portal will be redirected to this urlexternalClientId: stringoptional | External client id, you will receive this on webhookcustomerName: stringrequired | Customer namecontext: anyoptional | Any extra context JSON data, you will receive this on webhookaddress: stringoptional | Crypto wallet addresscurrencyType: "crypto" | "fiat"either | Currency type. valid fiat or cryptoprovider: string"or | Specify payment providerisKycOptional: booleanrequired | Indicates if KYC is optional. Must be falsecrypto: { tokenName: string, blockchainSymbol: string }required
Create Payment without KYC
- The diagram below illustrates the payment flow without KYC:

- The code below demonstrate the payment flow without KYC
- Select the product/service user want to purchase with proper
amount: numberandcurrency: string - Create a payment
const paymentPayload = { amount: 100, currency: 'USD', successCallback: 'https://your-success-url.com', failureCallback: 'https://your-failure-url.com', isKycOptional: true, customerEmail: '[email protected]', // At least one of customerEmail or customerPhone must be provided // customerPhone: '1234567890', // Optional if customerEmail is provided externalClientId: 'client123', currencyType: "fiat" // or "crypto", crypto: { tokenName: "MATIC", blockchainSymbol: "MATIC" } }; const paymentData = await banksy.createPayment(payload: JsonObject<PAYLOAD>); - Will return a payment link, open it to perform the payment.
- After successful payment the successCallback will be redirected automatically with
paymentId: stringon query parameter - Same thing will happen on failure.
- After receiving the
paymentIdvalidate the statusconst paymentData = await banksy.getPayment(paymentId);
PAYLOAD
amount: numberrequired | Amount to be chargedcurrency: stringrequired | Currency in which the amount to be chargedsuccessCallback: stringrequired | On payment success portal will be redirected to this urlfailureCallback: stringrequired | On payment failure portal will be redirected to this urlexternalClientId: stringoptional | External client id, you will receive this on webhookcustomerName: stringrequired | Customer namecontext: anyoptional | Any extra context JSON data, you will receive this on webhookaddress: stringoptional | Crypto wallet addresscurrencyType: "crypto" | "fiat"either | Currency type. valid fiat or cryptoprovider: string"or | Specify payment providerisKycOptional: booleanrequired | Indicates if KYC is optional. Must be truecustomerEmail: stringoptional | Customer's email (required if isKycOptional is true).customerPhone: stringoptional | Customer's phone number (required if isKycOptional is true).crypto: { tokenName: string, blockchainSymbol: string }required
WEBHOOK
Configure your webhook urls on the Dashboard/API keys Webhooks will be triggered automatically once any transaction happens using the API key.
Webhooks will accepts only POST methods
And body will be
{
"paymentId": string,
"paymentRaw": JSON Object // payment object
}