#Sandeep

1 messages · Page 1 of 1 (latest)

karmic harborBOT
idle rampart
#

👋 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?

zealous ridge
#

Sure I can.... then on which channel should I send it? Kindly confirm

idle rampart
#

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 the pm_card_visa magic 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

zealous ridge
#

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!

idle rampart
#

sure, let me know if you need any more help

zealous ridge
#

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....

idle rampart
zealous ridge
#

$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.

idle rampart
#

you need to store it yourself

zealous ridge
#

Ok. I will try..

#

Please help me regarding how to refund the payment using php..

idle rampart
zealous ridge
#

Thank you very much for your support. I will try this and let you know if stuck somewhere. Thank you.

idle rampart
#

let me know if you need any more help

zealous ridge
#

Yes sure please

zealous ridge
#

Hi

#

Please help me regarding how to refund

#

$stripe = new \Stripe\StripeClient(
$Secretkey
);
$stripe->refunds->create([
'charge' => 'ch_3Kg1J9CCyjo9885A05OWHpcs',
]);