Updating customer points with API

We are providing the API for updating customer points. Following, you can find a postman collection with all the necessary data. The postman collection contains these variables:

SHOPWARE_DOMAIN - The domain of the shopware project, without the http/https protocol.
SW_ACCESS_KEY - The shopware access key. (It's defined in the shopware integration)
SW_SECRET_ACCESS_KEY - The shopware secret key. (It's defined in the shopware integration)
ACCESS_TOKEN - The bearer token. (It's filled automatically by running the "1. Obtain API access token" post from the collection)

The test process using a postman:

Create a JSON file with the collection code posted bellow. 1. Import a collection. (a JSON format file) 2. Fill the collection variables. 3. Run the "1. Obtain API access token" post to fill the required ACCESS_TOKEN variable. 4. Run other posts from the collection. (Update bonus points by customer ID or number)

{
	"info": {
		"_postman_id": "55d7c3c5-bd28-44ad-bb5a-093a40ccd426",
		"name": "PremsBonusSystem: Update bonus points",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "5184947"
	},
	"item": [
		{
			"name": "1. Obtain API access token",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"pm.collectionVariables.set(\"ACCESS_TOKEN\", jsonData.access_token);"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"grant_type\": \"client_credentials\",\n  \"client_id\": \"{{SW_ACCESS_KEY}}\",\n  \"client_secret\": \"{{SW_SECRET_ACCESS_KEY}}\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/oauth/token",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"oauth",
						"token"
					]
				}
			},
			"response": []
		},
		{
			"name": "Update bonus points by customer number",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{ACCESS_TOKEN}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"customerNumber\": \"10382\",      // Customer number\n    \"description\": \"Test points\",   // Description for added/removed bonus points\n    \"points\": 5,                    // Amount of points, can be positive or negative\n    \"salesChannelId\": \"\"            // Optional: If it's not defined, it's obtained from the customer\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/v2/prems-bonus-system/create-bonus-booking",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"v2",
						"prems-bonus-system",
						"create-bonus-booking"
					]
				}
			},
			"response": []
		},
		{
			"name": "Update bonus points by customer ID",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{ACCESS_TOKEN}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"customerId\": \"019685763d44731cb4ac5938f107993e\",   // Customer ID\n    \"description\": \"Test points\",                       // Description for added/removed bonus points\n    \"points\": 5,                                        // Amount of points, can be positive or negative\n    \"salesChannelId\": \"\"                                // Optional: If it's not defined, it's obtained from the customer\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/_action/prems/create-bonus-booking-by-customer-id",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"_action",
						"prems",
						"create-bonus-booking-by-customer-id"
					]
				}
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "SHOPWARE_DOMAIN",
			"value": "domain.dev",
			"type": "string"
		},
		{
			"key": "SW_ACCESS_KEY",
			"value": "xxx",
			"type": "string"
		},
		{
			"key": "SW_SECRET_ACCESS_KEY",
			"value": "xxx",
			"type": "string"
		},
		{
			"key": "ACCESS_TOKEN",
			"value": "",
			"type": "string"
		}
	]
}

Last updated

Was this helpful?