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): [Peach Payments] Add Automatic Capture Flow for Peach Payments (#10270)

Anurag11f08eafc898
diff --git a/crates/hyperswitch_connectors/src/connectors/peachpayments.rs b/crates/hyperswitch_connectors/src/connectors/peachpayments.rs
index d319f25b0b..d7f017db61 100644
--- a/crates/hyperswitch_connectors/src/connectors/peachpayments.rs
+++ b/crates/hyperswitch_connectors/src/connectors/peachpayments.rs
@@ -2,7 +2,7 @@ pub mod transformers;
use std::sync::LazyLock;
-use common_enums::{self, enums};
+use common_enums::{self, enums, CaptureMethod};
use common_utils::{
errors::CustomResult,
ext_traits::{ByteSliceExt, BytesExt},
@@ -205,10 +205,21 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
fn get_url(
&self,
- _req: &PaymentsAuthorizeRouterData,
+ req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Ok(format!("{}/transactions", self.base_url(connectors)))
+ match req.request.capture_method.unwrap_or_default() {
+ CaptureMethod::Automatic => Ok(format!(
+ "{}/transactions/create-and-confirm",
+ self.base_url(connectors)
+ )),
+ CaptureMethod::Manual => Ok(format!("{}/transactions", self.base_url(connectors))),
+ CaptureMethod::ManualMultiple
+ | CaptureMethod::Scheduled
+ | CaptureMethod::SequentialAutomatic => {
+ Err(errors::ConnectorError::CaptureMethodNotSupported.into())
+ }
+ }
}
fn get_request_body(
@@ -762,10 +773,7 @@ impl webhooks::IncomingWebhook for Peachpayments {
static PEACHPAYMENTS_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
LazyLock::new(|| {
- let supported_capture_methods = vec![
- enums::CaptureMethod::Manual,
- enums::CaptureMethod::SequentialAutomatic,
- ];
+ let supported_capture_methods = vec![CaptureMethod::Automatic, CaptureMethod::Manual];
let supported_card_network = vec![
common_enums::CardNetwork::Visa,
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js b/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js
index ecf55c6b0c..c2d4ff00c1 100644
--- a/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js
+++ b/cypress-tests/cypress/e2e/configs/Payment/Peachpayments.js
@@ -1,19 +1,19 @@
import { customerAcceptance } from "./Commons";
const successfulNo3DSCardDetails = {
- card_number: "4242424242424242",
- card_exp_month: "10",
- card_exp_year: "25",
+ card_number: "5181030000183696",
+ card_exp_month: "01",
+ card_exp_year: "28",
card_holder_name: "John",
- card_cvc: "123",
+ card_cvc: "576",
};
const successfulThreeDSTestCardDetails = {
- card_number: "4242424242424242",
- card_exp_month: "10",
- card_exp_year: "25",
+ card_number: "5181030000183696",
+ card_exp_month: "01",
+ card_exp_year: "28",
card_holder_name: "Joseph",
- card_cvc: "123",
+ card_cvc: "576",
};
const singleUseMandateData = {
@@ -96,12 +96,11 @@ export const connectorDetails = {
Response: {
status: 200,
body: {
- status: "failed",
+ status: "succeeded",
shipping_cost: 50,
- amount_received: null,
+ amount_received: 6050,
amount: 6000,
net_amount: 6050,
- error_message: "No or unknown response code",
},
},
},
@@ -174,9 +173,6 @@ export const connectorDetails = {
},
},
No3DSAutoCapture: {
- config: {
- TRIGGER_SKIP: true,
- },
Request: {
payment_method: "card",
amount: 6000,
@@ -189,14 +185,9 @@ export const connectorDetails = {
billing: billingAddress,
},
Response: {
- status: 400,
+ status: 200,
body: {
- error: {
- code: "IR_19",
- message: "Payment method type not supported",
- reason: "automatic is not supported by peachpayments",
- type: "invalid_request",
- },
+ status: "succeeded",
},
},
},