Closed (fixed)
Project:
Commerce Payment: Paytrail
Version:
3.0.0-alpha3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Apr 2022 at 05:28 UTC
Updated:
4 Nov 2022 at 06:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
iamfredrik commentedSome additional info. The payments have been registered as paid in Paytrail's control panel despite the error. However, the orders have not been registered as completed in the Drupal Commerce shop.
Comment #3
tuutti commentedDo you have any idea what is giving that 403 error? The error message looks like something whatPaytrail::onNotify()would return.Nevermind, I didn't see your previous comment. It's definitely the Paytrail::onNotify() or Paytrail::onReturn() that fails then.
Comment #4
tuutti commentedCan you check if the failed orders have
commerce_paytrail_stampin order'sdatafield, like:Comment #5
iamfredrik commentedIt returns this:
{s:21:"paid_event_dispatched";b:0;s:20:"terms_and_conditions";i:1;s:32:"commerce_paytrail_transaction_id";s:36:"974adf96-b5db-11ec-8f0f-03abd6bbce33";s:23:"commerce_paytrail_stamp";s:36:"d27563f8-29e4-4afd-8488-4d86c1e289c3";}
Comment #6
iamfredrik commentedMore info from Paytrail support:
This does not explain why the payment has gone through. Why is the payment registered if stamp validation fails?
Comment #7
tuutti commentedThe stamp is generated and saved to commerce order when the payment form is rendered and is then validated when user returns from the payment gateway (
Paytrail::onReturn()) or when Paytrail calls the notification callback (Paytrail::onNotify()).I'm not sure why stamp wouldn't match tho. Can you ask/check if the
checkout-stampquery parameter matches with the stamp saved in commerce order?This is where it's validated: https://git.drupalcode.org/project/commerce_paytrail/-/blob/3.x/src/Plug...
Comment #8
iamfredrik commentedOkay, so it seems the shop returns the stamp validation error after Paytrail has returned that the payment is approved.
Will see if I can find the query parameter.
Comment #9
iamfredrik commentedThere are two queries for the same order and none of the checkout-stamps matches the one I posted in comment #5 for the same order.
/checkout/373/payment/return?checkout-account=977532&checkout-algorithm=sha512&checkout-amount=335&checkout-provider=mobilepay&checkout-reference=373&checkout-stamp=e8f96f74-6344-4e1c-97a1-2508bf49f0e3&checkout-status=ok&checkout-transaction-id=964bc006-b5db-11ec-8f0e-0b9ffd411762&signature=7d7cb9f2c4b33cd05bef956c05a5a9e82d5495b3a520a8aa4d1b55c5223441ee53f29a37750149de72bad7bb6b41c37d97abf438f86e1c9f46890860241c5d2a
/checkout/373/payment/return?checkout-account=977532&checkout-algorithm=sha512&checkout-amount=335&checkout-provider=mobilepay&checkout-reference=373&checkout-stamp=6e591138-3f8a-4710-b308-a45238a02ec5&checkout-status=ok&checkout-transaction-id=6f70550a-b5db-11ec-bfa2-3f4d9fc7f2cc&signature=427a575574db2338702b545cd310fb98195da495269f0d15d1cf17d967c80bfd31e0024d07e156d3bbc23a7fca283c9eb83b94e819512edc603221866481d8ee
Comment #10
simohell commentedNote: Similar issue with MobilePay+Paytrail has persisted for years already on Commerce 1.x and other old Paytrail payment modules and E1 (https://www.drupal.org/project/commerce_suomenverkkomaksut) as well as recently increased number of issues with Commerce 2.x and commerce_paytrail 2.x. The consistent factor seems to be combination of MobilePay+Paytrail+any version of Drupal Commerce.
This may be specific to MobilePay who is know for issues including double charging client purchases (national level news in 2021 https://www.iltalehti.fi/kotimaa/a/fd3087c2-2cf7-482a-bc67-45652eddc715). It is not impossible that MobilePay's fix for preventing double charges is somewhat incompatible with the other APIs. The fact that we seem to be getting doulbe responses indicates in this direction.
MobilePay is a popular payment method so it might make sense for to accommodate this by additional checks on wether a payment was already accepted. This is "wrong" as it should be fixed where the issue starts but fixing it in any possible way would benefit Durpal Commerce shop owners.
Comment #11
simohell commented#10 would apply to a case where the feedback
refers to case that some MobilePay payments are successful, if all fail then it's something different...
I'll start testing this with live credentials.
Comment #12
simohell commentedAfter live testing on an early stage development site (Ubuntu + Lando + Drupal 9 + Commerce 2 + Commerce Paytrail 3.0-alpha3 ) I cannot reproduce the error. The payment is recorded in Paytrail merchant's panel as to be expected and Commerce updates the order from Draft status to Completed status.
The issue might be related to payment method provider, some server side stuff, caching or some other site components or conditions but live payment by MobilePay using commerce_paytrail 3.0-alpha3 is tested working in the above setup.
Comment #13
iamfredrik commentedWe're still having problems with Mobile Pay payments. The orders do not register as completed, but remain as draft although the payment is shown as completed. What could be the reason why only Mobile Pay payments have this problem?
Comment #15
tuutti commentedCan you test if 3.0.0-alpha4 release fixes this? I've completely refactored how the return/notify callback validation works: https://git.drupalcode.org/project/commerce_paytrail/-/commit/5e892e3327...
I think this had something to do with PaytrailOffsiteForm being refreshed/re-rendered after user was redirected to Paytrail / MobilePay app, which caused transaction ID and stamp key to be regenerated.
Comment #16
iamfredrik commentedWith our limited testing, MobilePay seems to work, but we now have an other problem. When selecting shipping methods that changes the order total, we get the following error:
Paytrail\Payment\ApiException: [400] Client error: `POST https://services.paytrail.com/payments` resulted in a `400 Bad Request` response: {"status":"error","message":"Sum of purchase item amounts does not match total amount."} in Paytrail\Payment\Api\PaymentsApi->createPaymentWithHttpInfo() (line 580 of /backend/vendor/tuutti/php-paytrail-payment-api/src/Api/PaymentsApi.php).
Comment #17
tuutti commentedDid that happen with previous version?
Comment #18
iamfredrik commentedHmmm, I'm not sure. No one has reported the error. I just discovered it myself when testing the new version. I tried downgrading to the previous version, but the error still occurs.
Comment #19
iamfredrik commentedAdditionally, the following error occurs upon clicking a bank payment button after updating Commece from 2.30.0 => 2.32.0. This error applies to both current and previous version of Commerce Paytrail.
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getState() on null in Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowBase->getStepId() (line 211 of modules/contrib/commerce/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php).
Comment #20
tuutti commentedLooks like I forgot to add shipping support. Here's a separate issues for it: #3316739: Support commerce shipping
I wasn't able to reproduce this, does this only happen with Paytrail?
Comment #21
tuutti commentedI'll close this for now. Please open a new issue if that 2.32 commerce issue persists.
Comment #22
iamfredrik commentedI will have to conduct some more testing on the Commerce 2.32 issue.