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
fix(connector): [DummyConnector] add new icons and fix `we_chat_pay` (#1845)
Mani Chandra985ff6ba419b
diff --git a/config/config.example.toml b/config/config.example.tomlindex 4887464302..6e005dcb5a 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -304,12 +304,18 @@ payment_duration = 1000 # Fake delay duration for dummy connector paymepayment_tolerance = 100 # Fake delay tolerance for dummy connector paymentpayment_retrieve_duration = 500 # Fake delay duration for dummy connector payment syncpayment_retrieve_tolerance = 100 # Fake delay tolerance for dummy connector payment sync+payment_complete_duration = 500 # Fake delay duration for dummy connector payment complete+payment_complete_tolerance = 100 # Fake delay tolerance for dummy connector payment completerefund_ttl = 172800 # Time to live for dummy connector refund in redisrefund_duration = 1000 # Fake delay duration for dummy connector refundrefund_tolerance = 100 # Fake delay tolerance for dummy connector refundrefund_retrieve_duration = 500 # Fake delay duration for dummy connector refund syncrefund_retrieve_tolerance = 100 # Fake delay tolerance for dummy connector refund syncauthorize_ttl = 36000 # Time to live for dummy connector authorize request in redis+assets_base_url = "https://www.example.com/" # Base url for dummy connector assets+default_return_url = "https://www.example.com/" # Default return url when no return url is passed while payment+slack_invite_url = "https://www.example.com/" # Slack invite url for hyperswitch+discord_invite_url = "https://www.example.com/" # Discord invite url for hyperswitch[mandates.supported_payment_methods]card.credit = {connector_list = "stripe,adyen"} # Mandate supported payment method type and connector for carddiff --git a/config/development.toml b/config/development.tomlindex fa05727e0f..03cdc10bc3 100644--- a/config/development.toml+++ b/config/development.toml@@ -359,12 +359,18 @@ payment_duration = 1000payment_tolerance = 100payment_retrieve_duration = 500payment_retrieve_tolerance = 100+payment_complete_duration = 500+payment_complete_tolerance = 100refund_ttl = 172800refund_duration = 1000refund_tolerance = 100refund_retrieve_duration = 500refund_retrieve_tolerance = 100authorize_ttl = 36000+assets_base_url = "https://app.hyperswitch.io/assets/TestProcessor/"+default_return_url = "https://app.hyperswitch.io/"+slack_invite_url = "https://join.slack.com/t/hyperswitch-io/shared_invite/zt-1k6cz4lee-SAJzhz6bjmpp4jZCDOtOIg"+discord_invite_url = "https://discord.gg/wJZ7DVW8mm"[delayed_session_response]connectors_with_delayed_session_response = "trustpay"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex 7e0d4df6df..c58ced9902 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -201,12 +201,18 @@ payment_duration = 1000payment_tolerance = 100payment_retrieve_duration = 500payment_retrieve_tolerance = 100+payment_complete_duration = 500+payment_complete_tolerance = 100refund_ttl = 172800refund_duration = 1000refund_tolerance = 100refund_retrieve_duration = 500refund_retrieve_tolerance = 100authorize_ttl = 36000+assets_base_url = "https://app.hyperswitch.io/assets/TestProcessor/"+default_return_url = "https://app.hyperswitch.io/"+slack_invite_url = "https://join.slack.com/t/hyperswitch-io/shared_invite/zt-1k6cz4lee-SAJzhz6bjmpp4jZCDOtOIg"+discord_invite_url = "https://discord.gg/wJZ7DVW8mm"[payouts]payout_eligibility = truediff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rsindex 57766ff10f..9b09025edc 100644--- a/crates/router/src/configs/settings.rs+++ b/crates/router/src/configs/settings.rs@@ -145,12 +145,18 @@ pub struct DummyConnector {pub payment_tolerance: u64,pub payment_retrieve_duration: u64,pub payment_retrieve_tolerance: u64,+ pub payment_complete_duration: i64,+ pub payment_complete_tolerance: i64,pub refund_ttl: i64,pub refund_duration: u64,pub refund_tolerance: u64,pub refund_retrieve_duration: u64,pub refund_retrieve_tolerance: u64,pub authorize_ttl: i64,+ pub assets_base_url: String,+ pub default_return_url: String,+ pub slack_invite_url: String,+ pub discord_invite_url: String,}#[derive(Debug, Deserialize, Clone)]diff --git a/crates/router/src/routes/dummy_connector/consts.rs b/crates/router/src/routes/dummy_connector/consts.rsindex 3892cedfde..e872ce2120 100644--- a/crates/router/src/routes/dummy_connector/consts.rs+++ b/crates/router/src/routes/dummy_connector/consts.rs@@ -1,97 +1,4 @@pub const PAYMENT_ID_PREFIX: &str = "dummy_pay";pub const ATTEMPT_ID_PREFIX: &str = "dummy_attempt";pub const REFUND_ID_PREFIX: &str = "dummy_ref";-pub const DEFAULT_RETURN_URL: &str = "https://app.hyperswitch.io/";-pub const THREE_DS_CSS: &str = r#"- @import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;500;600;700&display=swap');- body {- font-family: Inter;- background-image: url('https://app.hyperswitch.io/images/hyperswitchImages/PostLoginBackground.svg');- display: flex;- background-size: cover;- height: 100%;- padding-top: 3rem;- margin: 0;- align-items: center;- flex-direction: column;- }- .authorize {- color: white;- background-color: #006DF9;- border: 1px solid #006DF9;- box-sizing: border-box;- margin: 1.5rem 0.5rem 1rem 0;- border-radius: 0.25rem;- padding: 0.75rem 1rem;- font-weight: 500;- font-size: 1.1rem;- }- .authorize:hover {- background-color: #0099FF;- border: 1px solid #0099FF;- cursor: pointer;- }- .reject {- background-color: #F7F7F7;- color: black;- border: 1px solid #E8E8E8;- box-sizing: border-box;- border-radius: 0.25rem;- margin-left: 0.5rem;- font-size: 1.1rem;- padding: 0.75rem 1rem;- font-weight: 500;- }- .reject:hover {- cursor: pointer;- background-color: #E8E8E8;- border: 1px solid #E8E8E8;- }- .container {- background-color: white;- width: 33rem;- margin: 1rem 0;- border: 1px solid #E8E8E8;- color: black;- border-radius: 0.25rem;- padding: 1rem 1.4rem 1rem 1.4rem;- font-family: Inter;- }- .container p {- font-weight: 400;- margin-top: 0.5rem 1rem 0.5rem 0.5rem;- color: #151A1F;- opacity: 0.5;- }- b {- font-weight: 600;- }- .disclaimer {- font-size: 1.25rem;- font-weight: 500 !important;- margin-top: 0.5rem !important;- margin-bottom: 0.5rem;- opacity: 1 !important;- }- .heading {- display: flex;- justify-content: center;- flex-direction: column;- align-items: center;- margin-bottom: 1rem;- }- .logo {- width: 8rem;- }- .payment_details {- height: 2rem;- display: flex;- margin: 1rem 0 2rem 0;- }- .border {- border-top: 1px dashed #151a1f80;- height: 1px;- margin: 0 1rem;- margin-top: 1rem;- width: 20%;- }"#;+pub const THREE_DS_CSS: &str = include_str!("threeds_page.css");diff --git a/crates/router/src/routes/dummy_connector/core.rs b/crates/router/src/routes/dummy_connector/core.rsindex b32d3d8684..64bd3a7d3a 100644--- a/crates/router/src/routes/dummy_connector/core.rs+++ b/crates/router/src/routes/dummy_connector/core.rs@@ -59,6 +59,7 @@ pub async fn payment_authorize(req: types::DummyConnectorPaymentConfirmRequest,) -> types::DummyConnectorResponse<String> {let payment_data = utils::get_payment_data_by_attempt_id(state, req.attempt_id.clone()).await;+ let dummy_connector_conf = &state.conf.dummy_connector;if let Ok(payment_data_inner) = payment_data {let return_url = format!(@@ -66,14 +67,16 @@ pub async fn payment_authorize(state.conf.server.base_url, req.attempt_id);Ok(api::ApplicationResponse::FileData((- utils::get_authorize_page(payment_data_inner, return_url)+ utils::get_authorize_page(payment_data_inner, return_url, dummy_connector_conf).as_bytes().to_vec(),mime::TEXT_HTML,)))} else {Ok(api::ApplicationResponse::FileData((- utils::get_expired_page().as_bytes().to_vec(),+ utils::get_expired_page(dummy_connector_conf)+ .as_bytes()+ .to_vec(),mime::TEXT_HTML,)))}@@ -83,6 +86,12 @@ pub async fn payment_complete(state: &AppState,req: types::DummyConnectorPaymentCompleteRequest,) -> types::DummyConnectorResponse<()> {+ utils::tokio_mock_sleep(+ state.conf.dummy_connector.payment_duration,+ state.conf.dummy_connector.payment_tolerance,+ )+ .await;+let payment_data = utils::get_payment_data_by_attempt_id(state, req.attempt_id.clone()).await;let payment_status = if req.confirm {@@ -118,7 +127,7 @@ pub async fn payment_complete(params: vec![],return_url_with_query_params: updated_payment_data.return_url- .unwrap_or(consts::DEFAULT_RETURN_URL.to_string()),+ .unwrap_or(state.conf.dummy_connector.default_return_url.clone()),http_method: "GET".to_string(),headers: vec![],},@@ -128,7 +137,7 @@ pub async fn payment_complete(api_models::payments::RedirectionResponse {return_url: String::new(),params: vec![],- return_url_with_query_params: consts::DEFAULT_RETURN_URL.to_string(),+ return_url_with_query_params: state.conf.dummy_connector.default_return_url.clone(),http_method: "GET".to_string(),headers: vec![],},diff --git a/crates/router/src/routes/dummy_connector/threeds_page.css b/crates/router/src/routes/dummy_connector/threeds_page.cssnew file mode 100644index 0000000000..6eb3fb9478--- /dev/null+++ b/crates/router/src/routes/dummy_connector/threeds_page.css@@ -0,0 +1,126 @@+@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;500;600;700&display=swap');+body {+ font-family: Inter;+ background-image: url('https://app.hyperswitch.io/images/hyperswitchImages/PostLoginBackground.svg');+ display: flex;+ background-size: cover;+ height: 100%;+ padding-top: 3rem;+ margin: 0;+ align-items: center;+ flex-direction: column;+}+.authorize {+ color: white;+ background-color: #006DF9;+ border: 1px solid #006DF9;+ box-sizing: border-box;+ margin: 1.5rem 0.5rem 1rem 0;+ border-radius: 0.25rem;+ padding: 0.75rem 1rem;+ font-weight: 500;+ font-size: 1.1rem;+}+.authorize:hover {+ background-color: #0099FF;+ border: 1px solid #0099FF;+ cursor: pointer;+}+.reject {+ background-color: #F7F7F7;+ color: black;+ border: 1px solid #E8E8E8;+ box-sizing: border-box;+ border-radius: 0.25rem;+ margin-left: 0.5rem;+ font-size: 1.1rem;+ padding: 0.75rem 1rem;+ font-weight: 500;+}+.reject:hover {+ cursor: pointer;+ background-color: #E8E8E8;+ border: 1px solid #E8E8E8;+}+.container {+ background-color: white;+ width: 33rem;+ margin: 1rem 0;+ border: 1px solid #E8E8E8;+ color: black;+ border-radius: 0.25rem;+ padding: 1rem 1.4rem 1rem 1.4rem;+ font-family: Inter;+}+.container p {+ font-weight: 400;+ margin-top: 0.5rem 1rem 0.5rem 0.5rem;+ color: #151A1F;+ opacity: 0.5;+}+b {+ font-weight: 600;+}+.disclaimer {+ font-size: 1.25rem;+ font-weight: 500 !important;+ margin-top: 0.5rem !important;+ margin-bottom: 0.5rem;+ opacity: 1 !important;+}+.heading {+ display: flex;+ justify-content: center;+ flex-direction: column;+ align-items: center;+ margin-bottom: 1rem;+}+.logo {+ width: 8rem;+}+.payment_details {+ height: 2rem;+ display: flex;+ margin: 1rem 0 2rem 0;+}+.border_horizontal {+ border-top: 1px dashed #151a1f80;+ height: 1px;+ margin: 0 1rem;+ margin-top: 1rem;+ width: 20%;+}+.contact {+ display: flex;+ gap: 10%;+ margin: 2rem 0 1rem 0;+ height: 3rem;+}+.contact img {+ aspect-ratio: 1/1;+ height: 2rem;+}+.contact_item {+ display: flex;+ height: 100%;+ flex-direction: column;+ justify-content: center;+}+.contact_item p {+ margin: 0;+}+.border_vertical {+ border-left: 1px solid #151a1f80;+ width: 1px;+ height: 100%;+}+.email {+ justify-content: space-between;+}+.hover_cursor:hover {+ cursor: pointer+}+a {+ text-decoration: none;+ opacity: 0.8;+}diff --git a/crates/router/src/routes/dummy_connector/types.rs b/crates/router/src/routes/dummy_connector/types.rsindex 0954d71b0f..fb20cd4c27 100644--- a/crates/router/src/routes/dummy_connector/types.rs+++ b/crates/router/src/routes/dummy_connector/types.rs@@ -42,21 +42,16 @@ pub enum DummyConnectors {}impl DummyConnectors {- pub fn get_connector_image_link(self) -> &'static str {- match self {- Self::PhonyPay => "https://app.hyperswitch.io/euler-icons/Gateway/Light/PHONYPAY.svg",- Self::FauxPay => "https://app.hyperswitch.io/euler-icons/Gateway/Light/FAUXPAY.svg",- Self::PretendPay => {- "https://app.hyperswitch.io/euler-icons/Gateway/Light/PRETENDPAY.svg"- }- Self::StripeTest => {- "https://app.hyperswitch.io/euler-icons/Gateway/Light/STRIPE_TEST.svg"- }- Self::PaypalTest => {- "https://app.hyperswitch.io/euler-icons/Gateway/Light/PAYPAL_TEST.svg"- }- _ => "https://app.hyperswitch.io/euler-icons/Gateway/Light/PHONYPAY.svg",- }+ pub fn get_connector_image_link(self, base_url: &str) -> String {+ let image_name = match self {+ Self::PhonyPay => "PHONYPAY.svg",+ Self::FauxPay => "FAUXPAY.svg",+ Self::PretendPay => "PRETENDPAY.svg",+ Self::StripeTest => "STRIPE_TEST.svg",+ Self::PaypalTest => "PAYPAL_TEST.svg",+ _ => "PHONYPAY.svg",+ };+ format!("{}{}", base_url, image_name)}}@@ -127,7 +122,7 @@ pub struct DummyConnectorPaymentRequest {pub trait GetPaymentMethodDetails {fn get_name(&self) -> &'static str;- fn get_image_link(&self) -> &'static str;+ fn get_image_link(&self, base_url: &str) -> String;}#[derive(Clone, Debug, serde::Serialize, Eq, PartialEq, serde::Deserialize)]@@ -168,11 +163,11 @@ impl GetPaymentMethodDetails for DummyConnectorPaymentMethodType {}}- fn get_image_link(&self) -> &'static str {+ fn get_image_link(&self, base_url: &str) -> String {match self {- Self::Card => "https://www.svgrepo.com/show/115459/credit-card.svg",- Self::Wallet(wallet) => wallet.get_image_link(),- Self::PayLater(pay_later) => pay_later.get_image_link(),+ Self::Card => format!("{}{}", base_url, "CARD.svg"),+ Self::Wallet(wallet) => wallet.get_image_link(base_url),+ Self::PayLater(pay_later) => pay_later.get_image_link(base_url),}}}@@ -212,15 +207,16 @@ impl GetPaymentMethodDetails for DummyConnectorWallet {Self::AliPayHK => "Alipay HK",}}- fn get_image_link(&self) -> &'static str {- match self {- Self::GooglePay => "https://pay.google.com/about/static_kcs/images/logos/google-pay-logo.svg",- Self::Paypal => "https://app.hyperswitch.io/euler-icons/Gateway/Light/PAYPAL.svg",- Self::WeChatPay => "https://raw.githubusercontent.com/datatrans/payment-logos/master/assets/apm/wechat-pay.svg?sanitize=true",- Self::MbWay => "https://upload.wikimedia.org/wikipedia/commons/e/e3/Logo_MBWay.svg",- Self::AliPay => "https://www.logo.wine/a/logo/Alipay/Alipay-Logo.wine.svg",- Self::AliPayHK => "https://www.logo.wine/a/logo/Alipay/Alipay-Logo.wine.svg",- }+ fn get_image_link(&self, base_url: &str) -> String {+ let image_name = match self {+ Self::GooglePay => "GOOGLE_PAY.svg",+ Self::Paypal => "PAYPAL.svg",+ Self::WeChatPay => "WECHAT_PAY.svg",+ Self::MbWay => "MBWAY.svg",+ Self::AliPay => "ALIPAY.svg",+ Self::AliPayHK => "ALIPAY.svg",+ };+ format!("{}{}", base_url, image_name)}}@@ -239,12 +235,13 @@ impl GetPaymentMethodDetails for DummyConnectorPayLater {Self::AfterPayClearPay => "Afterpay Clearpay",}}- fn get_image_link(&self) -> &'static str {- match self {- Self::Klarna => "https://docs.klarna.com/assets/media/7404df75-d165-4eee-b33c-a9537b847952/Klarna_Logo_Primary_Black.svg",- Self::Affirm => "https://upload.wikimedia.org/wikipedia/commons/f/ff/Affirm_logo.svg",- Self::AfterPayClearPay => "https://upload.wikimedia.org/wikipedia/en/c/c3/Afterpay_logo.svg"- }+ fn get_image_link(&self, base_url: &str) -> String {+ let image_name = match self {+ Self::Klarna => "KLARNA.svg",+ Self::Affirm => "AFFIRM.svg",+ Self::AfterPayClearPay => "AFTERPAY.svg",+ };+ format!("{}{}", base_url, image_name)}}diff --git a/crates/router/src/routes/dummy_connector/utils.rs b/crates/router/src/routes/dummy_connector/utils.rsindex 937f0d0e1a..6dee459fcf 100644--- a/crates/router/src/routes/dummy_connector/utils.rs+++ b/crates/router/src/routes/dummy_connector/utils.rs@@ -11,7 +11,7 @@ use super::{consts, errors,types::{self, GetPaymentMethodDetails},};-use crate::routes::AppState;+use crate::{configs::settings, routes::AppState};pub async fn tokio_mock_sleep(delay: u64, tolerance: u64) {let mut rng = rand::thread_rng();@@ -86,16 +86,22 @@ pub async fn get_payment_data_by_attempt_id(pub fn get_authorize_page(payment_data: types::DummyConnectorPaymentData,return_url: String,+ dummy_connector_conf: &settings::DummyConnector,) -> String {let mode = payment_data.payment_method_type.get_name();- let image = payment_data.payment_method_type.get_image_link();- let connector_image = payment_data.connector.get_connector_image_link();+ let image = payment_data+ .payment_method_type+ .get_image_link(dummy_connector_conf.assets_base_url.as_str());+ let connector_image = payment_data+ .connector+ .get_connector_image_link(dummy_connector_conf.assets_base_url.as_str());let currency = payment_data.currency.to_string();html! {head {title { "Authorize Payment" }style { (consts::THREE_DS_CSS) }+ link rel="icon" href=(connector_image) {}}body {div.heading {@@ -105,7 +111,7 @@ pub fn get_authorize_page(div.container {div.payment_details {img src=(image) {}- div.border {}+ div.border_horizontal {}img src=(connector_image) {}}(maud::PreEscaped(@@ -119,31 +125,47 @@ pub fn get_authorize_page("#, currency, mode, payment_data.amount)))- p { b { "Real money will not be debited for the payment." } " You can choose to simulate successful or failed payment while testing this payment."}+ p { b { "Real money will not be debited for the payment." } " \+ You can choose to simulate successful or failed payment while testing this payment." }div.user_action {- button.authorize onclick=(format!("window.location.href='{}?confirm=true'", return_url))+ button.authorize onclick=(format!("window.location.href='{}?confirm=true'", return_url)){ "Complete Payment" }- button.reject onclick=(format!("window.location.href='{}?confirm=false'", return_url))+ button.reject onclick=(format!("window.location.href='{}?confirm=false'", return_url)){ "Reject Payment" }}}div.container {p.disclaimer { "What is this page?" }- p { "This page is just a simulation for integration and testing purpose.\- In live mode, this page will not be displayed and the user will be taken to the\- Bank page (or) Googlepay cards popup (or) original payment method’s page. "- a href=("https://hyperswitch.io/contact") { "Contact us" } " for any queries." }+ p { "This page is just a simulation for integration and testing purpose. \+ In live mode, this page will not be displayed and the user will be taken to \+ the Bank page (or) Google Pay cards popup (or) original payment method's page. \+ Contact us for any queries."+ }+ div.contact {+ div.contact_item.hover_cursor onclick=(dummy_connector_conf.slack_invite_url) {+ img src="https://hyperswitch.io/logos/logo_slack.svg" alt="Slack Logo" {}+ }+ div.contact_item.hover_cursor onclick=(dummy_connector_conf.discord_invite_url) {+ img src="https://hyperswitch.io/logos/logo_discord.svg" alt="Discord Logo" {}+ }+ div.border_vertical {}+ div.contact_item.email {+ p { "Or email us at" }+ a href="mailto:[email protected]" { "[email protected]" }+ }+ }}}}.into_string()}-pub fn get_expired_page() -> String {+pub fn get_expired_page(dummy_connector_conf: &settings::DummyConnector) -> String {html! {head {title { "Authorize Payment" }style { (consts::THREE_DS_CSS) }+ link rel="icon" href="https://app.hyperswitch.io/HyperswitchFavicon.png" {}}body {div.heading {@@ -156,8 +178,21 @@ pub fn get_expired_page() -> String {div.container {p.disclaimer { "What is this page?" }p { "This page is just a simulation for integration and testing purpose.\- In live mode, this is not visible. "- a href=("https://hyperswitch.io/contact") { "Contact us" } " for any queries." }+ In live mode, this is not visible. Contact us for any queries."+ }+ div.contact {+ div.contact_item.hover_cursor onclick=(dummy_connector_conf.slack_invite_url) {+ img src="https://hyperswitch.io/logos/logo_slack.svg" alt="Slack Logo" {}+ }+ div.contact_item.hover_cursor onclick=(dummy_connector_conf.discord_invite_url) {+ img src="https://hyperswitch.io/logos/logo_discord.svg" alt="Discord Logo" {}+ }+ div.border_vertical {}+ div.contact_item.email {+ p { "Or email us at" }+ a href="mailto:[email protected]" { "[email protected]" }+ }+ }}}}diff --git a/loadtest/config/development.toml b/loadtest/config/development.tomlindex 8bf0f1d985..fede2d2e85 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -186,12 +186,18 @@ payment_duration = 1000payment_tolerance = 100payment_retrieve_duration = 500payment_retrieve_tolerance = 100+payment_complete_duration = 500+payment_complete_tolerance = 100refund_ttl = 172800refund_duration = 1000refund_tolerance = 100refund_retrieve_duration = 500refund_retrieve_tolerance = 100authorize_ttl = 36000+assets_base_url = "https://app.hyperswitch.io/assets/TestProcessor/"+default_return_url = "https://app.hyperswitch.io/"+slack_invite_url = "https://join.slack.com/t/hyperswitch-io/shared_invite/zt-1k6cz4lee-SAJzhz6bjmpp4jZCDOtOIg"+discord_invite_url = "https://discord.gg/wJZ7DVW8mm"[payouts]payout_eligibility = true