Skip to content

Test Magento SOAP API v2 with Postman

Peter Jaap Blaakmeer edited this page Nov 23, 2016 · 2 revisions

Postman is a great tool to test your API workflows with. You can use it to test the Paymill payment integration. Below you will find a collection JSON that you can import into Postman. Adjust the variables (such as API URL, customer ID, product ID, address ID, shipping method, etc) and create a token (which can be done through this HTML form).

{
	"variables": [],
	"info": {
		"name": "YourWebshop.com",
		"_postman_id": "6b940a31-113d-109f-f36a-75c1604ef7d4",
		"description": "",
		"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
	},
	"item": [
		{
			"name": "Login call",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var responseJson = xml2Json(responseBody);",
							"postman.setEnvironmentVariable(\"sessionId\", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:loginResponse']['loginReturn']['_']);"
						]
					}
				}
			],
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <login>\n   <username>username</username>\n   <apiKey>apikey]9</apiKey>\n  </login>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartCreate",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var responseJson = xml2Json(responseBody);",
							"postman.setEnvironmentVariable(\"quoteId\", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:shoppingCartCreateResponse']['quoteId']['_']);"
						]
					}
				}
			],
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartCreate>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<storeId>1</storeId>\n  </shoppingCartCreate>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartCustomerSet",
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartCustomerSet>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  \t<customer>\n  \t\t<customer_id>1</customer_id>\n  \t\t<mode>customer</mode>\n  \t</customer>\n  </shoppingCartCustomerSet>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartCustomerAddresses",
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartCustomerAddresses>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  \t<customer>\n  \t\t<address>\n  \t\t\t<mode>shipping</mode>\n  \t\t\t<address_id>1</address_id>\n  \t\t</address>\n  \t\t<address>\n  \t\t\t<mode>billing</mode>\n  \t\t\t<address_id>1</address_id>\n  \t\t</address>\n  \t</customer>\t\t\n  </shoppingCartCustomerAddresses>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartProductAdd",
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartProductAdd>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  \t<products>\n  \t\t<productsData>\n  \t\t\t<sku>PRODUCTSKUHERE</sku>\n  \t\t\t<qty>10</qty>\n  \t\t</productsData>\n  \t</products>\n  </shoppingCartProductAdd>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartShippingList",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var responseJson = xml2Json(responseBody);",
							"postman.setEnvironmentVariable(\"cartId\", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:shoppingCartCreateResponse']['quoteId']['_']);"
						]
					}
				}
			],
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartShippingList>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  </shoppingCartShippingList>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartShippingMethod",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var responseJson = xml2Json(responseBody);",
							"postman.setEnvironmentVariable(\"cartId\", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:shoppingCartCreateResponse']['quoteId']['_']);"
						]
					}
				}
			],
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartShippingMethod>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  \t<method>tablerate_bestway</method>\n  </shoppingCartShippingMethod>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartPaymentList",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var responseJson = xml2Json(responseBody);",
							"postman.setEnvironmentVariable(\"cartId\", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:shoppingCartCreateResponse']['quoteId']['_']);"
						]
					}
				}
			],
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartPaymentList>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  </shoppingCartPaymentList>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartInfo",
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartInfo>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  </shoppingCartInfo>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartPaymentMethod",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var responseJson = xml2Json(responseBody);",
							"postman.setEnvironmentVariable(\"cartId\", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:shoppingCartCreateResponse']['quoteId']['_']);"
						]
					}
				}
			],
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/?XDEBUG_SESSION_START=PHPSTORM",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					},
					{
						"key": "XDEBUG_SESSION",
						"value": "PHPSTORM",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartPaymentMethod>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  \t<method>\n  \t\t<method>paymill_creditcard</method>\n  \t\t<paymill-payment-token-cc>TOKEN_HERE</paymill-payment-token-cc>\n  \t</method>\n  </shoppingCartPaymentMethod>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartProductRemove",
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartProductRemove>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  \t<products>\n  \t\t<productsData>\n  \t\t\t<sku>PRODUCTSKUHERE</sku>\n  \t\t\t<qty>1</qty>\n  \t\t</productsData>\n  \t</products>\n  </shoppingCartProductRemove>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "catalogProductInfo",
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <catalogProductInfo>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<productId>1</productId>\n  </catalogProductInfo>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartTotals",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var responseJson = xml2Json(responseBody);",
							"postman.setEnvironmentVariable(\"cartId\", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:shoppingCartCreateResponse']['quoteId']['_']);"
						]
					}
				}
			],
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartTotals>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  </shoppingCartTotals>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "shoppingCartOrder",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var responseJson = xml2Json(responseBody);",
							"postman.setEnvironmentVariable(\"cartId\", responseJson['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns1:shoppingCartCreateResponse']['quoteId']['_']);"
						]
					}
				}
			],
			"request": {
				"url": "https://yourwebshop.com/index.php/api/v2_soap/",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "text/xml",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n <soapenv:Body>\n  <shoppingCartOrder>\n  \t<sessionId>{{sessionId}}</sessionId>\n  \t<quoteId>{{quoteId}}</quoteId>\n  </shoppingCartOrder>\n </soapenv:Body>\n</soapenv:Envelope>"
				},
				"description": ""
			},
			"response": []
		}
	]
}
Clone this wiki locally