{"_id":"54cc2149380ecd0d00ca18c1","category":{"_id":"54cc2149380ecd0d00ca18b2","project":"5436a1e1d0ffee0e00f18f8c","__v":2,"version":"54cc2148380ecd0d00ca18aa","pages":["54cc2149380ecd0d00ca18bc","54cc2149380ecd0d00ca18bd","54cc2149380ecd0d00ca18be","54cc2149380ecd0d00ca18bf","54cc2149380ecd0d00ca18c0","54cc2149380ecd0d00ca18c1","54cc2149380ecd0d00ca18c2","55cbcc534cf2180d00bb1bf4"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-30T14:26:30.616Z","from_sync":false,"order":7,"slug":"php-client","title":"PHP client"},"project":"5436a1e1d0ffee0e00f18f8c","user":"5436a1afb7cf0e1c0020d9ca","__v":0,"parentDoc":null,"version":{"_id":"54cc2148380ecd0d00ca18aa","__v":2,"forked_from":"5436a1e1d0ffee0e00f18f8f","project":"5436a1e1d0ffee0e00f18f8c","createdAt":"2015-01-31T00:26:48.753Z","releaseDate":"2015-01-31T00:26:48.753Z","categories":["54cc2149380ecd0d00ca18ab","54cc2149380ecd0d00ca18ac","54cc2149380ecd0d00ca18ad","54cc2149380ecd0d00ca18ae","54cc2149380ecd0d00ca18af","54cc2149380ecd0d00ca18b0","54cc2149380ecd0d00ca18b1","54cc2149380ecd0d00ca18b2","54cc2149380ecd0d00ca18b3","552f29ca633a5b0d00e99d09"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.1.0","version":"1.1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-30T14:32:04.171Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"never","params":[],"url":""},"isReference":false,"order":5,"body":"Sometimes an e-commerce system will mark an order as shipped outside of the ShippingEasy system. Therefore an API call is required to remove this order from ShippingEasy so that it is not double-shipped.\n\nFirst create a new cancellation object with your store's API key and the e-commerce order identifier used to create the order in ShippingEasy:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$cancellation = new ShippingEasy_Cancellation(\\\"d8821dde1d32f408def40b77273d5c11\\\", \\\"ABC123\\\");\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nThen simply call create to execute the remote call:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n$cancellation->create();\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nIf successful the call will return a JSON hash with the ShippingEasy order ID, as well as the external order identifier originally supplied in your call.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{ \\\"order\\\" => { \\\"id\\\" => \\\"27654\\\", \\\"external_order_identifier\\\" => \\\"ABC123\\\" } }\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Possible Exceptions\"\n}\n[/block]\n## ShippingEasy_AuthenticationError\nYour credentials could not be authenticated.\n\n## ShippingEasy_InvalidRequestError\nThe cancellation could not complete for one or more of the following reasons:\n\n* The order could not be found.\n* The order has already been marked as shipped in the ShippingEasy system and cannot be cancelled.\n\nThe exception will contain a message that indicates which of these conditions failed.","excerpt":"","slug":"canceling-an-order-1","type":"basic","title":"Canceling an order"}

Canceling an order


Sometimes an e-commerce system will mark an order as shipped outside of the ShippingEasy system. Therefore an API call is required to remove this order from ShippingEasy so that it is not double-shipped. First create a new cancellation object with your store's API key and the e-commerce order identifier used to create the order in ShippingEasy: [block:code] { "codes": [ { "code": "<?php\n$cancellation = new ShippingEasy_Cancellation(\"d8821dde1d32f408def40b77273d5c11\", \"ABC123\");", "language": "php" } ] } [/block] Then simply call create to execute the remote call: [block:code] { "codes": [ { "code": "<?php\n$cancellation->create();", "language": "php" } ] } [/block] If successful the call will return a JSON hash with the ShippingEasy order ID, as well as the external order identifier originally supplied in your call. [block:code] { "codes": [ { "code": "{ \"order\" => { \"id\" => \"27654\", \"external_order_identifier\" => \"ABC123\" } }", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "Possible Exceptions" } [/block] ## ShippingEasy_AuthenticationError Your credentials could not be authenticated. ## ShippingEasy_InvalidRequestError The cancellation could not complete for one or more of the following reasons: * The order could not be found. * The order has already been marked as shipped in the ShippingEasy system and cannot be cancelled. The exception will contain a message that indicates which of these conditions failed.