### Subscription Response Example (JSON) Source: https://developers.payrexx.com/reference/create-a-new-subscription This example demonstrates the structure of a successful response when retrieving subscription data. It includes details about the subscription's status, start date, and associated invoice and contact information. ```json { "status": "success", "data": [ { "id": 1, "status": "active", "start": "2014-12-18", "end": null, "valid_until": "2015-01-18", "invoice": { "number": "Test subscription", "amount": 1, "currency": "CHF", "referenceId": "", "paymentRequestId": null, "paymentLink": null }, "contact": { "id": 1, "title": "", "firstname": "", "lastname": "", "company": "", "street": "", "zip": "", "place": "", "country": "", "countryISO": "", "phone": "", "email": "user@example.com", "date_of_birth": "" } } ] } ``` -------------------------------- ### Retrieve a Design Example Source: https://developers.payrexx.com/reference/retrieve-a-design This example demonstrates how to retrieve a design using its UUID. Ensure you have installed the necessary NodeJS modules: axios, crypto-js, and qs. ```javascript const axios = require('axios'); const qs = require('qs'); const crypto = require('crypto'); async function retrieveDesign(uuid, instance, apiKey, apiSecret) { const method = 'GET'; const url = `https://api.payrexx.com/v1.16/Design/${uuid}/`; const params = { instance: instance }; const query = qs.stringify(params); const nonce = crypto.randomBytes(16).toString('hex'); const timestamp = Math.floor(Date.now() / 1000).toString(); const signature = crypto.createHmac('sha256', apiSecret) .update(method + url + query + nonce + timestamp) .digest('hex'); const headers = { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Payrexx-Auth-Key': apiKey, 'X-Payrexx-Auth-Nonce': nonce, 'X-Payrexx-Auth-Timestamp': timestamp, 'X-Payrexx-Auth-Signature': signature }; try { const response = await axios({ method: 'get', url: `${url}?${query}`, headers: headers }); return response.data; } catch (error) { console.error('Error retrieving design:', error.response ? error.response.data : error.message); throw error; } } // Example Usage: // const uuid = 'YOUR_DESIGN_UUID'; // const instance = 'YOUR_INSTANCE_NAME'; // const apiKey = 'YOUR_API_KEY'; // const apiSecret = 'YOUR_API_SECRET'; // // retrieveDesign(uuid, instance, apiKey, apiSecret) // .then(data => console.log(JSON.stringify(data, null, 2))) // .catch(err => console.error('Failed to get design')); ``` -------------------------------- ### Paylink Data Example Source: https://developers.payrexx.com/reference/retrieve-a-paylink This example shows the structure of a successful Paylink response, including reference ID, hash, subscription state, status, amount, currency, and the payment link. ```json { 'referenceId':'test', 'hash':'1fc5588c482e5e787eb271555b979f98', 'subscriptionState':False, 'status':'(waiting|confirmed|authorized|reserved)', 'name':'', 'amount':200, 'vatRate':7.7, 'sku':'P01122000', 'link':'https://demo.payrexx.com/?payment=1fc5588c482e5e787eb271555b979f98', 'preAuthorization':0, 'subscriptionPeriodMinAmount':0, 'id':38, 'createdAt':1481923840, 'currency':'CHF', 'subscriptionInterval':'', 'purpose':{ '7':'test', '2':'test', '1':'test', '3':'test', '4':'test' }, 'api':True, 'subscriptionCancellationInterval':'', 'fields':{ 'header':{ 'names':{ 'nl':'', 'de':'Kontaktdaten', 'it':'Dati di contatto', 'en':'Contact details', 'fr':'Données de contact' }, 'active':True, 'mandatory':False } }, 'title':'test', 'psp':1, 'description':'test', 'subscriptionPeriod':'', 'invoices':[ ] } ``` -------------------------------- ### Query Parameter for Instance Source: https://developers.payrexx.com/reference/retrieve-subscriptions This example demonstrates the use of the 'instance' query parameter, which is required when retrieving subscription data. ```json { "in": "query", "name": "instance", "schema": { "type": "string" }, "required": true } ``` -------------------------------- ### Transaction Example Source: https://developers.payrexx.com/reference/initiate-terminal-payment Example of a transaction request object, including amount, currency, payment method, and shop items. ```json { "amount": 100, "currency": "CHF", "paymentMethod": "twint", "printSlip": true, "tipAmount": 10, "shopItems": [ { "name": "Beer", "price": 10 } ] } ``` -------------------------------- ### Python JSON Dictionary Example Source: https://developers.payrexx.com/reference/create-a-gateway This snippet shows an example of a Python dictionary representing a payment response. It includes details like creation timestamp, amount, currency, and a payment link. ```python { 'createdAt':1481924665, 'amount':8925, 'vatRate':7.7, 'hash':'2665a4aa5508f2451df403ba04314477', 'psp':0, 'link':'https://demo.payrexx.com/de/?payment=2665a4aa5508f2451df403ba04314477', 'currency':'CHF', 'sku':'P01122000', 'referenceId':'', 'status':'waiting', 'id':1, 'invoices':[ ], 'preAuthorization':0, 'reservation':0, 'fields':[ ] } ``` -------------------------------- ### Not Found Error Response Source: https://developers.payrexx.com/reference/retrieve-subscriptions This example shows the JSON response when a requested resource cannot be found. The message indicates the resource and ID that were not found. ```json { "status": "error", "message": "An error occurred: No {resource} found with id {id}" } ``` -------------------------------- ### Get Apple Pay Payment Method Source: https://developers.payrexx.com/reference/get-one-payment-method Retrieves the details for the Apple Pay payment method. This is an example of how to fetch a specific payment method using its ID. ```APIDOC ## GET /v1.0/PaymentMethod/apple-pay/ ### Description Retrieves the details for a specific payment method, identified by its ID. This endpoint can be used to get information about payment methods like Apple Pay. ### Method GET ### Endpoint /v1.0/PaymentMethod/apple-pay/ ### Parameters #### Query Parameters - **instance** (string) - Required - The name of your Payrexx instance. - **ApiSignature** (string) - Required - The signature for API authentication. ### Request Example ```bash apiSignature=`echo -n "" | openssl dgst -sha256 -hmac "INSTANCE_API_SECRET" -binary | openssl enc -base64` curl --request GET "https://api.payrexx.com/v1.0/PaymentMethod/apple-pay/?instance=INSTANCE_NAME" \ --data-urlencode "ApiSignature=$apiSignature" ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the response (e.g., "success"). - **response** (object) - Contains the payment method details. - **id** (string) - The unique identifier of the payment method. - **name** (string) - The display name of the payment method. - **payment_type** (string) - The type of payment (e.g., "one-time"). - **psp** (object) - Details about the payment service provider. - **id** (integer) - The ID of the PSP. - **name** (string) - The name of the PSP. #### Response Example ```json { "status": "success", "response": { "payment_methods": [ { "id": "apple-pay", "name": "Apple Pay", "payment_type": "one-time", "psp": { "id": 36, "name": "Payrexx" } } ] } } ``` #### Error Response (404) - **status** (string) - Indicates the status of the error (e.g., "error"). - **message** (string) - A message describing the error, such as "An error occurred: No {resource} found with id {id}". ``` -------------------------------- ### Initialize Payrexx Gateway Source: https://developers.payrexx.com/reference/create-a-gateway Sets up the Payrexx API client with instance name and secret. Requires the Payrexx SDK to be included. ```php spl_autoload_register(function ($class) { $classFile = __DIR__ . '/../lib/' . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; if (file_exists($classFile)) { require_once $classFile; } }); // $instanceName is a part of the url where you access your payrexx installation. // https://{$instanceName}.payrexx.com $instanceName = 'YOUR_INSTANCE_NAME'; // $secret is the payrexx secret for the communication between the applications // if you think someone got your secret, just regenerate it in the payrexx administration $secret = 'YOUR_SECRET'; $payrexx = new \Payrexx\Payrexx($instanceName, $secret); ``` -------------------------------- ### Get One Payment Method Example Source: https://developers.payrexx.com/reference/get-one-payment-method This OpenAPI definition describes the endpoint for retrieving a single payment method. It includes parameters for the instance name and the payment method ID. ```json { "openapi": "3.1.0", "info": { "title": "api-settings", "version": "1.0" }, "servers": [ { "url": "https://api.payrexx.com/v1.16" } ], "security": [ {} ], "paths": { "/PaymentMethod/{paymentMethod}/": { "get": { "summary": "Get One Payment Method", "description": "", "operationId": "get-one-payment-method", "parameters": [ { "name": "instance", "in": "query", "description": "Your Payrexx instance name", "required": true, "schema": { "type": "string" } }, { "name": "paymentMethod", "in": "path", "description": "ID of the payment method (e.g. \"twint\" or \"mastercard\")", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "200", "content": { "application/json": { "examples": { "Result": { "value": "{\n \"status\":\"success\",\n \"data\":{\n \"id\":\"apple-pay\",\n \"name\":\"Apple Pay\",\n \"label\":{\n \"en\":\"Apple Pay\"\n },\n \"logo\":{\n \"en\":\"https:\/\/media.payrexx.com\/assets\/cardIcons\/card_apple-pay.svg\"\n },\n \"options_by_psp\":{\n \"36\":{\n \"mode\":\"test\",\n \"payment_types\":[ \"one-time\",\n \"reservation\",\n \"authorization\" ], \"currencies\":[ \"CHF\" ]\n }\n }\n }\n}" } }, "schema": { "type": "object", "properties": { "status": { "type": "string", "example": "success" }, "data": { "type": "object", "properties": { "id": { "type": "string", "example": "apple-pay" }, "name": { "type": "string", "example": "Apple Pay" }, "label": { "type": "object", "properties": { "en": { "type": "string", "example": "Apple Pay" } } }, "logo": { "type": "object", "properties": { "en": { "type": "string", "example": "https://media.payrexx.com/assets/cardIcons/card_apple-pay.svg" } } }, "options_by_psp": { "type": "object", "properties": { "36": { "type": "object", "properties": { "mode": { "type": "string", "example": "test" }, "payment_types": { "type": "array", "items": { "type": "string", "example": "one-time" } }, "currencies": { "type": "array", "items": { "type": "string", "example": "CHF" } } } } } } } } } } } } }, "400": { "description": "400", "content": { "application/json": { "schema": { "type": "object", "properties": {} } } } } } } } } } ``` -------------------------------- ### List all Invoices OpenAPI Definition Source: https://developers.payrexx.com/reference/list-all-invoices This OpenAPI definition outlines the GET endpoint for listing all invoices. It specifies the required 'instance' parameter and the structure of the successful JSON response, including example data. ```json { "openapi": "3.1.0", "info": { "title": "api-settings", "version": "1.0" }, "servers": [ { "url": "https://api.payrexx.com/v1.16" } ], "security": [ {} ], "paths": { "/Bill/": { "get": { "summary": "List all Invoices", "description": "", "operationId": "list-all-invoices", "parameters": [ { "name": "instance", "in": "query", "description": "Your Payrexx instance name", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "200", "content": { "application/json": { "examples": { "Result": { "value": "{\n \"status\": \"success\",\n \"data\": [\n {\n \"status\": \"draft\",\n \"payment_status\": \"unpaid\",\n \"id\": \"md021nl8\",\n \"date\": \"2019-04-01\",\n \"number\": 1,\n \"total\": 2700,\n \"language\": \"de\",\n \"currency\": \"CHF\",\n \"due_after_days\": 0,\n \"recipient\": {\n \"company\": \"My company\",\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"address\": \"Main Street 100\",\n \"zip\": \"1000\",\n \"city\": \"Wien\",\n \"country\": \"AT\",\n \"email\": \"john.doe@example.com\"\n },\n \"service_period\": {\n \"from\": \"2019-03-01\",\n \"to\": \"2019-03-10\"\n },\n \"discount\": {\n \"amount\": 0,\n \"type\": \"percent\"\n },\n \"cash_discounts\": [\n {\n \"days\": 10,\n \"percent\": 2\n }\n ],\n \"shipping_cost\": 700,\n \"application_fee\": 1000,\n \"note\": \"\",\n \"terms\": \"\",\n \"transactions\": [],\n \"positions\": [\n {\n \"id\": \"91m3n01a\",\n \"title\": \"\",\n \"description\": \"\",\n \"type\": \"piece\",\n \"number\": 2,\n \"price\": 1000,\n \"discount\": {\n \"amount\": 0,\n \"type\": \"percent\"\n },\n \"vat\": 0\n }\n ],\n \"payment_link\": \"\",\n \"attachments\": [],\n \"bank_information\": {\n \"iban\": \"\",\n \"name\": \"\",\n \"address\": \"\"\n },\n \"payout_descriptor\": \"\",\n \"psp\": [],\n \"pm\": [],\n \"mails\": [],\n \"reference\": \"myref_0001\",\n \"design\": \"85af2122\",\n \"reminders\": [\n {\n \"id\": \"25dec6ed\",\n \"days\": 20,\n \"friendly\": true,\n \"fee\": 0,\n \"delay_type\": \"days_after_invoice_date\",\n \"status\": \"sent\",\n \"reminder_date\": \"2021-03-17T00:00:00+00:00\"\n },\n {\n \"id\": \"e37eb554\",\n \"days\": 5,\n \"friendly\": true,\n \"fee\": 0,\n \"delay_type\": \"days_before_due_date\",\n \"status\": \"active\",\n \"reminder_date\": \"2021-03-22T00:00:00+00:00\"\n },\n {\n \"id\": \"c17ae3db\",\n \"days\": 20,\n \"friendly\": false,\n \"fee\": 1000,\n \"delay_type\": \"days_after_due_date\",\n \"status\": \"active\",\n \"reminder_date\": \"2021-04-16T00:00:00+00:00\"\n }\n ],\n \"purchaseOnInvoiceInformation\": {\n \"company\": \"Payrexx AG\",\n \"address\": \"Burgstrasse 18\",\n \"zip\": \"3600\",\n \"place\": \"Thun\",\n \"bankName\": \"Klarpay AG\",\n \"swift\": \"KLARCH22XXX\",\n \"iban\": \"CH083000522710975202X\",\n \"reference\": \"287133000000000000000001950\"\n }\n }\n ],\n \"meta\": {\n \"object\": \"merchant_invoice\",\n \"parent\": {\n \"object\": \"merchant\",\n \"id\": \"cedad42m\"\n },\n \"is_list\": false,\n \"isList\": true,\n \"hasMore\": true,\n \"lastElement\": \"37f386cb\"\n }\n}" } }, "schema": { "type": "object", "properties": { "status": { "type": "string", "example": "success" }, "data": { "type": "array", "items": { "type": "object", "properties": { "status": { "type": "string", "example": "draft" } } } } } } } } } } } } } } ``` -------------------------------- ### OpenAPI Definition for Payment Methods Endpoint Source: https://developers.payrexx.com/reference/get-pament-methods-from-terminal This JSON object defines the OpenAPI specification for the GET /ecr/{serialNumber}/paymentMethods API endpoint. It outlines the request parameters, response schema, and example responses. ```json { "openapi": "3.1.0", "info": { "title": "api-settings", "version": "1.0" }, "servers": [ { "url": "https://api.payrexx.com/v1.16" } ], "security": [ {} ], "paths": { "/ecr/{serialNumber}/paymentMethods": { "get": { "description": "", "operationId": "get_ecr{serialNumber}paymentMethods", "responses": { "200": { "description": "", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string" }, "data": { "type": "array", "items": { "properties": { "name": { "type": "string" }, "type": { "type": "string" }, "group": { "type": "string" }, "order_by": { "type": "string" }, "payment_options": { "type": "array", "items": { "properties": {}, "type": "object" } } }, "type": "object" } } }, "required": [ "status" ] }, "examples": { "OK": { "summary": "OK", "value": "{}" } } } } } }, "parameters": [ { "in": "path", "name": "serialNumber", "schema": { "type": "string" }, "required": true } ] } } }, "x-readme": { "headers": [ { "key": "X-API-KEY", "value": "INSTANCE_API_SECRET" } ], "explorer-enabled": false, "proxy-enabled": true }, "x-readme-fauxas": true } ``` -------------------------------- ### Python Example for Creating a Paylink Source: https://developers.payrexx.com/reference/create-a-paylink This Python code snippet demonstrates how to construct a request to create a paylink, including setting payment details and generating an API signature for authentication. ```APIDOC ## Create Paylink ### Description This endpoint allows you to create a new paylink with specified payment details. ### Method POST ### Endpoint https://api.payrexx.com/v1.0/Invoice/ ### Parameters #### Request Body - **title** (string) - Required - The title of the paylink. - **description** (string) - Optional - A description for the paylink. - **psp** (integer) - Required - The ID of the Payment Service Provider. - **referenceId** (string) - Optional - A unique reference ID for the transaction. - **purpose** (string) - Optional - The purpose of the payment. - **amount** (integer) - Required - The total amount in the smallest currency unit (e.g., cents). - **vatRate** (float) - Optional - The VAT rate applied to the amount. - **currency** (string) - Required - The ISO 4217 currency code (e.g., "CHF"). - **sku** (string) - Optional - The Stock Keeping Unit. - **preAuthorization** (integer) - Optional - Set to 1 for pre-authorization, 0 otherwise. - **reservation** (integer) - Optional - Set to 1 for reservation, 0 otherwise. - **ApiSignature** (string) - Required - The API signature generated for authentication. ### Request Example ```python import urllib.request import hmac import hashlib import base64 import json post_data = { "title": "test", "description": "test", "psp": 1, "referenceId": "test", "purpose": "test", "amount": 200, "vatRate" : 7.7, "currency": "CHF", "sku": "P01122000", "preAuthorization": 0, "reservation": 0, } data = urllib.parse.urlencode(post_data).encode('UTF-8') dig = hmac.new(b'INSTANCE_API_SECRET', msg=data, digestmod=hashlib.sha256).digest() post_data['ApiSignature'] = base64.b64encode(dig).decode() data = urllib.parse.urlencode(post_data, quote_via=urllib.parse.quote).encode('UTF-8') result = urllib.request.urlopen('https://api.payrexx.com/v1.0/Invoice/?instance=INSTANCE_NAME', data) content = result.read().decode('UTF-8') response = json.loads(content) invoice = response['data'][0] print(invoice) ``` ### Response #### Success Response (200) - **data** (array) - An array containing the created invoice object. - **id** (integer) - The unique ID of the invoice. - **amount** (integer) - The amount of the invoice. - **currency** (string) - The currency of the invoice. - **status** (string) - The status of the invoice (e.g., "open"). - **link** (string) - The URL to the paylink. #### Response Example ```json { "status": "success", "data": [ { "id": 12345, "amount": 200, "currency": "CHF", "status": "open", "link": "https://your-payrexx-instance.payrexx.com/pay/abcdef1234567890" } ] } ``` ``` -------------------------------- ### PHP Autoloader Setup Source: https://developers.payrexx.com/reference/create-a-gateway This snippet shows how to set up an autoloader for PHP classes, typically used when integrating with libraries or SDKs. It registers a function to automatically load class files based on their namespace and directory structure. ```php setUserId(1); // fire request with created and filled authToken request-object. try { $response = $payrexx->create($authToken); // response data can get accessed like this $authToken = $response->getAuthToken(); $authTokenExpirationDate = $response->getAuthTokenExpirationDate(); $link = $response->getLink(); } catch (\Payrexx\PayrexxException $e) { print $e->getMessage(); } ``` -------------------------------- ### Payrexx Invoice Response Example Source: https://developers.payrexx.com/reference/create-a-paylink This example shows the structure of a successful invoice response from the Payrexx API. It includes details such as the payment link, status, and itemized information. ```php Payrexx\Models\Response\Invoice::__set_state(array( 'hash' => '382c85eab7a86278e3c3b06a23af2358', 'link' => 'https://demo.payrexx.com/?payment=382c85eab7a86278e3c3b06a23af2358', 'status' => 'waiting', 'createdAt' => 1418392958, 'referenceId' => 'Order number of my online shop application', 'title' => '', 'description' => '', 'psp' => 1, 'name' => 'Online-Shop payment #001', 'purpose' => 'Shop Order #001', 'amount' => 590, 'vatRate' => 7.7, 'currency' => 'CHF', 'sku' => 'P01122000', 'preAuthorization' => 0, 'reservation' => 0, 'successRedirectUrl' => NULL, 'failedRedirectUrl' => NULL, 'subscriptionState' => false, 'subscriptionInterval' => '', 'subscriptionPeriod' => '', 'subscriptionPeriodMinAmount' => '', 'subscriptionCancellationInterval' => '', 'fields' => array ( 'title' => array ( 'active' => true, 'mandatory' => true, ), 'forename' => array ( 'active' => true, 'mandatory' => true, ), 'surname' => array ( 'active' => true, 'mandatory' => true, ), 'company' => array ( 'active' => true, 'mandatory' => true, ), 'street' => array ( 'active' => false, 'mandatory' => false, ), 'postcode' => array ( 'active' => false, 'mandatory' => false, ), 'place' => array ( 'active' => false, 'mandatory' => false, ), 'country' => array ( 'active' => true, 'mandatory' => true, ), 'phone' => array ( 'active' => false, 'mandatory' => false, ), 'email' => array ( 'active' => true, 'mandatory' => true, ), 'date_of_birth' => array ( 'active' => false, 'mandatory' => false, ), 'terms' => array ( 'active' => true, 'mandatory' => true, ), "privacy_policy" => array ( "active": true, "mandatory": true ), 'custom_field_1' => array ( 'active' => true, 'mandatory' => true, 'names' => array ( 'de' => 'This is a field', 'en' => 'This is a field', 'fr' => 'This is a field', 'it' => 'This is a field', ), ), 'custom_field_2' => array ( 'active' => false, 'mandatory' => false, 'names' => array ( 'de' => '', 'en' => '', 'fr' => '', 'it' => '', ), ), 'custom_field_3' => array ( 'active' => false, 'mandatory' => false, 'names' => array ( 'de' => '', 'en' => '', 'fr' => '', 'it' => '', ), ), 'custom_field_4' => array ( 'active' => false, 'mandatory' => false, 'names' => array ( 'de' => '', 'en' => '', 'fr' => '', 'it' => '', ), ), 'custom_field_5' => array ( 'active' => false, 'mandatory' => false, 'names' => array ( 'de' => '', 'en' => '', 'fr' => '', 'it' => '', ), ), ), 'id' => 8, )) ``` -------------------------------- ### Configure Gateway Details Source: https://developers.payrexx.com/reference/create-a-gateway Sets essential payment details for the gateway, including amount, VAT rate, SKU, currency, and language. ```php $gateway = new \Payrexx\Models\Request\Gateway(); // amount multiplied by 100 $gateway->setAmount(89.25 * 100); // VAT rate percentage (nullable) $gateway->setVatRate(7.70); //Product SKU $gateway->setSku('P01122000'); // currency ISO code $gateway->setCurrency('CHF'); // language ISO code $gateway->setLanguage('DE'); ``` -------------------------------- ### Create QR Code with PHP Source: https://developers.payrexx.com/reference/create-a-qr-code This PHP script demonstrates how to create a QR code using the Payrexx SDK. It requires setting up the autoloader, providing your instance name and secret, and defining the `webshopUrl`. Handle potential exceptions during the API call. ```php setWebshopUrl('https://www.merchant-website.com/cart'); try { $response = $payrexx->create($qrCode); var_dump($response); } catch (\Payrexx\PayrexxException $e) { print $e->getMessage(); } ``` -------------------------------- ### Retrieve Payment Providers using PHP Source: https://developers.payrexx.com/reference/retrieve-all-payment-providers This PHP script demonstrates how to fetch all payment providers using the Payrexx SDK. Initialize the Payrexx client with your instance name and secret, then call the getAll method. ```php getAll($paymentProvider); var_dump($response); } catch (\Payrexx\PayrexxException $e) { print $e->getMessage(); } ```