#primodirective_api
1 messages ยท Page 1 of 1 (latest)
๐ 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.
I don't understand the question. Can you share an ID that demonstrates the issue you describe?
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?
Sure
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?
I've no idea
If you can share some code and convey the problem you're experiencing, that might help
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...
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 Stripereq_xxxID somewhere for this
bear with me. I haven't been testing in a while. I'll see if I can force an error here...
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?
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?
Stripe IDs are fine yes, they're anonymous without your keys
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
OK, it's actually this request that errors: https://dashboard.stripe.com/logs/req_tclTxeBIA9wtZc
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
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
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?
The pattern for the remote API is.
- Make a new customer (if they don't already exist)
- Attach a payment method to the customer
- Send the appropriate property data along with the from and to date of the customer rental period
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
they're a pretty big company. I would imagine I'm not the only client of theirs doing this... but I could be wrong...
Here is their public facing API notes and specifically 'Create payment method', Option 1 in case it adds anything of use:
https://open-api-docs.guesty.com/reference/post_guests-id-payment-methods
'Option 1' is the Stripe specific instruction
OK so looks like what you're ultimately doing is:
- Creating and confirm and intent. Example: https://dashboard.stripe.com/payments/p_3OuYqXLbtdY4uA1h38w89VjJ
- Creating a Customer: https://dashboard.stripe.com/logs/req_djL2V9I8cXg449
- Attempting to attach
pm_xxxfrom 1 to the Customer from 2: https://dashboard.stripe.com/logs/req_tclTxeBIA9wtZc
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
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:
- Create a Customer
- Provide
cus_xxxandsetup_future_usagewhen creating the intent - Confirm the intent โ payment succeeds and save is saved
There's a guide for this here: https://docs.stripe.com/payments/save-during-payment
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
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!!
No problem, glad I could help! Hope you get sorted