Get started
Quickstart
Create a sandbox payment, pay it with a test card, and verify the result from your server.
Before you start
- Ask Wegopay to activate your account. Then create a sandbox key in Dashboard → API Keys.
- Optionally, add a sandbox webhook endpoint in Dashboard → Settings → Webhook. Store its signing secret on your server. See webhooks.
export WEGOPAY_API_BASE_URL="https://api.wegopay.tech"
# Load the sandbox key from your secret manager; never commit it.
export WEGOPAY_API_KEY="wgp_test_…"1. Create a payment
Call POST /v1/payments from your server. Generate an Idempotency-Key for the order and store it before sending, so a retry after a timeout cannot create a second payment.
/v1/paymentsHeaders
Idempotency-Key*requiredstring16–255 chars16 to 255 visible ASCII characters. Scope is authenticated merchant plus operation. Records are retained for twenty-four hours.
Request body application/json
amountCents*requiredinteger500–100000000currency*requiredstringAlways
USDreference*requiredstring1–255 charssuccessUrl*requiredstring <uri>1–2048 charsAbsolute URL parsed by a standards-compliant URL parser. Production permits HTTPS only. HTTP is accepted only when the hostname is exactly localhost, 127.0.0.1, or ::1 in development. Credentials and fragments are forbidden; hostnames are canonicalized before validation.
cancelUrl*requiredstring <uri>1–2048 charsAbsolute URL parsed by a standards-compliant URL parser. Production permits HTTPS only. HTTP is accepted only when the hostname is exactly localhost, 127.0.0.1, or ::1 in development. Credentials and fragments are forbidden; hostnames are canonicalized before validation.
paymentMethodstringOptional checkout restriction. Opens only this method and prevents switching. Must be enabled by the effective API-key and merchant settings, otherwise creation returns 422 validation_failed for paymentMethod. Omit to offer all configured methods. Custom card capture supports card only.
One of
cardwalletcheckoutModestringDefaults to hosted. Custom requires an enabled merchant capture integration. Prepare scoped access with POST capture, submit a token and captureReference, and open actionUrl in the customer browser when required.
One of
hostedcustomembeddingOriginstring1–255 charsExact approved website to embed this checkout. Required for embedding when the effective allowlist exceeds 20 sites. Omission preserves legacy embedding for lists up to 20 and otherwise permits hosted checkout only.
localestringWegopay checkout language. Omission on creation selects English. Provider-hosted content is controlled separately.
One of
enesptenvironmentstringImmutable provider account selection derived from the API key. Omit environment on creation or provide the same environment as the key; a mismatch is rejected. Test keys can only access sandbox payments and live keys can only access live payments.
One of
sandboxlivedisplayCurrencyobjectOptional price shown to the customer in another currency. The payment is still charged, refunded and settled in USD; checkout always states the USD charge. Wegopay computes the displayed amount once at creation, rounding half up to the currency's minor unit, and returns it with the number of decimals used; it never changes. Provider-hosted wallet pages may show their own conversion.
currency*requiredstringActive ISO 4217 code other than USD. Unknown codes return 422 validation_failed for displayCurrency.currency.
rate*requiredstringUnits of the display currency per 1 USD, as a decimal string, for example "5.42" to show USD 100.00 as BRL 542.00. Must be from 0.000001 to 1000000 and give a displayed amount of at least one minor unit.
customerobjectidstring1–191 charsYour stable identifier for this customer. Send the same value on every payment of the same customer. Payments are grouped into one customer profile by this ID, or by email when it is omitted, for the Customers page and customer block lists.
emailstring <email>≤ 320 charsnamestring1–255 charsdocumentNumberstringPayer document number for server-side wallet initiation.
phonestringPayer phone number for server-side wallet initiation.
metadataobject (free-form)≤ 100 keysMerchant-defined JSON object. The server measures canonical UTF-8 JSON, including keys and structural bytes, and rejects values over 16384 bytes. The limit is applied before persistence and is part of idempotency hashing.
Responses
Payment and checkout session created, or exact idempotent replay.
dataobjectidstring <uuid>statusstringAlways
pendingcheckoutUrlstring <uri>1–2048 charsAbsolute URL parsed by a standards-compliant URL parser. Production permits HTTPS only. HTTP is accepted only when the hostname is exactly localhost, 127.0.0.1, or ::1 in development. Credentials and fragments are forbidden; hostnames are canonicalized before validation.
expiresAtstring <date-time>environmentstringoptionalImmutable provider account selection derived from the API key. Omit environment on creation or provide the same environment as the key; a mismatch is rejected. Test keys can only access sandbox payments and live keys can only access live payments.
One of
sandboxlive
Malformed path, header, or strict JSON request.
Error codesinvalid_request
errorobjectcodestringAlways
invalid_requestmessagestring
Missing, malformed, unknown, revoked, or disabled-merchant API key.
Error codesunauthorized
HeadersWWW-Authenticate
errorobjectcodestringAlways
unauthorizedmessagestring
Idempotency key conflict or matching request still fenced.
Error codesidempotency_key_reusedidempotency_in_progress
errorobjectcodestringOne of
idempotency_key_reusedidempotency_in_progressmessagestring
Semantically invalid payment creation field, named in `field` with the broken rule in `message`. Without `field`, the merchant account cannot create this payment yet.
Error codesvalidation_failedvalidation_failed
errorobjectcodestringAlways
validation_failedmessagestringfieldstringoptional
Rate limit exceeded without starting payment work.
Error codesrate_limited
HeadersRetry-After
errorobjectcodestringAlways
rate_limitedmessagestring
Required persistence, encryption, hosted-fields, or payment processing dependency unavailable.
Error codesservice_unavailable
errorobjectcodestringAlways
service_unavailablemessagestring
curl -X POST "https://api.wegopay.tech/v1/payments" \
-H "Authorization: Bearer $WEGOPAY_API_KEY" \
-H "Idempotency-Key: order-1042-create" \
-H "Content-Type: application/json" \
-d '{
"amountCents": 1500,
"currency": "USD",
"reference": "order-1042",
"successUrl": "https://shop.example.com/orders/1042",
"cancelUrl": "https://shop.example.com/cart",
"customer": {
"email": "jane@example.com",
"name": "Jane Doe"
},
"metadata": {
"orderId": "order-1042"
}
}'{
"data": {
"environment": "sandbox",
"id": "7d5c2f1e-4b8a-4c3e-9f21-6a0b8e4d1c55",
"status": "pending",
"checkoutUrl": "https://wegopay.tech/c/wgp_chk_example",
"expiresAt": "2026-10-11T12:30:00Z"
}
}Save data.id against your order. The amount must be at least 500 cents ($5.00).
2. Send the customer to checkout
Redirect the customer’s browser to data.checkoutUrl exactly as returned. Treat it like a secret: it opens this payment. The session lasts about 30 minutes; the exact deadline is expiresAt.
3. Pay with a test card
On the sandbox checkout, choose Pay by card and enter 4242 4242 4242 4242. Use expiry 12/2030, CVV 123 and card holder TEST TEST. More cards are listed under sandbox testing.
4. Verify the payment
When the customer returns to your successUrl, or a webhook arrives, read the payment from your server:
/v1/payments/{id}Path parameters
id*requiredstring <uuid>
Responses
Merchant-scoped payment.
dataobjectidstring <uuid>referencestringstatusstringOne of
pendingrequiresActionpaidfailedrefundedpartiallyRefundeddisputeddisputeWondisputeLostmethodstringcan be nullOne of
cardwalletpixamountCentsinteger500–100000000refundedCentsinteger0–100000000netCentsinteger0–100000000currencystringAlways
USDcustomerobjectemailstring <email>can be null≤ 320 charsnamestringcan be null≤ 255 chars
metadataobject (free-form)≤ 100 keysMerchant-defined JSON object. The server measures canonical UTF-8 JSON, including keys and structural bytes, and rejects values over 16384 bytes. The limit is applied before persistence and is part of idempotency hashing.
checkoutUrlstring <uri>can be null1–2048 charsAbsolute URL parsed by a standards-compliant URL parser. Production permits HTTPS only. HTTP is accepted only when the hostname is exactly localhost, 127.0.0.1, or ::1 in development. Credentials and fragments are forbidden; hostnames are canonicalized before validation.
expiresAtstring <date-time>cardBinstringcan be nullIssuer prefix from authenticated PCI Vault capture matched to the verified attempt. Null when unavailable.
cardIssuerobjectcan be nullbankstringcan be null≤ 128 charscountryCodestringcan be nullcountryNamestringcan be null≤ 128 charstypestringcan be null≤ 128 charslevelstringcan be null≤ 128 charscategorystringcan be null≤ 128 charsregulatedstringcan be null≤ 128 chars
cardBrandstringcan be nullCard brand from verified provider status; also included in signed payment webhook data. Null when unavailable.
cardLast4stringcan be nullLast four card digits from verified provider status as a string preserving leading zeros; also included in signed payment webhook data. Null when unavailable. This is not a BIN/IIN; BIN/issuer metadata is separately available in cardBin and cardIssuer when PCI Vault capture metadata is configured.
failureCodestringcan be nullfailureMessagestringcan be nullcreatedAtstring <date-time>paidAtstring <date-time>can be nullrefundedAtstring <date-time>can be nullenvironmentstringoptionalImmutable provider account selection derived from the API key. Omit environment on creation or provide the same environment as the key; a mismatch is rejected. Test keys can only access sandbox payments and live keys can only access live payments.
One of
sandboxlivedisplayCurrencyobjectoptionalPresent only when the payment was created with a display currency.
currencystringratestringUnits of the display currency per 1 USD, exactly as supplied.
amountMinorinteger≥ 1Displayed amount in minor units; divide by 10^minorUnits for the major-unit value.
minorUnitsinteger0–4Decimal places Wegopay used for this currency, fixed at creation (for example 2 for BRL, 0 for CLP). Format the amount with exactly this many decimals.
Malformed path, header, or strict JSON request.
Error codesinvalid_request
errorobjectcodestringAlways
invalid_requestmessagestring
Missing, malformed, unknown, revoked, or disabled-merchant API key.
Error codesunauthorized
HeadersWWW-Authenticate
errorobjectcodestringAlways
unauthorizedmessagestring
Unknown or unauthorized resource/token, without existence disclosure.
Error codesnot_found
errorobjectcodestringAlways
not_foundmessagestring
Rate limit exceeded without starting payment work.
Error codesrate_limited
HeadersRetry-After
errorobjectcodestringAlways
rate_limitedmessagestring
Required persistence, encryption, hosted-fields, or payment processing dependency unavailable.
Error codesservice_unavailable
errorobjectcodestringAlways
service_unavailablemessagestring
curl "https://api.wegopay.tech/v1/payments/7d5c2f1e-4b8a-4c3e-9f21-6a0b8e4d1c55" \
-H "Authorization: Bearer $WEGOPAY_API_KEY"{
"data": {
"environment": "sandbox",
"id": "7d5c2f1e-4b8a-4c3e-9f21-6a0b8e4d1c55",
"reference": "order-1042",
"status": "paid",
"method": "card",
"amountCents": 1500,
"refundedCents": 0,
"netCents": 1500,
"currency": "USD",
"customer": {
"email": "jane@example.com",
"name": "Jane Doe"
},
"metadata": {
"orderId": "order-1042"
},
"checkoutUrl": "https://wegopay.tech/c/wgp_chk_example",
"expiresAt": "2026-10-11T12:30:00Z",
"cardBrand": "visa",
"cardBin": "424242",
"cardIssuer": null,
"cardLast4": "4242",
"failureCode": null,
"failureMessage": null,
"createdAt": "2026-10-11T12:00:00Z",
"paidAt": "2026-10-11T12:01:12Z",
"refundedAt": null
}
}Fulfill only on a verified match
status is paid and that the ID, reference, amountCents, currency and environment match your order. Then mark the order fulfilled, once.Next
- Receive signed webhooks so you hear about results without polling.
- Handle every payment status, including pending and failed.
- Retry safely with idempotency keys.