question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invoice not created when partial payment called from shopify

See original GitHub issue

Setup

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:

  1. Go to your shopify store
  2. Checkout your cart
  3. Redeem a gift card
  4. select BTCPayserver to pay in Bitcoin
  5. 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:

  1. 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"
  1. 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

Screenshot from 2021-12-12 16-26-13

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:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Kukkscommented, Dec 15, 2021

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.

0reactions
Kukkscommented, Dec 16, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

part payment of an invoice
If you're referring to an online store order, then you can take partial payments using a third-party app - like Split - Partial...
Read more >
Accept Partial payments on Draft orders or Manual orders
Currently the workaround i found is to create the order on the Shopify POS on an ipad and record the deposit cash/card payment...
Read more >
Re: Accept Partial payments on Draft orders or Manual ...
There is not an app out there that can produce a true partial payment invoice in Shopify. It is on Shopify to create...
Read more >
Partial delivery and invoicing
We tag all orders needing an invoice when they are created using FLOW. We filter orders using this tag and payment status and...
Read more >
Re: Accept Partial payments on Draft orders or Manual ...
What can't shopify create an option for a customer to partially pay an invoice and the invoice stay open and when the remaining...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found