### Get All Users with Go HTTP Client Source: https://documentation.layup.co.za/ This Go program demonstrates how to make a GET request to retrieve all users using the standard net/http package. Note that the request body handling is incomplete in this example. ```go package main import ( "bytes", "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://sandbox-api.layup.co.za/v1/users", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Download Report using Go HTTP Client Source: https://documentation.layup.co.za/ A Go example demonstrating how to make an HTTP GET request to download a settlement report. This snippet shows setting up the request and headers. ```go package main import ( "bytes", "net/http", ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://sandbox-api.layup.co.za/v3/settlements/files/{settlementReferenceWithExtension}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Get Many Order Amendments with Go HTTP Client Source: https://documentation.layup.co.za/ An example using Go's standard 'net/http' package to make a GET request for order amendments. This snippet shows setting up headers and initiating the client request. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://sandbox-api.layup.co.za/v1/order-amendments", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Download Report HTTP Request Example Source: https://documentation.layup.co.za/ An example of an HTTP GET request to download a settlement report. This shows the request line and host header. ```http GET https://sandbox-api.layup.co.za/v3/settlements/files/{settlementReferenceWithExtension} HTTP/1.1 Host: sandbox-api.layup.co.za Accept: application/json ``` -------------------------------- ### Login using Go HTTP client Source: https://documentation.layup.co.za/ Example of making a POST request to the login endpoint using Go's standard net/http package. Note the setup for headers and request body. ```go package main import ( "bytes", "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "https://sandbox-api.layup.co.za/v1/auth/login", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Download Report using Python Requests Source: https://documentation.layup.co.za/ A Python example using the `requests` library to download a settlement report. It shows how to set the necessary headers for the GET request. ```python import requests headers = { 'Accept': 'application/json', 'apikey': 'API_KEY' } r = requests.get('https://sandbox-api.layup.co.za/v3/settlements/files/{settlementReferenceWithExtension}', headers = headers) print(r.json()) ``` -------------------------------- ### Retrieve Order by ID using Go HTTP Client Source: https://documentation.layup.co.za/ This Go code snippet shows how to initiate an HTTP GET request to retrieve order details. It sets up the request headers and prepares to execute the request using the http.Client. Note that the request body handling is minimal in this example. ```go package main import ( "bytes" "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://sandbox-api.layup.co.za/v1/orders/{_id}", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Example 200 Response for GetMany Orders Source: https://documentation.layup.co.za/ This is an example of a successful response when retrieving orders. It includes details about orders, products, and payment plans. ```json { "orders": [ { "_id": "string", "endDateMax": "2019-08-24T14:15:22Z", "endDateMin": "2019-08-24T14:15:22Z", "initiatorId": "string", "products": [ { "_id": "string", "amount": 0, "link": "http://example.com", "sku": "string", "name": "string", "depositType": "string", "travelDate": "string" } ], "state": "PARTIAL", "supplierId": "string", "cancelledBy": "string", "amountDue": 0, "flatFee": 0, "percFee": 0.1, "depositPerc": 0.1, "reference": "string", "name": "string", "imageUrl": "string", "plans": [ { "_id": "string", "orderId": "string", "benefactorId": "string" ``` -------------------------------- ### Retrieve All Payments (JavaScript Fetch API) Source: https://documentation.layup.co.za/ Example using the Fetch API in JavaScript to get payment data. It configures the request with GET method and necessary headers. ```javascript const headers = { 'Accept':'application/json', 'apikey':'API_KEY' }; fetch('https://sandbox-api.layup.co.za/v1/payments', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Create Order using Go HTTP Client Source: https://documentation.layup.co.za/ An example in Go demonstrating how to create an order using the standard 'net/http' package. It shows setting up headers and making the POST request. ```go package main import ( "bytes", "net/http", ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "https://sandbox-api.layup.co.za/v1/orders", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Retrieve All Payments (Go HTTP Client) Source: https://documentation.layup.co.za/ An example in Go using the net/http package to fetch payment data. Note that the `jsonReq` variable and error handling are omitted for brevity. ```go package main import ( "bytes", "net/http", ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://sandbox-api.layup.co.za/v1/payments", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Retrieve Settlements with Go (net/http) Source: https://documentation.layup.co.za/ Demonstrates making an HTTP GET request to retrieve settlements using Go's standard net/http package. Note that the request body is not typically used for GET requests. ```go package main import ( "bytes", "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://sandbox-api.layup.co.za/v3/settlements", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Example 200 Response for Order Retrieval Source: https://documentation.layup.co.za/ This is an example of a successful response (200 OK) when retrieving an order. It details the structure of the order object, including product information, payment plans, and associated fees. Note that all currency values are in cents. ```json { "_id": "string", "endDateMax": "2019-08-24T14:15:22Z", "endDateMin": "2019-08-24T14:15:22Z", "initiatorId": "string", "products": [ { "_id": "string", "amount": 0, "link": "http://example.com", "sku": "string", "name": "string", "depositType": "string", "travelDate": "string" } ], "state": "PARTIAL", "supplierId": "string", "cancelledBy": "string", "amountDue": 0, "flatFee": 0, "percFee": 0.1, "depositPerc": 0.1, "reference": "string", "name": "string", "imageUrl": "string", "plans": [ { "_id": "string", "orderId": "string", "benefactorId": "string", "completed": true, "quantity": 0, "depositDue": 0, "amountDue": 0, "automaticBilling": true, "timestamp": 0.1, "payments": [ { "_id": "string", "due": "string", "amount": 0, "paid": true, "timestamp": 0.1, "paymentMethod": "string", "paymentType": "string", "amountExcludingFee": 0, "fee": 0, "pending": true, "failed": true, "reconciliated": true, "refundedAmount": 0, "refundPaymentId": "string", "connectorData": { "_id": "string", "amount": 0, "paymentProviderPaymentId": "string", "paymentReference": "string", "paymentMethod": "string", "paymentProvider": "string", "paymentProviderResponses": {} }, "verifiedAt": "string", "dueAt": "string" } ], "benefactor": { "_id": "string", "name": "string", "email": "string" }, "frequency": "WEEKLY", "offset": 0, "depositDueExcludingFee": 0, "amountDueExcludingFee": 0, "order": { "_id": "string", "endDateMax": "2019-08-24T14:15:22Z", "endDateMin": "2019-08-24T14:15:22Z", "initiatorId": "string", "products": [ { "_id": "string", "amount": 0, "link": "http://example.com", "sku": "string", "name": "string", "depositType": "string", "travelDate": "string" } ], "state": "PARTIAL", "supplierId": "string", "cancelledBy": "string", "amountDue": 0, "flatFee": 0, "percFee": 0.1, "depositPerc": 0.1, "reference": "string", "name": "string", "imageUrl": "string", "plans": [], "createdAt": "string", "timestamp": 0.1, "enablesSplit": true, "depositAmount": 0, "depositType": "INSTALMENT", "expire": "string", "cancellationTerms": { "active": true, "definition": [ { "type": { "name": "string", "definition": { "missed": 0, "percentage": 0 }, "finalPaymentMissed": true }, "policy": { ``` -------------------------------- ### Create Order using JavaScript Fetch API Source: https://documentation.layup.co.za/ Example of creating an order using the Fetch API in JavaScript. It demonstrates setting up the request body and headers. ```javascript const inputBody = '{ "products": "ProductCreateRequest", "endDateMax": "2019-08-24T14:15:22Z", "depositPerc": 5, "reference": "string", "name": "string", "depositType": "INSTALMENT" }'; const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'apikey':'API_KEY' }; fetch('https://sandbox-api.layup.co.za/v1/orders', { method: 'POST', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Retrieve Merchant by ID using HTTP Request Source: https://documentation.layup.co.za/ This example shows a raw HTTP GET request to retrieve merchant details. It includes the necessary Host and Accept headers. ```http GET https://sandbox-api.layup.co.za/v1/merchants/{_id} HTTP/1.1 Host: sandbox-api.layup.co.za Accept: application/json ``` -------------------------------- ### Login using Python Requests Source: https://documentation.layup.co.za/ Perform a user login using the Python Requests library. This example demonstrates setting up headers for the POST request. ```python import requests headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'apikey': 'API_KEY' } r = requests.post('https://sandbox-api.layup.co.za/v1/auth/login', headers = headers) print(r.json()) ``` -------------------------------- ### Order Send Request Body Example Source: https://documentation.layup.co.za/ This is an example of the JSON body required when sending an order request. It includes fields like amount, payment method, type, order ID, customer ID, and message. ```json { "amount": 10000, "paymentMethod": "CARD", "type": "sms", "orderId": "123f7f1496bd78001d6852f3", "customerId": "123f7f1496bd78001d6852f3", "message": "string" } ``` -------------------------------- ### Get Authenticated User with Go HTTP Client Source: https://documentation.layup.co.za/ This Go code snippet shows how to make a GET request to the /v1/auth/me endpoint using Go's standard 'net/http' package. It demonstrates setting up headers and initiating the client request. ```go package main import ( "bytes", "net/http" ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://sandbox-api.layup.co.za/v1/auth/me", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Example Response for List of Order Amendments Source: https://documentation.layup.co.za/ This is an example JSON response when successfully retrieving a list of order amendments. It includes details such as amendment ID, order ID, type, user, timestamp, and previous/new values. ```json { "orderAmendments": [ { "_id": "amend_125", "orderId": "order_123", "amendmentType": "CHANGE_PRODUCT", "userId": "user_789", "timestamp": "2026-05-07T12:00:00Z", "previousValue": "Product A", "newValue": "Product B" }, { "_id": "amend_126", "orderId": "order_123", "amendmentType": "CANCEL_PRODUCT", "userId": "user_999", "timestamp": "2026-05-08T09:30:00Z", "previousValue": "Product B", "newValue": "Cancelled" } ] } ``` -------------------------------- ### Get All Users with HTTP Request Source: https://documentation.layup.co.za/ This snippet shows the raw HTTP request for retrieving all users. It includes the necessary Host and Accept headers. ```http GET https://sandbox-api.layup.co.za/v1/users HTTP/1.1 Host: sandbox-api.layup.co.za Accept: application/json ``` -------------------------------- ### Send Order Request using Ruby RestClient Source: https://documentation.layup.co.za/ This Ruby example demonstrates sending an order request using the 'rest-client' and 'json' gems. It shows how to configure headers for the POST request. ```ruby require 'rest-client' require 'json' headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'apikey' => 'API_KEY' } result = RestClient.post 'https://sandbox-api.layup.co.za/v1/orders-send-request', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Successful Order Creation Response (200 OK) Source: https://documentation.layup.co.za/ Example of a successful response when an order is created. It includes details of the created order such as its ID, dates, products, and payment plan information. ```json { "_id": "string", "endDateMax": "2019-08-24T14:15:22Z", "endDateMin": "2019-08-24T14:15:22Z", "initiatorId": "string", "products": [ { "_id": "string", "amount": 0, "link": "http://example.com", "sku": "string", "name": "string", "depositType": "string", "travelDate": "string" } ], "state": "PARTIAL", "supplierId": "string", "cancelledBy": "string", "amountDue": 0, "flatFee": 0, "percFee": 0.1, "depositPerc": 0.1, "reference": "string", "name": "string", "imageUrl": "string", "plans": [ { "_id": "string", "orderId": "string", "benefactorId": "string", "completed": true, "quantity": 0, "depositDue": 0, "amountDue": 0, "automaticBilling": true, "timestamp": 0.1, "payments": [ { "_id": "string", "due": "string", "amount": 0, "paid": true, "timestamp": 0.1, "paymentMethod": "string", "paymentType": "string", "amountExcludingFee": 0, "fee": 0, "pending": true, "failed": true, "reconciliated": true, "refundedAmount": 0, "refundPaymentId": "string", "connectorData": { "_id": "string", "amount": 0, "paymentProviderPaymentId": "string", "paymentReference": "string", "paymentMethod": "string", "paymentProvider": "string", "paymentProviderResponses": {} }, "verifiedAt": "string", "dueAt": "string" } ], "benefactor": { "_id": "string", "name": "string", "email": "string" } } ] } ``` -------------------------------- ### Get All Users with cURL Source: https://documentation.layup.co.za/ Use this cURL command to retrieve all users from the API. Ensure you replace 'API_KEY' with your actual API key. ```bash # You can also use wget curl -X GET https://sandbox-api.layup.co.za/v1/users \ -H 'Accept: application/json' \ -H 'apikey: API_KEY' ``` -------------------------------- ### Download Report using JavaScript Fetch API Source: https://documentation.layup.co.za/ Use the Fetch API in JavaScript to download a settlement report. This example demonstrates setting headers and handling the JSON response. ```javascript const headers = { 'Accept':'application/json', 'apikey':'API_KEY' }; fetch('https://sandbox-api.layup.co.za/v3/settlements/files/{settlementReferenceWithExtension}', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Retrieve Order using Ruby RestClient Source: https://documentation.layup.co.za/ This Ruby example utilizes the `rest-client` gem to fetch order data. It defines the necessary headers and parses the JSON response. ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'apikey' => 'API_KEY' } result = RestClient.get 'https://sandbox-api.layup.co.za/v1/orders/reference/{reference}/cellNumber/{cellNumber}', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Increase Instalment Amount Source: https://documentation.layup.co.za/ Modify an existing order to increase the instalment amount without adding new instalments. This example shows a 10% increase. ```bash curl "https://sandbox-api.layup.co.za/v1/orders/$orderId" -X PUT -H 'Content-Type: application/json;charset=utf-8' -H "apikey: $merchantApiKey" \ --data-binary @- << EOF { "products":[{"amount":43000,"sku":"sku-5555","name":"amortiseOnAmend"}] } EOF ``` -------------------------------- ### Create Payment Plan Preview using Go HTTP Client Source: https://documentation.layup.co.za/ This Go program demonstrates how to create a payment plan preview using the standard net/http package. It sets up the request headers and body. ```go package main import ( "bytes", "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "https://sandbox-api.layup.co.za/v1/payment-plan/preview", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Get Many Order Amendments HTTP Request Source: https://documentation.layup.co.za/ An example of an HTTP/1.1 GET request to the sandbox API for retrieving order amendments. This shows the request line and headers. ```http GET https://sandbox-api.layup.co.za/v1/order-amendments HTTP/1.1 Host: sandbox-api.layup.co.za Accept: application/json ``` -------------------------------- ### Get Authenticated User with Ruby RestClient Source: https://documentation.layup.co.za/ This Ruby example utilizes the 'rest-client' and 'json' gems to retrieve authenticated user data. It sets the 'Accept' and 'apikey' headers for the GET request. ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'apikey' => 'API_KEY' } result = RestClient.get 'https://sandbox-api.layup.co.za/v1/auth/me', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Get Many Order Amendments with Ruby RestClient Source: https://documentation.layup.co.za/ Utilize the 'rest-client' and 'json' gems in Ruby to perform a GET request for order amendments. This example shows how to set headers and parse the JSON response. ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'apikey' => 'API_KEY' } result = RestClient.get 'https://sandbox-api.layup.co.za/v1/order-amendments', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Create Payment Plan Preview using cURL Source: https://documentation.layup.co.za/ Use this cURL command to send a POST request to the PaymentPlanService sandbox API to preview payment plans. Ensure you replace 'API_KEY' with your actual API key. ```bash # You can also use wget curl -X POST https://sandbox-api.layup.co.za/v1/payment-plan/preview \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -H "apikey: API_KEY" ``` -------------------------------- ### Get Many Order Amendments with JavaScript Fetch API Source: https://documentation.layup.co.za/ Use the Fetch API in JavaScript to make a GET request to retrieve order amendments. This example includes setting the necessary headers and logging the JSON response. ```javascript const headers = { 'Accept':'application/json', 'apikey':'API_KEY' }; fetch('https://sandbox-api.layup.co.za/v1/order-amendments', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Create Payment Plan Preview using JavaScript Fetch API Source: https://documentation.layup.co.za/ This JavaScript code demonstrates how to use the Fetch API to create a payment plan preview. It sends a POST request with the necessary headers and input body. ```javascript const inputBody = '{ "amountDue": 0, "depositPerc": 0, "endDateMax": "2019-08-24T14:15:22Z", "endDateMin": "2019-08-24T14:15:22Z", "frequency": "WEEKLY", "offset": 0, "depositAmount": 0, "depositType": "INSTALMENT", "flatFee": 0.1, "percFee": 0.1, "paymentPlanId": "string", "quantity": 0 }'; const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'apikey':'API_KEY' }; fetch('https://sandbox-api.layup.co.za/v1/payment-plan/preview', { method: 'POST', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Create Payment Plan Preview using Python Requests Source: https://documentation.layup.co.za/ This Python script uses the 'requests' library to send a POST request to the PaymentPlanService API for creating a payment plan preview. It includes setting up headers. ```python import requests headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'apikey': 'API_KEY' } r = requests.post('https://sandbox-api.layup.co.za/v1/payment-plan/preview', headers = headers) print(r.json()) ``` -------------------------------- ### PaymentPlanService_CreatePreview Source: https://documentation.layup.co.za/ Create a Payment Plan Preview. This endpoint will generate all available payment plans an item can allow, and showcase each Payment Plan's monthly installments. Note: 'endDateMin' and 'endDateMax' should be ISO-8601 Dates. 'amountDue' must be greater than 0. All currency values are stored in cents. ```APIDOC ## POST /v1/payment-plan/preview ### Description Create a Payment Plan Preview. This endpoint will generate all available payment plans an item can allow. This will also showcase each Payment Plan's monthly installments. **Note: 'endDateMin'** and **'endDateMax'** should be ISO-8601 Dates when sent to the API. e.g.: **'2019-02-18T01:02:56.277Z'** **Note: 'amountDue'** must be greater than **0** **Note: All currency values are stored in cents.** ### Method POST ### Endpoint https://sandbox-api.layup.co.za/v1/payment-plan/preview ### Parameters #### Request Body - **amountDue** (number) - Required - The amount due for the payment plan. - **depositPerc** (number) - Optional - The percentage of the deposit. - **endDateMax** (string) - Optional - The maximum end date for the payment plan (ISO-8601 format). - **endDateMin** (string) - Optional - The minimum end date for the payment plan (ISO-8601 format). - **frequency** (string) - Optional - The payment frequency (e.g., WEEKLY). - **offset** (number) - Optional - An offset value. - **depositAmount** (number) - Optional - The amount of the deposit. - **depositType** (string) - Optional - The type of deposit (e.g., INSTALMENT). - **flatFee** (number) - Optional - A flat fee. - **percFee** (number) - Optional - A percentage fee. - **paymentPlanId** (string) - Optional - The ID of the payment plan. - **quantity** (number) - Optional - The quantity. ### Request Example ```json { "amountDue": 0, "depositPerc": 0, "endDateMax": "2019-08-24T14:15:22Z", "endDateMin": "2019-08-24T14:15:22Z", "frequency": "WEEKLY", "offset": 0, "depositAmount": 0, "depositType": "INSTALMENT", "flatFee": 0.1, "percFee": 0.1, "paymentPlanId": "string", "quantity": 0 } ``` ### Response #### Success Response (200) - **amountDue** (number) - The amount due. - **merchant** (string) - The merchant's name. - **merchantTermsLink** (string) - Link to the merchant's terms. - **reference** (string) - A reference identifier. - **orderName** (string) - The name of the order. - **depositDue** (number) - The deposit amount due. - **endDateMax** (string) - The maximum end date. - **imageUrl** (string) - URL of an image. - **enablesSplit** (boolean) - Indicates if split payments are enabled. - **products** (array) - List of products associated with the order. - **_id** (string) - Product ID. - **amount** (number) - Product amount. - **link** (string) - Link to the product. - **sku** (string) - Product SKU. - **name** (string) - Product name. - **depositType** (string) - Product deposit type. - **travelDate** (string) - Product travel date. - **paymentPlans** (array) - List of available payment plans. - **months** (number) - Number of months for the payment plan. - **deposit** (number) - Deposit amount for the payment plan. - **payments** (array) - List of payments within the plan. - **_id** (string) - Payment ID. - **paymentPlanId** (string) - Associated payment plan ID. - **due** (string) - Due date for the payment. - **amount** (number) - Payment amount. - **paid** (boolean) - Indicates if the payment is paid. - **userId** (string) - User ID associated with the payment. - **locked** (boolean) - Indicates if the payment is locked. - **pending** (boolean) - Indicates if the payment is pending. - **timestamp** (number) - Timestamp of the payment. - **paymentMethod** (string) - Method used for payment. - **paymentType** (string) - Type of payment. - **note** (string) - Note for the payment. - **reference** (string) - Reference for the payment. - **orderStatus** (string) - Status of the order for this payment. - **amountExcludingFee** (number) - Amount excluding fees. - **fee** (number) - Fee amount. - **failed** (boolean) - Indicates if the payment failed. - **verifyError** (string) - Verification error message. - **refundedAmount** (number) - Amount refunded. - **refundPaymentId** (string) - ID of the refund payment. - **connectorData** (object) - Connector specific data. - **paymentProvider** (string) - Payment provider name. - **paymentMethod** (string) - Payment method used. - **destinationId** (string) - Destination ID for the payment. - **destinationType** (string) - Type of destination. - **quantity** (number) - Quantity for the payment plan. - **orderState** (string) - State of the order for this plan. - **depositAmount** (number) - The total deposit amount. - **depositType** (string) - The type of deposit. - **flatFee** (number) - The flat fee. - **percFee** (number) - The percentage fee. - **validDays** (array) - Array of valid days. - **validDates** (array) - Array of valid dates. - **amountDueExcludingFee** (number) - Amount due excluding fees. - **depositDueExcludingFee** (number) - Deposit due excluding fees. - **paymentMethods** (object) - Available payment methods. - **creditOrDebitCard** (boolean) - Whether credit/debit card is available. - **eft** (boolean) - Whether EFT is available. - **debiCheck** (boolean) - Whether DebiCheck is available. - **payAt** (boolean) - Whether Pay@ is available. - **capitecPay** (boolean) - Whether Capitec Pay is available. - **dashpay** (boolean) - Whether DashPay is available. - **terminalCard** (boolean) - Whether terminal card payments are available. - **offline** (boolean) - Whether offline payments are available. - **embeddedCheckout** (boolean) - Whether embedded checkout is available. ### Response Example ```json { "amountDue": 0, "merchant": "string", "merchantTermsLink": "string", "reference": "string", "orderName": "string", "depositDue": 0, "endDateMax": "string", "imageUrl": "string", "enablesSplit": true, "products": [ { "_id": "string", "amount": 0, "link": "http://example.com", "sku": "string", "name": "string", "depositType": "string", "travelDate": "string" } ], "paymentPlans": [ { "months": 0, "deposit": 0, "payments": [ { "_id": "string", "paymentPlanId": "string", "due": "string", "amount": 0, "paid": true, "userId": "string", "locked": true, "pending": true, "timestamp": 0.1, "paymentMethod": "string", "paymentType": "string", "note": "string", "reference": "string", "orderStatus": "string", "amountExcludingFee": 0.1, "fee": 0.1, "failed": true, "verifyError": "string", "refundedAmount": 0, "refundPaymentId": "string", "connectorData": { "paymentProvider": "string", "paymentMethod": "string" }, "destinationId": "string", "destinationType": "string" } ], "quantity": 0, "orderState": "string" } ], "depositAmount": 0, "depositType": "INSTALMENT", "flatFee": 0.1, "percFee": 0.1, "validDays": [ 0 ], "validDates": [ 0 ], "amountDueExcludingFee": 0, "depositDueExcludingFee": 0, "paymentMethods": { "creditOrDebitCard": true, "eft": true, "debiCheck": true, "payAt": true, "capitecPay": true, "dashpay": true, "terminalCard": true, "offline": true, "embeddedCheckout": true } } ``` -------------------------------- ### Skip Instalment by Reducing Order Value Source: https://documentation.layup.co.za/ If an order is suspended and an instalment needs to be skipped, reduce the order value. With `amortiseOnAmend` enabled, the unpaid amount is distributed to future instalments, and the order is unsuspended. ```bash curl "https://sandbox-api.layup.co.za/v1/orders/$orderId" -X PUT -H 'Content-Type: application/json;charset=utf-8' -H "apikey: $merchantApiKey" \ --data-binary @- << EOF { "products":[{"amount":30000,"sku":"sku-5555","name":"amortiseOnAmend"}] } EOF ``` -------------------------------- ### Send Order Request using Go HTTP Client Source: https://documentation.layup.co.za/ This Go code snippet illustrates how to make an HTTP POST request to send an order. It shows setting up headers and the request body. ```go package main import ( "bytes", "net/http" ) func main() { headers := map[string][]string{ "Content-Type": []string{"application/json"}, "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("POST", "https://sandbox-api.layup.co.za/v1/orders-send-request", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Example Successful Response for Delete Offline Payment Source: https://documentation.layup.co.za/ This is an example of a successful JSON response when an offline payment is deleted. It includes details of the deleted payment. ```json { "_id": "string", "paymentPlanId": "string", "due": "string", "amount": 0, "paid": true, "userId": "string", "locked": true, "pending": true, "timestamp": 0.1, "paymentMethod": "string", "paymentType": "string", "note": "string", "reference": "string", "orderStatus": "string", "amountExcludingFee": 0.1, "fee": 0.1, "failed": true, "verifyError": "string", "refundedAmount": 0, "refundPaymentId": "string", "connectorData": { "paymentProvider": "string", "paymentMethod": "string" }, "destinationId": "string", "destinationType": "string" } ``` -------------------------------- ### Send Customer to Payment Widget Source: https://documentation.layup.co.za/ Construct the payment widget URL using the obtained order ID. This URL is then provided to the customer for completing their payment. ```bash echo "https://shopper-sandbox.layup.co.za/order/$orderId" ``` -------------------------------- ### Example Response for 400 Bad Request Source: https://documentation.layup.co.za/ This is an example of a 400 Bad Request response, which may occur if invalid query parameters are provided to the API. ```json null ``` -------------------------------- ### Get All Users with Ruby Rest-Client Source: https://documentation.layup.co.za/ This Ruby code snippet uses the 'rest-client' gem to perform a GET request for all users. It parses and prints the JSON response. ```ruby require 'rest-client' require 'json' headers = { 'Accept' => 'application/json', 'apikey' => 'API_KEY' } result = RestClient.get 'https://sandbox-api.layup.co.za/v1/users', params: { }, headers: headers p JSON.parse(result) ``` -------------------------------- ### Offline Payment Request Body Example Source: https://documentation.layup.co.za/ This is an example of the JSON request body required to create an offline payment. It includes fields like amount, note, and paymentPlanId. ```json { "amount": 13333, "note": "Processed by employeeX", "paymentPlanId": "123f7f1496bd78001d6852f3", "reference": "Cash in hand", "verifiedAt": "2022-01-27T14:00:00.000Z" } ``` -------------------------------- ### HTTP Request for Payment Plan Preview Source: https://documentation.layup.co.za/ This snippet shows the raw HTTP request structure for creating a payment plan preview. It includes the host, content type, and accept headers. ```http POST https://sandbox-api.layup.co.za/v1/payment-plan/preview HTTP/1.1 Host: sandbox-api.layup.co.za Content-Type: application/json Accept: application/json ``` -------------------------------- ### Get All Users with JavaScript Fetch API Source: https://documentation.layup.co.za/ This JavaScript code uses the Fetch API to make a GET request to retrieve all users. It logs the response body to the console. ```javascript const headers = { 'Accept':'application/json', 'apikey':'API_KEY' }; fetch('https://sandbox-api.layup.co.za/v1/users', { method: 'GET', headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); ``` -------------------------------- ### Retrieve Orders using Go HTTP Client Source: https://documentation.layup.co.za/ This Go code snippet shows the basic structure for making an HTTP GET request to retrieve orders using the standard 'net/http' package. It includes setting headers and preparing the request. ```go package main import ( "bytes", "net/http", ) func main() { headers := map[string][]string{ "Accept": []string{"application/json"}, "apikey": []string{"API_KEY"}, } data := bytes.NewBuffer([]byte{jsonReq}) req, err := http.NewRequest("GET", "https://sandbox-api.layup.co.za/v1/orders", data) req.Header = headers client := &http.Client{} resp, err := client.Do(req) // ... } ``` -------------------------------- ### Get Settlements Source: https://documentation.layup.co.za/ Retrieve multiple settlements for a merchant. If your account has multiple merchants, use the GetMe endpoint from AuthService to get the merchant IDs you have access to. Set the merchantId in the header of this request. ```APIDOC ## GET /v3/settlements ### Description Retrieve multiple settlements for a merchant. If your account has multiple merchants use the GetMe endpoint from AuthService to get the merchant IDs you have access to. Set the merchantId in the header of this request. ### Method GET ### Endpoint /v3/settlements ### Parameters #### Query Parameters - **limit** (integer(int32)) - Optional - The maximum number of results to return. - **skip** (integer(int32)) - Optional - The number of results to skip. - **fromDate** (string) - Optional - The start date for the report. - **toDate** (string) - Optional - The end date for the report. - **search** (string) - Optional - Search term to filter results. - **sort** (string) - Optional - The field by which to sort the results. ### Response #### Success Response (200) - **settlements** (array) - An array of settlement objects. - **id** (string) - The unique identifier for the settlement. - **amount** (integer) - The settlement amount. - **batchType** (string) - The type of batch. - **merchantId** (string) - The ID of the merchant. - **status** (string) - The settlement status (e.g., PAID). - **reference** (string) - The settlement reference number. - **settledAt** (string) - The date the settlement was processed. - **zipUrl** (string) - A URL to download a zip file of settlement details. - **totalCount** (integer) - The total number of settlements available. #### Response Example ```json { "settlements": [ { "id": "123", "amount": 100, "batchType": "ALL", "merchantId": "68bfee73805611db20cb300f", "status": "PAID", "reference": "LUF5EAD-123", "settledAt": "2023-01-31", "zipUrl": "https://api.layup.co.za/v3/settlements/files/LU999Z9-999.zip" } ], "totalCount": 1254 } ``` ``` -------------------------------- ### Get Many Order Amendments with cURL Source: https://documentation.layup.co.za/ Use cURL to make a GET request to the sandbox API to retrieve order amendments. Ensure you replace 'API_KEY' with your actual API key. ```shell # You can also use wget curl -X GET https://sandbox-api.layup.co.za/v1/order-amendments \ -H 'Accept: application/json' \ -H 'apikey: API_KEY' ```