Invoice not created when partial payment called from shopify
See original GitHub issueSetup
We are running a selfhosted BTCPayserver with both Bitcoin and Lightning (c-lightning). The connection with shopify was setup following this guide: https://docs.btcpayserver.org/Shopify/
In Shopify we have several payment methods including Paypal, Stripe and BTCPayserver. The user can choose between the 3. If he choose bitcoin, a bitcoin invoice from BTCPayserver is presented. The user can choose Bitcoin or Lightning (default). The user can pay, the payment is detected and the status paid
sent to Shopify.
In Shopify, Gift Cards are generated and provided to some users, with some amounts in it. The user can redeem a Gift card in the checkout process, to reduce the price to pay. (Eg. if it has an cart worth 75 euros, using a voucher of 25 euros, the remaining price would be 50 euros.) This is working with Paypal and Stripe.
bug
After redeeming a Gift card, when trying to pay the remaining amount of an shopify order using bitcoin, the Shopify screen immediately show “success” page with no option to pay. In the backend of BTCPayserver, there is no invoice for any amount.
To Reproduce the bug Steps to reproduce the reported bug:
- Go to your shopify store
- Checkout your cart
- Redeem a gift card
- select BTCPayserver to pay in Bitcoin
- click on continue.
Expected behavior
The invoice is created on BTCPayserver for the remaining amount, and the invoice is shown within the Shopify payment process.
Your BTCPay Environment:
- BTCPay Server Version: v1.3.6.0
- Deployment Method: Docker
Logs
The output of docker logs --tail 100 nginx
shows:
- for a failed order (after using a gift card):
[10/Dec/2021:21:31:22 +0000] "GET /stores/6C1GYKBbEyFHnegieXwK5L26pBjY1kawo78ZvHbuw1RY/integrations/shopify/shopify.js HTTP/2.0" 200 2484 "https://nym.shop/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
- for a successful order (normal pattern):
[10/Dec/2021:16:11:59 +0000] "GET /stores/6C1GYKBbEyFHnegieXwK5L26pBjY1kawo78ZvHbuw1RY/integrations/shopify/shopify.js HTTP/2.0" 200 2484 "https://nym.shop/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:11:59 +0000] "OPTIONS /stores/6C1GYKBbEyFHnegieXwK5L26pBjY1kawo78ZvHbuw1RY/integrations/shopify/3908574969996?amount=48.20&checkonly=true HTTP/2.0" 204 0 "https://nym.shop/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:00 +0000] "GET /stores/6C1GYKBbEyFHnegieXwK5L26pBjY1kawo78ZvHbuw1RY/integrations/shopify/3908574969996?amount=48.20&checkonly=true HTTP/2.0" 200 0 "https://nym.shop/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:00 +0000] "GET /img/paybutton/pay.svg HTTP/2.0" 200 2618 "https://nym.shop/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:01 +0000] "OPTIONS /stores/6C1GYKBbEyFHnegieXwK5L26pBjY1kawo78ZvHbuw1RY/integrations/shopify/3908574969996?amount=48.20 HTTP/2.0" 204 0 "https://nym.shop/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:02 +0000] "GET /stores/6C1GYKBbEyFHnegieXwK5L26pBjY1kawo78ZvHbuw1RY/integrations/shopify/3908574969996?amount=48.20 HTTP/2.0" 200 53 "https://nym.shop/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /invoice?id=7bFohGJy1LABHvwYNU8Y3a&view=modal HTTP/2.0" 200 13547 "https://nym.shop/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /imlegacy/bitcoin-lightning.svg?v=mELGqPJIS0p2XOnkUkv3o7Jrc_tOdPuaPqXOKMXNAk0 HTTP/2.0" 200 889 "https://btcpay.nymte.ch/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /imlegacy/bitcoin.svg?v=mELGqPJIS0p2XOnkUkv3o7Jrc_tOdPuaPqXOKMXNAk0 HTTP/2.0" 200 889 "https://btcpay.nymte.ch/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /bundles/bootstrap-bundle.min.js?v=OYOQ4I7-grW_3pDlVCmi9W5SU5Pqx_IuTZaDYehKBbY HTTP/2.0" 200 63307 "https://btcpay.nymte.ch/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /bundles/checkout-bundle.min.css?v=sIBnepPnCOvSeEm-HJbCRpAM5X6dB3ryipFugVjGXkQ HTTP/2.0" 200 47778 "https://btcpay.nymte.ch/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /bundles/checkout-bundle.min.js?v=R3Sg1-YxQHLpO5vhzVm1Xs8WS-viSeJPuc8aHymSAB0 HTTP/2.0" 200 88427 "https://btcpay.nymte.ch/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /imlegacy/checkmark.svg?v=I5LHco7Ztucf7E1JiNtVbcBCdVLxVspjoi717TjT4j4 HTTP/2.0" 200 560 "https://btcpay.nymte.ch/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /imlegacy/bitcoin-lightning.svg HTTP/2.0" 200 889 "https://btcpay.nymte.ch/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /checkout/css/default-logo.svg HTTP/2.0" 200 2331 "https://btcpay.nymte.ch/bundles/checkout-bundle.min.css?v=sIBnepPnCOvSeEm-HJbCRpAM5X6dB3ryipFugVjGXkQ" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /vendor/font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0 HTTP/2.0" 200 77160 "https://btcpay.nymte.ch/bundles/checkout-bundle.min.css?v=sIBnepPnCOvSeEm-HJbCRpAM5X6dB3ryipFugVjGXkQ" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
[10/Dec/2021:16:12:03 +0000] "GET /locales/en.json HTTP/2.0" 200 1419 "https://btcpay.nymte.ch/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
I did not observe any other relevant logs
Shopify order
As shown in the screenshot (read from bottom to top) of the Shopify backend, even-though the payment is still pending, the order confirmation is sent to the client, that now is told, the order is complete. Luckily in the Shopify backend, the order is kept on the status partially paid
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thank you for such a detailed report! I’ve done some necessary changes as you outlined so that the API would generate an invoice based on outstanding amount instead of total. However I couldnt find a way to make the checkout flow to not skip the step where we would load our BTCPay specific JS. I’ll dig a bit deeper and see if there is any solution.
So it seems the blocker here is that if a payment of any kind is detected, the order status page is skipped and the user is taken directly to the Thank you page. This means that the btcpay integration js script is never loaded and the user is never given a chance to create the invoice.
The solution to this would be to create a post purchase extension BUT this requires a centralized entity to publish and any store would need to grant it access. 😦
I’m afraid I can’t progress further on this to make it smoother when a gift card is used. I will submit my small fixes to allow calling the btcpay integration api so that it would egenrate the invoice and detect payments, but you would need to send a URL to the customer to proceed with payment.