Reconciling Invoices using Chargebee’s API

Modified on: Mon, 6 Jan, 2020 at 6:09 PM

Use Case

Recording payments that were received outside of Chargebee

Using a non-supported payment gateway, with Chargebee.

Automate payments collected external to Chargebee

 

Solution

 

Creating a customer for the first time.

  1. Build a form on your website to capture the information required to create the Customer & Subscription (Name, Email, Plan ID, Add-ons, Units if applicable, Start date if applicable)

  2. Call an Estimate API to get the amount that needs to be charged.

  3. Pass the subscription estimate data to Payment gateway along with customer information.

  4. Depending on how you integrate with your payment gateway,  you can receive a page to capture the customer’s payment info (PCI compliant) or you can capture the payment information on your end and pass it to the payment gateway using their API.

  5. Once a confirmation of payment, is received  you can then call the Create Subscription API to create the Subscription in Chargebee.

  6. When the subscription goes Active (depending on the start date and trial period is applicable) an invoice will be created.

  7. When an invoice is created in Payment Due State, Chargebee registers an event and a subsequent webhooks is fired.

  8. On receiving this webhook, which will have information pertaining to the Invoice, Subscription & Customer ID.

  9. This webhook will be used to trigger a collect payment action on your payment gateway.

  10. And assuming the payment went through successfully you will update Chargebee.

  11. Using the Invoice ID from associated webhooks to call the Record an invoice payment API to apply the payments to the Pending invoice, which will then be put in a Paid state.


When a subscription renews,

Steps 7 to 11 will repeat.
  1. When a renewal happens, an invoice will be created in Payment due state

  2. An event will be recorded and webhooks will be fired.

  3. This webhook will be used to trigger a collect payment action on your payment gateway.

  4. And assuming the payment went through successfully you will update Chargebee.


When a refund needs to be issued

You can also use the Payment Refunded event can be used to trigger a refund on the payment gateway you are using.


Related Events & webhooks;

invoice_generated

payment_refunded

 

Related APIs

Record an invoice payment

Create Subscription

Create subscription estimate


Please Note: The intent of this document is to provide a guideline to automate recording payments received by any means apart from the payment gateway and this natively supported in Chargebee.
Since payments are not being collected internally (Chargebee), the Auto collection function for customers will need to be OFF.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.
×