#adil
1 messages · Page 1 of 1 (latest)
Let's back up for a second - which stripe products do you plan on using? Checkout? Payment Links? Subscrpitions? something else?
checkout
I want to store the customer and all his card details and charge him monthly
are you there?
Yeah I'm here - Have you read through our docs on this already? https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=checkout
docs are mess I am confused
Could you please give me breif example
I do not have any subscription I have checkout only
What specifically about the docs are confusing you? The docs I linked you are specifically showing how to do subscrpitions WITH checkout
We even have a quickstart version if that'd be more helpful https://stripe.com/docs/billing/quickstart?client=html
let me have a look
I am getting this exception You cannot confirm this PaymentIntent because it's missing a payment method. To confirm the PaymentIntent with cus_OGNJSJs7zwrFkl, specify a payment method attached to this customer along with the customer ID.
I am using this $paymentIntent = PaymentIntent::create([
'amount' => 1000, // Amount in cents
'currency' => 'inr',
'customer' => $customerId,
'payment_method_types' => ['card'],
]);
I have customer ID now I want to charge the amount with customer ID
Why are you creating PaymentIntents directly when you were planning on using Checkout?
I have created the customer
No I want charge him with customer id how to do that
I have used this // Create a new customer
$customer = Customer::create([
'email' => "adilbashir36@gmail.com",
'name' => "adil bashir",
// Add any additional customer data as needed
]);
Did you read the docs I shared with you? You can't just charge someone just from creating a Customer
Let's pause here for a second - is your plan to use Checkout (our stripe-hosted page) or not?
Yes I am using stripe chekout page let me send you the test page
No need to send me the page
So is your issue that you have someone who has ALREADY paid through Checkout, and you want to charge them again?
check the link above
Yes we have installments defined in the package
After first payment we need to store the customer and after that on installments he choose we need to charge him
we have 2 - 3 installments
First isntallment is fine with the checkout
But after that we need to charge him monthly for 2 installments
Instead of creating a payment Checokut Session why aren't you just creating a subcsription mode Checkout Session and cancelling it on the date you want?
No we have our own plans we do not want to use the subscription we have installment process our own
all we want to charge customer on the basis of installments
Gotcha
plz tell me what to do after creating customer do we need to store card details or t stores automatically uand attached to the customer
then you need to make sure you're also setting payment_intent_data.setup_future_usage and pass in the existing customer you have. when you create the Checkout Session
If you don't have the Customer already created then you can set customer_creation: if_required (https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer_creation) and the Checkout Session will create the customer for you
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
how to set this payment_intent_data.setup_future_usage
You can find all this in our API reference https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-setup_future_usage
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
give me an error
Stripe \ Exception \ InvalidRequestException
Received unknown parameter: payment_intent_data. Did you mean payment_method_data?
These are all things you set on the initial Checkout Session that collects payment
Are you accidentally setting these on the payment intent?
What specifically are you confused about?
You need to set those params I mention on the Checkout Session in order to attach the collected PaymentMethod to the customer
Afterwards, you can use that paymetn method with the customer in future payments
this is my checkout session function
public function createStripeSessionCheckout($request)
{
try {
\Stripe\Stripe::setApiKey($this->KEY_SECRET);
$session = $session = \Stripe\Checkout\Session::create([
// 'payment_method_types' => ['card', 'gpay'],
'line_items' => [[
'price_data' => [
'currency' => $request->input('currency'),
'unit_amount' => $request->input('unit_amount'),
'product_data' => [
'name' => $request->input('name'),
'description' => $request->input('description'),
'images' => $request->input('image'),
],
],
'quantity' => $request->input('quantity'),
]],
'mode' => 'payment',
'success_url' => $request->input('success_url') . "?session_id={CHECKOUT_SESSION_ID}",
'cancel_url' => $request->input('cancel_url'),
]);
return $session->id;
} catch (\Stripe\Exception\ApiErrorException $e) {
// Handle any API errors
return $e->getMessage();
return null;
}
how to attach that I am confused
Again, you'd set the params that I shared with you
You'd set payment_intent_data.setup_future_usage
and you can also pass in the customer (if you've already created it)
where in the above code
please give me the exaple
example with the above code
set what value payment_intent_data.setup_future_usage
I'm sorry, but I'm not going to write your code for you - since you're coding this you should understand how to pass in additional params to your Checkout Session creation
You'd pass in off_session for payment_intent_data.setup_future_usage
This is all talked about in the API reference links I gave you
this is insane poor support from you
Let me try another channel for support
anyways thanks
0 rating
just check this code I have added the options still gives me an error
public function createStripeSessionCheckout($request)
{
try {
\Stripe\Stripe::setApiKey($this->KEY_SECRET);
// Create a Stripe Customer
$customer = \Stripe\Customer::create([
'email' => $request->input('email'), // Customer email
// Additional customer information if needed
]);
// Create a Checkout Session with customer and setup_future_usage
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card', 'gpay'],
'line_items' => [[
'price_data' => [
'currency' => $request->input('currency'),
'unit_amount' => $request->input('unit_amount'),
'product_data' => [
'name' => $request->input('name'),
'description' => $request->input('description'),
'images' => $request->input('image'),
],
],
'quantity' => $request->input('quantity'),
]],
'mode' => 'payment',
'success_url' => $request->input('success_url') . "?session_id={CHECKOUT_SESSION_ID}",
'cancel_url' => $request->input('cancel_url'),
'customer' => $customer->id, // Attach the customer ID
'payment_intent_data' => [
'setup_future_usage' => 'off_session', // Set setup_future_usage to off_session
],
]);
return $session->id;
} catch (\Stripe\Exception\ApiErrorException $e) {
// Handle any API errors
return $e->getMessage();
return null;
}
}
I