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

feat(connector): Add Peachpayments Cypress (#9573)

Anurage03c0096d3f3
diff --git a/crates/hyperswitch_connectors/src/connectors/peachpayments.rs b/crates/hyperswitch_connectors/src/connectors/peachpayments.rs
index abc8caf1ef..dd5c4869cf 100644
--- a/crates/hyperswitch_connectors/src/connectors/peachpayments.rs
+++ b/crates/hyperswitch_connectors/src/connectors/peachpayments.rs
@@ -171,6 +171,16 @@ impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken>
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
for Peachpayments
{
+ fn build_request(
+ &self,
+ _req: &RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>,
+ _connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Err(errors::ConnectorError::NotImplemented(
+ "Setup Mandate flow for Peachpayments".to_string(),
+ )
+ .into())
+ }
}
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData>
diff --git a/crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs b/crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs
index 9b1776bf05..5ae02cc24c 100644
--- a/crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/peachpayments/transformers.rs
@@ -20,7 +20,7 @@ use time::{format_description::well_known::Rfc3339, OffsetDateTime};
use crate::{
types::ResponseRouterData,
- utils::{self, CardData},
+ utils::{self, CardData, RouterData as OtherRouterData},
};
//TODO: Fill the struct with respective fields
@@ -311,6 +311,14 @@ impl TryFrom<&PeachpaymentsRouterData<&PaymentsAuthorizeRouterData>>
fn try_from(
item: &PeachpaymentsRouterData<&PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
+ if item.router_data.is_three_ds() {
+ return Err(errors::ConnectorError::NotSupported {
+ message: "3DS flow".to_string(),
+ connector: "Peachpayments",
+ }
+ .into());
+ }
+
match item.router_data.request.payment_method_data.clone() {
PaymentMethodData::Card(req_card) => {
let amount_in_cents = item.amount;
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js b/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js
new file mode 100644
index 0000000000..73bfa95f6f
--- /dev/null
+++ b/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js
@@ -0,0 +1,648 @@
+import { customerAcceptance } from "./Commons";
+import { getCustomExchange } from "./Modifiers";
+
+const successfulNo3DSCardDetails = {
+ card_number: "4242424242424242",
+ card_exp_month: "10",
+ card_exp_year: "25",
+ card_holder_name: "John",
+ card_cvc: "123",
+};
+
+const successfulThreeDSTestCardDetails = {
+ card_number: "4242424242424242",
+ card_exp_month: "10",
+ card_exp_year: "25",
+ card_holder_name: "Joseph",
+ card_cvc: "123",
+};
+
+const singleUseMandateData = {
+ customer_acceptance: customerAcceptance,
+ mandate_type: {
+ single_use: {
+ amount: 8000,
+ currency: "USD",
+ },
+ },
+};
+
+const multiUseMandateData = {
+ customer_acceptance: customerAcceptance,
+ mandate_type: {
+ multi_use: {
+ amount: 8000,
+ currency: "USD",
+ },
+ },
+};
+
+const billingAddress = {
+ address: {
+ line1: "1467",
+ line2: "Harrison Street",
+ city: "San Francisco",
+ state: "California",
+ zip: "94122",
+ country: "US",
+ first_name: "Test",
+ last_name: "User",
+ },
+ phone: {
+ number: "9123456789",
+ country_code: "+1",
+ },
+};
+
+export const connectorDetails = {
+ card_pm: {
+ PaymentIntent: {
+ Request: {
+ currency: "USD",
+ amount: 6000,
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ },
+ PaymentIntentWithShippingCost: {
+ Request: {
+ currency: "USD",
+ amount: 6000,
+ shipping_cost: 50,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ amount: 6000,
+ shipping_cost: 50,
+ },
+ },
+ },
+ PaymentConfirmWithShippingCost: {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ shipping_cost: 50,
+ amount_received: null,
+ amount: 6000,
+ net_amount: 6050,
+ error_message: "No or unknown response code",
+ },
+ },
+ },
+ "3DSManualCapture": {
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ code: "IR_19",
+ message: "Payment method type not supported",
+ reason: "3DS flow is not supported by Peachpayments",
+ type: "invalid_request",
+ },
+ },
+ },
+ },
+ // 3DS automatic capture
+ "3DSAutoCapture": {
+ config: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulThreeDSTestCardDetails,
+ },
+ amount: 6000,
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ code: "IR_19",
+ message: "Payment method type not supported",
+ reason: "automatic is not supported by peachpayments",
+ type: "invalid_request",
+ },
+ },
+ },
+ },
+ No3DSManualCapture: {
+ Request: {
+ payment_method: "card",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ billing: billingAddress,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ No3DSAutoCapture: {
+ config: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ customer_acceptance: null,
+ setup_future_usage: "on_session",
+ billing: billingAddress,
+ },
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ code: "IR_19",
+ message: "Payment method type not supported",
+ reason: "automatic is not supported by peachpayments",
+ type: "invalid_request",
+ },
+ },
+ },
+ },
+ Capture: {
+ Request: {
+ amount_to_capture: 6000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ amount: 6000,
+ amount_capturable: 0,
+ amount_received: 6000,
+ },
+ },
+ },
+ PartialCapture: {
+ Request: {
+ amount_to_capture: 2000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "partially_captured",
+ amount: 6000,
+ amount_capturable: 0,
+ amount_received: 2000,
+ },
+ },
+ },
+ Void: {
+ Request: {},
+ Response: {
+ status: 200,
+ body: {
+ status: "cancelled",
+ },
+ },
+ },
+ Refund: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ amount: 6000,
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "This Payment could not be refund because it has a status of requires_capture. The expected state is succeeded, partially_captured",
+ code: "IR_14",
+ },
+ },
+ },
+ ResponseCustom: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Execute is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ }),
+ PartialRefund: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ amount: 2000,
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message:
+ "This Payment could not be refund because it has a status of requires_capture. The expected state is succeeded, partially_captured",
+ code: "IR_14",
+ },
+ },
+ },
+ ResponseCustom: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Execute is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ }),
+ manualPaymentRefund: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ amount: 6000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ ResponseCustom: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Execute is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ }),
+ manualPaymentPartialRefund: getCustomExchange({
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ amount: 2000,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ ResponseCustom: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Execute is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ }),
+ SyncRefund: {
+ Response: {
+ status: 200,
+ body: {
+ status: "failed",
+ },
+ },
+ },
+ ZeroAuthMandate: {
+ Response: {
+ status: 501,
+ body: {
+ error: {
+ code: "IR_00",
+ message: "Setup Mandate flow for Peachpayments is not implemented",
+ type: "invalid_request",
+ },
+ },
+ },
+ },
+ ZeroAuthPaymentIntent: {
+ Request: {
+ amount: 0,
+ setup_future_usage: "off_session",
+ currency: "USD",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ },
+ },
+ },
+ ZeroAuthConfirmPayment: {
+ Request: {
+ payment_type: "setup_mandate",
+ payment_method: "card",
+ payment_method_type: "credit",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ },
+ Response: {
+ status: 501,
+ body: {
+ error: {
+ type: "invalid_request",
+ message: "Setup Mandate flow for Peachpayments is not implemented",
+ code: "IR_00",
+ },
+ },
+ },
+ },
+ SaveCardUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ setup_future_usage: "on_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ SaveCardUseNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ amount: 6000,
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ setup_future_usage: "on_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ SaveCardUseNo3DSManualCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ setup_future_usage: "off_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ SaveCardConfirmManualCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ setup_future_usage: "off_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ SaveCardUseNo3DSAutoCaptureOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_type: "debit",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ setup_future_usage: "off_session",
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ MandateSingleUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ MandateMultiUseNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ MandateMultiUseNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: multiUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ MandateSingleUseNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: singleUseMandateData,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ PaymentMethodIdMandateNo3DSManualCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_capture",
+ },
+ },
+ },
+ MITAutoCapture: {
+ config: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {},
+ Response: {
+ status: 400,
+ body: {
+ error: {
+ code: "IR_19",
+ message: "Payment method type not supported",
+ reason: "automatic is not supported by peachpayments",
+ type: "invalid_request",
+ },
+ },
+ },
+ },
+ PaymentMethodIdMandateNo3DSAutoCapture: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ payment_method: "card",
+ payment_method_data: {
+ card: successfulNo3DSCardDetails,
+ },
+ currency: "USD",
+ mandate_data: null,
+ customer_acceptance: customerAcceptance,
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "succeeded",
+ },
+ },
+ },
+ PaymentIntentOffSession: {
+ Configs: {
+ TRIGGER_SKIP: true,
+ },
+ Request: {
+ currency: "EUR",
+ amount: 6000,
+ authentication_type: "no_three_ds",
+ customer_acceptance: null,
+ setup_future_usage: "off_session",
+ },
+ Response: {
+ status: 200,
+ body: {
+ status: "requires_payment_method",
+ setup_future_usage: "off_session",
+ },
+ },
+ },
+ },
+};
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Utils.js b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
index 90166c488e..62d7df0f69 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Utils.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Utils.js
@@ -47,6 +47,7 @@ import { connectorDetails as payloadConnectorDetails } from "./Payload.js";
import { connectorDetails as paypalConnectorDetails } from "./Paypal.js";
import { connectorDetails as paysafeConnectorDetails } from "./Paysafe.js";
import { connectorDetails as payuConnectorDetails } from "./Payu.js";
+import { connectorDetails as peachpaymentsConnectorDetails } from "./Peachpayments.js";
import { connectorDetails as powertranzConnectorDetails } from "./PowerTranz.js";
import { connectorDetails as redsysConnectorDetails } from "./Redsys.js";
import { connectorDetails as shift4ConnectorDetails } from "./Shift4.js";
@@ -110,6 +111,7 @@ const connectorDetails = {
paypal: paypalConnectorDetails,
paysafe: paysafeConnectorDetails,
payu: payuConnectorDetails,
+ peachpayments: peachpaymentsConnectorDetails,
powertranz: powertranzConnectorDetails,
redsys: redsysConnectorDetails,
shift4: shift4ConnectorDetails,
diff --git a/cypress-tests/cypress/e2e/spec/Payment/00009-RefundPayment.cy.js b/cypress-tests/cypress/e2e/spec/Payment/00009-RefundPayment.cy.js
index cb67a6cd05..2e157a91b8 100644
--- a/cypress-tests/cypress/e2e/spec/Payment/00009-RefundPayment.cy.js
+++ b/cypress-tests/cypress/e2e/spec/Payment/00009-RefundPayment.cy.js
@@ -362,7 +362,12 @@ describe("Card - Refund flow - No 3DS", () => {
"card_pm"
]["manualPaymentRefund"];
- cy.refundCallTest(fixtures.refundBody, data, globalState);
+ const newData = {
+ ...data,
+ Response: data.ResponseCustom || data.Response,
+ };
+
+ cy.refundCallTest(fixtures.refundBody, newData, globalState);
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});
@@ -448,7 +453,12 @@ describe("Card - Refund flow - No 3DS", () => {
"card_pm"
]["manualPaymentPartialRefund"];
- cy.refundCallTest(fixtures.refundBody, data, globalState);
+ const newData = {
+ ...data,
+ Response: data.ResponseCustom || data.Response,
+ };
+
+ cy.refundCallTest(fixtures.refundBody, newData, globalState);
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});
@@ -546,7 +556,12 @@ describe("Card - Refund flow - No 3DS", () => {
"card_pm"
]["manualPaymentPartialRefund"];
- cy.refundCallTest(fixtures.refundBody, data, globalState);
+ const newData = {
+ ...data,
+ Response: data.ResponseCustom || data.Response,
+ };
+
+ cy.refundCallTest(fixtures.refundBody, newData, globalState);
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});
@@ -632,7 +647,12 @@ describe("Card - Refund flow - No 3DS", () => {
"card_pm"
]["manualPaymentPartialRefund"];
- cy.refundCallTest(fixtures.refundBody, data, globalState);
+ const newData = {
+ ...data,
+ Response: data.ResponseCustom || data.Response,
+ };
+
+ cy.refundCallTest(fixtures.refundBody, newData, globalState);
if (shouldContinue) shouldContinue = utils.should_continue_further(data);
});