# Create Account Source: https://apidocs.paylias.xyz/api-reference/accounts/create-account post /api/v1/csp/account Create Account # Decrypt Account Source: https://apidocs.paylias.xyz/api-reference/accounts/decrypt-account get /api/v1/csp/account/{account_id}/decrypt Decrypt Account # Delete Account Source: https://apidocs.paylias.xyz/api-reference/accounts/delete-account delete /api/v1/csp/account/{account_id} Delete Account # Find Account Source: https://apidocs.paylias.xyz/api-reference/accounts/find-account get /api/v1/csp/account/{account_id} Find Account # List Accounts Source: https://apidocs.paylias.xyz/api-reference/accounts/list-accounts get /api/v1/csp/account List or search api keys generated against a Namespace Pagination is supported via the `limit` and `page` query parameters. # Find Payment Admission Task Source: https://apidocs.paylias.xyz/api-reference/admission-tasks/find-payment-admission-task get /api/v1/csp/payments/{payment_id}/admissions/{admission_id}/tasks/{task_id} Find Payment Admission Task # Find Payment Admission Task by Admission Source: https://apidocs.paylias.xyz/api-reference/admission-tasks/find-payment-admission-task-by-admission get /api/v1/csp/payments/{payment_id}/admissions/{admission_id}/tasks Find Payment Admission Task by Admission # Update Payment Admission Task Source: https://apidocs.paylias.xyz/api-reference/admission-tasks/update-payment-admission-task put /api/v1/csp/payments/{payment_id}/admissions/{admission_id}/tasks/{task_id} Update Payment Admission Task # Fetch Payment Admission by Payment Source: https://apidocs.paylias.xyz/api-reference/admissions/fetch-payment-admission-by-payment get /api/v1/csp/payments/{payment_id}/admissions Fetch Payment Admission by Payment # Find Payment Admission Source: https://apidocs.paylias.xyz/api-reference/admissions/find-payment-admission get /api/v1/csp/payments/{payment_id}/admissions/{admission_id} Find Payment Admission # Create API Key Source: https://apidocs.paylias.xyz/api-reference/api-authentication/create-api-key post /api/v1/csp/apikey Create a permissioned access token to access Paylias's networked APIs # Create JWT token Source: https://apidocs.paylias.xyz/api-reference/api-authentication/create-jwt-token post /api/v1/csp/organization/signin Use the `admin_email` and `admin_password` fields to generate a JWT token # Revoke API Key Source: https://apidocs.paylias.xyz/api-reference/api-authentication/revoke-api-key delete /api/v1/csp/apikey/{secret_key} Allows clients to notify the authorization server that a previously obtained refresh or access token is no longer needed # Find API Key Source: https://apidocs.paylias.xyz/api-reference/api-keys/find-api-key get /api/v1/csp/apikey/{secret_key} Retrieves details for the Api key with the specified Api Secret Key. # List API Keys Source: https://apidocs.paylias.xyz/api-reference/api-keys/list-api-keys get /api/v1/csp/apikey List or search api keys generated against a Namespace # Rotate API Key Source: https://apidocs.paylias.xyz/api-reference/api-keys/rotate-api-key post /api/v1/csp/apikey/{secret_key} The rotate endpoint generates a new API Key Secret. If you run this endpoint, any previous implementations where the old API Key secret is being used will no longer work. # Update API Key Source: https://apidocs.paylias.xyz/api-reference/api-keys/update-api-key put /api/v1/csp/apikey/{secret_key} Update a permissioned access token to access Paylias's networked APIs # Create Customer Source: https://apidocs.paylias.xyz/api-reference/customers/create-customer post /api/v1/csp/customer Create Customer # null Source: https://apidocs.paylias.xyz/api-reference/customers/delete-customer delete /api/v1/csp/customer/{payment_address} # null Source: https://apidocs.paylias.xyz/api-reference/customers/find-customer get /api/v1/csp/customer/{payment_address} # null Source: https://apidocs.paylias.xyz/api-reference/customers/patch-customer patch /api/v1/csp/customer/{payment_address} # Resolve Customer Source: https://apidocs.paylias.xyz/api-reference/customers/resolve-customer get /api/v1/csp/customer/{payment_address}/resolve Resolve Customer # Search Customers Source: https://apidocs.paylias.xyz/api-reference/customers/search-customers get /api/v1/csp/customer Search Customers # Find Payment Exceptions Source: https://apidocs.paylias.xyz/api-reference/exceptions/find-payment-exceptions get /api/v1/csp/payments/{payment_id}/exceptions Find Payment Exceptions # Health Check Source: https://apidocs.paylias.xyz/api-reference/health-check get /api/v1/csp/healthz Health Check # Create Namespace Source: https://apidocs.paylias.xyz/api-reference/namespace/create-namespace post /api/v1/csp/partner You can create a `Namespace` for an `Organization` through the dashboard by passing the required information to Paylias. The `domain` must be a string that conforms to this regexp \`^\[a-zA-Z0-9_.+-\]+@\[a-zA-Z0-9-\]+$\` and must be at a minimum 2 characters long and at a maximum 100 characters long The `name` must be a string that is at a minimum 2 characters long and at a maximum 100 characters long # Find Namespace Source: https://apidocs.paylias.xyz/api-reference/namespace/find-namespace get /api/v1/csp/partner/{partner_id} Retrieves details for the namespace. To get a namespace, you will need to provide the JWT token in the authorization header. # Search Namespaces Source: https://apidocs.paylias.xyz/api-reference/namespace/search-namespaces get /api/v1/csp/partner This endpoint makes an HTTP GET request to retrieve a list of partners from the CSP (Cloud Service Provider) API. The request includes query parameters for limiting the number of results and paginating through the data. # Create Organization Source: https://apidocs.paylias.xyz/api-reference/organizations/create-organization post /api/v1/csp/organization You can create an account for an `Organization` through the dashboard by passing the required information to Paylias. # Find Organization Source: https://apidocs.paylias.xyz/api-reference/organizations/find-organization get /api/v1/csp/organization Retrieves details for the organization. To get an organization, you will need to provide the JWT token in the authorization header. # Create Payment Source: https://apidocs.paylias.xyz/api-reference/payments/create-payment post /api/v1/csp/payments Create Payment # Find Payment Source: https://apidocs.paylias.xyz/api-reference/payments/find-payment get /api/v1/csp/payments/{payment_id} Find Payment # Search Payments Source: https://apidocs.paylias.xyz/api-reference/payments/search-payments get /api/v1/csp/payments Search Payments # Get Transaction Details Source: https://apidocs.paylias.xyz/api-reference/settlements/get-transaction-details get /api/v1/csp/settlements/{batch_id}/transactions/{transaction_id} Fetch a settled transaction within a settlement batch # List Settlement Batches Source: https://apidocs.paylias.xyz/api-reference/settlements/list-settlement-batches get /api/v1/csp/settlements List settlement batches visible to the authenticated partner # Settled Transactions in Batch Source: https://apidocs.paylias.xyz/api-reference/settlements/settled-transactions-in-batch get /api/v1/csp/settlements/{batch_id}/transactions List settled transactions for a settlement batch # Settlement Batch Details Source: https://apidocs.paylias.xyz/api-reference/settlements/settlement-batch-details get /api/v1/csp/settlements/{batch_id} Fetch merkle artefacts and net positions for a settlement batch # Create Payment Submission Source: https://apidocs.paylias.xyz/api-reference/submissions/create-payment-submission post /api/v1/csp/payments/{payment_id}/submissions Create Payment Submission # Fetch Payment Submission by Payment Source: https://apidocs.paylias.xyz/api-reference/submissions/fetch-payment-submission-by-payment get /api/v1/csp/payments/{payment_id}/submissions Fetch Payment Submission by Payment # Find Payment Submission Source: https://apidocs.paylias.xyz/api-reference/submissions/find-payment-submission get /api/v1/csp/payments/{payment_id}/submissions/{submission_id} Find Payment Submission # Fetch Transaction Source: https://apidocs.paylias.xyz/api-reference/transactions/fetch-transaction get /api/v1/csp/payments/{payment_id}/transactions/{transaction_id} Fetch Transaction # Fetch Transaction by Payment Source: https://apidocs.paylias.xyz/api-reference/transactions/fetch-transaction-by-payment get /api/v1/csp/payments/{payment_id}/transactions Fetch Transaction by Payment # Complete Validation Source: https://apidocs.paylias.xyz/api-reference/validation/complete-validation post /api/v1/csp/validate/{account_id}/{validation_id} Complete Validation # Create Validation Source: https://apidocs.paylias.xyz/api-reference/validation/create-validation post /api/v1/csp/validate/{account_id} Create Validation # Find Validation Source: https://apidocs.paylias.xyz/api-reference/validation/find-validation get /api/v1/csp/validate/{account_id}/{validation_id} Find Validation # Create Webhook Source: https://apidocs.paylias.xyz/api-reference/webhooks/create-webhook post /api/v1/csp/webhook Webhooks can be created by provinding the below listed parameters. Setting a webhook secret allows you to ensure that `POST` requests sent to the payload URL are from Paylias. When you set a secret, you'll receive the `X-Sfpy-Signature` header in the webhook `POST` request. The `events` array allows your webhook to subscribe to events that you're interested in. Please note however that no two webhooks can be subscribed to the same event. If there is an attempt to create or update a webhook where any one event in the list is already subscribed to by a previosuly created webhook, the API will return an error with status code `409` # Delete Webhook Source: https://apidocs.paylias.xyz/api-reference/webhooks/delete-webhook delete /api/v1/csp/webhook/{webhook_id} Deletes a webhooks associated with a namespace. # Find Webhook Source: https://apidocs.paylias.xyz/api-reference/webhooks/find-webhook get /api/v1/csp/webhook/{webhook_id} Retrieves details for the webhook with the specified ID. # List Delivery Errors Source: https://apidocs.paylias.xyz/api-reference/webhooks/list-delivery-errors get /api/v1/csp/webhook/{webhook_id}/errors Retrieve Webhook Delivery Errors Search for delivery errors against a webhook subscription Pagination is supported via the `limit` and `page` query parameters. # List Events Source: https://apidocs.paylias.xyz/api-reference/webhooks/list-events get /api/v1/csp/webhook/{webhook_id}/events List Events # List Webhooks Source: https://apidocs.paylias.xyz/api-reference/webhooks/list-webhooks get /api/v1/csp/webhook List or search webhooks generated against a Namespace # Update Webhook Source: https://apidocs.paylias.xyz/api-reference/webhooks/update-webhook put /api/v1/csp/webhook/{webhook_id} Webhooks can be updated by provinding the below listed parameters. Setting a webhook secret allows you to ensure that `POST` requests sent to the payload URL are from GitHub. When you set a secret, you'll receive the `X-PAYLIAS-SIGNATURE` header in the webhook `POST` request. The `add_events` array allows your webhook to subscribe to additional events while the `remove_events` array will unsubscribe the events from your webhook. Please note that the uniqueness constraint from the section above still applies. # API Resources Source: https://apidocs.paylias.xyz/concepts/api-resources Learn about the core resources that power Paylias How authentication works Guarantee safe retries and prevent duplicate operations Manage your organization Create namespaces to issue aliases Issue and manage aliases for individuals and businesses Learn how to move money with Paylias # Authentication Source: https://apidocs.paylias.xyz/concepts/authentication Learn how Paylias manages authentication Paylias authenticates your API requests using API keys that can be generated from the dashboard. All authentication is performed via HTTP Basic Auth via the `X-PAYLIAS-API-KEY` header. You do not need to pass in any additional information or a password. If a key is not included, or an incorrect key is passed, we will return a `401 - Unauthorized` HTTP status code. You must also use HTTPS, as we will reject all API requests over plain HTTP. API keys can be generated with scoped permissions to different resources as well as be assigned granularity through read and write access. This allows you to reduce the risk of a single API key compromising access to your entire Paylias account. However, we still recommend that your keys should never be exposed in any public forums, broadcasted internally within your organizations or saved in plain text inside your code repositories. ### Example Here's a simple example of passing in your API key with any Paylias API endpoint: ```bash Shell curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/customer/jane@paylias \ --header 'X-PAYLIAS-API-KEY: ' \ --header 'accept: application/json' ``` ### API Key Management Your API keys can be managed from the dashboard. Each API Key can only be used within the Namespace it was generated against to provide an added layer of security. If you feel that your key has been compromised, please revoke your key from the dashboard immediately. API keys can also be modified from the dashboard. You can modify the permissions for each API key by increasing or decreasing its access rights. Additionally, keys can be enabled or disabled as well. ### Required Headers Besides the `X-PAYLIAS-API-KEY` header, most endpoints also require the `X-Org-ID` and `X-Partner-ID` headers. * `X-Org-ID`: This refers to the unique ID of your organization. You can find this on your dashboard or through the [Login](/api-reference/api-authentication/create-jwt-token) and [Find Organization](/api-reference/organizations/find-organization) endpoints. An example organization ID looks like this `org_d1qe2es20or1uciuv4h0` * `X-Partner-ID`: This refers to the unique ID of the namespace you're making requests against. You can also find this on your dashboard or through the [Search Namespaces](/api-referece/namespace/search-namespace) endpoint. An example namespace ID looks like this `part_d1qe2ms20or1uciuv4hg` # Manage your customers Source: https://apidocs.paylias.xyz/concepts/customers/customers-api Learn how to use the Paylias Customer APIs to manage your issued aliases The Customers API allows you to issue and manage payment aliases for both individual and business users. Once created, each customer is uniquely identified by an alias within your namespace and becomes eligible to send and receive payments on the Paylias network provided they are enabled. Customers can be created directly via API and managed over time using the [Update Customer](/api-reference/customers/patch-customer) and [Delete Customer](/api-reference/customers/delete-customer) endpoints. While the assigned alias is permanent and cannot be changed, you can update other attributes such as the customer's first name, middle name, nickname, and their active status (enabled or disabled). ## Creating a Customer You can register a new customer by calling the [Create Customer](/api-reference/customers/create-customer) endpoint. This is the canonical way to issue a new alias within your namespace and associate it with an individual or business. By default, customers are created in a **DISABLED** state until explicitly enabled. ```bash Create an Individual Customer curl --request POST \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/customer \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ --data ' { "type": "Individual", "first_name": "Ziyad", "last_name": "Parekh", "middle_name": "", "payment_address": "ziyadparekh@safepay", "phone_number": "+16461234567", "email": "ziyad@gmail.com", "status": "ENABLED" }' ``` ```bash Create a Business Customer curl --request POST \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/customer \ --header 'Content-Type: application/json' \ --header 'X-PAYLIAS-API-KEY: ' \ --header 'idempotency-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --data ' { "type": "Business", "business_legal_name": "Elfbar, Inc.", "business_website": "https://elfbar.com", "business_description": "the bar for elfs", "business_trade_name": "Elfbar", "business_industry": "45678", "email": "support@elfbar.com", "payment_address": "elfbar@safepay", "status": "ENABLED" }' ``` Depending on the type of customer you're creating, you need to specify the right data to Paylias. The following table highlights which fields are applicable to which type of customer | Property | **Individual** | **Business** | | ---------------------- | -------------- | ------------ | | `type` | Y Required | Y Required | | `payment_address` | Y Required | Y Required | | `phone_number` | Y Required | O Optional | | `email` | Y Required | Y Required | | `status` | Y Required | Y Required | | `first_name` | Y Required | N/A | | `middle_name` | O Optional | N/A | | `last_name` | Y Required | N/A | | `business_legal_name` | N/A | Y Required | | `business_trade_name` | N/A | Y Required | | `business_website` | N/A | Y Required | | `business_description` | N/A | O Optional | | `business_industry` | N/A | Y Required | Once created and enabled, a customer can begin sending or receiving payments using their assigned alias. ## Updating a Customer To update a customer's details such as their name, nickname, or active status use the [Update Customer](/api-reference/customers/patch-customer) endpoint. This is a partial update operation; only the fields included in the request body will be updated. ```bash Update a customer curl --request PATCH \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/customer/{customer_id} \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ --data ' { "middle_name": "Zubair", "nick_name": "ziyadparekh" } ' ``` Note that the customer's alias (`payment_address`) is immutable and cannot be changed once assigned. While the Update Customer endpoint is fairly flexible and allows easy updates to properties, we advise to use this endpoint with care. Switching a customer from an individual to business or vice versa frequently can be seen as a sign of fraud on the network. Similarly, frequent switching of the cusomter's `business_industry` code can also be flagged by network partipants. ## Deleting a Customer If a customer no longer wishes to use Paylias or needs to be deactivated, you can perform a soft delete by calling the [Delete Customer](/api-reference/customers/delete-customer) endpoint. ```bash Archive a customer curl --request DELETE \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/customer/{customer_id} \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ ``` Deletes are final. Once a customer is deleted, their alias is sent back to the pool of available aliases under your namespace. Deleted customers cannot be restored. The Customers API is the foundation of identity on the Paylias network. It allows your platform to create and manage the individuals and businesses participating in your payment ecosystem—while keeping control over user lifecycle and compliance entirely within your infrastructure. # Overview Source: https://apidocs.paylias.xyz/concepts/customers/overview A customer is a representation of an alias issued under your namespace. Customers represent end users of your platform—whether individuals or businesses—who are issued a payment alias under your namespace. These aliases act as persistent identifiers that your users can use to send and receive payments across the Paylias network. Each customer is created and scoped within a namespace, and upon registration, they can choose a unique alias. This alias cannot be modified once issued and must be globally unique within the namespace. It serves as the primary reference for all transaction activity, enabling seamless routing of payment instructions between different participants in the network. Customers onboarded to Paylias can represent either individuals or businesses. If the customer is a business, you are required to assign them a valid 4-digit Merchant Category Code (MCC) that accurately reflects the nature of their business. Importantly, Paylias does not perform any KYC (Know Your Customer) or KYB (Know Your Business) checks. It is your responsibility as the platform operator to ensure that any customers you onboard meet your internal risk, compliance, and regulatory requirements. Paylias assumes that all participants have been properly vetted by your infrastructure before they are issued an alias. You can think of a customer in Paylias as analogous to a cardholder being issued a payment credential like a credit or debit card, where the namespace acts similarly to a BIN (Bank Identification Number). When a payment is submitted or admitted, Paylias uses the alias to resolve which namespace the customer belongs to, and routes the transaction accordingly. # Resolve a customer Source: https://apidocs.paylias.xyz/concepts/customers/resolve-customer Find details behind any alias The [Resolve Customer](/api-reference/customers/resolve-customer) endpoint allows you to verify that a payment alias is valid and belongs to an active customer. This is a critical step when building flows where users enter an alias to send or request payments, especially in push payment scenarios. Before submitting a payment, you can use this API to confirm that: * The alias exists * The associated customer is currently active * The customer’s metadata is accessible (e.g. whether they are an individual or a business) Using this API early in your payment flow can help reduce failed transaction attempts and improve your user experience. For example, if a user types an alias into your app, you can resolve that alias to validate the recipient and potentially surface their display name or business name before the payment is submitted. ## When to Use It * **Push Payments**: Before a user sends money, verify the recipient’s alias. * **Pull Payments**: Before requesting payment from a customer, confirm that their alias is active and valid. * **Risk & UX Decisions**: Retrieve additional metadata (like whether the customer is a business) and tailor your flow accordingly. * **Avoid Preventable Failures**: Prevent unnecessary calls to the Payments API that would otherwise fail due to inactive or non-existent aliases. ## Resolve a Customer ```bash Resolve customer curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/customer/{payment_address}/resolve \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ ``` ```json response expandable { "data": { "created_at": { "seconds": 1743092228 }, "first_name": "Ziyad", "last_name": "Parekh", "nick_name": "ziyad", "partner_id": "part_ct23b6420or249k5boag", "payment_address": "ziyadparekh@safepay-platinum", "status": 2, "token": "cust_cvink1420or763mhjesg", "updated_at": { "seconds": 1743092228 } }, "ok": true } ``` Replace `{payment_address}` with the alias you wish to resolve (e.g. `ziyadparekh@safepay`). By resolving an alias before attempting a payment, you not only improve reliability but also enhance confidence and security for your users. This API acts as the first touchpoint for validating intent and building trust into your payment flow. # Idempotency Source: https://apidocs.paylias.xyz/concepts/idempotence Safely retrying requests without accidentally performing the same operation twice All critical Paylias POST, PUT, PATCH and DELETE APIs require idempotency to safely allow you to make identical requests multiple times in the event of network failures or timeouts. In order to make a request idempotent, you must pass in an Idempotency-Key header with a unique value identifying that request. Read (i.e. GET) requests must not have an Idempotency-Key included as they are naturally idempotent. For 24 hours following the initial request, as long as subsequent requests contain the same Idempotency-Key value, we will guarantee that you can safely make the same request multiple times without any side effects. For example, if a request to create a Customer or a Payment object fails, you can retry with the same idempotency key to ensure that no more than one object is created. After 24 hours, you will receive a 422 when attempting to make an identical request with a previously used idempotency key for the next 24 hours. After 48 hours, the idempotency key will be pruned from our system and a new request will be generated if the same key is used. We recommend using a UUID generator in your language to create the idempotency key, store it in your database system, and then use it when calling out to Paylias. ## Example ```bash Create a payment highlight={8} expandable curl --request POST \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ --data ' { "payment_id": "cjes76vsemvj3obsnc52", "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "payment_address": "john@example.com", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": "+1234567890", "type": "Payee_Individual", "billing": { "country": "US" } }, "debtor_party": { "payment_address": "jane@example.com", "first_name": "Jane", "last_name": "Smith", "email": "jane@example.com", "phone": "+1987654321", "type": "Payer_Individual", "billing": { "country": "US" } }, "reference": "INV001", "payment_type": "Type_Pull" } ' ``` # Namespaces Source: https://apidocs.paylias.xyz/concepts/namespace Namespaces represent logical groupings of payment addresses issued by your organization. By creating and managing namespaces through the Paylias dashboard, you can provision, configure, and organize the identifiers your users rely on to send and receive payments across the Paylias network. Each namespace is tied to a unique domain, such as @acme or @globex, which serves as a branded extension for all aliases created under that namespace. Domains help clearly distinguish between different issuing entities and carry metadata that reflects your organization’s geography, brand identity, reward programs, and other operational characteristics. When you register a new namespace with Paylias, we will associate it with your organization and allocate it a unique token, which must be included in all subsequent API requests related to that namespace. This token ensures scoped access control and enables Paylias to route payment instructions, manage configurations, and enforce compliance rules specific to that namespace. If your platform supports multiple brands, products, or regional divisions, you can create distinct namespaces to reflect each one. This approach allows for tailored settings, including branding, user experiences, and transactional rules, while maintaining a clear audit trail across all issued payment addresses. Namespaces are foundational to how Paylias organizes and authorizes payments, and they act as the container for all aliases and transactional activity within your domain. Once set up, you can begin issuing aliases under the namespace, initiate transactions, and configure webhooks and policies specific to that namespace’s behavior. # Payment Exception Source: https://apidocs.paylias.xyz/concepts/payments/exceptions Sometimes a payment fails for one reason or another. Learn about how to handle exceptions. Sending and receiving payments with the Paylias Payments API is quick and simple, but sometimes a payment fails for one reason or another. If this happens, the API provides an error message to make it easy to identify the cause of the error. Exceptions are system-generated records that capture any **abnormality** or **failure** encountered during the lifecycle of a payment. These exceptions can be caused by: * Invalid or missing data from either the initiating or receiving partner * Business rule violations within Paylias * System errors, timeouts, or inconsistencies across parties Once an exception is raised, **the payment flow is halted**. To resume or retry the payment, a **new payment must be initiated**—exceptions are terminal and unrecoverable for the original request. ## How Exceptions Work Exceptions can be triggered at any stage, including: * During payment submission * While creating or processing a payment admission * While awaiting task resolution * Just before transaction finalization Whenever an exception occurs: The payment is marked as failed. A webhook is sent to both participating partners. A full exception object is stored and can be retrieved via the API. No further progress is made on the payment. ## Webhook Subscription To receive real-time notifications about exceptions, subscribe to the `payment_exception:created` event. Your endpoint will receive a webhook payload whenever a new exception is generated. ### List Exceptions for a Payment Retrieve all exception objects linked to a specific payment. ```bash curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/exceptions \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` #### Response ```json expandable { "ok": true, "data": { "count": 1, "exceptions": [ { "token": "pexc_cvk3rfk20or8munut4g0", "payment_id": "pay_123456789", "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "record_type": "PaymentSubmission", "exception_code": "O001", "exception_message": "Debtor party payment address is missing", "blame": "debtor_party", "relationships": { "payment": { "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "billing": { "country": "US" }, "email": "ziyad.parekh@gmail.com", "first_name": "Ziyad", "last_name": "Parekh", "payment_address": "ziyad@safepay-platinum", "phone": "+923008277879", "type": "Payee_Individual" }, "debtor_party": { "billing": { "country": "US" }, "email": "johnc@stripe.com", "first_name": "John", "last_name": "Collison", "payment_address": "john@stripe-platinum", "phone": "+16462442945", "type": "Payer_Individual" }, "device": {}, "expires_at": 1743276991, "initiated_at": 1743273391, "location": {}, "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "payment_id": "pay_123456789", "reference": "INV0001" } } } ] } } ``` ## Exception Object Fields | Field | Type | Description | | ----------------------- | ------ | ------------------------------------------------------------------------------------------- | | `token` | string | Unique identifier for the exception | | `payment_id` | string | Payment this exception belongs to | | `record_type` | string | Type of object that triggered the exception (`PaymentSubmission`, `PaymentAdmission`, etc.) | | `exception_code` | string | Code representing the type of failure | | `exception_message` | string | Human-readable explanation | | `blame` | string | Which party is responsible: `debtor_party`, `beneficiary_party`, or `system` | | `relationships.payment` | object | Snapshot of the original payment payload at the time of exception | ## Best Practices * Always listen for `payment_exception:created` webhooks. * Show a user-friendly message to customers when a payment fails due to an exception. * Log and monitor exception codes for debugging and support purposes. * Automatically retry payments only **after** user confirmation and correcting the root cause. # Overview Source: https://apidocs.paylias.xyz/concepts/payments/overview Learn more about how money moves on Paylias At its core, Paylias enables seamless movement of funds between users and platforms through a robust and standardized payment layer. Whether you're sending money to a friend or collecting payment at checkout, every transaction in Paylias flows through one of two fundamental types: Push Payments and Pull Payments. ## Push Payments Push payments empower users to initiate transfers from their own account to another customer’s alias. This type of payment is typically used in peer-to-peer (P2P) or person-to-business (P2B) scenarios. In a push payment, the sending customer initiates the transaction by entering the recipient’s alias and amount. Their financial platform constructs a payment request and submits it to Paylias. Paylias validates the request and issues a Payment Submission Task, which must be completed by the initiating platform before the payment can proceed. Once submitted, Paylias delivers a Payment Admission to the recipient’s financial platform, confirming receipt. Finally, a Transaction is created and both platforms are notified so they can update their customers accordingly. ```mermaid Push payment sequenceDiagram participant CA as Customer A participant PA as Partner A participant Paylias participant PB as Partner B participant CB as Customer B CA->>PA: Initiates payment to alias PA->>Paylias: Submits Payment Paylias->>PA: Returns Submission Task PA->>CA: Processes Submission Task PA->>Paylias: Submits Task Response Paylias->>PB: Submits Payment Admission Paylias->>PA: Submits Transaction Confirmation Paylias->>PB: Submits Transaction Confirmation PA->>CA: Show success PB->>CB: Show success ``` ## Pull Payments Pull payments facilitate merchant-led transactions—ideal for e-commerce checkouts, or service payments. In a pull payment, a merchant collects the customer’s alias and order information, then initiates the payment from their financial platform. The partner submits this request to Paylias, which verifies the request and sends a Payment Admission to the customer’s financial platform. Paylias also issues a Payment Admission Task, which the receiving partner must process by collecting customer authorization. Once completed, a Transaction is created and both sides are notified of the result. ```mermaid Pull payment sequenceDiagram participant M as Merchant participant PM as Merchant Partner participant Paylias participant PC as Customer Partner participant C as Customer M->>PM: Initiates payment (alias + order) PM->>Paylias: Submits Payment Paylias->>PC: Submits Payment Admission Paylias->>PC: Submits Admission Task PC->>C: Collects Customer Authorization PC->>Paylias: Submits Task Response Paylias->>PM: Transaction Confirmation Paylias->>PC: Transaction Confirmation PM->>M: Show success PC->>C: Show success ``` # Payment Source: https://apidocs.paylias.xyz/concepts/payments/payment A Payment is the core resource to orchestrate money movement on Paylias All transactions on the Paylias network begin with a **Payment**. Whether you're initiating a push or pull payment, the first step is to create a payment object that defines the intent and parties involved. A payment encapsulates key details such as the amount, payment type (push or pull), payer and payee aliases, and associated metadata like reference numbers and billing information. Once a payment is created, it can be acted upon through tasks — either a **Submission Task** (for push payments) or an **Admission Task** (for pull payments). All amounts must be specified in the **lowest denomination** of the currency (e.g. cents for USD). ## Payment APIs ### Create a Payment ```bash Create expandable curl --request POST \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ --data ' { "payment_id": "cjes76vsemvj3obsnc52", "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "payment_address": "john@example.com", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": "+1234567890", "type": "Payee_Individual", "billing": { "country": "US" } }, "debtor_party": { "payment_address": "jane@example.com", "first_name": "Jane", "last_name": "Smith", "email": "jane@example.com", "phone": "+1987654321", "type": "Payer_Individual", "billing": { "country": "US" } }, "reference": "INV001", "payment_type": "Type_Pull" } ' ``` #### Response ```json expandable { "ok": true, "data": { "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "payment_address": "john@example.com", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": "+1234567890", "type": "Payee_Individual", "billing": { "country": "US" } }, "debtor_party": { "payment_address": "jane@example.com", "first_name": "Jane", "last_name": "Smith", "email": "jane@example.com", "phone": "+1987654321", "type": "Payer_Individual", "billing": { "country": "US" } }, "device": {}, "location": {}, "expires_at": "2023-08-13T08:55:04Z", "initiated_at": "2023-08-12T08:55:04Z", "organization_id": "org_d09gv1s20or2svojjmt0", "partner_id": "part_123456789", "payment_id": "pay_123456789", "reference": "INV001", "payment_type": "Type_Pull" } } ``` ### Fetch a Payment Use this endpoint to retrieve the details of a specific payment using its `payment_id`. ```bash Find a payment curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id} \ --header 'accept: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` #### Response ```json expandable { "ok": true, "data": { "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "payment_address": "john@example.com", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": "+1234567890", "type": "Payee_Individual", "billing": { "country": "US" } }, "debtor_party": { "payment_address": "jane@example.com", "first_name": "Jane", "last_name": "Smith", "email": "jane@example.com", "phone": "+1987654321", "type": "Payer_Individual", "billing": { "country": "US" } }, "device": {}, "location": {}, "expires_at": "2023-08-13T08:55:04Z", "initiated_at": "2023-08-12T08:55:04Z", "organization_id": "org_d09gv1s20or2svojjmt0", "partner_id": "part_123456789", "payment_id": "pay_123456789", "reference": "INV001", "payment_type": "Type_Pull" } } ``` ### Search Payments You can search across your payment records using flexible filters such as `payment_id`, `reference`, alias fields, and pagination controls. ```bash curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments \ --header 'accept: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` #### Query Parameters
| Parameter | Type | Description | | ----------------------------- | ------ | -------------------------------------------- | | `payment_id` | string | Filter by a specific Payment ID | | `reference` | string | Filter by reference string (e.g. invoice ID) | | `beneficiary_payment_address` | string | Filter by the payee’s alias | | `debtor_payment_address` | string | Filter by the payer’s alias | | `limit` | string | Maximum number of records per page | | `page` | string | Page number for pagination | | `direction` | string | Optional direction filter (if applicable) | #### Response ```json expandable { "ok": true, "data": { "count": 1, "payments": [ { "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "payment_address": "john@example.com", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": "+1234567890", "type": "Payee_Individual", "billing": { "country": "US" } }, "debtor_party": { "payment_address": "jane@example.com", "first_name": "Jane", "last_name": "Smith", "email": "jane@example.com", "phone": "+1987654321", "type": "Payer_Individual", "billing": { "country": "US" } }, "device": {}, "location": {}, "expires_at": "2023-08-13T08:55:04Z", "initiated_at": "2023-08-12T08:55:04Z", "organization_id": "org_d09gv1s20or2svojjmt0", "partner_id": "part_123456789", "payment_id": "pay_123456789", "reference": "INV001" } ] } } ``` # Payment Admission Source: https://apidocs.paylias.xyz/concepts/payments/payment-admission A payment admission resource is created when the payment reaches the receiving side. A **Payment Admission** represents an incoming payment notification to a recipient's financial platform. It serves as a system generated request informing the recipient partner that one of their customers has initiated a payment. Payment Admissions are **read-only** resources—you **cannot create or modify** them via API. Instead, they are generated automatically by Paylias during the payment flow and delivered to your system via webhooks. ## Admission APIs ### Receiving Admissions To receive Payment Admissions, your platform must: * Subscribe to the `payment_admission:created` webhook event. * Implement a webhook endpoint that can securely accept and process these events. This ensures your system is notified immediately whenever an incoming payment is intended for one of your customers. ### Retrieve a Payment Admission by ID To fetch a specific Payment Admission by its ID: ```bash curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/admissions/{admission_id} \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` Replace `{payment_id}` and `{admission_id}` with the ID of the payment and admission you're looking for. #### Response ```json expandable { "ok": true, "data": { "token": "pay_adm_cvk3jvs20or8munut3mg", "payment_id": "cjes76vsemvj3obsnc52", "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "status": 1, "admission_time": 1743272447, "relationships": { "payment": { "payment_id": "cjes76vsemvj3obsnc52", "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "reference": "INV0001", "initiated_at": 1743270060, "expires_at": 1743273661, "amount": { "currency": "USD", "total": "10000" }, "debtor_party": { "payment_address": "john@stripe-platinum", "first_name": "John", "last_name": "Collison", "email": "johnc@stripe.com", "phone": "+16462442945", "type": "Payee_Individual", "billing": { "country": "US" } }, "beneficiary_party": { "payment_address": "ziyad@safepay-platinum", "first_name": "Ziyad", "last_name": "Parekh", "email": "ziyad.parekh@gmail.com", "phone": "+923008277879", "type": "Payee_Individual", "billing": { "country": "US" } }, "device": {}, "location": {} } } } } ``` ### List Admissions for a Payment You can also list all Payment Admissions linked to a given payment using the `payment_id`: ```bash curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/admissions \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` #### Response ```json expandable { "ok": true, "data": { "token": "pay_adm_cvk3jvs20or8munut3mg", "payment_id": "cjes76vsemvj3obsnc52", "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "status": 1, "admission_time": 1743272447, "relationships": { "payment": { "payment_id": "cjes76vsemvj3obsnc52", "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "reference": "INV0001", "initiated_at": 1743270060, "expires_at": 1743273661, "amount": { "currency": "USD", "total": "10000" }, "debtor_party": { "payment_address": "john@stripe-platinum", "first_name": "John", "last_name": "Collison", "email": "johnc@stripe.com", "phone": "+16462442945", "type": "Payee_Individual", "billing": { "country": "US" } }, "beneficiary_party": { "payment_address": "ziyad@safepay-platinum", "first_name": "Ziyad", "last_name": "Parekh", "email": "ziyad.parekh@gmail.com", "phone": "+923008277879", "type": "Payee_Individual", "billing": { "country": "US" } }, "device": {}, "location": {} } } } } ``` # Payment Admission Task Source: https://apidocs.paylias.xyz/concepts/payments/payment-admission-task Learn how to use Payment Admission Tasks to perform custom validation on inbound payments. **Payment Admission Tasks** are actions assigned to a partner in response to a [Payment Admission](/concepts/payments/payment-admission), typically as part of a **pull payment** scenario. They enable you to authenticate an incoming payment request with your customer before finalizing the transaction. This serves as an important checkpoint—particularly in e-commerce use cases—where funds are being requested from your customer. Payment Admission Tasks give your platform the opportunity to present the payment request to the user and require **explicit approval or rejection**. ## Purpose and Workflow When your platform receives a `Payment Admission Task`, you are expected to process it by: * Authenticating the request with your customer using your preferred mechanism (e.g., biometric, OTP, PIN) * Accepting or rejecting the task based on your customer's response or internal checks Once accepted, the task is considered complete and Paylias proceeds to create the transaction. If rejected, the payment is not processed and no funds are moved. ## Common Use Case: Pull Payments In pull payment scenarios—such as when a merchant requests a payment from a customer—the customer’s financial platform receives an Admission Task. Example: > Customer adds items to their cart, enters their Paylias, and the merchant’s partner submits a pull payment. Paylias creates a `Payment Admission` and assigns an **Admission Task** to the customer’s platform. The platform must now authenticate and confirm the request with the customer. ### Reason Codes When rejecting a task, one of the following `status_reason` values should be used: | Reason Code | Description | | ----------------------------- | ----------------------------------- | | accepted | Customer accepted the request | | invalid\_beneficiary\_details | Beneficiary info was invalid | | alias\_not\_provisioned | Alias exists but is not active | | unknown\_alias | Alias is unrecognized | | account\_closed | Customer account is closed | | duplicate\_payment | Detected as a duplicate | | blocked\_account | Customer is blocked | | currency\_mismatch | Currency not supported | | business\_reasons | Rejected due to internal policies | | deceased\_account\_holder | Account holder is deceased | | insufficient\_funds | Not enough balance | | unknown\_error | Generic system error | | fraud\_detected | Triggered fraud alert | | regulatory\_issues | Rejected due to compliance policies | | account\_unavailable | Account temporarily inaccessible | ## Webhook Integration To receive tasks in real-time, subscribe to the following webhook events: * `payment_admission_task:created` * `payment_admission_task:updated` ### Respond to an Admission Task ```bash Complete an admission task curl --request PUT \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/admissions/{admission_id}/tasks/{task_id} \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ --data ' { "status": "completed", "status_reason": "accepted" }' ``` ```bash Reject an admission task curl --request PUT \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/admissions/{admission_id}/tasks/{task_id} \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ --data ' { "status": "failed", "status_reason": "insufficient_funds" }' ``` #### Response ```json { "ok": true, "data": { "admission_id": "pay_adm_cvk3rfk20or8munut3v0", "assignee": 1, "status": 1, "status_reason": 1, "created_on": 1743273406, "modified_on": 1743273406, "name": "customer_authentication", "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "payment_id": "cjes76vsemvj3obsnc53", "token": "pat_cvk3rfk20or8munut400", "workflow": "customer_authentication" } } ``` *** #### Fetch a Task by ID ```bash Fetch curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/admissions/{admission_id}/tasks/{task_id} \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` # Payment Submission Source: https://apidocs.paylias.xyz/concepts/payments/payment-submission Once submitted, payments are propagated through the network Once a payment has been created the next required step, regardless of payment type (push or pull), is for the initiating partner to **submit** that payment to Paylias. This step signals the partner’s intent to move forward with the transaction and enables Paylias to issue admission or submission tasks to the receiving platform or finalize the payment flow. Submissions are tied to a specific payment ID and can be created, retrieved by ID, or listed per payment. ## Submission APIs ### Create a Payment Submission To submit a payment, call the [Create Payment Submission](/api-reference/submissions/create-payment-submission) endpoint. This action is required before Paylias can proceed with any further steps in the payment lifecycle. ```bash curl --request POST \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/submissions \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' ``` Replace `{payment_id}` with the ID of the payment you previously created. #### Response ```json expandable { "ok": true, "data": { "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "payment_id": "cjes76vsemvj3obsnc53", "status": 1, "submission_time": 1743273405, "token": "sub_cvk3rfc20or8munut3tg", "relationships": { "payment": { "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "billing": { "country": "US" }, "email": "ziyad.parekh@gmail.com", "first_name": "Ziyad", "last_name": "Parekh", "payment_address": "ziyad@safepay-platinum", "phone": "+923008277879", "type": "Payee_Individual" }, "debtor_party": { "billing": { "country": "US" }, "email": "johnc@stripe.com", "first_name": "John", "last_name": "Collison", "payment_address": "john@stripe-platinum", "phone": "+16462442945", "type": "Payee_Individual" }, "device": {}, "location": {}, "expires_at": 1743276991, "initiated_at": 1743273391, "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "payment_id": "cjes76vsemvj3obsnc53", "reference": "INV0001" } } } } ``` ### Retrieve a Payment Submission To retrieve a specific payment submission, use the [Find Payment Submission](/api-reference/submissions/find-payment-submission) endpoint. ```bash curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/submissions/{submission_id} \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` Replace `{payment_id}` and `{submission_id}` with the ID of the payment and submission you're looking for. #### Response ```json expandable { "ok": true, "data": { "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "payment_id": "cjes76vsemvj3obsnc53", "status": 1, "submission_time": 1743273405, "token": "sub_cvk3rfc20or8munut3tg", "relationships": { "payment": { "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "billing": { "country": "US" }, "email": "ziyad.parekh@gmail.com", "first_name": "Ziyad", "last_name": "Parekh", "payment_address": "ziyad@safepay-platinum", "phone": "+923008277879", "type": "Payee_Individual" }, "debtor_party": { "billing": { "country": "US" }, "email": "johnc@stripe.com", "first_name": "John", "last_name": "Collison", "payment_address": "john@stripe-platinum", "phone": "+16462442945", "type": "Payee_Individual" }, "device": {}, "location": {}, "expires_at": 1743276991, "initiated_at": 1743273391, "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "payment_id": "cjes76vsemvj3obsnc53", "reference": "INV0001" } } } } ``` ### List Submissions by Payment To fetch the submission(s) associated with a particular payment, use the [Fetch Submission by Payment](/api-reference/submissions/fetch-payment-submission-by-payment) endpoint. ```bash curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/submissions \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` Replace `{payment_id}` with the ID of the payment you previously created. This is useful if you want to confirm whether a submission has already been made for a given payment ID. #### Response ```json expandable { "ok": true, "data": { "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "payment_id": "cjes76vsemvj3obsnc53", "status": 1, "submission_time": 1743273405, "token": "sub_cvk3rfc20or8munut3tg", "relationships": { "payment": { "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "billing": { "country": "US" }, "email": "ziyad.parekh@gmail.com", "first_name": "Ziyad", "last_name": "Parekh", "payment_address": "ziyad@safepay-platinum", "phone": "+923008277879", "type": "Payee_Individual" }, "debtor_party": { "billing": { "country": "US" }, "email": "johnc@stripe.com", "first_name": "John", "last_name": "Collison", "payment_address": "john@stripe-platinum", "phone": "+16462442945", "type": "Payee_Individual" }, "device": {}, "location": {}, "expires_at": 1743276991, "initiated_at": 1743273391, "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "payment_id": "cjes76vsemvj3obsnc53", "reference": "INV0001" } } } } ``` # Transactions Source: https://apidocs.paylias.xyz/concepts/payments/transaction A transaction in Paylias represents a finalized commitment to move money A **Transaction** in the Paylias network is a fundamental ledger record that reflects the complete movement of funds between two partners. It adheres to double-entry accounting principles, meaning every transaction consists of both a **debit** and a **credit** line, ensuring the financial state of all parties remains consistent and auditable. Transactions are system generated and represent the successful culmination of a payment flow whether initiated via a **push** or **pull** payment. ## Key Characteristics Every transaction: * Is linked to a specific payment via its `payment_id` * Contains one debit and one credit entry in `transaction_lines` * Records lifecycle timestamps for initiation, processing, and settlement * Includes optional approval or response codes * Reflects real-time status updates and error handling through defined enums ## Transaction Fields | Field | Type | Description | | ------------------- | --------- | --------------------------------------------- | | `token` | `string` | Unique identifier for the transaction | | `transaction_id` | `string` | External-facing reference for the transaction | | `payment_id` | `string` | ID of the related payment | | `status` | `enum` | Lifecycle status of the transaction | | `transaction_lines` | `array` | List of credit/debit entries (see below) | | `response_code` | `string` | Optional processor response code | | `approval_code` | `string` | Optional authorization code | | `initiated_on` | `integer` | Timestamp when the transaction began | | `processed_on` | `integer` | Timestamp when the transaction was processed | | `settled_on` | `integer` | Timestamp when the transaction was settled | | `expires_on` | `integer` | Timestamp when the transaction expires | | `created_on` | `integer` | Timestamp when the transaction was created | | `updated_on` | `integer` | Timestamp of last update | ### Transaction Lines Each transaction line captures a single leg of the ledger entry—either a **debit** or a **credit**. Lines include: | Field | Type | Description | | ------------------ | -------- | ---------------------------------------------------------- | | `token` | `string` | Unique identifier for this transaction line | | `transaction_id` | `string` | Parent transaction | | `partner_id` | `string` | ID of the partner associated with this line | | `direction` | `enum` | Direction of funds (see below) | | `transaction_type` | `enum` | Type of transaction (e.g., payment, refund) | | `amount` | `object` | Object with `currency` and `total` (amount in minor units) | ### Status Types | Enum | Value | Description | | --------------- | ----- | ------------------------------------- | | `TS_INITIATED` | 1 | Transaction started | | `TS_PROCESSING` | 2 | Transaction is being processed | | `TS_COMPLETED` | 3 | Successfully completed | | `TS_FAILED` | 4 | Failed to complete | | `TS_REVERSED` | 5 | Manually or programmatically reversed | | `TS_EXPIRED` | 6 | Timed out | | `TS_RECOVERED` | 7 | Recovered from a failure | ### Direction Types | Enum | Value | Description | | ----------- | ----- | -------------- | | `TD_Credit` | 1 | Funds received | | `TD_Debit` | 2 | Funds sent | ### Transaction Types | Enum | Value | Description | | ------------- | ----- | -------------------------- | | `TT_PAYMENT` | 1 | Normal payment transaction | | `TT_REFUND` | 2 | Refund transaction | | `TT_REVERSAL` | 3 | Payment reversal | | `TT_FEE` | 4 | Service or platform fee | ### Retrieve a Transaction Fetch details of a specific transaction associated with a payment using the [Fetch Transaction](/api-reference/transactions/fetch-tranasction) endpoint. ```bash curl --request GET \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/transactions/{transaction_id} \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' ``` #### Response ```json expandable { "ok": true, "data": { "approval_code": "123456", "created_on": "2023-08-12T08:55:04Z", "initiated_on": "2023-08-12T08:55:04Z", "payment_id": "pay_123456789", "status": 1, "token": "trans_123456789", "transaction_id": "transaction_123456789", "updated_on": "2023-08-12T08:55:04Z", "transaction_lines": [ { "amount": { "currency": "USD", "total": "10000" }, "direction": "TD_Credit", "partner_id": "part_abc123", "token": "tline_1", "transaction_id": "transaction_123456789", "transaction_type": "TT_PAYMENT" }, { "amount": { "currency": "USD", "total": "10000" }, "direction": "TD_Debit", "partner_id": "part_xyz456", "token": "tline_2", "transaction_id": "transaction_123456789", "transaction_type": "TT_PAYMENT" } ] } } ``` # Event Structure Source: https://apidocs.paylias.xyz/concepts/webhooks/event-structure Understand the event payload and see examples for different events Currently Paylias supports webhook notifications for events that occur during the lifecycle of a payment. Additional events for other flows outside the scope of a payment will be added in due course. Your feedback is invaluable to us. Please feel free to suggest priority event categories you'd like us to focus on for future updates. ## Event definition When Paylias POSTs a notification to your endpoint, the payload will be a JSON object that contains the following fields Unique identifier for the event. Currently 1.0.0, the version in use by Paylias Webhook APIs Description of the event Currently can be one of two values: `EK_Created` or `EK_Updated` Record type of the payload Currently can be one of the following values: `RT_Payments` `RT_PaymentSubmissions` `RT_PaymentAdmissions` `RT_PaymentAdmissionTasks` `RT_Error` `RT_Transactions` The destination endpoint for the webhook subscription Object containing data associated with the event. This field will contain the resource corresponding to the `record_type` UTC Unix timestamp in seconds for when this event was created #### Example Event ```json Payment Created Event expandable { "token": "cjes76vsemvj3obsnc54", "version": "1.0.0", "event_type": "EK_Created", "resource_type": "RT_Payments", "endpoint": "https://www.postb.in/1743269295619-3870068176183", "data": { "payment_id": "cjes76vsemvj3obsnc54", "organization_id": "org_ct239n420or249k5bo90", "partner_id": "part_ct23b6420or249k5boag", "reference": "INV0001", "initiated_at": 1744270523, "expires_at": 1744274123, "amount": { "currency": "USD", "total": "10000" }, "debtor_party": { "payment_address": "john@stripe-platinum", "first_name": "John", "last_name": "Collison", "email": "johnc@stripe.com", "phone": "+16462442945", "type": "Payee_Individual", "billing": { "country": "US" } }, "beneficiary_party": { "payment_address": "ziyad@safepay-platinum", "first_name": "Ziyad", "last_name": "Parekh", "email": "ziyad.parekh@gmail.com", "phone": "+923008277879", "type": "Payee_Individual", "billing": { "country": "US" } }, "device": {}, "location": {} }, "created_at": { "seconds": 1744270524, "nanos": 58146000 } } ``` ## Notification definition When you use the [List events](/api-reference/webhooks/list-events) endpoint, or view delivered events through the dashboard, the structure is slightly different. This endpoint gives additional details surrounding the event. The notification object has the following fields Unique identifier for the notification Notification ID foreign key reference ID to link it back to the original webhook subscription Description of the event Currently can be one of two values: `1` corresponds to `EK_Created` `2` corresponds to `EK_Updated` Record type of the payload Currently can be one of the following values: `1` corresponds to`RT_Error` `2` corresponds to`RT_Payments` `3` corresponds to`RT_PaymentSubmissions` `4` corresponds to`RT_PaymentAdmissions` `5` corresponds to`RT_PaymentAdmissionTasks` `6` corresponds to`RT_Transactions` The raw bytes for the payload for the message This field contains a base64 encoded string of the JSON `event` defined above. The recipient endpoint URL HMAC signature for verifying the payload The status of the notification The number of delivery attempts made so far for this notification The timestamp of when the webhook notification was created The timestamp of when the webhook notification was last updated #### Example Webhook Notification ```json Webhook Notification { "token": "wh_cvrn9f420or7jl6nihg0", "notification_id": "notif_cvrn9es20or7jl6nihfg", "webhook_id": "whk_cvk2qqs20or7iffvl200", "event_kind": 1, "record_type": 2, "payload": "eyJ0b2tlbiI6ImNqZXM3NnZzZW12ajNvYnNuYzU0IiwidmVyc2lvbiI6IjEuMC4wIiwiZXZlbnRfdHlwZSI6IkVLX0NyZWF0ZWQiLCJyZXNvdXJjZV90eXBlIjoiUlRfUGF5bWVudHMiLCJlbmRwb2ludCI6Imh0dHBzOi8vd3d3LnBvc3RiLmluLzE3NDMyNjkyOTU2MTktMzg3MDA2ODE3NjE4MyIsImRhdGEiOnsicGF5bWVudF9pZCI6ImNqZXM3NnZzZW12ajNvYnNuYzU0Iiwib3JnYW5pemF0aW9uX2lkIjoib3JnX2N0MjM5bjQyMG9yMjQ5azVibzkwIiwicGFydG5lcl9pZCI6InBhcnRfY3QyM2I2NDIwb3IyNDlrNWJvYWciLCJyZWZlcmVuY2UiOiJJTlYwMDAxIiwiaW5pdGlhdGVkX2F0IjoxNzQ0MjcwNTIzLCJleHBpcmVzX2F0IjoxNzQ0Mjc0MTIzLCJhbW91bnQiOnsiY3VycmVuY3kiOiJVU0QiLCJ0b3RhbCI6IjEwMDAwIn0sImRlYnRvcl9wYXJ0eSI6eyJwYXltZW50X2FkZHJlc3MiOiJqb2huQHN0cmlwZS1wbGF0aW51bSIsImZpcnN0X25hbWUiOiJKb2huIiwibGFzdF9uYW1lIjoiQ29sbGlzb24iLCJlbWFpbCI6ImpvaG5jQHN0cmlwZS5jb20iLCJwaG9uZSI6IisxNjQ2MjQ0Mjk0NSIsInR5cGUiOiJQYXllZV9JbmRpdmlkdWFsIiwiYmlsbGluZyI6eyJjb3VudHJ5IjoiVVMifX0sImJlbmVmaWNpYXJ5X3BhcnR5Ijp7InBheW1lbnRfYWRkcmVzcyI6InppeWFkQHNhZmVwYXktcGxhdGludW0iLCJmaXJzdF9uYW1lIjoiWml5YWQiLCJsYXN0X25hbWUiOiJQYXJla2giLCJlbWFpbCI6InppeWFkLnBhcmVraEBnbWFpbC5jb20iLCJwaG9uZSI6Iis5MjMwMDgyNzc4NzkiLCJ0eXBlIjoiUGF5ZWVfSW5kaXZpZHVhbCIsImJpbGxpbmciOnsiY291bnRyeSI6IlVTIn19LCJkZXZpY2UiOnt9LCJsb2NhdGlvbiI6e319LCJjcmVhdGVkX2F0Ijp7InNlY29uZHMiOjE3NDQyNzA1MjQsIm5hbm9zIjo1ODE0NjAwMH19", "endpoint_url": "https://www.postb.in/1743269295619-3870068176183", "signature": "c568b3bf6d1621e9d79f8b8db3d83e4c30053fa610f265e3fd61aa4f5e123b1e123e390b26fdc74c3ab15eaef00e56d79f4c1321461f1aa9e9fbe4f9a6d78a61", "status": 0, "delivery_attempts": 1, "created_at": { "seconds": 1744270524 }, "updated_at": { "seconds": 1744270525 } }, ``` # Implementation Flow Source: https://apidocs.paylias.xyz/concepts/webhooks/implementation Create webhook subscriptions through the dashboard or through the API A typical flow to implement Paylias webhooks within your application may look like the following 1. Use the dashboard or the [Create Webhook](api-reference/webhooks/create-webhook) endpoint to subscribe to a single or multiple events. 2. If you have decided to opt in for webhook signature verification, implement your application logic for [Webhook Event Signature Verification](/concepts/webhooks/signature-verification). 3. Enable your webhook subscription through the [Update Webhook](api/reference/webhooks/update-webhook) endpoint if you haven't already done so. 4. Trigger events by [Creating a payment](/api-reference/payments/create-payment) to test the logic for receiving events from Paylias. You can [view event delivery logs](/api-reference/webhooks/list-events) and [delivery-errors](/api-reference/webhooks/list-delivery-errors) both through the API as well as on the dashboard. ## Subscribing to events Events in Paylias are structured as a JSON object with two keys: 1. `record_type`: This is the resource for which the event is being triggered 2. `event_type`: This is the operation on the resource that triggered the event. Currently Paylias supports the following combination of `record_type`s and `event_type`s | record\_type | EK\_Created | EK\_Updated | | -------------------------- | ----------- | ----------- | | `RT_Payments` | yes | yes | | `RT_PaymentSubmissions` | yes | yes | | `RT_PaymentAdmissions` | yes | yes | | `RT_PaymentAdmissionTasks` | yes | yes | | `RT_Error` | yes | no | | `RT_Transactions` | yes | no | When creating a webhook subscription, you can have a single endpoint subscribe to a single or multiple combinations of `record_type:event_type` depending on your own internal use cases and logic handling. While a single endpoint can subscribe to multiple events, an event can only be subscribed to a single endpoint. This means that if you already have an active subscription for a specific combination of `record_type:event_type` for example `RT_Payments:EK_Created`, you cannot resubscribe to this event through another endpoint. # Overview Source: https://apidocs.paylias.xyz/concepts/webhooks/overview Integrate webhooks to get realtime notifications on payment events. Paylias's [Webhooks API](/api-reference/webhooks/create-webhook) let developers manage webhook endpoints that are subscribed to webhook events for real-time updates instead of relying on API polling for faster, more efficient, and a better overall experience. Webhooks are the mechanism Paylias uses to communicate with your system to inform you of time-sensitive payment events, some of which may require action from your end. Webhook endpoints required you to provide a `url` with the https scheme and optionally a shared secret that will be used to sign the webhook payload before it is sent to your endpoint. When your endpoint is active, Paylias will deliver events through `POST` with the `application/json` content type. The endpoint should return a 200 status code back to Paylias as quickly as possible to avoid timeouts. Given the nature of payments on Paylias, webhooks related to payment events are delivered only once. This means that if your system fails to respond with an acknowledgement of receipt through a 200 http status code, an exception will be generated and the payment flow will halt. In this set of guides, we'll walk through 1. Webhook implementation 2. Supported events and event structure 3. Signature verification # Signature Verification Source: https://apidocs.paylias.xyz/concepts/webhooks/signature-verification Create webhook subscriptions through the dashboard or through the API For each event delivery, Paylias will include a webhook signature header in the HTTP request for event authenticity verification provided that your webhook subscription has been setup with a shared secret key. The signature will be available in the headers under the key `X-PAYLIAS-SIGNATURE`. Paylias uses the entire [Event](/concepts/webhooks/event-structure#event-definition) to generate signature. The payload is first marshaled to its raw JSON bytes, then an HMAC is computed over those bytes using SHA‑512 with your secret as the key, and finally the resulting digest is encoded as a hexadecimal string. ## Sample Code Please review the sample code below carefully to ensure your verification code aligns with it and passes the signature example provided below. The following code samples were generated with the help of AI. Please verify them before using them in production. ```go verification.go package webhook import ( "crypto/hmac" "crypto/sha512" "encoding/hex" ) // VerifyPayloadSignature returns true if `signature` matches the HMAC‑SHA512 of `payload` using `secret`. func VerifyPayloadSignature(secret string, payload []byte, signature string) bool { mac := hmac.New(sha512.New, []byte(secret)) mac.Write(payload) expected := hex.EncodeToString(mac.Sum(nil)) // hmac.Equal is timing‑safe return hmac.Equal([]byte(expected), []byte(signature)) } ``` ```javascript verification.js const crypto = require('crypto'); /** * @param {string} secret The HMAC secret * @param {Buffer|string} payload The raw JSON payload * @param {string} signature Hex‑encoded HMAC to verify * @returns {boolean} */ function verifyPayloadSignature(secret, payload, signature) { const expected = crypto .createHmac('sha512', secret) .update(payload) .digest('hex'); const sigBuf = Buffer.from(signature, 'hex'); const expectedBuf = Buffer.from(expected, 'hex'); if (sigBuf.length !== expectedBuf.length) return false; return crypto.timingSafeEqual(sigBuf, expectedBuf); } module.exports = { verifyPayloadSignature }; ``` ```java verification.java import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; public class WebhookVerifier { /** * Verify signature using HMAC‑SHA512. * * @param secret The HMAC secret * @param payload Raw JSON bytes * @param signature Hex‑encoded HMAC string to verify * @return true if signature is valid */ public static boolean verifySignature(String secret, byte[] payload, String signature) throws Exception { Mac mac = Mac.getInstance("HmacSHA512"); SecretKeySpec key = new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA512"); mac.init(key); byte[] rawHmac = mac.doFinal(payload); String expected = bytesToHex(rawHmac); byte[] sigBytes = signature.getBytes(StandardCharsets.UTF_8); byte[] expectedBytes = expected.getBytes(StandardCharsets.UTF_8); // constant‑time comparison return MessageDigest.isEqual(expectedBytes, sigBytes); } private static String bytesToHex(byte[] bytes) { StringBuilder sb = new StringBuilder(bytes.length * 2); for (byte b : bytes) { sb.append(String.format("%02x", b & 0xff)); } return sb.toString(); } } ``` ```ruby verification.rb require 'openssl' require 'rack/utils' # for secure_compare # @param secret [String] HMAC secret # @param payload [String] raw JSON payload # @param signature [String] hex‑encoded HMAC to verify # @return [Boolean] def verify_payload_signature(secret, payload, signature) expected = OpenSSL::HMAC.hexdigest('sha512', secret, payload) return false unless expected.bytesize == signature.bytesize Rack::Utils.secure_compare(expected, signature) end ``` # Paylias Source: https://apidocs.paylias.xyz/overview/index The payment network built for developers Paylias provides a payment network that allows push and pull payments across platforms (neobanks, acquirers, wallets) using payment aliases. The network manages identity resolution, routing to the correct platform and daily net position calculation. Participant members are then advised by Paylias to settle their calculated dues through stablecoins. ## How these guides are organized Below is a quick overview of how this documentation is organized to help you more quickly find what you're looking for: * [Quick Start](/overview/quickstart) guide helps you get up and running with our API in minutes * [Core Concepts](/core/api-resources) outline key REST resources (`Namespaces`, `Customers`, `Api Keys` etc.) along with additional details on Authentication, Idempotency and other relevant API concepts. * [Guides](/tutorials/overview) present the various payment journeys you can support to move and accept payments * [API Reference](/api-reference/api-authentication/create-jwt-token) contains all the relevant technical details, along with code examples, for our APIs. This guide assumes that you have a basic understanding of key concepts. * [Simulation](/simulation/overview) provides an understanding of how to use our Simulator service while integrating to test the various payment flows * [Settlement](/settlement/overview) provides an understanding of how Paylias manages net-settlement between all parties ## Getting help We're excited to have you build with us! If you're integrating, we will set up a shared Slack / WhatsApp channel. This will enable our teams to easily collaborate and ensure you launch as quickly as possible. # Quickstart Source: https://apidocs.paylias.xyz/overview/quickstart Start Building with Paylias APIs While our dashboard is under development, the same steps can be performed using the endpoints available in the [API reference](/api-reference). Get started with Paylias by heading over to sandbox.paylias.xyz. Create your free account. Note that Paylias will send you a unique code to the email you used to create the account. This code will be used to verify your account once its created. Once logged in, you'll be shown a page of all of your Namespaces. Since you may not have any right now, go ahead and click on the 'Create namespace' button and choose a name and domain. Note that domains cannot be edited once created.

