Hi all,
I am developing a custom app with erpnext through frappe_docker.
On clicking Help>About it shows that i am on
ERPNext: v14.x.x-develop () (develop)
Payments: v0.0.1 (version-14)
I have first configured stripe in the settings (using stripe testing keys).
And after creating a sales invoice, i click on
-
Create>Payment Request and copy the sample message below the message block to get the payment url.
-
Go to Communications doctype and search for the email being sent out. (Did this since i have not configured mailpit yet).
-
Click on the payment url embedded in the message and pay using 4242 4242 4242 4242 (stripe allows this example to go through for testing)
-
Success message shown and redirect as per configured in stripe settings.
-
Stripe website dashboard transaction shows that payment went through.
-
Issue is this part. Sales Invoice still shows status is unpaid.
Tried to check if theres any update done but unsure where to find although by looking into mariadb, theres a table called tabIntegration Request and it shows that the status is “Completed” for the payment request.
Can anyone help me try this out and see if it’s only me?
Or perhaps throw some ideas around for a workaround.
Thanks!
@Heyheyhey Did you figure it out?, do we need to use stripe webhook and handle the response in erpnext?
Hi @mohmed_fasil , yes you’re right!
If I remembered correctly, what I did back then was to use a stripe webhook and handle the response in erpnext.
Before going through the steps, I think i installed the payments app that includes the stripe settings. I don’t exactly remember if that secures the authorization for stripe.
So it goes something like:
-
In dev environment, there’s a bench command to use --site
or something like that. What you can search for is setting a default localhost url so instead of accessing through e.g. development.localhost:8000, you can access your site through localhost:8000.
-
The previous step is only so that you can use ngrok’s free url forwarding to https since if I’m not wrong it only allows localhost instead of other urls for the free plan. So after configuring ngrok, in your terminal or cmd, it goes something like ngrok http http://localhost:8000
. They will give you a random url so that your dev url can be accessed through https.
-
Now, Step 2 was so that you can use stripe webhooks since they need a accessible url for them to send the webhook back. So when configuring the stripe webhook, you can point it to a exposed server script function that has the decorator @frappe.whitelist(allow_guest=True)
or you can explore further on how to secure this endpoint.
-
Remember to point to the correct url path, which is the url that directly calls your function.
Also, just for you to test out since my memory can be quite bad, try creating a Payment Entry manually and see if your Sales Invoice gets updated automatically. If it does, then your function that you wrote should handle creating a Payment Entry + any additional validations that you need.
Cheers!
Ok, Thanks…
i more thing…,
After processing a payment in Stripe:
- The Stripe transaction details do not include the ERPNext Payment Request ID (e.g.,
PR-0001
). also The webhook payload from Stripe also lacks this Payment Request ID.
How can ERPNext identify which Payment Request to update when receiving a Stripe webhook, given there’s no direct reference to the Payment Request ID in the transaction data?
Ahh, i can’t exactly remember, and apologies as I am unsure on the right way to do this.
I’m trying to check the files, but maybe you can do a debug/console.log/print on these files
Payment page that customers will see
frappe-bench/apps/payments/payments/templates/pages/stripe_checkout.html
Seems like the submit button is calling this file
frappe-bench/apps/payments/payments/templates/includes/stripe_checkout.js
Which in turn calls make_payment()
function
frappe-bench/apps/payments/payments/tempaltes/pages/stripe_checkout.py
and create_request()
function is found in
frappe-bench/apps/payments/payments/payment_gateways/doctype/stripe_settings/stripe_settings.py
Looks like in the same file the create_charge_on_stripe() has charge.Charge.create()
function and I can see that description
is being passed in through self.data.description
.
Maybe there’s something you can inject into description from any of the previous files mentioned (unless there’s a configuration for this somewhere like Web Form Doctype
or something)
Or can you double check if under transactions/payments made tab in Stripe has no description being passed in?
Oh one other thing, do check if the manual creation of Payment Entry on an invoice automatically updates the Payment Request doc.
The Stripe integration doesn’t perform a two way communication. The main benefit is to generate a payment link for payment via credit card. Additional customization is needed to get communication back from Stripe.
We are working on an enhancement to the Payments app/Stripe Integration. It should be ready for testing in a week or so. It will have the ability to automate payment entry and creation of Sales Invoice (when payment request is set from Sales Order). It’s part of a larger app, but we will make a branch specific to the Stripe Plus module.