#rangermillze_api

1 messages ¡ Page 1 of 1 (latest)

safe thistleBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1303364389902225469

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

tender heath
#

hi, we are using the payment element to create the initial subscription

icy compass
tender heath
#

ah, ok so does the user need to go through the process of 3d authentication again?

#

we use:

#

$response = $stripe->subscriptions->update(
$order['current_subscription_id'],
[
'items' => [
[
'price' => $product_price_id,
'quantity' => 1,
],
],
'proration_behavior' => 'always_invoice',
'expand' => ['latest_invoice.payment_intent']
]
);

#

to add the item to the subscription

icy compass
#

maybe, maybe not, it depends. That's not the way I would think about it. They might have to make a payment, and part of making a payment is sometimes 3D Secure, it's inside the concept of making the payment.

tender heath
#

and $response->latest_invoice->payment_intent->status = requires_action however $response->latest_invoice->collection_method = automatical collection

#

the issue I have is that we need to update the user database but i dont want to do this unless payment has been made for the update.

icy compass
#

then you want the Pending Update feature linked to above

tender heath
#

ok, so I add 'payment_behavior' => 'pending_if_incomplete'

#

when I use pending_if_incomplete, can I show the paymenet element and go through the paymenet process again? or do I have to rely on the webhook to perform the update?

#

I use this to initial the subscription update:

#

$.ajax({
url:"/gateway/gateway_init.php",
type: "post",
dataType: 'json',
data: {
op: "updateSubscription",
sub:customer_id,
cus: subscription_id,
upgrade_to: upgrade_to,
gateway: 'stripe',
order: order
},
success:function( response ){
console.log(response);
if( response.paid == "updated" ){ //show success message } else ....

#

the ordercontains all th eupdate details. so depending on the response we either show the message to the user saying addon has been added or we show the payment element if the 3dsecure paymenet is required.

icy compass
#

I think the way it works is a payment is processed as soon as you call the update API. I don't think you can make the payment happen upfront in the PaymentElement, one option which is not great is to create a separate PaymentIntent, process it on that frontend and then if that succeeds, do the update and use coupons etc to not double charge.
Let me ask someone else, I haven't looked at this part of the API recently.

jolly kite
#

I think you'd be able to use the latest_invoice returned in the pending update response to initialise a Payment Element and re-confirm the intent yes. Should be easy enough to test!