hash
stringlengths 40
40
| date
stringdate 2022-11-17 13:04:47
2025-03-21 17:04:41
| author
stringclasses 141
values | commit_message
stringlengths 22
166
| is_merge
bool 1
class | git_diff
stringlengths 238
9.63M
| type
stringclasses 17
values | masked_commit_message
stringlengths 6
143
|
|---|---|---|---|---|---|---|---|
afae5906a8d6ceab136393c7588bfc447e822ddc
|
2024-07-23 20:54:56
|
Sakil Mostak
|
refactor(connector): [Itaubank] add dynamic fields for pix (#5419)
| false
|
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index e55485e945a..03dbf539c3b 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -9847,6 +9847,24 @@
}
}
}
+ },
+ {
+ "type": "string",
+ "enum": [
+ "user_pix_key"
+ ]
+ },
+ {
+ "type": "string",
+ "enum": [
+ "user_cpf"
+ ]
+ },
+ {
+ "type": "string",
+ "enum": [
+ "user_cnpj"
+ ]
}
],
"description": "Possible field type of required fields in payment_method_data"
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index 79cb60da2d7..85212ec7d0c 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -476,6 +476,9 @@ pub enum FieldType {
UserDateOfBirth,
UserVpaId,
LanguagePreference { options: Vec<String> },
+ UserPixKey,
+ UserCpf,
+ UserCnpj,
}
impl FieldType {
@@ -562,6 +565,9 @@ impl PartialEq for FieldType {
) => options_self.eq(options_other),
(Self::UserDateOfBirth, Self::UserDateOfBirth) => true,
(Self::UserVpaId, Self::UserVpaId) => true,
+ (Self::UserPixKey, Self::UserPixKey) => true,
+ (Self::UserCpf, Self::UserCpf) => true,
+ (Self::UserCnpj, Self::UserCnpj) => true,
(Self::LanguagePreference { .. }, Self::LanguagePreference { .. }) => true,
_unused => false,
}
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index 6121d8e503f..ffa3d81edea 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -8871,7 +8871,49 @@ impl Default for super::settings::RequiredFields {
}
),
])}),
- ])))
+ (enums::PaymentMethodType::Pix,
+ ConnectorFields {
+ fields: HashMap::from([
+ (
+ enums::Connector::Itaubank,
+ RequiredFieldFinal {
+ mandate: HashMap::new(),
+ non_mandate: HashMap::new(),
+ common: HashMap::from(
+ [
+ (
+ "payment_method_data.bank_transfer.pix.pix_key".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.bank_transfer.pix.pix_key".to_string(),
+ display_name: "pix_key".to_string(),
+ field_type: enums::FieldType::UserPixKey,
+ value: None,
+ }
+ ),
+ (
+ "payment_method_data.bank_transfer.pix.cnpj".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.bank_transfer.pix.cnpj".to_string(),
+ display_name: "cnpj".to_string(),
+ field_type: enums::FieldType::UserCnpj,
+ value: None,
+ }
+ ),
+ (
+ "payment_method_data.bank_transfer.pix.cpf".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.bank_transfer.pix.cpf".to_string(),
+ display_name: "cpf".to_string(),
+ field_type: enums::FieldType::UserCpf,
+ value: None,
+ }
+ ),
+ ]
+ ),
+ }
+ ),
+ ])}),
+ ])))
]))
}
}
|
refactor
|
[Itaubank] add dynamic fields for pix (#5419)
|
ea6bce663dcb084b5990834cb922eec5c626e897
|
2023-05-23 16:11:45
|
Sangamesh Kulkarni
|
test(connector): [Stripe] Fix redirection UI tests (#1215)
| false
|
diff --git a/crates/router/tests/connectors/stripe_ui.rs b/crates/router/tests/connectors/stripe_ui.rs
index f50d6670155..019979d1aee 100644
--- a/crates/router/tests/connectors/stripe_ui.rs
+++ b/crates/router/tests/connectors/stripe_ui.rs
@@ -23,7 +23,7 @@ async fn should_make_3ds_payment(c: WebDriver) -> Result<(), WebDriverError> {
async fn should_make_3ds_mandate_payment(c: WebDriver) -> Result<(), WebDriverError> {
let conn = StripeSeleniumTest {};
conn.make_redirection_payment(c, vec![
- Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/card?cname=CL-BRW1&ccnum=4000002500003155&expmonth=10&expyear=25&cvv=123&amount=10&country=US¤cy=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD&apikey=dev_DREFLPJC5SFpFBupKYovdCfg37xgM20g7oXVLQMHXP3t2kJMRSy6aof1rTe6tyyK&return_url={CHEKOUT_BASE_URL}/payments"))),
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/card?cname=CL-BRW1&ccnum=4000002500003155&expmonth=10&expyear=25&cvv=123&amount=10&country=US¤cy=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD&return_url={CHEKOUT_BASE_URL}/payments"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Click(By::Id("test-source-authorize-3ds"))),
Event::Assert(Assert::IsPresent("succeeded")),
@@ -42,7 +42,7 @@ async fn should_fail_recurring_payment_due_to_authentication(
) -> Result<(), WebDriverError> {
let conn = StripeSeleniumTest {};
conn.make_redirection_payment(c, vec![
- Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/card?cname=CL-BRW1&ccnum=4000002760003184&expmonth=10&expyear=25&cvv=123&amount=10&country=US¤cy=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD&apikey=dev_DREFLPJC5SFpFBupKYovdCfg37xgM20g7oXVLQMHXP3t2kJMRSy6aof1rTe6tyyK&return_url={CHEKOUT_BASE_URL}/payments"))),
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/card?cname=CL-BRW1&ccnum=4000002760003184&expmonth=10&expyear=25&cvv=123&amount=10&country=US¤cy=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD&return_url={CHEKOUT_BASE_URL}/payments"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Click(By::Id("test-source-authorize-3ds"))),
Event::Assert(Assert::IsPresent("succeeded")),
@@ -61,7 +61,7 @@ async fn should_make_3ds_mandate_with_zero_dollar_payment(
) -> Result<(), WebDriverError> {
let conn = StripeSeleniumTest {};
conn.make_redirection_payment(c, vec![
- Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/card?cname=CL-BRW1&ccnum=4000002500003155&expmonth=10&expyear=25&cvv=123&amount=0&country=US¤cy=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD&apikey=dev_DREFLPJC5SFpFBupKYovdCfg37xgM20g7oXVLQMHXP3t2kJMRSy6aof1rTe6tyyK&return_url={CHEKOUT_BASE_URL}/payments"))),
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/card?cname=CL-BRW1&ccnum=4000002500003155&expmonth=10&expyear=25&cvv=123&amount=0&country=US¤cy=USD&mandate_data[customer_acceptance][acceptance_type]=offline&mandate_data[customer_acceptance][accepted_at]=1963-05-03T04:07:52.723Z&mandate_data[customer_acceptance][online][ip_address]=127.0.0.1&mandate_data[customer_acceptance][online][user_agent]=amet%20irure%20esse&mandate_data[mandate_type][multi_use][amount]=700&mandate_data[mandate_type][multi_use][currency]=USD&return_url={CHEKOUT_BASE_URL}/payments"))),
Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
Event::Trigger(Trigger::Click(By::Id("test-source-authorize-3ds"))),
Event::Assert(Assert::IsPresent("succeeded")),
|
test
|
[Stripe] Fix redirection UI tests (#1215)
|
0a03d69b1627893b09688d833f86c5e54a76ae37
|
2023-08-04 13:28:37
|
Sanchith Hegde
|
ci: use `sccache-action` for caching compilation artifacts (#1857)
| false
|
diff --git a/.github/workflows/CI-pr.yml b/.github/workflows/CI-pr.yml
index 61d4c6f7df5..a13f0eb51e0 100644
--- a/.github/workflows/CI-pr.yml
+++ b/.github/workflows/CI-pr.yml
@@ -35,6 +35,9 @@ env:
RUST_BACKTRACE: short
# Use cargo's sparse index protocol
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
+ # Enable and use the sccache action for caching
+ SCCACHE_GHA_ENABLED: "true"
+ RUSTC_WRAPPER: "sccache"
jobs:
formatting:
@@ -84,9 +87,7 @@ jobs:
with:
toolchain: 1.65
- - uses: Swatinem/[email protected]
- with:
- save-if: ${{ github.event_name == 'push' }}
+ - uses: mozilla-actions/[email protected]
- name: Install cargo-hack
uses: baptiste0928/[email protected]
@@ -293,9 +294,7 @@ jobs:
# with:
# crate: cargo-nextest
- - uses: Swatinem/[email protected]
- with:
- save-if: ${{ github.event_name == 'push' }}
+ - uses: mozilla-actions/[email protected]
# - name: Setup Embark Studios lint rules
# shell: bash
diff --git a/.github/workflows/CI-push.yml b/.github/workflows/CI-push.yml
index e087c694c54..cba1fb715d4 100644
--- a/.github/workflows/CI-push.yml
+++ b/.github/workflows/CI-push.yml
@@ -19,6 +19,32 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
+env:
+ # Disable incremental compilation.
+ #
+ # Incremental compilation is useful as part of an edit-build-test-edit cycle,
+ # as it lets the compiler avoid recompiling code that hasn't changed. However,
+ # on CI, we're not making small edits; we're almost always building the entire
+ # project from scratch. Thus, incremental compilation on CI actually
+ # introduces *additional* overhead to support making future builds
+ # faster...but no future builds will ever occur in any given CI environment.
+ #
+ # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
+ # for details.
+ CARGO_INCREMENTAL: 0
+ # Allow more retries for network requests in cargo (downloading crates) and
+ # rustup (installing toolchains). This should help to reduce flaky CI failures
+ # from transient network timeouts or other issues.
+ CARGO_NET_RETRY: 10
+ RUSTUP_MAX_RETRIES: 10
+ # Don't emit giant backtraces in the CI logs.
+ RUST_BACKTRACE: short
+ # Use cargo's sparse index protocol
+ CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
+ # Enable and use the sccache action for caching
+ SCCACHE_GHA_ENABLED: "true"
+ RUSTC_WRAPPER: "sccache"
+
jobs:
formatting:
name: Check formatting
@@ -63,9 +89,7 @@ jobs:
with:
toolchain: 1.65
- - uses: Swatinem/[email protected]
- with:
- save-if: ${{ github.event_name == 'push' }}
+ - uses: mozilla-actions/[email protected]
- name: Install cargo-hack
uses: baptiste0928/[email protected]
@@ -138,9 +162,7 @@ jobs:
# with:
# crate: cargo-nextest
- - uses: Swatinem/[email protected]
- with:
- save-if: ${{ github.event_name == 'push' }}
+ - uses: mozilla-actions/[email protected]
# - name: Setup Embark Studios lint rules
# shell: bash
diff --git a/.github/workflows/connector-sanity-tests.yml b/.github/workflows/connector-sanity-tests.yml
index 4d6199a86d3..1aa14e56435 100644
--- a/.github/workflows/connector-sanity-tests.yml
+++ b/.github/workflows/connector-sanity-tests.yml
@@ -38,6 +38,9 @@ env:
RUST_BACKTRACE: short
# Use cargo's sparse index protocol
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
+ # Enable and use the sccache action for caching
+ SCCACHE_GHA_ENABLED: "true"
+ RUSTC_WRAPPER: "sccache"
jobs:
test_connectors:
@@ -86,7 +89,7 @@ jobs:
with:
toolchain: stable
- - uses: Swatinem/[email protected]
+ - uses: mozilla-actions/[email protected]
- name: Decrypt connector auth file
env:
diff --git a/.github/workflows/connector-ui-sanity-tests.yml b/.github/workflows/connector-ui-sanity-tests.yml
index 9c81d715b19..4809451d51e 100644
--- a/.github/workflows/connector-ui-sanity-tests.yml
+++ b/.github/workflows/connector-ui-sanity-tests.yml
@@ -2,9 +2,9 @@ name: Connector UI Sanity Tests
on:
workflow_dispatch:
-
+
pull_request_review:
- types:
+ types:
- submitted
merge_group:
types:
@@ -26,7 +26,7 @@ env:
#
# See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
- CARGO_INCREMENTAL: 1
+ CARGO_INCREMENTAL: 0
# Allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). This should help to reduce flaky CI failures
# from transient network timeouts or other issues.
@@ -36,6 +36,9 @@ env:
RUST_BACKTRACE: short
# Use cargo's sparse index protocol
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
+ # Enable and use the sccache action for caching
+ SCCACHE_GHA_ENABLED: "true"
+ RUSTC_WRAPPER: "sccache"
jobs:
test_connectors:
@@ -73,14 +76,13 @@ jobs:
# do not use more than 2 runners, try to group less time taking connectors together
- stripe,airwallex,bluesnap,checkout,trustpay_3ds,payu,authorizedotnet,aci,noon
- adyen_uk,shift4,worldline,multisafepay,paypal,mollie,nexinets
-
steps:
- name: Ignore Tests incase of pull request
if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
shell: bash
run: |
- echo "Skipped tests as the event is pull request"
+ echo "Skipped tests as the event is pull request"
exit 0
- name: Checkout repository
@@ -105,34 +107,34 @@ jobs:
run: echo "CONNECTOR_TESTS_FILE_PATH=$HOME/target/test/connector_tests.json" >> $GITHUB_ENV
- name: Set ignore_browser_profile usage in env
- if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
+ if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
shell: bash
run: echo "IGNORE_BROWSER_PROFILE=true" >> $GITHUB_ENV
- name: Install latest compiler
- if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
+ if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- - uses: Swatinem/[email protected]
+ - uses: mozilla-actions/[email protected]
- uses: baptiste0928/[email protected]
- if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
+ if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
with:
crate: diesel_cli
features: postgres
args: "--no-default-features"
- name: Diesel migration run
- if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
+ if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
shell: bash
env:
DATABASE_URL: postgres://db_user:db_pass@localhost:5432/hyperswitch_db
run: diesel migration run
- name: Start server and run tests
- if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
+ if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
env:
UI_TESTCASES_PATH: ${{ secrets.UI_TESTCASES_PATH }}
INPUT: ${{ matrix.connector }}
@@ -140,12 +142,12 @@ jobs:
run: sh .github/scripts/run_ui_tests.sh
- name: View test results
- if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
+ if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
shell: bash
run: cat tests/test_results.log
- name: Check test results
- if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
+ if: (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') || (github.event_name == 'workflow_dispatch')
shell: bash
run: |
if test "$( grep 'test result: FAILED' -r tests/test_results.log | wc -l )" -gt "0"; then
diff --git a/.github/workflows/postman-collection-runner.yml b/.github/workflows/postman-collection-runner.yml
index 37c1bdd1b31..b7615524c31 100644
--- a/.github/workflows/postman-collection-runner.yml
+++ b/.github/workflows/postman-collection-runner.yml
@@ -16,7 +16,9 @@ env:
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: short
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
- CONNECTORS: aci, adyen_uk, airwallex, authorizedotnet, bambora, bambora_3ds, bluesnap, checkout, globalpay, mollie, nexinets, nmi, shift4, stripe, trustpay, worldline
+ CONNECTORS: "aci, adyen_uk, airwallex, authorizedotnet, bambora, bambora_3ds, bluesnap, checkout, globalpay, mollie, nexinets, nmi, shift4, stripe, trustpay, worldline"
+ SCCACHE_GHA_ENABLED: "true"
+ RUSTC_WRAPPER: "sccache"
jobs:
runner:
@@ -33,6 +35,7 @@ jobs:
--health-retries 5
ports:
- 6379:6379
+
postgres:
image: "${{ github.event_name != 'pull_request' && 'postgres:14.5' || '' }}"
env:
@@ -52,7 +55,7 @@ jobs:
if: github.event_name == 'pull_request'
shell: bash
run: |
- echo "Skipped tests as the event is pull request"
+ echo "Skipped tests as the event is pull request"
exit 0
- name: Repository checkout
@@ -87,9 +90,8 @@ jobs:
with:
toolchain: stable
- - name: Build and Cache Rust Dependencies
+ - uses: mozilla-actions/[email protected]
if: github.event_name != 'pull_request'
- uses: Swatinem/[email protected]
- name: Install Diesel CLI with Postgres Support
if: github.event_name != 'pull_request'
@@ -112,12 +114,12 @@ jobs:
cargo run &
COUNT=0
# Wait for the server to start in port 8080
- while netstat -lnt | awk '$4 ~ /:8080$/ {exit 1}'; do
+ while netstat -lnt | awk '$4 ~ /:8080$/ {exit 1}'; do
# Wait for 15 mins to start otherwise kill the task
if [ $COUNT -gt 90 ];
then
exit 1
- else
+ else
COUNT=$((COUNT+1))
sleep 10
fi
diff --git a/.github/workflows/validate-openapi-spec.yml b/.github/workflows/validate-openapi-spec.yml
index 72b76157f10..a25380ffad7 100644
--- a/.github/workflows/validate-openapi-spec.yml
+++ b/.github/workflows/validate-openapi-spec.yml
@@ -11,6 +11,32 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
+env:
+ # Disable incremental compilation.
+ #
+ # Incremental compilation is useful as part of an edit-build-test-edit cycle,
+ # as it lets the compiler avoid recompiling code that hasn't changed. However,
+ # on CI, we're not making small edits; we're almost always building the entire
+ # project from scratch. Thus, incremental compilation on CI actually
+ # introduces *additional* overhead to support making future builds
+ # faster...but no future builds will ever occur in any given CI environment.
+ #
+ # See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
+ # for details.
+ CARGO_INCREMENTAL: 0
+ # Allow more retries for network requests in cargo (downloading crates) and
+ # rustup (installing toolchains). This should help to reduce flaky CI failures
+ # from transient network timeouts or other issues.
+ CARGO_NET_RETRY: 10
+ RUSTUP_MAX_RETRIES: 10
+ # Don't emit giant backtraces in the CI logs.
+ RUST_BACKTRACE: short
+ # Use cargo's sparse index protocol
+ CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
+ # Enable and use the sccache action for caching
+ SCCACHE_GHA_ENABLED: "true"
+ RUSTC_WRAPPER: "sccache"
+
jobs:
validate_json:
name: Validate generated OpenAPI spec file
@@ -35,6 +61,8 @@ jobs:
with:
toolchain: stable
+ - uses: mozilla-actions/[email protected]
+
- name: Generate the OpenAPI spec file
shell: bash
run: cargo run --features openapi -- generate-openapi-spec
|
ci
|
use `sccache-action` for caching compilation artifacts (#1857)
|
740749e18ae4458726cdf2501f3d3b789c819f7a
|
2024-04-01 18:49:55
|
Hrithikesh
|
feat: return customer details in payments response body (#4237)
| false
|
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 72592ec3cad..63b29306113 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -169,7 +169,7 @@ mod client_secret_tests {
}
}
-#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
+#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema, PartialEq)]
pub struct CustomerDetails {
/// The identifier for the customer.
pub id: String,
@@ -2935,6 +2935,9 @@ pub struct PaymentsResponse {
#[schema(max_length = 255, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]
pub customer_id: Option<String>,
+ /// Details of customer attached to this payment
+ pub customer: Option<CustomerDetails>,
+
/// A description of the payment
#[schema(example = "It's my first payment request")]
pub description: Option<String>,
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index d686d741c88..9aa552b86d8 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -490,6 +490,8 @@ where
))
}
+ let customer_details_response = customer.as_ref().map(ForeignInto::foreign_into);
+
headers.extend(
external_latency
.map(|latency| {
@@ -779,6 +781,7 @@ where
.set_payment_method_status(
payment_data.payment_method_info.map(|info| info.status),
)
+ .set_customer(customer_details_response.clone())
.to_owned(),
headers,
))
@@ -849,6 +852,7 @@ where
expires_on: payment_intent.session_expiry,
external_3ds_authentication_attempted: payment_attempt
.external_three_ds_authentication_attempted,
+ customer: customer_details_response,
..Default::default()
},
headers,
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index 8a53a58aabd..237dea196d6 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -1130,6 +1130,24 @@ impl ForeignFrom<storage::GatewayStatusMap> for gsm_api_types::GsmResponse {
}
}
+impl ForeignFrom<&domain::Customer> for api_models::payments::CustomerDetails {
+ fn foreign_from(customer: &domain::Customer) -> Self {
+ Self {
+ id: customer.customer_id.clone(),
+ name: customer
+ .name
+ .as_ref()
+ .map(|name| name.get_inner().to_owned()),
+ email: customer.email.clone().map(Into::into),
+ phone: customer
+ .phone
+ .as_ref()
+ .map(|phone| phone.get_inner().to_owned()),
+ phone_country_code: customer.phone_country_code.clone(),
+ }
+ }
+}
+
#[cfg(feature = "olap")]
impl ForeignTryFrom<api_types::webhook_events::EventListConstraints>
for api_types::webhook_events::EventListConstraintsInternal
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index fa9c7435632..1e16d072471 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -14338,6 +14338,14 @@
"nullable": true,
"maxLength": 255
},
+ "customer": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/CustomerDetails"
+ }
+ ],
+ "nullable": true
+ },
"description": {
"type": "string",
"description": "A description of the payment",
|
feat
|
return customer details in payments response body (#4237)
|
fe3cf54781302c733c1682ded2c1735544407a5f
|
2024-01-10 16:57:53
|
Branislav Kontur
|
chore: nits and small code improvements found during investigation of PR#3168 (#3259)
| false
|
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 886de4174db..39b404d0f55 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -806,7 +806,7 @@ impl CardData for api::Card {
let year = self.get_card_expiry_year_2_digit()?;
Ok(Secret::new(format!(
"{}{}{}",
- self.card_exp_month.peek().clone(),
+ self.card_exp_month.peek(),
delimiter,
year.peek()
)))
@@ -817,14 +817,14 @@ impl CardData for api::Card {
"{}{}{}",
year.peek(),
delimiter,
- self.card_exp_month.peek().clone()
+ self.card_exp_month.peek()
))
}
fn get_expiry_date_as_mmyyyy(&self, delimiter: &str) -> Secret<String> {
let year = self.get_expiry_year_4_digit();
Secret::new(format!(
"{}{}{}",
- self.card_exp_month.peek().clone(),
+ self.card_exp_month.peek(),
delimiter,
year.peek()
))
@@ -1211,7 +1211,7 @@ where
{
let connector_meta_secret =
connector_meta.ok_or_else(missing_field_err("connector_meta_data"))?;
- let json = connector_meta_secret.peek().clone();
+ let json = connector_meta_secret.expose();
json.parse_value(std::any::type_name::<T>()).switch()
}
diff --git a/crates/router/src/connector/worldline/transformers.rs b/crates/router/src/connector/worldline/transformers.rs
index c00913aa57d..c55663d59f4 100644
--- a/crates/router/src/connector/worldline/transformers.rs
+++ b/crates/router/src/connector/worldline/transformers.rs
@@ -342,7 +342,7 @@ fn make_card_request(
req: &PaymentsAuthorizeData,
ccard: &payments::Card,
) -> Result<CardPaymentMethod, error_stack::Report<errors::ConnectorError>> {
- let expiry_year = ccard.card_exp_year.peek().clone();
+ let expiry_year = ccard.card_exp_year.peek();
let secret_value = format!(
"{}{}",
ccard.card_exp_month.peek(),
diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rs
index 8be1876aed5..ad3a7638774 100644
--- a/crates/router/src/core/fraud_check.rs
+++ b/crates/router/src/core/fraud_check.rs
@@ -2,7 +2,7 @@ use std::fmt::Debug;
use api_models::{admin::FrmConfigs, enums as api_enums, payments::AdditionalPaymentData};
use error_stack::ResultExt;
-use masking::PeekInterface;
+use masking::{ExposeInterface, PeekInterface};
use router_env::{
logger,
tracing::{self, instrument},
@@ -167,10 +167,9 @@ where
match frm_configs_option {
Some(frm_configs_value) => {
let frm_configs_struct: Vec<FrmConfigs> = frm_configs_value
- .iter()
+ .into_iter()
.map(|config| { config
- .peek()
- .clone()
+ .expose()
.parse_value("FrmConfigs")
.change_context(errors::ApiErrorResponse::InvalidDataFormat {
field_name: "frm_configs".to_string(),
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index c25b0241581..070bca234c8 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -47,7 +47,7 @@ impl Vaultable for api::Card {
exp_month: self.card_exp_month.peek().clone(),
name_on_card: self
.card_holder_name
- .clone()
+ .as_ref()
.map(|name| name.peek().clone()),
nickname: None,
card_last_four: None,
|
chore
|
nits and small code improvements found during investigation of PR#3168 (#3259)
|
70b86b71e4809d2a47c6bc1214f72c37d3325c37
|
2023-12-14 16:45:10
|
Sampras Lopes
|
fix(locker): fix double serialization for json request (#3134)
| false
|
diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rs
index 71c2cf8f200..5506dc7eb9a 100644
--- a/crates/router/src/core/payment_methods/transformers.rs
+++ b/crates/router/src/core/payment_methods/transformers.rs
@@ -313,9 +313,6 @@ pub async fn mk_add_locker_request_hs<'a>(
.change_context(errors::VaultError::RequestEncodingFailed)?;
let jwe_payload = mk_basilisk_req(jwekey, &jws, locker_choice).await?;
-
- let body = utils::Encode::<encryption::JweBody>::encode_to_value(&jwe_payload)
- .change_context(errors::VaultError::RequestEncodingFailed)?;
let mut url = match locker_choice {
api_enums::LockerChoice::Basilisk => locker.host.to_owned(),
api_enums::LockerChoice::Tartarus => locker.host_rs.to_owned(),
@@ -323,7 +320,7 @@ pub async fn mk_add_locker_request_hs<'a>(
url.push_str("/cards/add");
let mut request = services::Request::new(services::Method::Post, &url);
request.add_header(headers::CONTENT_TYPE, "application/json".into());
- request.set_body(RequestContent::Json(Box::new(body.to_string())));
+ request.set_body(RequestContent::Json(Box::new(jwe_payload)));
Ok(request)
}
@@ -459,9 +456,6 @@ pub async fn mk_get_card_request_hs(
let target_locker = locker_choice.unwrap_or(api_enums::LockerChoice::Basilisk);
let jwe_payload = mk_basilisk_req(jwekey, &jws, target_locker).await?;
-
- let body = utils::Encode::<encryption::JweBody>::encode_to_value(&jwe_payload)
- .change_context(errors::VaultError::RequestEncodingFailed)?;
let mut url = match target_locker {
api_enums::LockerChoice::Basilisk => locker.host.to_owned(),
api_enums::LockerChoice::Tartarus => locker.host_rs.to_owned(),
@@ -469,7 +463,7 @@ pub async fn mk_get_card_request_hs(
url.push_str("/cards/retrieve");
let mut request = services::Request::new(services::Method::Post, &url);
request.add_header(headers::CONTENT_TYPE, "application/json".into());
- request.set_body(RequestContent::Json(Box::new(body.to_string())));
+ request.set_body(RequestContent::Json(Box::new(jwe_payload)));
Ok(request)
}
@@ -537,13 +531,11 @@ pub async fn mk_delete_card_request_hs(
let jwe_payload = mk_basilisk_req(jwekey, &jws, api_enums::LockerChoice::Basilisk).await?;
- let body = utils::Encode::<encryption::JweBody>::encode_to_value(&jwe_payload)
- .change_context(errors::VaultError::RequestEncodingFailed)?;
let mut url = locker.host.to_owned();
url.push_str("/cards/delete");
let mut request = services::Request::new(services::Method::Post, &url);
request.add_header(headers::CONTENT_TYPE, "application/json".into());
- request.set_body(RequestContent::Json(Box::new(body.to_string())));
+ request.set_body(RequestContent::Json(Box::new(jwe_payload)));
Ok(request)
}
@@ -602,14 +594,12 @@ pub fn mk_crud_locker_request(
path: &str,
req: api::TokenizePayloadEncrypted,
) -> CustomResult<services::Request, errors::VaultError> {
- let body = utils::Encode::<api::TokenizePayloadEncrypted>::encode_to_value(&req)
- .change_context(errors::VaultError::RequestEncodingFailed)?;
let mut url = locker.basilisk_host.to_owned();
url.push_str(path);
let mut request = services::Request::new(services::Method::Post, &url);
request.add_default_headers();
request.add_header(headers::CONTENT_TYPE, "application/json".into());
- request.set_body(RequestContent::Json(Box::new(body.to_string())));
+ request.set_body(RequestContent::Json(Box::new(req)));
Ok(request)
}
|
fix
|
fix double serialization for json request (#3134)
|
c8d35449cfe6113f184a972100bfc1cdeab9b662
|
2023-09-25 20:03:33
|
github-actions
|
chore(version): v1.46.0
| false
|
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 275e35aeb32..eb54ed9a85f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,33 @@ All notable changes to HyperSwitch will be documented here.
- - -
+## 1.46.0 (2023-09-25)
+
+### Features
+
+- **payment_attempt:** Add kv for find last successful attempt ([#2206](https://github.com/juspay/hyperswitch/pull/2206)) ([`d3157f0`](https://github.com/juspay/hyperswitch/commit/d3157f0bd6a0246c28182c88335d95ed6ae298a9))
+- **payments:** Add api locking for payments core ([#1898](https://github.com/juspay/hyperswitch/pull/1898)) ([`5d66156`](https://github.com/juspay/hyperswitch/commit/5d661561322a21f792e2cdb2ae8c30de96ce7d02))
+
+### Bug Fixes
+
+- **compatibility:** Update BillingDetails mappings in SCL ([#1926](https://github.com/juspay/hyperswitch/pull/1926)) ([`a48f986`](https://github.com/juspay/hyperswitch/commit/a48f9865bcd29d5c3fc5c380dde34b11c6bb254f))
+- **connector:** [stripe] use display impl for expiry date ([#2359](https://github.com/juspay/hyperswitch/pull/2359)) ([`35622af`](https://github.com/juspay/hyperswitch/commit/35622aff7a042764729565db1ed5aca2257603ba))
+- **drainer:** Ignore errors in case the stream is empty ([#2261](https://github.com/juspay/hyperswitch/pull/2261)) ([`53de86f`](https://github.com/juspay/hyperswitch/commit/53de86f60d14981087626e1a2a5856089b6f3899))
+- Add health metric to drainer ([#2217](https://github.com/juspay/hyperswitch/pull/2217)) ([`4e8471b`](https://github.com/juspay/hyperswitch/commit/4e8471be501806ceeb96c7683be00600c3c1a0d2))
+
+### Refactors
+
+- Enable `logs` feature flag in router crate ([#2358](https://github.com/juspay/hyperswitch/pull/2358)) ([`e4af381`](https://github.com/juspay/hyperswitch/commit/e4af3812d55689aefb5bb8ed6f12a6c9c0643a51))
+
+### Testing
+
+- **postman:** Update postman collection files ([`d7affab`](https://github.com/juspay/hyperswitch/commit/d7affab455adf1eeccaca3005797a81e51c902ac))
+
+**Full Changelog:** [`v1.45.0...v1.46.0`](https://github.com/juspay/hyperswitch/compare/v1.45.0...v1.46.0)
+
+- - -
+
+
## 1.45.0 (2023-09-22)
### Features
|
chore
|
v1.46.0
|
8a9fed36fc7f01f54d9a2e725abf459fac857222
|
2024-09-24 05:54:48
|
github-actions
|
chore(version): 2024.09.24.0
| false
|
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 46ac76cf7ae..c3e2bd01a15 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,21 @@ All notable changes to HyperSwitch will be documented here.
- - -
+## 2024.09.24.0
+
+### Features
+
+- **refunds:** Profile level refunds aggregate ([#5931](https://github.com/juspay/hyperswitch/pull/5931)) ([`f5e6165`](https://github.com/juspay/hyperswitch/commit/f5e61659d10c6670df80e4ff8e3e0a5fd3b7ec6b))
+
+### Bug Fixes
+
+- **payment_link:** Payment link render issue when `transaction_details` not passed ([#5948](https://github.com/juspay/hyperswitch/pull/5948)) ([`035906e`](https://github.com/juspay/hyperswitch/commit/035906e9b1b1a1e52fe970db5d7e028556fa82b4))
+- Log detailed error reports during deep health check failures ([#5984](https://github.com/juspay/hyperswitch/pull/5984)) ([`19e52b4`](https://github.com/juspay/hyperswitch/commit/19e52b420002c681a5a7312e6330e6f4726809f5))
+
+**Full Changelog:** [`2024.09.23.0...2024.09.24.0`](https://github.com/juspay/hyperswitch/compare/2024.09.23.0...2024.09.24.0)
+
+- - -
+
## 2024.09.23.0
### Features
|
chore
|
2024.09.24.0
|
4ce86afd4e00a036eba9b70916b4880a049e4d9f
|
2022-11-23 20:58:07
|
Narayan Bhat
|
feat(core): add server base_url in server config (#12)
| false
|
diff --git a/crates/router/src/configs/defaults.toml b/crates/router/src/configs/defaults.toml
index 75de8516d92..6cb55040318 100644
--- a/crates/router/src/configs/defaults.toml
+++ b/crates/router/src/configs/defaults.toml
@@ -4,6 +4,7 @@
port = 8080
host = "127.0.0.1"
request_body_limit = 16_384 # Post request body is limited to 16k.
+base_url = "http://localhost:8080"
[proxy]
# http_url = ""
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 07fb6a41a47..d4dfbfb360c 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -62,6 +62,7 @@ pub struct Server {
pub port: u16,
pub host: String,
pub request_body_limit: usize,
+ pub base_url: String,
}
#[derive(Debug, Deserialize, Clone)]
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 1b1f682c48b..294b10da5af 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -291,32 +291,24 @@ fn validate_new_mandate_request(req: &api::PaymentsRequest) -> RouterResult<()>
Ok(())
}
-pub fn create_server_url(server: &Server) -> String {
- if server.host.eq("127.0.0.1") || server.host.eq("localhost") {
- format!("http://{}:{}", server.host, server.port)
- } else {
- format!("https://{}", server.host)
- }
-}
pub fn create_startpay_url(
server: &Server,
payment_attempt: &storage::PaymentAttempt,
payment_intent: &storage::PaymentIntent,
) -> String {
- let server_url = create_server_url(server);
-
format!(
"{}/payments/start/{}/{}/{}",
- server_url, payment_intent.payment_id, payment_intent.merchant_id, payment_attempt.txn_id
+ server.base_url,
+ payment_intent.payment_id,
+ payment_intent.merchant_id,
+ payment_attempt.txn_id
)
}
pub fn create_redirect_url(server: &Server, payment_attempt: &storage::PaymentAttempt) -> String {
- let server_url = create_server_url(server);
-
format!(
"{}/payments/{}/{}/response/{}",
- server_url,
+ server.base_url,
payment_attempt.payment_id,
payment_attempt.merchant_id,
payment_attempt.connector
|
feat
|
add server base_url in server config (#12)
|
39d2d6c43800f609070b61a6148ddef7e40001bc
|
2025-01-21 17:14:14
|
Sarthak Soni
|
feat(routing): Integrate global success rates (#6950)
| false
|
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index b282566e509..d218e4d2074 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -25202,9 +25202,19 @@
}
],
"nullable": true
+ },
+ "specificity_level": {
+ "$ref": "#/components/schemas/SuccessRateSpecificityLevel"
}
}
},
+ "SuccessRateSpecificityLevel": {
+ "type": "string",
+ "enum": [
+ "merchant",
+ "global"
+ ]
+ },
"SupportedPaymentMethod": {
"allOf": [
{
diff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rs
index 2e570816ab4..8e502767575 100644
--- a/crates/api_models/src/routing.rs
+++ b/crates/api_models/src/routing.rs
@@ -779,6 +779,7 @@ impl Default for SuccessBasedRoutingConfig {
duration_in_mins: Some(5),
max_total_count: Some(2),
}),
+ specificity_level: SuccessRateSpecificityLevel::default(),
}),
}
}
@@ -801,6 +802,8 @@ pub struct SuccessBasedRoutingConfigBody {
pub default_success_rate: Option<f64>,
pub max_aggregates_size: Option<u32>,
pub current_block_threshold: Option<CurrentBlockThreshold>,
+ #[serde(default)]
+ pub specificity_level: SuccessRateSpecificityLevel,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)]
@@ -809,6 +812,14 @@ pub struct CurrentBlockThreshold {
pub max_total_count: Option<u64>,
}
+#[derive(serde::Serialize, serde::Deserialize, Debug, Default, Clone, ToSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum SuccessRateSpecificityLevel {
+ #[default]
+ Merchant,
+ Global,
+}
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct SuccessBasedRoutingPayloadWrapper {
pub updated_config: SuccessBasedRoutingConfig,
@@ -849,6 +860,7 @@ impl SuccessBasedRoutingConfigBody {
.as_mut()
.map(|threshold| threshold.update(current_block_threshold));
}
+ self.specificity_level = new.specificity_level
}
}
diff --git a/crates/diesel_models/src/dynamic_routing_stats.rs b/crates/diesel_models/src/dynamic_routing_stats.rs
index c055359d8b0..90cf4689080 100644
--- a/crates/diesel_models/src/dynamic_routing_stats.rs
+++ b/crates/diesel_models/src/dynamic_routing_stats.rs
@@ -20,6 +20,7 @@ pub struct DynamicRoutingStatsNew {
pub conclusive_classification: common_enums::SuccessBasedRoutingConclusiveState,
pub created_at: time::PrimitiveDateTime,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
+ pub global_success_based_connector: Option<String>,
}
#[derive(Clone, Debug, Eq, PartialEq, Queryable, Selectable, Insertable)]
@@ -40,4 +41,5 @@ pub struct DynamicRoutingStats {
pub conclusive_classification: common_enums::SuccessBasedRoutingConclusiveState,
pub created_at: time::PrimitiveDateTime,
pub payment_method_type: Option<common_enums::PaymentMethodType>,
+ pub global_success_based_connector: Option<String>,
}
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index dfe3d5acc23..7930ad5d9ae 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -435,6 +435,8 @@ diesel::table! {
created_at -> Timestamp,
#[max_length = 64]
payment_method_type -> Nullable<Varchar>,
+ #[max_length = 64]
+ global_success_based_connector -> Nullable<Varchar>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index b5361f4c95c..13abf8ee64b 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -447,6 +447,8 @@ diesel::table! {
created_at -> Timestamp,
#[max_length = 64]
payment_method_type -> Nullable<Varchar>,
+ #[max_length = 64]
+ global_success_based_connector -> Nullable<Varchar>,
}
}
diff --git a/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs b/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs
index fca4ff61fcc..278a2b50d15 100644
--- a/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs
+++ b/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs
@@ -1,15 +1,17 @@
use api_models::routing::{
CurrentBlockThreshold, RoutableConnectorChoice, RoutableConnectorChoiceWithStatus,
- SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody,
+ SuccessBasedRoutingConfig, SuccessBasedRoutingConfigBody, SuccessRateSpecificityLevel,
};
use common_utils::{ext_traits::OptionExt, transformers::ForeignTryFrom};
use error_stack::ResultExt;
use router_env::{instrument, logger, tracing};
pub use success_rate::{
- success_rate_calculator_client::SuccessRateCalculatorClient, CalSuccessRateConfig,
+ success_rate_calculator_client::SuccessRateCalculatorClient, CalGlobalSuccessRateConfig,
+ CalGlobalSuccessRateRequest, CalGlobalSuccessRateResponse, CalSuccessRateConfig,
CalSuccessRateRequest, CalSuccessRateResponse,
CurrentBlockThreshold as DynamicCurrentThreshold, InvalidateWindowsRequest,
- InvalidateWindowsResponse, LabelWithStatus, UpdateSuccessRateWindowConfig,
+ InvalidateWindowsResponse, LabelWithStatus,
+ SuccessRateSpecificityLevel as ProtoSpecificityLevel, UpdateSuccessRateWindowConfig,
UpdateSuccessRateWindowRequest, UpdateSuccessRateWindowResponse,
};
#[allow(
@@ -51,6 +53,15 @@ pub trait SuccessBasedDynamicRouting: dyn_clone::DynClone + Send + Sync {
id: String,
headers: GrpcHeaders,
) -> DynamicRoutingResult<InvalidateWindowsResponse>;
+ /// To calculate both global and merchant specific success rate for the list of chosen connectors
+ async fn calculate_entity_and_global_success_rate(
+ &self,
+ id: String,
+ success_rate_based_config: SuccessBasedRoutingConfig,
+ params: String,
+ label_input: Vec<RoutableConnectorChoice>,
+ headers: GrpcHeaders,
+ ) -> DynamicRoutingResult<CalGlobalSuccessRateResponse>;
}
#[async_trait::async_trait]
@@ -113,6 +124,7 @@ impl SuccessBasedDynamicRouting for SuccessRateCalculatorClient<Client> {
.transpose()?;
let labels_with_status = label_input
+ .clone()
.into_iter()
.map(|conn_choice| LabelWithStatus {
label: conn_choice.routable_connector_choice.to_string(),
@@ -120,12 +132,21 @@ impl SuccessBasedDynamicRouting for SuccessRateCalculatorClient<Client> {
})
.collect();
+ let global_labels_with_status = label_input
+ .into_iter()
+ .map(|conn_choice| LabelWithStatus {
+ label: conn_choice.routable_connector_choice.connector.to_string(),
+ status: conn_choice.status,
+ })
+ .collect();
+
let request = grpc_client::create_grpc_request(
UpdateSuccessRateWindowRequest {
id,
params,
labels_with_status,
config,
+ global_labels_with_status,
},
headers,
);
@@ -165,6 +186,55 @@ impl SuccessBasedDynamicRouting for SuccessRateCalculatorClient<Client> {
Ok(response)
}
+
+ async fn calculate_entity_and_global_success_rate(
+ &self,
+ id: String,
+ success_rate_based_config: SuccessBasedRoutingConfig,
+ params: String,
+ label_input: Vec<RoutableConnectorChoice>,
+ headers: GrpcHeaders,
+ ) -> DynamicRoutingResult<CalGlobalSuccessRateResponse> {
+ let labels = label_input
+ .clone()
+ .into_iter()
+ .map(|conn_choice| conn_choice.to_string())
+ .collect::<Vec<_>>();
+
+ let global_labels = label_input
+ .into_iter()
+ .map(|conn_choice| conn_choice.connector.to_string())
+ .collect::<Vec<_>>();
+
+ let config = success_rate_based_config
+ .config
+ .map(ForeignTryFrom::foreign_try_from)
+ .transpose()?;
+
+ let request = grpc_client::create_grpc_request(
+ CalGlobalSuccessRateRequest {
+ entity_id: id,
+ entity_params: params,
+ entity_labels: labels,
+ global_labels,
+ config,
+ },
+ headers,
+ );
+
+ let response = self
+ .clone()
+ .fetch_entity_and_global_success_rate(request)
+ .await
+ .change_context(DynamicRoutingError::SuccessRateBasedRoutingFailure(
+ "Failed to fetch the entity and global success rate".to_string(),
+ ))?
+ .into_inner();
+
+ logger::info!(dynamic_routing_response=?response);
+
+ Ok(response)
+ }
}
impl ForeignTryFrom<CurrentBlockThreshold> for DynamicCurrentThreshold {
@@ -216,6 +286,30 @@ impl ForeignTryFrom<SuccessBasedRoutingConfigBody> for CalSuccessRateConfig {
.change_context(DynamicRoutingError::MissingRequiredField {
field: "default_success_rate".to_string(),
})?,
+ specificity_level: match config.specificity_level {
+ SuccessRateSpecificityLevel::Merchant => Some(ProtoSpecificityLevel::Entity.into()),
+ SuccessRateSpecificityLevel::Global => Some(ProtoSpecificityLevel::Global.into()),
+ },
+ })
+ }
+}
+
+impl ForeignTryFrom<SuccessBasedRoutingConfigBody> for CalGlobalSuccessRateConfig {
+ type Error = error_stack::Report<DynamicRoutingError>;
+ fn foreign_try_from(config: SuccessBasedRoutingConfigBody) -> Result<Self, Self::Error> {
+ Ok(Self {
+ entity_min_aggregates_size: config
+ .min_aggregates_size
+ .get_required_value("min_aggregate_size")
+ .change_context(DynamicRoutingError::MissingRequiredField {
+ field: "min_aggregates_size".to_string(),
+ })?,
+ entity_default_success_rate: config
+ .default_success_rate
+ .get_required_value("default_success_rate")
+ .change_context(DynamicRoutingError::MissingRequiredField {
+ field: "default_success_rate".to_string(),
+ })?,
})
}
}
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index f3068e1b50b..3a634ae2a54 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -624,6 +624,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::routing::StraightThroughAlgorithm,
api_models::routing::ConnectorVolumeSplit,
api_models::routing::ConnectorSelection,
+ api_models::routing::SuccessRateSpecificityLevel,
api_models::routing::ToggleDynamicRoutingQuery,
api_models::routing::ToggleDynamicRoutingPath,
api_models::routing::ast::RoutableChoiceKind,
diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs
index 1395563a30a..ca14e3e7e48 100644
--- a/crates/router/src/core/routing/helpers.rs
+++ b/crates/router/src/core/routing/helpers.rs
@@ -714,7 +714,7 @@ pub async fn push_metrics_with_update_window_for_success_based_routing(
);
let success_based_connectors = client
- .calculate_success_rate(
+ .calculate_entity_and_global_success_rate(
business_profile.get_id().get_string_repr().into(),
success_based_routing_configs.clone(),
success_based_routing_config_params.clone(),
@@ -730,28 +730,34 @@ pub async fn push_metrics_with_update_window_for_success_based_routing(
let payment_status_attribute =
get_desired_payment_status_for_success_routing_metrics(payment_attempt.status);
- let first_success_based_connector_label = &success_based_connectors
- .labels_with_score
+ let first_merchant_success_based_connector = &success_based_connectors
+ .entity_scores_with_labels
.first()
.ok_or(errors::ApiErrorResponse::InternalServerError)
.attach_printable(
"unable to fetch the first connector from list of connectors obtained from dynamic routing service",
- )?
- .label
- .to_string();
+ )?;
- let (first_success_based_connector, _) = first_success_based_connector_label
+ let (first_merchant_success_based_connector_label, _) = first_merchant_success_based_connector.label
.split_once(':')
.ok_or(errors::ApiErrorResponse::InternalServerError)
.attach_printable(format!(
"unable to split connector_name and mca_id from the first connector {:?} obtained from dynamic routing service",
- first_success_based_connector_label
+ first_merchant_success_based_connector.label
))?;
+ let first_global_success_based_connector = &success_based_connectors
+ .global_scores_with_labels
+ .first()
+ .ok_or(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable(
+ "unable to fetch the first global connector from list of connectors obtained from dynamic routing service",
+ )?;
+
let outcome = get_success_based_metrics_outcome_for_payment(
payment_status_attribute,
payment_connector.to_string(),
- first_success_based_connector.to_string(),
+ first_merchant_success_based_connector_label.to_string(),
);
let dynamic_routing_stats = DynamicRoutingStatsNew {
@@ -760,7 +766,8 @@ pub async fn push_metrics_with_update_window_for_success_based_routing(
merchant_id: payment_attempt.merchant_id.to_owned(),
profile_id: payment_attempt.profile_id.to_owned(),
amount: payment_attempt.get_total_amount(),
- success_based_routing_connector: first_success_based_connector.to_string(),
+ success_based_routing_connector: first_merchant_success_based_connector_label
+ .to_string(),
payment_connector: payment_connector.to_string(),
payment_method_type: payment_attempt.payment_method_type,
currency: payment_attempt.currency,
@@ -770,6 +777,9 @@ pub async fn push_metrics_with_update_window_for_success_based_routing(
payment_status: payment_attempt.status,
conclusive_classification: outcome,
created_at: common_utils::date_time::now(),
+ global_success_based_connector: Some(
+ first_global_success_based_connector.label.to_string(),
+ ),
};
core_metrics::DYNAMIC_SUCCESS_BASED_ROUTING.add(
@@ -788,8 +798,20 @@ pub async fn push_metrics_with_update_window_for_success_based_routing(
),
),
(
- "success_based_routing_connector",
- first_success_based_connector.to_string(),
+ "merchant_specific_success_based_routing_connector",
+ first_merchant_success_based_connector_label.to_string(),
+ ),
+ (
+ "merchant_specific_success_based_routing_connector_score",
+ first_merchant_success_based_connector.score.to_string(),
+ ),
+ (
+ "global_success_based_routing_connector",
+ first_global_success_based_connector.label.to_string(),
+ ),
+ (
+ "global_success_based_routing_connector_score",
+ first_global_success_based_connector.score.to_string(),
),
("payment_connector", payment_connector.to_string()),
(
diff --git a/migrations/2025-01-07-101337_global_sr_connector_dynamic_routing/down.sql b/migrations/2025-01-07-101337_global_sr_connector_dynamic_routing/down.sql
new file mode 100644
index 00000000000..c99db9a384d
--- /dev/null
+++ b/migrations/2025-01-07-101337_global_sr_connector_dynamic_routing/down.sql
@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE dynamic_routing_stats
+DROP COLUMN IF EXISTS global_success_based_connector;
\ No newline at end of file
diff --git a/migrations/2025-01-07-101337_global_sr_connector_dynamic_routing/up.sql b/migrations/2025-01-07-101337_global_sr_connector_dynamic_routing/up.sql
new file mode 100644
index 00000000000..81e00a9753c
--- /dev/null
+++ b/migrations/2025-01-07-101337_global_sr_connector_dynamic_routing/up.sql
@@ -0,0 +1,3 @@
+-- Your SQL goes here
+ALTER TABLE dynamic_routing_stats
+ADD COLUMN IF NOT EXISTS global_success_based_connector VARCHAR(64);
\ No newline at end of file
diff --git a/proto/success_rate.proto b/proto/success_rate.proto
index f49618bc4b6..17d566af356 100644
--- a/proto/success_rate.proto
+++ b/proto/success_rate.proto
@@ -7,6 +7,8 @@ service SuccessRateCalculator {
rpc UpdateSuccessRateWindow (UpdateSuccessRateWindowRequest) returns (UpdateSuccessRateWindowResponse);
rpc InvalidateWindows (InvalidateWindowsRequest) returns (InvalidateWindowsResponse);
+
+ rpc FetchEntityAndGlobalSuccessRate (CalGlobalSuccessRateRequest) returns (CalGlobalSuccessRateResponse);
}
// API-1 types
@@ -20,6 +22,12 @@ message CalSuccessRateRequest {
message CalSuccessRateConfig {
uint32 min_aggregates_size = 1;
double default_success_rate = 2;
+ optional SuccessRateSpecificityLevel specificity_level = 3;
+}
+
+enum SuccessRateSpecificityLevel {
+ ENTITY = 0;
+ GLOBAL = 1;
}
message CalSuccessRateResponse {
@@ -31,12 +39,13 @@ message LabelWithScore {
string label = 2;
}
- // API-2 types
+// API-2 types
message UpdateSuccessRateWindowRequest {
string id = 1;
string params = 2;
repeated LabelWithStatus labels_with_status = 3;
UpdateSuccessRateWindowConfig config = 4;
+ repeated LabelWithStatus global_labels_with_status = 5;
}
message LabelWithStatus {
@@ -68,9 +77,28 @@ message InvalidateWindowsRequest {
}
message InvalidateWindowsResponse {
- enum InvalidationStatus {
+ enum InvalidationStatus {
WINDOW_INVALIDATION_SUCCEEDED = 0;
WINDOW_INVALIDATION_FAILED = 1;
}
InvalidationStatus status = 1;
+}
+
+// API-4 types
+message CalGlobalSuccessRateRequest {
+ string entity_id = 1;
+ string entity_params = 2;
+ repeated string entity_labels = 3;
+ repeated string global_labels = 4;
+ CalGlobalSuccessRateConfig config = 5;
+}
+
+message CalGlobalSuccessRateConfig {
+ uint32 entity_min_aggregates_size = 1;
+ double entity_default_success_rate = 2;
+}
+
+message CalGlobalSuccessRateResponse {
+ repeated LabelWithScore entity_scores_with_labels = 1;
+ repeated LabelWithScore global_scores_with_labels = 2;
}
\ No newline at end of file
|
feat
|
Integrate global success rates (#6950)
|
30fe9d19e4955035a370f8f9ce37963cdb76c68a
|
2023-12-18 21:31:06
|
Shanks
|
fix(euclid_wasm): add function to retrieve keys for 3ds and surcharge decision manager (#3160)
| false
|
diff --git a/crates/euclid_wasm/src/lib.rs b/crates/euclid_wasm/src/lib.rs
index 78c7677fe75..134016191f5 100644
--- a/crates/euclid_wasm/src/lib.rs
+++ b/crates/euclid_wasm/src/lib.rs
@@ -6,7 +6,10 @@ use std::{
str::FromStr,
};
-use api_models::{admin as admin_api, routing::ConnectorSelection};
+use api_models::{
+ admin as admin_api, conditional_configs::ConditionalConfigs, routing::ConnectorSelection,
+ surcharge_decision_configs::SurchargeDecisionConfigs,
+};
use common_enums::RoutableConnectors;
use currency_conversion::{
conversion::convert as convert_currency, types as currency_conversion_types,
@@ -20,7 +23,7 @@ use euclid::{
},
frontend::{
ast,
- dir::{self, enums as dir_enums},
+ dir::{self, enums as dir_enums, EuclidDirFilter},
},
};
use once_cell::sync::OnceCell;
@@ -205,6 +208,18 @@ pub fn get_key_type(key: &str) -> Result<String, String> {
Ok(key_str)
}
+#[wasm_bindgen(js_name = getThreeDsKeys)]
+pub fn get_three_ds_keys() -> JsResult {
+ let keys = <ConditionalConfigs as EuclidDirFilter>::ALLOWED;
+ Ok(serde_wasm_bindgen::to_value(keys)?)
+}
+
+#[wasm_bindgen(js_name= getSurchargeKeys)]
+pub fn get_surcharge_keys() -> JsResult {
+ let keys = <SurchargeDecisionConfigs as EuclidDirFilter>::ALLOWED;
+ Ok(serde_wasm_bindgen::to_value(keys)?)
+}
+
#[wasm_bindgen(js_name=parseToString)]
pub fn parser(val: String) -> String {
ron_parser::my_parse(val)
|
fix
|
add function to retrieve keys for 3ds and surcharge decision manager (#3160)
|
346d2d7ad647dd66f2016207ecaaec3fe365beb1
|
2024-08-27 20:38:38
|
Amisha Prabhat
|
fix(routing): fix routing routes to deserialise correctly (#5724)
| false
|
diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rs
index 267a3d55ce4..d5a3a96d155 100644
--- a/crates/router/src/core/routing.rs
+++ b/crates/router/src/core/routing.rs
@@ -428,18 +428,15 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
- algorithm_id: routing_types::RoutingAlgorithmId,
+ algorithm_id: String,
) -> RouterResponse<routing_types::MerchantRoutingAlgorithm> {
metrics::ROUTING_RETRIEVE_CONFIG.add(&metrics::CONTEXT, 1, &[]);
let db = state.store.as_ref();
let key_manager_state = &(&state).into();
- let routing_algorithm = RoutingAlgorithmUpdate::fetch_routing_algo(
- merchant_account.get_id(),
- &algorithm_id.routing_algorithm_id,
- db,
- )
- .await?;
+ let routing_algorithm =
+ RoutingAlgorithmUpdate::fetch_routing_algo(merchant_account.get_id(), &algorithm_id, db)
+ .await?;
core_utils::validate_and_get_business_profile(
db,
key_manager_state,
@@ -464,7 +461,7 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
state: SessionState,
merchant_account: domain::MerchantAccount,
key_store: domain::MerchantKeyStore,
- algorithm_id: routing_types::RoutingAlgorithmId,
+ algorithm_id: String,
) -> RouterResponse<routing_types::MerchantRoutingAlgorithm> {
metrics::ROUTING_RETRIEVE_CONFIG.add(&metrics::CONTEXT, 1, &[]);
let db = state.store.as_ref();
@@ -472,7 +469,7 @@ pub async fn retrieve_routing_algorithm_from_algorithm_id(
let routing_algorithm = db
.find_routing_algorithm_by_algorithm_id_merchant_id(
- &algorithm_id.routing_algorithm_id,
+ &algorithm_id,
merchant_account.get_id(),
)
.await
diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs
index 61d89e5e773..ecce0f96198 100644
--- a/crates/router/src/routes/routing.rs
+++ b/crates/router/src/routes/routing.rs
@@ -60,7 +60,7 @@ pub async fn routing_create_config(
pub async fn routing_link_config(
state: web::Data<AppState>,
req: HttpRequest,
- path: web::Path<routing_types::RoutingAlgorithmId>,
+ path: web::Path<String>,
transaction_type: &enums::TransactionType,
) -> impl Responder {
let flow = Flow::RoutingLinkConfig;
@@ -74,7 +74,7 @@ pub async fn routing_link_config(
state,
auth.merchant_account,
auth.key_store,
- algorithm.routing_algorithm_id,
+ algorithm,
transaction_type,
)
},
@@ -139,7 +139,7 @@ pub async fn routing_link_config(
pub async fn routing_retrieve_config(
state: web::Data<AppState>,
req: HttpRequest,
- path: web::Path<routing_types::RoutingAlgorithmId>,
+ path: web::Path<String>,
) -> impl Responder {
let algorithm_id = path.into_inner();
let flow = Flow::RoutingRetrieveConfig;
|
fix
|
fix routing routes to deserialise correctly (#5724)
|
54c3fc349d80d1d60a1678183dd0233eb0243b5d
|
2022-11-29 15:27:35
|
Kartikeya Hegde
|
feat: 3ds2 Integration (#35)
| false
|
diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs
index 82d586c0f6d..b4c3c6f28bc 100644
--- a/crates/router/src/connector/adyen.rs
+++ b/crates/router/src/connector/adyen.rs
@@ -304,24 +304,11 @@ impl
data: &types::PaymentsRouterData,
res: Response,
) -> CustomResult<types::PaymentsRouterData, errors::ConnectorError> {
- let response = match data.payment_method {
- types::storage::enums::PaymentMethodType::Wallet => {
- let response: adyen::AdyenWalletResponse = res
- .response
- .parse_struct("AdyenWalletResponse")
- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
-
- adyen::AdyenPaymentResponse::AdyenWalletResponse(response)
- }
- _ => {
- let response: adyen::AdyenResponse = res
- .response
- .parse_struct("AdyenResponse")
- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ let response: adyen::AdyenPaymentResponse = res
+ .response
+ .parse_struct("AdyenPaymentResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- adyen::AdyenPaymentResponse::AdyenResponse(response)
- }
- };
types::RouterData::try_from(types::ResponseRouterData {
response,
data: data.clone(),
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs
index 81bfb2807ff..d76081635ca 100644
--- a/crates/router/src/connector/adyen/transformers.rs
+++ b/crates/router/src/connector/adyen/transformers.rs
@@ -1,3 +1,5 @@
+use std::{collections::HashMap, str::FromStr};
+
use error_stack::{IntoReport, ResultExt};
use reqwest::Url;
use serde::{Deserialize, Serialize};
@@ -29,7 +31,7 @@ pub enum AdyenRecurringModel {
UnscheduledCardOnFile,
}
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AdyenPaymentRequest {
amount: Amount,
@@ -37,11 +39,25 @@ pub struct AdyenPaymentRequest {
payment_method: AdyenPaymentMethod,
reference: String,
return_url: String,
+ browser_info: Option<AdyenBrowserInfo>,
shopper_interaction: AdyenShopperInteraction,
#[serde(skip_serializing_if = "Option::is_none")]
recurring_processing_model: Option<AdyenRecurringModel>,
}
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+struct AdyenBrowserInfo {
+ user_agent: String,
+ accept_header: String,
+ language: String,
+ color_depth: u8,
+ screen_height: u32,
+ screen_width: u32,
+ time_zone_offset: i32,
+ java_enabled: bool,
+}
+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct AdyenRedirectRequest {
pub details: AdyenRedirectRequestTypes,
@@ -78,7 +94,7 @@ pub struct AdyenThreeDS {
#[serde(untagged)]
pub enum AdyenPaymentResponse {
AdyenResponse(AdyenResponse),
- AdyenWalletResponse(AdyenWalletResponse),
+ AdyenRedirectResponse(AdyenWalletResponse),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -109,6 +125,7 @@ pub struct AdyenWalletAction {
method: String,
#[serde(rename = "type")]
type_of_response: String,
+ data: HashMap<String, String>,
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
@@ -194,6 +211,27 @@ impl TryFrom<&types::ConnectorAuthType> for AdyenAuthType {
}
}
}
+
+impl TryFrom<&types::BrowserInformation> for AdyenBrowserInfo {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &types::BrowserInformation) -> Result<Self, Self::Error> {
+ Ok(Self {
+ accept_header: item.accept_header.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "accept_header".to_string(),
+ },
+ )?,
+ language: item.language.clone(),
+ screen_height: item.screen_height,
+ screen_width: item.screen_width,
+ color_depth: item.color_depth,
+ user_agent: item.user_agent.clone(),
+ time_zone_offset: item.time_zone,
+ java_enabled: item.java_enabled,
+ })
+ }
+}
+
// Payment Request Transform
impl TryFrom<&types::PaymentsRouterData> for AdyenPaymentRequest {
type Error = error_stack::Report<errors::ConnectorError>;
@@ -253,14 +291,29 @@ impl TryFrom<&types::PaymentsRouterData> for AdyenPaymentRequest {
}),
}?;
+ let browser_info = if matches!(item.auth_type, enums::AuthenticationType::ThreeDs) {
+ item.request
+ .browser_info
+ .clone()
+ .map(|d| AdyenBrowserInfo::try_from(&d))
+ .transpose()?
+ } else {
+ None
+ };
+
Ok(AdyenPaymentRequest {
amount,
merchant_account: auth_type.merchant_account,
payment_method,
reference,
- return_url: "juspay.io".to_string(),
+ return_url: item.orca_return_url.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "orca_return_url".into(),
+ },
+ )?,
shopper_interaction,
recurring_processing_model,
+ browser_info,
})
}
}
@@ -379,12 +432,10 @@ pub fn get_wallet_response(
let redirection_data = services::RedirectForm {
url: redirection_url_response.to_string(),
- method: services::Method::Get,
- form_fields: std::collections::HashMap::from_iter(
- redirection_url_response
- .query_pairs()
- .map(|(k, v)| (k.to_string(), v.to_string())),
- ),
+ method: services::Method::from_str(&response.action.method)
+ .into_report()
+ .change_context(errors::ParsingError)?,
+ form_fields: response.action.data,
};
let payments_response_data = types::PaymentsResponseData {
@@ -405,7 +456,7 @@ impl<F, Req>
) -> Result<Self, Self::Error> {
let (status, error, payment_response_data) = match item.response {
AdyenPaymentResponse::AdyenResponse(response) => get_adyen_response(response)?,
- AdyenPaymentResponse::AdyenWalletResponse(response) => get_wallet_response(response)?,
+ AdyenPaymentResponse::AdyenRedirectResponse(response) => get_wallet_response(response)?,
};
Ok(types::RouterData {
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 9e1a744055b..1fbb61654aa 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -26,7 +26,7 @@ use crate::{
enums::{self, IntentStatus},
},
},
- utils::OptionExt,
+ utils::{self, OptionExt},
};
#[derive(Debug, Clone, Copy, PaymentOperation)]
#[operation(ops = "all", flow = "authorize")]
@@ -70,6 +70,15 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
let billing_address =
helpers::get_address_for_payment_request(db, request.billing.as_ref(), None).await?;
+ let browser_info = request
+ .browser_info
+ .clone()
+ .map(|x| utils::Encode::<types::BrowserInformation>::encode_to_value(&x))
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InvalidDataValue {
+ field_name: "browser_info",
+ })?;
+
payment_attempt = match db
.insert_payment_attempt(Self::make_payment_attempt(
&payment_id,
@@ -78,6 +87,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
money,
payment_method_type,
request,
+ browser_info,
))
.await
{
@@ -287,6 +297,7 @@ impl PaymentCreate {
money: (i32, enums::Currency),
payment_method: Option<enums::PaymentMethodType>,
request: &api::PaymentsRequest,
+ browser_info: Option<serde_json::Value>,
) -> storage::PaymentAttemptNew {
let created_at @ modified_at @ last_synced = Some(crate::utils::date_time::now());
let status =
@@ -308,6 +319,7 @@ impl PaymentCreate {
modified_at,
last_synced,
authentication_type: request.authentication_type,
+ browser_info,
..storage::PaymentAttemptNew::default()
}
}
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index a09d474a3a9..dc78f6dccbe 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -255,6 +255,14 @@ impl<F: Clone> TryFrom<PaymentData<F>> for types::PaymentsRequestData {
type Error = error_stack::Report<errors::ApiErrorResponse>;
fn try_from(payment_data: PaymentData<F>) -> Result<Self, Self::Error> {
+ let browser_info: Option<types::BrowserInformation> = payment_data
+ .payment_attempt
+ .browser_info
+ .map(|b| b.parse_value("BrowserInformation"))
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InvalidDataValue {
+ field_name: "browser_info",
+ })?;
Ok(Self {
payment_method_data: {
let payment_method_type = payment_data
@@ -276,6 +284,7 @@ impl<F: Clone> TryFrom<PaymentData<F>> for types::PaymentsRequestData {
confirm: payment_data.payment_attempt.confirm,
statement_descriptor_suffix: payment_data.payment_intent.statement_descriptor_suffix,
capture_method: payment_data.payment_attempt.capture_method,
+ browser_info,
})
}
}
diff --git a/crates/router/src/db/payment_attempt.rs b/crates/router/src/db/payment_attempt.rs
index e7682cebfed..1c367303f0b 100644
--- a/crates/router/src/db/payment_attempt.rs
+++ b/crates/router/src/db/payment_attempt.rs
@@ -200,6 +200,7 @@ mod storage {
amount_to_capture: payment_attempt.amount_to_capture,
cancellation_reason: payment_attempt.cancellation_reason.clone(),
mandate_id: payment_attempt.mandate_id.clone(),
+ browser_info: payment_attempt.browser_info.clone(),
};
// TODO: Add a proper error for serialization failure
let redis_value = serde_json::to_string(&created_attempt)
diff --git a/crates/router/src/schema.rs b/crates/router/src/schema.rs
index d4d7b89595b..7dd78457a82 100644
--- a/crates/router/src/schema.rs
+++ b/crates/router/src/schema.rs
@@ -203,6 +203,7 @@ diesel::table! {
cancellation_reason -> Nullable<Varchar>,
amount_to_capture -> Nullable<Int4>,
mandate_id -> Nullable<Varchar>,
+ browser_info -> Nullable<Jsonb>,
}
}
diff --git a/crates/router/src/services/api/request.rs b/crates/router/src/services/api/request.rs
index 1c5c2f7a101..8f455a87362 100644
--- a/crates/router/src/services/api/request.rs
+++ b/crates/router/src/services/api/request.rs
@@ -12,7 +12,9 @@ use crate::{
pub(crate) type Headers = Vec<(String, String)>;
-#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize, strum::Display)]
+#[derive(
+ Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize, strum::Display, strum::EnumString,
+)]
#[serde(rename_all = "UPPERCASE")]
#[strum(serialize_all = "UPPERCASE")]
pub enum Method {
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 8677347dab8..981954086c8 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -75,6 +75,7 @@ pub struct PaymentsRequestData {
pub mandate_id: Option<String>,
pub off_session: Option<bool>,
pub setup_mandate_details: Option<payments::MandateData>,
+ pub browser_info: Option<BrowserInformation>,
}
#[derive(Debug, Clone)]
@@ -112,7 +113,7 @@ pub struct RefundsRequestData {
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
-pub struct DeviceInformation {
+pub struct BrowserInformation {
pub color_depth: u8,
pub java_enabled: bool,
pub java_script_enabled: bool,
diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs
index bdd79cd6410..300871a1e16 100644
--- a/crates/router/src/types/api/payments.rs
+++ b/crates/router/src/types/api/payments.rs
@@ -50,6 +50,7 @@ pub struct PaymentsRequest {
pub payment_token: Option<i32>,
pub shipping: Option<Address>,
pub billing: Option<Address>,
+ pub browser_info: Option<types::BrowserInformation>,
pub statement_descriptor_name: Option<String>,
pub statement_descriptor_suffix: Option<String>,
pub metadata: Option<serde_json::Value>,
diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rs
index 5d04890829f..3d14de11ed5 100644
--- a/crates/router/src/types/storage/payment_attempt.rs
+++ b/crates/router/src/types/storage/payment_attempt.rs
@@ -35,6 +35,7 @@ pub struct PaymentAttempt {
pub cancellation_reason: Option<String>,
pub amount_to_capture: Option<i32>,
pub mandate_id: Option<String>,
+ pub browser_info: Option<serde_json::Value>,
}
#[derive(Clone, Debug, Default, Insertable, router_derive::DebugAsDisplay)]
@@ -68,6 +69,7 @@ pub struct PaymentAttemptNew {
pub cancellation_reason: Option<String>,
pub amount_to_capture: Option<i32>,
pub mandate_id: Option<String>,
+ pub browser_info: Option<serde_json::Value>,
}
#[derive(Clone, Debug)]
diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs
index e88fe2caec5..3245a453c34 100644
--- a/crates/router/tests/connectors/aci.rs
+++ b/crates/router/tests/connectors/aci.rs
@@ -46,6 +46,7 @@ fn construct_payment_router_data() -> types::PaymentsRouterData {
off_session: None,
setup_mandate_details: None,
capture_method: None,
+ browser_info: None,
},
response: None,
payment_method_id: None,
diff --git a/crates/router/tests/connectors/authorizedotnet.rs b/crates/router/tests/connectors/authorizedotnet.rs
index defe0e28ba5..d3ad85344dd 100644
--- a/crates/router/tests/connectors/authorizedotnet.rs
+++ b/crates/router/tests/connectors/authorizedotnet.rs
@@ -46,6 +46,7 @@ fn construct_payment_router_data() -> types::PaymentsRouterData {
off_session: None,
setup_mandate_details: None,
capture_method: None,
+ browser_info: None,
},
payment_method_id: None,
response: None,
diff --git a/crates/router/tests/connectors/checkout.rs b/crates/router/tests/connectors/checkout.rs
index e09ae1f838f..3d95d5babd3 100644
--- a/crates/router/tests/connectors/checkout.rs
+++ b/crates/router/tests/connectors/checkout.rs
@@ -42,6 +42,7 @@ fn construct_payment_router_data() -> types::PaymentsRouterData {
off_session: None,
setup_mandate_details: None,
capture_method: None,
+ browser_info: None,
},
response: None,
payment_method_id: None,
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index 6ee96ecb41b..acbfd3ee70c 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -326,6 +326,7 @@ async fn payments_create_core() {
mandate_id: None,
off_session: None,
client_secret: None,
+ browser_info: None,
};
let expected_response = api::PaymentsResponse {
@@ -484,6 +485,7 @@ async fn payments_create_core_adyen_no_redirect() {
mandate_id: None,
off_session: None,
client_secret: None,
+ browser_info: None,
};
let expected_response = services::BachResponse::Json(api::PaymentsResponse {
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index 27bff1b3573..09aac122fd4 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -91,6 +91,7 @@ async fn payments_create_core() {
mandate_id: None,
off_session: None,
client_secret: None,
+ browser_info: None,
};
let expected_response = api::PaymentsResponse {
@@ -252,6 +253,7 @@ async fn payments_create_core_adyen_no_redirect() {
off_session: None,
mandate_id: None,
client_secret: None,
+ browser_info: None,
};
let expected_response = services::BachResponse::Json(api::PaymentsResponse {
diff --git a/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/down.sql b/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/down.sql
new file mode 100644
index 00000000000..b172b43b73b
--- /dev/null
+++ b/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/down.sql
@@ -0,0 +1,2 @@
+ALTER TABLE payment_attempt
+DROP COLUMN browser_info;
diff --git a/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/up.sql b/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/up.sql
new file mode 100644
index 00000000000..a072f6cb3bf
--- /dev/null
+++ b/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/up.sql
@@ -0,0 +1,2 @@
+ALTER TABLE payment_attempt
+ADD COLUMN browser_info JSONB DEFAULT '{}'::JSONB;
|
feat
|
3ds2 Integration (#35)
|
57887bdf3a892548afea80859c2553d5a1cca49d
|
2023-08-02 17:17:34
|
Prasunna Soppa
|
feat(connector): add support for bank redirect for Paypal (#1107)
| false
|
diff --git a/.github/testcases/ui_tests.json b/.github/testcases/ui_tests.json
index e0445ce8e8d..f85ffa23d9d 100644
--- a/.github/testcases/ui_tests.json
+++ b/.github/testcases/ui_tests.json
@@ -1,5 +1,4 @@
{
- "tests_to_ignore": [],
"1": {
"id": 1,
"name": "stripe giropay",
@@ -1348,6 +1347,75 @@
"id": 225,
"name": "Boleto Bancario",
"connector": "adyen_uk",
- "request": "{\"amount\":6540,\"currency\":\"BRL\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"voucher\",\"payment_method_type\":\"boleto_bancario\",\"payment_method_data\":{\"voucher\":{\"boleto_bancario\":{\"social_security_number\":\"56861752509\"}}}}"
- }
-}
+ "request": "{\"amount\":6540,\"currency\":\"BRL\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"voucher\",\"payment_method_type\":\"boleto\",\"payment_method_data\":{\"voucher\":{\"boleto\":{\"social_security_number\":\"56861752509\"}}}}"
+ },
+ "227": {
+ "id": 227,
+ "name": "authorizedotnet payment success for webhook",
+ "connector": "authorizedotnet",
+ "request": "{\"amount\":400,\"currency\":\"USD\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":40,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://hs-payments-test.netlify.app/payments\",\"payment_method\":\"card\",\"payment_method_type\":\"credit\",\"payment_method_data\":{\"card\":{\"card_number\":\"5424000000000015\",\"card_exp_month\":\"01\",\"card_exp_year\":\"2025\",\"card_holder_name\":\"joseph Doe\",\"card_cvc\":\"123\"}},\"billing\":{\"address\":{\"line1\":\"1467\",\"line2\":\"CA\",\"line3\":\"CA\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"joseph\",\"last_name\":\"Doe\"},\"phone\":{\"number\":\"8056594427\",\"country_code\":\"+91\"}},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"CA\",\"line3\":\"CA\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"joseph\",\"last_name\":\"Doe\"},\"phone\":{\"number\":\"8056594427\",\"country_code\":\"+91\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"ip_address\":\"127.2.2.0\",\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"}}"
+ },
+ "228": {
+ "id": 228,
+ "name": "BNI VA",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"IDR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"bank_transfer\",\"payment_method_type\":\"bni_va\",\"payment_method_data\":{\"bank_transfer\":{\"bni_va_bank_transfer\":{\"billing_details\":{\"first_name\":\"Some\",\"second_name\":\"one\",\"email\":\"[email protected]\"}}}}}"
+ },
+ "229": {
+ "id": 229,
+ "name": "pay_JbukS3WUqF6MVjTp2fe1",
+ "connector": "adyen",
+ "request": "{\"amount\":7000,\"currency\":\"SEK\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+65\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://hs-payments-test.netlify.app/payments\",\"billing\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"country\":\"SE\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"SE\",\"first_name\":\"John\",\"last_name\":\"Doe\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"order_details\":{\"product_name\":\"Socks\",\"amount\":7000,\"quantity\":1}},\"payment_method\":\"pay_later\",\"payment_method_type\":\"klarna\",\"payment_experience\":\"redirect_to_url\",\"payment_method_data\":{\"pay_later\":{\"klarna_redirect\":{\"billing_email\":\"[email protected]\",\"billing_country\":\"SE\"}}}}"
+ },
+ "230": {
+ "id": 230,
+ "name": "Indonesian Alfamart",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"IDR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"voucher\",\"payment_method_type\":\"alfamart\",\"payment_method_data\":{\"voucher\":{\"alfamart\":{\"first_name\":\"Some\",\"second_name\":\"one\",\"email\":\"[email protected]\"}}}}"
+ },
+ "231": {
+ "id": 231,
+ "name": "Indonesian Bank Transfer Permata",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"IDR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"bank_transfer\",\"payment_method_type\":\"permata_bank_transfer\",\"payment_method_data\":{\"bank_transfer\":{\"permata_bank_transfer\":{\"billing_details\":{\"first_name\":\"Some\",\"second_name\":\"one\",\"email\":\"[email protected]\"}}}}}"
+ },
+ "232": {
+ "id": 232,
+ "name": "Adyen Open Banking UK",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"GBP\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://hs-payments-test.netlify.app/payments\",\"payment_method\":\"bank_redirect\",\"payment_method_data\":{\"bank_redirect\":{\"open_banking_uk\":{\"issuer\":\"open_bank_success\",\"country\":\"GB\"}}},\"billing\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"GB\",\"first_name\":\"joseph\",\"last_name\":\"Doe\"},\"phone\":{\"number\":\"8056594427\",\"country_code\":\"+91\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"GB\",\"first_name\":\"joseph\",\"last_name\":\"Doe\"},\"phone\":{\"number\":\"8056594427\",\"country_code\":\"+91\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"}}"
+ },
+ "233": {
+ "id": 233,
+ "name": "paypal-giropay-success",
+ "connector": "paypal",
+ "request": "{\"amount\":1000,\"currency\":\"EUR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":1000,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+65\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://google.com\",\"billing\":{\"address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"DE\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"John\",\"last_name\":\"Doe\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"},\"payment_method\":\"bank_redirect\",\"payment_method_type\":\"giropay\",\"payment_method_data\":{\"bank_redirect\":{\"giropay\":{\"billing_details\":{\"billing_name\":\"John Doe\"},\"bank_name\":\"\",\"preferred_language\":\"en\",\"country\":\"DE\"}}}}"
+ },
+ "234": {
+ "id": 234,
+ "name": "paypal-eps-success",
+ "connector": "paypal",
+ "request": "{\"amount\":12300,\"currency\":\"EUR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":12300,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+65\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://google.com\",\"billing\":{\"address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"AT\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"John\",\"last_name\":\"Doe\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"},\"payment_method\":\"bank_redirect\",\"payment_method_type\":\"eps\",\"payment_method_data\":{\"bank_redirect\":{\"eps\":{\"billing_details\":{\"billing_name\":\"John Doe\"},\"bank_name\":\"american_express\",\"preferred_language\":\"en\",\"country\":\"AT\"}}}}"
+ },
+ "235": {
+ "id": 235,
+ "name": "paypal-sofort-success",
+ "connector": "paypal",
+ "request": "{\"amount\":1100,\"currency\":\"EUR\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":1100,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+65\",\"description\":\"Its my first payment request\",\"authentication_type\":\"three_ds\",\"return_url\":\"https://google.com\",\"billing\":{\"address\":{\"first_name\":\"John\",\"last_name\":\"Doe\",\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"AT\"}},\"browser_info\":{\"user_agent\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\",\"accept_header\":\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\",\"language\":\"nl-NL\",\"color_depth\":24,\"screen_height\":723,\"screen_width\":1536,\"time_zone\":0,\"java_enabled\":true,\"java_script_enabled\":true,\"ip_address\":\"127.0.0.1\"},\"shipping\":{\"address\":{\"line1\":\"1467\",\"line2\":\"Harrison Street\",\"line3\":\"Harrison Street\",\"city\":\"San Fransico\",\"state\":\"California\",\"zip\":\"94122\",\"country\":\"US\",\"first_name\":\"John\",\"last_name\":\"Doe\"}},\"statement_descriptor_name\":\"joseph\",\"statement_descriptor_suffix\":\"JS\",\"metadata\":{\"udf1\":\"value1\",\"new_customer\":\"true\",\"login_date\":\"2019-09-10T10:11:12Z\"},\"payment_method\":\"bank_redirect\",\"payment_method_type\":\"sofort\",\"payment_method_data\":{\"bank_redirect\":{\"sofort\":{\"billing_details\":{\"billing_name\":\"John Doe\"},\"bank_name\":\"\",\"preferred_language\":\"en\",\"country\":\"AT\"}}}}"
+ },
+ "236": {
+ "id": 236,
+ "name": "Adyen Seven Eleven",
+ "connector": "adyen_uk",
+ "request": "{\"amount\":6540,\"currency\":\"JPY\",\"confirm\":true,\"capture_method\":\"automatic\",\"capture_on\":\"2022-09-10T10:11:12Z\",\"amount_to_capture\":6540,\"customer_id\":\"StripeCustomer\",\"email\":\"[email protected]\",\"name\":\"John Doe\",\"phone\":\"999999999\",\"phone_country_code\":\"+1\",\"description\":\"Its my first payment request\",\"authentication_type\":\"no_three_ds\",\"return_url\":\"https://google.com/\",\"payment_method\":\"voucher\",\"payment_method_type\":\"seven_eleven\",\"payment_method_data\":{\"voucher\":{\"seven_eleven\":{\"first_name\":\"Some\",\"last_name\":\"One\",\"email\":\"[email protected]\",\"phone_number\":\"1234567890\"}}}}"
+ },
+ "tests_to_ignore": [
+ "noon_ui::should_make_noon_3ds_payment_test",
+ "adyen_uk_ui::should_make_adyen_online_banking_thailand_payment_test",
+ "adyen_uk_ui::should_make_adyen_blik_payment_test",
+ "authorizedotnet_ui::should_make_paypal_payment_test",
+ "multisafepay_ui::should_make_multisafepay_3ds_payment_failed_test",
+ "multisafepay_ui::should_make_multisafepay_3ds_payment_success_test",
+ "nexinets_ui::*"
+ ]
+}
\ No newline at end of file
diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs
index 0d1b3f8f9b6..248525fcc40 100644
--- a/crates/api_models/src/payment_methods.rs
+++ b/crates/api_models/src/payment_methods.rs
@@ -665,3 +665,13 @@ pub struct TokenizedBankTransferValue1 {
pub struct TokenizedBankTransferValue2 {
pub customer_id: Option<String>,
}
+
+#[derive(Debug, serde::Serialize, serde::Deserialize)]
+pub struct TokenizedBankRedirectValue1 {
+ pub data: payments::BankRedirectData,
+}
+
+#[derive(Debug, serde::Serialize, serde::Deserialize)]
+pub struct TokenizedBankRedirectValue2 {
+ pub customer_id: Option<String>,
+}
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 892590e58ac..5f5294589a5 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -803,6 +803,10 @@ pub enum BankRedirectData {
/// The hyperswitch bank code for eps
#[schema(value_type = BankNames, example = "triodos_bank")]
bank_name: Option<api_enums::BankNames>,
+
+ /// The country for bank payment
+ #[schema(value_type = CountryAlpha2, example = "US")]
+ country: Option<api_enums::CountryAlpha2>,
},
Giropay {
/// The billing details for bank redirection
@@ -816,6 +820,10 @@ pub enum BankRedirectData {
/// Bank account iban
#[schema(value_type = Option<String>)]
bank_account_iban: Option<Secret<String>>,
+
+ /// The country for bank payment
+ #[schema(value_type = CountryAlpha2, example = "US")]
+ country: Option<api_enums::CountryAlpha2>,
},
Ideal {
/// The billing details for bank redirection
@@ -824,6 +832,10 @@ pub enum BankRedirectData {
/// The hyperswitch bank code for ideal
#[schema(value_type = BankNames, example = "abn_amro")]
bank_name: Option<api_enums::BankNames>,
+
+ /// The country for bank payment
+ #[schema(value_type = CountryAlpha2, example = "US")]
+ country: Option<api_enums::CountryAlpha2>,
},
Interac {
/// The country for bank payment
diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs
index ec74a8f0214..4c11529f164 100644
--- a/crates/router/src/connector/paypal.rs
+++ b/crates/router/src/connector/paypal.rs
@@ -54,7 +54,8 @@ impl Paypal {
connector_meta: &Option<serde_json::Value>,
) -> CustomResult<Option<String>, errors::ConnectorError> {
match payment_method {
- Some(diesel_models::enums::PaymentMethod::Wallet) => {
+ Some(diesel_models::enums::PaymentMethod::Wallet)
+ | Some(diesel_models::enums::PaymentMethod::BankRedirect) => {
let meta: PaypalMeta = to_connector_meta(connector_meta.clone())?;
Ok(Some(meta.order_id))
}
@@ -384,7 +385,8 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
res: Response,
) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
match data.payment_method {
- diesel_models::enums::PaymentMethod::Wallet => {
+ diesel_models::enums::PaymentMethod::Wallet
+ | diesel_models::enums::PaymentMethod::BankRedirect => {
let response: paypal::PaypalRedirectResponse = res
.response
.parse_struct("paypal PaymentsRedirectResponse")
@@ -516,7 +518,8 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
) -> CustomResult<String, errors::ConnectorError> {
let paypal_meta: PaypalMeta = to_connector_meta(req.request.connector_meta.clone())?;
match req.payment_method {
- diesel_models::enums::PaymentMethod::Wallet => Ok(format!(
+ diesel_models::enums::PaymentMethod::Wallet
+ | diesel_models::enums::PaymentMethod::BankRedirect => Ok(format!(
"{}v2/checkout/orders/{}",
self.base_url(connectors),
paypal_meta.order_id
@@ -561,7 +564,8 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
res: Response,
) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError> {
match data.payment_method {
- diesel_models::enums::PaymentMethod::Wallet => {
+ diesel_models::enums::PaymentMethod::Wallet
+ | diesel_models::enums::PaymentMethod::BankRedirect => {
let response: paypal::PaypalOrdersResponse = res
.response
.parse_struct("paypal PaymentsOrderResponse")
diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs
index 622651aa9a5..4852016bfe1 100644
--- a/crates/router/src/connector/paypal/transformers.rs
+++ b/crates/router/src/connector/paypal/transformers.rs
@@ -1,3 +1,4 @@
+use api_models::payments::BankRedirectData;
use common_utils::errors::CustomResult;
use masking::Secret;
use serde::{Deserialize, Serialize};
@@ -5,8 +6,8 @@ use url::Url;
use crate::{
connector::utils::{
- self, to_connector_meta, AccessTokenRequestInfo, AddressDetailsData, CardData,
- PaymentsAuthorizeRequestData,
+ self, to_connector_meta, AccessTokenRequestInfo, AddressDetailsData,
+ BankRedirectBillingData, CardData, PaymentsAuthorizeRequestData,
},
core::errors,
services,
@@ -58,6 +59,7 @@ pub struct RedirectRequest {
#[derive(Debug, Serialize)]
pub struct ContextStruct {
return_url: Option<String>,
+ cancel_url: Option<String>,
}
#[derive(Debug, Serialize)]
@@ -70,6 +72,10 @@ pub struct PaypalRedirectionRequest {
pub enum PaymentSourceItem {
Card(CardRequest),
Paypal(PaypalRedirectionRequest),
+ IDeal(RedirectRequest),
+ Eps(RedirectRequest),
+ Giropay(RedirectRequest),
+ Sofort(RedirectRequest),
}
#[derive(Debug, Serialize)]
@@ -93,6 +99,68 @@ fn get_address_info(
};
Ok(address)
}
+fn get_payment_source(
+ item: &types::PaymentsAuthorizeRouterData,
+ bank_redirection_data: &BankRedirectData,
+) -> Result<PaymentSourceItem, error_stack::Report<errors::ConnectorError>> {
+ match bank_redirection_data {
+ BankRedirectData::Eps {
+ billing_details,
+ bank_name: _,
+ country,
+ } => Ok(PaymentSourceItem::Eps(RedirectRequest {
+ name: billing_details.get_billing_name()?,
+ country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "eps.country",
+ })?,
+ experience_context: ContextStruct {
+ return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
+ },
+ })),
+ BankRedirectData::Giropay {
+ billing_details,
+ country,
+ ..
+ } => Ok(PaymentSourceItem::Giropay(RedirectRequest {
+ name: billing_details.get_billing_name()?,
+ country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "giropay.country",
+ })?,
+ experience_context: ContextStruct {
+ return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
+ },
+ })),
+ BankRedirectData::Ideal {
+ billing_details,
+ bank_name: _,
+ country,
+ } => Ok(PaymentSourceItem::IDeal(RedirectRequest {
+ name: billing_details.get_billing_name()?,
+ country_code: country.ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "ideal.country",
+ })?,
+ experience_context: ContextStruct {
+ return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
+ },
+ })),
+ BankRedirectData::Sofort {
+ country,
+ preferred_language: _,
+ billing_details,
+ } => Ok(PaymentSourceItem::Sofort(RedirectRequest {
+ name: billing_details.get_billing_name()?,
+ country_code: *country,
+ experience_context: ContextStruct {
+ return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
+ },
+ })),
+ _ => Err(errors::ConnectorError::NotImplemented("Bank Redirect".to_string()).into()),
+ }
+}
impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaypalPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
@@ -152,6 +220,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaypalPaymentsRequest {
Some(PaymentSourceItem::Paypal(PaypalRedirectionRequest {
experience_context: ContextStruct {
return_url: item.request.complete_authorize_url.clone(),
+ cancel_url: item.request.complete_authorize_url.clone(),
},
}));
@@ -165,6 +234,31 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PaypalPaymentsRequest {
"Payment Method".to_string(),
))?,
},
+ api::PaymentMethodData::BankRedirect(ref bank_redirection_data) => {
+ let intent = match item.request.is_auto_capture()? {
+ true => PaypalPaymentIntent::Capture,
+ false => Err(errors::ConnectorError::FlowNotSupported {
+ flow: "Manual capture method for Bank Redirect".to_string(),
+ connector: "Paypal".to_string(),
+ })?,
+ };
+ let amount = OrderAmount {
+ currency_code: item.request.currency,
+ value: item.request.amount.to_string(),
+ };
+ let reference_id = item.attempt_id.clone();
+ let purchase_units = vec![PurchaseUnitRequest {
+ reference_id,
+ amount,
+ }];
+ let payment_source = Some(get_payment_source(item, bank_redirection_data)?);
+
+ Ok(Self {
+ intent,
+ purchase_units,
+ payment_source,
+ })
+ }
_ => Err(errors::ConnectorError::NotImplemented("Payment Method".to_string()).into()),
}
}
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 221ad0487bf..e7f36449640 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -795,6 +795,18 @@ impl AddressDetailsData for api::AddressDetails {
}
}
+pub trait BankRedirectBillingData {
+ fn get_billing_name(&self) -> Result<Secret<String>, Error>;
+}
+
+impl BankRedirectBillingData for payments::BankRedirectBilling {
+ fn get_billing_name(&self) -> Result<Secret<String>, Error> {
+ self.billing_name
+ .clone()
+ .ok_or_else(missing_field_err("billing_details.billing_name"))
+ }
+}
+
pub trait MandateData {
fn get_end_date(&self, format: date_time::DateFormat) -> Result<String, Error>;
fn get_metadata(&self) -> Result<pii::SecretSerdeValue, Error>;
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 6dca567567c..5a504a0facc 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -211,12 +211,57 @@ impl Vaultable for api::WalletData {
}
}
+impl Vaultable for api_models::payments::BankRedirectData {
+ fn get_value1(&self, _customer_id: Option<String>) -> CustomResult<String, errors::VaultError> {
+ let value1 = api_models::payment_methods::TokenizedBankRedirectValue1 {
+ data: self.to_owned(),
+ };
+
+ utils::Encode::<api_models::payment_methods::TokenizedBankRedirectValue1>::encode_to_string_of_json(&value1)
+ .change_context(errors::VaultError::RequestEncodingFailed)
+ .attach_printable("Failed to encode bank redirect data")
+ }
+
+ fn get_value2(&self, customer_id: Option<String>) -> CustomResult<String, errors::VaultError> {
+ let value2 = api_models::payment_methods::TokenizedBankRedirectValue2 { customer_id };
+
+ utils::Encode::<api_models::payment_methods::TokenizedBankRedirectValue2>::encode_to_string_of_json(&value2)
+ .change_context(errors::VaultError::RequestEncodingFailed)
+ .attach_printable("Failed to encode bank redirect supplementary data")
+ }
+
+ fn from_values(
+ value1: String,
+ value2: String,
+ ) -> CustomResult<(Self, SupplementaryVaultData), errors::VaultError> {
+ let value1: api_models::payment_methods::TokenizedBankRedirectValue1 = value1
+ .parse_struct("TokenizedBankRedirectValue1")
+ .change_context(errors::VaultError::ResponseDeserializationFailed)
+ .attach_printable("Could not deserialize into bank redirect data")?;
+
+ let value2: api_models::payment_methods::TokenizedBankRedirectValue2 = value2
+ .parse_struct("TokenizedBankRedirectValue2")
+ .change_context(errors::VaultError::ResponseDeserializationFailed)
+ .attach_printable("Could not deserialize into supplementary bank redirect data")?;
+
+ let bank_transfer_data = value1.data;
+
+ let supp_data = SupplementaryVaultData {
+ customer_id: value2.customer_id,
+ payment_method_id: None,
+ };
+
+ Ok((bank_transfer_data, supp_data))
+ }
+}
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum VaultPaymentMethod {
Card(String),
Wallet(String),
BankTransfer(String),
+ BankRedirect(String),
}
impl Vaultable for api::PaymentMethodData {
@@ -227,6 +272,9 @@ impl Vaultable for api::PaymentMethodData {
Self::BankTransfer(bank_transfer) => {
VaultPaymentMethod::BankTransfer(bank_transfer.get_value1(customer_id)?)
}
+ Self::BankRedirect(bank_redirect) => {
+ VaultPaymentMethod::BankRedirect(bank_redirect.get_value1(customer_id)?)
+ }
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.into_report()
.attach_printable("Payment method not supported")?,
@@ -244,6 +292,9 @@ impl Vaultable for api::PaymentMethodData {
Self::BankTransfer(bank_transfer) => {
VaultPaymentMethod::BankTransfer(bank_transfer.get_value2(customer_id)?)
}
+ Self::BankRedirect(bank_redirect) => {
+ VaultPaymentMethod::BankRedirect(bank_redirect.get_value2(customer_id)?)
+ }
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.into_report()
.attach_printable("Payment method not supported")?,
@@ -285,6 +336,15 @@ impl Vaultable for api::PaymentMethodData {
api_models::payments::BankTransferData::from_values(mvalue1, mvalue2)?;
Ok((Self::BankTransfer(Box::new(bank_transfer)), supp_data))
}
+ (
+ VaultPaymentMethod::BankRedirect(mvalue1),
+ VaultPaymentMethod::BankRedirect(mvalue2),
+ ) => {
+ let (bank_redirect, supp_data) =
+ api_models::payments::BankRedirectData::from_values(mvalue1, mvalue2)?;
+ Ok((Self::BankRedirect(bank_redirect), supp_data))
+ }
+
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.into_report()
.attach_printable("Payment method not supported"),
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 326ac771960..2970034d84c 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -1258,6 +1258,11 @@ pub async fn make_pm_data<'a, F: Clone, R>(
Some(storage_enums::PaymentMethod::BankTransfer);
pm
}
+ Some(api::PaymentMethodData::BankRedirect(_)) => {
+ payment_data.payment_attempt.payment_method =
+ Some(storage_enums::PaymentMethod::BankRedirect);
+ pm
+ }
Some(_) => Err(errors::ApiErrorResponse::InternalServerError)
.into_report()
.attach_printable(
@@ -1280,7 +1285,6 @@ pub async fn make_pm_data<'a, F: Clone, R>(
Ok(pm_opt.to_owned())
}
(pm @ Some(api::PaymentMethodData::PayLater(_)), _) => Ok(pm.to_owned()),
- (pm @ Some(api::PaymentMethodData::BankRedirect(_)), _) => Ok(pm.to_owned()),
(pm @ Some(api::PaymentMethodData::Crypto(_)), _) => Ok(pm.to_owned()),
(pm @ Some(api::PaymentMethodData::BankDebit(_)), _) => Ok(pm.to_owned()),
(pm @ Some(api::PaymentMethodData::Upi(_)), _) => Ok(pm.to_owned()),
@@ -1311,6 +1315,18 @@ pub async fn make_pm_data<'a, F: Clone, R>(
payment_data.token = Some(token);
Ok(pm_opt.to_owned())
}
+ (pm_opt @ Some(pm @ api::PaymentMethodData::BankRedirect(_)), _) => {
+ let token = vault::Vault::store_payment_method_data_in_locker(
+ state,
+ None,
+ pm,
+ payment_data.payment_intent.customer_id.to_owned(),
+ enums::PaymentMethod::BankRedirect,
+ )
+ .await?;
+ payment_data.token = Some(token);
+ Ok(pm_opt.to_owned())
+ }
_ => Ok(None),
}?;
diff --git a/crates/test_utils/tests/connectors/paypal_ui.rs b/crates/test_utils/tests/connectors/paypal_ui.rs
index 3e9fc162dc2..6f08c87be2e 100644
--- a/crates/test_utils/tests/connectors/paypal_ui.rs
+++ b/crates/test_utils/tests/connectors/paypal_ui.rs
@@ -19,8 +19,8 @@ async fn should_make_paypal_paypal_wallet_payment(
web_driver,
&format!("{CHEKOUT_BASE_URL}/saved/21"),
vec![
- Event::Trigger(Trigger::Click(By::Css(".reviewButton"))),
- Event::Assert(Assert::IsPresent("How Search works")),
+ Event::Trigger(Trigger::Click(By::Css("#payment-submit-btn"))),
+ Event::Assert(Assert::IsPresent("Google")),
Event::Assert(Assert::ContainsAny(
Selector::QueryParamStr,
vec!["status=processing"],
@@ -31,8 +31,92 @@ async fn should_make_paypal_paypal_wallet_payment(
Ok(())
}
+async fn should_make_paypal_ideal_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = PaypalSeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/181"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Name("Successful"))),
+ Event::Assert(Assert::IsPresent("processing")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
+async fn should_make_paypal_giropay_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = PaypalSeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/233"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Name("Successful"))),
+ Event::Assert(Assert::IsPresent("processing")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
+async fn should_make_paypal_eps_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = PaypalSeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/234"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Name("Successful"))),
+ Event::Assert(Assert::IsPresent("processing")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
+async fn should_make_paypal_sofort_payment(web_driver: WebDriver) -> Result<(), WebDriverError> {
+ let conn = PaypalSeleniumTest {};
+ conn.make_redirection_payment(
+ web_driver,
+ vec![
+ Event::Trigger(Trigger::Goto(&format!("{CHEKOUT_BASE_URL}/saved/235"))),
+ Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
+ Event::Trigger(Trigger::Click(By::Name("Successful"))),
+ Event::Assert(Assert::IsPresent("processing")),
+ ],
+ )
+ .await?;
+ Ok(())
+}
+
#[test]
#[serial]
fn should_make_paypal_paypal_wallet_payment_test() {
tester!(should_make_paypal_paypal_wallet_payment);
}
+
+#[test]
+#[serial]
+fn should_make_paypal_ideal_payment_test() {
+ tester!(should_make_paypal_ideal_payment);
+}
+
+#[test]
+#[serial]
+fn should_make_paypal_giropay_payment_test() {
+ tester!(should_make_paypal_giropay_payment);
+}
+
+#[test]
+#[serial]
+fn should_make_paypal_eps_payment_test() {
+ tester!(should_make_paypal_eps_payment);
+}
+
+#[test]
+#[serial]
+fn should_make_paypal_sofort_payment_test() {
+ tester!(should_make_paypal_sofort_payment);
+}
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index 4db52f964b3..e4d0c4bc5f0 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -2827,7 +2827,8 @@
"type": "object",
"required": [
"billing_details",
- "bank_name"
+ "bank_name",
+ "country"
],
"properties": {
"billing_details": {
@@ -2835,6 +2836,9 @@
},
"bank_name": {
"$ref": "#/components/schemas/BankNames"
+ },
+ "country": {
+ "$ref": "#/components/schemas/CountryAlpha2"
}
}
}
@@ -2849,7 +2853,8 @@
"giropay": {
"type": "object",
"required": [
- "billing_details"
+ "billing_details",
+ "country"
],
"properties": {
"billing_details": {
@@ -2864,6 +2869,9 @@
"type": "string",
"description": "Bank account iban",
"nullable": true
+ },
+ "country": {
+ "$ref": "#/components/schemas/CountryAlpha2"
}
}
}
@@ -2879,7 +2887,8 @@
"type": "object",
"required": [
"billing_details",
- "bank_name"
+ "bank_name",
+ "country"
],
"properties": {
"billing_details": {
@@ -2887,6 +2896,9 @@
},
"bank_name": {
"$ref": "#/components/schemas/BankNames"
+ },
+ "country": {
+ "$ref": "#/components/schemas/CountryAlpha2"
}
}
}
|
feat
|
add support for bank redirect for Paypal (#1107)
|
595f34e20f84bf1b62461ffae4631b6fad888d32
|
2022-11-29 23:34:05
|
Kartikeya Hegde
|
chore: Remove option from user-agent field (#41)
| false
|
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs
index d76081635ca..ec067a97dea 100644
--- a/crates/router/src/connector/adyen/transformers.rs
+++ b/crates/router/src/connector/adyen/transformers.rs
@@ -216,11 +216,7 @@ impl TryFrom<&types::BrowserInformation> for AdyenBrowserInfo {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &types::BrowserInformation) -> Result<Self, Self::Error> {
Ok(Self {
- accept_header: item.accept_header.clone().ok_or(
- errors::ConnectorError::MissingRequiredField {
- field_name: "accept_header".to_string(),
- },
- )?,
+ accept_header: item.accept_header.clone(),
language: item.language.clone(),
screen_height: item.screen_height,
screen_width: item.screen_width,
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 981954086c8..a8c4c9927bc 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -122,7 +122,7 @@ pub struct BrowserInformation {
pub screen_width: u32,
pub time_zone: i32,
pub ip_address: Option<std::net::IpAddr>,
- pub accept_header: Option<String>,
+ pub accept_header: String,
pub user_agent: String,
}
diff --git a/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/up.sql b/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/up.sql
index a072f6cb3bf..474e748d3f8 100644
--- a/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/up.sql
+++ b/migrations/2022-11-24-095709_add_browser_info_to_payment_attempt/up.sql
@@ -1,2 +1,2 @@
ALTER TABLE payment_attempt
-ADD COLUMN browser_info JSONB DEFAULT '{}'::JSONB;
+ADD COLUMN browser_info JSONB DEFAULT NULL;
|
chore
|
Remove option from user-agent field (#41)
|
ca749b32591edcbf4676da4327f8b6ccbc839d4b
|
2024-07-22 15:59:59
|
Prajjwal Kumar
|
refactor(core): change primary keys in payment_methods table (#5393)
| false
|
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index b8c5344cbbb..55f8e935b14 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -934,7 +934,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
- payment_methods (id) {
+ payment_methods (payment_method_id) {
id -> Int4,
#[max_length = 64]
customer_id -> Varchar,
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index 164600c88ac..90046d3fd95 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -931,7 +931,7 @@ diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
- payment_methods (id) {
+ payment_methods (payment_method_id) {
id -> Int4,
#[max_length = 64]
customer_id -> Varchar,
diff --git a/migrations/2024-07-22-082828_change_primary_key_for_payment_methods/down.sql b/migrations/2024-07-22-082828_change_primary_key_for_payment_methods/down.sql
new file mode 100644
index 00000000000..26dd04d739b
--- /dev/null
+++ b/migrations/2024-07-22-082828_change_primary_key_for_payment_methods/down.sql
@@ -0,0 +1,5 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE payment_methods DROP CONSTRAINT payment_methods_pkey;
+
+ALTER TABLE payment_methods
+ADD PRIMARY KEY (id);
diff --git a/migrations/2024-07-22-082828_change_primary_key_for_payment_methods/up.sql b/migrations/2024-07-22-082828_change_primary_key_for_payment_methods/up.sql
new file mode 100644
index 00000000000..5fc305bc92c
--- /dev/null
+++ b/migrations/2024-07-22-082828_change_primary_key_for_payment_methods/up.sql
@@ -0,0 +1,12 @@
+-- Your SQL goes here
+-- The below query will lock the payment_methods table
+-- Running this query is not necessary on higher environments
+-- as the application will work fine without these queries being run
+-- This query should be run after the new version of application is deployed
+ALTER TABLE payment_methods DROP CONSTRAINT payment_methods_pkey;
+
+-- Use the `payment_method_id` column as primary key
+-- This is already unique, not null column
+-- So this query should not fail for not null or duplicate value reasons
+ALTER TABLE payment_methods
+ADD PRIMARY KEY (payment_method_id);
|
refactor
|
change primary keys in payment_methods table (#5393)
|
e4c7ab8e683d969092910b3fcc046c2e65e18df9
|
2025-03-18 18:02:44
|
awasthi21
|
fix(connector): Handle Sequential Automatic case in MIT payments (#6833)
| false
|
diff --git a/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs b/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs
index 7da6b6e95ea..a1136f5eeb0 100644
--- a/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs
@@ -1198,7 +1198,9 @@ impl
PayboxAuthType::try_from(&item.router_data.connector_auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
let transaction_type = match item.router_data.request.capture_method {
- Some(enums::CaptureMethod::Automatic) | None => {
+ Some(enums::CaptureMethod::Automatic)
+ | None
+ | Some(enums::CaptureMethod::SequentialAutomatic) => {
Ok(MANDATE_AUTH_AND_CAPTURE_ONLY.to_string())
}
Some(enums::CaptureMethod::Manual) => Ok(MANDATE_AUTH_ONLY.to_string()),
|
fix
|
Handle Sequential Automatic case in MIT payments (#6833)
|
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 4