我正在使用 stripe SDK 创建客户并使用 API 向客户收费,但出现错误“致命错误:未捕获(状态 400)(请求 req_ZyqUtykjUcOqrU)根据印度法规,出口交易需要客户名称和地址。更多信息请参见:https://stripe.com/docs/india-exports https://stripe.com/docs/india-exports抛出 /opt/lampp/htdocs/stripe/lib/Exception/ApiErrorException.php 第 38 行”
我的代码如下:
\Stripe\Stripe::setApiKey(STRIPE_API_KEY);
$customer = \Stripe\Customer::create(array(
'name' => 'test',
'description' => 'test description',
'email' => $email,
'source' => $token
));
$orderID = strtoupper(str_replace('.','',uniqid('', true)));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
//'source' => 'rtest',
'amount' => $itemPrice,
'currency' => $currency,
'description' => $itemName,
'metadata' => array(
'order_id' => $orderID
)
));
正如您的错误所示,您需要在 stripe customer create API 中传递地址对象,如下例所示
$customer = \Stripe\Customer::create(array(
'name' => 'test',
'description' => 'test description',
'email' => $email,
'source' => $token,
"address" => ["city" => $city, "country" => $country, "line1" => $address, "line2" => "", "postal_code" => $zipCode, "state" => $state]
));
注意:地址对象中需要 line1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)