nimasdj
November 23, 2015, 10:36am
1
I am a bit confused how to charge with Stripe, if I understood correctly, if customer is new first I should provide a CC form to send his CC info to Stripe as mentioned here: https://stripe.com/docs/api/php#create_card_token
then with that returned token I may either directly charge the card as mentioned here https://stripe.com/docs/api/php#create_charge
or use that token to create a customer https://stripe.com/docs/api/php#create_customer first then charge the card as mentioned here https://stripe.com/docs/api/php#create_charge
Next time I can retrieve customer https://stripe.com/docs/api/php#retrieve_customer now how can I charge an existing customer? In response of retrieving a customer what should I fetch to pass to charge his card again?
Or creating customer is for reference purpose only and everytime I should provide CC form to charge his card via Stripe and cannot charge his card by retrieving a customer?
I think after create a card token https://stripe.com/docs/api/php#create_card_token and create a customer https://stripe.com/docs/api/php#create_customer I have to Create Card https://stripe.com/docs/api/php#create_card to attach the card to the customer?
Then I can Retrieve the card https://stripe.com/docs/api/php#retrieve_card and now to charge it with https://stripe.com/docs/api/php#create_charge as there is no tok_* in the response of retrieve card?
nimasdj
November 23, 2015, 12:11pm
2
Well, I created this code:
\Stripe\Stripe::setApiKey("sk_test_blah");
$t = \Stripe\Token::create(array( "card" => array(
"number" => "4242424242424242",
"exp_month" => 11,
"exp_year" => 2016,
"cvc" => "314" )));
$c = \Stripe\Customer::create(array(
"description" => "Customer for test@example.com",
"source" => $t->id));
With this I could create a CC token and assign it to customer to create a customer too.
Now I can retrieve the customer by:
\Stripe\Customer::retrieve(“cus_*****”);
But for next time how can I create a charge https://stripe.com/docs/api/php#create_charge just by retreiving existing customer without asking him to enter his CC on form again?
another question is that how can I use at the same time do Charge::create and Customer::create for the same card as token is one-time use only?
felgall
November 23, 2015, 5:50pm
3
yes - you can create a charge either on a card or on a customer
nimasdj
November 24, 2015, 11:46am
4
After submitting my Stripe.js-powered form, it seems $_POST[‘stripeToken’] has a value but when I call immediately:
\Stripe\Stripe::setApiKey("sk_test_*****");
$customer = \Stripe\Customer::create(array(
"source" => $_POST['stripeToken'],
"description" => "blah"
));
I get no such token error, but if I create token by Card like https://stripe.com/docs/api/php#create_card_token , it works fine. What is the problem?
felgall
November 24, 2015, 5:42pm
5
You don’t need the form to process payments for a customer - you just need the customer token that was returned when you set up the customer.
system
Closed
February 24, 2016, 12:48am
6
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.