#rups

1 messages · Page 1 of 1 (latest)

hybrid forumBOT
distant sentinel
#

👋 How can I help?

dawn mesa
#

hi what is your good name?

distant sentinel
#

I'm River. This channel is for Stripe technical integration questions. Is there anything that I can help?

dawn mesa
#

yes please I am struglling changing integration for 3d secure.

#

my requirement is to create trial subscription for 30 days and after 30 days 20pound will charge.

#

can you please guide be step by step.

#

as currently integration shows that I subscribe successfully with trial period

#

but im unsure that amound also deducted.

#

there?

distant sentinel
#

Thanks for waiting.

#

Can you share the subscription ID (sub_xxx)?

dawn mesa
#

just a minute

#

sub_1NJI19KEj4mhMNmpqiabKk67

#

trial subscription created successfullly.

#

?

distant sentinel
#

Customer will only be charged after the trial ends

dawn mesa
#

ok that is clear from subscription page

#

in overview

#

below "Subscription"
"Payments"

#

it says

#

20 pound | PaymentIntent Created | date |

#

on this last 3 dots click

#

there is option for refund payment

#

does not it mean this amount is deducted from customer account?

#

it seems like my integration issue..

#

amount also deducted in trial subscription

distant sentinel
dawn mesa
#

It was another request that your system made to make a separate payment:
=> so you mean to say that it is wrongly implemented?

distant sentinel
#

You have a subscription and one-time payment on this customer

#

I'd recommend checking which part of your code triggered one-time payment

#

If you only wishes to charge the customer through subscription, you shouldn't create a separate payment intent

dawn mesa
#

ok got it

#

`$paymentIntent = \Stripe\PaymentIntent::create([
'amount' => $amount*100,
'currency' => 'gbp',
'description' => 'PaymentIntent Created',
'payment_method_types' => [
'card'
]
]);

$data['output'] = [
'stripePlanId' => $stripePlanId,
'id' => $paymentIntent->id,
'clientSecret' => $paymentIntent->client_secret
];`

distant sentinel
#

Why do you create the payment intent for a subscription?

dawn mesa
#

I am passing this "clientsecret" to confirmcardpayment.

await stripe.confirmCardPayment(clientsecret, { payment_method: { card: cardElement, billing_details: { name: customer_name, }, }, return_url: "<?php echo base_url('paymentreturn.html'); ?>" }).

#

to enable 3d secure

distant sentinel
#

For a subscription, you don't need to create a payment intent

dawn mesa
#

but once trail end I have to charge customer

distant sentinel
dawn mesa
#

can you plass code for the same.

#

PHP with javascript / jquery?

#

as i am trying since 15 days and couldnt make it work perfectlly

distant sentinel
#

I'm afraid we don't have the full doc for this. The steps are:

  1. Follow the doc: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
  2. At step 5 of the doc, expand pending_setup_intent as well, i.e. 'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'],
  3. At step 6 of the doc, if the client secret is for Setup Intent (seti_xxx_secret_xxx), then stripe.confirmSetup() should be used instead of using stripe.confirmPayment: https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements#submit-payment-details
dawn mesa
#

Yes there is no document with code.

#

At step 5 of the doc, expand pending_setup_intent as well, i.e. 'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'],
=> how to achive this via code level?

#

you mean to say I have create subscription with expand as above?

distant sentinel
#

When you create a subscription, you will expand pending_setup_intent field as well, so that you can retrieve Setup Intent's client secret and send it to client to render Payment Element. For example,

    $subscription = $stripe->subscriptions->create([
        'customer' => $customer_id,
        'items' => [[
            'price' => $price_id,
        ]],
        'payment_behavior' => 'default_incomplete',
        'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
        'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'],
    ]);
dawn mesa
#

yes that I did and got client_secret too.

#

`$subscribe = \Stripe\Subscription::create([
'customer' => $user['stripeCustomerId'],
"items" => [
[
"plan" => $stripePlanId,
],
],
'payment_behavior' => 'default_incomplete',
'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'],
]);

        $data['output'] = [
            'stripePlanId' => $stripePlanId,
            // 'id' => $paymentIntent->id,
            'clientSecret' => $subscribe->latest_invoice->payment_intent->client_secret
        ];`
