Set up checkout refund hook 

Last updated by matthewkiata 3 years ago
 
For the one time payment, if your customer is asking for a refund. There is an easy way to do it.  
 
In today's article, we will talk about two different ways to make the refund super easy. 
 
Let’s get started 
 

Refund from panda checkout 

For every complete purchase, you will be able to see the order data in the dashboard. 
 
Image 1  
If you click the button, it will refund the purchase directly. If you set up the “Checkout refund” hook, your chatbot user should refund notification too. 
 

Set up checkout refund hook 

 
Let’s create the checkout refund hook, and then we will start setting up the custom field & add tag, and send the user to specific flow. 
 
Image 2  
 

Sample purchase data 

 
Now, before we go ahead, take a look at the sample purchase data points(from Stripe). Refund hook should have the same data points. 
 
customer_name:	matthew
customer_email:	iopoi@gmail.com
order_number:	QPOFM420
order_total:	49
success_url:	https://www.google.com
cancel_url:	https://www.pandacheckout.com
payment_gateway:	stripe
payment_gateway_id:	pi_1IeBwTK8NXoGf3baJNsVoVuu
payment_number:	SPWEAGXAXXCW23838
customer_platform:	chatrace
customer_platform_id:	3636079236501557
customer_payment_gateway:	stripe
customer_payment_gateway_id:	cus_JGjP1aeKZeFcWF
 
So you can send a refund notification using all these values from the payment gateway, you can set these values right to your chatbot user. 
 
Customer_name  is the value that the user types on the Stripe hosted checkout page.  
It should be the value of the Name on the card as screenshot below: 
 
Image 3  
 
 
 or the name you type on the billing address. 
Image 4  
 
Customer_email:  The value is the email address that the customer provided on the checkout page. 
 
 
 
Image 5  
 
Order_number:  this is the unique identifier of the purchase in panda checkout. You will use this to identify the purchase if you want to refund or cancel the purchase in our platform. 
 
Order_total:  This is the total amount that has been captured from your customer.  
 
Payment_gateway:  This will be stripe or paypal depending on which payment gateway your customer is using. 
 
Payment_gateway_id:  This is the payment intent or payment id from the payment gateway, it’s mostly for developer use, you don’t need to understand or use it. Same for the  payment_number  variable. 
 
Customer_payment_gateway_id:  This is the unique identifier of the customer in the payment platform. 
 
receipt_urls:  This is the Stripe hosted receipt url.  
 
 

Set custom field in Chatrace 

 
After you checked the payment information available for you to send to your customer, you can choose a few items you want, and then create the custom field in your chatbot platform first. I will use the Chatrace platform for example here. 
 
 

Input from Panda checkout

Custom field in Chatrace

Remarks

order_number

order_number

order_total

order_total_amount

payment_gateway

payment_gateway

customer_name

customer_name

customer_email

customer_email

 
 
Here is the list of custom field that created in Chatrace: 
Image 6  

Connect set custom field action in Panda checkout 

 
After you set up the custom field in your chatbot, now it’s time for us to set these custom fields once the purchase is complete. 
 
Make sure the custom field name is EXACTLY the same as in your chatbot. 
 
Now, let’s set all these custom fields as in the image below: 
 
Step 1: Drag all the input your want to set up from payment gateway, Drag the “ set custom field action ” from the integration 
 
 
 
Step 2: Copy the  EXACTLY the same custom field name  from your chatbot, and follow the setup process below 
 
Image 7  
 
Repeat the process if you want to set up multiple custom fields. 
 
Image 8  
 
 
 
Now, set the custom field all completed. So once the purchase is refunded in our dashboard, this “checkout refund” hook will be triggered, and all the refund inofrmation will be set up in the chatbot user who just refunded. 
 

Add Tag to the Chatbot user 

 
We can easily add the “purchased refunded” tag to the user.  
 
Obviously you can add any tag name and any number of tags you want.  
 
Now, check below steps to add a tag to the user, it’s pretty straight-forward. 
 
Image 9  
 
 
Just drag the “ Chatbot Add Tag ” action to the canvas, and then type any tags you want to add, I just suggest adding a simple tag “ Purchase refunded”. 

Send the user to flow 

 
As for the refund notification, we suggest you don’t send content to the user, because it’s possible your subscriber is out of the 24 hour window.  
 
Most chatbot platforms will block your message if the user is not interacting with your chatbot for the last 24 hour.  
 
We suggest you send the flow to the user, and add conditions to check if the user is out of the 24 hour window or not. 
 
If the user is out of the 24 hour window, you can choose to send notification through another channel. 
 
In this section, we will show you how to send the user to a refund notification flow, and using the custom field which should be set up after the refund is triggered. 
 
I have set up a simple flow as below in Chatrace.
 
 Image 10  
 
Add condition to check if the user is still within the 24 hour window. 
 
Now, Let’s  copy the Flow ID  in the Chatrace, just click that “fingerprint icon” when you hover over the messenger block:
 
Image 11  
 
 
Now, Let’s go back to Panda checkout, and drag “ Chatbot send flow” into the canvas, make sure you are adding to the correct hook.  
 
Image 12  
 
 
Now paste the flow Id you copied from Chatrace into it. Then it’s all set. 
 

Refund directly in chatbot 

 
We have offered the refund API, you can directly refund right from your chatbot. You don’t even have to login to panda checkout or Stripe/Paypal to refund the order. 
 
We only need to know the order number, and then follow the instruction below, you should be able to refund the purchase direclty. 
 
Go to our swagger to do some tests if you want. 
 
 
Image 13  
 
Please use the private API key for this refund request, not the public API key. 
 
 
Your private API key is located in the “integration” tab of your panda checkout. 
 
Image 14  
 
So let’s set up external request below: 
Image 15  
 
Use your own private API key in the header. 
 
Image 16  
 
And then use the order ID in the body & request URL, you can use the custom field in the chatbot to make the process more dynamic. 
 
That’s it. 
 

Checklist before test 

 
Up until now, we have set up the custom field, added the tag, and also set up send the chatbot user flows when the refund is processed. 
 
Those are 4 important actions you want to connect or set up in your chatbot platform. 
 
Before we do any test, here is a final check list: 
 
Connect your platform with Pandacheckout(Chatrace tutorials here , Manychat tutorials here ) 
Connect a Stripe account  with Panda checkout. 
Create flows and assign keys  of that flow to the Chatbot platform 
Created dynamic checkout links in your chatbot(Chatrace tutorials here ), make sure you include  platform, platform_customer_id, flow  in the body of the request.  
Set up Chatbot actions(set custom field, add tag, send flow, send content) in the exact flow ID when you create a dynamic checkout link. 
 
 

Last important notice 

 
Once the hook is triggered, our platform executes the action from top to bottom, and from right to left. 
 
Image 17  
 
This is important if you want to use some custom field in you flow, you need to put the “set custom field” action first at the top. 
 
And also you can add conditions in your flow to make sure those custom field are populated properly.  
 
 
 
 
 
Refreshed On: Apr 18, 2024 09:57:51 UTC+00:00