#peacep_api

1 messages ยท Page 1 of 1 (latest)

rose pilotBOT
#

๐Ÿ‘‹ 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/1286379284566507520

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

mild raven
#

Hello! I'm not sure I fully understand your question, can you provide more details? What is the exact behavior in live mode, and how does it differ from test mode? Are you seeing any errors? Is there anything relevant in your web server logs?

daring relic
#

this is what it looks like in live mode. In test mode I wouldn't see the right part of the screen, but would instead see the ability to finalize the purchase of additional licenses.

#

user shouldn't need to click to have a link sent to them. Here's a snippet of my code:
$payload = [
'client_reference_id' => $user->id(),
'success_url' => $GLOBALS['base_url'] . '/thank-you/0',
'mode' => 'subscription',
'subscription_data' => [
'metadata' => [
'groupid' => $group->id(),
'userid' => $user->id(),
'purchase_type' => 'license',
'language' => \Drupal::languageManager()->getCurrentLanguage()->getId(), // Add this line for language
],
],
'line_items' => $price_ids,
'automatic_tax' => [
'enabled' => false,
],
'allow_promotion_codes' => true,
'locale' => $this->determine_language_code(),
// 'custom_text' => [
// 'custom_text.submit' => [
// 'custom_text.submit.message' => 'hello this is my custom text.'
// ]
// ],
//'discounts' => [['coupon' => $coupon]]
];
//dpm(\Drupal::languageManager()->getCurrentLanguage()->getId());
if ($user->get('field_stripe_customer_id')->value && $user->get('field_stripe_customer_id')->value !== '') {
$payload['customer'] = $user->get('field_stripe_customer_id')->value;
} else {
$payload['customer_email'] = $user->getEmail();
}
// $coupon = $this->get_user_coupon($user);
// if ($coupon !== '') {
// $payload['discounts'] = [['coupon' => $coupon]];
// }

            $session = $stripe->checkout->sessions->create($payload);

            $response = new TrustedRedirectResponse($session->url);
mild raven
#

Ah, okay, can you show me two Checkout Session creation requests, one in test mode that's working as expected and another in live mode that isn't?

#

Like req_yL7Ym9fEFNmvlI that you shared above is a Checkout Session creation request in live mode. Is that one that's not working as expected?

daring relic
#

ok. i will look at older requests in test. it's been working flawlessly there. one sec

#

req_2iGrxhoz7Asupm

#

yes, all live requests are not working as expected. you have a good example.

mild raven
#

Okay, so in that request you set customer_email tot he email address shown in your screenshot, which is triggering that behavior. In your live mode request, you didn't set customer_email. Instead, you set customer to a specific Customer ID. That's why you're seeing different behavior.

daring relic
#

good catch. thank you. let me check. that seems odd because it's the same code...

#

i see there's some logic regarding this. is the best practice to set them both?

mild raven
#

No, you should set one or the other.

#

That explains what those two different parameters do.

daring relic
#

got it. thank you. I think you figured it out. :). So, is Discord where I go for live human chat now? When did this change?

mild raven
#

We've had this Discord server set up for a long while (and before that we used IRC). It's for developer help only, all other questions should go to Stripe support, and the have human chat over there as well.

daring relic
#

ok. thanks. It seems you can't get to a real person in real time for developer support over there like it used to be. So glad I found you in Discord. Thank you ๐Ÿ™‚

mild raven
#

Happy to help!

#

To clarify, we've never had realtime developer support at Stripe support. You can chat live with a support agent over there, but they're not developers.

daring relic
#

ok. i must have checked a different option last time other than API. so, when would I send over the stripe customer id? It seems odd that for this behavior I should be sending email.

mild raven
#

It depends on what you're trying to build/do. Can you tell me more about what your desired flow is here at a high level?

daring relic
#

still not working with this change. ๐Ÿ˜ฆ req_9qa8dveHzLFTlD

#

the flow is for users to be able to make additional license purchases (all purchases are subscriptions), then go back to my site.

mild raven
#

If you want an existing Customer to make an additional purchase you should set customer to their Customer ID so the Checkout Session is associated with them.

daring relic
#

that's what i figured. But i certainly don't want them to have to check their email for a new link.

mild raven
#

You should only use customer_email when you have their email address but not a Customer ID for them.

daring relic
#

that's what i've been doing

mild raven
#

Not sure what you mean?

#

Can you give me the request ID for the newest Checkout Session you created?

daring relic
#

I did, right before teh last screenshot. here it is again: req_9qa8dveHzLFTlD

#

i dont think that's what you want. let me try it again with customer id

#

req_9yeE4etyw7bSpp
basically the same screenshot

mild raven
#

Oh, I see what's happening. So I think I'm a bit confused. That prompt is coming up because you're creating a Checkout Session in subscription mode for a Customer who already has an active Subscription. Is your intention to create another Subscription for them that's separate from the existing one?

daring relic
#

yes. this is why i think its a configuration issue with stripe because again, the code is identical.

#

i recall something about stripe managing subscriptions so users can only have one, but I can't find this configuration ๐Ÿ˜ž

mild raven
#

Okay, so you do want this Customer to end up with two Subscriptions?

daring relic
#

2 or more, yes. i have 2 types of subscriptions. one of them is one only. the other is multiple but they can all be multiple and I can manage it.

mild raven
daring relic
#

Yay. that was it! Not where I expected to find it. I have one other unrelated question. We recently changed our domain name and I wanted to change the domain in stripe. can i add it, perform the switch, then remove the old domain? I think i was limited to only one domain on the plan i'm on, but I also don't want to break anything.

mild raven
#

Yeah, you can do that.

#

You can only have one active custom domain per account at a time.

#

When you make the new one active the old one will automatically be disabled and stop working.

#

You can then set up a redirect on your end to the new domain if you want.

daring relic
#

i don't think i can do it that way. i think i tried before but since I can't have two, I'd have to remove the active one first?

mild raven
#

Ah, yeah, that's how the UI works, I forgot about that.

#

Yep, you'd remove your existing one and then add the new one.

daring relic
#

ok. thanks Rubeus

mild raven
#

Happy to help!