I'm using Stripe API for one time payments, which works perfectly fine using something like:
$stripe = array("secret_key" => "MY_SECRET_KEY", "publishable_key" => "MY_PUBLISHABLE_KEY");
Stripe::setApiKey($stripe['secret_key']);
try {
$charge = Stripe_Charge::create(array(
"amount" => round($_POST['amount'] * 100, 0),
"currency" => "USD",
"card" => array(
"number" => 111111111111111111,
"exp_month" => 10,
"exp_year" => 2017,
"cvc" => 321,
),
"description" => $_POST['item_name']));
$json = json_decode($charge);
$amount_charged = round(($json->{'amount'} / 100), 2);
//process payment here......
}
catch (Stripe_CardError $e) {
$body = $e->getJsonBody();
print json_encode($json);
}
Now I want to be able to have recurring payments, by capturing user credit card info, and running cron job once a month. Will the above work fine, or do I need something else. I'm aware that Stripe has built in feature for recurring payments, but in my case payments for each month will have different amount.