sergej
sergej

Reputation: 371

Shopware 6 PayPal Invoice Purchase does not include order_transaction custom_fields swag_paypal_pui_payment_instruction on some orders

We sporadically observe missing data in PayPal purchase on invoice purchase orders. We have a middleware that listen to "state_enter.order_transaction.state.paid" webhook and then forwards the order to an ERP system.

Until now we have received all necessary data in the order_transaction => custom_fields. For invoice purchase the swag_paypal_pui_payment_instruction data are important for us.

{
"swag_paypal_order_id": "....", 
"swag_paypal_partner_attribution_id": "shopwareAG_Cart_Shopware6_PPCP", 
"swag_paypal_pui_payment_instruction": {
    "name": {... }, 
    "email": "...", 
    "birth_date": "...", 
    "phone": {...}, 
    "billing_address": {...}, 
    "payment_reference": "...", 
    "deposit_bank_details": {...}, 
    "experience_context": {....}, 
    "swag_paypal_resource_id": "..."
}

However, for some orders we do not receive any data in the field: swag_paypal_pui_payment_instruction.

{
    "swag_paypal_order_id": "....", 
    "swag_paypal_partner_attribution_id": "shopwareAG_Cart_Shopware6_PPCP"
}

But it is not a problem with the webhook or the request, because the data is already not available in the database for this orders.

I find the following error messages in the logs at this date, but for a different transaction, which then has the necessary data at the end. But I cannot find any log entries for the transaction that has no data.

[2022-11-27T20:30:10.896943+00:00] request.ERROR: Uncaught PHP Exception Swag\PayPal\Checkout\PUI\Exception\PaymentInstructionsNotReadyException: "Payment instructions for transaction "b87…….b0c1" not yet available" at /var/www/clients/client1/web3/web/prod/custom/plugins/SwagPayPal/src/Checkout/PUI/SalesChannel/PUIPaymentInstructionsRoute.php line 129 {"exception":"[object] (Swag\\PayPal\\Checkout\\PUI\\Exception\\PaymentInstructionsNotReadyException(code: 0): Payment instructions for transaction \" b87…….b0c1\" not yet available at /var/www/clients/client1/web3/web/prod/custom/plugins/SwagPayPal/src/Checkout/PUI/SalesChannel/PUIPaymentInstructionsRoute.php:129)"} []

Has anyone observed anything similar?

Shopware Version: 6.4.14.0

Paypal Plugin: 5.4.1

Upvotes: 0

Views: 367

Answers (2)

sergej
sergej

Reputation: 371

Here is shopwares support answer, it may help someone.

„The behaviour occurs when the customer does not wait for the confirmation from PayPal after the redirection from PayPal back to the shop.“

Ich hab den Sachverhalt nochmal genau geprüft und nach Rücksprache mit der Entwicklung identifizieren können, dass das Verhalten auftritt, wenn der Kunde nach der Umleitung von PayPal zum Shop zurück die Bestätigung von PayPal nicht abwartet. Dieses Verhalten ist entsprechend nicht direkt auf Shopware-Seite beeinflussbar. Die Kunden erhalten von RatePay / PayPal eine E-Mail mit der Zahlungsaufforderung. In solchen Fällen schreibt Shopware ein entsprechenden Hinweis auf die Rechnung anstelle der Kontodetails.

Unfortunately, the reference mentioned does not exist. The last statement is that Shopware will look into it.

ich habe mich noch mal Rücksprache mit der Entwicklung gehalten. Die Meldung auf der Rechnung erscheint nur, wenn der Zahlvorgang auch funktioniert hat. Wir schauen uns für zukünftige Updates an, ob sich das noch anders lösen lässt. In jedem Fall, also egal ob der Kunde die Bestätigung von PayPal abwartet oder nicht abwartet wird eine Mail von Ratepay mit den Zahlungsinformationen versendet.

I hope that it will be possible to solve this better in the future so that the necessary data can be transferred cleanly to other systems.

Upvotes: 1

dneustadt
dneustadt

Reputation: 13161

I'm not super familiar with the PayPal plugin but just from looking at the code I found two instances where the custom field is written.

PlusPuiHandler, PayPalPuiPaymentHandler

In both cases the custom field is explicitly not written if the instruction type is not invoice or if the payment instructions are null. Since you mentioned this specifically regards invoice payments, there's only one place I could find where instructions are set.

PUIPaymentInstructionDataService

There's potentially a PaymentInstructionsNotReadyException being thrown here. So it looks like you were on the right track. The exception is also deliberately being caught with the intention of "polling it later", even though I'm not quite sure what that means. Maybe you could try and repeat the call used for the argument of setPaymentInstructions and get the instructions at a later point?

Upvotes: 0

Related Questions