#

Uncaught (in promise) IntegrationError: Your code called confirmSetup() but you passed a client_secret associated with a PaymentIntent. Did you mean to call confirmPayment() instead?
now getting this

distant sentinel
#

For non-zero invoice (without trial), you will get Payment Intent client secret from latest_invoice->payment_intent->client_secret
For zero invoice (with trial), you will get Setup Intent client secret from pending_setup_intent->client_secret

dawn mesa
#

on frontside
' const {error1} = await stripe.confirmSetup({
//Elements instance that was used to create the Payment Element
elements,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});
'

distant sentinel
#

Is the subscription you created with trial?

dawn mesa
#

yes subscription with trial.

#

sorry mistake adding trial things here

distant sentinel
#
  • For non-zero invoice (without trial), you will get Payment Intent client secret from latest_invoice->payment_intent->client_secret -> Use stripe.confirmPayment()
  • For zero invoice (with trial), you will get Setup Intent client secret from pending_setup_intent->client_secret -> Use stripe.confirmSetup()
dawn mesa
#

$subscribe = \Stripe\Subscription::create([ 'customer' => $user['stripeCustomerId'], "items" => [ [ "plan" => $stripePlanId, ], ], 'payment_behavior' => 'default_incomplete', 'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'], 'payment_settings' => ['save_default_payment_method' => 'on_subscription'], 'trial_end' => 30, ]);

#

free trial

#

and I got client secret
$data['output'] = [ 'clientSecret' => $subscribe->latest_invoice->payment_intent->client_secret ];

distant sentinel
dawn mesa
#

is it correct?

distant sentinel
dawn mesa
#

'trial_end' => $trialEnd, ? is it right way?

distant sentinel
dawn mesa
#

currected.

#

check now.

distant sentinel
#

Yup, this is correct. So you need to get the Setup Intent client secret from pending_setup_intent->client_secret and pass to your client

dawn mesa
#

nd pass to your client? perticular which method?

#

const {error1} = await stripe.confirmSetup({
//Elements instance that was used to create the Payment Element
elements,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});

distant sentinel
dawn mesa
#

it didnt prompt 3d secure popup

#

