svileng/stripy

Change the way how request body is sent out

Closed this issue · 1 comments

At this moment post body is encoded and concatenated in url
see: https://github.com/heresydev/stripy/blob/1.2.1/lib/stripy.ex#L36

If the request contains a large body(>5000 characters), it will be rejected by Stripe with

{
  "body": {
    "error": {
      "message": "Invalid string: Lorem Ipsu...rem Ipsum.; must be at most 5000 characters",
      "param": "line_items[0][description]",
      "type": "invalid_request_error"
    }
  }
}

I belive it is better for https://github.com/heresydev/stripy/blob/1.2.1/lib/stripy.ex#L65 to send out the actual body, rather than just throw everything to the url.

I think this should be a matter of checking if the request is :post and passing the payload in the body, rather than encoding it in the URL.

I don't have much free time to work on this at the moment, so feel free (or anyone else) to send a PR with the relevant changes. I'd be happy to help if anyone needs guidance starting on this.