A Namespace is a logical grouping of all other relevant API resources like `Customers`, `Api Keys` `Payments` etc. For instance if your company is called **Oyster** and you want your issued aliases to look like `customer_name@oyster`, the name you select can be Oyster but the domain should be `oyster`.
After creating your Namespace, click on the "API Keys" tab on the sub menu bar and generate a new API key. API keys can be scoped by permission and restricted to access only certain resources. You can create multiple API keys with different permissions **but please make sure to keep the keys in a secure environment.** In case you think your keys have been compromised, you can immediately revoke access from our dashboard and generate a new key. For now, on your sandbox account, go ahead and create a new API Key and grant it all permissions. We don’t offer an official SDK just yet, but you can generate one using our OpenAPI spec. Tools like Swagger Codegen or OpenAPI Generator make it easy to scaffold a client in your language of choice. To issue your first credential, you can create a Customer object that represents a user or business in your system. Head over the [Create Customer](/api-reference/customers/create-customer) endpoint, fill in the details and issue your first alias. The `Org-ID` is the unique identifier for your organization and the `Partner-ID` is the unique identifier for the namspace you just created. Both can be copied from the dashboard.

If you prefer to use the command line, you can run this request but make sure to replace the values in the header with your own. ```bash Issue an Alias curl --request POST \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/customer \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ --data ' { "first_name": "Ziyad", "last_name": "Parekh", "middle_name": "", "nick_name": "ziyad", "payment_address": "ziyad@oyster", "status": "ENABLED" } ' ```
Before requesting a payment, you must create webhook subscriptions to be notified of events as and when they take place during the payment lifecycle. While all events are required to be acknowledged at the very least, some events require follow up action from your side.

