Skip to content

Commit

Permalink
Merge branch 'main' into refactor/wordline
Browse files Browse the repository at this point in the history
  • Loading branch information
kaustubh1106 authored Nov 18, 2023
2 parents 9e6e19b + 94897d8 commit 2bdf6bc
Show file tree
Hide file tree
Showing 132 changed files with 1,722 additions and 457 deletions.
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ optin = "optin" # Boku preflow name
optin_id = "optin_id" # Boku's id for optin flow
deriver = "deriver"
Deriver = "Deriver"
requestor_card_reference = "requestor_card_reference"

[default.extend-words]
aci = "aci" # Name of a connector
Expand Down
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,67 @@ All notable changes to HyperSwitch will be documented here.

- - -

## 1.84.0 (2023-11-17)

### Features

- **connector:** [BANKOFAMERICA] PSYNC Bugfix ([#2897](https://github.com/juspay/hyperswitch/pull/2897)) ([`bdcc138`](https://github.com/juspay/hyperswitch/commit/bdcc138e8d84577fc99f9a9aef3484b66f98209a))

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

- - -


## 1.83.1 (2023-11-17)

### Bug Fixes

- **router:** Add choice to use the appropriate key for jws verification ([#2917](https://github.com/juspay/hyperswitch/pull/2917)) ([`606daa9`](https://github.com/juspay/hyperswitch/commit/606daa9367cac8c2ea926313019deab2f938b591))

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

- - -


## 1.83.0 (2023-11-17)

### Features

- **events:** Add incoming webhook payload to api events logger ([#2852](https://github.com/juspay/hyperswitch/pull/2852)) ([`aea390a`](https://github.com/juspay/hyperswitch/commit/aea390a6a1c331f8e0dbea4f41218e43f7323508))
- **router:** Custom payment link config for payment create ([#2741](https://github.com/juspay/hyperswitch/pull/2741)) ([`c39beb2`](https://github.com/juspay/hyperswitch/commit/c39beb2501e63bbf7fd41bbc947280d7ff5a71dc))

### Bug Fixes

- **router:** Add rust locker url in proxy_bypass_urls ([#2902](https://github.com/juspay/hyperswitch/pull/2902)) ([`9a201ae`](https://github.com/juspay/hyperswitch/commit/9a201ae698c2cf52e617660f82d5bf1df2e797ae))

### Documentation

- **README:** Replace cloudformation deployment template with latest s3 url. ([#2891](https://github.com/juspay/hyperswitch/pull/2891)) ([`375108b`](https://github.com/juspay/hyperswitch/commit/375108b6df50e041fc9dbeb35a6a6b46b146037a))

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

- - -


## 1.82.0 (2023-11-17)

### Features

- **router:** Add fallback while add card and retrieve card from rust locker ([#2888](https://github.com/juspay/hyperswitch/pull/2888)) ([`f735fb0`](https://github.com/juspay/hyperswitch/commit/f735fb0551812fd781a2db8bac5a0deef4cabb2b))

### Bug Fixes

- **core:** Introduce new attempt and intent status to handle multiple partial captures ([#2802](https://github.com/juspay/hyperswitch/pull/2802)) ([`cb88be0`](https://github.com/juspay/hyperswitch/commit/cb88be01f22725948648976c2a5606a03b5ce92a))

### Testing

- **postman:** Update postman collection files ([`7d05b74`](https://github.com/juspay/hyperswitch/commit/7d05b74b950d9e078b063e17d046cbeb501d006a))

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

- - -


## 1.81.0 (2023-11-16)

### Features
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ The fastest and easiest way to try hyperswitch is via our CDK scripts
1. Click on the following button for a quick standalone deployment on AWS, suitable for prototyping.
No code or setup is required in your system and the deployment is covered within the AWS free-tier setup.

&emsp;&emsp; <a title="Bootstrap" href="https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=cdk-hs&templateURL=https://hyperswitch-synth.s3.eu-central-1.amazonaws.com/bootstrap-template.yml"> Click here if you have not bootstrapped your region before deploying</a>

&emsp;&emsp; <a href="https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=Hyperswitch&templateURL=https://hyperswitch-synth.s3.eu-central-1.amazonaws.com/deployment.yaml"><img src="./docs/imgs/aws_button.png" height="35"></a>
&emsp;&emsp; <a href="https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=HyperswitchBootstarp&templateURL=https://hyperswitch-synth.s3.eu-central-1.amazonaws.com/hs-starter-config.yaml"><img src="./docs/imgs/aws_button.png" height="35"></a>


2. Sign-in to your AWS console.
Expand Down
199 changes: 101 additions & 98 deletions config/config.example.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion connector-template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ impl api::IncomingWebhook for {{project-name | downcase | pascal_case}} {
fn get_webhook_resource_object(
&self,
_request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<serde_json::Value, errors::ConnectorError> {
) -> CustomResult<Box<dyn erased_serde::Serialize>, errors::ConnectorError> {
Err(errors::ConnectorError::WebhooksNotImplemented).into_report()
}
}
5 changes: 5 additions & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ pub struct PrimaryBusinessDetails {
#[derive(Clone, Debug, Deserialize, ToSchema, Serialize, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct PaymentLinkConfig {
#[schema(
max_length = 255,
max_length = 255,
example = "https://i.imgur.com/RfxPFQo.png"
)]
pub merchant_logo: Option<String>,
pub color_scheme: Option<PaymentLinkColorSchema>,
}
Expand Down
2 changes: 2 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3150,6 +3150,8 @@ pub struct PaymentLinkObject {
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub link_expiry: Option<PrimitiveDateTime>,
pub merchant_custom_domain_name: Option<String>,
#[schema(value_type = PaymentLinkConfig)]
pub payment_link_config: Option<admin::PaymentLinkConfig>,
/// Custom merchant name for payment link
pub custom_merchant_name: Option<String>,
}
Expand Down
7 changes: 5 additions & 2 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub enum AttemptStatus {
VoidFailed,
AutoRefunded,
PartialCharged,
PartialChargedAndChargeable,
Unresolved,
#[default]
Pending,
Expand All @@ -68,7 +69,8 @@ impl AttemptStatus {
| Self::Voided
| Self::VoidFailed
| Self::CaptureFailed
| Self::Failure => true,
| Self::Failure
| Self::PartialCharged => true,
Self::Started
| Self::AuthenticationFailed
| Self::AuthenticationPending
Expand All @@ -79,7 +81,7 @@ impl AttemptStatus {
| Self::CodInitiated
| Self::VoidInitiated
| Self::CaptureInitiated
| Self::PartialCharged
| Self::PartialChargedAndChargeable
| Self::Unresolved
| Self::Pending
| Self::PaymentMethodAwaited
Expand Down Expand Up @@ -861,6 +863,7 @@ pub enum IntentStatus {
RequiresConfirmation,
RequiresCapture,
PartiallyCaptured,
PartiallyCapturedAndCapturable,
}

#[derive(
Expand Down
1 change: 1 addition & 0 deletions crates/common_utils/src/ext_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ pub trait ByteSliceExt {
}

impl ByteSliceExt for [u8] {
#[track_caller]
fn parse_struct<'de, T>(
&'de self,
type_name: &'static str,
Expand Down
5 changes: 4 additions & 1 deletion crates/diesel_models/src/payment_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use time::PrimitiveDateTime;

use crate::{enums as storage_enums, schema::payment_link};

#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize)]
#[derive(Clone, Debug, Identifiable, Queryable, Serialize, Deserialize)]
#[diesel(table_name = payment_link)]
#[diesel(primary_key(payment_link_id))]
pub struct PaymentLink {
Expand All @@ -21,7 +21,9 @@ pub struct PaymentLink {
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub fulfilment_time: Option<PrimitiveDateTime>,
pub custom_merchant_name: Option<String>,
pub payment_link_config: Option<serde_json::Value>,
}

#[derive(
Clone,
Debug,
Expand All @@ -48,4 +50,5 @@ pub struct PaymentLinkNew {
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub fulfilment_time: Option<PrimitiveDateTime>,
pub custom_merchant_name: Option<String>,
pub payment_link_config: Option<serde_json::Value>,
}
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ diesel::table! {
fulfilment_time -> Nullable<Timestamp>,
#[max_length = 64]
custom_merchant_name -> Nullable<Varchar>,
payment_link_config -> Nullable<Jsonb>,
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/masking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license.workspace = true
[features]
default = ["alloc", "serde", "diesel"]
alloc = ["zeroize/alloc"]
serde = ["dep:serde", "dep:serde_json"]

[package.metadata.docs.rs]
all-features = true
Expand All @@ -19,7 +20,7 @@ rustdoc-args = ["--cfg", "docsrs"]
bytes = { version = "1", optional = true }
diesel = { version = "2.1.0", features = ["postgres", "serde_json", "time"], optional = true }
serde = { version = "1", features = ["derive"], optional = true }
serde_json = "1.0.96"
serde_json = { version = "1.0.96", optional = true }
subtle = "=2.4.1"
zeroize = { version = "1.6", default-features = false }

Expand Down
4 changes: 3 additions & 1 deletion crates/masking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ mod vec;
#[cfg(feature = "serde")]
mod serde;
#[cfg(feature = "serde")]
pub use crate::serde::{masked_serialize, Deserialize, SerializableSecret, Serialize};
pub use crate::serde::{
masked_serialize, Deserialize, ErasedMaskSerialize, SerializableSecret, Serialize,
};

/// This module should be included with asterisk.
///
Expand Down
25 changes: 25 additions & 0 deletions crates/masking/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,31 @@ pub fn masked_serialize<T: Serialize>(value: &T) -> Result<Value, serde_json::Er
})
}

///
/// Masked serialization.
///
/// Trait object for supporting serialization to Value while accounting for masking
/// The usual Serde Serialize trait cannot be used as trait objects
/// like &dyn Serialize or boxed trait objects like Box<dyn Serialize> because of Rust's "object safety" rules.
/// In particular, the trait contains generic methods which cannot be made into a trait object.
/// In this case we remove the generic for assuming the serialization to be of 2 types only raw json or masked json
pub trait ErasedMaskSerialize {
/// Masked serialization.
fn masked_serialize(&self) -> Result<Value, serde_json::Error>;
/// Normal serialization.
fn raw_serialize(&self) -> Result<Value, serde_json::Error>;
}

impl<T: Serialize> ErasedMaskSerialize for T {
fn masked_serialize(&self) -> Result<Value, serde_json::Error> {
masked_serialize(self)
}

fn raw_serialize(&self) -> Result<Value, serde_json::Error> {
serde_json::to_value(self)
}
}

use pii_serializer::PIISerializer;

mod pii_serializer {
Expand Down
1 change: 1 addition & 0 deletions crates/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ router_derive = { version = "0.1.0", path = "../router_derive" }
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
scheduler = { version = "0.1.0", path = "../scheduler", default-features = false }
storage_impl = { version = "0.1.0", path = "../storage_impl", default-features = false }
erased-serde = "0.3.31"

[build-dependencies]
router_env = { version = "0.1.0", path = "../router_env", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,17 @@ pub enum StripePaymentStatus {
impl From<api_enums::IntentStatus> for StripePaymentStatus {
fn from(item: api_enums::IntentStatus) -> Self {
match item {
api_enums::IntentStatus::Succeeded => Self::Succeeded,
api_enums::IntentStatus::Succeeded | api_enums::IntentStatus::PartiallyCaptured => {
Self::Succeeded
}
api_enums::IntentStatus::Failed => Self::Canceled,
api_enums::IntentStatus::Processing => Self::Processing,
api_enums::IntentStatus::RequiresCustomerAction
| api_enums::IntentStatus::RequiresMerchantAction => Self::RequiresAction,
api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod,
api_enums::IntentStatus::RequiresConfirmation => Self::RequiresConfirmation,
api_enums::IntentStatus::RequiresCapture
| api_enums::IntentStatus::PartiallyCaptured => Self::RequiresCapture,
| api_enums::IntentStatus::PartiallyCapturedAndCapturable => Self::RequiresCapture,
api_enums::IntentStatus::Cancelled => Self::Canceled,
}
}
Expand Down
6 changes: 4 additions & 2 deletions crates/router/src/compatibility/stripe/setup_intents/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,17 @@ pub enum StripeSetupStatus {
impl From<api_enums::IntentStatus> for StripeSetupStatus {
fn from(item: api_enums::IntentStatus) -> Self {
match item {
api_enums::IntentStatus::Succeeded => Self::Succeeded,
api_enums::IntentStatus::Succeeded | api_enums::IntentStatus::PartiallyCaptured => {
Self::Succeeded
}
api_enums::IntentStatus::Failed => Self::Canceled,
api_enums::IntentStatus::Processing => Self::Processing,
api_enums::IntentStatus::RequiresCustomerAction => Self::RequiresAction,
api_enums::IntentStatus::RequiresMerchantAction => Self::RequiresAction,
api_enums::IntentStatus::RequiresPaymentMethod => Self::RequiresPaymentMethod,
api_enums::IntentStatus::RequiresConfirmation => Self::RequiresConfirmation,
api_enums::IntentStatus::RequiresCapture
| api_enums::IntentStatus::PartiallyCaptured => {
| api_enums::IntentStatus::PartiallyCapturedAndCapturable => {
logger::error!("Invalid status change");
Self::Canceled
}
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/aci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ impl api::IncomingWebhook for Aci {
fn get_webhook_resource_object(
&self,
_request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<serde_json::Value, errors::ConnectorError> {
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
Err(errors::ConnectorError::WebhooksNotImplemented).into_report()
}
}
8 changes: 2 additions & 6 deletions crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,17 +1600,13 @@ impl api::IncomingWebhook for Adyen {
fn get_webhook_resource_object(
&self,
request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<serde_json::Value, errors::ConnectorError> {
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
let notif = get_webhook_object_from_body(request.body)
.change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;

let response: adyen::Response = notif.into();

let res_json = serde_json::to_value(response)
.into_report()
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?;

Ok(res_json)
Ok(Box::new(response))
}

fn get_webhook_api_response(
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/connector/airwallex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,13 +1081,13 @@ impl api::IncomingWebhook for Airwallex {
fn get_webhook_resource_object(
&self,
request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<serde_json::Value, errors::ConnectorError> {
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
let details: airwallex::AirwallexWebhookObjectResource = request
.body
.parse_struct("AirwallexWebhookObjectResource")
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?;

Ok(details.data.object)
Ok(Box::new(details.data.object))
}

fn get_dispute_details(
Expand Down
3 changes: 2 additions & 1 deletion crates/router/src/connector/airwallex/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,8 @@ pub enum AirwallexDisputeStage {

#[derive(Debug, Deserialize)]
pub struct AirwallexWebhookDataResource {
pub object: serde_json::Value,
// Should this be a secret by default since it represents webhook payload
pub object: Secret<serde_json::Value>,
}

#[derive(Debug, Deserialize)]
Expand Down
10 changes: 4 additions & 6 deletions crates/router/src/connector/authorizedotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,17 +875,15 @@ impl api::IncomingWebhook for Authorizedotnet {
fn get_webhook_resource_object(
&self,
request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<serde_json::Value, errors::ConnectorError> {
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
let payload: authorizedotnet::AuthorizedotnetWebhookObjectId = request
.body
.parse_struct("AuthorizedotnetWebhookObjectId")
.change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?;
let sync_payload = serde_json::to_value(

Ok(Box::new(
authorizedotnet::AuthorizedotnetSyncResponse::try_from(payload)?,
)
.into_report()
.change_context(errors::ConnectorError::ResponseHandlingFailed)?;
Ok(sync_payload)
))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/bambora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ impl api::IncomingWebhook for Bambora {
fn get_webhook_resource_object(
&self,
_request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<serde_json::Value, errors::ConnectorError> {
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
Err(errors::ConnectorError::WebhooksNotImplemented).into_report()
}
}
Expand Down
Loading

0 comments on commit 2bdf6bc

Please sign in to comment.