Omnipay条纹额外参数

时间:2014-04-07 23:34:33

标签: stripe-payments omnipay

我尝试使用带有条纹的Omnipay API,但我无法传递额外的参数,例如"名称","元数据"或" Zip& #34;

   // 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();

我无法解决任何问题,这不是内置于API中吗?

1 个答案:

答案 0 :(得分:5)

Omnipay使用它自己的参数名称,而不是Stripe's。这是因为Omnipay试图提取各种支付网关之间的大部分差异。

目前,omnipay/stripe软件包并不支持发送其中一些参数(仅amountcurrencydescription,现在{{1} })。您可以在此处查看支持的参数:

https://github.com/omnipay/stripe/blob/master/src/Message/AuthorizeRequest.php

也就是说,您仍然可以轻松访问基础Stripe请求以添加您自己的自定义参数:

metadata

请注意:

$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);

或者,您可以创建拉取请求以将额外参数添加到Omnipay Stripe包中。我刚刚添加了$response = $request->send(); 参数作为示例:

https://github.com/omnipay/stripe/commit/99c82dc42c7c0b9ec58d8c4fb917f3dc5d1c23e2