Omnipay Stripe 额外参数 [英] Omnipay Stripe Extra Parameters
问题描述
我正在尝试将 Omnipay API 与 Stripe 结合使用,但我无法传递额外的参数,例如名称"、元数据"或邮编".
//从stripe JS 中抓取token$this->stripe_gateway = Omnipay::create('Stripe');$response = $this->stripe_gateway->purchase(['金额' =>金额,'货币' =>'美元','名称' =>$姓名,'说明' =>$product->title,'zip_address' =>$zip,'元数据' =>['名称' =>$姓名,'user_id' =>$this->session->get('id')],'令牌' =>$stripeToken,])->send();
我无法使用任何东西,这不是内置在 API 中的吗?
Omnipay 使用它自己的参数名称,而不是 Stripe 的.这是因为 Omnipay 试图抽象出各种支付网关之间的大部分差异.
目前,omnipay/stripe
包不支持发送其中一些参数(仅amount
、currency
、描述
,现在是元数据
).您可以在此处查看支持的参数:
https://github.com/omnipay/stripe/blob/master/src/Message/AuthorizeRequest.php
也就是说,您仍然可以轻松访问底层 Stripe 请求以添加您自己的自定义参数:
$request = $this->stripe_gateway->purchase(['金额' =>金额,'令牌' =>$stripeToken,'元数据' =>['foo' =>'酒吧'],]);$data = $request->getData();$data['zip_address'] = '12345';$data['another_custom_parameter'] = '哇';$response = $request->sendData($data);
注意:
$data = $request->getData();$response = $request->sendData($data);
与调用完全相同:
$response = $request->send();
或者,您可以创建拉取请求以向 Omnipay Stripe 包添加额外参数.我刚刚添加了 metadata
参数作为示例:
https://github.com/omnipay/stripe/commit/99c82dc42c7c0b9ec58d8c4fb917f3dc5d1c23e2"/p> Im trying to use the Omnipay API with Stripe, but I can't pass in extra parameters such as "Name", "Metadata", or "Zip". I cant get anything to work, is this not built into the API? Omnipay uses it's own parameter names, not Stripe's. That's because Omnipay tries to abstract most of the differences between the various payment gateways. Right now, the https://github.com/omnipay/stripe/blob/master/src/Message/AuthorizeRequest.php That said, you can still easily access the underlying Stripe request to add your own custom parameters: Note that: is exactly the same as calling: Alternatively, you could create a pull request to add extra parameters to the Omnipay Stripe package. I just added the https://github.com/omnipay/stripe/commit/99c82dc42c7c0b9ec58d8c4fb917f3dc5d1c23e2 这篇关于Omnipay Stripe 额外参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! // The token is grabbed from stripe JS
$this->stripe_gateway = Omnipay::create('Stripe');
$response = $this->stripe_gateway->purchase([
'amount' => $amount,
'currency' => 'usd',
'name' => $name,
'description' => $product->title,
'zip_address' => $zip,
'metadata' => [
'name' => $name,
'user_id' => $this->session->get('id')
],
'token' => $stripeToken,
])->send();
omnipay/stripe
package doesn't support sending some of those parameters (only amount
, currency
, description
, and now metadata
). You can see the supported parameters here:$request = $this->stripe_gateway->purchase([
'amount' => $amount,
'token' => $stripeToken,
'metadata' => ['foo' => 'bar'],
]);
$data = $request->getData();
$data['zip_address'] = '12345';
$data['another_custom_parameter'] = 'wow';
$response = $request->sendData($data);
$data = $request->getData();
$response = $request->sendData($data);
$response = $request->send();
metadata
parameter as an example of this: