【问题标题】:How to create a customer in omnipay-stripe如何在omnipay-stripe中创建客户
【发布时间】:2015-07-03 07:21:48
【问题描述】:

我正在使用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,上面写着“这实际上并没有创建卡片,而是创建了一个客户。”

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

谢谢。

【问题讨论】:

    标签: php codeigniter stripe-payments omnipay


    【解决方案1】:

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

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

    【讨论】:

    • 感谢您的回复。我会检查一下。我还注意到github.com/thephpleague/omnipay-stripe/pull/13 所以也许客户支持即将到来?不过,我现在可能最终会使用 stripe api。
    • @Rob:有趣的 PR,我想知道为什么它还没有合并。 V3 客户管理中的类似内容可能即将推出,但如果我是你,我不会等待。无论如何,你必须抽象出那个库,所以值得留意,以便以后切换。
    猜你喜欢
    • 2014-03-30
    • 2016-11-20
    • 2023-01-18
    • 2014-11-12
    • 2016-09-11
    • 2019-03-28
    • 2017-12-23
    • 1970-01-01
    • 2022-10-19
    相关资源
    最近更新 更多