Skip to content

Commit

Permalink
Merge branch 'payment-management' of github.com:juspay/hyperswitch-we…
Browse files Browse the repository at this point in the history
…b into payment-management
  • Loading branch information
PritishBudhiraja committed Jul 8, 2024
2 parents d5c0436 + 70b920b commit 3d313e2
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 22 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [0.72.7](https://github.com/juspay/hyperswitch-web/compare/v0.72.6...v0.72.7) (2024-07-08)


### Bug Fixes

* passing customer acceptance if recurring_enabled is false in saved methods list ([#476](https://github.com/juspay/hyperswitch-web/issues/476)) ([27c132e](https://github.com/juspay/hyperswitch-web/commit/27c132e0dbad9102ec7b9e9cfbf4d6d886b33bdd))

## [0.72.6](https://github.com/juspay/hyperswitch-web/compare/v0.72.5...v0.72.6) (2024-07-04)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.72.6",
"version": "0.72.7",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
9 changes: 2 additions & 7 deletions src/Components/SavedMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ let make = (

let {paymentToken: paymentTokenVal, customerId} = paymentToken

let isCustomerAcceptanceRequired = useIsCustomerAcceptanceRequired(
~displaySavedPaymentMethodsCheckbox,
~isSaveCardsChecked,
~isGuestCustomer,
)

let bottomElement = {
savedMethods
->Array.mapWithIndex((obj, i) => {
Expand Down Expand Up @@ -106,6 +100,8 @@ let make = (
let json = ev.data->JSON.parseExn
let confirm = json->getDictFromJson->ConfirmType.itemToObjMapper

let isCustomerAcceptanceRequired = customerMethod.recurringEnabled->not

let savedPaymentMethodBody = switch customerMethod.paymentMethod {
| "card" =>
PaymentBody.savedCardBody(
Expand Down Expand Up @@ -215,7 +211,6 @@ let make = (
empty,
complete,
customerMethod,
isCustomerAcceptanceRequired,
applePayToken,
gPayToken,
isManualRetryEnabled,
Expand Down
4 changes: 4 additions & 0 deletions src/Types/PaymentType.res
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ type customerMethods = {
requiresCvv: bool,
lastUsedAt: string,
bank: bank,
recurringEnabled: bool,
}
type savedCardsLoadState =
LoadingSavedCards | LoadedSavedCards(array<customerMethods>, bool) | NoResult(bool)
Expand Down Expand Up @@ -193,6 +194,7 @@ let defaultCustomerMethods = {
requiresCvv: true,
lastUsedAt: "",
bank: {mask: ""},
recurringEnabled: false,
}
let defaultLayout = {
defaultCollapsed: false,
Expand Down Expand Up @@ -885,6 +887,7 @@ let itemToCustomerObjMapper = customerDict => {
requiresCvv: getBool(dict, "requires_cvv", true),
lastUsedAt: getString(dict, "last_used_at", ""),
bank: dict->getBank,
recurringEnabled: getBool(dict, "recurring_enabled", false),
}
})

Expand Down Expand Up @@ -921,6 +924,7 @@ let getCustomerMethods = (dict, str) => {
requiresCvv: getBool(dict, "requires_cvv", true),
lastUsedAt: getString(dict, "last_used_at", ""),
bank: dict->getBank,
recurringEnabled: getBool(dict, "recurring_enabled", false),
}
})
LoadedSavedCards(customerPaymentMethods, false)
Expand Down
6 changes: 3 additions & 3 deletions src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,7 @@ let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~switchToCu
~data,
~statusCode,
~apiLogType=Err,
~eventName=SAVED_PAYMENT_METHODS_CALL,
~eventName=DELETE_PAYMENT_METHODS_CALL,
~logType=ERROR,
~logCategory=API,
(),
Expand All @@ -2056,7 +2056,7 @@ let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~switchToCu
~url=uri,
~statusCode,
~apiLogType=Response,
~eventName=SAVED_PAYMENT_METHODS_CALL,
~eventName=DELETE_PAYMENT_METHODS_CALL,
~logType=INFO,
~logCategory=API,
(),
Expand All @@ -2070,7 +2070,7 @@ let deletePaymentMethod = (~ephemeralKey, ~paymentMethodId, ~logger, ~switchToCu
~optLogger=Some(logger),
~url=uri,
~apiLogType=NoResponse,
~eventName=SAVED_PAYMENT_METHODS_CALL,
~eventName=DELETE_PAYMENT_METHODS_CALL,
~logType=ERROR,
~logCategory=API,
~data=exceptionMessage,
Expand Down
8 changes: 0 additions & 8 deletions src/orca-loader/PaymentMethodsManagementElements.res
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ let make = (
->Option.getOr([])
->JSON.Encode.array

let blockConfirm =
GlobalVars.isInteg &&
options
->JSON.Decode.object
->Option.flatMap(x => x->Dict.get("blockConfirm"))
->Option.flatMap(JSON.Decode.bool)
->Option.getOr(false)
let switchToCustomPod =
GlobalVars.isInteg &&
options
Expand Down Expand Up @@ -199,7 +192,6 @@ let make = (
("publishableKey", publishableKey->JSON.Encode.string),
("endpoint", endpoint->JSON.Encode.string),
("sdkSessionId", sdkSessionId->JSON.Encode.string),
("blockConfirm", blockConfirm->JSON.Encode.bool),
("switchToCustomPod", switchToCustomPod->JSON.Encode.bool),
("sdkHandleOneClickConfirmPayment", sdkHandleOneClickConfirmPayment->JSON.Encode.bool),
("parentURL", "*"->JSON.Encode.string),
Expand Down
5 changes: 5 additions & 0 deletions src/orca-loader/PaymentSessionMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,17 @@ let getCustomerSavedPaymentMethods = (
let paymentMethod = lastUsedPaymentMethod.paymentMethod
let paymentMethodType = lastUsedPaymentMethod.paymentMethodType->Option.getOr("")
let paymentType = paymentMethodType->PaymentHelpers.getPaymentType
let isCustomerAcceptanceRequired = lastUsedPaymentMethod.recurringEnabled->not

let body = [
("payment_method", paymentMethod->JSON.Encode.string),
("payment_token", paymentToken->JSON.Encode.string),
]

if isCustomerAcceptanceRequired {
body->Array.push(("customer_acceptance", PaymentBody.customerAcceptanceBody))->ignore
}

if paymentMethodType !== "" {
body->Array.push(("payment_method_type", paymentMethodType->JSON.Encode.string))->ignore
}
Expand Down
1 change: 0 additions & 1 deletion src/orca-loader/Types.res
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ let getStrFromHyperComponentName = hyperComponentName => {

let getHyperComponentNameFromStr = hyperComponentName => {
switch hyperComponentName {
| "Elements" => Elements
| "PaymentMethodsManagementElements" => PaymentMethodsManagementElements
| _ => Elements
}
Expand Down
2 changes: 2 additions & 0 deletions src/orca-log-catcher/OrcaLogger.res
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type eventName =
| PAYMENT_MANAGEMENT_ELEMENTS_CALLED
| DELETE_SAVED_PAYMENT_METHOD
| DELETE_PAYMENT_METHODS_CALL_INIT
| DELETE_PAYMENT_METHODS_CALL

let eventNameToStrMapper = eventName => {
switch eventName {
Expand Down Expand Up @@ -164,6 +165,7 @@ let eventNameToStrMapper = eventName => {
| PAYMENT_MANAGEMENT_ELEMENTS_CALLED => "PAYMENT_MANAGEMENT_ELEMENTS_CALLED"
| DELETE_SAVED_PAYMENT_METHOD => "DELETE_SAVED_PAYMENT_METHOD"
| DELETE_PAYMENT_METHODS_CALL_INIT => "DELETE_PAYMENT_METHODS_CALL_INIT"
| DELETE_PAYMENT_METHODS_CALL => "DELETE_PAYMENT_METHODS_CALL"
}
}

Expand Down

0 comments on commit 3d313e2

Please sign in to comment.