By default, Odoo supports the Stripe Payment method which is one of the widely accepted payment solutions in the USA.
How does default Odoo Stripe Integration work?
- Whenever an online transaction is processed, Stripe Payment is displayed as one of the payment methods on the checkout page on Odoo website.
- After selecting Stripe for checkout on the website, customers can enter card details in the pop-up and follow the steps.
- The payment is completed on the Odoo website itself.
- The transaction record and invoice are maintained in the Stripe merchant portal.
How does custom Odoo Stripe Integrations work?
As mentioned above, the transaction record will be maintained in the Stripe merchant portal. But for those who are managing their transactions and records in Odoo, won’t have the records in the system. They will need to check their Stripe account to refer to the invoice every time.
So, custom Odoo Integration basically helps users create Sale Order, Delivery Order, and Invoice in Odoo same as generated in their Stripe account.
- When any new Invoice is generated in the Stripe Account, the same will reflect as sale order in your Odoo system based on that stripe invoice payload.
- Before creating sale order in Odoo, the custom flow will match data received from Stripe in reference to Customers, Products, Pricelist, Taxes.
- Once the sale order is created and confirmed in Odoo, the system will generate Invoice for the transaction.
Step-by-Step Guide to Setting-up Custom Odoo Stripe Integration
Step 1: Configuration for Stripe Account
- User needs to set up the Webhook and Event in their stripe account. Learn how to create a webhook event here.
- Add the below Information to create webhook and events.
- Endpoint URL
- Description
- Select event (here you need to select invoice. Created event)
- Once you have updated the above information, you need to click on the ‘Add endpoint’ button.
- To help call the Odoo controller, your endpoint URL should look like this: http:/your_odoo_server_URL/stripe_order
- Once you have created endpoints this is how your endpoint will look like:
Step 2: Configuration for Odoo
- The Odoo Stripe Integration module needs to be installed in your Odoo server.
Understand the Odoo Stripe Integration Mechanism
When any new Invoice is created in the Stripe Account then the system will trigger the “invoice.created” event which will eventually trigger the webhook wherein we have added the Odoo controller. Hence as soon as the invoice will be created in the Stripe account, it will call the Odoo controller.
Let’s run a test event:
- For the test purpose, you can also directly call the event via the “Send test event” button.
- As soon as the Odoo controller is called, the integration module will verify the payment details before creating the Sale order from the stripe invoice payload. Here’s how the details are verified:
- User Verification:
- If ‘customer_email’ and ‘customer’ tags from stripe request match with the Odoo customer’s ‘email’ and ‘external_id’ field then use matching customer.
- If ‘customer_email’ tags from stripe request match with Odoo customer’s ‘email’ field then use matching customer.
- If ‘customer’ tags from stripe request match with Odoo customer’s ‘external_id’ field then use matching customer.
- User Verification:
Note: If the system doesn’t find any matching customer in the Odoo database based on the above conditions then a new customer will be created.
- Currency and Price list Verification:
- We are updating ‘currency’ in the Sale Order based on the currency type. If the currency tag from stripe request match with the Odoo currency records. It will update matching currency in the Odoo SO.
- We are updating ‘price list’ in Odoo SO based on the currency of price list.
- Product Verification:
- To find the correct Product we are checking tags from Stripe and match it with Product’s name in Odoo.
- Suppose if the system doesn’t find any matching products an error will be displayed in Odoo’s chatter area along with the Stripe payload script.
- Product Price, UOM, and Tax on Sale Order Line:
- To update the correct ‘Product Price’ on sale order line we are checking price tags from stripe request and update the price accordingly in Odoo’s SO.
- To update the correct ‘Product Quantity’ on sale order line we are checking qty tags from stripe request and update the quantity accordingly in Odoo’s SO.
- We are updating ‘Tax’ on the Sale order from the Product master. Whatever tax is defined on the product master will be updated on the sale order line.
Once all the conditions are fulfilled, a new sale order is created in Odoo with all the information verified from Stripe.
- As soon as the Sale Order is created, the system calculates the fiscal position.
- If the Total of the sale order does not match with the given tag from the stripe request payload, then the system will not generate an Invoice and an iHub error log is posted in the sale order chatter area like this:
- stripe_order Total does not match with Order Total for ‘so total and payload total’
- If the total matches with the stripe request payload, then the system will create a full Invoice for that sale order and also post that invoice.
To know more about Odoo Stripe Integration workflow, schedule a live demo.