Stripe downgrade-upgrade plan using API in PHP
In this post we will show you Stripe downgrade-upgrade plan, hear for Stripe downgrade-upgrade plan we will give you demo and example for implement.
Syntex for Stripe downgrade-upgrade plan
this is Syntex for Stripe downgrade-upgrade plan, you need to change subscription id and STRIPE_API_KEY and plan hear.
// curl for Stripe downgrade-upgrade plan curl https://api.stripe.com/v1/subscriptions/sub_49ty47958G5z6a \ -u sk_test_a12RX8g5E58fT659vg4Gd1fp: \ -d plan=pro-monthly
Stripe Upgrading-Downgrading Plans
class Stripe { public $headers; // set url public $url = 'https://api.stripe.com/v1/'; //all fields array public $fields = array(); function __construct () { $this->headers = array('Authorization: Bearer sk_test_STRIPE_API_KEY'); // ADD HERE STRIPE_API_KEY = your application stripe api key } // PHP functions to curl call function call () { $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->fields)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $output = curl_exec($ch); curl_close($ch); return json_decode($output, true); // return here php array with stripe api response } } $subscription = new Stripe(); // add your subscription id hear $subscription->url .= 'subscriptions/sub_B6N1qfu8XnGEZp'; // sub_B6N1qfu8XnGEZp is example $subscription->fields['plan'] = 'your-new-plan'; // add your plan $subscription_add = $subscription->call(); echo "<pre>"; print_r($subscription_add); echo "</pre>";
Hope this code and post will helped you for implement Stripe downgrade-upgrade using API in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org
Change default configuration name of Laravel's created_at and updated_at
In this post we will give you information about Change default configuration name of Laravel's created_at and updated_at. Hear we will give you detail about Change default configuration name of Laravel's created_at and updated_atAnd how to use it also give you demo for it if it is necessary.
In this Laravel PHP Tutorial, I will let you know the use of created_at and updated_at column in a database table.
By default, Eloquent automatically maintain the date time value in created_at and updated_at column on your database table. If you do not want for eloquent to maintain created_at and updated_at columns then disable it by adding following property in your model class :
- class Member extends Eloquent {
- protected $table='members';
- public $timestamps= false;
- }
class Member extends Eloquent { protected $table = 'members'; public $timestamps = false; }
If you want to map Laravel's timestamp from created_at
to created_on
and updated_at
to modified_on
then you can override const on your model in following way :
const CREATED_AT = 'created_on'; const UPDATED_AT = 'modified_on';
Now Eloquent will take care of the column "created_on" and "modified_on" on your database table.
How to disable created_at and updated_at timestamps in Laravel Model?
Label :
PHP Laravel PHP Framework How To MVC Web DevelopmentHope this code and post will helped you for implement Change default configuration name of Laravel's created_at and updated_at. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs