Payment for shipment created in the offer mode
POST /v1/shipments/:shipment/buy
Parameters
Parameter | Type | Description | Validation |
---|---|---|---|
offer_id | integer | ID of the offer, which is available for paid shipment. | Attribute is required
|
Request example
POST /v1/shipments/12345/buy HTTP/1.1 Host: api-shipx-pl.easypack24.net Content-Type: application/json Authorization: Bearer lkfjasd9f70y43ohriw...[ommited for brevity]... { "offer_id": 1456 }
In response, the server returns 200 status with the object of the shipment.
HTTP/1.1 200 OK Content-Type: application/json { "href": "https://api-shipx-pl.easypack24.net/v1/organizations/1/shipments/1234567890", "id": "1234567890", "parcels": [ { "id": "small package", "template": "small", "dimensions": { "length": "80", "width": "360", "height": "640", "unit": "mm" }, "weight": { "amount": "25", "unit": "kg" }, "tracking_number": null } ], "custom_attributes": { "target_point": "KRA010", "dropoff_point": null, "sending_method": "parcel_locker", "dispatch_order_id": 1 }, "sender": { "id": "123", "name": "Nazwa", "company_name": "InPost S.A.", "first_name": "Jan", "last_name": "Nowak", "email": "sender@email.com", "phone": "888000000", "address": { "id": "123", "street": "Malborska", "building_number": "130", "city": "Kraków", "post_code": "30-624", "country_code": "PL" } }, "receiver": { "id": "123", "name": "Nazwa", "company_name": null, "first_name": null, "last_name": null, "email": "sender@email.com", "phone": "888000000", "address": null }, "created_at": "2015-09-06T19:21:00.000+02:00", "cod_amount": { "amount": 12.50, "currency": "PLN" }, "insurance": { "amount": 25, "currency": "PLN" }, "reference": "Order No. 12345", "is_return": false, "tracking_number": null, "external_customer_id": "8877xxx", "offers": [ { "id": 1456, "carrier": { "id": "inpost_locker", "name": "InPost Paczkomaty", "description": "InPost Paczkomaty - Przesyłki paczkomatowe." }, "service": { "id": "inpost_locker_standard", "name": "Paczkomatowa Standardowa", "description": "Przesyłka paczkomatowa standardowa." }, "status": "selected", "valid_to": null, "rate": 2.02, "currency": "PLN", "unavailability_reasons": null } ], "selected_offer": { "id": 1456, "carrier": { "id": "inpost_locker", "name": "InPost Paczkomaty", "description": "InPost Paczkomaty - Przesyłki paczkomatowe." }, "service": { "id": "inpost_locker_standard", "name": "Paczkomatowa Standardowa", "description": "Przesyłka paczkomatowa standardowa." }, "status": "selected", "valid_to": null, "rate": 2.02, "currency": "PLN", "unavailability_reasons": null }, "transactions": [] }
After choosing the offer, other not selected offers are removed.
Caution! Asynchronous operation.
Since the purchase of shipment is asynchronous, the server will return details of the shipment, not taking into account the changes caused by the purchase (status change, assigning transport number), as this information will only be available after a certain time.
To obtain information about the successful purchase of the shipment, define in the organization settings the url address for sending information on shipment_confirmed
. This makes ShipX application to send the following information to the provided address:
POST https://{{adres_podany_w_konfiguracji}} Content-Type: application/json { "event_ts":"2015-12-08 19:42:42 +0100", "event":"shipment_confirmed", "organization_id":1, "payload": { "shipment_id":1234567890, "tracking_number":"681549342531876019900138" } }
List of errors that may occur when paying for shipment:
resource_not_found
- may occur when a specific shipment does not exist or when the user has no access tooffer_unavailable
- occurs when an attempt is made to pay for the offer with status other thanavailable
orselected
,transaction_failed
- may occur when attempt to pay for shipment failed,offer_expired
- the offer cannot be purchased because it has expired (offers are valid for 5 minutes after their preparation)