Skip to content

Implementation for Merchant Server

Raka Westu Mogandhi edited this page Dec 1, 2016 · 12 revisions

The Merchant server

SDK Changes

There are some changes required on merchant server to make use latest SDK.

  • 1.0.x SDK needs merchant server to redirect the request to /pay in Snap endpoint.
  • 1.1.x SDK needs merchant server to redirect the request to /transactions in Snap endpoint.

Merchants need to implement the following web services for SDK to work correctly. Note all the below accept and return Content-Type JSON

Content-Type: application/json
Accept: application/json

Mandatory

Create Token(Checkout) : This API proxies the request to Snap Backend. This process generates the token necessary for the secure communication between Mobile SDK and Veritrans.

Endpoint: POST on /charge

  • Add header in the request.
Authorization: Basic Base64(SERVER_KEY + :)
  • Request will be sent to checkout / create transaction endpoint at Snap Backend.
  • Note the above request does not go to api.midtrans.com but to app.midtrans.com
Sandbox Endpoint: https://app.sandbox.midtrans.com/snap/v1/transactions
Production Endpoint: https://app.midtrans.com/snap/v1/transactions

Optional

This endpoint will be deprecated since Snap was already supported save card

We also additionally call a few endpoints if 1-Click or 2-Clicks is enabled :

  • To Store Credit Card Tokens: We explicitly invoke POST on /users/<userid>/tokens to allow the backend store generated credit card token after a successful Credit card charge.
  • To Retrieve Credit card Tokens : We explicitly invoke GET GET /users/<user_id>/tokens to retrieve saved card list.

The UserId refers to a generated UUID to associate card collection to each unique user. The mobile SDK generates this UUID during the initialization.

Store Credit Card Token

POST on /users/<userid>/tokens

Request Body

[
	{
	    "status_code": "200",
	    "cardhash": "481111-1114",
	    "token_id": "481111ROMUdhBGMQhjVtEPNcsGee1114"
	},
	{
		"status_code": "200",
	    "cardhash": "481111-1114",
	    "token_id": "481111ROMUdhBGMQhjVtEPNcsGee1114"
	}
]

Response Code : 200 Response Body

Card is saved

List Credit Cards

GET on /users/<userid>/tokens

Request Body

None

Response Body

[
	{
		"token_id": "481111ROMUdhBGMQhjVtEPNcsGee1114",
		"cardhash": "481111-1114"
	},
	{
		"token_id": "481111ROMUdhBGMQhjVtEPNcsGee1114",
		"cardhash": "481111-1114"
	}
]
    
Clone this wiki locally