### React Native iOS Setup - pod install Source: https://paymentservices.amazon.com/docs/accepting-payments/Mobile/integrate Run pod install in the iOS directory to set up the React Native SDK for iOS. ```bash cd ios && pod install ``` -------------------------------- ### Sample Response for Installment Plans Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Example response from the installment plans request, showing installment details with tenure, fees, and amounts. ```json { "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 } ``` -------------------------------- ### Get Installment Plans - Python Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Python example to retrieve installment plans. Sends a POST request to the payment API with the GET_INSTALLMENTS_PLANS service command. ```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, "cashback_wallet_amount": 300000 } # Send installment plans request response = requests.post( "https://sbpaymentservices.payfort.com/FortAPI/paymentApi", json=plans_request, headers={'Content-Type': 'application/json'} ) print(response.json()) ``` -------------------------------- ### React Native Installation with yarn Source: https://paymentservices.amazon.com/docs/accepting-payments/Mobile/integrate Install the react-native-payfort-sdk package using yarn. ```bash yarn add react-native-payfort-sdk ``` -------------------------------- ### OTP Generate Sample Response Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Example JSON response for the OTP_GENERATE request, showing success status, installment details, and wallet amounts. ```JSON { "service_command": "OTP_GENERATE", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "TEST-009967", "language": "en", "payment_option": "VALU", "phone_number": "01220422223", "merchant_order_id": "Valu123", "amount": 100000, "currency": "EGP", "total_downpayment": 10000, "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 } ``` -------------------------------- ### React Native Installation with npm Source: https://paymentservices.amazon.com/docs/accepting-payments/Mobile/integrate Install the react-native-payfort-sdk package using npm. ```bash npm install react-native-payfort-sdk ``` -------------------------------- ### iOS Installation with CocoaPods Source: https://paymentservices.amazon.com/docs/accepting-payments/Mobile/integrate Add the PayFortSDK to your iOS project using CocoaPods. This is the first installation option for iOS. ```ruby pod 'PayFortSDK' ``` -------------------------------- ### Get Installment Plans Sample Request (JSON) Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu JSON payload for the GET_INSTALLMENTS_PLANS service command. Includes merchant details, phone number, amount, and wallet amounts. ```JSON { "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 } ``` -------------------------------- ### iOS Installation with Swift Package Manager Source: https://paymentservices.amazon.com/docs/accepting-payments/Mobile/integrate Add the PayFortSDK to your iOS project using Swift Package Manager. This is the second installation option for iOS. ```swift dependencies: [ .package(url: "https://github.com/payfort/payfort-ios-sdk.git", from: "1.0.0") ] ``` -------------------------------- ### Sample response for GET_INSTALLMENTS_PLANS Source: https://paymentservices.amazon.com/docs/api/services/installments Example JSON response returned by the API when the request succeeds. Contains response_code 62000, response_message 'Success', and installment details including issuer and plan information. ```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" } ``` -------------------------------- ### Payment Links - API Request Example Source: https://paymentservices.amazon.com/docs/api Example request for creating a payment link using the PAYMENT_LINK service command. ```APIDOC ## Payment Links - API Request Example ### Description Example request for creating a payment link. ### Method POST ### Endpoint Not specified ### Parameters #### Request Body - **service_command** (string) - Required - Set to "PAYMENT_LINK". - **access_code** (string) - Required - The access code. - **merchant_identifier** (string) - Required - The merchant identifier. - **merchant_reference** (string) - Required - Unique merchant reference. - **amount** (string) - Required - Transaction amount in minor units. - **currency** (string) - Required - Currency code (e.g., AED). - **language** (string) - Required - Language code (en or ar). - **customer_email** (string) - Required - Customer email. - **customer_name** (string) - Required - Customer name. - **request_expiry_date** (string) - Required - Expiry date of the payment link. - **notification_type** (string) - Required - Notification type (e.g., EMAIL). - **order_description** (string) - Required - Description of the order. - **return_url** (string) - Required - URL to redirect after payment. - **signature** (string) - Required - SHA-256 signature. ### Request Example { "service_command": "PAYMENT_LINK", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "INV-2024-001", "amount": "125000", "currency": "AED", "language": "en", "customer_email": "customer@example.com", "customer_name": "John Smith", "request_expiry_date": "2024-12-31T23:59:59+04:00", "notification_type": "EMAIL", "order_description": "Premium subscription - 1 year", "return_url": "https://yoursite.com/payment-success", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } ``` -------------------------------- ### Payment Link Request Example Source: https://paymentservices.amazon.com/docs/api Example of a payment link request using the PAYMENT_LINK service command. Includes amount in minor units (fils), currency, customer details, and a return URL. ```json { "service_command": "PAYMENT_LINK", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "INV-2024-001", "amount": "125000", "currency": "AED", "language": "en", "customer_email": "customer@example.com", "customer_name": "John Smith", "request_expiry_date": "2024-12-31T23:59:59+04:00", "notification_type": "EMAIL", "order_description": "Premium subscription - 1 year", "return_url": "https://yoursite.com/payment-success", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } ``` -------------------------------- ### Response example for GET_INSTALLMENTS_PLANS Source: https://paymentservices.amazon.com/docs/Services/Installments Partial JSON response from the GET_INSTALLMENTS_PLANS API, showing response_code, response_message, signature, merchant_identifier, access_code, language, service_command, and installment_detail with issuer details. The example is truncated at 47 lines. ```json { "response_code": "20000", "response_message": "Success", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a", "merchant_identifier": "CycHZxVj", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "language": "en", "service_command": "GET_INSTALLMENTS_PLANS", "installment_detail": { "issuer_detail": [ { "issuer_code": "ADCB", "issuer_name_en": "Abu Dhabi Commercial Bank", "issuer_name_ar": "بنك أبوظبي التجاري", "issuer_logo_en": "https://paymentservices.amazon.com/docs/logos/adcb_en.png", "issuer_logo_ar": "https://paymentservices.amazon.com/docs/logos/adcb_ar.png", "bin_details": [ { ``` -------------------------------- ### Get Installment Plans - PHP Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu PHP example to retrieve installment plans using cURL. Sends a POST request with the GET_INSTALLMENTS_PLANS service command. ```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, "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; ?> ``` -------------------------------- ### POST /FortAPI/paymentApi - Get Installment Plans Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Retrieves available installment plans for a customer based on the provided parameters. This is used to display installment options to the customer before purchase. ```APIDOC ## POST /FortAPI/paymentApi ### Description Retrieves available installment plans for a customer based on the provided parameters. This is used to display installment options to the customer before purchase. ### Method POST ### Endpoint https://sbpaymentservices.payfort.com/FortAPI/paymentApi ### Parameters #### Request Body - **service_command** (string) - Required - The command to execute, set to "GET_INSTALLMENTS_PLANS". - **merchant_reference** (string) - Required - Unique merchant reference for the transaction. - **merchant_identifier** (string) - Required - Merchant identifier provided by PayFort. - **access_code** (string) - Required - Access code provided by PayFort. - **signature** (string) - Required - Signature for request authentication. - **phone_number** (string) - Required - Customer's phone number. - **payment_option** (string) - Required - Payment option, set to "VALU". - **language** (string) - Required - Language code (e.g., "en"). - **amount** (number) - Required - Transaction amount in minor units. - **currency** (string) - Required - Currency code (e.g., "EGP"). - **total_downpayment** (number) - Optional - Total down payment amount. - **wallet_amount** (number) - Optional - Wallet amount. - **cashback_wallet_amount** (number) - Optional - Cashback wallet amount. ### 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 the command. - **access_code** (string) - Access code. - **merchant_identifier** (string) - Merchant identifier. - **merchant_reference** (string) - Merchant reference. - **language** (string) - Language code. - **payment_option** (string) - Payment option. - **total_downpayment** (number) - Total down payment. - **phone_number** (string) - Customer phone number. - **amount** (number) - Transaction amount. - **currency** (string) - Currency code. - **signature** (string) - Response signature. - **installment_detail** (array) - List of installment plans. - **tenure** (number) - Number of installments. - **fee_amount** (number) - Fee amount. - **installment_amount** (number) - Amount per installment. - **total_installment** (number) - Total installment amount. - **wallet_amount** (number) - Wallet amount. - **cashback_wallet_amount** (number) - Cashback wallet amount. #### 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 } ``` -------------------------------- ### SDK Token Request Sample (SDK-request.json) Source: https://paymentservices.amazon.com/docs/accepting-payments/Mobile/integrate Example JSON request to generate an SDK token. Includes command, access_code, merchant_identifier, language, device_id, and signature. ```json { "command": "SDK_TOKEN", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "language": "en", "device_id": "ffffffff-a9fa-0b44-7b27-29e70033c587", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } ``` -------------------------------- ### Sample Payment Request (PURCHASE) Source: https://paymentservices.amazon.com/docs/api/accepting-payments/mobile-integration Sample JSON request for a purchase transaction using the SDK token. Includes command, merchant_reference, amount, currency, language, customer_email, sdk_token, payment_option, eci, order_description, customer_name, and customer_ip. ```json { "command": "PURCHASE", "merchant_reference": "ORDER-123456", "amount": 10000, "currency": "AED", "language": "en", "customer_email": "customer@example.com", "sdk_token": "Dwp78q9", "payment_option": "VISA", "eci": "ECOMMERCE", "order_description": "Test Order", "customer_name": "John Doe", "customer_ip": "192.168.1.1" } ``` -------------------------------- ### Get Installment Plans - cURL Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu cURL command to retrieve installment plans. Sends a POST request with the GET_INSTALLMENTS_PLANS service command. ```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 }' ``` -------------------------------- ### Sample Response from Installments Payment Source: https://paymentservices.amazon.com/docs/api/services/installments Example response from the payment gateway after a successful installments transaction. Shows response_code 14000, status 20, fort_id, payment_option VISA, authorization_code, and number_of_installments. ```plaintext command=PURCHASE access_code=zx0IPmPy5jp1vAz8Kpg7 merchant_identifier=CycHZxVj merchant_reference=INST-ORDER-2024-1725887587 amount=150000 currency=AED language=en response_code=14000 response_message=Success status=20 fort_id=149295435400084008 payment_option=VISA authorization_code=P1000000000000372136 customer_email=customer@example.com number_of_installments=6 signature=b2c4d6e8f0a1b3c5d7e9f1a2b4c6d8e0f2a4b6c8d0e2f4a6b8c0d2e4f6a8b0c2 ``` -------------------------------- ### Android Implementation - PaymentActivity Source: https://paymentservices.amazon.com/docs/accepting-payments/Mobile/integrate Initialize the Fort SDK and create a callback manager in an Android activity. The snippet shows the beginning of the onCreate method, including setting the content view and initializing the SDK. ```java import com.payfort.fort.android.sdk.base.FortSdk; import com.payfort.fort.android.sdk.base.callbacks.FortCallBackManager; public class PaymentActivity extends AppCompatActivity { private FortSdk fortSdk; private FortCallBackManager fortCallBackManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_payment); // Initialize SDK fortSdk = FortSdk.getInstance(); fortCallBackManager = FortCallBackManager.Factory.create(); // Set callback listener ``` -------------------------------- ### Get installments plans request in Python Source: https://paymentservices.amazon.com/docs/api/services/installments Python function that sends a POST request to the PayFort payment API to retrieve installment plans. It handles the response, checks for response_code 62000, and prints success or failure messages. ```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)} # Usage example plans_result = get_installments_plans() ``` -------------------------------- ### Purchase Request - JSON Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu JSON example for a purchase request using the PURCHASE command. Includes OTP and tenure parameters. ```json { "merchant_reference": "XYZ9239-yu898", "merchant_identifier": "CycHZxVj", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "signature": "b574e362cc08d7504d8277e71400132f06064ee1537cd570717569b583dec0b5", "command": "PURCHASE", "language": "en", "payment_option": "VALU", "phone_number": "00008557694", "amount": 10000, "currency": "EGP", "customer_email": "customer@domain.com", "otp": "123456", "tenure": "6", "total_down_payment": "1200", "purchase_description": "Test", "wallet_amount": 500000, "cashback_wallet_amount": 300000 } ``` -------------------------------- ### Sample Payment Request (payment-request.json) Source: https://paymentservices.amazon.com/docs/accepting-payments/custom-integration/integrate-non-pci JSON request for processing a payment using a token. Use command PURCHASE to capture immediately or AUTHORIZATION to hold the amount. ```json { "command": "PURCHASE", "access_code": "s4lwuuoY5upZlZY5D6dr", "merchant_identifier": "WeVJHPYm", "merchant_reference": "ORD-12345-2024", "amount": "2000", "currency": "AED", "language": "en", "customer_email": "customer@example.com", "signature": "calculated_signature_here", "token_name": "8bc8ba22dcc34b838024ef03f8d89786" } ``` -------------------------------- ### Get installments plans request JSON Source: https://paymentservices.amazon.com/docs/api/services/installments JSON payload for the GET_INSTALLMENTS_PLANS query command. Includes required parameters: query_command, access_code, merchant_identifier, amount, currency, language, and signature. ```json { "query_command": "GET_INSTALLMENTS_PLANS", "access_code": "zx0IPmPy5jp1vAz", "merchant_identifier": "CycHZxVj", "amount": 100000, "currency": "AED", "language": "en", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } ``` -------------------------------- ### Customer Verify Sample Request (Python) Source: https://paymentservices.amazon.com/docs/api/payment-methods/valu Python script using requests to send the Customer Verify request to the sandbox URL. Posts the JSON payload and prints the response. Requires the requests library. ```Python import requests # Customer verification request verify_request = { "service_command": "CUSTOMER_VERIFY", "merchant_reference": "XYZ9239-yu898", "merchant_identifier": "CycHZxVj", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "language": "en", "payment_option": "VALU", "phone_number": "00008557694", "signature": "54efbd76bd644e9ef237c39137bf5d2304dc1bfdf6f6302065b448f2456a07a7" } # Send verification request response = requests.post( "https://sbpaymentservices.payfort.com/FortAPI/paymentApi", json=verify_request, headers={'Content-Type': 'application/json'} ) print(response.json()) ``` -------------------------------- ### Capture Request Sample (JSON) Source: https://paymentservices.amazon.com/docs/managing-payments/capturing-payment Example JSON request for the capture API. The merchant_reference must match the one used in the original authorization. The signature is calculated as per the Signature Calculation Guide. ```json { "command": "CAPTURE", "access_code": "s4lwuuoY5upZlZY5D6dr", "merchant_identifier": "WeVJHPYm", "merchant_reference": "Test", "amount": "300", "currency": "AED", "language": "en", "signature": "{{signature}}" } ``` -------------------------------- ### Python Request Example Source: https://paymentservices.amazon.com/docs/api/security/protect-plus Python script using requests to send a PURCHASE request with Protect Plus parameters to the sandbox URL. Includes customer, shipping, fraud extra fields, cart details, and device fingerprint. ```Python import requests import json # Request payload with Protect Plus parameters request_data = { "command": "PURCHASE", "access_code": "zx0IPmPy5jp1vAz8Kpg7", "merchant_identifier": "CycHZxVj", "merchant_reference": "PROTECT-PLUS-001", "amount": "50000", "currency": "AED", "language": "en", "customer_email": "customer@example.com", "customer_ip": "192.168.1.100", "card_number": "4005550000000001", "expiry_date": "2505", "card_security_code": "123", "card_holder_name": "John Smith", "eci": "ECOMMERCE", # Customer Information "customer_type": "B", "customer_id": "CUST123456", "customer_first_name": "John", "customer_last_name": "Smith", "customer_phone": "00971501234567", "customer_address1": "Dubai Marina", "customer_city": "Dubai", "customer_country_code": "ARE", "customer_zip_code": "12345", # Shipping Information "ship_type": "S", "ship_first_name": "John", "ship_last_name": "Smith", "ship_address1": "Dubai Marina", "ship_address_city": "Dubai", "ship_country_code": "ARE", "ship_email": "customer@example.com", "ship_method": "N", # Fraud Extra Fields (Retail Sector Example) "fraud_extra1": "Dubai Marina, Dubai, ARE, 12345", "fraud_extra2": "Dubai Marina, Dubai, ARE, 12345", "fraud_extra11": "365", "fraud_extra12": "5", "fraud_extra13": "30", "fraud_extra14": "90", "fraud_extra16": "3", "fraud_extra17": "N", "fraud_extra18": "WEB", "fraud_extra19": "PRIVATE", "fraud_extra20": "10", "fraud_extra23": "WEB", # Cart Details "cart_details": "{cart_items:[{item_quantity:1,item_description:'iPhone 14 Pro', item_price:50000,item_sku:'IPHONE14PRO'}]}", # Device Fingerprint "device_fingerprint": "04003hQUMXGB0po2NmM9AAABAAAAAAA...", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } # Send request response = requests.post( "https://sbpaymentservices.payfort.com/FortAPI/paymentApi", json=request_data, headers={'Content-Type': 'application/json'} ) print(response.json()) ``` -------------------------------- ### cURL command to get installment plans Source: https://paymentservices.amazon.com/docs/api/services/installments cURL command that sends a POST request to the FortAPI payment endpoint with the GET_INSTALLMENTS_PLANS command. Uses JSON headers and includes the required parameters in the request body. ```bash # Get installment plans using cURL 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" }' ``` -------------------------------- ### iOS Implementation - PaymentViewController Source: https://paymentservices.amazon.com/docs/accepting-payments/Mobile/integrate Initialize the PayFort SDK and prepare a payment request in an iOS view controller. The snippet shows the beginning of the processPayment method, including setting up the request dictionary with command, access code, merchant identifier, and other required fields. ```swift import PayFortSDK class PaymentViewController: UIViewController { func processPayment() { // Initialize PayFort SDK let payFort = PayFortController.init() // Prepare payment request var request: NSMutableDictionary = NSMutableDictionary() request["command"] = "PURCHASE" request["access_code"] = "zx0IPmPy5jp1vAz8Kpg7" request["merchant_identifier"] = "CycHZxVj" request["merchant_reference"] = "XYZ9239-yu898" request["amount"] = "10000" request["currency"] = "AED" request["language"] = "en" request["customer_email"] = "customer@example.com" ``` -------------------------------- ### PHP function to get installment plans Source: https://paymentservices.amazon.com/docs/api/services/installments PHP function that sends a POST request to the FortAPI payment endpoint with the GET_INSTALLMENTS_PLANS command. It checks for HTTP 200 and response code 62000, printing success or error messages. Uses cURL with JSON headers and a 30-second timeout. ```php 'GET_INSTALLMENTS_PLANS', 'access_code' => 'zx0IPmPy5jp1vAz', 'merchant_identifier' => 'CycHZxVj', 'amount' => 100000, 'currency' => 'AED', 'language' => 'en', 'signature' => '7cad05f0212ed933c9a5d5dffa31661acf2c827a' ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $plansUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode === 200) { $result = json_decode($response, true); if ($result['response_code'] === '62000') { echo "Installment plans retrieved successfully\n"; return $result; } else { echo "Request failed: " . ($result['response_message'] ?? 'Unknown error') . "\n"; return $result; } } else { echo "HTTP Error: " . $httpCode . "\n"; return false; } } // Usage $plansResult = getInstallmentsPlans(); ?> ``` -------------------------------- ### Benefit Hosted Checkout Sample Response (JSON) Source: https://paymentservices.amazon.com/docs/payment-methods/local-payment-methods/benefit Example response returned to the return_url after payment processing. Contains transaction details and a signature for verification. ```json { "command": "PURCHASE", "access_code": "s4lwuuoY5upZlZY5D6dr", "merchant_identifier": "WeVJHPYm", "merchant_reference": "ORD-12345-2024", "amount": "2000", "currency": "BHD", "language": "en", "payment_option": "benefit", "customer_email": "test@amazon.com", "fort_id": "149295435400084008", "response_message": "Success", "response_code": "14000", "status": "14", "signature": "calculated_response_signature" } ``` -------------------------------- ### Python Flask route to generate and auto-submit installments form Source: https://paymentservices.amazon.com/docs/api/services/installments Flask route '/installments-checkout' that returns an HTML page containing the HTTPS POST form for the sandbox payment page. The form includes the same required parameters as the HTML example and auto-submits via JavaScript. The signature is a placeholder and must be replaced with a valid signature. ```Python # Frontend: Generate HTTPS POST form for installments from flask import Flask, render_template_string app = Flask(__name__) @app.route('/installments-checkout') def installments_checkout(): # Generate HTML form for frontend submission form_html = '''
Redirecting to Amazon Payment Services secure gateway...
''' return form_html if __name__ == '__main__': app.run(debug=True) ``` -------------------------------- ### POST /purchase (with installments) Source: https://paymentservices.amazon.com/docs/api/services/installments Process an installment payment using a tokenized card. Include the standard custom integration purchase parameters plus the installments, issuer_code, and plan_code parameters. ```APIDOC ## POST /purchase ### Description Process an installment payment using a tokenized card. Include the standard custom integration purchase parameters plus the installments, issuer_code, and plan_code parameters. ### Method POST ### Endpoint /purchase ### Parameters #### Request Body - **installments** (String, Max: 10) - Required - Specify hosted installments mode for custom integration. Value: `HOSTED`. Example: `HOSTED`. - **issuer_code** (String, Max: 8) - Required - Code identifying the card issuer selected by customer from installment plans. Example: `fHkigRtu`. - **plan_code** (String, Max: 8) - Required - Code identifying the specific installment plan selected by customer. Example: `zAS4XyG2`. ### Response #### Success Response - **installments** (String, Max: 10) - Installments service type used in the transaction. Value: `HOSTED`. Example: `HOSTED`. - **plan_code** (String, Max: 8) - Code identifying the installment plan used for the transaction. Example: `zAS4XyG2`. - **issuer_code** (String, Max: 8) - Code identifying the card issuer used for the transaction. Example: `fHkigRtu`. - **number_of_installments** (Integer, Max: 2) - Number of installments selected for the transaction. Example: `3`. ``` -------------------------------- ### PURCHASE/AUTH Sample Request (Bash cURL) Source: https://paymentservices.amazon.com/docs/api/accepting-payments/custom-integration/non-pci Bash command using cURL to send a PURCHASE payment request with a token to the sandbox payment API. ```Bash # Payment request using token # Example: Payment request using cURL curl -X POST https://sbpaymentservices.payfort.com/FortAPI/paymentApi \ -H "Content-Type: application/json" \ -d '{ "command": "PURCHASE", "access_code": "zx0IPmPy5jp1vAz", "merchant_identifier": "CycHZxVj", "merchant_reference": "XYZ9239-yu898", "amount": "10000", "currency": "USD", "language": "en", "customer_email": "customer@example.com", "token_name": "COp9Vmp", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" }' ``` -------------------------------- ### PURCHASE/AUTH Sample Request (Python) Source: https://paymentservices.amazon.com/docs/api/accepting-payments/custom-integration/non-pci Python script using requests to send a PURCHASE payment request with a token to the sandbox payment API. Prints the JSON response. ```Python # Payment request using token import requests # Payment request data payment_request = { "command": "PURCHASE", "access_code": "zx0IPmPy5jp1vAz", "merchant_identifier": "CycHZxVj", "merchant_reference": "XYZ9239-yu898", "amount": "10000", "currency": "USD", "language": "en", "customer_email": "customer@example.com", "token_name": "COp9Vmp", "signature": "7cad05f0212ed933c9a5d5dffa31661acf2c827a" } # Send payment request response = requests.post( "https://sbpaymentservices.payfort.com/FortAPI/paymentApi", json=payment_request, headers={'Content-Type': 'application/json'} ) print(response.json()) ```