Skip to content
OnCharge.io
View as Markdown
Developer docs

Wix (beta)

The integration is a Velo Payment Provider service plugin plus backend code you add to your site. It takes card payments through the OnCharge hosted checkout, keeps Wix orders in step with OnCharge, reports shipment tracking (OnCharge pays out once the carrier confirms delivery), refunds from the Wix dashboard, and serves the RUO compliance feed.

Requirements: a Wix premium plan that accepts payments, a connected custom domain (OnCharge accepts return URLs and webhooks only on registered domains), and Dev Mode. Wix allows this kind of plugin only on the owner's own site, not in the App Market.

How it plugs into Wix#

Wix callsWhenThe integration
connectAccount()You select Connect under Accept PaymentsChecks the API key and secret with a signed request.
createTransaction()A buyer places an orderPOST /api/v1/checkout/sessions (with the shipping address, line items and Idempotency-Key: wix-<transaction id>) and sends the buyer to the OnCharge checkout.
refundTransaction()You refund from the Orders pagePOST /api/v1/refunds.

Payment results reach Wix through an HTTP function that verifies the OnCharge webhook and updates the Wix transaction. Fulfillments are reported to POST /api/v1/shipments, with an hourly job resending numbers OnCharge could not judge yet.

Set up#

  1. Turn on Dev Mode in the Wix editor (Wix Studio has the code panel on by default).
  2. Add the payment plugin: Code sidebar → Public & Backend → Service Plugins → + → Payment, named oncharge. Replace the generated files with the integration's.
  3. Add the backend files from the integration package (http-functions.js, events.js, jobs.config and the oncharge/ folder), and install @wix/stores and @wix/essentials.
  4. Create the CMS collection OnChargeLog with admin-only permissions (fields kind and data). It holds session IDs, handled webhook IDs, compliance nonces and pending tracking numbers; no card data or secrets.
  5. Save the secrets in Developer Tools → Secrets Manager: oncharge_api_key, oncharge_api_secret, oncharge_webhook_secret and, for RUO stores, oncharge_compliance_code. They are read only in backend code.
  6. Edit backend/oncharge/config.js: your site's domain, policy page paths and reviewer settings.
  7. Publish the site. Service plugins, HTTP functions and backend events run only on the published site.
  8. In the OnCharge portal: register the site's domain under Security → Domains, and register https://<your domain>/_functions/onchargeWebhook as the store's webhook URL. Save the signing secret it shows as oncharge_webhook_secret, then publish again.
  9. Connect OnCharge in Wix: Dashboard → Settings → Accept Payments → See More Payment Options → OnCharge → Connect. OnCharge then appears at checkout as "Credit / Debit Card".

Endpoints#

Wix names an HTTP function after its exported JavaScript function, which cannot contain a hyphen, so the paths are camel case.

URLPurpose
POST https://<domain>/_functions/onchargeWebhookOnCharge webhooks
GET https://<domain>/_functions/onchargeReturnReturn URL of each checkout session (signed state; redirects to the matching Wix page)
GET https://<domain>/_functions/onchargeCompliance/proofCompliance feed: ownership proof
GET https://<domain>/_functions/onchargeCompliance/contentCompliance feed: catalogue (signed)
GET https://<domain>/_functions/onchargeCompliance/reviewer-accessCompliance feed: reviewer login status (signed)

Webhooks: payment.captured approves the Wix transaction after checking amount and currency; payment.pending, payment.refused and payment.cancelled set the matching Wix status; refund, chargeback and delivery events are logged. Refunds issued in the OnCharge portal are not mirrored into Wix.

RUO stores: compliance review#

In the OnCharge portal, add your host, choose Wix and set the feed base path to /_functions/onchargeCompliance. Save the connection code as oncharge_compliance_code, publish, then select Verify connection. For reviewer access, create a separate site member with the same access a verified buyer has, set its login email in config.js, sign in as it once to check it shows every product with its price, confirm it in config.js and publish.

Notes#

  • All OnCharge API calls run in backend code, where the secrets are available. Page code never sees them.
  • Use USPS, UPS, FedEx or DHL Express in Wix fulfillments so OnCharge can confirm delivery; other carriers are sent without a carrier name.