balanced / balanced-ruby

Balanced API library in ruby.
MIT License
111 stars 47 forks source link

Balanced::Debit.new results in Balanced::InternalServerError #166

Closed jbrowning closed 10 years ago

jbrowning commented 10 years ago

Gem version: 1.0.1

According to the documentation, a Debit may be created with the following parameters:

However, doing so with Balanced::Debit.new results in an Balanced::InternalServerError being raised:

> debit = Balanced::Debit.new amount: 10_00, source: "cards/CCiVHG5s4hbqNYDS6nSvSZ0"
> debit.save
Balanced::InternalServerError: Balanced::InternalServerError
from ...gems/balanced-1.0.1/lib/balanced/response/balanced_exception_middleware.rb:41:in `on_complete'
mjallday commented 10 years ago

We have a pull-request waiting to be merged that will fix this. Hopefully it will be out today or Monday.

mjallday commented 10 years ago

This has been resolved.

| => curl https://api.balancedpayments.com/cards \
| =>  -H "Accept: application/vnd.api+json;revision=1.1" \
| =>  -d "expiration_month=12" \
| =>  -d "cvv=123" \
| =>  -d "number=5105105105105100" \
| =>  -d "expiration_year=2020"
{
  "cards": [
    {
      "href": "/cards/CC579lUEJJbzytyfPWyK3rRU",
      "id": "CC579lUEJJbzytyfPWyK3rRU",
      "links": {}
    }
  ],
  "links": {}

BEFORE

| => curl https://api.balancedpayments.com/debits \
| =>  -H "Accept: application/vnd.api+json;revision=1.1" \
| =>  -u ak-test-XWwrkAngK60JtzWSvvKq4pjtm5ecCdjq: \
| =>  -d "source=/cards/CC4fGuwva3w8mshJ3J5g6cPI" \
| =>  -d "amount=500"
{
  "status": "Internal Server Error",
  "status_code": 500,
  "description": "Sorry, something has gone wrong. Your request id is OHMbe6c63a0cafd11e39fc902b12035401b.",
  "request_id": "OHMbe6c63a0cafd11e39fc902b12035401b"

AFTER

 curl https://api.balancedpayments.com/debits  -H "Accept: application/vnd.api+json;revision=1.1"  -u ak-test-XWwrkAngK60JtzWSvvKq4pjtm5ecCdjq:  -d "source=/cards/CC579lUEJJbzytyfPWyK3rRU"  -d "amount=500"
{
  "debits": [
    {
      "status": "succeeded",
      "description": null,
      "links": {
        "customer": null,
        "source": "CC579lUEJJbzytyfPWyK3rRU",
        "order": null,
        "dispute": null
      },
      "updated_at": "2014-04-23T16:42:48.197061Z",
      "created_at": "2014-04-23T16:42:47.390211Z",
      "transaction_number": "W647-436-3920",
      "failure_reason": null,
      "currency": "USD",
      "amount": 500,
      "failure_reason_code": null,
      "meta": {},
      "href": "/debits/WD2lm1Hgvx5r9Hsu1gvikgVn",
      "appears_on_statement_as": "BAL*example.com",
      "id": "WD2lm1Hgvx5r9Hsu1gvikgVn"
    }
  ],
  "links": {
    "debits.customer": "/customers/{debits.customer}",
    "debits.dispute": "/disputes/{debits.dispute}",
    "debits.source": "/resources/{debits.source}",
    "debits.order": "/orders/{debits.order}",
    "debits.refunds": "/debits/{debits.id}/refunds",
    "debits.events": "/debits/{debits.id}/events"
  }
}