### Get Invoice using C# Source: https://developers.trolley.com/ This C# example shows how to get an invoice using the Trolley Gateway. Ensure you initialize the Gateway with your access and secret keys. ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); string invoiceId = GetInvoiceId(); Invoice invoice = gateway.invoice.Get(invoiceId); Console.WriteLine(invoice.description); ... ``` -------------------------------- ### Search Invoice Payments with Python Source: https://developers.trolley.com/api This Python example shows how to set up the Trolley client using your access and secret keys and then perform a search for invoice payments. Ensure you have the 'trolley' library installed. ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') # Search for invoice payments invoice_payments = client.invoice_payment.search( [ invoice_payment.paymentId ]) ``` -------------------------------- ### Retrieve All Account Balances with Python Source: https://developers.trolley.com/ This Python example shows how to use the Trolley SDK to get all account balances. Configure the gateway client with your access and secret keys. ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') balances = client.balances.get_all_balances() print(balances) ``` -------------------------------- ### Get Batch Summary with Python Source: https://developers.trolley.com/api This Python example demonstrates using the Trolley SDK to get a batch summary. Ensure you have the necessary configuration and replace placeholders with your keys. ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') response = client.batch.summary(batch.id) print(response) ``` -------------------------------- ### Get Invoice using Python Source: https://developers.trolley.com/ This Python example demonstrates fetching an invoice using the Trolley SDK. It requires configuring the gateway with your access and secret keys. ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') response = client.invoice.get(invoice.id) print(response) ``` -------------------------------- ### Get Batch Summary with Node.js Source: https://developers.trolley.com/api This Node.js example shows how to connect to Trolley and retrieve a batch summary. Ensure you have the 'trolleyhq' package installed and replace placeholders with your keys. ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const response = await client.batch.summary(batch.id); console.log(response); ``` -------------------------------- ### Batch Management Examples (PHP, cURL, Node.js, Ruby) Source: https://developers.trolley.com/tags/api Code examples demonstrating how to initialize the client and interact with batch endpoints in various programming languages. ```APIDOC ## Client Initialization and Batch Operations ### PHP Example ```php "tag1", "referenceId" => "B-1a2B3c", "startDate" => "2025-01-23T00:05:00-05:00", "endDate" => "2025-01-24T00:05:00-05:00", "status" => "complete", "tags" => "tag1,tag2", "currency" => "EUR", "orderBy" => "amount", "sortBy" => "asc", "page" => 2, "pageSize" => 5 ]); foreach ($searchResults as $batch){ print_r($batch); } ?> ``` ### cURL Example ```bash curl \ -H 'Authorization: prsign :' \ -H 'Content-Type: application/json' \ -H 'X-PR-Timestamp: ' \ -X GET 'https://api.trolley.com/v1/batches?search=tag1&referenceId=B-1a2B3c&startDate=2025-01-23T00:05:00-05:00&endDate=2025-01-24T00:05:00-05:00&status=complete&tags=tag1,tag2¤cy=EUR&orderBy=amount&sortBy=asc&page=2&pageSize=5' ``` ### Node.js Example ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); // Support for all the filters coming soon const response = await client.batch.search(1, 10, "tag1"); console.log(response); ``` ### Ruby Example ```ruby require 'trolley' client = Trolley.client('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY') ``` ``` -------------------------------- ### Batch Operations (SDK Examples) Source: https://developers.trolley.com/api Examples of how to interact with the batch API using various SDKs, including searching with and without pagination, and listing batches. ```APIDOC ## Batch Operations (SDK Examples) ### Java Example (Manual Pagination) ```java Configuration config = new Configuration("",""); Gateway client = new Gateway(config); String batchId = getBatchId(); int page = 1; int pageSize = 10; // Get all batches with an optional search term and manual pagination Batches allBatches = client.batch.search(page, pageSize, ""); List batches = allBatches.getBatches(); for (Batch batch : batches){ System.out.println(batch.getId()); } ``` ### Java Example (Auto-Pagination) ```java Configuration config = new Configuration("",""); Gateway client = new Gateway(config); // Or, with auto-pagination BatchesIterator batches = client.batch.search(""); while(batches.hasNext()){ System.out.println(batches.next().getId()); } ``` ### C# Example (Manual Pagination) ```csharp using Trolley.Types; using Trolley; Gateway gateway = new Trolley.Gateway("", ""); string recipientId = GetRecipientId(); int page = 1; int pageSize = 10; // List all batches with manual pagination, with optional search term Batches allBatches = gateway.batch.ListAllBatches("", page, pageSize); // Get a List of Batch objects to iterate through List batches = allBatches.batches; // And get a Meta object to access page information Meta meta = allBatches.meta; ``` ### C# Example (Auto-Pagination) ```csharp using Trolley.Types; using Trolley; Gateway gateway = new Trolley.Gateway("", ""); // Or, list all batches with auto-pagination, with optional search term var batches = gateway.batch.ListAllBatches(""); foreach (Batch batch in batches) { Console.WriteLine(batch.id); } ``` ### PHP Example (List All Batches) ```php "tag1", "referenceId" => "B-1a2B3c", "startDate" => "2025-01-23T00:05:00-05:00", "endDate" => "2025-01-24T00:05:00-05:00", "status" => "complete", "tags" => "tag1,tag2", "currency" => "EUR", "orderBy" => "amount", "sortBy" => "asc", "page" => 2, "pageSize" => 5 ]); foreach ($searchResults as $batch){ print_r($batch); } ?> ``` ### Node.js Example ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); // Support for all the filters coming soon const response = await client.batch.search(1, 10, "tag1"); console.log(response); ``` ### Ruby Example ```ruby require 'trolley' client = Trolley.client('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY') # Example of searching batches (specific parameters may vary based on SDK version) # batches = client.batch.search("") # puts batches ``` ``` -------------------------------- ### Batch Operations (SDK Examples) Source: https://developers.trolley.com/ Examples of how to interact with the batch API using various programming language SDKs. ```APIDOC ## Batch Operations (SDK Examples) ### Java Example (Manual Pagination) ```java Configuration config = new Configuration("",""); Gateway client = new Gateway(config); String batchId = getBatchId(); int page = 1; int pageSize = 10; // Get all batches with an optional search term and manual pagination Batches allBatches = client.batch.search(page, pageSize, ""); List batches = allBatches.getBatches(); for (Batch batch : batches){ System.out.println(batch.getId()); } ``` ### Java Example (Auto-Pagination) ```java Configuration config = new Configuration("",""); Gateway client = new Gateway(config); // Or, with auto-pagination BatchesIterator batches = client.batch.search(""); while(batches.hasNext()){ System.out.println(batches.next().getId()); } ``` ### C# Example (Manual Pagination) ```csharp using Trolley.Types; using Trolley; Gateway gateway = new Trolley.Gateway("", ""); string recipientId = GetRecipientId(); int page = 1; int pageSize = 10; // List all batches with manual pagination, with optional search term Batches allBatches = gateway.batch.ListAllBatches("", page, pageSize); // Get a List of Batch objects to iterate through List batches = allBatches.batches; // And get a Meta object to access page information Meta meta = allBatches.meta; ``` ### C# Example (Auto-Pagination) ```csharp using Trolley.Types; using Trolley; Gateway gateway = new Trolley.Gateway("", ""); // Or, list all batches with auto-pagination, with optional search term var batches = gateway.batch.ListAllBatches(""); foreach (Batch batch in batches) { Console.WriteLine(batch.id); } ``` ### PHP Example (List All Batches) ```php "tag1", "referenceId" => "B-1a2B3c", "startDate" => "2025-01-23T00:05:00-05:00", "endDate" => "2025-01-24T00:05:00-05:00", "status" => "complete", "tags" => "tag1,tag2", "currency" => "EUR", "orderBy" => "amount", "sortBy" => "asc", "page" => 2, "pageSize" => 5 ]); foreach ($searchResults as $batch){ print_r($batch); } ?> ``` ### Node.js Example ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); // Support for all the filters coming soon const response = await client.batch.search(1, 10, "tag1"); console.log(response); ``` ### Ruby Example ```ruby require 'trolley' client = Trolley.client('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY') ``` ``` -------------------------------- ### API Request to Get Regions Source: https://developers.trolley.com/ This is an example of an HTTP GET request to retrieve a list of regions for a specific country using its ISO 3166-1 alpha-2 code. ```bash -H "Content-Type: application/json" \ -X GET \ https://api.trolley.com/v1/geography/countries/CA ``` -------------------------------- ### Create a Batch with Tags Source: https://developers.trolley.com/api Examples for creating a batch and assigning tags using various SDKs and direct API calls. ```bash curl \ -H 'Authorization: prsign :' \ -H 'Content-Type: application/json' \ -H 'X-PR-Timestamp: ' \ -X POST 'https://api.trolley.com/v1/batches' \ --data-raw '{ "currency": "USD", "description": "Month end payout", "tags":[ "tag1", "tag2" ], "payments": [...] }' ``` ```ruby require 'trolley' client = Trolley.client('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY') response = client.batch.create({ currency: "USD", description: "Month end payout", tags: [ "tag1", "tag2" ], payments: [...] }) print response ``` ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') payload = { "currency": "USD", "description": "Month end payout", "tags": [ "tag1", "tag2" ], "payments": [...] } response = client.batch.create(payload) print(response) ``` ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const response = await client.batch.create( { currency: "USD", description: "Month end payout", tags: [ "tag1", "tag2" ], payments: [...] }); console.log(response.batch.id); ``` ```php "USD", "description" => "Month end payout", "tags" => [ "tag1", "tag2" ] ], [...]); print_r($batch); ?> ``` ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); Batch batchRequest = new Batch("Month end payout", null, "USD", 0); batchRequest.tags = new List { "tag1", "tag2" }; Batch batch = gateway.batch.Create(batchRequest); Console.WriteLine(batch.id); ... ``` ```java ... Configuration config = new Configuration("",""); Gateway client = new Gateway(config); Recipient recipient = getRecipient(); // Create an empty batch Batch batchRequest = new Batch(); batchRequest.setCurrency("USD"); batchRequest.setDescription("Month end payout"); batchRequest.setTags(Arrays.asList("tag1", "tag2")); Batch batch = client.batch.create(batchRequest); System.out.println(batch.getId()); ... ``` -------------------------------- ### Create an invoice with .NET SDK Source: https://developers.trolley.com/ Initialize the Gateway and use the invoice.Create method. ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); string recipientId = GetRecipientId(); Invoice invoiceRequest = new Invoice(); invoiceRequest.recipientId = recipientId; invoiceRequest.description = "New Invoice with .Net SDK"; Invoice invoice = gateway.invoice.Create(invoiceRequest); Console.WriteLine(invoice.id); ... ``` -------------------------------- ### Create a batch with Ruby SDK Source: https://developers.trolley.com/ Initialize the client and create a batch with a list of payments. ```ruby require 'trolley' client = Trolley.client('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY') response = client.batch.create({ description: "New batch with Ruby SDK", currency: "USD", payments: [ { recipient: { id: recipient1.id }, amount: "100", currency: "USD" }, { recipient: { id: recipient2.reference_id }, amount: "200", currency: "USD", } ] }) print response ``` -------------------------------- ### GET /v1/balances Source: https://developers.trolley.com/ Retrieves the balances of your (merchant) Trolley account as well as your PayPal account, if setup. ```APIDOC ## GET /v1/balances ### Description Retrieves the balances of your (merchant) Trolley account as well as your PayPal account, if setup. ### Method GET ### Endpoint https://api.trolley.com/v1/balances ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the request was successful. - **balances** (object) - A collection of account balances indexed by currency or type. #### Response Example { "ok": true, "balances": { "paypal": { "primary": false, "amount": "1000.00", "currency": "USD", "type": "paypal", "accountNumber": null }, "USD": { "primary": true, "amount": "1463430.27", "currency": "USD", "type": "paymentrails", "accountNumber": "0000848" } } } ``` -------------------------------- ### Retrieve All Account Balances with C# Source: https://developers.trolley.com/ This C# example shows how to use the Trolley Gateway to fetch all account balances and print the amount for each balance. ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); List balances = gateway.balances.GetAllBalances(); foreach (Balance balance in balances){ Console.WriteLine(balance.amount); } ... ``` -------------------------------- ### Java Authentication and Request Execution Source: https://developers.trolley.com/tags/api Implementation of the request signing logic and an example of performing a GET request using HttpURLConnection. ```java import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.HashMap; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; ... HashMap getTrolleyAuthHeaders(HashMap params) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException{ HashMap headerValues = new HashMap(); int timeStamp = (int) (System.currentTimeMillis() / 1000L); String message = timeStamp + "\n" + params.get("method") + "\n" + params.get("requestPath") + "\n" + params.get("body") + "\n"; String digest = null; final SecretKeySpec key = new SecretKeySpec((params.get("secretKey")).getBytes("UTF-8"), "HmacSHA256"); Mac mac = Mac.getInstance("HmacSHA256"); mac.init(key); byte[] bytes = mac.doFinal(message.getBytes("ASCII")); StringBuffer hash = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(0xFF & bytes[i]); if (hex.length() == 1) { hash.append('0'); } hash.append(hex); } digest = hash.toString(); headerValues.put("Authorization", "prsign " + params.get("accessKey").toString() + ":" + digest); headerValues.put("X-PR-Timestamp", ""+timeStamp); headerValues.put("Content-Type", "application/json"); return headerValues; } ... String ACCESS_KEY = ""; String SECRET_KEY = ""; try { URL obj = new URL("https://api.trolley.com/v1/recipients"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); HashMap headerValues = getTrolleyAuthHeaders(new HashMap(){{ put("method", "get".toUpperCase()); put("requestPath", "/v1/recipients"); put("body",""); // if non-empty, body should be a valid JSON in string format put("accessKey", ACCESS_KEY); put("secretKey", SECRET_KEY); }}); //Setting header values for (String i : headerValues.keySet()) { con.setRequestProperty(i, headerValues.get(i)); } BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); }catch (IOException e) { e.printStackTrace(); } ``` -------------------------------- ### Retrieve Trolley Account Balances with Java Source: https://developers.trolley.com/api This Java example demonstrates initializing the Trolley Gateway with configuration and retrieving a list of account balances, printing their types. ```java Configuration config = new Configuration("",""); Gateway client = new Gateway(config); // Get Trolley Account Balances List balances = client.balances.getTrolleyAccountBalances(); for (Balances balance : balances) { System.out.println(balance.getType()); } ... ``` -------------------------------- ### Create a batch with PHP SDK Source: https://developers.trolley.com/ Initialize the Trolley configuration and use the Batch::create method. ```php "USD", "description" => "PHP SDK Batch Creation" ], [ // Payments (optional) [ "targetAmount" => "10.00", "targetCurrency" => "EUR", "recipient" => [ "id" => $recipient->id ] ] ]); print_r($batch); ?> ``` -------------------------------- ### Perform Authenticated GET Request Source: https://developers.trolley.com/api Example of a cURL request to retrieve recipient details using the required authentication headers. ```bash curl -H "Authorization:prsign ALJVaAj4Z764JE7C:ce1f667913c9ca794cd89291c61f68ff98144291bbdcc3d0" -H "X-PR-Timestamp:'1656393402'" -L -X GET "https://api.trolley.com/v1/recipients/R-BawfevFF8oWx" \ ``` -------------------------------- ### Create Batch with Python SDK Source: https://developers.trolley.com/api Demonstrates creating a batch using the Trolley Python SDK. This example uses the gateway method for client initialization. ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') payload = { "payments": [ { "recipient": { "id": recipient.id }, "sourceAmount": "65", "sourceCurrency": "EUR" } ] } response = client.batch.create(payload) print(response) ``` -------------------------------- ### Get Trolley Recipients List (Python) Source: https://developers.trolley.com/ Use the requests library to fetch a list of recipients from the Trolley API. Ensure you have the 'requests' library installed. ```python r = requests.get(api_url + 'recipients', auth=auth) print r.json() ``` -------------------------------- ### Retrieve Payment using C# Source: https://developers.trolley.com/api This C# example shows how to use the Trolley Gateway to get payment details. Ensure you have initialized the Gateway with your API keys. ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); string paymentId = GetPaymentId(); Payment payment = gateway.payment.Get(paymentId); Console.WriteLine(payment.amount); ... ``` -------------------------------- ### Create a Recipient with Node.js Source: https://developers.trolley.com/ This Node.js example shows how to create a recipient using the Trolley SDK. Make sure to install the SDK and provide your API keys. ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const recipient = await client.recipient.create( { type: "individual", firstName: "John", lastName: "Smith", email: "jsmith@example.com", address: { city: "MontrĂ©al", country: "CA", phone: "+15141111111", postalCode: "A1A 1A1", region: "BC", street1: "Toad Street", street2: "Avenue Rock" } } ); console.log(recipient.id); ``` -------------------------------- ### Retrieve Trolley Account Balances with Java Source: https://developers.trolley.com/ This Java example demonstrates initializing the Trolley Gateway client with configuration and then retrieving a list of account balances. ```java Configuration config = new Configuration("",""); Gateway client = new Gateway(config); // Get Trolley Account Balances List balances = client.balances.getTrolleyAccountBalances(); for (Balances balance : balances) { System.out.println(balance.getType()); } ... ``` -------------------------------- ### Retrieve Batch Summary via C# Source: https://developers.trolley.com/tags/api Initialize the gateway and retrieve the batch summary as a string. ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); string batchId = GetBatchId(); string summary = gateway.batch.Get(batchId); Console.WriteLine(summary); ... ``` -------------------------------- ### Get Invoice Request using cURL Source: https://developers.trolley.com/ This example demonstrates how to fetch an invoice using a cURL command. Ensure you replace placeholders with your actual ACCESS-KEY, SIGNATURE, and timestamp. ```bash curl \ -H 'Authorization: prsign :' -H 'Content-Type: application/json' -H 'X-PR-Timestamp: ' -L -X POST 'https://api.trolley.com/v1/invoices/get' \ --data-raw '{ "invoiceId": "I-HEG4x7Pb8VRkYZnu8Ja" }' ``` -------------------------------- ### Create an Invoice with Tags Source: https://developers.trolley.com/ Examples for creating an invoice and assigning tags during the initial request. ```curl curl \ -H 'Authorization: prsign :' \ -H 'Content-Type: application/json' \ -H 'X-PR-Timestamp: ' \ -L -X POST 'https://api.trolley.com/v1/invoices/create' \ --data-raw '{ "recipientId": "R-XgtzXghfxx4Z2E4Y3R", "description": "Invoice for artwork payment", "externalId": "acme-inv-1001", "tags": [ "tag1", "tag2" ], "lines": [ ... ] }' ``` ```ruby require 'trolley' client = Trolley.client('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY') response = client.invoice.create( recipientId: recipient.id, description: 'Invoice for artwork payment', invoiceNumber: "inv-number-1001", dueDate: "2023-02-01" tags: [ "tag1", "tag2" ] lines: [ ... ] ) print response ``` ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') invoice = client.invoice.create({ "recipientId": recipient.id, "description": "Invoice for artwork payment", "invoiceNumber": "inv-number-1001", "dueDate": "2023-02-01", "tags": [ "tag1", "tag2" ] "lines": [ ... ] }) print(invoice) ``` ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const response = await client.invoice.create( { recipientId: recipient.id, description: "Invoice for artwork payment", invoiceNumber: "inv-number-1001", dueDate: "2023-02-01", tags: [ "tag1", "tag2" ] lines: [ ... ] }); console.log(response); ``` ```php $recipient_id, "description" => "Invoice for artwork payment", "invoiceNumber" => "inv-number-1001", "dueDate" => "2023-02-01", "tags" => ["tag1", "tag2"] "lines" => [ ... ] ]); print_r($newInvoice); ?> ``` ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); string recipientId = GetRecipientId(); Invoice invoiceRequest = new Invoice(); invoiceRequest.recipientId = recipientId; invoiceRequest.description = "Invoice for artwork payment"; invoiceRequest.invoiceNumber = "inv-number-1001"; invoiceRequest.dueDate = "2023-02-01"; invoiceRequest.tags = new List { "tag1", "tag2"}; Invoice invoice = gateway.invoice.Create(invoiceRequest); Console.WriteLine(invoice.id); ... ``` ```java ... Configuration config = new Configuration("",""); Gateway client = new Gateway(config); String recipientId = getRecipientId(); //Create a request object Invoice invoice = new Invoice(); //Set request values invoice.setRecipientId(recipientId); invoice.setInvoiceNumber("inv-number-1001"); invoice.setDescription("Invoice for artwork payment"); invoice.setExternalId("ext-id-123"); invoice.setDueDate("2023-02-01"); invoice.setTags(Arrays.asList("tag1", "tag2")); //Making network request and collecting response Invoice invoiceResponse = client.invoice.create(invoice); System.out.println(invoice.getCreatedAt()); ... ``` -------------------------------- ### Create an invoice with PHP SDK Source: https://developers.trolley.com/ Configure the SDK with your credentials and use the Invoice::create method. ```php $recipient_id, "description" => "New Invoice sample code for PHP SDK", "invoiceNumber" => "inv-number-1001", "dueDate" => "2023-02-01" ]); print_r($newInvoice); ?> ``` -------------------------------- ### Retrieve All Account Balances with Node.js Source: https://developers.trolley.com/ This Node.js example shows how to connect to the Trolley API using the SDK and retrieve all account balances. Ensure you have the 'trolleyhq' package installed. ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const response = await client.balances.all(); console.log(response); ``` -------------------------------- ### Create a New Batch with Payments and Tags in Python Source: https://developers.trolley.com/api This Python example demonstrates creating a new batch with an associated payment that includes tags. It uses the Trolley library and requires your access and secret keys. ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') payload = { "currency": "USD", "description": "Month end payout", "payments": [ { "recipient": { "id": recipient.id }, "sourceAmount": "100", "sourceCurrency": "USD", "tags":[ "tag1", "tag2" ] } ] } response = client.batch.create(payload) print(response) ``` -------------------------------- ### Add Tags to Invoice Line (Node.js) Source: https://developers.trolley.com/ This Node.js example shows how to add tags to an invoice line. Make sure to install the trolleyhq package and replace the placeholder keys. ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const response = await client.invoiceLine.create( { invoice: { id: invoice.id }, unitAmount: { value: "50.00", currency: "EUR" }, tags:[ "tag1", "tag1" ] }); console.log(response); ``` -------------------------------- ### Get Batch Summary with C# Source: https://developers.trolley.com/api This C# example demonstrates retrieving a batch summary using the Trolley Gateway. Ensure you replace placeholders with your actual keys and provide a valid batch ID. ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); string batchId = GetBatchId(); string summary = gateway.batch.Get(batchId); Console.WriteLine(summary); ... ``` -------------------------------- ### Create a New Batch with Payments and Tags in PHP Source: https://developers.trolley.com/api This PHP example demonstrates creating a new batch with an associated payment that includes tags. It requires configuring Trolley with your public and private keys. ```php id); print_r($response); ?> ``` ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const response = await client.batch.find(batch.id); console.log(response.batch.id); ``` ```ruby require 'trolley' client = Trolley.client('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY') batch = client.batch.find(batch.id) print batch ``` ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') response = client.batch.find(batch.id) print(response) ``` ```java ... Configuration config = new Configuration("",""); Gateway client = new Gateway(config); String batchId = getBatchId(); // Get a batch with ID Batch batch = client.batch.find(batchId); System.out.println(batch.getId()); ... ``` ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); string batchId = GetBatchId(); Batch batch = gateway.batch.Get(batchId); Console.WriteLine(batch.id); ... ``` -------------------------------- ### API Response Examples Source: https://developers.trolley.com/ Examples of successful and failed API responses. ```json { "ok": true } ``` ```json { "ok": false, "errors": [ { "code": "invalid_field", "message": "Value is invalid", "field": "invoiceId" } ] } ``` -------------------------------- ### Example API Responses Source: https://developers.trolley.com/api JSON response examples for different payout methods. ```json // Bank Account { "ok": true, "account": { "recipientAccountId": "A-UnukXDTbLtxtDLXVZGE9re", "primary": true, "currency": "CAD", "country": "CA", "iban": "", "type": "bank-transfer", "accountNum": "*****2847", "accountHolderName": "John Smith", "bankId": "123", "branchId": "47261", "bankName": "TD bank", "bankAddress": "123 Nice Street", "bankCity": "Toronto", "bankRegionCode": "ON", "bankPostalCode": "M6A 0B1" } } // Check (US only) { "ok": true, "account": { "recipientAccountId": "A-UnukXDTbLtxtDLXVZGE9re", "primary": true, "currency": "USD", "country": "US", "type": "check", "mailing": { "name": "Leonardo Davinci", "street1": "123 Some Street", "street2": "", "city": "NYC", "region": "NY", "country": "US", "postal": "12345" } } } // Paypal { "ok": true, "account": { "recipientAccountId": "A-UnukXDTbLtxtDLXVZGE9re", "primary": true, "currency": "CAD", "type": "paypal", "emailAddress": "leonardo@example.com" } } // Venmo (US only) { "ok": true, "account": { "recipientAccountId": "A-UnukXDTbLtxtDLXVZGE9re", "primary": true, "currency": "USD", "type": "venmo", "phoneNumber": "+1 416 123 4567" } } ``` -------------------------------- ### Create a Payment with Tags in Python Source: https://developers.trolley.com/api This Python example shows how to create a payment with tags using the Trolley library. It requires initializing the client with your access and secret keys and defining the payment payload. ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') payload = { "sourceAmount": "150.10", "currency": "USD", "recipient":{ "id": recipient_id }, "tags": ["tag1", "tag2"] } response = client.payment.create(payload, batch.id) print(response) ``` -------------------------------- ### Example Verified Data (Phone) Source: https://developers.trolley.com/ Example of the `verifiedData` structure for phone verification. ```APIDOC ## Example Verified Data (Phone) ### Description This is an example of the `verifiedData` structure when the verification type is `phone`. ### Request Example ```json { "verifiedData": { "channel": "sms", "phone": "+1 123 456 789", "phoneExtension": null, "country": "US" } } ``` ``` -------------------------------- ### Retrieve Trolley Account Balances with C# Source: https://developers.trolley.com/ This C# example shows how to initialize the Trolley Gateway client and retrieve a list of Trolley balances, iterating through them to print the amount. ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); List balances = gateway.balances.GetTrolleyBalances(); foreach (Balance balance in balances){ Console.WriteLine(balance.amount); } ... ``` -------------------------------- ### Example Verified Data (Business) Source: https://developers.trolley.com/ Example of the `verifiedData` structure for business verification. ```APIDOC ## Example Verified Data (Business) ### Description This is an example of the `verifiedData` structure when the verification type is `business`. ### Request Example ```json { "verifiedData": { "businessRegistrationNumber": "123456789", "documentType": "document/generic", "name": "Acme Inc.", "reason": null, "address": { "street1": "123 Main St", "street2": "", "city": "San Francisco", "region": "CA", "postalCode": "94131", "country": "US" } } } ``` ``` -------------------------------- ### Retrieve Invoice Examples Source: https://developers.trolley.com/tags/api Examples for fetching an invoice using various programming languages. ```bash curl \ -H 'Authorization: prsign :' \ -H 'Content-Type: application/json' \ -H 'X-PR-Timestamp: ' \ -L -X POST 'https://api.trolley.com/v1/invoices/get' \ --data-raw '{ "invoiceId": "I-HEG4x7Pb8VRkYZnu8Ja" }' ``` ```php ``` ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const response = await client.invoice.find(invoice.id); console.log(response); ``` ```ruby require 'trolley' client = Trolley.client('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY') response = client.invoice.find(invoiceId: invoice.id) print response ``` ```python from trolley.configuration import Configuration client = Configuration.gateway(f'{ACCESS_KEY}', f'{SECRET_KEY}') response = client.invoice.get(invoice.id) print(response) ``` ```java ... Configuration config = new Configuration("",""); Gateway client = new Gateway(config); String invoiceId = getInvoiceId(); //Fetch an Invoice Invoice invoice = client.invoice.fetch(invoiceId); System.out.println(invoice.getDescription()); ... ``` ```csharp using Trolley.Types; using Trolley; ... Gateway gateway = new Trolley.Gateway("", ""); string invoiceId = GetInvoiceId(); Invoice invoice = gateway.invoice.Get(invoiceId); Console.WriteLine(invoice.description); ... ``` -------------------------------- ### Example Response (200 Ok) Source: https://developers.trolley.com/api This is an example of a successful response when a recipient account is deleted. ```json { "ok": true, "object": "deleted" } ``` -------------------------------- ### Start Batch Processing with Node.js Source: https://developers.trolley.com/tags/api Use the Trolley Node.js SDK to start batch processing. Connect to the client using your access key and secret, then call the batch.startProcessing method. ```javascript // Running in Node.js environment const trolley = require("trolleyhq"); const client = trolley.connect({ key: "YOUR_ACCESS_KEY", secret: "YOUR_SECRET_KEY" }); const response = await client.batch.startProcessing(batch.id); console.log(response); ``` -------------------------------- ### Batch Summary Response Example Source: https://developers.trolley.com/ Example JSON response for a successful batch summary request. ```json { "ok": true, "batchSummary": { "detail": { "bank-transfer": { "count": 1, "totalFees": "1.00", "merchantFees": "1.00", "debitAmount": "11.00", "sendingAmount": "10.00", "totalWithheld": "0.00" }, "paypal": { "count": 1, "totalFees": "1.00", "merchantFees": "1.00", "debitAmount": "11.00", "sendingAmount": "10.00", "totalWithheld": "0.00" } }, "total": { "count": 1, "totalFees": "2.00", "merchantFees": "2", "debitAmount": "22.00", "sendingAmount": "20.00", "totalWithheld": "0.00" } } } ```