#devsmith

1 messages · Page 1 of 1 (latest)

rain heraldBOT
plain fossil
#

Hi there, so what's your question?

haughty osprey
#

try {
$customerResponse = $gateway->createCustomer([
'email' => $email, // User's email
'token' => $request->input('stripeToken'), // Stripe token from card form
])->send();

          if (!$customerResponse->isSuccessful()) {
              return redirect()->back()->with('error', 'Failed to create customer.');
          }

          $customerData = $customerResponse->getData();
          $customer = $customerData['id'];
      $planId = 'plan_' . time();
          $planResponse = $gateway->createPlan([
              'amount' => 123, // Amount in cents
              'interval' => 'month',
              'name' => 'testpayment',
              'currency' => 'usd',
              'id' => $planId, // Replace with a dynamic plan ID
              'product'=>'prod_OmoFtTBrekqazp',
              'interval_count'=> 1,
          ])->send();
       
          if (!$planResponse->isSuccessful()) {
              return redirect()->back()->with('error', 'Failed to create plan.');
          }
         
          $subscriptionResponse = $gateway->createSubscription([
              'customer' => $customer,
              'items' => [['plan' => $planId]],
          ])->send();
        dd($subscriptionResponse->getData());
          if (!$subscriptionResponse->isSuccessful()) {
            $error_msg = 'cant create';
            $this->helper->one_time_message('error', $error_msg[0]." : ".$error_msg[1]);
            return redirect()->back();
          }

          return redirect()->back()->with('success', 'Subscription created successfully.');
      } catch (\Exception $e) {
          return redirect()->back()->with('error', 'An error occurred: ' . $e->getMessage());
      }
#

can not create subscription

#

but customer and plans are getting created not subscription

plain fossil
haughty osprey
#

kk

#

here check this code $subscriptionResponse = $gateway->createSubscription([
'customer' => $customer,
'items' => [['plan' => $planId]],
])->send();

#

what i meant is that subscription api is not working so there will be no request id

#

but yeah i can share customer plan request ids

plain fossil
#

What error do you see?

haughty osprey
#

thats first request id
req_W6IPWxRnVBjihq --token
req_kVhYsUJLbDcVIp -- customer creation
req_qZ5ktLlfpasc50 -- plan creation

but there is no api in logs for subscription

#

i cant see any error cause no subscription happened

plain fossil
#

You shouldn't use plans APIs anymore because it's deprecated

#

You should use Prics APIs instead

#

There must be an error if the subscription wasn't created succefully

#

Have you checked your server log?

haughty osprey
#

yes thats issue so can you provide me price pis for creating subscription

#

i checked it

#

cant see any errors

plain fossil
haughty osprey
#

can you tell which parameters i should pass here 'customer' => $customer,
'items' => [['plan' => $planId]],

plain fossil
haughty osprey
#

so that means instead of creating plan i should create price /

#

and then on that base i must create subscription /