Skip to content

Commit

Permalink
Merge branch 'main' into locker-id-as-hyps-token-for-cards
Browse files Browse the repository at this point in the history
  • Loading branch information
vspecky authored Oct 16, 2023
2 parents 55fa6ed + f43ed3c commit c0ccd6d
Show file tree
Hide file tree
Showing 543 changed files with 28,614 additions and 3,983 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@ All notable changes to HyperSwitch will be documented here.

- - -

## 1.58.0 (2023-10-15)

### Features

- **connector:**
- [HELCIM] Implement Cards for Helcim ([#2210](https://github.com/juspay/hyperswitch/pull/2210)) ([`b5feab6`](https://github.com/juspay/hyperswitch/commit/b5feab61d950921c75267ad88e944e7e2c4af3ca))
- [Paypal] use connector request reference id as reference for paypal ([#2577](https://github.com/juspay/hyperswitch/pull/2577)) ([`500405d`](https://github.com/juspay/hyperswitch/commit/500405d78938772e0e9f8e3ce4f930d782c670fa))
- [Airwallex] Currency Unit Conversion ([#2571](https://github.com/juspay/hyperswitch/pull/2571)) ([`8971b17`](https://github.com/juspay/hyperswitch/commit/8971b17b073315f869e3c843b0aee7644dcf6479))
- [Klarna] Use connector_request_reference_id as reference to connector ([#2494](https://github.com/juspay/hyperswitch/pull/2494)) ([`2609ef6`](https://github.com/juspay/hyperswitch/commit/2609ef6aeb17e1e89d8f98ff84a2c33b9704e6b2))
- [Dlocal] Use connector_response_reference_id as reference to merchant ([#2446](https://github.com/juspay/hyperswitch/pull/2446)) ([`f6677b8`](https://github.com/juspay/hyperswitch/commit/f6677b8e9300a75810a39de5b60243e34cf1d76c))
- **nexinets:** Use connector_request_reference_id as reference to the connector - Work In Progress ([#2515](https://github.com/juspay/hyperswitch/pull/2515)) ([`088dce0`](https://github.com/juspay/hyperswitch/commit/088dce076d8d8ff86769717368150e09d7d92593))
- **router:** Add Cancel Event in Webhooks and Mapping it in Stripe ([#2573](https://github.com/juspay/hyperswitch/pull/2573)) ([`92f7918`](https://github.com/juspay/hyperswitch/commit/92f7918e6f98460fb739d50b908ae33fda2f80b8))

### Refactors

- **connector:**
- [Worldline] Currency Unit Conversion ([#2569](https://github.com/juspay/hyperswitch/pull/2569)) ([`9f03a41`](https://github.com/juspay/hyperswitch/commit/9f03a4118ccdd6036d27074c9126a79d6e9b0495))
- [Authorizedotnet] Enhance currency Mapping with ConnectorCurrencyCommon Trait ([#2570](https://github.com/juspay/hyperswitch/pull/2570)) ([`d401975`](https://github.com/juspay/hyperswitch/commit/d4019751ff4acbd26abb2c32a600e8e6c55893f6))
- [noon] enhance response status mapping ([#2575](https://github.com/juspay/hyperswitch/pull/2575)) ([`053c79d`](https://github.com/juspay/hyperswitch/commit/053c79d248df0ff6ec702c3c301acc5654a1735a))
- **storage:** Update paymentintent object to provide a relation with attempts ([#2502](https://github.com/juspay/hyperswitch/pull/2502)) ([`fbf3c03`](https://github.com/juspay/hyperswitch/commit/fbf3c03d418242b1f5f1a15c69029023d0b25b4e))

### Testing

- **postman:** Update postman collection files ([`08141ab`](https://github.com/juspay/hyperswitch/commit/08141abb3e87504bb4fe54fdfea92e6c889d729a))

**Full Changelog:** [`v1.57.1+hotfix.1...v1.58.0`](https://github.com/juspay/hyperswitch/compare/v1.57.1+hotfix.1...v1.58.0)

- - -


## 1.57.1 (2023-10-12)

### Bug Fixes
Expand Down
20 changes: 18 additions & 2 deletions crates/router/src/connector/airwallex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ impl ConnectorCommon for Airwallex {
"airwallex"
}

fn get_currency_unit(&self) -> api::CurrencyUnit {
api::CurrencyUnit::Base
}

fn common_get_content_type(&self) -> &'static str {
"application/json"
}
Expand Down Expand Up @@ -369,7 +373,13 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
&self,
req: &types::PaymentsAuthorizeRouterData,
) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
let connector_req = airwallex::AirwallexPaymentsRequest::try_from(req)?;
let connector_router_data = airwallex::AirwallexRouterData::try_from((
&self.get_currency_unit(),
req.request.currency,
req.request.amount,
req,
))?;
let connector_req = airwallex::AirwallexPaymentsRequest::try_from(&connector_router_data)?;
let airwallex_req = types::RequestBody::log_and_get_request_body(
&connector_req,
utils::Encode::<airwallex::AirwallexPaymentsRequest>::encode_to_string_of_json,
Expand Down Expand Up @@ -810,7 +820,13 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
&self,
req: &types::RefundsRouterData<api::Execute>,
) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
let connector_req = airwallex::AirwallexRefundRequest::try_from(req)?;
let connector_router_data = airwallex::AirwallexRouterData::try_from((
&self.get_currency_unit(),
req.request.currency,
req.request.refund_amount,
req,
))?;
let connector_req = airwallex::AirwallexRefundRequest::try_from(&connector_router_data)?;
let airwallex_req = types::RequestBody::log_and_get_request_body(
&connector_req,
utils::Encode::<airwallex::AirwallexRefundRequest>::encode_to_string_of_json,
Expand Down
62 changes: 49 additions & 13 deletions crates/router/src/connector/airwallex/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,38 @@ impl TryFrom<&types::PaymentsInitRouterData> for AirwallexIntentRequest {
}
}

#[derive(Debug, Serialize)]
pub struct AirwallexRouterData<T> {
pub amount: String,
pub router_data: T,
}

impl<T>
TryFrom<(
&types::api::CurrencyUnit,
types::storage::enums::Currency,
i64,
T,
)> for AirwallexRouterData<T>
{
type Error = error_stack::Report<errors::ConnectorError>;

fn try_from(
(currency_unit, currency, amount, router_data): (
&types::api::CurrencyUnit,
types::storage::enums::Currency,
i64,
T,
),
) -> Result<Self, Self::Error> {
let amount = utils::get_amount_as_string(currency_unit, amount, currency)?;
Ok(Self {
amount,
router_data,
})
}
}

#[derive(Debug, Serialize)]
pub struct AirwallexPaymentsRequest {
// Unique ID to be sent for each transaction/operation request to the connector
Expand Down Expand Up @@ -125,16 +157,21 @@ pub struct AirwallexCardPaymentOptions {
auto_capture: bool,
}

impl TryFrom<&types::PaymentsAuthorizeRouterData> for AirwallexPaymentsRequest {
impl TryFrom<&AirwallexRouterData<&types::PaymentsAuthorizeRouterData>>
for AirwallexPaymentsRequest
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
fn try_from(
item: &AirwallexRouterData<&types::PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
let mut payment_method_options = None;
let payment_method = match item.request.payment_method_data.clone() {
let request = &item.router_data.request;
let payment_method = match request.payment_method_data.clone() {
api::PaymentMethodData::Card(ccard) => {
payment_method_options =
Some(AirwallexPaymentOptions::Card(AirwallexCardPaymentOptions {
auto_capture: matches!(
item.request.capture_method,
request.capture_method,
Some(enums::CaptureMethod::Automatic) | None
),
}));
Expand All @@ -158,7 +195,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AirwallexPaymentsRequest {
request_id: Uuid::new_v4().to_string(),
payment_method,
payment_method_options,
return_url: item.request.complete_authorize_url.clone(),
return_url: request.complete_authorize_url.clone(),
})
}
}
Expand Down Expand Up @@ -538,17 +575,16 @@ pub struct AirwallexRefundRequest {
payment_intent_id: String,
}

impl<F> TryFrom<&types::RefundsRouterData<F>> for AirwallexRefundRequest {
impl<F> TryFrom<&AirwallexRouterData<&types::RefundsRouterData<F>>> for AirwallexRefundRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
fn try_from(
item: &AirwallexRouterData<&types::RefundsRouterData<F>>,
) -> Result<Self, Self::Error> {
Ok(Self {
request_id: Uuid::new_v4().to_string(),
amount: Some(utils::to_currency_base_unit(
item.request.refund_amount,
item.request.currency,
)?),
reason: item.request.reason.clone(),
payment_intent_id: item.request.connector_transaction_id.clone(),
amount: Some(item.amount.to_owned()),
reason: item.router_data.request.reason.clone(),
payment_intent_id: item.router_data.request.connector_transaction_id.clone(),
})
}
}
Expand Down
27 changes: 18 additions & 9 deletions crates/router/src/connector/dlocal/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ pub struct DlocalPaymentsResponse {
status: DlocalPaymentStatus,
id: String,
three_dsecure: Option<ThreeDSecureResData>,
order_id: String,
}

impl<F, T>
Expand All @@ -269,12 +270,12 @@ impl<F, T>
});

let response = types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
resource_id: types::ResponseId::ConnectorTransactionId(item.response.order_id.clone()),
redirection_data,
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
connector_response_reference_id: Some(item.response.order_id.clone()),
};
Ok(Self {
status: enums::AttemptStatus::from(item.response.status),
Expand All @@ -288,6 +289,7 @@ impl<F, T>
pub struct DlocalPaymentsSyncResponse {
status: DlocalPaymentStatus,
id: String,
order_id: String,
}

impl<F, T>
Expand All @@ -307,12 +309,14 @@ impl<F, T>
Ok(Self {
status: enums::AttemptStatus::from(item.response.status),
response: Ok(types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
resource_id: types::ResponseId::ConnectorTransactionId(
item.response.order_id.clone(),
),
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
connector_response_reference_id: Some(item.response.order_id.clone()),
}),
..item.data
})
Expand All @@ -323,6 +327,7 @@ impl<F, T>
pub struct DlocalPaymentsCaptureResponse {
status: DlocalPaymentStatus,
id: String,
order_id: String,
}

impl<F, T>
Expand All @@ -342,12 +347,14 @@ impl<F, T>
Ok(Self {
status: enums::AttemptStatus::from(item.response.status),
response: Ok(types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
resource_id: types::ResponseId::ConnectorTransactionId(
item.response.order_id.clone(),
),
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
connector_response_reference_id: Some(item.response.order_id.clone()),
}),
..item.data
})
Expand All @@ -356,7 +363,7 @@ impl<F, T>

pub struct DlocalPaymentsCancelResponse {
status: DlocalPaymentStatus,
id: String,
order_id: String,
}

impl<F, T>
Expand All @@ -376,12 +383,14 @@ impl<F, T>
Ok(Self {
status: enums::AttemptStatus::from(item.response.status),
response: Ok(types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
resource_id: types::ResponseId::ConnectorTransactionId(
item.response.order_id.clone(),
),
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: None,
connector_response_reference_id: Some(item.response.order_id.clone()),
}),
..item.data
})
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/klarna/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct KlarnaPaymentsRequest {
order_amount: i64,
purchase_country: String,
purchase_currency: enums::Currency,
merchant_reference1: String,
}

#[derive(Default, Debug, Deserialize)]
Expand Down Expand Up @@ -140,6 +141,7 @@ impl TryFrom<&KlarnaRouterData<&types::PaymentsAuthorizeRouterData>> for KlarnaP
total_amount: i64::from(data.quantity) * (data.amount),
})
.collect(),
merchant_reference1: item.router_data.connector_request_reference_id.clone(),
}),
None => Err(report!(errors::ConnectorError::MissingRequiredField {
field_name: "product_name"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@
},
"url": {
"raw": "{{baseUrl}}/payments",
"host": ["{{baseUrl}}"],
"path": ["payments"]
"host": [
"{{baseUrl}}"
],
"path": [
"payments"
]
},
"description": "To process a payment you will have to create a payment, attach a payment method and confirm. Depending on the user journey you wish to achieve, you may opt to all the steps in a single request or in a sequence of API request using following APIs: (i) Payments - Update, (ii) Payments - Confirm, and (iii) Payments - Capture"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
],
"url": {
"raw": "{{baseUrl}}/payments/:id?force_sync=true",
"host": ["{{baseUrl}}"],
"path": ["payments", ":id"],
"host": [
"{{baseUrl}}"
],
"path": [
"payments",
":id"
],
"query": [
{
"key": "force_sync",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
],
"url": {
"raw": "{{baseUrl}}/payments/:id?force_sync=true",
"host": ["{{baseUrl}}"],
"path": ["payments", ":id"],
"host": [
"{{baseUrl}}"
],
"path": [
"payments",
":id"
],
"query": [
{
"key": "force_sync",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@
},
"url": {
"raw": "{{baseUrl}}/refunds",
"host": ["{{baseUrl}}"],
"path": ["refunds"]
"host": [
"{{baseUrl}}"
],
"path": [
"refunds"
]
},
"description": "To create a refund against an already processed payment"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@
},
"url": {
"raw": "{{baseUrl}}/refunds",
"host": ["{{baseUrl}}"],
"path": ["refunds"]
"host": [
"{{baseUrl}}"
],
"path": [
"refunds"
]
},
"description": "To create a refund against an already processed payment"
}
Loading

0 comments on commit c0ccd6d

Please sign in to comment.