Merciglobal Cloud ERP
Payment Integration Help
payNow() — Cashfree Payment Gateway
The payNow() function is used to initiate an online payment using the Cashfree payment gateway inside Merciglobal Cloud ERP modules such as orders, subscriptions, invoices, or product purchases.
This function creates a payment order via the ERP API and opens the Cashfree checkout modal for the user to complete the transaction.
Function Definition
async function payNow(
pfolder,
orderId = '',
currency = 'INR',
amount = 0,
cust_name,
cust_email,
cust_phone,
product=''
)
Description
The function performs the following steps:
- Sends a request to the ERP backend to create a payment order.
- Receives a Cashfree payment session ID.
- Opens the Cashfree checkout modal.
- After checkout closes, the system verifies the payment status.
- If successful, the optional callback
paymentOnSuccess()is executed.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| pfolder | string | Yes | — | Payment configuration folder used by the ERP backend. |
| orderId | string | No | '' | Unique order reference ID. |
| currency | string | No | INR | Payment currency code (ISO format). |
| amount | number | Yes | 0 | Payment amount. |
| cust_name | string | Yes | — | Customer name used in the payment order. |
| cust_email | string | Yes | — | Customer email address. |
| cust_phone | string | Yes | — | Customer mobile number. |
| product | string / object | Yes | — | Product or service description. |
Example Usage
await payNow(
'docsvault',
'ORD_1025_20250301_100000',
'INR',
7080,
'Ravi Patel',
'ravi@example.com',
'9876543210',
'DocsVault SME'
);
Payment Success Callback
If payment verification is successful, the system checks whether a function called:
paymentOnSuccess()
exists in the page.
If defined, it will be executed automatically.
Example
function paymentOnSuccess(){
//Generate Invoice
//Update Subscription Plan
alert("Payment successful! Thanks for the business");
}
Payment Flow
User Clicks Pay
│
▼
payNow() Called
│
▼
Create Order API
│
▼
Cashfree Checkout Modal
│
▼
User Completes / Cancels Payment
│
▼
Verify Order API
│
├── Success → paymentOnSuccess()
│
└── Failure → showerr()
Notes
- The checkout opens in a modal window (
_modal). - The function supports dynamic order creation.
- Suitable for ERP product purchases, invoice payments, subscriptions, and service payments.
Merciglobal Cloud ERP
Developer Help Documentation