const {error1} = await stripe.confirmSetup({ //Elementsinstance that was used to create the Payment Element elements, confirmParams: { return_url: 'https://example.com/order/123/complete', }, });

distant sentinel
dawn mesa
#

yes

distant sentinel
#

Can you share the subscription ID (sub_xxx)?

dawn mesa
#

sub_1NJXA7KEj4mhMNmp8QIVqXmx

distant sentinel
#

In the setup intent seti_1NJXA7KEj4mhMNmpQ9RWPyV6 of sub_1NJXA7KEj4mhMNmp8QIVqXmx, I can see that 3DS has been completed

dawn mesa
#

yes

distant sentinel
#

Didnt you see a pop up window to confirm 3DS authentication?

dawn mesa
#

4000000000003063
so it didnt ask for 3d popup. in above card.

distant sentinel
#

3DS was completed from what I saw in seti_1NJXA7KEj4mhMNmpQ9RWPyV6

#

Could you share your development website, so that I can have a closer look?

dawn mesa
#

I am testing in my local server.

#

i am initiating with new user

distant sentinel
#

From my logs, I do see 3DS performed, i.e. 3DS window has popped up and completed

#

I'd need your development website that's accessible for me to check why it wasn't the case

hybrid forumBOT
dawn mesa
#

what is next

fluid sky
#

Hi! I'm taking over this thread.

#

Can you clarify your question?

dawn mesa
#

ohh

#

im discussiong with rive since long

#

create trial subscription without initially payment charge.

fluid sky
#

Yes, but what's your question? What do you mean by "what is next"?

dawn mesa
#

ok

#

I am creating trail subscription without taking payment.

fluid sky
#

Yes I understand this part. But what's your question?

dawn mesa
#

now subscription is created without trial

#

but redirection not working as expected.

fluid sky
#

What does "not working as expected" mean? What is happening exactly?
And can you share a subscription ID (sub_xxx)?

dawn mesa
#

'await stripe.confirmSetup({
//Elements instance that was used to create the Payment Element
elements,
confirmParams: {
return_url: "<?php echo base_url('payment'); ?>"
},
})`

#

here what will be return url

fluid sky
#

And... what is the problem/question?

#

The return URL is something you set yourself, and users will be redirected there after the payment is successful

dawn mesa
#

but before redirect customer I need to submit form on db level

fluid sky
#

What "form" are you talking about? What exactly do you want to save in your database?

dawn mesa
#

register user

#

once register it will ask you for payment

fluid sky
#

I don't want to create an account on your website, I'm just trying to understand what is your issue exactly.

#

Usually you have a form with the customer information: you save that in your own database, and is unrelated to Stripe.
Then for the payment, you confirm the PaymentIntent, then the user is automatically redirected to the return_url, and then you can use a webhook endpoint to store the payment information.

dawn mesa
#

wait

#

above url is just development server.

#

you can create user there

#

have you checked?

static wedge
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

#

Could you please summarise the latest question?

dawn mesa
#

ok

static wedge
#

We can't register on your website, so please try to explain/show the situation.

dawn mesa
#

ok

#

requirement:
subcription create with 30 days

#

as suggested by river I did this in PHP

#

$subscribe = \Stripe\Subscription::create([
'customer' => $user['stripeCustomerId'],
"items" => [
[
"plan" => $stripePlanId,
],
],

                'payment_behavior' => 'default_incomplete',
                'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'],
                'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
                'trial_period_days' => 30,
            ]);
#

I got client secrete here

#

'clientSecret' => $subscribe->pending_setup_intent->client_secret

#

than this secret I am passing to client side

#

async function handleSubmit(e) {
showMessage('');
showLoadingBar();
event.preventDefault();

        console.log(clientSecret);

       
        await stripe.confirmSetup({
            //`Elements` instance that was used to create the Payment Element
            elements,
            confirmParams: {
                return_url: "<?php echo base_url('payment'); ?>"
            },
        });
#

are you getting?

static wedge
#

So what's the exact problem?

dawn mesa
#

now after click on submit button > my page is redirect to above return url.

#

wih get method

#

here I stuck now.

#

if I manually back from browser than subscription created with trial and no amount deducted.

#

but how to handle redirect things here.

#

is it compusory to redirect?

static wedge
#

The subscription is created anyway, because it's in trial, however it will cancel in the end of trial if no payment method will be added.

static wedge
#

Is this an issue?

#

What do you mean by "but how to handle redirect things here."?
Are you asking about fulfilling orders when the customer has successfully paid?

dawn mesa
#

lets start from scratch.

#

for trail subscription without payment.

#

1st Step:
Create Subcription with trail period defult incomplete

` $subscribe = \Stripe\Subscription::create([
'customer' => $user['stripeCustomerId'],
"items" => [
[
"plan" => $stripePlanId,
],
],

                'payment_behavior' => 'default_incomplete',
                'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'],
                'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
                'trial_period_days' => 30,
            ]);`
#

Can you please verify this? so that I move further

#

There?

static wedge
#

Sorry for delay, it's busy.
I can't review all of your code, unfortunately. Please let me know if you see any specific errors and we will solve it together.

dawn mesa
#

I am explaining error when we start discussiong

#

still you are not clear so I started from scratch

static wedge
#

Could you please share the exact error/problem you're seeing and I will be happy to look into it.
I understand your situation by now, but I don't see any issue.

dawn mesa
#

sub_1NJZbjKEj4mhMNmp0Ei6JZeV

#

can you check this?

#

after subscrtiption create with trial of 30 days and successfully attempted 3d secure

#

it gets cancel automatically

static wedge
dawn mesa
#

ok

hybrid forumBOT