To create a webhook subscription, head over to the dashboard and click on the "Webhooks" tab on the sub menu and create a new Webhook.
* Webhooks require you to pass in a valid endpoint that lives on your server. Please note that all endpoints must be `https` (SSL enabled). * Along with an endpoint, you must also subscribe to at least one event. For now, you may subscribe to all events but in production you can choose to segregate events per endpoint for better management. * If you would like Paylias to sign webhooks (recommended), you can optionally pass in a secret key which will be used to sign the generated payload. The signature will be included under the `X-PAYLIAS-SIGNATURE` header when the event is POSTed to your server. Make sure you implement this endpoint on your server and return a response with a `200` HTTP status code.
Paylias supports both Push and Pull payments but in this example we will initiate a **Pull payment**. A pull payment essentially is a payment request - your customer is initiating a request for payment from a customer on another platform (similar to an ecommerce payment).

Payments need to be created before they are submitted to the network. Just like in the previous step where you issued you first alias, you can head over to the [Create Payment](/api-reference/payments/create-payment) endpoint, update the ``, ``, `` and `` parameters below with your own identifiers and send the request. Alternatively, if you prefer to use the command line, run this code snippet in your terminal but make sure to replace the values in the header with your own. ```bash Create a payment expandable curl --request POST \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ --data ' { "payment_id": "cjes76vsemvj3obsnc52", "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "billing": { "country": "US" }, "payment_address": "ziyad@oyster", "first_name": "Ziyad", "last_name": "Parekh", "email": "ziyad.parekh@gmail.com", "phone": "+923008277879", "type": "Payee_Individual" }, "debtor_party": { "billing": { "country": "US" }, "payment_address": "jane@paylias", "first_name": "Jane", "last_name": "Smith", "email": "jane@paylias.com", "phone": "+1987654321", "type": "Payer_Individual" }, "payment_type": "Type_Pull", "reference": "INV001" } ``` In response you should get back the following confirmation ```json expandable { "ok": true, "data": { "payment_id": "cjes76vsemvj3obsnc52", "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "payment_address": "ziyad@oyster", "first_name": "Ziyad", "last_name": "Parekh", "email": "ziyad.parekh@gmail.com", "phone": "+923008277879", "type": "Payee_Individual", "billing": { "country": "US" } }, "debtor_party": { "payment_address": "jane@paylias", "first_name": "Jane", "last_name": "Smith", "email": "jane@paylias.com", "phone": "+1987654321", "type": "Payer_Individual", "billing": { "country": "US" } }, "device": {}, "location": {}, "expires_at": "2023-08-13T08:55:04Z", "initiated_at": "2023-08-12T08:55:04Z", "reference": "INV001", "payment_type": "Type_Pull" } } ``` A few important things to note: * The `payment_id` should be a unique ID generated by **your** system. This will be used as the main identifier to trace payments throughout its lifecycle. * Currently, only `USD` is supported and all amounts must be submitted in their lowest denomination. In this example a payment of \$100.00 is being requested. * Since this is a pull payment (`"payment_type": "Type_Pull"`), your customer is the `beneficiary_party` and their customer will be the `debtor_party`. This will reverse in the case of a push payment. * To make integration faster, we recommend using these credentials for the `debtor_party` since they will be routed to our simulator for a faster feedback loop. Otherwise, you will have to find other participants who are also integrating and request aliases they have configured on their end. More information about simulating payments can be found in our Simulator guide.
Using the same `payment_id` used above, submit the payment to the network. You can head over to the [Create Payment Submission](/api-reference/submissions/create-payment-submission) endpoint, update the ``, ``, `` and `` parameters below with your own identifiers and send the request.

