GetPaymentLink
Pay with POST /api/orders/{orderId}/paywithprepay. There’s no separate call to get a payment link.
What’s different
Section titled “What’s different”GetPaymentLink took a list of shipment IDs and returned a signed link to the Parcel Monkey checkout. On Parcel2Go:
- Payment is per order. To pay for several shipments together, create them as
Itemsin one order. - The create-order response already has the PrePay payment link in
Links.PayWithPrePay. - You pay with PrePay. It’s a single API call, and the order is paid from your Parcel2Go PrePay balance.
Pay with PrePay
Section titled “Pay with PrePay”- Make sure your token has the
paymentscope. See Request a token. - Keep your PrePay balance topped up. Check it with
GET /api/prepay. You can create top-up links withPOST /api/prepay/create-topup-links. - After creating the order, call
POST /api/orders/{orderId}/paywithprepay. The simplest way is to useLinks.PayWithPrePayfrom the create-order response, which is the same URL with the hash already added. - Then get your labels. See Labels.
If payment fails, the response is 400 with a list of Errors, each with a Name and Description.
curl -X POST "https://sandbox.parcel2go.com/api/orders/76423942/paywithprepay" \ -H "Authorization: Bearer $P2G_TOKEN" \ -H "Accept: application/json" \ -H "Content-Length: 0"<?php// $p2g is the client from the Authentication page$result = $p2g->request('POST', '/api/orders/76423942/paywithprepay');{ "Links": [ { "Name": "<link name>", "Link": "https://www.parcel2go.com/..." } ]}Shape only. Swagger says these links include labels and a picking list; read them by Name from the response.
Compare with the Parcel Monkey GetPaymentLink call
curl -X POST "https://api.parcelmonkey.co.uk/GetPaymentLink" \ -H "Content-Type: application/json" \ -H "apiversion: 3.3" \ -H "userid: $PM_USER_ID" \ -H "token: $PM_API_KEY" \ -d '[ "4749253", "4749254"]'<?php$ch = curl_init('https://api.parcelmonkey.co.uk/GetPaymentLink');curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'apiversion: 3.3', 'userid: ' . $pmUserId, 'token: ' . $pmApiKey], CURLOPT_POSTFIELDS => json_encode([ '4749253', '4749254', ]),]);$response = json_decode(curl_exec($ch), true);{ "OrderId": 1234567, "Shipments": [ "4749253", "4749254" ], "url": "https://www.parcelmonkey.co.uk/2falogin.php?UserId=12345&hash=...&return=%2Fcheckout.php%3Fsub%3Dresume%26OrderId%3D1234567"}Field mapping
Section titled “Field mapping”| Parcel Monkey | Parcel2Go | Required | Notes |
|---|---|---|---|
[ShipmentId, ...] | Items[] | Yes | No separate call. To pay for several shipments together, create them as Items in one order. |
| Parcel Monkey | Parcel2Go | Required | Notes |
|---|---|---|---|
OrderId | OrderId | No | |
Shipments | OrderlineIdMap[]. | No | |
url | No link needed. Pay from your PrePay balance with POST /api/orders/{orderId}/paywithprepay (the PayWithPrePay link in the create-order response). The token needs the payment scope. | ||
| New in Parcel2Go | Check PrePay balance; create top-up links (GBP, minimum stated in Swagger). |