{
	"info": {
		"_postman_id": "287346b7-f23d-474b-a167-ad7ffa389031",
		"name": "Orchestration API - Documentation",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "31034920",
		"_collection_link": "https://upstreampay.postman.co/workspace/Purse---Team-services~f2d02d0a-d272-4b13-aadd-dfc7e6341a5a/collection/31034920-287346b7-f23d-474b-a167-ad7ffa389031?action=share&source=collection_link&creator=31034920"
	},
	"item": [
		{
			"name": "Client session",
			"item": [
				{
					"name": "Create client-session",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"client-session\", function (){",
									"    pm.response.to.have.jsonBody(\"id\");",
									"    var jsonData = JSON.parse(responseBody);",
									"    pm.collectionVariables.set(\"session_id\", jsonData.id);",
									"    pm.collectionVariables.set(\"entity_id\", jsonData.entity_id);",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "x-api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"entity_id\": \"{{entity_id}}\",\n  \"amount\": 11500,\n  \"currency\": \"EUR\",\n  \"shopper_redirection_url\": \"https://www.example.com\",\n  \"customer\": {\n    \"reference\": \"2090000000000\",\n    \"type\": \"PERSON\",\n    \"email\": \"emily.rose.parker@example.org\",\n    \"gender\": \"FEMALE\",\n    \"first_name\": \"Emily\",\n    \"middle_name\": \"Rose\",\n    \"last_name\": \"PARKER\",\n    \"birth_date\": \"1995-08-25\",\n    \"ip_address\": \"203.0.113.195\",\n    \"locale\": \"fr-FR\",\n    \"account\": {\n      \"creation_date_time\": \"2017-06-15T15:30:00+02:00\",\n      \"update_date_time\": \"2023-02-20T20:54:00+01:00\",\n      \"password_update_date_time\": \"2023-02-20T20:54:00+01:00\",\n      \"purchase_count_last_day\": 0,\n      \"purchase_count_last_six_months\": 3,\n      \"purchase_count_last_year\": 8,\n      \"authentication_method\": \"MERCHANT_CREDENTIALS\",\n      \"authentication_date_time\": \"2023-10-30T15:33:00+02:00\",\n      \"age_indicator\": \"MORE_60_DAYS\",\n      \"change_indicator\": \"MORE_60_DAYS\",\n      \"password_change_indicator\": \"MORE_60_DAYS\"\n    }\n  },\n  \"order\": {\n    \"reference\": \"123456789\",\n    \"net_amount\": 12000,\n    \"discount_amount\": 500,\n    \"tax_amount\": 2000,\n    \"billing_address\": {\n      \"gender\": \"FEMALE\",\n      \"first_name\": \"Emily\",\n      \"middle_name\": \"Rose\",\n      \"last_name\": \"PARKER\",\n      \"address_lines\": [\n        \"NextNow\",\n        \"67 Rue de Luxembourg\"\n      ],\n      \"city\": \"Lille\",\n      \"postal_code\": \"59777\",\n      \"country_code\": \"FR\",\n      \"province_code\": \"FR-HDF\",\n      \"phone_number\": \"+33111111111\",\n      \"mobile_phone_number\": \"+33222222222\",\n      \"work_phone_number\": \"+33444444444\"\n    },\n    \"shipments\": [\n      {\n        \"net_amount\": 12000,\n        \"delivery_type\": \"EXTERNAL_PICKUP\",\n        \"delivery_quickness\": \"REGULAR\",\n        \"delivery_method_reference\": \"#1123-pickup\",\n        \"estimated_delivery_date_time\": \"2023-10-30T15:40:00+02:00\",\n        \"shipping_address\": {\n          \"gender\": \"FEMALE\",\n          \"first_name\": \"Rodriguez\",\n          \"middle_name\": \"Eios\",\n          \"last_name\": \"DESANTONS\",\n          \"address_lines\": [\n            \"Av. de la roja 1676\"\n          ],\n          \"city\": \"Porto\",\n          \"postal_code\": \"22000\",\n          \"country_code\": \"PT\",\n          \"province_code\": \"PT-13\",\n          \"phone_number\": \"+33555555555\",\n          \"mobile_phone_number\": \"+33666666666\",\n          \"work_phone_number\": \"+33777777777\",\n          \"delivery_point_name\": \"home\"\n        },\n        \"item_lines\": [\n          {\n            \"type\": \"PHYSICAL\",\n            \"sku_reference\": \"2600218\",\n            \"name\": \"Camiseta100 niño GYM\",\n            \"brand\": \"Quivio\",\n            \"unit_gross_price\": 5000,\n            \"net_amount\": 12000,\n            \"quantity\": 2,\n            \"tax_amount\": 2000,\n            \"tax_rate\": 20.00,\n            \"seller_reference\": \"#42-ACME\",\n            \"seller_name\": \"Acme Corp\",\n            \"is_marketplace_seller\": true\n          },\n          {\n            \"type\": \"SHIPPING_FEES\",\n            \"name\": \"Transporte\",\n            \"net_amount\": 0,\n            \"unit_gross_price\": 0,\n            \"quantity\": 1,\n            \"tax_amount\": 0,\n            \"tax_rate\": 0\n          }\n        ]\n      }\n    ]\n  },\n  \"three_ds_authentication_options\": {\n    \"challenge_indicator\": \"NO_PREFERENCE\",\n    \"challenge_exemption\": \"LOW_VALUE\"\n  },\n  \"webhook\": {\n    \"url\": \"https://www.example.com/payment-hook?order_id=123456789\",\n    \"headers\": [\n      {\n        \"name\": \"x-custon-header\",\n        \"values\": [\"lorem ipsum\"]\n      }\n    ]\n  }\n}",
							"options": {
								"raw": {
									"language": "json"
								}
							}
						},
						"url": {
							"raw": "https://api.purse-sandbox.com/payment/v2/client-sessions",
							"protocol": "https",
							"host": [
								"api",
								"purse-sandbox",
								"com"
							],
							"path": [
								"payment",
								"v2",
								"client-sessions"
							]
						}
					},
					"response": []
				},
				{
					"name": "Get client-session",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"client-session\", function (){",
									"    pm.response.to.have.jsonBody(\"id\");",
									"    var jsonData = JSON.parse(responseBody);",
									"    pm.collectionVariables.set(\"payment_id\", jsonData.payment_id);",
									"});"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "x-api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "https://api.purse-sandbox.com/payment/v2/client-sessions/{{session_id}}",
							"protocol": "https",
							"host": [
								"api",
								"purse-sandbox",
								"com"
							],
							"path": [
								"payment",
								"v2",
								"client-sessions",
								"{{session_id}}"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Payment",
			"item": [
				{
					"name": "Operations",
					"item": [
						{
							"name": "Capture payment",
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "x-api-key",
										"value": "{{api_key}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"amount\": 10000\n}\n",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "https://api.purse-sandbox.com/payment/v2/payments/{{payment_id}}/captures",
									"protocol": "https",
									"host": [
										"api",
										"purse-sandbox",
										"com"
									],
									"path": [
										"payment",
										"v2",
										"payments",
										"{{payment_id}}",
										"captures"
									]
								}
							},
							"response": []
						},
						{
							"name": "Void payment",
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "x-api-key",
										"value": "{{api_key}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"amount\": 1500\n}\n",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "https://api.purse-sandbox.com/payment/v2/payments/{{payment_id}}/voids",
									"protocol": "https",
									"host": [
										"api",
										"purse-sandbox",
										"com"
									],
									"path": [
										"payment",
										"v2",
										"payments",
										"{{payment_id}}",
										"voids"
									]
								}
							},
							"response": []
						},
						{
							"name": "Refund payment",
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "x-api-key",
										"value": "{{api_key}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"amount\": 5000\n}\n",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "https://api.purse-sandbox.com/payment/v2/payments/{{payment_id}}/refunds",
									"protocol": "https",
									"host": [
										"api",
										"purse-sandbox",
										"com"
									],
									"path": [
										"payment",
										"v2",
										"payments",
										"{{payment_id}}",
										"refunds"
									]
								}
							},
							"response": []
						}
					]
				},
				{
					"name": "Get payment",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "x-api-key",
								"value": "{{api_key}}"
							}
						],
						"url": {
							"raw": "https://api.purse-sandbox.com/payment/v2/payments/{{payment_id}}",
							"protocol": "https",
							"host": [
								"api",
								"purse-sandbox",
								"com"
							],
							"path": [
								"payment",
								"v2",
								"payments",
								"{{payment_id}}"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Authenticate",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"authenticate\", function (){",
							"    pm.response.to.have.jsonBody(\"access_token\");",
							"    var jsonData = JSON.parse(responseBody);",
							"    pm.collectionVariables.set(\"access_token\", jsonData.access_token);",
							"});"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"auth": {
					"type": "basic",
					"basic": [
						{
							"key": "password",
							"value": "{{client_secret}}",
							"type": "string"
						},
						{
							"key": "username",
							"value": "{{client_id}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [
					{
						"key": "x-api-key",
						"value": "{{api_key}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "urlencoded",
					"urlencoded": [
						{
							"key": "grant_type",
							"value": "client_credentials",
							"type": "text"
						}
					]
				},
				"url": {
					"raw": "https://api.purse-sandbox.com/oauth/token",
					"protocol": "https",
					"host": [
						"api",
						"purse-sandbox",
						"com"
					],
					"path": [
						"oauth",
						"token"
					]
				}
			},
			"response": []
		},
		{
			"name": "JWKS Signing keys",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"auth": {
					"type": "noauth"
				},
				"method": "GET",
				"header": [
					{
						"key": "x-api-key",
						"value": "{{api_key}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "https://api.purse-sandbox.com/payment/v2/signing-jwks",
					"protocol": "https",
					"host": [
						"api",
						"purse-sandbox",
						"com"
					],
					"path": [
						"payment",
						"v2",
						"signing-jwks"
					]
				}
			},
			"response": []
		}
	],
	"auth": {
		"type": "bearer",
		"bearer": [
			{
				"key": "token",
				"value": "{{access_token}}",
				"type": "string"
			}
		]
	},
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "entity_id",
			"value": ""
		},
		{
			"key": "client_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "client_secret",
			"value": "",
			"type": "string"
		},
		{
			"key": "api_key",
			"value": "",
			"type": "string"
		},
		{
			"key": "session_id",
			"value": ""
		},
		{
			"key": "payment_id",
			"value": ""
		},
		{
			"key": "access_token",
			"value": ""
		}
	]
}