Alternatively, if you prefer to use the command line, run this code snippet in your terminal but make sure to replace the values in the header with your own. ```bash Submit payment curl --request POST \ --url https://sandbox.paylias.xyz/gateway/api/v1/csp/payments/{payment_id}/submissions \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --header 'x-paylias-api-key: ' \ --header 'x-org-id: ' \ --header 'x-partner-id: ' \ --header 'idempotency-key: ' \ ``` In response you should get back the following confirmation ```json Response expandable { "ok": true, "data": { "payment_id": "cjes76vsemvj3obsnc53", "status": 1, "submission_time": 1743273405, "token": "sub_cvk3rfc20or8munut3tg", "relationships": { "payment": { "amount": { "currency": "USD", "total": "10000" }, "beneficiary_party": { "billing": { "country": "US" }, "email": "ziyad.parekh@gmail.com", "first_name": "Ziyad", "last_name": "Parekh", "payment_address": "ziyad@oyster", "phone": "+923008277879", "type": "Payee_Individual" }, "debtor_party": { "payment_address": "jane@paylias", "first_name": "Jane", "last_name": "Smith", "email": "jane@paylias.com", "phone": "+1987654321", "type": "Payer_Individual", "billing": { "country": "US" } }, "device": {}, "expires_at": 1743276991, "initiated_at": 1743273391, "location": {}, "payment_id": "cjes76vsemvj3obsnc53", "reference": "INV0001" } } } } ```
After submitting your payment, monitor your webhook logs to be notified as the payment travels through the network to the correct participant, its customer and finally, back to you. Once the payment has been confirmed, a Transaction is created both, yours and your debitor's, systems are notified and the payment is marked as completed.
Congratulations! You've just requested and received confirmation of your first payment. You can now reference subsequent guides to gain a deeper understanding of the various concepts we support along with how settlement works. # Overview Source: https://apidocs.paylias.xyz/settlement/overview A preview of how Paylias calculates and settles net positions between participants using Merkle trees and smart contracts. # Net Settlement on Paylias Traditional payment networks like Visa and Mastercard rely on net settlement to resolve balances between issuers and acquirers. But these systems are closed, expensive, and built on legacy financial infrastructure that wasn’t designed for modern software platforms. At Paylias we're rebuilding the settlement layer from the ground up—using open infrastructure, programmable money, and verifiable proofs to enable netting across platforms on-chain. This is a preview of how Paylias calculates net positions between participants and settles funds using stablecoins and smart contracts. ## How it works Settlement on Paylias runs once per day, at a predefined cutoff window. During this window, all transactions flowing through the network are recorded. When the cutoff hits, the engine kicks off. ### 1. Aggregate transactions The engine collects all transactions initiated during the cutoff window. This includes: * Push payments from one alias to another * Pull requests (like a merchant requesting payment from a customer) * Refunds, and network-level fee adjustments ### 2. Group by participant Each transaction is tied to two participants: * The **issuer** — the participant initiating the transaction * The **acquirer** — the participant receiving funds We use this mapping to understand the directional flow of funds across the network. ### 3. Calculate net positions Instead of settling each transaction individually, we collapse all activity into a single net position for each participant. * Credits (funds received) are added * Debits (funds sent or refunded) are subtracted The result is a single value per participant: a **net credit** (they are owed funds) or a **net debit** (they owe funds into the network). ## Submitting to the blockchain Once all net positions are calculated, they are encoded into a Merkle tree. Each leaf in the tree represents a participant’s final position: ```json { "partner_id": "part_xyz", "amount": 125000, "direction": "credit" } ``` The root of the tree is published to a Paylias smart contract on-chain. Participants receive a Merkle proof that they can later use to settle their dues. For a detailed walkthrough of how we use Merkle trees in this process, read our blog post, [Netting Payments with Merkle Trees](https://paylias.xyz/blog/merkle-trees). ## On-chain settlement Once the root is live: * Participants with a debit position are expected to fund the smart contract * Participants with a credit position can withdraw their funds, but only once all required funds have been received This gating ensures that no participant is paid until all dues have been funded, enabling atomic net settlement across the entire network. ## Why this matters Most fintechs today are locked out of direct access to settlement networks. They rely on expensive intermediaries and opaque pricing structures just to move money between platforms. Paylias makes this infrastructure accessible. By pushing settlement on-chain: * There is no central clearing house * Every participant has a cryptographic proof of what they owe or are owed * The entire flow is verifiable, programmable, and capital efficient ## What’s next This system is still in development. We’re currently: * Finalizing smart contract logic for proof verification and withdrawal gating * Designing tooling for reconciliation, test rounds, and monitoring * Iterating on feedback and refining the system If you’re a fintech, a wallet provider, or a stablecoin issuer and have feedback on how you would like settlement to work for your platform, I'd love to speak with you! Reach out to me at [ziyad@paylias.xyz](mailto:ziyad@paylias.xyz). # Overview Source: https://apidocs.paylias.xyz/simulation/overview Testing payments is a necessary part of the business, yet a challenging one to address. Use our simulator to speed up your integration Integrating a payment network like Paylias means that you often have to find another party integrating at the same time in order to send payment requests back and forth to each other to test out various success and failure scenarios. To overcome this catch 22 situation, we're building a simulator that you can interact with independently of others to ensure that your integration covers all possible use cases and edge cases. Our simulator is still a work in progress and more details will be added soon # Integrate Paylias as an Acquirer Source: https://apidocs.paylias.xyz/tutorials/acquirer/accept-payments Build a Next JS app to accept payments from your customers Coming soon! # Integrate Paylias as an Issuer Source: https://apidocs.paylias.xyz/tutorials/issuer/incoming-payments Build a Next JS app to manage incoming payments for your customers In this tutorial we're going to build a simple but feature complete Next JS application that lets your users view and take action against incoming payment requests that they have initiated using their payment alias. This tutorial is written from an issuer's point of view and is relevant for any company that manages an account or wallet balance on behalf of their customers. There's no database or other "production ready" things, so we can stay focused on Paylias. We expect this to take about 30 minutes if you're following along, otherwise it's a quick read so let get to it! ## Setup In our Next JS app that lets issuers surface pending tasks in the UI, and approve or reject them, we’ll use: 1. A singleton in-memory DB 2. ShadCN UI components 3. Lucide icons ```bash Scaffold your project # 1. Scaffold Next.js App Router with TypeScript npx create-next-app@latest paylias-issuer --typescript --app cd paylias-issuer # 2. Install dependencies npm install uuid @types/uuid lucide-react # 3. Initialize ShadCN UI (Tailwind + components) npx shadcn@latest init ``` In-memory DB means data resets on restart. For production, swap in a real database. ### Start the app ```bash # If you haven't already cd into the app directory cd paylias-issuer # start the app npm run dev ``` You should be able to open up [http://localhost:3000](http://localhost:3000) (or depending on your settings it should open up automatically) and see the default Next JS screen. ## Folder structure Next, you're going to want to create a folder struture similar to this layout. ```markdown folder structure paylias-issuer/ ├── app/ │ ├── api/ │ │ ├── webhook/ │ │ │ ├── payment-admission/ │ │ │ │ ├── created/route.ts │ │ │ │ └── updated/route.ts │ │ │ ├── payment-admission-task/ │ │ │ │ ├── created/route.ts │ │ │ │ └── updated/route.ts │ │ │ └── …other webhooks… │ │ └── tasks/ │ │ ├── route.ts ← GET all │ │ └── [token]/route.ts ← GET/PUT single │ └── page.tsx ← Main UI ├── components/ │ ├── NavBar.tsx │ └── task/ │ ├── TaskList.tsx │ ├── TaskItem.tsx │ ├── StatusBadge.tsx │ └── TaskModal.tsx ├── database/ │ └── memory-db.ts ├── repository/ │ └── taskRepository.ts ├── types/ │ └── task.ts ├── lib/ │ ├── utils.ts ← `cn()` helper │ └── signature.ts ← webhook signature verification ├── package.json └── tsconfig.json ``` The main thing to get right here are the files under the `api/webhook` folder. We're going to opt for creating a separate route for each webhook event to keep a clear separation of concerns and since we're using Next JS's app based routing system, that means we need to create the following files ```markdown expandable app/api/webhook/payment/created/route.ts app/api/webhook/payment/updated/route.ts app/api/webhook/payment-submission/created/route.ts app/api/webhook/payment-submission/updated/route.ts app/api/webhook/payment-admission/created/route.ts app/api/webhook/payment-admission/updated/route.ts app/api/webhook/payment-admission-task/created/route.ts app/api/webhook/payment-admission-task/updated/route.ts app/api/webhook/payment-exception/created/route.ts app/api/webhook/payment-transaction/created/route.ts ``` Once these files have been created, add this placeholder code in each file for now. Later on in this guide, we'll update the ones relevant for an issuer. ```ts Webhook POST handler expandable import { NextRequest, NextResponse } from 'next/server'; export async function POST(request: NextRequest) { try { // Parse the webhook payload const body = await request.json(); // Log the webhook payload for debugging console.log('Payment created webhook received:', body); // Here you would typically: // 1. Validate the webhook signature // 2. Process the payment created event // 3. Update your database accordingly // For now, just return a successful response return NextResponse.json( { message: 'Payment created webhook processed successfully' }, { status: 200 } ); } catch (error) { console.error('Error processing payment created webhook:', error); return NextResponse.json( { error: 'Internal server error' }, { status: 500 } ); } } ``` ### Signature Verification Finally, we'll add a helper function to validate the webhook signature from incoming events sent by Paylias. Open up the `lib/signature.ts` file and add in the following code. ```ts signature.ts expandable import crypto from 'crypto'; export function verifyPayloadSignature( secret: string, payload: Buffer | string, signature: string ): boolean { const expected = crypto .createHmac('sha512', secret) .update(payload) .digest('hex'); const sigBuf = Buffer.from(signature, 'hex'); const expectedBuf = Buffer.from(expected, 'hex'); if (sigBuf.length !== expectedBuf.length) return false; return crypto.timingSafeEqual(sigBuf, expectedBuf); } ``` ## Data Layer Next up, we'll define our basic data models to handle our internal representation of an incoming Payment Request, create a simple in-memory database and a repository layer that will let us perform our CRUD operations. Create a file under `types` called `task.ts` if you haven't already done so and paste this inside ```ts task.ts export enum TaskStatus { VERIFYING = "verifying", PENDING = "pending", ACCEPTED = "accepted", REJECTED = "rejected", } export interface Task { token: string; // payment_id from Paylias payment_id: string; // admission_id from Paylias admission_id: string; // task_id from Paylias task_id: string; amount: string; currency: string; status: TaskStatus; exception: string; } ``` Our task model will hold properties that are both internal to our issuer wallet app as well as properties from Paylias that identify an incoming [Payment](/concepts/payments/payment). In a production app, you can model this through database relations if required, but for now, we'll focus on simplicity to get a working app integrated with Paylias. Next, we'll define our in memory database as a simple `class` that manages a `Map`. Open up the `database/memory-db.ts` file (or create one if you haven't) and add the following code inside ```ts memory-db.ts expandable import { Task } from "../types/task"; class MemoryDatabase { private static instance: MemoryDatabase; private constructor() {} public static getInstance(): MemoryDatabase { if (!MemoryDatabase.instance) { MemoryDatabase.instance = new MemoryDatabase(); } return MemoryDatabase.instance; } public getTasks(): Map { return taskStore; } public addTask(task: Task): void { taskStore.set(task.payment_id, task); } public getTask(paymentId: string): Task | undefined { return taskStore.get(paymentId); } public updateTask(paymentId: string, updates: Partial): Task | null { const existing = taskStore.get(paymentId); if (!existing) { return null; } const updated = { ...existing, ...updates }; taskStore.set(paymentId, updated); return updated; } public deleteTask(paymentId: string): boolean { return taskStore.delete(paymentId); } public getAllTasks(): Task[] { return Array.from(taskStore.values()); } public clear(): void { taskStore.clear(); } } export default MemoryDatabase; ``` If you save your app, you may notice some build errors because the `taskStore` variable is not defined. Because we have chosen to use an in-memory database, in Next, (whether in dev with HMR or in production on Vercel’s serverless functions), the data in this module can be torn down and re-evaluated at any time, so tasks gets reset. In order to avoid this and truly get one bucket of memory to live across all imports (& HMR reloads) in a single Node process, you need to hang it on the Node “global”. So create a new file inside the `database` folder called `global-db.ts` and add this code ```ts global-db.ts expandable import { Task } from "../types/task"; // 1) Tell TypeScript about your new global... declare global { var _TASK_STORE: Map | undefined; } // 2) Initialize it once (or reuse the existing one) export const taskStore: Map = global._TASK_STORE ?? new Map(); // 3) Ensure it’s always on global if (!global._TASK_STORE) { global._TASK_STORE = taskStore; } ``` And add an import to your `memory-db.ts` file to fix the compile errors. ```js memory-db.ts icon="code" lines highlight={2} import { Task } from "../types/task"; import { taskStore } from "@/database/global-db"; ``` As a last step for the data layer, we'll define a simple TaskRepository that will allow us to manipulate tasks in the `memory-db`. So go ahead and open up the file `repository/taskRepository.ts` and add the following code inside. ```ts taskRepository.ts expandable import { v4 as uuidv4 } from "uuid"; import { Task, TaskStatus } from "@/types/task"; import MemoryDatabase from "@/database/memory-db"; export class TaskRepository { private db: MemoryDatabase; constructor() { this.db = MemoryDatabase.getInstance(); } public createTask(data: Omit): Task { const task: Task = { ...data, token: uuidv4(), status: TaskStatus.VERIFYING, exception: "", }; this.db.addTask(task); return task; } public findByPaymentId(paymentId: string): Task | undefined { return this.db.getTask(paymentId); } public findByToken(token: string): Task | undefined { const tasks = this.db.getAllTasks(); return tasks.find((t) => t.token === token); } public updateTask( paymentId: string, updates: Partial>, ): Task | null { return this.db.updateTask(paymentId, updates as Partial); } public getAllTasks(): Task[] { return this.db.getAllTasks(); } public deleteTask(paymentId: string): boolean { return this.db.deleteTask(paymentId); } } export default TaskRepository; ``` ## Webhook implementation Now that we've set up the data layer, we'll look into implementing the relevant webhooks required to build out our issuer app! If you haven't already, we recommend going through the [Webhook guides](/concepts/webhooks/overview) to get an understanding of what webhooks are and how they work. Once you've completed the guides, you can start implementing the webhooks for your issuer app. Since we're opting to create an individual endpoint for each combination of `record_type` and `event_type`, the first step we have to complete is to create webhook subscriptions on Paylias for each endpoint. You can follow the [Webhook Implementation](concepts/webhooks/implementation) guide to create the endpoint subscriptions on Paylias. Since Paylias cannot deliver webhooks to localhost, we're going to first have to expose our app through a tunnel. We recommend using [ngrok](https://ngrok.com/). You may need to create a free account and install it on your system before proceeding further. ### Side step You can run this command in another terminal window to expose your app through ngrok to the internet. ```bash # Replace with the port your app is running on ngrok http ``` You should see an output similar to this in your terminal ```bash lines highlight={8} Session Status online Account Ziyad Parekh (Plan: Free) Update update available (version 3.25.0, Ctrl-U to update) Version 3.23.3 Region United States (us) Latency 280ms Web Interface http://127.0.0.1:4040 Forwarding https://f0fd330d752f.ngrok-free.app -> http://localhost:3000 ``` Copy the URL that ngrok has assigned to your local app and use that as the base url when creating webhook subscriptions for Paylias. For example, for each of your webhook endpoints defined in the app, the full URL that you need to use when creating the webhook subscriptions will be as follows ```markdown expandable https://f0fd330d752f.ngrok-free.app/api/webhook/payment/created https://f0fd330d752f.ngrok-free.app/api/webhook/payment/updated https://f0fd330d752f.ngrok-free.app/api/webhook/payment-submission/created https://f0fd330d752f.ngrok-free.app/api/webhook/payment-submission/updated https://f0fd330d752f.ngrok-free.app/api/webhook/payment-admission/created https://f0fd330d752f.ngrok-free.app/api/webhook/payment-admission/updated https://f0fd330d752f.ngrok-free.app/api/webhook/payment-admission-task/created https://f0fd330d752f.ngrok-free.app/api/webhook/payment-admission-task/updated https://f0fd330d752f.ngrok-free.app/api/webhook/payment-exception/created https://f0fd330d752f.ngrok-free.app/api/webhook/payment-transaction/created ``` Using these endpoints, you can create webhook subscriptions using either the dashboard or the [Create Webhook](/api-reference/webhooks/create-webhook.mdx) API. Make sure you subscribe to the right combination of `record_type` and `event_type` for each endpoint on your app ### Implementation Now, we’ll implement only the four Paylias webhooks an Issuer needs When Paylias notifies us that a new payment admission has been created, we will * Parse the payload to extract the relevant information * Validate the signature in the header * Create a new Task record in your database with the amount and currency in the payment and status `PENDING` * Add a placeholder to trigger any risk-check logic * Send a response back to Paylias to acknowledge receipt of the webhook ```json payload.json expandable { "token":"pay_adm_d1rnv8k20or466p1vdl0", "version":"1.0.0", "event_type":"EK_Created", "record_type":"RT_PaymentAdmissions", "endpoint":"https://.../payment-admission/created", "data": { "token":"pay_adm_d1rnv8k20or466p1vdl0", "payment_id":"6644397b-acf3-456a-80d0-26ed2f9e84ef", "status":4, "admission_time":1752661922, "relationships": { "payment": { "payment_id":"6644397b-acf3-456a-80d0-26ed2f9e84ef", "reference":"INV001", "payment_type":1, "initiated_at":1752661918, "expires_at":1752665518, "amount":{"currency":"USD","total":"25000"}, "debtor_party":{/*…*/}, "beneficiary_party":{/*…*/}, "device":{/*…*/}, "location":{/*…*/} } } }, "created_at":{"seconds":1752661923,"nanos":289599000} } ``` ```ts route.ts expandable // app/api/webhook/payment-admission/created/route.ts import { NextResponse } from "next/server"; import { taskRepo } from "@/repository/taskRepository"; import { verifyPayloadSignature } from "@/lib/signature.ts" // import { riskEngine } from "@/services/riskEngine"; // optional export async function POST(req: Request) { const body = await req.json(); const repository = new TaskRepository(); const { data } = body; // 1. Verify webhook signature const webhookSecret = process.env.ADMISSION_CREATED_WH_SIGNATURE; const signature = req.headers["X-PAYLIAS-SIGNATURE"]; const payload = Buffer.from(JSON.stringify(data)); if (!verifyPayloadSignature(webhookSecret, payload, signature)) { return NextResponse.json({ error: "Invalid signature" }, { status: 401 }); } // 2. Extract payment details const { payment_id, relationships: { payment: { amount: { currency, total } } } } = data; // 3. Create a pending task repository.createTask({ payment_id, amount: total, currency }); // 4. (Optional) Run risk checks // await riskEngine.evaluate(payment_id); return NextResponse.json({ success: true }, { status: 200 }); } ``` When Paylias notifies us that a new payment admission task has been created, we will * Parse the payload to extract the relevant information * Validate the signature in the header * Look up the original task * Update the task to either `PENDING` or `REJECTED` * Send a response back to Paylias to acknowledge receipt of the webhook ```json payload.json expandable { "token": "pat_d1ro6p420or466p1ved0", "version": "1.0.0", "event_type": "EK_Updated", "record_type": "RT_PaymentAdmissionTasks", "endpoint": "https://.../payment-admission-task/created", "data": { "token": "pat_d1ro6p420or466p1ved0", "payment_id": "fa6c3c55-a5ec-455d-afcf-3f89d35bca0a", "admission_id": "pay_adm_d1ro6p420or466p1vec0", "created_on": 1752662884, "modified_on": 1752662907, "name": "customer_authentication", "workflow": "customer_authentication", "assignee": 1, "status": 1 }, "created_at": { "seconds": 1752662908, "nanos": 580380000 } } ``` ```ts route.ts expandable // app/api/webhook/payment-admission-task/created/route.ts import { NextResponse } from "next/server"; import { taskRepo } from "@/repository/taskRepository"; import { TaskStatus } from "@/types/task"; export async function POST(req: Request) { const body = await req.json(); const repository = new TaskRepository(); const { data } = body; // 1. Verify webhook signature const webhookSecret = process.env.ADMISSION_TASK_CREATED_WH_SIGNATURE; const signature = req.headers["X-PAYLIAS-SIGNATURE"]; const payload = Buffer.from(JSON.stringify(data)); if (!verifyPayloadSignature(webhookSecret, payload, signature)) { return NextResponse.json({ error: "Invalid signature" }, { status: 401 }); } // 2. Find original task const { payment_id, admission_id, token: task_id } = data; const task = taskRepo.findByPaymentId(payment_id); if (!task) { return NextResponse.json({ error: "Task not found" }, { status: 404 }); } // Optionally look up your risk checks and if you don't want to reject this payment // on behalf of your customer, you can use the update admissions task API to reject // the task. // 2. Update the approval task taskRepo.updateTask({ payment_id, task_id, status: TaskStatus.PENDING }); return NextResponse.json({ success: true }, { status: 200 }); } ``` If Paylias sends an event notifying us that there was an exception during the payment processing flow, we'll update the task to `REJECTED` and save the error message. ```json payload.json expandable { "token": "pay_exc_d1rjk2c20or466p1vcn0", "version": "1.0.0", "event_type": "EK_Created", "record_type": "RT_Error", "endpoint": "https://.../payment-exception/created", "data": { "token": "pay_exc_d1rjk2c20or466p1vcn0", "payment_id": "0245c72e-3644-4bd3-a86a-c453477cac95", "record_type": "RT_PaymentAdmissionTasks", "exception_code": "T22", "exception_message": "invalid payment admission task: failed" }, "created_at": { "seconds": 1752644105, "nanos": 881304000 } } ``` ```ts route.ts expandable // app/api/webhook/payment-exception/created/route.ts import { NextResponse } from "next/server"; import { taskRepo } from "@/repository/taskRepository"; import { TaskStatus } from "@/types/task"; export async function POST(req: Request) { const body = await req.json(); const repository = new TaskRepository(); const { data } = body; // 1. Verify webhook signature const webhookSecret = process.env.ADMISSION_TASK_CREATED_WH_SIGNATURE; const signature = req.headers["X-PAYLIAS-SIGNATURE"]; const payload = Buffer.from(JSON.stringify(data)); if (!verifyPayloadSignature(webhookSecret, payload, signature)) { return NextResponse.json({ error: "Invalid signature" }, { status: 401 }); } // 2. Locate the pending task const { payment_id, exception_message } = data; const task = taskRepo.findByPaymentId(payment_id); if (!task) { return NextResponse.json({ error: "Task not found" }, { status: 404 }); } // 2. Mark as rejected taskRepo.updateTask(task.payment_id, { status: TaskStatus.REJECTED, exception: exception_message }); return NextResponse.json({ success: true }, { status: 200 }); } ``` The final step in the payment journey is marking the payment complete. When you receive this event, the payment is considered as final and any deductions in the user's balance and ledger updates should be made on your platform (preferably asynchronously so you can respond back to Paylias quickly). The [Transaction Resource](/concepts/payments/transaction) guide explains this in more details. ```json payload.json expandable { "token": "txn_d1ro6v420or466p1veeg", "version": "1.0.0", "event_type": "EK_Created", "record_type": "RT_Transactions", "endpoint": "https://585d2031870a.ngrok-free.app/api/webhook/payment-transaction/created", "data": { "token": "txn_d1ro6v420or466p1veeg", "transaction_id": "d1ro6us20or486mvtda0", "payment_id": "fa6c3c55-a5ec-455d-afcf-3f89d35bca0a", "status": 1, "transaction_lines": [ { "token": "line_d1ro6v420or466p1vef0", "transaction_id": "txn_d1ro6v420or466p1veeg", "partner_id": "part_d1qdifs20or1uciuv43g", "direction": 2, "transaction_type": 1, "amount": { "currency": "USD", "total": "25000" } }, { "token": "line_d1ro6v420or466p1veg0", "transaction_id": "txn_d1ro6v420or466p1veeg", "partner_id": "part_d1qe2ms20or1uciuv4hg", "direction": 1, "transaction_type": 1, "amount": { "currency": "USD", "total": "25000" } } ], "approval_code": "7ISH9B", "initiated_on": 1752662908, "created_on": 1752662908, "updated_on": 1752662908, "relationships": { "payment": { "payment_id": "fa6c3c55-a5ec-455d-afcf-3f89d35bca0a", "reference": "INV001", "payment_type": 1, "initiated_at": 1752662880, "expires_at": 1752666480, "amount": { "currency": "USD", "total": "25000" }, "debtor_party": { "payment_address": "ziyad@safepay", "first_name": "Jane", "last_name": "Smith", "email": "jane@example.com", "phone": "+1987654321", "type": "Payee_Individual", "billing": { "country": "US" } }, "beneficiary_party": { "payment_address": "skins@coinbase", "first_name": "Primary", "last_name": "Skincare", "email": "john@example.com", "phone": "+1234567890", "type": "Payee_Individual", "billing": { "country": "US" } }, "device": { "browser": "Chrome" }, "location": { "ip_address": "192.168.1.1" } } } }, "created_at": { "seconds": 1752662908, "nanos": 638403000 } } ``` ```ts route.ts expanadable // app/api/webhook/payment-transaction/created/route.ts import { NextResponse } from "next/server"; import { taskRepo } from "@/repository/taskRepository"; import { TaskStatus } from "@/types/task"; export async function POST(req: Request) { const body = await req.json(); const repository = new TaskRepository(); const { data } = body; // 1. Verify webhook signature const webhookSecret = process.env.ADMISSION_TASK_CREATED_WH_SIGNATURE; const signature = req.headers["X-PAYLIAS-SIGNATURE"]; const payload = Buffer.from(JSON.stringify(data)); if (!verifyPayloadSignature(webhookSecret, payload, signature)) { return NextResponse.json({ error: "Invalid signature" }, { status: 401 }); } // 2. Find the existing task const { payment_id } = data; const task = taskRepo.findByPaymentId(payment_id); if (!task) { return NextResponse.json({ error: "Task not found" }, { status: 404 }); } // 2. Mark as accepted taskRepo.updateTask(task.payment_id, { status: TaskStatus.ACCEPTED }); // 3. Initiate async processing through a queue or something // to make ledger entries, debit user balance, send notifications // etc. return NextResponse.json({ success: true }, { status: 200 }); } ``` ## Front-End UI Now that we've set up majority of the application at the backend, its time to move on to the frontend so that our users can see and respond to their payment requests. The general functionality we're going to develop on the frontend will include * Displaying a list of all `Tasks` in a column view * Polling for all tasks in the background and updating the list * Taking action on `PENDING` tasks to allow our user to either accept or reject them. This is a fairly simple UI/UX implementation meant for demostration purposes only. In your production application you would most likely use push notifications as new tasks come in to your system and have a separate notification page or tray to display any pending tasks to your user. Lets get to it! ### Install shad-cn components First off, we'll install the relevant Shad Cn components needed to build our UI. Open up a terminal window and `cd` into the root directory of your app. Once there copy-paste this command ```bash npx shadcn-ui@latest add badge button card dialog label select ``` ### Create components Once these have been installed, add the following components under the `components` directory. ```ts NavBar.tsx expandable "use client"; import { RefreshCw } from "lucide-react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import React from "react"; interface NavBarProps { /** SVG logo or any element to render on the left */ logo?: React.ReactNode; /** If no logo is provided, a title can also be displayed */ title?: string; } export function NavBar({ logo }: NavBarProps) { return (
{logo ? logo : title}
); } export default NavBar; ``` ```ts StatusBadge.tsx expandable "use client"; import { Badge } from "@/components/ui/badge"; import { TaskStatus } from "@/types/task"; import { cn } from "@/lib/utils"; interface StatusBadgeProps { status: TaskStatus; } export function StatusBadge({ status }: StatusBadgeProps) { const statusStyles: Record = { [TaskStatus.PENDING]: "bg-orange-100 text-orange-800 dark:bg-orange-800/30 dark:text-orange-400", [TaskStatus.ACCEPTED]: "bg-green-100 text-green-800 dark:bg-green-800/30 dark:text-green-400", [TaskStatus.REJECTED]: "bg-red-100 text-red-800 dark:bg-red-800/30 dark:text-red-400", }; return ( {status} ); } export default StatusBadge; ``` ```ts Task.tsx expandable "use client"; import { Card, CardContent } from "@/components/ui/card"; import { cn } from "@/lib/utils"; import { Task, TaskStatus } from "@/types/task"; import { useMemo } from "react"; import StatusBadge from "@/components/StatusBadge"; interface TaskItemProps { task: Task; onClickAction: () => void; } export function TaskItem({ task, onClickAction }: TaskItemProps) { const formattedAmount = useMemo(() => { const value = Number(task.amount) / 100; return new Intl.NumberFormat(undefined, { style: "currency", currency: task.currency, }).format(value); }, [task.amount, task.currency]); return ( {formattedAmount} ); } ```
### Fetch All Tasks Now that we've created the basic components needed to display a Task, we're going to create an endpoint that will return us a list of tasks for us to render in a list. Open up `app/api/tasks/route.ts` and add in the following code ```ts route.ts expandable // app/api/tasks/route.ts import { NextResponse } from "next/server"; import { TaskRepository } from "@/repository/taskRepository.ts"; import { TaskStatus } from "@/types/task"; export async function GET() { const repository = new TaskRepository(); const all = repository.getAllTasks(); // filter out any tasks that have VERIFYING status const filtered = all.filter((task) => task.status !== TaskStatus.VERIFYING); // reverse the list so that the newest tasks show up on top. return NextResponse.json(filtered.reverse()); } ``` We're going to use this endpoint in the following `TasksList` component to poll for all tasks every 5 seconds. Lets create the `TasksList` component now. Create a new file under `components` called `TasksLists.tsx` and add in the following code ```ts TasksList.tsx expandable "use client"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { AlertTriangle } from "lucide-react"; import { Card, CardContent } from "@/components/ui/card"; import { Task } from "@/types/task"; import { TaskItem } from "@/components/Task"; export function TaskList({}) { const router = useRouter(); const [tasks, setTasks] = useState([]); useEffect(() => { const interval = setInterval(async () => { try { const res = await fetch("http://localhost:3000/api/tasks", { method: "GET", }); if (!res.ok) { throw new Error("Failed to fetch tasks"); } const tasks = await res.json(); setTasks(tasks); } catch (err) { console.error("Polling failed:", err); } }, 5000); return () => clearInterval(interval); }, [router]); if (tasks.length === 0) { return (

