💸Expected Payments

An Expected Payment belongs to a Product. On this object you set how much you want to charge, and what you want the checkout description to say.

URL Path

POST/products/:product_id/expected_payments - Create an expected payment programmatically via the Pay.so API.

Parameters

Required fields are marked in bold and with an asterisk.

Don't forget to include the headers!

  • product_id *: string The ID of the Product (pass this in as a URL parameter) .

  • description *: string The description of the charge you want the customer to see on the checkout.

  • dollar_amount *: decimal The amount in USD you want to charge the user. Pay.so will handle the conversation to crypto amounts for you. Not required and will default to null if the Product's open_amount attribute is set to true.

  • email: string The email address of the customer. This will be pre-filled at checkout and can be modified by the customer.

  • metadata: string Anything you put here will be returned - unmodified - in the webhook payload. An example use would be to set this is to { "customer_id": 123 } so you can match the payment with customers in your database. You can encrypt the metadata using a key only you know, if you want to keep this data completely private. Please note, you must ensure the metadata value is in JSON. A raw example would be "{\"customer_id\":123}".

You must nest the description and dollar_amount params under an "expected_payment" key.

Example Request

URL: "https://api.pay.so/api/v1/products/YOUR_PRODUCT_ID/expected_payments",
RequestType: "POST",
Headers:
{
    "Authorization": "Bearer YOUR_API_KEY",
    "X-ADDRESS": "YOUR_WALLET_ADDRESS",
    "Content-Type": "application/json"
},
Body: 
{
    "expected_payment": {
        "description": "Test Payment",
        "dollar_amount": 1.0
    }
}

Response

{
    "expected_payment": {
        "id": "69cf6ff1-50dc-4020-82e4-a084ad17f7a0",
        "product_id": "32dbf08d-4319-41bd-8b09-2d5e3d52be98",
        "email": null,
        "expired": false,
        "address": null,
        "dollar_amount": "1.0",
        "description": "Test Payment",
        "url": "http://app.pay.so/f80e2?id=69cf6ff1-50dc-4020-82e4-a084ad17f7a0",
        "metadata": null,
        "updated_at": "2022-04-11T13:09:32.080Z",
        "created_at": "2022-04-11T13:09:32.080Z"
    }
}

It's normal for email and address to be null at this stage. The customer will fill in this data during checkout.

URL Path

PATCH/products/:product_id/expected_payments/:expected_payment_id - Expire/re-enable an Expected Payment.

Parameters

Required fields are marked in bold and with an asterisk.

Don't forget to include the headers!

  • product_id *: string The ID of the Product (sent in URL) .

  • expected_payment_id *: string The ID of the Expected Payment (sent in URL) .

  • expired *: boolean Whether you want the charge to still be payable or not.

You must nest the expired param under an "expected_payment" key.

Example Request

URL: "https://api.pay.so/api/v1/products/YOUR_PRODUCT_ID/expected_payments/YOUR_EXPECTED_PAYMENT_ID",
RequestType: "PATCH",
Headers:
{
    "Authorization": "Bearer YOUR_API_KEY",
    "X-ADDRESS": "YOUR_WALLET_ADDRESS",
    "Content-Type": "application/json"
},
Body: 
{
    "expected_payment": {
        "expired": false
    }
}

Response

{
    "expected_payment": {
        "id": "3b8c1f53-f283-4467-bd4e-795345e98ada",
        "product_id": "32dbf08d-4319-41bd-8b09-2d5e3d52be98",
        "email": "chris@pay.so",
        "expired": false,
        "address": "0x43EF183c84079313fcE6fC65d93e569A2bd4Aafd",
        "dollar_amount": "1.0",
        "description": "Test Payment",
        "url": "http://app.pay.so/f80e2?id=3b8c1f53-f283-4467-bd4e-795345e98ada",
        "updated_at": "2022-04-08T12:44:36.818Z",
        "created_at": "2022-04-08T11:50:31.852Z"
    }
}

Last updated