### Refund Payment Success Response Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md This is an example of a successful response when a payment is refunded. It includes details about the refund and the original transaction. ```json { "status": "success", "data": { "refund": { "transactionType": "REFUND", "status": "COMPLETED", "refundedAmount": "number", "date": "number (timestamp)", "referenceNumber": "string", "dailyTransactionID": "string", "name": "string", "phoneNumber": "string", "email": "string" }, "originalTransaction": { "transactionType": "PAYMENT", "status": "COMPLETED", "date": "number (timestamp)", "referenceNumber": "string", "dailyTransactionID": "string", "name": "string", "phoneNumber": "string", "email": "string", "message": "string", "total": "number", "tax": "number", "subtotal": "number", "fee": "number", "netAmount": "number", "totalRefundedAmount": "number", "metadata1": "string", "metadata2": "string", "items": "array" } } } ``` -------------------------------- ### Amount Under Minimum Error Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/errors.md Indicates an error when the transfer amount is below the minimum allowed. ```json { "status": "error", "message": "The transfer amount is under Minimum allowed", "errorcode": "BTRA_0001", "data": null } ``` -------------------------------- ### Empty Request Body Error Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/errors.md Represents an error where a required request body is missing. ```json { "status": "error", "message": "Required request body is missing", "errorcode": "BTRA_0006", "data": null } ``` -------------------------------- ### Refund Payment Request Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md Use this JSON payload to initiate a refund for a completed transaction. Ensure the amount is valid and does not exceed the original transaction total. Partial refunds are supported. ```json { "publicToken": "hdb932832klnasKJGDW90291", "privateToken": "JHEFEWP2048FNDFLKJWB2", "referenceNumber": "fdew98ffw9fbfewkjb", "amount": "1.00", "message": "Customer requested refund" } ``` -------------------------------- ### Transaction Status Error Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/errors.md Illustrates a common error when transaction processing fails on the backend. ```json { "status": "error", "message": "No authorization header present.", "errorcode": "token.invalid.header", "data": null } ``` -------------------------------- ### Expired Token Error Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/errors.md Shows the error response when an API token has expired. ```json { "status": "error", "message": "The Token has expired on Fri Oct 28 15:21:00 AST 2022.", "errorcode": "token.expired", "data": null } ``` -------------------------------- ### Authorization Service Response Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md This JSON object represents a successful response from the Authorization Service endpoint, indicating a completed e-commerce transaction. ```json { "status": "success", "data": { "ecommerceStatus": "COMPLETED", "ecommerceId": "730e2c49-9387-11ed-8f43-c31784ccfc6c", "referenceNumber": "215070443-402894c185ab1be40185acfe61c2000b", "transactionDate": "2023-01-13 16:17:06", "dailyTransactionId": "0006", "businessName": "Tdameritrade", "total": 1, "fee": 0.6000000238418579, "netAmount": 0.40 } } ``` -------------------------------- ### Cancel Payment Success Response Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md A successful response for a cancelled payment indicates the cancellation was processed. ```json { "status": "success", "data": "Payment Cancelled." } ``` -------------------------------- ### Payment Service Request Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md This JSON payload is used to create a payment ticket or order via the Payment Service endpoint. Ensure all required fields like publicToken, total, metadata, phoneNumber, and items are correctly populated. ```json { "env": "production", "publicToken": "a66ce73d04f2087615f6320b724defc5b4eedc55", "timeout": "5000", "total": "10", "tax": "1", "subtotal": "9", "metadata1": "Store ID 123", "metadata2": "Location 456", "phoneNumber": "5613305493", "items": [ { "name": "Product Name", "description": "Product Description", "quantity": "1", "price": "10", "tax": "1", "metadata": "metadata" } ] } ``` -------------------------------- ### Payment Service Success Response Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md This JSON structure represents a successful response from the Payment Service endpoint. It contains the status and essential data including the unique ecommerceId and the authorization token. ```json { "status": "success", "data": { "ecommerceId": "0ab257f5-3837-11ed-855f-9b4af5a393ce", "auth_token": "eyJraWQiOiJVVTZpdEt0U0N5Tm9abUFkWkt3ZGxpSDE2SDk5SXI5clNFeXJwbzh6dVVFIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ..." } } ``` -------------------------------- ### Example JWT Header Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/configuration.md The JWT authorization token header contains information about the token's encryption and type. It is used to authorize transaction completion. ```json { "kid": "UU6itKtSCyNoZmAdZKwdliH16H99Ir9rSEyrpo8zuUE", "typ": "JWT", "alg": "RS256" } ``` -------------------------------- ### Example Public Token Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/configuration.md The public token identifies the ATH Business merchant account and is included in most API requests. It is a 40-character hexadecimal string. ```text a66ce73d04f2087615f6320b724defc5b4eedc55 ``` -------------------------------- ### Update Payment Phone Number Request Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md This JSON object demonstrates the structure for updating a customer's phone number for a transaction before it is confirmed. Ensure the 'ecommerceId' and 'phoneNumber' fields are correctly populated. ```json { "ecommerceId": "177a50fd-39fb-11ed-8b3d-230262020527", "phoneNumber": "7866575255" } ``` -------------------------------- ### Cancel Payment Request Example Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md Submit this JSON payload to cancel an active transaction before it has been completed. You must provide the transaction's ecommerce ID and your public token. ```json { "ecommerceId": "177a50fd-39fb-11ed-8b3d-230262020527", "publicToken": "3adc528b182e50b41acff658136bd974c89604c3" } ``` -------------------------------- ### Create Payment Request Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Use this cURL command to initiate a payment transaction. Ensure all required fields like publicToken, total, and items are correctly populated. The response will contain an ecommerceId and an auth_token. ```bash curl -X POST https://payments.athmovil.com/api/business-transaction/ecommerce/payment \ -H "Content-Type: application/json" \ -d '{ "publicToken": "a66ce73d04f2087615f6320b724defc5b4eedc55", "total": 10.00, "tax": 1.00, "subtotal": 9.00, "timeout": 300000, "metadata1": "Store123", "metadata2": "Location456", "phoneNumber": "5613305493", "items": [{ "name": "Product", "description": "Description", "quantity": 1, "price": 10.00, "tax": 1.00 }] }' ``` -------------------------------- ### Create Payment Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Initiates a new payment transaction. This is the first step in the payment process, where you provide transaction details and receive an `ecommerceId` and an `auth_token`. ```APIDOC ## POST /api/business-transaction/ecommerce/payment ### Description Creates a new payment transaction, returning an `ecommerceId` and an `auth_token` for subsequent operations. ### Method POST ### Endpoint https://payments.athmovil.com/api/business-transaction/ecommerce/payment ### Parameters #### Request Body - **publicToken** (string) - Required - A public token for authentication. - **total** (number) - Required - The total amount of the transaction. - **tax** (number) - Required - The tax amount. - **subtotal** (number) - Required - The subtotal amount. - **timeout** (number) - Optional - The transaction timeout in milliseconds. - **metadata1** (string) - Optional - Additional metadata. - **metadata2** (string) - Optional - Additional metadata. - **phoneNumber** (string) - Required - The phone number associated with the payment. - **items** (array) - Optional - An array of item objects. - **name** (string) - Required - The name of the item. - **description** (string) - Required - The description of the item. - **quantity** (number) - Required - The quantity of the item. - **price** (number) - Required - The price of the item. - **tax** (number) - Required - The tax for the item. ### Request Example ```json { "publicToken": "a66ce73d04f2087615f6320b724defc5b4eedc55", "total": 10.00, "tax": 1.00, "subtotal": 9.00, "timeout": 300000, "metadata1": "Store123", "metadata2": "Location456", "phoneNumber": "5613305493", "items": [ { "name": "Product", "description": "Description", "quantity": 1, "price": 10.00, "tax": 1.00 } ] } ``` ### Response #### Success Response (200) - **status** (string) - The status of the operation. - **data** (object) - Contains transaction data. - **ecommerceId** (string) - The unique identifier for the e-commerce transaction. - **auth_token** (string) - The authorization token for subsequent requests. #### Response Example ```json { "status": "success", "data": { "ecommerceId": "0ab257f5-3837-11ed-855f-9b4af5a393ce", "auth_token": "eyJ..." } } ``` ``` -------------------------------- ### Create Payment Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Initiates a payment transaction. This is the first step in the payment flow, used by merchants to create a new transaction request. ```APIDOC ## POST /api/business-transaction/ecommerce/payment ### Description Creates a new payment transaction for an e-commerce purchase. This endpoint is used by merchants to initiate a payment process that will be completed by the customer via the ATH Móvil app. ### Method POST ### Endpoint `/api/business-transaction/ecommerce/payment` ### Parameters #### Request Body - **publicToken** (string) - Required - Merchant's public token. - **total** (number) - Required - The total amount of the transaction. - **metadata** (object) - Required - Contains `metadata1` and `metadata2` for transaction details. - **metadata1** (string) - Required - Max 40 characters. - **metadata2** (string) - Required - Max 40 characters. - **items** (array) - Optional - List of items in the transaction. - **Item object** (object) - Optional - Details of an item. - **name** (string) - Optional - Item name. - **quantity** (number) - Optional - Item quantity. - **price** (number) - Optional - Item price. - **metadata** (string) - Optional - Item-specific metadata. - **phoneNumber** (string) - Required - Customer's phone number associated with ATH Móvil. - **timeout** (number) - Optional - Transaction timeout in milliseconds (120-600 seconds). ### Response #### Success Response (200) - **ecommerceId** (string) - Unique identifier for the e-commerce transaction. - **auth_token** (string) - Token for subsequent authorization steps. #### Response Example ```json { "ecommerceId": "some_ecommerce_id", "auth_token": "some_auth_token" } ``` ``` -------------------------------- ### POST /api/business-transaction/ecommerce/payment Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md Creates a payment ticket/order for the specified amount. This is the first step in the payment flow. ```APIDOC ## POST /api/business-transaction/ecommerce/payment ### Description Creates a payment ticket/order for the specified amount. This is the first step in the payment flow. ### Method POST ### Endpoint https://payments.athmovil.com/api/business-transaction/ecommerce/payment ### Headers - `Content-Type: application/json` - `Accept: application/json` ### Parameters #### Request Body - **env** (string) - Optional - Environment identifier (e.g., "production") - **publicToken** (string) - Yes - Business account public token identifier - **total** (number) - Yes - Transaction amount (1.00 to 1500.00) - **tax** (number) - Optional - Tax amount for the transaction - **subtotal** (number) - Optional - Subtotal amount before tax - **timeout** (number) - Optional - Time limit in milliseconds before timeout (default: 600000/10 mins, range: 120-600 seconds) - **metadata1** (string) - Yes - Additional transaction metadata (max 40 characters) - **metadata2** (string) - Yes - Additional transaction metadata (max 40 characters) - **phoneNumber** (string) - Yes - ATH Móvil account phone number receiving payment - **items** (array) - Yes - Array of item objects (see Item schema) #### Item Object Schema - **name** (string) - Yes - Item name - **description** (string) - Yes - Item description - **quantity** (number) - Yes - Item quantity - **price** (number) - Yes - Item unit price - **tax** (number) - Optional - Item tax amount (can be null) - **metadata** (string) - Optional - Item-level metadata (can be null) ### Request Example ```json { "env": "production", "publicToken": "a66ce73d04f2087615f6320b724defc5b4eedc55", "timeout": "5000", "total": "10", "tax": "1", "subtotal": "9", "metadata1": "Store ID 123", "metadata2": "Location 456", "phoneNumber": "5613305493", "items": [ { "name": "Product Name", "description": "Product Description", "quantity": "1", "price": "10", "tax": "1", "metadata": "metadata" } ] } ``` ### Response #### Success Response (200) - **status** (string) - Response status ("success" on success) - **data.ecommerceId** (string) - Unique transaction ticket identifier (UUID format) - **data.auth_token** (string) - JWT token required for authorization service call #### Response Example ```json { "status": "success", "data": { "ecommerceId": "0ab257f5-3837-11ed-855f-9b4af5a393ce", "auth_token": "eyJraWQiOiJVVTZpdEt0U0N5Tm9abUFkWkt3ZGxpSDE2SDk5SXI5clNFeXJwbzh6dVVFIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ..." } } ``` ``` -------------------------------- ### Create Payment Response Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md This is a sample success response for a payment creation request. It includes the ecommerceId for subsequent polling and an auth_token. ```json { "status": "success", "data": { "ecommerceId": "0ab257f5-3837-11ed-855f-9b4af5a393ce", "auth_token": "eyJ..." } } ``` -------------------------------- ### Example JWT Payload Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/configuration.md The JWT authorization token payload contains transaction-specific details such as subject, issuer, and expiration time. It is used to authorize transaction completion. ```json { "sub": "2d17fe3f88ecda6be7197c9ab4ea6e792...", "fiId": "", "nbf": 1663604458, "azp": [], "permissions": ["customer.business.ecommerce.authorization:write"], "iss": "Process Payment", "scopes": ["customer.business.ecommerce.authorization:write"], "exp": 1663604458, "iat": 1663604458 } ``` -------------------------------- ### Authorization Service Request Source: https://github.com/evertec/athm-payment-button-api/blob/main/README.md This cURL command demonstrates how to call the authorization service to process a confirmed transaction. Ensure the Authorization header includes the correct auth_token. ```bash curl --location --request POST 'HOST/api/business-transaction/ecommerce/authorization \ --header 'Accept: application/json' \ --header 'Authorization: Bearer TOKEN 'auth_token' \ --header 'Content-Type: application/json' \ --data-raw '' ``` -------------------------------- ### Create Payment Request Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Initiates a payment transaction. Requires merchant's public token, total amount, metadata, item details, and customer's phone number. Returns an ecommerce ID and an authorization token. ```json { "publicToken": "YOUR_PUBLIC_TOKEN", "total": 100.50, "metadata1": "Order #12345", "metadata2": "Customer John Doe", "items": [ { "description": "Product A", "quantity": 1, "amount": 50.25 }, { "description": "Product B", "quantity": 1, "amount": 50.25 } ], "phoneNumber": "+15551234567" } ``` -------------------------------- ### cURL POST Request for Payment Source: https://github.com/evertec/athm-payment-button-api/blob/main/README.md This cURL command demonstrates how to make a POST request to the payment service endpoint. Ensure the correct headers and JSON payload are included. ```bash curl --location --request POST 'HOST/api/business-transaction/ecommerce/payment' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data-raw ```json { "env": "production", "publicToken": "a66ce73d04f2087615f6320b724defc5b4eedc55", "timeout": "5000", "total": "10", "tax": "1", "subtotal": "9", "metadata1": "Metadata 1", "metadata2": "Metada 2", "items": [ { "name": "Diego MO", "description": "Diego", "quantity": "1", "price": "10", "tax": "1", "metadata": "metadata" } ], "phoneNumber": "5613305493" } ``` ``` -------------------------------- ### Find Payment Service Request Source: https://github.com/evertec/athm-payment-button-api/blob/main/README.md This cURL command demonstrates how to make a POST request to the Find Payment service. It includes the necessary headers and a JSON payload with 'ecommerceId' and 'publicToken'. ```bash curl --location --request POST 'https://payments.athmovil.com/api/business-transaction/ecommerce/business/findPayment' \ --header 'Host: https://payments.athmovil.com' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer \ --header 'Content-Type: application/json' \ --data-raw '{ "ecommerceId": "177a50fd-39fb-11ed-8b3d-230262020527", "publicToken": "a66ce73d04f2087615f6320b724defc5b4eedc55" }' ``` -------------------------------- ### Refund Operation Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/configuration.md Initiates a refund for a previous payment. Requires business account tokens and the original payment reference number. An optional message can be included to specify the reason for the refund. ```APIDOC ## POST /refund ### Description Initiates a refund for a previous payment. Requires business account tokens and the original payment reference number. An optional message can be included to specify the reason for the refund. ### Method POST ### Endpoint /refund ### Parameters #### Request Body - **publicToken** (string) - Required - Business account public token - **privateToken** (string) - Required - Business account private token - **referenceNumber** (string) - Required - Original payment reference number - **amount** (string) - Required - Refund amount. Must be between 0.01 and the original payment amount. - **message** (string) - Optional - Refund reason message. Max length 50 characters. ``` -------------------------------- ### RefundRequest Interface Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/types.md Defines the parameters required to initiate a transaction refund. Includes authentication tokens, reference number, amount, and an optional message. ```typescript interface RefundRequest { publicToken: string; privateToken: string; referenceNumber: string; amount: string; message?: string; } ``` -------------------------------- ### Process Payment and Handle API Errors (JavaScript) Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/errors.md This snippet demonstrates how to make a payment request and handle potential API errors by checking the response status and specific error codes. It includes error handling for common issues like invalid amounts, inactive businesses, and expired tokens. ```javascript async function processPayment(paymentRequest) { try { const response = await fetch('https://payments.athmovil.com/api/business-transaction/ecommerce/payment', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(paymentRequest) }); const data = await response.json(); if (data.status === 'error') { // Handle API error switch (data.errorcode) { case 'BTRA_0001': console.error('Amount too low', data.message); break; case 'BTRA_0009': console.error('Business inactive', data.message); break; case 'token.expired': console.error('Token expired, reauthenticate', data.message); break; default: console.error('Error:', data.errorcode, data.message); } throw new Error(data.message); } return data.data; } catch (error) { console.error('Request failed:', error); throw error; } } ``` -------------------------------- ### Error: No Authorization Header Source: https://github.com/evertec/athm-payment-button-api/blob/main/README.md This JSON response indicates an error due to a missing authorization header, typically meaning a token was not provided in the request. ```json { "status": "error", "message": "No authorization header present.", "errorcode": "token.invalid.header", "data": null } ``` -------------------------------- ### Find Payment Service Response - OPEN Status Source: https://github.com/evertec/athm-payment-button-api/blob/main/README.md This JSON response indicates a transaction that is pending confirmation by the ATH Móvil customer. The 'ecommerceStatus' is 'OPEN'. ```json { "status": "success", "data": { "ecommerceStatus": "OPEN", "ecommerceId": "39906664-e44e-11ed-b127-a519df48811e", "referenceNumber": "", "businessCustomerId": "402894d56e713892016e7f2963de0010", "transactionDate": "", "dailyTransactionId": "", "businessName": "Tdameritrade", "businessPath": "Tdameritrade", "industry": "COMPUTERS", "subTotal": 1.33, "tax": 1.00, "total": 2.33, "fee": 0.00, "netAmount": 0, "totalRefundedAmount": 0, "metadata1": "Metadata 1", "metadata2": "Metada 2", "items": [ { "name": "Diego MO", "description": "Diego", "quantity": 1, "price": 1.33, "tax": 1, "metadata": "metadata", "formattedPrice": "", "sku": "" } ], "isNonProfit": false } } ``` -------------------------------- ### Authorization Service Source: https://github.com/evertec/athm-payment-button-api/blob/main/README.md This service processes the transaction in the core system by debiting customer funds after user confirmation. It requires an authorization token and must be authenticated with JWT. ```APIDOC ## POST /api/business-transaction/ecommerce/authorization ### Description Processes the transaction in the core system by debiting customer funds after user confirmation. Requires an authorization token received from the /payment service and must be authenticated with JWT. ### Method POST ### Endpoint https://payments.athmovil.com/api/business-transaction/ecommerce/authorization ### Headers - **Content-Type**: application/json - **Authorization**: Bearer TOKEN 'auth_token' - **Accept**: application/json ### Request Body This endpoint does not require a request body. ### Response #### Success Response (200) - **status** (string) - Confirm status of the service response. - **data** (object) - Contains transaction details. - **ecommerceStatus** (string) - Represents the status of the ecommerce transaction (completed, cancelled, or expired). - **ecommerceId** (string) - Represents the transaction ticket ID token. - **referenceNumber** (string) - Unique transaction identifier. - **businessCustomerId** (string) - Business customer ID. - **transactionDate** (string) - Authorization date. - **dailyTransactionId** (string) - ID count for the transaction in the day. - **businessName** (string) - Business Name for the ATH Business account. - **businessPath** (string) - Business Path for the ATH Business account. - **industry** (string) - Industry of the business. - **subTotal** (number) - Subtotal of the transaction. - **tax** (number) - Tax captured in the transaction. - **total** (number) - Total amount. - **fee** (number) - Fee charged by ATH Business. - **netAmount** (number) - Net amount to be funded to the ATH Business account. - **totalRefundedAmount** (number) - Total refunded amount of the original transaction. - **metadata1** (string) - Variable for additional transaction information (e.g., store ID, location). Max length 40 characters. - **metadata2** (string) - Variable for additional transaction information (e.g., store ID, location). Max length 40 characters. - **items** (array) - Items paid for in the transaction. - **name** (string) - Item name. - **description** (string) - Item description. - **quantity** (number) - Item quantity. - **price** (number) - Item price. - **tax** (number) - Item tax. - **metadata** (string) - Item metadata. - **isNonProfit** (boolean) - Indicates if the business is non-profit. #### Response Example ```json { "status": "success", "data": { "ecommerceStatus": "COMPLETED", "ecommerceId": "730e2c49-9387-11ed-8f43-c31784ccfc6c", "referenceNumber": "215070443-402894c185ab1be40185acfe61c2000b", "businessCustomerId": "402894d56e713892016e7f2963de0010", "transactionDate": "2023-01-13 16:17:06", "dailyTransactionId": "0006", "businessName": "Tdameritrade", "businessPath": "Tdameritrade", "industry": "ENTERTAINMENT", "subTotal": 0, "tax": 0.00, "total": 1, "fee": 0.6000000238418579, "netAmount": 0.40, "totalRefundedAmount": 0, "metadata1": "Metadata 1", "metadata2": "Metada 2", "items": [ { "name": "Diego MO", "description": "Diego", "quantity": 1, "price": 10, "tax": 0, "metadata": "Articulo 1" } ], "isNonProfit": false } } ``` ``` -------------------------------- ### Item Interface Definition Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/types.md Represents a single item within a transaction. Specifies item name, description, quantity, price, and optional tax and metadata. ```typescript interface Item { name: string; description: string; quantity: number; price: number; tax?: number | null; metadata?: string | null; } ``` -------------------------------- ### Authorize Payment Request Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Completes the payment authorization process. Requires the authorization token obtained from the payment creation step, passed in the Authorization header. ```http POST /api/business-transaction/ecommerce/authorization HTTP/1.1 Host: payments.athmovil.com Authorization: Bearer YOUR_AUTH_TOKEN Content-Type: application/json {} ``` -------------------------------- ### Poll for Payment Confirmation Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Use this cURL command to poll the status of a payment using the ecommerceId. Continue polling until the ecommerceStatus field indicates 'CONFIRM'. ```bash curl -X POST https://payments.athmovil.com/api/business-transaction/ecommerce/business/findPayment \ -H "Content-Type: application/json" \ -d '{ "ecommerceId": "0ab257f5-3837-11ed-855f-9b4af5a393ce", "publicToken": "a66ce73d04f2087615f6320b724defc5b4eedc55" }' ``` -------------------------------- ### FindPaymentResponse Interface Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/types.md Defines the structure for a successful or failed response when querying for payment details. Contains a status and the transaction data. ```typescript interface FindPaymentResponse { status: "success" | "error"; data: TransactionData; } ``` -------------------------------- ### POST /api/business-transaction/ecommerce/refund Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/endpoints.md Refunds a completed transaction. Partial refunds are supported. Requires business account tokens and the original transaction reference number. ```APIDOC ## POST /api/business-transaction/ecommerce/refund ### Description Refunds a completed transaction. Partial refunds are supported. ### Method POST ### Endpoint https://payments.athmovil.com/api/business-transaction/ecommerce/refund ### Parameters #### Headers - `Content-Type`: `application/json` - `Accept`: `application/json` #### Request Body - **publicToken** (string) - Yes - Business account public token - **privateToken** (string) - Yes - Business account private token - **referenceNumber** (string) - Yes - Original payment transaction reference number - **amount** (string) - Yes - Refund amount (must be ≥ 0.01, cannot exceed original transaction amount) - **message** (string) - No - Refund reason message (max 50 characters) ### Request Example ```json { "publicToken": "hdb932832klnasKJGDW90291", "privateToken": "JHEFEWP2048FNDFLKJWB2", "referenceNumber": "fdew98ffw9fbfewkjb", "amount": "1.00", "message": "Customer requested refund" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation. - **data** (object) - Contains details about the refund and the original transaction. - **refund** (object) - Details of the refund. - **transactionType** (string) - Type of transaction, should be "REFUND". - **status** (string) - Status of the refund, e.g., "COMPLETED". - **refundedAmount** (number) - The amount that was refunded. - **date** (number) - Timestamp of the refund. - **referenceNumber** (string) - Unique identifier for the refund transaction. - **dailyTransactionID** (string) - Sequential identifier for the refund within the day. - **name** (string) - Name associated with the refund transaction. - **phoneNumber** (string) - Phone number associated with the refund transaction. - **email** (string) - Email associated with the refund transaction. - **originalTransaction** (object) - Details of the original transaction. - **transactionType** (string) - Type of the original transaction, should be "PAYMENT". - **status** (string) - Status of the original transaction, e.g., "COMPLETED". - **date** (number) - Timestamp of the original transaction. - **referenceNumber** (string) - Unique identifier for the original transaction. - **dailyTransactionID** (string) - Sequential identifier for the original transaction within the day. - **name** (string) - Name associated with the original transaction. - **phoneNumber** (string) - Phone number associated with the original transaction. - **email** (string) - Email associated with the original transaction. - **message** (string) - Message associated with the original transaction. - **total** (number) - Total amount of the original transaction. - **tax** (number) - Tax amount of the original transaction. - **subtotal** (number) - Subtotal amount of the original transaction. - **fee** (number) - Fee amount of the original transaction. - **netAmount** (number) - Net amount of the original transaction. - **totalRefundedAmount** (number) - Cumulative amount refunded from the original transaction. - **metadata1** (string) - Metadata field 1. - **metadata2** (string) - Metadata field 2. - **items** (array) - Array of items associated with the original transaction. #### Response Example ```json { "status": "success", "data": { "refund": { "transactionType": "REFUND", "status": "COMPLETED", "refundedAmount": 1.00, "date": 1678886400000, "referenceNumber": "ref12345", "dailyTransactionID": "DTID67890", "name": "John Doe", "phoneNumber": "123-456-7890", "email": "john.doe@example.com" }, "originalTransaction": { "transactionType": "PAYMENT", "status": "COMPLETED", "date": 1678886000000, "referenceNumber": "fdew98ffw9fbfewkjb", "dailyTransactionID": "DTID12345", "name": "Jane Smith", "phoneNumber": "987-654-3210", "email": "jane.smith@example.com", "message": "Purchase of goods", "total": 10.00, "tax": 0.50, "subtotal": 9.50, "fee": 0.25, "netAmount": 9.25, "totalRefundedAmount": 1.00, "metadata1": "meta1", "metadata2": "meta2", "items": [] } } } ``` ``` -------------------------------- ### Authorize Payment Request Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md This cURL command is used to authorize a payment after the customer has confirmed it. It requires the Authorization header with the Bearer token obtained previously. A successful response will indicate 'COMPLETED' status and provide a referenceNumber. ```bash curl -X POST https://payments.athmovil.com/api/business-transaction/ecommerce/authorization \ -H "Content-Type: application/json" \ -H "Authorization: Bearer eyJ..." \ -d '' ``` -------------------------------- ### Poll for Confirmation Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Polls the payment status using the `ecommerceId`. Continue polling until the `ecommerceStatus` field indicates 'CONFIRM'. ```APIDOC ## POST /api/business-transaction/ecommerce/business/findPayment ### Description Polls the status of a payment transaction using its `ecommerceId`. This endpoint should be polled repeatedly until the transaction status is confirmed. ### Method POST ### Endpoint https://payments.athmovil.com/api/business-transaction/ecommerce/business/findPayment ### Parameters #### Request Body - **ecommerceId** (string) - Required - The unique identifier for the e-commerce transaction. - **publicToken** (string) - Required - A public token for authentication. ### Request Example ```json { "ecommerceId": "0ab257f5-3837-11ed-855f-9b4af5a393ce", "publicToken": "a66ce73d04f2087615f6320b724defc5b4eedc55" } ``` ### Response #### Success Response (200) - **ecommerceStatus** (string) - The current status of the e-commerce transaction (e.g., 'CONFIRM'). - **referenceNumber** (string) - The reference number for settlement once the payment is completed. ``` -------------------------------- ### Find Payment Status Request Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Queries the status of a previously created payment transaction. Requires the ecommerce ID and the merchant's public token. Returns the transaction status. ```json { "ecommerceId": "generated_ecommerce_id", "publicToken": "YOUR_PUBLIC_TOKEN" } ``` -------------------------------- ### Find Payment Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/README.md Queries the status of an existing payment transaction. Merchants can use this to check if a payment has been confirmed or completed. ```APIDOC ## POST /api/business-transaction/ecommerce/business/findPayment ### Description Retrieves the current status of a previously initiated payment transaction. ### Method POST ### Endpoint `/api/business-transaction/ecommerce/business/findPayment` ### Parameters #### Request Body - **ecommerceId** (string) - Required - The unique identifier of the e-commerce transaction. - **publicToken** (string) - Required - The merchant's public token. ### Response #### Success Response (200) - **ecommerceStatus** (string) - The status of the transaction. Possible values: "OPEN", "CONFIRM", "COMPLETED", "CANCEL". #### Response Example ```json { "ecommerceStatus": "COMPLETED" } ``` ``` -------------------------------- ### PaymentRequest Interface Definition Source: https://github.com/evertec/athm-payment-button-api/blob/main/_autodocs/types.md Defines the structure for creating a new payment transaction. Includes fields for environment, public token, amounts, metadata, phone number, and items. ```typescript interface PaymentRequest { env?: string; publicToken: string; total: number; tax?: number; subtotal?: number; timeout?: number; metadata1: string; metadata2: string; phoneNumber: string; items: Item[]; } ``` -------------------------------- ### Completed Transaction Response Source: https://github.com/evertec/athm-payment-button-api/blob/main/README.md This section describes the response structure for a successfully completed transaction. The `ecommerceStatus` will be 'COMPLETED'. ```APIDOC ## Completed transaction (/Payment +/Confirmed & /Authorize) Response: Status **COMPLETED** ### Description This is the response received when a payment transaction is successfully completed. ### Response #### Success Response (200) - **status** (string) - Indicates the overall status of the API call, expected to be 'success'. - **data** (object) - Contains the details of the transaction. - **ecommerceStatus** (string) - The status of the e-commerce transaction, will be 'COMPLETED'. - **ecommerceId** (string) - Unique identifier for the transaction (Transaction invoice/ticket). - **referenceNumber** (string) - Payment transaction ID. - **businessCustomerId** (string) - Identifier for the business customer. - **transactionDate** (string) - The date and time the transaction occurred. - **dailyTransactionId** (string) - Sequential ID for transactions on a given day. - **businessName** (string) - The name of the business. - **businessPath** (string) - The path associated with the business. - **industry** (string) - The industry category of the business. - **subTotal** (number) - The subtotal amount of the transaction. - **tax** (number) - The tax amount. - **total** (number) - The total amount of the transaction. - **fee** (number) - The transaction fee. - **netAmount** (number) - The net amount after fees. - **totalRefundedAmount** (number) - The total amount refunded. - **metadata1** (string) - Additional metadata field 1. - **metadata2** (string) - Additional metadata field 2. - **items** (array) - An array of items included in the transaction. - **name** (string) - Name of the item. - **description** (string) - Description of the item. - **quantity** (number) - Quantity of the item. - **price** (number) - Price of the item. - **tax** (number) - Tax applied to the item. - **metadata** (string) - Metadata for the item. - **isNonProfit** (boolean) - Indicates if the business is non-profit. ### Response Example ```json { "status": "success", "data": { "ecommerceStatus": "COMPLETED", "ecommerceId": "730e2c49-9387-11ed-8f43-c31784ccfc6c", "referenceNumber": "215070443-402894c185ab1be40185acfe61c2000b", "businessCustomerId": "402894d56e713892016e7f2963de0010", "transactionDate": "2023-01-13 16:17:06", "dailyTransactionId": "0006", "businessName": "Tdameritrade", "businessPath": "Tdameritrade", "industry": "ENTERTAINMENT", "subTotal": 0, "tax": 0.00, "total": 1, "fee": 0.6000000238418579, "netAmount": 0.40, "totalRefundedAmount": 0, "metadata1": "Metadata 1", "metadata2": "Metada 2", "items": [ { "name": "Diego MO", "description": "Diego", "quantity": 1, "price": 10, "tax": 0, "metadata": "metadata" } ], "isNonProfit": false } } ``` ```