#Sandeep
1 messages · Page 1 of 1 (latest)
👋 happy to help, what is the question though?
moving your Q into the thread
hello to all... i am trying to create a code in php for creating a schedule of 3 months subscription i.e. 3 iterations but after running the code i am not able to see the end date in stripe panel. please guide me how to create a schedule of 3 months auto payments with 3 iterations. and please check the code if it is correct or not.. thanks
would you mind removing it from the main channel?
Sure I can.... then on which channel should I send it? Kindly confirm
here I will respond, it's just to keep all of our conversation in one thread
$pmethod = $stripe->paymentMethods->create([
'type' => 'card',
'card' => [
'number' => '4242424242424242',
'exp_month' => 11,
'exp_year' => 2023,
'cvc' => '314',
],
]);
you don't need this, you can use thepm_card_visamagic string instead
for testing
you would generate your customer like so
'description' => '4 weeks recurring / 3 months programe',
'name' => $custname,
'email' => $email,
'payment_method'=> "pm_card_visa",
'invoice_settings'=> [
'default_payment_method'=> 'pm_card_visa'
]
]);```
'customer' => $customerid,
'start_date' => 'now',
'end_behavior' => 'cancel', // if you wish to cancel the sub after 3 iterations
'phases' => [
[
'items' => [
[
'price' => 'price_1M6tkACCyjo9885AunK96LUI',
'quantity' => 1,
],
],
'iterations' => 3,
],
],
]);
I would also create a test_clock and add it in the customer creation request to advance the time and see how the subscription is behaving
more about test clocks here https://stripe.com/docs/billing/testing/test-clocks
Thanks a lot for your help!! If I'd still have any doubts then I would message you in the same thread only.... Thanks again!
sure, let me know if you need any more help
Thanks. This code worked out very well. It is running properly and giving wanted output.
Please tell me how to cancel the subscription in between the period suppose a customer is taking 3 month subscription and after his/her 1st installment he/she wants to cancel the subscription. How to do it? Please help me to sort it out....
$stripe = new \Stripe\StripeClient(
'test_key'
);
$subid = $subscriptionid;
$op = $stripe->subscriptions->cancel(
$subid,
[]
);
Thank you..
But according to your code how to get the subscription id. Its showing on stripe panel but I want to save in MySQL db.
you need to store it yourself
Thank you very much for your support. I will try this and let you know if stuck somewhere. Thank you.
let me know if you need any more help
Yes sure please