Skip to content

Commit

Permalink
Merge branch 'main' into feat/connector_bambora_use-connector-request…
Browse files Browse the repository at this point in the history
…-reference-id
  • Loading branch information
j-alder authored Oct 12, 2023
2 parents deaecf8 + 8a396a2 commit 9d2d018
Show file tree
Hide file tree
Showing 58 changed files with 1,302 additions and 120 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to HyperSwitch will be documented here.

- - -

## 1.57.1 (2023-10-12)

### Bug Fixes

- **connector:** Trigger Psync after redirection url ([#2422](https://github.com/juspay/hyperswitch/pull/2422)) ([`8029a89`](https://github.com/juspay/hyperswitch/commit/8029a895b2c27a1ac14a19aea23bbc06cc364809))

**Full Changelog:** [`v1.57.0...v1.57.1`](https://github.com/juspay/hyperswitch/compare/v1.57.0...v1.57.1)

- - -


## 1.57.0 (2023-10-12)

### Features
Expand Down
8 changes: 6 additions & 2 deletions crates/router/src/connector/authorizedotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,12 @@ impl services::ConnectorRedirectResponse for Authorizedotnet {
&self,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
Ok(payments::CallConnectorAction::Trigger)
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}
8 changes: 6 additions & 2 deletions crates/router/src/connector/bambora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,13 @@ impl services::ConnectorRedirectResponse for Bambora {
&self,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
Ok(payments::CallConnectorAction::Trigger)
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}

Expand Down
49 changes: 27 additions & 22 deletions crates/router/src/connector/bluesnap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,31 +1095,36 @@ impl services::ConnectorRedirectResponse for Bluesnap {
&self,
_query_params: &str,
json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
let redirection_response: bluesnap::BluesnapRedirectionResponse = json_payload
.ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
field_name: "json_payload",
})?
.parse_value("BluesnapRedirectionResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
match action {
services::PaymentAction::PSync => Ok(payments::CallConnectorAction::Trigger),
services::PaymentAction::CompleteAuthorize => {
let redirection_response: bluesnap::BluesnapRedirectionResponse = json_payload
.ok_or(errors::ConnectorError::MissingConnectorRedirectionPayload {
field_name: "json_payload",
})?
.parse_value("BluesnapRedirectionResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;

let redirection_result: bluesnap::BluesnapThreeDsResult = redirection_response
.authentication_response
.parse_struct("BluesnapThreeDsResult")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let redirection_result: bluesnap::BluesnapThreeDsResult = redirection_response
.authentication_response
.parse_struct("BluesnapThreeDsResult")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;

match redirection_result.status.as_str() {
"Success" => Ok(payments::CallConnectorAction::Trigger),
_ => Ok(payments::CallConnectorAction::StatusUpdate {
status: enums::AttemptStatus::AuthenticationFailed,
error_code: redirection_result.code,
error_message: redirection_result
.info
.as_ref()
.and_then(|info| info.errors.as_ref().and_then(|error| error.first()))
.cloned(),
}),
match redirection_result.status.as_str() {
"Success" => Ok(payments::CallConnectorAction::Trigger),
_ => Ok(payments::CallConnectorAction::StatusUpdate {
status: enums::AttemptStatus::AuthenticationFailed,
error_code: redirection_result.code,
error_message: redirection_result
.info
.as_ref()
.and_then(|info| info.errors.as_ref().and_then(|error| error.first()))
.cloned(),
}),
}
}
}
}
}
Expand Down
24 changes: 7 additions & 17 deletions crates/router/src/connector/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,25 +1289,15 @@ impl api::IncomingWebhook for Checkout {
impl services::ConnectorRedirectResponse for Checkout {
fn get_flow_type(
&self,
query_params: &str,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
let query =
serde_urlencoded::from_str::<transformers::CheckoutRedirectResponse>(query_params)
.into_report()
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
let connector_action = query
.status
.map(
|checkout_status| payments::CallConnectorAction::StatusUpdate {
status: diesel_models::enums::AttemptStatus::from(checkout_status),
error_code: None,
error_message: None,
},
)
.unwrap_or(payments::CallConnectorAction::Trigger);
Ok(connector_action)
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}

Expand Down
25 changes: 7 additions & 18 deletions crates/router/src/connector/globalpay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,25 +926,14 @@ impl api::IncomingWebhook for Globalpay {
impl services::ConnectorRedirectResponse for Globalpay {
fn get_flow_type(
&self,
query_params: &str,
_query_params: &str,
_json_payload: Option<Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
let query = serde_urlencoded::from_str::<response::GlobalpayRedirectResponse>(query_params)
.into_report()
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
Ok(query.status.map_or(
payments::CallConnectorAction::Trigger,
|status| match status {
response::GlobalpayPaymentStatus::Captured => {
payments::CallConnectorAction::StatusUpdate {
status: diesel_models::enums::AttemptStatus::from(status),
error_code: None,
error_message: None,
}
}
_ => payments::CallConnectorAction::Trigger,
},
))
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}
8 changes: 6 additions & 2 deletions crates/router/src/connector/mollie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,12 @@ impl services::ConnectorRedirectResponse for Mollie {
&self,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
Ok(payments::CallConnectorAction::Trigger)
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}
8 changes: 6 additions & 2 deletions crates/router/src/connector/noon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,13 @@ impl services::ConnectorRedirectResponse for Noon {
&self,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
Ok(payments::CallConnectorAction::Trigger)
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions crates/router/src/connector/payme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,13 @@ impl services::ConnectorRedirectResponse for Payme {
&self,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
Ok(payments::CallConnectorAction::Trigger)
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions crates/router/src/connector/paypal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,8 +1150,12 @@ impl services::ConnectorRedirectResponse for Paypal {
&self,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: PaymentAction,
action: PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
Ok(payments::CallConnectorAction::Trigger)
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}
33 changes: 7 additions & 26 deletions crates/router/src/connector/stripe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1962,33 +1962,14 @@ impl api::IncomingWebhook for Stripe {
impl services::ConnectorRedirectResponse for Stripe {
fn get_flow_type(
&self,
query_params: &str,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<crate::core::payments::CallConnectorAction, errors::ConnectorError> {
let query =
serde_urlencoded::from_str::<transformers::StripeRedirectResponse>(query_params)
.into_report()
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;

crate::logger::debug!(stripe_redirect_response=?query);

Ok(query
.redirect_status
.map_or(
payments::CallConnectorAction::Trigger,
|status| match status {
transformers::StripePaymentStatus::Failed
| transformers::StripePaymentStatus::Pending
| transformers::StripePaymentStatus::Succeeded => {
payments::CallConnectorAction::Trigger
}
_ => payments::CallConnectorAction::StatusUpdate {
status: enums::AttemptStatus::from(status),
error_code: None,
error_message: None,
},
},
))
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}
25 changes: 7 additions & 18 deletions crates/router/src/connector/trustpay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,26 +956,15 @@ impl api::IncomingWebhook for Trustpay {
impl services::ConnectorRedirectResponse for Trustpay {
fn get_flow_type(
&self,
query_params: &str,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
let query =
serde_urlencoded::from_str::<transformers::TrustpayRedirectResponse>(query_params)
.into_report()
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
crate::logger::debug!(trustpay_redirect_response=?query);
Ok(query.status.map_or(
payments::CallConnectorAction::Trigger,
|status| match status.as_str() {
"SuccessOk" => payments::CallConnectorAction::StatusUpdate {
status: diesel_models::enums::AttemptStatus::Charged,
error_code: None,
error_message: None,
},
_ => payments::CallConnectorAction::Trigger,
},
))
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions crates/router/src/connector/zen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,12 @@ impl services::ConnectorRedirectResponse for Zen {
&self,
_query_params: &str,
_json_payload: Option<serde_json::Value>,
_action: services::PaymentAction,
action: services::PaymentAction,
) -> CustomResult<payments::CallConnectorAction, errors::ConnectorError> {
Ok(payments::CallConnectorAction::Trigger)
match action {
services::PaymentAction::PSync | services::PaymentAction::CompleteAuthorize => {
Ok(payments::CallConnectorAction::Trigger)
}
}
}
}
2 changes: 1 addition & 1 deletion crates/router/src/services/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ pub fn build_redirection_form(
(PreEscaped(format!("<script>
bluesnap.threeDsPaymentsSetup(\"{payment_fields_token}\",
function(sdkResponse) {{
console.log(sdkResponse);
// console.log(sdkResponse);
var f = document.createElement('form');
f.action=window.location.pathname.replace(/payments\\/redirect\\/(\\w+)\\/(\\w+)\\/\\w+/, \"payments/$1/$2/redirect/complete/bluesnap?paymentToken={payment_fields_token}\");
f.method='POST';
Expand Down
6 changes: 3 additions & 3 deletions postman/collection-dir/stripe/.info.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"info": {
"_postman_id": "8690e6f5-b693-42f3-a9f5-a1492faecdd6",
"name": "stripe",
"_postman_id": "a553df38-fa33-4522-b029-1cd32821730e",
"name": "Stripe Postman Collection",
"description": "## Get started\n\nJuspay Router provides a collection of APIs that enable you to process and manage payments. Our APIs accept and return JSON in the HTTP body, and return standard HTTP response codes. \nYou can consume the APIs directly using your favorite HTTP/REST library. \nWe have a testing environment referred to \"sandbox\", which you can setup to test API calls without affecting production data.\n\n### Base URLs\n\nUse the following base URLs when making requests to the APIs:\n\n| Environment | Base URL |\n| --- | --- |\n| Sandbox | [https://sandbox.hyperswitch.io](https://sandbox.hyperswitch.io) |\n| Production | [https://router.juspay.io](https://router.juspay.io) |\n\n# Authentication\n\nWhen you sign up for an account, you are given a secret key (also referred as api-key). You may authenticate all API requests with Juspay server by providing the appropriate key in the request Authorization header. \nNever share your secret api keys. Keep them guarded and secure.\n\nContact Support: \nName: Juspay Support \nEmail: [[email protected]](mailto:[email protected])",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "25737662"
"_exporter_id": "24206034"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"Scenario18-Bank Redirect-giropay",
"Scenario19-Bank Transfer-ach",
"Scenario19-Bank Debit-ach",
"Scenario22-Wallet-Wechatpay"
"Scenario22-Wallet-Wechatpay",
"Scenario22- Update address and List Payment method",
"Scenario23- Update Amount"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"childrenOrder": [
"Payments - Create",
"List Payment Methods for a Merchant",
"Payments - Update",
"List Payment Methods for a Merchant-copy",
"Payments - Confirm",
"Payments - Retrieve"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}
Loading

0 comments on commit 9d2d018

Please sign in to comment.