#Willxcel

1 messages · Page 1 of 1 (latest)

bold dawn
#

Hello! Can you tell me more about your integration? Are you using Stripe Elements?

vagrant copper
#

Stripe php api

#

Checking the version.

bold dawn
#

Can you share the code that's producing the unexpected result?

vagrant copper
bold dawn
#

That's a link to Stripe.js, but what I need to see to help you is the code you wrote.

vagrant copper
#

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

bold dawn
#

Okay, looks like you're creating a Subscription there for an existing Customer. Where's the code involved in accepting their new card info?

vagrant copper
#

$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;
bold dawn
#

That's still not the code involved in accepting card info?

#

Is this code you wrote?

vagrant copper
#

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.

bold dawn
#

Is the developer who did write it available?

vagrant copper
#

No, not at the moment. I'll have him pick it up here in about an hour.

#

Thank you for your response.