Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

test(postman): Add proper `customer_id` in payment method create api (#2548)

Shankar Singh C7994a1259c58
diff --git a/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/.event.meta.json b/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/.event.meta.json
new file mode 100644
index 0000000000..0731450e6b
--- /dev/null
+++ b/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/.event.meta.json
@@ -0,0 +1,3 @@
+{
+ "eventOrder": ["event.test.js"]
+}
diff --git a/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/event.test.js b/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/event.test.js
new file mode 100644
index 0000000000..4ee1d3e8b2
--- /dev/null
+++ b/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/event.test.js
@@ -0,0 +1,53 @@
+// Validate status 2xx
+pm.test("[POST]::/customers - Status code is 2xx", function () {
+ pm.response.to.be.success;
+});
+
+// Validate if response header has matching content-type
+pm.test("[POST]::/customers - Content-Type is application/json", function () {
+ pm.expect(pm.response.headers.get("Content-Type")).to.include(
+ "application/json",
+ );
+});
+
+// Validate if response has JSON Body
+pm.test("[POST]::/customers - Response has JSON Body", function () {
+ pm.response.to.have.jsonBody();
+});
+
+// Set response object as internal variable
+let jsonData = {};
+try {
+ jsonData = pm.response.json();
+} catch (e) {}
+
+// Response body should have "customer_id"
+pm.test(
+ "[POST]::/customers - Content check if 'customer_id' exists",
+ function () {
+ pm.expect(typeof jsonData.customer_id !== "undefined").to.be.true;
+ },
+);
+
+// Response body should have a minimum length of "1" for "customer_id"
+if (jsonData?.customer_id) {
+ pm.test(
+ "[POST]::/customers - Content check if value of 'customer_id' has a minimum length of '1'",
+ function () {
+ pm.expect(jsonData.customer_id.length).is.at.least(1);
+ },
+ );
+}
+
+// pm.collectionVariables - Set customer_id as variable for jsonData.customer_id
+if (jsonData?.customer_id) {
+ pm.collectionVariables.set("customer_id", jsonData.customer_id);
+ console.log(
+ "- use {{customer_id}} as collection variable for value",
+ jsonData.customer_id,
+ );
+} else {
+ console.log(
+ "INFO - Unable to assign variable {{customer_id}}, as jsonData.customer_id is undefined.",
+ );
+}
diff --git a/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/request.json b/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/request.json
new file mode 100644
index 0000000000..be27f693d9
--- /dev/null
+++ b/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/request.json
@@ -0,0 +1,39 @@
+{
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ },
+ {
+ "key": "Accept",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "options": {
+ "raw": {
+ "language": "json"
+ }
+ },
+ "raw_json_formatted": {
+ "email": "[email protected]",
+ "name": "John Doe",
+ "phone": "999999999",
+ "phone_country_code": "+65",
+ "description": "First customer",
+ "metadata": {
+ "udf1": "value1",
+ "new_customer": "true",
+ "login_date": "2019-09-10T10:11:12Z"
+ }
+ }
+ },
+ "url": {
+ "raw": "{{baseUrl}}/customers",
+ "host": ["{{baseUrl}}"],
+ "path": ["customers"]
+ },
+ "description": "Create a customer object and store the customer details to be reused for future payments. Incase the customer already exists in the system, this API will respond with the customer details."
+}
diff --git a/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/response.json b/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/response.json
new file mode 100644
index 0000000000..fe51488c70
--- /dev/null
+++ b/postman/collection-dir/stripe/PaymentMethods/P_Create Customer/response.json
@@ -0,0 +1 @@
+[]
diff --git a/postman/collection-dir/stripe/PaymentMethods/PaymentMethods - Create/request.json b/postman/collection-dir/stripe/PaymentMethods/PaymentMethods - Create/request.json
index f9126f5e2e..2617b3e44a 100644
--- a/postman/collection-dir/stripe/PaymentMethods/PaymentMethods - Create/request.json
+++ b/postman/collection-dir/stripe/PaymentMethods/PaymentMethods - Create/request.json
@@ -27,7 +27,7 @@
"card_exp_year": "25",
"card_holder_name": "John Doe"
},
- "customer_id": "cus_mnewerunwiuwiwqw",
+ "customer_id": "{{customer_id}}",
"metadata": {
"city": "NY",
"unit": "245"