### Initiate Payout Source: https://gomobi.io/documents/payout/indonesia This API allows you to initiate a fund disbursement (payout) from your merchant wallet to a recipient's bank account in Indonesia. Both the request and response payloads are encrypted. ```APIDOC ## POST /payout ### Description Initiates a fund disbursement (payout) from a merchant wallet to a recipient's bank account in Indonesia. The request and response payloads are encrypted. ### Method POST ### Endpoint /payout ### Parameters #### Query Parameters - **country_code** (string) - Required - The country code for the payout destination (e.g., "ID" for Indonesia). #### Request Body - **recipient_account_number** (string) - Required - The bank account number of the recipient. - **amount** (number) - Required - The amount to be disbursed. - **currency** (string) - Required - The currency of the payout (e.g., "IDR"). - **reference_id** (string) - Optional - A unique reference ID for the transaction. - **encrypted_payload** (string) - Required - The encrypted request payload. ### Request Example ```json { "recipient_account_number": "1234567890", "amount": 100000, "currency": "IDR", "reference_id": "REF12345", "encrypted_payload": "encrypted_data_string" } ``` ### Response #### Success Response (200) - **status** (string) - The status of the payout request (e.g., "PENDING", "SUCCESS", "FAILED"). - **transaction_id** (string) - The unique identifier for the payout transaction. - **encrypted_response** (string) - The encrypted response payload. #### Response Example ```json { "status": "PENDING", "transaction_id": "TXN987654321", "encrypted_response": "encrypted_response_data_string" } ``` ``` -------------------------------- ### Encrypt Merchant API Key using 3DES in Java Source: https://gomobi.io/documents/authentication/3des Encrypts a merchant API key using the 3DES algorithm in ECB mode with PKCS5Padding. This method requires the merchant API key and a secret key provided by Mobi. It returns the Base64 encoded encrypted string or null if an error occurs. ```java public String encryptMerchantApikey(String merchantApikey, String mobiKey) { try { DESedeKeySpec dks = new DESedeKeySpec( Objects.requireNonNull(mobiKey).getBytes(StandardCharsets.UTF_8) ); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede"); SecretKey secureKey = keyFactory.generateSecret(dks); Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, secureKey); byte[] b = cipher.doFinal(merchantApikey.getBytes()); String encryptedValue = Base64.getEncoder().encodeToString(b); return encryptedValue.trim(); } catch (Exception e) { log.error("Exception occurred while encrypting merchantApiKey: " + e.getMessage()); return null; } } ``` -------------------------------- ### Encrypt Payload using AES-CBC in Java Source: https://gomobi.io/documents/authentication/aes-cbc This Java method encrypts a given input string using AES-CBC with PKCS5Padding. It requires a secret key, business name, and merchant ID to generate the encryption key and IV. The output is a Base64 encoded string, with a special hex format for card payments. ```java public static String encryptPayload(String input, String mobiKey, String businessName, String merchantId) { try { SecureRandom secureRandom = new SecureRandom(); byte[] iv = new byte[16]; secureRandom.nextBytes(iv); IvParameterSpec ivSpec = new IvParameterSpec(iv); String salt = businessName + merchantId; SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); KeySpec spec = new PBEKeySpec(mobiKey.toCharArray(), salt.getBytes(), 65536, 256); SecretKeySpec secretKeySpec = new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivSpec); byte[] cipherText = cipher.doFinal(input.getBytes(StandardCharsets.UTF_8)); byte[] encryptedData = new byte[iv.length + cipherText.length]; System.arraycopy(iv, 0, encryptedData, 0, iv.length); System.arraycopy(cipherText, 0, encryptedData, iv.length, cipherText.length); String base64Result = Base64.getEncoder().encodeToString(encryptedData); if (input.contains("#")) { // Card payments return bytesToHex(Base64.getDecoder().decode(base64Result)); } return base64Result; } catch (Exception e) { System.err.println("Encryption error: " + e.getMessage()); return null; } } // Helper for Card payments private static String bytesToHex(byte[] bytes) { StringBuilder hex = new StringBuilder(); for (byte b : bytes) { hex.append(String.format("%02X", b)); } return hex.toString(); } ``` -------------------------------- ### Decrypt Payload using Java Source: https://gomobi.io/documents/authentication/3des This Java method decrypts a Base64 encoded payload using AES/CBC/PKCS5Padding. It takes the encrypted signature, a Mobi secret key, and a salt as input. The method first decodes the signature, separates the IV and ciphertext, derives the secret key using PBKDF2WithHmacSHA256, and then decrypts the ciphertext. It returns the decrypted UTF-8 string or null if an error occurs. ```java public String decryptPayload(String signature, String mobiKey, String salt) { try { byte[] encryptedData = Base64.getDecoder().decode(signature); byte[] iv = new byte[16]; System.arraycopy(encryptedData, 0, iv, 0, iv.length); IvParameterSpec ivspec = new IvParameterSpec(iv); SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); KeySpec spec = new PBEKeySpec(mobiKey.toCharArray(), salt.getBytes(), ITERATION_COUNT, KEY_LENGTH); SecretKey tmp = factory.generateSecret(spec); SecretKeySpec secretKeySpec = new SecretKeySpec(tmp.getEncoded(), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivspec); byte[] cipherText = new byte[encryptedData.length - 16]; System.arraycopy(encryptedData, 16, cipherText, 0, cipherText.length); byte[] decryptedText = cipher.doFinal(cipherText); return new String(decryptedText, StandardCharsets.UTF_8); } catch (Exception e) { log.error("Exception occurred while decrypting: " + e.getMessage()); return null; } } ``` -------------------------------- ### Decrypt Mobi IO Payload in Java Source: https://gomobi.io/documents/authentication/aes-cbc Decrypts an encrypted payload received from Mobi IO. It handles both Base64 and Hex encoded inputs, extracts the Initialization Vector (IV) and ciphertext, derives the secret key using PBKDF2WithHmacSHA256 with a salt derived from business name and merchant ID, and performs AES/CBC/PKCS5Padding decryption. Requires the Mobi key, business name, and merchant ID as input. ```java public static String decryptPayload(String payload, String mobiKey, String businessName, String merchantId) { try { byte[] encryptedData = payload.contains("#") ? hexToBytes(payload) : Base64.getDecoder().decode(payload); byte[] iv = new byte[16]; byte[] cipherText = new byte[encryptedData.length - 16]; System.arraycopy(encryptedData, 0, iv, 0, iv.length); System.arraycopy(encryptedData, 16, cipherText, 0, cipherText.length); IvParameterSpec ivSpec = new IvParameterSpec(iv); String salt = businessName + merchantId; SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); KeySpec spec = new PBEKeySpec(mobiKey.toCharArray(), salt.getBytes(), 65536, 256); SecretKeySpec secretKeySpec = new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivSpec); byte[] decryptedText = cipher.doFinal(cipherText); return new String(decryptedText, StandardCharsets.UTF_8); } catch (Exception e) { System.err.println("Decryption error: " + e.getMessage()); return null; } } // Helper for Card payments private static byte[] hexToBytes(String hex) { byte[] bytes = new byte[hex.length() / 2]; for (int i = 0; i < hex.length(); i += 2) { bytes[i / 2] = (byte) Integer.parseInt(hex.substring(i, i + 2), 16); } return bytes; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.