添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Description

I'm Trying to build a headless shop on vue.js. Everything is going fine so far. The only part which i can't find any documentation is how to handle redirects after 3D Secure payments.

If i'm submitting the "/actions/commerce/payments/pay" method with ajax i will get the redirect url for 3D Secure Auth back and can successfully confirm or deny the payment but im always gettting redirected to the root of my Page. Is there a way to submit the desired locations for successful and denied payments with ajax?

@mildlygeeky @jan-thoma In case this helps either of you I needed this to work as well, in my Vue app I have an API endpoint that returns my state, and in that I sent the following data:

return $this->asJson([
    // Loads of other stuff
    'checkoutRedirect' => Craft::$app->getSecurity()->hashData('/order?number={number}'),
    'checkoutCancel' => Craft::$app->getSecurity()->hashData('/checkout#pay')

Then I used that in my Vue component when posting the payment to Commerce. I had to use stripe.createPaymentMethod() first to get the payment method ID, and then send that in the commerce/payments/pay request in the paymentMethodId param, as well as gatewayId and then redirect and cancelUrl populated from my state API.

I am having the same issue as OP, but the proposed solution by @mildlygeeky does not seem to work for me. I have added the event listener:

Event::on(
  Order::class,
  Order::EVENT_BEFORE_COMPLETE_ORDER,
  function (Event $event) {
    $order = $event->sender;
    $order->cancelUrl = UrlHelper::url("/payment-complete");
    $order->returnUrl = UrlHelper::url("/payment-complete");

But once I confirm the payment in the Stripe iFrame, I still get redirect to /index.php when clicking on Return to merchant. Changing this line manually solves the problem, but obviously is not a solution.