### Initiate Purchase Transaction - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Starts a purchase transaction using ExpressPay with amount, credit card details, and client IP. Returns an instance of Nihaopay::Transactions::ExpressPay. ```ruby express_pay = Nihaopay::Transactions::Purchase.start(amount, credit_card, client_ip: '192.x.x.x') ``` -------------------------------- ### Configure Nihaopay Gem Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Configures the Nihaopay gem with essential merchant details such as test mode status, merchant token, and default currency. This setup is crucial before initiating any transactions. Dependencies include the gem itself and standard Ruby environment. ```ruby Nihaopay.configure do |nihaopay| nihaopay.test_mode = true nihaopay.token = nihaopay.currency = 'USD' end ``` -------------------------------- ### Initiate Authorized Transaction with Options - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Starts an authorize transaction with ExpressPay, including optional parameters like currency, description, note, reference, and sub_mid. The sub_mid option is passed as a JSON string within a reserved field. ```ruby express_pay = Nihaopay::Transactions::Authorize.start(amount, credit_card, { client_ip: '192.x.x.x', # Required currency: 'JPY', description: 'Your order description', note: 'Something to remember', reference: 'A unique alphanumeric string', sub_mid: 'unique ID for nihaopay merchant' }) ``` -------------------------------- ### Initiate WeChatPay SecurePay Transaction Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Initiates a SecurePay transaction for WeChatPay. Similar to UnionPay and AliPay, it accepts the same options hash. The transaction is started using `Nihaopay::SecurePay::WeChatPay.start`. For WeChatPay, a QR code is typically displayed for mobile scanning. ```ruby response = Nihaopay::SecurePay::WeChatPay.start(amount, currency, options) ``` -------------------------------- ### Initiate AliPay SecurePay Transaction Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Initiates a SecurePay transaction for AliPay. It uses the same options hash as UnionPay, including reference, IPN URL, and callback URL. The `Nihaopay::SecurePay::AliPay.start` method handles the transaction initiation. The response body contains payment details. ```ruby response = Nihaopay::SecurePay::AliPay.start(amount, currency, options) ``` -------------------------------- ### Nihaopay Ruby Configuration Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Configure the Nihaopay client with your merchant token, test mode settings, and default currency. ```APIDOC ## Nihaopay Configuration ### Description Configure the Nihaopay gem with your merchant token, set the test mode, and specify the default currency. ### Method Configuration block ### Endpoint N/A ### Parameters #### Global Configuration - **test_mode** (Boolean) - Optional - Set to `true` for testing, `false` for production. Defaults to `false`. - **token** (String) - Required - Your merchant token provided by Nihaopay. - **currency** (String) - Optional - The default currency for transactions (e.g., 'USD', 'JPY'). Defaults to 'USD'. ### Request Example ```ruby Nihaopay.configure do |nihaopay| nihaopay.test_mode = true nihaopay.token = '' nihaopay.currency = 'USD' end ``` ### Response N/A (Configuration does not return a response) ``` -------------------------------- ### Initiate SecurePay Transaction - AliPay Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Initiates a SecurePay transaction using AliPay. Accepts the same options as UnionPay. ```APIDOC ## Initiate SecurePay Transaction - AliPay ### Description Initiates a SecurePay transaction for AliPay. This method accepts the same parameters as the UnionPay initiation. ### Method `Nihaopay::SecurePay::AliPay.start(amount, currency, options)` ### Endpoint N/A (Library method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **amount** (Integer) - Required - The transaction amount in the minor unit of the currency. - **currency** (String) - Required - The currency code (e.g., 'USD', 'JPY'). - **options** (Hash) - Optional - A hash containing additional transaction details (same as UnionPay). ### Request Example ```ruby options = { reference: '9876543210abcdef', ipn_url: 'http://website.com/ipn', callback_url: 'http://website.com/callback' } response = Nihaopay::SecurePay::AliPay.start(2000, 'USD', options) ``` ### Response #### Success Response (200) - **body** (String) - The response body from the Nihaopay API. #### Response Example ```ruby # Access the response body as needed puts response.body ``` ``` -------------------------------- ### Initiate SecurePay Transaction - UnionPay Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Initiates a SecurePay transaction using UnionPay. Requires amount, currency, and optional transaction details. ```APIDOC ## Initiate SecurePay Transaction - UnionPay ### Description Initiates a SecurePay transaction for UnionPay. This method requires the transaction amount, currency, and can include optional parameters for reference, notification URLs, and more. ### Method `Nihaopay::SecurePay::UnionPay.start(amount, currency, options)` ### Endpoint N/A (Library method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **amount** (Integer) - Required - The transaction amount in the minor unit of the currency (e.g., 1050 for $10.50 USD). - **currency** (String) - Required - The currency code (e.g., 'USD', 'JPY'). - **options** (Hash) - Optional - A hash containing additional transaction details: - **reference** (String) - Required - Alphanumeric string up to 30 characters, unique per transaction. - **ipn_url** (String) - Required - Instant Payment Notification URL. - **callback_url** (String) - Required - URL to redirect the user after transaction completion. - **description** (String) - Optional - Description of the transaction. - **note** (String) - Optional - Additional notes for the transaction. - **terminal** (String) - Optional - Specifies payment terminal ('ONLINE' for desktop, 'WAP' for mobile). 'WAP' for WeChat Pay is only available in live environments. - **timeout** (Integer) - Optional - Payment page timeout in minutes (1-1440). ### Request Example ```ruby options = { reference: '3461fcc31aec471780ad1a4dc6111947', ipn_url: 'http://website.com/ipn', callback_url: 'http://website.com/callback' } response = Nihaopay::SecurePay::UnionPay.start(1050, 'USD', options) ``` ### Response #### Success Response (200) - **body** (String) - The response body from the Nihaopay API, typically containing redirect information or transaction details. #### Response Example ```ruby # Assuming 'response' holds the result from the .start method # You would typically render the response body to redirect the user or display information render inline: "<%= response.body %>" ``` **Note**: Transaction data should ideally be captured from the IPN URL for reliability. ``` -------------------------------- ### Initiate SecurePay Transaction - WeChatPay Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Initiates a SecurePay transaction using WeChatPay. Displays a QR code for payment. ```APIDOC ## Initiate SecurePay Transaction - WeChatPay ### Description Initiates a SecurePay transaction for WeChatPay. This method will typically result in a QR code being displayed for the user to scan with their WeChat app to complete the payment. It accepts the same options as UnionPay. ### Method `Nihaopay::SecurePay::WeChatPay.start(amount, currency, options)` ### Endpoint N/A (Library method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **amount** (Integer) - Required - The transaction amount in the minor unit of the currency. - **currency** (String) - Required - The currency code (e.g., 'USD', 'JPY'). - **options** (Hash) - Optional - A hash containing additional transaction details (same as UnionPay). ### Request Example ```ruby options = { reference: 'wechat_ref_12345', ipn_url: 'http://website.com/ipn', callback_url: 'http://website.com/callback' } response = Nihaopay::SecurePay::WeChatPay.start(1500, 'USD', options) ``` ### Response #### Success Response (200) - **body** (String) - The response body from the Nihaopay API, which may contain information to display a QR code. #### Response Example ```ruby # The response body would be used to render the QR code or related payment information puts response.body ``` **Note**: Payment completion is indicated by a redirect to the `callback_url` or an IPN notification. ``` -------------------------------- ### Fetch Transactions with Options - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Fetches a list of transactions (SecurePay, ExpressPay, Captured) using chained methods for filtering by date range and setting a limit. Transactions are ordered by most recent first. ```ruby yesterday = Time.now - 24 * 60 * 60 week_ago = Time.now - 7 * 24 * 60 * 60 transactions = Nihaopay::Transactions::Base.before(yesterday) .after(week_ago) .limit(5).fetch ``` -------------------------------- ### Initiate UnionPay SecurePay Transaction Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Initiates a SecurePay transaction for UnionPay. Requires the transaction amount (in minor units), currency, and an options hash containing reference, IPN URL, and callback URL. Additional optional parameters like description, note, terminal type (ONLINE/WAP), and timeout can be provided. The response body contains payment details or redirects. ```ruby options = { reference: '3461fcc31aec471780ad1a4dc6111947', ipn_url: 'http://website.com/ipn', callback_url: 'http://website.com/callback' } response = Nihaopay::SecurePay::UnionPay.start(amount, currency, options) render inline: "<%= response.body %>" ``` -------------------------------- ### Fetch Transactions Default - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Fetches a list of transactions with default settings. By default, it returns the 10 most recent SecurePay, ExpressPay, and Captured transactions. ```ruby transactions = Nihaopay::Transactions::Base.fetch ``` -------------------------------- ### Refund Transaction API Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Initiate a refund for a transaction. Full refunds can be issued once, while partial refunds can be issued multiple times up to the original transaction amount. ```APIDOC ## POST /transactions/{transaction_id}/refund ### Description Initiates a refund for a specified transaction. Full refunds are allowed once per transaction, while partial refunds can be made multiple times up to the original transaction amount. ### Method POST ### Endpoint `/transactions/{transaction_id}/refund` ### Parameters #### Path Parameters - **transaction_id** (string) - Required - The unique identifier of the transaction to refund. #### Request Body - **amount** (decimal) - Optional (for partial refunds) - The amount to refund. - **reason** (string) - Optional - The reason for the refund. ### Request Example ```ruby # Full refund refunded = express_pay.refund # Full refund with reason refunded = express_pay.refund(reason: 'Out of stock') # Partial refund refunded = express_pay.partial_refund(amount) # Partial refund with reason refunded = express_pay.partial_refund(amount, reason: 'Cancellation fee') ``` ### Response #### Success Response (200) - **transaction_id** (string) - The unique identifier of the original transaction. - **status** (string) - The status of the refund operation (e.g., "success"). - **refunded** (boolean) - Indicates if the refund was successful. - **refund_transaction_id** (string) - The identifier of the refund transaction. - **time** (datetime) - The timestamp when the refund was processed. #### Response Example ```json { "transaction_id": "20160718111604002633", "status": "success", "refunded": true, "refund_transaction_id": "20160718111529002632", "time": "2017-01-18T12:08:42+0900" } ``` ``` -------------------------------- ### Fetch Transactions with Fetch Options - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Fetches a list of transactions by passing filtering options directly to the fetch method. This method supports filtering by date range ('before', 'after') and setting the number of results ('limit'). ```ruby yesterday = Time.now - 24 * 60 * 60 week_ago = Time.now - 7 * 24 * 60 * 60 transactions = Nihaopay::Transactions::Base.fetch(before: yesterday, after: week_ago, limit: 5) ``` -------------------------------- ### Refund Transaction in Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Initiate a refund for a transaction. Full refunds can be performed once per transaction, while partial refunds can be made multiple times up to the original transaction amount. Both methods accept an optional reason parameter. The refund operation returns a refund object with status and associated transaction IDs. ```ruby # Full refund refunded = express_pay.refund # Full refund with reason refunded = express_pay.refund(reason: 'Out of stock') # Partial refund refunded = express_pay.partial_refund(amount) # Partial refund with reason refunded = express_pay.partial_refund(amount, reason: 'Cancellation fee') ``` -------------------------------- ### Fetch Transactions with Limit - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Fetches a specified number of transactions, between 1 and 100, by calling the `limit` method before `fetch`. This allows for custom pagination of transaction results. ```ruby transactions = Nihaopay::Transactions::Base.limit(5).fetch ``` -------------------------------- ### Fetch Transactions Before Specific Time - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Retrieves transactions processed before a given time. The `before` method accepts a `Time` object to filter results based on their processing timestamp. ```ruby yesterday = Time.now - 24 * 60 * 60 transactions = Nihaopay::Transactions::Base.before(yesterday).fetch ``` -------------------------------- ### Merchant-Specific Transactions in Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Perform payment gateway operations using a specific merchant token for multi-merchant configurations. This allows for issuing transactions per merchant, including authorization, capture, purchase, release, and refund. These operations can include additional parameters like client IP, currency, and reason for refund. ```ruby # Authorize transaction for a specific merchant merchant_token = "6c4dc4828474fa73c5f438a9eb2fbf3092e44" nihaopay_merchant = Nihaopay::Merchant.new(merchant_token) express_pay = nihaopay_merchant.authorize(amount, credit_card) express_pay = nihaopay_merchant.authorize(amount, credit_card, client_ip: '192.x.x.x') # Capture transaction express_pay = nihaopay_merchant.capture(transaction_id, amount, currency) # Purchase transaction express_pay = nihaopay_merchant.purchase(amount, credit_card, client_ip: '192.x.x.x') # Release transaction express_pay = nihaopay_merchant.release(transaction_id) # Refund transaction express_pay = nihaopay_merchant.refund(transaction_id, amount, currency) express_pay = nihaopay_merchant.refund(transaction_id, amount, currency, reason: 'Cancellation fee') ``` -------------------------------- ### Create Credit Card Object for ExpressPay Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Defines a credit card object required for initiating an ExpressPay transaction. It includes mandatory fields like card number, expiry year, expiry month, and CVV. The expiry month should be between '01' and '12'. ```ruby credit_card = Nihaopay::CreditCard.new( number: '6221558812340000', expiry_year: 2017, expiry_month: 11, cvv: '123') ``` -------------------------------- ### Fetch Transactions After Specific Time - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Retrieves transactions processed after a given time. The `after` method accepts a `Time` object to filter results based on their processing timestamp. ```ruby yesterday = Time.now - 24 * 60 * 60 transactions = Nihaopay::Transactions::Base.after(yesterday).fetch ``` -------------------------------- ### Merchant Specific Transactions API Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Perform various payment transactions (authorize, capture, purchase, release, refund) using a specific merchant token, allowing for multi-merchant configurations. ```APIDOC ## Merchant Operations ### Description Perform various payment transactions like authorization, capture, purchase, release, and refund using a specific merchant token. This is useful when managing multiple merchant accounts. ### Method POST (for most operations) ### Endpoint Various endpoints depending on the operation, managed via `Nihaopay::Merchant` object. ### Parameters #### Override Global Token - **merchant_token** (string) - Required - The token for the specific merchant. #### Common Transaction Parameters - **amount** (decimal) - Required - The transaction amount. - **currency** (string) - Optional - The transaction currency. - **credit_card** (object) - Required (for authorize/purchase) - Credit card details. - **client_ip** (string) - Optional - The client's IP address. - **transaction_id** (string) - Required (for capture/release/refund) - The ID of the transaction to operate on. - **reason** (string) - Optional (for refund) - The reason for the refund. - **description** (string) - Optional - A description for the transaction. - **reference** (string) - Optional - A reference identifier for the transaction. - **note** (string) - Optional - Any notes associated with the transaction. - **sub_mid** (string) - Optional - Sub-merchant ID. ### Request Example ```ruby # Initialize with a specific merchant token merchant_token = "6c4dc4828474fa73c5f438a9eb2fbf3092e44" nihaopay_merchant = Nihaopay::Merchant.new(merchant_token) # Authorize a payment express_pay = nihaopay_merchant.authorize(amount, credit_card, client_ip: '192.x.x.x') # Capture a transaction express_pay = nihaopay_merchant.capture(transaction_id, amount, currency) # Purchase express_pay = nihaopay_merchant.purchase(amount, credit_card, client_ip: '192.x.x.x') # Release a transaction express_pay = nihaopay_merchant.release(transaction_id) # Refund a transaction (full) express_pay = nihaopay_merchant.refund(transaction_id, amount, currency) # Refund a transaction (partial with reason) express_pay = nihaopay_merchant.refund(transaction_id, amount, currency, reason: 'Cancellation fee') ``` ### Response #### Success Response (200) - **transaction_id** (string) - The unique identifier of the transaction. - **status** (string) - The status of the operation. - **amount** (decimal) - The transaction amount. - **currency** (string) - The transaction currency. - **time** (datetime) - The timestamp of the operation. #### Response Example ```json { "transaction_id": "20160718111604002633", "status": "success", "amount": 50.00, "currency": "USD", "time": "2016-07-18T11:16:04Z" } ``` ``` -------------------------------- ### Look up Transaction Details in Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Retrieve details of a specific transaction using its unique ID. This method requires a transaction ID as input and returns a transaction object containing details like transaction ID, type, status, amount, currency, time, reference, and note. Only SecurePay, ExpressPay, and Captured transactions are supported for lookup. ```ruby transaction = Nihaopay::Transactions::Base.find(transaction_id) transaction.transaction_id # => "20160718111604002633" transaction.type # => "charge" transaction.status # => "success" ``` -------------------------------- ### Capture Transaction - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Captures an authorized transaction. It returns details about the capture, including transaction ID, status, and whether it was successfully captured. Partial captures are also supported by passing an amount. ```ruby captured = express_pay.capture # captured.transaction_id # => "20160718111604002633" # captured.status # => "success" # captured.captured # => true # captured.capture_transaction_id # => "20160718111529002632" (id of the transaction that was captured) # captured.time # => 2017-01-18 12:08:42 +0900 ``` ```ruby captured = express_pay.partial_capture(amount) ``` -------------------------------- ### Release Transaction - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Releases an uncaptured transaction. The response includes details like the transaction ID, status, and whether it was successfully released. ```ruby released = express_pay.release # released.transaction_id # => "20160718111604002633" # released.status # => "success" # released.released # => true # released.release_transaction_id # => "20160718111529002632" (id of the transaction that was released) # released.time # => 2017-01-18 12:08:42 +0900 ``` -------------------------------- ### ExpressPay - Authorize Transaction Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Authorizes a transaction using ExpressPay with credit card details. ```APIDOC ## ExpressPay - Authorize Transaction ### Description Authorizes a payment transaction using ExpressPay by providing credit card details. This method is used for direct credit card processing. ### Method `Nihaopay::Transactions::Authorize.start(amount, credit_card, client_ip: 'x.x.x.x')` ### Endpoint N/A (Library method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **amount** (Integer) - Required - The transaction amount in the minor unit of the currency. - **credit_card** (Object) - Required - An instance of `Nihaopay::CreditCard` containing card details: - **number** (String) - Required - The credit card number. - **expiry_year** (Integer) - Required - The expiry year (e.g., 2025). - **expiry_month** (Integer) - Required - The expiry month (01-12). - **cvv** (String) - Required - The Card Verification Value. - **client_ip** (String) - Required - The IP address of the client making the transaction. ### Request Example ```ruby credit_card = Nihaopay::CreditCard.new( number: '6221558812340000', expiry_year: 2017, expiry_month: 11, cvv: '123' ) express_pay_response = Nihaopay::Transactions::Authorize.start(1000, credit_card, client_ip: '192.168.1.100') ``` ### Response #### Success Response (200) - **express_pay** (Object) - An instance of `Nihaopay::Transactions::ExpressPay` containing transaction details: - **transaction_id** (String) - The unique ID of the transaction. - **status** (String) - The status of the transaction (e.g., 'success'). - **reference** (String) - The reference ID provided for the transaction. - **currency** (String) - The currency code. - **amount** (Integer) - The transaction amount. - **captured** (Boolean) - Indicates if the amount has been captured. - **time** (DateTime) - The timestamp of the transaction. - **note** (String) - Optional notes. #### Response Example ```ruby puts express_pay_response.transaction_id # => "20160714132438002485" puts express_pay_response.status # => "success" puts express_pay_response.amount # => 1000 ``` ``` -------------------------------- ### Authorize ExpressPay Transaction Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Authorizes an ExpressPay transaction using the provided amount, a `Nihaopay::CreditCard` object, and the client's IP address. The `client_ip` is a mandatory parameter. The response object contains transaction details like ID, status, and amount. ```ruby express_pay = Nihaopay::Transactions::Authorize.start(amount, credit_card, client_ip: '192.x.x.x') express_pay.transaction_id # => "20160714132438002485" express_pay.status # => "success" express_pay.reference # => "3461fcc31aec471780ad1a4dc6111947" express_pay.currency # => "JPY" express_pay.amount # => 1000 express_pay.captured # => false express_pay.time # => 2017-01-18 12:08:42 +0900 ``` -------------------------------- ### Override Token for AliPay Transaction Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Overrides the default merchant token for an AliPay transaction by creating a `Nihaopay::Merchant` object with a specific token and then invoking the `ali_pay` method. This provides flexibility for using different merchant credentials. ```ruby merchant = Nihaopay::Merchant.new(token) response = merchant.ali_pay(amount, currency, options) ``` -------------------------------- ### Override Global Token for Payments Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Allows overriding the globally configured merchant token for specific payment operations. ```APIDOC ## Override Global Token ### Description This allows you to use a different merchant token for specific payment initiation calls, overriding the one set in the global configuration. ### Method `merchant.union_pay(amount, currency, options)` `merchant.ali_pay(amount, currency, options)` `merchant.wechat_pay(amount, currency, options)` ### Endpoint N/A (Library method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **merchant** (Object) - Required - An instance of `Nihaopay::Merchant` initialized with the desired token. - **token** (String) - Required - The specific merchant token to use for this operation. - **amount** (Integer) - Required - The transaction amount in the minor unit of the currency. - **currency** (String) - Required - The currency code (e.g., 'USD', 'JPY'). - **options** (Hash) - Optional - Transaction options (refer to SecurePay documentation for details). ### Request Example ```ruby # For UnionPay merchant = Nihaopay::Merchant.new('specific_merchant_token_for_unionpay') response = merchant.union_pay(1000, 'USD', { reference: 'unionpay_ref_override' }) # For AliPay merchant = Nihaopay::Merchant.new('specific_merchant_token_for_alipay') response = merchant.ali_pay(1500, 'JPY', { reference: 'alipay_ref_override' }) # For WeChatPay merchant = Nihaopay::Merchant.new('specific_merchant_token_for_wechatpay') response = merchant.wechat_pay(2000, 'USD', { reference: 'wechatpay_ref_override' }) ``` ### Response #### Success Response (200) - **response** (Object/String) - The response from the respective payment method. The exact format depends on the payment type (e.g., redirect URL, transaction details). #### Response Example ```ruby puts response.body # Or other relevant attributes based on the payment method ``` ``` -------------------------------- ### Transaction Lookup API Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Retrieve details of a specific transaction using its unique transaction ID. This is applicable for SecurePay, ExpressPay, and Captured transactions. ```APIDOC ## GET /transactions/{transaction_id} ### Description Retrieves the details of a specific transaction using its unique transaction ID. ### Method GET ### Endpoint `/transactions/{transaction_id}` ### Parameters #### Path Parameters - **transaction_id** (string) - Required - The unique identifier of the transaction to look up. ### Request Example ```ruby transaction = Nihaopay::Transactions::Base.find(transaction_id) puts transaction.transaction_id ``` ### Response #### Success Response (200) - **transaction_id** (string) - The unique identifier of the transaction. - **type** (string) - The type of transaction (e.g., "charge", "authorization", "capture"). - **status** (string) - The status of the transaction (e.g., "success"). - **amount** (decimal) - The transaction amount. - **currency** (string) - The transaction currency. - **time** (datetime) - The timestamp of the transaction. - **reference** (string) - The reference identifier for the transaction. - **note** (string) - Any notes associated with the transaction. #### Response Example ```json { "transaction_id": "20160718111604002633", "type": "charge", "status": "success", "amount": 100.50, "currency": "USD", "time": "2016-07-18T11:16:04Z", "reference": "REF12345", "note": "Customer order" } ``` ``` -------------------------------- ### Override Token for WeChatPay Transaction Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Allows overriding the globally configured merchant token for a WeChatPay transaction. This is achieved by instantiating `Nihaopay::Merchant` with a specific token and then calling the `wechat_pay` method, offering granular control over merchant credentials. ```ruby merchant = Nihaopay::Merchant.new(token) response = merchant.wechat_pay(amount, currency, options) ``` -------------------------------- ### Cancel Transaction - Ruby Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Cancels a transaction before the daily settlement deadline. The result provides the transaction ID, status, and cancellation confirmation. Cannot be used if a refund has been issued. ```ruby cancelled = express_pay.cancel # cancelled.transaction_id # => "20160718111604002633" # cancelled.status # => "success" # cancelled.cancelled # => true # cancelled.cancel_transaction_id # => "20160718111529002632" (id of the transaction that was cancelled) # cancelled.time # => 2017-01-18 12:08:42 +0900 ``` -------------------------------- ### Override Token for UnionPay Transaction Source: https://github.com/tablecheck/nihaopay-ruby/blob/master/README.md Allows overriding the globally configured merchant token for a specific UnionPay transaction. This is useful when managing multiple merchant accounts. It requires creating a Nihaopay::Merchant instance with the desired token and then calling the `union_pay` method. ```ruby merchant = Nihaopay::Merchant.new(token) response = merchant.union_pay(amount, currency, options) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.