mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
feat(Connector): [Stripe] Implement Wechatpay Digital Wallet (#1049)
Co-authored-by: Arjun Karthik <m.arjunkarthik@gmail.com> Co-authored-by: Jagan Elavarasan <jaganelavarasan@gmail.com>
This commit is contained in:
@ -298,6 +298,7 @@ pub enum StripeWallet {
|
|||||||
ApplepayToken(StripeApplePay),
|
ApplepayToken(StripeApplePay),
|
||||||
GooglepayToken(GooglePayToken),
|
GooglepayToken(GooglePayToken),
|
||||||
ApplepayPayment(ApplepayPayment),
|
ApplepayPayment(ApplepayPayment),
|
||||||
|
WechatpayPayment(WechatpayPayment),
|
||||||
AlipayPayment(AlipayPayment),
|
AlipayPayment(AlipayPayment),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,6 +334,22 @@ pub struct AlipayPayment {
|
|||||||
pub payment_method_data_type: StripePaymentMethodType,
|
pub payment_method_data_type: StripePaymentMethodType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Eq, PartialEq, Serialize)]
|
||||||
|
pub struct WechatpayPayment {
|
||||||
|
#[serde(rename = "payment_method_types[]")]
|
||||||
|
pub payment_method_types: StripePaymentMethodType,
|
||||||
|
#[serde(rename = "payment_method_data[type]")]
|
||||||
|
pub payment_method_data_type: StripePaymentMethodType,
|
||||||
|
#[serde(rename = "payment_method_options[wechat_pay][client]")]
|
||||||
|
pub client: WechatClient,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Eq, PartialEq, Serialize, Clone, Copy)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum WechatClient {
|
||||||
|
Web,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Serialize)]
|
#[derive(Debug, Eq, PartialEq, Serialize)]
|
||||||
pub struct GooglepayPayment {
|
pub struct GooglepayPayment {
|
||||||
#[serde(rename = "payment_method_data[card][token]")]
|
#[serde(rename = "payment_method_data[card][token]")]
|
||||||
@ -361,6 +378,8 @@ pub enum StripePaymentMethodType {
|
|||||||
Becs,
|
Becs,
|
||||||
#[serde(rename = "bacs_debit")]
|
#[serde(rename = "bacs_debit")]
|
||||||
Bacs,
|
Bacs,
|
||||||
|
#[serde(rename = "wechat_pay")]
|
||||||
|
Wechatpay,
|
||||||
Alipay,
|
Alipay,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -819,6 +838,15 @@ fn create_stripe_payment_method(
|
|||||||
StripeBillingAddress::default(),
|
StripeBillingAddress::default(),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
|
payments::WalletData::WeChatPayRedirect(_) => Ok((
|
||||||
|
StripePaymentMethodData::Wallet(StripeWallet::WechatpayPayment(WechatpayPayment {
|
||||||
|
client: WechatClient::Web,
|
||||||
|
payment_method_types: StripePaymentMethodType::Wechatpay,
|
||||||
|
payment_method_data_type: StripePaymentMethodType::Wechatpay,
|
||||||
|
})),
|
||||||
|
StripePaymentMethodType::Wechatpay,
|
||||||
|
StripeBillingAddress::default(),
|
||||||
|
)),
|
||||||
payments::WalletData::AliPay(_) => Ok((
|
payments::WalletData::AliPay(_) => Ok((
|
||||||
StripePaymentMethodData::Wallet(StripeWallet::AlipayPayment(AlipayPayment {
|
StripePaymentMethodData::Wallet(StripeWallet::AlipayPayment(AlipayPayment {
|
||||||
payment_method_types: StripePaymentMethodType::Alipay,
|
payment_method_types: StripePaymentMethodType::Alipay,
|
||||||
@ -832,7 +860,6 @@ fn create_stripe_payment_method(
|
|||||||
StripePaymentMethodType::Card,
|
StripePaymentMethodType::Card,
|
||||||
StripeBillingAddress::default(),
|
StripeBillingAddress::default(),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
_ => Err(errors::ConnectorError::NotImplemented(
|
_ => Err(errors::ConnectorError::NotImplemented(
|
||||||
"This wallet is not implemented for stripe".to_string(),
|
"This wallet is not implemented for stripe".to_string(),
|
||||||
)
|
)
|
||||||
@ -1251,8 +1278,9 @@ impl ForeignFrom<(Option<StripePaymentMethodOptions>, String)> for types::Mandat
|
|||||||
| StripePaymentMethodOptions::Ach {}
|
| StripePaymentMethodOptions::Ach {}
|
||||||
| StripePaymentMethodOptions::Bacs {}
|
| StripePaymentMethodOptions::Bacs {}
|
||||||
| StripePaymentMethodOptions::Becs {}
|
| StripePaymentMethodOptions::Becs {}
|
||||||
| StripePaymentMethodOptions::Sepa {}
|
| StripePaymentMethodOptions::WechatPay {}
|
||||||
| StripePaymentMethodOptions::Alipay {} => None,
|
| StripePaymentMethodOptions::Alipay {}
|
||||||
|
| StripePaymentMethodOptions::Sepa {} => None,
|
||||||
}),
|
}),
|
||||||
payment_method_id: Some(payment_method_id),
|
payment_method_id: Some(payment_method_id),
|
||||||
}
|
}
|
||||||
@ -1412,6 +1440,7 @@ pub enum StripeNextActionResponse {
|
|||||||
RedirectToUrl(StripeRedirectToUrlResponse),
|
RedirectToUrl(StripeRedirectToUrlResponse),
|
||||||
AlipayHandleRedirect(StripeRedirectToUrlResponse),
|
AlipayHandleRedirect(StripeRedirectToUrlResponse),
|
||||||
VerifyWithMicrodeposits(StripeVerifyWithMicroDepositsResponse),
|
VerifyWithMicrodeposits(StripeVerifyWithMicroDepositsResponse),
|
||||||
|
WechatPayDisplayQrCode(StripeRedirectToQr),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StripeNextActionResponse {
|
impl StripeNextActionResponse {
|
||||||
@ -1420,6 +1449,7 @@ impl StripeNextActionResponse {
|
|||||||
Self::RedirectToUrl(redirect_to_url) | Self::AlipayHandleRedirect(redirect_to_url) => {
|
Self::RedirectToUrl(redirect_to_url) | Self::AlipayHandleRedirect(redirect_to_url) => {
|
||||||
redirect_to_url.url.to_owned()
|
redirect_to_url.url.to_owned()
|
||||||
}
|
}
|
||||||
|
Self::WechatPayDisplayQrCode(redirect_to_url) => redirect_to_url.data.to_owned(),
|
||||||
Self::VerifyWithMicrodeposits(verify_with_microdeposits) => {
|
Self::VerifyWithMicrodeposits(verify_with_microdeposits) => {
|
||||||
verify_with_microdeposits.hosted_verification_url.to_owned()
|
verify_with_microdeposits.hosted_verification_url.to_owned()
|
||||||
}
|
}
|
||||||
@ -1453,6 +1483,11 @@ pub struct StripeRedirectToUrlResponse {
|
|||||||
url: Url,
|
url: Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
|
||||||
|
pub struct StripeRedirectToQr {
|
||||||
|
data: Url,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Deserialize)]
|
||||||
pub struct StripeVerifyWithMicroDepositsResponse {
|
pub struct StripeVerifyWithMicroDepositsResponse {
|
||||||
hosted_verification_url: Url,
|
hosted_verification_url: Url,
|
||||||
@ -1612,8 +1647,8 @@ pub struct StripeBillingAddress {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, serde::Deserialize, Eq, PartialEq)]
|
#[derive(Debug, Clone, serde::Deserialize, Eq, PartialEq)]
|
||||||
pub struct StripeRedirectResponse {
|
pub struct StripeRedirectResponse {
|
||||||
pub payment_intent: String,
|
pub payment_intent: Option<String>,
|
||||||
pub payment_intent_client_secret: String,
|
pub payment_intent_client_secret: Option<String>,
|
||||||
pub source_redirect_slug: Option<String>,
|
pub source_redirect_slug: Option<String>,
|
||||||
pub redirect_status: Option<StripePaymentStatus>,
|
pub redirect_status: Option<StripePaymentStatus>,
|
||||||
pub source_type: Option<Secret<String>>,
|
pub source_type: Option<Secret<String>>,
|
||||||
@ -1657,6 +1692,7 @@ pub enum StripePaymentMethodOptions {
|
|||||||
Becs {},
|
Becs {},
|
||||||
#[serde(rename = "bacs_debit")]
|
#[serde(rename = "bacs_debit")]
|
||||||
Bacs {},
|
Bacs {},
|
||||||
|
WechatPay {},
|
||||||
Alipay {},
|
Alipay {},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1945,6 +1981,14 @@ impl
|
|||||||
Ok(Self::Wallet(wallet_info))
|
Ok(Self::Wallet(wallet_info))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
payments::WalletData::WeChatPayRedirect(_) => {
|
||||||
|
let wallet_info = StripeWallet::WechatpayPayment(WechatpayPayment {
|
||||||
|
client: WechatClient::Web,
|
||||||
|
payment_method_types: StripePaymentMethodType::Wechatpay,
|
||||||
|
payment_method_data_type: StripePaymentMethodType::Wechatpay,
|
||||||
|
});
|
||||||
|
Ok(Self::Wallet(wallet_info))
|
||||||
|
}
|
||||||
payments::WalletData::AliPay(_) => {
|
payments::WalletData::AliPay(_) => {
|
||||||
let wallet_info = StripeWallet::AlipayPayment(AlipayPayment {
|
let wallet_info = StripeWallet::AlipayPayment(AlipayPayment {
|
||||||
payment_method_types: StripePaymentMethodType::Alipay,
|
payment_method_types: StripePaymentMethodType::Alipay,
|
||||||
|
|||||||
Reference in New Issue
Block a user