### Sample Success Response for Start Compass Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4 Indicates that the compass has been successfully started. ```json { "success": true, "ret": "GP_SUCCESS", "msg": "COMPASS_STARTED" } ``` -------------------------------- ### Start Compass Source: https://docs.midtrans.com/reference/frontend-v2 Starts the compass sensor and begins receiving updates. ```APIDOC ## Start Compass ### Description Starts the compass sensor and begins receiving updates. You can listen for compass events using `document.addEventListener('GPMotion.Event.compass', ...)`. ### Method `window.gpContainer.call` ### Endpoint `GPMotion`, `startCompass` ### Parameters #### Request Body - **interval** (string) - Optional - Specifies the update interval. Accepted values: 'game' (20ms), 'ui' (60ms), 'normal' (200ms). Defaults to 'normal'. ### Request Example ```javascript var params = { interval: 'normal' }; window.gpContainer.call( "GPMotion", "startCompass", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); // Listen to Compass result document.addEventListener('GPMotion.Event.compass', (e) => { console.log('Received gpAsyncCallback event:', JSON.stringify(e)); }); ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **ret** (string) - Returns 'GP_SUCCESS' on success. - **msg** (string) - Confirmation message, e.g., 'COMPASS_STARTED'. #### Response Example ```json { "success": true, "ret": "GP_SUCCESS", "msg": "COMPASS_STARTED" } ``` #### Compass Data Event - **direction** (double) - The value due north between [0,360). - **timestamp** (int64) - The timestamp of the reading. #### Compass Data Example ```json { "direction": 180.5, "timestamp": 1678886400000 } ``` #### Error Response - **success** (boolean) - Indicates if the operation failed. - **error_code** (string) - The error code. - **error_type** (string) - The type of error, e.g., 'JS_BRIDGE_ERROR'. - **error_message** (string) - A detailed error message. - **ret** (string) - Returns 'GP_EXCEPTION' on error. #### Error Response Example ```json { "success": false, "error_code": "", "error_type": "JS_BRIDGE_ERROR", "error_message": "", "ret": "GP_EXCEPTION" } ``` ``` -------------------------------- ### Show Authorization Guide Source: https://docs.midtrans.com/reference/list-of-jssdks-webview-v4 Displays a guide to the user explaining required permissions. ```Javascript var params = { permission: 'Address book' cancelbutton: 'Cancel' }; window.gpContainer.call( "GPUIDialog", "showAuthGuide", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); ``` ```JSON { "success": true, "ret": "GP_SUCCESS" } ``` ```JSON { "success": false, "errorCode": "", "errorType": "JS_BRIDGE_ERROR", "errorMessage": "", "ret": "GP_EXCEPTION" } ``` -------------------------------- ### Get Partner Token Example Source: https://docs.midtrans.com/reference/getpartnertoken-3 This example demonstrates a successful response when generating a partner token. The token can be used for subsequent API calls until its expiry. ```json { "success": true, "data": { "token": "eyJraWQiOiJlYzdmMjY0ZS0wNDkwLTQxODgtYTRjZS0wMWZlMzQ2MWFmYzUiLCJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "expiry_seconds": "5184000", "expires_at": "1738384686" } } ``` -------------------------------- ### Request Body Example Source: https://docs.midtrans.com/reference/account-linking-unlinking-notification Example JSON payload for the account binding request body. ```text { "additionalInfo": { "accessToken":"MjAyMjEwMTM2NjE1OGRiMS00NmM1LTQxMWQtYmU4NC01ODk1ZTdhMjg2NmY6OGNmM2U4NWUtZTc3Mi00NTJmLWFkYmEtNDcyNjRiOWZiZWIw", "merchantId": "G123123", "subMerchantId": "pop-id", "paymentType": "gopay", "accountStatus":"ENABLED" "statusMessage":"Account linked" } } ``` -------------------------------- ### Example Public Key Format Source: https://docs.midtrans.com/reference/credential-exchange-copy This is an example of a correctly formatted Public Key. Copy the entire content, including the BEGIN and END lines, for registration. ```text -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAomV+Vm1xlRXanmh108Kusls7SSKec0oCejtc9QG Obpd4RnQ+7gihm2k6etnSNP7b+XrpY+fBkiQNaBInii9M10kW9Bhf/M9GH/edL3IqnzDNSi7tcoQgnO7h8x mzLNWHTjtR6bkrsdBS5dry6htotaF5KXomuoYgztCdGDOa0W20aeLzYSXIoW7s/Ay5yIXt0xaXTll3/bmez leguFPnwQZq5EqZFWlUZvutDi+f2l9rTRY0Fb64y+VAf+mnIbEovGqsPEeF/p97YWxcY7CWm8NsT0lwBVOt kmEl967Brz5yvEObF5bJgVodi6mNVsN1ki0MCitIhYO8shcE7eUilQIDAQAB -----END PUBLIC KEY----- ``` -------------------------------- ### Missing Parameters Error Example Source: https://docs.midtrans.com/reference/getpartnertoken-3 This example shows the error response when required parameters like client-id or pass-key are missing during the token generation request. ```json { "success": false, "data": null, "errors": [ { "code": 1539, "cause": "Missing client-id or pass-key parameters" } ] } ``` -------------------------------- ### Seamless Data Format Example Source: https://docs.midtrans.com/reference/get-auth-code-api This example shows how to format the 'seamlessData' parameter, which includes mobile number and payment type. The data must be URL-encoded. ```text seamlessData = URLEncode("mobileNumber=62822999999\u0026paymentType=gopay") ``` -------------------------------- ### Handle Online Installment Responses Source: https://docs.midtrans.com/reference/card-feature-installment Examples of successful transaction responses and notification payloads for installment charges. ```json { "status_code": "200", "status_message": "Success, Credit Card transaction is successful", "transaction_id": "c1e1cc28-5208-4965-bc99-076919dc0a26", "order_id": "20527106", "gross_amount": "1687180.00", "payment_type": "credit_card", "transaction_time": "2016-06-19 09:12:15", "transaction_status": "capture", "fraud_status": "accept", "approval_code": "R71372", "masked_card": "48111111-1114", "bank": "bni", "installment_term": "6", "channel_response_code": "00", "channel_response_message": "Approved", "currency": "IDR", "card_type": "credit", "on_us": true } ``` ```json { "masked_card": "48111111-1114", "approval_code": "R71372", "bank": "bni", "eci": "01", "installment_term": 6, "transaction_time": "2016-06-19 09:12:15", "gross_amount": "1687180.00", "order_id": "20527106", "payment_type": "credit_card", "signature_key": "4a4e59bdc26b3c473014f8dbc1bb9faf35c1f29c473f48666ea6faaf9d8eb80bf8e47be8d79ef4cdec820c6aecad7da198a64461cdf08937f7c56688fafb8448", "status_code": "200", "transaction_id": "c1e1cc28-5208-4965-bc99-076919dc0a26", "transaction_status": "capture", "fraud_status": "accept", "status_message": "midtrans payment notification", "channel_response_code": "00", "channel_response_message": "Approved", "card_type": "credit", "on_us": false } ``` -------------------------------- ### Initialize Mini App SDK Source: https://docs.midtrans.com/reference/frontend-apis Import and initialize the Mini App SDK. Set `useDummyService` to `false` for production environments. ```javascript import MiniAppSDK from '@gopay/miniapp-client'; const inProductionEnvironment = import.meta.env.PROD; const miniAppSdk = new MiniAppSDK({useDummyService: !inProductionEnvironment}); ``` -------------------------------- ### Implement Snap Payment Integration Source: https://docs.midtrans.com/reference/frontend-integration-overview Full example showing the inclusion of snap.js, the viewport meta tag, and the event listener to trigger the payment modal. ```html ``` -------------------------------- ### HTTP Notification with account_id Source: https://docs.midtrans.com/reference/gopay-tokenization-1 Example of the JSON payload received via HTTP notification after a successful GoPay linking transaction, containing the necessary account_id for subscription setup. ```json { "transaction_time": "2023-09-04 14:10:30", "transaction_status": "settlement", "transaction_id": "57fxxxxxx-5f96-xxx0-xxxx-xxxxxx", "status_message": "midtrans payment notification", "status_code": "200", "signature_key": "f5xxxxxxxxxx", "settlement_time": "2023-09-04 14:10:30", "payment_type": "gopay", "order_id": "testrecurring", "metadata": { "extra_info": { "user_id": "aaaa-aaaa-aaaa-aaaa-aaaaaaaaaa", "account_id": "aaaa-aaaa-4e4f-aaaa-e81fc4f640a5" } }, "merchant_id": "G01xxxxxxxx", "gross_amount": "100000.00", "fraud_status": "accept", "expiry_time": "2023-09-04 14:25:30", "currency": "IDR" } ``` -------------------------------- ### POST /charge (Offline Installment) Source: https://docs.midtrans.com/reference/card-feature-installment Initiates an offline installment charge request by configuring the credit_card object with installment terms and BIN filtering. ```APIDOC ## POST /charge ### Description Allows merchants to perform installment conversion for transactions not supported by standard MID installment. The credit_card object is extended with the bins attribute to limit card usage. ### Method POST ### Endpoint /charge ### Parameters #### Request Body - **payment_type** (string) - Required - Must be "credit_card" - **transaction_details** (object) - Required - Contains order_id and gross_amount - **credit_card** (object) - Required - Contains card details - **token_id** (string) - Required - Token ID from Get Card Token response - **installment_term** (integer) - Required - Installment tenure in months - **bins** (array) - Optional - List of allowed Bank Identification Numbers ### Request Example { "payment_type": "credit_card", "transaction_details": { "order_id": "C17550", "gross_amount": 145000 }, "credit_card": { "token_id": "< your token ID >", "installment_term": 12, "bins": ["48111111", "3111", "5"] } } ``` -------------------------------- ### Error Response Example Source: https://docs.midtrans.com/reference/transaction-history-list-api Example of an unauthorized error response from the API. ```APIDOC ### Response Example { "responseCode": "4011200", "responseMessage": "Unauthorized. Client" } ``` -------------------------------- ### Initiate Snap Payment with Callbacks Source: https://docs.midtrans.com/reference/snap-js Use this method to launch the payment interface. It supports callback functions for success, pending, error, and closure events. ```javascript snap.pay('YOUR_SNAP_TOKEN', { onSuccess: function(result){console.log('success');console.log(result);}, onPending: function(result){console.log('pending');console.log(result);}, onError: function(result){console.log('error');console.log(result);}, onClose: function(){console.log('customer closed the popup without finishing the payment');} }) ``` -------------------------------- ### Start Compass Source: https://docs.midtrans.com/reference/list-of-jssdks-webkit-v4 Starts the compass sensor with a specified update interval. ```APIDOC ## Start Compass ### Description Starts the compass sensor. The interval can be set to 'game', 'ui', or 'normal'. ### Parameters #### Request Body - **interval** (string) - Optional - Update frequency: 'game' (20ms), 'ui' (60ms), or 'normal' (200ms). ### Request Example ```javascript var params = { interval: 'normal' }; window.gpContainer.call("GPMotion", "startCompass", params, ...); ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **ret** (string) - Return status code. - **msg** (string) - Status message. #### Response Example ```json { "success": true, "ret": "GP_SUCCESS", "msg": "COMPASS_STARTED" } ``` ``` -------------------------------- ### Error Response Examples Source: https://docs.midtrans.com/reference/confirmupload-1 Examples of various error responses that can be returned by the API. ```APIDOC ## Error Response Examples ### Description This section provides examples of common error responses encountered when interacting with the API. ### Examples #### Submission ID does not exist ```json { "success": false, "errors": [ { "code": "1652", "cause": "SUBMISSION_ID_DOES_NOT_EXIST" } ] } ``` #### Submission ID does not belong to user ```json { "success": false, "errors": [ { "code": "1653", "cause": "SUBMISSION_ID_DOES_NOT_BELONG_TO_CURRENT_USER" } ] } ``` #### Documents missing ```json { "success": false, "errors": [ { "code": "1652", "cause": "DOCUMENTS_MISSING" } ] } ``` #### Duplicate partner session ID ```json { "success": false, "errors": [ { "code": "1650", "cause": "DUPLICATE_PARTNER_SESSION_ID" } ] } ``` #### Invalid request parameters ```json { "success": false, "errors": [ { "code": "1539", "cause": "PARTNER_SESSION_ID_CANNOT_BE_EMPTY" }, { "code": "1539", "cause": "INPUT_VALIDATION_FAILED" } ] } ``` #### Unauthorized - Invalid token ```json { "success": false, "data": null, "errors": [ { "code": 1539, "cause": "INVALID_TOKEN" } ] } ``` #### Forbidden ```json { "success": false, "data": null, "errors": [ { "code": 1539, "cause": "FORBIDDEN" } ] } ``` #### Internal server error ```json { "success": false, "errors": [ { "code": 900, "cause": "GENERIC_SERVICE_ERROR" } ] } ``` ``` -------------------------------- ### Sample Error Response for Launch Uri Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4 An example of an error response when launching a URI, indicating a permission denial. ```json { "success": false, "errorCode": "300", "errorType": "JS_BRIDGE_ERROR", "errorMessage": "Permission denied", "ret": "GP_EXCEPTION" } ``` -------------------------------- ### GPApplication.openSettings Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4-internal-only Opens the application settings menu. ```APIDOC ## GPApplication.openSettings ### Description Opens the application settings menu. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **ret** (string) - Return status code. #### Response Example { "success": true, "ret": "GP_SUCCESS" } ``` -------------------------------- ### Response Header Example Source: https://docs.midtrans.com/reference/account-linking-unlinking-notification Example of the standard response headers returned by the API. ```text Content-type: application/json X-TIMESTAMP: 2024-03-19T14:30:00+07:00 ``` -------------------------------- ### GPNavigator: launchUri Source: https://docs.midtrans.com/reference/frontend-v2 Launches a specific URI. ```APIDOC ## GPNavigator: launchUri ### Description Launches a specific URI. ### Request Body - **uri** (string) - The URI to launch ### Response #### Success Response (200) - **success** (boolean) - Status of the request - **ret** (string) - Return status code ``` -------------------------------- ### Sample Success Response for Launch Uri Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4 A typical success response when launching a URI. ```json { "success": true, "ret": "GP_SUCCESS" } ``` -------------------------------- ### Check Multiple Apps Installation Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4-internal-only Checks the installation status for multiple applications simultaneously. ```Javascript var params = { gopay: { ios: 'gopay://', android: 'com.gopay.gopay' }, gojek: { ios: 'gojek://', android: 'com.gojek.gojek' } }; window.gpContainer.call( "GPBase", "isAppsInstalled", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); ``` ```JSON { "success": true, "ret": "GP_SUCCESS" } ``` ```JSON { "success": false, "errorCode": "", "errorType": "JS_BRIDGE_ERROR", "errorMessage": "", "ret": "GP_EXCEPTION" } ``` -------------------------------- ### Start Accelerometer Source: https://docs.midtrans.com/reference/list-of-jssdks-webkit-v4 Initialize the accelerometer sensor with a specified interval and listen for events. ```Javascript var params = { /** interval is either "game", "ui", or "normal". "normal" is default "game" : 20ms "ui": 60ms "normal": 200ms */ interval: 'normal' }; window.gpContainer.call( "GPMotion", "startAccelerometer", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); // Listen to Compass result document.addEventListener('GPMotion.Event.accelerometer', (e: GPMotionAccelerometerData) => { console.log('Received gpAsyncCallback event:', JSON.stringify(e)); }); ``` -------------------------------- ### Start Accelerometer Monitoring Source: https://docs.midtrans.com/reference/list-of-jssdks-webview-v4 Starts monitoring accelerometer data with a specified interval. Includes success and error callbacks. An event listener for 'GPMotion.Event.accelerometer' is also set up. ```javascript var params = { interval: 'normal' }; window.gpContainer.call( "GPMotion", "startAccelerometer", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); document.addEventListener('GPMotion.Event.accelerometer', function (e) { alert('event accelerometer: ' + JSON.stringify(e.param)); }); ``` -------------------------------- ### API Response Examples Source: https://docs.midtrans.com/reference/seamless-login-v2 Examples of successful and error response structures returned by the API. ```Javascript { "success": true, "data": { "auth_token": "MjAyNDA5MTdhYjQ1Nzk1NC1lMWQ4LTQ0YzUtYjgzMy1iOGZkYjE1YjU1OTk6NDJmZjAwN2UtZDU1YS00YzQwLTkyMTktZmUwNThhMjUzYjgx", "gopay_account_id": "01-0a0de883e1d846568db4c48ff12c5486-26" } } ``` ```Javascript { "success": false, "error": { "description": "AuthCode Not Found" } } ``` -------------------------------- ### showAuthGuide Source: https://docs.midtrans.com/reference/list-of-jssdks-webview-v4 Displays a guide to help users grant necessary permissions, such as access to their address book. ```APIDOC ## showAuthGuide ### Description Displays a guide or a dialog to assist users in granting specific permissions required by the application, such as access to their address book. It allows customization of the cancel button text. ### Method `window.gpContainer.call` ### Endpoint `GPUIDialog`, `showAuthGuide` ### Parameters #### Request Body - **permission** (string) - Required - The type of permission being requested (e.g., 'Address book'). - **cancelbutton** (string) - Optional - The text for the cancel button in the dialog (defaults to 'Cancel'). ### Request Example ```javascript var params = { permission: 'Address book', cancelbutton: 'Cancel' }; window.gpContainer.call( "GPUIDialog", "showAuthGuide", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **ret** (string) - A return code, typically 'GP_SUCCESS' on success. #### Response Example ```json { "success": true, "ret": "GP_SUCCESS" } ``` #### Error Response - **success** (boolean) - Indicates if the operation failed. - **errorCode** (string) - The error code. - **errorType** (string) - The type of error, e.g., 'JS_BRIDGE_ERROR'. - **errorMessage** (string) - A message describing the error. - **ret** (string) - A return code, typically 'GP_EXCEPTION' on error. #### Error Response Example ```json { "success": false, "errorCode": "", "errorType": "JS_BRIDGE_ERROR", "errorMessage": "", "ret": "GP_EXCEPTION" } ``` ``` -------------------------------- ### Open Settings Source: https://docs.midtrans.com/reference/list-of-jssdks-webview-v4 Call this method to open the application settings. It accepts callbacks for success and error responses. ```javascript window.gpContainer.call("GPApplication", "openSettings", {}, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); }); ``` -------------------------------- ### Request Header Example Source: https://docs.midtrans.com/reference/account-linking-unlinking-notification Example of the required HTTP headers for a Midtrans API request. ```text Content-type:application/json X-TIMESTAMP:2024-03-19T14:30:00+07:00 X-SIGNATURE: da1fa417c72d6b91c257e01e54fac824 X-PARTNER-ID: BMRI X-EXTERNAL-ID:12345678901234567890 ``` -------------------------------- ### GPNavigator.launchUri Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4-internal-only Navigates to a specified URI within the container environment. ```APIDOC ## GPNavigator.launchUri ### Description Opens a specified URI using the container's navigator. ### Parameters #### Request Body - **uri** (string) - Required - The target URI to launch. ### Request Example { "uri": "string" } ### Response #### Success Response (200) - **success** (boolean) - Indicates if the navigation was successful. - **ret** (string) - Return code. #### Response Example { "success": true, "ret": "GP_SUCCESS" } ``` -------------------------------- ### Display authorization guide Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4-internal-only Shows a guide dialog to the user regarding specific permissions. ```Javascript var params = { permission: 'Address book' cancelbutton: 'Cancel' }; window.gpContainer.call( "GPUIDialog", "showAuthGuide", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); ``` -------------------------------- ### Launch Payment Source: https://docs.midtrans.com/reference/coreflow-v2 Use this SDK to automatically redirect users to the GoPay app to complete the payment, then return them to your Mini App. This is the Frontend Payment Response. ```APIDOC ## POST /v1/payments/launch ### Description Use this SDK to automatically redirect users to the GoPay app to complete the payment, then return them to your Mini App. This is the FE Payment Response. ### Method POST ### Endpoint /v1/payments/launch ### Parameters #### Request Body - **deeplinkUrl** (string) - Required - The deeplink URL obtained from the 'Initiate Host to Host Payment' endpoint. ### Request Example ```json { "deeplinkUrl": "gopay://app/payment?url=https://api.midtrans.com/v1/payment-links/your_payment_link_id" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the payment launch (e.g., 'success'). #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Authorization Response Examples Source: https://docs.midtrans.com/reference/user-authentication Example JSON responses for successful and failed authorization code requests. ```json { "success": true, "data": { authCode: "GBNURP5WyBIqXiGxKv2cO8Qj4CyS0qZrRK5O4e8ehdnHpowG6k5pkj2SsF7BqGIF" }, "ret": "GP_SUCCESS" } ``` ```json { "success": false, "error_code": "", "error_type": "JS_BRIDGE_ERROR", "error_message": "", "ret": "GP_EXCEPTION" } ``` -------------------------------- ### Start Compass with Javascript Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4 Initiates the compass sensor. You can specify an interval for updates ('game', 'ui', or 'normal'). Listen for 'GPMotion.Event.compass' events to receive data. ```javascript var params = { /** interval is either "game", "ui", or "normal". "normal" is default "game" : 20ms "ui": 60ms "normal": 200ms */ interval: 'normal' }; window.gpContainer.call( "GPMotion", "startCompass", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); // Listen to Compass result document.addEventListener('GPMotion.Event.compass', function (e) { alert('event compass: ' + JSON.stringify(e.param)); }); ``` -------------------------------- ### Payouts API Header Example Source: https://docs.midtrans.com/reference/signature-generation-payouts Example of the required HTTP headers for a Payouts API request. ```http Content-type:application/json X-TIMESTAMP:2020-01-01T00:00:00+07:00 X-SIGNATURE: da1fa417c72d6b91c257e01e54fac824 Authorization: Bearer gp9HjjEj813Y9JGoqwOeOPWbnt4CupvIJbU1Mmu4a11MNDZ7Sg5u9a X-PARTNER-ID: BMRI X-EXTERNAL-ID:12345678901234567890 CHANNEL-ID:12345 ``` -------------------------------- ### Open application settings Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4-internal-only Opens the application's settings screen. This method takes no parameters and provides success and error callbacks. ```javascript window.gpContainer.call( "GPApplication", "openSettings", {}, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); ``` -------------------------------- ### API Request Header Example Source: https://docs.midtrans.com/reference/get-transaction-status-api Example of the required HTTP headers for a Midtrans API request. ```text X-TIMESTAMP 2022-03-04T08:02:09+07:00 X-SIGNATURE yqmBXZ3yV6NPG1LtwXMm3quXzJMRX5Ms+r9ebc5xWIZGSKbZL3Oy871GHb7WQUucLa5nxN/HcnZYoNHc+KkWTQ== X-PARTNER-ID 668052e34f194aa8be79e15a21e4fc2f X-EXTERNAL-ID 91919644194391346361915387229113 CHANNEL-ID 12345 Authorization Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxMmUzODE4Mi00YjIxLTQ0YWMtOTVkNi1mMjFhMjEwZmIxZTAiLCJjbGllbnRJZCI6IjY2ODA1MmUzNGYxOTRhYThiZTc5ZTE1YTIxZTRmYzJmIiwibmJmIjoxNjYzODQwNTU5LCJleHAiOjE2NjM4NDE0NTksImlhdCI6MTY2Mzg0MDU1OX0.fEr0vIbB2kY8alZ-SROl3ftAFbfRd0uU-lGq9XuFi8M Content-Type application/json ``` -------------------------------- ### Example Request Headers Source: https://docs.midtrans.com/reference/payment-notification-api A sample set of mandatory headers formatted for an HTTP request. ```http Content-type:application/json X-TIMESTAMP:2020-01-01T00:00:00+07:00 X-SIGNATURE: da1fa417c72d6b91c257e01e54fac824 X-PARTNER-ID: X-EXTERNAL-ID:12345678901234567890 ``` -------------------------------- ### Start Compass Source: https://docs.midtrans.com/reference/list-of-jssdks-webview-v4 Starts the compass sensor with a specified update interval and listens for result events. ```Javascript var params = { /** interval is either "game", "ui", or "normal". "normal" is default "game" : 20ms "ui": 60ms "normal": 200ms */ interval: 'normal' }; window.gpContainer.call( "GPMotion", "startCompass", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); // Listen to Compass result document.addEventListener('GPMotion.Event.compass', (e: GPMotionCompassData) => { console.log('Received gpAsyncCallback event:', JSON.stringify(e)); }); ``` ```JSON { "success": true, "ret": "GP_SUCCESS", "msg": "COMPASS_STARTED" } ``` ```JSON { direction: double, // The value due north between [0,360) timestamp: int64 } ``` ```JSON { "success": false, "errorCode": "", "errorType": "JS_BRIDGE_ERROR", "errorMessage": "", "ret": "GP_EXCEPTION" } ``` -------------------------------- ### Check App Installation Source: https://docs.midtrans.com/reference/list-of-jssdks-gopay-container-v4-internal-only Verifies if a specific application is installed on the device by providing iOS and Android identifiers. ```Javascript var params = { // The app label that is used in iOS. ios: 'gopay://', // The app label that is used in Android. android: 'com.gopay.gopay' }; window.gpContainer.call( "GPBase", "isInstall", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); ``` ```JSON { "success": true, "ret": "GP_SUCCESS" } ``` ```JSON { "success": false, "errorCode": "", "errorType": "JS_BRIDGE_ERROR", "errorMessage": "", "ret": "GP_EXCEPTION" } ``` -------------------------------- ### GPNavigator.launchDeeplink Source: https://docs.midtrans.com/reference/list-of-jssdks-webview-v4 Launches a specific deeplink within the GoPay environment. ```APIDOC ## GPNavigator.launchDeeplink ### Description Triggers a navigation action based on a provided deeplink URL. ### Parameters #### Request Body - **deeplink** (string) - Required - The deeplink URL to launch. ### Request Example ```javascript var params = { deeplink: "gopay://..." }; window.gpContainer.call( "GPNavigator", "launchDeeplink", params, function(response) { console.log('success:', response); }, function(error) { console.log('error:', error); } ); ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the call was successful. - **ret** (string) - Return status code. #### Response Example ```json { "success": true, "ret": "GP_SUCCESS" } ``` ``` -------------------------------- ### Offline Installment Response and Notifications Source: https://docs.midtrans.com/reference/card-feature-installment Details the structure of successful transaction responses and notification payloads for offline installments. ```APIDOC ## Offline Installment Response ### Description Successful installment transactions return a status of 'capture'. ### Response #### Success Response (200) - **transaction_status** (string) - Status of the transaction (e.g., "capture") - **bank** (string) - The name of the Acquiring Bank - **installment_term** (string) - The installment tenure applied #### Response Example { "status_code": "200", "status_message": "Success, Credit Card transaction is successful", "transaction_id": "b046340b-dc40-480a-828f-085fc265850c", "transaction_status": "capture", "bank": "bni", "installment_term": "6" } ``` -------------------------------- ### POST /charge (Online Installment) Source: https://docs.midtrans.com/reference/card-feature-installment Initiates an online installment payment transaction using a credit card token. ```APIDOC ## POST /charge ### Description Initiates an online installment payment transaction. Note that this feature is not supported for debit cards. ### Method POST ### Request Body - **payment_type** (string) - Required - Must be "credit_card" - **transaction_details** (object) - Required - Contains order_id and gross_amount - **credit_card** (object) - Required - Contains token_id, bank, and installment_term ### Parameters #### Request Body - **token_id** (string) - Required - Token ID representing customer's card information. - **bank** (string) - Required - The name of the Acquiring Bank. - **installment_term** (integer) - Required - Installment tenure in months. ### Request Example { "payment_type": "credit_card", "transaction_details": { "order_id": "C17550", "gross_amount": 145000 }, "credit_card": { "token_id": "< your token ID >", "bank": "bni", "installment_term": 12 } } ### Response #### Success Response (200) - **transaction_status** (string) - Returns "capture" upon success. - **status_code** (string) - Status code of the transaction. #### Response Example { "status_code": "200", "status_message": "Success, Credit Card transaction is successful", "transaction_id": "c1e1cc28-5208-4965-bc99-076919dc0a26", "transaction_status": "capture", "bank": "bni", "installment_term": "6" } ``` -------------------------------- ### Additional Implementation Notes Source: https://docs.midtrans.com/reference/snap-js Important notes regarding Snap's behavior in different modes, handling multiple instances, and UI customization. ```APIDOC ## Additional Implementation Notes ### Embedded Mode Behavior Unlike in Pop Up mode, the 'X' button in the modal is intentionally removed in Embedded mode to prevent users from accidentally exiting after making a payment. Merchants can still close the Snap window using the `hide()` method. ### Multiple Snap Instances It is not possible to have two different types of Snap instances open simultaneously. If a Snap Popup is currently active, Snap Embed cannot be displayed. To switch between modes, hide the active instance using the `hide()` method. ### Hiding Header Section The header section in the Snap modal, which displays the merchant/display name, can be hidden. Navigate to Dashboard > Snap Preference > Theme and Logo > then untick `Use Header`. ### Callback Implementation If the `snap.js` callback is not implemented, SNAP will redirect the user to the finish URL configured in the Midtrans Dashboard. ``` -------------------------------- ### GPApplication Methods Source: https://docs.midtrans.com/reference/list-of-jssdks-webview-v4 Methods for managing application state and settings. ```APIDOC ## GPApplication.appState ### Description Returns the status of the application, indicating whether it is running in the foreground. ## GPApplication.getNotificationSettings ### Description Returns the notification settings of the application. ## GPApplication.openSettings ### Description Displays the settings page of the application. ``` -------------------------------- ### B2B Access Token Header Example Source: https://docs.midtrans.com/reference/signature-generation-payouts Example of the required HTTP headers for a B2B Access Token request. ```http Content-type: application/json X-TIMESTAMP: 2023-01-01T00:00:00+07:00 X-SIGNATURE: da1fa417c72d6b91c257e01e54fac824 X-CLIENT-KEY: 962489e9-de5d-4eb7-92a4-b07d44d64bf4 ``` -------------------------------- ### Response Body Example Source: https://docs.midtrans.com/reference/cancel-api Example of the JSON structure returned in the response body upon a successful cancellation request. ```json { "responseCode":"20057000", "responseMessage":"Request has been processed successfully", "originalReferenceNo": "2020102977770000000009", "cancelTime":"2024-09-03T03:52:14Z" } ```