The Billing Engine is a customization requested by Zachys Wine and Liquor.
The Goal
The purpose of the Billing Engine was to integrate Netsuite and Stripe together so that customers with wine in storage can be invoiced and charged automatically.
The Highlights
The basis of the project needed to come from automation and the best way to do that with Netsuite is a Map/Reduce script. I created a Map/Reduce script that looked for all customers in which were supposed to be billed on the day it runs. When it finds the customers that have wine in storage, it performs the calculations, and creates an Invoice as a result.
There is another script created, a User Event deployed on the Invoice. This user event, upon creation of the Invoice, checks certain requirements of the Invoice to see if it is a Storage invoice and if the user is suppose to be charged automatically. If this checks out, we utilize a custom module I’ve built to communicate with Stripe’s API to charge the customer if they meet the following criteria:
- The customer has a user account in the subsidiary Stripe account for the company.
- The customer has a valid credit card attached to their Stripe account
- The customer’s ‘auto charge’ value on their Netsuite customer account is set to be auto charged.
If the customer does not meet the criteria, an email is sent to the customer with a link to make the payment themselves on Stripe.