· 9 years ago · Sep 16, 2016, 10:50 AM
1public function trigger_stripe(){
2
3 $stripe_keys = array(
4 "secret_key" => "sk_test_bwMnd0psas3XuMv2JKQSsNRgaXf",
5 "publishable_key" => "pk_test_BHyassaasBS8Xvm6SKWD7cFzVGDjlB"
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->type);
17 if($event === customer.subscription.created){
18
19 $data = array(
20 'value' => 'hi',
21 );
22 $this->Vendordashboard->even_trigger($data);//here i am sending hi to my table at my db
23
24 }else{
25
26 // do anything
27 }
28
29
30 // Do something with $event
31
32 http_response_code(200); // PHP 5.4 or greater
33
34 }