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

"Synchronize Order Status" - is failing for merchant codes other than the default one in multistore setup #135

Open
obsergiu opened this issue Mar 23, 2024 · 1 comment

Comments

@obsergiu
Copy link

The Order Sync process is failing for merchant codes other than the default one. Upon investigation, it has been found that the \Sapient\Worldpay\Model\Request\PaymentServiceRequest::inquiry function in the codebase does not utilize the $storeId parameter though is defined. This leads to incorrect retrieval of usernames and passwords per store scope.

[2024-03-23T07:47:41.971028+00:00] WorldPay.INFO: ########## Submitting order inquiry. OrderCode: (30000000062-17000084623) ########## [] []
[2024-03-23T07:47:41.971093+00:00] WorldPay.INFO: ## Interaction TypeECOM [] []
[2024-03-23T07:47:41.971268+00:00] WorldPay.INFO: Setting destination URL: https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp [] []
[2024-03-23T07:47:41.971322+00:00] WorldPay.INFO: Initialising request [] []
[2024-03-23T07:47:41.971413+00:00] WorldPay.INFO: Sending XML as: 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//WorldPay/DTD WorldPay PaymentService v1//EN" "http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService merchantCode="EUR" version="1.4">
    <inquiry>
        <orderInquiry orderCode="30000000062-17000084623"/>
    </inquiry>
</paymentService> [] []
[2024-03-23T07:47:42.332781+00:00] WorldPay.INFO: Request successfully sent [] []
[2024-03-23T07:47:42.332862+00:00] WorldPay.INFO: HTTP/2 200 
content-security-policy-report-only: default-src https: data: 'unsafe-eval' 'unsafe-inline'; object-src 'none'; report-uri https://secure.worldpay.com/public/CspReport
expires: Thu, 01 Jan 1970 00:00:00 GMT
pragma: No-cache
cache-control: no-store
content-length: 344
p3p: CP="NON"
content-type: text/plain
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-cnection: close
date: Sat, 23 Mar 2024 07:47:42 GMT
set-cookie: machine=0a844053;Secure;path=/
strict-transport-security: max-age=31536000 ; includeSubDomains

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN" "http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="GBP">
    <reply>
        <error code="4"><![CDATA[Security violation]]></error>
    </reply>
</paymentService>
 [] []
[2024-03-23T07:47:42.332941+00:00] WorldPay.INFO: Cookie Get: machine=0a053;Secure;path=/ [] []
[2024-03-23T07:47:42.333080+00:00] WorldPay.ERROR: An error occurred while sending the request [] []
[2024-03-23T07:47:42.333143+00:00] WorldPay.ERROR: Error (code 4): Security violation [] []
[2024-03-23T07:47:42.333264+00:00] WorldPay.ERROR: Security violation [] []
[2024-03-23T07:47:42.333321+00:00] WorldPay.ERROR: Synchronising Payment Status failed: Security violation [] []

You can potentially utilize the "Merchant Profile Override Configuration," but it's important to note that there are two issues:

  1. You can use only a single merchant code, as the payment method serves as the key and other merchant codes with the same key will overwrite the first one.
  2. The payment method designated for HPP is set to online while the currently available methods do not include "online".

Proposed Solution:

  • Update the inquiry function to properly utilize the $storeId parameter for retrieving the correct authentication credentials.
  • Update the getXmlUsername and getXmlPassword functions within \Sapient\Worldpay\Helper\Data to include the $storeId parameter. This ensures that the functions return credentials at the store scope, facilitating seamless integration with store-specific configurations.
@obsergiu
Copy link
Author

obsergiu commented Aug 19, 2024

Hi @chandan-PS, I've seen you added the changes from this PR into 2.4.7, thank you!

I just wanted to point out that in Model/Payment/Service.php:165, the line $worldPayOrder->getStoreId() needs to be replaced with $order->getStoreId() as the payment has no store_id associated.

image

The order object is already there, so it shouldn't be an issue to be used.

Or, there's another option: just fix the getStoreId() function in:
\Sapient\Worldpay\Model\Order::getStoreId:112

instead of:

$this->getOrder()->getPayment()->getStoreId(); 

you can add:

$this->getOrder()->getStoreId();

Unless I'm missing something 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant