If you are using ByBits' Stripe payments integration every now and then a payment will fail. This could be for many reasons such as a customer having insufficient funds or that their card has expired.

Below, a request has been made to the POST/statements endpoint in order to generate a statement. The statement has been generated despite the failed payment. In the response following the request there will be an error message in the payment block:

{
    "current": false,
    "policy_reference": "polaris-volume-transit",
    "policy_version_reference": "6e4003b6-9eeb-4a35-a431-d2ea70e1649d",
    "distance_in_metres": 0,
    "duration_in_mins": 0,
    "total_miles": 0,
    "total_kms": 0,
    "subscription_premium": 20,
    "usage_premium": 0,
    "total_premium": 20,
    "billed_premium": 20,
    "statement_start_date": "2021-10-26T11:22:14.000Z",
    "statement_end_date": "2021-10-27T10:53:16.000Z",
    "journey_count": 0,
    "journeys": [],
    "payment": {
        "payment_amount": null,
        "error_message": "BadRequestError: Charge is declined with an expired_card code."
    }
}

In this example the payment was declined by Stripe because of an expired card.

When a failed payment has occurred, you can attempt to make the transaction again by using the ByBits dashboard. Under the Reports tab you can click on  the Unpaid Versions item. This lists policy versions across all policies which are missing a payment. Simply click on the retry button and the payment will be attempted again.

You can also view failed payments by policy. Go to the policy view and click on the Policy Payments tab. You can attempt the payment again in the same way by clicking the retry button:

You can also make retries programmatically by using the POST /payments endpoint. In your request body you can use the RETRY_PAYMENT type like so:

{
    "type": "RETRY_PAYMENT",
    "product_reference": "by_bits_usage",
    "policy_reference": "latin-shadow-karma",
    "policy_version_reference": "06b956a9-0000-41a1-a736-b647af013124"
}