· 9 years ago · Sep 13, 2016, 04:36 PM
1$stripe_keys = array(
2 "secret_key" => "sk_test_bwMnd0p3sdfsdfXuMv2JKQSsNRgaXf",
3 "publishable_key" => "pk_test_BHyBS8Xvmsdfsdf6SKWD7cFzVGDjlB"
4 );
5 try{
6
7 $get = \Stripe\Stripe::setApiKey($stripe_keys["secret_key"]);
8
9
10 $create_token = \Stripe\Token::create(array(
11 "card" => array(
12 "number" => "4000000000000077",
13 "exp_month" => 7,
14 "exp_year" => 2017,
15 "cvc" => "314"
16
17 )
18 ));
19 echo "<pre>";
20 //echo $create_token->card->id ;
21 $create_cust = \Stripe\Customer::create(array(
22 "description" => "Customer for test@example.com",
23 "source" => $create_token->id ,// obtained with Stripe.js
24 "plan" => "SSPRE02",
25 "email" => "rajat@test.com"// obtained with Stripe.js
26 ));
27
28 echo $create_cust;
29 echo $create_cust->subscriptions->data->id; exit; //Please help how to access the data inside there
30
31
32 }catch(\Stripe\Error\Card $e) {
33
34 $this->session->set_flashdata("errors", "Invalid Card. Please try again with another credit card");
35 }