Payken Integration Guide:

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) Click on Side bar/ Navbar → Manage secrets .

Get started

To initiate a payment transaction, direct users to this dynamic 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}&user_id={email address}&total={total}&type={type}&order_id={order id}'

Ensure to replace {merchantId}, {merchantSecret},{display_name},{user_id}, {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.

User Id (user_id)

The user_id parameter is required to be the email address associated with the user's account

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 orderId = 123; const userId = user@example.com; const paymentURL = 'https://test.payken.io/invoice/merchant_id=merchant_id&merchant_secret=merchant_secret?display_name={name of purchase}&user_id={user@example.com}&total=30&type=purchase&order_id=123'

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}?display_name={name of subscription}&user_id={email address}&total={total}&type={recurring}&interval={subscription period in days}&order_id={order id}';

Example Integration

const merchant_id = 'your_generated_merchant_id'; const merchant_secret = 'your_generated_merchant_secret'; const totalAmount = 30; const transactionType = 'recurring'; const billingInterval = 7; const orderId = 123; const userId = user@example.com const paymentURL = 'https://test.payken.io/invoice/merchant_id=merchant_id&merchant_secret=merchant_secret?display_name={name of subscription}&user_id={user@example.com}&total=30&type=recurring&interval=7&order_id=123'
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_amount': This peramter indicates a amount of trial you want to charge from customers . If you want to set a free trial, you don't have to include this in query parms.
const subscriptionTrialPaymentURL = 'https://test.payken.io/invoice/merchant_id={merchantId}&merchant_secret={merchantSecret}?display_name={name of subscription}&user_id={email address}&total={total}&type={recurring}&interval={subscription period in days}&trial=true&trial_period=7&order_id={order id}';

Expected Response in Return Url

  • Successful Payment
https://website-domain.com/return-url?status=true&transaction_id={transactionID}&transaction_hash={block-chain-transactionhash}
  • Failed Payment
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:
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

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/auth/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(); // 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:
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

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(); // Handle the payment data here } catch (error) { console.error('Error fetching data:', error.message); // Handle errors here } }; // Call the fetchData function fetchData();

Supported Languages

Applying Any Language on the Checkout Page
  • 'lang': Include a "lang" parameter in the query to apply a specific language to the checkout page. Ensure that you send the ISO 639 language code in the "lang" parameter. For a list of supported languages, refer to this page.
paymentURL = 'https://test.payken.io/invoice/merchant_id={merchantId}&merchant_secret={merchantSecret}?display_name={name of purchase}&user_id={email address}&total={total}&type={type}&order_id={order id}&lang={ISO 639 language code }'

Supported Currencies

See what currencies you can use for making charges and for paying out to your bank account.

You can charge customers in native currencies . Businesses that have a global presence find this helpful because charging in a customer’s native currency can increase sales.

  • 'currency_code': Include a "currency_code" parameter in the query to apply a specific currency to the checkout page. Ensure that you send the currency code in the "currency_code" parameter. For a list of supported currencies, refer to this page.
paymentURL = 'https://test.payken.io/invoice/merchant_id={merchantId}&merchant_secret={merchantSecret}?display_name={name of purchase}&user_id={email address}&total={total}&type={type}&order_id={order id}&currency_code={currency code }'

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.