POST https://api.peanut.to/charges

Request Body Parameters

Parameter Type Description Example
pricing_type enum Options: fixed_price, no_price "fixed_price"
local_price object Price information `{
"amount": "13.37",
"currency": "USD"
}`
metadata [Optional] object Arbitrary additional data. Returned in webhook call { "item": "devcon_ticket" }
redirect_url [Optional] string URL to redirect user to after successful payment. "<https://shopify.com/success>"
cancel_url [Optional] string URL to redirect user to if they cancel the payment "<https://shopify.com/failure>"

Example Request

const res = await fetch('<https://api.peanut.to/charges>', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json",
      'api-key': "YOUR_API_KEY"
    },
    body: JSON.stringify({
      pricing_type: "fixed_price",
      local_price: {
        amount: "13.37",
        currency: "USD"
      },
      redirect_url: "<https://shopify.com/success>",
      cancel_url: "<https://shopify.com/cancel>"
    })
});
const data = await res.json();

Example Response

{
  "data": {
    "id": "4f77223g-f5be-5e6d-bcb3-443f29gf5f5g",
    "hosted_url": "<https://peanut.to/pay/4f77223g-f5be-5e6d-bcb3-443f29gf5f5g>",
    "created_at": "2024-11-28T06:45:23.034Z",
    "metadata": {
      "userId": "0x742d35"
    },
    "pricing_type": "fixed_price"
  }
}