Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelling Worldpay payment returns error message #232

Merged
merged 5 commits into from
Aug 6, 2018

Conversation

irisfaraway
Copy link
Member

https://eaflood.atlassian.net/browse/WC-394

Rather than showing a more informative message when cancelling a Worldpay payment, we get an 'Invalid response' error. This is caused because we are unable to build a valid MAC for a cancelled order if the user chooses to cancel their payment. In that case, the parameters we get back do not include the paymentAmount, the paymentCurrency or the paymentStatus. Instead we have orderAmount and orderCurrency.

We need to modify the params we receive for a cancelled payment so we can properly validate them, including the MAC.

https://eaflood.atlassian.net/browse/WC-394

Rather than showing a more informative message when cancelling a Worldpay payment, we get an 'Invalid response' error. This is caused because we are unable to build a valid MAC for a cancelled order if the user chooses to cancel their payment. In that case, the parameters we get back do not include the paymentAmount, the paymentCurrency or the paymentStatus. Instead we have orderAmount and orderCurrency.

We need to modify the params we receive for a cancelled payment so we can properly validate them, including the MAC.
- If paymentCurrency is blank, replace with orderCurrency
- If paymentAmount is blank, replace with orderAmount
- If paymentStatus is blank, replace with 'CANCELLED'
- Leave 'CANCELLED' status out of the MAC when generating it

Plus tests to cover all this.
@irisfaraway irisfaraway self-assigned this Aug 3, 2018
@@ -4,8 +4,9 @@ en:
failure:
invalid_response: "Invalid WorldPay failure response"
message:
REFUSED: "Your payment has been refused. Please try again or select a different payment method."
CANCELLED: "Your payment has been cancelled. Please try again or select a different payment method."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a content bod, but should this read more along the lines

Your attempt to pay was cancelled.

To my ears it currently sounds like payment was completed, and then subsequently cancelled. What do you 🤔 💭 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will change it now!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cruikshanks Aaaand updated.

@irisfaraway
Copy link
Member Author

Build is failing because VCR cassettes are out of date. Fixing now: #235

@irisfaraway irisfaraway merged commit bd736a4 into master Aug 6, 2018
@irisfaraway irisfaraway deleted the fix/cancelled-worldpay-payment branch August 6, 2018 08:56
@irisfaraway irisfaraway added the bug Something isn't working label Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants