Payken Integration Guide:

Code Integration Documentation:

Introduction

Welcome to Payken, where simplicity meets seamless transactions. Say goodbye to complex integrations and hello to effortless payments with our no-code integration solution. With Payken, you can easily implement link payments, allowing you to accept payments with just a simple link. Whether you’re a small business owner, freelancer, or enterprise, our platform simplifies the payment process, enabling you to focus on what you do best. Experience the convenience of frictionless transactions with Payken.

Generate Merchant Credentials

  (i) Log in to your Payken Dashboard.

  (ii) Send a “Become a Merchant” request and await approval.

  (iii) Navigate to Merchant Profile → Payken Integration .

 

Get started

To initiate a payment transaction, guide users to the following URL:

To create a payment link for simple purchase or cart purchase:

const paymentURL = 'https://test.payken.io/invoice/merchant_id={merchantId}&merchant_secret={merchantSecret}?display_name={name of purchase}&total={total}&type={type}'

Ensure to replace {merchantId}{merchantSecret}{total}{type}, and {interval} with the appropriate values.

Display purchase name (display_name)

The display_name parameter represents the name you want to display to customers related to purchase.

Total Amount (total)

The total parameter represents the total amount of the transaction.It must be greater than 0.

Type of Transaction (type)

Three options are available for the type parameter:

  • 'purchase': (for cart purchase or single item purchase) Initiates a transaction to acquire goods or services, typically involving a one-time payment.
  • 'recurring': (for subscription) Initiates an auto-billing transaction at a specified interval, allowing for periodic payments for goods or services.
  • 'invoice': (for invoice) Generates a document detailing a transaction, including items or services purchased, quantities, prices, and total cost, serving as a formal request for payment.

Example Integration

const merchant_id = 'your_generated_merchant_id';
const merchant_secret = 'your_generated_merchant_secret';
const totalAmount = 30;
const transactionType = 'purchase';
const paymentURL = 'https://test.payken.io/invoice/merchant_id=merchant_id&merchant_secret=merchant_secret?total=30&type=purchase';

To create a subscription payment link :

Type of Transaction (type=recurring)

Recurring Transaction Interval (interval)

If the user selects 'recurring' as the type, the interval parameter is required. The interval should be specified in days.

const subscriptionPaymentURL = 'https://test.payken.io/invoice/merchant_id={merchantId}&merchant_secret={merchantSecret}?total={total}&type={recurring}&interval={subscription period in days}';

Example Integration

Copy Button

const merchant_id = 'your_generated_merchant_id';
const merchant_secret = 'your_generated_merchant_secret';
const totalAmount = 30;
const transactionType = 'recurring';
const billingInterval = 7;
const paymentURL = 'https://test.payken.io/invoice/merchant_id=merchant_id&merchant_secret=merchant_secret?total=30&type=recurring&interval=7'

To create a subscription trial and generate a payment link, you have to include following permaters in subscription payment url:

  • 'trial (bool)': To Initiate a trial you have to set this perameter as true.
  • 'trial_period': This perameter indicates a trial period in days.
  • 'trial_period': This perameter indicates a trial period in days.
Copy Button

const subscriptionTrialPaymentURL = 'https://test.payken.io/invoice/merchant_id={merchantId}&merchant_secret={merchantSecret}?total={total}&type={recurring}&interval={subscription period in days}&trial=true&trial_period=7';

Expected Response in Return Url

  • Successful Payment
Copy Button

https://website-domain.com/return-url?status=true&transaction_id={transactionID}&transaction_hash={block-chain-transactionhash};

  • Failed Payment
Copy Button

https://website-domain.com/return-url?status=false&transaction_id={transactionID}&transaction_hash={block-chain-transactionhash}

Fetching Purchases Details

Authentication

Before making API requests, ensure that you have your merchant credentials (merchant ID and merchant secret) ready for authentication.

To fetch the list of purchases (includes all types of purchases) make a POST request to the following endpoint:
Copy Button

POST : https://api.payken.io/api/v1/auth/getinvoiceusersdetails

const requestBody = {
merchant_id: 'your_merchant_id',
merchant_secret: 'your_merchant_secret',
user_info : 'user email/phone',
page: 'page_number'
};

Example Code

Copy Button

const fetchData = async () => {
try {
// Define body parameters
const requestBody = {
merchant_id: 'your_merchant_id',
merchant_secret: 'your_merchant_secret',
user_info : 'user email/phone',
page: 'page_number'
}

const response = await fetch('https://api.payken.io/api/v1/aut
h/getinvoiceusersdetails ', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});

if (!response.ok) {
throw new Error('Failed to fetch data');
}

const responseData = await response.json();
console.log('Payment data:', responseData);
// Handle the payment data here
} catch (error) {
console.error('Error fetching data:', error.message);
// Handle errors here
}
};

// Call the fetchData function
fetchData();

Fetch details of purchase by transaction_id

To fetch invoice details,subscription details and purchase details by transaction_id make a POST request to the following endpoint:

Copy Button

POST : https://api.payken.io/api/v1/auth/paymentData

const requestBody = {
merchant_id: 'your_merchant_id',
merchant_secret: 'your_merchant_secret',
user_info: 'user email/phone',
id: 'transaction_id'
};

Example Usage

Copy Button

const fetchData = async () => {
try {
// Define body parameters
const requestBody = {
merchant_id: 'your_merchant_id',
merchant_secret: 'your_merchant_secret',
user_info: 'user email/phone',
id: 'transaction_id'
};

const response = await fetch('https://api.payken.io/api/v1/auth
/paymentData', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestBody)
});

if (!response.ok) {
throw new Error('Failed to fetch data');
}

const responseData = await response.json();
console.log('Payment data:', responseData);
// Handle the payment data here
} catch (error) {
console.error('Error fetching data:', error.message);
// Handle errors here
}
};

// Call the fetchData function
fetchData();



Conclusion

Congratulations! You’ve successfully integrated payment functionality into your website. Users can now navigate to the payment page with the generated URL, and transactions will be processed based on the provided details.


For further assistance or inquiries, feel free to contact our support teamhere.