{"id":18525211,"url":"https://github.com/rizdaprasetya/midtrans-mobile-merchant-server--php-sample-","last_synced_at":"2025-04-10T04:13:11.261Z","repository":{"id":97486953,"uuid":"73993495","full_name":"rizdaprasetya/midtrans-mobile-merchant-server--php-sample-","owner":"rizdaprasetya","description":"Sample for Midtrans mobile backend implementation written in PHP | ","archived":false,"fork":false,"pushed_at":"2019-09-25T04:21:41.000Z","size":22,"stargazers_count":17,"open_issues_count":1,"forks_count":29,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T05:34:50.808Z","etag":null,"topics":["api","midtrans","mobile","payment","payment-gateway"],"latest_commit_sha":null,"homepage":"https://mobile-docs.midtrans.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rizdaprasetya.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-17T05:28:43.000Z","updated_at":"2024-12-01T07:42:31.000Z","dependencies_parsed_at":"2024-03-14T16:01:14.244Z","dependency_job_id":null,"html_url":"https://github.com/rizdaprasetya/midtrans-mobile-merchant-server--php-sample-","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizdaprasetya%2Fmidtrans-mobile-merchant-server--php-sample-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizdaprasetya%2Fmidtrans-mobile-merchant-server--php-sample-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizdaprasetya%2Fmidtrans-mobile-merchant-server--php-sample-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizdaprasetya%2Fmidtrans-mobile-merchant-server--php-sample-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rizdaprasetya","download_url":"https://codeload.github.com/rizdaprasetya/midtrans-mobile-merchant-server--php-sample-/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154996,"owners_count":21056543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","midtrans","mobile","payment","payment-gateway"],"created_at":"2024-11-06T17:44:45.562Z","updated_at":"2025-04-10T04:13:11.215Z","avatar_url":"https://github.com/rizdaprasetya.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Simple Merchant Server Implementation Reference for Mobile SDK (PHP version).\n\n\u003e _Also available in other Language Implementation:_\n\u003e * [Ruby Sample Merchant Server for Midtrans Mobile SDK](https://github.com/Midtrans/Merchant-Server-for-Midtrans-Mobile-SDK-Ruby-Sample)\n\u003e * [Python Sample Merchant Server for Midtrans Mobile SDK](https://github.com/Midtrans/Merchant-Server-for-Midtrans-Mobile-SDK-Python-Sample)\n\n## Description\nThis is a example mobile SDK server for Midtrans's iOS and Android SDK, as an implementation reference to use the mobile sdk.\nPlease read more in [Documentation of Midtrans mobile SDK](http://mobile-docs.midtrans.com/).\n\n## Purpose\nThe main idea why this server implementation needed is: **To securely add HTTP Authorization Header** from server side.\nThis auth header is generated from **server key** (from your Midtrans account), this server key is secret, and should only be kept in server side, not client side (mobile app can be easily reverse engineered to extract any secret).\n\nAdditionally, it allows you to tweak JSON request parameter as needed from server side.\n\n## Endpoints\nThere is only one endpoint that are required to use Midtrans mobile SDK:\n\n```\nPOST /charge/\n```\n\nThis endpoint will **proxy (forward)** client request to Midtrans Snap API `'https://app.midtrans.com/snap/v1/transactions'` (or `'https://app.sandbox.midtrans.com/snap/v1/transactions'` for sandbox) with **HTTP Authorization Header** generated based on your Midtrans `Server Key`.\n\nThe response of API will be printed/returned to client as is. Example response that will be printed\n\n```\n{\n    \"token\": \"413ae932-471d-4c41-bfb4-e558cc271dcc\",\n    \"redirect_url\": \"https://app.sandbox.midtrans.com/snap/v2/vtweb/413ae932-471d-4c41-bfb4-e558cc271dcc\"\n}\n```\n\n## Usage\nEdit file `charge/index.php`, insert your Midtrans Account Server Key to `'\u003cserver key\u003e'`.\nUpload these to your host, and make sure the url `\u003curl where you host this\u003e/charge/index.php` can be accessed from the mobile app.\n\nSet `\u003curl where you host this\u003e/charge/index.php` as `merchant base url` in mobile SDK. (refer to [Midtrans mobile SDK doc](https://mobile-docs.midtrans.com))\n\n\u003e **Advanced Tips:**\n\u003e You can also configure your HTTP server to route `\u003curl where you host this\u003e/charge/` url to `/charge/index.php` file. \n\u003e So the `merchant base url` can be just configured as `\u003curl where you host this\u003e/`(without charge/index.php, because SDK will automatically convert it to `\u003curl where you host this\u003e/charge/` then your server will route to `/charge/index.php/`).\n\n## Testing\nYou can mock client's request by executing this CURL command to the `/charge/index.php` endpoint:\n\n```\ncurl -X POST -d '{  \n   \"transaction_details\":{  \n      \"order_id\":\"mobile-12345\",\n      \"gross_amount\":280000\n   },\n   \"item_details\":[  \n      {  \n         \"id\":\"A01\",\n         \"price\":280000,\n         \"quantity\":1,\n         \"name\":\"Mie Ayam Komplit\"\n      }\n   ],\n   \"customer_details\":[  \n      {  \n         \"email\":\"tester@example.com\",\n         \"first_name\":\"Budi\",\n         \"last_name\":\"Khannedy\",\n         \"phone\":\"628112341234\"\n      }\n   ]\n}' \"https://\u003cyour url\u003e/charge/index.php/\"\n```\n\nNote: dont forget to change `\"http://\u003cyour url\u003e/charge/index.php/\"` to your url where you hosted the `/charge/index.php`.\n\nYou can also import that curl command to Postman.\n\n## Notes\nThis is just for very basic implementation reference, in production, you should implement your backend more securely.\n\n## Troubleshooting\nWhen request sent to the url `https://\u003cyour url\u003e/charge/index.php` fail, try to change the url to `https://\u003cyour url\u003e/charge/`\n\n### Get help\n* [Midtrans\u0026nbsp;](https://www.midtrans.com)\n* [Midtrans registration](https://dashboard.midtrans.com/register)\n* [Midtrans documentation](http://docs.midtrans.com)\n* Can't find answer you looking for? email to [support@midtrans.com](mailto:support@midtrans.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizdaprasetya%2Fmidtrans-mobile-merchant-server--php-sample-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frizdaprasetya%2Fmidtrans-mobile-merchant-server--php-sample-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizdaprasetya%2Fmidtrans-mobile-merchant-server--php-sample-/lists"}