Transaction Context

Each merchant of PhonePe Switch needs to send
transactioncontext in the initiate API . The base 64 encoded value is mentioned below :

eyJvcmRlckNvbnRleHQiOnsidHJhY2tpbmdJbmZvIjp7InR5cGUiOiJIVFRQUyIsInVybCI6Imh0dHBzOi8vd3d3LnRlc3QuY29tL29yZGVycy9oaXN0b3J5In19LCJmYXJlRGV0YWlscyI6eyJ0b3RhbEFtb3VudCI6NzMwLCJwYXlhYmxlQW1vdW50Ijo3MzB9LCJjYXJ0RGV0YWlscyI6eyJjYXJ0SXRlbXMiOlt7ImNhdGVnb3J5IjoiU0hPUFBJTkciLCJpdGVtSWQiOjM3MDY2MiwicHJpY2UiOjM2NSwiaXRlbU5hbWUiOiI1IFBpZWNlIENvdXZlcnR1cmUgQ2hvY29sYXRlIEJveCIsInF1YW50aXR5IjoyLCJhZGRyZXNzIjp7ImFkZHJlc3NTdHJpbmciOiJTYWJoYSBwZWFybCwgMm5kIGZsb29yODAgZmVldCByb2FkLCBJbmRpcmFuYWdhciIsImNpdHkiOiJCZW5nYWx1cnUiLCJwaW5jb2RlIjoiNTYwMDM4IiwiY291bnRyeSI6IkluZGlhIiwibGF0aXR1ZGUiOjEyLjk2NjMsImxvbmdpdHVkZSI6NzcuNjAzOX0sInNoaXBwaW5nSW5mbyI6eyJkZWxpdmVyeVR5cGUiOiJTVEFOREFSRCIsInRpbWUiOnsidGltZXN0YW1wIjoxNTczNDY3OTgwLCJ6b25lT2ZmU2V0IjoiKzA1OjMwIn19fV19fQ==

Cart details

Note : Every merchant will have different cart details which will be shared by PhonePe Team.

CategoryDetails
Shopping Categoryhttps://developer.phonepe.com/v4/docs/shopping-category
Food Categoryhttps://developer.phonepe.com/v4/docs/food-category
Hotel Categoryhttps://developer.phonepe.com/v4/docs/hotel-category
Flight Categoryhttps://developer.phonepe.com/v4/docs/flight-category
Bus Categoryhttps://developer.phonepe.com/v4/docs/bus-cart-details
Home Services Categoryhttps://developer.phonepe.com/v4/docs/home-service
Rental Categoryhttps://developer.phonepe.com/v4/docs/rental
Events Categoryhttps://developer.phonepe.com/v4/docs/events

URL is sent in the initiate-service-request API. This object is used to open the page for this particular order. (User can open this URL through PhonePe’s transaction page, “View Details” button)

Note

url is a mandatory parameter and a merchant needs to send the URL which will take the user to the details of the particular order on their website.
{
“trackingInfo”:{
“type”:”HTTPS”,
“url”:”https://merchant.com/particula order”
}

Examples

Shopping Category

For the shopping category, you can base 64 encode the below JSON and pass the same in the transaction context. You can check the base encoding value at https://www.base64decode.org/

{
	"orderContext": {
		"trackingInfo": {
			"type": "HTTPS",
			"url": "https://www.test.com/orders/history"
		}
	},
	"fareDetails": {
		"totalAmount": 730,
		"payableAmount": 730
	},
	"cartDetails": {
		"cartItems": [{
			"category": "SHOPPING",
			"itemId": 370662,
			"price": 365,
			"itemName": "5 Piece Couverture Chocolate Box",
			"quantity": 2,
			"address": {
				"addressString": "Sabha pearl, 2nd floor80 feet road, Indiranagar",
				"city": "Bengaluru",
				"pincode": "560038",
				"country": "India",
				"latitude": 12.9663,
				"longitude": 77.6039
			},
			"shippingInfo": {
				"deliveryType": "STANDARD",
				"time": {
					"timestamp": 1573467980,
					"zoneOffSet": "+05:30"
				}
			}
		}]
	}
}

Food Category

{
	"orderContext": {
		"trackingInfo": {
			"type": "HTTPS",
			"url": "https://www.test.com/orders/history"
		}
	},
	"fareDetails": {
		"totalAmount": 3900,
		"payableAmount": 3900
	},
	"cartDetails": {
		"cartItems": [{
			"category": "FOOD",
			"itemId": "1234567890",
			"price": 3900,
			"itemName": "TEST",
			"deliveryInfo": {
				"deliveryType": "STANDARD",
				"time": {
					"timestamp": 1561540218,

					"zoneOffSet": "+05:30"
				}
			},
			"orderType": "ON_DEMAND",
			"address": {
				"addressString": "TEST",
				"city": "TEST",
				"pincode": "TEST",
				"country": "TEST",
				"latitude": 1,
				"longitude": 1
			},
			"quantity": 1
		}]
	}

}

=======================================================

Encoded Value : 

ewoJIm9yZGVyQ29udGV4dCI6IHsKCQkidHJhY2tpbmdJbmZvIjogewoJCQkidHlwZSI6ICJIVFRQUyIsCgkJCSJ1cmwiOiAiaHR0cHM6Ly9nb29nbGUuY29tIgoJCX0KCX0sCgkiZmFyZURldGFpbHMiOiB7CgkJInRvdGFsQW1vdW50IjogMzkwMCwKCQkicGF5YWJsZUFtb3VudCI6IDM5MDAKCX0sCgkiY2FydERldGFpbHMiOiB7CgkJImNhcnRJdGVtcyI6IFt7CgkJCSJjYXRlZ29yeSI6ICJGT09EIiwKCQkJIml0ZW1JZCI6ICIxMjM0NTY3ODkwIiwKCQkJInByaWNlIjogMzkwMCwKCQkJIml0ZW1OYW1lIjogIlRFU1QiLAoJCQkiZGVsaXZlcnlJbmZvIjogewoJCQkJImRlbGl2ZXJ5VHlwZSI6ICJTVEFOREFSRCIsCgkJCQkidGltZSI6IHsKCQkJCQkidGltZXN0YW1wIjogMTU2MTU0MDIxOCwKCgkJCQkJInpvbmVPZmZTZXQiOiAiKzA1OjMwIgoJCQkJfQoJCQl9LAoJCQkib3JkZXJUeXBlIjogIk9OX0RFTUFORCIsCgkJCSJhZGRyZXNzIjogewoJCQkJImFkZHJlc3NTdHJpbmciOiAiVEVTVCIsCgkJCQkiY2l0eSI6ICJURVNUIiwKCQkJCSJwaW5jb2RlIjogIlRFU1QiLAoJCQkJImNvdW50cnkiOiAiVEVTVCIsCgkJCQkibGF0aXR1ZGUiOiAxLAoJCQkJImxvbmdpdHVkZSI6IDEKCQkJfSwKCQkJInF1YW50aXR5IjogMQoJCX1dCgl9Cgp9