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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(deserialization): error message is different when invalid data is passed for payment method data (#4022)
Narayan Bhatf1fe295475ad
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex e5882fcb49..dee5f2d075 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -1095,12 +1095,19 @@ mod payment_method_data_serde {#[serde(untagged)]enum __Inner {RewardString(String),- OptionalPaymentMethod(Box<PaymentMethodDataRequest>),+ OptionalPaymentMethod(serde_json::Value),}let deserialize_to_inner = __Inner::deserialize(deserializer)?;match deserialize_to_inner {- __Inner::OptionalPaymentMethod(value) => Ok(Some(*value)),+ __Inner::OptionalPaymentMethod(value) => {+ let parsed_value = serde_json::from_value::<PaymentMethodDataRequest>(value)+ .map_err(|serde_json_error| {+ serde::de::Error::custom(serde_json_error.to_string())+ })?;++ Ok(Some(parsed_value))+ }__Inner::RewardString(inner_string) => {let payment_method_data = match inner_string.as_str() {"reward" => PaymentMethodData::Reward,@@ -4048,3 +4055,73 @@ pub enum PaymentLinkStatusWrap {PaymentLinkStatus(PaymentLinkStatus),IntentStatus(api_enums::IntentStatus),}++#[cfg(test)]+mod payments_request_api_contract {+ #![allow(clippy::unwrap_used)]+ #![allow(clippy::panic)]+ use std::str::FromStr;++ use super::*;++ #[test]+ fn test_successful_card_deser() {+ let payments_request = r#"+ {+ "amount": 6540,+ "currency": "USD",+ "payment_method": "card",+ "payment_method_data": {+ "card": {+ "card_number": "4242424242424242",+ "card_exp_month": "10",+ "card_exp_year": "25",+ "card_holder_name": "joseph Doe",+ "card_cvc": "123"+ }+ }+ }+ "#;++ let expected_card_number_string = "4242424242424242";+ let expected_card_number = CardNumber::from_str(expected_card_number_string).unwrap();++ let payments_request = serde_json::from_str::<PaymentsRequest>(payments_request);+ assert!(payments_request.is_ok());++ if let PaymentMethodData::Card(card_data) = payments_request+ .unwrap()+ .payment_method_data+ .unwrap()+ .payment_method_data+ {+ assert_eq!(card_data.card_number, expected_card_number);+ } else {+ panic!("Received unexpected response")+ }+ }++ #[test]+ fn test_successful_payment_method_reward() {+ let payments_request = r#"+ {+ "amount": 6540,+ "currency": "USD",+ "payment_method": "reward",+ "payment_method_data": "reward",+ "payment_method_type": "evoucher"+ }+ "#;++ let payments_request = serde_json::from_str::<PaymentsRequest>(payments_request);+ assert!(payments_request.is_ok());+ assert_eq!(+ payments_request+ .unwrap()+ .payment_method_data+ .unwrap()+ .payment_method_data,+ PaymentMethodData::Reward+ );+ }+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method/.event.meta.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/.event.meta.jsonsimilarity index 100%rename from postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method/.event.meta.jsonrename to postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/.event.meta.jsondiff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/event.test.js b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/event.test.jsnew file mode 100644index 0000000000..f1c2c6af77--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/event.test.js@@ -0,0 +1,26 @@+// Validate status 400+pm.test("[POST]::/payments - Status code is 400", function () {+ pm.response.to.be.error+});++// Validate if response header has matching content-type+pm.test("[POST]::/payments - 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]::/payments - 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) { }++pm.test("[POST]::/payments - Response has appropriate error message", function () {+ pm.expect(jsonData.error.message).eql("Invalid card_cvc length");+})diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/request.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/request.jsonnew file mode 100644index 0000000000..77b40a8ece--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/request.json@@ -0,0 +1,41 @@+{+ "method": "POST",+ "header": [+ {+ "key": "Content-Type",+ "value": "application/json"+ },+ {+ "key": "Accept",+ "value": "application/json"+ }+ ],+ "body": {+ "mode": "raw",+ "options": {+ "raw": {+ "language": "json"+ }+ },+ "raw_json_formatted": {+ "amount": 6540,+ "currency": "USD",+ "payment_method": "card",+ "payment_method_data": {+ "card": {+ "card_number": "4242424242424242",+ "card_exp_month": "10",+ "card_exp_year": "25",+ "card_holder_name": "joseph Doe",+ "card_cvc": ""+ }+ }+ }+ },+ "url": {+ "raw": "{{baseUrl}}/payments",+ "host": ["{{baseUrl}}"],+ "path": ["payments"]+ },+ "description": "Create a Payment to ensure api contract is intact"+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/.event.meta.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/.event.meta.jsonnew file mode 100644index 0000000000..4ac527d834--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/.event.meta.json@@ -0,0 +1,6 @@+{+ "eventOrder": [+ "event.test.js",+ "event.prerequest.js"+ ]+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/event.test.js b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/event.test.jsnew file mode 100644index 0000000000..c645f670eb--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/event.test.js@@ -0,0 +1,16 @@+// Validate status 400+pm.test("[POST]::/payments - Status code is 400", function () {+ pm.response.to.be.error+});++// Validate if response header has matching content-type+pm.test("[POST]::/payments - 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]::/payments - Response has JSON Body", function () {+ pm.response.to.have.jsonBody();+});diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/request.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/request.jsonnew file mode 100644index 0000000000..2cb146e30a--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Card Number/request.json@@ -0,0 +1,41 @@+{+ "method": "POST",+ "header": [+ {+ "key": "Content-Type",+ "value": "application/json"+ },+ {+ "key": "Accept",+ "value": "application/json"+ }+ ],+ "body": {+ "mode": "raw",+ "options": {+ "raw": {+ "language": "json"+ }+ },+ "raw_json_formatted": {+ "amount": 6540,+ "currency": "USD",+ "payment_method": "card",+ "payment_method_data": {+ "card": {+ "card_number": "1234",+ "card_exp_month": "10",+ "card_exp_year": "25",+ "card_holder_name": "joseph Doe",+ "card_cvc": "123"+ }+ }+ }+ },+ "url": {+ "raw": "{{baseUrl}}/payments",+ "host": ["{{baseUrl}}"],+ "path": ["payments"]+ },+ "description": "Create a Payment to ensure api contract is intact"+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/.event.meta.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/.event.meta.jsonnew file mode 100644index 0000000000..4ac527d834--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/.event.meta.json@@ -0,0 +1,6 @@+{+ "eventOrder": [+ "event.test.js",+ "event.prerequest.js"+ ]+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/event.test.js b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/event.test.jsnew file mode 100644index 0000000000..8b3d52a3c6--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/event.test.js@@ -0,0 +1,26 @@+// Validate status 400+pm.test("[POST]::/payments - Status code is 400", function () {+ pm.response.to.be.error+});++// Validate if response header has matching content-type+pm.test("[POST]::/payments - 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]::/payments - 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) { }++pm.test("[POST]::/payments - Response has appropriate error message", function () {+ pm.expect(jsonData.error.message).eql("Invalid Expiry Month");+})diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/request.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/request.jsonnew file mode 100644index 0000000000..2c3d0fe427--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/request.json@@ -0,0 +1,41 @@+{+ "method": "POST",+ "header": [+ {+ "key": "Content-Type",+ "value": "application/json"+ },+ {+ "key": "Accept",+ "value": "application/json"+ }+ ],+ "body": {+ "mode": "raw",+ "options": {+ "raw": {+ "language": "json"+ }+ },+ "raw_json_formatted": {+ "amount": 6540,+ "currency": "USD",+ "payment_method": "card",+ "payment_method_data": {+ "card": {+ "card_number": "4242424242424242",+ "card_exp_month": "13",+ "card_exp_year": "69",+ "card_holder_name": "joseph Doe",+ "card_cvc": "123"+ }+ }+ }+ },+ "url": {+ "raw": "{{baseUrl}}/payments",+ "host": ["{{baseUrl}}"],+ "path": ["payments"]+ },+ "description": "Create a Payment to ensure api contract is intact"+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/.event.meta.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/.event.meta.jsonnew file mode 100644index 0000000000..4ac527d834--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/.event.meta.json@@ -0,0 +1,6 @@+{+ "eventOrder": [+ "event.test.js",+ "event.prerequest.js"+ ]+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/event.test.js b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/event.test.jsnew file mode 100644index 0000000000..cd3df41663--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/event.test.js@@ -0,0 +1,31 @@+// Validate status 400+pm.test("[POST]::/payments - Status code is 400", function () {+ pm.response.to.be.error+});++// Validate if response header has matching content-type+pm.test("[POST]::/payments - 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]::/payments - 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) { }++if (jsonData?.error?.message) {+ pm.test(+ "[POST]::/payments - Content check for error message to equal `Invalid Expiry Year`",+ function () {+ pm.expect(jsonData.error.message).to.eql("Invalid Expiry Year");+ },+ );+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/request.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/request.jsonnew file mode 100644index 0000000000..63eda0afbe--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/request.json@@ -0,0 +1,41 @@+{+ "method": "POST",+ "header": [+ {+ "key": "Content-Type",+ "value": "application/json"+ },+ {+ "key": "Accept",+ "value": "application/json"+ }+ ],+ "body": {+ "mode": "raw",+ "options": {+ "raw": {+ "language": "json"+ }+ },+ "raw_json_formatted": {+ "amount": 6540,+ "currency": "USD",+ "payment_method": "card",+ "payment_method_data": {+ "card": {+ "card_number": "4242424242424242",+ "card_exp_month": "10",+ "card_exp_year": "22",+ "card_holder_name": "joseph Doe",+ "card_cvc": "123"+ }+ }+ }+ },+ "url": {+ "raw": "{{baseUrl}}/payments",+ "host": ["{{baseUrl}}"],+ "path": ["payments"]+ },+ "description": "Create a Payment to ensure api contract is intact"+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Success/.event.meta.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Success/.event.meta.jsonnew file mode 100644index 0000000000..4ac527d834--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Success/.event.meta.json@@ -0,0 +1,6 @@+{+ "eventOrder": [+ "event.test.js",+ "event.prerequest.js"+ ]+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Success/event.test.js b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Success/event.test.jsnew file mode 100644index 0000000000..600ad2ed90--- /dev/null+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Success/event.test.js@@ -0,0 +1,33 @@+// Validate status 2xx+pm.test("[POST]::/payments - Status code is 2xx", function () {+ pm.response.to.be.success;+});++// Validate if response header has matching content-type+pm.test("[POST]::/payments - 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]::/payments - 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 value "requires_payment_method" for "status"+if (jsonData?.status) {+ pm.test(+ "[POST]::/payments - Content check if value for 'status' matches 'requires_confirmation'",+ function () {+ pm.expect(jsonData.status).to.eql("requires_confirmation");+ },+ );+}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method/request.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Success/request.jsonsimilarity index 100%rename from postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method/request.jsonrename to postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method Success/request.jsondiff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method/event.test.js b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method/event.test.jsdeleted file mode 100644index d462b381cc..0000000000--- a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Card Payment Method/event.test.js+++ /dev/null@@ -1,9 +0,0 @@-// Validate status 2xx-pm.test("[POST]::/payments - Status code is 2xx", function () {- pm.response.to.be.success;-});--// Validate if response has JSON Body-pm.test("[POST]::/payments - Response has JSON Body", function () {- pm.response.to.have.jsonBody();-});\ No newline at end of filediff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Reward Payment Method/event.test.js b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Reward Payment Method/event.test.jsindex 0444324000..c899ee4eb0 100644--- a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Reward Payment Method/event.test.js+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Reward Payment Method/event.test.js@@ -19,53 +19,14 @@ pm.test("[POST]::/payments - Response has JSON Body", function () {let jsonData = {};try {jsonData = pm.response.json();-} catch (e) {}--// pm.collectionVariables - Set payment_id as variable for jsonData.payment_id-if (jsonData?.payment_id) {- pm.collectionVariables.set("payment_id", jsonData.payment_id);- console.log(- "- use {{payment_id}} as collection variable for value",- jsonData.payment_id,- );-} else {- console.log(- "INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined.",- );-}--// pm.collectionVariables - Set mandate_id as variable for jsonData.mandate_id-if (jsonData?.mandate_id) {- pm.collectionVariables.set("mandate_id", jsonData.mandate_id);- console.log(- "- use {{mandate_id}} as collection variable for value",- jsonData.mandate_id,- );-} else {- console.log(- "INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined.",- );-}--// pm.collectionVariables - Set client_secret as variable for jsonData.client_secret-if (jsonData?.client_secret) {- pm.collectionVariables.set("client_secret", jsonData.client_secret);- console.log(- "- use {{client_secret}} as collection variable for value",- jsonData.client_secret,- );-} else {- console.log(- "INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined.",- );-}+} catch (e) { }// Response body should have value "requires_payment_method" for "status"if (jsonData?.status) {pm.test(- "[POST]::/payments - Content check if value for 'status' matches 'requires_payment_method'",+ "[POST]::/payments - Content check if value for 'status' matches 'requires_confirmation'",function () {- pm.expect(jsonData.status).to.eql("requires_payment_method");+ pm.expect(jsonData.status).to.eql("requires_confirmation");},);}diff --git a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Reward Payment Method/request.json b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Reward Payment Method/request.jsonindex e5797a68e1..52c5f91109 100644--- a/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Reward Payment Method/request.json+++ b/postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario32-Ensure API Contract for Payment Method Data/Payments - Reward Payment Method/request.json@@ -19,7 +19,10 @@},"raw_json_formatted": {"amount": 6540,- "currency": "USD"+ "currency": "USD",+ "payment_method": "reward",+ "payment_method_type": "evoucher",+ "payment_method_data": "reward"}},"url": {diff --git a/postman/collection-json/stripe.postman_collection.json b/postman/collection-json/stripe.postman_collection.jsonindex 497d1c3669..c3d6371fd7 100644--- a/postman/collection-json/stripe.postman_collection.json+++ b/postman/collection-json/stripe.postman_collection.json@@ -21800,21 +21800,39 @@"name": "Scenario32-Ensure API Contract for Payment Method Data","item": [{- "name": "Payments - Card Payment Method",+ "name": "Payments - Card Payment Method Invalid Card CVC","event": [{"listen": "test","script": {"exec": [- "// Validate status 2xx",- "pm.test(\"[POST]::/payments - Status code is 2xx\", function () {",- " pm.response.to.be.success;",+ "// Validate status 400",+ "pm.test(\"[POST]::/payments - Status code is 400\", function () {",+ " pm.response.to.be.error",+ "});",+ "",+ "// Validate if response header has matching content-type",+ "pm.test(\"[POST]::/payments - 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]::/payments - 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) { }",+ "",+ "pm.test(\"[POST]::/payments - Response has appropriate error message\", function () {",+ " pm.expect(jsonData.error.message).eql(\"Invalid card_cvc length\");",+ "})",+ ""],"type": "text/javascript"}@@ -21839,7 +21857,7 @@"language": "json"}},- "raw": "{\"amount\":6540,\"currency\":\"USD\",\"payment_method\":\"card\",\"payment_method_data\":{\"card\":{\"card_number\":\"4242424242424242\",\"card_exp_month\":\"10\",\"card_exp_year\":\"25\",\"card_holder_name\":\"joseph Doe\",\"card_cvc\":\"123\"}}}"+ "raw": "{\"amount\":6540,\"currency\":\"USD\",\"payment_method\":\"card\",\"payment_method_data\":{\"card\":{\"card_number\":\"4242424242424242\",\"card_exp_month\":\"10\",\"card_exp_year\":\"25\",\"card_holder_name\":\"joseph Doe\",\"card_cvc\":\"\"}}}"},"url": {"raw": "{{baseUrl}}/payments",@@ -21854,15 +21872,77 @@}},{- "name": "Payments - Reward Payment Method",+ "name": "Payments - Card Payment Method Invalid Card Number","event": [{"listen": "test","script": {"exec": [- "// Validate status 2xx",- "pm.test(\"[POST]::/payments - Status code is 2xx\", function () {",- " pm.response.to.be.success;",+ "// Validate status 400",+ "pm.test(\"[POST]::/payments - Status code is 400\", function () {",+ " pm.response.to.be.error",+ "});",+ "",+ "// Validate if response header has matching content-type",+ "pm.test(\"[POST]::/payments - 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]::/payments - Response has JSON Body\", function () {",+ " pm.response.to.have.jsonBody();",+ "});",+ ""+ ],+ "type": "text/javascript"+ }+ }+ ],+ "request": {+ "method": "POST",+ "header": [+ {+ "key": "Content-Type",+ "value": "application/json"+ },+ {+ "key": "Accept",+ "value": "application/json"+ }+ ],+ "body": {+ "mode": "raw",+ "options": {+ "raw": {+ "language": "json"+ }+ },+ "raw": "{\"amount\":6540,\"currency\":\"USD\",\"payment_method\":\"card\",\"payment_method_data\":{\"card\":{\"card_number\":\"1234\",\"card_exp_month\":\"10\",\"card_exp_year\":\"25\",\"card_holder_name\":\"joseph Doe\",\"card_cvc\":\"123\"}}}"+ },+ "url": {+ "raw": "{{baseUrl}}/payments",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "payments"+ ]+ },+ "description": "Create a Payment to ensure api contract is intact"+ }+ },+ {+ "name": "Payments - Card Payment Method Invalid Expiry month",+ "event": [+ {+ "listen": "test",+ "script": {+ "exec": [+ "// Validate status 400",+ "pm.test(\"[POST]::/payments - Status code is 400\", function () {",+ " pm.response.to.be.error","});","","// Validate if response header has matching content-type",@@ -21881,53 +21961,242 @@"let jsonData = {};","try {"," jsonData = pm.response.json();",- "} catch (e) {}",+ "} catch (e) { }","",- "// pm.collectionVariables - Set payment_id as variable for jsonData.payment_id",- "if (jsonData?.payment_id) {",- " pm.collectionVariables.set(\"payment_id\", jsonData.payment_id);",- " console.log(",- " \"- use {{payment_id}} as collection variable for value\",",- " jsonData.payment_id,",+ "pm.test(\"[POST]::/payments - Response has appropriate error message\", function () {",+ " pm.expect(jsonData.error.message).eql(\"Invalid Expiry Month\");",+ "})",+ ""+ ],+ "type": "text/javascript"+ }+ }+ ],+ "request": {+ "method": "POST",+ "header": [+ {+ "key": "Content-Type",+ "value": "application/json"+ },+ {+ "key": "Accept",+ "value": "application/json"+ }+ ],+ "body": {+ "mode": "raw",+ "options": {+ "raw": {+ "language": "json"+ }+ },+ "raw": "{\"amount\":6540,\"currency\":\"USD\",\"payment_method\":\"card\",\"payment_method_data\":{\"card\":{\"card_number\":\"4242424242424242\",\"card_exp_month\":\"13\",\"card_exp_year\":\"69\",\"card_holder_name\":\"joseph Doe\",\"card_cvc\":\"123\"}}}"+ },+ "url": {+ "raw": "{{baseUrl}}/payments",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "payments"+ ]+ },+ "description": "Create a Payment to ensure api contract is intact"+ }+ },+ {+ "name": "Payments - Card Payment Method Invalid Expiry year",+ "event": [+ {+ "listen": "test",+ "script": {+ "exec": [+ "// Validate status 400",+ "pm.test(\"[POST]::/payments - Status code is 400\", function () {",+ " pm.response.to.be.error",+ "});",+ "",+ "// Validate if response header has matching content-type",+ "pm.test(\"[POST]::/payments - Content-Type is application/json\", function () {",+ " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",+ " \"application/json\","," );",- "} else {",- " console.log(",- " \"INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined.\",",+ "});",+ "",+ "// Validate if response has JSON Body",+ "pm.test(\"[POST]::/payments - 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) { }",+ "",+ "if (jsonData?.error?.message) {",+ " pm.test(",+ " \"[POST]::/payments - Content check for error message to equal `Invalid Expiry Year`\",",+ " function () {",+ " pm.expect(jsonData.error.message).to.eql(\"Invalid Expiry Year\");",+ " },"," );","}",+ ""+ ],+ "type": "text/javascript"+ }+ }+ ],+ "request": {+ "method": "POST",+ "header": [+ {+ "key": "Content-Type",+ "value": "application/json"+ },+ {+ "key": "Accept",+ "value": "application/json"+ }+ ],+ "body": {+ "mode": "raw",+ "options": {+ "raw": {+ "language": "json"+ }+ },+ "raw": "{\"amount\":6540,\"currency\":\"USD\",\"payment_method\":\"card\",\"payment_method_data\":{\"card\":{\"card_number\":\"4242424242424242\",\"card_exp_month\":\"10\",\"card_exp_year\":\"22\",\"card_holder_name\":\"joseph Doe\",\"card_cvc\":\"123\"}}}"+ },+ "url": {+ "raw": "{{baseUrl}}/payments",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "payments"+ ]+ },+ "description": "Create a Payment to ensure api contract is intact"+ }+ },+ {+ "name": "Payments - Card Payment Method Success",+ "event": [+ {+ "listen": "test",+ "script": {+ "exec": [+ "// Validate status 2xx",+ "pm.test(\"[POST]::/payments - Status code is 2xx\", function () {",+ " pm.response.to.be.success;",+ "});","",- "// pm.collectionVariables - Set mandate_id as variable for jsonData.mandate_id",- "if (jsonData?.mandate_id) {",- " pm.collectionVariables.set(\"mandate_id\", jsonData.mandate_id);",- " console.log(",- " \"- use {{mandate_id}} as collection variable for value\",",- " jsonData.mandate_id,",+ "// Validate if response header has matching content-type",+ "pm.test(\"[POST]::/payments - Content-Type is application/json\", function () {",+ " pm.expect(pm.response.headers.get(\"Content-Type\")).to.include(",+ " \"application/json\","," );",- "} else {",- " console.log(",- " \"INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined.\",",+ "});",+ "",+ "// Validate if response has JSON Body",+ "pm.test(\"[POST]::/payments - 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 value \"requires_payment_method\" for \"status\"",+ "if (jsonData?.status) {",+ " pm.test(",+ " \"[POST]::/payments - Content check if value for 'status' matches 'requires_confirmation'\",",+ " function () {",+ " pm.expect(jsonData.status).to.eql(\"requires_confirmation\");",+ " },"," );","}",+ ""+ ],+ "type": "text/javascript"+ }+ }+ ],+ "request": {+ "method": "POST",+ "header": [+ {+ "key": "Content-Type",+ "value": "application/json"+ },+ {+ "key": "Accept",+ "value": "application/json"+ }+ ],+ "body": {+ "mode": "raw",+ "options": {+ "raw": {+ "language": "json"+ }+ },+ "raw": "{\"amount\":6540,\"currency\":\"USD\",\"payment_method\":\"card\",\"payment_method_data\":{\"card\":{\"card_number\":\"4242424242424242\",\"card_exp_month\":\"10\",\"card_exp_year\":\"25\",\"card_holder_name\":\"joseph Doe\",\"card_cvc\":\"123\"}}}"+ },+ "url": {+ "raw": "{{baseUrl}}/payments",+ "host": [+ "{{baseUrl}}"+ ],+ "path": [+ "payments"+ ]+ },+ "description": "Create a Payment to ensure api contract is intact"+ }+ },+ {+ "name": "Payments - Reward Payment Method",+ "event": [+ {+ "listen": "test",+ "script": {+ "exec": [+ "// Validate status 2xx",+ "pm.test(\"[POST]::/payments - Status code is 2xx\", function () {",+ " pm.response.to.be.success;",+ "});","",- "// pm.collectionVariables - Set client_secret as variable for jsonData.client_secret",- "if (jsonData?.client_secret) {",- " pm.collectionVariables.set(\"client_secret\", jsonData.client_secret);",- " console.log(",- " \"- use {{client_secret}} as collection variable for value\",",- " jsonData.client_secret,",- " );",- "} else {",- " console.log(",- " \"INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined.\",",+ "// Validate if response header has matching content-type",+ "pm.test(\"[POST]::/payments - 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]::/payments - 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 value \"requires_payment_method\" for \"status\"","if (jsonData?.status) {"," pm.test(",- " \"[POST]::/payments - Content check if value for 'status' matches 'requires_payment_method'\",",+ " \"[POST]::/payments - Content check if value for 'status' matches 'requires_confirmation'\","," function () {",- " pm.expect(jsonData.status).to.eql(\"requires_payment_method\");",+ " pm.expect(jsonData.status).to.eql(\"requires_confirmation\");"," },"," );","}",@@ -21956,7 +22225,7 @@"language": "json"}},- "raw": "{\"amount\":6540,\"currency\":\"USD\"}"+ "raw": "{\"amount\":6540,\"currency\":\"USD\",\"payment_method\":\"reward\",\"payment_method_type\":\"evoucher\",\"payment_method_data\":\"reward\"}"},"url": {"raw": "{{baseUrl}}/payments",