#devsmith
1 messages · Page 1 of 1 (latest)
Hi there, so what's your question?
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
Hi! Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
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
What error do you see?
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
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?
yes thats issue so can you provide me price pis for creating subscription
i checked it
cant see any errors
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
can you tell which parameters i should pass here 'customer' => $customer,
'items' => [['plan' => $planId]],
https://stripe.com/docs/api/subscriptions/create#create_subscription you can find example code in the API reference as well
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.