#Willxcel
1 messages · Page 1 of 1 (latest)
Can you share the code that's producing the unexpected result?
That's a link to Stripe.js, but what I need to see to help you is the code you wrote.
//Create subscription & charge first payment
$subscription = \Stripe\Subscription::create([
'customer' => $customer_id,
'items' => [
[
'plan' => $planname,
],
],
'expand' => ['latest_invoice.payment_intent'],
]);
$subscription_id = $subscription->id;
$billing_cycle_anchor = $subscription->billing_cycle_anchor;
$current_period_start = $subscription->current_period_start;
$customer_id = $subscription->customer;
$plan_name = $plantype;
if(isset($subscription_id) && $subscription_id != ''){
$desc = $plan_name. ' subscription';
// ###PROCESS DATABASE UPDATES###
$sql = "INSERT INTO ".$prefix."_orders SET ordered = '".$billing_cycle_anchor."'";
$sql.= " ,ord_num = '".$subscription_id."'";
$sql.= " ,user_id = '".$user_id."'";
$sql.= " ,amount = '".($amount * 100)."'";
$sql.= " ,customer_id = '".$customer_id."'";
$sql.= " ,item = '".$desc."'";
$sql.= " ,paid = '1'";
$conn->query($sql);
$setquery = '';
if($plantype == 'MEMBERSHIP' || $plantype == 'PROMO_MEMBERSHIP'){
$setquery = " rec_mem = '".$subscription_id."'";
$setquery .= ", rate = '".$amount."'";
}
I believe this is the section
Okay, looks like you're creating a Subscription there for an existing Customer. Where's the code involved in accepting their new card info?
$onetime_charge_price = ($onetime_charge_base - $discount_charge) * $famount;
//$onetime_charge_price = #PURCHASE_RATE
$onetime_charge = $onetime_charge_price * 100;
$desc = '+ '.$famount.' credits ordered';
$charge = \Stripe\Charge::create(array(
'customer' => $customer_id,
'amount' => $onetime_charge,
'currency' => 'usd',
'description' => $desc
));
$ord_num = $charge->id;
$ordered = $charge->created;
I didn't write it. I think that is what I am missing... we submit the one time charge to the customer id which charges the card initially setup on file and are not posting the new card anywhere.
Is the developer who did write it available?