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
feat(payouts): [WorldpayWPG] Implement fast access feature of worldpaywpg for payouts (#10647)
Vani Gupta7eaff9542696
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex 30fe0a6159..520581e69d 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -6890,49 +6890,17 @@ key1="API Password"[worldpayxml_payout][[worldpayxml_payout.wallet]]payment_method_type = "apple_pay"-[[worldpayxml_payout.credit]]- payment_method_type = "Mastercard"[[worldpayxml_payout.credit]]payment_method_type = "Visa"-[[worldpayxml_payout.credit]]- payment_method_type = "Interac"-[[worldpayxml_payout.credit]]- payment_method_type = "AmericanExpress"-[[worldpayxml_payout.credit]]- payment_method_type = "JCB"-[[worldpayxml_payout.credit]]- payment_method_type = "DinersClub"-[[worldpayxml_payout.credit]]- payment_method_type = "Discover"-[[worldpayxml_payout.credit]]- payment_method_type = "CartesBancaires"-[[worldpayxml_payout.credit]]- payment_method_type = "UnionPay"-[[worldpayxml_payout.debit]]- payment_method_type = "Mastercard"[[worldpayxml_payout.debit]]payment_method_type = "Visa"-[[worldpayxml_payout.debit]]- payment_method_type = "Interac"-[[worldpayxml_payout.debit]]- payment_method_type = "AmericanExpress"-[[worldpayxml_payout.debit]]- payment_method_type = "JCB"-[[worldpayxml_payout.debit]]- payment_method_type = "DinersClub"-[[worldpayxml_payout.debit]]- payment_method_type = "Discover"-[[worldpayxml_payout.debit]]- payment_method_type = "CartesBancaires"-[[worldpayxml_payout.debit]]- payment_method_type = "UnionPay"[worldpayxml_payout.metadata.purpose_of_payment]name="purpose_of_payment"label="Purpose of Payment"placeholder="Select the purpose of payment"required=falsetype="Select"-options=["Family Support", "Regular Labour Transfers", "Travel and Tourism", "Education", "Hospitalisation and Medical Treatment", "Emergency Need", "Savings", "Gifts", "Other", "Salary", "Crowd Lending", "Crypto Currency","Gaming Repayment", "Stock Market Proceeds","Refund to a original card", "Refund to a new card"]+options=["Account management", "Transaction is the payment of allowance", "Settlement of annuity", "Unemployment disability benefit", "Business expenses", "Bonus payment", "Bus transport related business", "Cash management transfer", "Payment of cable TV bill", "Government institute issued related to cash compensation, helplessness, and disability", "Credit card payment", "Payment of credit card bill", "Payment for charity reasons", "Collection payment", "Commercial payment", "Commission", "Compensation relating to interest loss/value date adjustment and can include fees", "Payment of copyright", "Related to a debit card payment", "Payment of a deposit", "Payment of dividend", "Payment of study/tuition fees", "Energies", "General fees", "Payment for ferry related business", "Foreign exchange", "Payment of gas bill", "Compensation to unemployed persons during insolvency procedures", "Government payment", "Health insurance", "Reimbursement of credit card payment", "Reimbursement of debit card payment", "Payment of car insurance premium", "Transaction is related to the payment of an insurance claim", "Installment", "Insurance premium", "Payment of mutual funds, investment products and shares", "Intra company payment", "Interest", "Income tax", "Investment", "Labor insurance", "License fee", "Life insurance", "Loan", "Medical services" ,"Mobile P2B payment", "Mobile P2P payment", "Mobile top up", "Not otherwise specified", "Other", "Transaction is related to a payment of other telecom related bill", "Payroll", "Contribution to pension fund", "Pension payment", "Payment of telephone bill", "Property insurance", "Transaction is for general rental/lease", "The payment of rent", "Payment for railway transport related business", "Royalties", "Salary payment", "Payment to savings/retirement account", "Securities", "Social security benefit", "Study", "Subscription", "Supplier payment", "Refund of a tax payment or obligation", "Tax payment", "Transaction is related to a payment of telecommunications related bill", "Trade services operation", "Treasury payment", "Payment for travel", "Utility bill payment", "Value added tax payment", "With holding", "Payment of water bill"][worldpayxml_payout.connector_auth.SignatureKey]api_secret="Merchant Code"diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.tomlindex 54bf0ffe4a..ecffb305ed 100644--- a/crates/connector_configs/toml/production.toml+++ b/crates/connector_configs/toml/production.toml@@ -5539,49 +5539,17 @@ type="Text"[worldpayxml_payout][[worldpayxml_payout.wallet]]payment_method_type = "apple_pay"-[[worldpayxml_payout.credit]]- payment_method_type = "Mastercard"[[worldpayxml_payout.credit]]payment_method_type = "Visa"-[[worldpayxml_payout.credit]]- payment_method_type = "Interac"-[[worldpayxml_payout.credit]]- payment_method_type = "AmericanExpress"-[[worldpayxml_payout.credit]]- payment_method_type = "JCB"-[[worldpayxml_payout.credit]]- payment_method_type = "DinersClub"-[[worldpayxml_payout.credit]]- payment_method_type = "Discover"-[[worldpayxml_payout.credit]]- payment_method_type = "CartesBancaires"-[[worldpayxml_payout.credit]]- payment_method_type = "UnionPay"-[[worldpayxml_payout.debit]]- payment_method_type = "Mastercard"[[worldpayxml_payout.debit]]payment_method_type = "Visa"-[[worldpayxml_payout.debit]]- payment_method_type = "Interac"-[[worldpayxml_payout.debit]]- payment_method_type = "AmericanExpress"-[[worldpayxml_payout.debit]]- payment_method_type = "JCB"-[[worldpayxml_payout.debit]]- payment_method_type = "DinersClub"-[[worldpayxml_payout.debit]]- payment_method_type = "Discover"-[[worldpayxml_payout.debit]]- payment_method_type = "CartesBancaires"-[[worldpayxml_payout.debit]]- payment_method_type = "UnionPay"[worldpayxml_payout.metadata.purpose_of_payment]name="purpose_of_payment"label="Purpose of Payment"placeholder="Select the purpose of payment"required=falsetype="Select"-options=["Family Support", "Regular Labour Transfers", "Travel and Tourism", "Education", "Hospitalisation and Medical Treatment", "Emergency Need", "Savings", "Gifts", "Other", "Salary", "Crowd Lending", "Crypto Currency","Gaming Repayment", "Stock Market Proceeds","Refund to a original card", "Refund to a new card"]+options=["Account management", "Transaction is the payment of allowance", "Settlement of annuity", "Unemployment disability benefit", "Business expenses", "Bonus payment", "Bus transport related business", "Cash management transfer", "Payment of cable TV bill", "Government institute issued related to cash compensation, helplessness, and disability", "Credit card payment", "Payment of credit card bill", "Payment for charity reasons", "Collection payment", "Commercial payment", "Commission", "Compensation relating to interest loss/value date adjustment and can include fees", "Payment of copyright", "Related to a debit card payment", "Payment of a deposit", "Payment of dividend", "Payment of study/tuition fees", "Energies", "General fees", "Payment for ferry related business", "Foreign exchange", "Payment of gas bill", "Compensation to unemployed persons during insolvency procedures", "Government payment", "Health insurance", "Reimbursement of credit card payment", "Reimbursement of debit card payment", "Payment of car insurance premium", "Transaction is related to the payment of an insurance claim", "Installment", "Insurance premium", "Payment of mutual funds, investment products and shares", "Intra company payment", "Interest", "Income tax", "Investment", "Labor insurance", "License fee", "Life insurance", "Loan", "Medical services" ,"Mobile P2B payment", "Mobile P2P payment", "Mobile top up", "Not otherwise specified", "Other", "Transaction is related to a payment of other telecom related bill", "Payroll", "Contribution to pension fund", "Pension payment", "Payment of telephone bill", "Property insurance", "Transaction is for general rental/lease", "The payment of rent", "Payment for railway transport related business", "Royalties", "Salary payment", "Payment to savings/retirement account", "Securities", "Social security benefit", "Study", "Subscription", "Supplier payment", "Refund of a tax payment or obligation", "Tax payment", "Transaction is related to a payment of telecommunications related bill", "Trade services operation", "Treasury payment", "Payment for travel", "Utility bill payment", "Value added tax payment", "With holding", "Payment of water bill"][worldpayxml_payout.connector_auth.SignatureKey]api_secret="Merchant Code"diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex 900b78a528..ce4441ffb6 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -6866,49 +6866,17 @@ type="Text"[worldpayxml_payout][[worldpayxml_payout.wallet]]payment_method_type = "apple_pay"-[[worldpayxml_payout.credit]]- payment_method_type = "Mastercard"[[worldpayxml_payout.credit]]payment_method_type = "Visa"-[[worldpayxml_payout.credit]]- payment_method_type = "Interac"-[[worldpayxml_payout.credit]]- payment_method_type = "AmericanExpress"-[[worldpayxml_payout.credit]]- payment_method_type = "JCB"-[[worldpayxml_payout.credit]]- payment_method_type = "DinersClub"-[[worldpayxml_payout.credit]]- payment_method_type = "Discover"-[[worldpayxml_payout.credit]]- payment_method_type = "CartesBancaires"-[[worldpayxml_payout.credit]]- payment_method_type = "UnionPay"-[[worldpayxml_payout.debit]]- payment_method_type = "Mastercard"[[worldpayxml_payout.debit]]payment_method_type = "Visa"-[[worldpayxml_payout.debit]]- payment_method_type = "Interac"-[[worldpayxml_payout.debit]]- payment_method_type = "AmericanExpress"-[[worldpayxml_payout.debit]]- payment_method_type = "JCB"-[[worldpayxml_payout.debit]]- payment_method_type = "DinersClub"-[[worldpayxml_payout.debit]]- payment_method_type = "Discover"-[[worldpayxml_payout.debit]]- payment_method_type = "CartesBancaires"-[[worldpayxml_payout.debit]]- payment_method_type = "UnionPay"[worldpayxml_payout.metadata.purpose_of_payment]name="purpose_of_payment"label="Purpose of Payment"placeholder="Select the purpose of payment"required=falsetype="Select"-options=["Family Support", "Regular Labour Transfers", "Travel and Tourism", "Education", "Hospitalisation and Medical Treatment", "Emergency Need", "Savings", "Gifts", "Other", "Salary", "Crowd Lending", "Crypto Currency","Gaming Repayment", "Stock Market Proceeds","Refund to a original card", "Refund to a new card"]+options=["Account management", "Transaction is the payment of allowance", "Settlement of annuity", "Unemployment disability benefit", "Business expenses", "Bonus payment", "Bus transport related business", "Cash management transfer", "Payment of cable TV bill", "Government institute issued related to cash compensation, helplessness, and disability", "Credit card payment", "Payment of credit card bill", "Payment for charity reasons", "Collection payment", "Commercial payment", "Commission", "Compensation relating to interest loss/value date adjustment and can include fees", "Payment of copyright", "Related to a debit card payment", "Payment of a deposit", "Payment of dividend", "Payment of study/tuition fees", "Energies", "General fees", "Payment for ferry related business", "Foreign exchange", "Payment of gas bill", "Compensation to unemployed persons during insolvency procedures", "Government payment", "Health insurance", "Reimbursement of credit card payment", "Reimbursement of debit card payment", "Payment of car insurance premium", "Transaction is related to the payment of an insurance claim", "Installment", "Insurance premium", "Payment of mutual funds, investment products and shares", "Intra company payment", "Interest", "Income tax", "Investment", "Labor insurance", "License fee", "Life insurance", "Loan", "Medical services" ,"Mobile P2B payment", "Mobile P2P payment", "Mobile top up", "Not otherwise specified", "Other", "Transaction is related to a payment of other telecom related bill", "Payroll", "Contribution to pension fund", "Pension payment", "Payment of telephone bill", "Property insurance", "Transaction is for general rental/lease", "The payment of rent", "Payment for railway transport related business", "Royalties", "Salary payment", "Payment to savings/retirement account", "Securities", "Social security benefit", "Study", "Subscription", "Supplier payment", "Refund of a tax payment or obligation", "Tax payment", "Transaction is related to a payment of telecommunications related bill", "Trade services operation", "Treasury payment", "Payment for travel", "Utility bill payment", "Value added tax payment", "With holding", "Payment of water bill"][worldpayxml_payout.connector_auth.SignatureKey]api_secret="Merchant Code"diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs b/crates/hyperswitch_connectors/src/connectors/worldpayxml.rsindex c521ab48f0..7e7396655c 100644--- a/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs+++ b/crates/hyperswitch_connectors/src/connectors/worldpayxml.rs@@ -1198,9 +1198,7 @@ impl webhooks::IncomingWebhook for Worldpayxml {let body: worldpayxml::WorldpayXmlWebhookBody =utils::deserialize_xml_to_struct(request.body)?;let order_code = body.notify.order_status_event.order_code.clone();- if worldpayxml::is_refund_event(body.notify.order_status_event.payment.last_event)- && !order_code.starts_with("payout_")- {+ if worldpayxml::is_refund_event(body.notify.order_status_event.payment.last_event) {return Ok(api_models::webhooks::ObjectReferenceId::RefundId(api_models::webhooks::RefundIdType::ConnectorRefundId(order_code),));@@ -1211,7 +1209,7 @@ impl webhooks::IncomingWebhook for Worldpayxml {));}#[cfg(feature = "payouts")]- if order_code.starts_with("payout_") {+ if worldpayxml::is_payout_event(body.notify.order_status_event.payment.last_event) {return Ok(api_models::webhooks::ObjectReferenceId::PayoutId(api_models::webhooks::PayoutIdType::ConnectorPayoutId(order_code),));@@ -1227,8 +1225,7 @@ impl webhooks::IncomingWebhook for Worldpayxml {utils::deserialize_xml_to_struct(request.body)?;#[cfg(feature = "payouts")]{- let order_code = body.notify.order_status_event.order_code.clone();- if order_code.starts_with("payout_") {+ if worldpayxml::is_payout_event(body.notify.order_status_event.payment.last_event) {return Ok(worldpayxml::get_payout_webhook_event(body.notify.order_status_event.payment.last_event,));diff --git a/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rsindex 91bd0a3c30..a6c601498d 100644--- a/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/worldpayxml/transformers.rs@@ -3,8 +3,6 @@ use api_models::payouts::{ApplePayDecrypt, CardPayout};use base64::Engine;use common_enums::enums;#[cfg(feature = "payouts")]-use common_enums::CardNetwork;-#[cfg(feature = "payouts")]use common_utils::pii;use common_utils::types::StringMinorUnit;use error_stack::ResultExt;@@ -256,6 +254,7 @@ pub struct Payment {issuer_name: Option<String>,balance: Option<Vec<Balance>>,card_holder_name: Option<String>,+ fast_funds: Option<bool>,#[serde(rename = "ISO8583ReturnCode")]return_code: Option<ReturnCode>,}@@ -322,6 +321,11 @@ pub enum LastEvent {QueryRequired,CancelReceived,RefundReceived,+ PushApproved,+ PushPending,+ PushRequested,+ PushRefused,+ SettledByMerchant,}#[derive(Debug, Deserialize, Serialize)]@@ -497,11 +501,8 @@ enum PaymentMethod {#[serde(rename = "CARD-SSL")]CardSSL(CardSSL),- #[serde(rename = "VISA-SSL")]- VisaSSL(CardSSL),-- #[serde(rename = "ECMC-SSL")]- EcmcSSL(CardSSL),+ #[serde(rename = "FF_DISBURSE-SSL")]+ FastAccessSSL(FastAccessData),#[serde(rename = "PAYWITHGOOGLE-SSL")]PayWithGoogleSSL(GooglePayData),@@ -510,40 +511,45 @@ enum PaymentMethod {PayWithAppleSSL(ApplePayData),}-#[derive(Debug, Deserialize, Serialize)]+#[cfg(feature = "payouts")]+#[derive(Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]-struct CardSSL {- card_number: cards::CardNumber,- expiry_date: ExpiryDate,- card_holder_name: Option<Secret<String>>,- #[serde(skip_serializing_if = "Option::is_none")]- cvc: Option<Secret<String>>,- #[serde(skip_serializing_if = "CardAddress::is_empty_option")]- card_address: Option<CardAddress>,+struct FastAccessData {+ recipient: Recipient,#[serde(skip_serializing_if = "Option::is_none")]- purpose_of_payment_code: Option<String>,+ purpose_of_payment: Option<String>,}-#[derive(Debug, Deserialize, Serialize)]+#[cfg(feature = "payouts")]+#[derive(Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]-struct CardAddress {- #[serde(skip_serializing_if = "WorldpayxmlAddress::is_empty_option")]- address: Option<WorldpayxmlAddress>,+struct Recipient {+ payment_instrument: PaymentInstrument,+ address: Option<WorldpayxmlAddressData>,+}++#[cfg(feature = "payouts")]+#[derive(Debug, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]+struct PaymentInstrument {+ card_details: CardDetails,+}++#[cfg(feature = "payouts")]+#[derive(Debug, Serialize, Deserialize)]+struct CardDetails {+ #[serde(flatten)]+ card_ssl: CardSSL,}#[derive(Debug, Deserialize, Serialize)]#[serde(rename_all = "camelCase")]-struct WorldpayxmlAddress {- #[serde(skip_serializing_if = "Option::is_none")]- last_name: Option<Secret<String>>,- #[serde(skip_serializing_if = "Option::is_none")]- address1: Option<Secret<String>>,- #[serde(skip_serializing_if = "Option::is_none")]- postal_code: Option<Secret<String>>,- #[serde(skip_serializing_if = "Option::is_none")]- city: Option<String>,+struct CardSSL {+ card_number: cards::CardNumber,+ expiry_date: ExpiryDate,+ card_holder_name: Option<Secret<String>>,#[serde(skip_serializing_if = "Option::is_none")]- country_code: Option<common_enums::CountryAlpha2>,+ cvc: Option<Secret<String>>,}#[derive(Debug, Deserialize, Serialize)]@@ -590,11 +596,11 @@ impl TryFrom<LastEvent> for enums::PayoutStatus {type Error = errors::ConnectorError;fn try_from(item: LastEvent) -> Result<Self, Self::Error> {match item {- LastEvent::SentForRefund | LastEvent::RefundReceived => Ok(Self::Initiated),- LastEvent::Error | LastEvent::Refused => Ok(Self::Failed),- LastEvent::QueryRequired => Ok(Self::Pending),+ LastEvent::PushRequested => Ok(Self::Initiated),+ LastEvent::PushPending => Ok(Self::Pending),+ LastEvent::Error | LastEvent::PushRefused => Ok(Self::Failed),+ LastEvent::PushApproved | LastEvent::SettledByMerchant => Ok(Self::Success),LastEvent::CancelReceived => Ok(Self::Cancelled),- LastEvent::RefundedByMerchant => Ok(Self::Success),_ => Err(errors::ConnectorError::UnexpectedResponseError(bytes::Bytes::from("Invalid LastEvent".to_string()),)),@@ -655,8 +661,6 @@ impl TryFrom<(&Card, Option<enums::CaptureMethod>, Option<Session>)> for Payment},card_holder_name: card_data.card_holder_name.to_owned(),cvc: Some(card_data.card_cvc.to_owned()),- card_address: None,- purpose_of_payment_code: None,}),session,})@@ -2030,15 +2034,9 @@ impl TryFrom<&RefundSyncRouterData> for PaymentService {}#[cfg(feature = "payouts")]-impl TryFrom<(ApplePayDecrypt, Option<CardAddress>, Option<String>)> for PaymentDetails {+impl TryFrom<ApplePayDecrypt> for PaymentInstrument {type Error = errors::ConnectorError;- fn try_from(- (apple_pay_decrypted_data, address, purpose_of_payment): (- ApplePayDecrypt,- Option<CardAddress>,- Option<String>,- ),- ) -> Result<Self, Self::Error> {+ fn try_from(apple_pay_decrypted_data: ApplePayDecrypt) -> Result<Self, Self::Error> {let card_data = CardSSL {card_number: apple_pay_decrypted_data.dpan.clone(),expiry_date: ExpiryDate {@@ -2049,43 +2047,20 @@ impl TryFrom<(ApplePayDecrypt, Option<CardAddress>, Option<String>)> for Payment},card_holder_name: apple_pay_decrypted_data.card_holder_name.clone(),cvc: None,- card_address: address,- purpose_of_payment_code: purpose_of_payment,- };-- let card_network = apple_pay_decrypted_data.card_network.ok_or(- errors::ConnectorError::MissingRequiredField {- field_name: "card_network",- },- )?;-- let payment_method = match card_network {- CardNetwork::Visa => PaymentMethod::VisaSSL(CardSSL { ..card_data }),- CardNetwork::Mastercard => PaymentMethod::EcmcSSL(CardSSL { ..card_data }),- _ => Err(errors::ConnectorError::NotSupported {- message: format!("{} card network is not supported", card_network).to_string(),- connector: "WorldpayWPG Payout",- })?,};Ok(Self {- action: Some(Action::Refund),- payment_method,- session: None,+ card_details: CardDetails {+ card_ssl: card_data,+ },})}}#[cfg(feature = "payouts")]-impl TryFrom<(CardPayout, Option<CardAddress>, Option<String>)> for PaymentDetails {+impl TryFrom<CardPayout> for PaymentInstrument {type Error = error_stack::Report<errors::ConnectorError>;- fn try_from(- (card_payout, address, purpose_of_payment): (- CardPayout,- Option<CardAddress>,- Option<String>,- ),- ) -> Result<Self, Self::Error> {+ fn try_from(card_payout: CardPayout) -> Result<Self, Self::Error> {let card_data = CardSSL {card_number: card_payout.card_number.clone(),expiry_date: ExpiryDate {@@ -2096,30 +2071,12 @@ impl TryFrom<(CardPayout, Option<CardAddress>, Option<String>)> for PaymentDetai},card_holder_name: card_payout.card_holder_name.to_owned(),cvc: None,- card_address: address,- purpose_of_payment_code: purpose_of_payment,- };-- let card_network =- card_payout- .card_network- .ok_or(errors::ConnectorError::MissingRequiredField {- field_name: "card_network",- })?;-- let payment_method = match card_network {- CardNetwork::Visa => PaymentMethod::VisaSSL(CardSSL { ..card_data }),- CardNetwork::Mastercard => PaymentMethod::EcmcSSL(CardSSL { ..card_data }),- _ => Err(errors::ConnectorError::NotSupported {- message: format!("{} card network is not supported", card_network).to_string(),- connector: "WorldpayWPG Payout",- })?,};Ok(Self {- action: Some(Action::Refund),- payment_method,- session: None,+ card_details: CardDetails {+ card_ssl: card_data,+ },})}}@@ -2155,15 +2112,11 @@ impl TryFrom<&WorldpayxmlRouterData<&PayoutsRouterData<PoFulfill>>> for PaymentSfn try_from(item: &WorldpayxmlRouterData<&PayoutsRouterData<PoFulfill>>,) -> Result<Self, Self::Error> {- let billing_details = Some(CardAddress {- address: Some(WorldpayxmlAddress {- last_name: item.router_data.get_optional_billing_last_name(),- address1: item.router_data.get_optional_billing_line1(),- postal_code: item.router_data.get_optional_billing_zip(),- city: item.router_data.get_optional_billing_city(),- country_code: item.router_data.get_optional_billing_country(),- }),- });+ let billing_details = item+ .router_data+ .get_optional_billing()+ .and_then(get_address_details);+ let address = billing_details.map(|details| details.address);let purpose_of_payment: Option<WorldpayxmlPayoutConnectorMetadataObject> =match item.router_data.connector_meta_data {@@ -2179,16 +2132,12 @@ impl TryFrom<&WorldpayxmlRouterData<&PayoutsRouterData<PoFulfill>>> for PaymentS};let payout_method_data = item.router_data.get_payout_method_data()?;- let payment_details = match payout_method_data {+ let payment_instrument = match payout_method_data {api_models::payouts::PayoutMethodData::Wallet(api_models::payouts::Wallet::ApplePayDecrypt(apple_pay_decrypted_data),- ) => PaymentDetails::try_from((- apple_pay_decrypted_data,- billing_details,- purpose_of_payment_code,- ))?,+ ) => PaymentInstrument::try_from(apple_pay_decrypted_data)?,api_models::payouts::PayoutMethodData::Card(card_payout) => {- PaymentDetails::try_from((card_payout, billing_details, purpose_of_payment_code))?+ PaymentInstrument::try_from(card_payout)?}api_models::payouts::PayoutMethodData::Bank(_)| api_models::payouts::PayoutMethodData::Wallet(_)@@ -2200,14 +2149,20 @@ impl TryFrom<&WorldpayxmlRouterData<&PayoutsRouterData<PoFulfill>>> for PaymentS}};- let reference_id = item.router_data.connector_request_reference_id.to_owned();-- let order_code = if reference_id.starts_with("payout_") {- reference_id- } else {- format!("payout_{}", reference_id)+ let payment_details = PaymentDetails {+ action: None,+ payment_method: PaymentMethod::FastAccessSSL(FastAccessData {+ recipient: Recipient {+ payment_instrument,+ address,+ },+ purpose_of_payment: purpose_of_payment_code,+ }),+ session: None,};+ let order_code = item.router_data.connector_request_reference_id.to_owned();+let description = item.router_data.description.clone().ok_or(errors::ConnectorError::MissingRequiredField {field_name: "description",@@ -2267,8 +2222,8 @@ impl TryFrom<PayoutsResponseRouterData<PoFulfill, PayoutResponse>>) -> Result<Self, Self::Error> {let reply = item.response.reply;- match (reply.error, reply.order_status, reply.ok) {- (Some(error), None, None) => Ok(Self {+ match (reply.error, reply.order_status) {+ (Some(error), None) => Ok(Self {status: common_enums::AttemptStatus::Failure,response: Err(ErrorResponse {code: error.code,@@ -2284,7 +2239,7 @@ impl TryFrom<PayoutsResponseRouterData<PoFulfill, PayoutResponse>>}),..item.data}),- (None, Some(order_status), None) => {+ (None, Some(order_status)) => {match (order_status.payment, order_status.error) {(Some(payment), None) => Ok(Self {response: Ok(PayoutsResponseData {@@ -2319,26 +2274,6 @@ impl TryFrom<PayoutsResponseRouterData<PoFulfill, PayoutResponse>>),}},- (None, None, Some(ok_response)) => {- let response = ok_response.refund_received.ok_or(- errors::ConnectorError::UnexpectedResponseError(bytes::Bytes::from(- "ok.refund_received must be present in the response",- )),- )?;-- Ok(Self {- response: Ok(PayoutsResponseData {- status: Some(enums::PayoutStatus::try_from(LastEvent::RefundReceived)?),- connector_payout_id: Some(response.order_code),- payout_eligible: None,- should_add_next_step_to_process_tracker: false,- error_code: None,- error_message: None,- payout_connector_metadata: None,- }),- ..item.data- })- }_ => Err(errors::ConnectorError::UnexpectedResponseError(bytes::Bytes::from("Either reply.error or reply.order_status must be present in the response",@@ -2613,54 +2548,91 @@ fn process_payment_response(#[cfg(feature = "payouts")]pub fn map_purpose_code(value: Option<String>) -> Option<String> {let code = match value?.as_str() {- "Family Support" => "00",- "Regular Labour Transfers" => "01",- "Travel and Tourism" => "02",- "Education" => "03",- "Hospitalisation and Medical Treatment" => "04",- "Emergency Need" => "05",- "Savings" => "06",- "Gifts" => "07",- "Other" => "08",- "Salary" => "09",- "Crowd Lending" => "10",- "Crypto Currency" => "11",- "Gaming Repayment" => "12",- "Stock Market Proceeds" => "13",- "Refund to a original card" => "M1",- "Refund to a new card" => "M2",+ "Account management" => "ISACCT",+ "Transaction is the payment of allowance" => "ISALLW",+ "Settlement of annuity" => "ISANNI",+ "Unemployment disability benefit" => "ISBENE",+ "Business expenses" => "ISBEXP",+ "Bonus payment" => "ISBONU",+ "Bus transport related business" => "ISBUSB",+ "Cash management transfer" => "ISCASH",+ "Payment of cable TV bill" => "ISCBTV",+ "Government institute issued related to cash compensation, helplessness, and disability" => "ISCCHD",+ "Credit card payment" => "ISCCRD",+ "Payment of credit card bill" => "ISCDBL",+ "Payment for charity reasons" => "ISCHAR",+ "Collection payment" => "ISCOLL",+ "Commercial payment" => "ISCOMC",+ "Commission" => "ISCOMM",+ "Compensation relating to interest loss/value date adjustment and can include fees" => "ISCOMP",+ "Payment of copyright" => "ISCPYR",+ "Related to a debit card payment" => "ISDCRD",+ "Payment of a deposit" => "ISDEPT",+ "Payment of dividend" => "ISDIVD",+ "Payment of study/tuition fees" => "ISEDUC",+ "Payment of electricity bill" => "ISELEC",+ "Energies" => "ISENRG",+ "General fees" => "ISFEES",+ "Payment for ferry related business" => "ISFERB",+ "Foreign exchange" => "ISFREX",+ "Payment of gas bill" => "ISGASB",+ "Compensation to unemployed persons during insolvency procedures" => "ISGFRP",+ "Government payment" => "ISGOVT",+ "Health insurance" => "ISHLTI",+ "Reimbursement of credit card payment" => "ISICCP",+ "Reimbursement of debit card payment" => "ISIDCP",+ "Payment of car insurance premium" => "ISINPC",+ "Transaction is related to the payment of an insurance claim" => "ISINSC",+ "Installment" => "ISINSM",+ "Insurance premium" => "ISINSU",+ "Payment of mutual funds, investment products and shares" => "ISINVS",+ "Intra company payment" => "ISINTC",+ "Interest" => "ISINTE",+ "Income tax" => "ISINTX",+ "Investment" => "ISINVS",+ "Labor insurance" => "ISLBRI",+ "License fee" => "ISLICF",+ "Life insurance" => "ISLIFI",+ "Loan" => "ISLOAN",+ "Medical services" => "ISMDCS",+ "Mobile P2B payment" => "ISMP2B",+ "Mobile P2P payment" => "ISMP2P",+ "Mobile top up" => "ISMTUP",+ "Not otherwise specified" => "ISNOWS",+ "Transaction is related to a payment of other telecom related bill" => "ISOTLC",+ "Payroll" => "ISPAYR",+ "Contribution to pension fund" => "ISPEFC",+ "Pension payment" => "ISPENS",+ "Payment of telephone bill" => "ISPHON",+ "Property insurance" => "ISPPTI",+ "Transaction is for general rental/lease" => "ISRELG",+ "The payment of rent" => "ISRENT",+ "Payment for railway transport related business" => "ISRLWY",+ "Royalties" => "ISROYA",+ "Salary payment" => "ISSALA",+ "Payment to savings/retirement account" => "ISSAVG",+ "Securities" => "ISSECU",+ "Social security benefit" => "ISSSBE",+ "Study" => "ISSTDY",+ "Subscription" => "ISSUBS",+ "Supplier payment" => "ISSUPP",+ "Refund of a tax payment or obligation" => "ISTAXR",+ "Tax payment" => "ISTAXS",+ "Transaction is related to a payment of telecommunications related bill" => "ISTBIL",+ "Trade services operation" => "ISTRAD",+ "Treasury payment" => "ISTREA",+ "Payment for travel" => "ISTRPT",+ "Utility bill payment" => "ISUBIL",+ "Value added tax payment" => "ISVATX",+ "With holding" => "ISWHLD",+ "Payment of water bill" => "ISWTER",+ "Other" => "ISOTHR",_ => return None,};Some(code.to_string())}-impl WorldpayxmlAddress {- fn is_empty(&self) -> bool {- self.last_name.is_none()- || self.address1.is_none()- || self.postal_code.is_none()- || self.city.is_none()- || self.country_code.is_none()- }-- fn is_empty_option(addr: &Option<Self>) -> bool {- match addr {- Some(a) => a.is_empty(),- None => true,- }- }-}--impl CardAddress {- fn is_empty_option(addr: &Option<Self>) -> bool {- match addr {- Some(a) => WorldpayxmlAddress::is_empty_option(&a.address),- None => true,- }- }-}-#[derive(Debug, Serialize, Deserialize)]#[serde(rename = "paymentService")]pub struct WorldpayXmlWebhookBody {@@ -2687,15 +2659,14 @@ pub struct OrderStatusEvent {pub fn get_payout_webhook_event(status: LastEvent) -> api_models::webhooks::IncomingWebhookEvent {match status {- LastEvent::SentForRefund- | LastEvent::RefundedByMerchant- | LastEvent::SentForFastRefund- | LastEvent::RefundRequested => {+ LastEvent::PushRequested | LastEvent::PushPending => {api_models::webhooks::IncomingWebhookEvent::PayoutProcessing}- LastEvent::Refunded => api_models::webhooks::IncomingWebhookEvent::PayoutSuccess,+ LastEvent::SettledByMerchant | LastEvent::PushApproved => {+ api_models::webhooks::IncomingWebhookEvent::PayoutSuccess+ }LastEvent::Cancelled => api_models::webhooks::IncomingWebhookEvent::PayoutCancelled,- LastEvent::Refused | LastEvent::RefundFailed => {+ LastEvent::PushRefused | LastEvent::Error => {api_models::webhooks::IncomingWebhookEvent::PayoutFailure}_ => api_models::webhooks::IncomingWebhookEvent::EventNotSupported,@@ -2720,6 +2691,17 @@ pub fn get_payment_webhook_event(status: LastEvent) -> api_models::webhooks::Inc}}+pub fn is_payout_event(event_code: LastEvent) -> bool {+ matches!(+ event_code,+ LastEvent::PushApproved+ | LastEvent::PushPending+ | LastEvent::PushRequested+ | LastEvent::SettledByMerchant+ | LastEvent::PushRefused+ )+}+pub fn is_refund_event(event_code: LastEvent) -> bool {matches!(event_code,