#lucasemanuel

1 messages · Page 1 of 1 (latest)

vague martenBOT
azure rain
#

Hi 👋 can you elaborate on what you're trying to accomplish? You cannot complete payment for a Checkout Session via the API, as Checkout Sessions are a hosted surface for your customers to provide the necessary payment method details and complete the payment.

tender bane
#

allright,

#

already working with subscription

#

is there any alternative via api for buys one time?

azure rain
#

Sorry, I'm a little unclear what you're asking, can you include more context to ensure we're aligned? For instance, what is already working for with subscriptions, and is there an API flow that is an alternative to what?

tender bane
#

Okay, im use only api, already have payment_method and need buy products one time, but all flow must via api

#
$checkout = $stripe->checkout->sessions->create([
    'customer' => $user->stripe_id,
    'success_url' => 'https://example.com/success',
    'line_items' => [
        [
        'price' => 'price_1Mj4RwKoGRirOu8OBs1hy2EN',
        'quantity' => 1,
        ],
    ],
    'payment_intent_data' => [
        'setup_future_usage' => 'off_session'
    ],
    'invoice_creation' => [
        'enabled' => true
    ],
    'mode' => 'payment',
]);

$stripe->paymentIntents->confirm(
    $checkout->payment_intent,
    [
        'payment_method' => $paymentMethod->stripe_id
    ]
);
#

You cannot perform this action on PaymentIntents created by Checkout.

azure rain
#

Yeah, that won't work, if you want to confirm the Payment Intent directly then you should create the Payment Intent yourself.

#

When you're creating the Payment Methods that you want to use later, are you setting them up for future usage, and if so are you setting them up for on_session or off_session payments?

tender bane
#

set with off_session

#

I will try to use invoice instead of checkout.session

azure rain