# 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## 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.

## 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.

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:
\
**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

### ACH form

### PAD form

## 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:

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