我正在努力使Laravel Cashier Strip集成到3d安全卡上。我已经进行了设置,因此订阅可以正常使用,并且显示在我的条纹仪表板中,并且所有内容都显示在本地数据库中。但是,当我使用需要强身份验证的3ds卡进行测试时,它们会在我的条纹仪表板中显示为不完整状态。
我在控制台日志中看到了cashier.payment响应页面。但是收银员不应该重定向到此确认窗口吗?
我的代码如下
在我的订阅控制器中,我有
public function index() {
$data = [
'intent' => auth()->user()->createSetupIntent(),
// 'plans' => $available_plans
];
return view('artists.subscription')->with($data);
}
public function checkout(Request $request) {
$user = auth()->user();
$paymentMethod = $request->payment_method;
$planId = 'monthly_sub';
// SCA
try {
$subscription = $user->newSubscription('monthly', $planId)->create($paymentMethod);
} catch (IncompletePayment $exception) {
return redirect()->route(
'cashier.payment',
[$exception->payment->id, 'redirect' => route('front')]
);
}
// return response(['status' => 'Success']);
}
并且在我的条纹js文件中,我有这个
const stripe = Stripe('stripe_key'); // i have my test key here
const elements = stripe.elements();
const cardElement = elements.create('card',{hidePostalCode: true});
cardElement.mount('#card-element');
const cardHolderName = document.getElementById('card-holder-name');
const cardButton = document.getElementById('card-button');
const clientSecret = cardButton.dataset.secret;
cardButton.addEventListener('click', async (e) => {
const { setupIntent, error } = await stripe.confirmCardSetup(
clientSecret, {
payment_method: {
card: cardElement,
billing_details: { name: cardHolderName.value }
}
}
);
axios.post('checkout', {
payment_method: setupIntent.payment_method
}).then(response => {
console.log(response.request.responseURL)
})
.catch(error => {
console.log(error.response)
});
});
我的刀片视图是>
@extends('layouts.app') @section('head') @php // dd($intent); @endphp <script src="https://js.stripe.com/v3/"></script> <link href="{{ asset('css/stripe.css') }}" rel="stylesheet"> @endsection @section('content') <input id="card-holder-name" type="text"> <!-- Stripe Elements Placeholder --> <div id="card-element"></div> <button id="card-button" data-secret="{{ $intent->client_secret }}"> subscribe </button> @endsection @section('js') <script src="{{ asset('js/stripe.js') }}" type="text/javascript"></script> @endsection
一切似乎都正常,但是我只是在控制台中得到3ds确认页面作为响应。如何使laravel重定向并为用户打开该页面?
我正在努力使Laravel Cashier Strip集成到3d安全卡上。我已经进行了设置,因此订阅可以正常使用,并显示在我的条纹仪表板中,并且所有内容都显示在我的...
我认为问题在于事件的顺序,在将结果交还给您之后,您的代码应等待3DS被调用并完成,然后再调用您的代码。使用此调节器卡[1],您应该可以通过一些小的更改进行测试(我必须删除一些东西,但这应该作为参考):