Developer guide
VEX Pay siteAPI reference
Browse documentation

ERPNext payment app

The VEX Pay payment gateway for ERPNext v15 and v16: customers pay Payment Requests on VEX Pay’s hosted checkout and ERPNext records the Payment Entry against the invoice by itself.

What it does

Download (version 1.0.0, beta)

ERPNext v15 and v16: vexpay_erpnext-1.0.0.zip. The app is new: try it with a Test key before you take live payments. The Frappe Cloud Marketplace listing is coming soon; until then install it on a self-hosted bench (see "Install").

For companies that run ERPNext, the open-source ERP, self-hosted or on Frappe Cloud. It adds VEX Pay as a payment gateway through Frappe’s payments app, the same framework ERPNext’s other gateways use. Your customers pay invoices and sales orders on VEX Pay’s hosted checkout, and when VEX Pay reports the payment, ERPNext creates and submits the Payment Entry against the invoice or order. Nobody types the payment in by hand.

  • Works wherever ERPNext uses a payment gateway: the Payment Request (the payment link emailed with a Sales Invoice or Sales Order) and the ERPNext web shop.
  • Payment happens on VEX Pay’s hosted checkout: no card or bank data touches ERPNext.
  • USD and VES. A VES request is charged as that exact bolívar amount.
  • One VEX Pay account per company, on one site.
  • A status only moves forward: a late or repeated notification never undoes a payment or makes a second Payment Entry.
  • Refunds are recorded by hand in ERPNext (see Refunds).

For business owners: a short overview of the ERPNext integration, in Spanish, at vexpay.app/erpnext-venezuela.

Supported versions and hosting

Supported
ERPNext and Frappev15 and v16. v14 and older are not supported.
Required appsERPNext and Frappe’s payments app, on the same site.
HostingSelf-hosted bench. Frappe Cloud once the app is on its Marketplace (coming soon).
CurrenciesUSD and VES.
Not coveredERPNext POS, subscriptions, and refunds through VEX Pay.
  • VEX Pay notifies your site through a webhook, so the site needs a public HTTPS address for payments to show up within seconds. A site on localhost or a private network still works: the scheduled check records payments within about 10 minutes.
  • The web shop path depends on the payments app’s own web shop support, which has had problems on some v15 builds. Payment Requests are the supported path.
  • Frappe’s scheduler must be on for the 10-minute check (bench --site <site> enable-scheduler).

Requirements

  • A VEX Pay account. You can set everything up with a test API key right away; real payments need the account approved for live (see Going live).
  • An API key per company: Portal → Claves y webhooks (keys and webhooks). Use the Test key to try it, the Live key once approved.
  • The payment methods you want enabled on your account (Portal → Métodos y tarifas). The hosted checkout shows the methods your account can accept.
  • ERPNext v15 or v16 with the payments app, and System Manager access to the site (and to the bench, if self-hosted).

Install

Download

vexpay_erpnext-1.0.0.zip for ERPNext v15 and v16 on a self-hosted bench. Version 1.0.0, beta: try it with a Test key first.

  1. Have the payments app

    If the bench doesn’t have it: bench get-app payments, then bench --site <site> install-app payments.

  2. Get the app

    Download vexpay_erpnext-1.0.0.zip to your bench folder, unzip it (it holds one vexpay_erpnext folder), then run bench get-app ./vexpay_erpnext.

  3. Install it on the site

    bench --site <site> install-app vexpay_erpnext. It creates VEX Pay Settings and a VEX Pay Payment Gateway. If the site doesn’t have payments, the install stops and names the missing app.

  4. Restart

    On a production bench, bench restart so the workers load the app and its 10-minute check.

Configuration

Open VEX Pay Settings (search bar). Each row of the Companies table connects one ERPNext company to one VEX Pay account.

SettingWhat it does
CompanyThe ERPNext company. One row per company.
API keyThat company’s VEX Pay key (Test or Live). Stored encrypted as a Frappe password field and never written to a log. Saving checks it with VEX Pay; an invalid key is refused and nothing is saved.
EnabledUntick to stop offering VEX Pay for that company without deleting the key.
WebhookRead only. Registered once VEX Pay can notify this site; Not registered (site URL not public) on a local or private site.
VEX Pay API URL (Advanced)Leave it as https://api.vexpay.app unless VEX Pay support asks you to change it.
  1. Add your company and key

    Add a row with the company and its Test key, and save. The app checks the key and registers the webhook https://<your site>/api/method/vexpay_erpnext.api.webhook with VEX Pay (payment events only). Saving again updates the same webhook; it never makes a second one.

  2. Create a Payment Gateway Account

    In ERPNext: Payment Gateway Account → New. Payment Gateway VEX Pay, Payment Account the bank or cash account where VEX Pay payments are recorded, Currency USD or VES. Make one per company and currency.

  3. Try a test payment

    Create a Payment Request for a Sales Invoice with that gateway account, open its payment link and pay with the test checkout. The request becomes Paid and its Payment Entry appears.

  4. Switch to live

    Once your VEX Pay account is approved for live, replace the Test key with the Live key and save. The webhook is registered for the live account on that save.