No tasks found that require any action.

); } return (
{tasks.map((task) => ( router.push(`/update-task?taskId=${task.token}`) } /> ))}
); } ``` Lets put all of this together now. Open up `app/page.tsx` and replace the existing code with the following ```ts page.tsx expandable import Navbar from "@/components/NavBar"; import { TaskList } from "@/components/TaskList"; export default async function Home() { return (
); } ``` When you refresh your browser, you should see your Navbar and under that a message that says "No tasks found that require any action." Since we don't have any tasks in our database, there's nothing to display at the moment but that will change once we start receiving incoming payment requests. But lets *assume* our webhooks will work as expected and implement the functionality required to take action on a `PENDING` task. ### Updating a task Updating the task is a two step process. When our user clicks on a task they want to action on, we'll open up a dialog that will first fetch the task along with its details from our database. Then, depending on whether they want to approve or reject the payment request, we'll update the task accordingly and respond to Paylias with our decision. To make this work, lets first start with implementing the two endpoints we're going to need. Open up the `/api/tasks/[task-id]route.ts` file and add in the code below to implement both the `GET` and `PUT` endpoints. ```ts route.ts expandable import { NextRequest, NextResponse } from "next/server"; import { v4 as uuidv4 } from "uuid"; import { TaskRepository } from "@/repository/taskRepository.ts"; import { TaskStatus } from "@/types/task"; export async function GET( req: NextRequest, { params }: { params: { "task-id": string } }, ) { const repository = new TaskRepository(); const { "task-id": token } = await params; const task = repository.findByToken(token); if (!task) { return NextResponse.json({ error: "Not found" }, { status: 404 }) } return NextResponse.json(task); } export async function PUT( req: NextRequest, { params }: { params: { "task-id": string } }, ) { const repository = new TaskRepository(); const body = await req.json(); const { "task-id": token } = await params; const status = body.status as TaskStatus; if (![TaskStatus.ACCEPTED, TaskStatus.REJECTED].includes(status)) { return NextResponse.json({ error: "Invalid status" }, { status: 400 }); } const task = repository.findByToken(token); if (!task) { return NextResponse.json({ error: "Not found" }, { status: 404 }); } const payload = { status: status === TaskStatus.ACCEPTED ? "completed" : "failed", status_reason: status === TaskStatus.ACCEPTED ? "accepted" : "insufficient_funds" // use a generic rejection reason for now but change this based on your use case }; const response = await fetch( `${process.env.PAYLIAS_BASE_URL}/csp/payments/${task.payment_id}/admissions/${task.admission_id}/tasks/${task.task_id}`, { method: "PUT", headers: { "Content-Type": "application/json", "X-Paylias-Api-Key": process.env.PAYLIAS_API_SECRET || "", "X-Org-ID": process.env.PAYLIAS_ORG_ID || "", "X-Partner-ID": process.env.PAYLIAS_PARTNER_ID || "", "Idempotency-Key": uuidv4(), }, body: JSON.stringify(payload), }, ); return NextResponse.json(response); } ``` In our implementation of the `PUT` endpoint we're also calling the [Update Admission Task](/api-reference/admission-tasks/update-payment-admission-task) endpoint. You'll notice that we're not updating the task in our database yet. If we reject the task, Paylias will trigger an Exception event which our `/api/webhook/payment-exception/created` endpoint will catch. This is where our the task will be updated in our system. Similarly, if we approve the task, Paylias will trigger a Transaction event which our `/api/webhook/payment-transaction/created` endpoint will catch. This is where we will mark the task as `COMPLETED`. The final step in this guide is to implement the UI for updating a task. We'll accomplish this using the [``](https://ui.shadcn.com/docs/components/dialog) component from Shad Cn along with implementing [parallel and intercepting](https://nextjs.org/docs/app/api-reference/file-conventions/intercepting-routes) routes from Next JS. Create a new file under the `components` directory called `UpdateTask.tsx` and add in the following code ```ts UpdateTask.tsx expandable "use client"; import React, { useCallback, useEffect, useState } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import { Loader2, CheckCircle, AlertTriangle } from "lucide-react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Task, TaskStatus } from "@/types/task"; export function TaskModal({}) { const router = useRouter(); const searchParams = useSearchParams(); const taskId = searchParams.get("taskId"); const [task, setTask] = useState(null); useEffect(() => { fetch(`/api/tasks/${taskId}`) .then((res) => res.json()) .then((data: Task) => { if (data.hasOwnProperty("error")) { setTask(null); return; } setTask(data); }); }, [taskId]); const renderIcon = () => { if (task?.status === TaskStatus.PENDING) { return ; } if (task?.status === TaskStatus.REJECTED) { return ; } if (task?.status === TaskStatus.ACCEPTED) { return ; } return null; }; const renderLabel = () => { switch (task?.status) { case TaskStatus.PENDING: return "Task is pending"; case TaskStatus.ACCEPTED: return "Task has been accepted"; case TaskStatus.REJECTED: return "Task has been rejected"; default: return ""; } }; const updateTask = useCallback( async (status: string) => { const response = await fetch(`/api/tasks/${taskId}`, { method: "PUT", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ status }), }); if (!response.ok) { console.error("Failed to update task status"); return; } router.back(); }, [taskId, router], ); const isPending = task?.status === TaskStatus.PENDING; return ( router.back()}> {task ? ( <> Task Status {renderIcon()} {renderLabel()}
) : ( No Task Found )}
); } export default TaskModal; ``` Now that our client component is ready, we'll wire it up to the rest of our app so its accessible through routing. Create the following folder structure under your `app` directory. ```markdown ├── app/ │ ├── @modal/ │ │ ├── (.)update-task/ │ │ │ ├── page.tsx │ │ ├── default.tsx │ ├── update-task/ │ │ ├── page.tsx ``` Now add the following code to the relevant files ```ts app/@modal/(.)update-task/page.tsx import TaskModal from "@/components/UpdateTask"; export default function Page() { return ; } ``` ```ts app/@modal/default.tsx export default function Default() { return null; } ``` ```ts app/update-task/page.tsx export default function UpdateTaskFallbackPage() { return (

You are on the update task page

This is the fallback when accessed directly without modal context.

); } ```
## Conclusion That's it! You've just implemented money-movement as an issuer for your customers. We're grateful for giving Paylias a try and we hope this tutorial gives you a solid start to build great user experiences. There's a lot more you can do like [Creating namespaces](/concepts/namespace), [Issuing aliases](/concepts/customers/overview) and, if your use-case supports accepting payments, [Integrating Paylias as an Acquirer](/tutorials/acquirer/accept-payments). Be sure to check out our [Api Reference](/api-reference/api-authentication/create-jwt-token) and reach out at [ziyad@paylias.xyz](mailto:ziyad@paylias.xyz) if you need any help! # Overview Source: https://apidocs.paylias.xyz/tutorials/overview Learn how to build an issuer or acquirer app by following our tutorials Build an app to handle incoming payment requests Build an app to accept payments from customers