如何在 omnipay-stripe 中创建客户

How to create a customer in omnipay-stripe

我正在使用 Omnipay-stripe and I'm trying to 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,上面写着 "This doesn't actually create a card, it creates a customer."

我从 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"

谢谢。

Omnipay 不支持客户。 Stripe 确实有,但 Stripe-API 的那部分仅在 Omnipay 中使用,或多或少地提供了 Omnipay token billing functionality (you can see some bugs in the tracker, for example https://github.com/thephpleague/omnipay-stripe/issues/8).

所以问如何使用omnipay-stripe 进行客户管理听起来更像是找麻烦。我建议您使用非 Omnipay stripe API 来管理您的客户处理并保留 Omnipay 仅用于付款。