Site on localhost or a private network

Saving still checks the key, but VEX Pay can’t reach the site, so no webhook is registered and the settings show a message saying so. Payments are still recorded by the check that runs every 10 minutes. When the site gets a public address, open VEX Pay Settings and save again to register the webhook.

How a payment flows

  1. Payment Request

    From a Sales Invoice or Sales Order, create a Payment Request with the VEX Pay gateway account and submit it. ERPNext emails the payment link.

  2. The customer opens the link

    The link points to your site, which creates a VEX Pay checkout for the request’s amount and currency and sends the customer to it. Opening the link again before paying shows the same checkout while it is open (60 minutes); after that a new one is made.

  3. The customer pays

    On the hosted checkout, with the methods your account accepts. Afterwards the customer comes back to a page on your site that only shows the request’s state; it never marks anything paid by itself.

  4. ERPNext records it

    VEX Pay notifies the site (signed webhook). The app completes the Payment Request, and ERPNext creates and submits the Payment Entry against the invoice or order, so its outstanding amount drops to zero.

VEX Pay reportsPayment RequestPayment Entry
Payment started (PENDING)UnchangedNone
Completed (COMPLETED)PaidCreated and submitted against the invoice or order
Completed for less than the amountStays unpaid, with a comment saying how much arrivedNone. Settle the difference with your customer
Failed while the checkout is still openUnchanged: the customer can try againNone
Checkout ended without a paymentUnchanged, with a comment; the link makes a new checkoutNone
Reversed (REVERSED)A comment asks you to record the refundThe existing entry stays; record the refund by hand

Each VEX Pay checkout is kept in a VEX Pay Payment record (read only) with its reference (erpn_…), status and checkout link. A webhook for another integration, or for a reference this site doesn’t know, is acknowledged and ignored; a webhook with a bad signature is refused. A status only moves forward: a late or repeated notification never moves anything back, and a repeated completed event never makes a second Payment Entry.

The 10-minute check

Every 10 minutes the app re-reads, from VEX Pay, each open VEX Pay payment that has been quiet for 10 minutes (up to 50 per run) and applies any change the same way a webhook would. So a payment whose webhook was lost, or a site without a public address, is still recorded.

If ERPNext refuses to record a payment (for example the Payment Account is missing), the app tries again after 5, 10, 20 minutes and so on, up to every 6 hours. After 8 failed tries it stops, writes the reason to the Error Log and adds a comment on the Payment Request so you can record it by hand.

Refunds

ERPNext’s payment gateway framework has no refund hook, so the app never refunds. To give money back:

  1. Ask for the refund in VEX Pay

    Write to VEX Pay support with the payment’s reference (erpn_…, shown on the VEX Pay Payment record).

  2. Record it in ERPNext

    Make a Credit Note (a return against the Sales Invoice) and a Payment Entry of type Pay to the customer from the same Payment Account, or follow your usual refund procedure.

When VEX Pay reports the payment as reversed, the app adds a comment on the Payment Request as a reminder; it does not change the Payment Entry.

Several companies

  • Add one row per company in VEX Pay Settings, each with its own VEX Pay key. Each company’s Payment Requests are paid into its own VEX Pay account.
  • Make a Payment Gateway Account per company and currency, with that company’s Payment Account.
  • Two companies can share one VEX Pay key; they then share one webhook.
  • References carry a short code of the site, so two ERPNext sites on one VEX Pay account never mix their payments.

Troubleshooting

ProblemWhat to do
“The VEX Pay API key for … is not valid”Copy the key again from Portal → Claves y webhooks, with no spaces. A Live key only works once the account is approved for live.
Webhook not arrivingCheck the Webhook column says Registered. If not, the site URL isn’t public: fix it and save the settings again. In the portal (Claves y webhooks → Webhooks) you can see each delivery and resend it. Meanwhile the 10-minute check records payments.
Request stuck unpaid after payingMake sure the scheduler is on (bench --site <site> enable-scheduler) and wait for the next 10-minute run. Then open the VEX Pay Payment record: “Needs review” underpaid means less arrived than requested; Failed updates and the Error Log show why ERPNext refused the Payment Entry.
“Currency … is not supported by VEX Pay”The request is not in USD or VES. Use a Payment Gateway Account in USD or VES and a request in that currency.
Install stops naming paymentsInstall Frappe’s payments app on the bench and the site first (see Install), then install vexpay_erpnext again.
“VEX Pay is not set up for …”That company has no enabled row in VEX Pay Settings.

Uninstall

  • Wait until no customer is in the middle of paying, then bench --site <site> uninstall-app vexpay_erpnext.
  • Payment Requests and Payment Entries already recorded stay as they are. The app’s own records (VEX Pay Settings and VEX Pay Payment) are removed with it.
  • Payment links of unpaid requests stop working; send those customers a new link with another gateway.
  • The webhook stays registered in VEX Pay: delete it in Portal → Claves y webhooks → Webhooks.
  • To stop offering VEX Pay without uninstalling, untick Enabled for the company instead.