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

chore(euclid_wasm): update paypal payment experience #4811

Merged
merged 15 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 61 additions & 2 deletions crates/connector_configs/src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,36 @@ impl DashboardRequestPayload {
},
}
}

pub fn transform_paypal_payment_method(
providers: Vec<Provider>,
) -> Vec<payment_methods::RequestPaymentMethodTypes> {
let payment_experiences = [
api_models::enums::PaymentExperience::RedirectToUrl,
api_models::enums::PaymentExperience::InvokeSdkClient,
];

let mut payment_method_types = Vec::new();

for experience in payment_experiences {
for provider in &providers {
let data = payment_methods::RequestPaymentMethodTypes {
payment_method_type: provider.payment_method_type,
card_networks: None,
minimum_amount: Some(0),
maximum_amount: Some(68607706),
recurring_enabled: true,
installment_payment_enabled: false,
accepted_currencies: provider.accepted_currencies.clone(),
accepted_countries: provider.accepted_countries.clone(),
payment_experience: Some(experience),
};
payment_method_types.push(data);
}
}

payment_method_types
}
pub fn transform_payment_method(
connector: Connector,
provider: Vec<Provider>,
Expand Down Expand Up @@ -125,8 +155,37 @@ impl DashboardRequestPayload {
}
}

PaymentMethod::Wallet
| PaymentMethod::BankRedirect
PaymentMethod::Wallet => match request.connector {
Connector::Paypal => {
if let Some(provider) = payload.provider {
let val = Self::transform_paypal_payment_method(provider);
if !val.is_empty() {
let methods = PaymentMethodsEnabled {
payment_method: payload.payment_method,
payment_method_types: Some(val),
};
payment_method_enabled.push(methods);
}
}
}
_ => {
if let Some(provider) = payload.provider {
let val = Self::transform_payment_method(
request.connector,
provider,
payload.payment_method,
);
if !val.is_empty() {
let methods = PaymentMethodsEnabled {
payment_method: payload.payment_method,
payment_method_types: Some(val),
};
payment_method_enabled.push(methods);
}
}
}
},
PaymentMethod::BankRedirect
| PaymentMethod::PayLater
| PaymentMethod::BankTransfer
| PaymentMethod::Crypto
Expand Down
4 changes: 2 additions & 2 deletions crates/connector_configs/toml/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1650,9 +1650,9 @@ merchant_secret="Source verification key"
client_id="Client ID"

[paypal_payout]
[[paypal.wallet]]
[[paypal_payout.wallet]]
payment_method_type = "paypal"
[[paypal.wallet]]
[[paypal_payout.wallet]]
payment_method_type = "venmo"
[paypal_payout.connector_auth.BodyKey]
api_key="Client Secret"
Expand Down
4 changes: 2 additions & 2 deletions crates/connector_configs/toml/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1650,9 +1650,9 @@ merchant_secret="Source verification key"
client_id="Client ID"

[paypal_payout]
[[paypal.wallet]]
[[paypal_payout.wallet]]
payment_method_type = "paypal"
[[paypal.wallet]]
[[paypal_payout.wallet]]
payment_method_type = "venmo"
[paypal_payout.connector_auth.BodyKey]
api_key="Client Secret"
Expand Down
Loading