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

Metadata encoding issue with certain characters #1376

Closed
karlr-stripe opened this issue Nov 8, 2018 · 2 comments
Closed

Metadata encoding issue with certain characters #1376

karlr-stripe opened this issue Nov 8, 2018 · 2 comments

Comments

@karlr-stripe
Copy link
Contributor

karlr-stripe commented Nov 8, 2018

As noted in #1374, if you attempt to create an object in the API with metadata with certain characters(such as #), it results in a malformed request. The API itself accepts these characters so it appears to be an issue with the library. The following code reproduces the problem:

var chargeOptions = new ChargeCreateOptions()
{
   Amount = 2000,
   Currency = "usd",
   SourceId = "tok_visa",
   Metadata = new Dictionary<string, string>{
      {"Invoice #", "42"}
    }
};

ChargeService chargeService = new ChargeService();

Charge charge = chargeService.Create(chargeOptions);
Assert.NotNull(charge);

request ID : req_TSGAWLekqimvqv

It looks like the raw POST data sent is :
amount=2000&currency=usd&metadata[Invoice%20
but it should be
source=tok_visa&amount=1000&currency=usd&metadata%5BInvoice%20%23%5D=42

I'm not sure what the cause here is, maybe the string interpolation?

@ob-stripe
Copy link
Contributor

Thanks Karl. Looks like the key is not URL-encoded.

@ob-stripe
Copy link
Contributor

Fixed in 20.4.1.

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

No branches or pull requests

2 participants