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): [xendit] add QRIS payment methods (#10759)

AkshayaFoiger4abbf30772f7
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 22444a4251..a182aa9a18 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -26667,6 +26667,7 @@
"przelewy24",
"prompt_pay",
"pse",
+ "qris",
"red_compra",
"red_pagos",
"samsung_pay",
@@ -34116,6 +34117,17 @@
"type": "object"
}
}
+ },
+ {
+ "type": "object",
+ "required": [
+ "qris"
+ ],
+ "properties": {
+ "qris": {
+ "type": "object"
+ }
+ }
}
]
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 2bea87699b..b834e5ebad 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -20159,6 +20159,7 @@
"przelewy24",
"prompt_pay",
"pse",
+ "qris",
"red_compra",
"red_pagos",
"samsung_pay",
@@ -24483,6 +24484,17 @@
"type": "object"
}
}
+ },
+ {
+ "type": "object",
+ "required": [
+ "qris"
+ ],
+ "properties": {
+ "qris": {
+ "type": "object"
+ }
+ }
}
]
},
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 3274ac0205..1f4c89ad85 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -3828,6 +3828,7 @@ impl GetPaymentMethodType for RealTimePaymentData {
Self::DuitNow {} => api_enums::PaymentMethodType::DuitNow,
Self::PromptPay {} => api_enums::PaymentMethodType::PromptPay,
Self::VietQr {} => api_enums::PaymentMethodType::VietQr,
+ Self::Qris {} => api_enums::PaymentMethodType::Qris,
}
}
}
@@ -4864,6 +4865,8 @@ pub enum RealTimePaymentData {
PromptPay {},
#[smithy(nested_value_type)]
VietQr {},
+ #[smithy(nested_value_type)]
+ Qris {},
}
impl GetAddressFromPaymentMethodData for BankTransferData {
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index cbc4b7075b..a32af5b963 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -2328,6 +2328,7 @@ pub enum PaymentMethodType {
Przelewy24,
PromptPay,
Pse,
+ Qris,
RedCompra,
RedPagos,
SamsungPay,
@@ -2430,6 +2431,7 @@ impl PaymentMethodType {
Self::InstantBankTransfer => "Instant Bank Transfer",
Self::InstantBankTransferFinland => "Instant Bank Transfer Finland",
Self::InstantBankTransferPoland => "Instant Bank Transfer Poland",
+ Self::Qris => "QRIS",
Self::Klarna => "Klarna",
Self::KakaoPay => "KakaoPay",
Self::LocalBankRedirect => "Local Bank Redirect",
diff --git a/crates/common_enums/src/transformers.rs b/crates/common_enums/src/transformers.rs
index 975d155860..981307a2b5 100644
--- a/crates/common_enums/src/transformers.rs
+++ b/crates/common_enums/src/transformers.rs
@@ -1839,6 +1839,7 @@ impl From<PaymentMethodType> for PaymentMethod {
PaymentMethodType::Gcash => Self::Wallet,
PaymentMethodType::Mifinity => Self::Wallet,
PaymentMethodType::Ideal => Self::BankRedirect,
+ PaymentMethodType::Qris => Self::RealTimePayment,
PaymentMethodType::Klarna => Self::PayLater,
PaymentMethodType::KakaoPay => Self::Wallet,
PaymentMethodType::Knet => Self::CardRedirect,
diff --git a/crates/euclid/src/frontend/dir/enums.rs b/crates/euclid/src/frontend/dir/enums.rs
index 9f3f541e08..4759ad447f 100644
--- a/crates/euclid/src/frontend/dir/enums.rs
+++ b/crates/euclid/src/frontend/dir/enums.rs
@@ -351,6 +351,7 @@ pub enum RealTimePaymentType {
DuitNow,
PromptPay,
VietQr,
+ Qris,
}
#[derive(
diff --git a/crates/euclid/src/frontend/dir/lowering.rs b/crates/euclid/src/frontend/dir/lowering.rs
index 0406059677..c915f3590e 100644
--- a/crates/euclid/src/frontend/dir/lowering.rs
+++ b/crates/euclid/src/frontend/dir/lowering.rs
@@ -236,6 +236,7 @@ impl From<enums::RealTimePaymentType> for global_enums::PaymentMethodType {
enums::RealTimePaymentType::DuitNow => Self::DuitNow,
enums::RealTimePaymentType::PromptPay => Self::PromptPay,
enums::RealTimePaymentType::VietQr => Self::VietQr,
+ enums::RealTimePaymentType::Qris => Self::Qris,
}
}
}
diff --git a/crates/euclid/src/frontend/dir/transformers.rs b/crates/euclid/src/frontend/dir/transformers.rs
index 745be92146..6da1b5b03f 100644
--- a/crates/euclid/src/frontend/dir/transformers.rs
+++ b/crates/euclid/src/frontend/dir/transformers.rs
@@ -177,6 +177,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
global_enums::PaymentMethodType::InstantBankTransferPoland => {
Ok(dirval!(BankTransferType = InstantBankTransferPoland))
}
+ global_enums::PaymentMethodType::Qris => Ok(dirval!(RealTimePaymentType = Qris)),
global_enums::PaymentMethodType::PermataBankTransfer => {
Ok(dirval!(BankTransferType = PermataBankTransfer))
}
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen.rs b/crates/hyperswitch_connectors/src/connectors/adyen.rs
index 24843343c6..059c3de445 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen.rs
@@ -348,6 +348,7 @@ impl ConnectorValidation for Adyen {
| PaymentMethodType::InstantBankTransferFinland
| PaymentMethodType::InstantBankTransferPoland
| PaymentMethodType::IndonesianBankTransfer
+ | PaymentMethodType::Qris
| PaymentMethodType::SepaBankTransfer
| PaymentMethodType::Flexiti
| PaymentMethodType::RevolutPay
diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs b/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
index e6fd1d81e7..44c5fb3dd1 100644
--- a/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
@@ -496,7 +496,8 @@ impl TryFrom<&FiuuRouterData<&PaymentsAuthorizeRouterData>> for FiuuPaymentReque
}
RealTimePaymentData::Fps {}
| RealTimePaymentData::PromptPay {}
- | RealTimePaymentData::VietQr {} => {
+ | RealTimePaymentData::VietQr {}
+ | RealTimePaymentData::Qris {} => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("fiuu"),
)
diff --git a/crates/hyperswitch_connectors/src/connectors/iatapay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/iatapay/transformers.rs
index a4087aefd6..6a1458b5fc 100644
--- a/crates/hyperswitch_connectors/src/connectors/iatapay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/iatapay/transformers.rs
@@ -194,6 +194,9 @@ impl
(common_enums::CountryAlpha2::TH, None, None)
}
RealTimePaymentData::VietQr {} => (common_enums::CountryAlpha2::VN, None, None),
+ RealTimePaymentData::Qris {} => Err(errors::ConnectorError::NotImplemented(
+ get_unimplemented_payment_method_error_message("iatapay"),
+ ))?,
}
}
PaymentMethodData::Card(_)
diff --git a/crates/hyperswitch_connectors/src/connectors/klarna.rs b/crates/hyperswitch_connectors/src/connectors/klarna.rs
index 085b350fcb..b907635c86 100644
--- a/crates/hyperswitch_connectors/src/connectors/klarna.rs
+++ b/crates/hyperswitch_connectors/src/connectors/klarna.rs
@@ -641,6 +641,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
| common_enums::PaymentMethodType::InstantBankTransfer
| common_enums::PaymentMethodType::InstantBankTransferFinland
| common_enums::PaymentMethodType::InstantBankTransferPoland
+ | common_enums::PaymentMethodType::Qris
| common_enums::PaymentMethodType::MiniStop
| common_enums::PaymentMethodType::FamilyMart
| common_enums::PaymentMethodType::Seicomart
@@ -746,6 +747,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
| common_enums::PaymentMethodType::PaySafeCard
| common_enums::PaymentMethodType::Przelewy24
| common_enums::PaymentMethodType::Pse
+ | common_enums::PaymentMethodType::Qris
| common_enums::PaymentMethodType::RedCompra
| common_enums::PaymentMethodType::RedPagos
| common_enums::PaymentMethodType::SamsungPay
@@ -919,6 +921,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
| common_enums::PaymentMethodType::Flexiti
| common_enums::PaymentMethodType::OpenBankingPIS
| common_enums::PaymentMethodType::IndonesianBankTransfer
+ | common_enums::PaymentMethodType::Qris
| common_enums::PaymentMethodType::RevolutPay
| common_enums::PaymentMethodType::Breadpay
| common_enums::PaymentMethodType::Payjustnow
@@ -1012,6 +1015,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
| common_enums::PaymentMethodType::PaySafeCard
| common_enums::PaymentMethodType::Przelewy24
| common_enums::PaymentMethodType::Pse
+ | common_enums::PaymentMethodType::Qris
| common_enums::PaymentMethodType::RedCompra
| common_enums::PaymentMethodType::RedPagos
| common_enums::PaymentMethodType::SamsungPay
diff --git a/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs b/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
index 29c7e4c791..32cee396c9 100644
--- a/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paypal/transformers.rs
@@ -1271,6 +1271,7 @@ impl TryFrom<&PaypalRouterData<&PaymentsAuthorizeRouterData>> for PaypalPayments
| enums::PaymentMethodType::Przelewy24
| enums::PaymentMethodType::PromptPay
| enums::PaymentMethodType::Pse
+ | enums::PaymentMethodType::Qris
| enums::PaymentMethodType::RedCompra
| enums::PaymentMethodType::RedPagos
| enums::PaymentMethodType::SamsungPay
diff --git a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
index 2d899f3dda..6630fa3e77 100644
--- a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs
@@ -879,6 +879,7 @@ impl TryFrom<enums::PaymentMethodType> for StripePaymentMethodType {
| enums::PaymentMethodType::PermataBankTransfer
| enums::PaymentMethodType::PaySafeCard
| enums::PaymentMethodType::Paze
+ | enums::PaymentMethodType::Qris
| enums::PaymentMethodType::Givex
| enums::PaymentMethodType::Benefit
| enums::PaymentMethodType::Knet
diff --git a/crates/hyperswitch_connectors/src/connectors/xendit.rs b/crates/hyperswitch_connectors/src/connectors/xendit.rs
index 681307de9c..eb914af8b2 100644
--- a/crates/hyperswitch_connectors/src/connectors/xendit.rs
+++ b/crates/hyperswitch_connectors/src/connectors/xendit.rs
@@ -255,10 +255,14 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
fn get_url(
&self,
- _req: &PaymentsAuthorizeRouterData,
+ req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Ok(format!("{}/payment_requests", self.base_url(connectors)))
+ let base_url = self.base_url(connectors);
+ match req.request.payment_method_type {
+ Some(PaymentMethodType::Qris) => Ok(format!("{}/qr_codes", base_url)),
+ _ => Ok(format!("{}/payment_requests", self.base_url(connectors))),
+ }
}
fn get_request_body(
@@ -308,7 +312,11 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
let response_integrity_object = connector_utils::get_authorise_integrity_object(
self.amount_converter,
response.amount,
- response.currency.to_string().clone(),
+ response
+ .currency
+ .unwrap_or(data.request.currency)
+ .to_string()
+ .clone(),
)?;
event_builder.map(|i| i.set_response_body(&response));
@@ -504,13 +512,27 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Xen
xendit::XenditResponse::Payment(p) => connector_utils::get_sync_integrity_object(
self.amount_converter,
p.amount,
- p.currency.to_string().clone(),
- ),
- xendit::XenditResponse::Webhook(p) => connector_utils::get_sync_integrity_object(
- self.amount_converter,
- p.data.amount,
- p.data.currency.to_string().clone(),
+ p.currency
+ .unwrap_or(data.request.currency)
+ .to_string()
+ .clone(),
),
+ xendit::XenditResponse::Webhook(webhook_response_data) => match webhook_response_data {
+ XenditWebhookEvent::CommonEvent(event_data) => {
+ connector_utils::get_sync_integrity_object(
+ self.amount_converter,
+ event_data.data.amount,
+ event_data.data.currency.clone(),
+ )
+ }
+ XenditWebhookEvent::QrEvent(xendit_qris_webhook_response_data) => {
+ connector_utils::get_sync_integrity_object(
+ self.amount_converter,
+ xendit_qris_webhook_response_data.amount,
+ data.request.currency.to_string(),
+ )
+ }
+ },
};
event_builder.map(|i| i.set_response_body(&response));
@@ -902,23 +924,36 @@ impl webhooks::IncomingWebhook for Xendit {
.body
.parse_struct("XenditWebhookEvent")
.change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
- match details.event {
- XenditEventType::PaymentSucceeded
- | XenditEventType::PaymentAwaitingCapture
- | XenditEventType::PaymentFailed
- | XenditEventType::CaptureSucceeded
- | XenditEventType::CaptureFailed => {
+ match details {
+ XenditWebhookEvent::CommonEvent(event_data) => match event_data.event {
+ XenditEventType::PaymentSucceeded
+ | XenditEventType::PaymentAwaitingCapture
+ | XenditEventType::PaymentFailed
+ | XenditEventType::CaptureSucceeded
+ | XenditEventType::CaptureFailed => {
+ Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
+ api_models::payments::PaymentIdType::ConnectorTransactionId(
+ event_data
+ .data
+ .payment_request_id
+ .ok_or(errors::ConnectorError::WebhookReferenceIdNotFound)?,
+ ),
+ ))
+ }
+ XenditEventType::QrPayment => {
+ Err(errors::ConnectorError::WebhookReferenceIdNotFound.into())
+ }
+ },
+ XenditWebhookEvent::QrEvent(xendit_qris_webhook_event_data) => {
Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
api_models::payments::PaymentIdType::ConnectorTransactionId(
- details
- .data
- .payment_request_id
- .ok_or(errors::ConnectorError::WebhookReferenceIdNotFound)?,
+ xendit_qris_webhook_event_data.qr_code.external_id,
),
))
}
}
}
+
fn get_webhook_event_type(
&self,
request: &webhooks::IncomingWebhookRequestDetails<'_>,
@@ -927,17 +962,23 @@ impl webhooks::IncomingWebhook for Xendit {
.body
.parse_struct("XenditWebhookEvent")
.change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
- match body.event {
- XenditEventType::PaymentSucceeded => Ok(IncomingWebhookEvent::PaymentIntentSuccess),
- XenditEventType::CaptureSucceeded => {
- Ok(IncomingWebhookEvent::PaymentIntentCaptureSuccess)
- }
- XenditEventType::PaymentAwaitingCapture => {
- Ok(IncomingWebhookEvent::PaymentIntentAuthorizationSuccess)
- }
- XenditEventType::PaymentFailed | XenditEventType::CaptureFailed => {
- Ok(IncomingWebhookEvent::PaymentIntentFailure)
- }
+ match body {
+ XenditWebhookEvent::CommonEvent(event_data) => match event_data.event {
+ XenditEventType::PaymentSucceeded | XenditEventType::QrPayment => {
+ Ok(IncomingWebhookEvent::PaymentIntentSuccess)
+ }
+ XenditEventType::CaptureSucceeded => {
+ Ok(IncomingWebhookEvent::PaymentIntentCaptureSuccess)
+ }
+ XenditEventType::PaymentAwaitingCapture => {
+ Ok(IncomingWebhookEvent::PaymentIntentAuthorizationSuccess)
+ }
+ XenditEventType::PaymentFailed | XenditEventType::CaptureFailed => {
+ Ok(IncomingWebhookEvent::PaymentIntentFailure)
+ }
+ },
+ // Xendit’s QR Code system currently only sends a webhook for a successful payment
+ XenditWebhookEvent::QrEvent(_) => Ok(IncomingWebhookEvent::PaymentIntentSuccess),
}
}
@@ -955,6 +996,7 @@ impl webhooks::IncomingWebhook for Xendit {
static XENDIT_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
let supported_capture_methods = vec![CaptureMethod::Automatic, CaptureMethod::Manual];
+ let automatic_capture_supported = vec![CaptureMethod::Automatic];
let supported_card_network = vec![
common_enums::CardNetwork::Mastercard,
@@ -1008,6 +1050,17 @@ static XENDIT_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = Laz
},
);
+ xendit_supported_payment_methods.add(
+ enums::PaymentMethod::RealTimePayment,
+ PaymentMethodType::Qris,
+ PaymentMethodDetails {
+ mandates: enums::FeatureStatus::Supported,
+ refunds: enums::FeatureStatus::Supported,
+ supported_capture_methods: automatic_capture_supported.clone(),
+ specific_features: None,
+ },
+ );
+
xendit_supported_payment_methods
});
diff --git a/crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs b/crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs
index 2b8ea76fc8..298900d38e 100644
--- a/crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs
@@ -1,8 +1,12 @@
use std::collections::HashMap;
+use api_models::payments::QrCodeInformation;
use cards::CardNumber;
use common_enums::{enums, Currency};
-use common_utils::{pii, request::Method, types::FloatMajorUnit};
+use common_utils::{
+ errors::CustomResult, ext_traits::Encode, pii, request::Method, types::FloatMajorUnit,
+};
+use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData,
router_data::{ConnectorAuthType, ErrorResponse},
@@ -30,7 +34,7 @@ use crate::{
},
utils::{
get_unimplemented_payment_method_error_message, CardData, PaymentsAuthorizeRequestData,
- PaymentsSyncRequestData, RouterData as OtherRouterData,
+ PaymentsSyncRequestData, QrImage, RouterData as OtherRouterData,
},
};
@@ -80,7 +84,7 @@ pub struct XenditPaymentsCaptureRequest {
pub capture_amount: FloatMajorUnit,
}
#[derive(Serialize, Deserialize, Debug)]
-pub struct XenditPaymentsRequest {
+pub struct CommonXenditPaymentsRequestData {
pub amount: FloatMajorUnit,
pub currency: Currency,
pub capture_method: String,
@@ -92,6 +96,28 @@ pub struct XenditPaymentsRequest {
pub channel_properties: Option<ChannelProperties>,
}
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum QrType {
+ Dynamic,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+pub struct XenditQrisPaymentsRequestData {
+ pub amount: FloatMajorUnit,
+ pub external_id: String,
+ #[serde(rename = "type")]
+ pub qr_type: QrType,
+ pub callback_url: String,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(untagged)]
+pub enum XenditPaymentsRequest {
+ CommonXenditPaymentsRequest(Box<CommonXenditPaymentsRequestData>),
+ QrPaymentsRequest(XenditQrisPaymentsRequestData),
+}
+
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct XenditSplitRoute {
#[serde(skip_serializing_if = "Option::is_none")]
@@ -165,6 +191,8 @@ pub enum PaymentStatus {
Succeeded,
AwaitingCapture,
Verified,
+ Active,
+ Inactive,
}
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(untagged)]
@@ -177,11 +205,13 @@ pub struct XenditPaymentResponse {
pub id: String,
pub status: PaymentStatus,
pub actions: Option<Vec<Action>>,
- pub payment_method: PaymentMethodInfo,
+ pub payment_method: Option<PaymentMethodInfo>,
pub failure_code: Option<String>,
- pub reference_id: Secret<String>,
+ pub reference_id: Option<Secret<String>>,
pub amount: FloatMajorUnit,
- pub currency: Currency,
+ pub currency: Option<Currency>,
+ pub qr_string: Option<String>,
+ pub external_id: Option<String>,
}
fn map_payment_response_to_attempt_status(
@@ -189,7 +219,7 @@ fn map_payment_response_to_attempt_status(
is_auto_capture: bool,
) -> enums::AttemptStatus {
match response.status {
- PaymentStatus::Failed => enums::AttemptStatus::Failure,
+ PaymentStatus::Failed | PaymentStatus::Inactive => enums::AttemptStatus::Failure,
PaymentStatus::Succeeded | PaymentStatus::Verified => {
if is_auto_capture {
enums::AttemptStatus::Charged
@@ -198,7 +228,9 @@ fn map_payment_response_to_attempt_status(
}
}
PaymentStatus::Pending => enums::AttemptStatus::Pending,
- PaymentStatus::RequiresAction => enums::AttemptStatus::AuthenticationPending,
+ PaymentStatus::RequiresAction | PaymentStatus::Active => {
+ enums::AttemptStatus::AuthenticationPending
+ }
PaymentStatus::AwaitingCapture => enums::AttemptStatus::Authorized,
}
}
@@ -228,7 +260,38 @@ pub struct Action {
pub struct PaymentMethodInfo {
pub id: Secret<String>,
}
+
impl TryFrom<XenditRouterData<&PaymentsAuthorizeRouterData>> for XenditPaymentsRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: XenditRouterData<&PaymentsAuthorizeRouterData>) -> Result<Self, Self::Error> {
+ match item.router_data.request.payment_method_type {
+ Some(common_enums::PaymentMethodType::Qris) => {
+ if let Some(common_enums::CaptureMethod::Manual) =
+ item.router_data.request.capture_method
+ {
+ return Err(errors::ConnectorError::NotSupported {
+ message: "Manual Capture for QRIS payments".to_string(),
+ connector: "Xendit",
+ }
+ .into());
+ }
+ let qr_request = XenditQrisPaymentsRequestData {
+ amount: item.amount,
+ external_id: item.router_data.connector_request_reference_id.clone(),
+ qr_type: QrType::Dynamic,
+ callback_url: item.router_data.request.get_webhook_url()?,
+ };
+ Ok(Self::QrPaymentsRequest(qr_request))
+ }
+ _ => {
+ let common_request = CommonXenditPaymentsRequestData::try_from(item)?;
+ Ok(Self::CommonXenditPaymentsRequest(Box::new(common_request)))
+ }
+ }
+ }
+}
+
+impl TryFrom<XenditRouterData<&PaymentsAuthorizeRouterData>> for CommonXenditPaymentsRequestData {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: XenditRouterData<&PaymentsAuthorizeRouterData>) -> Result<Self, Self::Error> {
match item.router_data.request.payment_method_data.clone() {
@@ -309,6 +372,36 @@ impl TryFrom<XenditRouterData<&PaymentsCaptureRouterData>> for XenditPaymentsCap
})
}
}
+
+pub fn get_qr_image(qr_data: String) -> CustomResult<serde_json::Value, errors::ConnectorError> {
+ let image_data = QrImage::new_from_data(qr_data)
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)?;
+ let image_data_url = url::Url::parse(image_data.data.clone().as_str())
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)?;
+ let qr_code_info = QrCodeInformation::QrDataUrl {
+ image_data_url,
+ display_to_timestamp: None,
+ };
+ qr_code_info
+ .encode_to_value()
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)
+}
+
+pub fn extract_resource_id_from_payment_response(
+ payment_method_type: Option<common_enums::PaymentMethodType>,
+ response: &XenditPaymentResponse,
+) -> CustomResult<ResponseId, errors::ConnectorError> {
+ if payment_method_type == Some(common_enums::PaymentMethodType::Qris) {
+ let ext_id = response
+ .external_id
+ .clone()
+ .ok_or_else(|| errors::ConnectorError::WebhookReferenceIdNotFound)?;
+ Ok(ResponseId::ConnectorTransactionId(ext_id))
+ } else {
+ Ok(ResponseId::ConnectorTransactionId(response.id.clone()))
+ }
+}
+
impl TryFrom<PaymentsResponseRouterData<XenditPaymentResponse>> for PaymentsAuthorizeRouterData {
type Error = error_stack::Report<errors::ConnectorError>;
@@ -375,8 +468,19 @@ impl TryFrom<PaymentsResponseRouterData<XenditPaymentResponse>> for PaymentsAuth
_ => None,
};
+ let connector_metadata = if let Some(qr_data) = item.response.qr_string.clone() {
+ Some(get_qr_image(qr_data)?)
+ } else {
+ None
+ };
+
+ let resource_id = extract_resource_id_from_payment_response(
+ item.data.request.payment_method_type,
+ &item.response,
+ )?;
+
Ok(PaymentsResponseData::TransactionResponse {
- resource_id: ResponseId::ConnectorTransactionId(item.response.id.clone()),
+ resource_id,
redirection_data: match item.response.actions {
Some(actions) if !actions.is_empty() => {
actions.first().map_or(Box::new(None), |single_action| {
@@ -394,18 +498,23 @@ impl TryFrom<PaymentsResponseRouterData<XenditPaymentResponse>> for PaymentsAuth
},
mandate_reference: match item.data.request.is_mandate_payment() {
true => Box::new(Some(MandateReference {
- connector_mandate_id: Some(item.response.payment_method.id.expose()),
+ connector_mandate_id: item
+ .response
+ .payment_method
+ .map(|payment_method| payment_method.id.expose()),
payment_method_id: None,
mandate_metadata: None,
connector_mandate_request_reference_id: None,
})),
false => Box::new(None),
},
- connector_metadata: None,
+ connector_metadata,
network_txn_id: None,
- connector_response_reference_id: Some(
- item.response.reference_id.peek().to_string(),
- ),
+ connector_response_reference_id: item
+ .response
+ .reference_id
+ .map(|reference_id| reference_id.expose())
+ .or(item.response.external_id.clone()),
incremental_authorization_allowed: None,
charges,
})
@@ -427,10 +536,12 @@ impl TryFrom<PaymentsCaptureResponseRouterData<XenditCaptureResponse>>
item: PaymentsCaptureResponseRouterData<XenditCaptureResponse>,
) -> Result<Self, Self::Error> {
let status = match item.response.status {
- PaymentStatus::Failed => enums::AttemptStatus::Failure,
+ PaymentStatus::Failed | PaymentStatus::Inactive => enums::AttemptStatus::Failure,
PaymentStatus::Succeeded | PaymentStatus::Verified => enums::AttemptStatus::Charged,
PaymentStatus::Pending => enums::AttemptStatus::Pending,
- PaymentStatus::RequiresAction => enums::AttemptStatus::AuthenticationPending,
+ PaymentStatus::RequiresAction | PaymentStatus::Active => {
+ enums::AttemptStatus::AuthenticationPending
+ }
PaymentStatus::AwaitingCapture => enums::AttemptStatus::Authorized,
};
let response = if status == enums::AttemptStatus::Failure {
@@ -609,14 +720,17 @@ impl TryFrom<PaymentsSyncResponseRouterData<XenditResponse>> for PaymentsSyncRou
})
}
XenditResponse::Webhook(webhook_event) => {
- let status = match webhook_event.event {
- XenditEventType::PaymentSucceeded | XenditEventType::CaptureSucceeded => {
- enums::AttemptStatus::Charged
- }
- XenditEventType::PaymentAwaitingCapture => enums::AttemptStatus::Authorized,
- XenditEventType::PaymentFailed | XenditEventType::CaptureFailed => {
- enums::AttemptStatus::Failure
- }
+ let status = match webhook_event {
+ XenditWebhookEvent::CommonEvent(event_data) => match event_data.event {
+ XenditEventType::PaymentSucceeded
+ | XenditEventType::CaptureSucceeded
+ | XenditEventType::QrPayment => enums::AttemptStatus::Charged,
+ XenditEventType::PaymentAwaitingCapture => enums::AttemptStatus::Authorized,
+ XenditEventType::PaymentFailed | XenditEventType::CaptureFailed => {
+ enums::AttemptStatus::Failure
+ }
+ },
+ XenditWebhookEvent::QrEvent(_) => enums::AttemptStatus::Charged,
};
Ok(Self {
status,
@@ -789,11 +903,20 @@ pub struct XenditMetadata {
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
-pub struct XenditWebhookEvent {
+pub struct XenditCommonWebhookEvent {
pub event: XenditEventType,
pub data: EventDetails,
}
+#[derive(Debug, Serialize, Deserialize, Clone)]
+pub struct XenditQRWebhookEvent {
+ pub id: String,
+ pub event: XenditEventType,
+ pub amount: FloatMajorUnit,
+ pub qr_code: QrData,
+ pub status: QRPaymentStatus,
+}
+
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct EventDetails {
pub id: String,
@@ -814,4 +937,25 @@ pub enum XenditEventType {
CaptureSucceeded,
#[serde(rename = "capture.failed")]
CaptureFailed,
+ #[serde(rename = "qr.payment")]
+ QrPayment,
+}
+
+#[derive(Debug, Serialize, Deserialize, Clone)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum QRPaymentStatus {
+ Completed,
+}
+
+#[derive(Debug, Serialize, Deserialize, Clone)]
+pub struct QrData {
+ pub id: String,
+ pub external_id: String,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+#[serde(untagged)]
+pub enum XenditWebhookEvent {
+ CommonEvent(XenditCommonWebhookEvent),
+ QrEvent(XenditQRWebhookEvent),
}
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index 9ff55ae80a..32e62a187d 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -6494,6 +6494,7 @@ pub enum PaymentMethodDataType {
Fps,
PromptPay,
VietQr,
+ Qris,
OpenBanking,
NetworkToken,
NetworkTransactionIdAndCardDetails,
@@ -6705,6 +6706,7 @@ impl From<PaymentMethodData> for PaymentMethodDataType {
payment_method_data::RealTimePaymentData::Fps {} => Self::Fps,
payment_method_data::RealTimePaymentData::PromptPay {} => Self::PromptPay,
payment_method_data::RealTimePaymentData::VietQr {} => Self::VietQr,
+ payment_method_data::RealTimePaymentData::Qris {} => Self::Qris,
}
}
PaymentMethodData::GiftCard(gift_card_data) => match *gift_card_data {
diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs
index ea93017221..7ae0b64640 100644
--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs
+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs
@@ -742,6 +742,7 @@ pub enum RealTimePaymentData {
Fps {},
PromptPay {},
VietQr {},
+ Qris {},
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
@@ -2259,6 +2260,7 @@ impl From<api_models::payments::RealTimePaymentData> for RealTimePaymentData {
api_models::payments::RealTimePaymentData::DuitNow {} => Self::DuitNow {},
api_models::payments::RealTimePaymentData::PromptPay {} => Self::PromptPay {},
api_models::payments::RealTimePaymentData::VietQr {} => Self::VietQr {},
+ api_models::payments::RealTimePaymentData::Qris {} => Self::VietQr {},
}
}
}
@@ -2270,6 +2272,7 @@ impl From<RealTimePaymentData> for api_models::payments::RealTimePaymentData {
RealTimePaymentData::DuitNow {} => Self::DuitNow {},
RealTimePaymentData::PromptPay {} => Self::PromptPay {},
RealTimePaymentData::VietQr {} => Self::VietQr {},
+ RealTimePaymentData::Qris {} => Self::Qris {},
}
}
}
@@ -2580,6 +2583,7 @@ impl GetPaymentMethodType for RealTimePaymentData {
Self::DuitNow {} => api_enums::PaymentMethodType::DuitNow,
Self::PromptPay {} => api_enums::PaymentMethodType::PromptPay,
Self::VietQr {} => api_enums::PaymentMethodType::VietQr,
+ Self::Qris {} => api_enums::PaymentMethodType::Qris {},
}
}
}
diff --git a/crates/kgraph_utils/src/mca.rs b/crates/kgraph_utils/src/mca.rs
index 653151c655..7d6d30520a 100644
--- a/crates/kgraph_utils/src/mca.rs
+++ b/crates/kgraph_utils/src/mca.rs
@@ -138,6 +138,7 @@ fn get_dir_value_payment_method(
api_enums::PaymentMethodType::InstantBankTransferPoland => {
Ok(dirval!(BankTransferType = InstantBankTransferPoland))
}
+ api_enums::PaymentMethodType::Qris => Ok(dirval!(RealTimePaymentType = Qris)),
api_enums::PaymentMethodType::SepaBankTransfer => {
Ok(dirval!(BankTransferType = SepaBankTransfer))
}
diff --git a/crates/kgraph_utils/src/transformers.rs b/crates/kgraph_utils/src/transformers.rs
index 380cfb720e..162d28ab03 100644
--- a/crates/kgraph_utils/src/transformers.rs
+++ b/crates/kgraph_utils/src/transformers.rs
@@ -295,6 +295,7 @@ impl IntoDirValue for (api_enums::PaymentMethodType, api_enums::PaymentMethod) {
api_enums::PaymentMethodType::InstantBankTransferPoland => {
Ok(dirval!(BankTransferType = InstantBankTransferPoland))
}
+ api_enums::PaymentMethodType::Qris => Ok(dirval!(RealTimePaymentType = Qris)),
api_enums::PaymentMethodType::PermataBankTransfer => {
Ok(dirval!(BankTransferType = PermataBankTransfer))
}
diff --git a/crates/payment_methods/src/helpers.rs b/crates/payment_methods/src/helpers.rs
index c09bb672c7..f89fc31027 100644
--- a/crates/payment_methods/src/helpers.rs
+++ b/crates/payment_methods/src/helpers.rs
@@ -204,6 +204,7 @@ pub fn validate_payment_method_type_against_payment_method(
| api_enums::PaymentMethodType::DuitNow
| api_enums::PaymentMethodType::PromptPay
| api_enums::PaymentMethodType::VietQr
+ | api_enums::PaymentMethodType::Qris
),
api_enums::PaymentMethod::Upi => matches!(
payment_method_type,
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 6279fa2af8..6abbdf6ef5 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -2637,6 +2637,7 @@ pub enum PaymentMethodDataType {
Mifinity,
Fps,
PromptPay,
+ Qris,
VietQr,
OpenBanking,
NetworkToken,
@@ -2846,6 +2847,7 @@ impl From<domain::payments::PaymentMethodData> for PaymentMethodDataType {
hyperswitch_domain_models::payment_method_data::RealTimePaymentData::Fps { } => Self::Fps,
hyperswitch_domain_models::payment_method_data::RealTimePaymentData::PromptPay { } => Self::PromptPay,
hyperswitch_domain_models::payment_method_data::RealTimePaymentData::VietQr { } => Self::VietQr,
+ hyperswitch_domain_models::payment_method_data::RealTimePaymentData::Qris { } => Self::Qris,
},
domain::payments::PaymentMethodData::GiftCard(gift_card_data) => {
match *gift_card_data {
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 451fd16071..503ceb5f2d 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -385,7 +385,8 @@ impl ForeignFrom<api_enums::PaymentMethodType> for api_enums::PaymentMethod {
api_enums::PaymentMethodType::Fps
| api_enums::PaymentMethodType::DuitNow
| api_enums::PaymentMethodType::PromptPay
- | api_enums::PaymentMethodType::VietQr => Self::RealTimePayment,
+ | api_enums::PaymentMethodType::VietQr
+ | api_enums::PaymentMethodType::Qris => Self::RealTimePayment,
api_enums::PaymentMethodType::DirectCarrierBilling => Self::MobilePayment,
api_enums::PaymentMethodType::NetworkToken => Self::NetworkToken,
}