{"_id":"58112e72ded0340f0085d03e","__v":0,"category":{"_id":"58112e72ded0340f0085d032","project":"551e85be610f400d00837db7","__v":0,"version":"58112e71ded0340f0085d02a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-08-17T19:28:09.961Z","from_sync":false,"order":7,"slug":"merchant-api-methods","title":"Merchant API Methods"},"parentDoc":null,"version":{"_id":"58112e71ded0340f0085d02a","project":"551e85be610f400d00837db7","__v":4,"createdAt":"2016-10-26T22:30:09.862Z","releaseDate":"2016-10-26T22:30:09.862Z","categories":["58112e72ded0340f0085d02b","58112e72ded0340f0085d02c","58112e72ded0340f0085d02d","58112e72ded0340f0085d02e","58112e72ded0340f0085d02f","58112e72ded0340f0085d030","58112e72ded0340f0085d031","58112e72ded0340f0085d032","58112e72ded0340f0085d033","58112e72ded0340f0085d034","581137cc604d3c230048b7e4","58dc367221742d0f00a73f98","590768e54669da0f00db5c0b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"new designer","version_clean":"2.0.0","version":"2.0"},"project":"551e85be610f400d00837db7","user":"55f2fd49b5b25021002b7dfd","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-25T18:57:24.814Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":12,"body":"See the  [Transaction data model](doc:transaction) for a list of properties and available filters.\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/transactions/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint list\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/transactions/{trans_id}\\n  </span>\\n</div>\"\n}\n[/block]\n# List transactions\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/transactions/\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({     \\n  url: 'https://api.cratejoy.com/v1/transactions/',\\n  method: 'GET'\\n});\",\n      \"language\": \"javascript\",\n      \"name\": \"List\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"count\\\": 22, \\n  \\\"next\\\": \\\"?page=1\\\", \\n  \\\"prev\\\": null, \\n  \\\"results\\\": [\\n    {\\n      \\\"created_at\\\": \\\"2015-09-15T20:00:24Z\\\", \\n      \\\"id\\\": 75572233, \\n      \\\"is_test\\\": true, \\n      \\\"order\\\": {...}, // Order resource\\n      \\\"result\\\": \\\"captured\\\", \\n      \\\"total\\\": 1200, \\n      \\\"url\\\": \\\"/v1/transactions/75572233/\\\"\\n    } ]\\n}\",\n      \"language\": \"json\",\n      \"name\": \"200 OK\"\n    }\n  ]\n}\n[/block]\n# Get a transaction\n[block:html]\n{\n  \"html\": \"<div class=\\\"endpoint\\\">\\n  <span class=\\\"method get\\\">GET</span>\\n  <span class=\\\"uri\\\">\\n    http://api.cratejoy.com/v1/transactions/{trans_id}\\n  </span>\\n</div>\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$.ajax({     \\n  url: 'https://api.cratejoy.com/v1/transactions/75572233/',\\n  method: 'GET'\\n});\\n\",\n      \"language\": \"javascript\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n## How transactions relate to orders\n\nTransactions have a one-to-many relationship to orders. A transaction represents an attempted payment, a successful payment, an attempted refund, or a successful refund that can all map to a single order ID.\n\n**Example #1: Standard Order**\nSubscriber pays for order ID #001 and payment goes through successfully. \nResult: 1 transaction for order ID 001, enum result is `captured`, integer result is `2`.\n\n**Example #2: Multiple payment attempts**\nSubscriber pays for order ID #002 but payment fails. Subscriber tries a different card that succeeds. \nResult: 2 transactions for order ID 002:\n* One transaction has enum result `captured`, integer result `2`\n* One transaction has enum result `failed`, integer result `3`\n\n**Example #3: Standard order, with a partial refund**\nSubscriber pays for order ID #003. Later, seller partially refunds the order.\nResult: 2 transactions for order ID 003:\n* One transaction has enum result `captured`, integer result `2`\n* One transaction has enum result `refunded`, integer result `4`, with `total` as the refunded amount.","excerpt":"","slug":"transaction-methods","type":"basic","title":"Transaction Methods"}

Transaction Methods


See the [Transaction data model](doc:transaction) for a list of properties and available filters. [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/transactions/\n </span>\n</div>" } [/block] [block:html] { "html": "<div class=\"endpoint list\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/transactions/{trans_id}\n </span>\n</div>" } [/block] # List transactions [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/transactions/\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({ \n url: 'https://api.cratejoy.com/v1/transactions/',\n method: 'GET'\n});", "language": "javascript", "name": "List" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"count\": 22, \n \"next\": \"?page=1\", \n \"prev\": null, \n \"results\": [\n {\n \"created_at\": \"2015-09-15T20:00:24Z\", \n \"id\": 75572233, \n \"is_test\": true, \n \"order\": {...}, // Order resource\n \"result\": \"captured\", \n \"total\": 1200, \n \"url\": \"/v1/transactions/75572233/\"\n } ]\n}", "language": "json", "name": "200 OK" } ] } [/block] # Get a transaction [block:html] { "html": "<div class=\"endpoint\">\n <span class=\"method get\">GET</span>\n <span class=\"uri\">\n http://api.cratejoy.com/v1/transactions/{trans_id}\n </span>\n</div>" } [/block] [block:code] { "codes": [ { "code": "$.ajax({ \n url: 'https://api.cratejoy.com/v1/transactions/75572233/',\n method: 'GET'\n});\n", "language": "javascript", "name": null } ] } [/block] ## How transactions relate to orders Transactions have a one-to-many relationship to orders. A transaction represents an attempted payment, a successful payment, an attempted refund, or a successful refund that can all map to a single order ID. **Example #1: Standard Order** Subscriber pays for order ID #001 and payment goes through successfully. Result: 1 transaction for order ID 001, enum result is `captured`, integer result is `2`. **Example #2: Multiple payment attempts** Subscriber pays for order ID #002 but payment fails. Subscriber tries a different card that succeeds. Result: 2 transactions for order ID 002: * One transaction has enum result `captured`, integer result `2` * One transaction has enum result `failed`, integer result `3` **Example #3: Standard order, with a partial refund** Subscriber pays for order ID #003. Later, seller partially refunds the order. Result: 2 transactions for order ID 003: * One transaction has enum result `captured`, integer result `2` * One transaction has enum result `refunded`, integer result `4`, with `total` as the refunded amount.