### Python Request Example Setup Source: https://paymentservices.amazon.com/docs/api/security/standalone-3ds Basic Python import statements for using the requests and json libraries, typically used for making API calls. This snippet sets up the necessary tools for interacting with web services. ```python import requests import json ``` -------------------------------- ### Get Installment Plans Request to Payfort API in Python and JSON Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Prepares a request payload to retrieve installment plans for a given amount and downpayment via Payfort API for VALU option. Requires merchant details, phone number, total downpayment, and signature; Python example uses requests library for payload definition. Inputs are transaction parameters, outputs expected JSON with plan details. Limitations include incomplete request sending in Python sample and sandbox-only endpoint. ```python import requests # Get installment plans request plans_request = { "service_command": "GET_INSTALLMENTS_PLANS", "merchant_reference": "XYZ9239-yu898", "merchant_identifier": "CycHZxVj", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "signature": "b574e362cc08d7504d8277e71400132f06064ee1537cd570717569b583dec0b5", "phone_number": "01220422223", "payment_option": "VALU", "language": "en", "amount": 100000, "currency": "EGP", "total_downpayment": 1200, "wallet_amount": 500000, "cashback_wallet_amount": 300000 } ``` -------------------------------- ### Server-Side Integration Example (Flask) Source: https://paymentservices.amazon.com/docs/api/payment-methods/tamara An example of how to generate the Tamara payment form dynamically on the server-side using Flask. ```APIDOC ## Server-Side Integration Example (Flask) ### Description This example demonstrates how to create an HTML form for Tamara payments dynamically on the server-side using the Flask web framework in Python. This approach allows for dynamic population of form fields based on transaction data. ### Method N/A (Server-side rendering) ### Endpoint Example route: `/tamara-checkout` ### Request Body N/A (Form is generated server-side) ### Request Example (Python/Flask) ```python from flask import Flask, render_template_string app = Flask(__name__) @app.route('/tamara-checkout') def tamara_checkout(): form_html = ''' Tamara Payment Checkout

Pay with Tamara - Buy Now, Pay Later

Split your payment into interest-free installments

