Webhook Event Object

Example Checkout Session Complete Event Object

Events notify you of noteworthy activity in your account. When an event occurs, we generate an Event object and send it to your registered webhook endpoint via a POST request.

Why use webhooks

Assuming you've set up webhook event notifications, when a customer clicks the "Pay" button on your app or website, a webhook connection between Copperx and your app informs your app of the payment's status. Specifically, when your webhook endpoint receives the checkout_session.completed event, your webhook function can trigger backend actions, such as activating the premium plan for that particular user. Using an API for this process is similar to repeatedly calling the API every millisecond to ask if the payment was successful. Webhook Event Statuses

  • checkout_session.completed: Indicates that the user has successfully completed the checkout and payment has been processed.

  • checkout_session.expired: Occurs when the user fails to complete the payment within the allowed session time.

  • checkout_session.canceled : Triggered when the user cancels the checkout process, typically by clicking the back button or returning to the merchant's site.

Example

Here's an example of a data when Checkout Session is completed. This is one of the most useful webhook event that shows that the transaction is complete and you can activate plan for your user.

{
  "id": "518fa184-194b-40f3-9ce8-33fe668305a7",
  "apiVersion": "2023-01-11",
  "created": 1677070414201,
  "object": "checkoutSession",
  "type": "checkout_session.completed",
  "data": {
    "object": {
      "id": "6bce7b07-825f-454e-bea8-3a2bb04a570b",
      "createdAt": "2023-02-22T12:46:11.453Z",
      "updatedAt": "2023-02-22T12:53:34.189Z",
      "mode": "payment",
      "paymentMethodTypes": [
        "wallet"
      ],
      "paymentSetting": {
        "allowedChains": [
          {
            "chainId": 80001
          }
        ],
        "paymentMethodTypes": null,
        "preferredChainId": 80001
      },
      "expiresAt": "2023-02-22T13:46:11.441Z",
      "customerCreation": "if_required",
      "customerUpdate": null,
      "submitType": "pay",
      "afterCompletion": null,
      "organizationId": "ea2f521c-0f27-48bf-91f7-87dd8de98034",
      "amountTotal": "100000000",
      "currency": "usdc",
      "paymentLinkId": null,
      "subscriptionId": null,
      "customerId": null,
      "clientReferenceId": null,
      "successUrl": "https://copperx.io/success?cid=6bce7b07-825f-454e-bea8-3a2bb04a570b",
      "cancelUrl": null,
      "status": "complete",
      "paymentStatus": "unpaid",
      "metadata": null,
      "emailCollection": false,
      "phoneNumberCollection": false,
      "shippingAddressCollection": false,
      "billingAddressCollection": false,
      "afterCompletionConfirmMsg": null,
      "shippingDetails": {},
      "billingDetails": {},
      "url": "https://buy.copperx.dev/payment/checkout-session/6bce7b07-825f-454e-bea8-3a2bb04a570b"
    }
  }
}

Last updated