Skip to main content

Payment With KYC

Overview

This section outlines the process of handling payments that require KYC (Know Your Customer) verification. This flow is typically used for higher-risk transactions, large amounts, or when regulatory compliance requires identity verification.

Payload Parameters

ParameterTypeRequiredDescription
amountnumberYesAmount to be charged
currencystringYesCurrency in which the amount to be charged
currencyType"crypto" | "fiat"YesCurrency type. Valid values are "fiat" or "crypto"
providerstringNoSpecify payment provider
customerNamestringNoCustomer name
successCallbackstringYesOn payment success portal will be redirected to this url
failureCallbackstringYesOn payment failure portal will be redirected to this url
externalClientIdstringNoExternal client id, you will receive this on webhook
isKycOptionalbooleanYesIndicates if KYC is optional. Must be false
contextanyNoAny extra context JSON data, you will receive this on webhook

Steps to Implement Payment With KYC

Payment Process Example

1. Initialize the Banksy SDK

Set up the SDK with your API key and specify the environment (production or sandbox).

2. Perform KYC Verification

Implement the KYC process, verifying the user’s identity before proceeding with the payment.

3. Create a Payment

After successful KYC verification, prepare the payment payload and create the payment.

4. Redirect to Payment Provider

The SDK will generate a payment link upon creating the payment. Redirect the user to this link to complete the payment.

5. Handle Payment Success/Failure

Use the callback URLs to manage the outcome of the payment. Handle both success and failure cases.

Code Example

import { Banksy } from "banksy-sdk";

// Step 1: Initialize the Banksy SDK
const apiKey = "your-client-key";
const banksy = new Banksy(apiKey);

// Step 2: Implement KYC Verification (Pseudo-code for KYC step)
// This part depends on the specifics of your KYC process
async function verifyKYC(customerData) {
try {
const kycVerified = await someKYCService.verify(customerData);
return kycVerified;
} catch (error) {
console.error("KYC verification failed: ", error.message);
throw error;
}
}

// Step 3: Create a payment after KYC
async function initiatePaymentWithKYC(customerData) {
try {
const kycVerified = await verifyKYC(customerData);
if (kycVerified) {
const paymentPayload = {
amount: 1000,
currency: "USD",
successCallback: "https://yourdomain.com/success",
failureCallback: "https://yourdomain.com/failure",
currencyType: "fiat"
isKycOptional: false
};

const payment = await banksy.createPayment(paymentPayload);
console.log("Payment Created: ", payment);
// Step 4: Redirect to the payment provider's gateway
window.location.href = payment.paymentLink;
}
} catch (error) {
console.error("Payment failed: ", error.message);
}
}

// Example usage with customer data for KYC
const customerData = { /* Customer details for KYC */ };
initiatePaymentWithKYC(customerData);

Best Practices

  • Ensure KYC Compliance: Use a reliable KYC service to verify user identities and comply with regulatory requirements.
  • Secure Data Handling: Ensure that customer data used for KYC is securely transmitted and stored to protect sensitive information.
  • Error Handling: Implement error handling for both the KYC process and the payment creation to manage any issues that arise.