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

Using [ in ticket names created with Camptix causes an error with the Stripe API. #1270

Closed
hideokamoto opened this issue Mar 18, 2024 · 1 comment · Fixed by #1271
Closed

Comments

@hideokamoto
Copy link
Contributor

Describe the bug

When using Stripe payment for ticket purchases in Camptix, if the ticket name contains [, an error occurs in the Stripe API response. This is because the Stripe API specification interprets the string inside [] as an object key. To resolve this issue, the clean_metadata function needs to replace [] with another character like ().

To reproduce

  • Create a new ticket and include the [ string, e.g., 6/2 – Micro Sponsor [ 10USD ]
  • Enable Camptix Stripe Payment (it's okay to use sandbox mode)
  • Try to order this ticket from the Ticket page
  • You will encounter an error when creating a new Stripe Checkout Session

Expected behavior

The ticket name needs to be included in the metadata of the Stripe Payment Intent object when creating Stripe Checkout Sessions API.
e.g.: $args['payment_intent_data']['metadata']['6/2 [Sponsor ticket]'] = '1';

**Expected Behavior
The ticket name needs to be included in the metadata of the Stripe Payment Intent object when creating Stripe Checkout Sessions API.
e.g.: $args['payment_intent_data']['metadata']['6/2 [Sponsor ticket]'] = '1';

Actual Behavior**

Due to the Stripe API specification, a text inside the [] will be converted to an object key like the following:

$args['payment_intent_data']['metadata']['6/2 [Sponsor ticket]'] = '1';
->
{
  "metadata": {
    "6/2": {
      "Sponsor ticket": "1"
    }
  }
}

Suggestion
In the clean_metadata function, we may need to replace the [] string with another character like () instead.

$key = $this->trim_string( $key, 40, '' );
$key = str_replace( '[', '(', str_replace( ']', ')', $key ) );

When we avoid passing the [] string as the key of the metadata, the Stripe API request will work correctly.

This idea seems reasonable, and if you approve, I'll proceed with creating a new pull request for this.

Screenshots

If applicable, add screenshots to help explain your problem.

スクリーンショット 2024-03-18 16 38 23

WordCamp

If this is a problem on a specific WordCamp's site, list the site or page URL here.

At the WordCamp Kansai 2024, we suffered from this error:
https://kansai.wordcamp.org/2024/wp-admin/post.php?post=3772&action=edit

スクリーンショット 2024-03-18 16 39 59

System (please complete the following information):

  • Device: [e.g. laptop, iPhone6]
  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Security Issues

To report a security issue, please visit the WordPress HackerOne program: https://hackerone.com/wordpress.

@dd32
Copy link
Member

dd32 commented Mar 19, 2024

I think this is something that needs to be raised with Stripe, as to whether it's a bug on their platform, as using square brackets in their UI also results in a.. less than expected, unexpected request error.

Screen.Recording.2024-03-19.at.11.50.17.AM.mov

I've raised a support ticket with them, as [] are not documented as being invalid in the field.

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 a pull request may close this issue.

2 participants