#adil

1 messages · Page 1 of 1 (latest)

valid forgeBOT
bold crown
#

Let's back up for a second - which stripe products do you plan on using? Checkout? Payment Links? Subscrpitions? something else?

visual pawn
#

checkout

#

I want to store the customer and all his card details and charge him monthly

#

are you there?

bold crown
visual pawn
#

docs are mess I am confused

#

Could you please give me breif example

#

I do not have any subscription I have checkout only

bold crown
#

What specifically about the docs are confusing you? The docs I linked you are specifically showing how to do subscrpitions WITH checkout

visual pawn
#

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

bold crown
#

Why are you creating PaymentIntents directly when you were planning on using Checkout?

visual pawn
#

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
]);

bold crown
#

Did you read the docs I shared with you? You can't just charge someone just from creating a Customer

visual pawn
#

after customer what I need to do

#

I have created customer then what

bold crown
#

Let's pause here for a second - is your plan to use Checkout (our stripe-hosted page) or not?

visual pawn
#

Yes I am using stripe chekout page let me send you the test page

bold crown
#

No need to send me the page

bold crown
#

So is your issue that you have someone who has ALREADY paid through Checkout, and you want to charge them again?

visual pawn
#

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

bold crown
#

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?

visual pawn
#

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

bold crown
#

Gotcha

visual pawn
#

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

bold crown
#

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

visual pawn
#

how to set this payment_intent_data.setup_future_usage

bold crown
visual pawn
#

give me an error

#

Stripe \ Exception \ InvalidRequestException
Received unknown parameter: payment_intent_data. Did you mean payment_method_data?

bold crown
#

These are all things you set on the initial Checkout Session that collects payment

#

Are you accidentally setting these on the payment intent?

visual pawn
#

I am confused

#

please give an example simple one

bold crown
#

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

visual pawn
#

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

bold crown
#

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)

visual pawn
#

where in the above code

#

please give me the exaple

#

example with the above code

#

set what value payment_intent_data.setup_future_usage

bold crown
#

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

visual pawn
#

this is insane poor support from you

#

Let me try another channel for support

#

anyways thanks

#

0 rating

valid forgeBOT
visual pawn
#

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

quasi cedar
#

Hi taking over here

#

What error are you getting?

visual pawn
#

no customer found

#

where to get 'customer' => $customer->id