''' return form_html if __name__ == '__main__': app.run(debug=True) ``` ### Response #### Success Response (200) Returns an HTML page containing the payment form, ready for user interaction and submission to the Tamara payment gateway. ``` -------------------------------- ### Get Installment Plans Request - cURL Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu A command-line example using cURL to send a POST request for retrieving installment plans. It specifies the API endpoint, content type, and a JSON payload with all necessary parameters for the request. ```bash # Get installment plans request using cURL curl -X POST https://sbpaymentservices.payfort.com/FortAPI/paymentApi \ -H "Content-Type: application/json" \ -d '{ "service_command": "GET_INSTALLMENTS_PLANS", "merchant_reference": "XYZ9239-yu898", "merchant_identifier": "CycHZxVj", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "signature": "b574e362cc08d7504d8277e71400132f06064ee1537cd570717569b583dec0b5", "phone_number": "01220422223", "payment_option": "VALU", "language": "en", "amount": 100000, "currency": "EGP", "total_downpayment": 1200, "wallet_amount": 500000, "cashback_wallet_amount": 300000 }' ``` -------------------------------- ### GET /FortAPI/paymentApi - Get Installment Plans Source: https://paymentservices.amazon.com/docs/api/services/installments This endpoint allows you to retrieve available installment plans for a given amount and currency. It requires merchant and access credentials, along with payment details and a signature for authentication. ```APIDOC ## POST /FortAPI/paymentApi ### Description Retrieves available installment plans for a specified amount and currency. This is useful for e-commerce platforms to offer payment flexibility to customers. ### Method POST ### Endpoint https://sbpaymentservices.payfort.com/FortAPI/paymentApi ### Parameters #### Query Parameters (No query parameters defined for this endpoint) #### Request Body - **query_command** (string) - Required - Specifies the command to be executed, should be "GET_INSTALLMENTS_PLANS". - **access_code** (string) - Required - The access code provided by Payfort. - **merchant_identifier** (string) - Required - Your unique merchant identifier. - **amount** (integer) - Required - The total amount for which installment plans are requested (in the smallest currency unit, e.g., cents). - **currency** (string) - Required - The ISO currency code (e.g., "AED", "USD"). - **language** (string) - Optional - The preferred language for the response (e.g., "en", "ar"). Defaults to English. - **signature** (string) - Required - A signature generated using your secret key and request parameters for security. ### Request Example ```json { "query_command": "GET_INSTALLMENTS_PLANS", "access_code": "zx0IPmPy5jp1vAz", "merchant_identifier": "CycHZxVj", "amount": 100000, "currency": "AED", "language": "en", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } ``` ### Response #### Success Response (200) - **response_code** (string) - Indicates the success or failure of the operation (e.g., "62000" for success). - **response_message** (string) - A human-readable message describing the result of the operation. - **signature** (string) - A new signature for the response, used for verification. - **merchant_identifier** (string) - Your merchant identifier. - **access_code** (string) - The access code used in the request. - **query_command** (string) - The command executed. - **installment_detail** (object) - Contains detailed information about the installment plans, including issuer details and plan specifics. - **issuer_detail** (array) - A list of installment plans offered by different banks/issuers. - **issuer_code** (string) - Unique code for the issuer. - **issuer_name_ar** (string) - Issuer name in Arabic. - **issuer_name_en** (string) - Issuer name in English. - **country_code** (string) - ISO country code where the issuer operates. - **banking_system** (string) - The type of banking system (e.g., "Non Islamic"). - **terms_and_condition_ar** (string) - URL to terms and conditions in Arabic. - **terms_and_condition_en** (string) - URL to terms and conditions in English. - **formula** (string) - The formula used to calculate the installment amount. - **plan_details** (array) - Specific installment plan options for this issuer. - **plan_code** (string) - Unique code for the installment plan. - **currency_code** (string) - Currency code for the plan. - **number_of_installment** (integer) - Number of installments available. - **fees_type** (string) - Type of fees applied (e.g., "Percentage"). - **fees_amount** (number) - The amount or percentage of the fees. - **minimum_amount** (integer) - Minimum transaction amount for this plan. - **maximum_amount** (integer) - Maximum transaction amount for this plan. - **amountPerMonth** (string) - The calculated amount payable per month. - **status** (string) - A status code related to the installment plan retrieval. #### Error Response (Details on specific error codes and messages would typically be provided here, but are not in the source text) ### Request Example (cURL) ```bash curl -X POST https://sbpaymentservices.payfort.com/FortAPI/paymentApi \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "query_command": "GET_INSTALLMENTS_PLANS", "access_code": "zx0IPmPy5jp1vAz", "merchant_identifier": "CycHZxVj", "amount": 100000, "currency": "AED", "language": "en", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" }' ``` ### Response Example (Success) ```json { "response_code": "62000", "response_message": "Success", "signature": "9b02960d319318256efbc17cf57dbc1f7e7fd046e20e49215d0bed32a065c3ae", "merchant_identifier": "CycHZxVj", "access_code": "zx0IPmPy5jp1vAz", "query_command": "GET_INSTALLMENTS_PLANS", "installment_detail": { "issuer_detail": [ { "issuer_code": "fHkigRtu", "issuer_name_ar": "بنك الامارات دبي الوطني", "issuer_name_en": "Emirates NBD Egypt", "country_code": "EGY", "banking_system": "Non Islamic", "terms_and_condition_ar": "https://www.bank.com/terms-ar", "terms_and_condition_en": "https://www.bank.com/terms-en", "formula": "(amount +(amount *effective rate/100))/period", "plan_details": [ { "plan_code": "zAS4XyG2", "currency_code": "AED", "number_of_installment": 3, "fees_type": "Percentage", "fees_amount": 300, "minimum_amount": 300, "maximum_amount": 33333300, "amountPerMonth": "350.00" }, { "plan_code": "bCD5YzH3", "currency_code": "AED", "number_of_installment": 6, "fees_type": "Percentage", "fees_amount": 500, "minimum_amount": 500, "maximum_amount": 50000000, "amountPerMonth": "175.00" } ] } ] }, "status": "62" } ``` ``` -------------------------------- ### Testing The Integration Source: https://paymentservices.amazon.com/docs/api/accepting-payments/payment-link/generate Provides information on using the sandbox environment and testing cards. ```APIDOC ## POST /api/paymentservices_amazon_api/sandbox ### Description Instructions for testing the integration using the sandbox environment. ### Method POST ### Endpoint /api/paymentservices_amazon_api/sandbox ### Parameters None ### Request Body None ### Response #### Success Response (200) - **API URL:** `https://sbpaymentservices.payfort.com/FortAPI/paymentApi` - **Test Cards:** Use our comprehensive Testing Cards ``` -------------------------------- ### POST Get Installments Plans Source: https://paymentservices.amazon.com/docs/api/services/installments Retrieve available installment plans and issuer details configured for merchant account. First step of custom installments integration for building tailored user experience. ```APIDOC ## POST Get Installments Plans ### Description Retrieve available installment plans and issuer details configured for merchant account. This API provides foundation for building custom installment selection interfaces. ### Method POST ### Endpoint https://paymentservices.payfort.com/FortAPI/paymentApi ### Parameters #### Query Parameters - No query parameters #### Request Body - **command** (String) - Required - API command - **merchant_identifier** (String) - Required - Merchant identifier - **access_code** (String) - Required - Merchant access code - **merchant_reference** (String) - Required - Merchant transaction reference - **signature** (String) - Required - Request signature ### Request Example { "command": "GET_INSTALLMENTS_PLANS", "merchant_identifier": "your_merchant_id", "access_code": "your_access_code", "merchant_reference": "your_transaction_ref", "signature": "calculated_signature" } ### Response #### Success Response (200) - **installments_plans** (Array) - Available installment plans array - **issuer_details** (Object) - Bank issuer information - **command** (String) - Echo of request command - **response_code** (String) - API response code - **response_message** (String) - API response message #### Response Example { "command": "GET_INSTALLMENTS_PLANS", "response_code": "14000", "response_message": "Success", "installments_plans": [ { "plan_id": "3", "number_of_installments": "3", "issuer_name": "Bank Name", "monthly_amount": "33.33" } ], "issuer_details": { "bank_name": "Sample Bank", "eligible_amount_min": "100", "eligible_amount_max": "5000" } } ``` -------------------------------- ### Retail Cart Details Example - JSON Source: https://paymentservices.amazon.com/docs/api/security/protect-plus Example of 'cart_details' parameter for a retail sector, including item quantity, description, price, SKU, product code, and part number for iPhones and AirPods. ```json {"cart_items":[{"item_quantity":1,"item_description":"iPhone 14 Pro", "item_price":50000,"item_sku":"IPHONE14PRO","item_prod_code":"APPLE001","item_part_no":"A2894"},{"item_quantity":2,"item_description":"AirPods Pro", "item_price":15000,"item_sku":"AIRPODSPRO","item_prod_code":"APPLE002","item_part_no":"A2698"}]} ``` -------------------------------- ### Get Installment Plans Request - PHP Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Constructs and sends a POST request to the Payfort payment API to get installment plans using PHP's cURL functions. It includes a detailed JSON payload with merchant and payment information. The response from the API is then echoed. ```php "GET_INSTALLMENTS_PLANS", "merchant_reference" => "XYZ9239-yu898", "merchant_identifier" => "CycHZxVj", "access_code" => "zx0IPmPy5jp1vAz8Kpg7", "signature" => "b574e362cc08d7504d8277e71400132f06064ee1537cd570717569b583dec0b5", "phone_number" => "01220422223", "payment_option" => "VALU", "language" => "en", "amount" => 100000, "currency" => "EGP", "total_downpayment" => 1200, "wallet_amount" => 500000, "cashback_wallet_amount" => 300000 ]; // Send installment plans request $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://sbpaymentservices.payfort.com/FortAPI/paymentApi"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($plans_request)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### Gaming Cart Details Example - JSON Source: https://paymentservices.amazon.com/docs/api/security/protect-plus Example of 'cart_details' parameter for the gaming sector, detailing item quantity, description, price, SKU, product code, and part number for a balance item. ```json {"cart_items":[{"item_quantity":1000,"item_description":"2023-01-15", "item_price":25000,"item_sku":"GOLD_BALANCE","item_prod_code":"SILVER_BALANCE","item_part_no":"EXP_BALANCE"}]} ``` -------------------------------- ### Download Report via API (JSON, Python, PHP, Bash) Source: https://paymentservices.amazon.com/docs/api/managing-payments/reporting Multi-language examples for sending DOWNLOAD_REPORT command to PayFort API. Shows request structure with credentials and signature in JSON, Python, PHP, and Bash. Requires valid access_code and merchant_identifier for authentication. ```JSON { "query_command": "DOWNLOAD_REPORT", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "XYZ9239-yu898", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } ``` ```Python import requests download_data = { "query_command": "DOWNLOAD_REPORT", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "XYZ9239-yu898", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } response = requests.post( "https://sbpaymentservices.payfort.com/FortAPI/reportingApi", json=download_data, headers={"Content-Type": "application/json"} ) result = response.json() print(result) ``` ```PHP "DOWNLOAD_REPORT", "access_code" => "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier" => "CycHZxVj", "merchant_reference" => "XYZ9239-yu898", "signature" => "7cad05f0212ed933c9a5d5dffa31661acf2c827a" ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://sbpaymentservices.payfort.com/FortAPI/reportingApi"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($downloadData)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Content-Type: application/json" ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); print_r($result); ?> ``` ```Bash curl -X POST https://sbpaymentservices.payfort.com/FortAPI/reportingApi \ -H "Content-Type: application/json" \ -d '{ "query_command": "DOWNLOAD_REPORT", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "XYZ9239-yu898", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" }' ``` -------------------------------- ### POST /FortAPI/paymentApi - Get Installment Plans Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Retrieves available installment plans for a specific payment option. This endpoint allows merchants to fetch installment details based on amount, payment option, and other parameters. ```APIDOC ## POST /FortAPI/paymentApi ### Description Retrieves available installment plans for a specific payment option. This endpoint allows merchants to fetch installment details based on amount, payment option, and other parameters. ### Method POST ### Endpoint https://sbpaymentservices.payfort.com/FortAPI/paymentApi ### Parameters #### Request Body - **service_command** (string) - Required - Command type, should be "GET_INSTALLMENTS_PLANS" - **merchant_reference** (string) - Required - Merchant's unique reference for the transaction - **merchant_identifier** (string) - Required - Merchant identifier provided by Amazon Payment Services - **access_code** (string) - Required - Access code provided by Amazon Payment Services - **signature** (string) - Required - Generated signature for request authentication - **phone_number** (string) - Required - Customer's phone number - **payment_option** (string) - Required - Payment option (e.g., "VALU") - **language** (string) - Required - Language for the response (e.g., "en") - **amount** (integer) - Required - Transaction amount in smallest currency unit - **currency** (string) - Required - Currency code (e.g., "EGP") - **total_downpayment** (integer) - Optional - Total down payment amount - **wallet_amount** (integer) - Optional - Wallet amount to be used - **cashback_wallet_amount** (integer) - Optional - Cashback wallet amount to be used ### Request Example { "service_command": "GET_INSTALLMENTS_PLANS", "merchant_reference": "XYZ9239-yu898", "merchant_identifier": "CycHZxVj", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "signature": "b574e362cc08d7504d8277e71400132f06064ee1537cd570717569b583dec0b5", "phone_number": "01220422223", "payment_option": "VALU", "language": "en", "amount": 100000, "currency": "EGP", "total_downpayment": 1200, "wallet_amount": 500000, "cashback_wallet_amount": 300000 } ### Response #### Success Response (200) - **service_command** (string) - Command type - **access_code** (string) - Merchant access code - **merchant_identifier** (string) - Merchant identifier - **merchant_reference** (string) - Merchant reference - **language** (string) - Response language - **payment_option** (string) - Payment option used - **total_downpayment** (integer) - Total down payment amount - **phone_number** (string) - Customer phone number - **amount** (integer) - Transaction amount - **currency** (string) - Currency code - **signature** (string) - Response signature - **installment_detail** (array) - Array of installment plans - **tenure** (integer) - Number of months - **fee_amount** (integer) - Fee amount - **installment_amount** (integer) - Monthly installment amount - **total_installment** (integer) - Total installment amount - **wallet_amount** (integer) - Wallet amount used - **cashback_wallet_amount** (integer) - Cashback wallet amount used #### Response Example { "service_command": "GET_INSTALLMENTS_PLANS", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "XYZ9239-yu898", "language": "en", "payment_option": "VALU", "total_downpayment": 1200, "phone_number": "01220422223", "amount": 100000, "currency": "EGP", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a", "installment_detail": [ { "tenure": 6, "fee_amount": 2500, "installment_amount": 17083, "total_installment": 102500 }, { "tenure": 12, "fee_amount": 5000, "installment_amount": 8750, "total_installment": 105000 } ], "wallet_amount": 500000, "cashback_wallet_amount": 300000 } ``` -------------------------------- ### Sandbox Testing Source: https://paymentservices.amazon.com/docs/api/payment-methods/tabby Information on how to use the sandbox environment for development and testing of payment integration. ```APIDOC ## Testing The Integration ### Sandbox Testing Use the sandbox environment for development and testing: * **Sandbox URL:** `https://sbcheckout.payfort.com/FortAPI/paymentPage` * **Test Email:** Use `otp.success@tabby.ai` for successful test transactions * **Test Phone:** Use `500000001` for successful test scenarios ``` -------------------------------- ### GET /installment/plan/detail Source: https://paymentservices.amazon.com/docs/api/services/installments Retrieves details of a specific installment plan including plan code, currency, number of installments, fees structure, and amount limits. Used to display available installment options to customers. ```APIDOC ## GET /installment/plan/detail ### Description Retrieves details of a specific installment plan including plan code, currency, number of installments, fees structure, and amount limits. ### Method GET ### Endpoint /installment/plan/detail ### Parameters #### Query Parameters - **plan_code** (String) - Required - Unique code identifying the specific installment plan. Example: zAS4XyG2 - **currency_code** (String) - Required - Currency supported by this installment plan. Example: AED - **number_of_installment** (Integer) - Required - Number of monthly payments in this plan. Example: 3 - **fees_type** (String) - Required - Type of fees applied to the installment plan. Values: Fixed, Percentage - **fees_amount** (Integer) - Required - Fee amount (fixed amount or percentage based on fees_type). Example: 300 - **minimum_amount** (Integer) - Required - Minimum transaction amount eligible for this plan. Example: 300 - **maximum_amount** (Integer) - Required - Maximum transaction amount eligible for this plan. Example: 33333300 - **amountPerMonth** (Decimal) - Optional - Calculated monthly payment amount (only when amount and currency provided in request). Example: 3.00 ### Request Example ``` GET /installment/plan/detail?plan_code=zAS4XyG2¤cy_code=AED&number_of_installment=3&fees_type=Percentage&fees_amount=300&minimum_amount=300&maximum_amount=33333300 ``` ### Response #### Success Response (200) - **plan_code** (String) - Unique code identifying the specific installment plan - **currency_code** (String) - Currency supported by this installment plan - **number_of_installment** (Integer) - Number of monthly payments in this plan - **fees_type** (String) - Type of fees applied to the installment plan - **fees_amount** (Integer) - Fee amount (fixed amount or percentage based on fees_type) - **minimum_amount** (Integer) - Minimum transaction amount eligible for this plan - **maximum_amount** (Integer) - Maximum transaction amount eligible for this plan - **amountPerMonth** (Decimal) - Calculated monthly payment amount #### Response Example ```json { "plan_code": "zAS4XyG2", "currency_code": "AED", "number_of_installment": 3, "fees_type": "Percentage", "fees_amount": 300, "minimum_amount": 300, "maximum_amount": 33333300, "amountPerMonth": 3.00 } ``` ``` -------------------------------- ### Telecommunications Cart Details Example - JSON Source: https://paymentservices.amazon.com/docs/api/security/protect-plus Example of 'cart_details' parameter for the telecommunications sector, showing item quantity, description, price, SKU, product code, part number, and gift message for a monthly plan. ```json {"cart_items":[{"item_quantity":1,"item_description":"Monthly Plan", "item_price":10000,"item_sku":"MOBILE_PLAN","item_prod_code":"UNLIMITED","item_part_no":"PLAN001","item_gift_msg":"HIGH_RISK_FLAG"}]} ``` -------------------------------- ### POST /FortAPI/paymentApi (Get Installment Plans) Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Retrieves available installment plans for a given amount, payment option, and phone number using the GET_INSTALLMENTS_PLANS service command. ```APIDOC ## POST /FortAPI/paymentApi ### Description Retrieves installment plan options for the specified amount, currency, and payment option. Used to present installment choices before initiating payment. ### Method POST ### Endpoint https://sbpaymentservices.payfort.com/FortAPI/paymentApi ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **service_command** (string) - Required - Must be GET_INSTALLMENTS_PLANS - **merchant_reference** (string) - Required - Merchant transaction reference - **merchant_identifier** (string) - Required - Merchant identifier - **access_code** (string) - Required - Merchant access code - **signature** (string) - Required - HMAC/SHA signature computed by PayFort rules - **phone_number** (string) - Required - Customer phone number - **payment_option** (string) - Required - Payment option, e.g., VALU - **language** (string) - Required - Language code, e.g., en - **amount** (number) - Required - Amount in smallest currency unit - **currency** (string) - Required - ISO 4217 currency code, e.g., EGP - **total_downpayment** (number) - Optional - Downpayment amount in smallest currency unit - **wallet_amount** (number) - Optional - Wallet amount in smallest currency unit - **cashback_wallet_amount** (number) - Optional - Cashback wallet amount in smallest currency unit ### Request Example { "service_command": "GET_INSTALLMENTS_PLANS", "merchant_reference": "XYZ9239-yu898", "merchant_identifier": "CycHZxVj", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "signature": "b574e362cc08d7504d8277e71400132f06064ee1537cd570717569b583dec0b5", "phone_number": "01220422223", "payment_option": "VALU", "language": "en", "amount": 100000, "currency": "EGP", "total_downpayment": 1200, "wallet_amount": 500000, "cashback_wallet_amount": 300000 } ### Response #### Success Response (200) - **service_command** (string) - Echo of service_command - **merchant_reference** (string) - Echo of merchant_reference - **merchant_identifier** (string) - Echo of merchant_identifier - **merchant_order_id** (string) - Merchant order ID assigned by PayFort - **phone_number** (string) - Echo of phone_number - **language** (string) - Echo of language - **payment_option** (string) - Echo of payment_option - **amount** (number) - Echo of amount - **currency** (string) - Echo of currency - **total_downpayment** (number) - Total downpayment amount - **wallet_amount** (number) - Echo of wallet_amount if provided - **cashback_wallet_amount** (number) - Echo of cashback_wallet_amount if provided - **installment_detail** (array) - List of installment options: - **installment_per_month** (number) - Number of months - **installment_amount** (number) - Monthly installment amount - **fee_amount** (number) - Fee for the installment plan - **total_installment** (number) - Total amount for the installment plan - **signature** (string) - Signature for response computed by PayFort - **response_message** (string) - Human-readable response, e.g., Success - **response_code** (string) - Response code, e.g., 88000 indicates success - **status** (string) - Status code, e.g., 88 indicates success #### Response Example { "service_command": "GET_INSTALLMENTS_PLANS", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "XYZ9239-yu898", "language": "en", "payment_option": "VALU", "phone_number": "01220422223", "merchant_order_id": "Valu123", "amount": 100000, "currency": "EGP", "total_downpayment": 1200, "installment_detail": [ { "fee_amount": 500, "installment_amount": 17500, "installment_per_month": 6, "total_installment": 105000 } ], "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a", "response_message": "Success", "response_code": "88000", "status": "88", "wallet_amount": 500000, "cashback_wallet_amount": 300000 } ``` -------------------------------- ### Sample Payment Request - Python Source: https://paymentservices.amazon.com/docs/api/accepting-payments/custom-integration/pci A Python script demonstrating how to construct a payment purchase request payload using the requests library. It includes necessary parameters for API interaction. ```python import requests import json # Request payload request_data = { "command": "PURCHASE", "access_code": "zx0IPmPy5jp1vAz", "merchant_identifier": "CycHZxVj", "merchant_reference": "Test-10060", "amount": "200000", "currency": "AED", "language": "en", "customer_email": "test@payfort.com", "customer_ip": "192.178.1.10", "eci": "ECOMMERCE", "card_number": "4005550000000001", "expiry_date": "2105", "card_security_code": "123", "card_holder_name": "John Smith", "signature": "fb466699104651adb8c3eace5a3d8ea8e2dbd4739330b7379a6ece4956bed14b" } ``` -------------------------------- ### POST /FortAPI/paymentApi - Get Installments Plans Source: https://paymentservices.amazon.com/docs/api/services/installments Retrieves the list of installment plans that a merchant can offer for a specific transaction amount and currency. The request must include a valid signature and merchant credentials. Successful responses contain plan details and a response code of 62000. ```APIDOC ## POST /FortAPI/paymentApi\n\n### Description\nRetrieves available installment plans for a given transaction amount and currency.\n\n### Method\nPOST\n\n### Endpoint\nhttps://sbpaymentservices.payfort.com/FortAPI/paymentApi\n\n### Parameters\n#### Path Parameters\n*None*\n\n#### Query Parameters\n*None*\n\n#### Request Body\n- **query_command** (string) - Required - Command name, must be \"GET_INSTALLMENTS_PLANS\".\n- **access_code** (string) - Required - Merchant access code.\n- **merchant_identifier** (string) - Required - Merchant identifier.\n- **amount** (integer) - Required - Transaction amount in minor currency units (e.g., 100000 for AED 1000.00).\n- **currency** (string) - Required - ISO currency code, e.g., \"AED\".\n- **language** (string) - Optional - Language code for response messages, e.g., \"en\".\n- **signature** (string) - Required - SHA-256 signature of the request parameters.\n\n### Request Example\n{\n \"query_command\": \"GET_INSTALLMENTS_PLANS\",\n \"access_code\": \"zx0IPmPy5jp1vAz\",\n \"merchant_identifier\": \"CycHZxVj\",\n \"amount\": 100000,\n \"currency\": \"AED\",\n \"language\": \"en\",\n \"signature\": \"7cad05f0212ed933c9a5d5dffa31661acf2c827a\"\n}\n\n### Response\n#### Success Response (200)\n- **response_code** (string) - Response status code, e.g., \"62000\".\n- **response_message** (string) - Human readable message.\n- **installment_plans** (array) - List of available installment plans.\n\n#### Response Example\n{\n \"response_code\": \"62000\",\n \"response_message\": \"Success\",\n \"installment_plans\": [\n {\n \"plan_id\": \"PLAN123\",\n \"months\": 3,\n \"interest_rate\": 0.0,\n \"total_amount\": 100000\n }\n ]\n} ``` -------------------------------- ### Retrieve Installment Plans with cURL Source: https://paymentservices.amazon.com/docs/api/services/installments This command-line example shows how to fetch installment plans from the Amazon Payment Services API using cURL. It sends a POST request with a JSON payload containing the necessary parameters. This is a direct way to interact with the API without requiring a specific programming language environment. ```bash curl -X POST https://sbpaymentservices.payfort.com/FortAPI/paymentApi \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ \ "query_command": "GET_INSTALLMENTS_PLANS", \ "access_code": "zx0IPmPy5jp1vAz", \ "merchant_identifier": "CycHZxVj", \ "amount": 100000, \ "currency": "AED", \ "language": "en", \ "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" \ }' ``` -------------------------------- ### POST /sbcheckout.payfort.com/FortAPI/paymentPage (Sandbox) Source: https://paymentservices.amazon.com/docs/api/payment-methods/tamara This endpoint is for testing Tamara integration in the sandbox environment. It allows merchants to simulate transactions and verify the integration's functionality. ```APIDOC ## POST /sbcheckout.payfort.com/FortAPI/paymentPage ### Description This endpoint is for testing Tamara integration in the sandbox environment. ### Method POST ### Endpoint /sbcheckout.payfort.com/FortAPI/paymentPage ### Parameters #### Path Parameters #### Query Parameters #### Request Body - **Content-Type** (string) - Required - Must be `application/x-www-form-urlencoded` ### Request Example \`N/A (HTML Form submission)\` ### Response #### Success Response (200) - (Details about the success response are not provided in the original documentation) #### Response Example \`N/A\` ``` -------------------------------- ### Get Installments Plans Request (Python) Source: https://paymentservices.amazon.com/docs/api/services/installments Makes a POST request to the Payfort API to retrieve available installment plans for a given amount and currency. It uses the `requests` library to handle the HTTP communication and JSON for request and response payloads. Includes error handling for network issues and API response codes. ```python import requests import json def get_installments_plans(): plans_url = "https://sbpaymentservices.payfort.com/FortAPI/paymentApi" params = { 'query_command': 'GET_INSTALLMENTS_PLANS', 'access_code': 'zx0IPmPy5jp1vAz', 'merchant_identifier': 'CycHZxVj', 'amount': 100000, 'currency': 'AED', 'language': 'en', 'signature': '7cad05f0212ed933c9a5d5dffa31661acf2c827a' } try: response = requests.post( plans_url, json=params, headers={'Content-Type': 'application/json'}, timeout=30 ) response.raise_for_status() result = response.json() if result.get('response_code') == '62000': print("Installment plans retrieved successfully") return result else: print(f"Request failed: {result.get('response_message', 'Unknown error')}") return result except requests.exceptions.RequestException as e: print(f"Request failed: {str(e)}") return {'success': False, 'error': str(e)} ```