#primodirective_api

1 messages ยท Page 1 of 1 (latest)

autumn nimbusBOT
#

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

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

wraith driftBOT
queen notch
#

I don't understand the question. Can you share an ID that demonstrates the issue you describe?

edgy swift
#

There wasn't a lot of room to expand on the question, sorry

#

I can't show you an error because the error is coming from another server. Stripe's system is working perfectly and is not where the error lies. I am really looking for some more general advice about how to move forward from an error I am getting on my channel manager API. But it's to do with Guesty payments. Can I expand here a little?

queen notch
#

Sure

edgy swift
#

Is it ok to mention the name of the channel manager? The have a Stripe 'plug in' so they are already working officially with Stripe. I'm not going to be dissing them or anything, there is nothing wrong with their system. I am really just looking for a pattern to use with my work here.

#

Do you know what a channel manager is?

queen notch
#

I've no idea

#

If you can share some code and convey the problem you're experiencing, that might help

edgy swift
#

So, I already have a website which pulls properties from Guesty (a channel management service). A channel manager simply provides online services for companies like mine. We can store our property data on their services and they feed those properties out to other companies online in the same business as us - property rentals. On our own site, I take properties from their database via their API, list them for visitors and provide rental prices for those properties. When a visitor chooses a property, we show them the price and I use Stripe Elements on my site to take payment details from them. Basically I create a payment intent and then take the customers payment details via Stripe and store the data about which property has been rented, the start and end dates etc.

#

I have been asked to do some further work, where instead of storing our sales locally on our servers, we are now going to store this data on the channel manager website and I am trying to send the payment information, client information and property rental information ALL to Guesty. They have an API which allows me to do this.

#

Finally, my problem is that when I use their API to send the data about a new payment, they require a Payment Method ID which I get from Stripe during the payment process. Unfortunately, the API throws an error when I try to pass the payment method ID with the customer details and it tells me it can't accept the payment method because there is already a customer attached to it

#

I'm working with their help as well to try and remove this error and I think that I need a payment method id, but one that is not attached to a customer. My question is, is this possible? Can I get a payment intent and a payment method id without actually making the payment? The remote API can I think make the final request for payment as our Stripe account is attached to their system. Does this make any more sense to you?

#

Sorry if this is confusing. I find it confusing myself!

#

If my problem is not making sense just let me know and I'll find another way to ask...

queen notch
#

Unfortunately, the API throws an error when I try to pass the payment method ID with the customer details and it tells me it can't accept the payment method because there is already a customer attached to it
Can you share an example? There will be a Stripe req_xxx ID somewhere for this

edgy swift
#

bear with me. I haven't been testing in a while. I'll see if I can force an error here...

queen notch
#

But depending on the API requests you're making, what that error describes is accurate: if the PM is attached to another Stripe customer and/or it has been used previously without being attached then it cannot be used in some scenarios

#

If you can provide the API request and params you use, or an example ID then I can confirm

#

My question is, is this possible? Can I get a payment intent and a payment method id without actually making the payment? The remote API can I think make the final request for payment as our Stripe account is attached to their system. Does this make any more sense to you?
Overall yes, but it's not clear to me on what it is you're trying to do yet. Sounds like you just want to collect their payment details and save them without a payment?

edgy swift
#

Ok. Stand by and I'll make a request via Thunder Client in VS Code here. Back in a sec...

#

Is it secure to show pm_ id/payment proider ids etc. here or is this visible to all?

queen notch
#

Stripe IDs are fine yes, they're anonymous without your keys

edgy swift
#

Here's the error from the remote API:
Request from me:
{
"guestId": "redacted",
"stripeCardToken": "pm_redacted",
"skipSetupIntent": true,
"paymentProviderId": "redacted",
"reuse": true
}
Response:
{
"error": "This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.",
"code": "HTTP_UPSTREAM_REQUEST_ERROR",
"createTokenError": true
}
I was using the payment method attached to this test payment: req_6bx2hoZQly5NIB

#

The payment was successful. It's a test payment of 10 Euro

queen notch
#

So somewhere your integration is making that API call which is trying to attach a pm_xxx to a cus_xxx, but it's already attached to a different cus_xxx โ€“ they can't be attached to multiple different Customer objects

edgy swift
#

Ok, so that request id is probably coming from Guesty, using the information I'm sending them. I think my problem is that I'm not very clear what I'm expected to do. The remote API is asking for a payment method, and maybe THEY are trying to make the payment request? That's what makes me think that I should try and get a payment method id from Stripe, before the actual payment is made. Does that sound reasonable, and is that even possible?

wraith driftBOT
edgy swift
#

The pattern for the remote API is.

  1. Make a new customer (if they don't already exist)
  2. Attach a payment method to the customer
  3. Send the appropriate property data along with the from and to date of the customer rental period
queen notch
#

Yeah then your remote API needs to be reconfigured. Seems like it's naively jus trying to attach the PM to a customer without first checking if it's already attached

edgy swift
#

they're a pretty big company. I would imagine I'm not the only client of theirs doing this... but I could be wrong...

#

'Option 1' is the Stripe specific instruction

queen notch
#

OK so looks like what you're ultimately doing is:

  1. Creating and confirm and intent. Example: https://dashboard.stripe.com/payments/p_3OuYqXLbtdY4uA1h38w89VjJ
  2. Creating a Customer: https://dashboard.stripe.com/logs/req_djL2V9I8cXg449
  3. Attempting to attach pm_xxx from 1 to the Customer from 2: https://dashboard.stripe.com/logs/req_tclTxeBIA9wtZc
#

The issue is that the pm_xxx is 'consumed' (they're one-time use only by default) by step 1

#

So you can't then attach it after the payment. The error phrasing is slightly inaccurate

#

If the intention is to save the card during/after payment (which is what that flow is), then you should be doing it in reverse:

  1. Create a Customer
  2. Provide cus_xxx and setup_future_usage when creating the intent
  3. Confirm the intent โ€“ payment succeeds and save is saved
#

Now you're working with a third-party, so I've no idea how much control you have over this but ultimately you/they should be adapting the integration to do what I outlined

edgy swift
#

1 - 3 makes logical sense to me. I think I have a ways to go yet, but I think I understand what you're saying. Ok, many thanks for the input. I'll also get back on to Guesty API support and see if this makes sense to them too. I mean, they wrote the API right? ๐Ÿ™‚
Thanks for the help and sorry it was so confusing. I need a cup of tea after this!!

queen notch
#

No problem, glad I could help! Hope you get sorted