### Install GrabFood SDK for Go Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Instructions to install the GrabFood API SDK for Go using `go get` and how to import the package into your project. ```Go go get github.com/grab/grabfood-api-sdk-go ``` ```Go import grabfood "github.com/grab/grabfood-api-sdk-go" ``` -------------------------------- ### Install GrabFood API SDK for Python using pip Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 This snippet demonstrates how to install the GrabFood API SDK for Python using pip directly from the GitHub repository. It's the recommended method for quick setup. ```Python pip install git+https://github.com/grab/grabfood-api-sdk-python.git ``` -------------------------------- ### CLI Request Example: Get Merchant Menu Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 A `curl` command example to retrieve the merchant menu using a GET request. This example demonstrates how to include `merchantID`, `partnerMerchantID`, and an `Authorization` bearer token in the request headers. ```Shell curl -X GET \n'https://{{api-endpoint}}//merchant/menu?merchantID=1-C3VEJY6CMEEGUE&partnerMerchantID=Partner-ABECU' \n-H 'Authorization: Bearer ' ``` -------------------------------- ### Sample GET User Info API Request Source: https://developer.grab.com/docs/grab-express/grab-id An example cURL command to make a GET request to the userinfo endpoint, demonstrating the use of Authorization and Content-Type headers for authentication and data format. ```curl curl -X GET 'https://.../grabid/v1/oauth2/userinfo' \ -H 'Authorization: Bearer xxx' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Presenting a Deeplink-Handling ViewController in iOS Source: https://developer.grab.com/docs/grab-express/payment-otc/api/v2 This Swift example shows how to create a `UIViewController` (`AnotherViewController`) with a button that, when tapped, instantiates and pushes `YourViewController` onto the navigation stack. `YourViewController` is intended to be the destination for handling deeplinks. The example includes basic UI setup for the button and its action. ```Swift class AnotherViewController: UIViewController { private lazy var yourButton = UIButton = { let button: UIButton = UIButton() button.translatesAutoresizingMaskIntoConstraints = false button.backgroundColor = .blue button.setTitle("Your Button", for: .normal) button.addTarget(self, action:#selector(buttonClicked), for: .touchUpInside) return button }() override func viewDidLoad() { super.viewDidLoad() view.addSubview(yourButton) //Add constraints for button NSLayoutConstraint.activate([ yourButton.leadingAnchor.constraint(equalTo: view.leadingAnchor), yourButton.trailingAnchor.constraint(equalTo: view.trailingAnchor), yourButton.heightAnchor.constraint(equalToConstant: 30), yourButton.widthAnchor.constraint(equalToConstant: 30) ]) } @objc func buttonClicked() { openDeeplink() } // You can call this function on button tap/action func openDeeplink() { let viewController = YourViewController() viewController.view.backgroundColor = .white navigationController?.pushViewController(viewController, animated: true) } } ``` -------------------------------- ### Install GrabFood API SDK for Python using Setuptools Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 This snippet provides instructions for installing the GrabFood API SDK for Python using Setuptools. This method is an alternative to pip for local installation. ```Python python setup.py install --user ``` -------------------------------- ### Install GrabFood SDK for Java Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Instructions to install the GrabFood API SDK for Java using Maven or Gradle, including commands for local installation and dependency configurations for project build files. ```Maven mvn clean install ``` ```Maven com.grab grabfood-api-sdk-java 1.0.2 compile ``` ```Gradle repositories { mavenCentral() // Needed if the 'grabfood-api-sdk-java' jar has been published to maven central. mavenLocal() // Needed if the 'grabfood-api-sdk-java' jar has been published to the local maven repo. } dependencies { implementation "com.grab:grabfood-api-sdk-java:1.0.2" } ``` -------------------------------- ### Promo List API Successful Response Example Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/get-promo Sample JSON response demonstrating the structure of a successful API call to retrieve promo lists. It includes an array of promo objects, each detailing token, name, description, image links, currency, and availability status for a given promotion. ```json { "promoList": [ { "token": "2:655066", "name": "$10 off on purchase", "description": "$10 off on purchase", "summary": "", "icon": "https://d166bljuvofq9e.cloudfront.net/media/f8/f83a5ce7-47d5-4931-bd37-92caa732ca9f.png", "headerImage": "https://d166bljuvofq9e.cloudfront.net/media/26/2670d14e-9383-4826-b5a5-7536c95c3347.png", "currency": "SGD", "isAvailable": true } ] } ``` -------------------------------- ### Grab OAuth2 Authorization Endpoint: Sample GET Request Source: https://developer.grab.com/docs/grab-express/grab-id This GET request demonstrates how to initiate the authorization flow by requesting an authorization code. It includes parameters like client ID, scope, response type, redirect URI, state, nonce, and PKCE challenge. ```http GET https://.../grabid/v1/oauth2/authorize?client_id=0208d86bfe374b8eb6f2c47915b27b29&scope=openid%20booking%20payment&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A23456%2Foauth2callback&state=2345678&nonce=12345678&code_challenge_method=S256&code_challenge=345667&acr_values=deviceid%3AeOERVv1CUC%20service%3APASSENGER%20consent_ctx%3Acountry%3Dsg ``` -------------------------------- ### Receipt Configuration JSON Example Source: https://developer.grab.com/docs/grab-express/grab-kios-digital-products-api An example JSON structure showing how receipt header and footer information might be configured or returned in a system. ```JSON "receipt_footer": [ { "title": "Receipt Footer", "value": "MENYATAKAN STRUK INI SEBAGAI BUKTI PEMBAYARAN YANG SAH" } ], "receipt_header": [ { "title": "Receipt Header", "value": "STRUK PEMBAYARAN" } ] } ``` -------------------------------- ### iOS WKWebView: Programmatic Setup and Content Loading Source: https://developer.grab.com/docs/grab-express/payment-otc/api/v2 This Swift example shows how to programmatically embed a `WKWebView` into an iOS `UIViewController`. It configures the web view, sets the `uiDelegate` and `navigationDelegate` to the current view controller, and loads content from a specified URL using `URLRequest`. ```Swift class YourViewController: UIViewController, WKUIDelegate, WKNavigationDelegate { var webView: WKWebView! override func loadView() { let webConfiguration = WKWebViewConfiguration() webView = WKWebView(frame: .zero, configuration: webConfiguration) // Set current View Controller to be the UI delegate webView.uiDelegate = self webView.navigationDelegate = self // Setting the current view as webView view = webView } override func viewDidLoad() { super.viewDidLoad() // Check url is not nil if let myURL = URL(string:"grab://screenType=SOMETHING") { // Make a request object let myRequest = URLRequest(url: myURL) // Load the content of the URL webView.load(myRequest) } } } ``` -------------------------------- ### Install GrabFood Node.js SDK Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Command to install the GrabFood API SDK for Node.js directly from its GitHub repository using npm, enabling its use in Node.js projects. ```Shell npm install https://github.com/grab/grabfood-api-sdk-node ``` -------------------------------- ### GrabFood API: Mark Orders Ready Request Payload Example Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 An example JSON payload for marking an order as ready, demonstrating the `orderID` and `markStatus` fields. ```JSON { "orderID": "123-CYNKLPCVRN5", "markStatus": 1 } ``` -------------------------------- ### Fixed Authorisation Header Descriptions and Examples Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Incorrect descriptions and examples for the 'Authorisation' header parameter have been corrected, ensuring accurate guidance for API authentication. ```APIDOC API Header Parameters: - Authorisation: Corrected descriptions and examples. ``` -------------------------------- ### Example GrabID OAuth2 Authorization URL Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/auth-web-url This is an example of a complete GrabID OAuth2 authorization URL, demonstrating the structure with various parameters like 'client_id', 'scope', 'code_challenge', 'nonce', 'state', and 'redirect_uri'. ```url https://partner-api.grab.com/grabid/v1/oauth2/authorize?acr_values=consent_ctx%3AcountryCode%3DSG,currency%3DSGD&client_id={{CLIENT_ID}}&code_challenge=PP2Ut_vyvfkytkYEhobjNvYG7dNxil3vQNROIsm_JMU&code_challenge_method=S256&nonce=zYPZ8hIVW7CEfgCY&redirect_uri=https://www.developer.grab.com&request=eyJhbGciOiAibm9uZSJ9.eyJjbGFpbXMiOnsidHJhbnNhY3Rpb24iOnsidHhJRCI6IjNlZmQ1MGI5NmFjMTQ1NzViNzczNjU1YTEyMDRhNDNjIn19fQ.&response_type=code&scope=payment.recurring_charge&state=fdgidgI ``` -------------------------------- ### Sample API Request to Get ID Token Information (curl) Source: https://developer.grab.com/docs/grab-express/grab-id Provides a `curl` command example for making a GET request to the `/grabid/v1/oauth2/id-tokens/token-info` endpoint. It demonstrates how to include the `Content-Type` header and the JSON body containing `id_token`, `nonce`, and `client_id`. ```curl curl -X GET https://.../grabid/v1/oauth2/id-tokens/token-info \ -H 'Content-Type: application/json' \ -d '{ "id_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY3IiOiJbXCJzZXJ2c2U6UEF ........ DTbgfDpShdw_yeMH4c44nmCQ8OF29I0xqZiaB53SJnIax_7nilKMybWp3KzbXu3iMqjCQ2Lb_9T5mA", "nonce": "JhbGciOiJSUzI1NiIsInR5c", "client_id": "0d7cf002cb8242519b68b82f366d9dbe" }' ``` -------------------------------- ### Get Gift Links API Request Example with cURL Source: https://developer.grab.com/docs/grab-express/grab-gifts/gl-get-gift-links Example cURL command to query for a specific gift's details using the Get Gift Links API. It requires an 'orderID' in the URL path and an 'Authorization' header with a bearer token. ```curl curl --location --request GET 'https://partner-gateway.stg-myteksi.com/gifts/partner/orders/<>/gifts' \ --header 'Authorization: ' ``` -------------------------------- ### Android Kotlin Sample WebView Host Activity Implementation Source: https://developer.grab.com/docs/grab-express/payment-otc/api/v2 Implements `SampleWebViewHostActivity` in Kotlin, demonstrating how to initialize a WebView, enable JavaScript, and set up a `WebViewClient` to intercept URL loading. It includes logic to handle 'grab' or 'grabtaxi' scheme deep links and provides a fallback for when the target app is not installed. ```Kotlin class SampleWebViewHostActivity : AppCompatActivity() { override fun onCreate( savedInstanceState: Bundle?, persistentState: PersistableBundle? ) { super.onCreate(savedInstanceState, persistentState) setContentView(R.layout.activity_web) val webView : WebView = findViewById(R.id.web_view) webView.settings.javaScriptEnabled = true webView.webViewClient = object : WebViewClient() { override fun shouldOverrideUrlLoading( view: WebView?, url: String ): Boolean { val scheme = url.toUri().scheme /// if it’s grab, handle deep link if (scheme == "grab" || scheme == "grabtaxi") { handleDeepLink(url) // check step 03 return true } /// For others, do not override. /// Let it follow default behaviour. return false } } val url = intent.extras?.getString("extras_web_url") if(url.isNullOrBlank()) { Toast.makeText(this, "Url is empty", Toast.LENGTH_LONG).show() } else { webView.loadUrl(url) } } fun handleDeepLink(deeplink: String) { val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) if (intent.resolveActivity(packageManager) != null) { startActivity(intent) } else { handleAppNotInstalled() } } fun handleAppNotInstalled() { /// For example we are launching play store /// It’s up to the client, if you want to show a pop up /// or gracefully handle this situation try { /// try grab play store url val playStoreUrl = """https://play.google.com/store/apps/details ?id=com.grabtaxi.passenger""" startActivity( Intent(Intent.ACTION_VIEW, Uri.parse(playStoreUrl.toUri())) ) } catch (err: Throwable) { err.printStackTrace() } } } ``` -------------------------------- ### Example Curl Request for Get Transactions API Source: https://developer.grab.com/docs/grab-express/gfb/get-transactions This curl command demonstrates how to make a GET request to the Get Transactions API. It includes necessary headers for content type, company ID, and OAuth2 authorization, along with a JSON body specifying the query parameters. ```curl curl --location --request GET 'https://[HOST]/gfb/partner/v1/transactions' \ --header 'Content-Type: application/json' \ --header 'X-GFB-Company-ID: ' \ --header 'Authorization: ' \ --data '{ "vertical": "TRANSPORT", "fromDate": "2025-04-10", "toDate": "2025-04-18", "page": 1 }' ``` -------------------------------- ### Sample Response: OpenID Configuration JSON Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/service-discovery An example JSON response from the GrabID Service Discovery Endpoint, containing various OpenID Connect and OAuth2 endpoints, supported response types, claims, scopes, and authentication methods. ```json { "issuer": "https://idp.grab.com", "authorization_endpoint": "https://partner-api.grab.com/grabid/v1/oauth2/authorize", "token_endpoint": "https://partner-api.grab.com/grabid/v1/oauth2/token", "userinfo_endpoint": "https://partner-api.grab.com/grabid/v1/oauth2/userinfo", "revocation_endpoint": "https://partner-api.grab.com/grabid/v1/oauth2/revoke", "jwks_uri": "https://partner-api.grab.com/grabid/v1/oauth2/public_keys", "response_types_supported": [ "code", "token", "id_token", "id_token token" ], "code_challenge_methods_supported": [ "S256" ], "claims_supported": [ "aud", "sub", "exp", "iat", "iss", "nbf", "name", "email" ], "scopes_supported": [ "openid", "profile.read" ], "id_token_signing_alg_values_supported": [ "RS256" ], "userinfo_signing_alg_values_supported": [ "none" ], "request_object_signing_alg_values_supported": [ "none" ], "token_endpoint_auth_methods_supported": [ "client_secret_post" ], "registration_endpoint": "", "grant_types_supported": [ "authorization_code", "refresh_token", "client_credentials" ], "acr_values_supported": [ "service", "consent_ctx" ], "request_parameter_supported": true, "id_token_verification_endpoint": "https://partner-api.grab.com/grabid/v1/oauth2/id_tokens/token_info", "impl_pattern_endpoint": "https://partner-api.grab.com/grabid/v1/oauth2/scope_defs/name/impl_pattern", "service_acr_to_app_map": { "DEVELOPER": "PAX", "PASSENGER": "PAX" } } ``` -------------------------------- ### API: Get Membership Detail Endpoint Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Documents the GET endpoint for validating user membership, detailing header parameters, request body schema, and response examples. ```APIDOC GET /{api-endpoint}//v1/membership URL: https://{api-endpoint}//v1/membership Header Parameters: - Authorization (required, string): Bearer Description: Specify the generated authorization token of the bearer type. Request Body Schema (application/json): - memberID (required, string): The unique member ID on the partner's database. Request Sample Payload (application/json): { "memberID": "A12345689" } Responses: 200: Success 400: Bad Request. Invalid inputs. 404: Not Found. Membership doesn't exist. 500: Internal Server Error. Response Sample (200, application/json): { "membershipStatus": "VALID" } ``` -------------------------------- ### Grab Express API Request Example Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/bind-init This cURL command demonstrates how to make a sample API request to Grab Express, including necessary headers for authorization and content type, and a JSON payload for tokenization with specific merchant IDs. ```cURL -H 'Authorization: {{ partner_id:hmac_signature }}' \ -H 'Content-Type: application/json' \ -H 'Date: Mon, 21 Dec 2020 01:57:48 GMT' \ -d '{ "partnerTxID": "184d6a96728d40bc86b9f50dc18ae490", "countryCode": "SG", "merchantIDs": [ "14e808db-0d61-4a20-9da6-a8f31cbc55a2", "4102859d-96f4-4165-905d-572d7fb54e8d" ], "bindType": "TOKENIZE" }' ``` -------------------------------- ### GrabExpress API: Get Delivery Quotes with Valid Promo Code Source: https://developer.grab.com/docs/grab-express/grab-express Example JSON request and response for the 'Get Delivery Quotes' endpoint, demonstrating the successful application of a valid promo code. ```JSON { ..., "promoCode": "VALIDPROMO", ... } ``` ```JSON { ..., "discountInfo": { "success": true, "amount": 1, "errorMsg": "" }, ... } ``` -------------------------------- ### Python: Main Function for Sample Execution Source: https://developer.grab.com/docs/grab-express/grab-kios-digital-products-api/code-sample The `main` function in Python demonstrates the execution flow for various sample operations, including `inquiry_sample()`, `payment_sample()`, and `check_status_by_transaction_id_sample()`. This function serves as the primary entry point when the script is run directly, showcasing how different functionalities are invoked. ```Python def main(): inquiry_sample() payment_sample() check_status_by_transaction_id_sample() if __name__ == '__main__': main() ``` -------------------------------- ### Payment Initiate API Endpoint Details Source: https://developer.grab.com/docs/grab-express/pos-api-v3/init-overview This section provides the essential details for the Payment Initiate API endpoint, including its URL, the required HTTP method, and its operational characteristic. ```APIDOC Endpoint URL: /grabpay/partner/v3/payment/init HTTP Method: POST Operation: Asynchronous ``` -------------------------------- ### Get GrabGifts Account Balance using cURL Source: https://developer.grab.com/docs/grab-express/grab-gifts/ab-account-balance This example demonstrates how to retrieve the current account balance for GrabGifts using a GET request with cURL. It requires an Authorization header with a Bearer token and a Content-Type header. ```curl curl --location --request GET 'https://partner-gateway.stg-myteksi.com/gifts/partner/account/balance' \ --header 'Authorization: ' \ --header 'Content-Type: application/json' \ --data-raw '{}' ``` -------------------------------- ### GrabExpress API: Get Delivery Quotes with Invalid Promo Code Source: https://developer.grab.com/docs/grab-express/grab-express Example JSON request and response for the 'Get Delivery Quotes' endpoint, demonstrating how an invalid promo code is indicated in the response via the 'discountInfo' object. ```JSON { ..., "promoCode": "FULLPROMO", ... } ``` ```JSON { ..., "discountInfo": { "success": false, "amount": 0, "errorMsg": "offer is invalid" }, ... } ``` -------------------------------- ### Example API Responses for Grab Services Source: https://developer.grab.com/docs/grab-express/gfb/get-transactions Illustrates typical JSON response structures for different Grab service verticals: Transport, Express, and Food. These examples show transaction details, user information, fare breakdowns, and service-specific data. ```JSON { "page": 1, "hasNextPage": true, "transactions": [ { "creationTime": "2024-03-21T10:15:30Z", "completionTime": "2024-03-21T10:45:15Z", "bookingID": "GRAB123456789", "vertical": "TRANSPORT", "source": "IPHONE", "type": "IMMEDIATE", "userInfo": { "companyName": "Example Corp", "companyID": 12345, "email": "user@example.com", "employeeID": "EMP123", "groupName": "Sales", "tripCode": "TRIP001" }, "fare": { "baseFare": 15.50, "otherFees": 2.50, "amount": 18.00, "currency": "SGD", "paymentMethod": [ { "type": "Corporate Billing", "cardNumber": "XXXX-XXXX-XXXX-1234" } ], "billingType": "Corporate Billing" }, "transport": { "taxiType": "Standard (JG)", "city": "Singapore", "country": "SG", "pickUp": { "city": "Singapore", "address": "1 Raffles Place, Singapore 048616", "keyword": "Raffles Place" }, "dropOff": { "city": "Singapore", "address": "10 Marina Boulevard, Singapore 018983", "keyword": "Marina Bay Sands" }, "distance": 2500 }, "expenseCode": "TRAVEL001" } ] } ``` ```JSON { "page": 1, "hasNextPage": false, "transactions": [ { "creationTime": "2024-03-21T11:20:45Z", "completionTime": "2024-03-21T12:05:30Z", "bookingID": "GRAB987654321", "vertical": "EXPRESS", "source": "ANDROID", "type": "IMMEDIATE", "userInfo": { "companyName": "Example Corp", "companyID": 12345, "email": "user@example.com", "employeeID": "EMP123", "groupName": "Operations" }, "fare": { "baseFare": 8.00, "otherFees": 1.50, "amount": 9.50, "currency": "SGD", "paymentMethod": [ { "type": "MasterCard", "cardNumber": "XXXX-XXXX-XXXX-5678" } ] }, "express": { "taxiType": "GrabExpress - Instant - Bike", "city": "Singapore", "country": "SG", "pickUp": { "city": "Singapore", "address": "313 Orchard Road, Singapore 238895", "keyword": "313 Somerset" }, "dropOff": { "city": "Singapore", "address": "1 Scotts Road, Singapore 228208", "keyword": "Shaw Centre" }, "distance": 1500 } } ] } ``` ```JSON { "page": 1, "hasNextPage": true, "transactions": [ { "creationTime": "2024-03-21T12:30:15Z", "completionTime": "2024-03-21T13:15:45Z", "bookingID": "GRAB456789123", "vertical": "FOOD", "source": "IPHONE", "type": "IMMEDIATE", "userInfo": { "companyName": "Example Corp", "companyID": 12345, "email": "user@example.com", "employeeID": "EMP123", "groupName": "Marketing" }, "fare": { "baseFare": 25.80, "otherFees": 3.20, "amount": 29.00, "currency": "SGD", "paymentMethod": [ { "type": "Corporate Billing", "cardNumber": "XXXX-XXXX-XXXX-9012" } ], "billingType": "Corporate Billing" }, "food": { "merchantName": "Delicious Restaurant", "city": "Singapore", "country": "SG", "pickUp": { "city": "Singapore", "address": "1 Harbourfront Walk, Singapore 098585", "keyword": "VivoCity" }, "dropOff": { "city": "Singapore", "address": "10 Bayfront Avenue, Singapore 018956", "keyword": "Marina Bay Financial Centre" }, "distance": 3500 } } ] } ``` -------------------------------- ### Build GrabFood Java SDK JAR Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Instructions to compile and package the GrabFood Java SDK into a JAR file using Maven, a necessary step before manual installation and usage. ```Shell mvn clean package ``` -------------------------------- ### Retrieve Promo List via cURL Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/get-promo Example cURL command to retrieve the list of available promotions. This GET request includes necessary query parameters like merchantID, amount, currency, and paymentType, along with authorization and HMAC signature headers for authentication. ```curl curl --location --request GET 'https://partner-api.stg-myteksi.com/grabpay/partner/v4/promo?merchantID=907f3c50-c6a0-4466-8996-7aebae838de7&amount=10000¤cy=SGD&paymentType=GPWALLET&msgID=fjpNGtejMUMIUB7m9zDbuw28qQmjLjyX' \ --header 'Authorization: Bearer {{OAuth2_token}}' \ --header 'X-GID-AUX-POP: {{HMAC_signature}}' \ --header 'Content-Type: application/json' \ --header 'Date: Mon, 21 Apr 2025 09:22:11 GMT' \ --data '{}' ``` -------------------------------- ### GrabPay API Promotion Amount Breakdown Examples Source: https://developer.grab.com/docs/grab-express/paysi-partner Illustrates various promotion scenarios with corresponding 'amountBreakdown' JSON structures, showing how discounts, paid amounts, and different types of Grab or merchant-funded promotions are represented. ```JSON "amountBreakdown": { "discountAmount": 220, "paidAmount": 1099, "grabPromoAmount": 220 } ``` ```JSON "amountBreakdown": { "discountAmount": 120, "paidAmount": 479, "merchantFundedPromo": 120, "merchantRetentionPromoAmount": 120 } ``` ```JSON "amountBreakdown": { "discountAmount": 120, "paidAmount": 479, "merchantFundedPromo": 120, "merchantAcquisitionPromoAmount": 120 } ``` ```JSON "amountBreakdown": { "discountAmount": 120, "paidAmount": 479, "merchantFundedPromo": 120 } ``` -------------------------------- ### Authenticate and Use GrabFood SDK in Go Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Example demonstrating how to acquire and manage OAuth2 access tokens efficiently, then use the GrabFood SDK to call the GetStoreHour API. It emphasizes storing and reusing tokens to minimize server requests. ```Go config := grabfood.NewConfiguration() apiClient := grabfood.NewAPIClient(config) ctx := context.WithValue(context.Background(), grabfood.ContextServerIndex, grabfood.StgEnv) grabOauthRequest := *grabfood.NewGrabOauthRequest("client_id", "client_secret", "client_credentials", "food.partner_api") authResp, _, _ := apiClient.GetOauthGrabAPI.GetOauthGrab(ctx).GrabOauthRequest(grabOauthRequest).Execute() // Request a new token only when the previous one has expired. // Can utilize the `expires_in` from *authResp.ExpiresIn to determine the validity of the token. ACCESS_TOKEN := *authResp.AccessToken authorization := "Bearer " + ACCESS_TOKEN merchantID := "1-CYNGRUNGSBCCC" resp, _, _ := apiClient.GetStoreHourAPI.GetStoreHour(ctx, merchantID).Authorization(authorization).Execute() fmt.Printf("Response from `GetStoreHourAPI.GetStoreHour`: %+v\n", resp) ``` -------------------------------- ### Header Parameters for Get Additional ID Information Endpoint Source: https://developer.grab.com/docs/grab-express/grab-id Specifies the required `Content-Type` header for requests to the `/token-info` endpoint, which must be `application/json`. ```APIDOC Header Parameters: content-type (String): You should use application/json. ``` -------------------------------- ### GrabPay API: Sample Continue Charge Request Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/charge-topup An example `curl` command to make a GET request to the GrabPay continue charge endpoint, including necessary headers and a `txID` in the body. ```curl curl -X GET https://partner-api.grab.com/grabpay/partner/v4/charge/continue \ -H 'Authorization: Bearer {access_token}' \ -H 'Content-Type: application/json' \ -H 'X-GID-AUX-POP: eyJ0aW1lX3NpbmNlX2Vwb2NoIjoxNjE0MTM5MDUwLCJzaWciOiJqZW1oREFEZHdzQURkbnFSYk1HWFFweDNZVFJpY0M1SmdxU1hjRS1tYS1NIn0' \ -H 'Date: Mon, 21 Dec 2020 08:49:37 GMT' \ -d '{"txID": "fac7ab2f2f144057b6b669f12730d7bf"}' ``` -------------------------------- ### Android Kotlin Function to Launch WebView Host Activity Source: https://developer.grab.com/docs/grab-express/payment-otc/api/v2 Provides a simple Kotlin function to launch the `SampleWebViewHostActivity` from any calling activity. It demonstrates how to create an `Intent` and pass the initial URL to be loaded in the WebView. ```Kotlin /// -- In your Calling activity fun launch(initialUrl: String) { val intent = Intent( activityCtx, SampleWebViewHostActivity::class.java ) intent.putExtras("extras_web_url", initialUrl) startActivity(intent) } //// -- ``` -------------------------------- ### Sample API Request for Transaction Initiation Source: https://developer.grab.com/docs/grab-express/pos-api-v3/init-request This cURL command demonstrates a sample API request to initiate a transaction. It includes necessary headers like Authorization and Content-Type, along with a JSON payload detailing transaction specifics, payment methods, POS details, and basket items. The request specifies a payment channel, amount, currency, and various item details. ```cURL -H 'Authorization: {{ partner_id:hmac_signature }}' \ -H 'Content-Type: application/json' \ -H 'Date: Mon, 21 Dec 2020 01:57:48 GMT' \ -d '{ "transactionDetails": { "paymentChannel": "MPQR", "storeGrabID": "9e5921d9-cf09-4e68-8ca8-4dbab6251fe7", "partnerTxID": "bd77cf33aec04274b651fdf9ed3169d6", "partnerGroupTxID": "f841d0cbf9c248c68598c5f0379ebe6f", "billRefNumber": "", "amount": 150, "currency": "SGD", "paymentExpiryTime": 1658911817 }, "paymentMethod": { "paymentMethodExclusion": ["POSTPAID", "INSTALMENT_4"], "minAmtPostpaid": 0, "minAmt4Instalment": 140 }, "POSDetails": { "terminalID": "8ff9e12bacaf485abac0a7cef", "consumerIdentifier": "" }, "basketDetails": [ { "sku": "123", "itemName": "item 1", "category": "item 1 - animal", "quantity": 1, "price": 10001 }, { "sku": "456", "itemName": "item 2", "category": "item 2 - mobile phone", "quantity": 1, "price": 20002 }, { "sku": "456", "itemName": "item 2", "category": "item 2 - mobile phone", "quantity": 1, "price": 30003 } ] }' ``` -------------------------------- ### Sample GrabPay API Transaction Status Request Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/charge-status A `curl` command example to check the status of a GrabPay transaction using a GET request to the `/grabpay/partner/v4/charge/{partnerTxID}/status` endpoint. ```curl curl -X GET https://partner-api.grab.com/grabpay/partner/v4/charge/{partnerTxID}/st atus?currency=SGD \ -H 'Authorization: Bearer {{ OAuth2_token }}' -H 'X-GID-AUX-POP: eyJ0aW1lX3NpbmNlX2Vwb2NoIjoxNjE0MTM5MDUwLCJzaWciOiJqZW1oREFEZHdzQURkbnFSYk1HWFFweDNaVFJpY0M1SmdxU1hjRS1tYS1NIn0' -H 'Content-Type: application/json' \ -H 'Date: Mon, 21 Dec 2020 08:49:37 GMT' \ ``` -------------------------------- ### Troubleshooting: Recommended Logging Parameters Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Details essential parameters and information partners should log for all API calls to speed up troubleshooting in staging or production environments. ```APIDOC Recommended Logging Parameters: - Request endpoint / URL - Request body - Request headers - Response headers - Response body - X-Request-ID or X-Grabkit-Grab-RequestId (from response headers) ``` -------------------------------- ### Request Parameters for Get Additional ID Information Endpoint Source: https://developer.grab.com/docs/grab-express/grab-id Defines the parameters required for the `/token-info` endpoint, including the mandatory `client_id` and `id_token`, and the optional `nonce` for cryptographic verification. ```APIDOC Request Parameters: client_id (string): Required. Client ID created during the OAuth app registration process. id_token (string): Required. ID token issued by the /token endpoint. nonce (string): Optional. Cryptographically random string sent with the initial authorization request, used to verify the ID token. ``` -------------------------------- ### Overview of Grab Loyalty Program Integration Flow Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Outlines the step-by-step process for loyalty program integration, from initial contact and developer project access to content submission and API testing guidance. ```APIDOC Loyalty Program Integration Flow: 1. Submit interest form; local integration support team reaches out. 2. Gain access to developer project for configurations. 3. Submit required content for loyalty program setup. 4. Integration support team guides API functionality testing based on chosen method. ``` -------------------------------- ### Retrieve Orders by Date using cURL Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Example cURL command to retrieve a list of orders for a specific merchant and date, including pagination, by making a GET request to the GrabFood API. ```bash curl -X GET \ https://partner-api.grab.com/grabfood/partner/v1/orders?merchantID=1-C3VEJY6CMEEGUE&date=2020-01-20&page=0 \ -H 'Authorization: Bearer ' ``` -------------------------------- ### CLI Request to List GrabFood Campaigns Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Example `curl` command demonstrating how to make a GET request to the GrabFood API to retrieve a merchant's campaigns. Replace `` with your actual authorization token. ```CLI curl -L -X GET 'https://partner-api.grab.com/grabfood/partner/v1/campaigns?merchantID=4-CY4VMFMANYBYJ6' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### Get Store Hours API Request Sample (CLI) Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Example `curl` command to retrieve store hours for a specific merchant using the GrabFood API. Replace `` with a valid authorization token. ```bash curl -L -X GET 'https://partner-api.grab.com/grabfood/partner/v2/merchants/1-C3VEJY6CMEEGUE/store/hours' \ -H 'Authorization: Bearer ' ``` -------------------------------- ### API Reference: Initiate Bind Endpoint Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/bind-init This section provides the full API specification for initiating a bind between a customer's Grab account and a merchant account. It includes the HTTP method, URL, required header parameters, request body parameters, and expected response elements. ```APIDOC Method: POST URL: https://{{api-endpoint}}/grabpay/partner/v4/bind Header Parameters: - Authorization: Type: string Required: Yes Description: Header required for authorization purpose. Specify the HMAC signature based on the Partner Secret. Example: Authorization: {{partner_id:hmac_signature }} - Content-Type: Type: string Required: Yes Description: The content type of the request body. You must use application/json for this header because GrabPay doesn't support other formats currently. - Date: Type: timestamp Required: Yes Description: The date and time in GMT format. For example, Mon, 21 Dec 2020 08:29:58 GMT. Please note that: the Date & Time has to be the current time - it has to be the same as the Date used in the HMAC generation. Request Parameters: - partnerTxID: Type: string (max length = 32) Allowed Characters: alphanumeric, dashes, underscores Required: Yes Description: Specify the Partner transaction ID. Also used as the idempotency key. Make sure to provide the same partner transaction ID used when generating the signature. - countryCode: Type: string Required: Yes Description: Specify the two-letter ISO country code of the country where the transaction is initiated. Currently, supports SG, MY and PH. - merchantIDs: Type: array of object Required: Yes Description: Specify the list of MerchantIDs to which the customer's Grab account will be linked to. - bindType: Type: string (enum) Required: Yes Description: Specify the type of bind. Currently, only supports TOKENIZE. Response Elements: - request: Type: string Description: Transaction ID for this bind, encoded in JWT format, need to be provided as request URL parameter when constructing the authorization redirect URL to Grab web page. - partnerTxID: Type: string Description: Partner transaction ID used as the idempotency key for subsequent API calls. ``` -------------------------------- ### Example HTTP Request Headers for API Calls Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/started-api Demonstrates common HTTP headers required for Grab API requests, including Authorization with HMAC signature, Content-Type, and Date. ```HTTP -H 'Authorization: {{ partner_id:hmac_signature }}' \ -H 'Content-Type: application/json' \ -H 'Date: Mon, 21 Dec 2020 01:57:48 GMT' \ ``` -------------------------------- ### Acquire OAuth2 Access Token (Node.js) Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Example demonstrating how to obtain an OAuth2 access token using the GrabFood Node.js SDK. This function should be run once to get the token and re-run only upon token expiration. ```TypeScript import { GetOauthGrabApi, GrabOauthRequest, StgAuthEnv } from "@grab/grabfood-api-sdk/api"; async function getAccessToken(): Promise { const api = new GetOauthGrabApi(StgAuthEnv); const request: GrabOauthRequest = { client_id: "YOUR_CLIENT_ID", client_secret: "YOUR_CLIENT_SECRET", grant_type: "client_credentials", scope: "food.partner_api", }; try { const response = await api.getOauthGrab("application/json", request); return "Bearer " + response.body.access_token; } catch (error) { console.error("Error: ", (error as any)?.body ?? error); throw error; } } ``` -------------------------------- ### Run Tests for GrabFood SDK in PHP Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 This snippet provides commands to run unit tests for the GrabFood SDK in PHP using Composer and PHPUnit, ensuring the SDK is working correctly after installation. ```Bash composer install vendor/bin/phpunit ``` -------------------------------- ### GrabPay Promo Validation API Response Sample Source: https://developer.grab.com/docs/grab-express/tokenisation-v4/validate-promo An example JSON response received after successfully validating a promo. It includes promo details such as token, name, description, icon, currency, and detailed `amountMeta` with `additionalPaymentMethodDetail` and `repaymentDetail` for instalment payments. ```json { "token": "2:655066", "name": "$10 off on purchase", "description": "$10 off on purchase", "summary": "", "icon": "https://d166bljuvofq9e.cloudfront.net/media/f8/f83a5ce7-47d5-4931-bd37-92caa732ca9f.png", "headerImage": "https://d166bljuvofq9e.cloudfront.net/media/26/2670d14e-9383-4826-b5a5-7536c95c3347.png", "currency": "SGD", "amountMeta": { "discountedAmount": 9400, "additionalPaymentMethodDetail": { "paymentType": "INSTALMENT_8", "totalAmount": 99.6, "amountPerPayment": 12.45, "totalProcessingFee": 5.6, "processingFeePerPayment": 0.7, "processingFeePercentage": 0.75, "repaymentDetail": [ { "dueDate": 1745193600000, "amountDue": 12.45 }, { "dueDate": 1747785600000, "amountDue": 12.45 }, { "dueDate": 1750464000000, "amountDue": 12.45 }, { "dueDate": 1753056000000, "amountDue": 12.45 }, { "dueDate": 1755734400000, "amountDue": 12.45 }, { "dueDate": 1758412800000, "amountDue": 12.45 }, { "dueDate": 1761004800000, "amountDue": 12.45 }, { "dueDate": 1763683200000, "amountDue": 12.45 } ] } } } ``` -------------------------------- ### Get Store Hours API Response Sample Source: https://developer.grab.com/docs/grab-express/grabfood/api/v1-1-3 Example JSON response showing the structure for a merchant's daily dine-in and opening hours, as well as special opening hours with date ranges and descriptions. ```json { "dineInHour": { "mon": [ { "startTime": "11:30", "endTime": "21:30" } ], "tue": [ { "startTime": "11:30", "endTime": "21:30" } ], "wed": [ { "startTime": "11:30", "endTime": "21:30" } ], "thu": [ { "startTime": "11:30", "endTime": "21:30" } ], "fri": [ { "startTime": "11:30", "endTime": "21:30" } ], "sat": [ { "startTime": "11:30", "endTime": "21:30" } ], "sun": [ { "startTime": "11:30", "endTime": "21:30" } ] }, "openingHour": { "mon": [ { "startTime": "11:30", "endTime": "21:30" } ], "tue": [ { "startTime": "11:30", "endTime": "21:30" } ], "wed": [ { "startTime": "11:30", "endTime": "21:30" } ], "thu": [ { "startTime": "11:30", "endTime": "21:30" } ], "fri": [ { "startTime": "11:30", "endTime": "21:30" } ], "sat": [ { "startTime": "11:30", "endTime": "21:30" } ], "sun": [ { "startTime": "11:30", "endTime": "21:30" } ] }, "specialOpeningHours": [ { "startDate": "2024-02-01", "endDate": "2024-02-04", "metadata": { "description": "New Year Opening Hours" }, "openingHours": { "openPeriodType": "Period", "periods": [ { "startTime": "11:3 ```