2015-04-24 63 views
4

客户我使用Omnipay-stripe,我试图用Create a customer下面的代码:如何创建omnipay条纹

 $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" 

感谢。

回答

2

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

因此,询问如何使用omnipay-stripe进行客户管理听起来更像是向我求助麻烦。我建议你使用非Omnipay stripe API来管理你的客户处理,并保持Omnipay只支付。

+0

感谢您的回复。我会检查一下。我也注意到https://github.com/thephpleague/omnipay-stripe/pull/13所以也许客户支持即将到来?尽管现在我可能最终会使用stripe api。 – Rob

+0

@Rob:有趣的公关,我想知道为什么这还没有合并。在V3客户管理中可能会这样读,但如果我是你,我不会等待。无论如何,您必须抽象该库,所以值得留意,以便稍后切换。 – hakre