Skip to content

Instantly share code, notes, and snippets.

@mjallday
Created November 21, 2013 21:07
Show Gist options
  • Save mjallday/7589639 to your computer and use it in GitHub Desktop.
Save mjallday/7589639 to your computer and use it in GitHub Desktop.
Failed debit creates transaction

curl https://api.balancedpayments.com/debits -XPOST -u ak-test-2yK59ihwoOOk0S6wsg77iMGzLGnGxiohB: -d "source[number]=4444444444444448" -d "source[expiration_month]=12" -d "source[expiration_year]=2016" -d amount=100

{
  "errors": [
    {
      "status": "Payment Required",
      "category_code": "card-declined",
      "additional": "Account Frozen",
      "status_code": 402,
      "category_type": "banking",
      "extras": {},
      "request_id": "OHMae9c06eb52f011e38f2f10ddb1bbaf41",
      "description": "R758: Account Frozen. Your request id is OHMae9c06eb52f011e38f2f10ddb1bbaf41."
    }
  ],
  "links": {
    "debits.source": "/resources/{debits.source}",
    "debits.customer": "/customers/{debits.customer}",
    "debits.order": "/orders/{debits.order}",
    "debits.refunds": "/debits/{debits.id}/refunds",
    "debits.events": "/debits/{debits.id}/events"
  },
  "debits": [
    {
      "status": "failed",
      "description": null,
      "links": {
        "customer": "CU6wJUpqcVWf2JwgyfIsRy1z",
        "source": "CC5jBQ5WVtQidKXclIicdodz",
        "order": null
      },
      "href": "/debits/WD5jEFyCkaYCRtsJ328UhwEp",
      "created_at": "2013-11-21T21:05:42.792888Z",
      "updated_at": "2013-11-21T21:05:43.469758Z",
      "failure_reason": "R758: Account Frozen.",
      "currency": "USD",
      "amount": 100,
      "failure_reason_code": null,
      "meta": {},
      "appears_on_statement_as": "BAL*example.com",
      "id": "WD5jEFyCkaYCRtsJ328UhwEp"
    }
  ]
}

These failed transactions are hidden by default but can be found by explicitly querying for them

curl https://api.balancedpayments.com/debits?status=failed -u ak-test-2yK59ihwoOOk0S6wsg77iMGzLGnGxiohB:

{
  "meta": {
    "last": "/debits?status=failed&limit=10&offset=0",
    "next": null,
    "href": "/debits?status=failed&limit=10&offset=0",
    "limit": 10,
    "offset": 0,
    "previous": null,
    "total": 1,
    "first": "/debits?status=failed&limit=10&offset=0"
  },
  "links": {
    "debits.customer": "/customers/{debits.customer}",
    "debits.order": "/orders/{debits.order}",
    "debits.refunds": "/debits/{debits.id}/refunds",
    "debits.events": "/debits/{debits.id}/events",
    "debits.source": "/resources/{debits.source}"
  },
  "debits": [
    {
      "status": "failed",
      "description": null,
      "links": {
        "customer": "CU6wJUpqcVWf2JwgyfIsRy1z",
        "source": "CC5jBQ5WVtQidKXclIicdodz",
        "order": null
      },
      "href": "/debits/WD5jEFyCkaYCRtsJ328UhwEp",
      "created_at": "2013-11-21T21:05:42.792888Z",
      "updated_at": "2013-11-21T21:05:43.469758Z",
      "failure_reason": "R758: Account Frozen.",
      "currency": "USD",
      "amount": 100,
      "failure_reason_code": null,
      "meta": {},
      "appears_on_statement_as": "BAL*example.com",
      "id": "WD5jEFyCkaYCRtsJ328UhwEp"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment