### Example Signature Header Source: https://apidoc.alphapay.com/open-api/en/request This is an example of a completed Signature header, including algorithm, key version, and the generated signature. Ensure all components are correctly formatted and separated by commas. ```http Signature: algorithm=RS256, keyVersion=1, signature=d%2FqFC126U57guKgRRXnd4colw5Ed5tpq3NDh2M5JOtfDivAze4X%2BYEaUCWHNW7h02sSed7hsnsDtM2rjtYe8kqAJTV9fMLzraeUZvWBh4j8Sf2D%2Bcz4bJ23S4F7VtoWaxMWjySwWuS0nMQweg%3DM7MY1HQFz2EXZjAa4CVflxU1I61NuEURfiYJGW%2BLEf%2FPVPEgzBLO8LopYMovmgO7Fl97E9UVFZnFW37bSaEdkNCffJlBU00AYWKaXbsARLarETkY9NA8nTJ5yDwjKm4rH3O%2FUhwGYnwLAvozKKjfWLU4m15LoAUF30Tap6d7IGFfewnLxdY34sVYG3Nx6m0Mit%2Bg%3D%3D ``` -------------------------------- ### Apple Pay Response Example Source: https://apidoc.alphapay.com/open-api/en/apple_pay This is an example of a successful response (200 OK) after submitting an Apple Pay token. It includes details about the payment request, AlphaPay order, and transaction status. ```json { "paymentRequestId": "string", "paymentId": "string", "paymentStatus": "SUCCESS", "paymentTime": "2019-08-24T14:16:22Z", "transactionId": "string", "result": { "resultCode": "SUCCESS", "resultMessage": "string", "resultStatus": "S" } } ``` -------------------------------- ### Example Accept Header Source: https://apidoc.alphapay.com/open-api/en/request Indicates the media types that the client can accept in the response. For JSON APIs, this should be set to 'application/json'. ```http Accept: application/json ``` -------------------------------- ### Refund Inquiry Response Example (200 OK) Source: https://apidoc.alphapay.com/open-api/en/refund_inquiry This is an example of a successful response from the Refund Inquiry API. It includes details such as payment ID, refund ID, status, time, and refund object. ```JSON { "paymentId": "string", "refundRequestId": "string", "refundId": "string", "refundTime": "2019-08-24T14:15:22Z", "refundStatus": "REFUND_IN_PROCESS", "refund": { "refundAmount": { "value": "string", "currency": "CAD" }, "description": "string", "notifyUrl": "string" }, "result": { "resultCode": "string", "resultMessage": "string", "resultStatus": "S" } } ``` -------------------------------- ### Example Content-Type Header Source: https://apidoc.alphapay.com/open-api/en/request Specifies the media type of the request body. For JSON payloads, it should be set to 'application/json' with UTF-8 encoding. ```http Content-Type: application/json; charset=UTF-8 ``` -------------------------------- ### Refund Inquiry Request Body Example Source: https://apidoc.alphapay.com/open-api/en/refund_inquiry This is an example of the JSON request body used to query refund details. It requires the AlphaPay refund ID and optionally accepts the merchant refund ID. ```JSON { "refundId": "string", "refundRequestId": "string" } ``` -------------------------------- ### Order Inquiry Response (200 OK) Source: https://apidoc.alphapay.com/open-api/en/order_inquiry Example of a successful response from the Order Inquiry API, detailing payment and order information. ```JSON { "scenarioCode": "APP", "paymentRequestId": "string", "order": { "orderAmount": { "value": "string", "currency": "CAD" }, "description": "string", "notifyUrl": "string", "redirectUrl": "string" }, "paymentCreateTime": "2019-08-24T14:15:22Z", "paymentExpireTime": "2019-08-24T14:15:22Z", "paymentTime": "2019-08-24T14:15:22Z", "paymentId": "string", "paymentStatus": "PAYMENT_IN_PROCESS", "result": { "resultCode": "string", "resultMessage": "string", "resultStatus": "S" } } ``` -------------------------------- ### Apple Pay Request Body Example Source: https://apidoc.alphapay.com/open-api/en/apple_pay This is an example of the JSON request body required to submit an Apple Pay token. Ensure all required fields, especially within the token and paymentData objects, are populated correctly. ```json { "paymentId": "string", "customerId": "string", "token": { "transactionIdentifier": "string", "paymentMethod": { "displayName": "Visa 1234", "network": "Visa", "type": "debit" }, "paymentData": { "version": "EC_v1", "data": "string", "signature": "string", "header": { "publicKeyHash": "string", "ephemeralPublicKey": "string", "transactionId": "string" } } } } ``` -------------------------------- ### Refund Response (200 OK) Source: https://apidoc.alphapay.com/open-api/en/refund Example of a successful refund response. It includes identifiers, refund details, timestamp, and processing results. ```json { "refundId": "string", "paymentId": "string", "refundRequestId": "string", "refund": { "refundAmount": { "value": "string" }, "description": "string", "notifyUrl": "string" }, "refundTime": "2019-08-24T14:15:22Z", "result": { "resultCode": "string", "resultMessage": "string", "resultStatus": "S" } } ``` -------------------------------- ### Example Nonce Header Source: https://apidoc.alphapay.com/open-api/en/request A randomly generated string of 32 characters used for security purposes. Ensure this value is unique for each request. ```http Nonce: b111bcf0dfb54d4e8bae68c293d85e2e ``` -------------------------------- ### Example Push Notification Response Body Source: https://apidoc.alphapay.com/open-api/en/notification This is an example of the JSON response body that a merchant's server should send back to AlphaPay to confirm successful receipt and processing of a push notification. The `resultCode` must be 'SUCCESS' and `resultStatus` must be 'S'. ```json { "result": { "resultCode":"SUCCESS", "resultStatus":"S", "resultMessage":"success" } } ``` -------------------------------- ### Example Request-Time Header Source: https://apidoc.alphapay.com/open-api/en/request The Request-Time header specifies the exact time the request is sent, adhering to the ISO 8601 format and including milliseconds for precision. ```http Request-Time: 2019-04-04T12:08:56+05:30 ``` -------------------------------- ### Response Header: Signature Example Source: https://apidoc.alphapay.com/open-api/en/request The Signature field in the response header provides signature information. It includes the algorithm, key version, and the generated signature. ```text Signature: algorithm=RS256, keyVersion=1, signature={generatedSignature} ``` -------------------------------- ### Response Header: Response-Time Example Source: https://apidoc.alphapay.com/open-api/en/request The Response-Time field in the response header specifies the time when a request is sent, adhering to ISO 8601 format and accurate to milliseconds. ```text Response-Time: 2019-04-04T12:08:56+05:30 ``` -------------------------------- ### Example Merchant-Code Header Source: https://apidoc.alphapay.com/open-api/en/request The Merchant-Code is a unique identifier provided by AlphaPay. It is required for generating request signatures and typically ranges from 4 to 6 digits. ```http Merchant-Code: CXVJIU ``` -------------------------------- ### Generate Signature Source: https://apidoc.alphapay.com/open-api/en/sign Illustrates the syntax for generating a signature using SHA256withRSA, Base64 encoding, and URL encoding. It requires the content to be signed and the private key. ```string generatedSignature=urlEncode(base64Encode(sha256withrsa(), ))) ``` ```plaintext KrwDE9tAPJYBb4cUZU6ALJxGIZgwDXn5UkFPMip09n%2FkYKPhEIII%2Fki2rYY2lPtuKVgMNz%2BtuCU%2FjzRpohDbrOd8zYriiukpGAxBQDIVbatGI7WYOcc9YVQwdCR6ROuRQvr%2FD1AfdhHd6waAASu5Xugow9w1OW7Ti93LTd0tcyEWQYd2S7c3A73sHOJNYl8DC1PjasiBozZ%2FADgb7ONsqHo%2B8fKHsLygX9cuMkQYTGIRBQsvfgICnJhh%2BzXV8AQoecJBTrv6p%xxxx ``` -------------------------------- ### Construct Content to Sign Source: https://apidoc.alphapay.com/open-api/en/sign Defines the syntax for constructing the content that needs to be signed. This includes HTTP method, URI, merchant code, request time, nonce, and request body. ```java String.format("%s %s\n%s.%s.%s.%s", method, requestURI, merchantCode, requestTime, nonce, body); ``` ```plaintext POST /api/v2.0/payments/pay CXVJIU.2019-05-28T12:12:12+08:00.b111bcf0dfb54d4e8bae68c293d85e2e.{ "scenarioCode": "ONLINE_QRCODE", "paymentRequestId": "50", "order": { "orderAmount": { "value": "45366", "currency": "CNY" }, "description": "This is a test order", "notifyUrl": "https://alphapay.com/success", "redirectUrl": "https://alphapay.com/successPage" }, "paymentMethod": { "paymentMethodType": "Alipay" } } ``` -------------------------------- ### Constructing Content to Verify Source: https://apidoc.alphapay.com/open-api/en/sign Assemble the HTTP method, URI, merchant code, response time, nonce, and response body according to the specified syntax. This forms the data that will be used for signature verification. ```plaintext POST /api/v2.0/payments/pay CXVJIU.2019-05-28T12:12:12+08:00.b111bcf0dfb54d4e8bae68c293d85e2e.{ "result": { "resultCode":"SUCCESS", "resultStatus":"S", "resultMessage":"success" } } ``` -------------------------------- ### Add Signature to Request Header Source: https://apidoc.alphapay.com/open-api/en/sign Shows how to assemble the final signature string for the request header, including algorithm, key version, and the generated signature. ```string 'Signature: algorithm=, keyVersion=, signature=' ``` ```plaintext 'Signature: algorithm=RS256, keyVersion=1, signature=d%2FqFC126U57guKgRRXnd4colw5Ed5tpq3NDh2M5JOtfDivAze4X%2BYEaUCWHNW7h02sSed7hsnsDtM2rjtYe8kqAJTV9fMLzraeUZvWBh4j8Sf2D%2Bcz4bJ23S4F7VtoWaxMWjySwWuS0nMQweg%2BM7MY1HQFz2EXZjAa4CVflxU1I61NuEURfiYJGW%2BLEf%2FPVPEgzBLO8LopYMovmgO7Fl97E9UVFZnFW37bSaEdkNCffJlBU00AYWKaXbsARLarETkY9NA8nTJ5yDwjKm4rH3O%2FUhwGYnwLAvozKKjfWLU4m15LoAUF30Tap6d7IGFfewnLxdY34sVYG3Nx6m0Mit%2Bg%3D%3D' ``` -------------------------------- ### Create a QR Code order Source: https://apidoc.alphapay.com/open-api/en/payment This endpoint creates a QR code payment order suitable for PC and mobile browsers. Customers can pay by scanning the generated QR code with WeChat or Alipay. It supports returning a QR code image, a payment URL, or redirecting to the AlphaPay payment page. ```APIDOC ## POST {BASE_URL}/api/v2.0/payments/pay ### Description Creates a payment order for the `ONLINE_QRCODE` scenario. This is suitable for payments via PC and mobile browsers where customers scan a QR code using WeChat or Alipay. ### Method POST ### Endpoint `{BASE_URL}/api/v2.0/payments/pay` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **scenarioCode** (string) - REQUIRED - Scenario code. Allowed values: `ONLINE_QRCODE`, `ONLINE_WEB`, `JSAPI`, `NATIVE_JSAPI`, `ONLINE_WAP`, `APP`, `MINI_APP`, `CREDIT_CARD`, `OFFLINE_QRCODE`, `OFFLINE`. - **paymentRequestId** (string) - REQUIRED - Merchant order ID. - **order** (object) - REQUIRED - Order Information. - **orderAmount** (object) - REQUIRED - The amount of the order. - **value** (string) - REQUIRED - The value of the order amount. Figures are based on the minimum denomination unit of the currency (e.g., `100` means `1.00CAD`). - **currency** (string) - REQUIRED - Currency code. Allowed values: `CAD`, `USD`, `CNY`. - **description** (string) - REQUIRED - Title of the order (maximum length 128 characters). - **notifyUrl** (string) - Optional - Payment notification URL for pushing payment success notifications. - **redirectUrl** (string) - Optional - Payment redirect URL after a successful payment. - **paymentMethod** (object) - REQUIRED - Payment method information. - **paymentMethodType** (string) - REQUIRED - Payment method. Allowed values: `Alipay`, `Wechat`, `UnionPay`. ### Request Example ```json { "scenarioCode": "ONLINE_QRCODE", "paymentRequestId": "string", "order": { "orderAmount": { "value": "string", "currency": "CAD" }, "description": "string", "notifyUrl": "string", "redirectUrl": "string" }, "paymentMethod": { "paymentMethodType": "Alipay" } } ``` ### Response #### Success Response (200 OK) - **scenarioCode** (string) - Scenario code. - **paymentRequestId** (string) - Merchant order ID. - **order** (object) - Order Information. - **orderAmount** (object) - The amount of the order. - **value** (string) - The value of the order amount. - **currency** (string) - Currency code. - **description** (string) - Title of the order. - **notifyUrl** (string) - Payment notification URL. - **redirectUrl** (string) - Payment redirect URL. - **paymentMethod** (object) - Payment method information. - **paymentMethodType** (string) - Payment method. - **paymentInfo** (object) - Payment information. - **paymentUrl** (string) - Payment URL for generating the QR code. - **paymentQRImage** (string) - Base64-encoded image of the payment QR code. - **payUrl** (string) - URL to AlphaPay payment page. - **paymentCreateTime** (string) - Order creation time (ISO8601 format). - **paymentExpireTime** (string) - Payment expiration time (ISO8601 format). - **paymentId** (string) - AlphaPay order ID. - **result** (object) - Process result. #### Response Example ```json { "scenarioCode": "ONLINE_QRCODE", "paymentRequestId": "string", "order": { "orderAmount": { "value": "string", "currency": "CAD" }, "description": "string", "notifyUrl": "string", "redirectUrl": "string" }, "paymentMethod": { "paymentMethodType": "Alipay" }, "paymentInfo": { "paymentUrl": "string", "paymentQRImage": "string", "payUrl": "string" }, "paymentCreateTime": "2019-05-28T12:12:12+08:00", "paymentExpireTime": "2019-05-28T12:12:12+08:00", "paymentId": "string", "result": {} } ``` ``` -------------------------------- ### Create Apple Pay Order Source: https://apidoc.alphapay.com/open-api/en/apple_pay Creates an Apple Pay order and retrieves the necessary parameters for client-side Apple Pay authorization. This is the first step in the Apple Pay two-step flow. ```APIDOC ## POST /api/v2.0/apple-pay/preOrder ### Description Creates an Apple Pay order and retrieves the payment parameters required by the client application. ### Method POST ### Endpoint /api/v2.0/apple-pay/preOrder ### Parameters #### Request Body - **paymentRequestId** (string) - Required - Merchant order ID - **merchantIdentifier** (string) - Optional - Apple Pay Merchant Identifier - **order** (object) - Required - Order information - **order.orderAmount** (object) - Required - The amount of the order - **order.orderAmount.value** (string) - Required - The value of order amount. All amount figures are based on the minimum denomination unit of given currency. Take CAD as an example, `100` means `1.00CAD`. - **order.orderAmount.currency** (string) - Required - Currency code, allowed values: `CAD` - **order.description** (string) - Required - Order description `<= 128 characters` - **order.notifyUrl** (string) - Optional - Payment notification URL ### Request Example ```json { "paymentRequestId": "string", "merchantIdentifier": "merchant.com.example.applepay", "order": { "orderAmount": { "value": "1", "currency": "CAD" }, "description": "Apple Pay test order", "notifyUrl": "https://www.example.com/notify" } } ``` ### Response #### Success Response (200 OK) - **paymentRequestId** (string) - Merchant order ID - **paymentId** (string) - AlphaPay order ID - **paymentCreateTime** (string) - Order creation time - **paymentExpireTime** (string) - Payment expiration time - **applePayParams** (object) - Apple Pay parameters used by the client to invoke Apple Pay - **applePayParams.orderId** (string) - AlphaPay order ID - **applePayParams.merchantIdentifier** (string) - Apple Pay Merchant Identifier - **applePayParams.countryCode** (string) - Country code - **applePayParams.currencyCode** (string) - Currency code - **applePayParams.label** (string) - Merchant display name - **applePayParams.amount** (string) - Payment amount in decimal format - **applePayParams.supportedNetworks** (array[string]) - Supported card networks - **applePayParams.merchantCapabilities** (array[string]) - Apple Pay merchant capabilities - **result** (object) - Process result - **result.resultCode** (string) - Process result code, usually `PAYMENT_IN_PROCESS` - **result.resultMessage** (string) - Process result message - **result.resultStatus** (string) - The status of an API call (`U`: Order created and waiting for Apple Pay authorization, `F`: API call failed) #### Response Example ```json { "paymentRequestId": "string", "paymentId": "string", "paymentCreateTime": "2019-08-24T14:15:22Z", "paymentExpireTime": "2019-08-24T14:45:22Z", "applePayParams": { "orderId": "string", "merchantIdentifier": "merchant.com.example.applepay", "countryCode": "CA", "currencyCode": "CAD", "label": "Demo Merchant", "amount": "0.01", "supportedNetworks": ["visa", "masterCard", "amex"], "merchantCapabilities": ["supports3DS", "supportsCredit", "supportsDebit"] }, "result": { "resultCode": "PAYMENT_IN_PROCESS", "resultMessage": "string", "resultStatus": "U" } } ``` ``` -------------------------------- ### Order Inquiry API Endpoint Source: https://apidoc.alphapay.com/open-api/en/order_inquiry The POST endpoint for initiating an order inquiry. ```HTTP POST {BASE_URL}/api/v2.0/payments/inquiryPayment ``` -------------------------------- ### Refund API Endpoint Source: https://apidoc.alphapay.com/open-api/en/refund This is the endpoint for initiating a refund request. ```text POST {BASE_URL}/api/v2.0/payments/refund ``` -------------------------------- ### Send POST Request with cURL Source: https://apidoc.alphapay.com/open-api/en/sign Use this cURL command to send a POST request to the AlphaPay API for payment processing. Ensure all header fields, including the Signature, are correctly populated. ```bash curl --location --request POST 'https://openapi.alphapay.ca/api/v2.0/payments/pay' \ --header 'Accept: application/json' \ --header 'Merchant-Code: CXVJIU' \ --header 'Request-Time: 2023-03-15T22:37:47Z' \ --header 'Nonce: b111bcf0dfb54d4e8bae68c293d85e2e' \ --header 'Signature: algorithm=RS256, keyVersion=1, signature=d%2FqFC126U57guKgRRXnd4colw5Ed5tpq3NDh2M5JOtfDivAze4X%2BYEaUCWHNW7h02sSed7hsnsDtM2rjtYe8kqAJTV9fMLzraeUZvWBh4j8Sf2D%2Bcz4bJ23S4F7VtoWaxMWjySwWuS0nMQweg%2BM7MY1HQFz2EXZjAa4CVflxU1I61NuEURfiYJGW%2BLEf%2FPVPEgzBLO8LopYMovmgO7Fl97E9UVFZnFW37bSaEdkNCffJlBU00AYWKaXbsARLarETkY9NA8nTJ5yDwjKm4rH3O%2FUhwGYnwLAvozKKjfWLU4m15LoAUF30Tap6d7IGFfewnLxdY34sVYG3Nx6m0Mit%2Bg%3D%3D' \ --header 'Content-Type: application/json' \ --data-raw '{ "scenarioCode": "ONLINE_QRCODE", "paymentRequestId": "50", "order": { "orderAmount": { "value": "45366", "currency": "CNY" }, "description": "This is a test order", "notifyUrl": "https://alphapay.com/success", "redirectUrl": "https://alphapay.com/successPage" }, "paymentMethod": { "paymentMethodType": "Alipay" } }' ``` -------------------------------- ### Verifying the Signature Source: https://apidoc.alphapay.com/open-api/en/sign Use the sha256withrsa_verify function to validate the signature. This involves URL decoding and Base64 decoding the target signature, then comparing it against the constructed content and the AlphaPay public key. ```plaintext IS_SIGNATURE_VALID=sha256withrsa_verify(base64Decode(urlDecode()), , ) ``` -------------------------------- ### Create QR Code Order Request Body Source: https://apidoc.alphapay.com/open-api/en/payment This JSON structure is used to create a QR code payment order. It includes details about the order amount, currency, description, notification URL, redirect URL, and the payment method type. ```json { "scenarioCode": "ONLINE_QRCODE", "paymentRequestId": "string", "order": { "orderAmount": { "value": "string", "currency": "CAD" }, "description": "string", "notifyUrl": "string", "redirectUrl": "string" }, "paymentMethod": { "paymentMethodType": "Alipay" } } ``` -------------------------------- ### General Request Structure Source: https://apidoc.alphapay.com/open-api/en/request All requests to the AlphaPay Open API use the POST method. The request URL follows a specific format, and the request body must be in JSON format using UTF-8 encoding. Specific headers are required for authentication and request identification. ```APIDOC ## General Request Structure ### Description All requests to the AlphaPay Open API are made using the HTTP POST method. The `Accept` and `Content-Type` headers must be set to `application/json`. The system uses `UTF-8` encoding. ### Method POST ### URL Format `https://{domain name}/api/{version}/{endpoint}` - **domain name**: AlphaPay Open API domain (e.g., `openapi.alphapay.ca`). - **version**: API version number (e.g., `v1.0`, `v2.0`). - **endpoint**: The specific interface identifier (e.g., `/payments/pay`). Example URL: `https://openapi.alphapay.ca/api/v2.0/payments/pay` ### Request Header Required headers include `Signature`, `Merchant-Code`, `Request-Time`, `Nonce`, `Content-Type`, and `Accept`. #### Signature - **Required**: Yes - **Description**: Signature information. - **Format**: `Signature: algorithm={algorithm},keyVersion={keyVersion},signature={generatedSignature}` - `algorithm`: Defaults to `RS256`. - `keyVersion`: Currently `1`. - `signature`: Generated signature. Example: `Signature: algorithm=RS256, keyVersion=1, signature=d%2FqFC126U57guKgRRXnd4colw5Ed5tpq3NDh2M5JOtfDivAze4X%2BYEaUCWHNW7h02sSed7hsnsDtM2rjtYe8kqAJTV9fMLzraeUZvWBh4j8Sf2D%2Bcz4bJ23S4F7VtoWaxMWjySwWuS0nMQweg%3DM7MY1HQFz2EXZjAa4CVflxU1I61NuEURfiYJGW%2BLEf%2FPVPEgzBLO8LopYMovmgO7Fl97E9UVFZnFW37bSaEdkNCffJlBU00AYWKaXbsARLarETkY9NA8nTJ5yDwjKm4rH3O%2FUhwGYnwLAvozKKjfWLU4m15LoAUF30Tap6d7IGFfewnLxdY34sVYG3Nx6m0Mit%2Bg%3D%3D` #### Merchant-Code - **Required**: Yes - **Description**: Unique merchant ID provided by AlphaPay (4-6 digits). - **Example**: `Merchant-Code: CXVJIU` #### Request-Time - **Required**: Yes - **Description**: Time of request, ISO 8601 format, accurate to milliseconds. - **Example**: `Request-Time: 2019-04-04T12:08:56+05:30` #### Nonce - **Required**: Yes - **Description**: Random string with a length of 32. - **Example**: `Nonce: b111bcf0dfb54d4e8bae68c293d85e2e` #### Content-Type - **Required**: Yes - **Description**: Media types for the request body. - **Example**: `Content-Type: application/json; charset=UTF-8` #### Accept - **Required**: Yes - **Description**: Media types that can be accepted. - **Example**: `Accept: application/json` ### Request Body - **Format**: JSON - **Description**: Contains detailed request information. Refer to specific API specifications for details. ``` -------------------------------- ### Transaction Inquiry Response (200 OK) Source: https://apidoc.alphapay.com/open-api/en/transaction The structure of a successful response containing transaction details, pagination information, and processing results. ```json { "transactions": [ { "requestId": "string", "transactionId": "string", "amount": "string", "currency": "CAD", "transactionType": "Credit", "settleAmount": "string", "settleCurrency": "CAD", "exchangeRate": "string", "paymentMethod": "Alipay", "createTime": "2019-08-24T14:15:22Z", "transactionTime": "2019-08-24T14:15:22Z" } ], "pagination": { "page": 0, "pageLimit": 0, "totalPage": 0, "total": 0 }, "result": { "resultCode": "string", "resultMessage": "string", "resultStatus": "S" } } ``` -------------------------------- ### POST {BASE_URL}/api/v2.0/payments/inquiryPayment Source: https://apidoc.alphapay.com/open-api/en/order_inquiry Queries the details of a payment order using the AlphaPay order ID. ```APIDOC ## POST {BASE_URL}/api/v2.0/payments/inquiryPayment ### Description Allows querying the details of a payment order by the AlphaPay order ID. ### Method POST ### Endpoint {BASE_URL}/api/v2.0/payments/inquiryPayment ### Parameters #### Request Body - **paymentId** (string) - Required - AlphaPay order ID ### Request Example ```json { "paymentId": "string" } ``` ### Response #### Success Response (200 OK) - **scenarioCode** (string) - Scenario code, representing the payment scenario. - **paymentRequestId** (string) - Merchant order ID. - **order** (object) - Order Information. - **orderAmount** (object) - The amount of the order. - **value** (string) - The value of order amount. All amount figures are based on the minimum denomination unit of given currency. - **currency** (string) - Currency code, allowed values: `CAD`/`USD` `CNY`. - **description** (string) - Title of the order (maximum length 128 characters). - **notifyUrl** (string) - Payment notification URL. - **redirectUrl** (string) - Payment redirect URL. - **paymentCreateTime** (string) - Order creation time (ISO8601 format). - **paymentExpireTime** (string) - Payment expiration time (ISO8601 format). - **paymentTime** (string) - Payment completion time (ISO8601 format). - **paymentId** (string) - AlphaPay order ID. - **paymentStatus** (string) - Order status. - **result** (object) - Process result. - **resultCode** (string) - Process result code. - **resultMessage** (string) - Process result message. - **resultStatus** (string) - The status of an API call (`S`, `F`, or `U`). #### Response Example ```json { "scenarioCode": "APP", "paymentRequestId": "string", "order": { "orderAmount": { "value": "string", "currency": "CAD" }, "description": "string", "notifyUrl": "string", "redirectUrl": "string" }, "paymentCreateTime": "2019-08-24T14:15:22Z", "paymentExpireTime": "2019-08-24T14:15:22Z", "paymentTime": "2019-08-24T14:15:22Z", "paymentId": "string", "paymentStatus": "PAYMENT_IN_PROCESS", "result": { "resultCode": "string", "resultMessage": "string", "resultStatus": "S" } } ``` ``` -------------------------------- ### POST /api/v2.0/payments/refund Source: https://apidoc.alphapay.com/open-api/en/refund Requests a refund for a given payment order. A single payment can be refunded multiple times, but the total refund amount cannot exceed the original payment amount. The refund currency must match the payment currency. ```APIDOC ## POST /api/v2.0/payments/refund ### Description Requests a refund for a given payment order. A single payment can be refunded multiple times, but the total refund amount cannot exceed the original payment amount. The refund currency must match the payment currency. ### Method POST ### Endpoint {BASE_URL}/api/v2.0/payments/refund ### Parameters #### Request Body - **paymentId** (string) - Required - AlphaPay order ID - **refundRequestId** (string) - Optional - Merchant refund ID - **refund** (object) - Required - Refund Details - **refund.refundAmount** (object) - Required - Refund amount - **refund.refundAmount.value** (string) - Required - The value of the refund amount. All amount figures are based on the minimum denomination unit of the given currency. For example, for CAD, `100` means `1.00CAD`. - **refund.description** (string) - Optional - Remark of the refund (maximum length 128 characters) - **refund.notifyUrl** (string) - Optional - Refund notification URL for pushing refund success notifications. ### Request Example ```json { "paymentId": "string", "refundRequestId": "string", "refund": { "refundAmount": { "value": "string" }, "description": "string", "notifyUrl": "string" } } ``` ### Response #### Success Response (200 OK) - **refundId** (string) - AlphaPay refund ID - **paymentId** (string) - AlphaPay order ID - **refundRequestId** (string) - Merchant refund ID - **refund** (object) - Refund Details - **refund.refundAmount** (object) - Refund amount - **refund.refundAmount.value** (string) - The value of the refund amount. All amount figures are based on the minimum denomination unit of the given currency. For example, for CAD, `100` means `1.00CAD`. - **refund.description** (string) - Remark of the refund (maximum length 128 characters) - **refund.notifyUrl** (string) - Refund notification URL for pushing refund success notifications. - **refundTime** (string) - Refund Time (ISO8601 format, e.g., 2019-05-28T12:12:12+08:00) - **result** (object) - Process result - **result.resultCode** (string) - Process result code - **result.resultMessage** (string) - Process result message - **result.resultStatus** (string) - The status of an API call (`S`: Succeeded, `F`: Failed, `U`: Unknown/Intermediate) #### Response Example ```json { "refundId": "string", "paymentId": "string", "refundRequestId": "string", "refund": { "refundAmount": { "value": "string" }, "description": "string", "notifyUrl": "string" }, "refundTime": "2019-08-24T14:15:22Z", "result": { "resultCode": "string", "resultMessage": "string", "resultStatus": "S" } } ``` ``` -------------------------------- ### Apple Pay PreOrder Request Body Source: https://apidoc.alphapay.com/open-api/en/apple_pay This JSON object represents the request body for creating an Apple Pay pre-order. It includes the merchant order ID, optional merchant identifier, and detailed order information such as amount, currency, description, and notification URL. ```json { "paymentRequestId": "string", "merchantIdentifier": "merchant.com.example.applepay", "order": { "orderAmount": { "value": "1", "currency": "CAD" }, "description": "Apple Pay test order", "notifyUrl": "https://www.example.com/notify" } } ``` -------------------------------- ### QR Code Payment Response Structure Source: https://apidoc.alphapay.com/open-api/en/payment This JSON object represents the response received after initiating a QR code payment. It contains details about the payment request, order information, payment method, and the status of the payment. ```json { "scenarioCode": "ONLINE_QRCODE", "paymentRequestId": "string", "order": { "orderAmount": { "value": "string", "currency": "CAD" }, "notifyUrl": "string", "redirectUrl": "string", "description": "string" }, "paymentMethod": { "paymentMethodType": "string", }, "paymentInfo": { "paymentUrl": "string", "paymentQRImage": "string", "payUrl": "string" }, "paymentCreateTime": "2019-08-24T14:15:22Z", "paymentExpireTime": "2019-08-24T14:15:22Z", "paymentId": "string", "result": { "resultCode": "string", "resultMessage": "string", "resultStatus": "S" } } ``` -------------------------------- ### POST {BASE_URL}/api/v2.0/payments/inquiryRefund Source: https://apidoc.alphapay.com/open-api/en/refund_inquiry Queries the details of a refund order using the AlphaPay refund ID or the merchant's refund request ID. ```APIDOC ## POST /api/v2.0/payments/inquiryRefund ### Description Queries the details of a refund order using the AlphaPay refund ID or the merchant's refund request ID. ### Method POST ### Endpoint /api/v2.0/payments/inquiryRefund ### Parameters #### Request Body - **refundId** (string) - REQUIRED - AlphaPay refund ID - **refundRequestId** (string) - Optional - Merchant refund ID ### Request Example ```json { "refundId": "string", "refundRequestId": "string" } ``` ### Response #### Success Response (200 OK) - **paymentId** (string) - AlphaPay order ID - **refundRequestId** (string) - Merchant refund ID - **refundId** (string) - AlphaPay refund ID - **refundTime** (string) - Refund Time (ISO8601 format) - **refundStatus** (string) - Refund order status (`REFUND_IN_PROCESS`, `SUCCESS`, `FAILED`) - **refund** (object) - Refund Details - **refundAmount** (object) - Refund amount - **value** (string) - The value of refund amount (minimum denomination unit) - **currency** (string) - Currency code (e.g., CAD) - **description** (string) - Remark of the refund (max 128 characters) - **notifyUrl** (string) - Refund notification URL - **result** (object) - Process result - **resultCode** (string) - Process result code - **resultMessage** (string) - Process result message - **resultStatus** (string) - API call status (`S`, `F`, `U`) #### Response Example ```json { "paymentId": "string", "refundRequestId": "string", "refundId": "string", "refundTime": "2019-08-24T14:15:22Z", "refundStatus": "REFUND_IN_PROCESS", "refund": { "refundAmount": { "value": "string", "currency": "CAD" }, "description": "string", "notifyUrl": "string" }, "result": { "resultCode": "string", "resultMessage": "string", "resultStatus": "S" } } ``` ``` -------------------------------- ### Send a request Source: https://apidoc.alphapay.com/open-api/en/sign Construct and send a payment request to the Alphapay API. This involves adding specific merchant and signature details to the request header and providing payment information in the request body. ```APIDOC ## Send a request Construct a request by adding the `Merchant-Code`, `Request-Time`, `Nonce` and `Signature` properties to the request header. After a request is constructed, you can use common tools, such as cURL or Postman to send the request. In the following example, cURL is being used: ### Method POST ### Endpoint https://openapi.alphapay.ca/api/v2.0/payments/pay ### Headers - **Accept**: application/json - **Merchant-Code**: CXVJIU - **Request-Time**: 2023-03-15T22:37:47Z - **Nonce**: b111bcf0dfb54d4e8bae68c293d85e2e - **Signature**: algorithm=RS256, keyVersion=1, signature=d%2FqFC126U57guKgRRXnd4colw5Ed5tpq3NDh2M5JOtfDivAze4X%2BYEaUCWHNW7h02sSed7hsnsDtM2rjtYe8kqAJTV9fMLzraeUZvWBh4j8Sf2D%2Bcz4bJ23S4F7VtoWaxMWjySwWuS0nMQweg%2BM7MY1HQFz2EXZjAa4CVflxU1I61NuEURfiYJGW%2BLEf%2FPVPEgzBLO8LopYMovmgO7Fl97E9UVFZnFW37bSaEdkNCffJlBU00AYWKaXbsARLarETkY9NA8nTJ5yDwjKm4rH3O%2FUhwGYnwLAvozKKjfWLU4m15LoAUF30Tap6d7IGFfewnLxdY34sVYG3Nx6m0Mit%2Bg%3D%3D - **Content-Type**: application/json ### Request Body - **scenarioCode** (string) - Required - The code for the payment scenario. - **paymentRequestId** (string) - Required - The unique identifier for the payment request. - **order** (object) - Required - Details about the order. - **orderAmount** (object) - Required - The amount of the order. - **value** (string) - Required - The monetary value. - **currency** (string) - Required - The currency code (e.g., CNY). - **description** (string) - Optional - A description of the order. - **notifyUrl** (string) - Optional - The URL to notify upon successful payment. - **redirectUrl** (string) - Optional - The URL to redirect the user after payment. - **paymentMethod** (object) - Required - Details about the payment method. - **paymentMethodType** (string) - Required - The type of payment method (e.g., Alipay). ### Request Example ```json { "scenarioCode": "ONLINE_QRCODE", "paymentRequestId": "50", "order": { "orderAmount": { "value": "45366", "currency": "CNY" }, "description": "This is a test order", "notifyUrl": "https://alphapay.com/success", "redirectUrl": "https://alphapay.com/successPage" }, "paymentMethod": { "paymentMethodType": "Alipay" } } ``` ``` -------------------------------- ### Apple Pay PreOrder Response Source: https://apidoc.alphapay.com/open-api/en/apple_pay This JSON object represents a successful response after creating an Apple Pay pre-order. It contains AlphaPay order details, Apple Pay parameters required for client-side invocation, and the processing result. ```json { "paymentRequestId": "string", "paymentId": "string", "paymentCreateTime": "2019-08-24T14:15:22Z", "paymentExpireTime": "2019-08-24T14:45:22Z", "applePayParams": { "orderId": "string", "merchantIdentifier": "merchant.com.example.applepay", "countryCode": "CA", "currencyCode": "CAD", "label": "Demo Merchant", "amount": "0.01", "supportedNetworks": ["visa", "masterCard", "amex"], "merchantCapabilities": ["supports3DS", "supportsCredit", "supportsDebit"] }, "result": { "resultCode": "PAYMENT_IN_PROCESS", "resultMessage": "string", "resultStatus": "U" } } ``` -------------------------------- ### Refund Request Body Structure Source: https://apidoc.alphapay.com/open-api/en/refund Defines the structure for the refund request payload. Ensure all required fields are populated. ```json { "paymentId": "string", "refundRequestId": "string", "refund": { "refundAmount": { "value": "string" }, "description": "string", "notifyUrl": "string" } } ```