· 9 years ago · Sep 20, 2016, 11:54 AM
1public function test(){
2
3 $stripe_keys = array(
4 "secret_key" => "asdasdasdasdasda",
5 "publishable_key" => "asdasdasd"
6 );
7
8 \Stripe\Stripe::setApiKey($stripe_keys["secret_key"]);
9
10
11 // Retrieve the request's body and parse it as JSON
12 $input = @file_get_contents("php://input"); //my website url is secondschools.com/about/trigger_stripe
13 $event_json = json_decode($input);
14
15 // Verify the event by fetching it from Stripe
16 $event = \Stripe\Event::retrieve($event_json->id);
17 if($event->type == "customer.subscription.created"){
18
19 $data = array(
20 'value' => $event_json->id,
21 );
22 $this->Vendordashboard->even_trigger($data);//here i am sending ID to my table at my db
23
24 }else{
25
26 // do anything
27 echo "nothing";
28 }
29
30
31 // Do something with $event
32
33 http_response_code(200); // PHP 5.4 or greater
34
35 }