Find out how to Settle for On-line Funds with Zoho Funds

Shubham
6 Min Read

Learn to create a easy fee web page and settle for funds in your web site utilizing Zoho Funds. Clients pays you with UPI, and Credit score Playing cards.

Zoho Payments is a brand new fee gateway that allows you to settle for funds in your web site. You possibly can go to this sample store to see the Zoho Funds widget in motion.




In contrast to Stripe or RazorPay that are extra mature fee gateways, Zoho Funds solely helps home funds in INR (₹). Within the preliminary launch, retailers can solely settle for one-time funds and clients pays you with UPI, Internet Banking, and Credit score Playing cards.

The onboarding course of is straightforward and, upon getting uploaded your KYC paperwork, your account is accepted inside few enterprise days. There’s no transaction price for UPI funds whereas bank card transactions are topic to a 2% price (excluding GST)

Find out how to Settle for Funds with Zoho Funds

On this tutorial, we’ll create a simple payment page in Google Apps Script and settle for funds on our web site utilizing Zoho Funds.


Zoho Payments - Account ID and API Key

Assuming that you’ve signed up for Zoho Funds, you may go to the dashboard to seek out your “Account ID”. Subsequent, go to Settings > Developer House to seek out your “API Key”.

Organising the Google Apps Script

Open the Google Script undertaking and make a replica in your Google Drive.


Copy Google Apps Script

Contained in the Apps Script editor, go to perform dropown and choose printZohoPaymentsRedirectUrl. Run the script and it is best to see a URL within the console window.

Go to your Zoho API Console api-console.zoho.in and add a brand new consumer. Set the Shopper Kind to Server-based Functions and paste the Redirect URL from the previuos step within the Licensed Redirect URLs discipline. Give your software a reputation like MyPaymentsApp and click on on Create. Make an observation of the Shopper ID and Shopper Secret as we’ll want them within the subsequent step.


Zoho API Console

Return to the Apps Script editor and paste the Shopper ID and Shopper Secret within the corresponding variables. Additionally, you will want to stick your Account ID and API Key within the code.

Subsequent, run the printZohoPaymentsAuthUrl perform to generate the authorization URL. Open the URL in a brand new tab, permit the app to entry your Zoho Funds information and it is best to see a hit message. We’re limiting the scope of the appliance to ZohoPay.funds.CREATE in order that our software can solely create funds however not learn or replace some other information.

As soon as the appliance is allowed, click on the Deploy button and choose New Deployment. Choose the kind as Internet app, set the Execute as to Me and Who has entry to Anybody. Click on on Deploy and you’ll get the URL of your internet funds web page. Anybody can now make a fee by visiting this URL.

The Techical Particulars

The app makes use of the OAuth2 library to deal with the authorization course of and generate the entry token for connecting to the Zoho Funds API.

const getZohoPaymentsService_ = () => {
  return OAuth2.createService(ZOHO_SERVICE_NAME)
    .setAuthorizationBaseUrl('https://accounts.zoho.in/oauth/v2/auth')
    .setTokenUrl('https://accounts.zoho.in/oauth/v2/token')
    .setClientId(ZOHO_PAYMENTS_CLIENT_ID)
    .setClientSecret(ZOHO_PAYMENTS_CLIENT_SECRET)
    .setCallbackFunction('zohoOauthCallback')
    .setPropertyStore(PropertiesService.getScriptProperties())
    .setCache(CacheService.getScriptCache())
    .setParam('response_type', 'code')
    .setScope('ZohoPay.funds.CREATE')
    .setParam('access_type', 'offline')
    .setParam('immediate', 'consent');
};

The createZohoPaymentSession perform is used to create a brand new fee session. It takes the quantity as a parameter and returns the fee session particulars that are then handed to the Zoho Funds widget on the consumer aspect.

const createZohoPaymentSession = (quantity) => {
  const service = getZohoPaymentsService_();
  const baseUrl = 'https://funds.zoho.in/api/v1';
  const apiUrl = `${baseUrl}/paymentsessions?account_id=${ZOHO_PAYMENTS_ACCOUNT_ID}`;
  const response = UrlFetchApp.fetch(apiUrl, {
    methodology: 'put up',
    payload: JSON.stringify({ quantity, forex: 'INR' }),
    headers: {
      Authorization: `Zoho-oauthtoken ${service.getAccessToken()}`,
      'Content material-Kind': 'software/json',
    },
    muteHttpExceptions: true,
  });
  const consequence = JSON.parse(response.getContentText());
  const { message, payments_session } = consequence;
  return message === 'success'
    ? {
        account_id: ZOHO_PAYMENTS_ACCOUNT_ID,
        api_key: ZOHO_ACCOUNT_API_KEY,
        merchant_name: ZOHO_MERCHANT_NAME,
        session_id: payments_session.payments_session_id,
        order_amount: payments_session.quantity,
      }
    : { error: message };
};

You’ll find the entire code on GitHub.


Zoho Payments

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *