### Contact Array Example Source: https://developers.payrexx.com/docs/contact This example demonstrates the structure of the contact array, showing all available fields for shopper data. ```php 1, 'title' => 'mister', 'firstname' => 'Max', 'lastname' => 'Muster', 'company' => 'Company', 'street' => 'Street No', 'zip' => 'ZIP code', 'place' => 'Place', 'country' => 'Switzerland', 'countryISO' => 'CH', 'phone' => '', 'email' => 'max.muster@example.com', 'date_of_birth' => '', 'delivery_title' => '', 'delivery_firstname' => '', 'delivery_lastname' => '', 'delivery_company' => '', 'delivery_street' => '', 'delivery_zip' => '', 'delivery_place' => '', 'delivery_country' => '', 'delivery_countryISO' => '', ); ``` -------------------------------- ### Open Payrexx Gateway in Modal Window Source: https://developers.payrexx.com/docs/payrexx-gateway Use this HTML structure and JavaScript to trigger the Payrexx payment gateway in a modal window. Replace the example URL with your Payrexx installation URL and the gateway hash. ```html Open modal window ``` -------------------------------- ### Full Advanced iFrame Integration Example Source: https://developers.payrexx.com/docs/website-iframe A comprehensive example demonstrating dynamic iFrame height adjustment, page scrolling, transaction data handling, and modal closing via postMessage communication. This script requires jQuery and should be placed on the same page as the iFrame. ```javascript var iFrame = jQuery('iframe'); var transaction = null; var lastPostMessageHeight = 0; var updateIframeHeight = function() { var height = lastPostMessageHeight; // This can be individually changed. // Currently the full height is only applied for big displays (> 590px in width) if (window.innerWidth <= 590) { iFrame.css('height', '100%'); } else if (height) { iFrame.css('height', height + 'px'); } }; var scrollPage = function(offset) { var positionToScrollTo = iFrame.position().top + offset; jQuery('body, html').animate({scrollTop: positionToScrollTo}, 1000, 'linear', function() { jQuery(window).trigger('scroll') }); }; var postMessage = function(e) { if (typeof e.data === 'string') { try { var data = JSON.parse(e.data); } catch (e) {} if (data && data.payrexx) { jQuery.each(data.payrexx, function(name, value) { switch (name) { case 'height': lastPostMessageHeight = parseInt(value); updateIframeHeight(); break; case 'top': scrollPage(parseInt(value)); break; case 'transaction': if (typeof value === 'object') { transaction = value; } break; case 'closeModal': window.location.href = value; break; } }); } } }; window.addEventListener('message', postMessage, false); iFrame.on('load', function() { jQuery(this)[0].contentWindow.postMessage(JSON.stringify({origin: window.location.origin}), iFrame.attr('src')); jQuery(window).resize(updateIframeHeight); updateIframeHeight(); }); var t; jQuery(window).scroll(function(event) { window.clearTimeout(t); t = window.setTimeout(function() { iFrame[0].contentWindow.postMessage(JSON.stringify({scrollTopShoppingCart: jQuery(window).scrollTop() - iFrame.position().top}), iFrame.attr('src')); }, 100); }); ``` -------------------------------- ### PHP Example for HTTP POST Request Source: https://developers.payrexx.com/docs/invoice-1 This example shows how to structure an array for an HTTP POST request, likely for creating a transaction or order with product details, custom fields, and other relevant information. ```php 'Product 1, Product 2', 'products' => array( 0 => array( 'name' => 'Product 1', 'price' => 2.9, 'quantity' => 1, 'sku' => '01120001', 'vatRate' => 8, ), 1 => array( 'name' => 'Product 2', 'price' => 1.9, 'quantity' => 1, 'sku' => '01120000', 'vatRate' => 7.7, ), ), 'amount' => 4.8, 'discount' => array( 'code' => NULL, 'amount' => 0, 'percentage' => NULL, ), 'currency' => 'CHF', 'test' => 0, 'referenceId' => '', 'paymentRequestId' => NULL, 'paymentLink' => NULL, 'custom_fields' => array( 1 => array( 'name' => 'Field 1 name', 'value' => 'Field 1 value', ), 2 => array( 'name' => 'Field 2 name', 'value' => 'Field 2 value', ), 3 => array( 'name' => 'Field 3 name', 'value' => 'Field 3 value', ), ), ); ?> ``` -------------------------------- ### Subscription Object Example Source: https://developers.payrexx.com/docs/subscription-3 This PHP array represents a sample subscription object, illustrating the expected data types and structure for each field. ```php 1, 'uuid' => '82m09f9', 'status' => 'active', 'start' => '2020-01-01', 'end' => null, 'valid_until' => '2021-01-01', 'paymentInterval' => 'P1Y', 'invoice' => Invoice, 'contact' => Contact, ); ``` -------------------------------- ### PHP Example for PayPal Billing Agreement ID Source: https://developers.payrexx.com/docs/metadata This snippet shows how to include the `paypalBillingAgreementId` in the metadata for a Payrexx transaction. This is useful when you have activated the 'Create Billing Agreement' option in PayPal settings. ```php array( 'paypalBillingAgreementId' => 'B-XXXXXXXXXXXXXX', ), ); ``` -------------------------------- ### Open Payrexx Modal Window Source: https://developers.payrexx.com/docs/modal-window Use this HTML anchor tag and JavaScript snippet to trigger the Payrexx modal window. Replace the placeholder URL with your Payrexx installation URL and payment template ID. ```html Open modal window ``` -------------------------------- ### Advanced iFrame Communication Setup Source: https://developers.payrexx.com/docs/website-iframe Set up a message listener to receive communication from the Payrexx iFrame. This is necessary for advanced features like dynamic height adjustment and transaction updates. Ensure jQuery is included in your project. ```javascript var iFrame = jQuery('iframe'); var postMessage = function(e) { if (typeof e.data === 'string') { try { var data = JSON.parse(e.data); } catch (e) {} if (data && data.payrexx) { jQuery.each(data.payrexx, function(name, value) { switch (name) { // implement functions here } }); } } }; iFrame.on('load', function() { jQuery(this)[0].contentWindow.postMessage(JSON.stringify({origin: window.location.origin}), iFrame.attr('src')); }); window.addEventListener('message', postMessage, false); ``` -------------------------------- ### Payrexx Transaction Object Example Source: https://developers.payrexx.com/docs/transaction This JSON object represents a typical Payrexx transaction, including payment details, metadata, and status. It is useful for understanding the data structure returned by the Payrexx API. ```json { "id": 1, "uuid": "82m09f9", "time": "2014-11-18 13:44:53", "status": "waiting", "lang": "en", "psp": "Native_PSP", "pspId": 44, "payrexxFee": 0, "payment": { "brand": "visa", "wallet": null, "cardholderName": "Erika Mustermann", "purchaseOnInvoiceInformation": { "zip": "3600", "iban": "CH7431101111011000246", "place": "Thun", "swift": "KLARCH22XXX", "address": "Burgstrasse 20", "company": "Payrexx AG", "bankName": "Klarpay AG", "reference": "287133000000000000000128000" } }, "metadata": { /* Metadata object */ }, "invoice": { /* Invoice object */ }, "contact": { /* Contact object */ }, "type": "E-Commerce", "posSerialNumber": "N500W123456", "posTerminalName": "Cash register 1" } ``` -------------------------------- ### Payrexx Modal Initialization with Advanced Options Source: https://developers.payrexx.com/docs/modal-window Demonstrates how to initialize the Payrexx modal with various advanced options. ```APIDOC ## Payrexx Modal Initialization with Advanced Options ### Description This section covers the initialization of the Payrexx modal with advanced configuration options. ### Method JavaScript (jQuery plugin) ### Endpoint N/A (Client-side JavaScript) ### Parameters #### Request Body (Options Object) - **hideObjects** (Array) - Optional - An array of CSS selectors to hide elements within the payment template. - **show** (Function) - Optional - A callback function executed before the modal is shown. Useful for form validation. - **shown** (Function) - Optional - A callback function executed after the modal is shown. - **hide** (Function) - Optional - A callback function executed before the modal is hidden. - **hidden** (Function) - Optional - A callback function executed after the modal is hidden. Useful for post-transaction actions. ### Request Example ```javascript jQuery(".payrexx-modal-window").payrexxModal({ hideObjects: ['#contact-details', '.contact'], hidden: function(transaction) { location.href = "http://mywebsite.com/thank-you-for-your-payment"; }, show: function(e) { if (validateMyForm()) { return true; } return e.preventDefault(); } }); ``` ### Response N/A (Client-side configuration) ``` -------------------------------- ### Set QR Code Session ID and Return App Parameters Source: https://developers.payrexx.com/docs/qr-code When creating a payment gateway, pass the QR code session ID and determine the appropriate return app parameter for iOS or Android. ```php $gateway->setQrCodeSessionId($_GET['qr_code_session_id']); if ($_GET['returnAppScheme']) { $returnApp = 'returnAppScheme=' . $_GET['returnAppScheme']; // iOS } else if ($_GET['returnAppPackage']) { $returnApp = 'returnAppPackage=' . $_GET['returnAppPackage']; // Android } $gateway->setReturnApp($returnApp); ``` -------------------------------- ### Set Redirect URLs for Non-TWINT Payments Source: https://developers.payrexx.com/docs/qr-code For payments initiated by regular QR code scanners, set success, failed, and cancel redirect URLs when creating the gateway. ```php $gateway->setSuccessRedirectUrl('https://www.merchant-website.com/success'); $gateway->setFailedRedirectUrl('https://www.merchant-website.com/failed'); $gateway->setCancelRedirectUrl('https://www.merchant-website.com/cancel'); ``` -------------------------------- ### Include Payrexx Gateway JS Scripts Source: https://developers.payrexx.com/docs/payrexx-gateway Include these scripts in the head section of your HTML file to enable the Payrexx modal window functionality. Ensure jQuery is loaded before the Payrexx script. ```html ``` -------------------------------- ### Listen for Payrexx Gateway Messages Source: https://developers.payrexx.com/docs/mobile-apps-javascript Add an event listener to the window to capture messages from the Payrexx Gateway iFrame. This is essential for receiving transaction status updates. ```javascript window.addEventListener('message', handleMessage(this), false); ``` -------------------------------- ### Form Validation Before Opening Payrexx Modal Source: https://developers.payrexx.com/docs/modal-window Utilize the `show` function to perform form validation before the Payrexx modal is displayed. Return `true` to proceed or `e.preventDefault()` to stop the modal from opening. ```javascript jQuery(".payrexx-modal-window").payrexxModal({ show: function(e) { if (validateMyForm()) { return true; } return e.preventDefault(); } }); ``` -------------------------------- ### Gateway Response with App Link Source: https://developers.payrexx.com/docs/qr-code The gateway response contains an appLink which should be opened to initiate the TWINT payment process. ```json { "status": "success", "data": [ { "transactionId": "100", "appLink": "intent://payment#Intent;action=ch.twint.action.TWINT_PAYMENT;scheme=twint;S.code=12345;S.startingOrigin=EXTERNAL_WEB_BROWSER;S.browser_fallback_url=;end", // Android // "appLink": 'twint-issuer1://applinks/?al_applink_data={\"app_action_type\": \"TWINT_PAYMENT\",\"extras\": {\"code\": \"12345\"},\"referer_app_link\": {\"target_url\": \"\", \"url\": \"\", \"app_name\": \"EXTERNAL_WEB_BROWSER\"}, \"version\": \"6.0\" }' // iOS } ] } ``` -------------------------------- ### Include Payrexx Modal Resources Source: https://developers.payrexx.com/docs/modal-window Include these script tags in the
section of your HTML to enable the Payrexx modal functionality. Ensure jQuery is included before the Payrexx modal script. ```html ``` -------------------------------- ### Basic iFrame Integration Source: https://developers.payrexx.com/docs/website-iframe Embed a Payrexx payment page directly into your website by pasting this HTML code into your page. Replace the `src` URL with your specific payment page URL. ```html ``` -------------------------------- ### Process incoming transaction data in PHP Source: https://developers.payrexx.com/docs/webhooks This PHP snippet demonstrates how to access transaction data sent via a webhook POST request. It checks if transaction data exists and extracts invoice and contact information. ```php 1, 'title' => 'mister', 'firstname' => 'Max', 'lastname' => 'Muster', 'company' => 'Company', 'street' => 'Street No', 'zip' => 'ZIP code', 'place' => 'Place', 'country' => 'Switzerland', 'countryISO' => 'CH', 'phone' => '', 'email' => 'max.muster@example.com', 'date_of_birth' => '', 'delivery_title' => '', 'delivery_firstname' => '', 'delivery_lastname' => '', 'delivery_company' => '', 'delivery_street' => '', 'delivery_zip' => '', 'delivery_place' => '', 'delivery_country' => '', 'delivery_countryISO' => '', ); ``` ``` -------------------------------- ### Handle Payrexx Transaction Messages Source: https://developers.payrexx.com/docs/mobile-apps-javascript Implement the handleMessage function to parse incoming JSON data from the Payrexx Gateway. It checks for transaction status, allowing you to handle success or failure scenarios. ```javascript function handleMessage(e) { if (typeof e.data === 'string') { try { var data = JSON.parse(e.data); } catch (e) {} if (data && data.payrexx) { jQuery.each(data.payrexx, function(name, value) { switch (name) { case 'transaction': if (typeof value === 'object') { if (value.status === 'confirmed') { //handling success } else { //handling failure } } break; } }); } } } ``` -------------------------------- ### Custom Redirect After Payment in Payrexx Modal Source: https://developers.payrexx.com/docs/modal-window Implement a custom `hidden` function to redirect the user to a specific URL after a successful transaction. This is useful for displaying a 'Thank you' message. ```javascript jQuery(".payrexx-modal-window").payrexxModal({ hidden: function(transaction) { location.href = "http://mywebsite.com/thank-you-for-your-payment"; } }); ``` -------------------------------- ### Transaction Object Fields Source: https://developers.payrexx.com/docs/transaction This section details the fields available within a transaction object. ```APIDOC ## Transaction Object Fields This section details the fields available within a transaction object. ### Fields - **id** (integer) - Internal transaction ID - **uuid** (string|integer) - Public transaction ID - **time** (datetime) - Date and time of transaction creation (format: YYYY-MM-DD HH:MM:SS) - **status** (string) - The status of the transaction. Possible values include: `waiting`, `confirmed`, `cancelled`, `declined`, `authorized`, `reserved`, `refunded`, `refund_pending`, `partially-refunded`, `chargeback`, `error`, `uncaptured`. - **lang** (string) - ISO 639-1 code of the shopper's language. - **psp** (string) - The name of the payment service provider. - **pspId** (integer) - The ID of the payment service provider. - **amount** (integer) - The amount of the transaction in the smallest unit of the transaction currency. For refunds, this is the amount of the refund transaction. - **payrexxFee** (integer) - The transaction fee charged by Payrexx in the smallest unit of the currency (excluding acquiring or interchange fees). - **preAuthorizationId** (integer) - The ID of the origin pre-authorization transaction. - **payment** (object) - Details about the payment method. - **brand** (string) - The brand of the payment method (lowercase). - **cardNumber** (string) - The truncated card number (PAN). - **expiry** (string) - The expiry date of the card (format: YY-MM). - **wallet** (string) - The name of the wallet used (lowercase). - **cardholderName** (string) - The name of the cardholder. - **referenceId** (string) - The reference passed when creating a Gateway or Invoice. ``` -------------------------------- ### Extract Transaction ID from Gateway Response Source: https://developers.payrexx.com/docs/preauthorization This JSON structure shows where to find the transaction ID within the response when retrieving a gateway. Ensure the 'reservation' parameter was set to true during gateway creation. ```json { "status": "success", "data": [ { "id": 1, "status": "(waiting|confirmed|authorized|reserved)", "invoices": [ { "transactions": [ { "id": 2012844, } ], } ], } ] } ``` -------------------------------- ### Transaction Fields Source: https://developers.payrexx.com/docs/transaction This section details the various fields available for a Payrexx transaction, including their types and descriptions. ```APIDOC ## Transaction Fields ### Description This section details the various fields available for a Payrexx transaction, including their types and descriptions. ### Parameters #### Query Parameters - **referenceId** (string) - Optional - The referenceId which has been passed along with a charge on a pre-authorization. #### Request Body - **metadata** (array|object) - Optional - Metadata object. For versions prior to 2021-10-12, an empty object was transferred as an empty array. For versions 2021-10-12 and later, it's a Metadata object. - **subscription** (object) - Optional - Subscription object. - **invoice** (object) - Optional - Invoice object. - **contact** (object) - Optional - Contact object. - **refundable** (boolean) - Optional - Indicates whether refunds are possible. - **partiallyRefundable** (boolean) - Optional - Indicates whether partial refunds are possible. - **purchaseOnInvoiceInformation** (object) - Optional - Introduced in version 2024.06.01. Information on where to transfer the money for bank transfer payments. - **instanceName** (string) - Optional - Name of Instance. - **instanceUuid** (string) - Optional - UUID of Instance. - **type** (string) - Optional - Type of the transaction (POS, E-Commerce). - **posSerialNumber** (string) - Optional - Serial number of the POS terminal. - **posTerminalName** (string) - Optional - Name of the POS terminal. ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the transaction. - **uuid** (string) - The unique universal identifier for the transaction. - **time** (string) - The timestamp of the transaction in 'YYYY-MM-DD HH:MM:SS' format. - **status** (string) - The current status of the transaction (e.g., 'waiting', 'paid', 'failed'). - **lang** (string) - The language code for the transaction. - **psp** (string) - The Payment Service Provider used for the transaction. - **pspId** (integer) - The ID of the Payment Service Provider. - **payrexxFee** (float) - The fee charged by Payrexx for the transaction. - **payment** (object) - Contains details about the payment method. - **brand** (string) - The brand of the payment card or wallet. - **wallet** (string|null) - The type of digital wallet used, if any. - **cardholderName** (string) - The name of the cardholder. - **purchaseOnInvoiceInformation** (object) - Information for purchase on invoice payments. - **zip** (string) - The postal code. - **iban** (string) - The International Bank Account Number. - **place** (string) - The city or place. - **swift** (string) - The SWIFT/BIC code. - **address** (string) - The street address. - **company** (string) - The company name. - **bankName** (string) - The name of the bank. - **reference** (string) - The payment reference number. - **metadata** (object) - Metadata associated with the transaction. - **invoice** (object) - Invoice details for the transaction. - **contact** (object) - Contact information related to the transaction. - **type** (string) - The type of transaction (e.g., 'E-Commerce', 'POS'). - **posSerialNumber** (string) - The serial number of the POS terminal, if applicable. - **posTerminalName** (string) - The name of the POS terminal, if applicable. ### Request Example ```json { "referenceId": "preauth123", "metadata": { "order_id": "ORD-98765" }, "subscription": { "period": "monthly", "amount": 1000 }, "invoice": { "due_date": "2024-12-31" }, "contact": { "email": "customer@example.com" }, "refundable": true, "partiallyRefundable": false, "purchaseOnInvoiceInformation": { "zip": "1234", "iban": "DE89370400440532013000", "place": "Berlin", "swift": "COBADEFFXXX", "address": "Musterstrasse 1", "company": "Musterfirma", "bankName": "Musterbank", "reference": "INV-REF-12345" }, "instanceName": "MyInstance", "instanceUuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "type": "E-Commerce", "posSerialNumber": "SN123456789", "posTerminalName": "Terminal Alpha" } ``` ### Response Example ```json { "id": 123, "uuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "time": "2024-07-26 10:30:00", "status": "paid", "lang": "en", "psp": "Stripe", "pspId": 101, "payrexxFee": 2.50, "payment": { "brand": "mastercard", "wallet": null, "cardholderName": "Jane Doe", "purchaseOnInvoiceInformation": { "zip": "1234", "iban": "DE89370400440532013000", "place": "Berlin", "swift": "COBADEFFXXX", "address": "Musterstrasse 1", "company": "Musterfirma", "bankName": "Musterbank", "reference": "INV-REF-12345" } }, "metadata": { "order_id": "ORD-98765" }, "invoice": { "due_date": "2024-12-31" }, "contact": { "email": "customer@example.com" }, "refundable": true, "partiallyRefundable": false, "purchaseOnInvoiceInformation": { "zip": "1234", "iban": "DE89370400440532013000", "place": "Berlin", "swift": "COBADEFFXXX", "address": "Musterstrasse 1", "company": "Musterfirma", "bankName": "Musterbank", "reference": "INV-REF-12345" }, "instanceName": "MyInstance", "instanceUuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "type": "E-Commerce", "posSerialNumber": "SN123456789", "posTerminalName": "Terminal Alpha" } ``` ``` -------------------------------- ### Hide Contact Details in Payrexx Modal Source: https://developers.payrexx.com/docs/modal-window Use the `hideObjects` parameter to specify CSS selectors for elements to hide within the payment template's contact details section. ```javascript jQuery(".payrexx-modal-window").payrexxModal({ hideObjects: ['#contact-details', '.contact'] }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.