Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid client_reference_id composition #854

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

ledermann
Copy link
Contributor

I've been trying to integrate the Stripe pricing table without success. I realized that the current method Pay::Stripe.to_client_reference_id is creating an invalid string. It includes a forward slash (like User/42), which isn't allowed according to Stripe's docs:

The web component supports setting the client-reference-id property. When the property is set, the pricing table passes it to the Checkout Session’s client_reference_id attribute to help you reconcile the Checkout Session with your internal system. This can be an authenticated user ID or a similar string. client-reference-id can be composed of alphanumeric characters, dashes, or underscores, and be any value up to 200 characters. Invalid values are silently dropped and your pricing table will continue to work as expected.

Source: https://stripe.com/docs/payments/checkout/pricing-table#handle-fulfillment-with-the-stripe-api

The resulting webhook checkout.session.completed then contains client_reference_id: null, so the client cannot be found.

I changed the implementation to use an underscore instead of the slash (like User_42).

References: #670, #823

A slash is not allowed, so we use an underscore

From the Stripe docs:

client-reference-id can be composed of alphanumeric
characters, dashes, or underscores, and be any value
up to 200 characters.
@excid3 excid3 merged commit 91c3edc into pay-rails:master Oct 17, 2023
33 checks passed
@ledermann ledermann deleted the fix-invalid-client_reference_id branch October 18, 2023 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants