Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(connector): [Adyen] Implement Gcash for Adyen #1576

Merged
merged 58 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a65cc81
Added Alipay_hk
AkshayaFoiger Jun 26, 2023
aa5837d
additional
AkshayaFoiger Jun 26, 2023
bb4aef2
added GoPay
AkshayaFoiger Jun 26, 2023
bcee6bf
added KakaoPay
AkshayaFoiger Jun 26, 2023
ae2bfdb
addede Gcash Redirection
AkshayaFoiger Jun 26, 2023
a843db9
added specific country and currency
AkshayaFoiger Jun 27, 2023
fcf01d9
Merge branch 'main' into adyen/Alipay_HK
AkshayaFoiger Jun 27, 2023
4277b79
fix
AkshayaFoiger Jun 27, 2023
a0549a8
added testcase
AkshayaFoiger Jun 27, 2023
f409ea2
Merge branch 'adyen/Alipay_HK' into adyen/GoPay
AkshayaFoiger Jun 27, 2023
43845e9
addede country and currency
AkshayaFoiger Jun 27, 2023
c31cc48
formatted
AkshayaFoiger Jun 28, 2023
6a99b53
Merge branch 'adyen/GoPay' into adyen/kakao_pay
AkshayaFoiger Jun 28, 2023
16a888e
formatted
AkshayaFoiger Jun 28, 2023
50b2c01
Update crates/router/src/connector/adyen/transformers.rs
AkshayaFoiger Jun 28, 2023
3d9585f
updated
AkshayaFoiger Jun 29, 2023
2641335
Merge branch 'adyen/GoPay' of github.com:juspay/hyperswitch into adye…
AkshayaFoiger Jun 29, 2023
1276bdf
updated
AkshayaFoiger Jun 29, 2023
bae22d1
removed redundant type annotation
AkshayaFoiger Jun 30, 2023
934f84e
merged adyen/kakao_pay
AkshayaFoiger Jun 30, 2023
78b8c46
removed payment_type
AkshayaFoiger Jun 30, 2023
6043d8e
Merged main
AkshayaFoiger Jul 1, 2023
7898fa0
go_pay_redirect
AkshayaFoiger Jul 1, 2023
5b916e5
resolved conflicts
AkshayaFoiger Jul 1, 2023
4f13e7a
added redirect openapi
AkshayaFoiger Jul 1, 2023
5128bb7
merged gopay
AkshayaFoiger Jul 1, 2023
e532930
updated
AkshayaFoiger Jul 1, 2023
4119bf3
merged kakopay
AkshayaFoiger Jul 1, 2023
daad312
fixed openapi_spec
AkshayaFoiger Jul 1, 2023
6272a35
updated
AkshayaFoiger Jul 1, 2023
2c25402
merged go pay
AkshayaFoiger Jul 1, 2023
497bbfd
updated
AkshayaFoiger Jul 1, 2023
626957b
Merge branch 'adyen/kakao_pay' into adyen/gcash
AkshayaFoiger Jul 1, 2023
1a90eae
updated
AkshayaFoiger Jul 1, 2023
c3a07d0
updated
AkshayaFoiger Jul 1, 2023
8e6e544
removed get_channel_type
AkshayaFoiger Jul 7, 2023
e8a3fa9
openapi generated
AkshayaFoiger Jul 7, 2023
4dbe3e6
merged main
AkshayaFoiger Jul 10, 2023
474d308
conflict resolved
AkshayaFoiger Jul 10, 2023
565b41d
Merge branch 'main' into adyen/kakao_pay
AkshayaFoiger Jul 10, 2023
6aae341
merge go pay
AkshayaFoiger Jul 10, 2023
d9bfb6e
generated openapi
AkshayaFoiger Jul 10, 2023
e8455c4
added error response handler
AkshayaFoiger Jul 10, 2023
e418332
conflict resolved
AkshayaFoiger Jul 14, 2023
7c8354d
conflict resolved
AkshayaFoiger Jul 14, 2023
72a0875
fixed cargo.nix
AkshayaFoiger Jul 14, 2023
f675545
undo stack size
AkshayaFoiger Jul 14, 2023
561b22a
merge main
AkshayaFoiger Jul 14, 2023
1926b4e
conflict resolved
AkshayaFoiger Jul 14, 2023
acf079f
merge kakao_pay
AkshayaFoiger Jul 14, 2023
c7d813a
updated
AkshayaFoiger Jul 14, 2023
db3434a
undo build.rs
AkshayaFoiger Jul 14, 2023
6b4ffd2
merged main
AkshayaFoiger Jul 18, 2023
bfe6e2c
generated openapi
AkshayaFoiger Jul 18, 2023
55996cb
fixed
AkshayaFoiger Jul 18, 2023
750b4f8
resolved conflict
AkshayaFoiger Jul 18, 2023
2f79721
removed repeated enum variable
AkshayaFoiger Jul 18, 2023
9743c92
fixed kakaopay
AkshayaFoiger Jul 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ ach = {country = "US", currency = "USD"}
bacs = {country = "UK", currency = "GBP"}
sepa = {country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT", currency = "EUR"}
ali_pay_hk = {country = "HK", currency = "HKD"}
go_pay = {country = "ID", currency = "IDR"}
kakao_pay = {country = "KR", currency = "KRW"}
gcash = {country = "PH", currency = "PHP"}

[pm_filters.braintree]
paypal = { currency = "AUD,BRL,CAD,CNY,CZK,DKK,EUR,HKD,HUF,ILS,JPY,MYR,MXN,TWD,NZD,NOK,PHP,PLN,GBP,RUB,SGD,SEK,CHF,THB,USD" }
Expand Down
3 changes: 3 additions & 0 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,13 @@ pub enum PaymentMethodType {
Debit,
Eps,
Evoucher,
Gcash,
Giropay,
GooglePay,
GoPay,
Ideal,
Interac,
KakaoPay,
Klarna,
MbWay,
MobilePay,
Expand Down
15 changes: 15 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,12 @@ pub enum WalletData {
AliPayRedirect(AliPayRedirection),
/// The wallet data for Ali Pay HK redirect
AliPayHkRedirect(AliPayHkRedirection),
/// The wallet data for KakaoPay redirect
KakaoPayRedirect(KakaoPayRedirection),
/// The wallet data for GoPay redirect
GoPayRedirect(GoPayRedirection),
/// The wallet data for Gcash redirect
GcashRedirect(GcashRedirection),
/// The wallet data for Apple pay
ApplePay(ApplePayWalletData),
/// Wallet data for apple pay redirect flow
Expand Down Expand Up @@ -913,6 +919,15 @@ pub struct AliPayRedirection {}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct AliPayHkRedirection {}

#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct KakaoPayRedirection {}

#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct GoPayRedirection {}

#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct GcashRedirection {}

#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct MobilePayRedirection {}

Expand Down
57 changes: 56 additions & 1 deletion crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub struct AdyenPaymentRequest<'a> {
delivery_address: Option<Address>,
country_code: Option<api_enums::CountryAlpha2>,
line_items: Option<Vec<LineItem>>,
channel: Option<Channel>,
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -144,6 +145,11 @@ pub enum AdyenStatus {
Refused,
}

#[derive(Debug, Clone, Serialize)]
pub enum Channel {
Web,
}

/// This implementation will be used only in Authorize, Automatic capture flow.
/// It is also being used in Psync flow, However Psync will be called only after create payment call that too in redirect flow.
impl ForeignFrom<(bool, AdyenStatus)> for storage_enums::AttemptStatus {
Expand Down Expand Up @@ -254,6 +260,7 @@ pub struct Amount {

#[derive(Debug, Clone, Serialize)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub enum AdyenPaymentMethod<'a> {
AdyenAffirm(Box<AdyenPayLaterData>),
AdyenCard(Box<AdyenCard>),
Expand All @@ -266,9 +273,13 @@ pub enum AdyenPaymentMethod<'a> {
BancontactCard(Box<BancontactCardData>),
Blik(Box<BlikRedirectionData>),
Eps(Box<BankRedirectionWithIssuer<'a>>),
Gcash(Box<GcashData>),
Giropay(Box<BankRedirectionPMData>),
Gpay(Box<AdyenGPay>),
#[serde(rename = "gopay_wallet")]
GoPay(Box<GoPayData>),
Ideal(Box<BankRedirectionWithIssuer<'a>>),
Kakaopay(Box<KakaoPayData>),
Mandate(Box<AdyenMandate>),
Mbway(Box<MbwayData>),
MobilePay(Box<MobilePayData>),
Expand Down Expand Up @@ -620,6 +631,14 @@ pub struct AliPayHkData {
payment_type: PaymentType,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GoPayData {}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct KakaoPayData {}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GcashData {}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AdyenGPay {
#[serde(rename = "type")]
Expand Down Expand Up @@ -678,10 +697,14 @@ pub enum PaymentType {
Applepay,
Blik,
Eps,
Gcash,
Giropay,
Googlepay,
#[serde(rename = "gopay_wallet")]
GoPay,
Ideal,
Klarna,
Kakaopay,
Mbway,
MobilePay,
#[serde(rename = "onlineBanking_CZ")]
Expand Down Expand Up @@ -864,6 +887,7 @@ fn get_browser_info(
) -> Result<Option<AdyenBrowserInfo>, Error> {
if item.auth_type == storage_enums::AuthenticationType::ThreeDs
|| item.payment_method == storage_enums::PaymentMethod::BankRedirect
|| item.request.payment_method_type == Some(storage_enums::PaymentMethodType::GoPay)
{
let info = item.request.get_browser_info()?;
Ok(Some(AdyenBrowserInfo {
Expand Down Expand Up @@ -895,6 +919,13 @@ fn get_additional_data(item: &types::PaymentsAuthorizeRouterData) -> Option<Addi
}
}

fn get_channel_type(pm_type: &Option<storage_enums::PaymentMethodType>) -> Option<Channel> {
pm_type.as_ref().and_then(|pmt| match pmt {
storage_enums::PaymentMethodType::GoPay => Some(Channel::Web),
_ => None,
})
}

fn get_amount_data(item: &types::PaymentsAuthorizeRouterData) -> Amount {
Amount {
currency: item.request.currency.to_string(),
Expand Down Expand Up @@ -1103,6 +1134,18 @@ impl<'a> TryFrom<&api::WalletData> for AdyenPaymentMethod<'a> {
};
Ok(AdyenPaymentMethod::AliPayHk(Box::new(alipay_hk_data)))
}
api_models::payments::WalletData::GoPayRedirect(_) => {
let go_pay_data = GoPayData {};
Ok(AdyenPaymentMethod::GoPay(Box::new(go_pay_data)))
}
api_models::payments::WalletData::KakaoPayRedirect(_) => {
let kakao_pay_data = KakaoPayData {};
Ok(AdyenPaymentMethod::Kakaopay(Box::new(kakao_pay_data)))
}
api_models::payments::WalletData::GcashRedirect(_) => {
let gcash_data = GcashData {};
Ok(AdyenPaymentMethod::Gcash(Box::new(gcash_data)))
}
api_models::payments::WalletData::MbWayRedirect(data) => {
let mbway_data = MbwayData {
payment_type: PaymentType::Mbway,
Expand Down Expand Up @@ -1302,6 +1345,7 @@ impl<'a>
let browser_info = get_browser_info(item)?;
let additional_data = get_additional_data(item);
let return_url = item.request.get_return_url()?;
let channel = get_channel_type(&item.request.payment_method_type);
let payment_method = match mandate_ref_id {
payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids) => {
let adyen_mandate = AdyenMandate {
Expand Down Expand Up @@ -1357,6 +1401,7 @@ impl<'a>
line_items: None,
shopper_reference,
store_payment_method,
channel,
})
}
}
Expand All @@ -1373,6 +1418,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::Card)> for AdyenPay
get_recurring_processing_model(item)?;
let browser_info = get_browser_info(item)?;
let additional_data = get_additional_data(item);
let channel = get_channel_type(&item.request.payment_method_type);
let return_url = item.request.get_return_url()?;
let payment_method = AdyenPaymentMethod::try_from(card_data)?;
Ok(AdyenPaymentRequest {
Expand All @@ -1395,6 +1441,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::Card)> for AdyenPay
line_items: None,
shopper_reference,
store_payment_method,
channel,
})
}
}
Expand All @@ -1421,6 +1468,7 @@ impl<'a>
let browser_info = get_browser_info(item)?;
let additional_data = get_additional_data(item);
let return_url = item.request.get_return_url()?;
let channel = get_channel_type(&item.request.payment_method_type);
let payment_method = AdyenPaymentMethod::try_from(bank_debit_data)?;
let country_code = get_country_code(item);
let request = AdyenPaymentRequest {
Expand All @@ -1443,6 +1491,7 @@ impl<'a>
line_items: None,
shopper_reference: None,
store_payment_method: None,
channel,
};
Ok(request)
}
Expand Down Expand Up @@ -1470,6 +1519,7 @@ impl<'a>
let browser_info = get_browser_info(item)?;
let additional_data = get_additional_data(item);
let return_url = item.request.get_return_url()?;
let channel = get_channel_type(&item.request.payment_method_type);
let payment_method = AdyenPaymentMethod::try_from(bank_redirect_data)?;
let (shopper_locale, country) = get_sofort_extra_details(item);
let line_items = Some(get_line_items(item));
Expand All @@ -1494,6 +1544,7 @@ impl<'a>
line_items,
shopper_reference,
store_payment_method,
channel,
})
}
}
Expand Down Expand Up @@ -1535,9 +1586,10 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::WalletData)>
let additional_data = get_additional_data(item);
let payment_method = AdyenPaymentMethod::try_from(wallet_data)?;
let shopper_interaction = AdyenShopperInteraction::from(item);
let channel = get_channel_type(&item.request.payment_method_type);
let (recurring_processing_model, store_payment_method, shopper_reference) =
get_recurring_processing_model(item)?;
let return_url = item.request.get_return_url()?;
let return_url = item.request.get_router_return_url()?;
Ok(AdyenPaymentRequest {
amount,
merchant_account: auth_type.merchant_account,
Expand All @@ -1558,6 +1610,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::WalletData)>
line_items: None,
shopper_reference,
store_payment_method,
channel,
})
}
}
Expand All @@ -1584,6 +1637,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::PayLaterData)>
let billing_address = get_address_info(item.address.billing.as_ref());
let delivery_address = get_address_info(item.address.shipping.as_ref());
let country_code = get_country_code(item);
let channel = get_channel_type(&item.request.payment_method_type);
let line_items = Some(get_line_items(item));
let telephone_number = get_telephone_number(item);
Ok(AdyenPaymentRequest {
Expand All @@ -1606,6 +1660,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::PayLaterData)>
line_items,
shopper_reference,
store_payment_method,
channel,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/router/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::AddressDetails,
api_models::payments::BankDebitData,
api_models::payments::AliPayRedirection,
api_models::payments::GcashRedirection,
api_models::payments::KakaoPayRedirection,
api_models::payments::AliPayHkRedirection,
api_models::payments::GoPayRedirection,
api_models::payments::MbWayRedirection,
api_models::payments::MobilePayRedirection,
api_models::payments::WeChatPayRedirection,
Expand Down
4 changes: 2 additions & 2 deletions crates/router/tests/connectors/adyen_uk_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ async fn should_make_adyen_klarna_mandate_payment(
Ok(())
}

async fn should_make_adyen_alipay_hk_payment(c: WebDriver) -> Result<(), WebDriverError> {
async fn should_make_adyen_alipay_hk_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
let conn = AdyenSeleniumTest {};
conn.make_redirection_payment(
c,
web_driver,
vec![
Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/162"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Expand Down
3 changes: 3 additions & 0 deletions crates/storage_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,13 @@ pub enum PaymentMethodType {
Debit,
Eps,
Evoucher,
Gcash,
Giropay,
GooglePay,
GoPay,
Ideal,
Interac,
KakaoPay,
Klarna,
MbWay,
MobilePay,
Expand Down
45 changes: 45 additions & 0 deletions openapi/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,15 @@
"AliPayRedirection": {
"type": "object"
},
"GoPayRedirection": {
"type": "object"
},
"KakaoPayRedirection": {
"type": "object"
},
"GcashRedirection": {
"type": "object"
},
"AmountInfo": {
"type": "object",
"required": [
Expand Down Expand Up @@ -6188,11 +6197,14 @@
"debit",
"eps",
"evoucher",
"gcash",
"giropay",
"google_pay",
"go_pay",
"ideal",
"interac",
"klarna",
"kakao_pay",
"mb_way",
"mobile_pay",
"online_banking_czech_republic",
Expand Down Expand Up @@ -8138,6 +8150,28 @@
}
}
},
{
"type": "object",
"required": [
"gcash_redirect"
],
"properties": {
"gcash_redirect": {
"$ref": "#/components/schemas/GcashRedirection"
}
}
},
{
"type": "object",
"required": [
"kakao_pay_redirect"
],
"properties": {
"kakao_pay_redirect": {
"$ref": "#/components/schemas/KakaoPayRedirection"
}
}
},
{
"type": "object",
"required": [
Expand All @@ -8160,6 +8194,17 @@
}
}
},
{
"type": "object",
"required": [
"go_pay_redirect"
],
"properties": {
"go_pay_redirect": {
"$ref": "#/components/schemas/GoPayRedirection"
}
}
},
{
"type": "object",
"required": [
Expand Down