Stripe Tokenization Flow
Tokenize the credit card in Stripe to use it for guest payment.
Overview
There are three primary steps to creating a guest payment method for reservations.
- Determine the integrated payment processor account that is assigned to the listing.
- Collect and tokenize the guest's credit card.
- Create the guest payment method.
Connect a Stripe Account
Before Guesty can process Stripe payments for bookings, a Stripe account must be connected to your Guesty account. Learn more.
Step 1: Retrieve the Payment Processor ID
The payment method token must come from the same payment processor account integrated with your Guesty account and assigned to the relevant listing. Use the following request to discover the paymentProviderId
:
The payload will return a paymentProviderId
parameter with the required ID for the tokenization request.
Example
Request
curl --location --globoff 'https://open-api.guesty.com/v1/payment-providers/provider-by-listing?listingId={listingId}'
Response
{
"_id": "<processorIntegrationId>",
"connectedAt": "2020-10-25T15:23:20.486Z",
"status": "ACTIVE",
"syncedAt": "2022-05-16T13:34:24.227Z",
"lastPendingPaymentDate": null,
"pendingPaymentsCount": 0,
"paymentMethodsCount": 0,
"accountId": "<stringId>",
"providerAccountId": "acct_<stringId>",
"isDefault": false,
"providerType": "stripe",
"connectedBy": "<[email protected]/user>",
"accountName": "Stripe Account Name",
"defaultCurrency": "usd",
"statsLastUpdated": "2022-03-29T17:51:01.149Z",
"merchantName": "Display Name",
"paymentProcessorId": "<stringId>",
"paymentProcessorKey": "STRIPE",
"isGroupDefault": false,
"paymentProcessorName": "Stripe",
"paymentProviderId": "<stringId>",
"fallbackToDefault": false
}
You can see from the response that the payment processor is stripe
and its provider ID can be found under the paymentProviderId
field.
Step 2: Tokenize the Guest's Card
Generate a payment method token from the connected Stripe account assigned to the Guesty listing. You will need to develop your own integration with your application for this purpose.
Note
Take care to create only the payment token in Stripe, and not the customer (guest). Guesty will create the guest the first time it charges the card.
Step 3: Create the Guest Payment Method
This action is part of the second step of the Open API's booking process. You will use the token you've generated to create the payment method. For a detailed explanation and examples, see Create a Guest and Payment Method.
Troubleshooting
The reservation was created without a payment method
This may be due to either of the following:
- The credit card was tokenized in a different payment processor account than the one assigned to the listing. Determine the correct account using the Get payment provider by listing and Get provider stats.
- The payment processor or credit card issuer reported an issue. Check your payment processor extranet for error messages and see our Help Center troubleshooting articles.
How can I be sure the payment method succeeded?
Retrieve the reservation object. Its payload will show the payment method object nested under the money.payments
section.
Stripe Payment Error: This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer and may not be used again.
This occurred because you created the guest in Stripe. This attaches that customer to the payment method, causing an error when Guesty attempts to attach it with the customer recorded in Guesty. You should only create the guest in Guesty.
Correct this by implementing the following:
- Omit the pre-charge and subscribe to the payment.failed webhook to monitor for failed payments on the reservations.
- Tokenize the card again after you have completed the check and send Guesty a fresh pm token
Updated 4 months ago