# One payments platform. Two ways to build on it. Source: https://docs.payroc.com/solutions Solutions # One payments platform. *Two ways to build on it.* Payroc offers two integration tracks to fit different partner needs. Get up and running with minimal development effort, or build with the full power of our platform. [Compare Essentials and Full Stack](#compare) [Explore the integration guides](/guides) **Low-code** Essentials integration **Full API** Full Stack integration **In person** Payment device solutions **Online** Hosted and API payment options Choose your path ## Essentials or Full Stack Choose the integration effort, feature set and level of control that fit your team. Essentials ### Get up and running with low-code Powerful payment solutions without a lengthy development project. | Attribute | Essentials | | --- | --- | | Best for | Quick setup, self-service integration | | Integration effort | Low-code | | Features | Reduced feature set | | Payroc involvement | Minimal after setup | | Upgrade path | [Contact us](https://payroc.com/contacts-developer/) to move to Full Stack at any time | [Explore Essentials](#essentials) [Essentials overview](/solutions/essentials) Full Stack ### Build with the full platform Deep API integrations, advanced features and closer Payroc partnership. | Attribute | Full Stack | | --- | --- | | Best for | Deep customization and control | | Integration effort | Full API | | Features | Full feature set | | Payroc involvement | Closer ongoing partnership | | Capabilities | Board merchants, take payments, view reports and fund merchants | [Explore Full Stack](#full-stack) [Full Stack overview](/solutions/full-stack) Essentials ## Low-code payment solutions Choose from in-person and online payment options. Once you have your API key, our self-service solutions let you integrate and go live on your own schedule. ### Hosted Payment Page Add a secure Payroc-hosted payment page to a merchant's website. We handle the customer's sensitive payment information, reducing the merchant's PCI compliance obligations. - No payment form to build or maintain - Card and bank transfer payments - One-time payments and subscription billing - Customizable checkout experience **Online** Channel **Low-code** Integration [Learn about Hosted Payment Page](/solutions/essentials/online-payments/hosted-payment-page) ### Payment Links Create a shareable link to a secure hosted payment page. Request payments for invoices, donations or one-off purchases without a website or checkout integration. - Share links through your preferred channel - One-time or reusable links - Fixed or customer-entered amounts - Manage links through the API or Self-Care Portal **Online** Channel **Hosted link** Payment experience [Learn about Payment Links](/solutions/essentials/online-payments/payment-links) ### Payroc Cloud Connect your POS to payment devices through our gateway to run card sales and refunds. Your POS does not need a direct connection to the payment device. - Low-code POS integration - Devices in different physical locations - Android and non-Android device options - Cloud-based device management **In person** Channel **Through the gateway** Connection [Learn about Essentials Payroc Cloud](/solutions/essentials/in-person-payments/payroc-cloud) ### Hosted Fields Embed payment fields directly in a merchant's checkout page so customers can complete payments without a redirect. - Hosted card, ACH and PAD fields - Tokenized payment details - Built-in input validation - Customize the checkout appearance **Online** Channel **Embedded fields** Payment experience [Learn about Hosted Fields](/solutions/essentials/online-payments/hosted-fields) [All Essentials in-person solutions](/solutions/essentials/in-person-payments) [All Essentials online solutions](/solutions/essentials/online-payments) Full Stack ## Payments as part of your product Use a single specialized solution or a complete end-to-end payments platform. Full Stack covers merchant boarding, payments, reporting and funding. ### Board merchants Scale your business by adding merchants with our boarding solutions. [Explore merchant boarding](/solutions/full-stack/board-merchants/boarding) ### Take payments Use physical devices at the point of sale and e-commerce solutions for online payments. - In-person payments with physical devices - Online payments through our API and hosted solutions - Payroc Cloud for semi-integrated payments [Full Stack in-person solutions](/solutions/full-stack/take-payments/in-person-payments) [Full Stack online solutions](/solutions/full-stack/take-payments/online-payments) [Full Stack Payroc Cloud](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) ### View reports Access live transaction data from your merchants. View settled transactions and batches to reconcile transactions and verify merchant payouts. [Real-time transaction data](/solutions/full-stack/view-reports/real-time-transaction-data) [Settlement data](/solutions/full-stack/view-reports/settlement-data) ### Fund merchants Pay your merchants with our funding solutions. [Explore merchant funding](/solutions/full-stack/fund-merchants/funding) Build with the documentation ## Choose your next step ### Follow a guide Work through the shared integration procedures for your chosen solution. [Browse the guides](/guides) ### Explore the API Read the authentication guidance and canonical operation reference. [Open the API reference](/api) ### Follow a workflow Explore documented sequences of API requests and integration steps. [Browse the workflows](/workflows) ## Find the right solution for your integration. Compare the two tracks, explore their guides, or contact our experts for help choosing the solution that fits your needs. [Explore the guides](/guides) [Contact our team](https://payroc.com/contacts-developer/) # Essentials Source: https://docs.payroc.com/solutions/essentials Overview of Essentials as a suite of low-code payment solutions for merchants who want fast, self-service integration for in-person and online payments. Our Essentials solutions are low-code payment options designed to get you up and running quickly without a lengthy development project. Because our Essentials solutions are self-service by design, once you have your API key you can integrate and go live on your own schedule. - **Low-code setup** - Integrate without building a full API implementation from scratch. - **In-person and online options** - Choose the solution that fits your needs. - **Upgrade at any time** - Start your journey with our Essentials solutions and upgrade to Full Stack at any time. #### [In-person payments](/solutions/essentials/in-person-payments) Take payments at the counter with minimal setup and no deep device integrations. [Learn more about in-person payments →](/solutions/essentials/in-person-payments) #### [Online payments](/solutions/essentials/online-payments) Add a payment experience to any website or send a payment link, with minimal development effort. [Learn more about online payments →](/solutions/essentials/online-payments) # In-person payments Source: https://docs.payroc.com/solutions/essentials/in-person-payments Overview of Payroc Essentials in-person payment solutions, including Payroc Cloud, Roc Terminal+, and Roc Services for point-of-sale payment acceptance. Our Essentials in-person payment solutions give you a range of options for taking payments at the point of sale, from connecting your existing POS to payment devices to fully managed no-code payment and invoicing apps. #### [Payroc Cloud](/solutions/essentials/in-person-payments/payroc-cloud) Use our semi-integrated solution to run transactions without a direct connection between the POS and payment device. [Learn more about Payroc Cloud →](/solutions/essentials/in-person-payments/payroc-cloud) #### [Roc Terminal+](/solutions/essentials/in-person-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. [Learn more about Roc Terminal+ →](/solutions/essentials/in-person-payments/roc-terminal) #### [Roc Services](/solutions/essentials/in-person-payments/roc-services) Handle scheduling, invoicing, and payments in one system. [Learn more about Roc Services →](/solutions/essentials/in-person-payments/roc-services) # Payroc Cloud Source: https://docs.payroc.com/solutions/essentials/in-person-payments/payroc-cloud Overview of Payroc Cloud as a semi-integrated POS payment solution that connects payment devices to a POS system through the gateway without requiring a direct device connection. Payroc Cloud is our semi-integrated payments solution that allows your POS to communicate with payment devices through our gateway to run card sales and refunds. The key advantage is that your POS doesn't need a direct connection to the payment device. Payroc Cloud is an ideal Essentials solution if you want to use payment devices in different physical locations from your POS and want to get set up quickly with minimal development effort. ![Payroc Cloud solution image](/assets/live/solutions/payroc-cloud-solution.png) ## Key capabilities **Speed and simplicity** - Integrate with just a few lines of code. - Access over 30 payment devices through a single integration. - Get up and running quicker, with significantly less coding, testing, and certification than traditional API integrations. **Scalability** - Integrate new devices seamlessly with no additional development work. - Add new features and technologies as they become available with minimal effort. - Use Android or non-Android payment devices or both. **Security** - Use our PCI-DSS-compliant Payroc app that is available for Android devices. - Eliminate the need to develop your own payment application or handle sensitive card data directly. **Cloud-based management** - Sync and update payment devices easily via the cloud. - Remove the need for physical connections between your POS and your payment devices. - Operate anywhere with an internet connection. ## How to use Payroc Cloud Use our low-code API solution to integrate your POS with Payroc Cloud. To view our integration guides, go to [Payroc Cloud](/guides/payments/payroc-cloud). After you integrate with Payroc Cloud, you can use our Payroc Cloud Simulator to test your integration without using a physical device. For more information, go to [Payroc Cloud Simulator](/knowledge/testing/payroc-cloud-simulator). ## You might also be interested in... #### [Roc Terminal+](/solutions/essentials/in-person-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. #### [Roc Services](/solutions/essentials/in-person-payments/roc-services) Handle scheduling, invoicing, and payments in one system. # Roc Terminal+ Source: https://docs.payroc.com/solutions/essentials/in-person-payments/roc-terminal Overview of Roc Terminal+ as a no-code, multi-platform in-person payment solution supporting cards, bank transfers, recurring payments, and pre-authorizations on desktop, mobile, and compatible payment devices. Roc Terminal+ is our versatile payment solution that lets merchants accept a wide range of payments from a single application. Roc Terminal+ is optimized to run on desktop, mobile, and compatible payment devices, providing a seamless and adaptable solution that scales with any business. Roc Terminal+ is perfect if you need a no-code solution with a rapid setup-to-market timeline. ![Roc Terminal plus](/assets/live/solutions/roc-terminal-plus.png) ## Key capabilities **Flexible payment processing** - Facilitate a wide range of payment types from a single terminal, including cards, bank transfers, cash, and gift cards. - Enable recurring payments, pre-authorizations, and remote payment links to support diverse billing and checkout workflows. - Deliver mobile payment convenience with Bluetooth card-reader compatibility for merchants who are on the go. **Multi-platform capability** - Set up Roc Terminal+ on desktop to provide your merchants with a full-featured application, including an optional virtual terminal. - Give your merchants the ability to accept payments anywhere with Roc Terminal+ mobile apps on iOS and Android. - Deploy Roc Terminal+ directly on compatible payment devices such as the Newland N950 and X800 for maximum versatility. **Reporting, transaction, and inventory management** - Provide your merchants with real-time and historical transaction data to gain visibility into business trends and product performance. - Synchronize Roc Terminal+ with QuickBooks for accurate, real-time accounting. - Support inventory management to keep product data organized and up to date. ## How to use Roc Terminal+ We provide you with everything you need to quickly onboard merchants to Roc Terminal+. We set up all Roc Terminal+ merchants on the desktop application, and can extend their setup to the mobile application on iOS, Android, or compatible payment devices based on their requirements. For more information about getting set up with Roc Terminal+, [contact us](https://payroc.com/contacts/). To view helpful articles about how to use Roc Terminal+, go to our [Support Hub](https://support.payroc.com/en_US/roc-terminal). ## You might also be interested in... #### [Payment Links](/solutions/full-stack/take-payments/online-payments/payment-links) Generate and send URLs to collect payments from customers. #### [Roc Services](/solutions/essentials/in-person-payments/roc-services) Handle scheduling, invoicing, and payments in one system. #### [Payroc Cloud](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) Use our semi-integrated solution to run transactions without a direct connection between the POS and payment device. # Roc Services Source: https://docs.payroc.com/solutions/essentials/in-person-payments/roc-services Overview of Roc Services as a no-code scheduling, invoicing, and payment solution for service-based merchants on desktop and mobile. Roc Services is our scheduling and invoicing solution for service-based merchants. Optimized for both desktop and mobile, Roc Services brings appointments, payments, and reporting together in a single, easy-to-use solution. Roc Services is ideal if you need a no-code invoicing tool that scales with your merchants' businesses. ![Roc services image](/assets/live/solutions/roc-services.png) ## Key capabilities **Convenience and flexibility** - Facilitate payments on-the-go from any location where merchants have internet access. - Support recurring payments to help merchants automate consistent and timely customer billing. - Provide built-in tools for merchants to send estimates and invoices directly to their customers. **Appointment and customer management** - Help merchants reduce missed appointments with automated reminders. - Let merchants store customer information and transaction history to strengthen merchant-customer relationships. - Ensure service traceability for merchants by linking estimates and invoices to appointments in the scheduler. - Synchronize Roc Services with QuickBooks for accurate, real-time accounting. **Multi-platform and multi-user capability** - Offer a full-featured desktop application with virtual terminal, reporting, and scheduling tools. - Set up the mobile app on Android and iOS with our optional card reader to provide extra payment convenience for merchants in the field. - Allow merchants to configure and manage multiple user roles across both in-office and field operations. **Customizable and scalable** - Give merchants the tools to build complete catalogs for easy management of their products and services. - Deliver detailed reporting capabilities so merchants can monitor performance across services, users, and locations. ## How to use Roc Services We provide everything to quickly get merchants up and running with Roc Services on both desktop and mobile. For more information about getting set up with Roc Services, [contact us](https://payroc.com/contacts/). To view helpful articles about how to use Roc Services, go to our [Support Hub](https://support.payroc.com/en_US/roc-services). ## You might also be interested in... #### [Payment Links](/solutions/full-stack/take-payments/online-payments/payment-links) Generate and send URLs to collect payments from customers. #### [Roc Terminal+](/solutions/essentials/in-person-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. #### [Payroc Cloud](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) Use our semi-integrated solution to run transactions without a direct connection between the POS and payment device. # Online payments Source: https://docs.payroc.com/solutions/essentials/online-payments Overview of Essentials online payment solutions including Hosted Fields, Hosted Payment Page, Payment Links, and no-code terminal and invoicing options. Our Essentials online payment solutions give you a range of options for taking payments online, from embedding payment fields directly in your checkout to sending a payment link with no website integration needed. #### [Hosted Fields](/solutions/essentials/online-payments/hosted-fields) Add secure payment fields directly into a merchant's checkout page. [Learn more about Hosted Fields →](/solutions/essentials/online-payments/hosted-fields) #### [Hosted Payment Page](/solutions/essentials/online-payments/hosted-payment-page) Add a secure payment page to a merchant's website. [Learn more about Hosted Payment Page →](/solutions/essentials/online-payments/hosted-payment-page) #### [Payment Links](/solutions/essentials/online-payments/payment-links) Generate and send URLs to collect payments from customers. [Learn more about Payment Links →](/solutions/essentials/online-payments/payment-links) #### [Roc Terminal+](/solutions/essentials/online-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. [Learn more about Roc Terminal+ →](/solutions/essentials/online-payments/roc-terminal) #### [Roc Services](/solutions/essentials/online-payments/roc-services) Handle scheduling, invoicing, and payments in one system. [Learn more about Roc Services →](/solutions/essentials/online-payments/roc-services) # Hosted Fields Source: https://docs.payroc.com/solutions/essentials/online-payments/hosted-fields Overview of Hosted Fields as an online payment solution for merchants who want to embed card, ACH, and PAD payment forms directly into their checkout page without redirects. Our Hosted Fields solution lets you add payment fields directly to a merchant's checkout page, allowing customers to complete payments without any redirects or interruptions. Hosted Fields are ideal for an online retailer or any business that needs to accept payments directly on their platforms without the complexity of handling sensitive payment data. ## Key capabilities **Seamless checkout experience** - Embed payment fields directly on a merchant's website or mobile application. - Provide built-in input validation that detects invalid values and provides immediate feedback to customers. - Support both desktop and mobile applications. **Secure data handling** - Reduce the merchant's PCI compliance burden by hosting the payment fields. - Process payments securely using tokenized payment details. - Launch or update your checkout workflow quickly with security and compliance handled for you. **Versatile payment options** - Accept card, ACH, and PAD payments. - Use the payment form to run a sale, save a customer's payment details, or update a customer's saved payment details. **Customizable checkout** - Customize the appearance of the checkout page to match the merchant's branding. - Add custom fields to collect additional information from the customer. ## How to use Hosted Fields Use our Hosted Fields solution to create a payment form to take payments and manage customers' payment details. For detailed integration steps, go to our integration guide for [Hosted Fields](/guides/payments/hosted-fields). To perform follow-on actions for Hosted Fields transactions, such as refunds and reversals, you need to integrate with our API. For more information about our API, go to our [API Explorer](/api). ## You might also be interested in... #### [Hosted Payment Page](/solutions/essentials/online-payments/hosted-payment-page) Add a secure payment page to a merchant's website. #### [Payment Links](/solutions/essentials/online-payments/payment-links) Generate and send URLs to collect payments from customers. # Hosted Payment Page Source: https://docs.payroc.com/solutions/essentials/online-payments/hosted-payment-page Overview of Hosted Payment Page as a low-code online payment solution for merchants who want a Payroc-hosted, PCI-compliant checkout page. Our Hosted Payment Page solution allows merchants to easily add a secure payment page to their website, enabling customers to enter their payment details safely. Because we host the page, we handle the customer's sensitive payment information, significantly reducing the merchant's PCI compliance obligations. Our Hosted Payment Page solution is a low-code option for businesses that want to accept online payments without the complexity of handling sensitive payment data. ## Key capabilities **Simple, low-effort integration** - Eliminate the need to build or maintain your own payment form. - Reduce the merchant's PCI scope by relying on us to handle all sensitive payment data. **Flexible payment capabilities** - Accept card payments or bank transfer payments. - Expand your payment options to digital wallets and cryptocurrency with BeadPay. - Support one-time payments, pre-authorizations, delayed captures, and subscription billing. - Use tokenization for recurring and merchant-initiated transactions. - Take advantage of built-in security tools like 3-D Secure and AVS. **Customizable, scalable checkout experience** - Present a clean and responsive UI across desktop, tablet, and mobile devices. - Customize the checkout process for your customers for a seamless experience. ## How to use our Hosted Payment Page There are two ways to use our Hosted Payment Page: - [Integrate with our API](#api-integration). - [Use our Self-Care Portal](#self-care-portal). ### API integration Integrate with our low-code Hosted Payment Page methods to add a payment page to a merchant's website. For detailed integration steps, go to our integration guide for [Hosted Payment Page](/guides/payments/hosted-payment-page/overview). To perform follow-on actions, such as refunds, integrate with our other Payments methods. For more information about our Payroc API and other follow-on actions, go to our [API Explorer](/api). ### Self-Care Portal You can create a Hosted Payment Page on our Self-Care Portal. For more information about how to use the Self-Care Portal to create a Hosted Payment Page, [contact us](https://payroc.com/contacts/). ## You might also be interested in... #### [Hosted Fields](/solutions/essentials/online-payments/hosted-fields) Add secure payment fields directly into a merchant's checkout page. #### [Payment Links](/solutions/essentials/online-payments/payment-links) Generate and send URLs to collect payments from customers. # Payment Links Source: https://docs.payroc.com/solutions/essentials/online-payments/payment-links Overview of Payment Links as a solution for merchants to create and share secure hosted payment URLs without requiring a website or checkout integration. Our Payment Links solution allows a merchant to create a shareable link that directs a customer to a secure hosted payment page. The customer selects the link, completes the payment, and the merchant receives the funds, with no website or checkout integration needed. Payment links are ideal for a wide range of use cases, including invoices, donations, one-off purchases, bill payments, and any scenario where businesses need to request and receive payments quickly and reliably. ![Payment Links solution image](/assets/live/solutions/payment-links-solution.png) ## Key capabilities **On-demand link creation** - Generate payment links on demand. - Share links through the merchant's preferred channel. - Use our API or Self-Care Portal interchangeably. **Flexible configuration** - Create one-time links or reusable links. - Choose between a sale transaction or pre-authorization transaction. - Set up a fixed amount or allow the customer to enter the amount. - Accept card payments, bank transfer, or both. **Secure payment processing** - Redirect customers to a PCI-compliant payment page to make payments. - Limit the merchant's PCI scope as no merchant website is needed. **Tracking and reporting** - View payment statuses to check if the payment is completed or failed. - Access reporting for reconciliation and activity monitoring. - Manage links and follow-on actions from either the API or Self-Care Portal. ## How to use Payment Links There are two ways to use Payment Links: - [Integrate with our API](#api-integration). - [Use our Self-Care Portal](#self-care-portal). Both options provide the same capabilities to create, share, and manage payment links. They also use the same payment link data, so you can create a payment link with one option, and then share the payment link with the other option. ### API Integration Integrate with our low-code Payment Links endpoints to create payment links and share them. For detailed integration steps, go to our integration guide for [Payment Links](/guides/payments/payment-links). To perform follow-on actions, such as refunds, integrate with our other Payments methods. For more information about our Payroc API and other follow-on actions, go to our [API Explorer](/api). ### Self-Care Portal Our Payment Links solution can also be used through our Self-Care Portal. This no-code option allows merchants to create and share payment links without any development work. For more information about Payment Links, go to our [Support Hub](https://support.payroc.com/en_US/self-care-portal-payment-links). ## You might also be interested in... #### [Hosted Fields](/solutions/essentials/online-payments/hosted-fields) Add secure payment fields directly into a merchant's checkout page. #### [Hosted Payment Page](/solutions/essentials/online-payments/hosted-payment-page) Add a secure payment page to a merchant's website. # Roc Terminal+ Source: https://docs.payroc.com/solutions/essentials/online-payments/roc-terminal Overview of Roc Terminal+ as a no-code, multi-platform payment solution for accepting cards, bank transfers, and recurring payments from a single application. Roc Terminal+ is our versatile payment solution that lets merchants accept a wide range of payments from a single application. Roc Terminal+ is optimized to run on desktop, mobile, and compatible payment devices, providing a seamless and adaptable solution that scales with any business. Roc Terminal+ is perfect if you need a no-code solution with a rapid setup-to-market timeline. ![Roc Terminal plus](/assets/live/solutions/roc-terminal-plus.png) ## Key capabilities **Flexible payment processing** - Facilitate a wide range of payment types from a single terminal, including cards, bank transfers, cash, and gift cards. - Enable recurring payments, pre-authorizations, and remote payment links to support diverse billing and checkout workflows. - Deliver mobile payment convenience with Bluetooth card-reader compatibility for merchants who are on the go. **Multi-platform capability** - Set up Roc Terminal+ on desktop to provide your merchants with a full-featured application, including an optional virtual terminal. - Give your merchants the ability to accept payments anywhere with Roc Terminal+ mobile apps on iOS and Android. - Deploy Roc Terminal+ directly on compatible payment devices such as the Newland N950 and X800 for maximum versatility. **Reporting, transaction, and inventory management** - Provide your merchants with real-time and historical transaction data to gain visibility into business trends and product performance. - Synchronize Roc Terminal+ with QuickBooks for accurate, real-time accounting. - Support inventory management to keep product data organized and up to date. ## How to use Roc Terminal+ We provide you with everything you need to quickly onboard merchants to Roc Terminal+. We set up all Roc Terminal+ merchants on the desktop application, and can extend their setup to the mobile application on iOS, Android, or compatible payment devices based on their requirements. For more information about getting set up with Roc Terminal+, [contact us](https://payroc.com/contacts/). To view helpful articles about how to use Roc Terminal+, go to our [Support Hub](https://support.payroc.com/en_US/roc-terminal). ## You might also be interested in... #### [Payment Links](/solutions/full-stack/take-payments/online-payments/payment-links) Generate and send URLs to collect payments from customers. #### [Roc Services](/solutions/essentials/online-payments/roc-services) Handle scheduling, invoicing, and payments in one system. #### [Payroc Cloud](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) Use our semi-integrated solution to run transactions without a direct connection between the POS and payment device. # Roc Services Source: https://docs.payroc.com/solutions/essentials/online-payments/roc-services Overview of Roc Services as a no-code scheduling and invoicing solution for service-based merchants, covering appointments, recurring payments, and reporting. Roc Services is our scheduling and invoicing solution for service-based merchants. Optimized for both desktop and mobile, Roc Services brings appointments, payments, and reporting together in a single, easy-to-use solution. Roc Services is ideal if you need a no-code invoicing tool that scales with your merchants' businesses. ![Roc services image](/assets/live/solutions/roc-services.png) ## Key capabilities **Convenience and flexibility** - Facilitate payments on-the-go from any location where merchants have internet access. - Support recurring payments to help merchants automate consistent and timely customer billing. - Provide built-in tools for merchants to send estimates and invoices directly to their customers. **Appointment and customer management** - Help merchants reduce missed appointments with automated reminders. - Let merchants store customer information and transaction history to strengthen merchant-customer relationships. - Ensure service traceability for merchants by linking estimates and invoices to appointments in the scheduler. - Synchronize Roc Services with QuickBooks for accurate, real-time accounting. **Multi-platform and multi-user capability** - Offer a full-featured desktop application with virtual terminal, reporting, and scheduling tools. - Set up the mobile app on Android and iOS with our optional card reader to provide extra payment convenience for merchants in the field. - Allow merchants to configure and manage multiple user roles across both in-office and field operations. **Customizable and scalable** - Give merchants the tools to build complete catalogs for easy management of their products and services. - Deliver detailed reporting capabilities so merchants can monitor performance across services, users, and locations. ## How to use Roc Services We provide everything to quickly get merchants up and running with Roc Services on both desktop and mobile. For more information about getting set up with Roc Services, [contact us](https://payroc.com/contacts/). To view helpful articles about how to use Roc Services, go to our [Support Hub](https://support.payroc.com/en_US/roc-services). ## You might also be interested in... #### [Payment Links](/solutions/full-stack/take-payments/online-payments/payment-links) Generate and send URLs to collect payments from customers. #### [Roc Terminal+](/solutions/essentials/online-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. #### [Payroc Cloud](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) Use our semi-integrated solution to run transactions without a direct connection between the POS and payment device. # Essentials Guides Source: https://docs.payroc.com/solutions/essentials/guides Explore step-by-step guides for integrating with Payroc Cloud, Hosted Payment Page, Hosted Fields, and Payment Links. **Prerequisites:** [Authentication](/api/authentication) AI skills are available for our Essentials Solutions, get them on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Our Essentials guides provide step-by-step instructions to help you integrate with our low-code payment solutions. ## Take payments #### [Payroc Cloud](/guides/payments/payroc-cloud) Use our gateway to initiate payments and refunds on a physical payment device. #### [Hosted Payment Page](/guides/payments/hosted-payment-page/overview) Add a secure hosted payment page to a merchant's website. #### [Hosted Fields](/guides/payments/hosted-fields) Embed secure payment fields directly into a merchant's checkout page. #### [Payment Links](/guides/payments/payment-links) Create a payment link that a merchant shares with a customer. # Full Stack Source: https://docs.payroc.com/solutions/full-stack Overview of Full Stack solutions covering end-to-end payment platform capabilities including merchant boarding, in-person and online payments, reporting, and merchant funding. Whether you need a single, specialized solution or a complete end-to-end payments platform, our Full Stack solutions give you the full power of our platform. Full Stack solutions cover how to: - Board merchants - Take payments - View reports - Fund merchants ## Board merchants #### [Boarding](/solutions/full-stack/board-merchants/boarding) Scale your business by adding merchants with our boarding solutions. ## Take payments #### [In-person payments](/solutions/full-stack/take-payments/in-person-payments) Use physical devices to run payments at the point of sale. #### [Online payments](/solutions/full-stack/take-payments/online-payments) Run online payments with our e-commerce solutions. ## View reports #### [Real-time transaction data](/solutions/full-stack/view-reports/real-time-transaction-data) Access live transaction data from your merchants. #### [Settlement data](/solutions/full-stack/view-reports/settlement-data) View settled transactions and batches to reconcile transactions and verify merchant payouts. ## Fund merchants #### [Funding](/solutions/full-stack/fund-merchants/funding) Pay your merchants with our funding solutions. ## Questions? #### [Contact us](https://payroc.com/contacts/) If you are still unsure about which solution fits your needs, contact our experts to help get you on the right track. # Board merchants Source: https://docs.payroc.com/solutions/full-stack/board-merchants Onboard and configure your merchants. Onboard and configure your merchants. - [Boarding](/solutions/full-stack/board-merchants/boarding) # Boarding Source: https://docs.payroc.com/solutions/full-stack/board-merchants/boarding Overview of the Boarding solution for digitally onboarding merchants by submitting their information programmatically to enable faster account setup. Our Boarding solution allows you to digitally onboard merchants by submitting their information directly from your own software. This removes manual paperwork and speeds up account setup, giving both you and your merchants a smoother onboarding experience. If a full API integration isn't the right fit for you, [contact us](https://payroc.com/contacts/developers-isvs) to discuss alternative boarding options. ## Key capabilities **Speed and efficiency** - Enable merchants to go live quickly with faster application-to-processing time. - Reduce the paperwork burden with a fully digital submission process. - Provide just a few key pieces of information to onboard a merchant. **Seamless integration** - Submit boarding information through a single integration point. - Customize your platform by using only the components you need. **Flexibility** - Support merchants with multiple locations, brands, or business units. - Add processing accounts and contacts as the merchant grows. **Security and compliance** - Focus on working with your merchants while we handle due diligence and risk assessments behind the scenes. - Use our expert underwriting team to ensure merchant compliance. ## How to use Boarding Integrate with our medium-code Boarding endpoints to submit a merchant's legal information and processing account information. After you have boarded the merchant, you can perform follow-on actions, such as adding a processing account or ordering a terminal. For detailed integration steps, go to our integration guide for [Boarding](/guides/boarding). # Take payments Source: https://docs.payroc.com/solutions/full-stack/take-payments Accept in-person and online payments with Full Stack. Accept in-person and online payments with Full Stack. - [In-person payments](/solutions/full-stack/take-payments/in-person-payments) - [Online payments](/solutions/full-stack/take-payments/online-payments) # In-person payments Source: https://docs.payroc.com/solutions/full-stack/take-payments/in-person-payments Overview of in-person payment solutions for merchants, covering API-based, semi-integrated, terminal, and invoicing options. Explore how our in-person payment solutions can fit your needs. #### [Payroc API](/solutions/full-stack/take-payments/in-person-payments/payroc-api) Offer a full payment acceptance solution with broad capabilities. [Learn more about our Payroc API →](/solutions/full-stack/take-payments/in-person-payments/payroc-api) #### [Payroc Cloud](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) Use our semi-integrated solution to run transactions without a direct connection between the POS and payment device. [Learn more about Payroc Cloud →](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) #### [Tap to Pay on iPhone](/solutions/full-stack/take-payments/in-person-payments/tap-to-pay-on-iphone) Accept contactless payments on an iPhone without any other hardware. [Learn more about Tap to Pay on iPhone →](/solutions/full-stack/take-payments/in-person-payments/tap-to-pay-on-iphone) #### [Roc Terminal+](/solutions/essentials/in-person-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. [Learn more about Roc Terminal+ →](/solutions/essentials/in-person-payments/roc-terminal) #### [Roc Services](/solutions/essentials/in-person-payments/roc-services) Handle scheduling, invoicing, and payments in one system. [Learn more about Roc Services →](/solutions/essentials/in-person-payments/roc-services) # Payroc API for in-person payments Source: https://docs.payroc.com/solutions/full-stack/take-payments/in-person-payments/payroc-api Overview of the Payroc API as a fully customizable in-person payment solution for processing sales, pre-authorizations, refunds, and more with certified payment devices. Use our powerful API to design and integrate the perfect payment flow for your merchants. Integrate with any of our methods to build a fully customizable payment solution that delivers the exact look and functionality that your merchant needs. Our Payroc API is ideal if you want to have full control over the payment flow that you want to offer. ![API solution image](/assets/live/solutions/in-person-payments.png) ## Key capabilities **Maximum flexibility** - Process all types of transactions, including sales, pre-authorizations, captures, refunds, and reversals. - Use our API with our certified payment devices or with your own choice of terminals. - Select from multiple form factors designed to fit seamlessly into any retail setting. - Expand your integration and easily deploy new devices and add powerful features. - Provide a unified experience between in-person payments and online payments. **Powerful features** - Offer surcharging and dual pricing options to offset the merchant's processing fees. - Support offline processing, tipping, and custom data fields. - Accept specialized cards like EBT SNAP and healthcare cards. - Run reports to gain immediate, actionable insights for your merchants. **Advanced fraud prevention** - Use tokenization to protect payment information and simplify a merchant's PCI compliance requirements. - Rely on our built-in encryption tools for every transaction to instantly meet security standards with zero effort. - Enable signature capture for easy record-keeping, audit trails, and efficient dispute resolution. **Speed to market** - Choose from our collection of certified devices and instantly eliminate lengthy certification roadblocks. - Lean on our experts for ongoing support and advice to get the most out of your solution. - Follow our comprehensive guides to streamline your development process. ## How to use the Payroc API Follow our [comprehensive guides](/guides/payments) to quickly launch your integration. Our guides cover the basic functions of the API, including: - Run sales and refunds. - Save a customer's payment details. - Verify a customer's payment details. - Schedule repeat payments. ## You might also be interested in... #### [Payroc Cloud](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) Use our semi-integrated solution to run transactions without a direct connection between the POS and payment device. #### [Roc Terminal+](/solutions/essentials/in-person-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. #### [Payroc API for online payments](/solutions/full-stack/take-payments/online-payments/payroc-api) Offer a full payment acceptance solution with broad capabilities. # Payroc Cloud Source: https://docs.payroc.com/solutions/full-stack/take-payments/in-person-payments/payroc-cloud Overview of Payroc Cloud as a semi-integrated POS payments solution that connects payment devices to your POS through the gateway without requiring a direct device connection. Payroc Cloud is our semi-integrated payments solution that allows your POS to communicate with payment devices through our gateway to run card sales and refunds. The key advantage is that your POS doesn't need a direct connection to the payment device. Payroc Cloud is an ideal solution if you want to use payment devices in different physical locations from your POS and want to get set up quickly with minimal development effort. ![Payroc Cloud solution image](/assets/live/solutions/payroc-cloud-solution.png) ## Key capabilities **Speed and simplicity** - Integrate with just a few lines of code. - Access over 30 payment devices through a single integration. - Get up and running quicker, with significantly less coding, testing, and certification than traditional API integrations. **Scalability** - Integrate new devices seamlessly with no additional development work. - Add new features and technologies as they become available with minimal effort. - Use Android or non-Android payment devices or both. **Security** - Use our PCI-DSS-compliant Payroc app that is available for Android devices. - Eliminate the need to develop your own payment application or handle sensitive card data directly. **Cloud-based management** - Sync and update payment devices easily via the cloud. - Remove the need for physical connections between your POS and your payment devices. - Operate anywhere with an internet connection. ## How to use Payroc Cloud Use our low-code API solution to integrate your POS with Payroc Cloud. To view our API guides, which include detailed integration steps, go to [Payroc Cloud](/guides/payments/payroc-cloud). After you integrate with Payroc Cloud, you can use our Payroc Cloud Simulator to test your integration without using a physical device. For more information, go to [Payroc Cloud Simulator](/knowledge/testing/payroc-cloud-simulator). To perform follow-on actions, such as refunds, integrate with our other Payments methods. For more information about our Payroc API and other follow-on actions, go to our [API Explorer](/api/resources/card-payments). ## You might also be interested in... #### [Payroc API](/solutions/full-stack/take-payments/in-person-payments/payroc-api) Offer a full payment acceptance solution with broad capabilities. #### [Roc Terminal+](/solutions/essentials/in-person-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. # Tap to Pay on iPhone Source: https://docs.payroc.com/solutions/full-stack/take-payments/in-person-payments/tap-to-pay-on-iphone Overview of Tap to Pay on iPhone as an in-person payment solution that lets merchants accept contactless payments directly on an iPhone without external hardware. Tap to Pay on iPhone is a solution that allows merchants to accept contactless payments on their iPhone without any other hardware. Merchants can use Tap to Pay on iPhone to run transactions with credit and debit cards, Apple Pay, and other digital wallets. We provide you with an SDK that you can integrate with your iOS app to offer a seamless checkout experience without the need for additional hardware. Tap to Pay on iPhone is an ideal solution if you want to quickly set up merchants to accept in-person payments without the need for external card readers or payment devices. ## Key capabilities ### No additional hardware - Accept card-present payments on an iPhone using Apple's ProximityReader technology. - Remove the need for external terminals or card readers. ### Broad support - Deploy instantly with no hardware setup or certification delays. - Download the SDK package complete with documentation and sample apps to accelerate development. ### Core transaction types - Run sales and referenced refunds. - Accept contactless credit and debit cards, Apple Pay, and other digital wallets that use NFC. ## How to use Tap to Pay on iPhone Use our Tap to Pay on iPhone SDK to create your own iOS app that accepts card-present payments directly on an iPhone. To view our guides, which include detailed steps, go to [Tap to Pay on iPhone guides](/guides/payments/tap-to-pay-on-iphone). We can also provide a ready-to-use app that you can deploy to your merchants. The Mobile Sync app uses our Tap to Pay on iPhone SDK to let your merchants accept payments straightaway. For information about the Mobile Sync app, [contact us](https://payroc.com/contacts/). ## You might also be interested in… #### [Roc Services](/solutions/essentials/in-person-payments/roc-services) Handle scheduling, invoicing, and payments in one system. #### [Roc Terminal+](/solutions/essentials/in-person-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. #### [Payroc Cloud](/solutions/full-stack/take-payments/in-person-payments/payroc-cloud) Use our semi-integrated solution to run transactions without a direct connection between the POS and payment device. # Online payments Source: https://docs.payroc.com/solutions/full-stack/take-payments/online-payments Overview of Payroc's online payment solutions, including the Payroc API, Payment Links, Hosted Fields, Hosted Payment Page, and no-code terminal options. Explore how our online payment solutions can fit your needs. #### [Payroc API](/solutions/full-stack/take-payments/online-payments/payroc-api) Offer a full payment acceptance solution with broad capabilities. [Learn more about our Payroc API →](/solutions/full-stack/take-payments/online-payments/payroc-api) #### [Payment Links](/solutions/full-stack/take-payments/online-payments/payment-links) Generate and send URLs to collect payments from customers. [Learn more about Payment Links →](/solutions/full-stack/take-payments/online-payments/payment-links) #### [Hosted Fields](/solutions/full-stack/take-payments/online-payments/hosted-fields) Add secure payment fields directly into a merchant's checkout page. [Learn more about Hosted Fields →](/solutions/full-stack/take-payments/online-payments/hosted-fields) #### [Hosted Payment Page](/solutions/full-stack/take-payments/online-payments/hosted-payment-page) Add a secure payment page to a merchant’s website. [Learn more about Hosted Payment Page →](/solutions/full-stack/take-payments/online-payments/hosted-payment-page) #### [Roc Terminal+](/solutions/essentials/online-payments/roc-terminal) Accept in-person and online payments with our no-code payment terminal. [Learn more about Roc Terminal+ →](/solutions/essentials/online-payments/roc-terminal) #### [Roc Services](/solutions/essentials/online-payments/roc-services) Handle scheduling, invoicing, and payments in one system. [Learn more about Roc Services →](/solutions/essentials/online-payments/roc-services) # Payroc API for online payments Source: https://docs.payroc.com/solutions/full-stack/take-payments/online-payments/payroc-api Overview of the Payroc API as a fully flexible online payment solution supporting cards, bank transfers, digital wallets, tokenization, and recurring payments. Use our powerful API to manage the complete online payment experience for your merchants. Pick and choose from our comprehensive suite of features and methods to create a bespoke solution for online payments. Our Payroc API is ideal if you want to have full control over the payment flow that you want to offer. ![API solution image](/assets/live/solutions/online-payments.png) ## Key capabilities **Maximum flexibility** - Process all types of transactions, including sales, pre-authorizations, captures, refunds, and reversals. - Design a fully custom checkout page for maximum control or use payment links to reduce development effort. - Accept multiple payment methods, including card, bank transfers, and digital wallets. **Advanced fraud prevention** - Use 3-D Secure, AVS, and CVV checks to rigorously verify customer identity and reduce fraud. - Validate payment details without running a transaction to reduce unnecessary processing fees and errors. - Rely on our built-in encryption tools for every transaction to meet security standards with zero effort. **Powerful features** - Offer surcharging options to offset the merchant's processing fees. - Run reports to gain immediate, actionable insights for your merchants. - Accept specialized cards like EBT SNAP and various healthcare cards. - Create payment schedules that tell us when to take money from customers. - Save payment details using tokenization to improve the checkout flow and reduce your merchants' PCI burden when running regular payments. **Speed to market** - Lean on our experts for ongoing support and advice to get the most out of your solution. - Follow our comprehensive guides to streamline your development process. ## How to use the Payroc API Follow our [comprehensive guides](/guides/payments) to quickly launch your integration. Our guides cover the basic functions of the API, including: - Run sales and refunds. - Save a customer's payment details. - Verify a customer's payment details. - Schedule repeat payments. ## You might also be interested in... #### [Hosted Fields](/solutions/full-stack/take-payments/online-payments/hosted-fields) Add secure payment fields directly into a merchant's checkout page. #### [Hosted Payment Page](/solutions/full-stack/take-payments/online-payments/hosted-payment-page) Add a secure payment page to a merchant’s website. #### [Payroc API for in-person payments](/solutions/full-stack/take-payments/in-person-payments/payroc-api) Offer a full payment acceptance solution with broad capabilities. #### [Payment Links](/solutions/full-stack/take-payments/online-payments/payment-links) Generate and send URLs to collect payments from customers. # Payment Links Source: https://docs.payroc.com/solutions/full-stack/take-payments/online-payments/payment-links Overview of Payment Links as a solution for merchants to create and share secure payment links without needing a website or checkout integration. Our Payment Links solution allows a merchant to create a shareable link that directs a customer to a secure hosted payment page. The customer selects the link, completes the payment, and the merchant receives the funds — no website or checkout integration needed. Payment links are ideal for a wide range of use cases, including invoices, donations, one-off purchases, bill payments, and any scenario where businesses need to request and receive payments quickly and reliably. ![Payment Links solution image](/assets/live/solutions/payment-links-solution.png) ## Key capabilities **On-demand link creation** - Generate payment links on demand. - Share links through the merchant’s preferred channel. - Use our API or Self-Care Portal interchangeably. **Flexible configuration** - Create one-time links or reusable links. - Choose between a sale transaction or pre-authorization transaction. - Set up a fixed amount or allow the customer to enter the amount. - Accept card payments, bank transfer, or both. **Secure payment processing** - Redirect customers to a PCI-compliant payment page to make payments. - Limit the merchant's PCI scope as no merchant website is needed. **Tracking and reporting** - View payment statuses to check if the payment is completed or failed. - Access reporting for reconciliation and activity monitoring. - Manage links and follow-on actions from either the API or Self-Care Portal. ## How to use Payment Links There are two ways to use Payment Links: - [Integrate with our API](#api-integration). - [Use our Self-Care Portal](#self-care-portal). Both options provide the same capabilities to create, share, and manage payment links. They also use the same payment link data, so you can create a payment link with one option, and then share the payment link with the other option. ### API Integration Integrate with our low-code Payment Links endpoints to create payment links and share them. For detailed integration steps, go to our integration guide for [Payment Links](/guides/payments/payment-links). To perform follow-on actions, such as refunds, integrate with our other Payments methods. For more information about our Payroc API and other follow-on actions, go to our [API Explorer](/api). ### Self-Care Portal Our Payment Links solution can also be used through our Self-Care Portal. This no-code option allows merchants to create and share payment links without any development work. For more information about Payment Links, go to our [Support Hub](https://support.payroc.com/en_US/self-care-portal-payment-links). ## You might also be interested in... #### [Payroc API](/solutions/full-stack/take-payments/online-payments/payroc-api) Offer a full payment acceptance solution with broad capabilities. #### [Hosted Fields](/solutions/full-stack/take-payments/online-payments/hosted-fields) Add secure payment fields directly into a merchant's checkout page. #### [Hosted Payment Page](/solutions/full-stack/take-payments/online-payments/hosted-payment-page) Add a secure payment page to a merchant's website. # Hosted Fields Source: https://docs.payroc.com/solutions/full-stack/take-payments/online-payments/hosted-fields Overview of Hosted Fields as an online payment solution for merchants who want embedded checkout forms that accept card, ACH, and PAD payments without redirects. Our Hosted Fields solution lets you add payment fields directly to a merchant's checkout page, allowing customers to complete payments without any redirects or interruptions. Hosted Fields are ideal for an online retailer or any business that needs to accept payments directly on their platforms without the complexity of handling sensitive payment data. ## Key capabilities **Seamless checkout experience** - Embed payment fields directly on a merchant’s website or mobile application. - Provide built-in input validation that detects invalid values and provides immediate feedback to customers. - Support both desktop and mobile applications. **Secure data handling** - Reduce the merchant’s PCI compliance burden by hosting the payment fields. - Process payments securely using tokenized payment details. - Launch or update your checkout workflow quickly with security and compliance handled for you. **Versatile payment options** - Accept card, ACH, and PAD payments. - Use the payment form to run a sale, save a customer’s payment details, or update a customer’s saved payment details. **Customizable checkout** - Customize the appearance of the checkout page to match the merchant's branding. - Add custom fields to collect additional information from the customer. ## How to use Hosted Fields Use our Hosted Fields solution to create a payment form to take payments and manage customers’ payment details. For detailed integration steps, go to our integration guide for [Hosted Fields](/guides/payments/hosted-fields). To perform follow-on actions for Hosted Fields transactions, such as refunds and reversals, you need to integrate with our API. For more information about our API, go to our [API Explorer](/api). ## You might also be interested in... #### [Payroc API](/solutions/full-stack/take-payments/online-payments/payroc-api) Offer a full payment acceptance solution with broad capabilities. #### [Hosted Payment Page](/solutions/full-stack/take-payments/online-payments/hosted-payment-page) Add a secure payment page to a merchant’s website. #### [Payment Links](/solutions/full-stack/take-payments/online-payments/payment-links) Generate and send URLs to collect payments from customers. # Hosted Payment Page Source: https://docs.payroc.com/solutions/full-stack/take-payments/online-payments/hosted-payment-page Overview of Hosted Payment Page as a low-code online payment solution for merchants who want a secure, Payroc-hosted checkout page without handling sensitive payment data. Our Hosted Payment Page solution allows merchants to easily add a secure payment page to their website, enabling customers to enter their payment details safely. Because we host the page, we handle the customer's sensitive payment information, significantly reducing the merchant’s PCI compliance obligations. Our Hosted Payment Page solution is a low-code option for businesses that want to accept online payments without the complexity of handling sensitive payment data. ## Key capabilities **Simple, low-effort integration** - Eliminate the need to build or maintain your own payment form. - Reduce the merchant's PCI scope by relying on us to handle all sensitive payment data. **Flexible payment capabilities** - Accept card payments or bank transfer payments. - Support one-time payments, pre-authorizations, delayed captures, and subscription billing. - Use tokenization for recurring and merchant-initiated transactions. - Take advantage of built-in security tools like 3-D Secure and AVS. **Customizable, scalable checkout experience** - Present a clean and responsive UI across desktop, tablet, and mobile devices. - Customize the checkout process for your customers for a seamless experience. ## How to use our Hosted Payment Page There are two ways to use our Hosted Payment Page: - [Integrate with our API](#api-integration). - [Use our Self-Care Portal](#self-care-portal). ### API integration Integrate with our low-code Hosted Payment Page methods to add a payment page to a merchant's website. For detailed integration steps, go to our integration guide for [Hosted Payment Page](https://developers.worldnetpayments.com/hosted_pages:introduction). To perform follow-on actions, such as refunds, integrate with our other Payments methods. For more information about our Payroc API and other follow-on actions, go to our [API Explorer](/api). ### Self-Care Portal You can create a Hosted Payment Page on our Self-Care Portal. For more information about how to use the Self-Care Portal to create a Hosted Payment Page, [contact us](https://payroc.com/contacts/). ## You might also be interested in... #### [Payroc API](/solutions/full-stack/take-payments/online-payments/payroc-api) Offer a full payment acceptance solution with broad capabilities. #### [Hosted Fields](/solutions/full-stack/take-payments/online-payments/hosted-fields) Add secure payment fields directly into a merchant's checkout page. #### [Payment Links](/solutions/full-stack/take-payments/online-payments/payment-links) Generate and send URLs to collect payments from customers. # View reports Source: https://docs.payroc.com/solutions/full-stack/view-reports View transaction and settlement information. View transaction and settlement information. - [Real-time transaction data](/solutions/full-stack/view-reports/real-time-transaction-data) - [Settlement data](/solutions/full-stack/view-reports/settlement-data) # Real-time transaction data Source: https://docs.payroc.com/solutions/full-stack/view-reports/real-time-transaction-data Overview of tools for accessing real-time merchant transaction data, including sales, refunds, pre-authorizations, and captures via the Payroc API or Self-Care Portal. Our reporting tools give you access to your merchants' real-time transaction data, including sales, refunds, pre-authorizations, and captures. To view real-time transaction data, you can integrate with our Payroc API or use our Self-Care Portal. ## Different reporting tools | Aspect | Payroc API | Self-Care Portal | | --- | --- | --- | | Ideal for | Partners and ISVs who want to integrate reporting and analytics directly into their software. | Partners and merchants who want to access reporting through a separate self-service interface. | | Speed of setup | Moderate - Requires some development effort. | Fast – Transaction data is ready to view. | | Scalability | High – Handle reporting for multiple merchants and large datasets with ease. | Moderate – Suitable for day-to-day reporting for one or several merchant accounts. | | Customization | High – Fully customizable to your internal workflows and data needs. | Low – Preconfigured reports for quick and easy access to key insights. | ## Key capabilities of our Payroc API **Seamless integration** - Integrate reporting directly into your software for an uninterrupted user experience. - Automate data retrieval and synchronization to reduce manual tasks. **Scalability** - Scale reporting effortlessly as your merchant base expands. - Handle large volumes of data without significant manual effort. **Custom reporting** - Tailor reports to include the data that matters most to your merchants. - Provide customizable reporting interfaces that perfectly match your merchants' unique branding. ## Key capabilities of the Self-Care Portal **On-demand reporting** - Access transaction data quickly without any integration or setup. - Generate recurring reports for past transactions to streamline workflows. **User-friendly interface** - View and manage all transactions in one centralized hub. - Export reports easily for sharing or compliance purposes. **Risk management** - Detect failed or declined transactions immediately to reduce financial losses. - Monitor unusual transaction patterns in real time to prevent fraud. ## How to use our reporting tools Choose the reporting tool that aligns best with your requirements: - **Payroc API** - Integrate with our Payments endpoints to retrieve real-time transaction data, including payments, refunds, and secure tokens. For detailed information on our Payments endpoints, go to our [API Explorer](/api). - **Self-Care Portal** - Use the Self-Care Portal to access real-time transaction data in open batches and historical data in closed batches. For more information about how to use the Self-Care Portal, go to our [Support Hub](https://payroc.helpjuice.com/en_US/self-care-portal). ## You might also be interested in... #### [Settlement data](/solutions/full-stack/view-reports/settlement-data) View settled transactions and batches to reconcile transactions and verify merchant payouts. # Settlement data Source: https://docs.payroc.com/solutions/full-stack/view-reports/settlement-data Overview of tools for accessing and reconciling merchants' settled transaction data using the Payroc API or Payroc Insights reporting portal. Our reporting tools give you access to merchants’ settled transactions, which you can use to reconcile transactions and verify that merchants have received the correct funds. To view settlement data, you can integrate with our Payroc API or use Payroc Insights. ## Different reporting tools | Aspect | Payroc API | Self-Care Portal | | --- | --- | --- | | Ideal for | Partners and ISVs who want to integrate reporting and analytics directly into their software. | Partners and merchants who want to access reporting through a separate self-service interface. | | Speed of setup | Moderate - Requires some development effort. | Fast – Settlement data is ready to view. | | Scalability | High – Handle reporting for multiple merchants and large datasets with ease. | Moderate – Suitable for day-to-day reporting for one or several merchant accounts. | | Customization | High – Fully customizable to your internal workflows and data needs. | Low – Preconfigured reports for quick and easy access to key insights. | ## Key capabilities of our Payroc API **Seamless integration** - Integrate reporting directly into your software for an uninterrupted user experience. - Automate data retrieval and synchronization to reduce manual tasks. **Scalability** - Scale reporting effortlessly as your merchant base expands. - Handle large volumes of data without significant manual effort. **Custom reporting** - Tailor reports to include the data that matters most to your merchants. - Provide customizable reporting interfaces that perfectly match your merchants' unique branding. ## Key capabilities of Payroc Insights **On-demand reporting** - Access settlement reports on time without any integration or setup. - Review monthly statements to understand fees and account activity. **User-friendly interface** - Use the dashboard to gain a high-level overview of your transactions and merchants. - Highlight key metrics easily with the intuitive dashboard filters. **Automated notifications** - Stay informed with updates on merchant accounts, chargebacks, statements, and PCI compliance status. - Schedule notifications for the times that work best for you and your merchants. - Receive notifications and alerts by phone, email, or both. ## How to use our reporting tools Choose the reporting tool that aligns best with your requirements: - **Payroc API** - Integrate with our Settlement endpoints to retrieve settlement-related data, including settled transactions, batch details, and ACH deposits. For detailed information on our Settlement endpoints, go to our [API Explorer](/api). - **Payroc Insights** - Use Payroc Insights to view settlement reports and monthly statements. For more information about how to use Payroc Insights, go to our [Support Hub](https://payroc.helpjuice.com/en_US/payroc-insights). ## You might also be interested in... #### [Real-time transaction data](/solutions/full-stack/view-reports/real-time-transaction-data) Access live transaction data from your merchants. # Fund merchants Source: https://docs.payroc.com/solutions/full-stack/fund-merchants Fund your merchants and configure funding recipients. Fund your merchants and configure funding recipients. - [Funding](/solutions/full-stack/fund-merchants/funding) # Funding Source: https://docs.payroc.com/solutions/full-stack/fund-merchants/funding Overview of the Funding solution for controlling how and when settled transaction funds are delivered to merchant bank accounts, covering standard and dynamic funding models. Use our Funding solution to determine how and when settled transaction funds are delivered to a merchant's bank account. We offer a standard funding model and dynamic funding model, so you can choose the model that best fits the merchant's business and operational needs. ## Different funding models | Aspect | Standard funding model | Dynamic funding model | | --- | --- | --- | | Ideal for | Traditional merchants who want a straightforward flow of funds from their daily sales. | Partners and large merchants who run complex operations, such as multi-brand, multi-location, marketplaces, and platforms. | | Speed of setup | Fast - Default option that requires minimal setup. | Moderate - API integration that requires you to define allocation rules and account structure. | | Flexibility | Low - Built for simplicity and predictability. | High - Supports complex business models and payout scenarios. | | Deposit structure | We send a single, fixed deposit to the merchant's bank account. | You can distribute funds across multiple accounts. | | Cash flow control | Merchant automatically receives full deposit minus fees. | You can control how funds are distributed. | ## Key capabilities of the standard funding model **Simple, routine deposits** - Schedule fixed daily deposits, which gives merchants clear visibility of payouts. - Support merchants with predictable transaction patterns. **Fast setup** - Quickly activate new merchants at boarding. - Include standard fee and billing arrangements. **Advanced fee handling** - Separate billing and deposit accounts to manage fee deductions more precisely. - Reduce volatility in deposits by isolating fees from settlement amounts. ## Key capabilities of the dynamic funding model **Flexible fund allocation** - Distribute funds across multiple bank accounts based on business logic, operational needs, or risk. - Control when each merchant and third party receives funds. **Advanced fee handling** - Separate billing and deposit accounts to manage fee deductions more precisely. - Reduce volatility in deposits by isolating fees from settlement amounts. **Scalable configuration** - Add or change funding instructions as merchants grow or business needs evolve. - Adapt funding to expanding merchant locations, brands, or payment flows. ## How to use Funding Choose the funding model that aligns best with your business requirements: - **Standard funding model** - To use our standard funding model, [contact us](https://payroc.com/contacts/). - **Dynamic funding model** - Integrate with our medium-code Funding endpoints to create funding accounts, funding recipients, and funding instructions. For detailed information about our Funding endpoints, go to our [API Explorer](/api). # Integration guides Source: https://docs.payroc.com/solutions/full-stack/guides Explore guides for boarding merchants, taking payments, and funding merchants with the Payroc API. **Prerequisites:** [Authentication](/api/authentication) AI skills are available for some of our Full Stack Solutions, get them on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Our integration guides provide you with concise information and instructions to help you integrate with the key functions of our API. ## Board merchants #### [Boarding](/guides/boarding) Board merchants to our payments platform. #### [Event subscriptions](/guides/events) Add event notifications to your integration. ## Take payments #### [Payments](/guides/payments) Take payments and refunds from cards, bank accounts, or digital wallets. #### [Payroc Cloud](/guides/payments/payroc-cloud) Use our gateway to initiate a payment or a refund on a physical device. #### [Payment Links](/guides/payments/payment-links) Create a payment link that a merchant shares with a customer. #### [Hosted Fields](/guides/payments/hosted-fields) Add Hosted Fields to your webpage. #### [Apple Pay®](/guides/payments/apple-pay) Run online transactions with Apple Pay. #### [Google Pay®](/guides/payments/google-pay) Run online transactions with Google Pay. #### [Repeat payments](/knowledge/payments/repeat-payments) Create and manage repeat payments using our gateway or your own software. #### [Save payment details](/guides/payments/save-payment-details) Tokenize and save payment details. #### [Update saved payment details](/guides/payments/update-saved-payment-details) Update payment details that you previously saved. #### [3-D Secure](/guides/payments/three-d-secure) Use 3-D Secure to verify a cardholder's identity. #### [Add custom fields](/guides/payments/add-custom-fields) Allow merchants to add their own information to transactions. ## Fund merchants #### [Set up a funding recipient](/guides/funding/create-funding-recipients) Set up Funding Recipients that can receive funds from your account. #### [Send funds to your merchants](/guides/funding/create-funding-instructions) Create Funding Instructions to send funds to your merchants. # Guides Source: https://docs.payroc.com/guides Build and test your Payroc integration. ### [Getting started](/guides/getting-started) Set up and test your first integration. [Browse guides →](/guides/getting-started) ### [API keys](/guides/api-keys) Create and manage Payroc App API keys. [Browse guides →](/guides/api-keys) ### [Payments](/guides/payments) Integrate hosted checkout, Hosted Fields and digital wallets. [Browse guides →](/guides/payments) ### [Payroc Cloud](/guides/payments/payroc-cloud) Connect in-person payment devices to your integration. [Browse guides →](/guides/payments/payroc-cloud) ### [Testing](/guides/testing) Send requests to the Payroc Cloud Simulator. [Browse guides →](/guides/testing) # Getting started Source: https://docs.payroc.com/guides/getting-started Learn the stages of a Payroc integration, from your discovery call to going live with our API. **Prerequisites:** [Authentication](/api/authentication) To integrate with the Payroc API, you need an API key. [Contact our Sales team](https://payroc.com/contacts-developer/) to set up your account and get started. ## Your integration journey ```mermaid flowchart LR A["Discovery call"] B["Statement of work"] C["Development"] D["Validation"] E["Go live"] F["Ongoing support"] A --> B --> C --> D --> E --> F ``` \\ | Stage | What happens | | --- | --- | | **Discovery call** | Our Sales Engineering team discuss your requirements and identify the right solutions for your needs. | | **Statement of work** | We produce a statement of work that defines the scope of your integration. | | **Development** | Build against our API using our documentation, guides, and integration support team. | | **Validation** | Test your integration using our sandboxes and test cases. | | **Go live** | Go live with monitoring from our team for the first few weeks. | | **Ongoing support** | Reach out to our Customer Support team at any time after launch. | ## Base URL ``` https://api.payroc.com/ ``` # Quickstart Source: https://docs.payroc.com/guides/getting-started/quickstart Get sandbox credentials and make your first Payroc API call. Create a sandbox account at developers.payroc.com, generate an API key, and make your first request. > **Every request needs a fresh Idempotency-Key** > > Send a unique UUID v4 per request; reusing a key replays the original response instead of charging twice. ```bash curl https://api.payroc.com/v1/payments \ -H "Authorization: Bearer $PAYROC_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` # API keys Source: https://docs.payroc.com/guides/api-keys Create and manage Payroc App API keys. Create and manage Payroc App API keys. - [Generate a Payroc App API key](/guides/api-keys/generate-a-payroc-app-api-key) - [View a Payroc App API key](/guides/api-keys/view-a-payroc-app-api-key) - [Change the settings of a Payroc App API key](/guides/api-keys/change-the-settings-of-a-payroc-app-api-key) - [Deactivate a Payroc App API key](/guides/api-keys/deactivate-a-payroc-app-api-key) - [Reactivate a Payroc App API key](/guides/api-keys/reactivate-a-payroc-app-api-key) # Generate a Payroc App API key Source: https://docs.payroc.com/guides/api-keys/generate-a-payroc-app-api-key Shows how to generate and view a Payroc App API key in the Self-Care Portal to authenticate with the Payroc Cloud Simulator. To use the Payroc Cloud Simulator, you need a Payroc App API key, which you can generate and view in the Self-Care Portal. **Note:** If you don't have access to the Self-Care Portal, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Generate a Payroc App API key 1. Sign in to [https://payments.payroc.com/merchant/selfcare](https://payments.payroc.com/merchant/selfcare). 2. On the side menu, select **Settings**, and then select **API Keys**. 3. Select **NEW API KEY**. 4. In the Key Alias box, enter the name of the API key. 5. In the Notification Email box, enter your email address. We send notifications to this email address when we create, revoke, or reactivate the API key. 6. In the API Permissions section, select the following checkboxes:- **Account API** – Access the merchant gateway account. - **Customer API** – Access customer details, for example, secure tokens and subscriptions. - **Transaction API** – Run card transactions. - **Bank Transfer API** – Run bank transfer transactions. - **Reporting API** – Access to reporting data. 7. For each API that you selected, select the dropdown menu, and then select **Full Access**. 8. Select **SAVE**. 9. Select the processing terminals that the key applies to. 10. Select **SAVE**. ## View the Payroc App API key 1. On the side menu, select **Settings**, and then select **API Keys**. 2. Locate the API key that you want to view. **Note:** You can use the search function to search by the Key Alias that you assigned to the key when you created it. 3. From the Action column, select , and then select **View Authentication Key**. 4. Enter the password for your Self-Care Portal account. 5. View and copy the key. **Note:** You can use the Self-Care Portal to update, deactivate, and reactivate the Payroc App API keys. For more information about how to manage API keys, go to [API keys](/knowledge/api-basics/api-keys). # View a Payroc App API key Source: https://docs.payroc.com/guides/api-keys/view-a-payroc-app-api-key Explains how to locate and copy a Payroc App API key from the Self-Care Portal. You can view a Payroc App API key in the Self-Care Portal. **Note:** If you don't have access to the Self-Care Portal, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). To view a Payroc App API key, complete the following steps: 1. Sign in to [https://payments.payroc.com/merchant/selfcare](https://payments.payroc.com/merchant/selfcare). 2. On the side menu, select **Settings**, and then select **API Keys**. 3. Locate the API key that you want to view. **Note:** You can use the search function to search by the Key Alias that you assigned to the key when you created it. 4. From the Action column, select , and then select **View Authentication Key**. 5. Enter the password for your Self-Care Portal account. 6. View and copy the key. # Change the settings of a Payroc App API key Source: https://docs.payroc.com/guides/api-keys/change-the-settings-of-a-payroc-app-api-key Explains how to update the alias, notification email, API permissions, and processing terminals of a Payroc App API key using the Self-Care Portal. You can change the settings of a Payroc App API key in the Self-Care Portal. 1. Sign in to [https://payments.payroc.com/merchant/selfcare](https://payments.payroc.com/merchant/selfcare). 2. On the side menu, select **Settings**, and then select **API Keys**. 3. Select the API key that you want to update. **Note:** You can use the search function to search by the Key Alias that you assigned to the key when you created it. 4. In the **General Setup** tab, update the following settings: - **Key Alias** - Update the name of the API key. - **Notification Email** - Update the email address that we send notifications to when we create, deactivate, or reactivate the API key. - **API Permissions** - Select which APIs the API key can access and its permission levels. 5. Select **SAVE**. 6. In the **Processing Terminals** tab, select which processing terminals the API key applies to. 7. Select **SAVE**. # Deactivate a Payroc App API key Source: https://docs.payroc.com/guides/api-keys/deactivate-a-payroc-app-api-key Explains how to deactivate a Payroc App API key in the Self-Care Portal, preventing its use without permanently deleting it. You can deactivate a Payroc App API key in the Self-Care Portal. After you deactivate a Payroc App API key, you can still view its details, but you can't use it unless you reactivate it. To deactivate a Payroc App API key, complete the following steps: 1. Sign in to [https://payments.payroc.com/merchant/selfcare](https://payments.payroc.com/merchant/selfcare). 2. On the side menu, select **Settings**, and then select **API Keys**. 3. Locate the API key that you want to deactivate. **Note:** You can use the search function to search by the Key Alias that you assigned to the key when you created it. 4. From the Action column, select , and then select **Revoke**. 5. Select **OK**. # Reactivate a Payroc App API key Source: https://docs.payroc.com/guides/api-keys/reactivate-a-payroc-app-api-key Explains how to reactivate a previously deactivated Payroc App API key using the Self-Care Portal. You can reactivate a Payroc App API key that you previously deactivated in the Self-Care Portal. To reactivate a Payroc App API key, complete the following steps: 1. Sign in to [https://payments.payroc.com/merchant/selfcare](https://payments.payroc.com/merchant/selfcare). 2. On the side menu, select **Settings**, and then select **API Keys**. 3. To view the Payroc App API keys that you've deactivated, select the **Revoked** tab. ![API Keys Revoked Tab](/assets/reactivate-a-payroc-app-api-key-selfcareportal_apikeys_revokedtab.png) 3. Locate the API key that you want to reactivate. **Note:** You can use the search function to search by the Key Alias that you assigned to the key when you created it. 4. From the Action column, select , and then select **Authorize**. 5. Select **OK**. # Payments Source: https://docs.payroc.com/guides/payments Explains how to use the Payments endpoints to take card, bank account, and digital wallet payments, and to run refunds and repeat payments **Prerequisites:** [Authentication](/api/authentication) To take payments from a card, bank account, or digital wallet, use our Payments endpoints. You can use our Payments endpoints in the following channels: - **In-person payments** – Accept payments on a physical terminal. - **Online payments** – Accept payments through online checkout. - **MOTO payments** – Accept payments by telephone, email, and written request. After you integrate with the Payments endpoints, your merchant can: - Run transactions including sales and refunds. - Schedule repeat payments. - Save the customer’s payment details. - Verify that payment details are valid. ## Run transactions We offer the following transaction types: - Sale - Pre-authorization and capture - Referenced refund and unreferenced refund - Reversal When you integrate against the Payments endpoints, you can offer the following features: - [Currency conversion](/knowledge/payments/currency-conversion) - Give customers the option to pay in their own currency if the merchant’s currency is different. - [Offline processing](/knowledge/payments/offline-processing) – Accept payments even if the terminal can’t connect to the gateway, for example, if the terminal has an unreliable internet connection. - Surcharging – Add a surcharge to the customer’s total price to cover the cost of the merchant’s card processing fees. - Tipping – Present tip options to customers at the time of the transaction. ## Schedule repeat payments Integrate with our [payment plans](/api/create-payment-plan) and [subscriptions](/api/create-subscription) method so that your merchants can offer repeat payments to their customers. This can either be recurring payments with no end date, or a series of installment payments for a fixed period. To set up and manage repeat payments, you can either: - [Use your own software to manage payments, and our gateway to process them.](/guides/payments/repeat-payments/using-your-own-system-for-recurring-billing) OR - [Use our gateway to manage and process payments.](/guides/payments/repeat-payments/using-our-gateway-for-recurring-billing) ## Save payment details Using our [tokenization](/knowledge/payments/tokenization) solution, the merchant can save a customer’s payment details for future payments, which means a faster checkout. You store the payment details in either our vault or your own vault, and we return a token that a merchant uses instead of the payment details. Each time the merchant uses the token, it keeps sensitive payment information off their POS, which makes it more secure. There are two types of tokens that you can create: - **Secure tokens** - A token that the merchant can use multiple times. This saves time at the checkout for the merchant and the customer. - **Single use tokens** – A temporary token that the merchant can use only once. The token expires after 30 minutes. ## Verify payment details For online or MOTO transactions, your merchant can send extra information to verify the payment details: - [Address Verification Service (AVS)](/knowledge/payments/payment-method-verification#avs) – Compares the billing address that the customer uses in the transaction with the billing address that the customer provided to their issuing bank. - [Card Verification Value (CVV)](/knowledge/payments/payment-method-verification#cvv) – Three-digit number on a payment card that proves that the customer has the card. - [3-D Secure](/knowledge/payments/payment-method-verification#3-d-secure) - Two-factor authentication for every online purchase that requires a customer to verify their identity. We have two endpoints that you can integrate against to make sure payment details are valid without running a sale: - [Verify a bank account](/api/verify-bank-account) - [Verify a card](/api/verify-card) #### [Run a card sale](/guides/payments/run-a-card-sale) Take funds from a customer's card. #### [Run a sale with bank account details](/guides/payments/run-sale-using-bank-details) Take funds from a customer's bank account. #### [Run a pre-authorization](/guides/payments/run-a-pre-authorization) Hold funds in a customer's account. #### [Refunds](/guides/payments/refunds) Return funds to a customer's account. # Collect a payment with the Hosted Payment Page Source: https://docs.payroc.com/guides/payments/hosted-payment-page Redirect your customer to Payroc's hosted checkout; sale, pre-auth, and tokenize variants. Redirect your customer to Payroc's hosted checkout. Card entry, 3-D Secure, and receipt happen on the hosted page — keeping your PCI scope at SAQ A. The result comes back to your return URL and webhook. ## How it works 1. **Load the hosted payment page** — Your site → gateway Your site sends a signed form POST that redirects the customer to the HPP. 2. **Customer pays** — Customer → hosted page Card entry and 3-D Secure on the Payroc-hosted page. 3. **Result comes back** — Gateway → your webhook Return URL for the customer; webhook as source of truth. ## Load the hosted payment page Add a payment button that sends a signed form POST to the gateway — the [Load the Hosted Payment Page](/guides/payments/hosted-payment-page/load-payment-page) guide walks through every parameter and the [hash](/guides/payments/hosted-payment-page/authenticate-requests) that signs it. ```html
``` > **Gotcha — from the workflow spec** > > For a plain sale, do not call `capturePayment` afterward — the redirect and webhook already settled it. The capture step applies only to the pre-authorization variant. > **Every request needs a fresh Idempotency-Key** > > Send a unique UUID v4 per request; reusing a key replays the original response instead of charging twice. # Authenticate your requests Source: https://docs.payroc.com/guides/payments/hosted-payment-page/authenticate-requests Create a terminal secret in the Self-Care Portal and build a SHA-512 hash to authenticate your requests to load the Hosted Payment Page. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). To load the Hosted Payment Page, you need to include a SHA-512 hash in the HASH parameter. The hash authenticates your request and prevents tampering with sensitive values during transit to our gateway. When the gateway processes your request successfully, it returns the hash in the response. Use the returned hash to verify that the response is legitimate. ## Before you begin You must have credentials for the Self-Care Portal, which is a self-serve portal that you use to configure terminal settings for your merchant. Use this portal to create a terminal secret. If you don't have credentials for the Self-Care Portal, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Integration steps 1. Create a terminal secret in the Self-Care Portal. 2. Build the hash string and convert it to SHA-512. ## Step 1. Create a terminal secret The terminal secret is a shared key between your merchant's website and our gateway. Store it securely and rotate it according to your security policy. **Important:** Never expose the terminal secret on your merchant's website or mobile app. To create a terminal secret, complete the following steps: 1. Sign in to the Self-Care Portal:- Test: [https://payments.uat.payroc.com/merchant/selfcare/](https://payments.uat.payroc.com/merchant/selfcare/) - Production: [https://payments.payroc.com/merchant/selfcare/](https://payments.payroc.com/merchant/selfcare/) 2. From the side menu, select **Settings**, and then select **Terminal**. 3. In the Secret field, enter a secret that is between 16 and 48 characters. Use a mixture of letters, numbers, and special characters. **Note:** If your Hosted Payment Page integration communicates with third-party software, some special characters in the terminal secret can cause issues. Test your integration thoroughly to ensure there are no issues. 4. In the Confirm Secret field, reenter your secret. 5. Select **UPDATE SETTINGS**. 6. Select **OK** to confirm that you want to change your terminal secret. **Note:** Enter a terminal secret in both the test and the production environments to ensure that you don't have issues when you complete your testing phase and start to run live transactions. ## Step 2. Build and hash the request string **Important:** Build a dynamic hash function instead of hard-coding hash values. The hash string changes depending on the transaction type and optional parameters that you might include. 1. Create a colon-delimited string from the following values, and then convert the string to a SHA-512 hash: | Value | Type | Size | Description | | --- | --- | --- | --- | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | ORDERID | String | 1-24 characters | Unique identifier that the merchant assigns to the transaction. | | AMOUNT | Double | | Subtotal of the transaction including taxes. Don't include surcharges or convenience fees. | | DATETIME | String | | Date and time that you send the request. Send this value in **DD-MM-YYYY:HH:MM:SS:SSS** format, for example, `06-02-2026:12:23:23:719`. | | SECRET | String | 16-48 characters | Terminal secret that you added to the Self-Care Portal in [Step 1](#step-1-create-a-terminal-secret). | TERMINALID, ORDERID, AMOUNT, and DATETIME are request parameter values that you populate in your request when you [Load the Hosted Payment Page](/guides/payments/hosted-payment-page/load-payment-page). 2. Convert the string into a SHA-512 hash. ### Example To create a hash string for a sale, complete the following steps: 1. Build your hash with your parameter values in the following order:- `[TERMINALID]:[ORDERID]:[AMOUNT]:[DATETIME]:[SECRET]` 2. Replace the placeholders with actual values:- `3204004:HPP744359582:123.45:10-02-2026:09:14:54:058:example_secret_123` 3. Use a hashing library in your programming language to convert the string to a SHA-512 hash:- `af306cb3a3dd3c4d5d09f3e04b85da567b0a6c7b65f816cbc11b53a1802be70d277c8fe08bcc3b733303081ed5de2c3ff89c112881bb27004074bb29eb0ca549` You send this value in the HASH parameter of your request to load the Hosted Payment Page. ## Next steps - [Load the Hosted Payment Page](/guides/payments/hosted-payment-page/load-payment-page). # Load the Hosted Payment Page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/load-payment-page Add a button that sends a POST request with the transaction details and SHA-512 hash to load the Hosted Payment Page for the customer. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). When your customer is ready to pay, you need to load the Hosted Payment Page. To do this, add a button to your checkout page that sends a POST request to our gateway. When we receive the POST request, the Hosted Payment Page loads and the customer can submit their payment details. **Note:** The Hosted Payment Page doesn't return a transaction type in the transaction response. Because you can run sales, run pre-authorizations, and save a customer's payment details, we recommend that you record the transaction type in your system. ## Before you begin Make sure you have the unique identifier that we assigned to the merchant's terminal. Send this in your POST request in the TERMINALID parameter. ## Send a POST request to load the Hosted Payment Page To load the page, send a POST request to the Payment Page URL. | Environment | URL | | --- | --- | | Test | [https://payments.uat.payroc.com/merchant/paymentpage](https://payments.uat.payroc.com/merchant/paymentpage) | | Production | [https://payments.payroc.com/merchant/paymentpage](https://payments.payroc.com/merchant/paymentpage) | ### Request parameters To create the body of your request, use the following parameters: | Parameter | Type | Size | Description | | --- | --- | --- | --- | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | ORDERID | String | 1-24 characters | Unique identifier that the merchant assigns to the transaction. | | CURRENCY | String | 3 characters | Currency of the transaction. The value for the currency follows the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard. | | AMOUNT | Double | | Subtotal of the transaction including taxes. Don't include surcharges or convenience fees. | | DATETIME | String | | Date and time that you send the request. Send this value in **DD-MM-YYYY:HH:MM:SS:SSS** format, for example, `06-02-2026:12:23:23:719`. | | HASH | String | 1-128 characters | SHA-512 hash value that you generate with values from the request parameters and the terminal secret. For more information about how to create your HASH, go to [Authenticate your requests](/guides/payments/hosted-payment-page/authenticate-requests). | ### Example request ```html
``` ## Errors ### INVALID HASH If we can't authenticate your request, the Hosted Payment Page displays **INVALID HASH** in plain text. Check that you have set up your HASH correctly. For more information about the hash, go to [Authenticate your requests](). ### Validation Errors The Hosted Payment Page runs basic validation checks on the customer's input. If the customer enters incorrect information, for example, a card number that is too short, the page displays an error message and prompts the customer to correct the information. Your integration doesn't need to handle these validation errors because the Hosted Payment Page handles these errors for you. ## Next steps - [Build the merchant’s receipt page](/guides/payments/hosted-payment-page/build-receipt-page). # Build the merchant’s receipt page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/build-receipt-page Build a receipt page that parses the transaction response query parameters the Hosted Payment Page appends and shows the customer a success or decline message. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Create a receipt page on the merchant's website to display the transaction response to customers. After the customer makes a payment, the Hosted Payment Page redirects them to the merchant's receipt page and appends the transaction response as query parameters. The receipt page must parse these parameters and display a success or decline message. **Note:** If a payment is declined, the Hosted Payment Page still redirects the customer to the receipt page and returns the response in the query parameters. ## Before you begin You must have credentials for the Self-Care Portal, which is a self-serve portal that you use to configure terminal settings for your merchant. Use this portal to provide us with the URL for the receipt page. If you don't have credentials for the Self-Care Portal, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Integration steps 1. Provide us with the URL of the merchant's receipt page. 2. Handle the transaction response and present the outcome to the customer. ## Step 1. Provide us with the receipt page URL Provide us with the receipt page URL in the Self-Care Portal so that we know where to redirect customers after they submit their payment details and where to send the transaction response. To provide us with the URL, complete the following steps: 1. Sign in to the Self-Care Portal:- **Test:** [https://payments.uat.payroc.com/merchant/selfcare/](https://payments.uat.payroc.com/merchant/selfcare/) - **Production:** [https://payments.payroc.com/merchant/selfcare/](https://payments.payroc.com/merchant/selfcare/) 2. From the side menu, select **Settings**, and then select **Terminal**. 3. In the Receipt Page URL field, enter the URL of the receipt page. 4. Select **UPDATE SETTINGS**. **Note:** Enter the receipt page URL in both the test and the production environments to ensure that you don't have issues when you complete your testing phase and start to run live transactions. ## Step 2. Handle the transaction response The Hosted Payment Page returns the transaction response as query parameters appended to the receipt page URL. The query parameters change depending on whether the customer used their card details or their bank account details. ### Card details When a customer pays with credit card details or debit card details, the Hosted Payment Page returns the following query parameters: | Parameter | Type | Size | Description | | --- | --- | --- | --- | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | ORDERID | String | 1-24 characters | Unique identifier that the merchant assigned to the transaction. | | APPROVALCODE | String | 0-48 characters | Authorization code that the processor assigned to the transaction. | | AMOUNT | Double | | Subtotal of the transaction including taxes. This value doesn't include surcharges or convenience fees. | | RESPONSECODE | Enum | | Response code for the transaction from the processor. The value is one of the following: - `A` - Processor approved the transaction. - `E` - Processor authorized the transaction. This enum applies to only China UnionPay cards. - `D` - Processor declined the transaction. - `R` - Processor declined the transaction, and the customer should contact their bank. - `C` - Processor declined the transaction because the payment card was reported lost or stolen. | | RESPONSETEXT | String | 0-48 characters | Response description from the processor. | | DATETIME | String | | Date and time that the processor received the request and returned a response to our gateway. We return this value in **YYYY-MM-DDTHH:MM:SS** format, for example, `2026-02-10T14:51:40`. | | AVSRESPONSE | String | 1 character | Indicates if the address that the customer entered on the Hosted Payment Page matches the address linked to the card. The value is one of the following: - `A` - First five numerical characters in the address match, but the ZIP code or postal code doesn't match. - `E` - Transaction isn't eligible for an AVS check. - `N` - Address doesn't match. - `R` - AVS check temporarily unavailable. - `S` - Card type not supported by AVS. - `U` - Address information unavailable from the card issuer. - `G` - Address information unavailable from the card issuer. This value applies to only Visa cards. - `W` - ZIP code or postal code matches, but the street address doesn't. - `X` - Address matches. - `Y` - Address matches. - `Z` - ZIP code or postal code matches, but the street address doesn't. | | CVVRESPONSE | String | 1 character | Indicates if the card verification value (CVV) that the customer entered on the Hosted Payment Page matches the CVV on the card. The value is one of the following: - `M` - CVV matches. - `N` - CVV doesn't match. - `P` - CVV not processed. - `U` - CVV isn't registered. **Note:** Our gateway doesn't automatically decline transactions when the CVV doesn't match, unless the merchant has asked us to decline transactions where the CVV doesn't match. | | UNIQUEREF | String | 10 characters | Unique identifier that our gateway assigned to the transaction. **Note:** Store the UNIQUEREF if you use our API for follow-on transactions, for example, to refund the transaction. | | CARDREFERENCE | String | 12-19 characters | Secure token that represents the customer's payment details. | | EMAIL | String | 1-128 characters | Customer's email address. | | PHONE | String | 5-20 characters | Customer's phone number. | | REGION | String | 0-128 characters | Region of the customer's billing address. | | CITY | String | 0-40 characters | City of the customer's billing address. | | POSTCODE | String | 0-128 characters | Zip code or postal code of the customer's address. | | STATE | String | 0-128 characters | Name of the state or state abbreviation of the customer's billing address. | | COUNTRY | String | 2 characters | Two-letter code for the country of the customer's card. The format follows the [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) standard. | | CARDNUMBER | String | 12-19 characters | Masked card number. Our gateway returns only the first six digits and the last four digits of the card number, for example, `548010******5929`. | | CARDHOLDERNAME | String | 0-50 characters | Customer's name. | | CARDTYPE | String | | Card brand of the card. | | HASH | String | 1-128 characters | SHA-512 hash value that we generate with values from the response parameters and the terminal secret. You can use this hash to verify that the response is legitimate. We return the hash in the following order: - `[TERMINALID]:[ORDERID]:[AMOUNT]:[DATETIME]:[RESPONSECODE]:[RESPONSETEXT]:[SECRET]` | | CUSTOMFIELD | String | | Custom field that you sent in the request. | | OTHERFIELD | String | 0-2000 characters | Other field that you sent in the request. | | BRANDTXIDENTIFIER | String | 1-50 characters | Unique identifier that the card brand assigns to the transaction. If you use a third-party vault for tokenization, include this value when you use a secure token in follow-on transactions with our API, for example, to refund the transaction. | | SECURECARDMERCHANTREF | String | 1-200 characters | Unique identifier that the merchant assigned to the secure token. | | STOREDCREDENTIALUSE | Enum | | Indicates how the merchant can use the card details, as agreed by the customer: - `UNSCHEDULED` - Transactions for a fixed or variable amount that are run at a certain predefined event. - `RECURRING` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Recurring transactions don't have a fixed duration and run until the customer cancels the agreement. - `INSTALLMENT` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Installment transactions have a fixed duration. **Note:** We return this field only if the merchant has tokenized the card details as part of the transaction. | | STOREDCREDENTIALTXTYPE | Enum | | Indicates if a payment with stored card details is the first in a series of payments, or if it is a follow-on payment. The value is one of the following: - `FIRST_TXN` - First payment in a series of payments. - `SUBSEQUENT_CARDHOLDER_INITIATED_TXN` - Payment that the customer initiates after the first payment in the series. - `SUBSEQUENT_MERCHANT_INITIATED_TXN` - Payment that the merchant initiates after the first payment in the series. **Note:** We return this field only if the customer used saved payment details for the transaction. | | BYPASS\_SURCHARGE | Boolean | | Indicates if the merchant has bypassed surcharges for the transaction. The value is one of the following: - `true` - Surcharges don't apply to the transaction. - `false` - Surcharges apply to the transaction. **Note:** You can't apply surcharges to pre-authorizations. | | ACCEPTTERMSANDCONDITIONS | Enum | | Indicates if the customer accepted the terms and conditions for convenience fees. We return a value of `ON` because the customer can't complete the transaction without accepting the terms and conditions. **Note:** You can't apply convenience fees to pre-authorizations. | | CONVENIENCE\_FEE | Double | | Convenience fee that the merchant applied to the transaction. **Note:** You can't apply convenience fees to pre-authorizations. | | SURCHARGE\_FEE | Double | | Surcharge fee that the merchant applied to the transaction. **Note:** You can't apply surcharges to pre-authorizations. | | SURCHARGE\_PERCENT | Double | | Surcharge percentage that the merchant applied to the transaction. **Note:** You can't apply surcharges to pre-authorizations. | | DL\_NUMBER | String | 0-30 characters | License number of the customer's driver's license. | | DL\_STATE | String | 2 characters | Two-character abbreviation of the state that issued the customer's driver's license, for example, `IL`. | | POSDEVICE | String | 0-30 characters | Name of the POS device that captured the customer's payment details. | #### Example response ``` https://[receipt_page_url].com/receipt?DL_NUMBER=&DL_STATE=&CARDREFERENCE=&POSDEVICE=&STATE=&OTHERFIELD_1=Other+Field1&ORDERID=HPP967631811&AMOUNT=10.17&BYPASS_SURCHARGE=&ACCEPTTERMSANDCONDITIONS=ON&SECURECARDMERCHANTREF=®ION=&TERMINALID=3204004&CITY=&CONVENIENCE_FEE=2.00&RESPONSETEXT=OK8835&RESPONSECODE=A&APPROVALCODE=OK8835&CVVRESPONSE=M&DATETIME=2026-02-10T09:16:23&UNIQUEREF=JH1TY9LL4S&EMAIL=vvd%40worldnettps.it&PHONE=8000005555&CARDTYPE=VISA%20DEBIT&CARDNUMBER=411111******1111&HASH=70a28ef2f11f3b415ba0aac52631cb2755a56641bfebaa33dd581f59b9cf3a48e264e5710886987bf5cd54967a67716b2b256ed92ce33ca529547c024b5e9398 ``` ### Bank details When a customer pays with their bank account details, the Hosted Payment Page returns the following query parameters: | Parameter | Type | Size | Description | | --- | --- | --- | --- | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | ORDERID | String | 1-24 characters | Unique identifier that the merchant assigned to the transaction. | | UNIQUEREF | String | 10 characters | Unique identifier that our gateway assigned to the transaction. **Note:** Store the UNIQUEREF if you use our API for follow-on transactions, for example, to refund the transaction. | | AMOUNT | Double | | Subtotal of the transaction including taxes. This value doesn't include surcharges or convenience fees. | | TRANSITNUMBER | String | 5 characters | Five-digit number that identifies the customer's bank branch. | | ROUTING\_NUMBER | String | 9 characters | Nine-digit number that identifies the customer's bank. | | ACCOUNT\_NUMBER | String | 4-17 characters | Customer's bank account number. Our gateway returns only the last four digits of the account number, for example, `*****5929`. | | INSTITUTION\_NUMBER | String | 3 characters | Three-digit number that identifies the customer's bank. | | ACCOUNTHOLDER\_NAME | String | 1-29 characters | Customer's name. | | ACCOUNT\_TYPE | Enum | | Indicates the customer's account type. The value is one of the following: - `CHECKINGS` - Checking account - `SAVINGS` - Savings account | | RESPONSECODE | Enum | | Response code for the transaction from the processor. The value is one of the following: - `A` - Processor approved the transaction. - `D` - Processor declined the transaction. | | RESPONSETEXT | String | 0-48 characters | Response description from the processor. | | DISCOUNT\_AMOUNT | Double | | Discount amount that the merchant applied to the transaction. | | DATETIME | String | | Date and time that the processor received the request and returned a response to our gateway. We return this value in **YYYY-MM-DDTHH:MM:SS** format, for example, `2026-02-10T14:51:40`. | | EMAIL | String | 1-128 characters | Customer's email address. | | PHONE | String | 5-20 characters | Customer's phone number. | | COUNTRY | String | 2 characters | Two-letter code for the country of the customer's bank account. The format follows the [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) standard. | | HASH | String | 1-128 characters | SHA-512 hash value that we generated with values from the response parameters and the terminal secret. You can use this hash to verify that the response is legitimate. We return the hash in the following order: - `[TERMINALID]:[ORDERID]:[AMOUNT]:[DATETIME]:[RESPONSECODE]:[RESPONSETEXT]:[SECRET]` | | CUSTOMFIELD | String | | Custom field that you sent in the request. | | OTHERFIELD | String | 0-2000 characters | Optional field that you sent in the request. | #### Example response ``` https://[receipt_page_url].com/receipt?UNIQUEREF=FTL0SDST82&RESPONSECODE=A&ACCOUNT_TYPE=SAVINGS&ACCOUNTHOLDER_NAME=Test&HASH=20a1f6b2a4fbbfacfc03cf4362e73de339f220f85bc6d85e66ae1c44907e9311e8da650735dc2b85bb1e6735fc336b07463d002db290851ad32b4e8044ba8092&OTHERFIELD_1=Other+Field1&ORDERID=HPP467934940&TERMINALID=3204004&DATETIME=2026-02-10T09:38:54&AMOUNT=10.17&ROUTING_NUMBER=011***015&RESPONSETEXT=NoError&CONVENIENCE_FEE=2.00&ACCOUNT_NUMBER=******0000&ACCEPTTERMSANDCONDITIONS=ON ``` ### BeadPay details When a customer pays with alternative payment details through BeadPay, the Hosted Payment Page returns the following query parameters: | Parameter | Type | Size | Description | | --- | --- | --- | --- | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | ORDERID | String | 1-24 characters | Unique identifier that the merchant assigned to the transaction. | | AMOUNT | Double | | Subtotal of the transaction including taxes. This value doesn't include surcharges or convenience fees. | | DATETIME | String | | Date and time that the processor received the request and returned a response to our gateway. We return this value in **YYYY-MM-DDTHH:MM:SS** format, for example, `2026-02-10T14:51:40`. | | STATUS | String | 1-128 characters | Status of the transaction. | | TENDER\_TYPE | String | 1-128 characters | Type of tender that the customer used for the transaction. | | HASH | String | 1-128 characters | SHA-512 hash value that we generated with values from the response parameters and the terminal secret. You can use this hash to verify that the response is legitimate. We return the hash in the following order: - `[TERMINALID]:[ORDERID]:[AMOUNT]:[DATETIME]:[STATUS]:[TENDER_TYPE]:[SECRET]` | | OTHERFIELD | String | 0-2000 characters | Optional field that you sent in the request. | #### Example response ``` https://[receipt_page_url].com/receipt?TERMINALID=3204004&ORDERID=HPP328491756&AMOUNT=10.17&DATETIME=2026-02-10T09:52:31&STATUS=COMPLETE&TENDER_TYPE=bitcoin&HASH=b4840eefc97ebaea7be8a45fd788d07064df568dbd30b3f0f77827e925b85e07df882370d8981632946623c030a07d80fc243cfd438a6571baef37d8dec49d58&OTHERFIELD_1=Other+Field1 ``` # Implement background validation Source: https://docs.payroc.com/guides/payments/hosted-payment-page/background-validation Set up a validation URL in the Self-Care Portal and handle the webhook notification our gateway sends to confirm whether it processed a card payment. **Important:** We strongly recommend that you implement background validation as part of your Hosted Payment Page integration. However, you can’t implement background validation if a customer uses bank account details as a payment method. Background validation is a webhook-based mechanism that confirms whether our gateway processed a card payment. When you implement background validation, our gateway sends an HTTP POST request to a URL called the validation URL. Our gateway sends a notification each time a customer submits their card details on the Hosted Payment Page, whether the payment is successful or unsuccessful. The notification is useful if the connection fails between our gateway and the merchant’s website because the notification confirms whether we received the payment. ## How it works ```mermaid sequenceDiagram actor C as Customer participant HPP as Hosted Payment Page participant GW as Gateway participant S as Your server C->>HPP: Submit card details HPP->>GW: Process the payment rect rgba(0, 81, 194, 0.4) Note over GW,S: Background validation GW->>S: POST the transaction response to your validation URL alt Your server returns OK S-->>GW: OK Note over GW: Notification confirmed else No OK response loop Retry with exponential backoff, up to 96 hours GW->>S: Retry the notification end Note over GW,S: If every retry fails, the gateway sets the transaction
to expired and emails the merchant end end ``` 1. The customer submits their card details on the Hosted Payment Page. 2. Our gateway processes the payment and sends the transaction response to your validation URL as an HTTP POST request. 3. Your server returns the text `OK` to confirm that it received the notification. 4. If our gateway doesn't receive an `OK` response, it retries with exponential backoff over 96 hours. If every retry fails, our gateway sets the transaction to expired and emails the merchant. ## Before you begin You must have credentials for the Self-Care Portal, which is a self-serve portal that you use to configure terminal settings for your merchant. Use this portal to provide us with the validation URL. If you don't have credentials for the Self-Care Portal, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Integration steps 1. Provide us with the validation URL. 2. Handle the webhook notification that contains the transaction response. ## Step 1. Provide us with the validation URL Provide us with the validation URL in the Self-Care Portal to inform us where to send the webhook notification. To provide us with the URL, complete the following steps: 1. Sign in to the Self-Care Portal:- Test: [https://payments.uat.payroc.com/merchant/selfcare/](https://payments.uat.payroc.com/merchant/selfcare/) - Production: [https://payments.payroc.com/merchant/selfcare/](https://payments.payroc.com/merchant/selfcare/) 2. From the side menu, select Settings, and then select Terminal. 3. Select the Enable Validation checkbox. 4. In the Validation URL field, enter your validation URL. 5. Select UPDATE SETTINGS. **Note:** Enter the validation URL in both the test and the production environments to ensure that you don't have issues when you complete your testing phase and start to run live transactions. ## Step 2. Handle the webhook notification Each time a customer submits their card details on the Hosted Payment Page, our gateway sends an HTTP POST request to your validation URL. Your server must return the text OK in the response body to confirm that it received the notification. If our gateway doesn't receive an `OK` response, it retries the notification with exponential backoff over a 96-hour period. If all retries fail, our gateway sets the transaction to expired and sends an email to the merchant. Each notification contains the following parameters: | Parameter | Type | Size | Description | | --- | --- | --- | --- | | ADDRESS1 | String | 0-50 characters | First line of the customer's address. | | ADDRESS2 | String | 0-50 characters | Second line of the customer's address. | | ALLOWHPPSCSTORAGE | String | | Indicates if the customer chose to store their card details. If they stored their card details, we return a value of `ON`. | | AMOUNT | Double | | Subtotal of the transaction including taxes. This value doesn't include surcharges or convenience fees. | | APPROVALCODE | String | 0-48 characters | Authorization code that the processor assigned to the transaction. | | AVSRESPONSE | String | 1 character | Indicates if the address that the customer entered on the Hosted Payment Page matches the address linked to the card. The value is one of the following: - `A` - First five numerical characters in the address match, but the ZIP code or postal code doesn't match. - `E` - Transaction isn't eligible for an AVS check. - `N` - Address doesn't match. - `R` - AVS check temporarily unavailable. - `S` - Card type not supported by AVS. - `U` - Address information unavailable from the card issuer. - `G` - Address information unavailable from the card issuer. This value applies to only Visa cards. - `W` - ZIP code or postal code matches, but the street address doesn't. - `X` - Address matches. - `Y` - Address matches. - `Z` - ZIP code or postal code matches, but the street address doesn't. | | CARDHOLDERNAME | String | 0-50 characters | Customer's name. | | CARDNUMBER | String | 12-20 characters | Masked card number. Our gateway returns only the first six digits and the last four digits of the card number, for example, `548010******5929`. | | CITY | String | 0-40 characters | City of the customer's billing address. | | CVVRESPONSE | String | 1 character | Indicates if the card verification value (CVV) that the customer entered on the Hosted Payment Page matches the CVV on the card. The value is one of the following: - `M` - CVV matches. - `N` - CVV doesn't match. - `P` - CVV not processed. - `U` - CVV isn't registered. **Note:** Our gateway doesn't automatically decline transactions when the CVV doesn't match, unless the merchant has asked us to decline transactions where the CVV doesn't match. | | DATETIME | String | | Date and time that the processor received the request and returned a response to our gateway. We return this value in **YYYY-MM-DDTHH:MM:SS** format, for example, `2026-02-10T14:51:40`. | | DL\_NUMBER | String | 0-30 characters | License number of the customer's driver's license. | | DL\_STATE | String | 2 characters | Two-character abbreviation of the state that issued the customer's driver's license, for example, IL. | | HASH | String | 1-128 characters | SHA-512 hash value that we generate with values from the response parameters and the terminal secret. You can use this hash to verify that the response is legitimate. We return the hash in the following order: - `[TERMINALID]:[ORDERID]:[AMOUNT]:[DATETIME]:[RESPONSECODE]:[RESPONSETEXT]:[SECRET]` | | ORDERID | String | 1-24 characters | Unique identifier that the merchant assigned to the transaction. | | PAYLINK | String, UUID | 36 characters | Indicates the UUID of the payment link that the customer used to access the Hosted Payment Page. | | POSDEVICE | String | 0-30 characters | Name of the POS device that captured the customer's payment details. | | POSTCODE | String | 0-128 characters | Zip code or postal code of the customer's address. | | REGION | String | 0-128 characters | Region of the customer's billing address. | | RESPONSECODE | Enum | | Response code for the transaction from the processor. The value is one of the following: - `A` - Processor approved the transaction. - `E` - Processor authorized the transaction. This enum applies to only China UnionPay cards. - `D` - Processor declined the transaction. - `R` - Processor declined the transaction, and the customer should contact their bank. - `C` - Processor declined the transaction because the payment card was reported lost or stolen. | | RESPONSETEXT | String | 0-48 characters | Response description from the processor. | | SECURECARDMERCHANTREF | String | 1-200 characters | Unique identifier that the merchant assigned to the secure token. | | STATE | String | 0-128 characters | Name of the state or state abbreviation of the customer's billing address. | | SURCHARGE\_FEE | Double | | Surcharge fee that the merchant applied to the transaction. **Note:** You can't apply surcharges to pre-authorizations. | | SURCHARGE\_PERCENT | Double | | Surcharge percentage that the merchant applied to the transaction. **Note:** You can't apply surcharges to pre-authorizations. | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | UNIQUEREF | String | 10 characters | Unique identifier that our gateway assigned to the transaction. **Note:** Store the UNIQUEREF if you use our API for follow-on transactions, for example, to refund the transaction. | ### Example webhook notification ``` POSTCODE=*******&STATE=&ORDERID=40177609&AMOUNT=40.68®ION=Midwest&TERMINALID=12320002&CITY=Wisconsin&RESPONSETEXT=Invalid+card+number&RESPONSECODE=D&APPROVALCODE=&AVSRESPONSE=U&CVVRESPONSE=N&DATETIME=2026-04-09T09:34:46&UNIQUEREF=ABCULH4PKQ&CARDNUMBER=446261******1234&HASH=4r71bb0c4f488cb073985812ec9ccd28 ``` # Load the Hosted Payment Page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/preauth-load-payment-page Load the Hosted Payment Page for a pre-authorization by sending a POST request to the Pre-authorization Page URL with a signed HASH parameter An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). When your customer is ready to enter their payment details, load the Hosted Payment Page. To do this, add a button to your checkout page that sends a POST request to our gateway. When we receive the POST request, the Hosted Payment Page loads and the customer can submit their payment details. **Note:** The Hosted Payment Page doesn't return a transaction type in the transaction response. Because you can run sales, run pre-authorizations, and save a customer's payment details, we recommend that you record the transaction type in your system. ## Before you begin If you've already integrated with Hosted Payment Pages run a sale, the request parameters for running a pre-authorization are the same as the parameters for running a sale, but the URLs are different. ## Send a POST request to load the Hosted Payment Page To load the page, send a POST request to the Pre-authorization Page URL. | Environment | URL | | --- | --- | | Test | [https://payments.uat.payroc.com/merchant/preauthpage](https://payments.uat.payroc.com/merchant/preauthpage) | | Production | [https://payments.payroc.com/merchant/preauthpage](https://payments.payroc.com/merchant/preauthpage) | ### Request parameters To create the body of your request, use the following parameters: | Parameter | Type | Size | Description | | --- | --- | --- | --- | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | ORDERID | String | 1-24 characters | Unique identifier that the merchant assigns to the transaction. | | CURRENCY | String | 3 characters | Currency of the transaction. The value for the currency follows the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard. | | AMOUNT | Double | | Subtotal of the transaction including taxes. Don't include surcharges or convenience fees. | | DATETIME | String | | Date and time that you send the request. Send this value in **DD-MM-YYYY:HH:MM:SS:SSS** format, for example, `06-02-2026:12:23:23:719`. | | HASH | String | 1-128 characters | SHA-512 hash value that you generate with values from the request parameters and the terminal secret. For more information about how to create your HASH, go to [Authenticate your requests](/guides/payments/hosted-payment-page/preauth-authenticate-requests). | ### Example request ```html
``` ## Errors ### INVALID HASH If we can't authenticate your request, the Hosted Payment Page displays **INVALID HASH** in plain text. Check that you have set up your HASH correctly. For more information about the hash, go to [Authenticate your requests](). ### Validation Errors The Hosted Payment Page runs basic validation checks on the customer's input. If the customer enters incorrect information, for example, a card number that is too short, the page displays an error message and prompts the customer to correct the information. Your integration doesn't need to handle these validation errors because the Hosted Payment Page handles these errors for you. ## Next steps - [Build the merchant’s receipt page](/guides/payments/hosted-payment-page/preauth-build-receipt-page). # Load the Hosted Payment Page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/save-details-load-payment-page Load the Hosted Payment Page to save or update a customer's payment details by sending a POST request to the Secure Card Page URL with a signed HASH parameter An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). When your customer wants to save their payment details, load the Hosted Payment Page. To do this, add a button to your checkout page that sends a POST request to our gateway. When we receive the POST request, the Hosted Payment Page loads and the customer can submit their payment details. **Note:** The Hosted Payment Page doesn't return a transaction type in the transaction response. Because you can run sales, run pre-authorizations, and save a customer's payment details, we recommend that you record the transaction type in your system. You can also use this page to update a customer's payment details. When you load the Hosted Payment Page, provide the MERCHANTREF to indicate the customer's secure token that you want to update and send a value for the ACTION parameter of `update` instead of `register`. ## Send a POST request to load the Hosted Payment Page To load the page, send a POST request to the Secure Card Page URL. | Environment | URL | | --- | --- | | Test | [https://payments.uat.payroc.com/merchant/securecardpage](https://payments.uat.payroc.com/merchant/securecardpage) | | Production | [https://payments.payroc.com/merchant/securecardpage](https://payments.payroc.com/merchant/securecardpage) | ### Request parameters To create the body of your request, use the following parameters: | Parameter | Type | Size | Description | | --- | --- | --- | --- | | ACTION | Enum | | Indicates if the customer is saving new payment details or if they are updating existing payment details. The value is one of the following: - `register` - Customer is saving new payment details. - `update` - Customer is updating existing payment details. | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | MERCHANTREF | String | 1-200 characters | Unique identifier that the merchant assigns to the secure token. **Note:** We recommend that you store this value. | | DATETIME | String | | Date and time that you send the request. Send this value in **DD-MM-YYYY:HH:MM:SS:SSS** format, for example, `06-02-2026:12:23:23:719`. | | HASH | String | 1-128 characters | SHA-512 hash value that you generate with values from the request parameters and the terminal secret. For more information about how to create your hash, go to \[Authenticate your requests\]. | | STOREDCREDENTIALUSE | Enum | | Indicates how the merchant can use the card details, as agreed by the customer: - `UNSCHEDULED` - Transactions for a fixed or variable amount that are run at a certain predefined event. - `RECURRING` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Recurring transactions don't have a fixed duration and run until the customer cancels the agreement. - `INSTALLMENT` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Installment transactions have a fixed duration. **Note:** Send a value for this parameter if the customer is saving card details. | ## Next steps - [Build the merchant's receipt page]() # Build the merchant’s receipt page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/save-details-build-receipt-page Build a receipt page that reads the CARDREFERENCE and MERCHANTREF query parameters the Hosted Payment Page returns after saving a customer's payment details An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Create a receipt page on the merchant's website to display the transaction response to customers. After the customer submits their payment details, the Hosted Payment Page redirects them to the merchant's receipt page and appends the transaction response as query parameters. The receipt page must parse these parameters and display a success or decline message. **Note:** If there is an issue with saving the customer's payment details, the Hosted Payment Page still redirects the customer to the receipt page and returns the response in the query parameters. ## Before you begin You must have credentials for the Self-Care Portal, which is a self-serve portal that you use to configure terminal settings for your merchant. Use this portal to provide us with the URL for the receipt page. If you don't have credentials for the Self-Care Portal, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Integration steps 1. Provide us with the URL of the merchant's receipt page. 2. Handle the transaction response and present the outcome to the customer. ## Step 1. Provide us with the URL of the merchant's receipt page. **Important:** You must provide us with a URL that we redirect your customer to when they save their payment details. This URL is not the same as the receipt page URL you set up for sales and pre-authorizations. Provide us with the receipt page URL in the Self-Care Portal so that we know where to redirect customers after they submit their payment details and where to send the transaction response. To provide us with the URL, complete the following steps: 1. Sign in to the Self-Care Portal:- **Test:** [https://payments.uat.payroc.com/merchant/selfcare/](https://payments.uat.payroc.com/merchant/selfcare/) - **Production:** [https://payments.payroc.com/merchant/selfcare/](https://payments.payroc.com/merchant/selfcare/) 2. From the side menu, select **Settings**, and then select **Terminal**. 3. In the Secure Token URL field, enter the URL of the receipt page. 4. Select **UPDATE SETTINGS**. **Note:** Enter the receipt page URL in both the test and the production environments to ensure that you don't have issues when you complete your testing phase and start to run live transactions. ## Step 2. Handle the transaction response The Hosted Payment Page returns the transaction response as query parameters appended to the receipt page URL. The query parameters change depending on whether the customer saved their card details or their bank account details. You must program your integration to associate the MERCHANTREF and CARDREFERENCE parameters with the customer. You can use MERCHANTREF to look up the token in your merchant's database, and you use CARDREFERENCE instead of the customer's payment details in follow-on transactions. ### Query parameters | Parameter | Type | Size | Description | | --- | --- | --- | --- | | RESPONSECODE | Enum | | Response code from our gateway. The value is one of the following: - `A` - We stored the payment details. - `E14` - We couldn't store the card details because we couldn't validate them. - `E43` - We couldn't validate the bank details, but we stored the updated details. - `E44` - We couldn't store the bank details because we couldn't validate them. | | RESPONSETEXT | String | 1-48 characters | Description of the response code. | | MASKEDCARDNUMBER | String | 12-19 characters | Masked card number. Our gateway returns only the first six digits and the last four digits of the card number, for example, `548010******5929`. | | MERCHANTREF | String | 1-200 characters | Unique identifier that the merchant assigns to the secure token. **Note:** We recommend that you store this value. | | CARDHOLDERNAME | String | 1-50 characters | Customer's name. | | CARDREFERENCE | String | 12-19 characters | Secure token that represents the customer's payment details. **Note:** We recommend that you store this value to run follow-on transactions. | | CARDTYPE | String | | Card brand of the card. | | CARDEXPIRY | String | 4 characters | Expiry date of the customer's card. The format for this value is **MMYY**. | | TRANSITNUMBER | String | 5 characters | Five-digit number that identifies the customer's bank branch. | | ROUTINGNUMBER | String | 9 characters | Nine-digit number that identifies the customer's bank. | | ACCOUNTNUMBER | String | 4-17 characters | Number of the customer's bank account. Our gateway masks all digits except the last four digits, for example, `****3159`. | | ACCOUNTHOLDER\_NAME | String | 1-29 characters | Customer's name. | | INSTITUTIONNUMBER | String | 3 characters | Three-digit number that identifies the customer's bank. | | ACCOUNTTYPE | Enum | | Indicates the customer's account type. The value is one of the following: - `CHECKING` - `SAVINGS` | | DATETIME | String | | Date and time that the customer submitted their payment details. Our gateway returns this value in **DD-MM-YYYY:HH:MM:SS:SSS** format, for example, `06-02-2026:12:23:23:719`. | | HASH | String | 1-128 characters | SHA-512 hash value that we generated with values from the response parameters and the terminal secret. You can use this hash to verify that the response is legitimate. We return the hash in the following order: - `[TERMINALID]:[RESPONSECODE]:[RESPONSETEXT]:[MERCHANTREF]:[CARDREFERENCE]:[DATETIME]:[SECRET]` | | STOREDCREDENTIALUSE | Enum | | Indicates how the merchant can use the card details, as agreed by the customer: - `UNSCHEDULED` - Transactions for a fixed or variable amount that are run at a certain predefined event. - `RECURRING` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Recurring transactions don't have a fixed duration and run until the customer cancels the agreement. - `INSTALLMENT` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Installment transactions have a fixed duration. | | STOREDCREDENTIALTXTYPE | Enum | | Indicates if a payment with stored card details is the first in a series of payments, or if it is a follow-on payment. The value is one of the following: - `FIRST_TXN` - First payment in a series of payments. - `SUBSEQUENT_CARDHOLDER_INITIATED_TXN` - Payment that the customer initiates after the first payment in the series. - `SUBSEQUENT_MERCHANT_INITIATED_TXN` - Payment that the merchant initiates after the first payment in the series. **Note:** We return this field only if the customer used saved payment details for the transaction. | | BRANDTXIDENTIFIER | String | 1-64 characters | Unique identifier that the card brand assigns to the transaction. If you use a third-party vault for tokenization, include this value when you use a secure token in follow-on transactions with our API, for example, to refund the transaction. | # Capture the pre-authorization Source: https://docs.payroc.com/guides/payments/hosted-payment-page/capture-pre-authorization Capture a pre-authorization by sending a POST request to the Payments capture endpoint with the UNIQUEREF paymentId, optionally specifying an amount to capture a partial value. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). If your merchant doesn't capture a pre-authorization, it expires and the issuing bank releases the hold on the customer's card. To capture the pre-authorization, you must use our API. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Send a POST request to capture the pre-authorization To capture the pre-authorization, you need the UNIQUEREF that we returned to the merchant's receipt page. Send the UNIQUEREF in the paymentId path parameter in a POST request to our Payments endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/payments/:paymentId/capture](https://api.uat.payroc.com/v1/payments/:paymentId/capture) | | Production | [https://api.payroc.com/v1/payments/:paymentId/capture](https://api.payroc.com/v1/payments/:paymentId/capture) | Depending on the amount you want to capture: - **Capture the full amount of the pre-authorization** - Don’t send a value for the amount parameter in your request. - **Capture less than the amount of the pre-authorization** - Send a value for the amount parameter in your request. - **Capture more than the amount of the pre-authorization** - Adjust the pre-authorization before you capture it. For more information about adjusting a pre-authorization, go to [Adjust Payment](/api/adjust-payment). ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments/{paymentId}/capture`](/api/capture-payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments/\{paymentId\}/capture](https://api.payroc.com/v1/payments/%7BpaymentId%7D/capture) **`Payment capture`** ```curl curl -X POST https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "operator": "Jane", "amount": 4999, "breakdown": { "subtotal": 4999, "dutyAmount": 499, "freightAmount": 500, "items": [ { "unitPrice": 4000, "quantity": 1 } ] } }' ``` **`Payment capture`** ```python import requests url = "https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture" payload = { "processingTerminalId": "1234001", "operator": "Jane", "amount": 4999, "breakdown": { "subtotal": 4999, "dutyAmount": 499, "freightAmount": 500, "items": [ { "unitPrice": 4000, "quantity": 1 } ] } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Payment capture`** ```javascript const url = 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","operator":"Jane","amount":4999,"breakdown":{"subtotal":4999,"dutyAmount":499,"freightAmount":500,"items":[{"unitPrice":4000,"quantity":1}]}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment capture`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"operator\": \"Jane\",\n \"amount\": 4999,\n \"breakdown\": {\n \"subtotal\": 4999,\n \"dutyAmount\": 499,\n \"freightAmount\": 500,\n \"items\": [\n {\n \"unitPrice\": 4000,\n \"quantity\": 1\n }\n ]\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment capture`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"operator\": \"Jane\",\n \"amount\": 4999,\n \"breakdown\": {\n \"subtotal\": 4999,\n \"dutyAmount\": 499,\n \"freightAmount\": 500,\n \"items\": [\n {\n \"unitPrice\": 4000,\n \"quantity\": 1\n }\n ]\n }\n}" response = http.request(request) puts response.read_body ``` **`Payment capture`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"operator\": \"Jane\",\n \"amount\": 4999,\n \"breakdown\": {\n \"subtotal\": 4999,\n \"dutyAmount\": 499,\n \"freightAmount\": 500,\n \"items\": [\n {\n \"unitPrice\": 4000,\n \"quantity\": 1\n }\n ]\n }\n}") .asString(); ``` **`Payment capture`** ```php request('POST', 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture', [ 'body' => '{ "processingTerminalId": "1234001", "operator": "Jane", "amount": 4999, "breakdown": { "subtotal": 4999, "dutyAmount": 499, "freightAmount": 500, "items": [ { "unitPrice": 4000, "quantity": 1 } ] } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Payment capture`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"operator\": \"Jane\",\n \"amount\": 4999,\n \"breakdown\": {\n \"subtotal\": 4999,\n \"dutyAmount\": 499,\n \"freightAmount\": 500,\n \"items\": [\n {\n \"unitPrice\": 4000,\n \"quantity\": 1\n }\n ]\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Payment capture`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "operator": "Jane", "amount": 4999, "breakdown": [ "subtotal": 4999, "dutyAmount": 499, "freightAmount": 500, "items": [ [ "unitPrice": 4000, "quantity": 1 ] ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we capture the pre-authorization and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments/{paymentId}/capture`](/api/capture-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Customize your Hosted Payment Page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/customize-hosted-payment-page Customize the look of your Hosted Payment Page to match the look and feel of your website. **Prerequisites:** [Authentication](/api/authentication) You can change the appearance of the Hosted Payment Page to match the styling of your integration. Use the Self-Care Portal to create or edit an existing template, and choose which template you display to users on different devices. When you apply a template, it shows on all Hosted Payment Pages that you've integrated with, for example, if you've extended your integration to run a pre-authorization or to set up subscriptions. **Note:** You can't edit the validation error messages that we display on the Hosted Payment Page. To edit the appearance of the Hosted Payment Page and display it to a user, complete the following steps: 1. Customize a template. 2. Apply the template. ## Step 1. Customize a template 1. Log in to the Self-Care Portal: - Test: [https://payments.uat.payroc.com/merchant/selfcare/](https://payments.uat.payroc.com/merchant/selfcare/) - Production: [https://payments.payroc.com/merchant/selfcare/](https://payments.payroc.com/merchant/selfcare/). 2. From the navigation menu, select **Settings**, and then select **Pay Pages**. 3. Select **Add Template** to create a new template, or select **Edit** to make changes to an existing template. 4. Select your editor mode:- Basic – Style the page using the editor. - Advanced – Edit the CSS directly. 5. Use the editor to configure the template. 6. (Optional) If you have extended your integration to run pre-authorizations, tokenize payment details, or set up subscriptions, use the **Preview** dropdown menu to preview your changes for each type of Hosted Payment Page. 7. (Optional) If your account uses Level 3 enhanced data, enable **Display Enhanced Data** to show itemized transaction details on the payment page. 8. Select **Save Changes**. ## Step 2. Apply the template After you create a template, you must indicate if it is the default. You can also specify if you want to apply the template only on a specific device type, for example, when a user accesses the Hosted Payment Page from a mobile device. ### Set the template as the default You can set only one template as the default. When you load the Hosted Payment Page, we display the default template automatically unless you apply settings for specific device types. To set the template as the default, select the radio button in the **Default** column. ### Apply the template for specific device types You can also specify which Hosted Payment Page template displays on a specific device type. If a user accesses the Hosted Payment Page from a device that matches the criteria you set, this overrides the default. To apply the template for specific device types, select from the following checkboxes under the **Use for Internet** column: - **Mobile** – We display the template to users who access the Hosted Payment Page on a mobile device. - **Tablet** – We display the template to users who access the Hosted Payment Page on a tablet device. - **Other** – We display the template to users who access the Hosted Payment Page on a device that is not a tablet or mobile device, for example, a desktop computer. **Note:** The **Use for MOTO** column doesn't apply to your integration. # Extend your integration Source: https://docs.payroc.com/guides/payments/hosted-payment-page/extend-your-integration Explore guides for extending a Hosted Payment Page integration, including pre-authorizations, saving payment details, repeat payments, and background validation. **Prerequisites:** [Authentication](/api/authentication) After you set up the Hosted Payment Page to run a sale, you can extend your integration to include the following: - [**Run a pre-authorization**](/guides/payments/hosted-payment-page/pre-authorization) - Hold an amount on a customer's card and then capture the payment later. - [**Save a customer's payment details**](/guides/payments/hosted-payment-page/save-payment-details) - Store customer payment details for use in future transactions. - [**Set up repeat payments**](/guides/payments/hosted-payment-page/set-up-repeat-payments) - Create payment plans and subscribe your customers to them to accept regular, scheduled payments. - [**Implement background validation**](/guides/payments/hosted-payment-page/background-validation) - Check if our gateway processed a card payment. ## Guides To extend your Hosted Payment Page integration, follow our guides: #### [Run a pre-authorization](/guides/payments/hosted-payment-page/pre-authorization) #### [Save a customer's payment details](/guides/payments/hosted-payment-page/save-payment-details) #### [Set up repeat payments](/guides/payments/hosted-payment-page/set-up-repeat-payments) #### [Implement background validation](/guides/payments/hosted-payment-page/background-validation) # Hosted Payment Page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/integration-overview Learn how the Hosted Payment Page works and follow the integration journey to run a sale, then extend your integration with optional features. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Use our Hosted Payment Page solution to add a secure payment page to your checkout. When a customer is ready to pay, redirect them to an external payment page that we host where they can submit their payment details. We then securely process the transaction and return the transaction response. Because we host the payment page and handle the sensitive payment details, your integration does not need to process or store the payment details. This reduces the merchant's PCI compliance scope while still allowing them to accept payments online. ## How it works ```mermaid sequenceDiagram participant W as Website participant GW as Gateway participant HPP as Hosted Payment Page rect rgba(0, 81, 194, 0.4) Note over W: 1. Customer selects button to pay W->>GW: 2. Send transaction request Note over GW: 3. Authenticate the request GW->>HPP: 4. Load the Hosted Payment Page Note over HPP: 5. Customer submits their payment details HPP->>GW: 6. Send transaction details Note over GW: 7. Send transaction details to the processor Note over GW: 8. Processor returns a response for the transaction GW-->>W: 9. Send transaction response Note over W: 10. Display transaction response to the customer end ``` 1. Customer selects button to pay on the merchant's website. 2. Button sends a transaction request to our gateway for authentication and to load the Hosted Payment Page. 3. Gateway validates the request. 4. Gateway loads the Hosted Payment Page and redirects the customer. 5. Customer submits their payment details on the Hosted Payment Page. 6. Hosted Payment Page sends the transaction details to our gateway. 7. Gateway sends the transaction details to the processor. 8. Processor returns a response for the transaction. 9. Gateway sends the transaction response to the merchant's website. 10. Merchant's website displays the transaction response to the customer. ## Your integration journey To run a sale with the Hosted Payments Page, complete the following steps: - [Authenticate your requests](/guides/payments/hosted-payment-page/authenticate-requests) - Create a SHA-512 hash that you send in your request to load the Hosted Payment Page. This authenticates that you can send transactions to our gateway. - [Add a button to load the page](/guides/payments/hosted-payment-page/load-payment-page) - Send a request that loads the Hosted Payment Page. The request contains all the transaction details that you need to complete the sale, for example, amount and payment method. - [Build your receipt page](/guides/payments/hosted-payment-page/build-receipt-page) - Provide us with a URL for the merchant's receipt page that you want us to send the transaction response to and to redirect customers to. **Important:** If your integration accepts card payments, we strongly recommend that you implement background validation. It confirms if our gateway processed the payment even if there's a communication issue between our gateway and the Hosted Payment Page. For more information about background validation, go to [Implement Background Validation](/guides/payments/hosted-payment-page/background-validation). ## Extend your integration After you integrate with Hosted Payment Page to run a sale, you can extend your integration to include the following: - Implement background validation. - Run pre-authorizations. - Save a customer's payment details. - Set up repeat payments. - Add optional parameters to your requests. - Run refunds and reversals. - Re-present an ACH payment. For more information about how to extend your integration, go to [Extend your integration](/guides/payments/hosted-payment-page/extend-your-integration). # Hosted Payment Page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/overview Learn how the Hosted Payment Page works and follow the integration journey to run a sale, then extend your integration with optional features. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Use our Hosted Payment Page solution to add a secure payment page to your checkout. When a customer is ready to pay, redirect them to an external payment page that we host where they can submit their payment details. We then securely process the transaction and return the transaction response. Because we host the payment page and handle the sensitive payment details, your integration does not need to process or store the payment details. This reduces the merchant's PCI compliance scope while still allowing them to accept payments online. ## How it works ```mermaid sequenceDiagram participant W as Website participant GW as Gateway participant HPP as Hosted Payment Page rect rgba(0, 81, 194, 0.4) Note over W: 1. Customer selects button to pay W->>GW: 2. Send transaction request Note over GW: 3. Authenticate the request GW->>HPP: 4. Load the Hosted Payment Page Note over HPP: 5. Customer submits their payment details HPP->>GW: 6. Send transaction details Note over GW: 7. Send transaction details to the processor Note over GW: 8. Processor returns a response for the transaction GW-->>W: 9. Send transaction response Note over W: 10. Display transaction response to the customer end ``` 1. Customer selects button to pay on the merchant's website. 2. Button sends a transaction request to our gateway for authentication and to load the Hosted Payment Page. 3. Gateway validates the request. 4. Gateway loads the Hosted Payment Page and redirects the customer. 5. Customer submits their payment details on the Hosted Payment Page. 6. Hosted Payment Page sends the transaction details to our gateway. 7. Gateway sends the transaction details to the processor. 8. Processor returns a response for the transaction. 9. Gateway sends the transaction response to the merchant's website. 10. Merchant's website displays the transaction response to the customer. ## Your integration journey To run a sale with the Hosted Payments Page, complete the following steps: - [Authenticate your requests](/guides/payments/hosted-payment-page/authenticate-requests) - Create a SHA-512 hash that you send in your request to load the Hosted Payment Page. This authenticates that you can send transactions to our gateway. - [Add a button to load the page](/guides/payments/hosted-payment-page/load-payment-page) - Send a request that loads the Hosted Payment Page. The request contains all the transaction details that you need to complete the sale, for example, amount and payment method. - [Build your receipt page](/guides/payments/hosted-payment-page/build-receipt-page) - Provide us with a URL for the merchant's receipt page that you want us to send the transaction response to and to redirect customers to. **Important:** If your integration accepts card payments, we strongly recommend that you implement background validation. It confirms if our gateway processed the payment even if there's a communication issue between our gateway and the Hosted Payment Page. For more information about background validation, go to [Implement Background Validation](/guides/payments/hosted-payment-page/background-validation). ## Extend your integration After you integrate with Hosted Payment Page to run a sale, you can extend your integration to include the following: - Implement background validation. - Run pre-authorizations. - Save a customer's payment details. - Set up repeat payments. - Add optional parameters to your requests. - Run refunds and reversals. - Re-present an ACH payment. For more information about how to extend your integration, go to [Extend your integration](/guides/payments/hosted-payment-page/extend-your-integration). # Run a pre-authorization Source: https://docs.payroc.com/guides/payments/hosted-payment-page/pre-authorization Run a pre-authorization on the Hosted Payment Page to hold an amount on a customer's card before your merchant captures it later An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Use the Hosted Payment Page to run a pre-authorization. Your merchant runs a pre-authorization to hold an amount on a customer's card, which your merchant then captures later. If your merchant doesn't capture a pre-authorization, it expires and the issuing bank releases the hold on the customer's card. Your merchant can't run pre-authorizations if they: - Use a dual pricing or a surcharging program - Apply convenience fees to transactions Your merchant can't run a pre-authorization if the customer uses bank account details. If a customer submits bank account details, our gateway runs a sale instead of a pre-authorization. ## Integration journey - [Authenticate your requests](/guides/payments/hosted-payment-page/preauth-authenticate-requests) - [Load the Hosted Payment Page](/guides/payments/hosted-payment-page/preauth-load-payment-page) - [Build the merchant's receipt page](/guides/payments/hosted-payment-page/preauth-build-receipt-page) - [Capture the pre-authorization](/guides/payments/hosted-payment-page/capture-pre-authorization) # Authenticate your requests Source: https://docs.payroc.com/guides/payments/hosted-payment-page/preauth-authenticate-requests Authenticate a pre-authorization request on the Hosted Payment Page by reusing the same SHA-512 hash setup you built to run a sale An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). To load the Hosted Payment Page, you need to include a SHA-512 hash in the HASH parameter. The hash authenticates your request and prevents tampering with sensitive values during transit to our gateway. Because you've already integrated with Hosted Payment pages to run a sale, you've completed the following steps: - Created a terminal secret - Created a dynamic hash function You don't need to do anything as the required parameter values for the hash to run a pre-authorization are the same as the parameter values to run a sale. ## Next steps - [Load the Hosted Payment Page](/guides/payments/hosted-payment-page/preauth-load-payment-page) # Build the merchant’s receipt page Source: https://docs.payroc.com/guides/payments/hosted-payment-page/preauth-build-receipt-page Build a receipt page that reads the query parameters the Hosted Payment Page appends after a pre-authorization, including the UNIQUEREF you need to capture it later An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Create a receipt page on the merchant's website to display the transaction response to customers. After the customer submits their payment details, the Hosted Payment Page redirects them to the merchant's receipt page and appends the transaction response as query parameters. The receipt page must parse these parameters and display a success or decline message. **Note:** If a pre-authorization is declined, the Hosted Payment Page still redirects the customer to the receipt page and returns the response in the query parameters. ## Before you begin If you've already integrated with run a sale, you've completed the following steps: - You've provided us with the URL of the merchant's receipt page. - You've handled the response parameters to run a sale, which are the same for running pre-authorizations. We’ve included them below. However, you must store the UNIQUEREF from the response so you can capture the pre-authorization later. ## Handle the transaction response The Hosted Payment Page returns the transaction response as query parameters appended to the receipt page URL. ### Card details | Parameter | Type | Size | Description | | --- | --- | --- | --- | | TERMINALID | String | 1-50 characters | Unique identifier that we assigned to the terminal. | | ORDERID | String | 1-24 characters | Unique identifier that the merchant assigned to the transaction. | | APPROVALCODE | String | 0-48 characters | Authorization code that the processor assigned to the transaction. | | AMOUNT | Double | | Subtotal of the transaction including taxes. This value doesn't include surcharges or convenience fees. | | RESPONSECODE | Enum | | Response code for the transaction from the processor. The value is one of the following: - `A` - Processor approved the transaction. - `E` - Processor authorized the transaction. This enum applies to only China UnionPay cards. - `D` - Processor declined the transaction. - `R` - Processor declined the transaction, and the customer should contact their bank. - `C` - Processor declined the transaction because the payment card was reported lost or stolen. | | RESPONSETEXT | String | 0-48 characters | Response description from the processor. | | DATETIME | String | | Date and time that the processor received the request and returned a response to our gateway. We return this value in **YYYY-MM-DDTHH:MM:SS** format, for example, `2026-02-10T14:51:40`. | | AVSRESPONSE | String | 1 character | Indicates if the address that the customer entered on the Hosted Payment Page matches the address linked to the card. The value is one of the following: - `A` - First five numerical characters in the address match, but the ZIP code or postal code doesn't match. - `E` - Transaction isn't eligible for an AVS check. - `N` - Address doesn't match. - `R` - AVS check temporarily unavailable. - `S` - Card type not supported by AVS. - `U` - Address information unavailable from the card issuer. - `G` - Address information unavailable from the card issuer. This value applies to only Visa cards. - `W` - ZIP code or postal code matches, but the street address doesn't. - `X` - Address matches. - `Y` - Address matches. - `Z` - ZIP code or postal code matches, but the street address doesn't. | | CVVRESPONSE | String | 1 character | Indicates if the card verification value (CVV) that the customer entered on the Hosted Payment Page matches the CVV on the card. The value is one of the following: - `M` - CVV matches. - `N` - CVV doesn't match. - `P` - CVV not processed. - `U` - CVV isn't registered. **Note:** Our gateway doesn't automatically decline transactions when the CVV doesn't match, unless the merchant has asked us to decline transactions where the CVV doesn't match. | | UNIQUEREF | String | 10 characters | Unique identifier that our gateway assigned to the transaction. **Note:** Store the UNIQUEREF if you use our API for follow-on transactions, for example, to refund the transaction. | | CARDREFERENCE | String | 12-19 characters | Secure token that represents the customer's payment details. | | EMAIL | String | 1-128 characters | Customer's email address. | | PHONE | String | 5-20 characters | Customer's phone number. | | REGION | String | 0-128 characters | Region of the customer's billing address. | | CITY | String | 0-40 characters | City of the customer's billing address. | | POSTCODE | String | 0-128 characters | Zip code or postal code of the customer's address. | | STATE | String | 0-128 characters | Name of the state or state abbreviation of the customer's billing address. | | COUNTRY | String | 2 characters | Two-letter code for the country of the customer's card. The format follows the [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) standard. | | CARDNUMBER | String | 12-19 characters | Masked card number. Our gateway returns only the first six digits and the last four digits of the card number, for example, `548010******5929`. | | CARDHOLDERNAME | String | 0-50 characters | Customer's name. | | CARDTYPE | String | | Card brand of the card. | | HASH | String | 1-128 characters | SHA-512 hash value that we generate with values from the response parameters and the terminal secret. You can use this hash to verify that the response is legitimate. We return the hash in the following order: - `[TERMINALID]:[ORDERID]:[AMOUNT]:[DATETIME]:[RESPONSECODE]:[RESPONSETEXT]:[SECRET]` | | CUSTOMFIELD | String | | Custom field that you sent in the request. | | OTHERFIELD | String | 0-2000 characters | Other field that you sent in the request. | | BRANDTXIDENTIFIER | String | 1-50 characters | Unique identifier that the card brand assigns to the transaction. If you use a third-party vault for tokenization, include this value when you use a secure token in follow-on transactions with our API, for example, to refund the transaction. | | SECURECARDMERCHANTREF | String | 1-200 characters | Unique identifier that the merchant assigned to the secure token. | | STOREDCREDENTIALUSE | Enum | | Indicates how the merchant can use the card details, as agreed by the customer: - `UNSCHEDULED` - Transactions for a fixed or variable amount that are run at a certain predefined event. - `RECURRING` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Recurring transactions don't have a fixed duration and run until the customer cancels the agreement. - `INSTALLMENT` - Transactions for a fixed amount that are run at regular intervals, for example, monthly. Installment transactions have a fixed duration. **Note:** We return this field only if the merchant has tokenized the card details as part of the transaction. | | STOREDCREDENTIALTXTYPE | Enum | | Indicates if a payment with stored card details is the first in a series of payments, or if it is a follow-on payment. The value is one of the following: - `FIRST_TXN` - First payment in a series of payments. - `SUBSEQUENT_CARDHOLDER_INITIATED_TXN` - Payment that the customer initiates after the first payment in the series. - `SUBSEQUENT_MERCHANT_INITIATED_TXN` - Payment that the merchant initiates after the first payment in the series. **Note:** We return this field only if the customer used saved payment details for the transaction. | | BYPASS\_SURCHARGE | Boolean | | Indicates if the merchant has bypassed surcharges for the transaction. The value is one of the following: - `true` - Surcharges don't apply to the transaction. - `false` - Surcharges apply to the transaction. **Note:** You can't apply surcharges to pre-authorizations. | | ACCEPTTERMSANDCONDITIONS | Enum | | Indicates if the customer accepted the terms and conditions for convenience fees. We return a value of `ON` because the customer can't complete the transaction without accepting the terms and conditions. **Note:** You can't apply convenience fees to pre-authorizations. | | CONVENIENCE\_FEE | Double | | Convenience fee that the merchant applied to the transaction. **Note:** You can't apply convenience fees to pre-authorizations. | | SURCHARGE\_FEE | Double | | Surcharge fee that the merchant applied to the transaction. **Note:** You can't apply surcharges to pre-authorizations. | | SURCHARGE\_PERCENT | Double | | Surcharge percentage that the merchant applied to the transaction. **Note:** You can't apply surcharges to pre-authorizations. | | DL\_NUMBER | String | 0-30 characters | License number of the customer's driver's license. | | DL\_STATE | String | 2 characters | Two-character abbreviation of the state that issued the customer's driver's license, for example, `IL`. | | POSDEVICE | String | 0-30 characters | Name of the POS device that captured the customer's payment details. | #### Example response ``` https://[receipt_page_url].com/receipt?DL_NUMBER=&DL_STATE=&CARDREFERENCE=&POSDEVICE=&STATE=&OTHERFIELD_1=Other+Field1&ORDERID=HPP967631811&AMOUNT=10.17&BYPASS_SURCHARGE=&ACCEPTTERMSANDCONDITIONS=ON&SECURECARDMERCHANTREF=®ION=&TERMINALID=3204004&CITY=&CONVENIENCE_FEE=2.00&RESPONSETEXT=OK8835&RESPONSECODE=A&APPROVALCODE=OK8835&CVVRESPONSE=M&DATETIME=2026-02-10T09:16:23&UNIQUEREF=JH1TY9LL4S&EMAIL=vvd%40worldnettps.it&PHONE=8000005555&CARDTYPE=VISA%20DEBIT&CARDNUMBER=411111******1111&HASH=70a28ef2f11f3b415ba0aac52631cb2755a56641bfebaa33dd581f59b9cf3a48e264e5710886987bf5cd54967a67716b2b256ed92ce33ca529547c024b5e9398 ``` # Authenticate your requests Source: https://docs.payroc.com/guides/payments/hosted-payment-page/save-details-authenticate-requests Build the SHA-512 hash string needed to authenticate a request that saves a customer's payment details on the Hosted Payment Page An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). To load the Hosted Payment Page, you need to include a SHA-512 hash in the HASH parameter. The hash authenticates your request and prevents tampering with sensitive values during transit to our gateway. Because you've already integrated with Hosted Payment Pages to [run a sale](/guides/payments/hosted-payment-page/load-payment-page), you've already added a terminal secret. However, the hash string for saving a customer's payment details is made up of different values. ## Build and hash the request string Create a colon-delimited string from specific request parameter values, append your terminal secret, and then convert the string to a SHA-512 hash. To create the hash string to save a customer's payment details, complete the following steps: 1. Build your hash with your parameter values in the following order:- `[TERMINALID]:[MERCHANTREF]:[DATETIME]:[ACTION]:[SECRET]` 2. Replace the placeholders with actual values:- `3204004:561234:10-02-2026:09:14:54:058:register:example_secret_123` 3. Use a hashing library in your programming language to convert the string to a SHA-512 hash:- `a674cad40ad2c6bb9421c053e254dbe5fa49335babd0360e15a7875b43c1dedb880df5ca000946a1376237a039bd36c33758c1a3a4c396a324d2534fbddacb44` You send this value in the HASH parameter of your request to load the Hosted Payment Page. ## Next steps - [Load the Hosted Payment Page](/guides/payments/hosted-payment-page/save-details-load-payment-page) # Save a Customer’s Payment Details Source: https://docs.payroc.com/guides/payments/hosted-payment-page/save-payment-details Save a customer's card or bank details on the Hosted Payment Page and get back a secure token you can use for follow-on transactions An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Use the Hosted Payment Page to save a customer’s payment details. When the customer submits their card or bank details, we store the payment information in our vault and return a secure token. Your integration needs to store this secure token and associate it with your customer, then the merchant or the customer can use it in follow-on transactions. ## Integration journey - [Authenticate your requests](/guides/payments/hosted-payment-page/save-details-authenticate-requests) - [Load the Hosted Payment Page](/guides/payments/hosted-payment-page/save-details-load-payment-page) - [Build the merchant’s receipt page](/guides/payments/hosted-payment-page/save-details-build-receipt-page) # Set up repeat payments Source: https://docs.payroc.com/guides/payments/hosted-payment-page/set-up-repeat-payments Set up repeat payments via the Hosted Payment Page by creating a payment plan and subscription using POST requests to the Payment Plans and Subscriptions endpoints. **Prerequisites:** [Authentication](/api/authentication) · [Save a Customer’s Payment Details](/guides/payments/hosted-payment-page/save-payment-details) An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Repeat payments are payments that a merchant takes from a customer on a regular schedule. For example, a merchant can offer a monthly product such as a magazine subscription or a merchant can allow customers to split large payments into smaller regular payments. To schedule repeat payments, you need to complete the following steps: - Save the customer's payment details to use instead of their raw payment details. - Create a payment plan to indicate how a merchant takes payments from their customer. It defines the frequency, amount, length, and collection method for each payment. - Use a subscription to assign a customer to a payment plan. A merchant can personalize a subscription for a specific customer, for example, add a discount or collect a one-off setup fee. ## How it works ```mermaid sequenceDiagram actor C as Customer participant HPP as Hosted Payment Page participant MS as Merchant's server participant GW as Gateway rect rgba(0, 81, 194, 0.4) Note over C,HPP: Step 1 — Save payment details C->>HPP: Enter card details HPP->>GW: Tokenize card GW-->>HPP: CARDREFERENCE HPP-->>MS: Redirect with CARDREFERENCE Note right of MS: Store CARDREFERENCE end rect rgba(0, 224, 184, 0.3) Note over MS,GW: Step 2 — Create payment plan MS->>GW: POST /payment-plans Note over MS,GW: name, currency, type, frequency,
length, recurringOrder.amount GW-->>MS: paymentPlanId Note right of MS: Store paymentPlanId end rect rgba(0, 224, 184, 0.3) Note over MS,GW: Step 3 — Create subscription MS->>GW: POST /subscriptions Note over MS,GW: paymentPlanId,
paymentMethod.secureToken.token = CARDREFERENCE,
startDate GW-->>MS: subscriptionId Note right of MS: Store subscriptionId end rect rgba(0, 224, 184, 0.3) Note over MS,GW: Step 4 — Collect payments alt Automatic plan GW-->>C: Gateway collects on schedule else Manual plan MS->>GW: POST /subscriptions/{subscriptionId}/pay Note over MS,GW: order.orderId, order.amount GW-->>MS: Payment confirmed end end ``` 1. The customer submits their card details on the Hosted Payment Page (HPP) tokenization page. Our gateway stores the payment details and returns a CARDREFERENCE. 2. You create a payment plan with our API. Our gateway returns a `paymentPlanId`. 3. You create a subscription with our API to assign the customer to the payment plan. In your request, send the CARDREFERENCE and the `paymentPlanId`. 4. Our gateway collects payments automatically according to the plan schedule. If the payment plan uses manual collection, use the `subscriptionId` to collect each payment. ## Integration journey 1. Integrate with the Hosted Payment Page to save a customer's payment details. 2. Integrate with our API to:- Create a payment plan. - Assign a customer to a payment plan. - (Optional) Manually collect a payment from a customer. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Save a customer's payment details Before you can schedule repeat payments, you need to save the customer's payment details using the Hosted Payment Page. The Hosted Payment Page captures the card details and stores them in our vault. Our gateway returns a value for the CARDREFERENCE parameter, which is a secure token that represents the customer's payment details. Store the CARDREFERENCE and use it when you create a subscription. To integrate with the Hosted Payment Page to save a customer's payment details, go to [Save a customer's payment details](/guides/payments/hosted-payment-page/save-payment-details). ## Step 2. Create a payment plan To create a payment plan, send a POST request to our Payment Plans endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId\}/payment-plans](https://api.uat.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/payment-plans) | | Production | [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/payment-plans](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/payment-plans) | **Note:** To allow merchants to add their own information to the payment plan, use custom fields. For more information about how to add custom fields, go to [Add custom fields to your integration](/guides/payments/add-custom-fields). ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/payment-plans`](/api/create-payment-plan) ### Example request ### Request POST https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/payment-plans ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/payment-plans \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": [ "yourCustomField" ], "setupOrder": { "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } } }' ``` **`Payment Plan`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/payment-plans" payload = { "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": ["yourCustomField"], "setupOrder": { "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Payment Plan`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/payment-plans'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"paymentPlanId":"PlanRef8765","name":"Premium Club","currency":"USD","type":"automatic","frequency":"monthly","onUpdate":"continue","onDelete":"complete","description":"Monthly Premium Club subscription","length":12,"customFieldNames":["yourCustomField"],"setupOrder":{"amount":4999,"description":"Initial setup fee for Premium Club subscription","breakdown":{"subtotal":4347,"taxes":[{"name":"Sales Tax","rate":5}]}},"recurringOrder":{"amount":4999,"description":"Monthly Premium Club subscription","breakdown":{"subtotal":4347,"taxes":[{"name":"Sales Tax","rate":5}]}}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment Plan`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/payment-plans" payload := strings.NewReader("{\n \"paymentPlanId\": \"PlanRef8765\",\n \"name\": \"Premium Club\",\n \"currency\": \"USD\",\n \"type\": \"automatic\",\n \"frequency\": \"monthly\",\n \"onUpdate\": \"continue\",\n \"onDelete\": \"complete\",\n \"description\": \"Monthly Premium Club subscription\",\n \"length\": 12,\n \"customFieldNames\": [\n \"yourCustomField\"\n ],\n \"setupOrder\": {\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment Plan`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/payment-plans") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"paymentPlanId\": \"PlanRef8765\",\n \"name\": \"Premium Club\",\n \"currency\": \"USD\",\n \"type\": \"automatic\",\n \"frequency\": \"monthly\",\n \"onUpdate\": \"continue\",\n \"onDelete\": \"complete\",\n \"description\": \"Monthly Premium Club subscription\",\n \"length\": 12,\n \"customFieldNames\": [\n \"yourCustomField\"\n ],\n \"setupOrder\": {\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n }\n}" response = http.request(request) puts response.read_body ``` **`Payment Plan`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/payment-plans") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"paymentPlanId\": \"PlanRef8765\",\n \"name\": \"Premium Club\",\n \"currency\": \"USD\",\n \"type\": \"automatic\",\n \"frequency\": \"monthly\",\n \"onUpdate\": \"continue\",\n \"onDelete\": \"complete\",\n \"description\": \"Monthly Premium Club subscription\",\n \"length\": 12,\n \"customFieldNames\": [\n \"yourCustomField\"\n ],\n \"setupOrder\": {\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n }\n}") .asString(); ``` **`Payment Plan`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/payment-plans', [ 'body' => '{ "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": [ "yourCustomField" ], "setupOrder": { "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Payment Plan`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/payment-plans"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"paymentPlanId\": \"PlanRef8765\",\n \"name\": \"Premium Club\",\n \"currency\": \"USD\",\n \"type\": \"automatic\",\n \"frequency\": \"monthly\",\n \"onUpdate\": \"continue\",\n \"onDelete\": \"complete\",\n \"description\": \"Monthly Premium Club subscription\",\n \"length\": 12,\n \"customFieldNames\": [\n \"yourCustomField\"\n ],\n \"setupOrder\": {\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Payment Plan`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": ["yourCustomField"], "setupOrder": [ "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": [ "subtotal": 4347, "taxes": [ [ "name": "Sales Tax", "rate": 5 ] ] ] ], "recurringOrder": [ "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": [ "subtotal": 4347, "taxes": [ [ "name": "Sales Tax", "rate": 5 ] ] ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/payment-plans")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we create the payment plan and return a response. Store the `paymentPlanId` and send it when you create the subscription. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/payment-plans`](/api/create-payment-plan) ### Example response ### Response (201) ```json { "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "processingTerminalId": "1234001", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": [ "yourCustomField" ], "setupOrder": { "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } } } ``` ## Step 3. Create a subscription To assign a customer to a payment plan, send a POST request to our Subscriptions endpoint. Send the CARDREFERENCE from Step 1 in the `token` parameter. You can also use this request to personalize the payment plan for each customer, for example, apply a discount on each payment or add a one-off setup fee. | Environment | URL | | --- | --- | | Test | https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions | | Production | https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions | ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/subscriptions`](/api/create-subscription) ### Example request ### Request POST https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/subscriptions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "subscriptionId": "SubRef7654", "paymentPlanId": "PlanRef8765", "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "startDate": "2024-07-02", "name": "Premium Club", "description": "Premium Club subscription", "setupOrder": { "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription" }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ] } }, "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0 }' ``` **`Subscription with surcharge`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions" payload = { "subscriptionId": "SubRef7654", "paymentPlanId": "PlanRef8765", "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "startDate": "2024-07-02", "name": "Premium Club", "description": "Premium Club subscription", "setupOrder": { "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription" }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ] } }, "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0 } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Subscription with surcharge`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/subscriptions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"subscriptionId":"SubRef7654","paymentPlanId":"PlanRef8765","paymentMethod":{"type":"secureToken","token":"296753123456"},"startDate":"2024-07-02","name":"Premium Club","description":"Premium Club subscription","setupOrder":{"orderId":"OrderRef6543","amount":4999,"description":"Initial setup fee for Premium Club subscription"},"recurringOrder":{"amount":4999,"description":"Monthly Premium Club subscription","breakdown":{"subtotal":4347,"taxes":[{"rate":5,"name":"Sales Tax","type":"rate"}]}},"endDate":"2025-07-01","length":12,"pauseCollectionFor":0}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Subscription with surcharge`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions" payload := strings.NewReader("{\n \"subscriptionId\": \"SubRef7654\",\n \"paymentPlanId\": \"PlanRef8765\",\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"startDate\": \"2024-07-02\",\n \"name\": \"Premium Club\",\n \"description\": \"Premium Club subscription\",\n \"setupOrder\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\"\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ]\n }\n },\n \"endDate\": \"2025-07-01\",\n \"length\": 12,\n \"pauseCollectionFor\": 0\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Subscription with surcharge`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"subscriptionId\": \"SubRef7654\",\n \"paymentPlanId\": \"PlanRef8765\",\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"startDate\": \"2024-07-02\",\n \"name\": \"Premium Club\",\n \"description\": \"Premium Club subscription\",\n \"setupOrder\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\"\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ]\n }\n },\n \"endDate\": \"2025-07-01\",\n \"length\": 12,\n \"pauseCollectionFor\": 0\n}" response = http.request(request) puts response.read_body ``` **`Subscription with surcharge`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"subscriptionId\": \"SubRef7654\",\n \"paymentPlanId\": \"PlanRef8765\",\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"startDate\": \"2024-07-02\",\n \"name\": \"Premium Club\",\n \"description\": \"Premium Club subscription\",\n \"setupOrder\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\"\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ]\n }\n },\n \"endDate\": \"2025-07-01\",\n \"length\": 12,\n \"pauseCollectionFor\": 0\n}") .asString(); ``` **`Subscription with surcharge`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/subscriptions', [ 'body' => '{ "subscriptionId": "SubRef7654", "paymentPlanId": "PlanRef8765", "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "startDate": "2024-07-02", "name": "Premium Club", "description": "Premium Club subscription", "setupOrder": { "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription" }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ] } }, "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Subscription with surcharge`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"subscriptionId\": \"SubRef7654\",\n \"paymentPlanId\": \"PlanRef8765\",\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"startDate\": \"2024-07-02\",\n \"name\": \"Premium Club\",\n \"description\": \"Premium Club subscription\",\n \"setupOrder\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\"\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ]\n }\n },\n \"endDate\": \"2025-07-01\",\n \"length\": 12,\n \"pauseCollectionFor\": 0\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Subscription with surcharge`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "subscriptionId": "SubRef7654", "paymentPlanId": "PlanRef8765", "paymentMethod": [ "type": "secureToken", "token": "296753123456" ], "startDate": "2024-07-02", "name": "Premium Club", "description": "Premium Club subscription", "setupOrder": [ "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription" ], "recurringOrder": [ "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": [ "subtotal": 4347, "taxes": [ [ "rate": 5, "name": "Sales Tax", "type": "rate" ] ] ] ], "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we assign the customer to the payment plan and return a response. Store the `subscriptionId`. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/subscriptions`](/api/create-subscription) ### Example response ### Response (201) ```json { "subscriptionId": "SubRef7654", "processingTerminalId": "1234001", "paymentPlan": { "paymentPlanId": "PlanRef8765", "name": "Monthly Premium Club subscription", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/payment-plans/PlanRef8765" } }, "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "name": "Premium Club", "currency": "USD", "currentState": { "status": "active", "paidInvoices": 0, "nextDueDate": "2024-08-02", "outstandingInvoices": 3 }, "startDate": "2024-07-02", "type": "automatic", "frequency": "monthly", "description": "Premium Club subscription", "setupOrder": { "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "surcharge": { "amount": 217, "percentage": 5 }, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Premium Club subscription", "breakdown": { "subtotal": 4347, "surcharge": { "amount": 217, "percentage": 5 }, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Step 4. (Optional) Manually collect a payment Our gateway can automatically collect payments, or the merchant can manually collect payments. - If the payment plan has a value of `automatic` for the `type` parameter, our gateway automatically collects payments from the customer. - If the payment plan has a value of `manual` for the `type` parameter, send a POST request to the Subscriptions endpoint to collect a payment from a customer. | Environment | URL | | --- | --- | | Test | https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/pay | | Production | https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/pay | ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/subscriptions/{subscriptionId}/pay`](/api/pay-subscription) ### Example request ### Request POST https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/pay ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "order": { "orderId": "OrderRef6543", "amount": 4999, "description": "Monthly Premium Club subscription" }, "operator": "Jane" }' ``` **`Subscription manual payment`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay" payload = { "order": { "orderId": "OrderRef6543", "amount": 4999, "description": "Monthly Premium Club subscription" }, "operator": "Jane" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Subscription manual payment`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"order":{"orderId":"OrderRef6543","amount":4999,"description":"Monthly Premium Club subscription"},"operator":"Jane"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Subscription manual payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay" payload := strings.NewReader("{\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\"\n },\n \"operator\": \"Jane\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Subscription manual payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\"\n },\n \"operator\": \"Jane\"\n}" response = http.request(request) puts response.read_body ``` **`Subscription manual payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\"\n },\n \"operator\": \"Jane\"\n}") .asString(); ``` **`Subscription manual payment`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay', [ 'body' => '{ "order": { "orderId": "OrderRef6543", "amount": 4999, "description": "Monthly Premium Club subscription" }, "operator": "Jane" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Subscription manual payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\"\n },\n \"operator\": \"Jane\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Subscription manual payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "order": [ "orderId": "OrderRef6543", "amount": 4999, "description": "Monthly Premium Club subscription" ], "operator": "Jane" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we take the payment from the customer and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/subscriptions/{subscriptionId}/pay`](/api/pay-subscription) ### Example response ### Response (201) ```json { "subscriptionId": "SubRef7654", "processingTerminalId": "1234001", "payment": { "paymentId": "M2MJOG6O2Y", "dateTime": "2024-07-02T15:30:00Z", "currency": "USD", "amount": 4999, "status": "ready", "responseCode": "A", "responseMessage": "Transaction approved", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" } }, "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "currentState": { "status": "active", "paidInvoices": 1, "nextDueDate": "2024-08-02", "outstandingInvoices": 2 }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Hosted Fields Source: https://docs.payroc.com/guides/payments/hosted-fields Add secure, gateway-hosted payment fields to your own checkout page design using Hosted Fields. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Use our Hosted Fields solution to add payment fields to your checkout page. You control the look and feel of the checkout page, but we host the fields to make them more secure. By integrating with Hosted Fields, you allow the merchant to: - Accept payments from cards and bank accounts. - Keep the design of their checkout page. - Reduce their PCI-DSS compliance requirements. ## How it works Use our Hosted Fields solution to create a form that the customer uses to enter their payment details. After the customer submits their payment details, we generate a single-use token that represents the details. ```mermaid sequenceDiagram participant M as Merchant participant GW as Gateway rect rgba(0, 81, 194, 0.4) Note over M: 1. Checkout page loads the form with Hosted Fields Note over M: 2. Customer enters and submits their payment details M->>GW: 3. Hosted Fields sends the payment details to the gateway Note over GW: 4. Gateway creates a single-use token GW-->>M: 5. Gateway returns the single-use token Note over M: 6. Use the single-use token in follow-on actions end ``` ## Your integration journey 1. **[Authenticate your session](/guides/payments/hosted-fields/authenticate-your-session)** - Create a session token to authenticate your integration each time you load Hosted Fields on a webpage. 2. **[Create a payment form](/guides/payments/hosted-fields/create-a-payment-form)** - Use our HTML and our Hosted Fields JavaScript Library to create a payment form. 3. **[Run a sale](/guides/payments/hosted-fields/run-a-sale)** - Use the single-use token to run a sale. ### Extend your integration After you integrate with Hosted Fields to run a sale, you can extend your integration with additional features, for example: - Customize your payment form. - Close a session. - Save a customer's payment details. For more information about how to add these features to your integration, go to [Extend your integration](/guides/payments/hosted-fields/extend-your-integration). # Add your own fields Source: https://docs.payroc.com/guides/payments/hosted-fields/add-your-own-fields Add your own HTML fields to Hosted Fields to capture extra customer or transaction information, such as address details for address verification. You can add your own HTML fields to capture additional information about the customer or the transaction, for example, address information for the address verification service (AVS). After you capture the customer’s address information, you can send it in the payment request. **Important:** If you add your own HTML fields, you are responsible for handling the additional information that you capture. To help you understand how to add your own fields, we have created a worked example that you can follow. In our example, we capture billing details from the customer and then use the billing details in the payment request. In our example, we complete the following actions: 1. [Add our own HTML fields.](#step-1-add-your-own-html-fields) 2. [Validate the data in the fields.](#step-2-validate-the-data-in-the-fields) 3. [Handle the response.](#step-3-handle-the-response) 4. [Retrieve the data from the fields.](#step-4-retrieve-the-data-from-the-fields) 5. [Create a payment request.](#step-5-create-payment-request) ## Step 1. Add your own HTML fields In the following code block, we created a `
` to capture the customer's billing details and an error message for each required field. ```html
*Required
*Required
*Required
*Required
*Required
``` ## Step 2. Validate the data in the fields We use the onPreSubmit function to validate the data that the customer provides in our fields. If the field is empty or if the data doesn't match the format that we specify, the JS library doesn't submit the form to our gateway. To use the onPreSubmit function in our worked example, we complete the following actions: **Step 2a.** Add the onPreSubmit function. **Step 2b.** Define the onPreSubmit function. ### Step 2a. Add the onPreSubmit function To delay the submission of the form until we validate the data the customer provides, we add the onPreSubmit function. In the following code block, we add the onPreSubmit function. ```js this.form = new Payroc.hostedFields({ sessionToken: sessionRequest['token'], mode: scenario, fields: fields, // Add the onPreSubmit function to validate the data in the fields before the JS Library sends the request to our gateway. onPreSubmit: () => this.validateCustomerDetails(), }); ``` ### Step 2b. Define the onPreSubmit function We define the onPreSubmit function to specify the format and rules for the values that the customer must enter into the fields. If the field is missing a value, we call a [displayMissingFieldsError](#displaymissingfieldserror-function) function to display the error. In the following code block, we check if the customer provides a value for each field. ```js async validateCustomerDetails() { // Check if the .billing-details is present, and returns false if there are no values in any of the fields. const customerDetails = document.querySelector(".billing-details"); if (!customerDetails) return false; let validation = true; // Retrieve all values from inside the .billing-details div const requiredFields = customerDetails.querySelectorAll("input[required]"); for (const field of requiredFields) { // Check that the customer has provided a value for each field and that the value is in the correct format. if (!field.value.trim()) { // Call a function to display any errors. displayMissingFieldsError(field.id); validation = false; } } // If the values are present and in the correct format, the JS Library sends the request to our gateway. return validation; } ``` #### displayMissingFieldsError function If the customer doesn't enter a value in a field, the displayMissingFieldsError function displays an error for five seconds. ```js function displayMissingFieldsError(id) { const input = document.getElementById(id); // Locate the element that contains the error. const errorMessage = document.getElementById(id + "-error"); input.classList.add('invalid'); errorMessage.style.visibility = 'visible'; // Show the error message. setTimeout(() => { input.classList.remove('invalid'); errorMessage.style.visibility = 'hidden'; // Hide the error message after five seconds. }, 5000); // 5000 ms = 5 seconds } ``` ## Step 3. Handle the response If the onPreSubmit function validates the values that the customer provides the JS library sends the request to our gateway, which returns a single-use token in the response. In the following code block, we handle the response and close the Hosted Fields session. ```js this.form.on("submissionSuccess", async ({ token, expiresAt }) => { // Get the customer object using the data that the customer provided. const customer = this._getCustomerObject(); // Forward all the required data to the server to create a payment request. const response = scenario === "payment" ? await yourServer.createPayment(customer, token) : await yourServer.createSecureToken(customer, token); // Close the Hosted Fields session and display a response. document.querySelector('.billing-details').style.display = "none"; document.querySelector(".pyrc-hosted-fields").style.display = "none"; this._renderJSONResponse(response); }); ``` ## Step 4. Retrieve the data from the fields After we sent the request and received the single-use token, we use the information from the form to create a payment request. In the following code block, we retrieve the billing details that the customer provides and organize them into a billingAddress object. ```js // Retrieve the data from the fields and organize them into a billingDetails object within a customer object. _getCustomerObject() { let data = {}; const billingAddress = this._getCustomFieldValues(); if (Object.keys(billingAddress).length > 0) data['billingAddress'] = billingAddress; return data; } _getCustomFieldValues() { const fields = document.querySelectorAll(".billing-details input, .billing-details select"); const values = {}; fields.forEach(field => { const value = field.value; if (value) values[field.id] = value.trim(); }); return values; } ``` ## Step 5. Create payment request We add the information that we received from the customer and the single-use token to a [payment request](/api/payment), and then send the payment request to our gateway. For more information about how to create a payment request, go to [Run a card sale](/guides/payments/run-a-card-sale). In the following code block, we create a payment request using the billing details that the customer provides and the single-use token that we receive from the gateway. ```js { "channel": "web", "processingTerminalId": "{TerminalID}", "order": { "orderId": "{OrderId}", "amount": 4999, "currency": "USD" }, "customer": { "firstName": "Joe", "lastName": "Bloggs", "billingAddress": data['billingAddress'] }, "paymentMethod": { "secCode": "web", "token": "{single use token}", "type": "singleUseToken" } } ``` # Close a Hosted Fields session Source: https://docs.payroc.com/guides/payments/hosted-fields/close-session Call the destroy method in your JavaScript to close an idle Hosted Fields session before starting a new one. **Important:** To call the destroy method, you must be using one of the following versions of our Hosted Fields JavaScript library: - **Test** - 1.7.0.261457 - **Production** - 1.7.0.261471 To close an idle session of Hosted Fields, call the destroy method in your JavaScript. ```js const hostedFields = new Payroc.hostedFields(options); hostedFields.destroy(); ``` After calling the destroy method, you must start a new Hosted Fields session before you can take payment from the customer. For more information about how to generate a session token, go to [Authenticate your Hosted Fields session](/guides/payments/hosted-fields/authenticate-your-session). **Note:** You don't need to use this method for every integration, but it is considered good practice in scenarios where Hosted Fields might run on more than one session, for example, in single-page applications. ## What does the destroy method do? - Removes our event listener associated with the session, so that we don't receive messages from more than one session. - Prevents further communication between the Hosted Fields JavaScript library and your Hosted Fields. - Helps to avoid memory leaks and duplicate event handling. # Authenticate your session Source: https://docs.payroc.com/guides/payments/hosted-fields/authenticate-your-session Generate a session token for Hosted Fields by sending a POST request to the Processing Terminals hosted-fields-sessions endpoint using a Bearer token. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). To authenticate your access to the Payroc gateway, include a session token every time you run the Hosted Fields script on a webpage. ## Before you begin - Make sure you have your API key for both the test environment and the production environment. - Make sure that your integration can handle errors. If a request is unsuccessful, we return an error that follows the [RFC 7807 format](https://datatracker.ietf.org/doc/html/rfc7807). For more information about errors, go to [Errors](/api/errors). ## Integration steps **Step 1.** Generate a Bearer token. **Step 2.** Generate a session token from the Bearer token. ## Step 1. Generate a Bearer token [Authenticate your requests](/api/authentication) to generate a Bearer token. ## Step 2. Generate a session token from the Bearer token You must use our Hosted Fields Sessions endpoint to generate a new session token each time you initialize Hosted Fields. A session token expires after 10 minutes. When you generate a session token, you need to specify the version of the Hosted Fields JavaScript library that you are using. Include the version number in the libVersion parameter in the body of your request. | Environment | Version | | --- | --- | | Test | 1.7.0.261457 | | Production | 1.7.0.261471 | ### Request To generate a session token, send a POST request to our Processing Terminals endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId\}/hosted-fields-sessions](https://api.uat.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/hosted-fields-sessions) | | Production | [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/hosted-fields-sessions](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/hosted-fields-sessions) | Include the following headers in your request: - **Content-Type:** Include `application/json` as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. - **Idempotency-Key:** Include a UUID v4 to make the request idempotent. To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/hosted-fields-sessions`](/api/create-session) ### Example request ### Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/hosted-fields-sessions](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/hosted-fields-sessions) **`Create session`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "libVersion": "1.1.0.123456", "scenario": "payment" }' ``` **`Create session`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions" payload = { "libVersion": "1.1.0.123456", "scenario": "payment" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create session`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"libVersion":"1.1.0.123456","scenario":"payment"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create session`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions" payload := strings.NewReader("{\n \"libVersion\": \"1.1.0.123456\",\n \"scenario\": \"payment\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create session`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"libVersion\": \"1.1.0.123456\",\n \"scenario\": \"payment\"\n}" response = http.request(request) puts response.read_body ``` **`Create session`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"libVersion\": \"1.1.0.123456\",\n \"scenario\": \"payment\"\n}") .asString(); ``` **`Create session`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions', [ 'body' => '{ "libVersion": "1.1.0.123456", "scenario": "payment" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create session`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"libVersion\": \"1.1.0.123456\",\n \"scenario\": \"payment\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create session`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "libVersion": "1.1.0.123456", "scenario": "payment" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway generates a session token. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/hosted-fields-sessions`](/api/create-session) ### Example response ### Response (201) ```json { "processingTerminalId": "1234001", "token": "abcdef1234567890abcdef1234567890", "expiresAt": "2025-07-02T15:30:00.123456789+02:00" } ``` # Create a payment form Source: https://docs.payroc.com/guides/payments/hosted-fields/create-a-payment-form Build a card, ACH, or PAD payment form by adding HTML fields and configuring the Hosted Fields JavaScript library with your session token. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). To create a payment form with Hosted Fields you need to add HTML for the fields, and then add and configure our JavaScript library. We provide HTML and JavaScript libraries for the following payment types: - Card - ACH - PAD You also need to add event listeners so that you can receive responses when a customer submits their payment details or if an error occurs. When a customer uses the payment form to submit their payment details, we return a single-use token that you need to run a sale. ## Before you begin Make sure that your integration can [create a session token](/guides/payments/hosted-fields/authenticate-your-session) each time you initialize Hosted Fields. ## Integration steps **Step 1**. Add HTML for each payment type. **Step 2**. Add and configure JavaScript. **Step 3**. Add event listeners. ## Step 1. Add HTML for each payment type. **Important:** Each webpage can support only one payment type. To accept a different payment type, you need to create another webpage. - Add the HTML for one of the payment types. **`Card`** ```html
``` **`ACH`** ```html
``` **`PAD`** ```html
``` **Note:** For the card HTML, we added the `col` and `col-2` custom CSS attributes to create the structure for the example form. ## Step 2. Add and configure the JavaScript library The JavaScript library controls the behavior of the fields and provides a fully functional submit button that the customer can use to submit their payment details. We provide you with different JavaScript library configurations for different payment types. To add and configure JavaScript for Hosted Fields, complete the following steps: - **Step 2a.** Insert the JavaScript library into your webpage. - **Step 2b.** Configure the JavaScript library. ### Step 2a. Insert the JavaScript library into your webpage Add the JavaScript library for your payment type to your webpage and ensure that the ` ``` **`ACH`** ```js ``` **`PAD`** ```js ``` ### Step 2b. Configure the JavaScript library 1. In the sessionToken field, include your session token. 2. To test your integration in our test environment or run transactions in our production environment, use one of the following JavaScript configurations: \ \ \ \ Environment \ \ Parameter \ \ Value \ \ \ \ \ \ Test \ \ src \ \ [https://cdn.uat.payroc.com/js/hosted-fields/hosted-fields-1.7.0.261457.js](https://cdn.uat.payroc.com/js/hosted-fields/hosted-fields-1.7.0.261457.js) \ \ \ \ integrity \ \ sha384-m1A0nfFYa8sAfpDN0d60o4ztd/aCPC2xDVaOT31Urrmn4xypfHqgHQMayZeIK1PM \ \ \ \ Production \ \ src \ \ [https://cdn.payroc.com/js/hosted-fields/hosted-fields-1.7.0.261471.js](https://cdn.payroc.com/js/hosted-fields/hosted-fields-1.7.0.261471.js) \ \ \ \ integrity \ \ sha384-4KD8EaeEaCR2jLV6vnBwfEAEy/o2bR0GkODVpr8iePLTK5eOOmjoPuDVKJ0wM1oP \ \ \ \ **Note:** Make sure that the version number in the src parameter matches the version number that you used to [create the session token](/guides/payments/hosted-fields/authenticate-your-session#step-2-generate-a-session-token-from-the-bearer-token). ## Step 3. Add event listeners To receive and handle responses from the payment form, you need to add event listeners to subscribe to the following events: - **submissionSuccess** - Triggers when a customer successfully submits their payment details. - **error** - Triggers when an error occurs with the payment form. ### submissionSuccess When the customer successfully submits their payment details, our gateway tokenizes them and returns a single-use token in a submissionSuccess event. The response also includes the expiry time of the single-use token. **Important:** Each webpage can support only one payment type. To accept a different payment type, you need to create another webpage. To subscribe to the submissionSuccess event, add an event listener to the payment form. For example: ```js cardForm.on("submissionSuccess", ({ token, expiresAt }) => { }); ``` When the submissionSuccess event triggers, we return the following fields: | Field | Description | | --- | --- | | token | Single-use token that represents the customer's payment details. | | expiresAt | Expiry date and time of the single-use token. | #### Example response ```js { "token": "c96cb928e39c34bd05022cd821d2cbba2349f047ce0cef4f77cd2b5762be7608fb7c23e673bf014d58c64672928eb8256e38aa26911a22853143d22dd48ac9aa", "expiresAt": "2024-05-18T23:17:34.844Z" } ``` ### error To help you identify and fix any errors that you might encounter when using Hosted Fields, subscribe to our error event. To subscribe to the error event, add an event listener to the form. For example: ```js cardForm.on("error", ({ type, field, message }) => { }); ``` When the error event triggers, we return the following fields: | Field | Description | | --- | --- | | type | Type of error. The value is one of the following: • `config` - Error with the config object. • `init` - Error occurred when we tried to initialize the JavaScript Library. • `field` - Error occurred when we tried to embed a field. • `submission` - Error with the cardholder’s submission. | | field | Field that has caused the error. If the error didn’t occur with a field, we return a value of `undefined`. | | message | Details about the error. | #### Example response ```js { "type": "field", "field": "cardNumber", "message": "The maximum number of retries to embed this field has been reached." } ``` The following lists include the messages that we return for each type of error: #### Error messages ## `config` errors - "The mode should be either 'payment' or 'tokenization'." - "The gateway origin is not defined." - "The api origin is not defined." - "A valid config is required to use hosted fields." - "An authentication token is required to use hosted fields." - "Secure token must be a string." - "Authentication token must be a string." - "You have passed a secure token or are in tokenization mode but the terminal is not setup to allow secure tokens." - "The mode must be set to 'tokenization' to use secure tokens." - "A processing terminal ID is required to use hosted fields." - "Processing terminal ID must be a number." - "The css value in your config must be supported by the property." - "The css key in your config must be an object as per the documentation." - "Card, ACH or PAD fields are required for hosted fields." - "Only one of Card, ACH or PAD fields should be supplied for hosted fields." - "A card number field is required for card forms." - "A card holder name field is required for card forms." - "A card expiry field is required for card forms." - "A card CVV field is required for card forms." - "A card issue number field is required for card forms." - "A submit button is required for payment forms." - "An account holder field is required for PAD and ACH forms." - "An account number field is required for PAD forms." - "An institution number field is required for PAD forms." - "A transit number field is required for PAD forms." - "An account number field is required for ACH forms." - "A routing number field is required for ACH forms." - "An account type field is required for ACH forms." - "An SEC code field is required for ACH forms." - "The target selector supplied for card number either occurs more than once or does not exist on the page." - "The target selector supplied for card issue number either occurs more than once or does not exist on the page." - "The target selector supplied for card issue number wrapper either occurs more than once or does not exist on the page." - "The target selector supplied for CVV wrapper either occurs more than once or does not exist on the page." - "The target selector supplied for card issue number error either occurs more than once or does not exist on the page." - "Card issue number wrapper is required for card forms. If you do not have a wrapper, please provide false." - "CVV wrapper is required for card forms. If you do not have a wrapper, please provide false." - "The target selector supplied for cardholder name either occurs more than once or does not exist on the page." - "The target selector supplied for card expiry either occurs more than once or does not exist on the page." - "The target selector supplied for card CVV either occurs more than once or does not exist on the page." - "The target selector supplied for submit button either occurs more than once or does not exist on the page." - "The target selector supplied for account holder either occurs more than once or does not exist on the page." - "The target selector supplied for account number either occurs more than once or does not exist on the page." - "The target selector supplied for institution number either occurs more than once or does not exist on the page." - "The target selector supplied for transit number either occurs more than once or does not exist on the page." - "The target selector supplied for account holder either occurs more than once or does not exist on the page." - "The target selector supplied for account number either occurs more than once or does not exist on the page." - "The target selector supplied for routing number either occurs more than once or does not exist on the page." - "The target selector supplied for account type either occurs more than once or does not exist on the page." - "The target selector supplied for SEC code either occurs more than once or does not exist on the page." - "The error container target selector supplied for card number either occurs more than once or does not exist on the page." - "The error container target selector supplied for cardholder name either occurs more than once or does not exist on the page." - "The error container target selector supplied for card expiry either occurs more than once or does not exist on the page." - "The error container target selector supplied for card CVV either occurs more than once or does not exist on the page." - "The error container target selector supplied for submit button either occurs more than once or does not exist on the page." - "The error container target selector supplied for account holder either occurs more than once or does not exist on the page." - "The error container target selector supplied for account number either occurs more than once or does not exist on the page." - "The error container target selector supplied for institution number either occurs more than once or does not exist on the page." - "The error container target selector supplied for transit number either occurs more than once or does not exist on the page." - "The error container target selector supplied for account holder either occurs more than once or does not exist on the page." - "The error container target selector supplied for account number either occurs more than once or does not exist on the page." - "The error container target selector supplied for routing number either occurs more than once or does not exist on the page." - "The error container target selector supplied for account type either occurs more than once or does not exist on the page." - "The error container target selector supplied for SEC code either occurs more than once or does not exist on the page." ## `init` errors - "A session token is required to use hosted fields and was not received." - "The request is unauthorised, please check your credentials." - "The maximum number of retries to authenticate has been reached, please check your credentials." - "Session request response is invalid." - "You have passed ACH fields but the terminal is not setup to allow ACH." - "You have passed PAD fields but the terminal is not setup to allow PAD." - "You have passed PAD or ACH fields but the terminal is not setup to allow bank transfers." - "The terminal does not support the capability you are trying to use." ## `field` errors - "field must be provided in URL query parameters" - "token must be provided in URL query parameters" - "auth token must be provided in URL query parameters" - "targetOrigin must be provided in URL query parameters" - "Could not find input element on page" - "Could not find radio buttons for ACH account type" - "Could not find button element on page" - "The maximum number of retries to embed this field has been reached." - "The maximum number of retries to submit this field has been reached." ## `submission` errors - "Invalid response from the payment gateway when submitting details" - "Max number of retries has been reached" # Extend your integration Source: https://docs.payroc.com/guides/payments/hosted-fields/extend-your-integration Extend your Hosted Fields integration by styling fields, adding custom fields, closing sessions, and saving payment details. After you set up Hosted Fields to run a sale, you can extend your integration to include the following: - [**Style your fields**](/guides/payments/hosted-fields/styling-hosted-fields) - Change the look and feel of the fields to match your branding, for example, you can update the font and color of the text. - [**Add your own fields**](/guides/payments/hosted-fields/add-your-own-fields) - Validate and capture other information, for example, a customer's email address. - [**Close a session**](/guides/payments/hosted-fields/close-session) - Close an idle session of Hosted Fields if the customer navigates away from the checkout page. - [**Save a customer's payment details**](/guides/payments/hosted-fields/save-payment-details-overview) - Save a customer's payment details as a secure token that you can use for multiple sales. - [**Update a customer's saved payment details**](/guides/payments/hosted-fields/update-payment-details) - Update a customer's payment details associated with a secure token. You can run follow-on actions with our API, for example, to view a payment or to void a payment. ## Guides To extend your Hosted Fields integration, follow our guides: #### [Style your fields](/guides/payments/hosted-fields/styling-hosted-fields) #### [Add your own fields](/guides/payments/hosted-fields/add-your-own-fields) #### [Close a session](/guides/payments/hosted-fields/close-session) #### [Save a customer's payment details](/guides/payments/hosted-fields/save-payment-details-overview) #### [Update a customer's payment details](/guides/payments/hosted-fields/update-payment-details) # Repeat payments With Hosted Fields Source: https://docs.payroc.com/guides/payments/hosted-fields/repeat-payments-with-hosted-fields Set up repeat payments by charging a customer's stored payment token after saving their details with Hosted Fields. **Prerequisites:** [Authentication](/api/authentication) · [Save a customer's payment details](/guides/payments/hosted-fields/save-payment-details-overview) **Important:** Before you continue, make sure you have set up your Hosted Fields integration to save a customer's payment details. For more information, go to [Save a customer's payment details](/guides/payments/hosted-fields/save-payment-details-overview). After you have set up your integration to store customer payment details with a secure token, you can use the secure token to set up repeat payments. Repeat payments are payments that a merchant agrees to take from a customer on a regular schedule, for example, monthly installments for a large purchase. To extend your integration to include repeat payments, go to our [Repeat Payments](/knowledge/payments/repeat-payments) guides. --- # Save payment details when running a sale Source: https://docs.payroc.com/guides/payments/hosted-fields/run-a-sale-tokenize Save card or bank account payment details when running a sale by sending a POST request to the Payments or Bank Transfer Payments endpoint with a credentialOnFile object. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/hosted-fields/run-a-sale) ## Save payment details when running a sale You can use the single-use token from your existing Hosted Fields integration to save a customer's payment details at the same time that you run a sale. If you save a customer's payment details during a sale, our gateway uses the single-use token from Hosted Fields to charge the customer, and then saves the customer's payment details as a secure token. You can use the secure token multiple times, and it doesn't expire. To tokenize payment details during a sale, you need to send some additional parameters in your request to our API. You don't need to change the JavaScript configuration or authentication for your existing Hosted Fields integration. ## Before you begin Make sure that you've set up your Hosted Fields integration to run a sale with the single-use token from the submissionSuccess event. For more information, go to [Run a sale](/guides/payments/hosted-fields/run-a-sale). [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Integration steps The steps that you need to follow depend on whether your single-use token represents card details or bank account details: - If the single-use token represents card details, go to [Save card details when you run a sale](#save-card-details-when-you-run-a-sale). - If the single-use token represents bank account details, go to [Save bank account details when you run a sale](#save-bank-account-details-when-you-run-a-sale). ## Save card details when you run a sale To run a sale and tokenize the card details, you need to update your POST request to our Payments endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/payments](https://api.uat.payroc.com/v1/payments) | | Production | [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) | ### Request parameters **Important:** The request includes parameters for functions and features that we don't cover in this guide. These functions and features might require additional integration effort and cost. For more information, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). To save a customer's card details when you run a sale, update your request to our Payments endpoint. Send the single-use token from Hosted Fields in the `paymentMethod` object, and include the following parameters in the `credentialOnFile` object: - `tokenize` - Send a value of `true`. - `secureTokenId` - Assign a unique identifier to the secure token. **Note:** If you want to use the stored payment details to run repeat payments with your own software, include the `standingInstructions` object in your request. For more information about repeat payments with Hosted Fields, go to [Repeat payments with Hosted Fields](/guides/payments/hosted-fields/repeat-payments-with-hosted-fields). ### Schema (`request.body`) [Request body schema for `POST /payments`](/api/payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **`Card sale with single-use token that we convert to a secure token`** ```curl curl -X POST https://api.payroc.com/v1/payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "credentialOnFile": { "tokenize": true, "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Card sale with single-use token that we convert to a secure token`** ```python import requests url = "https://api.payroc.com/v1/payments" payload = { "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "credentialOnFile": { "tokenize": True, "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Card sale with single-use token that we convert to a secure token`** ```javascript const url = 'https://api.payroc.com/v1/payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"channel":"web","processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","amount":4999,"currency":"USD","description":"Large Pepperoni Pizza"},"paymentMethod":{"type":"singleUseToken","token":"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"},"operator":"Jane","customer":{"firstName":"Sarah","lastName":"Hopper","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}}},"credentialOnFile":{"tokenize":true,"secureTokenId":"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Card sale with single-use token that we convert to a secure token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments" payload := strings.NewReader("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"tokenize\": true,\n \"secureTokenId\": \"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Card sale with single-use token that we convert to a secure token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"tokenize\": true,\n \"secureTokenId\": \"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Card sale with single-use token that we convert to a secure token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"tokenize\": true,\n \"secureTokenId\": \"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Card sale with single-use token that we convert to a secure token`** ```php request('POST', 'https://api.payroc.com/v1/payments', [ 'body' => '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "credentialOnFile": { "tokenize": true, "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Card sale with single-use token that we convert to a secure token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"tokenize\": true,\n \"secureTokenId\": \"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Card sale with single-use token that we convert to a secure token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "channel": "web", "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" ], "paymentMethod": [ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" ], "operator": "Jane", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ] ], "credentialOnFile": [ "tokenize": true, "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway runs the sale and converts the single-use token into a secure token that we return in the response. You need to store the token so that you can use it in follow-up requests. The response also contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments`](/api/payment) ### Example response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "cardholderName": "Sarah Hopper", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3", "cardSchemeReferenceId": "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Save bank account details when you run a sale To run a sale and tokenize the bank account details, you need to update your POST request to our Bank Transfer Payments endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/bank-transfer-payments](https://api.uat.payroc.com/v1/bank-transfer-payments) | | Production | [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) | ### Request parameters **Important:** The request includes parameters for functions and features that we don't cover in this guide. These functions and features might require additional integration effort and cost. For more information, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). To save a customer's bank account details when you run a sale, update your request to our Bank Transfer Payments endpoint. Send the single-use token from Hosted Fields in the `paymentMethod` object, and include the following parameters in the `credentialOnFile` object: - `tokenize` - Send a value of `true`. - `secureTokenId` - Assign a unique identifier to the secure token. ### Schema (`request.body`) [Request body schema for `POST /bank-transfer-payments`](/api/bank-transfer-payment) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) **`Bank transfer sale with single-use token that we convert to a secure token`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "credentialOnFile": { "tokenize": true, "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Bank transfer sale with single-use token that we convert to a secure token`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments" payload = { "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "credentialOnFile": { "tokenize": True, "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Bank transfer sale with single-use token that we convert to a secure token`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","order":{"amount":4999,"currency":"USD","orderId":"OrderRef6543","description":"Large Pepperoni Pizza"},"paymentMethod":{"type":"singleUseToken","token":"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890","accountType":"checking","secCode":"web"},"customer":{"notificationLanguage":"en","contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}]},"credentialOnFile":{"tokenize":true,"secureTokenId":"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Bank transfer sale with single-use token that we convert to a secure token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true,\n \"secureTokenId\": \"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Bank transfer sale with single-use token that we convert to a secure token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true,\n \"secureTokenId\": \"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Bank transfer sale with single-use token that we convert to a secure token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true,\n \"secureTokenId\": \"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Bank transfer sale with single-use token that we convert to a secure token`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-payments', [ 'body' => '{ "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "credentialOnFile": { "tokenize": true, "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Bank transfer sale with single-use token that we convert to a secure token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true,\n \"secureTokenId\": \"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Bank transfer sale with single-use token that we convert to a secure token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "order": [ "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "description": "Large Pepperoni Pizza" ], "paymentMethod": [ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", "accountType": "checking", "secCode": "web" ], "customer": [ "notificationLanguage": "en", "contactMethods": [ [ "type": "email", "value": "sarah.hopper@example.com" ] ] ], "credentialOnFile": [ "tokenize": true, "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway runs the sale and converts the single-use token into a secure token that we return in the response. You need to store the token so that you can use it in follow-up requests. The response also contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-payments`](/api/bank-transfer-payment) ### Example response ### Response (201) ```json { "paymentId": "E29U8OU8Q4", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "ach", "accountNumber": "****1591", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "063100277", "secCode": "web", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } } }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "NoError", "processorResponseCode": "0" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Using the secure token After you receive the secure token that represents the customer's payment details, you can use it in follow-up requests to our API, including: - [Create a card payment](/guides/payments/run-a-card-sale) - [Create a bank transfer payment](/guides/payments/run-sale-using-bank-details) - [Update a customer's payment details with Hosted Fields](/guides/payments/hosted-fields/update-payment-details) **Note:** You can also use the secure token to set up repeat payments with our gateway, which requires more integration effort and cost. For more information, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). --- # Run a sale Source: https://docs.payroc.com/guides/payments/hosted-fields/run-a-sale Run a card or bank account sale using a Hosted Fields single-use token by sending a POST request to the Payments or Bank Transfer Payments endpoint. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). After a customer enters their payment details into Hosted Fields, we tokenize them and return a single-use token. To run a sale, use the single-use token with our API. The API method that you need to use depends on the payment type that the single-use token represents, for example, card details or bank account details. ## Before you begin ### Single-use token Make sure that your integration can handle submissionSuccess events to receive a single-use token when a customer submits their payment details. [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Integration steps The method that you need to use to run the sale depends on the customer's payment type: - If the single-use token represents card details, go to [Run a sale with card details](#run-a-sale-with-card-details). - If the single-use token represents ACH or PAD details, go to [Run a sale with bank account details](#run-a-sale-with-bank-account-details). ## Run a sale with card details To run a sale with card details, send a POST request to our Payments endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/payments](https://api.uat.payroc.com/v1/payments) | | Production | [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) | ### Request parameters **Important:** The request includes parameters for functions and features that we don't cover in this guide. These functions and features might require additional integration effort and cost. For more information, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). For the paymentMethod object, send values for the following parameters: - **type:** Send a value of `singleUseToken`. - **token:** Send the single-use token that you received in the submissionSuccess event. ### Schema (`request.body`) [Request body schema for `POST /payments`](/api/payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **`Card Payment`** ```curl curl -X POST https://api.payroc.com/v1/payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Card Payment`** ```python import requests url = "https://api.payroc.com/v1/payments" payload = { "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Card Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"channel":"web","processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","amount":4999,"currency":"USD","description":"Large Pepperoni Pizza"},"paymentMethod":{"type":"card","cardDetails":{"entryMethod":"keyed","keyedData":{"dataFormat":"plainText","cardNumber":"4539858876047062","device":{"model":"paxA80","serialNumber":"WPC202833004712"},"expiryDate":"1230"}}},"operator":"Jane","customer":{"firstName":"Sarah","lastName":"Hopper","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}}},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Card Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments" payload := strings.NewReader("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Card Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Card Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Card Payment`** ```php request('POST', 'https://api.payroc.com/v1/payments', [ 'body' => '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Card Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Card Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "channel": "web", "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" ], "paymentMethod": [ "type": "card", "cardDetails": [ "entryMethod": "keyed", "keyedData": [ "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": [ "model": "paxA80", "serialNumber": "WPC202833004712" ], "expiryDate": "1230" ] ] ], "operator": "Jane", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ] ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway uses the card details to run a sale. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments`](/api/payment) ### Example response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Run a sale with bank account details To run a sale with bank account details, send a POST request to our Bank Transfer Payments endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/bank-transfer-payments](https://api.uat.payroc.com/v1/bank-transfer-payments) | | Production | [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) | ### Request parameters **Important:** The request includes parameters for functions and features that we don't cover in this guide. These functions and features might require additional integration effort and cost. For more information, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). For the paymentMethod object, send values for the following parameters: - **type:** Send a value of `singleUseToken`. - **token:** Send the single-use token that you received in the submissionSuccess event. - **accountType:** Indicate if the bank account is a savings account or a checking account. - **secCode:** If the single-use token represents ACH details, indicate how the customer authorized the payment. ### Schema (`request.body`) [Request body schema for `POST /bank-transfer-payments`](/api/bank-transfer-payment) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) **`Store Token Bank Transfer Payment`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ], "tip": { "type": "percentage", "percentage": 10 } }, "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "joe@blogssoftware.com" } ] }, "credentialOnFile": { "tokenize": true }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Store Token Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments" payload = { "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ], "tip": { "type": "percentage", "percentage": 10 } }, "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "joe@blogssoftware.com" } ] }, "credentialOnFile": { "tokenize": True }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Store Token Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","order":{"amount":4999,"currency":"USD","orderId":"OrderRef6543","breakdown":{"subtotal":4347,"taxes":[{"rate":5,"name":"Sales Tax","type":"rate"}],"tip":{"type":"percentage","percentage":10}},"description":"Large Pepperoni Pizza"},"paymentMethod":{"type":"ach","accountNumber":"11101010","nameOnAccount":"Sarah Hazel Hopper","routingNumber":"053200983","accountType":"checking","secCode":"web"},"customer":{"notificationLanguage":"en","contactMethods":[{"type":"email","value":"joe@blogssoftware.com"}]},"credentialOnFile":{"tokenize":true},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Store Token Bank Transfer Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ],\n \"tip\": {\n \"type\": \"percentage\",\n \"percentage\": 10\n }\n },\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@blogssoftware.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Store Token Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ],\n \"tip\": {\n \"type\": \"percentage\",\n \"percentage\": 10\n }\n },\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@blogssoftware.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Store Token Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ],\n \"tip\": {\n \"type\": \"percentage\",\n \"percentage\": 10\n }\n },\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@blogssoftware.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Store Token Bank Transfer Payment`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-payments', [ 'body' => '{ "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ], "tip": { "type": "percentage", "percentage": 10 } }, "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "joe@blogssoftware.com" } ] }, "credentialOnFile": { "tokenize": true }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Store Token Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ],\n \"tip\": {\n \"type\": \"percentage\",\n \"percentage\": 10\n }\n },\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@blogssoftware.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Store Token Bank Transfer Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "order": [ "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": [ "subtotal": 4347, "taxes": [ [ "rate": 5, "name": "Sales Tax", "type": "rate" ] ], "tip": [ "type": "percentage", "percentage": 10 ] ], "description": "Large Pepperoni Pizza" ], "paymentMethod": [ "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "web" ], "customer": [ "notificationLanguage": "en", "contactMethods": [ [ "type": "email", "value": "joe@blogssoftware.com" ] ] ], "credentialOnFile": ["tokenize": true], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway uses the bank account details to run a sale. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-payments`](/api/bank-transfer-payment) ### Example response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "ach", "accountNumber": "****3159", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "secCode": "web", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } } }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "NoError", "processorResponseCode": "0" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Save a customer's payment details Source: https://docs.payroc.com/guides/payments/hosted-fields/save-payment-details-overview Convert a single-use payment token into a reusable secure token to save a customer's payment details for a future or repeat payment. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/hosted-fields/run-a-sale) **Important:** Make sure that you have set up your Hosted Fields integration to run a sale. For more information, go to [Run a sale](/guides/payments/hosted-fields/run-a-sale). When you use Hosted Fields to capture a customer's payment details, we return a single-use token that represents the payment details. You can use the single-use token only once, and it expires 30 minutes after we return it. If you want to save the customer's payment details for a future payment or repeat payments, you need to convert the single-use token into a secure token. You can use the secure token more than once, and it doesn't expire. You can use the secure token as the payment method in follow-up transactions, for example: - **Faster checkout** - Link the secure token with the customer's profile on your merchant's website, so the customer doesn't need to reenter their payment details for a future payment. - **Repeat payments** - Set up recurring payments so that a merchant can take payments from a customer on a regular schedule. ## Using the secure token After you receive the secure token that represents the customer's payment details, you can use it in follow-up requests to our API, including: - [Create a card payment](/guides/payments/run-a-card-sale) - [Create a bank transfer payment](/guides/payments/run-sale-using-bank-details) - [Update a customer's payment details with Hosted Fields](/guides/payments/hosted-fields/update-payment-details) **Note:** You can also use the secure token to set up repeat payments with our gateway, which requires more integration effort and cost. For more information, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Use Hosted Fields to save a customer's payment details To extend your integration to save a customer's payment details, go to one of the following guides: - [**Save payment details when running a sale**](/guides/payments/hosted-fields/run-a-sale-tokenize) - Take payment from the customer and store their payment details in the same transaction. - [**Save payment details without running a sale**](/guides/payments/hosted-fields/save-payment-details) - Store a customer's payment details without charging the customer. --- # Save a customer's payment details Source: https://docs.payroc.com/guides/payments/hosted-fields/save-payment-details Convert a Hosted Fields single-use token into a reusable secure token by sending a POST request to the Secure Tokens endpoint, enabling future card and bank account payments without recapturing payment details. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). You can update your Hosted Fields integration to save a customer's payment details as a secure token without charging the customer. To tokenize the customer's payment details, you need to update the Hosted Fields JavaScript configuration, and then send a request to our Secure Tokens endpoint. You don't need to change your authentication process for your existing Hosted Fields integration. ## Before you begin Make sure that you've set up your Hosted Fields integration to handle the single-use token from the submissionSuccess event. For more information, go to [Run a sale](/guides/payments/hosted-fields/run-a-sale). [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Integration steps 1. Update the JavaScript configuration. 2. Convert the single-use token into a secure token. ## Step 1. Update the JavaScript configuration - In the JavaScript configuration, change the value for the mode parameter from payment to `tokenization`. **`Card`** ```js ``` **`ACH`** ```js ``` **`PAD`** ```js ``` ## Step 2. Convert the single-use token into a secure token To convert the single-use token into a secure token, send a POST request to our Secure Tokens endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.uat.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) | | Production | [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) | ### Request parameters In the body of your request, include the singleUseToken from the submissionSuccess event in the source object. We also recommend that you assign a secureTokenId. ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens`](/api/create-secure-token) ### Example request ### Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) **`Secure token created from a single-use token`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "source": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2" }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Secure token created from a single-use token`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" payload = { "source": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2" }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Secure token created from a single-use token`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"source":{"type":"singleUseToken","token":"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"},"operator":"Jane","mitAgreement":"unscheduled","customer":{"firstName":"Sarah","lastName":"Hopper","dateOfBirth":"1990-07-15","referenceNumber":"Customer-12","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2"},"contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}],"notificationLanguage":"en"},"ipAddress":{"type":"ipv4","value":"104.18.24.203"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Secure token created from a single-use token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" payload := strings.NewReader("{\n \"source\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Secure token created from a single-use token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"source\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Secure token created from a single-use token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"source\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Secure token created from a single-use token`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens', [ 'body' => '{ "source": { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2" }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Secure token created from a single-use token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"source\": {\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Secure token created from a single-use token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "source": [ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" ], "operator": "Jane", "mitAgreement": "unscheduled", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2" ], "contactMethods": [ [ "type": "email", "value": "sarah.hopper@example.com" ] ], "notificationLanguage": "en" ], "ipAddress": [ "type": "ipv4", "value": "104.18.24.203" ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway converts the single-use token into a secure token. Our gateway returns the secure token in the token field. The response also contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens`](/api/create-secure-token) ### Response example ### Response (201) ```json { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Hazel Hopper", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Using the secure token After you receive the secure token that represents the customer's payment details, you can use it in follow-up requests to our API, including: - [Create a card payment](/guides/payments/run-a-card-sale) - [Create a bank transfer payment](/guides/payments/run-sale-using-bank-details) - [Update a customer's payment details with Hosted Fields](/guides/payments/hosted-fields/update-payment-details) **Note:** You can also use the secure token to set up repeat payments with our gateway, which requires more integration effort and cost. For more information, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). # Styling your Hosted Fields Source: https://docs.payroc.com/guides/payments/hosted-fields/styling-hosted-fields Customize the look of your Hosted Fields payment form by replacing the default CSS and responding to the fieldValidityChange event. We provide you with default styles in Hosted Fields, but you can remove the default styles and add your own custom styles to match the look and feel of the merchant's website. Our styling options include the following: - Default styles - Custom styles - fieldValidityChange event ## Default styles Our default styles render your form to look like the following: ### Card form ![Card form](/assets/live/guides/hf-default-card.png) ### ACH form ![ACH form](/assets/live/guides/hf-default-ach.png) ### PAD form ![PAD form](/assets/live/guides/hf-default-pad.png) ## Custom styles To change the look and feel of the form, update your CSS, for example, the following code changes the color of the submit button on the form to red: ```js styles: { disableDefaultStyles: true, css: { "button[type='submit']": { 'background-color': '#d72d2d', 'border-color': '#d72d2d', }, }, } ``` ### Remove the default styles To remove the default styles, add a styles object to the config of the Hosted Fields JavaScript library with the following: - A disableDefaultStyles parameter with a value of `true`. - Your custom styles. ```js styles: { disableDefaultStyles: true, css: { // Custom styles }, }, ``` #### Default CSS If you add custom styles to your CSS, we recommend that you copy our default CSS and make your changes to it. ```js css: { body: { margin: "0", }, form: { display: "flex", "align-items": "center", }, input: { "line-height": "2", "box-sizing": "border-box", border: "1px rgb(158, 158, 158) solid", width: "100%", height: "100%", padding: "8px", "border-radius": "5px", "background-color": "#FFF", color: "rgb(99, 99, 99)", "text-align": "left", "font-size": "0.8rem", }, label: { padding: "8px 0", "font-family": "Arial", "font-size": "0.8rem", display: "inline-block", }, ":focus": { outline: "none", }, "::placeholder": { color: "rgb(158, 158, 158)", }, "input[type='text']": { "min-height": "45px", }, "::before": { content: "", width: "1rem", height: "1rem", "flex-basis": "1", "border-radius": "50%", transform: "scale(0)", "transform-origin": "center center", transition: "60ms transform ease-in-out", "box-shadow": "inset 1rem 1rem rgb(23, 134, 97)", }, ":checked::before": { transform: "scale(1)", "transform-origin": "center center", width: "23px", color: "red", outline: "1px black solid", "line-height": "2", }, button: { "background-color": "rgb(23, 134, 97)", color: "#FFF", border: "1px rgb(23, 134, 97) solid", "border-radius": "8px", width: "100%", "text-align": "center", "min-height": "45px", padding: "8px", }, div: { margin: "0", display: "flex", "align-items": "center", "justify-content": "center", "margin-left": "8px", }, 'input[type="radio"]': { "line-height": "unset", "box-sizing": "content-box", appearance: "none", "background-color": "#fff", margin: "0", "border-radius": "50%", width: "1.5rem", height: "1.5rem", "border-color": "rgb(158, 158, 158)", color: "rgb(23, 134, 97)", display: "flex", "justify-content": "center", "align-items": "center", "flex-direction": "column", padding: "unset", "min-height": "unset", "margin-right": "5px", }, 'input[type="radio"]::before': { content: "'.'", width: "1rem", height: "1rem", "flex-basis": "1", "border-radius": "50%", transform: "scale(0)", "transform-origin": "center center", transition: "60ms transform ease-in-out", "box-shadow": "inset 1rem 1rem rgb(23, 134, 97)", }, 'input[type="radio"]:checked::before': { transform: "scale(1)", "transform-origin": "center center", }, "input.invalid": { color: "#d72d2d", "border-color": "#d72d2d", }, ".loading-svg": { display: "none", color: "rgb(255, 255, 255)", }, ".button-text": { display: "inline-block", }, ".loading .loading-svg": { display: "inline-block", }, ".loading .button-text": { display: "none", }, ".spin": { animation: "spin 1s linear infinite", }, "@keyframes spin": { to: { transform: "rotate(1turn)", }, }, "button:hover": { cursor: "pointer", }, }, ``` #### Supported CSS elements - animation - align-items - appearance - background-color - border-color - border-radius - border - box-shadow - box-sizing - color - content - direction - display - flex-basis - flex-direction - float - font-family - font-size - font-style - font-weight - font - height - justify-content - letter-spacing - line-height - margin-bottom - margin-left - margin-right - margin-top - margin - max-width - min-height - opacity - outline - padding-bottom - padding-left - padding-right - padding-top - padding - text-align - text-shadow - transform-origin - transform - transition - width #### Supported HTML elements - button\[type="submit"\]::after - button\[type="submit"\]::before - button\[type="submit"\]:active - button\[type="submit"\]:after - button\[type="submit"\]:before - button\[type="submit"\]:checked - button\[type="submit"\]:disabled - button\[type="submit"\]:enabled - button\[type="submit"\]:focus - button\[type="submit"\]:hover - button\[type="submit"\]:indeterminate - button\[type="submit"\]:not(:checked) - input\[type="radio"\]:active - input\[type="radio"\]:checked::before - input\[type="radio"\]:checked - input\[type="radio"\]:disabled - input\[type="radio"\]:enabled - input\[type="radio"\]:focus - input\[type="radio"\]:hover - input\[type="radio"\]:indeterminate - input\[type="radio"\]:not(:checked) - input\[type="submit"\]::after - input\[type="submit"\]::before - input\[type="submit"\]:active - input\[type="submit"\]:after - input\[type="submit"\]:before - input\[type="submit"\]:checked - input\[type="submit"\]:disabled - input\[type="submit"\]:enabled - input\[type="submit"\]:focus - input\[type="submit"\]:hover - input\[type="submit"\]:indeterminate - input\[type="submit"\]:not(:checked) - input\[type="text"\]:active - input\[type="text"\]:checked - input\[type="text"\]:disabled - input\[type="text"\]:enabled - input\[type="text"\]:focus - input\[type="text"\]:hover - input\[type="text"\]:indeterminate - input\[type="text"\]:not(:checked) - .button-text - .invalid - .loading .button-text - .loading .loading-svg - .loading-svg - .spin - .valid - body - button::after - button::before - button:active - button:after - button:before - button:checked - button:disabled - button:enabled - button:focus - button:hover - button:indeterminate - button:not(:checked) - button - button\[type='submit'\] - div:first-of-type - div - fieldset - form - input.invalid - input.valid - input - input\[type='radio'\]::after - input\[type='radio'\]::before - input\[type='radio'\]:after - input\[type='radio'\]:before - input\[type='radio'\] - input\[type='submit'\] - input\[type='text'\]::after - input\[type='text'\]::before - input\[type='text'\]:after - input\[type='text'\]:before - input\[type='text'\] - label ## fieldValidityChange event If a customer enters an incorrect value, our default styles apply a red border and text with more information about the error, for example: ![Default fieldValidityChange event](/assets/live/guides/hf-defaultfield-validity-change.png) To change the style when the customer enters a correct value or an incorrect value in the Hosted Fields, subscribe to the fieldValidityChange event and update your CSS with: - A disableDefaultStyles parameter with a value of `true`. - Your custom styles. For example, to change the default red border to a blue border for incorrect information, include the following code in your CSS: ```js styles: { disableDefaultStyles: true, css: { "input.invalid": { "border-color": "#335bff" } }, } ``` ### Subscribe to the event To subscribe to the fieldValidityChange event, add an event listener to your form, for example: ```js cardForm.on("fieldValidityChange", ({ field, ValidationError }) => { }); ``` ### Handle the response If the customer enters a value and triggers the event, you receive a response that contains the name of the field that triggered the event and the validation error. If the customer enters a letter in the card number field, the event returns the following: ```js { "field": "cardNumber", "validationError": "Card number must contain numbers only" } ``` **Note:** If you change the styles to highlight a valid entry, we return a value of `undefined` for the validationError field. # Update a customer's payment details Source: https://docs.payroc.com/guides/payments/hosted-fields/update-payment-details Update a customer's saved payment details by submitting a single-use token from Hosted Fields to the Secure Tokens update-account endpoint. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). If a customer uses Hosted Fields to change their payment details, our gateway returns a single-use token that represents the updated payment details. To update the customer’s saved payment details, send the single-use token to our gateway to update the secure token. You can use a single-use token to update only the payment details linked to a secure token. To update the customer’s contact details or the merchant-initiated transaction (MIT) agreement, go to Update a secure token. ## Before you begin Make sure that you’ve set up your integration to [save payment details](/guides/payments/hosted-fields/save-payment-details-overview). [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ### Headers To create the header of each POST request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. - **Idempotency-Key:** Include a UUID v4 to make the request idempotent. ```curl -H "Content-Type: application/json" -H "Authorization: " -H "Idempotency-Key: " ``` To create the header of each GET request, include the Authorization header parameter. ```curl -H "Authorization: " ``` ### Errors Make sure that your integration can handle errors. If a request is unsuccessful, we return an error that follows the [RFC 7807 format](https://www.rfc-editor.org/rfc/rfc7807). For more information about errors, go to [Errors](/api/errors). ## Integration steps 1. List secure tokens. 2. Generate a session token. 3. Update the JavaScript library. 4. Update the secure token. ## Step 1. List secure tokens Before you update the customer’s payment details, you need the secureTokenId of the secure token that represents the customer's payments details. To search for the secureTokenId, use our List Secure Tokens method to view all the secure tokens associated with the processing terminal. You can use query parameters to filter your search, for example, you can filter by the customer’s name or email address. To view the secure tokens associated with the processing terminal, send a GET request to our Secure Tokens endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.uat.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) | | Production | [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) | ### Request parameters To create your request, use the following parameters: ### Schema (`request`) [Request schema for `GET /processing-terminals/{processingTerminalId}/secure-tokens`](/api/list-secure-tokens) ### Example request ### Request GET [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) **`Paginated Secure Token`** ```curl curl -G https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens \ -H "Authorization: Bearer " \ -d after=8516 \ -d before=2571 \ --data-urlencode customerName=Sarah%20Hazel%20Hopper \ --data-urlencode email=sarah.hopper@example.com \ -d first6=453985 \ -d last4=7062 \ -d limit=25 \ -d phone=2025550165 \ -d secureTokenId=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa \ -d token=296753123456 ``` **`Paginated Secure Token`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" querystring = {"after":"8516","before":"2571","customerName":"Sarah%20Hazel%20Hopper","email":"sarah.hopper@example.com","first6":"453985","last4":"7062","limit":"25","phone":"2025550165","secureTokenId":"MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa","token":"296753123456"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` **`Paginated Secure Token`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?after=8516&before=2571&customerName=Sarah%2520Hazel%2520Hopper&email=sarah.hopper%40example.com&first6=453985&last4=7062&limit=25&phone=2025550165&secureTokenId=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa&token=296753123456'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Paginated Secure Token`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?after=8516&before=2571&customerName=Sarah%2520Hazel%2520Hopper&email=sarah.hopper%40example.com&first6=453985&last4=7062&limit=25&phone=2025550165&secureTokenId=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa&token=296753123456" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Paginated Secure Token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?after=8516&before=2571&customerName=Sarah%2520Hazel%2520Hopper&email=sarah.hopper%40example.com&first6=453985&last4=7062&limit=25&phone=2025550165&secureTokenId=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa&token=296753123456") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Paginated Secure Token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?after=8516&before=2571&customerName=Sarah%2520Hazel%2520Hopper&email=sarah.hopper%40example.com&first6=453985&last4=7062&limit=25&phone=2025550165&secureTokenId=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa&token=296753123456") .header("Authorization", "Bearer ") .asString(); ``` **`Paginated Secure Token`** ```php request('GET', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?after=8516&before=2571&customerName=Sarah%2520Hazel%2520Hopper&email=sarah.hopper%40example.com&first6=453985&last4=7062&limit=25&phone=2025550165&secureTokenId=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa&token=296753123456', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Paginated Secure Token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?after=8516&before=2571&customerName=Sarah%2520Hazel%2520Hopper&email=sarah.hopper%40example.com&first6=453985&last4=7062&limit=25&phone=2025550165&secureTokenId=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa&token=296753123456"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Paginated Secure Token`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?after=8516&before=2571&customerName=Sarah%2520Hazel%2520Hopper&email=sarah.hopper%40example.com&first6=453985&last4=7062&limit=25&phone=2025550165&secureTokenId=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa&token=296753123456")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we return a list of secure tokens associated with the processing terminal. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `GET /processing-terminals/{processingTerminalId}/secure-tokens`](/api/list-secure-tokens) ### Example response ### Response (200) ```json { "limit": 2, "count": 2, "hasMore": true, "data": [ { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Hopper", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } } }, { "secureTokenId": "MREF_fe0d9876-cba5-432f-e10d-9cb87654a3f2e1", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "500165******0000", "cardholderName": "Sarah Hazel Hopper", "expiryDate": "0328" }, "token": "307864234567", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ], "links": [ { "rel": "next", "method": "get", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?limit=2&after=MREF_fe0d9876-cba5-432f-e10d-9cb87654a3f2e1" }, { "rel": "previous", "method": "get", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens?limit=2&before=MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } ] } ``` ## Step 2. Generate a session token When you generate the session token, you need to include the secureTokenId of the secure token that you want to update. To generate a session token, send a POST request to our Processing Terminals endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId\}/hosted-fields-sessions](https://api.uat.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/hosted-fields-sessions) | | Production | [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/hosted-fields-sessions](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/hosted-fields-sessions) | ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/hosted-fields-sessions`](/api/create-session) ### Example request ### Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/hosted-fields-sessions](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/hosted-fields-sessions) **`Create session`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "libVersion": "1.1.0.123456", "scenario": "payment" }' ``` **`Create session`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions" payload = { "libVersion": "1.1.0.123456", "scenario": "payment" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create session`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"libVersion":"1.1.0.123456","scenario":"payment"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create session`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions" payload := strings.NewReader("{\n \"libVersion\": \"1.1.0.123456\",\n \"scenario\": \"payment\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create session`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"libVersion\": \"1.1.0.123456\",\n \"scenario\": \"payment\"\n}" response = http.request(request) puts response.read_body ``` **`Create session`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"libVersion\": \"1.1.0.123456\",\n \"scenario\": \"payment\"\n}") .asString(); ``` **`Create session`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions', [ 'body' => '{ "libVersion": "1.1.0.123456", "scenario": "payment" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create session`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"libVersion\": \"1.1.0.123456\",\n \"scenario\": \"payment\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create session`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "libVersion": "1.1.0.123456", "scenario": "payment" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/hosted-fields-sessions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway generates a session token. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/hosted-fields-sessions`](/api/create-session) ### Example response ### Response (201) ```json { "processingTerminalId": "1234001", "token": "abcdef1234567890abcdef1234567890", "expiresAt": "2025-07-02T15:30:00.123456789+02:00" } ``` ## Step 3. Update the JavaScript library In the JavaScript configuration, change the value for the mode parameter from payment to `tokenization`. **`Card`** ```js ``` **`ACH`** ```js ``` **`PAD`** ```js ``` ## Step 4. Update the secure token After the customer submits their new payment details and you receive the single-use token from the submissionSuccess event, send the single-use token to our gateway to update the secure token. To send the single-use token to our gateway, send a POST request to our Secure Tokens endpoint. | Environment | URL | | --- | --- | | Test | [https://api.uat.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens/\{secureTokenId\}/update-account](https://api.uat.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens/%7BsecureTokenId%7D/update-account) | | Production | [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens/\{secureTokenId\}/update-account](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens/%7BsecureTokenId%7D/update-account) | ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}/update-account`](/api/account-update) ### Example request ### Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens/\{secureTokenId\}/update-account](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens/%7BsecureTokenId%7D/update-account) **`Update account details`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }' ``` **`Update account details`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account" payload = { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Update account details`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"type":"singleUseToken","token":"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Update account details`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account" payload := strings.NewReader("{\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Update account details`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n}" response = http.request(request) puts response.read_body ``` **`Update account details`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n}") .asString(); ``` **`Update account details`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account', [ 'body' => '{ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Update account details`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Update account details`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we update the payment details associated with the secure token. The response contains the following fields: **Note:** When we update the payment details associated with the secure token, we change only the payment details that the secure token represents. The values for the secureTokenId parameter and the token parameter stay the same. ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}/update-account`](/api/account-update) ### Example response ### Response (200) ```json { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Hazel Hopper", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Apple Pay® Source: https://docs.payroc.com/guides/payments/apple-pay Add Apple Pay to your integration so merchants can accept Apple Pay as a payment method for online transactions. **Prerequisites:** [Authentication](/api/authentication) An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Apple Pay® is a digital wallet application that Apple customers can use to store payment card details and to pay for goods and services using their Apple devices. When you add Apple Pay to your integration, your merchants can accept Apple Pay as a payment method for online transactions. When a customer uses Apple Pay to make a payment, your integration communicates with the Apple JS API and the Payroc gateway to make the sale. To simplify your integration, our gateway creates and handles the Apple Pay Certificate that you need to run transactions with Apple Pay. ## How it works ```mermaid sequenceDiagram participant AP as Apple Pay JS API participant YI as Your integration participant GW as Gateway rect rgba(0, 81, 194, 0.4) Note over AP,GW: Start an Apple Pay session Note over YI: 1. Cardholder chooses to pay with Apple Pay YI->>AP: 2. Request the validation URL AP-->>YI: 3. Return the validation URL YI->>GW: 4. Send the validation URL to the Apple Pay sessions API Note over GW: 5. Start the session with Apple and retrieve the merchant session object GW-->>YI: 6. Return the merchant session object end rect rgba(0, 224, 184, 0.3) Note over AP,GW: Run a sale Note over YI: 1. Cardholder confirms their payment method YI->>AP: 2. Send payment request to Apple Note over AP: 3. Apple encrypts the payment details AP-->>YI: 4. Return encrypted payment details YI->>GW: 5. Send the payment details in a payment request GW-->>YI: 6. Return payment response end ``` ### Start an Apple Pay session 1. Cardholder chooses to pay with Apple Pay, for example, they select the Apple Pay button on the merchant's web page. 2. Your integration requests the validation URL from Apple. 3. Apple returns the validation URL to your integration. 4. Your integration sends a request to our Apple Pay sessions endpoint. The request must include the unique domainId and validation URL. 5. We start an Apple Pay session and get the merchant session object from Apple. 6. We return the merchant session object to your integration. ### Run a sale 1. Cardholder confirms the payment method they want to use. 2. Your integration sends a request to Apple that includes details about the transaction and the merchant session object. 3. Apple returns the cardholder's encrypted payment details to your integration. 4. Your integration sends a request to our Payments endpoint. The request must include the cardholder's encrypted payment details in hexadecimal format. 5. Our gateway returns a successful payment response to your integration. ## Your integration journey To set up Apple Pay for a merchant, complete the following actions: **Step 1.** Add Apple Pay to your integration: - **Integrate with the Apple Pay JS API** - Use the Apple Pay JS API to validate the merchant's domain and to receive a cardholder's encrypted payment details. - **Integrate with the Payroc API** - Use our gateway to start a merchant session with Apple and to run a sale with the encrypted payment details you received from Apple. **Step 2.** Set up Apple Pay for a merchant: - **Domain verification file** - Add the domain verification file to the merchant's domain. - **Self-Care Portal** - Use the Self-Care Portal to set up Apple Pay for a merchant, and to get their unique domain ID that you send to Apple. ## Extend your integration You can extend your integration to add convenience fees and to split a payment between multiple third parties. ## Guides #### [Add Apple Pay to your integration](/guides/payments/apple-pay/apple-pay-integrate) Set up Apple Pay to run transactions with our gateway. #### [Set up Apple Pay for a merchant](/guides/payments/apple-pay/set-up-apple-pay-merchant) Configure Apple Pay with the Self-Care Portal. #### [Add a convenience fee](/guides/payments/apple-pay/add-a-convenience-fee) Apply a convenience fee to Apple Pay payments. #### [Split a payment with multiple merchants](/guides/payments/apple-pay/split-a-payment-with-multiple-merchants) Divide a payment with other merchants or third parties. # Set up Apple Pay for a merchant Source: https://docs.payroc.com/guides/payments/apple-pay/set-up-apple-pay-merchant Configure Apple Pay for a merchant by adding the domain verification file and registering the domain in the Self-Care Portal to generate a unique merchant domain ID. **Prerequisites:** [Authentication](/api/authentication) · [Add Apple Pay to your integration](/guides/payments/apple-pay/apple-pay-integrate) After you integrate with the Apple Pay JS API and the Payroc API, you need to set up Apple Pay for each individual merchant. We then generate a unique ID for the merchant's domain that you need to start an Apple Pay session. To set up Apple Pay for a merchant, complete the following steps: **Step 1.** Add the domain verification file to the merchant's domain. **Step 2.** Add the merchant's domain to the Self-Care Portal. ## Before you begin Add the following subfolder to the merchant's domain: `/.well-known` ## Step 1. Add the domain verification file to the merchant's domain 1. Log into the [Self-Care Portal](https://payments.payroc.com/). 2. From the side menu, select **Settings**, and then select **Apple Pay Domains**. 3. Select **DOWNLOAD DOMAIN VERIFICATION FILE**. 4. Add the file to the merchant's domain in the following subfolder: `/.well-known/apple-developer-merchantid-domain-association` **Important:** Do not change the name of the domain verification file. The file name must be `apple-developer-merchantid-domain-association`. ## Step 2. Add the merchant's domain to the Self-Care Portal 1. Select **ADD NEW DOMAIN**. 2. In the **Domain** field, enter the merchant's domain name, for example, website.com. 3. Select **Save**. The Self-Care Portal redirects you to the Apple Pay Domains page where it displays the unique ID of the merchant's domain. **Important:** Store the unique ID of the merchant's domain. You need to send the unique ID when you start an Apple Pay Session. The Self-Care Portal also displays the Merchant Identifier, which you need if you want to [add a convenience fee](/guides/payments/apple-pay/add-a-convenience-fee) or [split a payment with multiple merchants](/guides/payments/apple-pay/split-a-payment-with-multiple-merchants). # Add a convenience fee Source: https://docs.payroc.com/guides/payments/apple-pay/add-a-convenience-fee Apply a convenience fee to Apple Pay payments by including the multiTokenContexts array in your ApplePayPaymentRequest and sending a single payment request to our gateway. **Prerequisites:** [Add Apple Pay to your integration](/guides/payments/apple-pay/apple-pay-integrate) · [Set up Apple Pay for a merchant](/guides/payments/apple-pay/set-up-apple-pay-merchant) You can extend your Apple Pay integration to add a convenience fee to a payment. ## How it works 1. You send a request to the Apple Pay JS API that contains the amount for the payment and the amount for the convenience fee. 2. Apple returns a cryptogram after your customer authorizes the total amount. 3. You send a single payment request to our gateway for the total amount of the payment including the convenience fee. ## Before you begin - [Integrate with Apple Pay](/guides/payments/apple-pay/apple-pay-integrate). - [Set up Apple Pay for the merchant](/guides/payments/apple-pay/set-up-apple-pay-merchant) and store their merchant identifier. You must use Apple Pay JS API version 14 or later. ## Integration steps 1. Update your Apple Pay integration. 2. Send a payment request. ## Step 1. Update your Apple Pay integration Update your Apple Pay integration to include the `multiTokenContexts` array with two entries in the `ApplePayPaymentRequest`. One entry is for the sale amount, and the other entry is for the convenience fee. If your request is successful and the customer authorizes the payment, Apple Pay returns a cryptogram that you need to include in the payment request to our gateway. ### Request parameters | Parameter | Description | | --- | --- | | **merchantIdentifier** | Merchant identifier that we assigned when you set up the merchant with Apple Pay. The value is the same for both entries. | | **externalIdentifier** | ID that our gateway uses to identify the payment and the convenience fee. The value depends on the entry: • For the sale amount, send `PRIMARY`. • For the convenience fee, send `CONVENIENCE_FEE`. | | **merchantName** | Name of the merchant that you set up with Apple Pay. | | **amount** | Amount for the sale or the convenience fee. | ### multiTokenContexts example ```json "multiTokenContexts": [ { "merchantIdentifier": "PMID-2", "externalIdentifier": "PRIMARY", "merchantName": "Merchant 1", "amount": "100.00" }, { "merchantIdentifier": "PMID-2", "externalIdentifier": "CONVENIENCE_FEE", "merchantName": "Merchant 1", "amount": "2.50" } ] ``` ## Step 2. Send a payment request After you receive the cryptogram from the Apple Pay JS API, send a payment request to our Payments endpoint to run the sale. In the payment request, the value for the `order.amount` parameter is the total amount of the payment including the convenience fee. If your request is successful, our gateway splits the total amount between the sale amount and the convenience fee. # Split a payment with multiple merchants Source: https://docs.payroc.com/guides/payments/apple-pay/split-a-payment-with-multiple-merchants Split an Apple Pay payment between multiple merchants using the multi-merchant of record (MMoR) function by sending the multiTokenContexts array to Apple Pay and individual payment requests to our gateway. **Prerequisites:** [Add Apple Pay to your integration](/guides/payments/apple-pay/apple-pay-integrate) · [Set up Apple Pay for a merchant](/guides/payments/apple-pay/set-up-apple-pay-merchant) If you need to split an Apple Pay payment between multiple merchants or third parties, you can use the multi-merchant of record (MMoR) function within Apple Pay. With MMoR, the cardholder authorizes the total amount once, and then you send the separate amounts to each merchant or third party. ## How it works 1. You send a request to the Apple Pay JS API that contains the amount for each merchant. 2. Apple returns a cryptogram after your customer authorizes the total amount. 3. You send a payment request to our gateway for each merchant. Each payment request contains the same cryptogram and the amount that the merchant should receive. ## Before you begin - [Integrate with Apple Pay](/guides/payments/apple-pay/apple-pay-integrate). - [Set up Apple Pay for each merchant](/guides/payments/apple-pay/set-up-apple-pay-merchant) and store their merchant identifier. You must use Apple Pay JS API version 14 or later. ## Integration steps 1. Update your Apple Pay integration. 2. Send a payment request for each merchant. ## Step 1. Update your Apple Pay integration Update your Apple Pay integration to include the `multiTokenContexts` array in the `ApplePayPaymentRequest`. Each entry in the array represents a payment amount to each merchant. If your request is successful and the customer authorizes the payment, Apple Pay returns a cryptogram that you need to include in each payment request to our gateway. ### Request parameters | Parameter | Description | | --- | --- | | **merchantIdentifier** | Merchant identifier that we assigned when you set up the merchant with Apple Pay. | | **externalIdentifier** | Order ID for the payment. This value must match the value for `orderId` in the payment request. | | **merchantName** | Name of the merchant that you set up with Apple Pay. | | **amount** | Amount that each merchant receives from the total amount. | ### multiTokenContexts example ```json "multiTokenContexts": [ { "merchantIdentifier": "PMID-101", "externalIdentifier": "ORDER-A1", "merchantName": "Merchant 1", "amount": "100.00" }, { "merchantIdentifier": "PMID-102", "externalIdentifier": "ORDER-B7", "merchantName": "Merchant 2", "amount": "25.00" }, { "merchantIdentifier": "PMID-103", "externalIdentifier": "ORDER-C3", "merchantName": "Merchant 3", "amount": "10.00" } ] ``` ## Step 2. Send a payment request for each merchant After you receive the cryptogram from the Apple Pay JS API, send a payment request to our Payments endpoint for each merchant. In each payment request, include the same cryptogram in the `encryptedData` parameter, but adjust the following parameters for each merchant: - `processingTerminalId` – Unique identifier that we assigned to the merchant's terminal. - `order.orderId` – Order ID that matches the `externalIdentifier` that you sent to the Apple Pay JS API. - `order.amount` – Amount that the merchant receives. If your requests are successful, our gateway sends the amounts to each merchant. # Add Apple Pay to your integration Source: https://docs.payroc.com/guides/payments/apple-pay/apple-pay-integrate Integrate Apple Pay by starting a merchant session via the Apple Pay sessions endpoint and running a sale via the Payments endpoint with encrypted digital wallet data. **Prerequisites:** [Authentication](/api/authentication) Allow your merchants to accept Apple Pay as a payment method. ## Integration steps **Step 1.** Integrate with the Apple Pay JS API. **Step 2.** Integrate with the Payroc API: Step 2a - Start an Apple Pay session. Step 2b - Run a sale. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ### Headers To create the header of each GET request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. ```sh curl -H "Content-Type: application/json" -H "Authorization: " ``` To create the header of each POST request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. - **Idempotency-Key:** Include a UUID v4 to make the request idempotent. ```sh curl -H "Content-Type: application/json" -H "Authorization: " -H "Idempotency-Key: " ``` ### Errors If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors). ## Step 1. Integrate with the Apple JS API To integrate with the Apple Pay JS API, go to [https://developer.apple.com/apple-pay/](https://developer.apple.com/apple-pay/). Your integration with Apple must retrieve the following information: - **Validation URL** - Apple provides the validation URL that you send to us when you create an Apple Pay session. - **Encrypted payment details** - Apple encrypts the cardholder's payment details and returns them to your integration. After you receive the encrypted payment details, convert them to hexadecimal. ## Step 2. Integrate with the Payroc API Use our API to start the merchant session with Apple Pay and retrieve the startSessionResponse object. After you use the Apple Pay JS API to encrypt the cardholder's payment details, use our API to run the sale. ### Step 2a. Start an Apple Pay session To start an Apple Pay session with Apple, send a request to our Apple Pay sessions endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/apple-pay-sessions` In the body of your request, include the following parameters: - **appleDomainId** - You can view the appleDomainId after you add the merchant's domain to the Self-Care Portal. - **appleValidationUrl** - Apple provides the validation URL as part of your integration with the Apple Pay JS API. In the response, we return the startSessionResponse object. Send the content of the startSessionResponse object to Apple to retrieve the cardholder's encrypted payment details. ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/apple-pay-sessions`](/api/apple-pay-sessions) ### Example request ### Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/apple-pay-sessions](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/apple-pay-sessions) **`Apple Pay session`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "appleDomainId": "DUHDZJHGYY", "appleValidationUrl": "https://apple-pay-gateway.apple.com/paymentservices/startSession" }' ``` **`Apple Pay session`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions" payload = { "appleDomainId": "DUHDZJHGYY", "appleValidationUrl": "https://apple-pay-gateway.apple.com/paymentservices/startSession" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Apple Pay session`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"appleDomainId":"DUHDZJHGYY","appleValidationUrl":"https://apple-pay-gateway.apple.com/paymentservices/startSession"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Apple Pay session`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions" payload := strings.NewReader("{\n \"appleDomainId\": \"DUHDZJHGYY\",\n \"appleValidationUrl\": \"https://apple-pay-gateway.apple.com/paymentservices/startSession\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Apple Pay session`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"appleDomainId\": \"DUHDZJHGYY\",\n \"appleValidationUrl\": \"https://apple-pay-gateway.apple.com/paymentservices/startSession\"\n}" response = http.request(request) puts response.read_body ``` **`Apple Pay session`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"appleDomainId\": \"DUHDZJHGYY\",\n \"appleValidationUrl\": \"https://apple-pay-gateway.apple.com/paymentservices/startSession\"\n}") .asString(); ``` **`Apple Pay session`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions', [ 'body' => '{ "appleDomainId": "DUHDZJHGYY", "appleValidationUrl": "https://apple-pay-gateway.apple.com/paymentservices/startSession" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`Apple Pay session`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"appleDomainId\": \"DUHDZJHGYY\",\n \"appleValidationUrl\": \"https://apple-pay-gateway.apple.com/paymentservices/startSession\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Apple Pay session`** ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "appleDomainId": "DUHDZJHGYY", "appleValidationUrl": "https://apple-pay-gateway.apple.com/paymentservices/startSession" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/apple-pay-sessions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway starts the merchant session with Apple and returns the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/apple-pay-sessions`](/api/apple-pay-sessions) ### Example response ### Response (200) ```json { "startSessionResponse": "{\n \"epochTimestamp\": 1736264582447,\n \"expiresAt\": 1736268182447,\n \"merchantSessionIdentifier\": \"SSHE464E2B91B714F18BFD19D46D0F582BF_916523AAED1343F5BC5815E12BEE9250AFFDC1A17C46B0DE5A943F0F94927C24\",\n \"nonce\": \"e5775127\",\n \"merchantIdentifier\": \"BFB110EE83BE2AF4AA7468926C926CCFC57F4A541CCE6E7F3BEFD05002ECE503\",\n \"domainName\": \"store.com\",\n \"displayName\": \"Store One\",\n \"signature\": \"a1b1c012345678a000b000c0012345d0e0f010g10061a031i001j071k0a1b0c1d0e1234567890120f1g0h1i0j1k0a1b0123451c012d0e1f0g1h0i1j123k1a1b1c1d1e1f1g123h1i1j1k1a1b1c1d1e1f1g123h123i1j123k12340a120a12345b012c0123012d0d1e0f1g0h1i123j123k10000\",\n \"operationalAnalyticsIdentifier\": \"Store One:BFB110EE83BE2AF4AA7468926C926CCFC57F4A541CCE6E7F3BEFD05002ECE503\",\n \"retries\": 0,\n \"pspId\": \"17D4AAA8D9357D26D771ABA0DAA0B9D3BB462AD1585492E1FE688AF8BB9558E5\"\n}\n" } ``` ### Step 2b. Run a sale After you retrieve the cardholder's encrypted payment details from Apple, use our payments endpoint to run a sale. **Endpoint:** `https://api.payroc.com/v1/payments` In your request, send the following parameters in the paymentMethod object: **type** - Provide a value of `digitalWallet`. **serviceProvider** - Provide a value of `apple`. **encryptedData** - Provide the encrypted payment details that you retrieved from the Apple Pay JS API. The payment details must be in hexadecimal format. ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments`](/api/payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **`Apple Pay Payment`** ```curl curl -X POST https://api.payroc.com/v1/payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "1234567890W", "amount": 4999, "currency": "USD", "description": "Card Transaction (APPLE)" }, "paymentMethod": { "type": "digitalWallet", "encryptedData": "7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d", "serviceProvider": "apple" }, "operator": "Jane" }' ``` **`Apple Pay Payment`** ```python import requests url = "https://api.payroc.com/v1/payments" payload = { "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "1234567890W", "amount": 4999, "currency": "USD", "description": "Card Transaction (APPLE)" }, "paymentMethod": { "type": "digitalWallet", "encryptedData": "7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d", "serviceProvider": "apple" }, "operator": "Jane" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Apple Pay Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"channel":"web","processingTerminalId":"1234001","order":{"orderId":"1234567890W","amount":4999,"currency":"USD","description":"Card Transaction (APPLE)"},"paymentMethod":{"type":"digitalWallet","encryptedData":"7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d","serviceProvider":"apple"},"operator":"Jane"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Apple Pay Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments" payload := strings.NewReader("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"1234567890W\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Card Transaction (APPLE)\"\n },\n \"paymentMethod\": {\n \"type\": \"digitalWallet\",\n \"encryptedData\": \"7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d\",\n \"serviceProvider\": \"apple\"\n },\n \"operator\": \"Jane\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Apple Pay Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"1234567890W\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Card Transaction (APPLE)\"\n },\n \"paymentMethod\": {\n \"type\": \"digitalWallet\",\n \"encryptedData\": \"7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d\",\n \"serviceProvider\": \"apple\"\n },\n \"operator\": \"Jane\"\n}" response = http.request(request) puts response.read_body ``` **`Apple Pay Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"1234567890W\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Card Transaction (APPLE)\"\n },\n \"paymentMethod\": {\n \"type\": \"digitalWallet\",\n \"encryptedData\": \"7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d\",\n \"serviceProvider\": \"apple\"\n },\n \"operator\": \"Jane\"\n}") .asString(); ``` **`Apple Pay Payment`** ```php request('POST', 'https://api.payroc.com/v1/payments', [ 'body' => '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "1234567890W", "amount": 4999, "currency": "USD", "description": "Card Transaction (APPLE)" }, "paymentMethod": { "type": "digitalWallet", "encryptedData": "7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d", "serviceProvider": "apple" }, "operator": "Jane" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Apple Pay Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"1234567890W\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Card Transaction (APPLE)\"\n },\n \"paymentMethod\": {\n \"type\": \"digitalWallet\",\n \"encryptedData\": \"7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d\",\n \"serviceProvider\": \"apple\"\n },\n \"operator\": \"Jane\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Apple Pay Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "channel": "web", "processingTerminalId": "1234001", "order": [ "orderId": "1234567890W", "amount": 4999, "currency": "USD", "description": "Card Transaction (APPLE)" ], "paymentMethod": [ "type": "digitalWallet", "encryptedData": "7b2262696c6c696e67436f6e74616374223a7b2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c227368697070696e67436f6e74616374223a7b22656d61696c41646472657373223a227465737440646f6d61696e2e636f6d222c2266616d696c794e616d65223a22222c22676976656e4e616d65223a22222c2270686f6e6574696346616d696c794e616d65223a22222c2270686f6e65746963476976656e4e616d65223a22227d2c22746f6b656e223a7b227061796d656e7444617461223a7b2264617461223a2259314b37626731573479755568587473335941627a6150756c384d31795057304c724637734e2f70415950456d3871647969716c6257777356792b7732334c666c74344e6932525a684c2f6a52727563356f69496235537437763248543739682b74702f78517838496b6a5631485354594d747156644c6a413977686379774f654f70326575556d306e56386b50726569564273726a596c355931437a30576371495648595134424e737a4b5876675063686a497a6f4d4b456336425650744c7335777654667a434b51574a496a646b62516161306265685958524b422b7941773872537a6a4a476f3758523061467a414b4e70346c6f436e69484e564838373244504e4a77364b30336e544d69724b37725a615566485356754d477544473348366e4d78336c48436e6b517478764551474771754132676c416434424f427943414976483541566671655173534137776a4459702f494c6c66614e64307469467478344d6235566f6952513249387379384548547670307736667861316973613874636f484855614b32353857486474673d3d222c227369676e6174757265223a224d494147435371475349623344514548417143414d494143415145784454414c42676c67686b67425a514d45416745776741594a4b6f5a496876634e415163424141436767444343412b517767674f4c6f414d434151494343466e596f627971394f504e4d416f4743437147534d343942414d434d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730794d5441304d6a41784f544d334d444261467730794e6a41304d546b784f544d324e546c614d4749784b44416d42674e5642414d4d4832566a5979317a62584174596e4a76613256794c584e705a32356656554d304c564e42546b5243543167784644415342674e564241734d43326c505579425465584e305a57317a4d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941424949772f6176446e50646549437851325a74464575593334716b423357797a344c484e53314a6e6d506a505472336f4769576f7768354d4d39334f6a697157777661766f5a4d445263546f656b516d7a7055624570576a676749524d4949434454414d42674e5648524d4241663845416a41414d42384741315564497751594d42614146435079536352506b2b54764a2b62453969687350364b372f53354c4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d4449776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d4230474131556444675157424251434a44414c6d753774526a4758704b5a614b5a3543635949635254414f42674e56485138424166384542414d43423441774477594a4b6f5a496876646a5a415964424149464144414b42676771686b6a4f5051514441674e4841444245416942306f624d6b32304a4a517733544a307851644d53416a5a6f6653413436686358424e69566d4d6c2b386f7749676154615155367631433170532b6659415463574b725778517039594961446551344b63363042354b3259457767674c754d49494364614144416745434167684a62532b2f4f706a616c7a414b42676771686b6a4f50515144416a426e4d527377475159445651514444424a42634842735a5342536232393049454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a4165467730784e4441314d4459794d7a51324d7a4261467730794f5441314d4459794d7a51324d7a42614d486f784c6a417342674e5642414d4d4a5546776347786c4945467763477870593246306157397549456c756447566e636d46306157397549454e4249433067527a4d784a6a416b42674e564241734d485546776347786c49454e6c636e52705a6d6c6a59585270623234675158563061473979615852354d524d77455159445651514b44417042634842735a53424a626d4d754d517377435159445651514745774a56557a425a4d424d4742797147534d34394167454743437147534d34394177454841304941425041584559515a31325346315270654a594548647569416f752f656536354e34493338533550684d3162565a6c733172694c516c33594e496b353775676a396468664f694d743275325a7776736a6f4b59542f5645576a6766637767665177526759494b77594242515548415145454f6a41344d4459474343734741515546427a41426869706f644852774f69387662324e7a63433568634842735a53356a6232307662324e7a634441304c5746776347786c636d397664474e685a7a4d77485159445652304f4242594546435079536352506b2b54764a2b62453969687350364b372f53354c4d41384741315564457745422f7751464d414d4241663877487759445652306a42426777466f4155753744656f56677a694a716b69706e65767233727239724c4a4b73774e77594456523066424441774c6a41736f4371674b49596d6148523063446f764c324e7962433568634842735a53356a623230765958427762475679623239305932466e4d79356a636d777744675944565230504151482f42415144416745474d42414743697147534962335932514741673445416755414d416f4743437147534d343942414d43413263414d4751434d447250636f4e5246706d78687673317731624b59722f30462b335a4433564e6f6f362b385a7942586b4b33696669593935745a6e356a56515132506e656e432f6749774d693356524347776f7756336246337a4f4475515a2f305866437768625a5a50786e4a7067684a76565068366652755a7935734a6953466842706b50435a4964414141786767474a4d4949426851494241544342686a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d4343466e596f627971394f504e4d417347435743475341466c41775143416143426b7a415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730794e4445794d5449784e6a51774d5452614d43674743537147534962334451454a4e4445624d426b774377594a59495a4941575544424149426f516f4743437147534d343942414d434d43384743537147534962334451454a4244456942434335615768366c647944637435626844536b62345835494a612b576f746d6d74344a624c74386949754a6b6a414b42676771686b6a4f50515144416752494d45594349514437637561364c6430697a6148716d5371713747303433476770363467484d6b514e523577757a32736137674968414e44643730585a6639432f412b58774e716a75672b76684c39534c4c4966465159746f6745377842534c774141414141414141222c22686561646572223a7b227075626c69634b657948617368223a225542347255754d6b7044627054564b7448636a6452525a496f643465766562754d4f696b7a4156556441593d222c22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a3044415163445167414557556a70324f663878427449432f354335535349544e443554736f75564c423831464547383847504b7243394e394d753365534e72586c32636564757533552f504f53652f616f75384477556a674e6670584d7831673d3d222c227472616e73616374696f6e4964223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d2c2276657273696f6e223a2245435f7631227d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a224d6173746572436172642031343731222c226e6574776f726b223a224d617374657243617264222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2231363431326566383238303362633133356338333165396235663732376432366165623661616130363364633138353861313562323734386666346636333739227d7d", "serviceProvider": "apple" ], "operator": "Jane" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway uses the card details to run a sale. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments`](/api/payment) ### Example response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Next steps After you integrate with the Apple Pay JS API and the Payroc API, complete the following steps: - **Set up Apple Pay for each merchant** - To set up Apple Pay for a merchant to run transactions, go to [Set up Apple Pay for a Merchant](/guides/payments/apple-pay/set-up-apple-pay-merchant). - **Set up a Sandbox Apple Account** - To run test transactions with Apple Pay, set up a Sandbox Apple Account. To set up a Sandbox Apple Account, contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). # Extend your integration Source: https://docs.payroc.com/guides/payments/apple-pay/extend-your-integration Extend your Apple Pay integration to add convenience fees or split payments between multiple merchants using the multi-merchant of record function. After you set up Apple Pay to run a sale, you can extend your integration to include the following: - [Split a payment between merchants](/guides/payments/apple-pay/split-a-payment-with-multiple-merchants) - Divide a payment with other merchants or third parties. - [Add a convenience fee](/guides/payments/apple-pay/add-a-convenience-fee) - Apply a convenience fee to Apple Pay payments. # Google Pay Source: https://docs.payroc.com/guides/payments/google-pay Add Google Pay to your integration so merchants can accept Google Pay as a payment method for online transactions. **Prerequisites:** [Authentication](/api/authentication) An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Google Pay® is a digital wallet application that Google customers can use to store payment card details and to pay for goods and services. When you add Google Pay to your integration, your merchants can accept Google Pay as a payment method for online transactions. When a customer uses Google Pay to make a payment, your integration communicates with Google Pay and the Payroc gateway to make the sale. ## How it works The following diagram shows the flow of a transaction with Google Pay. ```mermaid sequenceDiagram participant GP as Google Pay API participant YI as Your integration participant GW as Gateway rect rgba(0, 81, 194, 0.4) Note over GP,GW: Run a sale Note over YI: 1. Cardholder chooses to pay with Google Pay YI->>GP: 2. Request the cardholder's payment details GP-->>YI: 3. Return the encrypted payment details Note over YI: 4. Convert the payment details to hexadecimal format YI->>GW: 5. Send the payment details in a payment request GW-->>YI: 6. Return payment response end ``` 1. Cardholder chooses to pay with Google Pay, for example, they select the Google Pay button on the merchant's web page. 2. Your integration requests the cardholder's payment details from Google Pay. 3. Google Pay returns the cardholder's encrypted payment details. 4. Your integration converts the cardholder's payment details to hexadecimal format. 5. Your integration sends a request to our Payments endpoint with the cardholder's encrypted payment details in hexadecimal format. 6. Our gateway returns a successful payment response to your integration. ## Guides #### [Add Google Pay to your integration](/guides/payments/google-pay/google-pay-integrate) Run transactions with Google Pay. # Add Google Pay to your integration Source: https://docs.payroc.com/guides/payments/google-pay/google-pay-integrate Integrate Google Pay by retrieving encrypted payment details from the Google Pay API and submitting them to the POST /v1/payments endpoint with a digitalWallet paymentMethod type. **Prerequisites:** [Authentication](/api/authentication) When a customer uses Google Pay® to pay for goods or services on a merchant’s website or mobile app, use the Google Pay API to retrieve the customer’s encrypted payment details. You can then use our API to run a transaction with the encrypted payment details. ## Integration steps 1. Integrate with the Google Pay API to retrieve encrypted payment details. 2. Integrate with our API to run transactions. 3. Register your integration. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ### Headers To create the header of each GET request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. ```sh curl -H "Content-Type: application/json" -H "Authorization: " ``` To create the header of each POST request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. - **Idempotency-Key:** Include a UUID v4 to make the request idempotent. ```sh curl -H "Content-Type: application/json" -H "Authorization: " -H "Idempotency-Key: " ``` ### Errors If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors). ## Step 1. Integrate with the Google Pay API To integrate with the web version of the Google Pay API, go to [https://developers.google.com/pay/api/web/overview](https://developers.google.com/pay/api/web/overview). During your integration with the Google Pay API, you need the following: - **merchantId** - Merchant ID that Google assigned to you. - **gatewayMerchantId** - Gateway ID, which is usually your processing terminal ID without the last three characters. For example, if your *processingTerminalId* is 9876001, your *gatewayMerchantId* is 9876. - **gateway** – Name of the gateway that processes the transaction. Use the case-sensitive value of `worldnet`. **Note:** Payroc now owns the Worldnet gateway and uses it to process transactions. After you integrate with the Google Pay API, you can send requests to the Google Pay API to retrieve encrypted details that represent the customer’s payment details. Convert the encrypted payment details into hexadecimal format. ## Step 2. Run a sale To run a sale, send a POST request to our Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/payments` In your request, send the following parameters in the paymentMethod object: - **type** – Provide a value of `digitalWallet`. - **serviceProvider** – Provide a value of `google`. - **encryptedData** – Provide the encrypted payment details that you retrieved from the Google Pay API in hexadecimal format. **Note:** For more information about how to run other transaction types with our API, go to our [API Explorer](/api). ### Example request ```json { "channel": "web", "processingTerminalId": "3204001", "operator": "001", "order": { "orderId": "1234567890W", "description": "Card Transaction (WEB) - Sale - digital_wallet (GOOGLE)", "amount": 99, "currency": "USD" }, "paymentMethod": { "type": "digitalWallet", "serviceProvider": "google", "encryptedData": "7b22746f6b656e223a7b227061796d656e7444617461225a7b2276657273696f6e223a2245435f7631222c2264617461225a2275417239476a6470394869492f676f634f4d7068706c666c415a624172557050344f304149797a305666724b4e6c73576a6478523356566b793955746476387145335052523469772b4a5a4944426661786664576568734874514d37416a6c54524b5572587a6564524c367577685257676f387746463157626f4f674546776a64394155306857375944394a496c55715636494672792f4d3157375433314c72366e3044696e4f645454426b6e66686a5339424234694f2f476431505152715946545a48365558517647774169616c576d2f727971784e4348486a755a6e6a424168495269676530756f46645a51304331417733726c684b564c4b6b656c4c2f47682b63566b3248415655706241424566316b4f413445336f34336158537139427a45544d706375634279714d5971305949327945777368566147734133472f5755472b683951517243567630486e536f5a685a6549793748576b6d72416636523563564b57795572323667454d7735767672434c7856557a4e785878594a4c387248584d3970377a37616348795758627347764f392f326c7572506f4b716e386e53543843426c222c227369676e6174757265223a224d494147435371475349623344514548417143414d49414341514578447a414e42676c67686b67425a514d45416745464144434142676b71686b69473977304242774541414b43414d494944356a4343413475674177494241674949614744326d646e4d70773877436759494b6f5a497a6a304541774977656a45754d437747413155454177776c51584277624755675158427762476c6a5958527062323467535735305a5764795958527062323467513045674c5342484d7a456d4d435147413155454377776451584277624755675132567964476c6d61574e6864476c76626942426458526f62334a7064486b78457a415242674e5642416f4d436b46776347786c49456c7559793478437a414a42674e5642415954416c56544d423458445445324d4459774d7a45344d5459304d466f58445449784d4459774d6a45344d5459304d466f77596a456f4d43594741315545417777665a574e6a4c584e7463433169636d39725a58497463326c6e626c3956517a51745530464f52454a50574445554d424947413155454377774c6155395449464e356333526c62584d78457a415242674e5642416f4d436b46776347786c49456c7559793478437a414a42674e5642415954416c56544d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a30444151634451674145676a443971384f63393134674c46445a6d305553356a666971514864624c50677363314c556d65592b4d394f766567614a616a43486b777a3363364f4b70624339712b686b774e46784f68365243624f6c5273536c614f43416845776767494e4d45554743437347415155464277454242446b774e7a4131426767724267454642516377415959706148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a5746705932457a4d444977485159445652304f424259454641496b4d417561377531474d5a656b706c6f706e6b4a78676878464d41774741315564457745422f7751434d414177487759445652306a42426777466f4155492f4a4a78452b54354f386e357354324b47772f6f7276394c6b73776767456442674e5648534145676745554d4949424544434341517747435371475349623359325146415443422f6a4342777759494b77594242515548416749776762594d67624e535a5778705957356a5a5342766269423061476c7a49474e6c636e52705a6d6c6a5958526c49474a35494746756553427759584a306553426863334e316257567a4947466a593256776447467559325567623259676447686c4948526f5a5734675958427762476c6a59574a735a53427a644746755a4746795a4342305a584a7463794268626d5167593239755a476c3061573975637942765a6942316332557349474e6c636e52705a6d6c6a5958526c4948427662476c6a65534268626d51675932567964476c6d61574e6864476c7662694277636d466a64476c6a5a53427a644746305a57316c626e527a4c6a4132426767724267454642516343415259716148523063446f764c33643364793568634842735a53356a623230765932567964476c6d61574e68644756686458526f62334a7064486b764d44514741315564487751744d4373774b61416e6f43574749326830644841364c79396a636d77755958427762475575593239744c3246776347786c59576c6a59544d7559334a734d41344741315564447745422f775145417749486744415042676b71686b694739324e6b42683045416755414d416f4743437147534d343942414d4341306b414d4559434951446148474f75692b583254343452364756704e376d326e456372365436734d6a4f685a354e75536f316567774968414c31612b2f68703838444b4a3073763365543346785763733731786d624c4b442f514a336d576167724a4e4d494943376a4343416e5767417749424167494953573076767a715932706377436759494b6f5a497a6a3045417749775a7a45624d426b4741315545417777535158427762475567556d397664434244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d774868634e4d5451774e5441324d6a4d304e6a4d775768634e4d6a6b774e5441324d6a4d304e6a4d77576a42364d5334774c4159445651514444435642634842735a5342426348427361574e6864476c766269424a626e526c5a334a6864476c7662694244515341744945637a4d5359774a4159445651514c44423142634842735a5342445a584a3061575a7059324630615739754945463164476876636d6c30655445544d424547413155454367774b51584277624755675357356a4c6a454c4d416b474131554542684d4356564d775754415442676371686b6a4f5051494242676771686b6a4f50514d4242774e4341415477467847454764646b68645561586957424233626f674b4c76336e75755465434e2f45755434544e5731575a624e613469304a643244534a4f65376f492f5859587a6f6a4c6472746d634c374936436d452f3152466f3448334d4948304d45594743437347415155464277454242446f774f444132426767724267454642516377415959716148523063446f764c32396a633341755958427762475575593239744c32396a633341774e433168634842735a584a766233526a5957637a4d42304741315564446751574242516a386b6e455435506b3779666d7850596f62442b69752f3075537a415042674e5648524d4241663845425441444151482f4d42384741315564497751594d426141464c7577337146594d3469617049715a3372363936362f61797953724d44634741315564487751774d4334774c4b41716f4369474a6d6830644841364c79396a636d77755958427762475575593239744c3246776347786c636d397664474e685a7a4d7559334a734d41344741315564447745422f77514541774942426a415142676f71686b694739324e6b4267494f424149464144414b42676771686b6a4f5051514441674e6e4144426b416a41367a334b445552615a735962374e634e57796d4b2f394266743251393154614b4f767647636756354374346e346d506562575a2b593155454e6a353370777634434d44497431555168734b4d4664327864387a67376b476639463377734957325754385a796159495362315434656e30626d63756243596b685951615a44776d53485141414d5949426a444343415967434151457767595977656a45754d437747413155454177776c51584277624755675158427762476c6a5958527062323467535735305a5764795958527062323467513045674c5342484d7a456d4d435147413155454377776451584277624755675132567964476c6d61574e6864476c76626942426458526f62334a7064486b78457a415242674e5642416f4d436b46776347786c49456c7559793478437a414a42674e5642415954416c56544167686f5950615a3263796e447a414e42676c67686b67425a514d4541674546414b43426c54415942676b71686b69473977304243514d784377594a4b6f5a496876634e415163424d42774743537147534962334451454a42544550467730784f44417a4d6a6b784d7a4d324d4456614d436f4743537147534962334451454a4e4445644d4273774451594a59495a49415755444241494242514368436759494b6f5a497a6a3045417749774c77594a4b6f5a496876634e41516b454d5349454944677a61314873582b6f334d4c6e2f6176674a2f6141753877737a426746746d397a6e433144506e426a314d416f4743437147534d343942414d43424563775251496841495870622b4c4f2f784f34497953773743697765623737426a56456d67472f5a6562317a416f7544354d6d416942566e4672327759335932462f72444867765a3137516443634b70414f782f42615773474c4a756b3657574141414141414141413d3d222c22686561646572223a7b22657068656d6572616c5075626c69634b6579223a224d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741454c3846326b3952584c56746c5979564353624b79694e394337526669676e52386f504a38774e4c6f575232334e317a424a4e7153364e38346e634e7a347549384b657576446147526d6c435445396756346f776d39413d3d222c227075626c69634b657948617368223a226f587657624266474c43494d6c4158776f473553716f6747633930516f6f5657636f5a646e3379555042303d222c227472616e73616374696f6e4964223a2235333332356537653336396163313364373461313833623161653839626236386362636162383330646263633163363861373632383339616639646434616331227d7d2c227061796d656e744d6574686f64223a7b22646973706c61794e616d65223a22566973612030343932222c226e6574776f726b223a2256697361222c2274797065223a226465626974227d2c227472616e73616374696f6e4964656e746966696572223a2235333332354537453336394143313344373441313833423141453839424236384342434142383330444243433143363841373632383339414639444434414331227d7d" } } ``` ## Step 3. Register your integration To complete your integration and run live transactions with Google Pay: 1. Contact Google to register your integration and website. 2. Contact our Integrations Team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). # Payroc Cloud Source: https://docs.payroc.com/guides/payments/payroc-cloud Explore guides for configuring your payment device, running a sale, and extending your Payroc Cloud integration with refunds and signature capture. Payroc Cloud is our semi-integrated solution that you can use to send instructions to a payment device without the need for a direct connection between the Point of Sale (POS) and the payment device. An instruction contains information that the device uses to perform actions, for example, if the merchant wants to run a sale, the instruction includes the amount of the sale. There are three Payroc Cloud solutions that you can integrate with, depending on your merchants' requirements: - Android payment device with the Payroc App and your POS app. - Android payment device with the Payroc App, with your POS system on a different device. - Non-Android payment device, with your POS system on a different device. We support Ingenico payment devices and ID TECH payment devices. ## Your integration journey 1. Configure your payment device:- [Android (POS on the same device)](/guides/payments/payroc-cloud/device-setup/android-same-device) - [Android (POS on a separate device)](/guides/payments/payroc-cloud/device-setup/android-diff-device) - [Ingenico](/guides/payments/payroc-cloud/device-setup/ingenico) - [ID TECH](/guides/payments/payroc-cloud/device-setup/idtech) 2. Use our API to send instructions to [run a sale](/guides/payments/payroc-cloud/run-sale). 3. (Optional) Test your integration with our [Payroc Cloud Simulator](/knowledge/testing/payroc-cloud-simulator). ## Extend your integration After you integrate with Payroc Cloud to run a sale, you can extend your integration to include the following: - Run an unreferenced refund - Capture a signature For more information about how to extend your integration, go to [Extend your integration](/guides/payments/payroc-cloud/extend-your-integration). # Device setup Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup Configure ID TECH and Ingenico devices. Configure ID TECH and Ingenico devices. - [ID TECH - Linux](/guides/payments/payroc-cloud/device-setup/idtech-linux) - [ID TECH - Windows](/guides/payments/payroc-cloud/device-setup/idtech-windows) - [Ingenico - Linux](/guides/payments/payroc-cloud/device-setup/ingenico-linux) - [Ingenico - Windows](/guides/payments/payroc-cloud/device-setup/ingenico-windows) - [Android (POS on a different device)](/guides/payments/payroc-cloud/device-setup/android-diff-device) - [Android (POS on the same device)](/guides/payments/payroc-cloud/device-setup/android-same-device) - [ID TECH](/guides/payments/payroc-cloud/device-setup/idtech) - [Ingenico](/guides/payments/payroc-cloud/device-setup/ingenico) # ID TECH - Linux Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup/idtech-linux Set up the Payroc Cloud middleware on a Linux host machine so it can connect to your ID TECH card reader and communicate with our gateway. In this configuration, your ID TECH device communicates with your Linux host machine through the Payroc Cloud middleware. To ensure your POS can communicate with the ID TECH device, you need to configure your Linux host machine. ## Integration steps 1. Prepare your host machine for configuration. 2. Configure the native libraries. 3. Configure the payconfig.xml file. 4. Run the middleware. ## Before you begin Your host machine must have Java 8 or later installed. ## Step 1. Prepare your host machine for configuration To download the Payroc Cloud middleware and connect your payment device to your host machine, complete the following steps: 1. Connect your payment device to a USB port on your host machine. 2. Go to our [Github repository](https://github.com/payroc/payroc-pos-sdks), and then download Payroc Cloud middleware from the release files.- If your host machine has Java 8 up to Java 16 installed, download version 1.6.76. - If your host machine has Java 17 or later installed, download version 1.6.78+. 3. Extract the files from the zipped folder. ## Step 2. Configure native libraries You need to copy the libraries that match your operating system into the middleware root folder so the middleware can load them when it starts. To do this, complete the following steps: 1. Open the folder that you extracted the Payroc Cloud middleware to. 2. Locate the folder that contains the library that you want to use, for example, to use 64-bit Linux with ID TECH, go to libs \> idtech \> linux-native-64. 3. Copy the contents of the folder into the root folder. 4. Create a new file in `/etc/udev/rules.d` and name the file `usb.rules`. 5. Add the following contents to the file: `SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"0acd\", MODE=\"0666\"`. 6. Create a new file in `/etc/ld.so.conf.d` and name the file `idtech_libs.conf`. 7. In the idtech\_libs.conf file, add the path to the ID TECH middleware package that contains the libraries for your Linux machine. 8. Run the following command to load the libraries: `$ sudo ldconfig`. ## Step 3. Configure the payconfig.xml file The payconfig.xml file defines how the middleware communicates with your ID TECH device and our gateway, including: - Which Payroc account and integration you are working with, for example, you send your API key to authenticate your requests. - Which payment device the middleware is communicating with, for example, you send the value for the port that your ID TECH device is connected to on your host machine. - How your ID TECH device should behave in transactions, for example, you indicate if your device should accept keyed transaction details. Use the following values to configure your payconfig.xml file: | Field | Value | | --- | --- | | apiKey | Enter your Payroc App API key. | | integrationId | Enter your integrationId. | | terminalId | Enter your processingTerminalId. | | deviceType | Indicates the type of payment device you are using. Enter `IDTECH`. | | sdkMode | Indicates the SDK mode. Enter one of the following values: – `LIVE` - Production mode – `TEST` - Test environment – `DEV` - Developer mode | | logLevel | Indicates the logging level for the SDK. Enter one of the following values: – `LEVEL_FUL` - Verbose – `LEVEL_INFO` - Informational messages – `LEVEL_ERROR` - Errors only – `LEVEL_NONE` - Disables logging | | portName | For IDTech devices, do not edit this value. | | emvType | Indicates the EMV processing type you want the device to support. Enter one of the following values: – `STANDARD` - Standard EMV processing. – `QUICK_CHIP` - Faster EMV transaction flow. | | inputMethod | Indicates the EMV processing type you want the device to support. Enter one of the following values: – `SWIPE_OR_INSERT_OR_TAP` - Cardholder can swipe, insert, or tap their card. – `SWIPE_OR_INSERT` - Cardholder can swipe or insert their card. | | debitAIDPreference | For IDTech devices, do not edit this value. | | disableOnDeviceSignature | For IDTech devices, do not edit this value. | | enableDeviceLogs | Indicates whether the device collects debug logs. Enter one of the following values: – `true` - Device collects debug logs. – `false` - Device does not collect debug logs. | ## Step 4. Run the middleware To run the middleware, complete the following steps: 1. Run the following command to make the start.sh file executable: `$chmod +x start-idtech.sh` 2. Run the following script to start the middleware: `$ ./start-idtech.sh` This establishes communication between your host machine, your ID TECH device, and our gateway. After the middleware starts, the logs display the serial number of your ID TECH device. You need this serial number to send transaction requests so the gateway can route the instructions to the correct device. ## Next steps To program your POS to send instructions to your ID TECH device, go to [Run a sale](/guides/payments/payroc-cloud/run-sale). # ID TECH - Windows Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup/idtech-windows Set up the Payroc Cloud middleware on a Windows host machine so it can connect to your ID TECH card reader and communicate with our gateway. In this configuration, your ID TECH device communicates with your Windows host machine through the Payroc Cloud middleware. To ensure your POS can communicate with the ID TECH device, you need to configure your Windows host machine. ## Integration steps 1. Prepare your host machine for configuration. 2. Configure the native libraries. 3. Configure the payconfig.xml file. 4. Run the middleware. ## Before you begin Your host machine must have Java 8 or later installed. If you use a Windows 32-bit host machine, make sure you have installed 32-bit Java and configured its path. ## Step 1. Prepare your host machine for configuration To download the Payroc Cloud middleware and connect the payment device to the host machine, complete the following steps: 1. Connect your payment device to a USB port on your host machine. 2. Go to our [Github repository](https://github.com/payroc/payroc-pos-sdks) and download Payroc Cloud middleware from the release files.- If your host machine has Java 8 up to Java 16 installed, download version 1.6.76. - If your host machine has Java 17 or later installed, download version 1.6.78+. 3. Extract the files from the zipped folder. ## Step 2. Configure native libraries You need to copy the libraries that match your operating system into the middleware root folder so the middleware can load them when it starts. To do this, complete the following steps: 1. Open the folder that you extracted the Payroc Cloud Middleware to. 2. Locate the folder that contains the library that you want to use, for example, to use 64-bit Windows with ID TECH, go to libs \> idtech \> win-native-64. 3. Copy the contents of the folder into the root folder. ## Step 3. Configure the payconfig.xml file The payconfig.xml file defines how the middleware communicates with the ID TECH device and our gateway, including: - Which Payroc account and integration you are working with, for example, you send your API key to authenticate your requests. - Which payment device the middleware is communicating with, for example, you send the value for the port that the ID TECH device is connected to on the host machine. - How the ID TECH device should behave in transactions, for example, you indicate if the device should accept keyed transaction details. Use the following values to configure your payconfig.xml file: | Field | Value | | --- | --- | | apiKey | Enter your Payroc App API key. | | integrationId | Enter your integrationId. | | terminalId | Enter your processingTerminalId. | | deviceType | Indicates the type of payment device you are using. Enter `IDTECH`. | | sdkMode | Indicates the SDK mode. Enter one of the following values: – `LIVE` - Production mode – `TEST` - Test environment – `DEV` - Developer mode | | logLevel | Indicates the logging level for the SDK. Enter one of the following values: – `LEVEL_FUL` - Verbose – `LEVEL_INFO` - Informational messages – `LEVEL_ERROR` - Errors only – `LEVEL_NONE` - Disables logging | | portName | For IDTech devices, do not edit this value. | | emvType | Indicates the EMV processing type you want the device to support. Enter one of the following values: – `STANDARD` - Standard EMV processing. – `QUICK_CHIP` - Faster EMV transaction flow. | | inputMethod | Indicates the EMV processing type you want the device to support. Enter one of the following values: – `SWIPE_OR_INSERT_OR_TAP` - Cardholder can swipe, insert, or tap their card. – `SWIPE_OR_INSERT` - Cardholder can swipe or insert their card. | | debitAIDPreference | For IDTech devices, do not edit this value. | | disableOnDeviceSignature | For IDTech devices, do not edit this value. | | enableDeviceLogs | Indicates whether the device collects debug logs. Enter one of the following values: – `true` - Device collects debug logs. – `false` - Device does not collect debug logs. | ## Step 4. Run the middleware To run the middleware, double-click the start-idtech batch file in the root folder. This establishes communication between your host machine, your ID TECH device, and our gateway. After the middleware starts, the logs display the serial number of your ID TECH device. You need this serial number to send transaction requests so that the gateway can route the instructions to the correct device. ## Next steps To program your POS to send instructions to your ID TECH device, go to [Run a sale](/guides/payments/payroc-cloud/run-sale). # Ingenico - Linux Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup/ingenico-linux Set up the Payroc Cloud middleware on a Linux host machine so it can connect to your Ingenico card reader and communicate with our gateway. In this configuration, your Ingenico device communicates with your Linux host machine through the Payroc Cloud middleware. To ensure your POS can communicate with your Ingenico device, you need to configure your Linux host machine. ## Integration steps 1. Prepare your host machine for configuration. 2. Configure the native libraries. 3. Configure the payconfig.xml file. 4. Run the middleware. ## Before you begin Your host machine must have Java 8 or later installed. ## Step 1. Prepare your host machine for configuration To download the Payroc Cloud middleware and connect your payment device to your host machine, complete the following steps: 1. Connect your payment device to a USB port on your host machine. 2. Go to our [Github repository](https://github.com/payroc/payroc-pos-sdks), and then download Payroc Cloud middleware from the release files.- If your host machine has Java 8 up to Java 16 installed, download version 1.6.76. - If your host machine has Java 17 or later installed, download version 1.6.78+. 3. Extract the files from the zipped folder. ## Step 2. Configure native libraries You need to copy the libraries that match your operating system into the middleware root folder so the middleware can load them when it starts. To do this, complete the following steps: 1. Open the folder that you extracted the Payroc Cloud middleware to. 2. Go to the folder that contains the library that you want to use, for example, to use 64-bit Linux with Ingenico, go to libs \> ingenico \> nativeLibsLinux \> 64\_bit. 3. Copy the contents of the folder into the root folder. 4. Create a new file in /etc/udev/rules.d and name it `usb.rules`. 5. Add the following contents to the file: `SUBSYSTEM==\"usb\", MODE=\"0666\"`. ## Step 3. Configure the payconfig.xml file The payconfig.xml file defines how the middleware communicates with your Ingenico device and our gateway, including: - Which Payroc account and integration you are working with, for example, you send your API key to authenticate your requests. - Which payment device the middleware is communicating with, for example, you send the value for the port that your Ingenico device is connected to on your host machine. - How your Ingenico device should behave in transactions, for example, you indicate if the device should accept keyed transaction details. Use the following values to configure your payconfig.xml file: | Field | Value | | --- | --- | | apiKey | Enter your Payroc App API key. | | integrationId | Enter your integrationId. | | terminalId | Enter your processingTerminalId. | | deviceType | Indicates the type of payment device you are using. Enter `INGENICO`. | | sdkMode | Indicates the SDK mode. Enter one of the following values: – `LIVE` - Production mode – `TEST` - Test environment – `DEV` - Developer mode | | logLevel | Indicates the logging level for the SDK. Enter one of the following values: – `LEVEL_FUL` - Verbose – `LEVEL_INFO` - Informational messages – `LEVEL_ERROR` - Errors only – `LEVEL_NONE` - Disables logging | | portName | Indicates the Serial/COM port name of the USB port that you connected the Ingenico device to. | | emvType | Indicates the EMV processing type you want the device to support. Enter one of the following values: – `STANDARD` - Standard EMV processing. – `QUICK_CHIP` - Faster EMV transaction flow. | | inputMethod | Indicates the EMV processing type you want the device to support. Enter one of the following values: – `SWIPE_OR_INSERT_OR_TAP_OR_KEYED` - Cardholder can swipe, insert, tap, or key in their card number manually. – `SWIPE_OR_INSERT_OR_TAP` - Cardholder can swipe, insert, or tap their card. – `SWIPE_OR_INSERT` - Cardholder can swipe or insert their card. | | debitAIDPreference | Indicates the Debit Application Identifier (AID). Applies to dual-branded cards. The value must be one of the following: –`PREFER_GLOBAL_DEBIT_AID` - Prioritize global AID. –`PREFER_US_COMMON_DEBIT_AID` - Prioritize U.S. debit AID. –`APPLICATION_SELECTION` - Cardholder can choose between debit or credit. | | disableOnDeviceSignature | For Ingenico 5000 and 7000 devices, enter one of the following values: –`true` - Device does not support cardholder signatures. –`false` - Device supports cardholder signatures. For other Ingenico devices, do not edit this value. | | enableDeviceLogs | Indicates whether the device collects debug logs. Enter one of the following values: – `true` - Device collects debug logs. – `false` - Device does not collect debug logs. | ## Step 4. Run the middleware To run the middleware, complete the following steps: 1. Run the following command to make the start.sh file executable: `$chmod +x start-ingenico.sh` 2. Run the following script to start the middleware: `$ ./start-ingenico.sh` This establishes communication between your host machine, your Ingenico device, and our gateway. After the middleware starts, the logs display the serial number of your Ingenico device. You need this serial number to send transaction requests so the gateway can route the instructions to the correct device. ## Next steps To program your POS to send instructions to your Ingenico device, go to [Run a sale](/guides/payments/payroc-cloud/run-sale). # Ingenico - Windows Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup/ingenico-windows Set up the Payroc Cloud middleware on a Windows host machine so it can connect to your Ingenico card reader and communicate with our gateway. In this configuration, your Ingenico device communicates with your Windows host machine through the Payroc Cloud middleware. To ensure your POS can communicate with your Ingenico device, you need to configure your Windows host machine. ### Integration steps 1. Prepare your host machine for configuration. 2. Configure the native libraries. 3. Configure the payconfig.xml file. 4. Run the middleware. ### Before you begin Your host machine must have Java 8 or later installed. If you use a Windows 32-bit host machine, make sure you have installed 32-bit Java and configured its path. ## Step 1. Prepare your host machine for configuration To download the Payroc Cloud middleware and connect your payment device to your host machine, complete the following steps: 1. Connect your payment device to a USB port on your host machine. 2. Go to our [Github repository](https://github.com/payroc/payroc-pos-sdks) and download Payroc Cloud middleware from the release files.- If your host machine has Java 8 up to Java 16 installed, download version 1.6.76. - If your host machine has Java 17 or later installed, download version 1.6.78+. 3. Extract the files from the zipped folder. ## Step 2. Configure native libraries You need to copy the libraries that match your operating system into the middleware root folder so the middleware can load them when it starts. To do this, complete the following steps: 1. Open the folder that you extracted the Payroc Cloud middleware to. 2. Go to the folder that contains the library that you want to use, for example, to use 64-bit Windows with Ingenico, go to libs \> ingenico \> nativeLibsWindows \> 64bit. 3. Copy the contents of the folder into the root folder. ## Step 3. Configure the payconfig.xml file The payconfig.xml file defines how the middleware communicates with your Ingenico device and our gateway, including: - Which Payroc account and integration you are working with, for example, you send your API key to authenticate your requests. - Which payment device the middleware is communicating with, for example, you send the value for the port that your Ingenico device is connected to on your host machine. - How your Ingenico device should behave in transactions, for example, you indicate if the device should accept keyed transaction details. Use the following values to configure your payconfig.xml file: | Field | Value | | --- | --- | | apiKey | Enter your Payroc App API key. | | integrationId | Enter your integrationId. | | terminalId | Enter your processingTerminalId. | | deviceType | Indicates the type of payment device you are using. Enter `INGENICO`. | | sdkMode | Indicates the SDK mode. Enter one of the following values: – `LIVE` - Production mode – `TEST` - Test environment – `DEV` - Developer mode | | logLevel | Indicates the logging level for the SDK. Enter one of the following values: – `LEVEL_FUL` - Verbose – `LEVEL_INFO` - Informational messages – `LEVEL_ERROR` - Errors only – `LEVEL_NONE` - Disables logging | | portName | Indicates the Serial/COM port name of the USB port that you connected the Ingenico device to. | | emvType | Indicates the EMV processing type you want the device to support. Enter one of the following values: – `STANDARD` - Standard EMV processing. – `QUICK_CHIP` - Faster EMV transaction flow. | | inputMethod | Indicates the EMV processing type you want the device to support. Enter one of the following values: – `SWIPE_OR_INSERT_OR_TAP_OR_KEYED` - Cardholder can swipe, insert, tap, or key in their card number manually. – `SWIPE_OR_INSERT_OR_TAP` - Cardholder can swipe, insert, or tap their card. – `SWIPE_OR_INSERT` - Cardholder can swipe or insert their card. | | debitAIDPreference | Indicates the Debit Application Identifier (AID). Applies to dual-branded cards. The value must be one of the following: –`PREFER_GLOBAL_DEBIT_AID` - Prioritize global AID. –`PREFER_US_COMMON_DEBIT_AID` - Prioritize U.S. debit AID. –`APPLICATION_SELECTION` - Cardholder can choose between debit or credit. | | disableOnDeviceSignature | For Ingenico 5000 and 7000 devices, enter one of the following values: –`true` - Device does not support cardholder signatures. –`false` - Device supports cardholder signatures. For other Ingenico devices, do not edit this value. | | enableDeviceLogs | Indicates whether the device collects debug logs. Enter one of the following values: – `true` - Device collects debug logs. – `false` - Device does not collect debug logs. | ## Step 4. Run the middleware To run the middleware, double-click the start-ingenico batch file in the root folder. This establishes communication between your host machine, your Ingenico device, and our gateway. After the middleware starts, the logs display the serial number of your Ingenico device. You need this serial number to send transaction requests so the gateway can route the instructions to the correct device. ## Next steps To program your POS to send instructions to your Ingenico device, go to [Run a sale](/guides/payments/payroc-cloud/run-sale). # Android (POS on a different device) Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup/android-diff-device Connect your POS to an Android payment device running the Payroc App over the internet, so the app can process payments while your POS handles checkout. Use our Android (POS on a separate device) configuration to connect your POS to an Android payment device that is running the Payroc App. Your POS and the payment device don't need to be on the same network or in the same location, but they must be connected to the internet. Your POS system manages the checkout experience and sends instructions to the payment device, while the Payroc App processes the payment. ## How it works The following diagram describes the flow of a transaction between your POS, our gateway, and the payment device. ```mermaid sequenceDiagram participant POS as POS participant GW as Gateway participant D as Device rect rgba(0, 81, 194, 0.4) Note over POS,D: Initiate a transaction POS->>GW: 1. Create instruction GW->>D: 2. Send instruction to device D-->>GW: 3. Confirm delivery of instruction GW-->>POS: 4. Confirm that the device accepted the instruction end rect rgba(0, 224, 184, 0.3) Note over POS,D: Run the transaction Note over D: 1. Device captures the card information D->>GW: 2. Send transaction details Note over GW: 3. Gateway sends transaction details to the processor Note over GW: 4. Processor returns a response for the transaction GW-->>D: 5. Send transaction response end rect rgba(0, 81, 194, 0.4) Note over POS,D: Get a link to the transaction POS->>GW: 1. Get the status of the instruction GW-->>POS: 2. Return instruction with a link to the transaction end rect rgba(0, 224, 184, 0.3) Note over POS,D: View the transaction POS->>GW: 1. View details of the transaction GW-->>POS: 2. Return details of the transaction end ``` **Initiate a transaction** 1. Your POS sends an instruction to our gateway. 2. Our gateway passes the instruction to the payment device. 3. The payment device confirms that it has received the instruction. 4. Our gateway sends a response to your POS that contains an identifier for the instruction. **Run the transaction** 1. The payment device captures the card details. 2. The payment device sends the transaction details to our gateway. 3. Our gateway sends the transaction details to the processor. 4. The processor sends a response to our gateway. 5. Our gateway sends the response to the payment device. **Get a link to the transaction** 1. Your POS sends a request to our gateway to check the status of the instruction. 2. Our gateway sends the response to your POS that contains a HATEOAS link to view the transaction. **View the transaction** 1. Your POS sends a request to our gateway to view the details of the transaction. 2. Our gateway sends a response to your POS. The response contains details about the transaction. ## Integration journey 1. Use our API to [send sale instructions](/guides/payments/payroc-cloud/run-sale) to the payment device. 2. Test your integration with our [Payroc Cloud Simulator](/knowledge/testing/payroc-cloud-simulator). # Android (POS on the same device) Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup/android-same-device Configure your Android payment device to run your POS app and the Payroc App together, including permissions, app switching, and Paxstore upload. Use our Android (POS on same device) configuration to run your POS app and our Payroc App on the same payment device. Your POS app manages the checkout experience, while our Payroc App securely processes the payment on the device. Because both apps run on one device, your integration must manage how they interact. This includes preparing the Payroc App to receive payment instructions and switching between the two apps when a transaction is in progress. ## How it works The following diagram describes the flow of a transaction between your POS app, our gateway, and the Payroc App. ```mermaid sequenceDiagram participant POS as POS app participant GW as Gateway participant PA as Payroc app rect rgba(0, 81, 194, 0.4) Note over POS,PA: Initiate a transaction POS->>GW: 1. Create instruction GW->>PA: 2. Send instruction to the Payroc app PA-->>GW: 3. Confirm delivery of instruction GW-->>POS: 4. Confirm that the Payroc app accepted the instruction Note over POS: 5. Switch to the Payroc app end rect rgba(0, 224, 184, 0.3) Note over POS,PA: Run the transaction Note over PA: 1. Payroc app captures the card information PA->>GW: 2. Send transaction details Note over GW: 3. Gateway sends transaction details to the processor Note over GW: 4. Processor returns a response for the transaction GW-->>PA: 5. Send transaction response end rect rgba(0, 81, 194, 0.4) Note over POS,PA: Get a link to the transaction POS->>GW: 1. Get the status of the instruction GW-->>POS: 2. Return instruction with a link to the transaction end rect rgba(0, 224, 184, 0.3) Note over POS,PA: View the transaction POS->>GW: 1. View details of the transaction GW-->>POS: 2. Return details of the transaction Note over POS: 3. Switch to POS app Note over POS: 4. Display the receipt end ``` **Initiate a transaction** 1. Your POS App sends an instruction to our gateway. 2. Our gateway passes the instruction to the Payroc App. 3. The Payroc App confirms that it has received the instruction. 4. Our gateway sends a response to your POS app that contains an identifier for the instruction. 5. You switch from your POS app to the Payroc App. **Run the transaction** 1. The Payroc App captures the card details. 2. The Payroc App sends the transaction details to our gateway. 3. Our gateway sends the transaction details to the processor. 4. The processor sends a response to our gateway. 5. Our gateway sends the response to the Payroc App. **Get a link to the transaction** 1. Your POS App sends a request to our gateway to check the status of the instruction. 2. Our gateway sends the response to your POS app that contains a HATEOAS link to view the transaction. **View the transaction** 1. Your POS App sends a request to our gateway to view the details of the transaction. 2. Our gateway sends a response to your POS App that contains details about the transaction. 3. You switch from the Payroc App to your POS App. 4. Your POS App displays the receipt. ## Integration journey 1. [Configure the payment device.](#configure-the-payment-device) 2. Use our API to [send sale instructions](/guides/payments/payroc-cloud/run-sale) to the payment device. 3. Test your integration with our [Payroc Cloud Simulator](/knowledge/testing/payroc-cloud-simulator). ## Configure the payment device In this configuration, your POS App and the Payroc App are installed on the same Android payment device. To ensure that both Apps work together correctly, you must configure the device and your POS App to support background services and App switching. ## Integration steps 1. Adjust the permissions on the payment device. 2. Update the Payroc App. 3. Configure your activity to run a single task. 4. (Optional) Set the Payroc App to start first. 5. Handle App switching. 6. Upload your POS App to the Paxstore. ## Step 1. Adjust the permissions on the payment device **Note:** This step applies only to Android 10 devices. To switch back to your POS App from the Payroc App, you need to request the overlay permission at runtime. To request the overlay permission, adjust the following permission in your Android manifest: ```xml ``` **Example code** ```kotlin private fun requestPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { val intent = Intent( Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:$packageName") ) startActivityForResult(intent, ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE) } } ``` ## Step 2. Update the Payroc App To confirm that your Payroc App is up to date, open the Payroc App from the home screen. After you open the Payroc App, it downloads the latest version and settings. **Note:** The Payroc App doesn't display the navigation bar. To view the navigation bar, tap the Payroc logo three times. ## Step 3. Configure your activity to run a single task To return to the same activity instance when you switch back to your POS App, configure the launch mode to `singleTask`, and then add the following code to your Android manifest: ```xml ``` ## Step 4. (Optional) Set the Payroc App to start first If you want to start your POS App when the device turns on, you need to make sure that the Payroc App starts first. To set the Payroc App to start first, set the priority of the intent filter in the boot receiver to `0`. ```xml ``` ## Step 5. Handle App switching Before you can run transactions, you need to: - Start the Payroc App service. - Handle switching from your POS App to the Payroc App. - Handle switching from the Payroc App to your POS App. ### Start the Payroc App service Before you send instructions to the Payroc App, run a command to start the Payroc App service on the payment device. If you start this service first, the Payroc App runs in the background before you send it instructions. To start the Payroc App service, use the following package name: | Environment | Package name | | --- | --- | | Test | com.payroc.test | | Production | com.payroc | ```xml val payrocServiceIntent = Intent() payrocServiceIntent.component = ComponentName(PACKAGE_NAME, "wn.pax.mitc.service.PBCService") if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { applicationContext.startForegroundService(payrocServiceIntent) } else { applicationContext.startService(payrocServiceIntent) } ``` ### Switch from your POS App to the Payroc App After you receive a response for a payment instruction with a status of `inProgress`, switch to the Payroc App on the payment device. ```xml val payrocAppIntent = Intent() payrocAppIntent.component = ComponentName(PACKAGE_NAME, "wn.pax.mitc.MITCActivity") payrocAppIntent.flags = FLAG_ACTIVITY_NEW_TASK applicationContext.startActivity(payrocAppIntent) ``` ### Switch from the Payroc App to your POS App After your POS App receives the details of a transaction or the transaction is canceled, switch back to your POS App. ```xml val launchIntent = packageManager.getLaunchIntentForPackage(applicationContext.packageName) applicationContext.startActivity(launchIntent) ``` ## Step 6. Upload your POS App to the Paxstore After you create your POS App, upload it to the Paxstore. We recommend that you become a sub-reseller on the Payroc marketplace on the Paxstore. For more information about how to set up your sub-reseller account and upload your app, contact your integration specialist. ## Next steps Now that you have configured your payment device, program your POS app to submit sale instructions. For more information about how to submit sale instructions, go to [Run a sale](/guides/payments/payroc-cloud/run-sale). # ID TECH Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup/idtech Connect an ID TECH card reader to your POS through the Payroc Cloud middleware, choosing the setup guide for your Windows or Linux host machine. You can use Payroc Cloud to send instructions from your POS to an ID TECH payment device that doesn't use an Android operating system. Your POS manages the checkout experience, while your ID TECH device captures the payment details. To enable communication between your POS, your payment device, and our gateway, you need to download the Payroc Cloud middleware. The middleware runs on a host machine with a Windows or Linux operating system, and it connects to only one payment device at a time by USB. ## How it works ```mermaid sequenceDiagram participant POS as POS participant GW as Gateway participant MW as Middleware participant D as Device rect rgba(0, 81, 194, 0.4) Note over POS,D: Initiate a transaction POS->>GW: 1. Create instruction GW->>MW: 2. Send instruction to middleware MW->>D: 3. Start payment on device MW-->>GW: 4. Confirm delivery of instruction GW-->>POS: 5. Return identifier for the instruction end rect rgba(0, 224, 184, 0.3) Note over POS,D: Run the transaction Note over D: 1. Device captures the transaction details D->>MW: 2. Send transaction details MW->>GW: 3. Send transaction details Note over GW: 4. Gateway sends transaction details to the processor Note over GW: 5. Processor returns a response for the transaction GW-->>MW: 6. Send transaction response MW-->>D: 7. Send transaction response end rect rgba(0, 81, 194, 0.4) Note over POS,D: Get a link to the transaction POS->>GW: 1. Get the status of the instruction GW-->>POS: 2. Return instruction with a link to the transaction end rect rgba(0, 224, 184, 0.3) Note over POS,D: View the transaction POS->>GW: 1. View details of the transaction GW-->>POS: 2. Return details of the transaction end ``` **Initiate a transaction** 1. Your POS sends an instruction to our gateway. 2. Our gateway sends the instruction to the middleware. 3. The middleware starts the payment on your payment device. 4. The middleware confirms it received the instruction by sending a response to our gateway. 5. Our gateway returns an identifier to your POS for the payment instruction. **Run the transaction** 1. Your payment device captures the transaction details. 2. Your payment device sends the transaction details to the middleware. 3. The middleware sends the transaction details to our gateway. 4. Our gateway sends the transaction details to the processor. 5. The processor returns a response to our gateway. 6. Our gateway returns a response to the middleware. 7. The middleware sends the response to your payment device. **Get a link to the transaction** 1. Your POS sends a request to our gateway to check the status of the instruction. 2. Our gateway sends the response to the POS that contains a HATEOAS link to view the transaction. **View the transaction** 1. Your POS sends a request to our gateway to view the details of the transaction. 2. Our gateway sends a response to your POS that contains the details about the transaction. ## Integration steps To configure Payroc Cloud on an ID TECH device, complete the following steps: 1. Prepare your host machine for configuration. 2. Configure native libraries. 3. Configure the payconfig.xml file. 4. Run the middleware. We have two guides to help you configure your ID TECH device, depending on the operating system that you use: - [Configure an ID TECH device for a Windows host machine](/guides/payments/payroc-cloud/device-setup/idtech-windows) - [Configure an ID TECH device for a Linux host machine](/guides/payments/payroc-cloud/device-setup/idtech-linux) After you configure your device, program your POS to submit sale instructions to the device. For more information about how to submit sale instructions, go to [Run a sale](/guides/payments/payroc-cloud/run-sale). # Ingenico Source: https://docs.payroc.com/guides/payments/payroc-cloud/device-setup/ingenico Connect an Ingenico card reader to your POS through the Payroc Cloud middleware, choosing the setup guide for your Windows or Linux host machine. You can use Payroc Cloud to send instructions from a POS to an Ingenico payment device that doesn't use an Android operating system. Your POS manages the checkout experience, while your Ingenico device captures the payment details. To enable communication between your POS, your payment device, and our gateway, you need to download the Payroc Cloud middleware. The middleware runs on a host machine with a Windows or Linux operating system, and it connects to only one payment device at a time by USB. ## How it works The following diagram describes the flow of a transaction between your POS, the gateway, the middleware, and your payment device. ```mermaid sequenceDiagram participant POS as POS participant GW as Gateway participant MW as Middleware participant D as Device rect rgba(0, 81, 194, 0.4) Note over POS,D: Initiate a transaction POS->>GW: 1. Create instruction GW->>MW: 2. Send instruction to middleware MW->>D: 3. Start payment on device MW-->>GW: 4. Confirm delivery of instruction GW-->>POS: 5. Return identifier for the instruction end rect rgba(0, 224, 184, 0.3) Note over POS,D: Run the transaction Note over D: 1. Device captures the transaction details D->>MW: 2. Send transaction details MW->>GW: 3. Send transaction details Note over GW: 4. Gateway sends transaction details to the processor Note over GW: 5. Processor returns a response for the transaction GW-->>MW: 6. Send transaction response MW-->>D: 7. Send transaction response end rect rgba(0, 81, 194, 0.4) Note over POS,D: Get a link to the transaction POS->>GW: 1. Get the status of the instruction GW-->>POS: 2. Return instruction with a link to the transaction end rect rgba(0, 224, 184, 0.3) Note over POS,D: View the transaction POS->>GW: 1. View details of the transaction GW-->>POS: 2. Return details of the transaction end ``` **Initiate a transaction** 1. Your POS sends an instruction to our gateway. 2. Our gateway sends the instruction to the middleware. 3. The middleware starts the payment on your payment device. 4. The middleware confirms it received the instruction by sending a response to our gateway. 5. Our gateway returns an identifier to your POS for the payment instruction. **Run the transaction** 1. Your payment device captures the transaction details. 2. Your payment device sends the transaction details to the middleware. 3. The middleware sends the transaction details to our gateway. 4. Our gateway sends the transaction details to the processor. 5. The processor returns a response to our gateway. 6. Our gateway returns a response to the middleware. 7. The middleware sends the response to your payment device. **Get a link to the transaction** 1. Your POS sends a request to our gateway to check the status of the instruction. 2. Our gateway sends the response to your POS that contains a HATEOAS link to view the transaction. **View the transaction** 1. Your POS sends a request to our gateway to view the details of the transaction. 2. Our gateway sends a response to your POS that contains the details of the transaction. ## Integration steps To configure Payroc Cloud on an Ingenico device, complete the following steps: 1. Prepare your host machine for configuration. 2. Configure native libraries. 3. Configure the payconfig.xml file. 4. Run the middleware. We have two guides to help you configure your Ingenico device, depending on the operating system that you use: - [Configure an Ingenico device for a Windows host machine](/guides/payments/payroc-cloud/device-setup/ingenico-windows) - [Configure an Ingenico device for a Linux host machine](/guides/payments/payroc-cloud/device-setup/ingenico-linux) After you configure your device, program your POS to submit sale instructions to the device. For more information about how to submit sale instructions, go to [Run a sale](/guides/payments/payroc-cloud/run-sale). # Capture a signature Source: https://docs.payroc.com/guides/payments/payroc-cloud/capture-signature Capture a cardholder's signature on a Payroc Cloud device by submitting a signature instruction, polling for its status, and retrieving the captured signature image. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). After you configure a device for Payroc Cloud, program your POS to use the Submit Signature Instruction method to send a signature instruction to the payment device. To capture a cardholder’s signature, complete the following: 1. Submit a signature instruction to the device. 2. View the status of the signature instruction. 3. View the signature. You can also cancel a signature instruction if it hasn’t yet completed. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Submit a signature instruction To submit a signature instruction to a device, send a POST request to the Devices endpoint. **Endpoint:** `https://api.payroc.com/v1/devices/{serialNumber}/signature-instructions` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /devices/{serialNumber}/signature-instructions`](/api/send-signature-instruction) #### Example request ### Request POST [https://api.payroc.com/v1/devices/\{serialNumber\}/signature-instructions](https://api.payroc.com/v1/devices/%7BserialNumber%7D/signature-instructions) **`Signature Instruction`** ```curl curl -X POST https://api.payroc.com/v1/devices/1850010868/signature-instructions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001" }' ``` **`Signature Instruction`** ```python import requests url = "https://api.payroc.com/v1/devices/1850010868/signature-instructions" payload = { "processingTerminalId": "1234001" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Signature Instruction`** ```javascript const url = 'https://api.payroc.com/v1/devices/1850010868/signature-instructions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Signature Instruction`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/devices/1850010868/signature-instructions" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Signature Instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/devices/1850010868/signature-instructions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\"\n}" response = http.request(request) puts response.read_body ``` **`Signature Instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/devices/1850010868/signature-instructions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\"\n}") .asString(); ``` **`Signature Instruction`** ```php request('POST', 'https://api.payroc.com/v1/devices/1850010868/signature-instructions', [ 'body' => '{ "processingTerminalId": "1234001" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Signature Instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/devices/1850010868/signature-instructions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Signature Instruction`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["processingTerminalId": "1234001"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/devices/1850010868/signature-instructions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we send the signature instruction to the device. **Note:** The response returns a value of `inProgress` for the status field and an identifier for the instruction that you can use to check the status of the instruction. To get a link to view the details of the signature capture, go to Step 2. ### Schema (`response.body`) [Response body schema for `POST /devices/{serialNumber}/signature-instructions`](/api/send-signature-instruction) #### Example response ### Response (202) ```json { "status": "inProgress", "signatureInstructionId": "a37439165d134678a9100ebba3b29597", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597" } } ``` ## Step 2. View the status of a signature instruction To check for updates to the status of the signature instruction, send a GET request to the Signature Instructions endpoint. **Endpoint:** `https://api.payroc.com/v1/signature-instructions/{signatureInstructionId}` Before our gateway sends a response, it waits for up to a minute for the status of the instruction to change. We recommend that you keep the session open until the status of the instruction changes or the request times out. If the status of the instruction doesn’t change, send another GET request. Our gateway waits up to a minute for the status of the instruction to change. Continue to send GET requests until the status changes. **Note:** Wait until you receive a response from our gateway before you send another request. ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `GET /signature-instructions/{signatureInstructionId}`](/api/get-signature-instruction) #### Example request ### Request GET [https://api.payroc.com/v1/signature-instructions/\{signatureInstructionId\}](https://api.payroc.com/v1/signature-instructions/%7BsignatureInstructionId%7D) **`Signature instruction`** ```curl curl https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597 \ -H "Authorization: Bearer " ``` **`Signature instruction`** ```python import requests url = "https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Signature instruction`** ```javascript const url = 'https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Signature instruction`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Signature instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Signature instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597") .header("Authorization", "Bearer ") .asString(); ``` **`Signature instruction`** ```php request('GET', 'https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Signature instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Signature instruction`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/signature-instructions/a37439165d134678a9100ebba3b29597")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we return the details of the signature instruction, including HATEOAS links to check the signature. Use the HATEOAS links to get the signatureId, which you need in Step 3. If the status of the signature instruction is `inProgress`, our gateway waits up to a minute for the status to change before it returns a response. ### Schema (`response.body`) [Response body schema for `GET /signature-instructions/{signatureInstructionId}`](/api/get-signature-instruction) #### Example response ### Response (200) ```json { "status": "completed", "signatureInstructionId": "a37439165d134678a9100ebba3b29597", "link": { "rel": "signature", "method": "GET", "href": "https://api.payroc.com/v1/signatures/M2MJOG6O2Y" } } ``` ## Step 3. View the signature capture To view the signature that the payment device captured, send a GET request to the Signatures endpoint. **Endpoint:** `https://api.payroc.com/v1/signatures/{signatureId}` ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `GET /signatures/{signatureId}`](/api/retrieve-signature) #### Example request ### Request GET [https://api.payroc.com/v1/signatures/\{signatureId\}](https://api.payroc.com/v1/signatures/%7BsignatureId%7D) **`Signature`** ```curl curl https://api.payroc.com/v1/signatures/JDN4ILZB0T \ -H "Authorization: Bearer " ``` **`Signature`** ```python import requests url = "https://api.payroc.com/v1/signatures/JDN4ILZB0T" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Signature`** ```javascript const url = 'https://api.payroc.com/v1/signatures/JDN4ILZB0T'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Signature`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/signatures/JDN4ILZB0T" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Signature`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/signatures/JDN4ILZB0T") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Signature`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/signatures/JDN4ILZB0T") .header("Authorization", "Bearer ") .asString(); ``` **`Signature`** ```php request('GET', 'https://api.payroc.com/v1/signatures/JDN4ILZB0T', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Signature`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/signatures/JDN4ILZB0T"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Signature`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/signatures/JDN4ILZB0T")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we return the details of the signature. ### Schema (`response.body`) [Response body schema for `GET /signatures/{signatureId}`](/api/retrieve-signature) #### Example response ### Response (200) ```json { "signatureId": "JDN4ILZB0T", "processingTerminalId": "1024", "createdOn": "2024-07-02", "contentType": "image/png", "signature": "iVBORw0KGgoAAAANSUhEUgAAASwAAABkCAYAAAA8AQ3AAAAJT0lEQVR4Xu3dW4hN7x/H8UnOF5ScSaGcY4hyvJiSQ6RE3FDIkEuHNDdcKacc0pSQiCuUw4UL5YKcipGQclYkJKcccv7+/58ne35jzZ5t7b3XWns/a96v2s2etdfMYDyf/Xyf51nPqjDk9Pr1a7t06ZLt2bPH1qxZY7NmzbJBgwZZ69atrbKy0qqrq622ttbq6urs69evwS/P27Nnz2zYsGHBwwD+ryJ4wDffvn2z48eP29y5c12IVFRUZH20adPGzp07F/xy58ePH3bnzh07ceKEbd682RYvXmxjx461Tp06uYee65he0zk699OnTy6kFFYKLYVXu3btig6xBQsW2Pr164OHAZjHgaXwUTAoUKqqqmz//v32/v374Gn1dH7Xrl3/Cq3v37/bxo0bXZip16Tek3pR6k2pV6XeVT4UTsEQ0/d+/Phx8NSsrl69ar169XJhCKAxrwLr9u3bVlNTY3369LERI0bYli1bXAkVVsPQOn/+vA0ZMsRmzpxpT548CZ4aGfXKpk+fHjyc1cSJE+3AgQPBwwD+KPvAUiApmBRQCioFloKrUKdOnbK2bdtat27dXCkZN5Wbw4cPtyNHjgRf+svRo0dt1KhR9uvXr+BLAP4oy8BSaacST6WeSj6VV02NP4X1+/dv27dvn+thzZ8/37p06VL09wzrypUrrtRrqmRVKdm3b9/E/jyAr8ousA4ePOh6QBpEVw9Ig+rFunnzpo0fP9499FwUDhpfSsqKFSvcIxuVjbNnzw4eBhBQNoH1+fNnW7RokQ0dOtTNwkXh48ePbhBdvSr1rtTLakizh0lR70q9LPW2Gnr16pV17tzZHjx48NdxAI0l12JzUEApqBRYCq4oqHemMS99z6Zm+5IMLNE4lsazNK6VsXz5clu1alWDswA0JdkWm4VKQI0n6WMUNOOnmT/NAGomMJekA0s0Y6gSUDR5oMH/d+/eBc4CkE3yLfaPOErAe/fuufEvra3SGqt/KUVgaU1WZuxsypQpbs0WgHCSb7EWTwmoMmvMmDG2e/fu4EtNKkVgiX7u6dOnbfDgwX+VhwByS7zFRl0CZqxbt85mzJgRPJxTKQNLYaXQAhBeYi02jhIw4/Lly9ajRw97+fJl8KWcShlYKgcB5CeRFhtHCZihpQv9+/e3kydPBl/6p1IElgbY9XOLWa0PNFext9i4SsCMpUuXuke+dAmMdndImpYwlCIogTSIreXEWQJmqFel3pV6WfnS2iwt2EySFofqZxJYQGFiaTlxloAZGq/SuJXGrwpx9+5dGzhwYPBwrHT5jdZgEVhAYSJvObpGTxvZxVUCZmhGUDODhbp48aJNmDAheDg2+nfRBc4fPnwoSSkKpEGkgZVtk7w4aK2V1lwVs4ZJ5aQ27EuCxsu0dYy2kNEmfSNHjgyeAiCEyAIrqbASrRTXqvZiaPuaJUuWBA/HQpvyaXM+UdgWMkkAIKLASjKsJIoxII0lrV27Nng4ctruWLs0qGclCqt8VuMD+E/RLT/psJIoAkthlbkIOQ5v3751Zee4cePczGCuG2SEebRq1arRsYavAc1BUS2/FGElaqTFUjmosjAquqj50KFDtmzZMrdTRIcOHWzq1KnWsmVLO3bsmH358sXtLNq+ffu876TzL1H8ewA+KPh/eqnCSqJooBpwL2R1vGgjwBs3btiuXbts3rx51rNnT/fQcx3Tazrn6dOn1rt37/qvi2vAPYp/D8AHBf1PL2VYSRQNVEsatLQhDPWO9HfdsGGDTZs2zfWe1ItSb0q9qqZu46U1YrqnYUYcA+76cyW51TNQSnm3/FKHlWg8SDccvXDhQvCl0LRoVItHG8p1l2cFj46pV6bxqTC0w6j2ps+IesC9HH4XQJLyCqxyaSBv3ryxHTt2uF6OHnquY2Fk7vKsXpLusBzmLs+Frvfatm2brVy5sv5zlYOZ2cJilcvvAkhS6MAq1waiXpZ6W2Fn4XTegAEDrEWLFrZ69eqC7/IchsJKoSUKPu2GGsWAe7n+LoC4hQqstDWQw4cPJ7LKXeWgykJdT6lrK6O4XCltvwsgH/8MrDQ2EIWVQituKi818K6LwPUoxs+fP23r1q3uOs00/S6AfOQMrDSGlS4+7tixo/sYNy1p2L59u+tdFbNrxfXr1921iNqltKkZSaA5aDKwHj16lMp386TKQdF4mZYcFLofmEJOM5O6FZiWTwDNXZOBpXdzlSBpk1Q5WKwzZ8647Wg0oRDHhADgo6yBpXdzlSAaN0mTJMvBQimcFFIKK4UWgP80Ciw1mO7du7txk7RJshwshN4oVP6pDCxmzAtIq0aBtXDhQtdgmqI7Kt+6dcttRqcdP+fMmeMGlZPebrgQ5VoOaiBdJbh6tWl8owCi8ldgqQTp169f1nd37Zq5c+dON4isgFJQKbAUXAqwMLeGL6VyLAd1iU9NTY1bUKrxwrSV4EDU6gNLIaWwyjZu8vDhQ5s0aZJ76LmPyqkc1MXUmzZtcrc/0wXUz58/D54CIIv6wFIZqHKwoUyvSg1LH/W5r8qhHNQ1iXv37nU7kGormmK3eQaaGxdYGjfRQHvD6fM09KoyVAaqlC1lOajSWdcwTp482a5duxZ8GUAIFRo30WBvZmFi5mJijav43qvKKGU5ePbsWRs9erR76DmAwlVosLeqqqrg7Vp8UIpyUL0o9abUq1LvCkDxKnT5SBQb4pWrpGcHNS6l8SmNU2m8qtC9tAA0VqE9ohpuMpc2SZWDmunTjJ8mKDQDqJlAANFyPawXL14Ej6dGHOWgNuGrq6uz2tpaq66utsrKSjeorzVVYbdPBpC/Rivd00ZBcv/+/eDh0LKFk3ax0Ed9ruN6PYqdRAHklvrAUrkbtuQlnIDylvrAUrmbz37vhBNQvlIfWADSg8AC4A0CC4A3CCwA3iCwAHiDwALgDQILgDcILADeILAAeIPAAuANAguANwgsAN4gsAB4g8AC4A0CC4A3CCwA3iCwAHiDwALgDQILgDcILADeILAAeIPAAuANAguANwgsAN4gsAB4g8AC4A0CC4A3CCwA3iCwAHiDwALgDQILgDcILADeILAAeIPAAuANAguANwgsAN4gsAB4g8AC4A0CC4A3CCwA3iCwAHiDwALgDQILgDcILADeILAAeIPAAuANAguANwgsAN4gsAB4g8AC4A0CC4A3/gdbd1ZfSyjQ+QAAAABJRU5ErkJggg==" } ``` ## (Optional) Cancel a signature instruction To cancel a signature instruction, send a DELETE request to the Signature Instructions endpoint. **Endpoint:** `https://api.payroc.com/v1/signature-instructions/{signatureInstructionId}` **Note:** You can cancel a signature instruction only if its status is `inProgress`. ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `DELETE /signature-instructions/{signatureInstructionId}`](/api/delete-signature-instruction) #### Example request ### Schema [Operation schema for `DELETE /signature-instructions/{signatureInstructionId}`](/api/delete-signature-instruction) ### Response If your request is successful, we cancel the signature instruction. # Extend your solution Source: https://docs.payroc.com/guides/payments/payroc-cloud/extend-your-integration Extend your Payroc Cloud integration with signature capture, referenced and unreferenced refunds, and transaction reversal. **Prerequisites:** [Authentication](/api/authentication) An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). After you configure your payment device to run a sale, you can also extend your integration to include the following: - [**Capture a signature**](/guides/payments/payroc-cloud/capture-signature) - Capture a signature on a payment device. - [**Run an unreferenced refund**](/guides/payments/payroc-cloud/run-unreferenced-refund) - Run a refund that isn't linked to a transaction. - [**Run a referenced refund**](/guides/payments/refunds/referenced-refund-card) - Run a refund that is linked to a transaction. - [**Reverse a transaction**](/guides/payments/refunds/void-card) - Cancel a transaction in an open batch. # Run a sale Source: https://docs.payroc.com/guides/payments/payroc-cloud/run-sale Run a card sale on a Payroc Cloud device by submitting a payment instruction via POST to the Devices endpoint, polling for status, and retrieving the final payment result. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). After you configure a device for Payroc Cloud, program your POS to send a payment instruction to the payment device. Your POS then checks the status of the instruction until the payment finishes, and views the details of the payment. ## How it works ```mermaid sequenceDiagram participant POS as Your POS participant GW as Gateway participant D as Payment device rect rgba(0, 81, 194, 0.4) Note over POS,D: 1. Submit a payment instruction POS->>GW: POST /devices/{serialNumber}/payment-instructions GW->>D: Send the payment instruction GW-->>POS: paymentInstructionId, status = inProgress end rect rgba(0, 224, 184, 0.3) Note over POS,D: 2. Check the status of the payment instruction Note over D: Cardholder taps their card and
completes the payment on the device loop Until the status changes from inProgress POS->>GW: GET /payment-instructions/{paymentInstructionId} Note over GW: Waits up to a minute
for the status to change GW-->>POS: Current status
(when complete, includes a link to the payment) end end rect rgba(0, 224, 184, 0.3) Note over POS,GW: 3. View the details of the payment POS->>GW: GET /payments/{paymentId} GW-->>POS: Payment details (approved or declined) end opt Cancel while the status is inProgress POS->>GW: DELETE /payment-instructions/{paymentInstructionId} GW-->>POS: Payment instruction canceled end ``` 1. Your POS submits a payment instruction to the device. Our gateway sends the instruction to the device and returns a `paymentInstructionId` with a status of `inProgress`. 2. The cardholder completes the payment on the device. Your POS checks the status of the payment instruction. Our gateway waits up to a minute for the status to change before it responds. If the status is still `inProgress`, your POS sends another request and keeps checking until the status changes. 3. When the payment finishes, your POS uses the link in the response to view the details of the payment and to check whether the processor approved it or declined it. You can also cancel the payment instruction while its status is `inProgress`. ### Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Submit a payment instruction To submit a payment instruction to the device, send a POST request to the Devices endpoint. **Endpoint:** `https://api.payroc.com/v1/devices/{serialNumber}/payment-instructions` ### Request parameters To create the body of your request, use the following parameters:\\ ### Schema (`request.body`) [Request body schema for `POST /devices/{serialNumber}/payment-instructions`](/api/send-payment-instruction) #### Example request ### Request POST https://api.payroc.com/v1/devices/\{serialNumber\}/payment-instructions ```curl curl -X POST https://api.payroc.com/v1/devices/1850010868/payment-instructions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD" }, "operator": "Jane", "customizationOptions": { "entryMethod": "deviceRead" }, "autoCapture": true }' ``` **`Payment Instruction`** ```python import requests url = "https://api.payroc.com/v1/devices/1850010868/payment-instructions" payload = { "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD" }, "operator": "Jane", "customizationOptions": { "entryMethod": "deviceRead" }, "autoCapture": True } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Payment Instruction`** ```javascript const url = 'https://api.payroc.com/v1/devices/1850010868/payment-instructions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","amount":4999,"currency":"USD"},"operator":"Jane","customizationOptions":{"entryMethod":"deviceRead"},"autoCapture":true}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment Instruction`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/devices/1850010868/payment-instructions" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"operator\": \"Jane\",\n \"customizationOptions\": {\n \"entryMethod\": \"deviceRead\"\n },\n \"autoCapture\": true\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment Instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/devices/1850010868/payment-instructions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"operator\": \"Jane\",\n \"customizationOptions\": {\n \"entryMethod\": \"deviceRead\"\n },\n \"autoCapture\": true\n}" response = http.request(request) puts response.read_body ``` **`Payment Instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/devices/1850010868/payment-instructions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"operator\": \"Jane\",\n \"customizationOptions\": {\n \"entryMethod\": \"deviceRead\"\n },\n \"autoCapture\": true\n}") .asString(); ``` **`Payment Instruction`** ```php request('POST', 'https://api.payroc.com/v1/devices/1850010868/payment-instructions', [ 'body' => '{ "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD" }, "operator": "Jane", "customizationOptions": { "entryMethod": "deviceRead" }, "autoCapture": true }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Payment Instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/devices/1850010868/payment-instructions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"operator\": \"Jane\",\n \"customizationOptions\": {\n \"entryMethod\": \"deviceRead\"\n },\n \"autoCapture\": true\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Payment Instruction`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "amount": 4999, "currency": "USD" ], "operator": "Jane", "customizationOptions": ["entryMethod": "deviceRead"], "autoCapture": true ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/devices/1850010868/payment-instructions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we send the payment instruction to the device. \ **Note:** The response returns a value of `inProgress` for the status field and an identifier for the instruction that you can use to check the status of the instruction. To get a link to view the details of the payment, go to Step 2. \ ### Schema (`response.body`) [Response body schema for `POST /devices/{serialNumber}/payment-instructions`](/api/send-payment-instruction) ### Response parameters ### Response (202) ```json { "status": "inProgress", "paymentInstructionId": "a37439165d134678a9100ebba3b29597", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/payment-instructions/a37439165d134678a9100ebba3b29597" } } ``` ## Step 2. View the status of a payment instruction To check for updates to the status of the payment instruction, send a GET request to the Payment Instructions endpoint. **Endpoint:** `https://api.payroc.com/v1/payment-instructions/{paymentInstructionId}` Before our gateway sends a response, it waits for up to a minute for the status of the instruction to change. We recommend that you keep the session open until the status of the instruction changes or the request times out. If the status of the instruction doesn’t change, send another GET request. Our gateway waits up to a minute for the status of the instruction to change. Continue to send GET requests until the status changes. \ **Note:** Wait until you receive a response from our gateway before you send another request. \ ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `GET /payment-instructions/{paymentInstructionId}`](/api/get-payment-instruction) #### Example request ### Request GET https://api.payroc.com/v1/payment-instructions/\{paymentInstructionId\} ```curl curl https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597 \ -H "Authorization: Bearer " ``` **`Payment instruction`** ```python import requests url = "https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Payment instruction`** ```javascript const url = 'https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment instruction`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Payment instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597") .header("Authorization", "Bearer ") .asString(); ``` **`Payment instruction`** ```php request('GET', 'https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Payment instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Payment instruction`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payment-instructions/e743a9165d134678a9100ebba3b29597")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we return the details of the payment instruction, including HATEOAS links to check the details of the payment. Use the HATEOAS links to get the paymentId, which you need in Step 3. If the status of the payment instruction is `inProgress`, our gateway waits up to a minute for the status to change before it returns a response. ### Schema (`response.body`) [Response body schema for `GET /payment-instructions/{paymentInstructionId}`](/api/get-payment-instruction) #### Example response ### Response (200) ```json { "status": "completed", "paymentInstructionId": "a37439165d134678a9100ebba3b29597", "link": { "rel": "payment", "method": "GET", "href": "https://api.payroc.com/v1/payments/M2MJOG6O2Y" } } ``` ## Step 3. View the details of the payment To check whether the processor approved or declined the payment, send a GET request to the Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/payments/{paymentId}` ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `GET /payments/{paymentId}`](/api/get-payment) #### Example request ### Request GET https://api.payroc.com/v1/payments/\{paymentId\} ```curl curl https://api.payroc.com/v1/payments/M2MJOG6O2Y \ -H "Authorization: Bearer " ``` **`Payment`** ```python import requests url = "https://api.payroc.com/v1/payments/M2MJOG6O2Y" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments/M2MJOG6O2Y'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments/M2MJOG6O2Y" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments/M2MJOG6O2Y") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/payments/M2MJOG6O2Y") .header("Authorization", "Bearer ") .asString(); ``` **`Payment`** ```php request('GET', 'https://api.payroc.com/v1/payments/M2MJOG6O2Y', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments/M2MJOG6O2Y"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments/M2MJOG6O2Y")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we return the details of the payment. ### Schema (`response.body`) [Response body schema for `GET /payments/{paymentId}`](/api/get-payment) #### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "cardNumber": "453985******7062", "expiryDate": "1230", "entryMethod": "keyed", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## (Optional) Cancel a payment instruction To cancel a payment instruction, send a DELETE request to the Payment Instructions endpoint. **Endpoint:** `https://api.payroc.com/v1/payment-instructions/{paymentInstructionId}` \ **Note:** You can cancel a payment instruction only if its status is `inProgress`. \ ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `DELETE /payment-instructions/{paymentInstructionId}`](/api/delete-payment-instruction) #### Example request ### Schema [Operation schema for `DELETE /payment-instructions/{paymentInstructionId}`](/api/delete-payment-instruction) ### Response If your request is successful, we cancel the payment instruction. # Run unreferenced refunds Source: https://docs.payroc.com/guides/payments/payroc-cloud/run-unreferenced-refund Submit an unreferenced refund instruction to a Payroc Cloud device by sending a POST request to the Devices endpoint, then poll for status and retrieve refund details. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). After you configure a device for Payroc Cloud, program your POS to use the Submit Refund Instruction method to send a refund instruction to the payment device. To return funds to a cardholder, complete the following: 1. Submit a refund instruction to the device. 2. View the status of the refund instruction. 3. View the details of the refund instruction. You can also cancel a refund instruction if it hasn’t yet completed. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Submit a refund instruction To submit a refund instruction to a device, send a POST request to the Devices endpoint. **Endpoint:** `https://api.payroc.com/v1/devices/{serialNumber}/refund-instructions` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /devices/{serialNumber}/refund-instructions`](/api/send-refund-instruction) #### Example request ### Request POST [https://api.payroc.com/v1/devices/\{serialNumber\}/refund-instructions](https://api.payroc.com/v1/devices/%7BserialNumber%7D/refund-instructions) **`Refund instruction`** ```curl curl -X POST https://api.payroc.com/v1/devices/1850010868/refund-instructions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "operator": "Jane", "customizationOptions": { "entryMethod": "manualEntry" } }' ``` **`Refund instruction`** ```python import requests url = "https://api.payroc.com/v1/devices/1850010868/refund-instructions" payload = { "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "operator": "Jane", "customizationOptions": { "entryMethod": "manualEntry" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Refund instruction`** ```javascript const url = 'https://api.payroc.com/v1/devices/1850010868/refund-instructions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","description":"Refund for order OrderRef6543","amount":4999,"currency":"USD"},"operator":"Jane","customizationOptions":{"entryMethod":"manualEntry"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Refund instruction`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/devices/1850010868/refund-instructions" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"operator\": \"Jane\",\n \"customizationOptions\": {\n \"entryMethod\": \"manualEntry\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Refund instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/devices/1850010868/refund-instructions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"operator\": \"Jane\",\n \"customizationOptions\": {\n \"entryMethod\": \"manualEntry\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Refund instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/devices/1850010868/refund-instructions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"operator\": \"Jane\",\n \"customizationOptions\": {\n \"entryMethod\": \"manualEntry\"\n }\n}") .asString(); ``` **`Refund instruction`** ```php request('POST', 'https://api.payroc.com/v1/devices/1850010868/refund-instructions', [ 'body' => '{ "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "operator": "Jane", "customizationOptions": { "entryMethod": "manualEntry" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Refund instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/devices/1850010868/refund-instructions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"operator\": \"Jane\",\n \"customizationOptions\": {\n \"entryMethod\": \"manualEntry\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Refund instruction`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" ], "operator": "Jane", "customizationOptions": ["entryMethod": "manualEntry"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/devices/1850010868/refund-instructions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we send the refund instruction to the device. **Note:** The response returns a value of `inProgress` for the status field and an identifier for the instruction that you can use to check the status of the instruction. To get a link to view the details of the refund, go to Step 2. ### Schema (`response.body`) [Response body schema for `POST /devices/{serialNumber}/refund-instructions`](/api/send-refund-instruction) #### Example response ### Response (202) ```json { "status": "inProgress", "refundInstructionId": "a37439165d134678a9100ebba3b29597", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597" } } ``` ## Step 2. View the status of a refund instruction To check for updates to the status of the refund instruction, send a GET request to the Refund Instructions endpoint. **Endpoint:** `https://api.payroc.com/v1/refund-instructions/{refundInstructionId}` Before our gateway sends a response, it waits for up to a minute for the status of the instruction to change. We recommend that you keep the session open until the status of the instruction changes or the request times out. If the status of the instruction doesn’t change, send another GET request. Our gateway waits up to a minute for the status of the instruction to change. Continue to send GET requests until the status changes. **Note:** Wait until you receive a response from our gateway before you send another request. ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `GET /refund-instructions/{refundInstructionId}`](/api/get-refund-instruction) #### Example request ### Request GET [https://api.payroc.com/v1/refund-instructions/\{refundInstructionId\}](https://api.payroc.com/v1/refund-instructions/%7BrefundInstructionId%7D) **`Refund instruction`** ```curl curl https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597 \ -H "Authorization: Bearer " ``` **`Refund instruction`** ```python import requests url = "https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Refund instruction`** ```javascript const url = 'https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Refund instruction`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Refund instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Refund instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597") .header("Authorization", "Bearer ") .asString(); ``` **`Refund instruction`** ```php request('GET', 'https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Refund instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Refund instruction`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/refund-instructions/a37439165d134678a9100ebba3b29597")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we return the details of the refund instruction, including HATEOAS links to check the details of the refund. Use the HATEOAS links to get the refundId, which you need in Step 3. If the status of the refund instruction is `inProgress`, our gateway waits up to a minute for the status to change before it returns a response. ### Schema (`response.body`) [Response body schema for `GET /refund-instructions/{refundInstructionId}`](/api/get-refund-instruction) #### Example response ### Response (200) ```json { "status": "completed", "refundInstructionId": "a37439165d134678a9100ebba3b29597", "link": { "rel": "refund", "method": "GET", "href": "https://api.payroc.com/v1/refunds/CD3HN88U9F" } } ``` ## Step 3. View the details of the refund To check whether the processor approved or declined the refund, send a GET request to the Refunds endpoint. **Endpoint:** `https://api.payroc.com/v1/refunds/{refundId}` ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `GET /refunds/{refundId}`](/api/get-refund) #### Example request ### Request GET [https://api.payroc.com/v1/refunds/\{refundId\}](https://api.payroc.com/v1/refunds/%7BrefundId%7D) **`Refund`** ```curl curl https://api.payroc.com/v1/refunds/CD3HN88U9F \ -H "Authorization: Bearer " ``` **`Refund`** ```python import requests url = "https://api.payroc.com/v1/refunds/CD3HN88U9F" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Refund`** ```javascript const url = 'https://api.payroc.com/v1/refunds/CD3HN88U9F'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Refund`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/refunds/CD3HN88U9F" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Refund`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/refunds/CD3HN88U9F") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Refund`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/refunds/CD3HN88U9F") .header("Authorization", "Bearer ") .asString(); ``` **`Refund`** ```php request('GET', 'https://api.payroc.com/v1/refunds/CD3HN88U9F', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Refund`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/refunds/CD3HN88U9F"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Refund`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/refunds/CD3HN88U9F")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we return the details of the refund. ### Schema (`response.body`) [Response body schema for `GET /refunds/{refundId}`](/api/get-refund) #### Example response ### Response (200) ```json { "refundId": "CD3HN88U9F", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z" }, "card": { "type": "Visa Credit", "cardNumber": "453985******7062", "expiryDate": "1230", "entryMethod": "keyed" }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "refund", "approvalCode": "000000", "authorizedAmount": -4999, "currency": "USD", "responseMessage": "OK5" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## (Optional) Cancel a refund instruction To cancel a refund instruction, send a DELETE request to the Refund Instructions endpoint. **Endpoint:** `https://api.payroc.com/v1/refund-instructions/{refundInstructionId}` **Note:** You can cancel a refund instruction only if its status is `inProgress`. ### Request parameters To create your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `DELETE /refund-instructions/{refundInstructionId}`](/api/delete-refund-instruction) #### Example request ### Schema [Operation schema for `DELETE /refund-instructions/{refundInstructionId}`](/api/delete-refund-instruction) ### Response If your request is successful, we cancel the refund instruction. # Payment Links Source: https://docs.payroc.com/guides/payments/payment-links Explains how to use Payment Links to create a hosted payment page that a merchant can share with a customer An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Use our Payment Links solution to create a payment link that a merchant can share with a customer. The customer uses the payment link to open a payment page that we host. You can configure a payment link to do the following actions: - Take a single payment or multiple payments from one or more customers. - Run a sale or a pre-authorization. - Accept card payments, bank transfers, or both. - Set a fixed payment amount or ask the customer to enter the amount. ## How it works After a merchant creates a payment link and shares it with a customer, our gateway sends the link to the customer by email. The customer selects the link to open a hosted payment page, where they submit their payment details. ## Your integration journey To get started with Payment Links, go to [Create and share a payment link](/guides/payments/payment-links/create-share-link). ### Extend your integration After you set up your integration to create and share a payment link, you can extend your integration with additional features, for example: - Update a payment link. - Retrieve a link's sharing events. For more information about how to add these features to your integration, go to [Extend your integration](/guides/payments/payment-links/extend-your-integration). # Create and share a payment link Source: https://docs.payroc.com/guides/payments/payment-links/create-share-link Create a payment link and share it with customers by sending POST requests to the Processing Terminals and Payment Links endpoints. An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). Use our Payment Links feature to create a payment link that the merchant can email to customers to pay for goods and services. The request to create a payment link contains the following settings for the payment link: - **type** - Indicates whether the link can be used only once or if it can be used multiple times. - **authType** - Indicates whether the transaction is a sale or a pre-authorization. - **paymentMethod** - Indicates the payment methods that the merchant accepts. - **charge** - Indicates whether the merchant or customer enters the amount for the transaction. When the gateway creates the link, it returns the paymentLinkId that you use in the request to share the payment link. ## Integration steps **Step 1.** Create a payment link. \\ **Step 2.** Share a payment link. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ### Headers To create the header of each GET request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. ```sh curl -H "Content-Type: application/json" -H "Authorization: " ``` To create the header of each POST request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. - **Idempotency-Key:** Include a UUID v4 to make the request idempotent. ```sh curl -H "Content-Type: application/json" -H "Authorization: " -H "Idempotency-Key: " ``` ### Errors If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors). ## Step 1. Create a payment link To create a payment link, send a POST request to our Processing Terminals endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/payment-links` ### Request parameters To create the body of your request, use the following parameters: \<\#\#\# Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/payment-links`](/api/create-payment-link) ### Example request \<\#\#\# Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/payment-links](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/payment-links) **`Multi-use payment link`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/payment-links \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "authType": "sale", "customLabels": [ { "element": "paymentButton", "label": "SUPPORT US" } ], "merchantReference": "LinkRef6543", "order": { "charge": { "currency": "USD", "type": "prompt" }, "description": "Pie It Forward charitable trust donation" }, "paymentMethods": [ "card", "bankTransfer" ], "type": "multiUse" }' ``` **`Multi-use payment link`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/payment-links" payload = { "authType": "sale", "customLabels": [ { "element": "paymentButton", "label": "SUPPORT US" } ], "merchantReference": "LinkRef6543", "order": { "charge": { "currency": "USD", "type": "prompt" }, "description": "Pie It Forward charitable trust donation" }, "paymentMethods": ["card", "bankTransfer"], "type": "multiUse" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Multi-use payment link`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/payment-links'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"authType":"sale","customLabels":[{"element":"paymentButton","label":"SUPPORT US"}],"merchantReference":"LinkRef6543","order":{"charge":{"currency":"USD","type":"prompt"},"description":"Pie It Forward charitable trust donation"},"paymentMethods":["card","bankTransfer"],"type":"multiUse"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Multi-use payment link`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/payment-links" payload := strings.NewReader("{\n \"authType\": \"sale\",\n \"customLabels\": [\n {\n \"element\": \"paymentButton\",\n \"label\": \"SUPPORT US\"\n }\n ],\n \"merchantReference\": \"LinkRef6543\",\n \"order\": {\n \"charge\": {\n \"currency\": \"USD\",\n \"type\": \"prompt\"\n },\n \"description\": \"Pie It Forward charitable trust donation\"\n },\n \"paymentMethods\": [\n \"card\",\n \"bankTransfer\"\n ],\n \"type\": \"multiUse\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Multi-use payment link`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/payment-links") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"authType\": \"sale\",\n \"customLabels\": [\n {\n \"element\": \"paymentButton\",\n \"label\": \"SUPPORT US\"\n }\n ],\n \"merchantReference\": \"LinkRef6543\",\n \"order\": {\n \"charge\": {\n \"currency\": \"USD\",\n \"type\": \"prompt\"\n },\n \"description\": \"Pie It Forward charitable trust donation\"\n },\n \"paymentMethods\": [\n \"card\",\n \"bankTransfer\"\n ],\n \"type\": \"multiUse\"\n}" response = http.request(request) puts response.read_body ``` **`Multi-use payment link`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/payment-links") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"authType\": \"sale\",\n \"customLabels\": [\n {\n \"element\": \"paymentButton\",\n \"label\": \"SUPPORT US\"\n }\n ],\n \"merchantReference\": \"LinkRef6543\",\n \"order\": {\n \"charge\": {\n \"currency\": \"USD\",\n \"type\": \"prompt\"\n },\n \"description\": \"Pie It Forward charitable trust donation\"\n },\n \"paymentMethods\": [\n \"card\",\n \"bankTransfer\"\n ],\n \"type\": \"multiUse\"\n}") .asString(); ``` **`Multi-use payment link`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/payment-links', [ 'body' => '{ "authType": "sale", "customLabels": [ { "element": "paymentButton", "label": "SUPPORT US" } ], "merchantReference": "LinkRef6543", "order": { "charge": { "currency": "USD", "type": "prompt" }, "description": "Pie It Forward charitable trust donation" }, "paymentMethods": [ "card", "bankTransfer" ], "type": "multiUse" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Multi-use payment link`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/payment-links"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"authType\": \"sale\",\n \"customLabels\": [\n {\n \"element\": \"paymentButton\",\n \"label\": \"SUPPORT US\"\n }\n ],\n \"merchantReference\": \"LinkRef6543\",\n \"order\": {\n \"charge\": {\n \"currency\": \"USD\",\n \"type\": \"prompt\"\n },\n \"description\": \"Pie It Forward charitable trust donation\"\n },\n \"paymentMethods\": [\n \"card\",\n \"bankTransfer\"\n ],\n \"type\": \"multiUse\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Multi-use payment link`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "authType": "sale", "customLabels": [ [ "element": "paymentButton", "label": "SUPPORT US" ] ], "merchantReference": "LinkRef6543", "order": [ "charge": [ "currency": "USD", "type": "prompt" ], "description": "Pie It Forward charitable trust donation" ], "paymentMethods": ["card", "bankTransfer"], "type": "multiUse" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/payment-links")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway returns a paymentLinkId. Save the paymentLinkId so that you can include it in the request to share the link. The response contains the following fields: \<\#\#\# Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/payment-links`](/api/create-payment-link) ### Example response \<\#\#\# Response (201) ```json { "assets": { "paymentButton": "SUPPORT US\n", "paymentUrl": "https://payments.payroc.com/merchant/pay-by-link?token=02ada211-ff51-4845-b0b5-e685aeb4b19d" }, "authType": "sale", "createdOn": "2024-09-24", "customLabels": [ { "element": "paymentButton", "label": "SUPPORT US" } ], "merchantReference": "LinkRef6543", "order": { "charge": { "currency": "USD", "type": "prompt" }, "description": "Pie It Forward charitable trust donation" }, "paymentLinkId": "JZURRJBUPS", "paymentMethods": [ "card", "bankTransfer" ], "status": "active", "type": "multiUse" } ``` ## Step 2. Share a payment link To share a payment link, send a POST request to our Payment Links endpoint that includes the paymentLinkId of the link you want to share. **Endpoint:** `https://api.payroc.com/v1/payment-links/{paymentLinkId}/sharing-events` ### Request parameters To create the body of your request, use the following parameters: \<\#\#\# Schema (`request.body`) [Request body schema for `POST /payment-links/{paymentLinkId}/sharing-events`](/api/share-payment-link) ### Example request \<\#\#\# Request POST [https://api.payroc.com/v1/payment-links/\{paymentLinkId\}/sharing-events](https://api.payroc.com/v1/payment-links/%7BpaymentLinkId%7D/sharing-events) **`Share a payment link`** ```curl curl -X POST https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "merchantCopy": true, "message": "Dear Sarah,\n\nYour insurance is expiring this month.\nPlease, pay the renewal fee by the end of the month to renew it.\n", "recipients": [ { "email": "sarah.hopper@example.com", "name": "Sarah Hazel Hopper" } ], "sharingMethod": "email" }' ``` **`Share a payment link`** ```python import requests url = "https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events" payload = { "merchantCopy": True, "message": "Dear Sarah, Your insurance is expiring this month. Please, pay the renewal fee by the end of the month to renew it. ", "recipients": [ { "email": "sarah.hopper@example.com", "name": "Sarah Hazel Hopper" } ], "sharingMethod": "email" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Share a payment link`** ```javascript const url = 'https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"merchantCopy":true,"message":"Dear Sarah,\n\nYour insurance is expiring this month.\nPlease, pay the renewal fee by the end of the month to renew it.\n","recipients":[{"email":"sarah.hopper@example.com","name":"Sarah Hazel Hopper"}],"sharingMethod":"email"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Share a payment link`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events" payload := strings.NewReader("{\n \"merchantCopy\": true,\n \"message\": \"Dear Sarah,\\n\\nYour insurance is expiring this month.\\nPlease, pay the renewal fee by the end of the month to renew it.\\n\",\n \"recipients\": [\n {\n \"email\": \"sarah.hopper@example.com\",\n \"name\": \"Sarah Hazel Hopper\"\n }\n ],\n \"sharingMethod\": \"email\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Share a payment link`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"merchantCopy\": true,\n \"message\": \"Dear Sarah,\\n\\nYour insurance is expiring this month.\\nPlease, pay the renewal fee by the end of the month to renew it.\\n\",\n \"recipients\": [\n {\n \"email\": \"sarah.hopper@example.com\",\n \"name\": \"Sarah Hazel Hopper\"\n }\n ],\n \"sharingMethod\": \"email\"\n}" response = http.request(request) puts response.read_body ``` **`Share a payment link`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"merchantCopy\": true,\n \"message\": \"Dear Sarah,\\n\\nYour insurance is expiring this month.\\nPlease, pay the renewal fee by the end of the month to renew it.\\n\",\n \"recipients\": [\n {\n \"email\": \"sarah.hopper@example.com\",\n \"name\": \"Sarah Hazel Hopper\"\n }\n ],\n \"sharingMethod\": \"email\"\n}") .asString(); ``` **`Share a payment link`** ```php request('POST', 'https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events', [ 'body' => '{ "merchantCopy": true, "message": "Dear Sarah,\\n\\nYour insurance is expiring this month.\\nPlease, pay the renewal fee by the end of the month to renew it.\\n", "recipients": [ { "email": "sarah.hopper@example.com", "name": "Sarah Hazel Hopper" } ], "sharingMethod": "email" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Share a payment link`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"merchantCopy\": true,\n \"message\": \"Dear Sarah,\\n\\nYour insurance is expiring this month.\\nPlease, pay the renewal fee by the end of the month to renew it.\\n\",\n \"recipients\": [\n {\n \"email\": \"sarah.hopper@example.com\",\n \"name\": \"Sarah Hazel Hopper\"\n }\n ],\n \"sharingMethod\": \"email\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Share a payment link`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "merchantCopy": true, "message": "Dear Sarah, Your insurance is expiring this month. Please, pay the renewal fee by the end of the month to renew it. ", "recipients": [ [ "email": "sarah.hopper@example.com", "name": "Sarah Hazel Hopper" ] ], "sharingMethod": "email" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payment-links/JZURRJBUPS/sharing-events")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway shares the payment link with the recipients. The response contains the following fields: \<\#\#\# Schema (`response.body`) [Response body schema for `POST /payment-links/{paymentLinkId}/sharing-events`](/api/share-payment-link) ### Example response \<\#\#\# Response (201) ```json { "dateTime": "2024-07-02T15:30:00Z", "message": "Dear Sarah,\n\nYou can pay for your order via the link below.\n", "recipients": [ { "email": "sarah.hopper@example.com", "name": "Sarah Hazel Hopper" } ], "sharingEventId": "GTZH5WVXK9", "sharingMethod": "email" } ``` # Extend your integration Source: https://docs.payroc.com/guides/payments/payment-links/extend-your-integration Extend a payment links integration by sharing, updating, retrieving, listing, or deactivating payment links **Prerequisites:** [Authentication](/api/authentication) An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). After you set up your integration to create and share a payment link, you extend your integration to include the following: - [**Share a link**](/api/share-payment-link) — Send an existing payment link to one or more customers by email. - [**Update a link**](/api/update-payment-link) — Update a payment link, for example, its expiration date. - [**Retrieve a link**](/api/retrieve-payment-link) — Retrieve the details of a payment link. - [**Retrieve a list of links**](/api/list-payment-links) - Retrieve a paginated list of payment links that are associated with a processing terminal. - [**Retrieve a link's sharing events**](/api/list-payment-link-share-events) — Retrieve a paginated list of the times that a merchant shared a payment link. - [**Deactivate a link**](/api/deactivate-payment-link) — Deactivate a payment link. # Refunds Source: https://docs.payroc.com/guides/payments/refunds Explains referenced refunds, unreferenced refunds, and reversals, and when to use each one to return funds to a customer **Prerequisites:** [Authentication](/api/authentication) When a customer returns an item or requests money back, the merchant can run a refund to return a payment to the customer’s account if it is in a closed batch or cancel the payment if it is in an open batch. Our gateway supports two types of refund: - Referenced refund - Unreferenced refund ## Refund types The refund type you use depends on whether you still have the original payment. If you do, the gateway's action depends on whether the payment is in an open or a closed batch. ```mermaid flowchart TD A([Customer requests a refund]):::blue B{Do you have the original payment,
with valid payment details?}:::yellow U([Unreferenced refund
Send the customer's new payment details]):::green R[Referenced refund
Send the refund with the original paymentId]:::neutral C{Is the payment in an open batch?}:::yellow CANCEL([Gateway cancels the payment.]):::green REFUND([Gateway returns the funds to the customer]):::green A --> B B -->|No, or the details have expired| U B -->|Yes| R R --> C C -->|Yes, open batch| CANCEL C -->|No, closed batch| REFUND classDef blue fill:#0051C2,stroke:#001D4E,color:#FFFFFF classDef green fill:#00E0B8,stroke:#001D4E,color:#001D4E classDef yellow fill:#F4F7FE,stroke:#0051C2,color:#0051C2,font-size:15px classDef neutral fill:#E5E5E5,stroke:#636363,color:#001D4E ``` ## Referenced refund Our gateway uses the payment details from the original payment to return the payment to the customer. If the payment is in an open batch, the gateway automatically cancels the payment. If the payment is in a closed batch, the gateway refunds the payment. ### Example A customer returns an item to the merchant and wants a refund. The merchant uses their POS to look up the original sale and run a refund against the sale. ## Unreferenced refund If there is no previous payment or the customer payment details have expired, you need to provide our gateway with the customer’s new payment details so that we know where to send the funds to. ### Example A customer returns an item to the merchant and wants a refund. However, their original payment details have expired. The merchant uses their new payment details to run an unreferenced refund. ## Reversal If the customer’s payment is in an open batch, the merchant can cancel the payment before we process it. This is known as a reversal. **Note:** Although there is a discrete endpoint to reverse a payment, if you send a refund request to our refund endpoint, our gateway automatically cancels the payment if it is in an open batch. ## Guides #### [Send a referenced refund to a bank account](/guides/payments/refunds/referenced-refund-bank) Return funds to a customer’s bank account with a paymentId. #### [Reverse a bank transfer payment](/guides/payments/refunds/void-bank) Cancel a bank transfer payment that’s in an open batch. #### [Send an unreferenced refund to a customer’s bank account](/guides/payments/refunds/unreferenced-refund-bank) Return funds to a customer’s bank account without a paymentId. #### [Run a referenced refund for a card payment](/guides/payments/refunds/unreferenced-refund-card) Return funds to a customer’s account with a paymentId. #### [Run an unreferenced refund for a card payment](/guides/payments/refunds/referenced-refund-card) Return funds to a customer’s account without a paymentId. #### [Reverse a card sale or a pre-authorization](/guides/payments/refunds/void-card) Cancel a card sale or a pre-authorization that's in an open batch. # Send a referenced refund to a bank account Source: https://docs.payroc.com/guides/payments/refunds/referenced-refund-bank Refund a bank transfer payment by sending a POST request to the Bank Transfer Payments Refund endpoint using the original paymentId. **Prerequisites:** [Authentication](/api/authentication) A merchant can use the payment details of a card payment to run a referenced refund. To run a referenced refund, the merchant should first retrieve the payment information in one of the following ways: - Use the paymentId. - Search for the payment using payment information such as the bank account number. ## Integration steps **Step 1.** Retrieve information about the original payment. **(Optional) Step 1a.** Retrieve information about the payment using the paymentId. **(Optional) Step 1b.** Retrieve information about the payment without the paymentId. **Step 2.** Refund the payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ### Headers To create the header of each GET request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. ```bash curl -H "Content-Type: application/json" -H "Authorization: " ``` To create the header of each POST request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. - **Idempotency-Key:** Include a UUID v4 to make the request idempotent. ```bash curl -H "Content-Type: application/json" -H "Authorization: " -H "Idempotency-Key: " ``` ### Errors If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors). ## Step 1 - Retrieve the details of the payment ### 1a (Optional) – Retrieve the details of the payment with a paymentId Send a GET request with the paymentID to our Bank Transfer Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments/{paymentId}` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `GET /bank-transfer-payments/{paymentId}`](/api/get-bank-transfer-payment) ### Example request ### Request GET [https://api.payroc.com/v1/bank-transfer-payments/\{paymentId\}](https://api.payroc.com/v1/bank-transfer-payments/%7BpaymentId%7D) **`Store Token Bank Transfer Payment`** ```curl curl https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y \ -H "Authorization: Bearer " ``` **`Store Token Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Store Token Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Store Token Bank Transfer Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Store Token Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Store Token Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y") .header("Authorization", "Bearer ") .asString(); ``` **`Store Token Bank Transfer Payment`** ```php request('GET', 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Store Token Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Store Token Bank Transfer Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway returns the details of the payment. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `GET /bank-transfer-payments/{paymentId}`](/api/get-bank-transfer-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "ach", "accountNumber": "****3159", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "secCode": "web", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } } }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "NoError", "processorResponseCode": "0" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ### 1b (Optional) – Retrieve the details of the payment without a paymentId Send a GET request to our Bank Transfer Payments endpoint. To filter your results, use query parameters. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.query`) [Query parameters for `GET /bank-transfer-payments`](/api/list-bank-transfer-payments) ### Example request ### Request GET [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) **`Bank Transfer Payment`** ```curl curl -G https://api.payroc.com/v1/bank-transfer-payments \ -H "Authorization: Bearer " \ -d after=8516 \ -d before=2571 \ --data-urlencode dateFrom=2024-07-01T00:00:00Z \ --data-urlencode dateTo=2024-07-31T23:59:59Z \ -d last4=7890 \ -d limit=25 \ --data-urlencode nameOnAccount=Sarah%20Hazel%20Hopper \ -d orderId=OrderRef6543 \ -d paymentLinkId=JZURRJBUPS \ -d processingTerminalId=1234001 \ -d settlementDate=2024-07-15 \ -d settlementState=settled \ -d status=ready \ -d type=payment ``` **`Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments" querystring = {"after":"8516","before":"2571","dateFrom":"2024-07-01T00:00:00Z","dateTo":"2024-07-31T23:59:59Z","last4":"7890","limit":"25","nameOnAccount":"Sarah%20Hazel%20Hopper","orderId":"OrderRef6543","paymentLinkId":"JZURRJBUPS","processingTerminalId":"1234001","settlementDate":"2024-07-15","settlementState":"settled","status":"[\"ready\"]","type":"[\"payment\"]"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` **`Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Bank Transfer Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D") .header("Authorization", "Bearer ") .asString(); ``` **`Bank Transfer Payment`** ```php request('GET', 'https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Bank Transfer Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway returns a list of payments that match the query parameters. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `GET /bank-transfer-payments`](/api/list-bank-transfer-payments) ### Example response ### Response (200) ```json { "limit": 2, "count": 2, "hasMore": true, "data": [ { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "pad", "accountNumber": "*******3159", "institutionNumber": "543", "nameOnAccount": "Sarah Hazel Hopper", "transitNumber": "76543" }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] } }, { "paymentId": "E29U8OU8Q4", "processingTerminalId": "1234001", "order": { "amount": 3999, "currency": "USD", "orderId": "OrderRef7654", "breakdown": { "subtotal": 3477, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 174 } ], "tip": { "type": "percentage", "amount": 348, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "test" }, "bankAccount": { "type": "pad", "accountNumber": "*******7890", "institutionNumber": "543", "nameOnAccount": "Sarah Hazel Hopper", "transitNumber": "76543" }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 3999, "currency": "USD" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ], "links": [ { "rel": "next", "method": "get", "href": "https://api.payroc.com/v1/bank-transfer-payments?limit=2&processingTerminalId=1234001&after=E29U8OU8Q4" }, { "rel": "previous", "method": "get", "href": "https://api.payroc.com/v1//bank-transfer-payments?limit=2&processingTerminalId=1234001&before=M2MJOG6O2Y" } ] } ``` ## Step 2 - Refund the payment To refund the payment, send a POST request to our Bank Transfer Payments Refund endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments/{paymentId}/refund` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /bank-transfer-payments/{paymentId}/refund`](/api/refund-bank-transfer-payment) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-payments/\{paymentId\}/refund](https://api.payroc.com/v1/bank-transfer-payments/%7BpaymentId%7D/refund) **`Refund Bank Transfer Payment`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "amount": 4999, "description": "amount to refund" }' ``` **`Refund Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund" payload = { "amount": 4999, "description": "amount to refund" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Refund Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"amount":4999,"description":"amount to refund"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Refund Bank Transfer Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund" payload := strings.NewReader("{\n \"amount\": 4999,\n \"description\": \"amount to refund\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Refund Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"amount\": 4999,\n \"description\": \"amount to refund\"\n}" response = http.request(request) puts response.read_body ``` **`Refund Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"amount\": 4999,\n \"description\": \"amount to refund\"\n}") .asString(); ``` **`Refund Bank Transfer Payment`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund', [ 'body' => '{ "amount": 4999, "description": "amount to refund" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Refund Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"amount\": 4999,\n \"description\": \"amount to refund\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Refund Bank Transfer Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "amount": 4999, "description": "amount to refund" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/refund")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway refunds the payment. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-payments/{paymentId}/refund`](/api/refund-bank-transfer-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Refund for order OrderRef6543" }, "bankAccount": { "type": "pad", "accountNumber": "****7890", "institutionNumber": "543", "nameOnAccount": "Sarah Hazel Hopper", "transitNumber": "76543", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } } }, "transactionResult": { "type": "payment", "status": "reversal", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Run a referenced refund for a card payment Source: https://docs.payroc.com/guides/payments/refunds/referenced-refund-card Refund a card payment by sending a POST request to the Payments endpoint using the original paymentId, with optional GET requests to retrieve payment details first. **Prerequisites:** [Authentication](/api/authentication) · [Run a card sale](/guides/payments/run-a-card-sale) An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). A merchant can use the payment details of a card payment to run a referenced refund. To run a referenced refund, the merchant should first retrieve the payment information in one of the following ways: - Use the paymentId. - Search for the payment using payment information such as the card number. **Note:** If the merchant runs a refund on a payment that is in an open batch, our gateway automatically cancels the payment. ## Integration steps **Step 1.** Retrieve information about the original payment. **(Optional) Step 1a.** Retrieve information about the payment using the paymentId. **(Optional) Step 1b.** Retrieve information about the payment without the paymentId. **Step 2.** Refund the payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Retrieve information about the original payment **1a – (Optional) Retrieve information with the paymentId** Send a GET request with the paymentID to the Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/payments/{paymentId}` ### Schema (`request.path`) [Path parameters for `GET /payments/{paymentId}`](/api/get-payment) ### Example request ### Request GET [https://api.payroc.com/v1/payments/\{paymentId\}](https://api.payroc.com/v1/payments/%7BpaymentId%7D) **`Payment`** ```curl curl https://api.payroc.com/v1/payments/M2MJOG6O2Y \ -H "Authorization: Bearer " ``` **`Payment`** ```python import requests url = "https://api.payroc.com/v1/payments/M2MJOG6O2Y" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments/M2MJOG6O2Y'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments/M2MJOG6O2Y" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments/M2MJOG6O2Y") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/payments/M2MJOG6O2Y") .header("Authorization", "Bearer ") .asString(); ``` **`Payment`** ```php request('GET', 'https://api.payroc.com/v1/payments/M2MJOG6O2Y', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments/M2MJOG6O2Y"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments/M2MJOG6O2Y")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we retrieve the card payment information and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `GET /payments/{paymentId}`](/api/get-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "cardNumber": "453985******7062", "expiryDate": "1230", "entryMethod": "keyed", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` **1b (Optional) – Retrieve information without the payment ID** Send a GET request to the Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/payments` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `GET /payments`](/api/list-payments) ### Example request ### Request GET [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **`Payment`** ```curl curl -G https://api.payroc.com/v1/payments \ -H "Authorization: Bearer " \ -d after=8516 \ -d before=2571 \ --data-urlencode cardholderName=Sarah%20Hazel%20Hopper \ --data-urlencode dateFrom=2024-07-01T15:30:00Z \ --data-urlencode dateTo=2024-07-03T15:30:00Z \ -d first6=453985 \ -d last4=7062 \ -d limit=25 \ -d operator=Jane \ -d orderId=OrderRef6543 \ -d paymentLinkId=JZURRJBUPS \ -d processingTerminalId=1234001 \ -d settlementDate=2024-07-02 \ -d settlementState=settled \ -d status=accepted \ -d status=ready \ -d status=complete \ -d tender=ebt \ -d tipMode=noTip \ -d tipMode=prompted \ -d type=sale \ -d type=preAuthorization ``` **`Payment`** ```python import requests url = "https://api.payroc.com/v1/payments" querystring = {"after":"8516","before":"2571","cardholderName":"Sarah%20Hazel%20Hopper","dateFrom":"2024-07-01T15:30:00Z","dateTo":"2024-07-03T15:30:00Z","first6":"453985","last4":"7062","limit":"25","operator":"Jane","orderId":"OrderRef6543","paymentLinkId":"JZURRJBUPS","processingTerminalId":"1234001","settlementDate":"2024-07-02","settlementState":"settled","status":"[\"accepted\",\"ready\",\"complete\"]","tender":"ebt","tipMode":"[\"noTip\",\"prompted\"]","type":"[\"sale\",\"preAuthorization\"]"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` **`Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D") .header("Authorization", "Bearer ") .asString(); ``` **`Payment`** ```php request('GET', 'https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we retrieve a list of card payments and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `GET /payments`](/api/list-payments) ### Example response ### Response (200) ```json { "limit": 2, "count": 2, "hasMore": true, "data": [ { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Monthly Premium Club subscription" }, "card": { "type": "Visa Credit", "cardNumber": "453985******7062", "expiryDate": "1230", "entryMethod": "keyed", "cardholderName": "Sarah Hopper", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "securityChecks": { "cvvResult": "M", "avsResult": "X" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "APPROVAL" }, "operator": "Automatic Payment", "supportedOperations": [ "fullyReverse", "setAsPending" ] }, { "paymentId": "E29U8OU8Q4", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef7654", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Monthly Premium Club subscription" }, "card": { "type": "Visa Debit", "cardNumber": "453985******7062", "expiryDate": "1230", "entryMethod": "keyed", "cardholderName": "Sarah Hopper", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "securityChecks": { "cvvResult": "M", "avsResult": "X" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "475318", "authorizedAmount": 1000, "currency": "EUR", "responseMessage": "APPROVAL" }, "operator": "Automatic Payment", "supportedOperations": [ "fullyReverse", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ], "links": [ { "rel": "next", "method": "get", "href": "https://api.payroc.com/v1/payments?processingTerminalId=1234001&limit=2&after=E29U8OU8Q4" }, { "rel": "previous", "method": "get", "href": "https://api.payroc.com/v1/payments?processingTerminalId=1234001&limit=2&before=M2MJOG6O2Y" } ] } ``` ## Step 2. Refund the payment To refund a card transfer payment, send a POST request to the Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/payments/{paymentId}/refund` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments/{paymentId}/refund`](/api/refund-payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments/\{paymentId\}/refund](https://api.payroc.com/v1/payments/%7BpaymentId%7D/refund) **`Refund Payment`** ```curl curl -X POST https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "amount": 4999, "description": "Refund for order OrderRef6543" }' ``` **`Refund Payment`** ```python import requests url = "https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund" payload = { "amount": 4999, "description": "Refund for order OrderRef6543" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Refund Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"amount":4999,"description":"Refund for order OrderRef6543"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Refund Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund" payload := strings.NewReader("{\n \"amount\": 4999,\n \"description\": \"Refund for order OrderRef6543\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Refund Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"amount\": 4999,\n \"description\": \"Refund for order OrderRef6543\"\n}" response = http.request(request) puts response.read_body ``` **`Refund Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"amount\": 4999,\n \"description\": \"Refund for order OrderRef6543\"\n}") .asString(); ``` **`Refund Payment`** ```php request('POST', 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund', [ 'body' => '{ "amount": 4999, "description": "Refund for order OrderRef6543" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Refund Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"amount\": 4999,\n \"description\": \"Refund for order OrderRef6543\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Refund Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "amount": 4999, "description": "Refund for order OrderRef6543" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments/M2MJOG6O2Y/refund")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we refund the card payment and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments/{paymentId}/refund`](/api/refund-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "complete", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK13" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "refunds": [ { "refundId": "CD3HN88U9F", "dateTime": "2024-07-02T15:30:00Z", "currency": "USD", "amount": -4999, "status": "ready", "responseCode": "A", "responseMessage": "Transaction refunded", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/refunds/BI77XQFQ05" } } ], "supportedOperations": [ "refund" ], "customFields": [ { "name": "yourCustomField", "value": "acb123" } ] } ``` ## Test cases Before you run test cases, read the [Payments](/guides/testing/online-payments) page in Test Your Integration. ### Refund a card payment Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments/\{paymentId\}/refund](https://api.payroc.com/v1/payments/%7BpaymentId%7D/refund) **Note:** To settle a payment, the terminal must first close the batch and then our gateway settles the payments within an hour. To adjust when the terminal closes a batch, use the terminal settings in the Merchant Portal. **Example response** ```json { "paymentId": "C8Y177VHWR", "processingTerminalId": "3204001", "order": { "orderId": "Test_006", "dateTime": "2023-05-24T15:21:01+01:00", "amount": 4000, "currency": "USD", "standingInstructions": { "sequence": "subsequent", "processingModel": "recurring" } }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "1226", "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "refunds": [ { "refundId": "G6T6S6KF74", "dateTime": "2023-05-25T11:12:55+01:00", "amount": -4000, "currency": "USD", "status": "ready", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/refunds/G6T6S6KF74" } } ], "transactionResult": { "type": "sale", "status": "ready", "approvalCode": "OK14486", "authorizedAmount": 4000, "currency": "USD", "responseCode": "A", "responseMessage": "OK14486", "cardSchemeReferenceId": "JxDfFMHyOE2lyQJ2MnFp" } } ``` # Send an unreferenced refund to a customer’s bank account Source: https://docs.payroc.com/guides/payments/refunds/unreferenced-refund-bank Send an unreferenced refund to a customer's bank account by posting to the Bank Transfer Refunds endpoint without a paymentId. **Prerequisites:** [Authentication](/api/authentication) **Note:** Only certain merchant accounts can send unreferenced refunds. A merchant can refund a payment to a customer's bank account without a paymentId by running an unreferenced refund. ## Integration steps **Step 1.** Refund the payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Refund the payment To refund a bank transfer payment, send a POST request to the Bank Transfer Refunds endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-refunds` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /bank-transfer-refunds`](/api/bank-transfer-unreferenced-refund) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-refunds](https://api.payroc.com/v1/bank-transfer-refunds) **`Bank Transfer Unreferenced Refund`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-refunds \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "refundMethod": { "type": "ach", "accountNumber": "1234567890", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "123456789", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Bank Transfer Unreferenced Refund`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-refunds" payload = { "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "refundMethod": { "type": "ach", "accountNumber": "1234567890", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "123456789", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Bank Transfer Unreferenced Refund`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-refunds'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","description":"Refund for order OrderRef6543","amount":4999,"currency":"USD"},"refundMethod":{"type":"ach","accountNumber":"1234567890","nameOnAccount":"Sarah Hazel Hopper","routingNumber":"123456789","accountType":"checking","secCode":"web"},"customer":{"notificationLanguage":"en","contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}]},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Bank Transfer Unreferenced Refund`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-refunds" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"refundMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"1234567890\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"123456789\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Bank Transfer Unreferenced Refund`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-refunds") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"refundMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"1234567890\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"123456789\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Bank Transfer Unreferenced Refund`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-refunds") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"refundMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"1234567890\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"123456789\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Bank Transfer Unreferenced Refund`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-refunds', [ 'body' => '{ "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "refundMethod": { "type": "ach", "accountNumber": "1234567890", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "123456789", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Bank Transfer Unreferenced Refund`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-refunds"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"refundMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"1234567890\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"123456789\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Bank Transfer Unreferenced Refund`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" ], "refundMethod": [ "type": "ach", "accountNumber": "1234567890", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "123456789", "accountType": "checking", "secCode": "web" ], "customer": [ "notificationLanguage": "en", "contactMethods": [ [ "type": "email", "value": "sarah.hopper@example.com" ] ] ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-refunds")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we send the refund to the customer's bank account and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-refunds`](/api/bank-transfer-unreferenced-refund) ### Example response ### Response (201) ```json { "refundId": "CD3HN88U9F", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z" }, "bankAccount": { "type": "ach", "accountNumber": "****7890", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "*****6789", "secCode": "web" }, "transactionResult": { "type": "unreferencedRefund", "status": "ready", "responseCode": "A", "authorizedAmount": -4999, "currency": "USD", "responseMessage": "NoError", "processorResponseCode": "0" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Run an unreferenced refund for a card payment Source: https://docs.payroc.com/guides/payments/refunds/unreferenced-refund-card Run an unreferenced card refund by sending a POST request to the Refunds endpoint without a paymentId to return funds to a customer's card. **Prerequisites:** [Authentication](/api/authentication) A merchant can return a payment to a customer’s card without a paymentId by running an unreferenced refund. ## Integration steps **Step 1.** Refund the payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Refund the payment To refund a card transfer payment, send a POST request to the Refund endpoint. **Endpoint:** `https://api.payroc.com/v1/refunds` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /refunds`](/api/unreferenced-refund) ### Example request ### Request POST [https://api.payroc.com/v1/refunds](https://api.payroc.com/v1/refunds) **`Refund`** ```curl curl -X POST https://api.payroc.com/v1/refunds \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "channel": "pos", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "refundMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA920", "serialNumber": "1850010868" }, "expiryDate": "1230" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Refund`** ```python import requests url = "https://api.payroc.com/v1/refunds" payload = { "channel": "pos", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "refundMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA920", "serialNumber": "1850010868" }, "expiryDate": "1230" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Refund`** ```javascript const url = 'https://api.payroc.com/v1/refunds'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"channel":"pos","processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","description":"Refund for order OrderRef6543","amount":4999,"currency":"USD"},"refundMethod":{"type":"card","cardDetails":{"entryMethod":"keyed","keyedData":{"dataFormat":"plainText","cardNumber":"4539858876047062","device":{"model":"paxA920","serialNumber":"1850010868"},"expiryDate":"1230"}}},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Refund`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/refunds" payload := strings.NewReader("{\n \"channel\": \"pos\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"refundMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA920\",\n \"serialNumber\": \"1850010868\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Refund`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/refunds") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"channel\": \"pos\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"refundMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA920\",\n \"serialNumber\": \"1850010868\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Refund`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/refunds") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"channel\": \"pos\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"refundMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA920\",\n \"serialNumber\": \"1850010868\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Refund`** ```php request('POST', 'https://api.payroc.com/v1/refunds', [ 'body' => '{ "channel": "pos", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" }, "refundMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA920", "serialNumber": "1850010868" }, "expiryDate": "1230" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Refund`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/refunds"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"channel\": \"pos\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Refund for order OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\"\n },\n \"refundMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA920\",\n \"serialNumber\": \"1850010868\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Refund`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "channel": "pos", "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD" ], "refundMethod": [ "type": "card", "cardDetails": [ "entryMethod": "keyed", "keyedData": [ "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": [ "model": "paxA920", "serialNumber": "1850010868" ], "expiryDate": "1230" ] ] ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/refunds")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we refund the card transfer payment and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /refunds`](/api/unreferenced-refund) ### Example response ### Response (201) ```json { "refundId": "CD3HN88U9F", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "description": "Refund for order OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z" }, "card": { "type": "Visa Credit", "cardNumber": "453985******7062", "expiryDate": "1230", "entryMethod": "keyed" }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "refund", "approvalCode": "000000", "authorizedAmount": -4999, "currency": "USD", "responseMessage": "OK5" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Reverse a bank transfer payment Source: https://docs.payroc.com/guides/payments/refunds/void-bank Reverse a bank transfer payment in an open batch by sending a POST request to the Bank Transfer Payments reverse endpoint with the paymentId. **Prerequisites:** [Authentication](/api/authentication) If a customer requests a refund and the payment is still in an open batch, the merchant can use their POS to look up the bank transfer payment and cancel the transaction. To find the paymentId of the bank transfer payment that the merchant wants to reverse, they can retrieve a list of all the bank transfer payments that meet the search criteria that the merchant provides. They can then find the transaction that they want in the list of returned results. **Note:** If the merchant runs a referenced refund on a bank transfer payment that is in an open batch, our gateway automatically reverses the payment. ## Integration steps **Step 1.** (Optional) List bank transfer payments. **Step 2.** Reverse the bank transfer payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ### Headers To create the header of each GET request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. ```bash curl -H "Content-Type: application/json" -H "Authorization: " ``` To create the header of each POST request, you must include the following parameters: - **Content-Type:** Include application/json as the value for this parameter. - **Authorization:** Include your Bearer token in this parameter. - **Idempotency-Key:** Include a UUID v4 to make the request idempotent. ```bash curl -H "Content-Type: application/json" -H "Authorization: " -H "Idempotency-Key: " ``` ### Errors If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors). ## Step 1. (Optional) List bank transfer payments To retrieve a list of bank transfer payments, send a GET request to our Bank Transfer Payments endpoint. Use our filters to narrow down the search results. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.query`) [Query parameters for `GET /bank-transfer-payments`](/api/list-bank-transfer-payments) ### Example request ### Request GET [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) **`Bank Transfer Payment`** ```curl curl -G https://api.payroc.com/v1/bank-transfer-payments \ -H "Authorization: Bearer " \ -d after=8516 \ -d before=2571 \ --data-urlencode dateFrom=2024-07-01T00:00:00Z \ --data-urlencode dateTo=2024-07-31T23:59:59Z \ -d last4=7890 \ -d limit=25 \ --data-urlencode nameOnAccount=Sarah%20Hazel%20Hopper \ -d orderId=OrderRef6543 \ -d paymentLinkId=JZURRJBUPS \ -d processingTerminalId=1234001 \ -d settlementDate=2024-07-15 \ -d settlementState=settled \ -d status=ready \ -d type=payment ``` **`Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments" querystring = {"after":"8516","before":"2571","dateFrom":"2024-07-01T00:00:00Z","dateTo":"2024-07-31T23:59:59Z","last4":"7890","limit":"25","nameOnAccount":"Sarah%20Hazel%20Hopper","orderId":"OrderRef6543","paymentLinkId":"JZURRJBUPS","processingTerminalId":"1234001","settlementDate":"2024-07-15","settlementState":"settled","status":"[\"ready\"]","type":"[\"payment\"]"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` **`Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Bank Transfer Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D") .header("Authorization", "Bearer ") .asString(); ``` **`Bank Transfer Payment`** ```php request('GET', 'https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Bank Transfer Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments?after=8516&before=2571&dateFrom=2024-07-01T00%3A00%3A00Z&dateTo=2024-07-31T23%3A59%3A59Z&last4=7890&limit=25&nameOnAccount=Sarah%2520Hazel%2520Hopper&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-15&settlementState=settled&status=%5B%22ready%22%5D&type=%5B%22payment%22%5D")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we retrieve a list of the bank transfer payments and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `GET /bank-transfer-payments`](/api/list-bank-transfer-payments) ### Example response ### Response (200) ```json { "limit": 2, "count": 2, "hasMore": true, "data": [ { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "pad", "accountNumber": "*******3159", "institutionNumber": "543", "nameOnAccount": "Sarah Hazel Hopper", "transitNumber": "76543" }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] } }, { "paymentId": "E29U8OU8Q4", "processingTerminalId": "1234001", "order": { "amount": 3999, "currency": "USD", "orderId": "OrderRef7654", "breakdown": { "subtotal": 3477, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 174 } ], "tip": { "type": "percentage", "amount": 348, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "test" }, "bankAccount": { "type": "pad", "accountNumber": "*******7890", "institutionNumber": "543", "nameOnAccount": "Sarah Hazel Hopper", "transitNumber": "76543" }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 3999, "currency": "USD" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ], "links": [ { "rel": "next", "method": "get", "href": "https://api.payroc.com/v1/bank-transfer-payments?limit=2&processingTerminalId=1234001&after=E29U8OU8Q4" }, { "rel": "previous", "method": "get", "href": "https://api.payroc.com/v1//bank-transfer-payments?limit=2&processingTerminalId=1234001&before=M2MJOG6O2Y" } ] } ``` ## Step 2. Reverse the bank transfer payment To reverse a bank transfer payment, send a POST request to the Bank Transfer Payments endpoint. If the merchant wants to reverse only part of the transaction, send the amount that they want to reverse in the amount parameter. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments/{paymentId}/reverse` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.path`) [Path parameters for `POST /bank-transfer-payments/{paymentId}/reverse`](/api/reverse-bank-transfer-payment) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-payments/\{paymentId\}/reverse](https://api.payroc.com/v1/bank-transfer-payments/%7BpaymentId%7D/reverse) **`Reverse Bank Transfer Payment`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " ``` **`Reverse Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse" headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer " } response = requests.post(url, headers=headers) print(response.json()) ``` **`Reverse Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ' } }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Reverse Bank Transfer Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Reverse Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Reverse Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .asString(); ``` **`Reverse Bank Transfer Payment`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse', [ 'headers' => [ 'Authorization' => 'Bearer ', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Reverse Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Reverse Bank Transfer Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer " ] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/reverse")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we reverse the bank transfer payment and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-payments/{paymentId}/reverse`](/api/reverse-bank-transfer-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "VAT", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "pad", "accountNumber": "*******7890", "institutionNumber": "543", "nameOnAccount": "Sarah Hazel Hopper", "transitNumber": "76543" }, "transactionResult": { "type": "payment", "status": "reversal", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Reverse a card sale or a pre-authorization Source: https://docs.payroc.com/guides/payments/refunds/void-card Reverse a card sale or pre-authorization in an open batch by sending a POST request to the Reverse endpoint with the paymentId. **Prerequisites:** [Authentication](/api/authentication) An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). If a customer requests a refund and the payment is still in an open batch, the merchant can use their POS to look up the card payment and cancel the transaction. To find the `paymentId` of the card payment that the merchant wants to reverse, they can retrieve a list of all the card payments that meet the search criteria that the merchant provides. They can then find the transaction that they want in the list of returned results. **Note:** If the merchant runs a referenced refund on a bank transfer payment that is in an open batch, our gateway automatically reverses the payment. ## Integration steps **Step 1.** (Optional) List card payments. **Step 2.** Reverse a card payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1 (Optional) List payments To retrieve a list of card payments, send a GET request to our Payments endpoint. Use our filters to narrow down the search results. **Endpoint:** `https://api.payroc.com/v1/payments` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.query`) [Query parameters for `GET /payments`](/api/list-payments) ### Example request ### Request GET [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **`Payment`** ```curl curl -G https://api.payroc.com/v1/payments \ -H "Authorization: Bearer " \ -d after=8516 \ -d before=2571 \ --data-urlencode cardholderName=Sarah%20Hazel%20Hopper \ --data-urlencode dateFrom=2024-07-01T15:30:00Z \ --data-urlencode dateTo=2024-07-03T15:30:00Z \ -d first6=453985 \ -d last4=7062 \ -d limit=25 \ -d operator=Jane \ -d orderId=OrderRef6543 \ -d paymentLinkId=JZURRJBUPS \ -d processingTerminalId=1234001 \ -d settlementDate=2024-07-02 \ -d settlementState=settled \ -d status=accepted \ -d status=ready \ -d status=complete \ -d tender=ebt \ -d tipMode=noTip \ -d tipMode=prompted \ -d type=sale \ -d type=preAuthorization ``` **`Payment`** ```python import requests url = "https://api.payroc.com/v1/payments" querystring = {"after":"8516","before":"2571","cardholderName":"Sarah%20Hazel%20Hopper","dateFrom":"2024-07-01T15:30:00Z","dateTo":"2024-07-03T15:30:00Z","first6":"453985","last4":"7062","limit":"25","operator":"Jane","orderId":"OrderRef6543","paymentLinkId":"JZURRJBUPS","processingTerminalId":"1234001","settlementDate":"2024-07-02","settlementState":"settled","status":"[\"accepted\",\"ready\",\"complete\"]","tender":"ebt","tipMode":"[\"noTip\",\"prompted\"]","type":"[\"sale\",\"preAuthorization\"]"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` **`Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D") .header("Authorization", "Bearer ") .asString(); ``` **`Payment`** ```php request('GET', 'https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments?after=8516&before=2571&cardholderName=Sarah%2520Hazel%2520Hopper&dateFrom=2024-07-01T15%3A30%3A00Z&dateTo=2024-07-03T15%3A30%3A00Z&first6=453985&last4=7062&limit=25&operator=Jane&orderId=OrderRef6543&paymentLinkId=JZURRJBUPS&processingTerminalId=1234001&settlementDate=2024-07-02&settlementState=settled&status=%5B%22accepted%22%2C%22ready%22%2C%22complete%22%5D&tender=ebt&tipMode=%5B%22noTip%22%2C%22prompted%22%5D&type=%5B%22sale%22%2C%22preAuthorization%22%5D")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we retrieve the card payment information and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `GET /payments`](/api/list-payments) ### Example response ### Response (200) ```json { "limit": 2, "count": 2, "hasMore": true, "data": [ { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Monthly Premium Club subscription" }, "card": { "type": "Visa Credit", "cardNumber": "453985******7062", "expiryDate": "1230", "entryMethod": "keyed", "cardholderName": "Sarah Hopper", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "securityChecks": { "cvvResult": "M", "avsResult": "X" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "APPROVAL" }, "operator": "Automatic Payment", "supportedOperations": [ "fullyReverse", "setAsPending" ] }, { "paymentId": "E29U8OU8Q4", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef7654", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Monthly Premium Club subscription" }, "card": { "type": "Visa Debit", "cardNumber": "453985******7062", "expiryDate": "1230", "entryMethod": "keyed", "cardholderName": "Sarah Hopper", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "securityChecks": { "cvvResult": "M", "avsResult": "X" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "475318", "authorizedAmount": 1000, "currency": "EUR", "responseMessage": "APPROVAL" }, "operator": "Automatic Payment", "supportedOperations": [ "fullyReverse", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ], "links": [ { "rel": "next", "method": "get", "href": "https://api.payroc.com/v1/payments?processingTerminalId=1234001&limit=2&after=E29U8OU8Q4" }, { "rel": "previous", "method": "get", "href": "https://api.payroc.com/v1/payments?processingTerminalId=1234001&limit=2&before=M2MJOG6O2Y" } ] } ``` ## Step 2. Reverse a payment To reverse a card payment, send a POST request to our Reverse endpoint. If the merchant wants to reverse only part of the transaction, send the amount that they want to reverse in the amount parameter. **Endpoint:** `https://api.payroc.com/v1/payments/{paymentId}/reverse` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments/{paymentId}/reverse`](/api/reverse-payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments/\{paymentId\}/reverse](https://api.payroc.com/v1/payments/%7BpaymentId%7D/reverse) **`Reversal Payment`** ```curl curl -X POST https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "amount": 4999 }' ``` **`Reversal Payment`** ```python import requests url = "https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse" payload = { "amount": 4999 } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Reversal Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"amount":4999}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Reversal Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse" payload := strings.NewReader("{\n \"amount\": 4999\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Reversal Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"amount\": 4999\n}" response = http.request(request) puts response.read_body ``` **`Reversal Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"amount\": 4999\n}") .asString(); ``` **`Reversal Payment`** ```php request('POST', 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse', [ 'body' => '{ "amount": 4999 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Reversal Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"amount\": 4999\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Reversal Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["amount": 4999] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments/M2MJOG6O2Y/reverse")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we reverse the card payment and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments/{paymentId}/reverse`](/api/reverse-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "reversal", "responseCode": "A", "type": "sale", "approvalCode": "OK2", "authorizedAmount": 100, "currency": "USD", "responseMessage": "OK2" }, "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "IT", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Test cases Before you run test cases, read the [Payments](/guides/testing/online-payments) page in Test Your Integration. ### Reverse a card payment Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments/\{paymentId\}/reverse](https://api.payroc.com/v1/payments/%7BpaymentId%7D/reverse) **Note:** The previous payment must be in the open batch and not settled. **Example response** ```json { "paymentId": "LRJ1QWEFRN", "processingTerminalId": "3204001", "operator": "notRequired", "order": { "orderId": "Test_007", "dateTime": "2023-05-25T10:39:10+01:00", "amount": 4000, "currency": "USD", "standingInstructions": { "sequence": "subsequent", "processingModel": "recurring" } }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "1226", "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "type": "sale", "status": "reversal", "approvalCode": "OK14866", "authorizedAmount": 4000, "currency": "USD", "responseCode": "A", "responseMessage": "OK14866", "cardSchemeReferenceId": "zz67WbxsEwMkvbSNcxz9" } } ``` # Repeat payments Source: https://docs.payroc.com/guides/payments/repeat-payments Run recurring payments with your software or the gateway. Run recurring payments with your software or the gateway. - [Use our gateway](/guides/payments/repeat-payments/using-our-gateway-for-recurring-billing) - [Use your own software](/guides/payments/repeat-payments/using-your-own-system-for-recurring-billing) # Use our gateway Source: https://docs.payroc.com/guides/payments/repeat-payments/using-our-gateway-for-recurring-billing Set up recurring billing by creating a payment plan, saving a secure token, and assigning a customer to a subscription via POST requests to the Payment Plans, Secure Tokens, and Subscriptions endpoints. **Prerequisites:** [Authentication](/api/authentication) A merchant can use our gateway to take repeat payments automatically or manually from their customers. ## How it works ```mermaid sequenceDiagram actor C as Customer participant MS as Merchant's server participant GW as Gateway rect rgba(0, 81, 194, 0.4) Note over MS,GW: Step 1 — Create a payment plan MS->>GW: POST /payment-plans Note over MS,GW: name, currency, type, frequency,
length, recurringOrder.amount GW-->>MS: paymentPlanId Note right of MS: Store paymentPlanId end rect rgba(0, 224, 184, 0.3) Note over C,GW: Step 2 — Create a secure token C->>MS: Provide payment details MS->>GW: POST /secure-tokens GW-->>MS: secureToken Note right of MS: Store the secure token end rect rgba(0, 224, 184, 0.3) Note over MS,GW: Step 3 — Create a subscription MS->>GW: POST /subscriptions Note over MS,GW: paymentPlanId,
paymentMethod.secureToken.token,
startDate GW-->>MS: subscriptionId Note right of MS: Store subscriptionId end rect rgba(0, 224, 184, 0.3) Note over C,GW: Step 4 — Collect payments alt Automatic plan GW-->>C: Gateway collects on schedule else Manual plan MS->>GW: POST /subscriptions/{subscriptionId}/pay Note over MS,GW: order.orderId, order.amount GW-->>MS: Payment confirmed end end ``` 1. You create a payment plan with our API. Our gateway returns a `paymentPlanId`. 2. You collect the customer's payment details and save them as a secure token. 3. You create a subscription to assign the customer to the payment plan. In your request, send the `paymentPlanId` and the secure token. 4. Our gateway collects payments automatically according to the plan schedule. If the payment plan uses manual collection, use the `subscriptionId` to collect each payment. A payment plan is a template that describes how the merchant takes payments from their customers, including the following information: - Number of payments - Length of the payment plan - Amount for each payment - How often payments are taken - Initial costs - Whether to automatically collect payments or manually collect payments A merchant can create multiple payment plans and assign multiple customers to each plan. For example, if the merchant wants to allow customers to pay in weekly installments or in monthly installments, the merchant creates a payment plan for each installment schedule. The merchant can then offer customers a choice of payment plans, and then use subscriptions to assign customers to the plans that they choose. If the merchant chooses to automatically collect payments, our gateway collects payments from each customer. If the merchant chooses to manually collect payments, they need to use their POS to collect the payments. ## Integration steps To use our gateway to take regular payments, integrate with the following: **Step 1.** Create a payment plan. **Step 2.** Create a secure token. **Step 3.** Create a subscription. **Step 4.** (Optional) Manually collect a payment from the customer. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Create a payment plan To create a payment plan, send a POST request to our Payment Plans endpoint: **Endpoint:** `https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/payment-plans` **Note:** To allow merchants to add their own information to the payment plan, use custom fields. For more information about how to add custom fields, go to [Add custom fields to your integration](/guides/payments/add-custom-fields). ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/payment-plans`](/api/create-payment-plan) ### Example request ### Request POST https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/payment-plans ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/payment-plans \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": [ "yourCustomField" ], "setupOrder": { "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } } }' ``` **`Payment Plan`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/payment-plans" payload = { "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": ["yourCustomField"], "setupOrder": { "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Payment Plan`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/payment-plans'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"paymentPlanId":"PlanRef8765","name":"Premium Club","currency":"USD","type":"automatic","frequency":"monthly","onUpdate":"continue","onDelete":"complete","description":"Monthly Premium Club subscription","length":12,"customFieldNames":["yourCustomField"],"setupOrder":{"amount":4999,"description":"Initial setup fee for Premium Club subscription","breakdown":{"subtotal":4347,"taxes":[{"name":"Sales Tax","rate":5}]}},"recurringOrder":{"amount":4999,"description":"Monthly Premium Club subscription","breakdown":{"subtotal":4347,"taxes":[{"name":"Sales Tax","rate":5}]}}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Payment Plan`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/payment-plans" payload := strings.NewReader("{\n \"paymentPlanId\": \"PlanRef8765\",\n \"name\": \"Premium Club\",\n \"currency\": \"USD\",\n \"type\": \"automatic\",\n \"frequency\": \"monthly\",\n \"onUpdate\": \"continue\",\n \"onDelete\": \"complete\",\n \"description\": \"Monthly Premium Club subscription\",\n \"length\": 12,\n \"customFieldNames\": [\n \"yourCustomField\"\n ],\n \"setupOrder\": {\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Payment Plan`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/payment-plans") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"paymentPlanId\": \"PlanRef8765\",\n \"name\": \"Premium Club\",\n \"currency\": \"USD\",\n \"type\": \"automatic\",\n \"frequency\": \"monthly\",\n \"onUpdate\": \"continue\",\n \"onDelete\": \"complete\",\n \"description\": \"Monthly Premium Club subscription\",\n \"length\": 12,\n \"customFieldNames\": [\n \"yourCustomField\"\n ],\n \"setupOrder\": {\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n }\n}" response = http.request(request) puts response.read_body ``` **`Payment Plan`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/payment-plans") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"paymentPlanId\": \"PlanRef8765\",\n \"name\": \"Premium Club\",\n \"currency\": \"USD\",\n \"type\": \"automatic\",\n \"frequency\": \"monthly\",\n \"onUpdate\": \"continue\",\n \"onDelete\": \"complete\",\n \"description\": \"Monthly Premium Club subscription\",\n \"length\": 12,\n \"customFieldNames\": [\n \"yourCustomField\"\n ],\n \"setupOrder\": {\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n }\n}") .asString(); ``` **`Payment Plan`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/payment-plans', [ 'body' => '{ "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": [ "yourCustomField" ], "setupOrder": { "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Payment Plan`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/payment-plans"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"paymentPlanId\": \"PlanRef8765\",\n \"name\": \"Premium Club\",\n \"currency\": \"USD\",\n \"type\": \"automatic\",\n \"frequency\": \"monthly\",\n \"onUpdate\": \"continue\",\n \"onDelete\": \"complete\",\n \"description\": \"Monthly Premium Club subscription\",\n \"length\": 12,\n \"customFieldNames\": [\n \"yourCustomField\"\n ],\n \"setupOrder\": {\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 5\n }\n ]\n }\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Payment Plan`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": ["yourCustomField"], "setupOrder": [ "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": [ "subtotal": 4347, "taxes": [ [ "name": "Sales Tax", "rate": 5 ] ] ] ], "recurringOrder": [ "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": [ "subtotal": 4347, "taxes": [ [ "name": "Sales Tax", "rate": 5 ] ] ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/payment-plans")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we create the payment plan and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/payment-plans`](/api/create-payment-plan) ### Example response ### Response (201) ```json { "paymentPlanId": "PlanRef8765", "name": "Premium Club", "currency": "USD", "type": "automatic", "frequency": "monthly", "onUpdate": "continue", "onDelete": "complete", "processingTerminalId": "1234001", "description": "Monthly Premium Club subscription", "length": 12, "customFieldNames": [ "yourCustomField" ], "setupOrder": { "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } } } ``` ## Step 2. Create a secure token \ **Important:** If you have already set up your integration to create a secure token, go to [Step 3. Create a subscription](#step-3-create-a-subscription). \ Before you can assign a customer to a payment plan, save their payment details and create a secure token. To save the customer’s payment details, send a POST request to our Secure Tokens endpoint. **Endpoint:** https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens \ **Note:** We assign the secure token to the terminal that sent the request. Depending on the merchant’s account settings, other terminals within the merchant’s account can also use the secure token. \ ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens`](/api/create-secure-token) ### Example request ### Request POST https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Secure Token`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" payload = { "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Secure Token`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"source":{"type":"card","cardDetails":{"entryMethod":"keyed","keyedData":{"dataFormat":"plainText","cardNumber":"4539858876047062","cvv":"234","expiryDate":"1230"},"cardholderName":"Sarah Hazel Hopper"}},"operator":"Jane","mitAgreement":"unscheduled","customer":{"firstName":"Sarah","lastName":"Hopper","dateOfBirth":"1990-07-15","referenceNumber":"Customer-12","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}},"contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}],"notificationLanguage":"en"},"ipAddress":{"type":"ipv4","value":"104.18.24.203"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Secure Token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" payload := strings.NewReader("{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Secure Token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Secure Token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Secure Token`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens', [ 'body' => '{ "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Secure Token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Secure Token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "source": [ "type": "card", "cardDetails": [ "entryMethod": "keyed", "keyedData": [ "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" ], "cardholderName": "Sarah Hazel Hopper" ] ], "operator": "Jane", "mitAgreement": "unscheduled", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ], "contactMethods": [ [ "type": "email", "value": "sarah.hopper@example.com" ] ], "notificationLanguage": "en" ], "ipAddress": [ "type": "ipv4", "value": "104.18.24.203" ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we store the customer’s payment details and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens`](/api/create-secure-token) ### Example response ### Response (201) ```json { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Hazel Hopper", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Step 3. Create a subscription To assign a customer to a payment plan, send a POST request to our Subscriptions endpoint. You can also use this request to personalize the payment plan for each customer, for example, provide a discount on each payment or add a one-off setup fee. **Endpoint:** https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/subscriptions`](/api/create-subscription) ### Example request ### Request POST https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/subscriptions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "subscriptionId": "SubRef7654", "paymentPlanId": "PlanRef8765", "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "startDate": "2024-07-02", "name": "Premium Club", "description": "Premium Club subscription", "setupOrder": { "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription" }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ] } }, "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0 }' ``` **`Subscription with surcharge`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions" payload = { "subscriptionId": "SubRef7654", "paymentPlanId": "PlanRef8765", "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "startDate": "2024-07-02", "name": "Premium Club", "description": "Premium Club subscription", "setupOrder": { "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription" }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ] } }, "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0 } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Subscription with surcharge`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/subscriptions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"subscriptionId":"SubRef7654","paymentPlanId":"PlanRef8765","paymentMethod":{"type":"secureToken","token":"296753123456"},"startDate":"2024-07-02","name":"Premium Club","description":"Premium Club subscription","setupOrder":{"orderId":"OrderRef6543","amount":4999,"description":"Initial setup fee for Premium Club subscription"},"recurringOrder":{"amount":4999,"description":"Monthly Premium Club subscription","breakdown":{"subtotal":4347,"taxes":[{"rate":5,"name":"Sales Tax","type":"rate"}]}},"endDate":"2025-07-01","length":12,"pauseCollectionFor":0}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Subscription with surcharge`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions" payload := strings.NewReader("{\n \"subscriptionId\": \"SubRef7654\",\n \"paymentPlanId\": \"PlanRef8765\",\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"startDate\": \"2024-07-02\",\n \"name\": \"Premium Club\",\n \"description\": \"Premium Club subscription\",\n \"setupOrder\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\"\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ]\n }\n },\n \"endDate\": \"2025-07-01\",\n \"length\": 12,\n \"pauseCollectionFor\": 0\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Subscription with surcharge`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"subscriptionId\": \"SubRef7654\",\n \"paymentPlanId\": \"PlanRef8765\",\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"startDate\": \"2024-07-02\",\n \"name\": \"Premium Club\",\n \"description\": \"Premium Club subscription\",\n \"setupOrder\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\"\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ]\n }\n },\n \"endDate\": \"2025-07-01\",\n \"length\": 12,\n \"pauseCollectionFor\": 0\n}" response = http.request(request) puts response.read_body ``` **`Subscription with surcharge`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"subscriptionId\": \"SubRef7654\",\n \"paymentPlanId\": \"PlanRef8765\",\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"startDate\": \"2024-07-02\",\n \"name\": \"Premium Club\",\n \"description\": \"Premium Club subscription\",\n \"setupOrder\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\"\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ]\n }\n },\n \"endDate\": \"2025-07-01\",\n \"length\": 12,\n \"pauseCollectionFor\": 0\n}") .asString(); ``` **`Subscription with surcharge`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/subscriptions', [ 'body' => '{ "subscriptionId": "SubRef7654", "paymentPlanId": "PlanRef8765", "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "startDate": "2024-07-02", "name": "Premium Club", "description": "Premium Club subscription", "setupOrder": { "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription" }, "recurringOrder": { "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ] } }, "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Subscription with surcharge`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"subscriptionId\": \"SubRef7654\",\n \"paymentPlanId\": \"PlanRef8765\",\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"startDate\": \"2024-07-02\",\n \"name\": \"Premium Club\",\n \"description\": \"Premium Club subscription\",\n \"setupOrder\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Initial setup fee for Premium Club subscription\"\n },\n \"recurringOrder\": {\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ]\n }\n },\n \"endDate\": \"2025-07-01\",\n \"length\": 12,\n \"pauseCollectionFor\": 0\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Subscription with surcharge`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "subscriptionId": "SubRef7654", "paymentPlanId": "PlanRef8765", "paymentMethod": [ "type": "secureToken", "token": "296753123456" ], "startDate": "2024-07-02", "name": "Premium Club", "description": "Premium Club subscription", "setupOrder": [ "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription" ], "recurringOrder": [ "amount": 4999, "description": "Monthly Premium Club subscription", "breakdown": [ "subtotal": 4347, "taxes": [ [ "rate": 5, "name": "Sales Tax", "type": "rate" ] ] ] ], "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we assign the customer to the payment plan and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/subscriptions`](/api/create-subscription) ### Example response ### Response (201) ```json { "subscriptionId": "SubRef7654", "processingTerminalId": "1234001", "paymentPlan": { "paymentPlanId": "PlanRef8765", "name": "Monthly Premium Club subscription", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/payment-plans/PlanRef8765" } }, "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "name": "Premium Club", "currency": "USD", "currentState": { "status": "active", "paidInvoices": 0, "nextDueDate": "2024-08-02", "outstandingInvoices": 3 }, "startDate": "2024-07-02", "type": "automatic", "frequency": "monthly", "description": "Premium Club subscription", "setupOrder": { "orderId": "OrderRef6543", "amount": 4999, "description": "Initial setup fee for Premium Club subscription", "breakdown": { "subtotal": 4347, "surcharge": { "amount": 217, "percentage": 5 }, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "recurringOrder": { "amount": 4999, "description": "Premium Club subscription", "breakdown": { "subtotal": 4347, "surcharge": { "amount": 217, "percentage": 5 }, "taxes": [ { "name": "Sales Tax", "rate": 5 } ] } }, "endDate": "2025-07-01", "length": 12, "pauseCollectionFor": 0, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Step 4. (Optional) Manually collect a payment The merchant can choose to let our gateway automatically collect payments, or the merchant can manually collect payments. If the merchant chooses to manually collect payments, you must send a request every time the merchant wants to collect a payment from the customer. To manually collect a payment from a customer, send a POST request to the Subscriptions endpoint. **Endpoint:** https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/pay ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/subscriptions/{subscriptionId}/pay`](/api/pay-subscription) ### Example request ### Request POST https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/pay ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "order": { "orderId": "OrderRef6543", "amount": 4999, "description": "Monthly Premium Club subscription" }, "operator": "Jane" }' ``` **`Subscription manual payment`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay" payload = { "order": { "orderId": "OrderRef6543", "amount": 4999, "description": "Monthly Premium Club subscription" }, "operator": "Jane" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Subscription manual payment`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"order":{"orderId":"OrderRef6543","amount":4999,"description":"Monthly Premium Club subscription"},"operator":"Jane"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Subscription manual payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay" payload := strings.NewReader("{\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\"\n },\n \"operator\": \"Jane\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Subscription manual payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\"\n },\n \"operator\": \"Jane\"\n}" response = http.request(request) puts response.read_body ``` **`Subscription manual payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\"\n },\n \"operator\": \"Jane\"\n}") .asString(); ``` **`Subscription manual payment`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay', [ 'body' => '{ "order": { "orderId": "OrderRef6543", "amount": 4999, "description": "Monthly Premium Club subscription" }, "operator": "Jane" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Subscription manual payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"description\": \"Monthly Premium Club subscription\"\n },\n \"operator\": \"Jane\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Subscription manual payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "order": [ "orderId": "OrderRef6543", "amount": 4999, "description": "Monthly Premium Club subscription" ], "operator": "Jane" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/subscriptions/SubRef7654/pay")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we take the payment from the customer and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/subscriptions/{subscriptionId}/pay`](/api/pay-subscription) ### Example response ### Response (201) ```json { "subscriptionId": "SubRef7654", "processingTerminalId": "1234001", "payment": { "paymentId": "M2MJOG6O2Y", "dateTime": "2024-07-02T15:30:00Z", "currency": "USD", "amount": 4999, "status": "ready", "responseCode": "A", "responseMessage": "Transaction approved", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" } }, "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "currentState": { "status": "active", "paidInvoices": 1, "nextDueDate": "2024-08-02", "outstandingInvoices": 2 }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Test cases Before you run test cases, read the [Payments](/test/test-your-integration/payments) page in Test Your Integration. ### Create a payment plan Send a POST request to the following endpoint: POST https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/payment-plans **Example response** ```json { "paymentPlanId": "PaymentPlanTest", "processingTerminalId": "3204001", "name": "Davi Crisostomo", "description": "Payment Plan creation", "currency": "USD", "setupOrder": { "amount": 11000, "description": "Setup Amount" }, "length": 24, "type": "manual", "frequency": "monthly", "onUpdate": "update", "onDelete": "complete" } ``` ### Create a secure token Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) **Example response** ```json { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "processingTerminalId": "3204001", "source": { "type": "card", "cardholderName": "", "cardNumber": "444433******1111", "expiryDate": "1226" }, "token": "2967538502417872", "status": "cvv_validated" } ``` ### Create a subscription for a payment plan Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/subscriptions) **Example response** ```json { "subscriptionId": "SubTest", "processingTerminalId": "3204001", "paymentPlan": { "paymentPlanId": "PaymentPlanTest", "name": "Davi Crisostomo", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/payment-plans/PaymentPlanTest" } }, "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "name": "Davi Crisostomo", "description": "Create Subscription from ICC payment", "currency": "USD", "setupOrder": { "orderId": "TheOrderID", "amount": 11000, "description": "Description of SETUPORDER" }, "recurringOrder": { "amount": 11000, "description": "RECURRING Order price" }, "currentState": { "status": "active", "nextDueDate": "2023-08-02", "paidInvoices": 0, "outstandingInvoices": 122 }, "startDate": "2023-08-02", "endDate": "2025-12-02", "length": 24, "type": "automatic", "frequency": "weekly", "pauseCollectionFor": 0 } ``` ### Manually pay a subscription Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/pay](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/subscriptions/%7BsubscriptionId%7D/pay) **Example response** ```json { "paymentId": "KOHM1D3EZH", "processingTerminalId": "3204001", "operator": "Davi Crisostomo", "order": { "orderId": "UniqueValueForOrderID", "dateTime": "2023-06-20T20:25:57.641+01:00", "description": "Subscription Payment - Manual", "amount": 11000, "currency": "USD" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "1226", "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "type": "sale", "status": "ready", "approvalCode": "OK24225", "authorizedAmount": 11000, "currency": "USD", "responseCode": "A", "responseMessage": "OK24225", "cardSchemeReferenceId": "nkMX2G7ZqPavgbYiYacQ" } } ``` # Use your own software Source: https://docs.payroc.com/guides/payments/repeat-payments/using-your-own-system-for-recurring-billing Set up recurring billing using your own software by creating secure tokens and sending POST requests to the Payments endpoint with standingInstructions to manage the payment cycle. **Prerequisites:** [Authentication](/api/authentication) If you use your own software to manage repeat payments, program your software to run a sale each time the merchant wants to take a payment. Each request should also include the following information: - Type of repeat payment - Position of the payment in the billing cycle - Information about the first payment You can also use our tokenization service to save the customer’s payment details as a secure token. For each repeat payment, you can use the secure token instead of the customer's payment details. ## Integration steps To use your own software for repeat payments, integrate with the following: **Step 1.** (Optional) Create a secure token. **Step 2.** Create a payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. (Optional) Create a secure token **Note:** If you have already set up your integration to create a secure token, go to [Step 2. Create a payment](#step-2-create-a-payment). To save the customer’s payment details, send a POST request to our Secure Tokens endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/secure-tokens` **Note:** We assign the secure token to the terminal that sent the request. Depending on the merchant’s account settings, other terminals within the merchant’s account can also use the secure token. ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens`](/api/create-secure-token) ### Example request ### Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) **`Secure Token`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Secure Token`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" payload = { "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Secure Token`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"source":{"type":"card","cardDetails":{"entryMethod":"keyed","keyedData":{"dataFormat":"plainText","cardNumber":"4539858876047062","cvv":"234","expiryDate":"1230"},"cardholderName":"Sarah Hazel Hopper"}},"operator":"Jane","mitAgreement":"unscheduled","customer":{"firstName":"Sarah","lastName":"Hopper","dateOfBirth":"1990-07-15","referenceNumber":"Customer-12","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}},"contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}],"notificationLanguage":"en"},"ipAddress":{"type":"ipv4","value":"104.18.24.203"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Secure Token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" payload := strings.NewReader("{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Secure Token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Secure Token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Secure Token`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens', [ 'body' => '{ "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Secure Token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Secure Token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "source": [ "type": "card", "cardDetails": [ "entryMethod": "keyed", "keyedData": [ "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" ], "cardholderName": "Sarah Hazel Hopper" ] ], "operator": "Jane", "mitAgreement": "unscheduled", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ], "contactMethods": [ [ "type": "email", "value": "sarah.hopper@example.com" ] ], "notificationLanguage": "en" ], "ipAddress": [ "type": "ipv4", "value": "104.18.24.203" ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we store the customer’s payment details and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens`](/api/create-secure-token) ### Example response ### Response (201) ```json { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Hazel Hopper", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Step 2. Create a payment You can run repeat payments with card details or with bank details. The endpoint that you use depends on the payment method: - [Create a card payment](). - [Create a bank transfer payment](). ### Create a card payment To take a payment from the customer, send a POST request to the Payments endpoint. In your request, include the standingInstructions object, which contains information about the repeat payment. **Endpoint:** `https://api.payroc.com/v1/payments` #### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments`](/api/payment) #### Example request ### Request POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **`Card sale with secure token and is the first payment in a series`** ```curl curl -X POST https://api.payroc.com/v1/payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Pizza Doe #1234 - Dinner", "standingInstructions": { "sequence": "first", "processingModel": "recurring" } }, "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "credentialOnFile": { "mitAgreement": "recurring" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Card sale with secure token and is the first payment in a series`** ```python import requests url = "https://api.payroc.com/v1/payments" payload = { "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Pizza Doe #1234 - Dinner", "standingInstructions": { "sequence": "first", "processingModel": "recurring" } }, "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "credentialOnFile": { "mitAgreement": "recurring" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Card sale with secure token and is the first payment in a series`** ```javascript const url = 'https://api.payroc.com/v1/payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"channel":"web","processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","amount":4999,"currency":"USD","description":"Pizza Doe #1234 - Dinner","standingInstructions":{"sequence":"first","processingModel":"recurring"}},"paymentMethod":{"type":"secureToken","token":"296753123456"},"operator":"Jane","customer":{"firstName":"Sarah","lastName":"Hopper","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}}},"credentialOnFile":{"mitAgreement":"recurring"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Card sale with secure token and is the first payment in a series`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments" payload := strings.NewReader("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Pizza Doe #1234 - Dinner\",\n \"standingInstructions\": {\n \"sequence\": \"first\",\n \"processingModel\": \"recurring\"\n }\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"mitAgreement\": \"recurring\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Card sale with secure token and is the first payment in a series`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Pizza Doe #1234 - Dinner\",\n \"standingInstructions\": {\n \"sequence\": \"first\",\n \"processingModel\": \"recurring\"\n }\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"mitAgreement\": \"recurring\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Card sale with secure token and is the first payment in a series`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Pizza Doe #1234 - Dinner\",\n \"standingInstructions\": {\n \"sequence\": \"first\",\n \"processingModel\": \"recurring\"\n }\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"mitAgreement\": \"recurring\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Card sale with secure token and is the first payment in a series`** ```php request('POST', 'https://api.payroc.com/v1/payments', [ 'body' => '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Pizza Doe #1234 - Dinner", "standingInstructions": { "sequence": "first", "processingModel": "recurring" } }, "paymentMethod": { "type": "secureToken", "token": "296753123456" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "credentialOnFile": { "mitAgreement": "recurring" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Card sale with secure token and is the first payment in a series`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Pizza Doe #1234 - Dinner\",\n \"standingInstructions\": {\n \"sequence\": \"first\",\n \"processingModel\": \"recurring\"\n }\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"credentialOnFile\": {\n \"mitAgreement\": \"recurring\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Card sale with secure token and is the first payment in a series`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "channel": "web", "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Pizza Doe #1234 - Dinner", "standingInstructions": [ "sequence": "first", "processingModel": "recurring" ] ], "paymentMethod": [ "type": "secureToken", "token": "296753123456" ], "operator": "Jane", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ] ], "credentialOnFile": ["mitAgreement": "recurring"], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` #### Response fields If your request is successful, we create the payment and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments`](/api/payment) #### Example response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Pizza Doe #1234 - Dinner", "standingInstructions": { "sequence": "first", "processingModel": "recurring" } }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "cardholderName": "Sarah Hopper", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } }, "securityChecks": { "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3", "cardSchemeReferenceId": "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "fullyReverse", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ### Create a bank transfer payment To take a payment from the customer, send a POST request to our Bank Transfer Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments` ### Request parameters If you have a secure token that represents the bank account details, include the secure token in the paymentMethod object. ### Schema (`request.body`) [Request body schema for `POST /bank-transfer-payments`](/api/bank-transfer-payment) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) **`Bank transfer payment with a secure token`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "description": "Pizza Doe" }, "paymentMethod": { "type": "secureToken", "token": "296753123456", "accountType": "checking", "secCode": "web" }, "customer": { "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Bank transfer payment with a secure token`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments" payload = { "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "description": "Pizza Doe" }, "paymentMethod": { "type": "secureToken", "token": "296753123456", "accountType": "checking", "secCode": "web" }, "customer": { "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Bank transfer payment with a secure token`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","order":{"amount":4999,"currency":"USD","orderId":"OrderRef6543","description":"Pizza Doe"},"paymentMethod":{"type":"secureToken","token":"296753123456","accountType":"checking","secCode":"web"},"customer":{"contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}]},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Bank transfer payment with a secure token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Pizza Doe\"\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Bank transfer payment with a secure token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Pizza Doe\"\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Bank transfer payment with a secure token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Pizza Doe\"\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Bank transfer payment with a secure token`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-payments', [ 'body' => '{ "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "description": "Pizza Doe" }, "paymentMethod": { "type": "secureToken", "token": "296753123456", "accountType": "checking", "secCode": "web" }, "customer": { "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Bank transfer payment with a secure token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"description\": \"Pizza Doe\"\n },\n \"paymentMethod\": {\n \"type\": \"secureToken\",\n \"token\": \"296753123456\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ]\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Bank transfer payment with a secure token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "order": [ "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "description": "Pizza Doe" ], "paymentMethod": [ "type": "secureToken", "token": "296753123456", "accountType": "checking", "secCode": "web" ], "customer": ["contactMethods": [ [ "type": "email", "value": "sarah.hopper@example.com" ] ]], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we create the payment and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-payments`](/api/bank-transfer-payment) ### Example response ### Response (201) ```json { "paymentId": "E29U8OU8Q4", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "dateTime": "2024-07-02T15:30:00Z", "description": "Pizza Doe #1234 - Dinner" }, "bankAccount": { "type": "ach", "accountNumber": "******3491", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "063100277", "secCode": "web", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "bankAccountValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } } }, "transactionResult": { "type": "payment", "status": "pending", "responseCode": "P", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "Pending" }, "customer": { "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Test cases Before you run test cases, read the [Payments](/guides/testing/online-payments) page in Test Your Integration. ### Run a card sale Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **Example response** ```json { "paymentId": "F1I17KBL0E", "processingTerminalId": "3204001", "order": { "orderId": "Test_001", "dateTime": "2023-05-24T14:44:20.63+01:00", "amount": 4000, "currency": "USD" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "0334", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "paymentResult": { "type": "sale", "status": "ready", "approvalCode": "OK14472", "authorizedAmount": 4000, "currency": "USD", "responseCode": "A", "responseMessage": "OK14472" } } ``` # Tap to Pay on iPhone Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone Use our Tap to Pay on iPhone SDK to accept contactless card-present payments directly on an iPhone without an external card reader. **Prerequisites:** [Authentication](/api/authentication) Use our Tap to Pay on iPhone SDK to create an iOS app that accepts card-present payments directly on an iPhone. The SDK uses the iPhone's NFC reader and Apple's ProximityReader framework to securely read a customer's card details and send them directly to our gateway. Your app doesn't handle any sensitive card details. The SDK supports sales and referenced refunds, and accepts contactless credit and debit cards, Apple Pay, and other digital wallets that use NFC. ## How it works When a customer taps their card or device against the merchant's iPhone, our SDK communicates with the iPhone's contactless reader and our gateway to make the sale. ```mermaid sequenceDiagram participant YA as Your app participant SD as SDK participant IP as iPhone participant GW as Gateway rect rgba(0, 81, 194, 0.4) Note over YA,GW: Run a sale YA->>SD: 1. Initialize the SDK Note over YA: 2. Merchant starts a sale in your app YA->>SD: 3. Send the sale details SD->>IP: 4. Prompt the customer to tap their card IP-->>SD: 5. Return the card details SD->>GW: 6. Send the sale details and the card details GW-->>YA: 7. Return the sale response end ``` 1. Your app initializes the SDK. 2. The merchant starts a sale in your app, for example, the merchant enters an amount and taps **Charge**. 3. Your app calls the SDK with the sale details. 4. The iPhone prompts the customer to tap their card. 5. The iPhone reads the card and returns the card details to the SDK. 6. The SDK sends the sale details and the card details to our gateway to run the sale. 7. Our gateway authorizes the transaction and returns the sale response to your app. ## Before you begin Our guides use Xcode as your integrated development environment (IDE). If you work in a different IDE, your steps might differ. Make sure that you have the following: - Your processing terminal ID. We send you the terminal ID when you sign up with us. - Your integration API key. We send you the API key when you sign up with us. - An Apple Developer account that is enrolled in the Apple Developer Program. - The [Tap to Pay on iPhone entitlement](https://developer.apple.com/documentation/proximityreader/setting-up-the-entitlement-for-tap-to-pay-on-iphone) for your Apple Developer account. To distribute your app through the App Store, you also need to request a distribution entitlement. - A dedicated [Apple Pay sandbox account](https://developer.apple.com/apple-pay/sandbox-testing/) to connect to Apple's certification environment for testing. - A physical device. You can't run the SDK on an iOS simulator. ### Supported devices and iOS versions The SDK supports iPhone XS and later models that run iOS 18 or later. For the full list of supported iOS versions, go to [Apple's Business Register documentation](https://register-docs.apple.com/tap-to-pay-on-iphone/docs/ios-application-development#ios-deprecation-policy). ## Your integration journey 1. **[Set up the SDK](/guides/payments/tap-to-pay-on-iphone/set-up-the-sdk)** - Add the SDK to your Xcode project and configure your build settings. 2. **[Configure the processing terminal](/guides/payments/tap-to-pay-on-iphone/configure-the-processing-terminal)** - Initialize the terminal and load the merchant's payment settings from our gateway. 3. **[Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale)** - Register your listeners, initialize the reader, and process a sale. 4. **[Handle errors](/guides/payments/tap-to-pay-on-iphone/handle-errors)** - Handle transaction, communication, and device errors. ### Extend your integration After you set up your app to run a sale, you can extend your integration with additional features, for example: - Run refunds. - Retrieve transactions. - Add tips, taxes, and line items to a sale. - Handle surcharges. For more information about how to add these features to your integration, go to [Extend your integration](/guides/payments/tap-to-pay-on-iphone/extend-your-integration). # Add a line item Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/add-a-line-item Add itemized product details to a Tap to Pay on iPhone sale using the CoreLineItem object, including a per-item tax. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) To provide more information about a sale, you can add individual line items. Create a `CoreLineItem` object for each item, and assign the collection to the `CoreSale` object's lineItems array. The `CoreLineItem` object includes the following fields: | **Field** | **Description** | | --- | --- | | `commodityCode` | Commodity code of the item. | | `productCode` | Product code of the item. | | `itemDescription` | Description of the item. | | `unitOfMeasure` | Unit of measure. A three-letter code used in international trade. For more information about the values that you can use, go to [Units of measurement](/knowledge/api-basics/unit-of-measure). The SDK doesn't support the following units: `ANN`, `GIA`, `LBT`, `STN`, `YRD`. | | `unitPrice` | Price for each unit of measure before any taxes or discounts | | `quantity` | Number of units. | | `discountRate` | Discount percentage to apply to the item. | | `taxes` | The list of taxes to apply to the item. For more information, go to [Add a tax to a line item](#add-a-tax-to-a-line-item). | **Important:** The SDK doesn't calculate the sale amount from the line items for you. Set `sale.amount` to the subtotal of all your line items. The subtotal is the unit price multiplied by the quantity, minus any discount. The following example adds a line item to a sale: **`Swift`** ```swift let item = CoreLineItem() item.commodityCode = "AA" item.productCode = "BB" item.itemDescription = "Bread" item.unitOfMeasure = EA item.unitPrice = 2.00 item.quantity = 2 item.discountRate = 0 item.taxes = [] let lineItems = NSMutableArray() lineItems.add(item) let sale = CoreSale() sale.amount = NSNumber(value: 4.00) sale.transactionInputMethod = TAP sale.lineItems = lineItems terminal.processSale(sale) ``` **`Objective-C`** ```objectivec CoreLineItem *item = [[CoreLineItem alloc] init]; item.commodityCode = @"AA"; item.productCode = @"BB"; item.itemDescription = @"Bread"; item.unitOfMeasure = EA; item.unitPrice = @2.00; item.quantity = @2; item.discountRate = @0; item.taxes = [NSMutableArray array]; NSMutableArray *lineItems = [NSMutableArray array]; [lineItems addObject:item]; CoreSale *sale = [[CoreSale alloc] init]; sale.amount = @4.00; sale.transactionInputMethod = TAP; sale.lineItems = lineItems; [[WTPSTerminal singleton] processSale:sale]; ``` ## Add a tax to a line item To apply a tax to an individual line item, add a `CoreTax` to the item's `taxes` array. To calculate the tax amount from a percentage, use `CoreUtil`, and then set a global `CoreTax` on the sale with the total tax amount. **`Swift`** ```swift let tax = CoreTax() tax.percentage = 10 let taxAmount = (CoreUtil.singleton() as! CoreUtil).calcTax( tax.percentage, withAmount: item.unitPrice, with: terminal.currency ) tax.amount = taxAmount item.taxes = [tax] let globalTax = CoreTax() globalTax.amount = taxAmount globalTax.name = "Item tax" sale.tax = globalTax ``` **`Objective-C`** ```objectivec CoreTax *tax = [[CoreTax alloc] init]; tax.percentage = @10; NSNumber *taxAmount = [[CoreUtil singleton] calcTax:tax.percentage withAmount:item.unitPrice withCurrency:[[WTPSTerminal singleton] getCurrency]]; tax.amount = taxAmount; item.taxes = [NSMutableArray arrayWithObject:tax]; CoreTax *globalTax = [[CoreTax alloc] init]; globalTax.amount = taxAmount; globalTax.name = @"Item tax"; sale.tax = globalTax; ``` If you want to apply a tax to the whole sale instead of a single line item, go to [Add a tax](/guides/payments/tap-to-pay-on-iphone/add-a-tax). The following example runs a complete sale with a line item and a tax applied to that line item: **`Swift`** ```swift guard terminal.getDevice() != NODEVICE else { return } let unitPrice = 2.00 let quantity = 2.0 let lineSubtotal = unitPrice * quantity let item = CoreLineItem() item.commodityCode = "AA" item.productCode = "BB" item.itemDescription = "Bread" item.unitOfMeasure = EA item.unitPrice = NSNumber(value: unitPrice) item.quantity = NSNumber(value: quantity) item.discountRate = 0 let tax = CoreTax() tax.percentage = 10 tax.amount = (CoreUtil.singleton() as! CoreUtil).calcTax( tax.percentage, withAmount: NSNumber(value: lineSubtotal), with: terminal.currency ) item.taxes = [tax] let lineItems = NSMutableArray() lineItems.add(item) let globalTax = CoreTax() globalTax.amount = tax.amount globalTax.name = "Item tax" let sale = CoreSale() sale.amount = NSNumber(value: lineSubtotal) sale.transactionInputMethod = TAP sale.orderId = "YOUR_ORDER_REFERENCE" sale.lineItems = lineItems sale.tax = globalTax terminal.processSale(sale) ``` **`Objective-C`** ```objectivec if ([[WTPSTerminal singleton] getDevice] == NODEVICE) { return; } double unitPrice = 2.00; double quantity = 2.0; double lineSubtotal = unitPrice * quantity; CoreLineItem *item = [[CoreLineItem alloc] init]; item.commodityCode = @"AA"; item.productCode = @"BB"; item.itemDescription = @"Bread"; item.unitOfMeasure = EA; item.unitPrice = @(unitPrice); item.quantity = @(quantity); item.discountRate = @0; CoreTax *tax = [[CoreTax alloc] init]; tax.percentage = @10; tax.amount = [[CoreUtil singleton] calcTax:tax.percentage withAmount:@(lineSubtotal) withCurrency:[[WTPSTerminal singleton] getCurrency]]; item.taxes = [NSMutableArray arrayWithObject:tax]; NSMutableArray *lineItems = [NSMutableArray array]; [lineItems addObject:item]; CoreTax *globalTax = [[CoreTax alloc] init]; globalTax.amount = tax.amount; globalTax.name = @"Item tax"; CoreSale *sale = [[CoreSale alloc] init]; sale.amount = @(lineSubtotal); sale.transactionInputMethod = TAP; sale.orderId = @"YOUR_ORDER_REFERENCE"; sale.lineItems = lineItems; sale.tax = globalTax; [[WTPSTerminal singleton] processSale:sale]; ``` # Add a tax Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/add-a-tax Add a predefined tax or a custom tax to a Tap to Pay on iPhone sale using the CoreTax object. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) If you want to add a tax to a sale, you can [add a tax that you've predefined in the terminal](#add-a-predefined-tax), or you can [add a custom tax amount](#add-a-custom-tax). **Note:** A sale can include only one tax at a time. If you assign a predefined tax, it replaces any other tax that you previously assigned to the sale, including a custom tax. ## Add a predefined tax You can use the SDK to add a tax that you've already set up in the terminal. Your predefined taxes are available in `terminal.settings.taxListArray`. Each entry is a `CoreTax` with a `percentage`, `amount`, and `name` already set. You don't need to carry out any calculations, our gateway automatically adds the tax amount for you. **Note:** `taxListArray` can be empty if there are no predefined taxes in your terminal. Check that a tax is available before you select one. To create a tax, go to [Add a tax](https://support.payroc.com/en-US/core-products/payroc-gateway/web-portal/transaction-management/create-a-tax-on-the-self-care-portal#create-a-tax-on-the-self-care-portal). In your app, let the merchant or the POS choose which tax to apply to the sale. The following code selects the first tax in the list: **`Swift`** ```swift if let taxes = terminal.settings.taxListArray, taxes.count > 0 { sale.tax = taxes[0] as? CoreTax } ``` **`Objective-C`** ```objectivec NSMutableArray *taxes = [[WTPSTerminal singleton] getSettings].taxListArray; sale.tax = taxes.firstObject; ``` The following example runs a complete sale with a predefined tax: **`Swift`** ```swift guard terminal.getDevice() != NODEVICE else { // The reader isn't connected. Prompt the merchant to connect before you continue. return } let sale = CoreSale() sale.amount = 42.00 sale.transactionInputMethod = TAP sale.orderId = "YOUR_ORDER_REFERENCE" if let taxes = terminal.settings.taxListArray, taxes.count > 0 { sale.tax = taxes[0] as? CoreTax } terminal.processSale(sale) ``` **`Objective-C`** ```objectivec if ([[WTPSTerminal singleton] getDevice] == NODEVICE) { // The reader isn't connected. Prompt the merchant to connect before you continue. return; } CoreSale *sale = [[CoreSale alloc] init]; sale.amount = [NSNumber numberWithDouble:42.00]; sale.transactionInputMethod = TAP; sale.orderId = @"YOUR_ORDER_REFERENCE"; NSMutableArray *taxes = [[WTPSTerminal singleton] getSettings].taxListArray; sale.tax = taxes.firstObject; [[WTPSTerminal singleton] processSale:sale]; ``` ## Add a custom tax You can use the SDK to add a custom tax that's specific to each sale. The SDK accepts only an amount for a custom tax, but you can use `CoreUtil` to calculate the tax amount from a percentage. ### Add a custom tax by amount To add a custom tax by amount and name, use `addTaxWithAmount:withTaxName:`. The following example adds a tax amount of $3.50 to a sale: **`Swift`** ```swift sale.addTax(withAmount: 3.50, withTaxName: "Custom tax") ``` **`Objective-C`** ```objectivec [sale addTaxWithAmount:@3.50 withTaxName:@"Custom tax"]; ``` The following example runs a complete sale with a custom tax amount: **`Swift`** ```swift guard terminal.getDevice() != NODEVICE else { // The reader isn't connected. Prompt the merchant to connect before you continue. return } let sale = CoreSale() sale.amount = 42.00 sale.transactionInputMethod = TAP sale.orderId = "YOUR_ORDER_REFERENCE" sale.addTax(withAmount: 3.50, withTaxName: "Custom tax") terminal.processSale(sale) ``` **`Objective-C`** ```objectivec if ([[WTPSTerminal singleton] getDevice] == NODEVICE) { // The reader isn't connected. Prompt the merchant to connect before you continue. return; } CoreSale *sale = [[CoreSale alloc] init]; sale.amount = [NSNumber numberWithDouble:42.00]; sale.transactionInputMethod = TAP; sale.orderId = @"YOUR_ORDER_REFERENCE"; [sale addTaxWithAmount:@3.50 withTaxName:@"Custom tax"]; [[WTPSTerminal singleton] processSale:sale]; ``` ### Add a custom tax by percentage `addTaxWithAmount:withTaxName:` has no percentage parameter. To add a custom tax based on a percentage, build a `CoreTax` yourself, and then use `CoreUtil` to calculate the amount. The following example adds a tax of 8% to a sale. **`Swift`** ```swift let tax = CoreTax() tax.percentage = 8 tax.name = "Sales tax" tax.amount = (CoreUtil.singleton() as! CoreUtil).calcTax( tax.percentage, withAmount: sale.amount, with: terminal.currency ) sale.tax = tax ``` **`Objective-C`** ```objectivec CoreTax *tax = [[CoreTax alloc] init]; tax.percentage = @8; tax.name = @"Sales tax"; tax.amount = [[CoreUtil singleton] calcTax:tax.percentage withAmount:sale.amount withCurrency:[[WTPSTerminal singleton] getCurrency]]; sale.tax = tax; ``` The following example runs a complete sale with a custom tax amount based on a percentage: **`Swift`** ```swift guard terminal.getDevice() != NODEVICE else { // The reader isn't connected. Prompt the merchant to connect before you continue. return } let sale = CoreSale() sale.amount = 42.00 sale.transactionInputMethod = TAP sale.orderId = "YOUR_ORDER_REFERENCE" let tax = CoreTax() tax.percentage = 8 tax.name = "Sales tax" tax.amount = (CoreUtil.singleton() as! CoreUtil).calcTax( tax.percentage, withAmount: sale.amount, with: terminal.currency ) sale.tax = tax terminal.processSale(sale) ``` **`Objective-C`** ```objectivec if ([[WTPSTerminal singleton] getDevice] == NODEVICE) { // The reader isn't connected. Prompt the merchant to connect before you continue. return; } CoreSale *sale = [[CoreSale alloc] init]; sale.amount = [NSNumber numberWithDouble:42.00]; sale.transactionInputMethod = TAP; sale.orderId = @"YOUR_ORDER_REFERENCE"; CoreTax *tax = [[CoreTax alloc] init]; tax.percentage = @8; tax.name = @"Sales tax"; tax.amount = [[CoreUtil singleton] calcTax:tax.percentage withAmount:sale.amount withCurrency:[[WTPSTerminal singleton] getCurrency]]; sale.tax = tax; [[WTPSTerminal singleton] processSale:sale]; ``` # Add a tip Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/add-a-tip Add a predefined tip or a custom tip to a Tap to Pay on iPhone sale using the CoreTip object. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) If you want to add a tip to a sale, you can [add a tip that you've predefined in the terminal](#add-a-predefined-tip), or you can [add a custom tip amount](#add-a-custom-tip). **Note:** A sale can include only one tip at a time. If you assign a predefined tip, it replaces any tip amount that you previously set, including a custom tip amount. ## Add a predefined tip You can use the SDK to add a tip that you've already set up in the terminal. Your predefined tips are available in `terminal.settings.tipListArray`. Each entry is a `CoreTip` with a `tipType` of either `PERCENTAGE` or `FIXED_AMOUNT`. You don't need to carry out any calculations. Our gateway automatically adds the tip amount for you. **Note:** `tipListArray` can be empty if there are no predefined tips in your terminal. Check that a tip is available before you select one. To create a tip, go to [Create a predefined tip on the Self-Care Portal](https://support.payroc.com/en_US/self-care-portal-transaction-management/create-a-predefined-tip-on-the-self-care-portal). In your app, let the customer choose which tip to apply to the sale. The following code selects the first tip in the list: **`Swift`** ```swift if let tips = terminal.settings.tipListArray, tips.count > 0 { sale.tip = tips[0] as? CoreTip } ``` **`Objective-C`** ```objectivec sale.tip = [[WTPSTerminal singleton] getSettings].tipListArray.firstObject; ``` The following example runs a complete sale with a predefined tip: **`Swift`** ```swift guard terminal.getDevice() != NODEVICE else { return } let sale = CoreSale() sale.amount = 42.00 sale.transactionInputMethod = TAP sale.orderId = "YOUR_ORDER_REFERENCE" if let tips = terminal.settings.tipListArray, tips.count > 0 { sale.tip = tips[0] as? CoreTip } terminal.processSale(sale) ``` **`Objective-C`** ```objectivec if ([[WTPSTerminal singleton] getDevice] == NODEVICE) { return; } CoreSale *sale = [[CoreSale alloc] init]; sale.amount = [NSNumber numberWithDouble:42.00]; sale.transactionInputMethod = TAP; sale.orderId = @"YOUR_ORDER_REFERENCE"; sale.tip = [[WTPSTerminal singleton] getSettings].tipListArray.firstObject; [[WTPSTerminal singleton] processSale:sale]; ``` ## Add a custom tip You can use the SDK to add a custom tip that's specific to each sale. The SDK accepts only an amount for a custom tip, and doesn't accept a percentage. To specify the value of the custom tip, use `addTipWithAmount`. The following example adds a tip amount of $5.00 to a sale: **`Swift`** ```swift sale.addTip(withAmount: 5.00) ``` **`Objective-C`** ```objectivec [sale addTipWithAmount:@5.00]; ``` The following example runs a complete sale with a custom tip: **`Swift`** ```swift guard terminal.getDevice() != NODEVICE else { return } let sale = CoreSale() sale.amount = 42.00 sale.transactionInputMethod = TAP sale.orderId = "YOUR_ORDER_REFERENCE" sale.addTip(withAmount: 5.00) terminal.processSale(sale) ``` **`Objective-C`** ```objectivec if ([[WTPSTerminal singleton] getDevice] == NODEVICE) { return; } CoreSale *sale = [[CoreSale alloc] init]; sale.amount = [NSNumber numberWithDouble:42.00]; sale.transactionInputMethod = TAP; sale.orderId = @"YOUR_ORDER_REFERENCE"; [sale addTipWithAmount:[NSNumber numberWithDouble:5.00]]; [[WTPSTerminal singleton] processSale:sale]; ``` # Cancel a sale Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/cancel-a-sale Cancel an in-progress sale with the Tap to Pay on iPhone SDK, and handle the cancellation status that the SDK returns. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) If a merchant starts a sale by mistake, or a customer changes their mind before they tap their card, you can cancel the sale while it's still in progress. To cancel a sale, call `cancelTransaction` on `WTPSTerminal`. You can't cancel a sale after our gateway starts to authorize the sale. To return funds after a sale, go to [Run a refund](/guides/payments/tap-to-pay-on-iphone/run-a-refund). ## Integration steps 1. [Cancel the sale](#step-1-cancel-the-sale). 2. [Handle the cancellation status](#step-2-handle-the-cancellation-status). ## Step 1. Cancel the sale - Call `cancelTransaction` while the sale is in progress. **`Swift`** ```swift terminal.cancelTransaction() ``` **`Objective-C`** ```objectivec [[WTPSTerminal singleton] cancelTransaction]; ``` The SDK returns the outcome to `onCancelTransactionAttempt:withError:` on your `CoreAPISaleListener`. You registered this listener in [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale), so you don't need to register another listener. ## Step 2. Handle the cancellation status The SDK sends a `TransactionCancellationStatus` value to `onCancelTransactionAttempt:withError:`. The value indicates whether the SDK canceled the sale: | **Value** | **Description** | | --- | --- | | `TRANSACTION_CANCELLATION_STATUS_CANCELLING` | The SDK is canceling the transaction. Wait for the SDK to confirm the outcome. | | `TRANSACTION_CANCELLATION_STATUS_CANCELLED` | The SDK canceled the transaction. | | `TRANSACTION_CANCELLATION_STATUS_NOT_ALLOWED` | The SDK can't cancel the transaction, for example, because our gateway is authorizing the sale. | | `TRANSACTION_CANCELLATION_STATUS_NOTHING_TO_CANCEL` | There was no transaction to cancel. | **Important:** `TRANSACTION_CANCELLATION_STATUS_CANCELLING` means that the SDK accepted your request, not that it canceled the sale. Wait for `TRANSACTION_CANCELLATION_STATUS_CANCELLED` before your app tells the merchant that the SDK canceled the sale. The following example handles each cancellation status and enables or disables a payment button: **`Swift`** ```swift func onCancelTransactionAttempt(_ cancellationStatus: TransactionCancellationStatus, withError sdkError: CoreSdkErrorWrapper?) { switch cancellationStatus { case TRANSACTION_CANCELLATION_STATUS_CANCELLING: // The SDK is canceling the transaction. Wait for the outcome. confirmButton.isEnabled = false case TRANSACTION_CANCELLATION_STATUS_CANCELLED: // The SDK canceled the transaction. You can start another sale. confirmButton.isEnabled = true case TRANSACTION_CANCELLATION_STATUS_NOT_ALLOWED: // It's too late to cancel. Wait for onSaleResponse:. confirmButton.isEnabled = true case TRANSACTION_CANCELLATION_STATUS_NOTHING_TO_CANCEL: // No transaction was in progress. confirmButton.isEnabled = true default: confirmButton.isEnabled = true } } ``` **`Objective-C`** ```objectivec - (void)onCancelTransactionAttempt:(TransactionCancellationStatus)cancellationStatus withError:(CoreSdkErrorWrapper *)sdkError { switch (cancellationStatus) { case TRANSACTION_CANCELLATION_STATUS_CANCELLING: // The SDK is canceling the transaction. Wait for the outcome. _confirmButton.enabled = NO; break; case TRANSACTION_CANCELLATION_STATUS_CANCELLED: // The SDK canceled the transaction. You can start another sale. _confirmButton.enabled = YES; break; case TRANSACTION_CANCELLATION_STATUS_NOT_ALLOWED: // It's too late to cancel. Wait for onSaleResponse:. _confirmButton.enabled = YES; break; case TRANSACTION_CANCELLATION_STATUS_NOTHING_TO_CANCEL: // No transaction was in progress. _confirmButton.enabled = YES; break; } } ``` ### Find out why the SDK didn't cancel the sale If the SDK returns `TRANSACTION_CANCELLATION_STATUS_NOT_ALLOWED`, it also sends a `CoreSdkErrorWrapper` that explains why. The wrapper has the following properties: | **Property** | **Description** | | --- | --- | | `type` | Type of error that the wrapper holds. The SDK returns one of the following error types: - `SDK_CORE_DEVICE_ERROR` indicates a `CoreDeviceError` value. - `SDK_CORE_ERROR` indicates a `CoreError` value. | | `value` | Value of the error as an `NSNumber`. Cast the value to the type that `type` indicates. | If the SDK returns a `CoreDeviceError`, the value can be one of the following: | **Value** | **Description** | | --- | --- | | `CANCELLATION_NOT_ALLOWED_TRANSACTION_STARTING` | The sale is starting. | | `CANCELLATION_NOT_ALLOWED_TRANSACTION_GOING_ONLINE` | The sale is going to our gateway. | The following example reads the error from the wrapper: **`Swift`** ```swift if let sdkError = sdkError { switch sdkError.type { case .SDK_CORE_DEVICE_ERROR: let deviceError = CoreDeviceError(rawValue: sdkError.value.uint32Value) // For example, CANCELLATION_NOT_ALLOWED_TRANSACTION_GOING_ONLINE case .SDK_CORE_ERROR: let coreError = CoreError(rawValue: sdkError.value.uint32Value) } } ``` **`Objective-C`** ```objectivec if (sdkError != nil) { if ([sdkError type] == SDK_CORE_DEVICE_ERROR) { CoreDeviceError deviceError = (CoreDeviceError)[[sdkError value] integerValue]; // For example, CANCELLATION_NOT_ALLOWED_TRANSACTION_GOING_ONLINE } else { CoreError coreError = (CoreError)[[sdkError value] integerValue]; } } ``` # Configure the processing terminal Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/configure-the-processing-terminal Configure the Tap to Pay on iPhone terminal by initializing it locally, setting the operating mode, and loading your settings from our gateway. **Prerequisites:** [Authentication](/api/authentication) · [Set up the SDK](/guides/payments/tap-to-pay-on-iphone/set-up-the-sdk) Before your app can run a sale, it needs the merchant's payment settings. To get the payment settings, initialize `WTPSTerminal` in your app, and then send your terminal ID to our gateway. ## Integration steps 1. Initialize `WTPSTerminal`. 2. Load the settings from our gateway. ## Step 1. Initialize WTPSTerminal 1. Add the following code to your app delegate or to wherever your app runs its launch code: **`Swift`** ```swift let terminal = WTPSTerminal.singleton() as! WTPSTerminal terminal.initialize() terminal.mode = TEST // TEST or LIVE terminal.setLogLevel(LEVEL_INFO) ``` **`Objective-C`** ```objectivec [[WTPSTerminal singleton] initialize]; [(WTPSTerminal *)[WTPSTerminal singleton] setMode:TEST]; // TEST or LIVE [[WTPSTerminal singleton] setLogLevel:LEVEL_INFO]; ``` 2. Set the operating mode to one of the following values: | **Value** | **Description** | | --- | --- | | `TEST` | Sends requests to our test environment. Use `TEST` while you develop your integration. | | `LIVE` | Sends requests to our production environment. Use `LIVE` when you're ready to run live transactions. | 3. Set the log level to one of the following values: | **Value** | **Description** | | --- | --- | | `LEVEL_FULL` | Records all messages, including raw data. Available only in `TEST` mode. | | `LEVEL_INFO` | Records informational messages. | | `LEVEL_ERROR` | Records only errors. | | `LEVEL_NONE` | Records nothing. | 4. (Optional) To receive the SDK's log output in your own code, register a `CoreAPILogsListener`: **`Swift`** ```swift terminal.registerLogListener(self) func onLogMessage(_ message: String!, with logLevel: LogLevel) { print("[SDK \(logLevel.rawValue)] \(message ?? "")") } ``` **`Objective-C`** ```objectivec [[WTPSTerminal singleton] registerLogListener:self]; - (void)onLogMessage:(NSString *)message withLogLevel:(LogLevel)logLevel { NSLog(@"[SDK %d] %@", (int)logLevel, message); } ``` **Note:** To stop receiving log messages, send `nil` to `registerLogListener`. ## Step 2. Load the settings from our gateway **Important:** Make sure that you register your settings listener before you call `initWithConfiguration:`. If you register your settings listener afterward, you miss the `onSettingsRetrieved:` callback that indicates the SDK has your settings. 1. Add the following code to register your settings listener and to send your terminal ID to our gateway: **`Swift`** ```swift terminal.register(self as CoreAPISettingsListener) terminal.initWithConfiguration("YOUR_TERMINAL_ID") ``` **`Objective-C`** ```objectivec [[WTPSTerminal singleton] registerCoreAPISettingsListener:self]; [[WTPSTerminal singleton] initWithConfiguration:@"YOUR_TERMINAL_ID"]; ``` **Note:** This example shows only the method for this task. Each listener requires you to implement all of its methods. For a complete implementation, go to the [sample apps](/guides/take-payments/tap-to-pay-on-iphone/extend-your-integration/run-the-sample-apps). 2. Replace `YOUR_TERMINAL_ID` with your terminal ID. We provided you with your terminal ID when you boarded with us. 3. Add the following code to handle the `onSettingsRetrieved:` and `onError:withDescription:` callbacks: **`Swift`** ```swift func onSettingsRetrieved(_ settings: CoreSettings!) { // Settings loaded from the gateway. You can now initialize the device. terminal.initDevice(APPLETTP, with: DCT_INTERNAL, withDeviceData: [:]) } func onError(_ error: CoreError, withDescription message: String!) { // Could not load settings. Check your terminal ID and connectivity. } ``` **`Objective-C`** ```objectivec - (void)onSettingsRetrieved:(CoreSettings *)settings { // Settings loaded from the gateway. You can now initialize the device. [[WTPSTerminal singleton] initDevice:APPLETTP withConnectionType:DCT_INTERNAL withDeviceData:nil]; } - (void)onError:(CoreError)error withDescription:(NSString *)message { // Could not load settings. Check your terminal ID and connectivity. } ``` The `onSettingsRetrieved:` callback indicates that the SDK has your payment processing settings. After the SDK has your settings, you can initialize the device to run a sale. ## Next step After you configure the processing terminal, go to [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale). # Extend your integration Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/extend-your-integration Extend your Tap to Pay on iPhone integration with refunds, transaction reporting, tips, taxes, line items, and surcharges. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) After you set up your app to run a sale, you can extend your integration to include the following: - [**Run a refund**](/guides/payments/tap-to-pay-on-iphone/run-a-refund) - Return funds to the same card that the customer used for the original sale. - [**Retrieve transactions**](/guides/payments/tap-to-pay-on-iphone/retrieve-transactions) - Retrieve a single transaction or list multiple transactions. - [**Add a tip to a sale**](/guides/payments/tap-to-pay-on-iphone/add-a-tip) - Add a predefined tip or a custom tip to a sale. - [**Add a tax to a sale**](/guides/payments/tap-to-pay-on-iphone/add-a-tax) - Add a predefined tax or a custom tax to a sale. - [**Add a line item to a sale**](/guides/payments/tap-to-pay-on-iphone/add-a-line-item) - Add itemized product details to a sale. - [**Handle surcharges**](/guides/payments/tap-to-pay-on-iphone/handle-surcharges) - Present a surcharge fee to the customer for confirmation. - [**Cancel a sale**](/guides/payments/tap-to-pay-on-iphone/cancel-a-sale) - Cancel an in-progress sale, and handle the cancellation status that the SDK returns. - [**Run the sample apps**](/guides/payments/tap-to-pay-on-iphone/run-the-sample-apps) - Run the Swift or Objective-C sample app from the SDK package. ## Guides To extend your Tap to Pay on iPhone integration, follow our guides: #### [Run a refund](/guides/payments/tap-to-pay-on-iphone/run-a-refund) Refund a sale to the same card. #### [Retrieve transactions](/guides/payments/tap-to-pay-on-iphone/retrieve-transactions) View your sales and refunds. #### [Add a tip to a sale](/guides/payments/tap-to-pay-on-iphone/add-a-tip) Add a predefined or custom tip. #### [Add a tax to a sale](/guides/payments/tap-to-pay-on-iphone/add-a-tax) Add a predefined or custom tax. #### [Add a line item to a sale](/guides/payments/tap-to-pay-on-iphone/add-a-line-item) Add itemized product details. #### [Handle surcharges](/guides/payments/tap-to-pay-on-iphone/handle-surcharges) Present a surcharge for confirmation. #### [Cancel a sale](/guides/payments/tap-to-pay-on-iphone/cancel-a-sale) Cancel an in-progress sale. #### [Run the sample apps](/guides/payments/tap-to-pay-on-iphone/run-the-sample-apps) Run our Swift or Objective-C sample app. # Handle errors Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/handle-errors Handle transaction, communication, and device errors in your Tap to Pay on iPhone integration, and resolve a sale with an unknown outcome after a communication failure. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) The SDK reports errors through different callbacks depending on the context. There are three main types of error that the SDK can return: | **Type** | **Callback** | **Listener** | | --- | --- | --- | | [Transaction errors](#transaction-errors) | `onError:withDescription:` | `CoreAPISaleListener` | | [Communication errors](#communication-errors) | `onTransactionCommError:withError:withMessage:` | `CoreAPISaleListener` | | [Device errors](#device-errors) | `onDeviceError:withDescription:` | `CoreAPIDeviceListener` | **Note:** The examples on this page show only the method for this task. Each listener requires you to implement all of its methods. For a complete implementation, go to the [sample apps](/guides/take-payments/tap-to-pay-on-iphone/extend-your-integration/run-the-sample-apps). ## Transaction errors The SDK returns transaction processing failures, such as network problems, to `onError:withDescription:` on `CoreAPISaleListener`. The `CoreError` enumeration identifies the type of failure. **`Swift`** ```swift func onError(_ error: CoreError, withDescription message: String!) { print("Sale error \(error.rawValue): \(message ?? "")") } ``` **`Objective-C`** ```objectivec - (void)onError:(CoreError)error withDescription:(NSString *)message { NSLog(@"Sale error %d: %@", (int)error, message); } ``` **Note:** `CoreAPIRefundListener` uses the same parameters for refund errors. For the full list of `CoreError` values, go to the `CoreError` page in the SDK reference. ## Communication errors **Important:** If you receive a communication error, treat the sale as unresolved. If we authorized the sale, we recommend that you reverse the sale. A communication error happens when the device reads the card successfully but the transaction request doesn't reach our gateway. Because the customer has already tapped their card, you don't know the outcome on our gateway. The SDK returns communication errors to `onTransactionCommError:withError:withMessage:` on `CoreAPISaleListener`, and passes back the original `CoreSale` object. **Note:** Referenced refunds don't have a dedicated communication error callback. If a referenced refund fails to reach our gateway, the SDK reports it through `onError:withDescription:` on `CoreAPIRefundListener` instead. We recommend that you use the following recovery process for sales: 1. Store the `CoreSale` object on the device. 2. When the device is back online, use `RestConnector.requestTransactionList` to search for the transaction by `orderId` or by the last four digits of the card. 3. Check the result: - `code` is `A`: we authorized the transaction. - `code` not `A`: we declined the transaction. There's nothing to reverse. - No transaction: the transaction didn't reach our gateway. There's nothing to resolve, and you can run the sale again. 4. If we authorized the sale, we recommend that you reverse it. Create a `CoreReversal` with the `uniqueRef` of the transaction, and then send it to `RestConnector.request` with `isRefund` set to `NO`. 5. (Optional) Run the sale again. The following example checks the status of the sale and resolves it when the device is back online: **`Swift`** ```swift func onTransactionCommError(_ sale: CoreSale!, withError error: CoreError, withMessage message: String!) { // Persist the sale locally for later reversal saveSaleOffline(sale) } // When connectivity is restored: func syncPendingReversal(orderId: String, amount: NSDecimalNumber, maskedPan: String) { let filter = CoreTransactionFilter() filter.orderId = orderId guard let result = try? RestConnector.requestTransactionList(filter, withTerminal: terminal), let match = result.transactionSummary?.first as? CoreTransactionSummary else { return } guard match.amount == amount as NSNumber, let cardNumber = match.cardNumber, cardNumber.hasSuffix(maskedPan) else { return } let reversal = CoreReversal() reversal.deviceType = "AppleTTP" reversal.uniqueRef = match.uniqueRef _ = try? RestConnector.requestReversal(reversal, isRefund: NSNumber(value: false), withTerminal: terminal) } ``` **`Objective-C`** ```objectivec - (void)onTransactionCommError:(CoreSale *)sale withError:(CoreError)error withMessage:(NSString *)message { // Persist the sale locally for later reversal [self saveSaleOffline:sale]; } // When connectivity is restored: - (void)syncPendingReversal:(NSString *)orderId amount:(NSNumber *)amount maskedPan:(NSString *)maskedPan { NSError *error = nil; CoreTransactionFilter *filter = [[CoreTransactionFilter alloc] init]; filter.orderId = orderId; CoreTransactions *result = [RestConnector requestTransactionList:filter withTerminal:self.terminal error:&error]; if (error || result.transactionSummary.count == 0) { return; } CoreTransactionSummary *match = result.transactionSummary.firstObject; if (![match.amount isEqualToNumber:amount]) { return; } if (match.cardNumber.length < 4 || ![[match.cardNumber substringFromIndex:match.cardNumber.length - 4] isEqualToString:maskedPan]) { return; } CoreReversal *reversal = [[CoreReversal alloc] init]; reversal.deviceType = @"AppleTTP"; reversal.uniqueRef = match.uniqueRef; [RestConnector requestReversal:reversal isRefund:[NSNumber numberWithBool:NO] withTerminal:self.terminal error:&error]; } ``` ## Device errors The SDK returns device errors to `onDeviceError:withDescription:` on `CoreAPIDeviceListener`. The `CoreDeviceError` enumeration covers device failures, entitlement problems, and hardware faults. **`Swift`** ```swift func onDeviceError(_ deviceError: CoreDeviceError, withDescription message: String!) { print("Device error \(deviceError.rawValue): \(message ?? "")") } ``` **`Objective-C`** ```objectivec - (void)onDeviceError:(CoreDeviceError)deviceError withDescription:(NSString *)message { NSLog(@"Device error %d: %@", (int)deviceError, message); } ``` The SDK includes a set of `CoreDeviceError` values that are specific to Apple Tap to Pay, and they all start with `APPLE_TTP_`. They cover problems such as an unsupported iPhone model, an unsupported iOS version, a disabled passcode, a blocked merchant, and account-linking failures. For the full list, go to the `CoreDeviceError` page in the SDK reference. If the device encounters an error and becomes unavailable, `onDeviceDisconnected:` fires. **`Swift`** ```swift func onDeviceConnected(_ type: DeviceEnum, withDeviceInfo deviceInfo: [AnyHashable: Any]!) { // The device is active and ready } func onDeviceDisconnected(_ type: DeviceEnum) { // The reader is unavailable. Disable your payment button. } ``` **`Objective-C`** ```objectivec - (void)onDeviceConnected:(DeviceEnum)type withDeviceInfo:(NSDictionary *)deviceInfo { // The device is active and ready } - (void)onDeviceDisconnected:(DeviceEnum)type { // The reader is unavailable. Disable your payment button. } ``` # Handle surcharges Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/handle-surcharges Handle surcharges with Tap to Pay on iPhone by reading your terminal's surcharge settings, presenting the fee for confirmation, and letting the customer bypass it. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) A surcharge is an additional fee that we apply to card-present sales if surcharging is active on the terminal and if the card supports surcharging. When the SDK calculates a surcharge, it pauses the sale and asks your app to present the fee to the customer for confirmation. If a card is eligible for surcharging, the following flow describes what happens during a sale: 1. Your app runs a sale. 2. The customer taps their card. 3. Our gateway authorizes the transaction and calculates the surcharge. 4. Your app presents the fee to the customer:- If the customer accepts, your app confirms that our gateway should apply the surcharge. Our gateway sends the sale for settlement. - If the customer declines, your app notifies the SDK, which then automatically reverses the sale. - If the confirmation timer expires, the SDK automatically reverses the sale. ## Integration steps 1. [Read your surcharge settings](#step-1-read-your-surcharge-settings). 2. [Run a sale](#step-2-run-a-sale). 3. [Confirm the surcharge](#step-3-confirm-the-surcharge). 4. [Handle reversal errors](#step-4-handle-reversal-errors) 5. [(Optional) Change the confirmation timeout](#step-5-optional-change-the-confirmation-timeout) ## Step 1. Read your surcharge settings We configure surcharging on the terminal, so your app can't adjust the surcharge settings. Your app can only read the surcharge settings from `CoreSettings.surchargeSettings` in your `onSettingsRetrieved:` callback. `CoreSurchargeSettings` has the following properties: | **Property** | **Type** | **Description** | | --- | --- | --- | | `enable` | `NSNumber*` (bool) | `true` when surcharging is active for the terminal. | | `allowBypass` | `NSNumber*` (bool) | `true` when customers can opt out of the surcharge before they tap. | | `discloseFee` | `NSNumber*` (bool) | `true` when you must disclose the fee to the customer. | | `percentage` | `NSNumber*` | The surcharge rate as a percentage of the sale amount. | **Important:** Don't hard-code the surcharge settings. Always read `CoreSettings.surchargeSettings` at runtime. ## Step 2. Run a sale Create a sale request, and set `bypassSurcharge` to `false` or `nil`. **Note:** If you want to let the customer bypass the surcharge, set `bypassSurcharge` to `true` instead. The SDK then skips the confirmation step in Step 3 and completes the sale without applying the surcharge fee. **`Swift`** ```swift guard terminal.getDevice() != NODEVICE else { // The reader isn't connected. Prompt the merchant to connect before you continue. return } let sale = CoreSale() sale.amount = 42.00 sale.transactionInputMethod = TAP sale.orderId = "YOUR_ORDER_REFERENCE" sale.bypassSurcharge = false terminal.processSale(sale) ``` **`Objective-C`** ```objectivec if ([[WTPSTerminal singleton] getDevice] == NODEVICE) { // The reader isn't connected. Prompt the merchant to connect before you continue. return; } CoreSale *sale = [[CoreSale alloc] init]; sale.amount = [NSNumber numberWithDouble:42.00]; sale.transactionInputMethod = TAP; sale.orderId = @"YOUR_ORDER_REFERENCE"; sale.bypassSurcharge = [NSNumber numberWithBool:NO]; [[WTPSTerminal singleton] processSale:sale]; ``` ## Step 3. Confirm the surcharge When you run the sale and the cardholder taps their card, our gateway authorizes the sale and checks if the card is eligible for surcharging. After our gateway authorizes the card, the SDK calls `onRequestSurchargeConfirm:` on your `CoreAPISaleListener` with a `CoreBinLookupResponse` that contains the calculated surcharge. Depending on whether the customer accepts or declines the surcharge, your app must respond by calling `confirmSurchargeFee:` with either `true` or `false`. **Important:** If your app doesn't call `confirmSurchargeFee:` within the timeout window, the SDK automatically reverses the sale. The default timeout window is 30 seconds. To change the timeout window, go to [Change the confirmation timeout](#step-5-optional-change-the-confirmation-timeout). ### Display the confirmation Use the surcharge amount from `binLookupResponse.surcharge.amount` to create a screen that displays the surcharge amount to the customer and prompts them to accept or decline the surcharge. We recommend that you show any tips or taxes alongside the surcharge so that the customer sees the full total. ### If the customer accepts Call `confirmSurchargeFee(true)`. The SDK keeps the sale as approved and calls `onSaleResponse:` with an approved response. ### If the customer declines Call `confirmSurchargeFee(false)`. The SDK reverses the authorized sale. When the reversal completes, `onSaleResponse:` returns a declined response with a `code` of `D` and a `status` of `VOID`. To handle a failed reversal, go to [Handle reversal errors](#step-4-handle-reversal-errors). ### Example The following example displays the surcharge amount to the customer and calls `confirmSurchargeFee:` with the response: **`Swift`** ```swift func onRequestSurchargeConfirm(_ binLookupResponse: CoreBinLookupResponse!) { var message = String( format: "Surcharge fee: %@\nConfirm?", binLookupResponse.surcharge.amount ) // Optionally include a tip and tax breakdown that you already calculated if let breakdown = breakDownLabel.text { message = breakdown + "\n" + message } showSurchargeAlert(message: message) } func showSurchargeAlert(message: String) { let alert = UIAlertController(title: "Surcharge", message: message, preferredStyle: .alert) alert.addAction(UIAlertAction(title: "Accept", style: .default) { _ in self.terminal.confirmSurchargeFee(true) }) alert.addAction(UIAlertAction(title: "Decline", style: .destructive) { _ in self.terminal.confirmSurchargeFee(false) }) present(alert, animated: true) } ``` **`Objective-C`** ```objectivec - (void)onRequestSurchargeConfirm:(CoreBinLookupResponse *)binLookupResponse { NSString *message = [NSString stringWithFormat: @"Surcharge fee: %@\nConfirm?", binLookupResponse.surcharge.amount]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Surcharge" message:message preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"Accept" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [[WTPSTerminal singleton] confirmSurchargeFee:YES]; }]]; [alert addAction:[UIAlertAction actionWithTitle:@"Decline" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { [[WTPSTerminal singleton] confirmSurchargeFee:NO]; }]]; [self presentViewController:alert animated:YES completion:nil]; } ``` ## Step 4. Handle reversal errors If the automatic reversal fails, for example because of a network interruption, the SDK calls `onSurchargeReversalError:` with the original `CoreSaleResponse`. Our gateway authorized the sale, but the reversal didn't complete. To handle a failed reversal, store the `uniqueRef` of the sale, and then call `terminal.processReversal` to try again. The following example handles a failed reversal: **`Swift`** ```swift func onSurchargeReversalError(_ saleResponse: CoreSaleResponse!) { guard let saleResponse = saleResponse else { return } // Our gateway authorized the sale but the reversal failed. // Store the uniqueRef and retry the reversal when the device is online. savePendingReversal(uniqueRef: saleResponse.uniqueRef) // Mark the response as declined so that you can display it saleResponse.code = "D" saleResponse.status = "VOID" saleResponse.descriptionCode = "SURCHARGE DECLINED" openReceipt(response: saleResponse) } // Call this when the device is back online, using the same terminal that ran the original sale. func retryPendingReversal(uniqueRef: String) { let reversal = CoreReversal() reversal.uniqueRef = uniqueRef terminal.processReversal(reversal, isRefund: NSNumber(value: false)) } ``` **`Objective-C`** ```objectivec - (void)onSurchargeReversalError:(CoreSaleResponse *)saleResponse { NSLog(@"onSurchargeReversalError - uniqueRef %@ requires manual reversal", saleResponse.uniqueRef); // Store the uniqueRef and retry the reversal when the device is online [self savePendingReversal:saleResponse.uniqueRef]; saleResponse.code = @"D"; saleResponse.status = @"VOID"; saleResponse.descriptionCode = @"SURCHARGE DECLINED"; [self openReceipt:saleResponse]; } // Call this when the device is back online, using the same terminal that ran the original sale. - (void)retryPendingReversal:(NSString *)uniqueRef { CoreReversal *reversal = [[CoreReversal alloc] init]; reversal.uniqueRef = uniqueRef; [[WTPSTerminal singleton] processReversal:reversal isRefund:[NSNumber numberWithBool:NO]]; } ``` ## Step 5. (Optional) Change the confirmation timeout The SDK starts a timer when `onRequestSurchargeConfirm:` fires. If you don't call `confirmSurchargeFee:` before the timer expires, the SDK reverses the sale. To change the timeout from the default of 30 seconds, set `surchargeConfirmationTimeoutInSeconds` in your device data dictionary before you initialize the device. The value must be greater than zero. If you set zero or a negative value, the SDK uses the default. The following example sets the timeout to 60 seconds: **`Swift`** ```swift var deviceSettings = Dictionary() // Surcharge confirmation timeout - the default is 30 seconds deviceSettings["surchargeConfirmationTimeoutInSeconds"] = 60 terminal.initDevice(APPLETTP, with: DCT_INTERNAL, withDeviceData: deviceSettings) ``` **`Objective-C`** ```objectivec NSMutableDictionary *data = [[NSMutableDictionary alloc] init]; // Surcharge confirmation timeout - the default is 30 seconds [data setObject:[NSNumber numberWithInt:60] forKey:@"surchargeConfirmationTimeoutInSeconds"]; [[WTPSTerminal singleton] initDevice:APPLETTP withConnectionType:DCT_INTERNAL withDeviceData:data]; ``` # Retrieve transactions Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/retrieve-transactions Retrieve a single transaction or list multiple transactions with the Tap to Pay on iPhone SDK using the reporting listener. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) You can use the SDK to view your transactions, which include sales and refunds. The steps that you follow depend on whether you want to [retrieve a single transaction](#retrieve-a-single-transaction) or [list your transactions](#list-your-transactions). We return all results to the `CoreAPIReportingListener`. ## Retrieve a single transaction Before you retrieve a single transaction, you need to have the `uniqueRef` of the transaction. If you don't have the `uniqueRef`, go to [List your transactions](#list-your-transactions). To retrieve a transaction, register the reporting listener, and then call `getTransaction:` with the `uniqueRef`. ### Step 1. Register the reporting listener - Register `CoreAPIReportingListener` when your view appears, and unregister it when the view disappears. **`Swift`** ```swift // viewWillAppear: terminal.register(self as CoreAPIReportingListener) // viewWillDisappear: terminal.unRegister(self as CoreAPIReportingListener) ``` **`Objective-C`** ```objectivec // viewWillAppear: [[WTPSTerminal singleton] registerCoreAPIReportingListener:self]; // viewWillDisappear: [[WTPSTerminal singleton] unRegisterCoreAPIReportingListener:self]; ``` **Note:** This example shows only the method for this task. Each listener requires you to implement all of its methods. For a complete implementation, go to the [sample apps](/guides/take-payments/tap-to-pay-on-iphone/extend-your-integration/run-the-sample-apps). ### Step 2. Retrieve the transaction - Call `getTransaction:` with a `uniqueRef` to get the full details of a transaction. **`Swift`** ```swift terminal.getTransaction(uniqueRef) ``` **`Objective-C`** ```objectivec [[WTPSTerminal singleton] getTransaction:uniqueRef]; ``` The SDK returns the transaction details to `onTransactionRetrieved:` as a `CoreResponse`. ## List your transactions If you want to view a list of your transactions, you can use the SDK to return multiple transactions. To handle large numbers of results, the SDK uses pagination to split the request into multiple pages. You can then navigate the pages to view all the transactions that the SDK returned. To list your transactions, register your reporting listener, and then call `getTransactions:` with optional filters. You can then navigate through the results. ### Step 1. Register the reporting listener - Register `CoreAPIReportingListener` when your view appears, and unregister it when the view disappears. **`Swift`** ```swift // viewWillAppear: terminal.register(self as CoreAPIReportingListener) // viewWillDisappear: terminal.unRegister(self as CoreAPIReportingListener) ``` **`Objective-C`** ```objectivec // viewWillAppear: [[WTPSTerminal singleton] registerCoreAPIReportingListener:self]; // viewWillDisappear: [[WTPSTerminal singleton] unRegisterCoreAPIReportingListener:self]; ``` ### Step 2. List transactions 1. Create a `CoreTransactionFilter`. 2. (Optional) To filter your results by date, send a value for `startDate` and for `endDate`. 3. (Optional) To filter your results by transaction state, send a value for `state`. 4. (Optional) To adjust the number of results returned in each page, send a value for `resultsPerPage`. 5. Call `getTransactions:`. The following example lists transactions with filters for transaction state and dates. The example also specifies that the SDK returns 25 results in each page: **`Swift`** ```swift let filter = CoreTransactionFilter() filter.state = OPEN // OPEN, CLOSED, or ALL let calendar = NSCalendar(calendarIdentifier: .gregorian)! var from = calendar.components([.day, .month, .year], from: fromDatePicker.date) from.hour = 0; from.minute = 0; from.second = 0 filter.startDate = calendar.date(from: from) var to = calendar.components([.day, .month, .year], from: toDatePicker.date) to.hour = 23; to.minute = 59; to.second = 59 filter.endDate = calendar.date(from: to) filter.resultsPerPage = 25 terminal.getTransactions(filter) ``` **`Objective-C`** ```objectivec CoreTransactionFilter *filter = [[CoreTransactionFilter alloc] init]; filter.state = OPEN; // OPEN, CLOSED, or ALL NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSDateComponents *from = [calendar components:(NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:self.fromDate.date]; from.hour = 0; from.minute = 0; from.second = 0; filter.startDate = [calendar dateFromComponents:from]; NSDateComponents *to = [calendar components:(NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear) fromDate:self.toDate.date]; to.hour = 23; to.minute = 59; to.second = 59; filter.endDate = [calendar dateFromComponents:to]; filter.resultsPerPage = @25; [[WTPSTerminal singleton] getTransactions:filter]; ``` The SDK returns the results to `onTransactionListResponse:` in a `CoreTransactions` object. The `CoreTransactions` object has a `transactionSummary` array of `CoreTransactionSummary` items, each containing information about a transaction. **Note:** `CoreTransactionSummary` doesn't include receipt information. If you want to view `merchantReceipt` or `cardholderReceipt`, [retrieve the single transaction](#retrieve-a-single-transaction) instead. The following code prints each result to the console: **`Swift`** ```swift func onTransactionListResponse(_ transactions: CoreTransactions!) { guard let summaries = transactions.transactionSummary, summaries.count > 0 else { return // No more results } for case let summary as CoreTransactionSummary in summaries { print("\(summary.uniqueRef ?? "") - \(summary.transactionType ?? "") \(summary.amount ?? 0)") } } ``` **`Objective-C`** ```objectivec - (void)onTransactionListResponse:(CoreTransactions *)transactions { if (transactions.transactionSummary.count == 0) { return; // No more results } for (CoreTransactionSummary *summary in transactions.transactionSummary) { NSLog(@"%@ - %@ %@", summary.uniqueRef, summary.transactionType, summary.amount); } } ``` ### Step 3. Navigate through the results When the SDK returns the `CoreTransactions` object, it includes a `next` field. To get the next page, set `filter.next` to the value that you received in the `next` field, and then call `getTransactions:` again. If there are no more results, the SDK doesn't return a `next` value. The following code navigates to the next page of results: **`Swift`** ```swift // In onTransactionListResponse: store the next cursor nextPage = transactions.next // When the last visible row is displayed: if let nextPageRef = nextPage, !nextPageRef.isEmpty { filter.next = nextPageRef terminal.getTransactions(filter) } ``` **`Objective-C`** ```objectivec // In onTransactionListResponse: store the next cursor self.nextPage = transactions.next; // When the last visible row is displayed: if (self.nextPage.length > 0) { filter.next = self.nextPage; [[WTPSTerminal singleton] getTransactions:filter]; } ``` # Run a refund Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/run-a-refund Run a referenced refund with the Tap to Pay on iPhone SDK using the uniqueRef of the original sale. **Prerequisites:** [Authentication](/api/authentication) · [Run a sale](/guides/payments/tap-to-pay-on-iphone/run-a-sale) **Important:** You can't run an unreferenced refund with the Tap to Pay on iPhone SDK. For more information about refund types, go to [Refunds and reversals](/knowledge/payments/refunds-and-reversals). A referenced refund returns funds to the same card that the customer used for the original sale. You don't need the customer to tap their card again. If you refund a sale that hasn't settled yet, our gateway reverses the sale instead. Before you begin, you need the `uniqueRef` of the sale that you want to refund. If you don't have it, go to [Retrieve transactions](/guides/payments/tap-to-pay-on-iphone/retrieve-transactions). ## Integration steps 1. [Register the refund listener](#step-1-register-the-refund-listener). 2. [Run the refund](#step-2-run-the-refund). ## Step 1. Register the refund listener The SDK returns refund results to `onRefundResponse:` on your `CoreAPIRefundListener`. To register your refund listener when your view appears, and unregister it when the view disappears, use the following code: **`Swift`** ```swift // viewWillAppear: terminal.register(self as CoreAPIRefundListener) // viewWillDisappear: terminal.unRegister(self as CoreAPIRefundListener) ``` **`Objective-C`** ```objectivec // viewWillAppear: [[WTPSTerminal singleton] registerCoreAPIRefundListener:self]; // viewWillDisappear: [[WTPSTerminal singleton] unRegisterCoreAPIRefundListener:self]; ``` ## Step 2. Run the refund To run a refund, create a `CoreRefund`, and then call `processRefund:`. `CoreRefund` includes the following properties: | **Property** | **Description** | **Required or optional** | | --- | --- | --- | | `uniqueRef` | Unique ID of the sale that you want to refund. | Required | | `reason` | Reason for the refund. | Required | | `amount` | Amount that you want to refund. | Required | | `orderId` | Your identifier for the order. | Optional | | `previousTxnDateTime` | The date and time of the original transaction. | Optional | | `autoCapture` | Whether to capture the refund automatically. The default value is `true`. | Optional | The following example refunds a sale: **`Swift`** ```swift let refund = CoreRefund() refund.uniqueRef = "ORIGINAL_UNIQUE_REF" refund.reason = "Customer request" refund.amount = 42.00 terminal.processRefund(refund) ``` **`Objective-C`** ```objectivec CoreRefund *refund = [[CoreRefund alloc] init]; refund.uniqueRef = @"ORIGINAL_UNIQUE_REF"; refund.reason = @"Customer request"; refund.amount = [NSNumber numberWithDouble:42.00]; [[WTPSTerminal singleton] processRefund:refund]; ``` The SDK returns the result to `onRefundResponse:`. **Note:** If the SDK reversed the sale instead of refunding it, `onRefundResponse:` returns a `CoreSaleResponse` instead of a `CoreRefundResponse`. ### Refund errors `CoreAPIRefundListener` uses the same `onError:withDescription:` signature as the sale listener. For more information, go to [Handle errors](/guides/payments/tap-to-pay-on-iphone/handle-errors). # Run a sale Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/run-a-sale Run a sale with Tap to Pay on iPhone by registering your listeners, initializing the contactless reader, and processing a CoreSale object. **Prerequisites:** [Authentication](/api/authentication) · [Set up the SDK](/guides/payments/tap-to-pay-on-iphone/set-up-the-sdk) · [Configure the processing terminal](/guides/payments/tap-to-pay-on-iphone/configure-the-processing-terminal) Register your listeners, initialize the AppleTTP plugin on the device, and then create a `CoreSale` object. The SDK presents Apple's ProximityReader interface for you, so you don't need to build a card-capture screen. ## Integration steps 1. Register your listeners. 2. Initialize the device. 3. Process the sale. ## Step 1. Register your listeners **Important:** Each listener requires you to implement all of its methods. The code examples in these guides show only the methods that are relevant to each task. For a complete implementation, including placeholders for the methods that you don't use, go to [Run the sample apps](/guides/take-payments/tap-to-pay-on-iphone/extend-your-integration/run-the-sample-apps). Register your listeners before you use them, and unregister them when your view controller disappears. If you don't unregister your listeners, your app can receive callbacks that are no longer relevant. - Add the following code to register and unregister your listeners: **`Swift`** ```swift // viewWillAppear: terminal.register(self as CoreAPISaleListener) terminal.register(self as CoreAPIRefundListener) terminal.register(self as CoreAPIDeviceListener) terminal.register(self as CoreAPIMessageListener) // viewWillDisappear: terminal.unRegister(self as CoreAPISaleListener) terminal.unRegister(self as CoreAPIRefundListener) terminal.unRegister(self as CoreAPIDeviceListener) terminal.unRegister(self as CoreAPIMessageListener) ``` **`Objective-C`** ```objectivec // viewWillAppear: [[WTPSTerminal singleton] registerCoreAPISaleListener:self]; [[WTPSTerminal singleton] registerCoreAPIRefundListener:self]; [[WTPSTerminal singleton] registerCoreAPIDeviceListener:self]; [[WTPSTerminal singleton] registerCoreAPIMessageListener:self]; // viewWillDisappear: [[WTPSTerminal singleton] unRegisterCoreAPISaleListener:self]; [[WTPSTerminal singleton] unRegisterCoreAPIRefundListener:self]; [[WTPSTerminal singleton] unRegisterCoreAPIDeviceListener:self]; [[WTPSTerminal singleton] unRegisterCoreAPIMessageListener:self]; ``` ## Step 2. Initialize the device **Important:** Don't call `initDevice` before you receive the `onSettingsRetrieved:` callback. The SDK needs your settings before it can connect to the reader. For more information, go to [Configure the processing terminal](/guides/payments/tap-to-pay-on-iphone/configure-the-processing-terminal). 1. Add the following code to initialize the reader with `DCT_INTERNAL` as the connection type: **`Swift`** ```swift terminal.initDevice(APPLETTP, with: DCT_INTERNAL, withDeviceData: [:]) ``` **`Objective-C`** ```objectivec [[WTPSTerminal singleton] initDevice:APPLETTP withConnectionType:DCT_INTERNAL withDeviceData:nil]; ``` 2. Add the following code to monitor the reader's connection state with `CoreAPIDeviceListener`: **`Swift`** ```swift func onDeviceConnected(_ type: DeviceEnum, withDeviceInfo deviceInfo: [AnyHashable: Any]!) { // The device is active. You can start a transaction. } func onDeviceDisconnected(_ type: DeviceEnum) { // The reader is unavailable. Check the entitlement and the iOS version. } func onDeviceError(_ deviceError: CoreDeviceError, withDescription message: String!) { print("Device error: \(message ?? "")") } ``` **`Objective-C`** ```objectivec - (void)onDeviceConnected:(DeviceEnum)type withDeviceInfo:(NSDictionary *)deviceInfo { // The device is active. You can start a transaction. } - (void)onDeviceDisconnected:(DeviceEnum)type { // The reader is unavailable. Check the entitlement and the iOS version. } - (void)onDeviceError:(CoreDeviceError)deviceError withDescription:(NSString *)message { NSLog(@"Device error: %@", message); } ``` ### Accept the terms and conditions The first time that you connect to the AppleTTP plugin for a merchant, iOS displays the terms and conditions for Apple's Tap to Pay on iPhone. The merchant or a legal representative of the merchant must use an Apple account to accept the terms and conditions. They can use an existing Apple Account or a separate account for the business. ## Step 3. Process the sale 1. Add the following code to create a `CoreSale` object: **`Swift`** ```swift guard terminal.getDevice() != NODEVICE else { // The reader isn't connected. Prompt the merchant to connect before you continue. return } let sale = CoreSale() sale.amount = 42.00 sale.transactionInputMethod = TAP sale.orderId = "YOUR_ORDER_REFERENCE" terminal.processSale(sale) ``` **`Objective-C`** ```objectivec if ([[WTPSTerminal singleton] getDevice] == NODEVICE) { // The reader isn't connected. Prompt the merchant to connect before you continue. return; } CoreSale *sale = [[CoreSale alloc] init]; sale.amount = [NSNumber numberWithDouble:42.00]; sale.transactionInputMethod = TAP; sale.orderId = @"YOUR_ORDER_REFERENCE"; [[WTPSTerminal singleton] processSale:sale]; ``` 2. In `amount`, enter the amount of the sale in dollars. 3. In `orderId`, enter a unique identifier for the order. 4. Call `processSale`. **Note:** For more information about the other parameters that you can send in a `CoreSale` object, go to the documentation in the SDK package. ### Time limit for the tap screen After you send a successful `CoreSale` request, the Tap to Pay screen prompts the customer to hold their card near the reader. The screen expires 40 seconds after it appears and the session times out. If the session times out, iOS displays a **Payment Timeout** alert, and the customer can tap **Try Again** to reactivate the reader. ### Messages during the sale While the SDK runs a sale, it sends messages that describe the progress of the transaction. To receive the messages, use the `CoreAPIMessageListener` that you registered in [Step 1. Register your listeners](#step-1-register-your-listeners). Apple's interface handles the card-capture screen, so you don't need to show a message while the customer taps their card. After the SDK reads the card, your app is visible again while we authorize the transaction. Use the messages to show the progress of the transaction during that time. The SDK sends a `CoreMessage` value instead of a string. Map each value to your own text so that you can localize your messages and match the tone of your app. The following code handles the `CoreMessage` value during the sale: **`Swift`** ```swift func onMessage(_ message: CoreMessage) { // Show your own text for this message value } ``` **`Objective-C`** ```objectivec - (void)onMessage:(CoreMessage)message { // Show your own text for this message value } ``` ### Sale response The SDK returns the result of the sale to `onSaleResponse:` on your `CoreAPISaleListener` and contains the `CoreSaleResponse` object. The `CoreSaleResponse` object includes the following fields: | **Field** | **Description** | | --- | --- | | `code` | Indicator for the sale response. `A` indicates that we approved the sale. Any other value indicates that we declined the sale. | | `uniqueRef` | Unique reference that we apply to the sale. You need to store this value to run follow-on actions, for example, retrieve the sale or run a refund. | | `status` | Status of the sale. | | `descriptionCode` | Description of the transaction result. | | `approvalCode` | Approval code for the sale. Our gateway returns a value for `approvalCode` only if the value of `code` is `A`. | | `authorizedAmount` | Amount that we authorized. This amount can differ from the amount that you requested if you add a tip, a tax, or a surcharge. | | `currency` | Currency of the sale. | | `cardNumber` | Masked card number. | | `cardType` | Card scheme. | | `cardHolderName` | Cardholder's name. | | `expiryDate` | Card's expiry date. | | `dateTime` | Date and time that we processed the sale. | | `orderNumber` | Order number for the sale. | | `surcharge` | Surcharge that we applied to the sale, if any. | The following code handles the `CoreSaleResponse` object during the sale and checks if the sale was approved: **`Swift`** ```swift func onSaleResponse(_ sale: CoreSaleResponse!) { if sale.code == "A" { // Approved. Store uniqueRef so that you can refund this sale later. store(uniqueRef: sale.uniqueRef) } else { // Declined. Show descriptionCode to the merchant. print("Declined: \(sale.descriptionCode ?? "")") } } ``` **`Objective-C`** ```objectivec - (void)onSaleResponse:(CoreSaleResponse *)sale { if ([sale.code isEqualToString:@"A"]) { // Approved. Store uniqueRef so that you can refund this sale later. [self storeUniqueRef:sale.uniqueRef]; } else { // Declined. Show descriptionCode to the merchant. NSLog(@"Declined: %@", sale.descriptionCode); } } ``` ### Alternative payment methods Apple requires apps that use Tap to Pay on iPhone to provide an alternative payment method so that merchants can always complete a sale with only an iPhone. To offer an alternative payment method, add [Payment Links](/guides/payments/payment-links) to your integration. ## Next steps - [Handle errors](/guides/payments/tap-to-pay-on-iphone/handle-errors). - [Retrieve transactions](/guides/payments/tap-to-pay-on-iphone/retrieve-transactions). - [Add a tip](/guides/payments/tap-to-pay-on-iphone/add-a-tip), [add a tax](/guides/payments/tap-to-pay-on-iphone/add-a-tax), or [add a line item](/guides/payments/tap-to-pay-on-iphone/add-a-line-item) to your sales. - [Handle surcharges](/guides/payments/tap-to-pay-on-iphone/handle-surcharges). - [Run a refund](/guides/payments/tap-to-pay-on-iphone/run-a-refund). # Run the sample apps Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/run-the-sample-apps Run the Swift or Objective-C sample app from the Tap to Pay on iPhone SDK package by configuring signing, adding your API key, and setting your terminal ID. **Prerequisites:** [Authentication](/api/authentication) · [Set up the SDK](/guides/payments/tap-to-pay-on-iphone/set-up-the-sdk) We've created sample apps in Swift and Objective-C that you can use to see how our SDK works. Each sample app has the following tabs: | **Tab** | **Description** | | --- | --- | | **Sale** | Enter an amount and select **Process** to open the Tap to Pay reader. Hold a contactless card or an Apple Pay device near the iPhone to complete the transaction. | | **Reporting** | Browse the transaction history for your terminal. Select a row to view the full details of a transaction. | | **Settings** | Set the terminal ID. Your changes take effect after you select **Save** and reconnect. | ## Before you begin Make sure that you've downloaded the Tap to Pay on iPhone SDK and extracted the contents. For more information, go to [Download the SDK package](/guides/payments/tap-to-pay-on-iphone/set-up-the-sdk#step-1-download-the-sdk-package). Make sure that you have the following: - Xcode 15 or later. - An iPhone XS or later that runs iOS 18 or later. - An Apple Developer account that you've enrolled in the Apple Developer Program. - An approved [Tap to Pay on iPhone entitlement](https://developer.apple.com/documentation/proximityreader/setting-up-the-entitlement-for-tap-to-pay-on-iphone). ## Integration steps 1. [Open the project](#step-1-open-the-project). 2. [Configure signing](#step-2-configure-signing). 3. [Add your API key](#step-3-add-your-api-key). 4. [Run the app](#step-4-run-the-app). ## Step 1. Open the project 1. From the Tap to Pay on iPhone SDK folder, go to the sample app folder in `iosSample/`. 2. Open the `.xcodeproj` file in Xcode for the language that you want to use:- Swift: `iosSample/swiftSample/SwiftSample.xcodeproj` - Objective-C: `iosSample/objectivecSample/CoreSDKExample.xcodeproj` 3. In the **Project navigator**, select the project file, and then select the app target. ## Step 2. Configure signing The package doesn't include signing configuration, so you must set your own team and bundle ID before you build. **Important:** The provisioning profile for your bundle identifier must include the Tap to Pay on iPhone entitlement, `com.apple.developer.proximity-reader.payment.acceptance`. Add the entitlement to your App ID in the Apple Developer portal, and then generate your provisioning profile again. In the target's **Signing & Capabilities** tab, complete the following steps: 1. For **Development Team**, select your Apple Developer team. 2. For **Bundle Identifier**, enter a unique reverse-DNS identifier that is registered to your account, for example, `com.yourcompany.payroc-sample`. 3. For **Signing Certificate**, select **Automatically manage signing**, or select a provisioning profile that includes the Tap to Pay on iPhone entitlement. **Note:** If you use automatic signing, add an entitlements file to the target, and then enable **Tap to Pay on iPhone** in **Signing & Capabilities**. Xcode syncs the entitlement to your provisioning profile. ## Step 3. Add your API key The `payconfig.xml` file in the project root contains the gateway URLs and your API key. The file in the package already has the environment URLs, but you must add your API key. ```xml YOUR_API_KEY ``` ## Step 4. Run the app 1. Connect your iPhone to your Mac with a cable, or pair it wirelessly. 2. In Xcode, from the run destination picker, select your device. 3. Select **Run**. 4. When the app opens, go to the **Settings** tab. 5. Enter your terminal ID, and then select **Save**. 6. After the app retrieves your terminal configuration, on the **Sale** tab, select the device icon to initialize the reader. **Note:** The sample apps run in `TEST` mode. Test transactions don't process real payments and don't appear in your production reporting. # Set up the SDK Source: https://docs.payroc.com/guides/payments/tap-to-pay-on-iphone/set-up-the-sdk Add the Tap to Pay on iPhone SDK to your Xcode project, link the libraries, and configure your build settings. **Prerequisites:** [Authentication](/api/authentication) To set up the SDK and start integrating, add the Tap to Pay on iPhone SDK to your Xcode project, and then configure your build settings. ## Integration steps 1. Download the SDK package. 2. Extract the archives. 3. Link the libraries to your app. 4. Copy the resources to your project. 5. Add your API key. 6. (Optional) Create a Swift bridging header. 7. Update your build settings. ## Step 1. Download the SDK package - Go to our [Tap to Pay on iPhone GitHub repository](https://github.com/payroc/payroc-sdk-tap_to_pay_iphone/releases), and then download the latest release. ## Step 2. Extract the archives 1. Extract the contents from the **PayrocTapToPayOniPhoneSDK** zip folder. The package contains the following folders and files: | **Folder or file** | **Description** | | --- | --- | | docs/ | HTML documentation and a script to load the documentation on your computer. | | iosSample/ | [Sample apps](/guides/payments/tap-to-pay-on-iphone/run-the-sample-apps) that we've created using Swift and Objective-C. | | libs/ | SDK and plugin static libraries. | | payconfig.xml | Configuration file that contains the gateway URLs and your API key. | 2. Go to the **libs** folder, and then extract the following zip folders: - **gochip-applettp\*.zip** - **gochip-sdk\*.zip** ## Step 3. Link the libraries to your app 1. In Xcode, open your project, and then select your project in the **Project navigator**. 2. From the **TARGETS** list, select your app. 3. Select the **Build Phases** tab. 4. Expand **Link Binary With Libraries**, and then select **+**. 5. Add each of the following libraries: - **libAFNetworking\*.a** - **libc++.tbd** - **libgochip-common\*.a** - **libgochip-restconnector\*.a** - **libgochip-sdk\*.a** - **libgochip-applettp\*.a** - **libISO8601\*.a** - **libJSONModel\*.a** ## Step 4. Copy the resources to your project - Copy the following files to the root of your app project: - **PayrocTapToPayOniPhoneSDK/libs/Core.h** - **PayrocTapToPayOniPhoneSDK/payconfig.xml** ### Check that Xcode copied payconfig.xml into your app If the **payconfig.xml** file isn't in **Copy Bundle Resources**, your app builds successfully but can't reach our gateway. To check that Xcode copied **payconfig.xml** into your app when it builds, complete the following steps: 1. From the **TARGETS** list, select your app, and then select the **Build Phases** tab. 2. Expand **Copy Bundle Resources**. 3. Check that the **payconfig.xml** file appears in the list. 4. (Optional) If the **payconfig.xml** file isn't in the list, select **+**, and then add it. ## Step 5. Add your API key - In the **payconfig.xml** file, enter your API key and integration ID. **Note:** We provided you with your API key and integration ID when you boarded with us. ## Step 6. (Optional) Create a Swift bridging header If you're using Objective-C, go to [Step 7. Update your build settings](#step-7-update-your-build-settings). If you're using Swift, you need to create a Swift bridging header. To create a Swift bridging header, complete the following steps: 1. Create a file named **\[YourAppName\]-Bridging-Header.h** in the root of your project. 2. Add the following code to the file: ```objectivec #ifndef [YourAppName]_Bridging_Header_h #define [YourAppName]_Bridging_Header_h #import "Core.h" #endif /* [YourAppName]_Bridging_Header_h */ ``` ## Step 7. Update your build settings 1. From the **TARGETS** list, select your app, and then select the **Build Settings** tab. 2. In the search box, search for **Other Linker Flags**, and then set its value to `-ObjC`. 3. Search for **Header Search Paths**, and then add the path to the root of your app project. 4. (Optional) If you're using Swift, search for **Objective-C Bridging Header**, and then set its value to the path of the bridging header that you created in [Step 6](#step-6-optional-create-a-swift-bridging-header). ## Next step After you set up the SDK, you need to [configure the processing terminal](/guides/payments/tap-to-pay-on-iphone/configure-the-processing-terminal). # 3-D Secure Source: https://docs.payroc.com/guides/payments/three-d-secure Explains how 3-D Secure verifies a cardholder's identity during online transactions and how it fits into your integration **Prerequisites:** [Authentication](/api/authentication) 3-D Secure is a security feature that helps to verify the cardholder’s identity during e-commerce transactions. Each time the merchant runs a transaction, the issuing bank assesses the transaction. If the risk of fraud is high, the issuing bank uses 3-D Secure to challenge the cardholder to verify their identity. ## How it works The following diagram shows how 3-D Secure works with your integration. ```mermaid sequenceDiagram participant YI as Your integration participant GW as Gateway participant MPI as MPI service participant IB as Issuing bank rect rgba(0, 81, 194, 0.4) Note over YI,GW: 1. Tokenize the payment details YI->>GW: Convert card details to a single-use token
POST /v1/processing-terminals/{processingTerminalId}/single-use-tokens
or Hosted Fields GW-->>YI: singleUseToken end rect rgba(0, 224, 184, 0.3) Note over YI,IB: 2. Run the 3-D Secure check YI->>MPI: Redirect the cardholder to /merchant/mpi
(processingTerminalId, singleUseToken, amount, currency, orderId, email) MPI->>IB: Send payment details for authentication Note over IB: Assess risk and, if needed,
challenge the cardholder IB-->>MPI: Authentication result MPI-->>YI: Redirect the cardholder back to your MPI receipt URL
(result, mpiReference, status, eci, orderId) end rect rgba(0, 224, 184, 0.3) Note over YI,GW: 3. Run the sale YI->>GW: POST /v1/payments
(threeDSecure.serviceProvider = gateway,
threeDSecure.mpiReference) GW-->>YI: Payment response end ``` 1. Your integration converts the cardholder's payment details into a single-use token. 2. Your integration redirects the cardholder's browser to our merchant plug-in (MPI) service and includes the single-use token and the transaction details as query parameters. 3. The MPI service sends the details to the cardholder's issuing bank, which assesses the risk of fraud and, if needed, challenges the cardholder to verify their identity. 4. We redirect the cardholder's browser to your MPI receipt URL, with the result and the MPI reference in the query parameters. 5. Your integration sends a payment request with the MPI reference to our gateway. Our gateway returns the transaction result. ## Guides #### [Run a sale with 3-D Secure](/guides/payments/three-d-secure/run-a-sale-with-3-d-secure) Use 3-D Secure to verify a cardholder's identity before you run a sale. # Run a sale with 3-D Secure Source: https://docs.payroc.com/guides/payments/three-d-secure/run-a-sale-with-3-d-secure Run a card sale with 3-D Secure authentication by redirecting the cardholder to our merchant plug-in (MPI) service to verify their identity, then submitting the MPI reference in a POST request to the Payments endpoint. **Prerequisites:** [Authentication](/api/authentication) Use our 3-D Secure feature to verify a cardholder’s identity during an e-Commerce transaction. ## Integration steps **Step 1.** Sign up for 3-D Secure. **Step 2.** Convert the cardholder’s payment details into a single-use token. **Step 3.** Redirect the browser to the MPI service. **Step 4.** Run a sale. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Sign up for 3-D Secure To sign up for 3-D Secure, contact our Customer Support team at [cs@payroc.com](mailto:cs@payroc.com). When you sign up for 3-D Secure, provide us with the URL of the page on your website that you want us to send the cardholder to after the 3-D Secure check. We refer to this as the MPI receipt URL. Each processing terminal can have only one MPI receipt URL. You must include the domain of the website and the path, for example, `https://{mydomain}.com/Home/MPIResponse`. If you need to change the MPI receipt URL, contact [cs@payroc.com](mailto:cs@payroc.com). ## Step 2. Convert the cardholder’s payment details into a single-use token Before you can redirect the cardholder to our MPI service, you need to convert the cardholder’s payment details into a single-use token. You send the single-use token when you redirect the cardholder to the MPI service URL in Step 3, and when you run the sale in Step 4. To create a single-use token, you can use [Hosted Fields](/guides/payments/hosted-fields) or you can use our tokenization feature in our [API](/api). Single-use tokens expire after 30 minutes. To run a 3-D Secure check, you need to include the cardholder's email address. Hosted Fields doesn’t capture the cardholder’s email address by default, so you need to capture it as part of your checkout. To extend your Hosted Fields integration to capture an email address, go to [Add your own fields](/guides/payments/hosted-fields/add-your-own-fields). ## Step 3. Redirect the browser to the MPI service **Important:** Don’t call the MPI service URL from your server. Set up a client-side redirect that sends the cardholder’s browser to the MPI service URL. In the query parameters of the URL, send the single-use token and information about the transaction. Before you redirect the cardholder, make sure that you save the single-use token and the transaction details. You need them to run the sale in Step 4. | Environment | URL | | --- | --- | | Test | [https://payments.uat.payroc.com/merchant/mpi](https://payments.uat.payroc.com/merchant/mpi) | | Production | [https://payments.payroc.com/merchant/mpi](https://payments.payroc.com/merchant/mpi) | ### Query parameters Include the following query parameters in the MPI service URL: | Parameter | Type | Required? | Description | | --- | --- | --- | --- | | processingTerminalId | string | Yes | Unique identifier that we assigned to the terminal. | | singleUseToken | string | Yes | Unique token that the gateway assigned to the payment details. | | email | string | Yes | Cardholder’s email address. | | amount | number \ | Yes | Total amount of the transaction, which includes surcharges. The value is in the currency’s lowest denomination, for example, cents. | | currency | string | Yes | [ISO-4217](https://www.iso.org/iso-4217-currency-codes.html) currency code of the transaction. | | orderId | string | Yes | Unique identifier that the merchant assigns to the order. | | cardholderChallenge | string | No | Indicates if the merchant wants the issuing bank to challenge the cardholder. Send one of the following values: • `REQUIRED` - Merchant wants the issuing bank to challenge the cardholder. • `OPTIONAL` - Issuing bank decides whether to challenge the cardholder. | ### Example request ``` https://payments.payroc.com/merchant/mpi?processingTerminalId=4479001&amount=100¤cy=EUR&orderId=25&email=joe%40adomain.com&singleUseToken=1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d ``` ### Response fields After the 3-D Secure check, we redirect the cardholder’s browser to the MPI receipt URL that you provided when you signed up for 3-D Secure. We include the following response fields as query parameters to the MPI receipt URL: | Field | Description | | --- | --- | | result | Indicates the result of the 3-D Secure check. We return one of the following values: • `A` - The issuing bank approved the transaction. • `D` - The issuing bank declined the transaction. | | mpiReference | MPI reference of the 3-D Secure check. | | orderId | Unique identifier that the merchant assigned to the order. | | status | Status of the 3-D Secure check. We return one of the following values: • `A` - Issuing bank attempted to authenticate the cardholder’s identity. • `N` - Issuing bank didn’t attempt to authenticate the cardholder’s identity. • `U` - Issuing bank was unable to authenticate the cardholder’s identity. • `Y` - Issuing bank authenticated the cardholder’s identity. | | eci | Response code from 3-D Secure. We return one of the following values: • `05` - Issuing bank used 3-D Secure to authenticate the cardholder. • `06` - Issuing bank or cardholder is not enrolled for 3D Secure. • `07` - 3-D Secure check failed. | ### Example response ``` https://{MPI_RECEIPT_URL}?result=A&status=A&eci=06&mpiReference=d01656cf0ec3e62e3754&orderId=25 ``` ## Step 4. Run a sale To run a sale, send a POST request from your server to our Payments endpoint. Use the same single-use token and transaction details that you sent to the MPI service in Step 3. **Endpoint:** `https://api.payroc.com/v1/payments` ### Request parameters For the paymentMethod object, send values for the following parameters: - **type:** Send a value of `singleUseToken`. - **token:** Send the single-use token that you used in Step 3. For the threeDSecure object, send values for the following parameters: - **serviceProvider:** Send a value of `gateway`. - **mpiReference:** Send the MPI reference that we sent to your MPI receipt URL in Step 3. To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments`](/api/payment) ### Example request ### Request POST https://api.payroc.com/v1/payments ```curl curl -X POST https://api.payroc.com/v1/payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "channel": "web", "processingTerminalId": "4479001", "order": { "orderId": "25", "amount": 100, "currency": "EUR", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d" }, "threeDSecure": { "serviceProvider": "gateway", "mpiReference": "d01656cf0ec3e62e3754" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "contactMethods": [ { "type": "email", "value": "joe@adomain.com" } ], "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Card Payment`** ```python import requests url = "https://api.payroc.com/v1/payments" payload = { "channel": "web", "processingTerminalId": "4479001", "order": { "orderId": "25", "amount": 100, "currency": "EUR", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d" }, "threeDSecure": { "serviceProvider": "gateway", "mpiReference": "d01656cf0ec3e62e3754" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "contactMethods": [ { "type": "email", "value": "joe@adomain.com" } ], "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Card Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"channel":"web","processingTerminalId":"4479001","order":{"orderId":"25","amount":100,"currency":"EUR","description":"Large Pepperoni Pizza"},"paymentMethod":{"type":"singleUseToken","token":"1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d"},"threeDSecure":{"serviceProvider":"gateway","mpiReference":"d01656cf0ec3e62e3754"},"operator":"Jane","customer":{"firstName":"Sarah","lastName":"Hopper","contactMethods":[{"type":"email","value":"joe@adomain.com"}],"billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}}},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Card Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments" payload := strings.NewReader("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"4479001\",\n \"order\": {\n \"orderId\": \"25\",\n \"amount\": 100,\n \"currency\": \"EUR\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d\"\n },\n \"threeDSecure\": {\n \"serviceProvider\": \"gateway\",\n \"mpiReference\": \"d01656cf0ec3e62e3754\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@adomain.com\"\n }\n ],\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Card Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"4479001\",\n \"order\": {\n \"orderId\": \"25\",\n \"amount\": 100,\n \"currency\": \"EUR\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d\"\n },\n \"threeDSecure\": {\n \"serviceProvider\": \"gateway\",\n \"mpiReference\": \"d01656cf0ec3e62e3754\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@adomain.com\"\n }\n ],\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Card Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"4479001\",\n \"order\": {\n \"orderId\": \"25\",\n \"amount\": 100,\n \"currency\": \"EUR\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d\"\n },\n \"threeDSecure\": {\n \"serviceProvider\": \"gateway\",\n \"mpiReference\": \"d01656cf0ec3e62e3754\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@adomain.com\"\n }\n ],\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Card Payment`** ```php request('POST', 'https://api.payroc.com/v1/payments', [ 'body' => '{ "channel": "web", "processingTerminalId": "4479001", "order": { "orderId": "25", "amount": 100, "currency": "EUR", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "singleUseToken", "token": "1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d" }, "threeDSecure": { "serviceProvider": "gateway", "mpiReference": "d01656cf0ec3e62e3754" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "contactMethods": [ { "type": "email", "value": "joe@adomain.com" } ], "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Card Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"4479001\",\n \"order\": {\n \"orderId\": \"25\",\n \"amount\": 100,\n \"currency\": \"EUR\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"singleUseToken\",\n \"token\": \"1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d\"\n },\n \"threeDSecure\": {\n \"serviceProvider\": \"gateway\",\n \"mpiReference\": \"d01656cf0ec3e62e3754\"\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@adomain.com\"\n }\n ],\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Card Payment`** ````swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "channel": "web", "processingTerminalId": "4479001", "order": [ "orderId": "25", "amount": 100, "currency": "EUR", "description": "Large Pepperoni Pizza" ], "paymentMethod": [ "type": "singleUseToken", "token": "1a8731f50b02e287ac0529fbce352317c089d4adc1178c1867d65114078791d3c3e13962cbab6b574769dfe9ad5397a5aa67a529ceb0b7be17751f076bbe0e4d" ], "threeDSecure": [ "serviceProvider": "gateway", "mpiReference": "d01656cf0ec3e62e3754" ], "operator": "Jane", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "contactMethods": [ [ "type": "email", "value": "joe@adomain.com" ] ], "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ] ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```nse fields If your request is successful, we create the payment and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments`](/api/payment) le response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ```` ## Test your integration To test your integration, use the following test cards with the test MPI service URL. | Card number | Card brand | Expected outcome | Expected status | | --- | --- | --- | --- | | 4012000000020071 | Visa | 3-D Secure doesn't challenge the cardholder. | `Y` - Issuing bank authenticated the cardholder’s identity. | | 4012000000020089 | Visa | 3-D Secure doesn't challenge the cardholder. | `A` - Issuing bank attempted to authenticate the cardholder’s identity. | | 5100270000000023 | Mastercard | 3-D Secure doesn't challenge the cardholder. | `Y` - Issuing bank authenticated the cardholder’s identity. | | 4012000000020006 | Visa | 3-D Secure requests authentication from the cardholder. | `Y` - Issuing bank authenticated the cardholder’s identity. | | 5100270000000031 | Mastercard | 3-D Secure requests authentication from the cardholder. | `Y` - Issuing bank authenticated the cardholder’s identity. | | 4012000000020121 | Visa | 3-D Secure doesn't challenge the cardholder. | `N` - Issuing bank didn’t attempt to authenticate the cardholder’s identity. | | 5100270000000056 | Mastercard | 3-D Secure requests authentication from the cardholder. | `N` - Issuing bank didn’t attempt to authenticate the cardholder’s identity. | | 5555666666662222 | Mastercard | 3-D Secure doesn't challenge the cardholder. | `U` - Issuing bank was unable to authenticate the cardholder’s identity. | If a test card triggers a 3-D Secure challenge, the test MPI service redirects the cardholder’s browser to a simulated authentication page where you need to enter a password. Follow the instructions on the page to enter the password. After you submit the password, we redirect the cardholder’s browser to your MPI receipt URL. # Add custom fields to your integration Source: https://docs.payroc.com/guides/payments/add-custom-fields Add merchant-defined custom fields to card payments, bank transfers, refunds, subscriptions, and secure token requests using the customFields object. **Prerequisites:** [Authentication](/api/authentication) To allow merchants to add their own information to transactions, use the custom fields feature of our API. For example, your merchants can use custom fields to add a credit agreement ID, a magazine subscription name, or an internal customer ID. You can also use the custom fields feature to create dynamic descriptors. A dynamic descriptor is text that appears on the customer's statement with the transaction. For more information about dynamic descriptors, go to [Dynamic Descriptors](/knowledge/payments/dynamic-descriptors). The following resources on our API support the custom fields feature: - Card payments and refunds - Bank transfer payments and refunds - Subscriptions - Secure tokens ## Integration steps **Step 1.** Contact us to activate custom fields. **Step 2.** Create the custom field on the merchant's Self Care Portal. **Step 3.** (Optional) Set the custom field as a dynamic descriptor. **Step 4.** Add the custom field to your integration. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). **Note:** If your request is successful but there is an issue with the custom field, we don’t store the custom field and don’t return it in the response. ### Step 1. Contact us to activate custom fields Before you can use custom fields, contact our Integrations Team to activate the custom fields feature on your account. To contact our Integrations Team, send an email to [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ### Step 2. Create the custom field on the Self Care Portal 1. Log in to the [Self Care Portal](https://payments.payroc.com/) or the [UAT version of the Self Care Portal](https://payments.uat.payroc.com/merchant). 2. From the **side menu**, select **Settings** \> **Custom Fields** \> **NEW CUSTOM FIELD**. 3. Enter the following information about the custom field: **Name** – The name of the custom field. **Type** – The data type that the Self Care Portal displays for the custom field. **Display order** – The position of the custom field on the Self Care Portal. For example, if you set the value for the display order to 3, the custom field appears third in the list of custom fields. **Label** – The label for the custom field in the Self Care Portal. **Language** – The language for the label. 4. (Optional) If you want to use custom fields with payment plans and subscriptions, select **Enable Subscription**. 5. (Optional) Select the other payment features that you want to use custom fields with. 6. Select **SAVE**. ### Step 3. (Optional) Set the custom field as a dynamic descriptor To set the custom field as a dynamic descriptor, turn on dynamic descriptors for the processing terminal, and then select which custom field you want to use as the dynamic descriptor. #### Enable dynamic descriptors 1. In the **Self Care Portal**, select **Merchants**, and then select the merchant that you want to edit. 2. Select **Processing Terminal**, and then select the terminal that you want to edit. 3. Select **Features**. 4. Select **Allow Dynamic Descriptor**. 5. Enter the following information for the dynamic descriptor: **Dynamic Descriptor Prefix** – The prefix that appears at the start of the description. For example, `Order #`. **Dynamic Descriptor Default Value** – The default description for the dynamic descriptor if the merchant doesn't provide a value. 6. Select **SAVE**. #### Select the custom field to use as the dynamic descriptor 1. From the **Custom Fields** screen, select the **Settings** tab, and then select Dynamic Descriptors. 2. From the **Other** drop-down menu, select the custom field that you want to use as the dynamic descriptor. **Note:** If you want to add the custom field as a dynamic descriptor for other features, select the custom field from the Virtual Terminal, Hosted Payment Page, or Bulk Payments drop-down menus. ### Step 4. Add the custom field object to your API requests You can use custom fields with the following POST requests: **Bank transfer payments** - [Create payment](/api/bank-transfer-payment) **Bank transfer refunds** - [Create refund](/api/bank-transfer-unreferenced-refund) **Payments** - [Create payment](/api/payment) **Refunds** - [Create refund](/api/unreferenced-refund) **Secure tokens** - [Create secure token](/api/create-secure-token) **Subscriptions** - [Create subscription](/api/create-subscription) - [Pay manual subscription](/api/pay-subscription) **Note:** Before you can use a custom field with a subscription, you need to add the custom field to the payment plan. For more information about using custom fields with payment plans and subscriptions, go to [Payment plans and subscriptions](#payment-plans-and-subscriptions). To add custom fields to your integration, include the customFields object in the body of your requests. ```json "customFields": [ { "name": "EXAMPLE", "value": "1" } ] ``` | Parameter | Description | | --- | --- | | name | The name of the custom field. This must match the name you provided in the Self Care Portal and is case-sensitive. | | value | The string value for the custom field. | If your request is successful, we store the custom field and return it in the response. **Important:** If there is a problem with the custom field, we still process the request but we don't return the custom field in the response. For example, if the name of the custom field doesn't match the name you provided in the Self Care Portal, we don't return the custom field in the response. #### Update the value of a custom field To update a custom field, send a PATCH request to the relevant endpoint. Structure your request to follow the RFC 6902 standard. **Note:** If you update a custom field that is also a dynamic descriptor, the new value doesn’t appear on the customer’s statement. #### Payment plans and subscriptions When you create a payment plan you need to indicate which custom fields are available for subscriptions that are linked to the payment plan. To indicate which custom fields are available for subscriptions, add the name of the custom field in a customFieldNames array to the [Create payment plan](/api/create-payment-plan) request. ```json "customFieldNames": [ "yourCustomField" ] ``` **Important:** The name of the custom field must match the name you provided in the Self Care Portal. # Close an ACH payment Source: https://docs.payroc.com/guides/payments/close-ach Close an ACH payment: If NACHA returned an ACH payment and the merchant accepted an alternative payment method, you can use our API to close the return without re-presenting the payment to NACHA. If NACHA returned an ACH payment and the merchant accepted an alternative payment method, you can use our API to close the return without re-presenting the payment to NACHA. **Note:** Use this method to permanently close a return. If you want to retry the payment, use our [Re-present Payment](/api/represent-bank-transfer-payment) method instead. ## How it works 1. We email the merchant to let them know that NACHA returned an ACH payment. 2. Merchant uses an alternative payment method to collect payment from their customer. 3. Merchant uses their POS to close the return. ## Your integration journey 1. View the payment details. 2. Close the return. ## Things to consider When you close a return, don't use the paymentId that you use to retrieve the payment. In the response of the Retrieve Payment method, our gateway includes a returns array with a new paymentId, which you need to send in the Close Return request. ```json ... "returns": [ { "paymentId": "GIJXAU3WUJ", "date": "2025-06-23", "returnCode": "R01", "returnReason": "Insufficient Funds", "represented": false, "closed": false, "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/bank-transfer-payments/GIJXAU3WUJ" } } ], ... ``` ## Errors If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors). ## Step 1. View the payment details To view the details of the return, send a GET request to our Bank Transfer Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments/:paymentId` ### Request parameters ### Schema (`request.path`) [Path parameters for `GET /bank-transfer-payments/{paymentId}`](/api/get-bank-transfer-payment) ### Example request ### Request GET [https://api.payroc.com/v1/bank-transfer-payments/\{paymentId\}](https://api.payroc.com/v1/bank-transfer-payments/%7BpaymentId%7D) **`Store Token Bank Transfer Payment`** ```curl curl https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y \ -H "Authorization: Bearer " ``` **`Store Token Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Store Token Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Store Token Bank Transfer Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Store Token Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Store Token Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y") .header("Authorization", "Bearer ") .asString(); ``` **`Store Token Bank Transfer Payment`** ```php request('GET', 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Store Token Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Store Token Bank Transfer Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields **Important:** Save the paymentId from the returns object for closing the payment. If your request is successful, our gateway sends a returns object that contains a returnCode field and a returnReason field that indicates the reason the payment was returned. ### Schema (`response.body`) [Response body schema for `GET /bank-transfer-payments/{paymentId}`](/api/get-bank-transfer-payment) ### Example response ### Response (200) ```json { "paymentId": "E29U8OU8Q4", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef7654", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "ach", "accountNumber": "****1591", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "secCode": "web" }, "transactionResult": { "type": "payment", "status": "declined", "responseCode": "D", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "Payment Declined", "processorResponseCode": "R11" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "returns": [ { "paymentId": "M2MJOG6O2Y", "date": "2024-07-02", "returnCode": "R11", "returnReason": "Customer advises not authorized", "represented": false, "closed": false, "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" } } ] } ``` ## Step 2. Close the return To close the return, send a POST request to our Bank Transfer Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments/:paymentId/close` ### Request parameters ### Schema (`request.path`) [Path parameters for `POST /bank-transfer-payments/{paymentId}/close`](/api/close-bank-transfer-payment) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-payments/\{paymentId\}/close](https://api.payroc.com/v1/bank-transfer-payments/%7BpaymentId%7D/close) **`Store Token Bank Transfer Payment`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " ``` **`Store Token Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close" headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer " } response = requests.post(url, headers=headers) print(response.json()) ``` **`Store Token Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ' } }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Store Token Bank Transfer Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Store Token Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Store Token Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .asString(); ``` **`Store Token Bank Transfer Payment`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close', [ 'headers' => [ 'Authorization' => 'Bearer ', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Store Token Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Store Token Bank Transfer Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer " ] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/close")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway closes the return. ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-payments/{paymentId}/close`](/api/close-bank-transfer-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "ach", "accountNumber": "****3159", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "secCode": "web", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } } }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "NoError", "processorResponseCode": "0" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Re-present an ACH payment Source: https://docs.payroc.com/guides/payments/represent-ach Retrieve the reason a bank transfer payment failed and resubmit it by sending a GET and then a POST request to the Bank Transfer Payments endpoint **Prerequisites:** [Authentication](/api/authentication) If an ACH payment has failed, we send an email to the merchant to let them know that the payment has failed. You can integrate with our API return the reason that the payment failed and then re-present the payment. **Note:** When the merchant views the reason why the payment failed, they might have to contact their customer to fix the issue before they can re-present the payment. ## How it works Each time you re-present a payment, you use a new `paymentId` from the returns object of the retrieved payment, not the `paymentId` you used to retrieve it. You can re-present a payment up to two times. ```mermaid sequenceDiagram participant M as Merchant participant GW as Gateway participant N as NACHA Note over M,N: An ACH payment has failed rect rgba(0, 81, 194, 0.4) Note over M,GW: Find out why the payment failed GW-->>M: Email: the ACH payment failed M->>GW: GET /bank-transfer-payments/:paymentId GW-->>M: returns[].paymentId and the failure reason Note over M: Contact the customer to
fix the issue, if needed end rect rgba(0, 224, 184, 0.3) Note over M,N: Re-present the payment M->>GW: POST /bank-transfer-payments/:paymentId/represent
using the new paymentId from returns GW->>N: Submit the re-presentment Note over M,N: If the payment fails again, repeat both steps with each new
paymentId from the returns object. You can re-present twice. end ``` 1. We email the merchant to let them know that an ACH payment has failed. 2. Merchant uses their POS to view the details of the payment and the reason the payment has failed. 3. Merchant contacts their customer to fix the issue. 4. Merchant uses their POS to re-present the payment. ## Your integration journey 1. View the payment details. 2. Re-present the payment. 3. (Optional) Re-present the payment again. **Note:** You can re-present a payment up to two times. ## Things to consider When you re-present a payment, don't use the same `paymentId` that you use to retrieve the payment. In the response of the Retrieve Payment method, our gateway sends a returns object with a new `paymentId`, which you need to send in the Re-present Payment request. ```json ... "returns": [ { "paymentId": "GIJXAU3WUJ", "date": "2025-06-23", "returnCode": "R01", "returnReason": "Insufficient Funds", "represented": false, "closed": false, "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/bank-transfer-payments/GIJXAU3WUJ" } } ], ... ``` ## Errors If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors). ## Step 1. View the payment details To view the reason why the payment failed, send a GET request to our Bank Transfer Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments/{paymentId}` ### Request parameters ### Schema (`request.path`) [Path parameters for `GET /bank-transfer-payments/{paymentId}`](/api/get-bank-transfer-payment) ### Example request ### Request GET [https://api.payroc.com/v1/bank-transfer-payments/\{paymentId\}](https://api.payroc.com/v1/bank-transfer-payments/%7BpaymentId%7D) **`Store Token Bank Transfer Payment`** ```curl curl https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y \ -H "Authorization: Bearer " ``` **`Store Token Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Store Token Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Store Token Bank Transfer Payment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Store Token Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Store Token Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y") .header("Authorization", "Bearer ") .asString(); ``` **`Store Token Bank Transfer Payment`** ```php request('GET', 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Store Token Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Store Token Bank Transfer Payment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields **Important:** Save the `paymentId` from the returns object for the re-presentment. If your request is successful, our gateway sends a returns object that contains a returnCode field and a returnReason field that indicates the reason the payment failed. ### Schema (`response.body`) [Response body schema for `GET /bank-transfer-payments/{paymentId}`](/api/get-bank-transfer-payment) ### Example response ### Response (200) ```json { "paymentId": "E29U8OU8Q4", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef7654", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "ach", "accountNumber": "****1591", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "secCode": "web" }, "transactionResult": { "type": "payment", "status": "declined", "responseCode": "D", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "Payment Declined", "processorResponseCode": "R11" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "returns": [ { "paymentId": "M2MJOG6O2Y", "date": "2024-07-02", "returnCode": "R11", "returnReason": "Customer advises not authorized", "represented": false, "closed": false, "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y" } } ] } ``` ## Step 2. Re-present the payment To retry the payment, send a POST request to our Bank Transfer Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments/{paymentId}/represent` ### Request parameters ### Schema (`request.path`) [Path parameters for `POST /bank-transfer-payments/{paymentId}/represent`](/api/represent-bank-transfer-payment) ### Schema (`request.body`) [Request body schema for `POST /bank-transfer-payments/{paymentId}/represent`](/api/represent-bank-transfer-payment) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-payments/\{paymentId\}/represent](https://api.payroc.com/v1/bank-transfer-payments/%7BpaymentId%7D/represent) **`Representment Bank Transfer Payment`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "tel" } }' ``` **`Representment Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent" payload = { "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "tel" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Representment Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"paymentMethod":{"type":"ach","accountNumber":"11101010","nameOnAccount":"Sarah Hopper","routingNumber":"053200983","accountType":"checking","secCode":"tel"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Representment Bank Transfer Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent" payload := strings.NewReader("{\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"tel\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Representment Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"tel\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Representment Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"tel\"\n }\n}") .asString(); ``` **`Representment Bank Transfer Payment`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent', [ 'body' => '{ "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "tel" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Representment Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"tel\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Representment Bank Transfer Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["paymentMethod": [ "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "tel" ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments/M2MJOG6O2Y/represent")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: \{ (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway sends the re-presentment to NACHA to retry the payment. ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-payments/{paymentId}/represent`](/api/represent-bank-transfer-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "ach", "accountNumber": "****1010", "nameOnAccount": "Sarah Hopper", "routingNumber": "053200983", "secCode": "tel", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } } }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "NoError", "processorResponseCode": "0" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Step 3. (Optional) Re-present the payment again If the re-presentment fails, you can send a second and final re-presentment request. To do this: 1. Save the paymentId from the response in Step 2. This is the paymentId of the failed re-presentment. 2. Use our [Retrieve Payment](https://docs.payroc.com/api/schema/bank-transfer-payments/payments/retrieve) method with the paymentId of the failed re-presentment. In the response, our gateway sends a returns object with a new paymentId. 3. Use our [Re-present Payment](https://docs.payroc.com/api/schema/bank-transfer-payments/payments/represent) method with this new paymentId to re-present the payment for a final time. # Run a card sale Source: https://docs.payroc.com/guides/payments/run-a-card-sale Run a card sale by sending a POST request to the Payments endpoint with card details and amount to take funds from a customer's card. **Prerequisites:** [Authentication](/api/authentication) A merchant can use their POS to run card sales. ## Integration steps - Run a sale. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ### Run a sale To run a sale, send a POST request to our Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/payments` **Important:** This method includes the following functions: - Tokenization - Pre-authorization - Currency conversion - Offline processing We don’t describe how to integrate with these functions in this guide. ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments`](/api/payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **`Card Payment`** ```curl curl -X POST https://api.payroc.com/v1/payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Card Payment`** ```python import requests url = "https://api.payroc.com/v1/payments" payload = { "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Card Payment`** ```javascript const url = 'https://api.payroc.com/v1/payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"channel":"web","processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","amount":4999,"currency":"USD","description":"Large Pepperoni Pizza"},"paymentMethod":{"type":"card","cardDetails":{"entryMethod":"keyed","keyedData":{"dataFormat":"plainText","cardNumber":"4539858876047062","device":{"model":"paxA80","serialNumber":"WPC202833004712"},"expiryDate":"1230"}}},"operator":"Jane","customer":{"firstName":"Sarah","lastName":"Hopper","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}}},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Card Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments" payload := strings.NewReader("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Card Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Card Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Card Payment`** ```php request('POST', 'https://api.payroc.com/v1/payments', [ 'body' => '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Card Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Card Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "channel": "web", "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "description": "Large Pepperoni Pizza" ], "paymentMethod": [ "type": "card", "cardDetails": [ "entryMethod": "keyed", "keyedData": [ "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": [ "model": "paxA80", "serialNumber": "WPC202833004712" ], "expiryDate": "1230" ] ] ], "operator": "Jane", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ] ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway uses the card details to run a sale. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments`](/api/payment) ### Example response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 4999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "OK3" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "adjustTip", "setAsPending" ], "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Test cases Before you run test cases, read the [Payments](/guides/testing/online-payments) page in Test Your Integration. ### Run a card sale without a surcharge Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **Example response** ```json { "paymentId": "F1I17KBL0E", "processingTerminalId": "3204001", "order": { "orderId": "Test_001", "dateTime": "2023-05-24T14:44:20.63+01:00", "amount": 4000, "currency": "USD" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "0334", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "paymentResult": { "type": "sale", "status": "ready", "approvalCode": "OK14472", "authorizedAmount": 4000, "currency": "USD", "responseCode": "A", "responseMessage": "OK14472" } } ``` ### Run a card sale with a surcharge Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **Note:** If you are unsure whether your account supports surcharges, email our Integration team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). **Example response** ```json { "paymentId": "CBA7UOVS0J", "processingTerminalId": "3204001", "order": { "orderId": "Test_005", "dateTime": "2023-05-24T14:48:39.548+01:00", "amount": 4160, "currency": "USD", "breakdown": { "subtotal": 4000, "surcharge": { "bypass": false, "amount": 160, "percentage": 4.0 } } }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "0334", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "paymentResult": { "type": "sale", "status": "ready", "approvalCode": "OK14476", "authorizedAmount": 4160, "currency": "USD", "responseCode": "A", "responseMessage": "OK14476" } } ``` # Run a pre-authorization Source: https://docs.payroc.com/guides/payments/run-a-pre-authorization Hold funds on a customer's card by sending a POST request to the Payments endpoint with autoCapture and processAsSale set to false, then optionally adjust and finally capture the pre-authorization. **Prerequisites:** [Authentication](/api/authentication) A merchant can use pre-authorizations to hold an amount on a customer’s card to capture later. The merchant can run pre-authorizations only if we have enabled the function on their account. If a merchant needs to capture more than they originally pre-authorized, they can adjust the pre-authorization amount before they capture it. For example: 1. A hotel pre-authorizes a one-night stay for a customer at $100. 2. The customer decides to have dinner in the hotel for $50. The hotel adjusts the $100 pre-authorization to $150. 3. At checkout, the hotel captures $150 from the customer’s account for the one-night stay and dinner. ## Integration steps **Step 1.** Create a payment. **Step 2.** (Optional) Adjust a payment. **Step 3.** Capture a payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Create a payment To run a pre-authorization, send a POST request to our Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/payments` ### Request parameters To run a pre-authorization, set the value for the `autoCapture` and `processAsSale` parameters to `false` in the request body of a Create Payment request. ### Schema (`request.body`) [Request body schema for `POST /payments`](/api/payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **`Create a pre-authorization`** ```curl curl -X POST https://api.payroc.com/v1/payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 9999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "autoCapture": false, "processAsSale": false, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Create a pre-authorization`** ```python import requests url = "https://api.payroc.com/v1/payments" payload = { "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 9999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "autoCapture": False, "processAsSale": False, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create a pre-authorization`** ```javascript const url = 'https://api.payroc.com/v1/payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"channel":"web","processingTerminalId":"1234001","order":{"orderId":"OrderRef6543","amount":9999,"currency":"USD","description":"Large Pepperoni Pizza"},"paymentMethod":{"type":"card","cardDetails":{"entryMethod":"keyed","keyedData":{"dataFormat":"plainText","cardNumber":"4539858876047062","device":{"model":"paxA80","serialNumber":"WPC202833004712"},"expiryDate":"1230"}}},"operator":"Jane","customer":{"firstName":"Sarah","lastName":"Hopper","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}}},"autoCapture":false,"processAsSale":false,"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create a pre-authorization`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments" payload := strings.NewReader("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 9999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"autoCapture\": false,\n \"processAsSale\": false,\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create a pre-authorization`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 9999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"autoCapture\": false,\n \"processAsSale\": false,\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Create a pre-authorization`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 9999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"autoCapture\": false,\n \"processAsSale\": false,\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Create a pre-authorization`** ```php request('POST', 'https://api.payroc.com/v1/payments', [ 'body' => '{ "channel": "web", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 9999, "currency": "USD", "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": { "model": "paxA80", "serialNumber": "WPC202833004712" }, "expiryDate": "1230" } } }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } } }, "autoCapture": false, "processAsSale": false, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create a pre-authorization`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"channel\": \"web\",\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"orderId\": \"OrderRef6543\",\n \"amount\": 9999,\n \"currency\": \"USD\",\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"device\": {\n \"model\": \"paxA80\",\n \"serialNumber\": \"WPC202833004712\"\n },\n \"expiryDate\": \"1230\"\n }\n }\n },\n \"operator\": \"Jane\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n }\n },\n \"autoCapture\": false,\n \"processAsSale\": false,\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create a pre-authorization`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "channel": "web", "processingTerminalId": "1234001", "order": [ "orderId": "OrderRef6543", "amount": 9999, "currency": "USD", "description": "Large Pepperoni Pizza" ], "paymentMethod": [ "type": "card", "cardDetails": [ "entryMethod": "keyed", "keyedData": [ "dataFormat": "plainText", "cardNumber": "4539858876047062", "device": [ "model": "paxA80", "serialNumber": "WPC202833004712" ], "expiryDate": "1230" ] ] ], "operator": "Jane", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ] ], "autoCapture": false, "processAsSale": false, "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields **Important:** Save the `paymentId`. You need the `paymentId` to adjust or capture the payment. If your request is successful, we send a pre-authorization request to the customer’s bank or card company for the specific amount. In the `transactionResult` object, we include the following fields to indicate that we created the pre-authorization: - **`type`** - The value is `preAuthorization`. - **`status`** - The value is `pending`. The response also contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments`](/api/payment) ### Example response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 9999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "avsResult": "U" } }, "transactionResult": { "status": "pending", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 9999, "currency": "USD", "responseMessage": "APPROVAL", "processorResponseCode": "00" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "setAsReady" ] } ``` ## Step 2. (Optional) Adjust a payment **Important:** A merchant can capture more than they originally pre-authorized, however each card brand sets different limits to the additional amount that the merchant can capture. If a merchant needs to capture more than they originally pre-authorized, we recommend that they adjust the pre-authorization before they capture it. To adjust a pre-authorized amount, send a POST request to our Payments endpoint. Include the `paymentId` in the path of your request. **Endpoint:** `https://api.payroc.com/v1/payments/{paymentId}/adjust` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments/{paymentId}/adjust`](/api/adjust-payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments/\{paymentId\}/adjust](https://api.payroc.com/v1/payments/%7BpaymentId%7D/adjust) **`Adjust pre-authorization`** ```curl curl -X POST https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "adjustments": [ { "type": "order", "amount": 3999 } ], "operator": "Jane" }' ``` **`Adjust pre-authorization`** ```python import requests url = "https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust" payload = { "adjustments": [ { "type": "order", "amount": 3999 } ], "operator": "Jane" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Adjust pre-authorization`** ```javascript const url = 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"adjustments":[{"type":"order","amount":3999}],"operator":"Jane"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Adjust pre-authorization`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust" payload := strings.NewReader("{\n \"adjustments\": [\n {\n \"type\": \"order\",\n \"amount\": 3999\n }\n ],\n \"operator\": \"Jane\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Adjust pre-authorization`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"adjustments\": [\n {\n \"type\": \"order\",\n \"amount\": 3999\n }\n ],\n \"operator\": \"Jane\"\n}" response = http.request(request) puts response.read_body ``` **`Adjust pre-authorization`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"adjustments\": [\n {\n \"type\": \"order\",\n \"amount\": 3999\n }\n ],\n \"operator\": \"Jane\"\n}") .asString(); ``` **`Adjust pre-authorization`** ```php request('POST', 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust', [ 'body' => '{ "adjustments": [ { "type": "order", "amount": 3999 } ], "operator": "Jane" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Adjust pre-authorization`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"adjustments\": [\n {\n \"type\": \"order\",\n \"amount\": 3999\n }\n ],\n \"operator\": \"Jane\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Adjust pre-authorization`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "adjustments": [ [ "type": "order", "amount": 3999 ] ], "operator": "Jane" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments/M2MJOG6O2Y/adjust")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we adjust the pre-authorization amount and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments/{paymentId}/adjust`](/api/adjust-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 3999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "avsResult": "U" } }, "transactionResult": { "status": "pending", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 3999, "currency": "USD", "responseMessage": "APPROVAL", "processorResponseCode": "00" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "setAsReady" ] } ``` ## Step 3. Capture a payment To capture the pre-authorization, send a POST request to our Payments endpoint. Include the `paymentId` in the path of your request. **Endpoint:** `https://api.payroc.com/v1/payments/{paymentId}/capture` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /payments/{paymentId}/capture`](/api/capture-payment) ### Example request ### Request POST [https://api.payroc.com/v1/payments/\{paymentId\}/capture](https://api.payroc.com/v1/payments/%7BpaymentId%7D/capture) **`Capture a pre-authorization`** ```curl curl -X POST https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "operator": "Jane", "amount": 3999 }' ``` **`Capture a pre-authorization`** ```python import requests url = "https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture" payload = { "processingTerminalId": "1234001", "operator": "Jane", "amount": 3999 } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Capture a pre-authorization`** ```javascript const url = 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","operator":"Jane","amount":3999}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Capture a pre-authorization`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"operator\": \"Jane\",\n \"amount\": 3999\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Capture a pre-authorization`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"operator\": \"Jane\",\n \"amount\": 3999\n}" response = http.request(request) puts response.read_body ``` **`Capture a pre-authorization`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"operator\": \"Jane\",\n \"amount\": 3999\n}") .asString(); ``` **`Capture a pre-authorization`** ```php request('POST', 'https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture', [ 'body' => '{ "processingTerminalId": "1234001", "operator": "Jane", "amount": 3999 }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Capture a pre-authorization`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"operator\": \"Jane\",\n \"amount\": 3999\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Capture a pre-authorization`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "operator": "Jane", "amount": 3999 ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/payments/M2MJOG6O2Y/capture")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we capture the pre-authorization and return a response. In the `transactionResult` object, we return the following fields that indicate we captured the pre-authorization and added the payment to the open batch: - **`type`** - The value is `preAuthorizationCompletion`. - **`status`** - The value is `ready`. The response also contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /payments/{paymentId}/capture`](/api/capture-payment) ### Example response ### Response (200) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 3999, "currency": "USD", "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "avsResult": "U" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "OK3", "authorizedAmount": 3999, "currency": "USD", "responseMessage": "APPROVAL", "processorResponseCode": "00" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "setAsPending" ] } ``` ## Test cases Before you run test cases, read the [Payments](/guides/testing/online-payments) page in Test Your Integration. ### Run a pre-authorization Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **Note:** Set the value for the `autoCapture` and the `processAsSale` parameters to `false` in the request body. **Example response** ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 9999, "currency": "USD", "dateTime": "2026-08-19T16:16:22+01:00", "description": "Large Pepperoni Pizza" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "avsResult": "U" } }, "transactionResult": { "status": "pending", "responseCode": "A", "type": "sale", "approvalCode": "582235", "authorizedAmount": 9999, "currency": "USD", "responseMessage": "APPROVAL", "processorResponseCode": "00" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "setAsReady" ] } ``` ### Capture a pre-authorization Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments/\{paymentId\}/capture](https://api.payroc.com/v1/payments/%7BpaymentId%7D/capture) **Example response** ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 3999, "currency": "USD", "dateTime": "2026-08-19T16:16:22+01:00", "description": "Large Pepperoni Pizza" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "avsResult": "U" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "582235", "authorizedAmount": 3999, "currency": "USD", "responseMessage": "APPROVAL", "processorResponseCode": "00" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "setAsPending" ] } ``` # Run a sale with bank account details Source: https://docs.payroc.com/guides/payments/run-sale-using-bank-details Run a bank transfer payment by sending a POST request to the Bank Transfer Payments endpoint with ACH or PAD bank account details and amount. **Prerequisites:** [Authentication](/api/authentication) Our gateway supports the following bank transfer services: - **Automated Clearing House (ACH):** A service that U.S. banks use to transfer funds between accounts. - **Pre-Authorized Debit (PAD):** A service that Canadian banks use to transfer funds between accounts. ## Integration steps - Create a bank transfer payment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Create a bank transfer payment To create a bank transfer payment, send a POST request to our Bank Transfer Payments endpoint. **Endpoint:** `https://api.payroc.com/v1/bank-transfer-payments` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /bank-transfer-payments`](/api/bank-transfer-payment) ### Example request ### Request POST [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) **`Store Token Bank Transfer Payment`** ```curl curl -X POST https://api.payroc.com/v1/bank-transfer-payments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ], "tip": { "type": "percentage", "percentage": 10 } }, "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "joe@blogssoftware.com" } ] }, "credentialOnFile": { "tokenize": true }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Store Token Bank Transfer Payment`** ```python import requests url = "https://api.payroc.com/v1/bank-transfer-payments" payload = { "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ], "tip": { "type": "percentage", "percentage": 10 } }, "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "joe@blogssoftware.com" } ] }, "credentialOnFile": { "tokenize": True }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Store Token Bank Transfer Payment`** ```javascript const url = 'https://api.payroc.com/v1/bank-transfer-payments'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"processingTerminalId":"1234001","order":{"amount":4999,"currency":"USD","orderId":"OrderRef6543","breakdown":{"subtotal":4347,"taxes":[{"rate":5,"name":"Sales Tax","type":"rate"}],"tip":{"type":"percentage","percentage":10}},"description":"Large Pepperoni Pizza"},"paymentMethod":{"type":"ach","accountNumber":"11101010","nameOnAccount":"Sarah Hazel Hopper","routingNumber":"053200983","accountType":"checking","secCode":"web"},"customer":{"notificationLanguage":"en","contactMethods":[{"type":"email","value":"joe@blogssoftware.com"}]},"credentialOnFile":{"tokenize":true},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Store Token Bank Transfer Payment`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/bank-transfer-payments" payload := strings.NewReader("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ],\n \"tip\": {\n \"type\": \"percentage\",\n \"percentage\": 10\n }\n },\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@blogssoftware.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Store Token Bank Transfer Payment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/bank-transfer-payments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ],\n \"tip\": {\n \"type\": \"percentage\",\n \"percentage\": 10\n }\n },\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@blogssoftware.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Store Token Bank Transfer Payment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/bank-transfer-payments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ],\n \"tip\": {\n \"type\": \"percentage\",\n \"percentage\": 10\n }\n },\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@blogssoftware.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Store Token Bank Transfer Payment`** ```php request('POST', 'https://api.payroc.com/v1/bank-transfer-payments', [ 'body' => '{ "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "rate": 5, "name": "Sales Tax", "type": "rate" } ], "tip": { "type": "percentage", "percentage": 10 } }, "description": "Large Pepperoni Pizza" }, "paymentMethod": { "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "web" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "joe@blogssoftware.com" } ] }, "credentialOnFile": { "tokenize": true }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Store Token Bank Transfer Payment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/bank-transfer-payments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"processingTerminalId\": \"1234001\",\n \"order\": {\n \"amount\": 4999,\n \"currency\": \"USD\",\n \"orderId\": \"OrderRef6543\",\n \"breakdown\": {\n \"subtotal\": 4347,\n \"taxes\": [\n {\n \"rate\": 5,\n \"name\": \"Sales Tax\",\n \"type\": \"rate\"\n }\n ],\n \"tip\": {\n \"type\": \"percentage\",\n \"percentage\": 10\n }\n },\n \"description\": \"Large Pepperoni Pizza\"\n },\n \"paymentMethod\": {\n \"type\": \"ach\",\n \"accountNumber\": \"11101010\",\n \"nameOnAccount\": \"Sarah Hazel Hopper\",\n \"routingNumber\": \"053200983\",\n \"accountType\": \"checking\",\n \"secCode\": \"web\"\n },\n \"customer\": {\n \"notificationLanguage\": \"en\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"joe@blogssoftware.com\"\n }\n ]\n },\n \"credentialOnFile\": {\n \"tokenize\": true\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Store Token Bank Transfer Payment`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "processingTerminalId": "1234001", "order": [ "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": [ "subtotal": 4347, "taxes": [ [ "rate": 5, "name": "Sales Tax", "type": "rate" ] ], "tip": [ "type": "percentage", "percentage": 10 ] ], "description": "Large Pepperoni Pizza" ], "paymentMethod": [ "type": "ach", "accountNumber": "11101010", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "accountType": "checking", "secCode": "web" ], "customer": [ "notificationLanguage": "en", "contactMethods": [ [ "type": "email", "value": "joe@blogssoftware.com" ] ] ], "credentialOnFile": ["tokenize": true], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/bank-transfer-payments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we create the payment and return the following response: ### Schema (`response.body`) [Response body schema for `POST /bank-transfer-payments`](/api/bank-transfer-payment) ### Example response ### Response (201) ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "amount": 4999, "currency": "USD", "orderId": "OrderRef6543", "breakdown": { "subtotal": 4347, "taxes": [ { "name": "Sales Tax", "rate": 5, "amount": 217 } ], "tip": { "type": "percentage", "amount": 435, "percentage": 10 } }, "dateTime": "2024-07-02T15:30:00Z", "description": "Large Pepperoni Pizza" }, "bankAccount": { "type": "ach", "accountNumber": "****3159", "nameOnAccount": "Sarah Hazel Hopper", "routingNumber": "053200983", "secCode": "web", "secureToken": { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "customerName": "Sarah Hazel Hopper", "token": "296753123456", "status": "notValidated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" } } }, "transactionResult": { "type": "payment", "status": "ready", "responseCode": "A", "authorizedAmount": 4999, "currency": "USD", "responseMessage": "NoError", "processorResponseCode": "0" }, "customer": { "notificationLanguage": "en", "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ] }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Test cases Before you run test cases, read the [Payments](/guides/testing/online-payments) page in Test Your Integration. ### Run a sale with bank account details Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) **Example response** ```json { "channel": "POS", "processingTerminalId": "3204001", "operator": "Davi-CHP", "order": { "orderId": "CC-12", "description": "BT ACH - Sale with CC", "currency": "USD", "amount": 9700 }, "paymentMethod": { "type": "ach", "accountType": "checking", "secCode": "web", "nameOnAccount": "Davi", "accountNumber": "49100130", "routingNumber": "292735277" } } ``` # Save payment details Source: https://docs.payroc.com/guides/payments/save-payment-details Save a customer's payment details to the vault by sending a POST request to the secure-tokens endpoint, returning a secureTokenId for use in follow-on card or bank transfer transactions. **Prerequisites:** [Authentication](/api/authentication) Integrate with our API to create a secure token to represent a customer’s payment details. There are two ways to save the payment details in our vault and get a secure token: - Save the payment details when running a sale. - Save the payment details without running a sale. When you create your request, you can assign an ID to the secure token. If you don’t, our gateway assigns an ID to the secure token. We return the secureTokenID and the token in the response, which the merchant uses in follow-on transactions, including: - Create a payment with [card details](/api/payment) or [bank account details](/api/bank-transfer-payment). - Create a refund with [card details](/api/refund-payment) or [bank account details](/api/refund-bank-transfer-payment). - [Look up BIN information](/api/bin-lookup). **Note:** For more information about secure tokens, go to [Tokenization](/knowledge/payments/tokenization). ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Run a sale and save payment details To run a sale and save the payment details, send a Create a Payment request. In the request, include a credentialOnFile object and set the tokenize parameter to true. Our gateway runs the sale and saves the customer’s payment details in our vault. In the response, we return a secureTokenId and the token that the merchant can use for follow-on transactions. Note: For more information about how to run a sale, go to [Run a card sale](/guides/payments/run-a-card-sale) or [Run a sale with bank account details](/guides/payments/run-sale-using-bank-details). ## Save payment details To save a customer’s payment details without running a sale, send a POST request to: **Endpoint:** `https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/secure-tokens` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens`](/api/create-secure-token) ### Example request ### Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) **`Secure Token`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }' ``` **`Secure Token`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" payload = { "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Secure Token`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"source":{"type":"card","cardDetails":{"entryMethod":"keyed","keyedData":{"dataFormat":"plainText","cardNumber":"4539858876047062","cvv":"234","expiryDate":"1230"},"cardholderName":"Sarah Hazel Hopper"}},"operator":"Jane","mitAgreement":"unscheduled","customer":{"firstName":"Sarah","lastName":"Hopper","dateOfBirth":"1990-07-15","referenceNumber":"Customer-12","billingAddress":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"shippingAddress":{"recipientName":"Sarah Hopper","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"}},"contactMethods":[{"type":"email","value":"sarah.hopper@example.com"}],"notificationLanguage":"en"},"ipAddress":{"type":"ipv4","value":"104.18.24.203"},"customFields":[{"name":"yourCustomField","value":"abc123"}]}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Secure Token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens" payload := strings.NewReader("{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Secure Token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` **`Secure Token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}") .asString(); ``` **`Secure Token`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens', [ 'body' => '{ "source": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" }, "cardholderName": "Sarah Hazel Hopper" } }, "operator": "Jane", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "ipAddress": { "type": "ipv4", "value": "104.18.24.203" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Secure Token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"source\": {\n \"type\": \"card\",\n \"cardDetails\": {\n \"entryMethod\": \"keyed\",\n \"keyedData\": {\n \"dataFormat\": \"plainText\",\n \"cardNumber\": \"4539858876047062\",\n \"cvv\": \"234\",\n \"expiryDate\": \"1230\"\n },\n \"cardholderName\": \"Sarah Hazel Hopper\"\n }\n },\n \"operator\": \"Jane\",\n \"mitAgreement\": \"unscheduled\",\n \"customer\": {\n \"firstName\": \"Sarah\",\n \"lastName\": \"Hopper\",\n \"dateOfBirth\": \"1990-07-15\",\n \"referenceNumber\": \"Customer-12\",\n \"billingAddress\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"shippingAddress\": {\n \"recipientName\": \"Sarah Hopper\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n }\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"sarah.hopper@example.com\"\n }\n ],\n \"notificationLanguage\": \"en\"\n },\n \"ipAddress\": {\n \"type\": \"ipv4\",\n \"value\": \"104.18.24.203\"\n },\n \"customFields\": [\n {\n \"name\": \"yourCustomField\",\n \"value\": \"abc123\"\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Secure Token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "source": [ "type": "card", "cardDetails": [ "entryMethod": "keyed", "keyedData": [ "dataFormat": "plainText", "cardNumber": "4539858876047062", "cvv": "234", "expiryDate": "1230" ], "cardholderName": "Sarah Hazel Hopper" ] ], "operator": "Jane", "mitAgreement": "unscheduled", "customer": [ "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "shippingAddress": [ "recipientName": "Sarah Hopper", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ] ], "contactMethods": [ [ "type": "email", "value": "sarah.hopper@example.com" ] ], "notificationLanguage": "en" ], "ipAddress": [ "type": "ipv4", "value": "104.18.24.203" ], "customFields": [ [ "name": "yourCustomField", "value": "abc123" ] ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we return a token that you can use instead of the customer’s payment details in follow-on transactions. ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens`](/api/create-secure-token) ### Example response ### Response (201) ```json { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Hazel Hopper", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Update saved payment details Source: https://docs.payroc.com/guides/payments/update-saved-payment-details Update a customer's saved payment details by sending a PATCH request to the Update Secure Token endpoint or a POST request to the Update Account Details endpoint using a single-use token. **Prerequisites:** [Authentication](/api/authentication) · [Save payment details](/guides/payments/save-payment-details) Integrate with our API to update a customer’s saved payment details. Our API has two endpoints to update payment details represented by a secure token: - [Update saved payment details](/guides/payments/update-saved-payment-details#update-saved-payment-details) – Use our Update Secure Token endpoint if you are sending the raw payment details, for example, if you are updating a card’s expiry date or a billing address. - [Update saved payment details with a single-use token](/guides/payments/update-saved-payment-details#update-saved-payment-details-with-a-single-use-token) – Use our Update Account Details endpoint if you have a single-use token that represents updated payment details, for example, if you have a single-use token from Hosted Fields. **Note:** To update saved payment details, you need the ID of the secure token that represents the payment details. If you don’t know the ID, go to List Secure Tokens. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Update saved payment details Use the Update Secure Token method if you have the raw information that a customer wants to update. You can update the following payment details: - Sensitive payment details, including:- **Card** - Cardholder name and expiry date - **ACH** - Accountholder name and account type - **PAD** - Accountholder name and institution number - MIT agreement - Customer’s contact details - Customer’s address details ## Integration steps - Update a secure token ## Update a secure token To update the payment details represented by a secure token, send a PATCH request to our Update Secure Token endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}` **Note:** The request format follows the RFC 6902 standard. ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `PATCH /processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}`](/api/update-secure-token) ### Example request ### Request PATCH [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens/\{secureTokenId\}](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens/%7BsecureTokenId%7D) **`Update secure token`** ```curl curl -X PATCH https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '[ { "op": "add", "path": "/customer/lastName", "value": null }, { "op": "add", "path": "/shippingAddress/recipientName", "value": null }, { "op": "add", "path": "/source/cardDetails/cardholderName", "value": null } ]' ``` **`Update secure token`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" payload = [ { "op": "add", "path": "/customer/lastName", "value": None }, { "op": "add", "path": "/shippingAddress/recipientName", "value": None }, { "op": "add", "path": "/source/cardDetails/cardholderName", "value": None } ] headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.patch(url, json=payload, headers=headers) print(response.json()) ``` **`Update secure token`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa'; const options = { method: 'PATCH', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '[{"op":"add","path":"/customer/lastName","value":null},{"op":"add","path":"/shippingAddress/recipientName","value":null},{"op":"add","path":"/source/cardDetails/cardholderName","value":null}]' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Update secure token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" payload := strings.NewReader("[\n {\n \"op\": \"add\",\n \"path\": \"/customer/lastName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/shippingAddress/recipientName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/source/cardDetails/cardholderName\",\n \"value\": null\n }\n]") req, _ := http.NewRequest("PATCH", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Update secure token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "[\n {\n \"op\": \"add\",\n \"path\": \"/customer/lastName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/shippingAddress/recipientName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/source/cardDetails/cardholderName\",\n \"value\": null\n }\n]" response = http.request(request) puts response.read_body ``` **`Update secure token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.patch("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("[\n {\n \"op\": \"add\",\n \"path\": \"/customer/lastName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/shippingAddress/recipientName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/source/cardDetails/cardholderName\",\n \"value\": null\n }\n]") .asString(); ``` **`Update secure token`** ```php request('PATCH', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa', [ 'body' => '[ { "op": "add", "path": "/customer/lastName", "value": null }, { "op": "add", "path": "/shippingAddress/recipientName", "value": null }, { "op": "add", "path": "/source/cardDetails/cardholderName", "value": null } ]', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Update secure token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa"); var request = new RestRequest(Method.PATCH); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "[\n {\n \"op\": \"add\",\n \"path\": \"/customer/lastName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/shippingAddress/recipientName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/source/cardDetails/cardholderName\",\n \"value\": null\n }\n]", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Update secure token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ [ "op": "add", "path": "/customer/lastName", "value": ], [ "op": "add", "path": "/shippingAddress/recipientName", "value": ], [ "op": "add", "path": "/source/cardDetails/cardholderName", "value": ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we update the secure token and return the details represented by the secure token. ### Schema (`response.body`) [Response body schema for `PATCH /processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}`](/api/update-secure-token) ### Example response ### Response (200) ```json { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Reed", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Reed", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Reed", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Update saved payment details with a single-use token If you use our Hosted Fields solution, our gateway creates a single-use token to represent the customer’s updates to their card, ACH, or PAD details. Send the single-use token to our gateway so that we can update the details represented by the secure token. You can also send a secondary request to our gateway to update other details that the single-use token doesn’t change: - MIT agreement - Customer’s contact details - Customer’s address details ## Integration steps **Step 1.** Update saved payment details with a single-use token **Step 2.** (Optional) Update a secure token ## Step 1. Update saved payment details with a single-use token To update saved payment details with a single-use token, send a POST request to our Update Account Details endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}/update-account` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}/update-account`](/api/account-update) ### Example request ### Request POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens/\{secureTokenId\}/update-account](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens/%7BsecureTokenId%7D/update-account) **`Update account details`** ```curl curl -X POST https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }' ``` **`Update account details`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account" payload = { "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Update account details`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"type":"singleUseToken","token":"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Update account details`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account" payload := strings.NewReader("{\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Update account details`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n}" response = http.request(request) puts response.read_body ``` **`Update account details`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n}") .asString(); ``` **`Update account details`** ```php request('POST', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account', [ 'body' => '{ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Update account details`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"type\": \"singleUseToken\",\n \"token\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Update account details`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "type": "singleUseToken", "token": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa/update-account")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we update the secure token and return the details represented by the secure token. ### Schema (`response.body`) [Response body schema for `POST /processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}/update-account`](/api/account-update) ### Example response ### Response (200) ```json { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Hazel Hopper", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Hopper", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` ## Step 2. (Optional) Update a secure token To update the payment details represented by a secure token, send a PATCH request to our Update Secure Token endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}` **Note:** The request format follows the RFC 6902 standard. ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `PATCH /processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}`](/api/update-secure-token) ### Example request ### Request PATCH [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens/\{secureTokenId\}](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens/%7BsecureTokenId%7D) **`Update secure token`** ```curl curl -X PATCH https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '[ { "op": "add", "path": "/customer/lastName", "value": null }, { "op": "add", "path": "/shippingAddress/recipientName", "value": null }, { "op": "add", "path": "/source/cardDetails/cardholderName", "value": null } ]' ``` **`Update secure token`** ```python import requests url = "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" payload = [ { "op": "add", "path": "/customer/lastName", "value": None }, { "op": "add", "path": "/shippingAddress/recipientName", "value": None }, { "op": "add", "path": "/source/cardDetails/cardholderName", "value": None } ] headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.patch(url, json=payload, headers=headers) print(response.json()) ``` **`Update secure token`** ```javascript const url = 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa'; const options = { method: 'PATCH', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '[{"op":"add","path":"/customer/lastName","value":null},{"op":"add","path":"/shippingAddress/recipientName","value":null},{"op":"add","path":"/source/cardDetails/cardholderName","value":null}]' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Update secure token`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa" payload := strings.NewReader("[\n {\n \"op\": \"add\",\n \"path\": \"/customer/lastName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/shippingAddress/recipientName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/source/cardDetails/cardholderName\",\n \"value\": null\n }\n]") req, _ := http.NewRequest("PATCH", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Update secure token`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "[\n {\n \"op\": \"add\",\n \"path\": \"/customer/lastName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/shippingAddress/recipientName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/source/cardDetails/cardholderName\",\n \"value\": null\n }\n]" response = http.request(request) puts response.read_body ``` **`Update secure token`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.patch("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("[\n {\n \"op\": \"add\",\n \"path\": \"/customer/lastName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/shippingAddress/recipientName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/source/cardDetails/cardholderName\",\n \"value\": null\n }\n]") .asString(); ``` **`Update secure token`** ```php request('PATCH', 'https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa', [ 'body' => '[ { "op": "add", "path": "/customer/lastName", "value": null }, { "op": "add", "path": "/shippingAddress/recipientName", "value": null }, { "op": "add", "path": "/source/cardDetails/cardholderName", "value": null } ]', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Update secure token`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa"); var request = new RestRequest(Method.PATCH); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "[\n {\n \"op\": \"add\",\n \"path\": \"/customer/lastName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/shippingAddress/recipientName\",\n \"value\": null\n },\n {\n \"op\": \"add\",\n \"path\": \"/source/cardDetails/cardholderName\",\n \"value\": null\n }\n]", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Update secure token`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ [ "op": "add", "path": "/customer/lastName", "value": ], [ "op": "add", "path": "/shippingAddress/recipientName", "value": ], [ "op": "add", "path": "/source/cardDetails/cardholderName", "value": ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-terminals/1234001/secure-tokens/MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we update the secure token and return the details represented by the secure token. ### Schema (`response.body`) [Response body schema for `PATCH /processing-terminals/{processingTerminalId}/secure-tokens/{secureTokenId}`](/api/update-secure-token) ### Example response ### Response (200) ```json { "secureTokenId": "MREF_abc1de23-f4a5-6789-bcd0-12e345678901fa", "processingTerminalId": "1234001", "source": { "type": "card", "cardNumber": "453985******7062", "cardholderName": "Sarah Reed", "expiryDate": "1230" }, "token": "296753123456", "status": "notValidated", "mitAgreement": "unscheduled", "customer": { "firstName": "Sarah", "lastName": "Reed", "dateOfBirth": "1990-07-15", "referenceNumber": "Customer-12", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Reed", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "contactMethods": [ { "type": "email", "value": "sarah.hopper@example.com" } ], "notificationLanguage": "en" }, "customFields": [ { "name": "yourCustomField", "value": "abc123" } ] } ``` # Testing Source: https://docs.payroc.com/guides/testing Send requests to the Payroc Cloud Simulator. Send requests to the Payroc Cloud Simulator. - [Send test requests to our gateway](/guides/testing/send-test-requests-to-our-gateway) - [Bank Payments](/guides/testing/bank-payments) - [Funding](/guides/testing/funding-instructions) - [Payments](/guides/testing/online-payments) - [Payroc Cloud](/guides/testing/payroc-cloud) # Send test requests to our gateway Source: https://docs.payroc.com/guides/testing/send-test-requests-to-our-gateway Step-by-step guide for using the Payroc Cloud Simulator to send test payment and refund requests to the gateway, including accessing the simulator and reviewing outcomes. To test your integration, use the Payroc Cloud Simulator to send test requests to our gateway. ## Before you begin Before you use the Payroc Cloud Simulator, you need the following: - **Processing terminal ID** - We sent you the processing terminal ID when you signed up with us. - **Payroc App API key** - Use the Self-Care Portal to generate a Payroc App API key. For more information about how to generate a Payroc App API key, go to [Generate a Payroc App API key](/guides/api-keys/generate-a-payroc-app-api-key). ## Send test requests to our gateway To send test requests to our gateway, complete the following steps: 1. Access the simulator. 2. Send a request. 3. (Optional) Cancel the request. ### Step 1. Access the simulator 1. Go to [https://cloud.uat.payroc.com](https://cloud.uat.payroc.com). 2. Enter your processing terminal ID and your Payroc App API key. 3. Select **Save**. 4. Review the credentials that you entered. 5. Select **Copy S/N and Continue**. You need to include the mock serial number in your requests to our gateway. **Note:** The simulator assigns a unique mock serial number to each browser tab, and each browser session expires after 15 minutes of inactivity. If you close the browser tab, you permanently delete all data from the session. ### Step 2. Send a request 1. Choose one of the following methods: - To run a sale, use our [Submit Payment Instruction](/api/send-payment-instruction) method. - To run a refund, use our [Submit Refund Instruction](/api/send-refund-instruction) method. 2. Configure and send your request. **Note:** For more information about test transaction amounts, go to [Test transaction values](/knowledge/testing/test-transaction-values). 3. Review the outcome of the request: - If the request is successful, your REST client and simulator will update. You can also view the instruction in the Self-Care Portal. - If the request is unsuccessful, you can view the log file in the Payroc Cloud Simulator to investigate the error. To view the log file, complete the following steps:1. Select **Simulator Details**. 2. Select **Download log file**. ![Payroc Cloud Simulator Log File](/assets/send-test-requests-to-our-gateway-simulator-downloadlogfile.png) ### Step 3. (Optional) Cancel the request 1. Depending on the request you sent, choose one of the following methods:- To cancel a sale, use our [Cancel Payment Instruction](/api/delete-payment-instruction) method. - To cancel a refund, use our [Cancel Refund Instruction](/api/delete-refund-instruction) method. 2. Configure and send your request. 3. Review the outcome of the request:- If the request is successful, your REST client and simulator will update. You can also view the instruction in the Self-Care Portal. - If the request is unsuccessful, you can view the log file in the Payroc Cloud Simulator to investigate the error. To view the log file, complete the following steps:1. Select **Simulator Details**. 2. Select **Download log file**. ![Payroc Cloud Simulator Log File](/assets/send-test-requests-to-our-gateway-simulator-downloadlogfile.png) # Bank Payments Source: https://docs.payroc.com/guides/testing/bank-payments Test values and return codes for validating bank payment integrations in the test environment. Before you can run live bank payments, use our test environment to check that your integration works correctly. You can use our test environment to test the following transaction types: - Sales - Authorizations - Reversals - Unreferenced refunds In addition to testing different transaction types, you can trigger specific return codes and re-present payments. **Note:** If you have any issues when you run our test cases, email our integrations team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Before you begin To help you with testing, we provide you with: - Test environment - Test values - Returns ## Test environment Create a test API key in the [Developer Portal](https://developers.payroc.com). We automatically send requests that use a test API key to our test environment, so you don't need to change the endpoint. **Base URI:** [https://api.payroc.com/v1](https://api.payroc.com/v1) **Important:** Use only test bank account details in our test environment. ### Authenticating your requests Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate your Bearer token, complete the following steps: 1. Include your API key in the x-api-key parameter in the header of a POST request. 2. Send your request to [https://identity.payroc.com/authorize](https://identity.payroc.com/authorize). **Note:** You need to generate a new Bearer token before the previous Bearer token expires. #### Example request ```bash curl --location --request POST 'https://identity.payroc.com/authorize' --header 'x-api-key: ' ``` #### Example response If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires. ```json { "access_token": "eyJhbGc....adQssw5c", "expires_in": 3600, "scope": "service_a service_b", "token_type": "Bearer" } ``` #### Example request header ```bash curl -H "Authorization: Bearer " ``` ## Test values Use the following routing number and account number combinations to trigger specific results: | Routing number | Account number | Result | Description | | --- | --- | --- | --- | | 053200983 | 11101010 | Approved | Successful transaction. | | 053200983 | 11101011 | Declined | Generic account-level decline. | | 053200983 | 11101012 | Declined | Routing number is incorrect. | | 053200983 | 11101013 | Declined | Account number is incorrect. | | 053200983 | 11101014 | Declined | Potential fraudulent transaction. | | 053200983 | 11101015 | Warning | Warning that indicates the account structure is incorrect. | | 053200983 | 11101016 | Declined | Daily transaction limit exceeded. | | 053200983 | 11101017 | Declined | Transaction limit exceeded over a specific time. | | 053200983 | 11101018 | Declined | Transaction amount exceeds the maximum limit. | | 053200983 | 11101019 | Declined | Duplicate check number. | | 053200983 | 11101020 | Declined | Check number too low. | | 053200983 | 11101021 | Declined | Customer needs to provide a driver's license. | | 053200983 | 11101022 | Declined | Customer needs to provide a phone number. | | 053200983 | 11101023 | Declined | Incorrect driver's license format. | You can also use the following routing number and account number combinations: | Routing number | Account number | Result | Reason | | --- | --- | --- | --- | | 123123123 | 123123123 | Declined | Routing number and account number are identical. | | 123123123 | Any other account number | Declined | Unqualified receiving bank. | | 111111111 | 222222222 | Declined | Incorrect transit number. | ## Returns To simulate a return, send a value of `888000XX` for the account number, where `XX` is the return code without the R. The following table shows a few examples of how to use test account numbers to trigger return codes: | Return code | Reason | Routing number | Account number | | --- | --- | --- | --- | | R01 | Insufficient funds. | 053200983 | 88800001 | | R02 | Account closed. | 053200983 | 88800002 | | R03 | Unable to locate account. | 053200983 | 88800003 | | R04 | Incorrect account number. | 053200983 | 88800004 | **Note:** Each night we check for any requests that trigger a return code. It might take a day for us to create a return for the transaction. ### Re-presentments For some return codes, you can choose to [re-present the payment](/api/represent-bank-transfer-payment) or [close the return](/api/close-bank-transfer-payment). You can re-present or close returns with the following return codes: - R01 - R03 - R04 - R09 **Note:** You can re-present a payment up to two times. # Funding Source: https://docs.payroc.com/guides/testing/funding-instructions Test cases for verifying funding recipients, funding accounts, funding instructions, and funding activity integrations against the Payroc API. To check that you have correctly coded your integration to our API specifications, complete our test cases for each API resource. Each API resource has a unique test endpoint and a unique set of test cases. **If your tests are successful:** We send you an email to inform you that you can now send requests to the live endpoint. **If your tests are unsuccessful:** Contact the project owner or email us for help at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Test environment Run the following tests using a test API key. Create a test API key in the [Developer Portal](https://developers.payroc.com). We automatically send requests that use a test API key to our test environment, so you don't need to change the endpoint. **Base URI:** [https://api.payroc.com/v1](https://api.payroc.com/v1) ## Testing Funding Recipients Use our `/funding-recipients` endpoint to create and manage third-party recipients that receive funds from your transactions. To verify that your integration works with this endpoint, run the following tests: ### Test 1: Create a Funding Recipient You can create a Funding Recipient independently of any existing MIDs on your account. - Use our `/funding-recipients` endpoint to create a new Funding Recipient. ### Request POST [https://api.payroc.com/v1/funding-recipients](https://api.payroc.com/v1/funding-recipients) **`Create funding recipient`** ```curl curl -X POST https://api.payroc.com/v1/funding-recipients \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "relationship": { "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false }, "middleName": "Helen" } ], "fundingAccounts": [ { "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ] } ], "metadata": { "yourCustomField": "abc123" } }' ``` **`Create funding recipient`** ```python import requests url = "https://api.payroc.com/v1/funding-recipients" payload = { "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "relationship": { "isControlProng": True, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": False }, "middleName": "Helen" } ], "fundingAccounts": [ { "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ] } ], "metadata": { "yourCustomField": "abc123" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create funding recipient`** ```javascript const url = 'https://api.payroc.com/v1/funding-recipients'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"recipientType":"privateCorporation","taxId":"12-3456789","doingBusinessAs":"Pizza Doe","address":{"address1":"1 Example Ave.","address2":"Example Address Line 2","address3":"Example Address Line 3","city":"Chicago","country":"US","postalCode":"60056","state":"Illinois"},"contactMethods":[{"type":"email","value":"jane.doe@example.com"},{"type":"phone","value":"2025550164"}],"owners":[{"firstName":"Jane","lastName":"Doe","dateOfBirth":"1964-03-22","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056"},"identifiers":[{"type":"nationalId","value":"000-00-4320"}],"contactMethods":[{"type":"email","value":"jane.doe@example.com"},{"type":"phone","value":"2025550164"}],"relationship":{"isControlProng":true,"equityPercentage":48.5,"title":"CFO","isAuthorizedSignatory":false},"middleName":"Helen"}],"fundingAccounts":[{"type":"checking","use":"credit","nameOnAccount":"Jane Doe","paymentMethods":[{"type":"ach","value":{"routingNumber":"123456789","accountNumber":"1234567890"}}]}],"metadata":{"yourCustomField":"abc123"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create funding recipient`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-recipients" payload := strings.NewReader("{\n \"recipientType\": \"privateCorporation\",\n \"taxId\": \"12-3456789\",\n \"doingBusinessAs\": \"Pizza Doe\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create funding recipient`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-recipients") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"recipientType\": \"privateCorporation\",\n \"taxId\": \"12-3456789\",\n \"doingBusinessAs\": \"Pizza Doe\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Create funding recipient`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/funding-recipients") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"recipientType\": \"privateCorporation\",\n \"taxId\": \"12-3456789\",\n \"doingBusinessAs\": \"Pizza Doe\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") .asString(); ``` **`Create funding recipient`** ```php request('POST', 'https://api.payroc.com/v1/funding-recipients', [ 'body' => '{ "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "relationship": { "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false }, "middleName": "Helen" } ], "fundingAccounts": [ { "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ] } ], "metadata": { "yourCustomField": "abc123" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create funding recipient`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-recipients"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"recipientType\": \"privateCorporation\",\n \"taxId\": \"12-3456789\",\n \"doingBusinessAs\": \"Pizza Doe\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create funding recipient`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": [ "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ], [ "type": "phone", "value": "2025550164" ] ], "owners": [ [ "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" ], "identifiers": [ [ "type": "nationalId", "value": "000-00-4320" ] ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ], [ "type": "phone", "value": "2025550164" ] ], "relationship": [ "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false ], "middleName": "Helen" ] ], "fundingAccounts": [ [ "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ [ "type": "ach", "value": [ "routingNumber": "123456789", "accountNumber": "1234567890" ] ] ] ] ], "metadata": ["yourCustomField": "abc123"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-recipients")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` **Successful response:** ### Response (201) ```json { "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "owners": [ { "ownerId": 4564, "link": { "rel": "owner", "href": "https://api.payroc.com/v1/owners/4564", "method": "get" } } ], "fundingAccounts": [ { "fundingAccountId": 123, "status": "pending", "link": { "rel": "fundingAccount", "href": "https://api.payroc.com/v1/funding-accounts/123", "method": "get" } } ], "recipientId": 234, "status": "pending", "createdDate": "2024-07-02T15:30:00+00:00", "lastModifiedDate": "2024-07-02T15:30:00+00:00", "metadata": { "yourCustomField": "abc123" } } ``` ### Test 2: Add a Funding Account to a Recipient You can use our `/funding-recipients` endpoint to manage Funding Accounts associated with a Recipient. - Use our `/funding-recipients` endpoint to add a new Funding Account to an existing Recipient. ### Request POST [https://api.payroc.com/v1/funding-recipients/\{recipientId\}/funding-accounts](https://api.payroc.com/v1/funding-recipients/%7BrecipientId%7D/funding-accounts) **`Create funding account`** ```curl curl -X POST https://api.payroc.com/v1/funding-recipients/234/funding-accounts \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "type": "savings", "use": "credit", "nameOnAccount": "Fred Nerk", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123123123", "accountNumber": "987654321" } } ], "metadata": { "responsiblePerson": "Jane Doe" } }' ``` **`Create funding account`** ```python import requests url = "https://api.payroc.com/v1/funding-recipients/234/funding-accounts" payload = { "type": "savings", "use": "credit", "nameOnAccount": "Fred Nerk", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123123123", "accountNumber": "987654321" } } ], "metadata": { "responsiblePerson": "Jane Doe" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create funding account`** ```javascript const url = 'https://api.payroc.com/v1/funding-recipients/234/funding-accounts'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"type":"savings","use":"credit","nameOnAccount":"Fred Nerk","paymentMethods":[{"type":"ach","value":{"routingNumber":"123123123","accountNumber":"987654321"}}],"metadata":{"responsiblePerson":"Jane Doe"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create funding account`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-recipients/234/funding-accounts" payload := strings.NewReader("{\n \"type\": \"savings\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Fred Nerk\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123123123\",\n \"accountNumber\": \"987654321\"\n }\n }\n ],\n \"metadata\": {\n \"responsiblePerson\": \"Jane Doe\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create funding account`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-recipients/234/funding-accounts") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"type\": \"savings\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Fred Nerk\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123123123\",\n \"accountNumber\": \"987654321\"\n }\n }\n ],\n \"metadata\": {\n \"responsiblePerson\": \"Jane Doe\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Create funding account`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/funding-recipients/234/funding-accounts") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"type\": \"savings\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Fred Nerk\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123123123\",\n \"accountNumber\": \"987654321\"\n }\n }\n ],\n \"metadata\": {\n \"responsiblePerson\": \"Jane Doe\"\n }\n}") .asString(); ``` **`Create funding account`** ```php request('POST', 'https://api.payroc.com/v1/funding-recipients/234/funding-accounts', [ 'body' => '{ "type": "savings", "use": "credit", "nameOnAccount": "Fred Nerk", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123123123", "accountNumber": "987654321" } } ], "metadata": { "responsiblePerson": "Jane Doe" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create funding account`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-recipients/234/funding-accounts"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"type\": \"savings\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Fred Nerk\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123123123\",\n \"accountNumber\": \"987654321\"\n }\n }\n ],\n \"metadata\": {\n \"responsiblePerson\": \"Jane Doe\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create funding account`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "type": "savings", "use": "credit", "nameOnAccount": "Fred Nerk", "paymentMethods": [ [ "type": "ach", "value": [ "routingNumber": "123123123", "accountNumber": "987654321" ] ] ], "metadata": ["responsiblePerson": "Jane Doe"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-recipients/234/funding-accounts")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` **Successful response:** ### Response (201) ```json { "type": "savings", "use": "credit", "nameOnAccount": "Fred Nerk", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "*****3123", "accountNumber": "******4321" } } ], "fundingAccountId": 123, "createdDate": "2024-07-02T15:30:00+00:00", "lastModifiedDate": "2024-07-02T15:30:00+00:00", "status": "pending", "metadata": { "responsiblePerson": "Jane Doe" }, "links": [ { "rel": "parent", "method": "get", "href": "https://api.payroc.com/v1/funding-recipients/234" } ] } ``` ### Test 3: Add a new Owner to a Recipient You can use our `/funding-recipients` endpoint to create and manage Owner objects associated with the Funding Recipient. - Use our `/funding-recipients` endpoint to create a new Owner. ### Request POST [https://api.payroc.com/v1/funding-recipients/\{recipientId\}/owners](https://api.payroc.com/v1/funding-recipients/%7BrecipientId%7D/owners) **`Create funding recipient owner`** ```curl curl -X POST https://api.payroc.com/v1/funding-recipients/234/owners \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "firstName": "Fred", "lastName": "Nerk", "dateOfBirth": "1980-01-19", "address": { "address1": "2 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-9876" } ], "contactMethods": [ { "type": "email", "value": "fred.nerk@example.com" }, { "type": "phone", "value": "2025550110" } ], "relationship": { "isControlProng": false, "equityPercentage": 51.5, "title": "CEO", "isAuthorizedSignatory": true }, "middleName": "Jim" }' ``` **`Create funding recipient owner`** ```python import requests url = "https://api.payroc.com/v1/funding-recipients/234/owners" payload = { "firstName": "Fred", "lastName": "Nerk", "dateOfBirth": "1980-01-19", "address": { "address1": "2 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-9876" } ], "contactMethods": [ { "type": "email", "value": "fred.nerk@example.com" }, { "type": "phone", "value": "2025550110" } ], "relationship": { "isControlProng": False, "equityPercentage": 51.5, "title": "CEO", "isAuthorizedSignatory": True }, "middleName": "Jim" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create funding recipient owner`** ```javascript const url = 'https://api.payroc.com/v1/funding-recipients/234/owners'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"firstName":"Fred","lastName":"Nerk","dateOfBirth":"1980-01-19","address":{"address1":"2 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056"},"identifiers":[{"type":"nationalId","value":"000-00-9876"}],"contactMethods":[{"type":"email","value":"fred.nerk@example.com"},{"type":"phone","value":"2025550110"}],"relationship":{"isControlProng":false,"equityPercentage":51.5,"title":"CEO","isAuthorizedSignatory":true},"middleName":"Jim"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create funding recipient owner`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-recipients/234/owners" payload := strings.NewReader("{\n \"firstName\": \"Fred\",\n \"lastName\": \"Nerk\",\n \"dateOfBirth\": \"1980-01-19\",\n \"address\": {\n \"address1\": \"2 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-9876\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"fred.nerk@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550110\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": false,\n \"equityPercentage\": 51.5,\n \"title\": \"CEO\",\n \"isAuthorizedSignatory\": true\n },\n \"middleName\": \"Jim\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create funding recipient owner`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-recipients/234/owners") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"firstName\": \"Fred\",\n \"lastName\": \"Nerk\",\n \"dateOfBirth\": \"1980-01-19\",\n \"address\": {\n \"address1\": \"2 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-9876\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"fred.nerk@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550110\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": false,\n \"equityPercentage\": 51.5,\n \"title\": \"CEO\",\n \"isAuthorizedSignatory\": true\n },\n \"middleName\": \"Jim\"\n}" response = http.request(request) puts response.read_body ``` **`Create funding recipient owner`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/funding-recipients/234/owners") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"firstName\": \"Fred\",\n \"lastName\": \"Nerk\",\n \"dateOfBirth\": \"1980-01-19\",\n \"address\": {\n \"address1\": \"2 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-9876\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"fred.nerk@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550110\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": false,\n \"equityPercentage\": 51.5,\n \"title\": \"CEO\",\n \"isAuthorizedSignatory\": true\n },\n \"middleName\": \"Jim\"\n}") .asString(); ``` **`Create funding recipient owner`** ```php request('POST', 'https://api.payroc.com/v1/funding-recipients/234/owners', [ 'body' => '{ "firstName": "Fred", "lastName": "Nerk", "dateOfBirth": "1980-01-19", "address": { "address1": "2 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-9876" } ], "contactMethods": [ { "type": "email", "value": "fred.nerk@example.com" }, { "type": "phone", "value": "2025550110" } ], "relationship": { "isControlProng": false, "equityPercentage": 51.5, "title": "CEO", "isAuthorizedSignatory": true }, "middleName": "Jim" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create funding recipient owner`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-recipients/234/owners"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"firstName\": \"Fred\",\n \"lastName\": \"Nerk\",\n \"dateOfBirth\": \"1980-01-19\",\n \"address\": {\n \"address1\": \"2 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-9876\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"fred.nerk@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550110\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": false,\n \"equityPercentage\": 51.5,\n \"title\": \"CEO\",\n \"isAuthorizedSignatory\": true\n },\n \"middleName\": \"Jim\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create funding recipient owner`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "firstName": "Fred", "lastName": "Nerk", "dateOfBirth": "1980-01-19", "address": [ "address1": "2 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" ], "identifiers": [ [ "type": "nationalId", "value": "000-00-9876" ] ], "contactMethods": [ [ "type": "email", "value": "fred.nerk@example.com" ], [ "type": "phone", "value": "2025550110" ] ], "relationship": [ "isControlProng": false, "equityPercentage": 51.5, "title": "CEO", "isAuthorizedSignatory": true ], "middleName": "Jim" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-recipients/234/owners")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` **Successful response:** ### Response (201) ```json { "firstName": "Fred", "lastName": "Nerk", "dateOfBirth": "1980-01-19", "address": { "address1": "2 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "xxxxx9876" } ], "contactMethods": [ { "type": "email", "value": "fred.nerk@example.com" }, { "type": "phone", "value": "2025550110" } ], "relationship": { "isControlProng": false, "equityPercentage": 51.5, "title": "CEO", "isAuthorizedSignatory": true }, "ownerId": 12346, "middleName": "Jim" } ``` ### Test 4: Retrieve the Funding Accounts for a Recipient To create accurate Funding Instructions, it's important to make sure that you can retrieve a list of Funding Accounts for any Funding Recipients that you create. - Use our `/funding-accounts` endpoint to retrieve a list of Funding Accounts for a Funding Recipient. ### Request GET [https://api.payroc.com/v1/funding-recipients/\{recipientId\}/funding-accounts](https://api.payroc.com/v1/funding-recipients/%7BrecipientId%7D/funding-accounts) **`List of funding accounts`** ```curl curl https://api.payroc.com/v1/funding-recipients/234/funding-accounts \ -H "Authorization: Bearer " ``` **`List of funding accounts`** ```python import requests url = "https://api.payroc.com/v1/funding-recipients/234/funding-accounts" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`List of funding accounts`** ```javascript const url = 'https://api.payroc.com/v1/funding-recipients/234/funding-accounts'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`List of funding accounts`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-recipients/234/funding-accounts" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`List of funding accounts`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-recipients/234/funding-accounts") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`List of funding accounts`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/funding-recipients/234/funding-accounts") .header("Authorization", "Bearer ") .asString(); ``` **`List of funding accounts`** ```php request('GET', 'https://api.payroc.com/v1/funding-recipients/234/funding-accounts', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`List of funding accounts`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-recipients/234/funding-accounts"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`List of funding accounts`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-recipients/234/funding-accounts")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` **Successful response:** ### Response (200) ```json [ { "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "*****6789", "accountNumber": "******7890" } } ], "fundingAccountId": 123, "createdDate": "2024-07-02T15:30:00+00:00", "lastModifiedDate": "2024-07-02T15:30:00+00:00", "status": "approved", "metadata": { "yourCustomField": "abc123" }, "links": [ { "rel": "parent", "method": "get", "href": "https://api.payroc.com/v1/funding-recipients/234" } ] }, { "type": "checking", "use": "debit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "*****8725", "accountNumber": "******3491" } } ], "fundingAccountId": 124, "createdDate": "2024-07-02T15:30:00+00:00", "lastModifiedDate": "2024-07-02T15:30:00+00:00", "status": "pending", "metadata": { "yourCustomField": "abc123" }, "links": [ { "rel": "parent", "method": "get", "href": "https://api.payroc.com/v1/funding-recipients/235" } ] } ] ``` ## Testing Funding Instructions You can use our `/funding-instructions` endpoint to tell us how to split your available funds across multiple Funding Accounts. For example, Funding Accounts that belong to your sales office, your merchants, or any Funding Recipients. To verify that your integration works with this endpoint, run the following tests: ### Test 5: Create a new Funding Instruction A Funding Instruction tells us how to split funds across multiple accounts. - Use our `/funding-accounts` endpoint to retrieve a list of Funding Accounts. - Use our `/funding-instructions` endpoint to create a new Funding Instruction. ### Request POST [https://api.payroc.com/v1/funding-instructions](https://api.payroc.com/v1/funding-instructions) **`Funding instruction`** ```curl curl -X POST https://api.payroc.com/v1/funding-instructions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "merchants": [ { "merchantId": "4525644354", "recipients": [ { "fundingAccountId": 123, "paymentMethod": "ACH", "amount": { "value": 120000, "currency": "USD" }, "metadata": { "yourCustomField": "abc123" } } ] } ], "metadata": { "yourCustomField": "abc123" } }' ``` **`Funding instruction`** ```python import requests url = "https://api.payroc.com/v1/funding-instructions" payload = { "merchants": [ { "merchantId": "4525644354", "recipients": [ { "fundingAccountId": 123, "paymentMethod": "ACH", "amount": { "value": 120000, "currency": "USD" }, "metadata": { "yourCustomField": "abc123" } } ] } ], "metadata": { "yourCustomField": "abc123" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Funding instruction`** ```javascript const url = 'https://api.payroc.com/v1/funding-instructions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"merchants":[{"merchantId":"4525644354","recipients":[{"fundingAccountId":123,"paymentMethod":"ACH","amount":{"value":120000,"currency":"USD"},"metadata":{"yourCustomField":"abc123"}}]}],"metadata":{"yourCustomField":"abc123"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Funding instruction`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-instructions" payload := strings.NewReader("{\n \"merchants\": [\n {\n \"merchantId\": \"4525644354\",\n \"recipients\": [\n {\n \"fundingAccountId\": 123,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 120000,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Funding instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-instructions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"merchants\": [\n {\n \"merchantId\": \"4525644354\",\n \"recipients\": [\n {\n \"fundingAccountId\": 123,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 120000,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Funding instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/funding-instructions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"merchants\": [\n {\n \"merchantId\": \"4525644354\",\n \"recipients\": [\n {\n \"fundingAccountId\": 123,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 120000,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") .asString(); ``` **`Funding instruction`** ```php request('POST', 'https://api.payroc.com/v1/funding-instructions', [ 'body' => '{ "merchants": [ { "merchantId": "4525644354", "recipients": [ { "fundingAccountId": 123, "paymentMethod": "ACH", "amount": { "value": 120000, "currency": "USD" }, "metadata": { "yourCustomField": "abc123" } } ] } ], "metadata": { "yourCustomField": "abc123" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Funding instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-instructions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"merchants\": [\n {\n \"merchantId\": \"4525644354\",\n \"recipients\": [\n {\n \"fundingAccountId\": 123,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 120000,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Funding instruction`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "merchants": [ [ "merchantId": "4525644354", "recipients": [ [ "fundingAccountId": 123, "paymentMethod": "ACH", "amount": [ "value": 120000, "currency": "USD" ], "metadata": ["yourCustomField": "abc123"] ] ] ] ], "metadata": ["yourCustomField": "abc123"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-instructions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` **Successful response:** ### Response (201) ```json { "instructionId": 64643131, "createdDate": "2024-07-02T15:30:00Z", "lastModifiedDate": "2024-07-02T15:30:00Z", "status": "accepted", "merchants": [ { "merchantId": "4525644354", "recipients": [ { "fundingAccountId": 123, "paymentMethod": "ACH", "amount": { "value": 120000, "currency": "USD" }, "status": "accepted", "metadata": { "yourCustomField": "abc123" }, "link": { "rel": "fundingAccount", "method": "get", "href": "https://api.payroc.com/v1/funding-accounts/123" } } ], "link": { "rel": "merchant", "method": "get", "href": "https://api.payroc.com/v1/processing-accounts/4525644354" } } ], "metadata": { "yourCustomField": "abc123" } } ``` ### Test 6: Update a Funding Instruction While a Funding Instruction has a status of `accepted`, you can continue to edit and update the instruction. To update a Funding Instruction, you must send a `PUT` request to the correct Funding Instruction id. - Use our `/funding-instructions/{instructionId}` endpoint to update a Funding Instruction. ### Request PUT [https://api.payroc.com/v1/funding-instructions/\{instructionId\}](https://api.payroc.com/v1/funding-instructions/%7BinstructionId%7D) **`Update funding instruction`** ```curl curl -X PUT https://api.payroc.com/v1/funding-instructions/64643131 \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "merchants": [ { "merchantId": "9876543219", "recipients": [ { "fundingAccountId": 124, "paymentMethod": "ACH", "amount": { "value": 69950, "currency": "USD" }, "metadata": { "supplier": "IT Support Services" } } ] } ], "metadata": { "instructionCreatedBy": "Jane Doe" } }' ``` **`Update funding instruction`** ```python import requests url = "https://api.payroc.com/v1/funding-instructions/64643131" payload = { "merchants": [ { "merchantId": "9876543219", "recipients": [ { "fundingAccountId": 124, "paymentMethod": "ACH", "amount": { "value": 69950, "currency": "USD" }, "metadata": { "supplier": "IT Support Services" } } ] } ], "metadata": { "instructionCreatedBy": "Jane Doe" } } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.put(url, json=payload, headers=headers) print(response.json()) ``` **`Update funding instruction`** ```javascript const url = 'https://api.payroc.com/v1/funding-instructions/64643131'; const options = { method: 'PUT', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"merchants":[{"merchantId":"9876543219","recipients":[{"fundingAccountId":124,"paymentMethod":"ACH","amount":{"value":69950,"currency":"USD"},"metadata":{"supplier":"IT Support Services"}}]}],"metadata":{"instructionCreatedBy":"Jane Doe"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Update funding instruction`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-instructions/64643131" payload := strings.NewReader("{\n \"merchants\": [\n {\n \"merchantId\": \"9876543219\",\n \"recipients\": [\n {\n \"fundingAccountId\": 124,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 69950,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"supplier\": \"IT Support Services\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"instructionCreatedBy\": \"Jane Doe\"\n }\n}") req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Update funding instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-instructions/64643131") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"merchants\": [\n {\n \"merchantId\": \"9876543219\",\n \"recipients\": [\n {\n \"fundingAccountId\": 124,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 69950,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"supplier\": \"IT Support Services\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"instructionCreatedBy\": \"Jane Doe\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Update funding instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://api.payroc.com/v1/funding-instructions/64643131") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"merchants\": [\n {\n \"merchantId\": \"9876543219\",\n \"recipients\": [\n {\n \"fundingAccountId\": 124,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 69950,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"supplier\": \"IT Support Services\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"instructionCreatedBy\": \"Jane Doe\"\n }\n}") .asString(); ``` **`Update funding instruction`** ```php request('PUT', 'https://api.payroc.com/v1/funding-instructions/64643131', [ 'body' => '{ "merchants": [ { "merchantId": "9876543219", "recipients": [ { "fundingAccountId": 124, "paymentMethod": "ACH", "amount": { "value": 69950, "currency": "USD" }, "metadata": { "supplier": "IT Support Services" } } ] } ], "metadata": { "instructionCreatedBy": "Jane Doe" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` **`Update funding instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-instructions/64643131"); var request = new RestRequest(Method.PUT); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"merchants\": [\n {\n \"merchantId\": \"9876543219\",\n \"recipients\": [\n {\n \"fundingAccountId\": 124,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 69950,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"supplier\": \"IT Support Services\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"instructionCreatedBy\": \"Jane Doe\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Update funding instruction`** ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "merchants": [ [ "merchantId": "9876543219", "recipients": [ [ "fundingAccountId": 124, "paymentMethod": "ACH", "amount": [ "value": 69950, "currency": "USD" ], "metadata": ["supplier": "IT Support Services"] ] ] ] ], "metadata": ["instructionCreatedBy": "Jane Doe"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-instructions/64643131")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` **Successful response:** ### Test 7: List Funding Activity You can use our `/funding-activity` endpoint to retrieve a list of all funding activity so far. - Use our `/funding-activity` endpoint to retrieve a list of all funding activity. ### Request GET [https://api.payroc.com/v1/funding-activity](https://api.payroc.com/v1/funding-activity) **`Paginated activity records`** ```curl curl -G https://api.payroc.com/v1/funding-activity \ -H "Authorization: Bearer " \ -d after=8516 \ -d before=2571 \ -d dateFrom=2024-07-02 \ -d dateTo=2024-07-03 \ -d limit=25 \ -d merchantId=4525644354 ``` **`Paginated activity records`** ```python import requests url = "https://api.payroc.com/v1/funding-activity" querystring = {"after":"8516","before":"2571","dateFrom":"2024-07-02","dateTo":"2024-07-03","limit":"25","merchantId":"4525644354"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` **`Paginated activity records`** ```javascript const url = 'https://api.payroc.com/v1/funding-activity?after=8516&before=2571&dateFrom=2024-07-02&dateTo=2024-07-03&limit=25&merchantId=4525644354'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Paginated activity records`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-activity?after=8516&before=2571&dateFrom=2024-07-02&dateTo=2024-07-03&limit=25&merchantId=4525644354" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Paginated activity records`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-activity?after=8516&before=2571&dateFrom=2024-07-02&dateTo=2024-07-03&limit=25&merchantId=4525644354") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Paginated activity records`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/funding-activity?after=8516&before=2571&dateFrom=2024-07-02&dateTo=2024-07-03&limit=25&merchantId=4525644354") .header("Authorization", "Bearer ") .asString(); ``` **`Paginated activity records`** ```php request('GET', 'https://api.payroc.com/v1/funding-activity?after=8516&before=2571&dateFrom=2024-07-02&dateTo=2024-07-03&limit=25&merchantId=4525644354', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Paginated activity records`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-activity?after=8516&before=2571&dateFrom=2024-07-02&dateTo=2024-07-03&limit=25&merchantId=4525644354"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Paginated activity records`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-activity?after=8516&before=2571&dateFrom=2024-07-02&dateTo=2024-07-03&limit=25&merchantId=4525644354")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` **Successful response:** ### Response (200) ```json { "data": [ { "id": 11, "date": "2024-07-02T17:00:00.000Z", "merchant": "Pizza Doe", "description": "sales", "amount": 4999, "type": "credit", "currency": "USD" }, { "id": 12, "date": "2024-07-02T19:32:00.000Z", "merchant": "Pizza Doe", "description": "sales", "amount": 3999, "type": "credit", "currency": "USD" }, { "id": 13, "date": "2024-07-02T17:00:00.000Z", "merchant": "Pizza Doe", "description": "sales", "amount": 3299, "type": "credit", "currency": "USD" }, { "id": 14, "date": "2024-07-02T17:00:00.000Z", "merchant": "Pizza Doe", "description": "Interchange Fees", "amount": 50, "type": "debit", "currency": "USD", "recipient": "Payroc" }, { "id": 15, "date": "2024-07-02T09:10:00.000Z", "merchant": "Pizza Doe", "description": "sales", "amount": 4999, "type": "credit", "currency": "USD" }, { "id": 16, "date": "2024-07-02T17:00:00.000Z", "merchant": "Doe Hot Dogs", "description": "Adjustment", "amount": 750, "type": "credit", "currency": "USD" }, { "id": 17, "date": "2024-07-02T17:00:00.000Z", "merchant": "Doe Hot Dogs", "description": "Interchange Fees", "amount": 5, "type": "debit", "currency": "USD", "recipient": "Payroc" }, { "id": 18, "date": "2024-07-02T17:00:00.000Z", "merchant": "Pizza Doe", "description": "Charge back", "amount": 1000, "type": "debit", "currency": "USD", "recipient": "Payroc" }, { "id": 19, "date": "2024-07-02T17:00:00.000Z", "merchant": "Pizza Doe", "description": "sales", "amount": 5999, "type": "credit", "currency": "USD" }, { "id": 20, "date": "2024-07-02T17:00:00.000Z", "merchant": "Pizza Doe", "description": "payment", "amount": 1000, "type": "debit", "currency": "USD", "recipient": "Pizza Doe" } ], "limit": 10, "count": 10, "hasMore": true, "links": [ { "rel": "previous", "method": "get", "href": "https://api.payroc.com/v1/funding-activity?before=11&limit=10&datefrom=2024-07-01&dateto=2024-07-03" }, { "rel": "next", "method": "get", "href": "https://api.payroc.com/v1/funding-activity?after=20&limit=10&datefrom=2024-07-01&dateto=2024-07-03" } ] } ``` ## Results After you complete your tests, send your results to [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). A member of our team will contact you to confirm certification or to provide support. ## Need more help? We are here to help\! If you need help with your integration, contact us at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com) or through our **Developer Community**. # Payments Source: https://docs.payroc.com/guides/testing/online-payments Test cases and test data for validating online payment integrations including card payments, secure tokens, payment plans, and bank transfers in the test environment. Before you can run live payments, we require you to run our test cases to make sure that you have correctly integrated against our API. **Note:** If you have any issues when you run our test cases, email our integrations team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Before you begin To help you with testing, we provide you with: - Test environment - Test cards - Test values You should also review our [testing recommendations](/guides/testing/online-payments#testing-recommendations). ## Test environment Create a test API key in the [Developer Portal](https://developers.payroc.com). We automatically send requests that use a test API key to our test environment, so you don't need to change the endpoint. **Base URI:** [https://api.payroc.com/v1](https://api.payroc.com/v1) **Important:** Use only test cards in our test environment. ### Authenticating your requests Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate your Bearer token, complete the following steps: 1. Include your API key in the x-api-key parameter in the header of a POST request. 2. Send your request to [https://identity.payroc.com/authorize](https://identity.payroc.com/authorize). **Note:** You need to generate a new Bearer token before the previous Bearer token expires. #### Example request ```bash curl --location --request POST 'https://identity.payroc.com/authorize' --header 'x-api-key: ' ``` #### Example response If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires. ```json { "access_token": "eyJhbGc....adQssw5c", "expires_in": 3600, "scope": "service_a service_b", "token_type": "Bearer" } ``` #### Example request header ```bash curl -H "Authorization: Bearer " ``` ## Test cards **Note:** Our gateway accepts any value for the CVV. | Card scheme | Card number | Requires CVV? | | --- | --- | --- | | American Express | 3400000000000000 | Yes | | Debit MasterCard | 5100270000000007 | Yes | | Diners | 3600000000000008 | No | | Discover | 6011000000000004 | Yes | | JCB | 3528000000000007 | Yes | | Maestro | 5000330000000000 | Yes | | MasterCard | 5001650000000000 | Yes | | Visa Credit | 4539858876047062 | Yes | | Visa Debit | 4000060000000006 | Yes | | Visa Electron | 4001020000000009 | No | ### EBT test cards **Note:** You can only test EBT transactions if the processor is Fiserv or TSYS. | Card number | Benefit category | PIN | | --- | --- | --- | | 6007602801003837964 | Food Stamp | 1234 | | 6007602801003837965 | Food Stamp | 1234 | | 060076028010038379673 | Cash Only | 1234 | | 6007602801003837968 | Cash Only | 1234 | | 6007602801003837969 | Cash Only | 1234 | | 6007602801003837971 | Inactive card | 1234 | ## Test values To return a specific response from the gateway, change the value in the **amount** parameter to end in one of the following values: | Value | Response | Example | | --- | --- | --- | | 01 | Declined | 501 | | 02 | Referral | 1002 | | 03 | CVV failure | 1403 | | Any other | Authorized | 4541 | ## Testing recommendations **Important:** Do not use live card data to test your integration. This is a breach of PCI DSS. When you test your integration, we recommend that you do the following: - **Test error scenarios** – To check that your integration can handle errors, run scenarios that produce [errors](/api/errors). For example, test that your integration can handle the response when the value for a request parameter is in the wrong format. - **Follow PCI DSS** – To help protect the payment data, make sure that your integration complies with [PCI DSS](https://www.pcisecuritystandards.org/). - **Test all card types** – If your integration accepts multiple card types, test your integration with each card type. For example, if your integration accepts EBT cards, you should test with an EBT card. - **Refresh tokens for authentication** – [Bearer tokens](/api/authentication) expire after one hour, and you must generate a new Bearer token before the previous token expires. Test your integration to make sure that it can correctly refresh Bearer tokens. ## Test cases We provide you with test cases for the following: - [Card payments](/guides/testing/online-payments#card-payments) - [Secure tokens](/guides/testing/online-payments#secure-tokens) - [Payment plans and subscriptions](/guides/testing/online-payments#payment-plans-and-subscriptions) - [Bank transfers](/guides/testing/online-payments#bank-transfers) ### Card payments #### Run a card sale without a surcharge Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **Example response** ```json { "paymentId": "F1I17KBL0E", "processingTerminalId": "3204001", "order": { "orderId": "Test_001", "dateTime": "2023-05-24T14:44:20.63+01:00", "amount": 4000, "currency": "USD" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "0334", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "paymentResult": { "type": "sale", "status": "ready", "approvalCode": "OK14472", "authorizedAmount": 4000, "currency": "USD", "responseCode": "A", "responseMessage": "OK14472" } } ``` #### Run a card sale with a surcharge Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **Note:** If you are unsure whether your account supports surcharges, email our Integration team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). **Example response** ```json { "paymentId": "CBA7UOVS0J", "processingTerminalId": "3204001", "order": { "orderId": "Test_005", "dateTime": "2023-05-24T14:48:39.548+01:00", "amount": 4160, "currency": "USD", "breakdown": { "subtotal": 4000, "surcharge": { "bypass": false, "amount": 160, "percentage": 4.0 } } }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "0334", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "paymentResult": { "type": "sale", "status": "ready", "approvalCode": "OK14476", "authorizedAmount": 4160, "currency": "USD", "responseCode": "A", "responseMessage": "OK14476" } } ``` #### Run a pre-authorization Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **Note:** Set the value for the `autoCapture` and the `processAsSale` parameters to `false` in the request body. **Example response** ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 9999, "currency": "USD", "dateTime": "2026-08-19T16:16:22+01:00", "description": "Large Pepperoni Pizza" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "avsResult": "U" } }, "transactionResult": { "status": "pending", "responseCode": "A", "type": "sale", "approvalCode": "582235", "authorizedAmount": 9999, "currency": "USD", "responseMessage": "APPROVAL", "processorResponseCode": "00" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "shippingAddress": { "recipientName": "Sarah Hopper", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "setAsReady" ] } ``` #### Capture a pre-authorization Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments/\{paymentId\}/capture](https://api.payroc.com/v1/payments/%7BpaymentId%7D/capture) **Example response** ```json { "paymentId": "M2MJOG6O2Y", "processingTerminalId": "1234001", "order": { "orderId": "OrderRef6543", "amount": 3999, "currency": "USD", "dateTime": "2026-08-19T16:16:22+01:00", "description": "Large Pepperoni Pizza" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "453985******7062", "expiryDate": "1230", "securityChecks": { "avsResult": "U" } }, "transactionResult": { "status": "ready", "responseCode": "A", "type": "sale", "approvalCode": "582235", "authorizedAmount": 3999, "currency": "USD", "responseMessage": "APPROVAL", "processorResponseCode": "00" }, "operator": "Jane", "customer": { "firstName": "Sarah", "lastName": "Hopper", "billingAddress": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } }, "supportedOperations": [ "capture", "fullyReverse", "partiallyReverse", "incrementAuthorization", "setAsPending" ] } ``` #### Adjust a card payment Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments/\{paymentId\}/adjust](https://api.payroc.com/v1/payments/%7BpaymentId%7D/adjust) **Example response** ```json { "paymentId": "C7BHY7KWCW", "processingTerminalId": "3204001", "operator": "ROBBIE-KIRWAN-adjust", "order": { "orderId": "1234567890Q1", "dateTime": "2023-06-20T21:03:31+01:00", "description": "PreAuth Card Transaction (WEB) - Sale - KEYED (plain_text) with CVV", "amount": 400, "currency": "USD" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardholderName": "Davi", "cardNumber": "444433******1111", "expiryDate": "1223", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "type": "sale", "status": "ready", "approvalCode": "OK24233", "authorizedAmount": 400, "currency": "USD", "responseCode": "A", "responseMessage": "OK24233" } } ``` ### Secure tokens #### Create a secure token Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/secure-tokens](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens) **Example response** ```json { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "processingTerminalId": "3204001", "source": { "type": "card", "cardholderName": "", "cardNumber": "444433******1111", "expiryDate": "1226" }, "token": "2967538502417872", "status": "cvv_validated" } ``` #### Create a payment with a secure token Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/payments](https://api.payroc.com/v1/payments) **Example response** ```json { "paymentId": "C8Y177VHWR", "processingTerminalId": "3204001", "order": { "orderId": "Test_006", "dateTime": "2023-05-24T15:21:01.037+01:00", "amount": 4000, "currency": "USD" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "1226", "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "type": "sale", "status": "ready", "approvalCode": "OK14486", "authorizedAmount": 4000, "currency": "USD", "responseCode": "A", "responseMessage": "OK14486", "cardSchemeReferenceId": "JxDfFMHyOE2lyQJ2MnFp" } } ``` #### Delete a secure token Send a DELETE request to the following endpoint: DELETE [https://api.payroc.com/v1/payments/processing-terminals/\{processingTerminalId\}/secure-tokens/\{secureTokenId\}](https://api.payroc.com/v1/payments/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens/%7BsecureTokenId%7D) **Example response** No response body. #### Update a secure token Send a PATCH request to the following endpoint: PATCH [https://api.payroc.com/v1/payments/processing-terminals/\{processingTerminalId\}/secure-tokens/\{secureTokenId\}](https://api.payroc.com/v1/payments/processing-terminals/%7BprocessingTerminalId%7D/secure-tokens/%7BsecureTokenId%7D) **Example response** ```json { "secureTokenId": "MREF_fe532d13-d330-4872-b646-61750144030bG4", "processingTerminalId": "3204001", "customer": { "contactMethods": [ { "type": "email", "value": "EMAIL3@gmail.com" } ] }, "source": { "type": "card", "cardholderName": "Test Card 13 Uat Usa", "cardNumber": "374245*****1003", "expiryDate": "1224" }, "token": "2967538321403871", "status": "cvv_validated" } ``` ### Payment plans and subscriptions #### Create a payment plan Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/payment-plans](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/payment-plans) **Example response** ```json { "paymentPlanId": "PaymentPlanTest", "processingTerminalId": "3204001", "name": "Davi Crisostomo", "description": "Payment Plan creation", "currency": "USD", "setupOrder": { "amount": 11000, "description": "Setup Amount" }, "length": 24, "type": "manual", "frequency": "monthly", "onUpdate": "update", "onDelete": "complete" } ``` #### Update a payment plan Send a PATCH request to the following endpoint: PATCH [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/payment-plans/\{paymentPlanId\}](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/payment-plans/%7BpaymentPlanId%7D) **Example response** ```json { "paymentPlanId": "PaymentPlanTest", "processingTerminalId": "3204001", "name": "Davi Crisostomo", "description": "Payment Plan creation", "currency": "USD", "setupOrder": { "amount": 11000, "description": "Setup Amount" }, "length": 24, "type": "automatic", "frequency": "weekly", "onUpdate": "update", "onDelete": "complete" } ``` #### Create a subscription for a payment plan Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/subscriptions) **Example response** ```json { "subscriptionId": "SubTest", "processingTerminalId": "3204001", "paymentPlan": { "paymentPlanId": "PaymentPlanTest", "name": "Davi Crisostomo", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/payment-plans/PaymentPlanTest" } }, "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "name": "Davi Crisostomo", "description": "Create Subscription from ICC payment", "currency": "USD", "setupOrder": { "orderId": "TheOrderID", "amount": 11000, "description": "Description of SETUPORDER" }, "recurringOrder": { "amount": 11000, "description": "RECURRING Order price" }, "currentState": { "status": "active", "nextDueDate": "2023-08-02", "paidInvoices": 0, "outstandingInvoices": 122 }, "startDate": "2023-08-02", "endDate": "2025-12-02", "length": 24, "type": "automatic", "frequency": "weekly", "pauseCollectionFor": 0 } ``` #### Manually pay a subscription Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/pay](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/subscriptions/%7BsubscriptionId%7D/pay) **Example response** ```json { "paymentId": "KOHM1D3EZH", "processingTerminalId": "3204001", "operator": "Davi Crisostomo", "order": { "orderId": "UniqueValueForOrderID", "dateTime": "2023-06-20T20:25:57.641+01:00", "description": "Subscription Payment - Manual", "amount": 11000, "currency": "USD" }, "card": { "type": "Visa Credit", "entryMethod": "keyed", "cardNumber": "444433******1111", "expiryDate": "1226", "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "type": "sale", "status": "ready", "approvalCode": "OK24225", "authorizedAmount": 11000, "currency": "USD", "responseCode": "A", "responseMessage": "OK24225", "cardSchemeReferenceId": "nkMX2G7ZqPavgbYiYacQ" } } ``` #### Update a subscription Send a PATCH request to the following endpoint: PATCH [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/subscriptions/%7BsubscriptionId%7D) **Example response** ```json { "subscriptionId": "SubTest", "processingTerminalId": "3204001", "paymentPlan": { "paymentPlanId": "PaymentPlanTest", "name": "Davi Crisostomo", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/payment-plans/PaymentPlanTest" } }, "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "name": "Davi Crisostomo", "description": "NEW DESCRIPTION FOR SUBSCRIPTION", "currency": "USD", "setupOrder": { "orderId": "TheOrderID", "amount": 11000, "description": "Description of SETUPORDER" }, "recurringOrder": { "amount": 11000, "description": "RECURRING Order price" }, "currentState": { "status": "active", "nextDueDate": "2023-08-02", "paidInvoices": 1, "outstandingInvoices": 121 }, "startDate": "2023-08-02", "endDate": "2025-12-02", "length": 24, "type": "automatic", "frequency": "weekly", "pauseCollectionFor": 0 } ``` #### Deactivate a subscription Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/deactivate](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/subscriptions/%7BsubscriptionId%7D/deactivate) **Example response** ```json { "subscriptionId": "SubTest", "processingTerminalId": "3204001", "paymentPlan": { "paymentPlanId": "PaymentPlanTest", "name": "Davi Crisostomo", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/payment-plans/PaymentPlanTest" } }, "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "name": "Davi Crisostomo", "description": "NEW DESCRIPTION FOR SUBSCRIPTION", "currency": "USD", "setupOrder": { "orderId": "TheOrderID", "amount": 11000, "description": "Description of SETUPORDER" }, "recurringOrder": { "amount": 11000, "description": "RECURRING Order price" }, "currentState": { "status": "cancelled", "nextDueDate": "2023-08-02", "paidInvoices": 1, "outstandingInvoices": 121 }, "startDate": "2023-08-02", "endDate": "2025-12-02", "length": 24, "type": "automatic", "frequency": "weekly", "pauseCollectionFor": 0 } ``` #### Re-activate a subscription Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/processing-terminals/\{processingTerminalId\}/subscriptions/\{subscriptionId\}/reactivate](https://api.payroc.com/v1/processing-terminals/%7BprocessingTerminalId%7D/subscriptions/%7BsubscriptionId%7D/reactivate) **Example response** ```json { "subscriptionId": "SubTest", "processingTerminalId": "3204001", "paymentPlan": { "paymentPlanId": "PaymentPlanTest", "name": "Davi Crisostomo", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/payment-plans/PaymentPlanTest" } }, "secureToken": { "secureTokenId": "MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA", "customerName": "", "token": "2967538502417872", "status": "cvv_validated", "link": { "rel": "self", "method": "GET", "href": "https://api.payroc.com/v1/processing-terminals/3204001/secure-tokens/MREF_1a93f3a6-9029-419f-9e87-3e2db6f0ae85uA" } }, "name": "Davi Crisostomo", "description": "NEW DESCRIPTION FOR SUBSCRIPTION", "currency": "USD", "setupOrder": { "orderId": "TheOrderID", "amount": 11000, "description": "Description of SETUPORDER" }, "recurringOrder": { "amount": 11000, "description": "RECURRING Order price" }, "currentState": { "status": "active", "nextDueDate": "2023-08-02", "paidInvoices": 1, "outstandingInvoices": 121 }, "startDate": "2023-08-02", "endDate": "2025-12-02", "length": 24, "type": "automatic", "frequency": "weekly", "pauseCollectionFor": 0 } ``` ### Bank transfers #### Run a sale with bank account details Send a POST request to the following endpoint: POST [https://api.payroc.com/v1/bank-transfer-payments](https://api.payroc.com/v1/bank-transfer-payments) **Example response** ```json { "channel": "POS", "processingTerminalId": "3204001", "operator": "Davi-CHP", "order": { "orderId": "CC-12", "description": "BT ACH - Sale with CC", "currency": "USD", "amount": 9700 }, "paymentMethod": { "type": "ach", "accountType": "checking", "secCode": "web", "nameOnAccount": "Davi", "accountNumber": "49100130", "routingNumber": "292735277" } } ``` # Payroc Cloud Source: https://docs.payroc.com/guides/testing/payroc-cloud Test cases and test data for validating a Payroc Cloud physical POS integration before going live. Before you can run live payments, we require you to run our test cases to make sure that you have correctly integrated against our API. **Note:** If you have any issues when you run our test cases, email our integrations team at [payroc-integrations@payroc.com](mailto:payroc-integrations@payroc.com). ## Before you begin To help you with testing, we provide you with: - Test environment - Test cards - Test values You should also review our [testing recommendations](/guides/testing/payroc-cloud#testing-recommendations). ## Test environment Create a test API key in the [Developer Portal](https://developers.payroc.com). We automatically send requests that use a test API key to our test environment, so you don't need to change the endpoint. **Base URI:** [https://api.payroc.com/v1](https://api.payroc.com/v1) **Important:** Use only test cards in our test environment. ### Authenticating your requests Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate your Bearer token, complete the following steps: 1. Include your API key in the x-api-key parameter in the header of a POST request. 2. Send your request to [https://identity.payroc.com/authorize](https://identity.payroc.com/authorize). **Note:** You need to generate a new Bearer token before the previous Bearer token expires. #### Example request ```bash curl --location --request POST 'https://identity.payroc.com/authorize' --header 'x-api-key: ' ``` #### Example response If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires. ```json { "access_token": "eyJhbGc....adQssw5c", "expires_in": 3600, "scope": "service_a service_b", "token_type": "Bearer" } ``` #### Example request header ```bash curl -H "Authorization: Bearer " ``` ## Test cards **Important:** Use only test cards in our test environment. | Card scheme | Card number | Verification | | --- | --- | --- | | Visa | 4761 7300 0000 0011 | Online only | | Mastercard | 5413 3300 8960 4111 | Online only | | Visa | 4761 7310 0000 0043 | Online or offline | | Mastercard | 5413 3300 8960 4111 | Online or offline | | Visa | 4761 7310 0000 0043 | Online or offline | | Mastercard | 5413 3300 8960 4111 | Online or offline | ## Test values To return a specific response from the gateway, change the value in the **amount** parameter to end in one of the following values: | Value | Response | Example | | --- | --- | --- | | 01 | Declined | 501 | | 02 | Referral | 1002 | | 03 | CVV failure | 1403 | | Any other | Authorized | 4541 | ## Testing recommendations When you test your integration, we recommend that you do the following: - **Test error scenarios** – To check that your integration can handle errors, run scenarios that produce [errors](/api/errors). For example, test that your integration can handle the response when the value for a request parameter is in the wrong format. - **Follow PCI DSS** – To help protect the payment data, make sure that your integration complies with [PCI DSS](https://www.pcisecuritystandards.org/). - **Test all card types** – If your integration accepts multiple card types, test your integration with each card type. For example, if your integration accepts EBT cards, you should test with an EBT card. - **Refresh tokens for authentication** – [Bearer tokens](/api/authentication) expire after one hour, and you must generate a new Bearer token before the previous token expires. Test your integration to make sure that it can correctly refresh Bearer tokens. ## Test cases We provide you with test cases for the following: - [Create a payment instruction using options that you configured in the gateway](/guides/testing/payroc-cloud#create-a-payment-instruction-using-options-that-you-configured-in-the-gateway) - [Create a payment instruction that overrides the values that you configured in the gateway](/guides/testing/payroc-cloud#create-a-payment-instruction-that-overrides-the-values-that-you-configured-in-the-gateway) - [Create a refund instruction for when the card isn’t present](/guides/testing/payroc-cloud#create-a-refund-instruction-for-when-the-card-isnt-present) **Note:** For some test cases you need to adjust the gateway settings, for example, to display a tip prompt. If you need help to adjust the gateway settings, contact your Payroc Integration Engineer. ### Create a payment instruction using options that you configured in the gateway #### Step 1. Create a payment instruction Use our gateway to configure the surcharging options, tip options, and tax amounts. **Note:** If you’re unsure about how to configure these options, contact your Payroc Integration Engineer. Send a POST request to the Devices test endpoint: [https://api.payroc.com/v1/devices/\{serialNumber\}/payment-instructions](https://api.payroc.com/v1/devices/%7BserialNumber%7D/payment-instructions) **Example request** ```json { "operator": "jbloggs", "processingTerminalId": "1021", "order": { "orderId": "4fd4-99bc", "currency": "USD", "amount": 1000, "orderBreakdown": { "subtotalAmount": 1000 } }, "customizationOptions": { "entryMethod": "deviceRead" }, "autoCapture": true, "processAsSale": false } ``` #### Step 2. Retrieve the status of the payment instruction Send a GET request to the Payment Instructions test endpoint: [https://api.payroc.com/v1/payment-instructions/\{paymentInstructionId\}](https://api.payroc.com/v1/payment-instructions/%7BpaymentInstructionId%7D) If the status of the payment instruction is `inProgress`, our gateway waits up to a minute for the status to change before it returns a response. Send GET requests until the value for **status** changes to `completed`. **Note:** If the status of the payment instruction is `failed` or `canceled`, contact your Payroc Integration Engineer. **Example response** ```json { "paymentInstructionId": "3743a9165d134678a9100ebba3b29597", "status": "completed", "link": { "rel": "payment", "method": "GET", "href": "https://api.payroc.com/v1/payments/DD6ZDQU7L2" } } ``` #### Step 3. Retrieve the status of the payment instruction Send a GET request to the Payment test endpoint: [https://api.payroc.com/v1/payments/\{paymentId\}](https://api.payroc.com/v1/payments/%7BpaymentId%7D) Use the paymentID that you received in the response from Step 2. **Example response** ```json { "operator": "XYZ", "terminal": 1021, "order": { "orderId": "4fd4-99bc", "description": "Payment Instruction", "currency": "USD", "totalAmount": 10.00, "orderBreakdown": { "subtotalAmount": 10.00, "surcharge": { "bypass": "true" }, "taxes": [ { "name": "TAX10", "rate": 10.0 } ], "tip": {} } }, "customizationOptions": { "entryMethod": "DEVICE_READ" }, "customer": { "name": "First Last", "dateOfBirth": "2023-01-01", "referenceNumber": "ABCDEFGH", "billingAddress": { "line1": "billing Addr Line1", "line2": "billing Addr Line2", "city": "billCity", "state": "AZ", "country": "US", "postalCode": 12345 }, "shippingAddress": { "name": "shipping recipient name", "line1": "shipping Addr Line1", "line2": "shipping Addr Line2", "city": "shipCity", "state": "AZ", "country": "US", "postalCode": "SH12345" }, "email": "email@domain.com", "phone": "+353891234567", "notificationLanguage": "en" }, "autoCapture": true, "processAsSale": false } ``` ### Create a payment instruction that overrides the values that you configured in the gateway #### Step 1. Create a payment instruction Send a POST request to the Devices test endpoint: [https://api.payroc.com/v1/devices/\{serialNumber\}/payment-instructions](https://api.payroc.com/v1/devices/%7BserialNumber%7D/payment-instructions) **Example request** ```json { "operator": "XYZ", "terminal": 1021, "order": { "orderId": "TestPBC-123", "description": "Payment Instruction", "currency": "USD", "totalAmount": 12100, "orderBreakdown": { "subtotalAmount": 12100, "surcharge": { "bypass": "true" }, "taxes": [ { "name": "TAX10", "rate": 10.0 } ], "tip": { "percentage": 10, "type": "PERCENTAGE" } } }, "customizationOptions": { "entryMethod": "DEVICE_READ" }, "autoCapture": true, "processAsSale": false } ``` #### Step 2. Retrieve the status of the payment instruction Send a GET request to the Payment Instructions test endpoint: [https://api.payroc.com/v1/payment-instructions/\{paymentInstructionId\}](https://api.payroc.com/v1/payment-instructions/%7BpaymentInstructionId%7D) If the status of the payment instruction is `inProgress`, our gateway waits up to a minute for the status to change before it returns a response. Send GET requests until the value for **status** changes to `completed`. **Note:** If the status of the payment instruction is `failed` or `canceled`, contact your Payroc Integration Engineer. **Example response** ```json { "paymentInstructionId": "3743a9165d134678a9100ebba3b29597", "status": "completed", "link": { "rel": "payment", "method": "GET", "href": "https://api.payroc.com/v1/payments/DD6ZDQU7L2" } } ``` #### Step 3. Retrieve the status of the payment instruction Send a GET request to the Payment test endpoint: [https://api.payroc.com/v1/payments/\{paymentId\}](https://api.payroc.com/v1/payments/%7BpaymentId%7D) Use the paymentID that you received in the response from Step 2. **Example response** ```json { "paymentId": "DD6ZDQU7L2", "processingTerminalId": "1021", "operator": "Postman", "order": { "orderId": "4fd4-99bc", "dateTime": "2023-07-26T16:42:25.018Z", "description": "Example payment", "amount": 1000, "currency": "USD" }, "customer": { "shippingAddress": {} }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "500165******0000", "expiryDate": "0328", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "type": "sale", "status": "ready", "approvalCode": "OK3", "authorizedAmount": 1000, "currency": "USD", "responseCode": "A", "responseMessage": "OK3" } } ``` ### Create a refund instruction for when the card isn’t present #### Step 1. Create a refund instruction Send a POST request to the Devices test endpoint: [https://api.payroc.com/v1/devices/\{serialNumber\}/refund-instructions](https://api.payroc.com/v1/devices/%7BserialNumber%7D/refund-instructions) **Example request** ```json { "operator": "jbloggs", "processingTerminalId": "1021", "order": { "orderId": "4fd4-99bc", "currency": "USD", "amount": 1000 }, "customizationOptions": { "entryMethod": "manualEntry" } } ``` #### Step 2. Retrieve the status of the refund instruction Send a GET request to the Refund Instructions test endpoint: [https://api.payroc.com/v1/refund-instructions/\{refundInstructionId\}](https://api.payroc.com/v1/refund-instructions/%7BrefundInstructionId%7D) If the status of the refund instruction is `inProgress`, our gateway waits up to a minute for the status to change before it returns a response. Send GET requests until the value for **status** changes to `completed`. **Note:** If the status of the refund instruction is `failed` or `canceled`, contact your Payroc Integration Engineer. **Example response** ```json { "refundInstructionId": "3743a9165d134678a9100ebba3b29597", "status": "completed", "link": { "rel": "refunds", "method": "GET", "href": "https://api.payroc.com/v1/refunds/DD6ZDQU7L27" } } ``` #### Step 3. Retrieve the status of the refund instruction Send a GET request to the Refunds test endpoint: [https://api.payroc.com/v1/refunds/\{refundId\}](https://api.payroc.com/v1/refunds/%7BrefundId%7D) Use the refundID that you received in the response from Step 2. **Example response** ```json { "paymentId": "DD6ZDQU7L2", "processingTerminalId": "1021", "operator": "Postman", "order": { "orderId": "4fd4-99bc", "dateTime": "2023-07-26T16:42:25.018Z", "description": "Example payment", "amount": 1000, "currency": "USD" }, "customer": { "shippingAddress": {} }, "card": { "type": "MasterCard", "entryMethod": "keyed", "cardNumber": "500165******0000", "expiryDate": "0328", "securityChecks": { "cvvResult": "M", "avsResult": "Y" } }, "transactionResult": { "type": "sale", "status": "ready", "approvalCode": "OK3", "authorizedAmount": 1000, "currency": "USD", "responseCode": "A", "responseMessage": "OK3" } } ``` # Board a merchant Source: https://docs.payroc.com/guides/boarding Board a merchant by creating a merchant platform with processing accounts, owners, contacts, and a terminal order. **Prerequisites:** [Authentication](/api/authentication) To board a merchant with Payroc, you need to create the following resources: - **Merchant platform** – The business and its legal information, its owners, and its processing accounts. - **Processing accounts** – Each merchant platform must include one or more processing accounts that run transactions. - **Owners** – Each processing account must include one or more owners. You must assign a control prong who is responsible for their merchant account. - **Contacts** – Each processing account can include additional contacts. They are individuals we can contact about the processing account, for example, a store manager. - **Terminal orders** – Each processing account can order one or more terminals to run transactions. **Note:** When you create a merchant platform, we recommend that you add all the business's processing accounts. If the business expands after you board a merchant, you can add additional processing accounts and their contacts. ## Relationship between the boarding resources The merchant platform is the main boarding resource and includes all the information about the business, including its legal information, processing accounts, owners, and contacts. The following diagram shows the relationship between the boarding resources: ```mermaid flowchart TD MP["Merchant platform"]:::blue PA["Processing account"]:::green TO["Terminal order"]:::neutral OW["Owner"]:::neutral CO["Contact"]:::neutral MP --- PA PA -.- TO PA --- OW & CO classDef blue fill:#0051C2,stroke:#001D4E,color:#FFFFFF classDef green fill:#00E0B8,stroke:#001D4E,color:#001D4E classDef neutral fill:#E5E5E5,stroke:#636363,color:#001D4E ``` ### Example The following example shows a merchant platform with two processing accounts: - Springfield processing account has one owner and two contacts. - Boston processing account has two owners and one contact. ```mermaid flowchart TD RMP["Rocfood merchant platform"]:::blue SPA["Springfield processing account"]:::green BPA["Boston processing account"]:::green STO["Terminal order"]:::neutral SOW["Owner"]:::neutral SCO1["Contact"]:::neutral SCO2["Contact"]:::neutral BOW1["Owner"]:::neutral BOW2["Owner"]:::neutral BCO["Contact"]:::neutral RMP --- SPA & BPA SPA -.- STO SPA --- SOW & SCO1 & SCO2 BPA --- BOW1 & BOW2 & BCO classDef blue fill:#0051C2,stroke:#001D4E,color:#FFFFFF classDef green fill:#00E0B8,stroke:#001D4E,color:#001D4E classDef neutral fill:#E5E5E5,stroke:#636363,color:#001D4E ``` ## Pricing When you add a processing account to a merchant platform, you must provide the pricing model. Assign one of the following pricing models in the pricing object: - **Pricing intent** - Create a pricing intent and provide its ID in the `pricingIntentId` parameter. - **Pricing agreement** - Enter the details for the pricing model including the base fees, processor fees, and gateway fees. ## Your integration journey **Important:** After you board the merchant we review their information and approve their account to process transactions. 1. (Optional) Create a pricing intent. 2. Create a merchant platform. 3. Create a terminal order. ## Guides #### [Create a pricing intent](/guides/boarding/pricing-intent) Create a template of fees that you can apply to processing accounts. #### [Create a merchant platform](/guides/boarding/merchant-platform) Create a resource for the business. #### [Add a processing account to a merchant platform](/guides/boarding/processing-account-create) Create processing accounts that run transactions. #### [Create a terminal order](/guides/boarding/order-a-terminal) Order a terminal for the business. #### [Add an attachment to a processing account](/guides/boarding/add-attachment-to-processing-account) Upload a document to support a merchant's application. # Add an attachment to a processing account Source: https://docs.payroc.com/guides/boarding/add-attachment-to-processing-account Upload a document to a processing account by sending a POST request to the Processing Accounts attachments endpoint, then optionally check the upload status via the Attachments endpoint. **Prerequisites:** [Authentication](/api/authentication) You can use the attachments feature of our API to add a document to a processing account to support a merchant's application, for example, questionnaires, banking evidence, and personal identification. You can add only one attachment in each request to our API, and each attachment must be an uncompressed file under 50 MB in one of the following formats: - .bmp, .csv, .doc, .docx, .gif, .htm, .html, .jpg, .jpeg, .msg, .pdf, .png, .ppt, .pptx, .tif, .tiff, .txt, .xls, .xlsx After we receive your request, we upload the document and attach it to the processing account. You can use our API to check the upload status of the document and to view information about the document. ## Integration steps 1. Upload an attachment. 2. (Optional) Check the upload status of the attachment. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). **Important:** This endpoint accepts a file upload. Set the value of the Content-Type header to `multipart/form-data` instead of `application/json`. ## Step 1. Upload an attachment To upload an attachment, send a POST request to our Processing Accounts endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-accounts/{processingAccountId}/attachments` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-accounts/{processingAccountId}/attachments`](/api/create-processing-account-attachment) ### Example request ### Request POST [https://api.payroc.com/v1/processing-accounts/\{processingAccountId\}/attachments](https://api.payroc.com/v1/processing-accounts/%7BprocessingAccountId%7D/attachments) ```curl curl -X POST https://api.payroc.com/v1/processing-accounts/38765/attachments \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: multipart/form-data" \ -F attachment='{ "type": "personalIdentification", "description": "Passport as identification for lease agreement", "metadata": { "documentId": "2345" } }' \ -F file=@ ``` ```python import requests url = "https://api.payroc.com/v1/processing-accounts/38765/attachments" files = { "file": "open('', 'rb')" } payload = { "attachment": "{ \"type\": \"personalIdentification\", \"description\": \"Passport as identification for lease agreement\", \"metadata\": { \"documentId\": \"2345\" } }" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer " } response = requests.post(url, data=payload, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.payroc.com/v1/processing-accounts/38765/attachments'; const form = new FormData(); form.append('attachment', '{ "type": "personalIdentification", "description": "Passport as identification for lease agreement", "metadata": { "documentId": "2345" } }'); form.append('file', ''); const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ' } }; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-accounts/38765/attachments" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"attachment\"\r\n\r\n{\n \"type\": \"personalIdentification\",\n \"description\": \"Passport as identification for lease agreement\",\n \"metadata\": {\n \"documentId\": \"2345\"\n }\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-accounts/38765/attachments") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"attachment\"\r\n\r\n{\n \"type\": \"personalIdentification\",\n \"description\": \"Passport as identification for lease agreement\",\n \"metadata\": {\n \"documentId\": \"2345\"\n }\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-accounts/38765/attachments") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"attachment\"\r\n\r\n{\n \"type\": \"personalIdentification\",\n \"description\": \"Passport as identification for lease agreement\",\n \"metadata\": {\n \"documentId\": \"2345\"\n }\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.payroc.com/v1/processing-accounts/38765/attachments', [ 'multipart' => [ [ 'name' => 'attachment', 'contents' => '{ "type": "personalIdentification", "description": "Passport as identification for lease agreement", "metadata": { "documentId": "2345" } }' ], [ 'name' => 'file', 'filename' => '', 'contents' => null ] ] 'headers' => [ 'Authorization' => 'Bearer ', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-accounts/38765/attachments"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"attachment\"\r\n\r\n{\n \"type\": \"personalIdentification\",\n \"description\": \"Passport as identification for lease agreement\",\n \"metadata\": {\n \"documentId\": \"2345\"\n }\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer " ] let parameters = [ [ "name": "attachment", "value": "{ \"type\": \"personalIdentification\", \"description\": \"Passport as identification for lease agreement\", \"metadata\": { \"documentId\": \"2345\" } }" ], [ "name": "file", "fileName": "" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-accounts/38765/attachments")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway uploads the attachment. ### Schema (`response.body`) [Response body schema for `POST /processing-accounts/{processingAccountId}/attachments`](/api/create-processing-account-attachment) ### Example response ### Response (201) ```json { "attachmentId": "2587", "type": "personalIdentification", "uploadStatus": "pending", "fileName": "JaneDoePassport.pdf", "contentType": "application/pdf", "entity": { "type": "processingAccount", "id": "38765" }, "createdDate": "2024-07-02T12:00:00.000Z", "lastModifiedDate": "2024-07-02T12:00:00.000Z", "description": "Passport as identification for lease agreement", "metadata": { "documentId": "2345" } } ``` ## Step 2. (Optional) Check the upload status of the attachment To check the upload status of the attachment, send a GET request to our Attachments endpoint. **Endpoint:** `https://api.payroc.com/v1/attachments/{attachmentId}` ### Example request ### Request GET [https://api.payroc.com/v1/attachments/\{attachmentId\}](https://api.payroc.com/v1/attachments/%7BattachmentId%7D) **`Upload Attachment`** ```curl curl https://api.payroc.com/v1/attachments/12876 \ -H "Authorization: Bearer " ``` **`Upload Attachment`** ```python import requests url = "https://api.payroc.com/v1/attachments/12876" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` **`Upload Attachment`** ```javascript const url = 'https://api.payroc.com/v1/attachments/12876'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Upload Attachment`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/attachments/12876" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Upload Attachment`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/attachments/12876") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Upload Attachment`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/attachments/12876") .header("Authorization", "Bearer ") .asString(); ``` **`Upload Attachment`** ```php request('GET', 'https://api.payroc.com/v1/attachments/12876', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Upload Attachment`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/attachments/12876"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Upload Attachment`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/attachments/12876")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway returns details about the attachment. ### Schema (`response.body`) [Response body schema for `GET /attachments/{attachmentId}`](/api/get-attachment) ### Example response ### Response (200) ```json { "attachmentId": "15387", "type": "personalIdentification", "uploadStatus": "accepted", "fileName": "JaneDoePassport.pdf", "contentType": "application/pdf", "entity": { "type": "processingAccount", "id": "2585" }, "createdDate": "2025-09-18T10:19:18.522Z", "lastModifiedDate": "2025-09-18T10:19:18.522Z", "description": "Passport for Jane Doe", "metadata": { "passportId": "123456789" } } ``` # Create a merchant platform Source: https://docs.payroc.com/guides/boarding/merchant-platform Create a merchant platform by sending a POST request to the merchant-platforms endpoint with the business's legal information, then optionally send a reminder to prompt the merchant's signature. **Prerequisites:** [Authentication](/api/authentication) An AI skill is available for this guide, get it on the [Skills Marketplace (GitHub)](https://github.com/payroc/skills). A merchant platform contains all the details of a merchant's business. When you create a merchant platform, you provide the legal information about the business, which includes the unique tax ID, the legal business name, and the type of organization. We recommend that you also add all processing accounts that the merchant's business requires. For each processing account, include the following details: - **Business details** including the Merchant Category Code (MCC), Doing Business As (DBA) name, and address of the business. - **Owners' details** including their names, addresses, and contact details. You must assign a control prong who is responsible for their account. - **Processing details** including estimated average transaction amounts and monthly processing amounts. - **Pricing and funding details** including pricing agreements and funding accounts for the processing account. **Note:** If the merchant’s business expands, you can add more processing accounts. ## Integration steps **Step 1.** Create a merchant platform **Step 2.** (Optional) Create a reminder ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Create a merchant platform To create a merchant platform, send a POST request to our merchant platform endpoint. **Endpoint:** `https://api.payroc.com/v1/merchant-platforms` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /merchant-platforms`](/api/create-merchant) ### Example request ### Request POST [https://api.payroc.com/v1/merchant-platforms](https://api.payroc.com/v1/merchant-platforms) **`Create merchant platform`** ```curl curl -X POST https://api.payroc.com/v1/merchant-platforms \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "business": { "name": "Example Corp", "taxId": "12-3456789", "organizationType": "privateCorporation", "addresses": [ { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois", "type": "legalAddress" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "countryOfOperation": "US" }, "processingAccounts": [ { "doingBusinessAs": "Pizza Doe", "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "relationship": { "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false }, "middleName": "Helen" } ], "merchandiseOrServiceSold": "Pizza", "businessStartDate": "2020-01-01", "timezone": "America/Chicago", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "processing": { "transactionAmounts": { "average": 5000, "highest": 10000 }, "monthlyAmounts": { "average": 50000, "highest": 100000 }, "volumeBreakdown": { "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 }, "isSeasonal": true, "monthsOfOperation": [ "jan", "feb" ], "ach": { "refunds": { "writtenRefundPolicy": true, "refundPolicyUrl": "http://www.example.com/refunds" }, "estimatedMonthlyTransactions": 3000, "limits": { "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 }, "naics": "5812", "previouslyTerminatedForAch": false, "transactionTypes": [ "prearrangedPayment", "other" ], "transactionTypesOther": "recurringBilling" }, "cardAcceptance": { "debitOnly": false, "hsaFsa": false, "cardsAccepted": [ "visa", "mastercard" ], "specialityCards": { "americanExpressDirect": { "enabled": true, "merchantNumber": "abc1234567" }, "electronicBenefitsTransfer": { "enabled": true, "fnsNumber": "6789012" }, "other": { "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" } } } }, "funding": { "fundingSchedule": "nextday", "acceleratedFundingFee": 1999, "dailyDiscount": false, "fundingAccounts": [ { "type": "checking", "use": "creditAndDebit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ], "metadata": { "yourCustomField": "abc123" } } ] }, "pricing": { "type": "intent", "pricingIntentId": "6123" }, "signature": { "type": "requestedViaDirectLink" }, "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "contacts": [ { "type": "manager", "firstName": "Jane", "lastName": "Doe", "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "middleName": "Helen", "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ] } ], "metadata": { "customerId": "2345" } } ], "metadata": { "customerId": "2345" } }' ``` **`Create merchant platform`** ```python import requests url = "https://api.payroc.com/v1/merchant-platforms" payload = { "business": { "name": "Example Corp", "taxId": "12-3456789", "organizationType": "privateCorporation", "addresses": [ { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois", "type": "legalAddress" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "countryOfOperation": "US" }, "processingAccounts": [ { "doingBusinessAs": "Pizza Doe", "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "relationship": { "isControlProng": True, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": False }, "middleName": "Helen" } ], "merchandiseOrServiceSold": "Pizza", "businessStartDate": "2020-01-01", "timezone": "America/Chicago", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "processing": { "transactionAmounts": { "average": 5000, "highest": 10000 }, "monthlyAmounts": { "average": 50000, "highest": 100000 }, "volumeBreakdown": { "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 }, "isSeasonal": True, "monthsOfOperation": ["jan", "feb"], "ach": { "refunds": { "writtenRefundPolicy": True, "refundPolicyUrl": "http://www.example.com/refunds" }, "estimatedMonthlyTransactions": 3000, "limits": { "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 }, "naics": "5812", "previouslyTerminatedForAch": False, "transactionTypes": ["prearrangedPayment", "other"], "transactionTypesOther": "recurringBilling" }, "cardAcceptance": { "debitOnly": False, "hsaFsa": False, "cardsAccepted": ["visa", "mastercard"], "specialityCards": { "americanExpressDirect": { "enabled": True, "merchantNumber": "abc1234567" }, "electronicBenefitsTransfer": { "enabled": True, "fnsNumber": "6789012" }, "other": { "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" } } } }, "funding": { "fundingSchedule": "nextday", "acceleratedFundingFee": 1999, "dailyDiscount": False, "fundingAccounts": [ { "type": "checking", "use": "creditAndDebit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ], "metadata": { "yourCustomField": "abc123" } } ] }, "pricing": { "type": "intent", "pricingIntentId": "6123" }, "signature": { "type": "requestedViaDirectLink" }, "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "contacts": [ { "type": "manager", "firstName": "Jane", "lastName": "Doe", "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "middleName": "Helen", "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ] } ], "metadata": { "customerId": "2345" } } ], "metadata": { "customerId": "2345" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create merchant platform`** ```javascript const url = 'https://api.payroc.com/v1/merchant-platforms'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"business":{"name":"Example Corp","taxId":"12-3456789","organizationType":"privateCorporation","addresses":[{"address1":"1 Example Ave.","address2":"Example Address Line 2","address3":"Example Address Line 3","city":"Chicago","country":"US","postalCode":"60056","state":"Illinois","type":"legalAddress"}],"contactMethods":[{"type":"email","value":"jane.doe@example.com"}],"countryOfOperation":"US"},"processingAccounts":[{"doingBusinessAs":"Pizza Doe","owners":[{"firstName":"Jane","lastName":"Doe","dateOfBirth":"1964-03-22","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"identifiers":[{"type":"nationalId","value":"000-00-4320"}],"contactMethods":[{"type":"email","value":"jane.doe@example.com"}],"relationship":{"isControlProng":true,"equityPercentage":48.5,"title":"CFO","isAuthorizedSignatory":false},"middleName":"Helen"}],"merchandiseOrServiceSold":"Pizza","businessStartDate":"2020-01-01","timezone":"America/Chicago","address":{"address1":"1 Example Ave.","address2":"Example Address Line 2","address3":"Example Address Line 3","city":"Chicago","country":"US","postalCode":"60056","state":"Illinois"},"contactMethods":[{"type":"email","value":"jane.doe@example.com"}],"processing":{"transactionAmounts":{"average":5000,"highest":10000},"monthlyAmounts":{"average":50000,"highest":100000},"volumeBreakdown":{"cardPresent":77,"mailOrTelephone":3,"ecommerce":20},"isSeasonal":true,"monthsOfOperation":["jan","feb"],"ach":{"refunds":{"writtenRefundPolicy":true,"refundPolicyUrl":"http://www.example.com/refunds"},"estimatedMonthlyTransactions":3000,"limits":{"singleTransaction":10000,"dailyDeposit":200000,"monthlyDeposit":6000000},"naics":"5812","previouslyTerminatedForAch":false,"transactionTypes":["prearrangedPayment","other"],"transactionTypesOther":"recurringBilling"},"cardAcceptance":{"debitOnly":false,"hsaFsa":false,"cardsAccepted":["visa","mastercard"],"specialityCards":{"americanExpressDirect":{"enabled":true,"merchantNumber":"abc1234567"},"electronicBenefitsTransfer":{"enabled":true,"fnsNumber":"6789012"},"other":{"wexMerchantNumber":"abc1234567","voyagerMerchantId":"abc1234567","fleetMerchantId":"abc1234567"}}}},"funding":{"fundingSchedule":"nextday","acceleratedFundingFee":1999,"dailyDiscount":false,"fundingAccounts":[{"type":"checking","use":"creditAndDebit","nameOnAccount":"Jane Doe","paymentMethods":[{"type":"ach","value":{"routingNumber":"123456789","accountNumber":"1234567890"}}],"metadata":{"yourCustomField":"abc123"}}]},"pricing":{"type":"intent","pricingIntentId":"6123"},"signature":{"type":"requestedViaDirectLink"},"website":"www.example.com","businessType":"restaurant","categoryCode":5999,"processor":"tsys","contacts":[{"type":"manager","firstName":"Jane","lastName":"Doe","contactMethods":[{"type":"email","value":"jane.doe@example.com"}],"middleName":"Helen","identifiers":[{"type":"nationalId","value":"000-00-4320"}]}],"metadata":{"customerId":"2345"}}],"metadata":{"customerId":"2345"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create merchant platform`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/merchant-platforms" payload := strings.NewReader("{\n \"business\": {\n \"name\": \"Example Corp\",\n \"taxId\": \"12-3456789\",\n \"organizationType\": \"privateCorporation\",\n \"addresses\": [\n {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\",\n \"type\": \"legalAddress\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"countryOfOperation\": \"US\"\n },\n \"processingAccounts\": [\n {\n \"doingBusinessAs\": \"Pizza Doe\",\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"merchandiseOrServiceSold\": \"Pizza\",\n \"businessStartDate\": \"2020-01-01\",\n \"timezone\": \"America/Chicago\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"processing\": {\n \"transactionAmounts\": {\n \"average\": 5000,\n \"highest\": 10000\n },\n \"monthlyAmounts\": {\n \"average\": 50000,\n \"highest\": 100000\n },\n \"volumeBreakdown\": {\n \"cardPresent\": 77,\n \"mailOrTelephone\": 3,\n \"ecommerce\": 20\n },\n \"isSeasonal\": true,\n \"monthsOfOperation\": [\n \"jan\",\n \"feb\"\n ],\n \"ach\": {\n \"refunds\": {\n \"writtenRefundPolicy\": true,\n \"refundPolicyUrl\": \"http://www.example.com/refunds\"\n },\n \"estimatedMonthlyTransactions\": 3000,\n \"limits\": {\n \"singleTransaction\": 10000,\n \"dailyDeposit\": 200000,\n \"monthlyDeposit\": 6000000\n },\n \"naics\": \"5812\",\n \"previouslyTerminatedForAch\": false,\n \"transactionTypes\": [\n \"prearrangedPayment\",\n \"other\"\n ],\n \"transactionTypesOther\": \"recurringBilling\"\n },\n \"cardAcceptance\": {\n \"debitOnly\": false,\n \"hsaFsa\": false,\n \"cardsAccepted\": [\n \"visa\",\n \"mastercard\"\n ],\n \"specialityCards\": {\n \"americanExpressDirect\": {\n \"enabled\": true,\n \"merchantNumber\": \"abc1234567\"\n },\n \"electronicBenefitsTransfer\": {\n \"enabled\": true,\n \"fnsNumber\": \"6789012\"\n },\n \"other\": {\n \"wexMerchantNumber\": \"abc1234567\",\n \"voyagerMerchantId\": \"abc1234567\",\n \"fleetMerchantId\": \"abc1234567\"\n }\n }\n }\n },\n \"funding\": {\n \"fundingSchedule\": \"nextday\",\n \"acceleratedFundingFee\": 1999,\n \"dailyDiscount\": false,\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"creditAndDebit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n },\n \"pricing\": {\n \"type\": \"intent\",\n \"pricingIntentId\": \"6123\"\n },\n \"signature\": {\n \"type\": \"requestedViaDirectLink\"\n },\n \"website\": \"www.example.com\",\n \"businessType\": \"restaurant\",\n \"categoryCode\": 5999,\n \"processor\": \"tsys\",\n \"contacts\": [\n {\n \"type\": \"manager\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"middleName\": \"Helen\",\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ]\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create merchant platform`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/merchant-platforms") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"business\": {\n \"name\": \"Example Corp\",\n \"taxId\": \"12-3456789\",\n \"organizationType\": \"privateCorporation\",\n \"addresses\": [\n {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\",\n \"type\": \"legalAddress\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"countryOfOperation\": \"US\"\n },\n \"processingAccounts\": [\n {\n \"doingBusinessAs\": \"Pizza Doe\",\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"merchandiseOrServiceSold\": \"Pizza\",\n \"businessStartDate\": \"2020-01-01\",\n \"timezone\": \"America/Chicago\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"processing\": {\n \"transactionAmounts\": {\n \"average\": 5000,\n \"highest\": 10000\n },\n \"monthlyAmounts\": {\n \"average\": 50000,\n \"highest\": 100000\n },\n \"volumeBreakdown\": {\n \"cardPresent\": 77,\n \"mailOrTelephone\": 3,\n \"ecommerce\": 20\n },\n \"isSeasonal\": true,\n \"monthsOfOperation\": [\n \"jan\",\n \"feb\"\n ],\n \"ach\": {\n \"refunds\": {\n \"writtenRefundPolicy\": true,\n \"refundPolicyUrl\": \"http://www.example.com/refunds\"\n },\n \"estimatedMonthlyTransactions\": 3000,\n \"limits\": {\n \"singleTransaction\": 10000,\n \"dailyDeposit\": 200000,\n \"monthlyDeposit\": 6000000\n },\n \"naics\": \"5812\",\n \"previouslyTerminatedForAch\": false,\n \"transactionTypes\": [\n \"prearrangedPayment\",\n \"other\"\n ],\n \"transactionTypesOther\": \"recurringBilling\"\n },\n \"cardAcceptance\": {\n \"debitOnly\": false,\n \"hsaFsa\": false,\n \"cardsAccepted\": [\n \"visa\",\n \"mastercard\"\n ],\n \"specialityCards\": {\n \"americanExpressDirect\": {\n \"enabled\": true,\n \"merchantNumber\": \"abc1234567\"\n },\n \"electronicBenefitsTransfer\": {\n \"enabled\": true,\n \"fnsNumber\": \"6789012\"\n },\n \"other\": {\n \"wexMerchantNumber\": \"abc1234567\",\n \"voyagerMerchantId\": \"abc1234567\",\n \"fleetMerchantId\": \"abc1234567\"\n }\n }\n }\n },\n \"funding\": {\n \"fundingSchedule\": \"nextday\",\n \"acceleratedFundingFee\": 1999,\n \"dailyDiscount\": false,\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"creditAndDebit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n },\n \"pricing\": {\n \"type\": \"intent\",\n \"pricingIntentId\": \"6123\"\n },\n \"signature\": {\n \"type\": \"requestedViaDirectLink\"\n },\n \"website\": \"www.example.com\",\n \"businessType\": \"restaurant\",\n \"categoryCode\": 5999,\n \"processor\": \"tsys\",\n \"contacts\": [\n {\n \"type\": \"manager\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"middleName\": \"Helen\",\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ]\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Create merchant platform`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/merchant-platforms") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"business\": {\n \"name\": \"Example Corp\",\n \"taxId\": \"12-3456789\",\n \"organizationType\": \"privateCorporation\",\n \"addresses\": [\n {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\",\n \"type\": \"legalAddress\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"countryOfOperation\": \"US\"\n },\n \"processingAccounts\": [\n {\n \"doingBusinessAs\": \"Pizza Doe\",\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"merchandiseOrServiceSold\": \"Pizza\",\n \"businessStartDate\": \"2020-01-01\",\n \"timezone\": \"America/Chicago\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"processing\": {\n \"transactionAmounts\": {\n \"average\": 5000,\n \"highest\": 10000\n },\n \"monthlyAmounts\": {\n \"average\": 50000,\n \"highest\": 100000\n },\n \"volumeBreakdown\": {\n \"cardPresent\": 77,\n \"mailOrTelephone\": 3,\n \"ecommerce\": 20\n },\n \"isSeasonal\": true,\n \"monthsOfOperation\": [\n \"jan\",\n \"feb\"\n ],\n \"ach\": {\n \"refunds\": {\n \"writtenRefundPolicy\": true,\n \"refundPolicyUrl\": \"http://www.example.com/refunds\"\n },\n \"estimatedMonthlyTransactions\": 3000,\n \"limits\": {\n \"singleTransaction\": 10000,\n \"dailyDeposit\": 200000,\n \"monthlyDeposit\": 6000000\n },\n \"naics\": \"5812\",\n \"previouslyTerminatedForAch\": false,\n \"transactionTypes\": [\n \"prearrangedPayment\",\n \"other\"\n ],\n \"transactionTypesOther\": \"recurringBilling\"\n },\n \"cardAcceptance\": {\n \"debitOnly\": false,\n \"hsaFsa\": false,\n \"cardsAccepted\": [\n \"visa\",\n \"mastercard\"\n ],\n \"specialityCards\": {\n \"americanExpressDirect\": {\n \"enabled\": true,\n \"merchantNumber\": \"abc1234567\"\n },\n \"electronicBenefitsTransfer\": {\n \"enabled\": true,\n \"fnsNumber\": \"6789012\"\n },\n \"other\": {\n \"wexMerchantNumber\": \"abc1234567\",\n \"voyagerMerchantId\": \"abc1234567\",\n \"fleetMerchantId\": \"abc1234567\"\n }\n }\n }\n },\n \"funding\": {\n \"fundingSchedule\": \"nextday\",\n \"acceleratedFundingFee\": 1999,\n \"dailyDiscount\": false,\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"creditAndDebit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n },\n \"pricing\": {\n \"type\": \"intent\",\n \"pricingIntentId\": \"6123\"\n },\n \"signature\": {\n \"type\": \"requestedViaDirectLink\"\n },\n \"website\": \"www.example.com\",\n \"businessType\": \"restaurant\",\n \"categoryCode\": 5999,\n \"processor\": \"tsys\",\n \"contacts\": [\n {\n \"type\": \"manager\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"middleName\": \"Helen\",\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ]\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n}") .asString(); ``` **`Create merchant platform`** ```php request('POST', 'https://api.payroc.com/v1/merchant-platforms', [ 'body' => '{ "business": { "name": "Example Corp", "taxId": "12-3456789", "organizationType": "privateCorporation", "addresses": [ { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois", "type": "legalAddress" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "countryOfOperation": "US" }, "processingAccounts": [ { "doingBusinessAs": "Pizza Doe", "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "relationship": { "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false }, "middleName": "Helen" } ], "merchandiseOrServiceSold": "Pizza", "businessStartDate": "2020-01-01", "timezone": "America/Chicago", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "processing": { "transactionAmounts": { "average": 5000, "highest": 10000 }, "monthlyAmounts": { "average": 50000, "highest": 100000 }, "volumeBreakdown": { "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 }, "isSeasonal": true, "monthsOfOperation": [ "jan", "feb" ], "ach": { "refunds": { "writtenRefundPolicy": true, "refundPolicyUrl": "http://www.example.com/refunds" }, "estimatedMonthlyTransactions": 3000, "limits": { "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 }, "naics": "5812", "previouslyTerminatedForAch": false, "transactionTypes": [ "prearrangedPayment", "other" ], "transactionTypesOther": "recurringBilling" }, "cardAcceptance": { "debitOnly": false, "hsaFsa": false, "cardsAccepted": [ "visa", "mastercard" ], "specialityCards": { "americanExpressDirect": { "enabled": true, "merchantNumber": "abc1234567" }, "electronicBenefitsTransfer": { "enabled": true, "fnsNumber": "6789012" }, "other": { "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" } } } }, "funding": { "fundingSchedule": "nextday", "acceleratedFundingFee": 1999, "dailyDiscount": false, "fundingAccounts": [ { "type": "checking", "use": "creditAndDebit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ], "metadata": { "yourCustomField": "abc123" } } ] }, "pricing": { "type": "intent", "pricingIntentId": "6123" }, "signature": { "type": "requestedViaDirectLink" }, "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "contacts": [ { "type": "manager", "firstName": "Jane", "lastName": "Doe", "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "middleName": "Helen", "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ] } ], "metadata": { "customerId": "2345" } } ], "metadata": { "customerId": "2345" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create merchant platform`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/merchant-platforms"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"business\": {\n \"name\": \"Example Corp\",\n \"taxId\": \"12-3456789\",\n \"organizationType\": \"privateCorporation\",\n \"addresses\": [\n {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\",\n \"type\": \"legalAddress\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"countryOfOperation\": \"US\"\n },\n \"processingAccounts\": [\n {\n \"doingBusinessAs\": \"Pizza Doe\",\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"merchandiseOrServiceSold\": \"Pizza\",\n \"businessStartDate\": \"2020-01-01\",\n \"timezone\": \"America/Chicago\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"processing\": {\n \"transactionAmounts\": {\n \"average\": 5000,\n \"highest\": 10000\n },\n \"monthlyAmounts\": {\n \"average\": 50000,\n \"highest\": 100000\n },\n \"volumeBreakdown\": {\n \"cardPresent\": 77,\n \"mailOrTelephone\": 3,\n \"ecommerce\": 20\n },\n \"isSeasonal\": true,\n \"monthsOfOperation\": [\n \"jan\",\n \"feb\"\n ],\n \"ach\": {\n \"refunds\": {\n \"writtenRefundPolicy\": true,\n \"refundPolicyUrl\": \"http://www.example.com/refunds\"\n },\n \"estimatedMonthlyTransactions\": 3000,\n \"limits\": {\n \"singleTransaction\": 10000,\n \"dailyDeposit\": 200000,\n \"monthlyDeposit\": 6000000\n },\n \"naics\": \"5812\",\n \"previouslyTerminatedForAch\": false,\n \"transactionTypes\": [\n \"prearrangedPayment\",\n \"other\"\n ],\n \"transactionTypesOther\": \"recurringBilling\"\n },\n \"cardAcceptance\": {\n \"debitOnly\": false,\n \"hsaFsa\": false,\n \"cardsAccepted\": [\n \"visa\",\n \"mastercard\"\n ],\n \"specialityCards\": {\n \"americanExpressDirect\": {\n \"enabled\": true,\n \"merchantNumber\": \"abc1234567\"\n },\n \"electronicBenefitsTransfer\": {\n \"enabled\": true,\n \"fnsNumber\": \"6789012\"\n },\n \"other\": {\n \"wexMerchantNumber\": \"abc1234567\",\n \"voyagerMerchantId\": \"abc1234567\",\n \"fleetMerchantId\": \"abc1234567\"\n }\n }\n }\n },\n \"funding\": {\n \"fundingSchedule\": \"nextday\",\n \"acceleratedFundingFee\": 1999,\n \"dailyDiscount\": false,\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"creditAndDebit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n },\n \"pricing\": {\n \"type\": \"intent\",\n \"pricingIntentId\": \"6123\"\n },\n \"signature\": {\n \"type\": \"requestedViaDirectLink\"\n },\n \"website\": \"www.example.com\",\n \"businessType\": \"restaurant\",\n \"categoryCode\": 5999,\n \"processor\": \"tsys\",\n \"contacts\": [\n {\n \"type\": \"manager\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"middleName\": \"Helen\",\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ]\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create merchant platform`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "business": [ "name": "Example Corp", "taxId": "12-3456789", "organizationType": "privateCorporation", "addresses": [ [ "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois", "type": "legalAddress" ] ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ] ], "countryOfOperation": "US" ], "processingAccounts": [ [ "doingBusinessAs": "Pizza Doe", "owners": [ [ "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "identifiers": [ [ "type": "nationalId", "value": "000-00-4320" ] ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ] ], "relationship": [ "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false ], "middleName": "Helen" ] ], "merchandiseOrServiceSold": "Pizza", "businessStartDate": "2020-01-01", "timezone": "America/Chicago", "address": [ "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ] ], "processing": [ "transactionAmounts": [ "average": 5000, "highest": 10000 ], "monthlyAmounts": [ "average": 50000, "highest": 100000 ], "volumeBreakdown": [ "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 ], "isSeasonal": true, "monthsOfOperation": ["jan", "feb"], "ach": [ "refunds": [ "writtenRefundPolicy": true, "refundPolicyUrl": "http://www.example.com/refunds" ], "estimatedMonthlyTransactions": 3000, "limits": [ "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 ], "naics": "5812", "previouslyTerminatedForAch": false, "transactionTypes": ["prearrangedPayment", "other"], "transactionTypesOther": "recurringBilling" ], "cardAcceptance": [ "debitOnly": false, "hsaFsa": false, "cardsAccepted": ["visa", "mastercard"], "specialityCards": [ "americanExpressDirect": [ "enabled": true, "merchantNumber": "abc1234567" ], "electronicBenefitsTransfer": [ "enabled": true, "fnsNumber": "6789012" ], "other": [ "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" ] ] ] ], "funding": [ "fundingSchedule": "nextday", "acceleratedFundingFee": 1999, "dailyDiscount": false, "fundingAccounts": [ [ "type": "checking", "use": "creditAndDebit", "nameOnAccount": "Jane Doe", "paymentMethods": [ [ "type": "ach", "value": [ "routingNumber": "123456789", "accountNumber": "1234567890" ] ] ], "metadata": ["yourCustomField": "abc123"] ] ] ], "pricing": [ "type": "intent", "pricingIntentId": "6123" ], "signature": ["type": "requestedViaDirectLink"], "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "contacts": [ [ "type": "manager", "firstName": "Jane", "lastName": "Doe", "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ] ], "middleName": "Helen", "identifiers": [ [ "type": "nationalId", "value": "000-00-4320" ] ] ] ], "metadata": ["customerId": "2345"] ] ], "metadata": ["customerId": "2345"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/merchant-platforms")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway creates the merchant platform. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /merchant-platforms`](/api/create-merchant) ### Example response ### Response (201) ```json { "business": { "name": "Example Corp", "taxId": "xxxxx6789", "organizationType": "privateCorporation", "addresses": [ { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois", "type": "legalAddress" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "countryOfOperation": "US" }, "processingAccounts": [ { "doingBusinessAs": "Pizza Doe", "processor": "tsys", "status": "pending", "addendums": [], "processingAccountId": "38765", "link": { "rel": "processingAccount", "href": "https://api.payroc.com/v1/processing-accounts/38765", "method": "get" }, "signature": { "type": "requestedViaDirectLink", "link": { "rel": "agreement", "method": "get", "href": "https://us.agreementexpress.net/mv2/viewer2.jsp?docId=00000000-0000-0000-0000-000000000000" } } } ], "merchantPlatformId": "12345", "createdDate": "2024-07-02T12:00:00.000+00:00", "lastModifiedDate": "2024-07-02T12:00:00.000+00:00" } ``` ## Step 2. (Optional) Create a reminder If you requested the merchant’s signature by email and they don’t respond, use our Reminders endpoint to send another email. **Note:** You can use the Reminders endpoint only if you request the merchant’s signature by email. If you generate a link to the pricing agreement, you can’t use the Reminders endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-accounts/{processingAccountId}/reminders` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-accounts/{processingAccountId}/reminders`](/api/create-reminder) ### Example request ### Request POST [https://api.payroc.com/v1/processing-accounts/\{processingAccountId\}/reminders](https://api.payroc.com/v1/processing-accounts/%7BprocessingAccountId%7D/reminders) **`Create reminder for processing account`** ```curl curl -X POST https://api.payroc.com/v1/processing-accounts/38765/reminders \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "type": "pricingAgreement" }' ``` **`Create reminder for processing account`** ```python import requests url = "https://api.payroc.com/v1/processing-accounts/38765/reminders" payload = { "type": "pricingAgreement" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create reminder for processing account`** ```javascript const url = 'https://api.payroc.com/v1/processing-accounts/38765/reminders'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"type":"pricingAgreement"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create reminder for processing account`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-accounts/38765/reminders" payload := strings.NewReader("{\n \"type\": \"pricingAgreement\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create reminder for processing account`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-accounts/38765/reminders") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"type\": \"pricingAgreement\"\n}" response = http.request(request) puts response.read_body ``` **`Create reminder for processing account`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-accounts/38765/reminders") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"type\": \"pricingAgreement\"\n}") .asString(); ``` **`Create reminder for processing account`** ```php request('POST', 'https://api.payroc.com/v1/processing-accounts/38765/reminders', [ 'body' => '{ "type": "pricingAgreement" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create reminder for processing account`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-accounts/38765/reminders"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"type\": \"pricingAgreement\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create reminder for processing account`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["type": "pricingAgreement"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-accounts/38765/reminders")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway creates the reminder and sends the email to the merchant. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-accounts/{processingAccountId}/reminders`](/api/create-reminder) ### Example response ### Response (201) ```json { "type": "pricingAgreement", "reminderId": "1234567" } ``` # Order a terminal Source: https://docs.payroc.com/guides/boarding/order-a-terminal Order one or more terminals for a processing account by sending a POST request to the processing accounts terminal-orders endpoint with training, shipping, and solution details. **Prerequisites:** [Authentication](/api/authentication) **Important:** These documents are an early draft and are subject to change. To order a terminal, you need the `processingAccountId` of the account you want to order the terminal for. To get the `processingAccountId`, go to [Retrieve Merchant Platform](/api#getMerchantAcccounts). To order one or more terminals for a processing account, provide the following information: - Training provider who will train the merchant to use the solution. - Shipping address for hardware devices and peripheral devices. - Solution details for each terminal including gateway settings, device settings, and application settings. To receive a notification when we change the status of a terminal order, subscribe to our terminalOrder.status.changed event. For more information about how to subscribe to an event, go to [Create a Subscription](/guides/events/create-event-subscription). ## Integration steps - Create a terminal order. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Create a terminal order To order a terminal, send a POST request to our processing accounts endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-accounts/{processingAccountId}/terminal-orders` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-accounts/{processingAccountId}/terminal-orders`](/api/create-terminal-order) ### Example request ### Request POST [https://api.payroc.com/v1/processing-accounts/\{processingAccountId\}/terminal-orders](https://api.payroc.com/v1/processing-accounts/%7BprocessingAccountId%7D/terminal-orders) **`Terminal order`** ```curl curl -X POST https://api.payroc.com/v1/processing-accounts/38765/terminal-orders \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "orderItems": [ { "type": "solution", "solutionTemplateId": "Roc Services_DX8000", "solutionQuantity": 1, "deviceCondition": "new", "solutionSetup": { "timezone": "America/Chicago", "industryTemplateId": "Retail", "gatewaySettings": { "merchantPortfolioId": "Company Ltd", "merchantTemplateId": "Company Ltd Merchant Template", "userTemplateId": "Company Ltd User Template", "terminalTemplateId": "Company Ltd Terminal Template" }, "applicationSettings": { "clerkPrompt": false, "security": { "refundPassword": true, "keyedSalePassword": false, "reversalPassword": true } }, "deviceSettings": { "numberOfMobileUsers": 2, "communicationType": "wifi" }, "batchClosure": { "batchCloseType": "automatic", "batchCloseTime": "23:40" }, "receiptNotifications": { "emailReceipt": true, "smsReceipt": false }, "taxes": [ { "taxRate": 6, "taxLabel": "Sales Tax" } ], "tips": { "enabled": false }, "tokenization": true } } ], "trainingProvider": "payroc", "shipping": { "preferences": { "method": "nextDay", "saturdayDelivery": true }, "address": { "recipientName": "Sarah Hopper", "addressLine1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "postalCode": "60056", "email": "example@mail.com", "businessName": "Company Ltd", "addressLine2": "Example Address Line 2", "phone": "2025550164" } }, "paymentIntent": { "paymentIntentType": "purchase", "payment": { "payer": "merchant", "method": "hostedPaymentPage", "frequency": { "type": "singlePayment" } }, "costBreakdown": { "items": [ { "name": "dx8000", "quantity": 1, "unitCost": 4999 } ], "shippingCost": 599 }, "subTotal": 5598 } }' ``` **`Terminal order`** ```python import requests url = "https://api.payroc.com/v1/processing-accounts/38765/terminal-orders" payload = { "orderItems": [ { "type": "solution", "solutionTemplateId": "Roc Services_DX8000", "solutionQuantity": 1, "deviceCondition": "new", "solutionSetup": { "timezone": "America/Chicago", "industryTemplateId": "Retail", "gatewaySettings": { "merchantPortfolioId": "Company Ltd", "merchantTemplateId": "Company Ltd Merchant Template", "userTemplateId": "Company Ltd User Template", "terminalTemplateId": "Company Ltd Terminal Template" }, "applicationSettings": { "clerkPrompt": False, "security": { "refundPassword": True, "keyedSalePassword": False, "reversalPassword": True } }, "deviceSettings": { "numberOfMobileUsers": 2, "communicationType": "wifi" }, "batchClosure": { "batchCloseType": "automatic", "batchCloseTime": "23:40" }, "receiptNotifications": { "emailReceipt": True, "smsReceipt": False }, "taxes": [ { "taxRate": 6, "taxLabel": "Sales Tax" } ], "tips": { "enabled": False }, "tokenization": True } } ], "trainingProvider": "payroc", "shipping": { "preferences": { "method": "nextDay", "saturdayDelivery": True }, "address": { "recipientName": "Sarah Hopper", "addressLine1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "postalCode": "60056", "email": "example@mail.com", "businessName": "Company Ltd", "addressLine2": "Example Address Line 2", "phone": "2025550164" } }, "paymentIntent": { "paymentIntentType": "purchase", "payment": { "payer": "merchant", "method": "hostedPaymentPage", "frequency": { "type": "singlePayment" } }, "costBreakdown": { "items": [ { "name": "dx8000", "quantity": 1, "unitCost": 4999 } ], "shippingCost": 599 }, "subTotal": 5598 } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Terminal order`** ```javascript const url = 'https://api.payroc.com/v1/processing-accounts/38765/terminal-orders'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"orderItems":[{"type":"solution","solutionTemplateId":"Roc Services_DX8000","solutionQuantity":1,"deviceCondition":"new","solutionSetup":{"timezone":"America/Chicago","industryTemplateId":"Retail","gatewaySettings":{"merchantPortfolioId":"Company Ltd","merchantTemplateId":"Company Ltd Merchant Template","userTemplateId":"Company Ltd User Template","terminalTemplateId":"Company Ltd Terminal Template"},"applicationSettings":{"clerkPrompt":false,"security":{"refundPassword":true,"keyedSalePassword":false,"reversalPassword":true}},"deviceSettings":{"numberOfMobileUsers":2,"communicationType":"wifi"},"batchClosure":{"batchCloseType":"automatic","batchCloseTime":"23:40"},"receiptNotifications":{"emailReceipt":true,"smsReceipt":false},"taxes":[{"taxRate":6,"taxLabel":"Sales Tax"}],"tips":{"enabled":false},"tokenization":true}}],"trainingProvider":"payroc","shipping":{"preferences":{"method":"nextDay","saturdayDelivery":true},"address":{"recipientName":"Sarah Hopper","addressLine1":"1 Example Ave.","city":"Chicago","state":"Illinois","postalCode":"60056","email":"example@mail.com","businessName":"Company Ltd","addressLine2":"Example Address Line 2","phone":"2025550164"}},"paymentIntent":{"paymentIntentType":"purchase","payment":{"payer":"merchant","method":"hostedPaymentPage","frequency":{"type":"singlePayment"}},"costBreakdown":{"items":[{"name":"dx8000","quantity":1,"unitCost":4999}],"shippingCost":599},"subTotal":5598}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Terminal order`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-accounts/38765/terminal-orders" payload := strings.NewReader("{\n \"orderItems\": [\n {\n \"type\": \"solution\",\n \"solutionTemplateId\": \"Roc Services_DX8000\",\n \"solutionQuantity\": 1,\n \"deviceCondition\": \"new\",\n \"solutionSetup\": {\n \"timezone\": \"America/Chicago\",\n \"industryTemplateId\": \"Retail\",\n \"gatewaySettings\": {\n \"merchantPortfolioId\": \"Company Ltd\",\n \"merchantTemplateId\": \"Company Ltd Merchant Template\",\n \"userTemplateId\": \"Company Ltd User Template\",\n \"terminalTemplateId\": \"Company Ltd Terminal Template\"\n },\n \"applicationSettings\": {\n \"clerkPrompt\": false,\n \"security\": {\n \"refundPassword\": true,\n \"keyedSalePassword\": false,\n \"reversalPassword\": true\n }\n },\n \"deviceSettings\": {\n \"numberOfMobileUsers\": 2,\n \"communicationType\": \"wifi\"\n },\n \"batchClosure\": {\n \"batchCloseType\": \"automatic\",\n \"batchCloseTime\": \"23:40\"\n },\n \"receiptNotifications\": {\n \"emailReceipt\": true,\n \"smsReceipt\": false\n },\n \"taxes\": [\n {\n \"taxRate\": 6,\n \"taxLabel\": \"Sales Tax\"\n }\n ],\n \"tips\": {\n \"enabled\": false\n },\n \"tokenization\": true\n }\n }\n ],\n \"trainingProvider\": \"payroc\",\n \"shipping\": {\n \"preferences\": {\n \"method\": \"nextDay\",\n \"saturdayDelivery\": true\n },\n \"address\": {\n \"recipientName\": \"Sarah Hopper\",\n \"addressLine1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"postalCode\": \"60056\",\n \"email\": \"example@mail.com\",\n \"businessName\": \"Company Ltd\",\n \"addressLine2\": \"Example Address Line 2\",\n \"phone\": \"2025550164\"\n }\n },\n \"paymentIntent\": {\n \"paymentIntentType\": \"purchase\",\n \"payment\": {\n \"payer\": \"merchant\",\n \"method\": \"hostedPaymentPage\",\n \"frequency\": {\n \"type\": \"singlePayment\"\n }\n },\n \"costBreakdown\": {\n \"items\": [\n {\n \"name\": \"dx8000\",\n \"quantity\": 1,\n \"unitCost\": 4999\n }\n ],\n \"shippingCost\": 599\n },\n \"subTotal\": 5598\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Terminal order`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-accounts/38765/terminal-orders") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"orderItems\": [\n {\n \"type\": \"solution\",\n \"solutionTemplateId\": \"Roc Services_DX8000\",\n \"solutionQuantity\": 1,\n \"deviceCondition\": \"new\",\n \"solutionSetup\": {\n \"timezone\": \"America/Chicago\",\n \"industryTemplateId\": \"Retail\",\n \"gatewaySettings\": {\n \"merchantPortfolioId\": \"Company Ltd\",\n \"merchantTemplateId\": \"Company Ltd Merchant Template\",\n \"userTemplateId\": \"Company Ltd User Template\",\n \"terminalTemplateId\": \"Company Ltd Terminal Template\"\n },\n \"applicationSettings\": {\n \"clerkPrompt\": false,\n \"security\": {\n \"refundPassword\": true,\n \"keyedSalePassword\": false,\n \"reversalPassword\": true\n }\n },\n \"deviceSettings\": {\n \"numberOfMobileUsers\": 2,\n \"communicationType\": \"wifi\"\n },\n \"batchClosure\": {\n \"batchCloseType\": \"automatic\",\n \"batchCloseTime\": \"23:40\"\n },\n \"receiptNotifications\": {\n \"emailReceipt\": true,\n \"smsReceipt\": false\n },\n \"taxes\": [\n {\n \"taxRate\": 6,\n \"taxLabel\": \"Sales Tax\"\n }\n ],\n \"tips\": {\n \"enabled\": false\n },\n \"tokenization\": true\n }\n }\n ],\n \"trainingProvider\": \"payroc\",\n \"shipping\": {\n \"preferences\": {\n \"method\": \"nextDay\",\n \"saturdayDelivery\": true\n },\n \"address\": {\n \"recipientName\": \"Sarah Hopper\",\n \"addressLine1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"postalCode\": \"60056\",\n \"email\": \"example@mail.com\",\n \"businessName\": \"Company Ltd\",\n \"addressLine2\": \"Example Address Line 2\",\n \"phone\": \"2025550164\"\n }\n },\n \"paymentIntent\": {\n \"paymentIntentType\": \"purchase\",\n \"payment\": {\n \"payer\": \"merchant\",\n \"method\": \"hostedPaymentPage\",\n \"frequency\": {\n \"type\": \"singlePayment\"\n }\n },\n \"costBreakdown\": {\n \"items\": [\n {\n \"name\": \"dx8000\",\n \"quantity\": 1,\n \"unitCost\": 4999\n }\n ],\n \"shippingCost\": 599\n },\n \"subTotal\": 5598\n }\n}" response = http.request(request) puts response.read_body ``` **`Terminal order`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-accounts/38765/terminal-orders") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"orderItems\": [\n {\n \"type\": \"solution\",\n \"solutionTemplateId\": \"Roc Services_DX8000\",\n \"solutionQuantity\": 1,\n \"deviceCondition\": \"new\",\n \"solutionSetup\": {\n \"timezone\": \"America/Chicago\",\n \"industryTemplateId\": \"Retail\",\n \"gatewaySettings\": {\n \"merchantPortfolioId\": \"Company Ltd\",\n \"merchantTemplateId\": \"Company Ltd Merchant Template\",\n \"userTemplateId\": \"Company Ltd User Template\",\n \"terminalTemplateId\": \"Company Ltd Terminal Template\"\n },\n \"applicationSettings\": {\n \"clerkPrompt\": false,\n \"security\": {\n \"refundPassword\": true,\n \"keyedSalePassword\": false,\n \"reversalPassword\": true\n }\n },\n \"deviceSettings\": {\n \"numberOfMobileUsers\": 2,\n \"communicationType\": \"wifi\"\n },\n \"batchClosure\": {\n \"batchCloseType\": \"automatic\",\n \"batchCloseTime\": \"23:40\"\n },\n \"receiptNotifications\": {\n \"emailReceipt\": true,\n \"smsReceipt\": false\n },\n \"taxes\": [\n {\n \"taxRate\": 6,\n \"taxLabel\": \"Sales Tax\"\n }\n ],\n \"tips\": {\n \"enabled\": false\n },\n \"tokenization\": true\n }\n }\n ],\n \"trainingProvider\": \"payroc\",\n \"shipping\": {\n \"preferences\": {\n \"method\": \"nextDay\",\n \"saturdayDelivery\": true\n },\n \"address\": {\n \"recipientName\": \"Sarah Hopper\",\n \"addressLine1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"postalCode\": \"60056\",\n \"email\": \"example@mail.com\",\n \"businessName\": \"Company Ltd\",\n \"addressLine2\": \"Example Address Line 2\",\n \"phone\": \"2025550164\"\n }\n },\n \"paymentIntent\": {\n \"paymentIntentType\": \"purchase\",\n \"payment\": {\n \"payer\": \"merchant\",\n \"method\": \"hostedPaymentPage\",\n \"frequency\": {\n \"type\": \"singlePayment\"\n }\n },\n \"costBreakdown\": {\n \"items\": [\n {\n \"name\": \"dx8000\",\n \"quantity\": 1,\n \"unitCost\": 4999\n }\n ],\n \"shippingCost\": 599\n },\n \"subTotal\": 5598\n }\n}") .asString(); ``` **`Terminal order`** ```php request('POST', 'https://api.payroc.com/v1/processing-accounts/38765/terminal-orders', [ 'body' => '{ "orderItems": [ { "type": "solution", "solutionTemplateId": "Roc Services_DX8000", "solutionQuantity": 1, "deviceCondition": "new", "solutionSetup": { "timezone": "America/Chicago", "industryTemplateId": "Retail", "gatewaySettings": { "merchantPortfolioId": "Company Ltd", "merchantTemplateId": "Company Ltd Merchant Template", "userTemplateId": "Company Ltd User Template", "terminalTemplateId": "Company Ltd Terminal Template" }, "applicationSettings": { "clerkPrompt": false, "security": { "refundPassword": true, "keyedSalePassword": false, "reversalPassword": true } }, "deviceSettings": { "numberOfMobileUsers": 2, "communicationType": "wifi" }, "batchClosure": { "batchCloseType": "automatic", "batchCloseTime": "23:40" }, "receiptNotifications": { "emailReceipt": true, "smsReceipt": false }, "taxes": [ { "taxRate": 6, "taxLabel": "Sales Tax" } ], "tips": { "enabled": false }, "tokenization": true } } ], "trainingProvider": "payroc", "shipping": { "preferences": { "method": "nextDay", "saturdayDelivery": true }, "address": { "recipientName": "Sarah Hopper", "addressLine1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "postalCode": "60056", "email": "example@mail.com", "businessName": "Company Ltd", "addressLine2": "Example Address Line 2", "phone": "2025550164" } }, "paymentIntent": { "paymentIntentType": "purchase", "payment": { "payer": "merchant", "method": "hostedPaymentPage", "frequency": { "type": "singlePayment" } }, "costBreakdown": { "items": [ { "name": "dx8000", "quantity": 1, "unitCost": 4999 } ], "shippingCost": 599 }, "subTotal": 5598 } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Terminal order`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-accounts/38765/terminal-orders"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"orderItems\": [\n {\n \"type\": \"solution\",\n \"solutionTemplateId\": \"Roc Services_DX8000\",\n \"solutionQuantity\": 1,\n \"deviceCondition\": \"new\",\n \"solutionSetup\": {\n \"timezone\": \"America/Chicago\",\n \"industryTemplateId\": \"Retail\",\n \"gatewaySettings\": {\n \"merchantPortfolioId\": \"Company Ltd\",\n \"merchantTemplateId\": \"Company Ltd Merchant Template\",\n \"userTemplateId\": \"Company Ltd User Template\",\n \"terminalTemplateId\": \"Company Ltd Terminal Template\"\n },\n \"applicationSettings\": {\n \"clerkPrompt\": false,\n \"security\": {\n \"refundPassword\": true,\n \"keyedSalePassword\": false,\n \"reversalPassword\": true\n }\n },\n \"deviceSettings\": {\n \"numberOfMobileUsers\": 2,\n \"communicationType\": \"wifi\"\n },\n \"batchClosure\": {\n \"batchCloseType\": \"automatic\",\n \"batchCloseTime\": \"23:40\"\n },\n \"receiptNotifications\": {\n \"emailReceipt\": true,\n \"smsReceipt\": false\n },\n \"taxes\": [\n {\n \"taxRate\": 6,\n \"taxLabel\": \"Sales Tax\"\n }\n ],\n \"tips\": {\n \"enabled\": false\n },\n \"tokenization\": true\n }\n }\n ],\n \"trainingProvider\": \"payroc\",\n \"shipping\": {\n \"preferences\": {\n \"method\": \"nextDay\",\n \"saturdayDelivery\": true\n },\n \"address\": {\n \"recipientName\": \"Sarah Hopper\",\n \"addressLine1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"postalCode\": \"60056\",\n \"email\": \"example@mail.com\",\n \"businessName\": \"Company Ltd\",\n \"addressLine2\": \"Example Address Line 2\",\n \"phone\": \"2025550164\"\n }\n },\n \"paymentIntent\": {\n \"paymentIntentType\": \"purchase\",\n \"payment\": {\n \"payer\": \"merchant\",\n \"method\": \"hostedPaymentPage\",\n \"frequency\": {\n \"type\": \"singlePayment\"\n }\n },\n \"costBreakdown\": {\n \"items\": [\n {\n \"name\": \"dx8000\",\n \"quantity\": 1,\n \"unitCost\": 4999\n }\n ],\n \"shippingCost\": 599\n },\n \"subTotal\": 5598\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Terminal order`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "orderItems": [ [ "type": "solution", "solutionTemplateId": "Roc Services_DX8000", "solutionQuantity": 1, "deviceCondition": "new", "solutionSetup": [ "timezone": "America/Chicago", "industryTemplateId": "Retail", "gatewaySettings": [ "merchantPortfolioId": "Company Ltd", "merchantTemplateId": "Company Ltd Merchant Template", "userTemplateId": "Company Ltd User Template", "terminalTemplateId": "Company Ltd Terminal Template" ], "applicationSettings": [ "clerkPrompt": false, "security": [ "refundPassword": true, "keyedSalePassword": false, "reversalPassword": true ] ], "deviceSettings": [ "numberOfMobileUsers": 2, "communicationType": "wifi" ], "batchClosure": [ "batchCloseType": "automatic", "batchCloseTime": "23:40" ], "receiptNotifications": [ "emailReceipt": true, "smsReceipt": false ], "taxes": [ [ "taxRate": 6, "taxLabel": "Sales Tax" ] ], "tips": ["enabled": false], "tokenization": true ] ] ], "trainingProvider": "payroc", "shipping": [ "preferences": [ "method": "nextDay", "saturdayDelivery": true ], "address": [ "recipientName": "Sarah Hopper", "addressLine1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "postalCode": "60056", "email": "example@mail.com", "businessName": "Company Ltd", "addressLine2": "Example Address Line 2", "phone": "2025550164" ] ], "paymentIntent": [ "paymentIntentType": "purchase", "payment": [ "payer": "merchant", "method": "hostedPaymentPage", "frequency": ["type": "singlePayment"] ], "costBreakdown": [ "items": [ [ "name": "dx8000", "quantity": 1, "unitCost": 4999 ] ], "shippingCost": 599 ], "subTotal": 5598 ] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-accounts/38765/terminal-orders")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If the request is successful, we create the terminal order and return the following response: **Status code 201** Successful request. We created the terminal order. ### Schema (`response.body`) [Response body schema for `POST /processing-accounts/{processingAccountId}/terminal-orders`](/api/create-terminal-order) ### Example response ### Response (201) ```json { "terminalOrderId": "2346", "status": "open", "orderItems": [ { "type": "solution", "solutionTemplateId": "Roc Services_DX8000", "solutionQuantity": 1, "deviceCondition": "new", "solutionSetup": { "timezone": "America/Chicago", "industryTemplateId": "Retail", "gatewaySettings": { "merchantPortfolioId": "Example Corp", "merchantTemplateId": "Example Corp Merchant Template", "userTemplateId": "Example Corp User Template", "terminalTemplateId": "Example Corp Terminal Template" }, "applicationSettings": { "clerkPrompt": false, "security": { "refundPassword": true, "keyedSalePassword": false, "reversalPassword": true } }, "deviceSettings": { "numberOfMobileUsers": 2, "communicationType": "wifi" }, "batchClosure": { "batchCloseType": "automatic", "batchCloseTime": "23:40" }, "receiptNotifications": { "emailReceipt": true, "smsReceipt": false }, "taxes": [ { "taxRate": 6, "taxLabel": "Sales Tax" } ], "tips": { "enabled": false }, "tokenization": true } } ], "createdDate": "2024-07-02T12:00:00.000+00:00", "lastModifiedDate": "2024-07-02T12:00:00.000+00:00", "trainingProvider": "payroc", "shipping": { "preferences": { "method": "nextDay", "saturdayDelivery": true }, "address": { "recipientName": "Jane Doe", "addressLine1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "postalCode": "60056", "email": "jane.doe@example.com", "businessName": "Example Corp", "addressLine2": "Example Address Line 2", "phone": "2025550164" } } } ``` # Create a pricing intent Source: https://docs.payroc.com/guides/boarding/pricing-intent Create a pricing intent by sending a POST request to the Pricing Intents endpoint, defining base fees, processor fees, and gateway fees to use as a reusable template for merchant processing accounts. **Prerequisites:** [Authentication](/api/authentication) A pricing intent is a template of fees that you apply to processing accounts when you board merchants. You can apply the same pricing intent to all processing accounts that you create or create multiple pricing intents to apply to different processing accounts. A pricing intent can include the following fee types: - **Base fees:** For monthly maintenance, chargebacks, and early contract termination. All pricing intents must include base fees. - **Processor fees:** For card payments and Automated Clearing House (ACH) payments. Processor fees also include the pricing model that you offer to the merchant, for example, RewardPay. - **Gateway fees:** For using our payment gateway. ## Integration steps - Create a pricing intent. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Create a pricing intent Send a POST request to our Pricing Intents endpoint: **Endpoint:** `https://api.payroc.com/v1/pricing-intents` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /pricing-intents`](/api/create-pricing-intent) ### Example request ### Request POST [https://api.payroc.com/v1/pricing-intents](https://api.payroc.com/v1/pricing-intents) **`Created pricing intent`** ```curl curl -X POST https://api.payroc.com/v1/pricing-intents \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " ``` **`Created pricing intent`** ```python import requests url = "https://api.payroc.com/v1/pricing-intents" headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer " } response = requests.post(url, headers=headers) print(response.json()) ``` **`Created pricing intent`** ```javascript const url = 'https://api.payroc.com/v1/pricing-intents'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ' } }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Created pricing intent`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/pricing-intents" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Created pricing intent`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/pricing-intents") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Created pricing intent`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/pricing-intents") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .asString(); ``` **`Created pricing intent`** ```php request('POST', 'https://api.payroc.com/v1/pricing-intents', [ 'headers' => [ 'Authorization' => 'Bearer ', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Created pricing intent`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/pricing-intents"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Created pricing intent`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer " ] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/pricing-intents")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway creates the pricing intent. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /pricing-intents`](/api/create-pricing-intent) ### Example response ### Response (201) ```json { "base": { "addressVerification": 5, "annualFee": { "amount": 100, "billInMonth": "june" }, "batch": 1000, "chargeback": 2500, "earlyTermination": 57500, "maintenance": 500, "minimum": 100, "pciNonCompliance": 4995, "platinumSecurity": { "amount": 1295, "billingFrequency": "monthly" }, "regulatoryAssistanceProgram": 15, "retrieval": 1500, "voiceAuthorization": 95 }, "country": "US", "createdDate": "2024-07-02T09:00:00Z", "gateway": { "fees": { "monthly": 2000, "perDeviceMonthly": 10, "perTransaction": 2000, "setup": 5000 } }, "id": "5", "key": "Your-Unique-Identifier", "lastUpdatedDate": "2024-07-02T09:00:00Z", "metadata": { "yourCustomField": "abc123" }, "processor": { "ach": { "fees": { "accountVerification": 100, "batch": 1000, "discountRateAbove10000": 10, "discountRateUnder10000": 5.25, "monthlyMinimum": 20000, "returns": 400, "statement": 800, "transaction": 50, "unauthorizedReturn": 1999 } }, "card": { "fees": { "amex": { "transaction": 5, "type": "optBlue", "volume": 1.25 }, "electronicBenefitsTransfer": { "transaction": 10 }, "mastercardVisaDiscover": { "transaction": 5, "volume": 1.25 }, "pinDebit": { "additionalDiscount": 1.25, "monthlyAccess": 1200, "transaction": 10 }, "specialityCards": { "transaction": 10 } }, "planType": "interchangePlus" } }, "services": [ { "enabled": true, "name": "hardwareAdvantagePlan" } ], "status": "pendingReview", "version": "5.2" } ``` # Add a processing account to a merchant platform Source: https://docs.payroc.com/guides/boarding/processing-account-create Add a processing account to an existing merchant platform by sending a POST request to the Merchant Platforms endpoint with business, owner, processing, and pricing details. **Prerequisites:** [Authentication](/api/authentication) · [Create a merchant platform](/guides/boarding/merchant-platform) **Important:** You must create a merchant platform before you can add additional processing accounts. Each merchant platform includes one or more processing accounts that run transactions for the business. To create a processing account, you must provide the following types of information: - **Business details** including the Merchant Category Code (MCC), Doing Business As (DBA) name, and address of the business. - **Owners’ details** including their names, addresses, and contact details. You must assign a control prong who is responsible for their account. - **Processing details** including estimated average transaction amounts and monthly processing amounts. - **Pricing and funding details** including pricing agreements and funding accounts for the processing account. **Note:** You can add more than one processing account in the same request. ## Integration steps **Step 1.** Create a processing account **Step 2.** (Optional) Create a reminder ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Create a processing account Send a POST request with the merchantPlatformId to our Merchant Platform endpoint: **Endpoint:** `https://api.payroc.com/v1/merchant-platforms/{merchantPlatformId}/processing-accounts` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /merchant-platforms/{merchantPlatformId}/processing-accounts`](/api/create-processing-account) ### Example request ### Request POST [https://api.payroc.com/v1/merchant-platforms/\{merchantPlatformId\}/processing-accounts](https://api.payroc.com/v1/merchant-platforms/%7BmerchantPlatformId%7D/processing-accounts) **`Create processing account`** ```curl curl -X POST https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "doingBusinessAs": "Pizza Doe", "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "relationship": { "isControlProng": true, "equityPercentage": 51.5, "title": "CFO", "isAuthorizedSignatory": false }, "middleName": "Helen" } ], "merchandiseOrServiceSold": "Pizza", "businessStartDate": "2020-01-01", "timezone": "America/Chicago", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "processing": { "transactionAmounts": { "average": 5000, "highest": 10000 }, "monthlyAmounts": { "average": 50000, "highest": 100000 }, "volumeBreakdown": { "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 }, "isSeasonal": true, "monthsOfOperation": [ "jan", "feb" ], "ach": { "refunds": { "writtenRefundPolicy": true, "refundPolicyUrl": "http://www.example.com/refunds" }, "estimatedMonthlyTransactions": 3000, "limits": { "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 }, "naics": "5812", "previouslyTerminatedForAch": false, "transactionTypes": [ "prearrangedPayment", "other" ], "transactionTypesOther": "recurringBilling" }, "cardAcceptance": { "debitOnly": false, "hsaFsa": false, "cardsAccepted": [ "visa", "mastercard" ], "specialityCards": { "americanExpressDirect": { "enabled": true, "merchantNumber": "abc1234567" }, "electronicBenefitsTransfer": { "enabled": true, "fnsNumber": "6789012" }, "other": { "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" } } } }, "funding": { "fundingSchedule": "nextday", "acceleratedFundingFee": 1999, "dailyDiscount": false, "fundingAccounts": [ { "type": "checking", "use": "creditAndDebit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ], "metadata": { "yourCustomField": "abc123" } } ] }, "pricing": { "type": "intent", "pricingIntentId": "6123" }, "signature": { "type": "requestedViaDirectLink" }, "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "contacts": [ { "type": "manager", "firstName": "Jane", "lastName": "Doe", "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "middleName": "Helen", "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ] } ], "metadata": { "customerId": "2345" } }' ``` **`Create processing account`** ```python import requests url = "https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts" payload = { "doingBusinessAs": "Pizza Doe", "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "relationship": { "isControlProng": True, "equityPercentage": 51.5, "title": "CFO", "isAuthorizedSignatory": False }, "middleName": "Helen" } ], "merchandiseOrServiceSold": "Pizza", "businessStartDate": "2020-01-01", "timezone": "America/Chicago", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "processing": { "transactionAmounts": { "average": 5000, "highest": 10000 }, "monthlyAmounts": { "average": 50000, "highest": 100000 }, "volumeBreakdown": { "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 }, "isSeasonal": True, "monthsOfOperation": ["jan", "feb"], "ach": { "refunds": { "writtenRefundPolicy": True, "refundPolicyUrl": "http://www.example.com/refunds" }, "estimatedMonthlyTransactions": 3000, "limits": { "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 }, "naics": "5812", "previouslyTerminatedForAch": False, "transactionTypes": ["prearrangedPayment", "other"], "transactionTypesOther": "recurringBilling" }, "cardAcceptance": { "debitOnly": False, "hsaFsa": False, "cardsAccepted": ["visa", "mastercard"], "specialityCards": { "americanExpressDirect": { "enabled": True, "merchantNumber": "abc1234567" }, "electronicBenefitsTransfer": { "enabled": True, "fnsNumber": "6789012" }, "other": { "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" } } } }, "funding": { "fundingSchedule": "nextday", "acceleratedFundingFee": 1999, "dailyDiscount": False, "fundingAccounts": [ { "type": "checking", "use": "creditAndDebit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ], "metadata": { "yourCustomField": "abc123" } } ] }, "pricing": { "type": "intent", "pricingIntentId": "6123" }, "signature": { "type": "requestedViaDirectLink" }, "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "contacts": [ { "type": "manager", "firstName": "Jane", "lastName": "Doe", "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "middleName": "Helen", "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ] } ], "metadata": { "customerId": "2345" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create processing account`** ```javascript const url = 'https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"doingBusinessAs":"Pizza Doe","owners":[{"firstName":"Jane","lastName":"Doe","dateOfBirth":"1964-03-22","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056","address2":"Example Address Line 2","address3":"Example Address Line 3"},"identifiers":[{"type":"nationalId","value":"000-00-4320"}],"contactMethods":[{"type":"email","value":"jane.doe@example.com"}],"relationship":{"isControlProng":true,"equityPercentage":51.5,"title":"CFO","isAuthorizedSignatory":false},"middleName":"Helen"}],"merchandiseOrServiceSold":"Pizza","businessStartDate":"2020-01-01","timezone":"America/Chicago","address":{"address1":"1 Example Ave.","address2":"Example Address Line 2","address3":"Example Address Line 3","city":"Chicago","country":"US","postalCode":"60056","state":"Illinois"},"contactMethods":[{"type":"email","value":"jane.doe@example.com"}],"processing":{"transactionAmounts":{"average":5000,"highest":10000},"monthlyAmounts":{"average":50000,"highest":100000},"volumeBreakdown":{"cardPresent":77,"mailOrTelephone":3,"ecommerce":20},"isSeasonal":true,"monthsOfOperation":["jan","feb"],"ach":{"refunds":{"writtenRefundPolicy":true,"refundPolicyUrl":"http://www.example.com/refunds"},"estimatedMonthlyTransactions":3000,"limits":{"singleTransaction":10000,"dailyDeposit":200000,"monthlyDeposit":6000000},"naics":"5812","previouslyTerminatedForAch":false,"transactionTypes":["prearrangedPayment","other"],"transactionTypesOther":"recurringBilling"},"cardAcceptance":{"debitOnly":false,"hsaFsa":false,"cardsAccepted":["visa","mastercard"],"specialityCards":{"americanExpressDirect":{"enabled":true,"merchantNumber":"abc1234567"},"electronicBenefitsTransfer":{"enabled":true,"fnsNumber":"6789012"},"other":{"wexMerchantNumber":"abc1234567","voyagerMerchantId":"abc1234567","fleetMerchantId":"abc1234567"}}}},"funding":{"fundingSchedule":"nextday","acceleratedFundingFee":1999,"dailyDiscount":false,"fundingAccounts":[{"type":"checking","use":"creditAndDebit","nameOnAccount":"Jane Doe","paymentMethods":[{"type":"ach","value":{"routingNumber":"123456789","accountNumber":"1234567890"}}],"metadata":{"yourCustomField":"abc123"}}]},"pricing":{"type":"intent","pricingIntentId":"6123"},"signature":{"type":"requestedViaDirectLink"},"website":"www.example.com","businessType":"restaurant","categoryCode":5999,"processor":"tsys","contacts":[{"type":"manager","firstName":"Jane","lastName":"Doe","contactMethods":[{"type":"email","value":"jane.doe@example.com"}],"middleName":"Helen","identifiers":[{"type":"nationalId","value":"000-00-4320"}]}],"metadata":{"customerId":"2345"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create processing account`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts" payload := strings.NewReader("{\n \"doingBusinessAs\": \"Pizza Doe\",\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 51.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"merchandiseOrServiceSold\": \"Pizza\",\n \"businessStartDate\": \"2020-01-01\",\n \"timezone\": \"America/Chicago\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"processing\": {\n \"transactionAmounts\": {\n \"average\": 5000,\n \"highest\": 10000\n },\n \"monthlyAmounts\": {\n \"average\": 50000,\n \"highest\": 100000\n },\n \"volumeBreakdown\": {\n \"cardPresent\": 77,\n \"mailOrTelephone\": 3,\n \"ecommerce\": 20\n },\n \"isSeasonal\": true,\n \"monthsOfOperation\": [\n \"jan\",\n \"feb\"\n ],\n \"ach\": {\n \"refunds\": {\n \"writtenRefundPolicy\": true,\n \"refundPolicyUrl\": \"http://www.example.com/refunds\"\n },\n \"estimatedMonthlyTransactions\": 3000,\n \"limits\": {\n \"singleTransaction\": 10000,\n \"dailyDeposit\": 200000,\n \"monthlyDeposit\": 6000000\n },\n \"naics\": \"5812\",\n \"previouslyTerminatedForAch\": false,\n \"transactionTypes\": [\n \"prearrangedPayment\",\n \"other\"\n ],\n \"transactionTypesOther\": \"recurringBilling\"\n },\n \"cardAcceptance\": {\n \"debitOnly\": false,\n \"hsaFsa\": false,\n \"cardsAccepted\": [\n \"visa\",\n \"mastercard\"\n ],\n \"specialityCards\": {\n \"americanExpressDirect\": {\n \"enabled\": true,\n \"merchantNumber\": \"abc1234567\"\n },\n \"electronicBenefitsTransfer\": {\n \"enabled\": true,\n \"fnsNumber\": \"6789012\"\n },\n \"other\": {\n \"wexMerchantNumber\": \"abc1234567\",\n \"voyagerMerchantId\": \"abc1234567\",\n \"fleetMerchantId\": \"abc1234567\"\n }\n }\n }\n },\n \"funding\": {\n \"fundingSchedule\": \"nextday\",\n \"acceleratedFundingFee\": 1999,\n \"dailyDiscount\": false,\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"creditAndDebit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n },\n \"pricing\": {\n \"type\": \"intent\",\n \"pricingIntentId\": \"6123\"\n },\n \"signature\": {\n \"type\": \"requestedViaDirectLink\"\n },\n \"website\": \"www.example.com\",\n \"businessType\": \"restaurant\",\n \"categoryCode\": 5999,\n \"processor\": \"tsys\",\n \"contacts\": [\n {\n \"type\": \"manager\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"middleName\": \"Helen\",\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ]\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create processing account`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"doingBusinessAs\": \"Pizza Doe\",\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 51.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"merchandiseOrServiceSold\": \"Pizza\",\n \"businessStartDate\": \"2020-01-01\",\n \"timezone\": \"America/Chicago\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"processing\": {\n \"transactionAmounts\": {\n \"average\": 5000,\n \"highest\": 10000\n },\n \"monthlyAmounts\": {\n \"average\": 50000,\n \"highest\": 100000\n },\n \"volumeBreakdown\": {\n \"cardPresent\": 77,\n \"mailOrTelephone\": 3,\n \"ecommerce\": 20\n },\n \"isSeasonal\": true,\n \"monthsOfOperation\": [\n \"jan\",\n \"feb\"\n ],\n \"ach\": {\n \"refunds\": {\n \"writtenRefundPolicy\": true,\n \"refundPolicyUrl\": \"http://www.example.com/refunds\"\n },\n \"estimatedMonthlyTransactions\": 3000,\n \"limits\": {\n \"singleTransaction\": 10000,\n \"dailyDeposit\": 200000,\n \"monthlyDeposit\": 6000000\n },\n \"naics\": \"5812\",\n \"previouslyTerminatedForAch\": false,\n \"transactionTypes\": [\n \"prearrangedPayment\",\n \"other\"\n ],\n \"transactionTypesOther\": \"recurringBilling\"\n },\n \"cardAcceptance\": {\n \"debitOnly\": false,\n \"hsaFsa\": false,\n \"cardsAccepted\": [\n \"visa\",\n \"mastercard\"\n ],\n \"specialityCards\": {\n \"americanExpressDirect\": {\n \"enabled\": true,\n \"merchantNumber\": \"abc1234567\"\n },\n \"electronicBenefitsTransfer\": {\n \"enabled\": true,\n \"fnsNumber\": \"6789012\"\n },\n \"other\": {\n \"wexMerchantNumber\": \"abc1234567\",\n \"voyagerMerchantId\": \"abc1234567\",\n \"fleetMerchantId\": \"abc1234567\"\n }\n }\n }\n },\n \"funding\": {\n \"fundingSchedule\": \"nextday\",\n \"acceleratedFundingFee\": 1999,\n \"dailyDiscount\": false,\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"creditAndDebit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n },\n \"pricing\": {\n \"type\": \"intent\",\n \"pricingIntentId\": \"6123\"\n },\n \"signature\": {\n \"type\": \"requestedViaDirectLink\"\n },\n \"website\": \"www.example.com\",\n \"businessType\": \"restaurant\",\n \"categoryCode\": 5999,\n \"processor\": \"tsys\",\n \"contacts\": [\n {\n \"type\": \"manager\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"middleName\": \"Helen\",\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ]\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Create processing account`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"doingBusinessAs\": \"Pizza Doe\",\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 51.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"merchandiseOrServiceSold\": \"Pizza\",\n \"businessStartDate\": \"2020-01-01\",\n \"timezone\": \"America/Chicago\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"processing\": {\n \"transactionAmounts\": {\n \"average\": 5000,\n \"highest\": 10000\n },\n \"monthlyAmounts\": {\n \"average\": 50000,\n \"highest\": 100000\n },\n \"volumeBreakdown\": {\n \"cardPresent\": 77,\n \"mailOrTelephone\": 3,\n \"ecommerce\": 20\n },\n \"isSeasonal\": true,\n \"monthsOfOperation\": [\n \"jan\",\n \"feb\"\n ],\n \"ach\": {\n \"refunds\": {\n \"writtenRefundPolicy\": true,\n \"refundPolicyUrl\": \"http://www.example.com/refunds\"\n },\n \"estimatedMonthlyTransactions\": 3000,\n \"limits\": {\n \"singleTransaction\": 10000,\n \"dailyDeposit\": 200000,\n \"monthlyDeposit\": 6000000\n },\n \"naics\": \"5812\",\n \"previouslyTerminatedForAch\": false,\n \"transactionTypes\": [\n \"prearrangedPayment\",\n \"other\"\n ],\n \"transactionTypesOther\": \"recurringBilling\"\n },\n \"cardAcceptance\": {\n \"debitOnly\": false,\n \"hsaFsa\": false,\n \"cardsAccepted\": [\n \"visa\",\n \"mastercard\"\n ],\n \"specialityCards\": {\n \"americanExpressDirect\": {\n \"enabled\": true,\n \"merchantNumber\": \"abc1234567\"\n },\n \"electronicBenefitsTransfer\": {\n \"enabled\": true,\n \"fnsNumber\": \"6789012\"\n },\n \"other\": {\n \"wexMerchantNumber\": \"abc1234567\",\n \"voyagerMerchantId\": \"abc1234567\",\n \"fleetMerchantId\": \"abc1234567\"\n }\n }\n }\n },\n \"funding\": {\n \"fundingSchedule\": \"nextday\",\n \"acceleratedFundingFee\": 1999,\n \"dailyDiscount\": false,\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"creditAndDebit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n },\n \"pricing\": {\n \"type\": \"intent\",\n \"pricingIntentId\": \"6123\"\n },\n \"signature\": {\n \"type\": \"requestedViaDirectLink\"\n },\n \"website\": \"www.example.com\",\n \"businessType\": \"restaurant\",\n \"categoryCode\": 5999,\n \"processor\": \"tsys\",\n \"contacts\": [\n {\n \"type\": \"manager\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"middleName\": \"Helen\",\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ]\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n}") .asString(); ``` **`Create processing account`** ```php request('POST', 'https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts', [ 'body' => '{ "doingBusinessAs": "Pizza Doe", "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "relationship": { "isControlProng": true, "equityPercentage": 51.5, "title": "CFO", "isAuthorizedSignatory": false }, "middleName": "Helen" } ], "merchandiseOrServiceSold": "Pizza", "businessStartDate": "2020-01-01", "timezone": "America/Chicago", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "processing": { "transactionAmounts": { "average": 5000, "highest": 10000 }, "monthlyAmounts": { "average": 50000, "highest": 100000 }, "volumeBreakdown": { "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 }, "isSeasonal": true, "monthsOfOperation": [ "jan", "feb" ], "ach": { "refunds": { "writtenRefundPolicy": true, "refundPolicyUrl": "http://www.example.com/refunds" }, "estimatedMonthlyTransactions": 3000, "limits": { "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 }, "naics": "5812", "previouslyTerminatedForAch": false, "transactionTypes": [ "prearrangedPayment", "other" ], "transactionTypesOther": "recurringBilling" }, "cardAcceptance": { "debitOnly": false, "hsaFsa": false, "cardsAccepted": [ "visa", "mastercard" ], "specialityCards": { "americanExpressDirect": { "enabled": true, "merchantNumber": "abc1234567" }, "electronicBenefitsTransfer": { "enabled": true, "fnsNumber": "6789012" }, "other": { "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" } } } }, "funding": { "fundingSchedule": "nextday", "acceleratedFundingFee": 1999, "dailyDiscount": false, "fundingAccounts": [ { "type": "checking", "use": "creditAndDebit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ], "metadata": { "yourCustomField": "abc123" } } ] }, "pricing": { "type": "intent", "pricingIntentId": "6123" }, "signature": { "type": "requestedViaDirectLink" }, "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "contacts": [ { "type": "manager", "firstName": "Jane", "lastName": "Doe", "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "middleName": "Helen", "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ] } ], "metadata": { "customerId": "2345" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create processing account`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"doingBusinessAs\": \"Pizza Doe\",\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 51.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"merchandiseOrServiceSold\": \"Pizza\",\n \"businessStartDate\": \"2020-01-01\",\n \"timezone\": \"America/Chicago\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"processing\": {\n \"transactionAmounts\": {\n \"average\": 5000,\n \"highest\": 10000\n },\n \"monthlyAmounts\": {\n \"average\": 50000,\n \"highest\": 100000\n },\n \"volumeBreakdown\": {\n \"cardPresent\": 77,\n \"mailOrTelephone\": 3,\n \"ecommerce\": 20\n },\n \"isSeasonal\": true,\n \"monthsOfOperation\": [\n \"jan\",\n \"feb\"\n ],\n \"ach\": {\n \"refunds\": {\n \"writtenRefundPolicy\": true,\n \"refundPolicyUrl\": \"http://www.example.com/refunds\"\n },\n \"estimatedMonthlyTransactions\": 3000,\n \"limits\": {\n \"singleTransaction\": 10000,\n \"dailyDeposit\": 200000,\n \"monthlyDeposit\": 6000000\n },\n \"naics\": \"5812\",\n \"previouslyTerminatedForAch\": false,\n \"transactionTypes\": [\n \"prearrangedPayment\",\n \"other\"\n ],\n \"transactionTypesOther\": \"recurringBilling\"\n },\n \"cardAcceptance\": {\n \"debitOnly\": false,\n \"hsaFsa\": false,\n \"cardsAccepted\": [\n \"visa\",\n \"mastercard\"\n ],\n \"specialityCards\": {\n \"americanExpressDirect\": {\n \"enabled\": true,\n \"merchantNumber\": \"abc1234567\"\n },\n \"electronicBenefitsTransfer\": {\n \"enabled\": true,\n \"fnsNumber\": \"6789012\"\n },\n \"other\": {\n \"wexMerchantNumber\": \"abc1234567\",\n \"voyagerMerchantId\": \"abc1234567\",\n \"fleetMerchantId\": \"abc1234567\"\n }\n }\n }\n },\n \"funding\": {\n \"fundingSchedule\": \"nextday\",\n \"acceleratedFundingFee\": 1999,\n \"dailyDiscount\": false,\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"creditAndDebit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n },\n \"pricing\": {\n \"type\": \"intent\",\n \"pricingIntentId\": \"6123\"\n },\n \"signature\": {\n \"type\": \"requestedViaDirectLink\"\n },\n \"website\": \"www.example.com\",\n \"businessType\": \"restaurant\",\n \"categoryCode\": 5999,\n \"processor\": \"tsys\",\n \"contacts\": [\n {\n \"type\": \"manager\",\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n }\n ],\n \"middleName\": \"Helen\",\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ]\n }\n ],\n \"metadata\": {\n \"customerId\": \"2345\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create processing account`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "doingBusinessAs": "Pizza Doe", "owners": [ [ "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056", "address2": "Example Address Line 2", "address3": "Example Address Line 3" ], "identifiers": [ [ "type": "nationalId", "value": "000-00-4320" ] ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ] ], "relationship": [ "isControlProng": true, "equityPercentage": 51.5, "title": "CFO", "isAuthorizedSignatory": false ], "middleName": "Helen" ] ], "merchandiseOrServiceSold": "Pizza", "businessStartDate": "2020-01-01", "timezone": "America/Chicago", "address": [ "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ] ], "processing": [ "transactionAmounts": [ "average": 5000, "highest": 10000 ], "monthlyAmounts": [ "average": 50000, "highest": 100000 ], "volumeBreakdown": [ "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 ], "isSeasonal": true, "monthsOfOperation": ["jan", "feb"], "ach": [ "refunds": [ "writtenRefundPolicy": true, "refundPolicyUrl": "http://www.example.com/refunds" ], "estimatedMonthlyTransactions": 3000, "limits": [ "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 ], "naics": "5812", "previouslyTerminatedForAch": false, "transactionTypes": ["prearrangedPayment", "other"], "transactionTypesOther": "recurringBilling" ], "cardAcceptance": [ "debitOnly": false, "hsaFsa": false, "cardsAccepted": ["visa", "mastercard"], "specialityCards": [ "americanExpressDirect": [ "enabled": true, "merchantNumber": "abc1234567" ], "electronicBenefitsTransfer": [ "enabled": true, "fnsNumber": "6789012" ], "other": [ "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" ] ] ] ], "funding": [ "fundingSchedule": "nextday", "acceleratedFundingFee": 1999, "dailyDiscount": false, "fundingAccounts": [ [ "type": "checking", "use": "creditAndDebit", "nameOnAccount": "Jane Doe", "paymentMethods": [ [ "type": "ach", "value": [ "routingNumber": "123456789", "accountNumber": "1234567890" ] ] ], "metadata": ["yourCustomField": "abc123"] ] ] ], "pricing": [ "type": "intent", "pricingIntentId": "6123" ], "signature": ["type": "requestedViaDirectLink"], "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "contacts": [ [ "type": "manager", "firstName": "Jane", "lastName": "Doe", "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ] ], "middleName": "Helen", "identifiers": [ [ "type": "nationalId", "value": "000-00-4320" ] ] ] ], "metadata": ["customerId": "2345"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/merchant-platforms/12345/processing-accounts")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway creates the processing account. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /merchant-platforms/{merchantPlatformId}/processing-accounts`](/api/create-processing-account) ### Example response ### Response (201) ```json { "doingBusinessAs": "Pizza Doe", "owners": [ { "ownerId": 4564, "firstName": "Jane", "lastName": "Doe", "link": { "rel": "owner", "href": "https://api.payroc.com/v1/owners/4564", "method": "get" } } ], "merchandiseOrServiceSold": "Pizza", "timezone": "America/Chicago", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" } ], "processing": { "transactionAmounts": { "average": 5000, "highest": 10000 }, "monthlyAmounts": { "average": 50000, "highest": 100000 }, "volumeBreakdown": { "cardPresent": 77, "mailOrTelephone": 3, "ecommerce": 20 }, "isSeasonal": true, "monthsOfOperation": [ "jan", "feb" ], "ach": { "refunds": { "writtenRefundPolicy": true, "refundPolicyUrl": "http://www.example.com/refunds" }, "estimatedMonthlyTransactions": 3000, "limits": { "singleTransaction": 10000, "dailyDeposit": 200000, "monthlyDeposit": 6000000 }, "naics": "5812", "previouslyTerminatedForAch": false, "transactionTypes": [ "prearrangedPayment", "other" ], "transactionTypesOther": "recurringBilling" }, "cardAcceptance": { "debitOnly": false, "hsaFsa": false, "cardsAccepted": [ "visa", "mastercard" ], "specialityCards": { "americanExpressDirect": { "enabled": true, "merchantNumber": "abc1234567" }, "electronicBenefitsTransfer": { "enabled": true, "fnsNumber": "6789012" }, "other": { "wexMerchantNumber": "abc1234567", "voyagerMerchantId": "abc1234567", "fleetMerchantId": "abc1234567" } } } }, "funding": { "acceleratedFundingFee": 1999, "dailyDiscount": false, "fundingAccounts": [ { "fundingAccountId": 123, "status": "pending", "link": { "rel": "fundingAccount", "method": "get", "href": "https://api.payroc.com/v1/funding-accounts/123" } } ], "fundingSchedule": "nextday", "status": "enabled" }, "pricing": { "link": { "rel": "pricing", "href": "https://api.payroc.com/v1/processing-accounts/12345/pricing", "method": "get" } }, "signature": { "type": "requestedViaDirectLink", "link": { "rel": "agreement", "method": "get", "href": "https://us.agreementexpress.net/mv2/viewer2.jsp?docId=00000000-0000-0000-0000-000000000000" } }, "addendums": [], "processingAccountId": "38765", "createdDate": "2024-07-02T12:00:00.000+00:00", "lastModifiedDate": "2024-07-02T12:00:00.000+00:00", "status": "entered", "website": "www.example.com", "businessType": "restaurant", "categoryCode": 5999, "processor": "tsys", "businessStartDate": "2020-01-01", "contacts": [ { "contactId": 1543, "firstName": "Jane", "lastName": "Doe", "link": { "rel": "contact", "href": "https://api.payroc.com/v1/contacts/1543", "method": "get" } } ], "metadata": { "customerId": "2345" } } ``` ## Step 2. (Optional) Create a reminder If you requested the merchant’s signature by email and they don’t respond, use our Reminders endpoint to send another email. **Important:** You can use the Reminders endpoint only if you request the merchant’s signature by email. If you generate a link to the pricing agreement, you can’t use the Reminders endpoint. **Endpoint:** `https://api.payroc.com/v1/processing-accounts/{processingAccountId}/reminders` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /processing-accounts/{processingAccountId}/reminders`](/api/create-reminder) ### Example request ### Request POST [https://api.payroc.com/v1/processing-accounts/\{processingAccountId\}/reminders](https://api.payroc.com/v1/processing-accounts/%7BprocessingAccountId%7D/reminders) **`Create reminder for processing account`** ```curl curl -X POST https://api.payroc.com/v1/processing-accounts/38765/reminders \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "type": "pricingAgreement" }' ``` **`Create reminder for processing account`** ```python import requests url = "https://api.payroc.com/v1/processing-accounts/38765/reminders" payload = { "type": "pricingAgreement" } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create reminder for processing account`** ```javascript const url = 'https://api.payroc.com/v1/processing-accounts/38765/reminders'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"type":"pricingAgreement"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create reminder for processing account`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/processing-accounts/38765/reminders" payload := strings.NewReader("{\n \"type\": \"pricingAgreement\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create reminder for processing account`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/processing-accounts/38765/reminders") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"type\": \"pricingAgreement\"\n}" response = http.request(request) puts response.read_body ``` **`Create reminder for processing account`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/processing-accounts/38765/reminders") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"type\": \"pricingAgreement\"\n}") .asString(); ``` **`Create reminder for processing account`** ```php request('POST', 'https://api.payroc.com/v1/processing-accounts/38765/reminders', [ 'body' => '{ "type": "pricingAgreement" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create reminder for processing account`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/processing-accounts/38765/reminders"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"type\": \"pricingAgreement\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create reminder for processing account`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["type": "pricingAgreement"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/processing-accounts/38765/reminders")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, our gateway creates the reminder and sends the email to the merchant. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /processing-accounts/{processingAccountId}/reminders`](/api/create-reminder) ### Example response ### Response (201) ```json { "type": "pricingAgreement", "reminderId": "1234567" } ``` # Event subscriptions Source: https://docs.payroc.com/guides/events Subscribe to account changes and handle webhook notifications sent by our gateway. **Prerequisites:** [Authentication](/api/authentication) Event subscriptions are a feature of our API that you can subscribe to so that we notify you about changes to an account, for example, when we change the status of a processing account. **Note:** For a list of the events that you can subscribe to, go to [Events list](/knowledge/events). ## How it works The following diagram shows how to subscribe to an event and how to handle an event. ```mermaid sequenceDiagram participant YI as Your integration participant GW as Gateway rect rgba(0, 81, 194, 0.4) Note over YI,GW: Subscribe to events YI->>GW: 1. Create an event subscription Note over GW: 2. Gateway creates the event subscription GW-->>YI: 3. Return a response end rect rgba(0, 224, 184, 0.3) Note over YI,GW: Handle event webhook requests Note over GW: 1. A change on the account triggers an event notification GW->>YI: 2. Send a webhook request Note over YI: 3. Receive the webhook request YI->>GW: 4. Return a 200 response end ``` ### Subscribe to events 1. Create an event subscription and send it to our gateway. 2. Our gateway creates the event subscription. 3. Our gateway sends you a response to confirm that we have created the subscription. ### Handle event notifications 1. We make a change to an account and trigger an event notification. 2. Our gateway sends a webhook to your endpoint. 3. Your server returns a 200 response to confirm that you have received the webhook. ## Your integration journey To add event notifications to your integration, complete the following steps: 1. Create an event subscription with our API. 2. Handle the webhook. ## Guides #### [Event notifications](/guides/events/create-event-subscription) Add event notifications to your integration. # Create an event subscription Source: https://docs.payroc.com/guides/events/create-event-subscription Create an event subscription by sending a POST request to the event-subscriptions endpoint to receive webhook notifications when specified events occur. **Prerequisites:** [Authentication](/api/authentication) To add event notifications to your integration, use our API to create an event subscription and handle the notification that we send by webhook when an event occurs. **Important:** To receive notifications, your server must be able to handle POST requests. To create an event subscription, send the following information in your request: - **Event type** - The event that you want to subscribe to. You can subscribe to more than one event within the same request. - **URI** - The endpoint that we send notifications to. The endpoint must be publicly available. - **Secret** - A secret that we return in the header of webhook requests to verify that it is a genuine request. - **Event status** - The status of the event subscription. - **Email address** - An email address that we contact if we can't communicate with the endpoint that you provided. **Note:** For a complete list of events that you can subscribe to, go to [Events list](/knowledge/events). ## Integration steps **Step 1.** Create an event subscription **Step 2.** Send a 200 response code **Step 3.** Handle the notification content ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. Create an event subscription To create an event subscription, send a POST request to our event subscriptions endpoint. **Endpoint:** `https://api.payroc.com/v1/event-subscriptions` ### Request parameters To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /event-subscriptions`](/api/create-event-subscription) ### Example request ### Request POST [https://api.payroc.com/v1/event-subscriptions](https://api.payroc.com/v1/event-subscriptions) **`Create event subscription`** ```curl curl -X POST https://api.payroc.com/v1/event-subscriptions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "enabled": true, "eventTypes": [ "processingAccount.status.changed" ], "notifications": [ { "type": "webhook", "secret": "aBcD1234eFgH5678iJkL9012mNoP3456", "supportEmailAddress": "jane.doe@example.com", "uri": "https://my-server/notification/endpoint" } ], "metadata": { "yourCustomField": "abc123" } }' ``` **`Create event subscription`** ```python import requests url = "https://api.payroc.com/v1/event-subscriptions" payload = { "enabled": True, "eventTypes": ["processingAccount.status.changed"], "notifications": [ { "type": "webhook", "secret": "aBcD1234eFgH5678iJkL9012mNoP3456", "supportEmailAddress": "jane.doe@example.com", "uri": "https://my-server/notification/endpoint" } ], "metadata": { "yourCustomField": "abc123" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create event subscription`** ```javascript const url = 'https://api.payroc.com/v1/event-subscriptions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"enabled":true,"eventTypes":["processingAccount.status.changed"],"notifications":[{"type":"webhook","secret":"aBcD1234eFgH5678iJkL9012mNoP3456","supportEmailAddress":"jane.doe@example.com","uri":"https://my-server/notification/endpoint"}],"metadata":{"yourCustomField":"abc123"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create event subscription`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/event-subscriptions" payload := strings.NewReader("{\n \"enabled\": true,\n \"eventTypes\": [\n \"processingAccount.status.changed\"\n ],\n \"notifications\": [\n {\n \"type\": \"webhook\",\n \"secret\": \"aBcD1234eFgH5678iJkL9012mNoP3456\",\n \"supportEmailAddress\": \"jane.doe@example.com\",\n \"uri\": \"https://my-server/notification/endpoint\"\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create event subscription`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/event-subscriptions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"enabled\": true,\n \"eventTypes\": [\n \"processingAccount.status.changed\"\n ],\n \"notifications\": [\n {\n \"type\": \"webhook\",\n \"secret\": \"aBcD1234eFgH5678iJkL9012mNoP3456\",\n \"supportEmailAddress\": \"jane.doe@example.com\",\n \"uri\": \"https://my-server/notification/endpoint\"\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Create event subscription`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/event-subscriptions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"enabled\": true,\n \"eventTypes\": [\n \"processingAccount.status.changed\"\n ],\n \"notifications\": [\n {\n \"type\": \"webhook\",\n \"secret\": \"aBcD1234eFgH5678iJkL9012mNoP3456\",\n \"supportEmailAddress\": \"jane.doe@example.com\",\n \"uri\": \"https://my-server/notification/endpoint\"\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") .asString(); ``` **`Create event subscription`** ```php request('POST', 'https://api.payroc.com/v1/event-subscriptions', [ 'body' => '{ "enabled": true, "eventTypes": [ "processingAccount.status.changed" ], "notifications": [ { "type": "webhook", "secret": "aBcD1234eFgH5678iJkL9012mNoP3456", "supportEmailAddress": "jane.doe@example.com", "uri": "https://my-server/notification/endpoint" } ], "metadata": { "yourCustomField": "abc123" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create event subscription`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/event-subscriptions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"enabled\": true,\n \"eventTypes\": [\n \"processingAccount.status.changed\"\n ],\n \"notifications\": [\n {\n \"type\": \"webhook\",\n \"secret\": \"aBcD1234eFgH5678iJkL9012mNoP3456\",\n \"supportEmailAddress\": \"jane.doe@example.com\",\n \"uri\": \"https://my-server/notification/endpoint\"\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create event subscription`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "enabled": true, "eventTypes": ["processingAccount.status.changed"], "notifications": [ [ "type": "webhook", "secret": "aBcD1234eFgH5678iJkL9012mNoP3456", "supportEmailAddress": "jane.doe@example.com", "uri": "https://my-server/notification/endpoint" ] ], "metadata": ["yourCustomField": "abc123"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/event-subscriptions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Response fields If your request is successful, we send you the ID of the subscription. You can use the ID to update, retrieve, or delete the event subscription. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /event-subscriptions`](/api/create-event-subscription) ### Example response ### Response (201) ```json { "enabled": true, "eventTypes": [ "processingAccount.status.changed" ], "notifications": [ { "type": "webhook", "secret": "**********oP3456", "supportEmailAddress": "jane.doe@example.com", "uri": "https://my-server/notification/endpoint" } ], "id": 2565435189324, "status": "registered", "metadata": { "yourCustomField": "abc123" } } ``` ## Step 2. Send a 200 response code We send notifications by webhook request to the URI endpoint that you provided when you created the subscription. You must return a 200 status code when you receive the request. If we do not receive a 200 response, we retry the request five times. After the fifth attempt, we send an email to the support email address that you provided when you created the subscription. **Note:** We send an email only when a single instance of an event notification fails to deliver. If the event occurs again, we send another notification. ## Step 3. Handle the notification content Each notification follows the [CloudEvents](https://cloudevents.io/) standard, and we use the data object to communicate information about the event that occurred, for example: ```json { "specversion": "1.0", "type": "processingAccount.status.changed", "version": "1.0", "source": "payroc", "id": "123e4567-e89b-12d3-a456-426614174000", "time": "2024-07-02T15:30:00.000Z", "datacontenttype": "application/json", "data": { "processingAccountId": "38765", "status": "entered" } } ``` You can view our event notifications on the [Events](/knowledge/events) page. # Fund merchants Source: https://docs.payroc.com/guides/funding Configure funding recipients and instructions. Configure funding recipients and instructions. - [Send funds to your merchants](/guides/funding/create-funding-instructions) - [Set up a funding recipient](/guides/funding/create-funding-recipients) # Send funds to your merchants Source: https://docs.payroc.com/guides/funding/create-funding-instructions Send funds to your merchants by creating a Funding Instruction with a POST request to the Funding Instructions endpoint, optionally checking available balance first via GET /v1/funding-balance. **Prerequisites:** [Authentication](/api/authentication) **Important:** Before you begin, make sure that you have read our [Getting Started](/guides/getting-started "Getting started") guide, and that you have received your API key. To send funds to your merchants, you need to provide us with instructions about: - Funding accounts that we should send the funds to - Amount of funds that we should send Before you create your funding instructions, we recommend that you check to make sure you have the funds available to send. ## Integration steps **Step 1.** (Optional) Check the available balance. **Step 2.** Create a funding instruction. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Step 1. (Optional) Check the available balance To check the available balance, you need to send a GET request to our Funding Balance endpoint. **Endpoint:** `https://api.payroc.com/v1/funding-balance` ### Schema (`request.query`) [Query parameters for `GET /funding-balance`](/api/get-funding-balance) ### Example request ### Request GET [https://api.payroc.com/v1/funding-balance](https://api.payroc.com/v1/funding-balance) **`Paginated list of merchant balances`** ```curl curl -G https://api.payroc.com/v1/funding-balance \ -H "Authorization: Bearer " \ -d after=8516 \ -d before=2571 \ -d limit=25 \ -d merchantId=4525644354 ``` **`Paginated list of merchant balances`** ```python import requests url = "https://api.payroc.com/v1/funding-balance" querystring = {"after":"8516","before":"2571","limit":"25","merchantId":"4525644354"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` **`Paginated list of merchant balances`** ```javascript const url = 'https://api.payroc.com/v1/funding-balance?after=8516&before=2571&limit=25&merchantId=4525644354'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Paginated list of merchant balances`** ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-balance?after=8516&before=2571&limit=25&merchantId=4525644354" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Paginated list of merchant balances`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-balance?after=8516&before=2571&limit=25&merchantId=4525644354") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` **`Paginated list of merchant balances`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.payroc.com/v1/funding-balance?after=8516&before=2571&limit=25&merchantId=4525644354") .header("Authorization", "Bearer ") .asString(); ``` **`Paginated list of merchant balances`** ```php request('GET', 'https://api.payroc.com/v1/funding-balance?after=8516&before=2571&limit=25&merchantId=4525644354', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` **`Paginated list of merchant balances`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-balance?after=8516&before=2571&limit=25&merchantId=4525644354"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` **`Paginated list of merchant balances`** ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-balance?after=8516&before=2571&limit=25&merchantId=4525644354")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` If your request is successful, we return a response that contains the funds available for your merchant. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `GET /funding-balance`](/api/get-funding-balance) ### Example response ### Response (200) ```json { "data": [ { "merchantId": "4525644354", "funds": 120000, "pending": 50050, "available": 69950, "currency": "USD" }, { "merchantId": "9876543219", "funds": 50000, "pending": 0, "available": 50000, "currency": "USD" } ], "limit": 2, "count": 2, "hasMore": true, "links": [ { "rel": "previous", "method": "get", "href": "https://api.payroc.com/v1/funding-balance?before=4525644354&limit=2" }, { "rel": "next", "method": "get", "href": "https://api.payroc.com/v1/funding-balance?after=9876543219&limit=2" } ] } ``` ## Step 2. Create a funding instruction **Note:** You can use a funding instruction to send funds to a single merchant or to multiple merchants in a single request. To create your funding instruction, send a POST request to our Funding Instructions endpoint. **Endpoint:** `https://api.payroc.com/v1/funding-instructions` To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /funding-instructions`](/api/create-instruction) **Note:** Use our [metadata](/api/metadata "Metadata") feature to add custom information to your request. ### Example request ### Request POST [https://api.payroc.com/v1/funding-instructions](https://api.payroc.com/v1/funding-instructions) **`Funding instruction`** ```curl curl -X POST https://api.payroc.com/v1/funding-instructions \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "merchants": [ { "merchantId": "4525644354", "recipients": [ { "fundingAccountId": 123, "paymentMethod": "ACH", "amount": { "value": 120000, "currency": "USD" }, "metadata": { "yourCustomField": "abc123" } } ] } ], "metadata": { "yourCustomField": "abc123" } }' ``` **`Funding instruction`** ```python import requests url = "https://api.payroc.com/v1/funding-instructions" payload = { "merchants": [ { "merchantId": "4525644354", "recipients": [ { "fundingAccountId": 123, "paymentMethod": "ACH", "amount": { "value": 120000, "currency": "USD" }, "metadata": { "yourCustomField": "abc123" } } ] } ], "metadata": { "yourCustomField": "abc123" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Funding instruction`** ```javascript const url = 'https://api.payroc.com/v1/funding-instructions'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"merchants":[{"merchantId":"4525644354","recipients":[{"fundingAccountId":123,"paymentMethod":"ACH","amount":{"value":120000,"currency":"USD"},"metadata":{"yourCustomField":"abc123"}}]}],"metadata":{"yourCustomField":"abc123"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Funding instruction`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-instructions" payload := strings.NewReader("{\n \"merchants\": [\n {\n \"merchantId\": \"4525644354\",\n \"recipients\": [\n {\n \"fundingAccountId\": 123,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 120000,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Funding instruction`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-instructions") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"merchants\": [\n {\n \"merchantId\": \"4525644354\",\n \"recipients\": [\n {\n \"fundingAccountId\": 123,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 120000,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Funding instruction`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/funding-instructions") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"merchants\": [\n {\n \"merchantId\": \"4525644354\",\n \"recipients\": [\n {\n \"fundingAccountId\": 123,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 120000,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") .asString(); ``` **`Funding instruction`** ```php request('POST', 'https://api.payroc.com/v1/funding-instructions', [ 'body' => '{ "merchants": [ { "merchantId": "4525644354", "recipients": [ { "fundingAccountId": 123, "paymentMethod": "ACH", "amount": { "value": 120000, "currency": "USD" }, "metadata": { "yourCustomField": "abc123" } } ] } ], "metadata": { "yourCustomField": "abc123" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Funding instruction`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-instructions"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"merchants\": [\n {\n \"merchantId\": \"4525644354\",\n \"recipients\": [\n {\n \"fundingAccountId\": 123,\n \"paymentMethod\": \"ACH\",\n \"amount\": {\n \"value\": 120000,\n \"currency\": \"USD\"\n },\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Funding instruction`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "merchants": [ [ "merchantId": "4525644354", "recipients": [ [ "fundingAccountId": 123, "paymentMethod": "ACH", "amount": [ "value": 120000, "currency": "USD" ], "metadata": ["yourCustomField": "abc123"] ] ] ] ], "metadata": ["yourCustomField": "abc123"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-instructions")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` If your request is successful, we create the funding instruction and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /funding-instructions`](/api/create-instruction) ### Example response ### Response (201) ```json { "instructionId": 64643131, "createdDate": "2024-07-02T15:30:00Z", "lastModifiedDate": "2024-07-02T15:30:00Z", "status": "accepted", "merchants": [ { "merchantId": "4525644354", "recipients": [ { "fundingAccountId": 123, "paymentMethod": "ACH", "amount": { "value": 120000, "currency": "USD" }, "status": "accepted", "metadata": { "yourCustomField": "abc123" }, "link": { "rel": "fundingAccount", "method": "get", "href": "https://api.payroc.com/v1/funding-accounts/123" } } ], "link": { "rel": "merchant", "method": "get", "href": "https://api.payroc.com/v1/processing-accounts/4525644354" } } ], "metadata": { "yourCustomField": "abc123" } } ``` ## Test cases Our integration team provides you with [test cases](/guides/testing) that you can run to verify that your integration works with our API. For your next steps, we recommend that you integrate with the other functions so you can manage your funding instructions. To view the other functions, see [funding instructions](/api/resources/funding-instructions). # Set up a funding recipient Source: https://docs.payroc.com/guides/funding/create-funding-recipients Create a funding recipient by sending a POST request to the Funding Recipients endpoint, enabling third-party entities such as charities to receive funds from your account. **Prerequisites:** [Authentication](/api/authentication) **Important:** Before you begin, make sure that you have read our [Getting Started](/guides/getting-started "Getting started") guide, and that you have received your API key. A funding recipient is an entity that can receive funds using funding instructions. Each funding recipient includes at least one of the following: - **Funding account:** The funding recipient’s bank account. - **Owner:** Individuals that are associated with the funding recipient. You can create funding recipients for third parties that can’t directly process sales. For example, charities. ## Integration steps - Create your funding recipient. ## Before you begin [Authenticate your requests](/api/authentication) before making API calls. If your request fails, see [Errors](/api/errors). ## Create your funding recipient To create your funding recipient, send a POST request to our Funding Recipients endpoint. **Endpoint:** `https://api.payroc.com/v1/funding-recipients` To create the body of your request, use the following parameters: ### Schema (`request.body`) [Request body schema for `POST /funding-recipients`](/api/create-funding-recipient) **Note:** Use our [metadata](/api/metadata "Metadata") feature to add custom information to your request. ### Example request ### Request POST [https://api.payroc.com/v1/funding-recipients](https://api.payroc.com/v1/funding-recipients) **`Create funding recipient`** ```curl curl -X POST https://api.payroc.com/v1/funding-recipients \ -H "Idempotency-Key: 8e03978e-40d5-43e8-bc93-6894a57f9324" \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "relationship": { "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false }, "middleName": "Helen" } ], "fundingAccounts": [ { "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ] } ], "metadata": { "yourCustomField": "abc123" } }' ``` **`Create funding recipient`** ```python import requests url = "https://api.payroc.com/v1/funding-recipients" payload = { "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "relationship": { "isControlProng": True, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": False }, "middleName": "Helen" } ], "fundingAccounts": [ { "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ] } ], "metadata": { "yourCustomField": "abc123" } } headers = { "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` **`Create funding recipient`** ```javascript const url = 'https://api.payroc.com/v1/funding-recipients'; const options = { method: 'POST', headers: { 'Idempotency-Key': '8e03978e-40d5-43e8-bc93-6894a57f9324', Authorization: 'Bearer ', 'Content-Type': 'application/json' }, body: '{"recipientType":"privateCorporation","taxId":"12-3456789","doingBusinessAs":"Pizza Doe","address":{"address1":"1 Example Ave.","address2":"Example Address Line 2","address3":"Example Address Line 3","city":"Chicago","country":"US","postalCode":"60056","state":"Illinois"},"contactMethods":[{"type":"email","value":"jane.doe@example.com"},{"type":"phone","value":"2025550164"}],"owners":[{"firstName":"Jane","lastName":"Doe","dateOfBirth":"1964-03-22","address":{"address1":"1 Example Ave.","city":"Chicago","state":"Illinois","country":"US","postalCode":"60056"},"identifiers":[{"type":"nationalId","value":"000-00-4320"}],"contactMethods":[{"type":"email","value":"jane.doe@example.com"},{"type":"phone","value":"2025550164"}],"relationship":{"isControlProng":true,"equityPercentage":48.5,"title":"CFO","isAuthorizedSignatory":false},"middleName":"Helen"}],"fundingAccounts":[{"type":"checking","use":"credit","nameOnAccount":"Jane Doe","paymentMethods":[{"type":"ach","value":{"routingNumber":"123456789","accountNumber":"1234567890"}}]}],"metadata":{"yourCustomField":"abc123"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` **`Create funding recipient`** ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.payroc.com/v1/funding-recipients" payload := strings.NewReader("{\n \"recipientType\": \"privateCorporation\",\n \"taxId\": \"12-3456789\",\n \"doingBusinessAs\": \"Pizza Doe\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **`Create funding recipient`** ```ruby require 'uri' require 'net/http' url = URI("https://api.payroc.com/v1/funding-recipients") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Idempotency-Key"] = '8e03978e-40d5-43e8-bc93-6894a57f9324' request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"recipientType\": \"privateCorporation\",\n \"taxId\": \"12-3456789\",\n \"doingBusinessAs\": \"Pizza Doe\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}" response = http.request(request) puts response.read_body ``` **`Create funding recipient`** ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.payroc.com/v1/funding-recipients") .header("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"recipientType\": \"privateCorporation\",\n \"taxId\": \"12-3456789\",\n \"doingBusinessAs\": \"Pizza Doe\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}") .asString(); ``` **`Create funding recipient`** ```php request('POST', 'https://api.payroc.com/v1/funding-recipients', [ 'body' => '{ "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "owners": [ { "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": { "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" }, "identifiers": [ { "type": "nationalId", "value": "000-00-4320" } ], "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "relationship": { "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false }, "middleName": "Helen" } ], "fundingAccounts": [ { "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ { "type": "ach", "value": { "routingNumber": "123456789", "accountNumber": "1234567890" } } ] } ], "metadata": { "yourCustomField": "abc123" } }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', 'Idempotency-Key' => '8e03978e-40d5-43e8-bc93-6894a57f9324', ], ]); echo $response->getBody(); ``` **`Create funding recipient`** ```csharp using RestSharp; var client = new RestClient("https://api.payroc.com/v1/funding-recipients"); var request = new RestRequest(Method.POST); request.AddHeader("Idempotency-Key", "8e03978e-40d5-43e8-bc93-6894a57f9324"); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"recipientType\": \"privateCorporation\",\n \"taxId\": \"12-3456789\",\n \"doingBusinessAs\": \"Pizza Doe\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"address2\": \"Example Address Line 2\",\n \"address3\": \"Example Address Line 3\",\n \"city\": \"Chicago\",\n \"country\": \"US\",\n \"postalCode\": \"60056\",\n \"state\": \"Illinois\"\n },\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"owners\": [\n {\n \"firstName\": \"Jane\",\n \"lastName\": \"Doe\",\n \"dateOfBirth\": \"1964-03-22\",\n \"address\": {\n \"address1\": \"1 Example Ave.\",\n \"city\": \"Chicago\",\n \"state\": \"Illinois\",\n \"country\": \"US\",\n \"postalCode\": \"60056\"\n },\n \"identifiers\": [\n {\n \"type\": \"nationalId\",\n \"value\": \"000-00-4320\"\n }\n ],\n \"contactMethods\": [\n {\n \"type\": \"email\",\n \"value\": \"jane.doe@example.com\"\n },\n {\n \"type\": \"phone\",\n \"value\": \"2025550164\"\n }\n ],\n \"relationship\": {\n \"isControlProng\": true,\n \"equityPercentage\": 48.5,\n \"title\": \"CFO\",\n \"isAuthorizedSignatory\": false\n },\n \"middleName\": \"Helen\"\n }\n ],\n \"fundingAccounts\": [\n {\n \"type\": \"checking\",\n \"use\": \"credit\",\n \"nameOnAccount\": \"Jane Doe\",\n \"paymentMethods\": [\n {\n \"type\": \"ach\",\n \"value\": {\n \"routingNumber\": \"123456789\",\n \"accountNumber\": \"1234567890\"\n }\n }\n ]\n }\n ],\n \"metadata\": {\n \"yourCustomField\": \"abc123\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` **`Create funding recipient`** ```swift import Foundation let headers = [ "Idempotency-Key": "8e03978e-40d5-43e8-bc93-6894a57f9324", "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": [ "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ], [ "type": "phone", "value": "2025550164" ] ], "owners": [ [ "firstName": "Jane", "lastName": "Doe", "dateOfBirth": "1964-03-22", "address": [ "address1": "1 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" ], "identifiers": [ [ "type": "nationalId", "value": "000-00-4320" ] ], "contactMethods": [ [ "type": "email", "value": "jane.doe@example.com" ], [ "type": "phone", "value": "2025550164" ] ], "relationship": [ "isControlProng": true, "equityPercentage": 48.5, "title": "CFO", "isAuthorizedSignatory": false ], "middleName": "Helen" ] ], "fundingAccounts": [ [ "type": "checking", "use": "credit", "nameOnAccount": "Jane Doe", "paymentMethods": [ [ "type": "ach", "value": [ "routingNumber": "123456789", "accountNumber": "1234567890" ] ] ] ] ], "metadata": ["yourCustomField": "abc123"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.payroc.com/v1/funding-recipients")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` If your request is successful, we create the funding recipient and return a response. The response contains the following fields: ### Schema (`response.body`) [Response body schema for `POST /funding-recipients`](/api/create-funding-recipient) ### Example response ### Response (201) ```json { "recipientType": "privateCorporation", "taxId": "12-3456789", "doingBusinessAs": "Pizza Doe", "address": { "address1": "1 Example Ave.", "address2": "Example Address Line 2", "address3": "Example Address Line 3", "city": "Chicago", "country": "US", "postalCode": "60056", "state": "Illinois" }, "contactMethods": [ { "type": "email", "value": "jane.doe@example.com" }, { "type": "phone", "value": "2025550164" } ], "owners": [ { "ownerId": 4564, "link": { "rel": "owner", "href": "https://api.payroc.com/v1/owners/4564", "method": "get" } } ], "fundingAccounts": [ { "fundingAccountId": 123, "status": "pending", "link": { "rel": "fundingAccount", "href": "https://api.payroc.com/v1/funding-accounts/123", "method": "get" } } ], "recipientId": 234, "status": "pending", "createdDate": "2024-07-02T15:30:00+00:00", "lastModifiedDate": "2024-07-02T15:30:00+00:00", "metadata": { "yourCustomField": "abc123" } } ``` ## Test cases Our integration team provides you with [test cases](/guides/testing) that you can run to verify that your integration works with our API. For your next steps, we recommend that you follow our guide about [sending funds to your funding recipients](/guides/funding/create-funding-instructions). To view other functions about managing your funding recipients, see [funding recipients](/api/create-funding-recipient "Funding Recipients"). # Knowledge Source: https://docs.payroc.com/knowledge Understand Payroc API behavior and payment concepts. ### [API basics](/knowledge/api-basics) Understand authentication, requests and API behavior. [Browse articles →](/knowledge/api-basics) ### [Payments](/knowledge/payments) Understand payment methods, processing and transaction behavior. [Browse articles →](/knowledge/payments) ### [Payroc Cloud](/knowledge/payroc-cloud) Understand device integrations and signature capture. [Browse articles →](/knowledge/payroc-cloud) ### [Testing](/knowledge/testing) Use the simulator and its test transaction values. [Browse articles →](/knowledge/testing) ### [Boarding](/knowledge/boarding) Understand pricing before boarding merchants. [Browse articles →](/knowledge/boarding) ### [Data migration](/knowledge/data-migration) Move payment data from another provider. [Browse articles →](/knowledge/data-migration) ### [Integration tools](/knowledge/tooling) Find tools for building your integration. [Browse articles →](/knowledge/tooling) ### [Events](/knowledge/events) Understand event notifications and payloads. [Browse articles →](/knowledge/events) Welcome to our knowledge base. Our knowledge base includes articles that explain the features and functions of our API, as well as key concepts and terms that we use in our documentation. ## What our knowledge base contains - [Glossary of terms.](/knowledge/api-basics/glossary) Our glossary of terms provides short definitions of key terms that we use throughout our API. - Articles that describe the features and functions of our API, and why we offer them to our merchants and partners. For example, what [Pagination](/api/pagination) is and why we use it. - Articles that provide more detailed explanations of key concepts. If you want help integrating with Payroc or using our API's key features, check out our [Guides](/solutions/full-stack/guides) and our [API Explorer](/api). To test your integration, check out [Test your integration.](/guides/testing/funding-instructions) # API basics Source: https://docs.payroc.com/knowledge/api-basics Understand authentication, requests and API behavior. Understand authentication, requests and API behavior. - [Getting started with the Payroc API](/knowledge/api-basics/getting-started) - [API keys](/knowledge/api-basics/api-keys) - [Hypermedia as the engine of application state (HATEOAS)](/knowledge/api-basics/hateoas) - [Glossary](/knowledge/api-basics/glossary) - [Units of measurement](/knowledge/api-basics/unit-of-measure) # Getting started with the Payroc API Source: https://docs.payroc.com/knowledge/api-basics/getting-started Sandbox account, API keys, and your first authenticated request. ## Getting started with the Payroc API Create a sandbox account at developers.payroc.com, generate an API key, and make your first request. Sandbox keys start `sk_test_` and are shown once. # API keys Source: https://docs.payroc.com/knowledge/api-basics/api-keys Explains the two types of API keys used to authenticate requests to the Payroc gateway — the standard API key for Bearer token generation and the Payroc App API key for terminal access. An API key is a unique string of letters and numbers that we use to authenticate requests to our gateway. We use two types of API keys: - [API key](/knowledge/api-basics/api-keys#api-key) - [Payroc App API key](/knowledge/api-basics/api-keys#payroc-app-api-key) ## API key Use your API key with our identity service to generate a Bearer token, so that you can send requests to our API. We send you an API key when you sign up with us. For more information about Bearer token authentication, go to [Authentication](/api/authentication). ## Payroc App API key Use your Payroc App API key with the Payroc App and to access the Payroc Cloud Simulator. Each Payroc App API key is specific to a merchant account and its processing terminals. You can create and manage Payroc App API keys in the Self-Care Portal. For more information about Payroc App API keys, go to the following articles: - [Generate a Payroc App API key](/guides/api-keys/generate-a-payroc-app-api-key). - [View a Payroc App API key](/guides/api-keys/view-a-payroc-app-api-key). - [Change the settings of a Payroc App API key](/guides/api-keys/change-the-settings-of-a-payroc-app-api-key). - [Deactivate a Payroc App API key](/guides/api-keys/deactivate-a-payroc-app-api-key). - [Reactivate a Payroc App API key](/guides/api-keys/reactivate-a-payroc-app-api-key). # Hypermedia as the engine of application state (HATEOAS) Source: https://docs.payroc.com/knowledge/api-basics/hateoas Explains how the Payroc API uses HATEOAS links to surface related resources and paginate large result sets within API responses. We implement HATEOAS throughout our API to help you: - [View additional information about a resource.](#view-additional-information-about-a-resource) - [Navigate a list of records using pagination.](#navigate-a-list-of-records-using-pagination) ## View additional information about a resource If a resource has a relationship with other resources in our API, we provide HATEOAS links to the other resources in our response. ### Example If you retrieve the details of a payment, we include a `links` object that contains links to any referenced refunds or reversals that are related to the payment. The following example response contains links to two refunds related to the payment. ```json "links": [ { "rel": "refund", "method": "get", "href": "https://api.payroc.com/v1/refunds/CD3HN88U9F" }, { "rel": "refund", "method": "get", "href": "https://api.payroc.com/v1/refunds/FPU8P48WN8" } ] ``` ## Navigate a list of records using pagination If a GET request returns a large number of results, we send the results as a [paginated list](/api/pagination). To help you navigate through the results, we include HATEOAS links so that you can navigate through the results. ### Example The following example response contains a `links` object with HATEOAS links to the next page and previous page of a paginated list of payments. ```json { "links": [ { "rel": "next", "method": "get", "href": "" }, { "rel": "previous", "method": "get", "href": "" } ] } ``` # Glossary Source: https://docs.payroc.com/knowledge/api-basics/glossary Definitions of payment industry terms, acronyms, and Payroc-specific concepts used across the developer documentation. ## 123 | Term | Definition | | --- | --- | | **3-D Secure** | Security protocol for online credit and debit transactions. | ## A | Term | Definition | | --- | --- | | **Acquirer** | Merchant's bank that accepts funds from transactions. Also known as the acquiring bank. | | **Acquirer Reference Number (ARN)** | Unique 23-digit number that the acquirer assigns to a Visa or Mastercard payment or refund. The acquirer uses the ARN to track the transaction as it transfers between the merchant and the cardholder. | | **Address Verification Service (AVS)** | Service that checks whether the billing address associated with the transaction matches the billing address that the issuing bank has stored for the card. Financial institutions use this service to detect suspicious or fraudulent transactions. | | **American Banker's Association (ABA) number** | For US checks, this is the unique identifier of the financial institution. Also known as the ABA routing number. We use the ABA routing number and the [Demand Deposit Account (DDA)](#dda) to identify individual bank accounts. | | **API key** | Secret credential that authenticates your application when it calls our API. For example, a [Payroc App API key](#payroc-app-api-key) authenticates with the Payroc App and the Payroc Cloud Simulator. For more information, see [API keys](/knowledge/api-basics/api-keys). | | **Apple Pay** | Payment service by Apple that cardholders use to pay with their Apple Wallet. | | **Apple Pay session** | Session that we start with the Apple Pay JS API when we receive a successful request to our Apple Pay session endpoint. The session validates the merchant so they can run a sale with Apple Pay. | | **Apple Wallet** | Type of digital wallet that Apple device users can use to store their payment cards. | | **Application Programming Interface (API)** | Software that different computer programs use to communicate with each other. For example, [Point of Sale (POS)](#pos) devices communicate with our [payment gateway](#payment-gateway) using our API. | | **Arbitration** | Final stage of the dispute process, where the card network reviews evidence from both sides and makes a final, binding decision. This happens after the cardholder's issuing bank challenges a merchant's [chargeback reversal](#chargeback-reversal). See also [Dispute](#dispute). | | **Attestation of Compliance (AOC)** | Declaration of an organization's compliance with [Payment Card Industry Data Security Standard (PCI DSS)](#pci-dss). | | **Authorization** | Process that places a temporary hold on funds in a customer's account. For example, a hotel can reserve a dollar amount on a customer's card at check-in to cover future additional costs such as room service. The hotel then captures the actual final amount that the customer spent when they check out. | | **Authorized signatory** | Payroc term. Type of [owner](#owners) that can make decisions for the processing account. They don't have an equity stake in the business. | | **Automated Clearing House (ACH)** | Method that U.S. financial institutions use to electronically send funds between bank accounts. | | **Autosave** | Payroc product. When a merchant runs a credit card sale, we send a percentage of the funds to a savings account. The merchant sets the percentage that they want to contribute from each sale. | ## B | Term | Definition | | --- | --- | | **B2B** | Business to business. | | **B2C** | Business to consumer. | | **Background validation** | Webhook-based mechanism that confirms whether our gateway processed a card payment. | | **Bank Identification Number (BIN)** | First six digits on a payment card. The BIN identifies the specific financial institution that issued the card. | | **Bank Identifier Code, Business Identifier Code, Bank International Code (BIC)** | Unique identifier for a bank. Also known as a [SWIFT code](#swift-code). The terms "BIC" and "SWIFT" are often used interchangeably. | | **Bank Secrecy Act (BSA)** | U.S. law that requires financial institutions to assist government agencies to detect and prevent money laundering. | | **Basis point (BP)** | Basis points are a unit of measurement for rates in finance. One basis point is equal to 0.01%. For example, if you apply 10bp to $1,000,000, this is equal to $1,000. Basis points are sometimes referred to as a "bip" or a "beep". | | **Batch** | Collection of card transactions. | | **Bearer token** | Access token that we use to authenticate requests sent to our API. | | **Boarding** | Process of setting up a new merchant so they can start processing payments with us. Boarding includes creating the merchant's [processing account](#processing-account) and collecting details about the business and its [owners](#owners). | ## C | Term | Definition | | --- | --- | | **Canadian Payments Association (CPA)** | Canadian organization that manages the national system to clear and settle payments. | | **Capture** | Process that moves pre-authorized funds to the merchant. For example, a hotel reserved a dollar amount on a customer's card at check-in to cover future additional costs such as room service. The hotel then captures the actual final amount that the customer spent when they check out. | | **Card Not Present (CNP)** | Type of payment that occurs when the card isn't physically present at the point of sale. For example, a cardholder buys an item from an online store. | | **Card Verification Value (CVV)** | Three-digit or four-digit code that an issuing bank prints on credit cards and debit cards. For card-not-present transactions, cardholders provide this code to verify that they have access to the card. You're not allowed to store the CVV for future transactions. | | **Cash advance** | Cash advance can refer to: – A high interest, short-term loan from a bank or lender. – The withdrawal of cash from a credit card account. | | **Cash discounting** | Type of pricing program that merchants can use to help offset the cost of processing fees. If the merchant uses this type of pricing program, they add an additional cost to all goods or services that they provide. The POS then removes the additional cost as a discount when a customer pays with cash. | | **Cash rewards** | Cash Discounting program that Payroc offers to merchants. | | **Certified Anti Money Laundering Specialist (CAMS)** | Certified professional who investigates money laundering. | | **Chargeback** | Payment that is returned to a cardholder after they successfully dispute the payment through their [issuing bank](#issuing-bank). For example, if the cardholder doesn't receive the goods that they paid for, the cardholder can open a dispute to recover the cost of the goods. A chargeback is not the same as a refund. A chargeback must follow a dispute and must involve the cardholder's issuing bank. | | **Chargeback Reversal** | Reversal of a previous chargeback. For example, if the merchant provides evidence that the disputed transaction was valid. | | **Check 21** | U.S. law under which banks can create and send digital copies of checks. | | **Clearing** | Process of moving funds from the customer's account to the merchant's account. See also [Settlement](#settlement). | | **Closed-loop card** | Card that can be used at only one merchant or a specific group of stores, such as a gift card or a loyalty card. Different from cards issued by the [V/MC/D/AE](#v-mc-d-ae) networks, which work anywhere that accepts them. | | **CloudEvents standard** | Common format for describing events, so different systems can read them in a standard way. | | **Consumer Choice** | Cash discounting program that Payroc offers to merchants. | | **Control prong** | Type of [owner](#owners) that can make decisions for the processing account. They have an equity stake in the business. | | **Cryptogram** | Encrypted block of text that contains sensitive information, for example, payment details. | ## D | Term | Definition | | --- | --- | | **Debit network** | Network that processes debit transactions between the cardholder and merchant. Examples of debit networks include Visa, Mastercard, and Star. | | **Demand Deposit Account (DDA)** | ID number on US checks that identifies the customer's bank account. Also known as an account number. We use the [ABA routing number](#aba-number) and the Demand Deposit Account (DDA) to identify individual bank accounts. | | **Digital Wallet** | Application that a cardholder can use to store payment details and to pay for goods and services. Apple Wallet and Google Wallet are examples of digital wallets. | | **Dispute** | Transaction dispute that occurs when a cardholder makes a formal complaint against a merchant about a specific transaction. The cardholder normally registers the dispute through their issuing bank to begin the chargeback process. **Note:** Visa uses the term "dispute" to refer to a chargeback. | | **Doing business as (DBA)** | Public-facing name of a business. Also known as an assumed name, a fictitious business name, or a trade name. | | **Domain Verification File** | File that you add to a merchant's domain. Apple uses this file to validate the merchant so they can accept payments with Apple Pay. For more information, see [Apple Pay](#apple-pay). | | **Downgrade** | When a [payment processor](#payment-processor) sends a transaction through the [interchange network](#interchange-network), it assigns it to an interchange category. If the transaction doesn't meet the requirements for that interchange category, it is re-routed, and charged a higher [interchange fee](#interchange-fee). This is known as a downgrade. There are many reasons a transaction can be downgraded, for example, if there is an [Address Verification Service (AVS)](#avs) mismatch. | | **Dynamic Currency Conversion (DCC)** | Service that provides cardholders with the choice to pay in either their own currency or the merchant's currency. For example, when a cardholder purchases goods when they travel abroad. | | **Dynamic funding model** | Funding option where you distribute settled funds across multiple accounts using your own allocation rules. It suits complex or multi-location businesses. See also [Standard funding model](#standard-funding-model). | ## E | Term | Definition | | --- | --- | | **Easy pay** | Payroc product. Merchants can direct a portion of funds in each batch to a recipient of their choice. They can also set a limit to the amount that they send. | | **Electronic Commerce Indicator (ECI)** | Code returned from a 3-D Secure check that shows whether the issuing bank authenticated the cardholder. | | **eCommerce** | Buying or selling goods or services through the Internet. | | **Effective Merchant Discount Rate (EMDR)** | Percentage of total sales volume that a merchant pays as fees to their acquirer. See also [Merchant Discount Rate (MDR)](#mdr). | | **Electronic Benefits Transfer (EBT)** | Card that the U.S. government issues to people eligible for benefits. | | **Electronic Funds Transfer (EFT)** | Term that describes the electronic movement of funds from one account to another. | | **Employer Identification Number (EIN)** | Unique nine-digit number that the Internal Revenue Service assigns to U.S. businesses. Also known as a [Tax Identification Number (TIN)](#tin). | | **Encryption** | Process of protecting information by transforming it into a format that third parties can't read. Only the intended recipient of the information can read it. | | **End-to-end Encryption (E2EE)** | Type of encryption that protects communication between two devices. The sending device encrypts the data and only the intended recipient device can decrypt it. Third parties are unable to access the sent data. See also [encryption](#encryption). | | **Equipment Request Form (ERF)** | Form that merchants use to request processing equipment from us. | | **Europay, Mastercard, Visa (EMV)** | EMV can refer to: – EMV technology, such as the chip on a credit card or debit card. – EMVco, the company that manages EMV specifications. | | **Event** | We trigger an event when we make a change to a resource, for example, when we change the status of a processing account. You can subscribe to an event so that you receive a notification each time we trigger the event. For more information about events subscriptions, go to [Events subscriptions](/guides/events). | | **Event subscription** | Feature of our API that you can subscribe to so that we notify you about any changes to your account, for example, when we change the status of a processing account. For more information about event subscriptions, go to [Event subscriptions](/guides/events). | ## F | Term | Definition | | --- | --- | | **Federal Trade Commission (FTC)** | Enforces consumer protection laws in commerce. | | **Financial Institutions File (FIF)** | Electronic directory of routing numbers of financial institutions in Canada. | | **FinTech** | Financial technology. Technology that supports banking and financial services. | | **Fixed Acquirer Network Fee (FANF)** | Fee that Visa charges to all businesses that accept Visa cards. | | **Flexible Spending Account (FSA)** | Type of debit account that cardholders use for healthcare expenses. | | **Fluidpay** | Third-party payment gateway. | | **Food and Consumer Service Number (FCS number)** | Unique identifier that the Department of Agriculture assigns to a merchant that accepts [EBT](#ebt) transactions. Also known as a Food and Nutrition Service (FNS) number. | | **Food and Nutrition Service Number (FNS number)** | Unique identifier that the Department of Agriculture assigns to a merchant that accepts [EBT](#ebt) transactions. Also known as a Food and Consumer Service (FCS) number. | | **Fund reversals** | The return of funds to the cardholder's account. This can be a [refund](#refund), a payment [reversal](#reversal-void), or a [chargeback](#chargeback). The cardholder, [merchant](#merchant), [issuing bank](#issuing-bank), [acquiring bank](#acquirer), or card network can initiate a fund reversal. | | **Funding account** | Bank account details that a funding recipient or a merchant uses to receive funds. **Note:** A funding account is not the same as a [processing account](#processing-account). A funding account does not process transactions. | | **Funding activity** | History of events associated with a funding account. For example, details of funds that were sent to the funding account. | | **Funding balance** | Available funds that you can send to funding accounts. | | **Funding instruction** | Instructions that we use to send funds to funding accounts. | | **Funding recipient** | Entity that can receive funds but doesn't process transactions, for example, a charity. | ## G | Term | Definition | | --- | --- | | **Gateway** | See [Payment Gateway](#payment-gateway). | | **Google Pay** | Payment service by Google that cardholders use to pay with their Google Wallet. | | **Google Wallet** | Type of digital wallet that Google Account holds can use to store their payment details. | ## H | Term | Definition | | --- | --- | | **Health Insurance Portability and Accountability Act (HIPAA)** | U.S. law that covers how to protect patient information. Mandatory for payments in healthcare industry. | | **Health Savings Account (HSA)** | Type of debit account that cardholders use for healthcare expenses and investments. | | **Host configuration** | Transaction processing settings that the host processor holds for the processing terminal. | | **Hosted Payment Page (HPP)** | Page that a third party hosts for secure payment on an eCommerce site. For example, a customer clicks the checkout button on an [eCommerce](#ecommerce) site, and the site redirects them to the hosted payment page to complete their purchase. Also known as a hosted [payment gateway](#payment-gateway). | ## I | Term | Definition | | --- | --- | | **Idempotency** | For API requests, an operation that has no additional effect if it is called more than once with the same input parameters. For example for payments, idempotency prevents duplicate transactions. | | **Identity service** | Our API endpoint that issues bearer tokens. | | **Independent Sales Organization (ISO)** | Company that sells credit card processing services independently from a financial firm or bank. See also Independent Sales Group (ISG). Also known as a Merchant Service Provider (MSP). | | **Independent Software Vendor (ISV)** | Organization that creates and sells software. | | **Interac** | Canada's network for debit cards. | | **Interbank Card Association number (ICA)** | Unique identifier that MasterCard uses to identify issuers and acquirers. | | **Interchange fee** | Fee that card brands charge to merchants when a customer pays by credit card or debit card. | | **Interchange network** | Electronic networks that card brands manage that exchange card transaction data between issuers and acquirers. See also [interchange fee](/knowledge/payments/interchange). | | **International Bank Account Number (IBAN)** | Unique identifier of a customer's bank account. | | **Internet Protocol (IP) address** | Numerical label that identifies a network device on a computer network. | | **Issuing Bank** | Financial institution that provides a debit card or a credit card to a cardholder. Also known as an issuer or card issuer. | ## J | Term | Definition | | --- | --- | | **Japan Credit Bureau (JCB)** | Major credit network in Japan. | | **JSON Patch** | Standard format (RFC 6902) for describing changes to make to a JSON document. For example, when you send a PATCH request, you can use JSON Patch to update part of a resource without resending the whole thing. | | **JSON Pointer** | Standard syntax for pointing to a specific field inside a JSON document. For example, `/name/first` points to the `first` field inside `name`. Used in [JSON Patch](#json-patch) requests. | ## K | Term | Definition | | --- | --- | | **Know Your Customer (KYC)** | Know Your Customer (KYC). We run KYC checks to confirm a business's or a person's identity before they can process payments or receive funds, and to help prevent fraud and money laundering. | ## L | Term | Definition | | --- | --- | | **Legal Business Name (LBN)** | Name used by a business for government and legal matters. Often different from the trade name, or [DBA](#dba). | | **Level 1 card data** | Information about a transaction. Level 1 is the most basic level and requires only standard card information. Level 1 payments include the following information: – Card number – CVV code – Total purchase amount – Merchant name Each card network can require different information for a payment to qualify for level 1, 2, or 3. | | **Level 2 card data** | Additional information about a transaction. Level 2 payments include the following information: – All information from Level 1 – Purchase Order number – Destination ZIP – Tax indicator – Tax amount – Requestor name – Destination address – Destination city – Destination state – VAT ID Each card network requires different information for a payment to qualify for level 1, 2, or 3. | | **Level 3 card data** | Additional information about a transaction. Level 3 payments include the following information: – All information from Level 2 – Item ID or SKU – Unit price – Extended price – Unit of measure – Unit of cost – Commodity code – Quantity – Discount amount, per line item and total – Shipping or shipping amount – VAT information – Debit or credit indicator Each card network requires different information for a transaction to qualify for level 1, 2, or 3. | ## M | Term | Definition | | --- | --- | | **Magnetic Stripe Reader (MSR)** | Device that reads the raw data on a card's magnetic stripe. | | **Mail Order/Telephone Order (MOTO)** | Payment through written request or over-the-phone. To run the payment, the merchant enters the card data into a device or a [virtual terminal](#virtual-terminal). | | **Merchant** | Entity that accepts payments. | | **Merchant agreement** | Contract between a merchant and an [acquirer](#acquirer) that defines their respective rights, responsibilities, and warranties related to the processing of payment transactions. | | **Merchant Category Code (MCC)** | Merchant Category Code (MCC). Four-digit code that classifies the type of business a merchant runs, for example, restaurant or retail. Card networks use the MCC to work out [interchange fees](#interchange-fee) and spending limits. | | **Merchant Discount Rate (MDR)** | Percentage fee that the [payment processor](#payment-processor) charges to a merchant for each debit card transaction or credit card transaction. | | **Merchant Identification Number (MID)** | Unique identifier for an individual merchant. Every active merchant with a processing account has a MID. | | **Merchant Initiated Transaction (MIT)** | Payment that the merchant initiates instead of the customer. MITs are subject to a MIT agreement between the merchant and the customer. MITs are often used for recurring payments, for example, a monthly subscription to a streaming service. | | **Merchant of Record (MOR)** | Entity that sells goods or services to a customer. This is the name that appears on the customer's credit card statement. | | **Merchant platform** | Record that holds a business's legal details, and lists its owners and processing accounts. | | **Merchant plug-in (MPI)** | Service that verifies a cardholder's identity as part of a 3-D Secure check. See also [3-D Secure](#3-d-secure). | | **Merchant Processing Application (MPA)** | Application form that merchants complete to process payments with Payroc. | | **Metadata** | Data that describes data. Using our API, you can add metadata to certain requests – for more information about how to add metadata to your API requests, see [Metadata](/api/metadata). | | **Money Express** | Payroc service for next-day merchant funding. For an additional monthly fee, we deposit funds to the merchant account the next day. | | **Money Express Prime** | Payroc service for same-day merchant funding. For an additional monthly fee, we deposit funds to the merchant account the same day. | ## N | Term | Definition | | --- | --- | | **National Automated Clearing House Association (NACHA)** | Non-profit association that governs the [Automated Clearing House (ACH)](#ach) network. | | **Near Field Communication (NFC)** | Technology that devices use to wirelessly send information to other NFC devices. Devices use NFC for contactless payments. | | **Network Access Brand Usage (NABU)** | Fee that MasterCard charges to the [acquirer](#acquirer) for using their network. See also [Fixed Acquirer Network Fee (FANF)](#fanf). | ## O | Term | Definition | | --- | --- | | **Office of Foreign Assets Control (OFAC)** | U.S. government body that administers and enforces economic and trade sanctions against targeted foreign governments, individuals, groups, and entities. | | **Optical Character Recognition (OCR)** | In payments, refers to a mobile device's ability to read alphanumeric characters on a physical card or a check. | | **Order item** | An item in a terminal order, which includes the solution template, industry settings, and gateway settings. | | **Originating Depository Financial Institution (ODFI)** | Financial institution that helps to transmit [ACH](#ach) payments to the Federal Reserve or the ACH network. | | **Owners** | Payroc term. **Owner for a processing account** An individual that owns the relationship between Payroc and the processing account. An owner for a processing account can be a [control prong](#control-prong) or [authorized signatory](#authorized-signatory). **Owner for a funding recipient** An individual that is associated with the funding recipient. | ## P | Term | Definition | | --- | --- | | **Pagination** | Limits the number of results that we return in response to a GET request. | | **Payment Card Industry Data Security Standard (PCI DSS)** | Data security requirements that the Payment Card Industry Security Standards Council (PCI SSC) created to protect cardholder data. PCI DSS applies to all entities that process, store, or transmit cardholder data and sensitive authentication data. Entities that meet the requirements are PCI compliant. | | **Payment Card Industry Security Standards Council (PCI SSC)** | Organization that designs and upholds Payment Card Industry Data Security Standard (PCI DSS). | | **Payment facilitator** | Entity that provides software and services to merchants so that they can run payments without the need to apply to an acquiring bank for an account. | | **Payment gateway** | Infrastructure that securely sends payment data to a processor. | | **Payment plan** | Template that describes how the merchant takes repeat payments from their customers. Merchants use a subscription to set up recurring payments for a customer. | | **Payment Processor** | Entity that communicates with [issuing banks](#issuing-bank) to authorize and [settle](#settlement) transactions. | | **Payroc App API key** | [API key](/knowledge/api-basics/api-keys) that you use to authenticate with the Payroc App and to access the Payroc Cloud Simulator. | | **Payroc Cloud Simulator** | [Web app](/knowledge/testing/payroc-cloud-simulator) that simulates our Payroc App on a virtual payment device, which you can use to test your integration in a virtual environment. | | **Payroc Insights (Formerly Partner Engage)** | Payroc's portal that hosts transaction reporting data and documents, for example, Schedule A, merchant statements, and 1099 tax forms. | | **Payroc Payment System (PPS)** | Internal system that we use to manage merchants and payments. | | **Peer-to-peer Payments (P2P)** | Payments directly between cardholders. | | **Per trans** | Set fee that applies to each transaction. | | **Personal Identification Number (PIN)** | Number that the cardholder enters into the device to verify that they are the legitimate cardholder. | | **Personally Identifiable Information (PII)** | Information that can be used to identify an individual. | | **Point of Sale (POS)** | Device or software that merchants use to run transactions. | | **Point to Point Encryption (P2PE)** | Encryption standard established by the [Payment Card Industry Security Standards Council (PCI SSC)](#pci-ssc). | | **Pre-authorization** | Temporary hold placed on a customer's account to ensure the availability of funds, such as at check-in for a hotel stay. | | **Pre-Authorized debit (PAD)** | Canadian payment system. A recipient or merchant can use PAD payments to withdraw money from a bank account when a payment is due. Commonly used for monthly payments. The account holder must complete a Pre-Authorized Debit Agreement to set up the recurring payments. | | **Precompliance** | Optional review stage that can happen before a full [dispute](#dispute), where a card network flags a possible chargeback so the [acquirer](#acquirer) and merchant can try to resolve it early. | | **Pricing agreement** | Pricing structure that the merchant signed up for when we created the processing account. | | **Primary Account Number (PAN)** | Cardholder's unique credit card or debit card number, also known as account number or long card number. | | **Processing account** | Type of account that a merchant uses to run transactions for the business. Each processing account is linked to a merchant platform. **Note**: A processing account is not the same as a [funding account](#funding-account). | | **Processing terminal** | Transaction processing settings for a physical terminal or a virtual terminal. | ## Q | Term | Definition | | --- | --- | ## R | Term | Definition | | --- | --- | | **Real-time Payments (RTP)** | Payments between bank accounts that are initiated, cleared, and settled within seconds. | | **Receiving Depository Financial Institution (RDFI)** | [NACHA](#nacha)-recognized bank or credit union that can receive [ACH](#ach) payments. | | **Recurring payments** | Payment that occurs on a regular basis, for example, a [subscription](#subscription) fee. | | **Registered Independent Sales Organization (Registered ISO)** | Independent company that sells for a Merchant Acquirer such as Payroc. See also [Independent Sales Organization (ISO)](#iso). | | **Refund** | Payment that the merchant returns to the customer if the payment is in a settled [batch](#batch). If the merchant has not settled the batch that contains the payment, they must [reverse](#reversal-void) the payment instead. | | **Remote Deposit Capture** | Method that financial institutions use to scan paper checks and electronically process them. | | **Representment** | Process of providing evidence to challenge a [chargeback](#chargeback) and asking the card network to reverse it. See also [Chargeback Reversal](#chargeback-reversal). | | **Reversal (void)** | Payment that the merchant returns to the customer if the payment is in an open [batch](#batch). If the merchant has settled the batch, they must [refund](#refund) the payment instead. | | **Reward pay, Reward pay choice** | Payroc pricing programs that pass processing fees to the customer. | | **RFC 7807** | Internet standard that defines a common format for API error messages. | ## S | Term | Definition | | --- | --- | | **Same Day Funding** | Service where a merchant can close and settle a batch as late as 4:00 CDT and receive the funds of the settled transactions the same business day. | | **Secure token** | Token that represents a customer's saved payment details and can be reused for future payments. See also [Single-use token](#single-use-token). | | **Self-Assessment Questionnaire (SAQ)** | Questionnaire that merchants complete to verify that they are [PCI-DSS](#pci-dss) compliant. | | **Semi-integrated** | Solution where a payment device sends instructions to our gateway without needing a direct connection to the merchant's POS. | | **Session token** | Token that authenticates a Hosted Fields session. It expires after 10 minutes. | | **Settlement** | Process of paying authorized funds to merchants. The settlement process includes the following steps: 1. A merchant closes and submits a batch of transactions to the payment processor. 2. The payment processor sends the transaction data to the card brand. 3. The payment processor sends the funds from the transaction to the merchant's bank account. 4. The card brand settles the batch of transactions and issues the funds to the payment processor. | | **Single-use token** | A [token](#token) that represents a cardholder's payment details. A single-use token has a 30-minute expiry and can only be used once. | | **Social security number (SSN)** | Nine-digit number that identifies a citizen or resident of the United States. | | **Society for Worldwide Interbank Financial Telecommunication (SWIFT) code** | Code that helps overseas banks identify which bank to send money to. Also known as a [BIC code](#bic). | | **Solution** | A combination of products and features that your merchant uses to process payments. | | **Standard Entry Class (SEC) Code** | Three-letter code that describes how an [Automated Clearing House (ACH)](#ach) payment is authorized. The most common ACH SEC Codes are: – **CCD** - Corporate credit or debit transaction – **TEL** - Telephone transaction – **PPD** - Prearranged payment or deposit transaction – **WEB** - Online transaction | | **Standard funding model** | Funding option that gives merchants a single, fixed daily deposit with minimal setup. It suits merchants with predictable transaction patterns. See also [Dynamic funding model](#dynamic-funding-model). | | **Sub-merchant** | Merchant customer of a [payment facilitator](#payment-facilitator). | | **Subscription** | We use a subscription to add a customer to a [payment plan](#payment-plan). | | **Surcharge** | Fee that the [payment processor](#payment-processor) charges per transaction for credit card and debit card processing. | ## T | Term | Definition | | --- | --- | | **Tax Identification Number (TIN)** | Unique nine-digit number that the Internal Revenue Service assigns to business identities operating in the U.S. Also known as [Employer Identification Number (EIN)](#ein). | | **Terminal ID (TID)** | Unique identifier of the device that initiates a payment transaction. | | **Terminal order** | Order details for one or more terminal solutions. A terminal order contains descriptions of the items, the shipping details for the items, and who is training the merchant to use the solutions. See also [Order item](#order-item). | | **Third Party Payment Processor (TPPP)** | Company that has a merchant account with a [processor](#payment-processor), through which [sub-merchants](#sub-merchant) accept credit and debit cards. Also known as an aggregator. | | **Token** | Unique identifier that represents card details or bank account details. Tokens are specific to the entity that stored them and cannot be used elsewhere if they are stolen. | | **Tokenization** | Tokenization is the process by which a financial entity saves card details or bank account details in a vault. The financial entity creates a token that represents the payment details in the vault and can be used in future payments. | | **Transaction** | Any instance where goods are exchanged for money. | ## U | Term | Definition | | --- | --- | | **Underwriting** | Process of checking that a business is legitimate and financially sound before approving it to process payments. Part of [boarding](#boarding) a new merchant. | | **Uniform resource identifier (URI)** | Identifies an internet resource. Different to a [Uniform Resource Locator (URL)](#url), which identifies and locates an internet resource. | | **Uniform resource locator (URL)** | Identifies and locates an internet resource. | | **Union Card** | Main credit network in China. | | **Unreferenced refund** | A [refund](#refund) that you issue without linking it to the original payment. You typically do this when you don't have the ID of the original payment. | | **UUID v4** | Randomly generated 36-character value used to make sure each request is unique. | ## V | Term | Definition | | --- | --- | | **V/MC/D/AE** | Visa, MasterCard, Discover, American Express. The main credit card networks in the U.S. | | **Virtual Terminal** | Website application that merchants use to accept payments. | | **Voyager** | U.S. fuel card. | ## W | Term | Definition | | --- | --- | | **Webhook** | Message that our system sends automatically to your server when something happens, instead of you checking for updates. For example, we send a webhook when a processing account's status changes. See also [Event subscription](#event-subscription). | | **WorldPay** | Payment processor. | | **Wright Express (WEX)** | Commerce platform with several business interests, including employee benefits, payment processing, and fleet services. | ## X | Term | Definition | | --- | --- | ## Y | Term | Definition | | --- | --- | ## Z | Term | Definition | | --- | --- | # Units of measurement Source: https://docs.payroc.com/knowledge/api-basics/unit-of-measure Reference list of unit of measurement codes supported by the Payroc API, covering weight, volume, length, time, energy, and quantity units. We use the following units of measurement in our API: | Code | Unit of Measurement | | :---: | :---: | | ACR | Acre | | AMH | Ampere-hour | | AMP | Ampere | | ANN | Year | | APZ | Troy or apothecaries’ ounce. 12 troy ounces = 1 troy pound. | | ARE | Are | | ASM | Alcoholic strength mass | | ASV | Alcoholic strength by volume | | ATM | Standard atmosphere | | ATT | Technical atmosphere | | BAR | Bar | | BFT | Board foot | | BHP | Brake horsepower | | BHX | Hundred boxes | | BIL | Billion, E.U. **Note:** This is equivalent to trillion in the U.S. | | BLD | Dry barrel | | BLL | Barrel | | BQL | Becquerel | | BTU | British thermal unit | | BUA | Bushel, U.S. | | BUI | Bushel, U.K. | | BX | Box | | CCT | Carrying capacity in metric tonnes | | CDL | Candela | | CEL | Degrees Celsius | | CEN | Hundred | | CGM | Centigram | | CKG | Coulomb per kilogram | | CLF | Hundred leaves | | CLT | Centiliter | | CMK | Square centimeter | | CMT | Centimeter | | CNP | Hundred packs | | CNT | Cental U.K. | | COU | Coulomb | | CS | Case | | CTM | Metric carat | | CUR | Curie | | CWA | Hundredweight U.S. | | DAA | Decare | | DAD | Ten days | | DAY | Day | | DEC | Decade | | DLT | Deciliter | | DMK | Square decimeter | | DMQ | Cubic decimeter | | DMT | Decimeter | | DPC | Dozen pieces | | DPT | Displacement tonnage | | DRA | Dram, U.S. | | DRI | Dram, U.K. | | DRL | Dozen rolls | | DRM | Drachm | | DTH | Hectokilogram | | DTN | Centner or quintal, metric | | DWT | Pennyweight | | DZN | Dozen | | DZP | Dozen packs | | DZR | Dozen pairs | | EA | Each | | EAC | Each | | FAH | Degrees Fahrenheit | | FAR | Farad | | FOT | Foot | | FTK | Square foot | | FTQ | Cubic foot | | GBQ | Gigabecquerel | | GFI | Gram of fissile isotopes | | GGR | Great gross | | GIA | Gill, U.S. | | GII | Gill, U.K. | | GLD | Dry gallon, U.S. | | GLI | Gallon, U.K. | | GLL | Liquid gallon, U.S. | | GRM | Gram | | GRN | Grain | | GRO | Gross | | GRT | Gross register tonnage | | GWH | Gigawatt-hour | | HAR | Hectare | | HBA | Hectobar | | HGM | Hectogram | | HIU | Hundred international units | | HLT | Hectoliter | | HMQ | Million cubic meters | | HMT | Hectometer | | HPA | Hectoliter of pure alcohol | | HTZ | Hertz | | HUR | Hour | | INH | Inch | | INK | Square inch | | INQ | Cubic inch | | ITM | Item | | JOU | Joule | | KBA | Kilobar | | KEL | Kelvin | | KGM | Kilogram | | KGS | Kilogram per second | | KHZ | Kilohertz | | KJO | Kilojoule | | KMH | Kilometer per hour | | KMK | Square kilometer | | KMQ | Kilogram per cubic meter | | KMT | Kilometer | | KNI | Kilogram of nitrogen | | KNS | Kilogram of named substance | | KNT | Knot | | KPA | Kilopascal | | KPH | Kilogram of caustic potash, kilogram of potassium hydroxide | | KPO | Kilogram of potassium oxide | | KPP | Kilogram of phosphoric anhydride, kilogram of phosphoric pentoxide | | KSD | Kilogram of substance, 90% dry | | KSH | Kilogram of caustic soda | | KTN | Kilotonne | | KUR | Kilogram of uranium | | KVA | Kilovolt-ampere | | KVR | Kilovar | | KVT | Kilovolt | | KWH | Kilowatt-hour | | KWT | Kilowatt | | LBR | Pound, U.K., U.S. | | LBS | Pounds | | LBT | Troy pound | | LEF | Leaf | | LPA | Liter of pure alcohol | | LTN | Long ton, imperial | | LTR | Liter | | LUM | Lumen | | LUX | Lux | | MAL | Megaliter | | MAM | Megameter | | MAW | Megawatt | | MBE | Thousand standard brick equivalent | | MBF | Thousand board-feet | | MBR | Millibar | | MCU | Millicurie | | MGM | Milligram | | MHZ | Megahertz | | MIK | Square mile | | MIL | Thousand | | MIN | Minute | | MIO | Million | | MIU | Million international units | | MLD | Billion, U.S., one thousand million) | | MLT | Milliliter | | MMK | Square millimeter | | MMQ | Cubic millimeter | | MMT | Millimeter | | MON | Month | | MQH | Cubic meter per hour | | MQS | Cubic meter per second | | MSK | Meter per second squared | | MTK | Square meter | | MTQ | Cubic meter | | MTR | Meter | | MTS | Meter per second | | MVA | Megavolt-ampere | | MWH | Megawatt-hour | | NAR | Number of articles | | NBB | Number of bobbins | | NCL | Number of cells | | NEW | Newton | | NIU | Number of international units | | NMB | Number | | NMI | Nautical mile | | NMP | Number of packs | | NMR | Number of pairs | | NPL | Number of parcels | | NPT | Number of parts | | NRL | Number of rolls | | NTT | Net register tonnage | | OHM | Ohm | | ONZ | Imperial ounce, sometimes known as an avoirdupois ounce. 16 avoirdupois ounces = 1 pound. | | OZA | Fluid ounce U.S. | | OZI | Fluid ounce U.K. | | PAL | Pascal | | PCB | Piece | | PCE | Piece | | PGL | Proof gallon | | PK | Package | | PTD | Dry pint, U.S. | | PTI | Pint, U.K. | | PTL | Pint, U.S. | | QAN | Quarter of a year | | QTD | Dry quart, U.S. | | QTI | Quart, U.K. | | QTL | Liquid quart, U.S. | | QTR | Quarter, U.K. | | RPM | Revolution per minute | | RPS | Revolution per second | | SAN | Half year | | SCO | Score | | SCR | Scruple | | SEC | Second | | SET | Set | | SHT | Shipping ton | | SIE | Siemens | | SMI | Statute mile | | SST | Short Standard | | ST | Unknown unit of measure | | STI | Stone U.K. | | STN | Short ton | | TAH | Thousand ampere-hour | | TNE | Metric tonne | | TPR | Ten pairs | | TQD | Thousand cubic meters per day | | TRL | Trillion, E.U. | | TSD | Tonne of substance 90% dry | | TSH | Ton of steam per hour | | VLT | Volt | | WCD | Cord | | WEB | Weber | | WEE | Week | | WHR | Watt-hour | | WSD | Standard | | WTT | Watt | | YDK | Square yard | | YDQ | Cubic yard | | YRD | Yard | # Payments Source: https://docs.payroc.com/knowledge/payments Understand payment methods, processing and transaction behavior. Understand payment methods, processing and transaction behavior. - [Credit card surcharging](/knowledge/payments/surcharging) - [Tokenization](/knowledge/payments/tokenization) - [Interchange fee](/knowledge/payments/interchange) - [Refunds and reversals](/knowledge/payments/refunds-and-reversals) - [Dynamic currency conversion](/knowledge/payments/currency-conversion) - [Repeat payments](/knowledge/payments/repeat-payments) - [Dynamic descriptors](/knowledge/payments/dynamic-descriptors) - [Payment plans and subscriptions](/knowledge/payments/payment-plans) - [Offline processing](/knowledge/payments/offline-processing) - [Payment method verification](/knowledge/payments/payment-method-verification) - [3-D Secure](/knowledge/payments/threedsecure) - [Enhanced data](/knowledge/payments/enhanced-data) # Credit card surcharging Source: https://docs.payroc.com/knowledge/payments/surcharging Explains how credit card surcharging works, including how merchants add a fee to cover card processing costs and the rules governing surcharge rates and disclosure. When a customer pays with their credit card, a merchant can add a surcharge to the customer’s total price to cover the cost of the merchant’s card processing fees. Merchants must display the fee separately from the total price and offer the customer two different payment options. The customer can choose to accept the surcharge and pay with their credit card or choose to pay with cash without a surcharge. For example, if a merchant is eligible for surcharging and their customer chooses to pay with their credit card: 1. Customer has a total cost for goods or services from the merchant’s store for $100. 2. Merchant adds the three percent surcharge rate to the customer’s total cost. 3. Merchant offers the customer two price options: a. $103 – Credit card payment b. $100 – Cash payment 4. Customer chooses to pay with their credit card. 5. Merchant receives a total payment of $103. ## What you need to know about surcharging Surcharges are: - Added to the total price of goods or services at the point of sale. - A maximum of three percent of the total purchase price. - A non-taxable amount because it is added only to the retail price. **Important:** Check the surcharging requirements for each state and each card brand. # Tokenization Source: https://docs.payroc.com/knowledge/payments/tokenization Explains how tokenization replaces sensitive payment details with reusable secure tokens or single-use tokens, enabling repeat payments without additional PCI compliance requirements. A token is a string that represents a customer’s payment details. Merchants use the token instead of the customer’s payment details to take a payment. To save a customer’s payment details, the merchant uses their POS to send us a tokenization request and we store the customer’s payment details in our vault. We then generate a token and send it to the merchant in the response. Tokens don’t contain any payment details and only the merchant that saved the payment details can use the token. Another benefit of tokenization is that merchants can store the tokens on their devices without any additional PCI compliance requirements. Our gateway can generate two types of tokens: - Secure tokens - Single-use tokens ## Secure tokens Secure tokens are useful for repeat payments because the merchant can use them multiple times. Merchants can also use their POS to manage their secure tokens, for example, they can update secure tokens when the customer updates their payment details. When a merchant stores payment details and creates a secure token, they must use a merchant-initiated transaction (MIT) agreement to indicate how they’re going to use the token. There are three options that merchants can choose: - **Recurring** – The merchant takes payments at set intervals until the customer cancels the payments. For example, a monthly magazine subscription. - **Installment** – The merchant takes payments over a fixed period. For example, monthly payments to pay for a household appliance. - **Unscheduled** - Payments are not part of a payment plan or regular billing schedule. For example, a dental practice charges a fee for a missed appointment. ## Single-use tokens Single-use tokens expire after 30 minutes and merchants can use them only once. After the merchant uses their POS to create a single-use token, they can’t update it or delete it. Because merchants can’t use single-use tokens for repeat payments, they don’t have to provide a MIT agreement. # Interchange fee Source: https://docs.payroc.com/knowledge/payments/interchange Explains how interchange fees are structured, what card brands charge for network use, and what factors determine which interchange category a transaction is assigned. The interchange fee is a non-negotiable fee set by card brands for the use of their networks. Payment processors like Payroc use the card brand’s networks to process credit transactions and debit transactions. The card brand assigns the transaction a target interchange category for each credit transaction and debit transaction. The rate of the interchange fee depends on which interchange category the card brand assigns to the transaction. The interchange fee is composed of: - **Set percentage (Basis Points):** Fee of 1 hundredth of 1 percentage point, for the dollar-value of each individual transaction. - **Set transaction fee:** Fee to pay for the cost of processing each individual transaction. ## Target interchange category Factors that influence what interchange category the card brand assigns to a transaction include: - Card brand - Card type - Length of time to batch - Method of transaction - Mismatched authorization amount and settlement amount - Missing or incomplete validation code - SIC (Standard Industry Classification) for merchant type - Size of transaction # Refunds and reversals Source: https://docs.payroc.com/knowledge/payments/refunds-and-reversals Explains the difference between refunds and reversals for card payments, including referenced and unreferenced refund types and when each applies. Refunds and reversals are ways to return a payment to a customer. Whether you choose to refund a payment or to reverse a payment depends on if the payment is in a closed batch or an open batch: - **Closed batch** - Refund - **Open batch** - Reversal ## Refunds If the payment is in a closed batch, refund the payment to the customer. There are two types of refund: - [Referenced](/knowledge/payments/refunds-and-reversals#referenced-refund) - [Unreferenced](/knowledge/payments/refunds-and-reversals#unreferenced-refund) ### Referenced refund A referenced refund is a refund that the merchant links directly to a previous payment. The merchant refunds the amount of the referenced payment without the customer needing to provide their payment details again. For example, if a customer wants to return an item, the merchant can look up the payment on their POS and return the payment amount directly to the customer. ### Unreferenced refund **Note:** Only certain merchant accounts can run unreferenced refunds. An unreferenced refund is a refund the merchant does not link to a previous payment. The customer needs to provide a payment method to return the funds to, and the merchant needs to specify the amount to return to the customer. For example, if a customer wants to return an item but their card has expired, the merchant can return the payment amount to a different payment method. ## Reversals **Note:** A reversal is also known as a void. If the payment is in an open batch, reverse the payment to remove it from the batch. The reversal cancels the transaction before we process it. For example, a customer buys an item in a shop and returns the item before the merchant closes the batch. The merchant can run a reversal so that they don’t charge the customer. # Dynamic currency conversion Source: https://docs.payroc.com/knowledge/payments/currency-conversion Explains how Dynamic Currency Conversion (DCC) lets cardholders pay in their home currency at point of sale, including eligibility requirements, regulations, and decision screen rules. Merchants can use the Dynamic currency conversion (DCC) service to give cardholders the option to pay in their own currency if the merchant’s currency is different. For example, a cardholder from the U.S. wants to purchase goods from a merchant in Ireland. The merchant can offer the cardholder two payment options with the DCC service: - **Pay in U.S. dollars:** Use the exchange rate of the merchant's acquiring bank:- The payment device displays the total amount of the payment, which includes the cost of the goods, the exchange rate, and mark-up percentage for the payment. - **Pay in Euros:** Use the exchange rate of the cardholder’s bank:- The payment device displays the cost of the goods, which does not include the exchange rate or potential fees from the cardholder’s bank. ## Important things to consider To offer DCC: - The merchant must be based in the UK or Ireland. - The merchant’s acquiring bank must be Elavon or AIBMS. - The cardholder’s card must be Mastercard, VISA, or Diners Club International. ## How does a payment with DCC work? 1. The cardholder presents their card to the payment device for payment. 2. The payment device displays a decision screen to the cardholder. 3. The cardholder chooses to pay in their own currency or the merchant's currency, and payment is taken from the cardholder’s account. 4. The merchant prints a receipt for the payment that contains the details of the DCC offer. **Note:** If a card isn’t eligible for DCC, the payment device should run a standard payment without the DCC decision screen. ## Regulations If a merchant offers DCC to a cardholder, the cardholder must be fully aware of the details of the DCC offer. Therefore, the decision screen and receipts have specific regulations. **Important:** The decision screen and receipt must not include misleading text or use inappropriate layout or font sizes that may confuse the cardholder. ## Decision screen The decision screen must include the following information: - Clear instruction to the cardholder to explain what they need to do, for example, “Select currency:” - Exchange rate of the transaction - Total amount of the transaction in the merchant’s currency - Total amount of the transaction in the cardholder’s currency - Mark-up percentage on the transaction- If the currency is in the European Economic Area, you must add the suffix “over ECB rate” to the mark-up percentage, for example, “3.72% over the ECB rate” - Clear options to allow the cardholder to accept or decline the offer - A disclaimer that states: "I have been offered a choice of currencies and have chosen to accept DCC and pay in \{Cardholder Currency\} at today’s exchange rate." - Details about the provider and the source of the exchange rate: "DCC provided by \{provider\}. \{Provider\} receives Foreign Exchange Transaction Services from \{source\}." ## Receipt The receipt must include the following information: - Exchange rate of the transaction - Total amount of the transaction in the merchant’s currency - Total amount of the transaction in the cardholder’s currency - Mark-up percentage of the transaction- If the currency is in the European Economic Area, you must add the suffix “over ECB the rate” to the mark-up percentage, for example, “3.72% over the ECB rate” - A disclaimer that states: "I have been offered a choice of currencies and have chosen to accept DCC and pay in \{Cardholder Currency\} at today’s exchange rate." - Details about the provider and the source of the exchange rate: "DCC provided by \{provider\}. \{Provider\} receives Foreign Exchange Transaction Services from \{source\}." # Repeat payments Source: https://docs.payroc.com/knowledge/payments/repeat-payments Explains recurring payments and installment payments, and how to choose between your own software or our gateway to manage them **Prerequisites:** [Authentication](/api/authentication) Repeat payments are payments that a merchant takes from a customer on a regular schedule. For example, a merchant may offer a monthly product such as a magazine subscription or a merchant may allow customers to split large payments into smaller regular payments. The two types of repeat payments that we support are: - **Recurring payment:** A repeat payment that has no known end date. Examples of recurring payments include:- A customer joins a merchant’s gym and the merchant takes $40 each month until the customer cancels their membership. - A customer subscribes to a weekly magazine and the merchant takes $5 each week until the customer cancels their subscription. - **Installment payment:** A single large transaction that a customer pays over a fixed period. Examples of installment payments include:- A customer buys a television for $1200 and the merchant takes $100 each month for a year. - A customer books a holiday that costs $2000 and the merchant takes $250 each month for eight months. ## Set up repeat payments To set up and manage repeat payments, you can either: - Use your own software to manage payments, and our gateway to process them. OR - Use our gateway to manage and process payments. ## Guides #### [Use your own software](/guides/payments/repeat-payments/using-your-own-system-for-recurring-billing) Use your own software to take repeat payments. #### [Use our gateway](/guides/payments/repeat-payments/using-our-gateway-for-recurring-billing) Create a payment plan to take repeat payments. # Dynamic descriptors Source: https://docs.payroc.com/knowledge/payments/dynamic-descriptors Explains how dynamic descriptors let merchants customize the transaction text displayed on a customer's card statement to reduce chargebacks. A dynamic descriptor is text that describes a transaction on a customer’s statement. A dynamic descriptor helps to reduce the risk of a chargeback because it helps the customer to identify the transaction. A dynamic descriptor can contain information about the transaction, for example: - Order number - Merchant's phone number - Merchant's Doing Business As (DBA) name **Note:** A dynamic descriptor is also known as a billing descriptor. ## How we use dynamic descriptors We use hard dynamic descriptors to display the descriptor on the customer’s statement after the processor has settled the transaction. To create a dynamic descriptor, use our custom fields feature to create a custom field and assign it as a dynamic descriptor. For more information about how to create custom fields and dynamic descriptors, go to our [Custom Fields](/guides/payments/add-custom-fields) guide. # Payment plans and subscriptions Source: https://docs.payroc.com/knowledge/payments/payment-plans Explains how payment plans and subscriptions work together to enable merchants to take recurring and installment payments from customers. Merchants use payment plans and subscriptions to take repeat payments from their customers. A payment plan is a template that describes how a merchant takes payments from their customers. To add a customer to a payment plan and take repeat payments, the merchant uses a subscription. A subscription contains information about the customer and a secure token that represents the customer’s payment details. The merchant assigns the subscription to the payment plan to start taking payments. Each subscription inherits the details of the payment plan that the merchant assigns it to. However, the merchant can adjust each subscription to change the payments without affecting the payment plan that they assigned the subscription to. For example, a merchant can pause a subscription for the first month to offer a free trial period for a customer. **Notes:** - Merchants can offer more than one payment plan. - Each payment plan can have more than one subscription. - Each subscription can contain the details of only one customer. ## Example A merchant offers two payment plans: a recurring plan, and an installment plan. The recurring plan has no fixed end date, and the installment plan has a fixed number of payments. Each payment plan has two customers subscribed to it. ```mermaid flowchart TD M["Merchant"]:::neutral RP["Recurring plan"]:::green IP["Installment plan"]:::green C1["Customer 1 subscription"]:::neutral C2["Customer 2 subscription"]:::neutral C3["Customer 3 subscription"]:::neutral C4["Customer 4 subscription"]:::neutral M --> RP & IP RP --> C1 & C2 IP --> C3 & C4 classDef green fill:#00E0B8,stroke:#001D4E,color:#001D4E classDef neutral fill:#E5E5E5,stroke:#636363,color:#001D4E ``` # Offline processing Source: https://docs.payroc.com/knowledge/payments/offline-processing Explains how offline processing allows terminals to accept card payments without a gateway connection and store them for later submission. If offline processing is enabled on a terminal, the terminal can still accept payments when it can’t connect to the gateway, for example, if the terminal loses internet connection. When a merchant runs a payment and the terminal is offline, the terminal saves the payment details and information about the transaction. When the terminal connects to the gateway, it sends the payment details to the gateway to process the payment. **Note:** Offline processing should be used only temporarily as there are risks to the merchant. For more information about the risks, see [risks of offline processing](#risks-of-offline-processing). ## How it works ```mermaid flowchart TD A([Run a payment]):::blue B[Customer presents their card]:::neutral C{Can the terminal connect to the gateway?}:::yellow D([Payment sent to the gateway for processing]):::green E{Is the terminal enabled for offline processing?}:::yellow F([Payment declined]):::red G[Terminal saves the payment details and transaction information]:::neutral H{Can the terminal connect to the gateway?}:::yellow I([Payment sent to the gateway for processing]):::green A --> B --> C C -->|Yes| D C -->|No| E E -->|No| F E -->|Yes| G --> H H -->|Yes| I H -->|No| G classDef blue fill:#0051C2,stroke:#001D4E,color:#FFFFFF classDef green fill:#00E0B8,stroke:#001D4E,color:#001D4E classDef yellow fill:#F4F7FE,stroke:#0051C2,color:#0051C2,font-size:15px classDef red fill:#DC2626,stroke:#991B1B,color:#FFFFFF classDef neutral fill:#E5E5E5,stroke:#636363,color:#001D4E ``` ## Risks of offline processing If the terminal can’t connect to the gateway, the gateway can’t authorize the payment. There are many risks involved with accepting an unauthorized payment including: - Customer could use a fraudulent card. - Customer might not have the funds to pay. - Customer could claim that they didn't authorize the payment and raise a chargeback. **Important:** The merchant is liable for funds that they can't capture from a cardholder's account and chargebacks arising from offline payments. # Payment method verification Source: https://docs.payroc.com/knowledge/payments/payment-method-verification Explains the methods available for verifying a cardholder's identity during a transaction, including PIN, signature, AVS, CVV, and 3-D Secure. When running a transaction, we recommend that a merchant verifies the payment method to make sure that the person using the card is the genuine cardholder. There are several ways that a merchant can verify a payment method: - [PIN verification](#pin-verification) - [Signature verification](#signature-verification) - [Address Verification Service (AVS)](#avs) - [Cardholder Verification Value (CVV)](#cvv) - [3-D Secure](#3-d-secure) ## PIN verification A terminal prompts a cardholder to enter their PIN if the card is: - Chip and PIN - Swipe and PIN - Contactless and the card has reached the contactless CVM limit If the terminal is connected to our gateway, our gateway verifies the PIN with the card issuer. If the terminal is running transactions offline, the terminal verifies the PIN with the chip on the card. ## Signature verification A terminal prompts a cardholder to enter their PIN if the card is: - Chip and PIN - Swipe and PIN - Contactless and the card has reached the contactless CVM limit If the terminal is connected to our gateway, our gateway verifies the PIN with the card issuer. If the terminal is running transactions offline, the terminal verifies the PIN with the chip on the card. **Note:** The major card brands such as VISA, Mastercard, and American Express don’t require a signature to complete a transaction. However, a merchant can require signatures for their own records. ## AVS During an e-Commerce transaction or a mail-order or telephone-order (MOTO) transaction, the merchant can ask the cardholder for their billing address. If the cardholder provides an address that matches the address that the cardholder has provided to their issuing bank, the transaction passes the AVS check. If the transaction does not pass the AVS check, the merchant can choose whether to accept or to decline the transaction. ## CVV During an e-Commerce transaction or a MOTO transaction, the merchant should request the CVV of the card. The CVV is a three-digit code or a four-digit code on the card. If the CVV is correct, the issuing bank approves the transaction. If the CVV is incorrect, the issuing bank declines the transaction. ## 3-D Secure Issuing banks use 3-D Secure to help prevent fraud in e-commerce payments. For more information about 3-D Secure, go to [3-D Secure](/knowledge/payments/threedsecure). # 3-D Secure Source: https://docs.payroc.com/knowledge/payments/threedsecure Explains how 3-D Secure authentication works to prevent e-commerce fraud by verifying cardholder identity with the issuing bank. Issuing banks use 3-D Secure to help prevent fraud in e-commerce payments. When a merchant runs an e-commerce payment, they can send details about the payment to the 3-D Secure service. The 3-D Secure service then sends these details to the issuing bank to assess the risk of fraud for the payment. If the risk of fraud is too high, the issuing bank then asks the cardholder to verify their identity. For example, if a cardholder wants to buy an expensive item from an online store, the issuing bank prompts the cardholder to log in to their banking app to verify their identity. 3-D Secure is also known as: - Visa Secure - Verified by Visa - Mastercard identity check - Mastercard SecureCode - American Express Safekey ## How 3-D Secure works ```mermaid flowchart TD A([Cardholder submits a payment on the merchant's checkout page]):::blue B[Merchant's POS sends the payment details to the 3-D Secure service]:::neutral C[The 3-D Secure service sends the payment details to the cardholder's issuing bank]:::neutral D[Issuing bank assesses the payment details for risk of fraud]:::neutral E{Is there a high risk of fraud?}:::yellow F([Issuing bank approves the payment]):::green G[Issuing bank prompts cardholder to verify their identity]:::neutral H{Does the cardholder verify their identity?}:::yellow I([Issuing bank declines the payment]):::red A --> B --> C --> D --> E E -->|No| F E -->|Yes| G --> H H -->|Yes| F H -->|No| I classDef blue fill:#0051C2,stroke:#001D4E,color:#FFFFFF classDef green fill:#00E0B8,stroke:#001D4E,color:#001D4E classDef yellow fill:#F4F7FE,stroke:#0051C2,color:#0051C2,font-size:15px classDef red fill:#DC2626,stroke:#991B1B,color:#FFFFFF classDef neutral fill:#E5E5E5,stroke:#636363,color:#001D4E ``` # Enhanced data Source: https://docs.payroc.com/knowledge/payments/enhanced-data Explains how to add enhanced data to card payments and qualify for lower interchange rates. To qualify for lower interchange rates in a business-to-business (B2B) or a business-to-government (B2G) card payment, merchants can add enhanced data to their payments. Enhanced data is additional information about a transaction beyond the amount and card details. Mastercard, Visa, and American Express offer programs that give merchants lower interchange rates based on the amount of enhanced data the merchant provides. | Program | Card brand | Enhanced data | | --- | --- | --- | | Level 2 | Mastercard and American Express | Tax amount and purchase order (PO) number. American Express also requires some line-item details. | | Level 3 | Mastercard | Details about each item, shipping information, duty amount, tax amount, and PO number. | | Commercial Enhanced Data Program (CEDP) | Visa | Details about each item, shipping information, duty amount, tax amount, and PO number. | **Note:** Card brands can update their requirements at any time. Even if you send all the required information, Payroc can't guarantee that the transaction qualifies for a program. ## Things to consider - Your processing terminal must support enhanced data. - Enhanced data applies only to commercial credit cards, for example, business cards and purchasing cards. - Enhanced data isn't available for all merchant category codes (MCCs). - Merchants must apply to American Express before they can qualify for Level 2. - American Express supports up to 4 line-items for each transaction. - Mastercard and Visa support up to 50 line-items for each transaction. - TSYS and FDRC terminals support tax-exempt transactions. ## Level 2 To qualify for Level 2, you need to add the following information to your payment request: - PO number - Tax amount - Subtotal **Note:** American Express also requires some line-item details, for example, a description and a price for each unit. The following table shows the API parameters you need to send in the [Create Payment](/api/payment) request to qualify for Level 2: | Information | API parameters | | --- | --- | | PO number | `customer.referenceNumber` | | Tax | `order.breakdown.taxes[].name` `order.breakdown.taxes[].amount` `order.breakdown.taxes[].taxRate` | | Subtotal | `order.breakdown.subtotal` | | Line-item details (American Express only) | `order.breakdown.items[].productCode` `order.breakdown.items[].description` `order.breakdown.items[].unitOfMeasure` `order.breakdown.items[].unitPrice` `order.breakdown.items[].quantity` | ### Example request **Mastercard** ```json { "channel": "moto", "processingTerminalId": "1234001", "operator": "Jane", "autoCapture": true, "customer": { "referenceNumber": "CustomerCode234567" }, "order": { "orderId": "OrderRef6543", "amount": 4564, "currency": "USD", "breakdown": { "subtotal": 4347, "taxes": [ { "type": "amount", "name": "Sales Tax", "amount": 217 } ] } }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "5001650000000000", "expiryDate": "1230", "cvv": "234" }, "cardholderName": "Sarah Hazel Hopper" } } } ``` **American Express** ```json { "channel": "moto", "processingTerminalId": "1234001", "operator": "Jane", "autoCapture": true, "customer": { "referenceNumber": "CustomerCode234567" }, "order": { "orderId": "OrderRef6543", "amount": 2899, "currency": "USD", "breakdown": { "subtotal": 2709, "taxes": [ { "type": "amount", "name": "Sales Tax", "amount": 190 } ], "items": [ { "productCode": "PZA-001-LG", "description": "Large Pepperoni Pizza", "unitOfMeasure": "EA", "unitPrice": 2709, "quantity": 1 } ] } }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "378282246310005", "expiryDate": "1230", "cvv": "234" }, "cardholderName": "Sarah Hazel Hopper" } } } ``` ## Level 3 To qualify for Level 3, you need to add all the information from Level 2 and the following information to your payment request: - Shipping information - Line-item details - Duty amount The following table shows the API parameters you need to send in the [Create Payment](/api/payment) request to qualify for Level 3: | Information | API parameters | | --- | --- | | PO number | `customer.referenceNumber` | | Tax | `order.breakdown.taxes[].name` `order.breakdown.taxes[].amount` `order.breakdown.taxes[].taxRate` | | Subtotal | `order.breakdown.subtotal` | | Shipping information | `customer.shippingAddress.recipientName` `customer.shippingAddress.address` `order.breakdown.freightAmount` | | Line-item details | `order.breakdown.items[].commodityCode` `order.breakdown.items[].productCode` `order.breakdown.items[].description` `order.breakdown.items[].unitOfMeasure` `order.breakdown.items[].unitPrice` `order.breakdown.items[].quantity` `order.breakdown.items[].discountRate` `order.breakdown.items[].taxes[].name` `order.breakdown.items[].taxes[].amount` `order.breakdown.items[].taxes[].taxRate` | | Duty amount | `order.breakdown.dutyAmount` | ### Example request ```json { "channel": "moto", "processingTerminalId": "1234001", "operator": "Jane", "autoCapture": true, "customer": { "referenceNumber": "CustomerCode234567", "shippingAddress": { "recipientName": "Sarah Hazel Hopper", "address": { "address1": "2 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "order": { "orderId": "OrderRef6543", "amount": 4899, "currency": "USD", "breakdown": { "subtotal": 2709, "freightAmount": 1500, "dutyAmount": 500, "taxes": [ { "type": "amount", "name": "Sales Tax", "amount": 190 } ], "items": [ { "commodityCode": "5812-0111", "productCode": "PZA-001-LG", "description": "Large Pepperoni Pizza", "unitOfMeasure": "EA", "unitPrice": 2709, "quantity": 1, "discountRate": 5.0, "taxes": [ { "type": "amount", "name": "Sales Tax", "amount": 190 } ] } ] } }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "5001650000000000", "expiryDate": "1230", "cvv": "234" }, "cardholderName": "Sarah Hazel Hopper" } } } ``` ## CEDP Visa replaced its Level 2 and Level 3 programs with CEDP, which checks the quality of the enhanced data that you send. To qualify for CEDP, you need to send the same information as Level 3. You also need to make sure that you don't send dummy data or placeholder data. For more information, see [Data quality best practices](#data-quality-best-practices). The following table shows the API parameters you need to send in the [Create Payment](/api/payment) request to qualify for CEDP: | Information | API parameters | | --- | --- | | PO number | `customer.referenceNumber` | | Tax | `order.breakdown.taxes[].name` `order.breakdown.taxes[].amount` `order.breakdown.taxes[].taxRate` | | Subtotal | `order.breakdown.subtotal` | | Shipping information | `customer.shippingAddress.recipientName` `customer.shippingAddress.address` `order.breakdown.freightAmount` | | Line-item details | `order.breakdown.items[].commodityCode` `order.breakdown.items[].productCode` `order.breakdown.items[].description` `order.breakdown.items[].unitOfMeasure` `order.breakdown.items[].unitPrice` `order.breakdown.items[].quantity` `order.breakdown.items[].discountRate` `order.breakdown.items[].taxes[].name` `order.breakdown.items[].taxes[].amount` `order.breakdown.items[].taxes[].taxRate` | | Duty amount | `order.breakdown.dutyAmount` | ### Example request ```json { "channel": "moto", "processingTerminalId": "1234001", "operator": "Jane", "autoCapture": true, "customer": { "referenceNumber": "CustomerCode234567", "shippingAddress": { "recipientName": "Sarah Hazel Hopper", "address": { "address1": "2 Example Ave.", "city": "Chicago", "state": "Illinois", "country": "US", "postalCode": "60056" } } }, "order": { "orderId": "OrderRef6543", "amount": 4899, "currency": "USD", "breakdown": { "subtotal": 2709, "freightAmount": 1500, "dutyAmount": 500, "taxes": [ { "type": "amount", "name": "Sales Tax", "amount": 190 } ], "items": [ { "commodityCode": "5812-0111", "productCode": "PZA-001-LG", "description": "Large Pepperoni Pizza", "unitOfMeasure": "EA", "unitPrice": 2709, "quantity": 1, "discountRate": 5.0, "taxes": [ { "type": "amount", "name": "Sales Tax", "amount": 190 } ] } ] } }, "paymentMethod": { "type": "card", "cardDetails": { "entryMethod": "keyed", "keyedData": { "dataFormat": "plainText", "cardNumber": "4539858876047062", "expiryDate": "1230", "cvv": "234" }, "cardholderName": "Sarah Hazel Hopper" } } } ``` ## Data quality best practices To help merchants avoid common data quality issues, Visa provides the following guidelines: | Field | Do | Don't | | --- | --- | --- | | `order.breakdown.items[].description` | Use specific product names, especially for subscriptions. | Use generic names, blanks, repeated business names, or single characters. | | `order.breakdown.items[].productCode` | Use actual stock keeping units (SKU) or meaningful descriptors. | Submit tax codes, card products, or random data. | | `order.breakdown.items[].taxes[].amount` | Provide the correct tax amount, or if the transaction is tax-exempt, send a value of `0`. | Provide incorrect or uniform tax values that don't match jurisdiction rules. | | `order.breakdown.taxes[].amount` | Provide the correct tax amount, or if the transaction is tax-exempt, send a value of `0`. | Provide incorrect or uniform tax values that don't match jurisdiction rules. | --- # Payroc Cloud Source: https://docs.payroc.com/knowledge/payroc-cloud Explains how Payroc Cloud works as a semi-integrated payments solution, enabling POS systems to communicate with payment devices through the Payroc gateway. Payroc Cloud is our semi-integrated payments solution that you can use to run card sales and refunds. With Payroc Cloud, your Point of Sale (POS) system uses our gateway to communicate with the payment device. There are two main ways that you can use Payroc Cloud: **Separate POS and payment device** - Because the communication goes through our gateway, the payment device can be on a different network or even in a different location. **POS app and Payroc App on the same payment device** - Switch from your POS app to our Payroc App, which captures the card details and then sends them to our gateway. ## How it works Your POS or POS app sends transaction information to our gateway, which then passes the information to the payment device. The payment device then uses the information to run the transaction. ```mermaid flowchart LR POS["Point of Sale"]:::blue GW["Payroc Cloud"]:::green PD["Payment Device"]:::blue POS <--> GW <--> PD classDef blue fill:#0051C2,stroke:#001D4E,color:#FFFFFF classDef green fill:#00E0B8,stroke:#001D4E,color:#001D4E ``` After the payment device completes the transaction, you can use the methods in our Payroc API to run follow-on actions. ### Differences with fully integrated solutions #### Effort **Fully integrated:** You need to develop a method for your POS to communicate with your payment device. You may also need to develop an app for the payment device. **Payroc Cloud:** Your POS communicates with the payment device through our gateway. Your POS can even communicate with payment devices on different networks. #### Security **Fully integrated:** You need to develop an app for the payment device and make sure it follows the Payment Application Data Security Standards (PA-DSS), or Payment Card Industry Data Security Standards (PCI-DSS). **Payroc Cloud:** You use our Payroc App, which already follows PCI-DSS principles. ## What we do We provide the payments devices with the Payroc App installed. **Note:** When you use Payroc Cloud, the Payroc App runs only sales and refunds. ## What you do Integrate your POS software with our API. To help you integrate, follow our [guides](/guides/payments/payroc-cloud). # How to send a signature to our gateway Source: https://docs.payroc.com/knowledge/payroc-cloud/signature-capture Explains how to capture and encode a customer's handwritten signature as a base-28 coordinate string for submission to the Payroc gateway. In some requests you can include the customer’s signature, which is used to verify the customer’s identity. To send a signature to our gateway, the signature must be in the correct format. Our gateway uses a series of co-ordinates to represent the customer’s signature. Each co-ordinate consists of an `x` value and a `y` value from a 300-pixel by 100-pixel canvas. For example, the co-ordinate `(150, 50)` represents the center of the canvas. **Note:** The y-axis starts at the top of the canvas. ![Canvas](/assets/signature-capture-y-axis.png) When the customer uses a pen or their finger to write their signature on the canvas, you must capture the co-ordinates of the signature. If the customer lifts the pen or their finger from the canvas to start a new line, use `0000` to represent the break between the lines. After the customer writes their signature, convert the co-ordinate values into base-28 then concatenate the co-ordinates into a single string. **Note:** Our gateway accepts only alphanumeric characters for the signature parameter. Before you send the concatenated string to our gateway, remove any punctuation. ## Constraints - Our gateway accepts only co-ordinates that are smaller than 300 for the x-axis and 100 for the y-axis. If your canvas is greater than 300-pixels by 100-pixels, you can use a 3:1 ratio to scale down the co-ordinates. - The maximum length of the signature value must be less than 1600 characters. If the value is greater than 1600 characters, you can decrease the sampling rate to reduce the number of co-ordinates. ## Example ![Example signature](/assets/signature-capture-cross.png) To represent a capital letter “T” on the canvas, and convert it to a value that our gateway accepts, complete the following steps: **Step 1.** Capture the decimal co-ordinates of the signature. The decimal co-ordinates of the letter T are: - `(115, 25), (185, 25)` - the top horizontal line. - `(0000)` - new line begins. - `(150, 25), (150, 75)` - the vertical line. **Step 2.** Convert the decimal co-ordinates into base-28: - `(43, 0p), (6h, 0p)` - `(0000)` - `(5a, 0p), (5a, 2j)` **Step 3.** Concatenate the base-28 co-ordinates: `430p6h0p00005a0p5a2j` # Supported Devices Source: https://docs.payroc.com/knowledge/payroc-cloud/supported-devices Reference for all card-reading devices supported across Payroc solutions, including device type, operating environment, certified processors, and integration requirements. Payroc supports a range of card-reading devices across its solutions. The table includes information about each device that we offer, including: - **Type** - Form factor of the device. - **Environment** - Indicates whether the cardholder operates the device or the merchant operates the device. - **Certified processors** - Payment processors the device is certified to work with. - **Region** - Geographic region where we have certified the device. - **Integration** - Indicates whether the device requires a software integration or can operate as a standalone terminal. **Note:** If you want to use a device with the Payroc API, we provide SDKs to help you add the device to your integration. For more information about the SDKs, go to the [POS and mPOS integration guide](https://developers.worldnetpayments.com/gochip:introduction). \ \