How can we apply future recurring payment in stripe payment gateway in php

99 Views Asked by At

I am working on subscription, i want to do subscription from future date, i did code for that, but i am not sure is it correct or not, here i have added my code, can anyone please look in this code and tell me i am correct or not, or you can also you give your thoughts on that, here is my subscription code.

$customer = \Stripe\Customer::create(array(
    'source' => $token,
    'description'=> 'Test Customer',
    'email' => '[email protected]',
    'plan' => $plan_id,
));
// Charge the order:
$dateTime = new DateTime('2018-07-10');
$date_timestamp = $dateTime->format('U');
$charge = \Stripe\Subscription::create(array(
    'customer' => $customer->id,
    "items" => array(
        array(
            "plan" => $plan_id,
        ),
    ),
    "billing_cycle_anchor"=> $date_timestamp
));
1

There are 1 best solutions below

0
Felipe Augusto On

I'm not sure about your code, but I can give you some tips.

Implement recurring payment can be harder than you expect.

You can use other payment gateway, the recurly can make you life easier. Here you can see a client api in PHP for recurly