5

I'm using Omnipay-stripe and I'm trying to Create a customer with the following code:

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

and I haven't had any luck. I checked CreateCardRequest and it says "This doesn't actually create a card, it creates a customer."

My parsed request POST body from the API is:

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

and my Response body is:

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"

Thanks.

Rob
  • 2,332
  • 7
  • 31
  • 35

1 Answers1

2

Omnipay has no support for customers. Stripe does have but that part of the Stripe-API is only used in Omnipay to more or less well provide the Omnipay token billing functionality (you can see some bugs in the tracker, for example https://github.com/thephpleague/omnipay-stripe/issues/8).

So asking about how to use omnipay-stripe for customer management sounds more like asking for trouble to me. I would suggest you use the non-Omnipay stripe API to manage your customer handling and keep Omnipay for the payment only.

hakre
  • 193,403
  • 52
  • 435
  • 836
  • Thanks for the response. I'll check that out. I also noticed https://github.com/thephpleague/omnipay-stripe/pull/13 so maybe customer support is coming? I'll probably end up using the stripe api for now though. – Rob Apr 26 '15 at 15:22
  • @Rob: Interesting PR, I wonder why this isn't yet merged. Reads like that in V3 customer management *might* be coming but I wouldn't wait for that if I were you. You have to abstract that library anyway, so worth to keep an eye so you can switch later. – hakre Apr 26 '15 at 16:31