如何在omnipay-stripe中创建客户

时间:2015-04-24 15:35:41

标签: php codeigniter stripe-payments omnipay

我正在使用Omnipay-stripe而我正在使用以下代码尝试Create a customer

        $gateway = Omnipay::create('Stripe');
    $gateway->setApiKey('sk_test_....');
    $token = $this->input->post('stripeToken'); // Code Igniter for $_POST['stripeToken']

    $customer = $gateway->createCard(array(
        "source" => $token,
        "description" => "Example Customer")
    );
    echo 'Customer: ';
    echo '<pre>';
    print_r($customer);
    echo '</pre>';

我没有运气。我检查了CreateCardRequest,它说&#34;这实际上并没有创建一张卡片,而是创建了一个客户。&#34;

我从API解析的请求POST正文是:

key: "pk_test_...."
payment_user_agent: "stripe.js/6a67cf0"
card:
number: "************4242"
cvc: "***"
exp_month: "12"
exp_year: "2017"

我的回复正文是:

id: tok_15v8exD17chNNDaoGMbDebAL
livemode: false
created: 1429889047
used: false
object: "token"
type: "card"
card:
id: card_15v8exD17chNNDao92nWH2rP
object: "card"
last4: "4242"
brand: "Visa"
funding: "credit"
exp_month: 12
exp_year: 2017
country: "US"
name: null
address_line1: null
address_line2: null
address_city: null
address_state: null
address_zip: null
address_country: null
cvc_check: "unchecked"
address_line1_check: null
address_zip_check: null
dynamic_last4: null
client_ip: "x.x.x.x"

感谢。

1 个答案:

答案 0 :(得分:2)

Omnipay不支持客户。 Stripe确实有,但Stripe-API的一部分仅在Omnipay中使用或多或少提供Omnipay token billing functionality(您可以在跟踪器中看到一些错误,例如https://github.com/thephpleague/omnipay-stripe/issues/8)。

因此,询问如何使用omnipay-stripe进行客户管理听起来更像是在向我提出麻烦。我建议您使用非Omnipay stripe API管理您的客户处理,并保留Omnipay仅用于付款。