Closed staskus closed 1 day ago
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
App Name | WooCommerce iOS | |
Build Number | pr14475-914f8db | |
Version | 21.1 | |
Bundle ID | com.automattic.alpha.woocommerce | |
Commit | 914f8dbe122ef8ed8382244db99780af7bdca462 | |
App Center Build | WooCommerce - Prototype Builds #11690 |
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.
1 Warning | |
---|---|
:warning: | This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews. |
Generated by :no_entry_sign: Danger
Failed Card Reader Payment: Create an order, attach a customer with an email, set a failure amount, and pay with a card reader. Confirm 'Email sent' message is shown and the email is received.
✅ "A receipt has been sent to xxxx" shows ✅ Email "your order was unsuccesful" received (bit of email title congratulating) ✅ After retrying once, I cannot retry again, a dismiss button appears
Failed TTP payment: Create an order, attach a customer with an email, set a failure amount, and pay with TTP. Confirm 'Email sent' message is shown and the email is received.
✅ "A receipt has been sent to xxxx" shows ✅ Email "your order was unsuccesful" received (bit of email title congratulating)
Try Collecting Again: After payment failure, try collecting again, Confirm the 'Email sent' message is shown.
✅ "A receipt has been sent to xxxx" shows ✅ Email "your order was unsuccesful" received (bit of email title congratulating)
Payment-unrelated failure: Create an order, attach a customer with an email, trigger a card payment, instead of tapping a card, disable Bluetooth on the phone. Confirm no 'Email sent' message is displayed and email is not received.
✅ No "A receipt has been sent" message appears ✅ No email is received
Try Collecting Later: Make 'Failed Card Reader Payment', come back to the order screen, tap 'Collect Payment' again, try to make a card reader. Confirm 'Email sent' message is shown and the email is received.
✅ "A receipt has been sent to xxxx" shows ✅ Email "your order was unsuccesful" received (bit of email title congratulating) ✅ After retrying once, I cannot retry again, a dismiss button appears
Unrelated to the app, but from the web and email delivery: Is a bit odd the email that we receive "congrats on the purchase" when we have an unsuccessful purchase 😅
Good catch. I'll bring this up.
We improved some of the failure receipt text just yesterday https://github.com/woocommerce/woocommerce/pull/52977, shouldn;t be a problem.
Follow up on "Congrats on the purchase!" @iamgabrielma
For some reason it's set as "From" field on Jurassic Ninja site (WooCommerce -> Settings -> Emails):
It appears as site name on a Pressable site:
Show "A receipt has been sent to {email}" message after a failed payment when the order has a customer email set.
Partially addresses #14163, I'll address failed payments sent via the API in the next task.
Description
I planned to implement the whole remaining failure receipt functionality within a single PR but it already grew more complex than I anticipated.
In this PR I address the functionality of sending receipts after failed payment to attached customer and displaying "Email sent" message. Equivalent of https://github.com/woocommerce/woocommerce-ios/pull/14390 but to failed payments.
Solution
Reminder of backend changes:
I had to make more changes than anticipated before development:
CardPresentModalErrorEmailSent
CardPresentModalNonRetryableErrorEmailSent
CardReaderServiceError.paymentCapture(.paymentDeclinedByPaymentProcessorAPI)
errors. Other types of errors related to order preparation, card readers, and network issues don't produce failed order status. I haven't found any other way to determine whether the order turned into a failed state. Retrieving an order and checking status after payment failure is unreliable since webhook usually doesn't manage to update the order status before we make a call. I will use the same logic to display a button to send failure receipts as well.failed
status and is retried and fails again, the new receipt doesn't get sent. To avoid this, I set the order status back topending
when the order payment is collected again.Steps to reproduce
Before testing:
sendReceiptAfterPayment
inDefaultFeatureFlagService
Test cases:
Testing information
The feature is still behind the feature flag. Added new unit tests.
Screenshots
RELEASE-NOTES.txt
if necessary.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: