How to Redirect from PaymentService file to My Controller in shopware6

Hello Charles,

the payment process in Shopware 6 is explained here: https://docs.shopware.com/en/shopware-platform-dev-en/internals/core/checkout-process/payment

As you can read here Shopware 6: Payment plugin in the code example, the AsynchronousPaymentHandlerInterface gets an AsyncPaymentTransactionStruct in the pay method. This object contains the return URL. So no need to generate it on your own. 

Now you should do your request to the payment provider API to give it all the information about the payment. You can find an example in our PayPal plugin: https://github.com/shopwareLabs/SwagPayPal/blob/master/src/Payment/PayPalPaymentHandler.php#L111
Normally you will get back a redirect URL from your payment provider, so you just need to return a RedirectResponse with the given redirect URL.

If the customer now accepts the payment, you will automatically will be redirected to the shop, and the finalize method is called. Now you can do stuff to finish your payment. 

Best regards from Schöppingen

cool Michael Telgmann

1 „Gefällt mir“