{"id":21878095,"url":"https://github.com/midtrans/merchant-server-for-midtrans-mobile-sdk-python-sample","last_synced_at":"2026-05-11T02:21:17.971Z","repository":{"id":96453208,"uuid":"173872020","full_name":"Midtrans/Merchant-Server-for-Midtrans-Mobile-SDK-Python-Sample","owner":"Midtrans","description":"Merchant Server for Midtrans Mobile SDK Python Sample","archived":false,"fork":false,"pushed_at":"2020-09-04T09:28:51.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-26T18:17:28.358Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/Midtrans.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":"2019-03-05T04:15:57.000Z","updated_at":"2020-09-04T09:28:54.000Z","dependencies_parsed_at":"2023-04-19T23:27:19.169Z","dependency_job_id":null,"html_url":"https://github.com/Midtrans/Merchant-Server-for-Midtrans-Mobile-SDK-Python-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/Midtrans%2FMerchant-Server-for-Midtrans-Mobile-SDK-Python-Sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Midtrans%2FMerchant-Server-for-Midtrans-Mobile-SDK-Python-Sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Midtrans%2FMerchant-Server-for-Midtrans-Mobile-SDK-Python-Sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Midtrans%2FMerchant-Server-for-Midtrans-Mobile-SDK-Python-Sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Midtrans","download_url":"https://codeload.github.com/Midtrans/Merchant-Server-for-Midtrans-Mobile-SDK-Python-Sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244885532,"owners_count":20526293,"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":[],"created_at":"2024-11-28T08:11:39.788Z","updated_at":"2026-05-11T02:21:17.706Z","avatar_url":"https://github.com/Midtrans.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Simple Merchant Server Implementation Reference for Mobile SDK (Python version).\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### Prerequisites\nYou need these to run the app:\n\n* [Python 2.7.x](https://www.python.org/)\n\n### Install dependencies\n```bash\n$ pip install -r requirements.txt\n```\n\n### Running the app\n```bash\n$ export FLASK_ENV=development\n$ python app.py / flask run\n```\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 `config.yml`, insert your Midtrans Account Server Key to `sandbox_server_key` and `production_server_key`.\nSet `is_production` to `True` when you use env production.\n\nSet `\u003curl where you host this\u003e/charge` as `merchant base url` in mobile SDK. (refer to [Midtrans mobile SDK doc](https://mobile-docs.midtrans.com))\n\n\n## Testing\nYou can mock client's request by executing this CURL command to the `/charge` endpoint:\n\n```\ncurl -X POST \\\n   http://\u003cyour url\u003e/charge \\\n  -H 'Accept: application/json' \\\n  -H 'Content-Type: application/json' \\\n  -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}'\n```\n\nNote: dont forget to change `\"http://\u003cyour url\u003e/charge\"` to your url where you hosted the `/charge`.\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## Gopay Tokenization Merchant Server\nFor sample reference please refer to [this example](https://github.com/Midtrans/Merchant-Server-for-Midtrans-Mobile-SDK-Python-Sample/tree/master/tokenization-example) as it has a different specification.\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\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidtrans%2Fmerchant-server-for-midtrans-mobile-sdk-python-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmidtrans%2Fmerchant-server-for-midtrans-mobile-sdk-python-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidtrans%2Fmerchant-server-for-midtrans-mobile-sdk-python-sample/lists"}