Skip to content

Create a One-Time Charge ​

Last updated View as Markdown

Creates a single, one-time charge that requires merchant approval. Once created, redirect the merchant to the returned confirmation_url. After the merchant responds, YouCan redirects them to your return_url.

Endpoint: https://api.youcan.shop/billing/apps/charges/onetime

Method: POST

Tip

Raw amounts work without any catalog. For your standard tiers, prefer referencing a pricing plan by handle, so your listing and your charges cannot drift apart.

Parameters ​

ParameterTypeRequiredValidationDescription
namestringYesmax:255Display name shown to the merchant on the confirmation page.
return_urlstringYesurl, max:2048URL to redirect the merchant to after they approve or decline. If it has the scheme, host and port of your app URL, the merchant returns to your app inside the admin, with the signed session parameters. Otherwise the merchant is redirected to it with no parameters added.
plan_handlestringNomax:64Handle of a pricing plan. The charge is priced from the plan.
price.amountnumericYes*decimal:0,2, min:0.00, max:1000.00Charge amount in USD.
testbooleanNo-Mark as a test charge. Defaults to false. Required for non-approved apps and development stores.

* Required unless plan_handle is given.

Request ​

json
{
  "name": "Premium Features Unlock",
  "return_url": "https://myapp.com/billing/success",
  "price": {
    "amount": 29.99
  },
  "test": false
}

Response ​

json
[201]
{
  "type": "onetime",
  "id": "aoch_01234567890abcdef",
  "store_id": "...",
  "name": "Premium Features Unlock",
  "status": "pending",
  "plan_id": null,
  "price": {
    "amount": "29.99",
    "currency": "USD"
  },
  "test": false,
  "confirmation_url": "https://..."
}

Redirect the merchant to confirmation_url immediately after receiving this response.

Tip

The charge remains in pending status until the merchant approves or declines it. Verify the final status via List charges after the merchant is redirected back to your return_url.

AppOnetimeCharge object ​

FieldTypeDescription
typestringAlways "onetime" for one-time charges.
idstringUnique charge identifier, prefixed with aoch_.
store_idstringID of the store this charge belongs to.
namestringName of the charge as provided in the request.
statusstringCurrent charge status. See charge statuses.
priceobjectPrice information object.
price.amountstringCharge amount as a decimal string (e.g. "29.99").
price.currencystringCurrency code. Always "USD".
testbooleanWhether this is a test charge.
confirmation_urlstringURL for the merchant to approve or decline the charge. Only present when status is pending.