laravel - Laravel Cashier 付款尝试失败,因为付款方式无效
问题描述
即使我在后端获得了支付方式 ID,我也获得了无效的支付网关。我正在尝试从印度进行操作,因此根据印度的规定,我必须在付款时提交地址和姓名。我猜我无法在这里整合那部分。请帮帮我,这花了我一整天的时间仍未解决。
$user = auth()->user();
$paymentMethod = $request->payment_method;
$planId = $request->plan;
$city="my city";
$country="India";
$address="user address"
$zipCode="111111";
$state="Maharashtra";
$user->createOrGetStripeCustomer([
'email' => $user->email,
'name' => 'test',
'description' => 'test description',
"address" => ["city" => $city, "country" => $country, "line1" => $address, "line2" => "", "postal_code" => $zipCode, "state" => $state]
]);
$user->newSubscription('main', $planId)->create($paymentMethod);
return response([
'success_url'=> redirect()->intended('/')->getTargetUrl(),
'message'=>'success'
]);
这是前端代码
window.addEventListener('load', function() {
const stripe = Stripe('{{env('STRIPE_KEY')}}');
const elements = stripe.elements();
const cardElement = elements.create('card');
cardElement.mount('#card-element');
const cardHolderName = document.getElementById('card-holder-name');
const cardButton = document.getElementById('card-button');
const clientSecret = cardButton.dataset.secret;
const plan = document.getElementById('subscription-plan').value;
cardButton.addEventListener('click', async (e) => {
const { setupIntent, error } = await stripe.handleCardSetup(
clientSecret, cardElement, {
payment_method_data: {
billing_details: { name: cardHolderName.value }
}
}
);
if (error) {
// Display "error.message" to the user...
} else {
// The card has been verified successfully...
console.log('handling success', setupIntent.payment_method);
axios.post('/subscribe',{
payment_method: setupIntent.payment_method,
plan : plan
}).then((data)=>{
location.replace(data.data.success_url)
});
}
});
})
我的收银台版本是 10.3
我也尝试过使用实时键。它显示相同的错误。谁能帮我?
解决方案
根据印度法规,只有注册的印度企业(即独资企业、有限责任合伙企业和公司,但不包括个人)可以接受国际支付。更多信息:https ://stripe.com/docs/india-exports
因此,该测试不适用于 4242 4242 4242 4242 卡和没有注册业务的印度条纹帐户...这件事杀死了我 3 小时..
推荐阅读
- c# - 将视图模型集合绑定到 WPF MVVM TabControl
- neo4j - 在 NEO4J 中导入 csv 时出错
- mapbox-gl-js - 在“填充”类型的 mapbox gl js 层中:我们可以控制笔画粗细吗?
- java - Eclipse 对可访问代码给出死代码警告
- python - 将多个 csv 文件读入 Pandas 数据框
- python - 从 mongo db 游标的嵌套数据中构建 pandas 数据框
- javascript - Webpack - worker importScripts 的单独捆绑包
- java - 如何使用java程序执行oraenv脚本?
- azure - 流分析 - 将传入的 JSON 转换为 PowerBI 流数据集
- google-chrome - Chrome DevTools 控制台中的 Service Worker(不可见)错误