From 1b748a8dd9a397554d4327c73efff3ea7f529073 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Fri, 19 Apr 2024 15:49:07 +0530 Subject: [PATCH] feat: normal mandate changes --- Hyperswitch-React-Demo-App/.env | 8 +-- Hyperswitch-React-Demo-App/server.js | 17 ++++-- .../src/CheckoutForm.js | 19 ++++++- Hyperswitch-React-Demo-App/src/Payment.js | 1 + src/Components/SavedMethods.res | 2 +- webpack.common.js | 57 ++++++++++--------- 6 files changed, 65 insertions(+), 39 deletions(-) diff --git a/Hyperswitch-React-Demo-App/.env b/Hyperswitch-React-Demo-App/.env index d2c398adf..2a32c4a34 100644 --- a/Hyperswitch-React-Demo-App/.env +++ b/Hyperswitch-React-Demo-App/.env @@ -1,6 +1,6 @@ STATIC_DIR=./dist -HYPERSWITCH_PUBLISHABLE_KEY= -HYPERSWITCH_SECRET_KEY= -HYPERSWITCH_SERVER_URL= -HYPERSWITCH_CLIENT_URL= +HYPERSWITCH_PUBLISHABLE_KEY="pk_snd_3b33cd9404234113804aa1accaabe22f" +HYPERSWITCH_SECRET_KEY="snd_c691ade6995743bd88c166ba509ff5da" +HYPERSWITCH_SERVER_URL="https://sandbox.hyperswitch.io" +HYPERSWITCH_CLIENT_URL="http://localhost:9050" diff --git a/Hyperswitch-React-Demo-App/server.js b/Hyperswitch-React-Demo-App/server.js index caddd6e02..99d95e9dd 100644 --- a/Hyperswitch-React-Demo-App/server.js +++ b/Hyperswitch-React-Demo-App/server.js @@ -45,8 +45,8 @@ app.get("/create-payment-intent", async (req, res) => { try { var paymentIntent; const request = { - currency: "USD", - amount: 2999, + currency: "EUR", + amount: 0, order_details: [ { product_name: "Apple iphone 15", @@ -60,7 +60,16 @@ app.get("/create-payment-intent", async (req, res) => { customer_id: "hyperswitch_sdk_demo_id", email: "hyperswitch_sdk_demo_id@gmail.com", description: "Hello this is description", - // allowed_payment_method_types:["sofort"], + profile_id: "pro_E6k4XxWE3fVzTIYDMzJa", + setup_future_usage: "off_session", + // mandate_data: { + // mandate_type: { + // single_use: { + // amount: 4000, + // currency: "USD", + // }, + // }, + // }, shipping: { address: { state: "zsaasdas", @@ -96,7 +105,7 @@ app.get("/create-payment-intent", async (req, res) => { city: "San Fransico", state: "California", zip: "94122", - country: "US", + country: "PT", first_name: "joseph", last_name: "Doe", }, diff --git a/Hyperswitch-React-Demo-App/src/CheckoutForm.js b/Hyperswitch-React-Demo-App/src/CheckoutForm.js index 3a1013d4b..62f93ba71 100644 --- a/Hyperswitch-React-Demo-App/src/CheckoutForm.js +++ b/Hyperswitch-React-Demo-App/src/CheckoutForm.js @@ -1,7 +1,7 @@ import { PaymentElement } from "@juspay-tech/react-hyper-js"; import Cart from "./Cart"; import { useState, useEffect } from "react"; -import { useHyper, useElements } from "@juspay-tech/react-hyper-js"; +import { useHyper, useWidgets } from "@juspay-tech/react-hyper-js"; import { useNavigate } from "react-router-dom"; import "./App.css"; import "./index"; @@ -10,7 +10,7 @@ import Completion from "./Completion"; export default function CheckoutForm() { const hyper = useHyper(); - const elements = useElements(); + const elements = useWidgets(); const navigate = useNavigate(); const [isSuccess, setSucces] = useState(false); @@ -104,6 +104,21 @@ export default function CheckoutForm() { height: 55, }, }, + // displaySavedPaymentMethodsCheckbox: false, + // displaySavedPaymentMethods: true, + // paymentMethodsHeaderText: "1ssttttt csdnjdnjcnsdjcds", + // savedPaymentMethodsHeaderText: "Saveddd", + business: { + name: "dscsndjkndsjnsc", + }, + showCardFormByDefault: false, + sdkHandleConfirmPayment: { + handleConfirm: true, + buttonText: "SDK Pay Now", + confirmParams: { + return_url: "http://localhost:9060/", + }, + }, }; return ( diff --git a/Hyperswitch-React-Demo-App/src/Payment.js b/Hyperswitch-React-Demo-App/src/Payment.js index b2b104a2f..1bea689cd 100644 --- a/Hyperswitch-React-Demo-App/src/Payment.js +++ b/Hyperswitch-React-Demo-App/src/Payment.js @@ -58,6 +58,7 @@ function Payment() { clientSecret, appearance: { labels: "floating", + theme: "brutal", }, }} > diff --git a/src/Components/SavedMethods.res b/src/Components/SavedMethods.res index 12c0729b4..6ac0ccaef 100644 --- a/src/Components/SavedMethods.res +++ b/src/Components/SavedMethods.res @@ -177,7 +177,7 @@ let make = ( useSubmitPaymentData(submitCallback) let conditionsForShowingSaveCardCheckbox = React.useMemo(() => { - !isGuestCustomer && list.payment_type !== SETUP_MANDATE && displaySavedPaymentMethodsCheckbox + !isGuestCustomer && list.payment_type === NEW_MANDATE && displaySavedPaymentMethodsCheckbox }, (isGuestCustomer, list.payment_type, displaySavedPaymentMethodsCheckbox))
diff --git a/webpack.common.js b/webpack.common.js index c8fc54102..df605b23a 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -98,22 +98,23 @@ module.exports = (publicPath = "auto") => { clean: true, publicPath: `${repoPublicPath}/`, }, - optimization: { - sideEffects: true, - minimize: true, - minimizer: [ - new TerserPlugin({ - terserOptions: { - compress: { - drop_console: false, - }, - }, - }), - // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line - // `...`, - // new CssMinimizerPlugin(), - ], - }, + // TODO - Can be commented + // optimization: { + // sideEffects: true, + // minimize: true, + // minimizer: [ + // new TerserPlugin({ + // terserOptions: { + // compress: { + // drop_console: false, + // }, + // }, + // }), + // // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line + // // `...`, + // // new CssMinimizerPlugin(), + // ], + // }, plugins: [ new MiniCssExtractPlugin(), new CopyPlugin({ @@ -155,18 +156,18 @@ module.exports = (publicPath = "auto") => { // new webpack.HTMLInjectPlugin({ // publicPath: JSON.stringify(repoVersion), // }), - sentryWebpackPlugin({ - org: "sentry", - project: "hyperswitch-react-sdk", - authToken: process.env.SENTRY_AUTH_TOKEN, - url: process.env.SENTRY_URL, - release: { - name: "0.2", - uploadLegacySourcemaps: { - paths: ["dist"], - }, - }, - }), + // sentryWebpackPlugin({ + // org: "sentry", + // project: "hyperswitch-react-sdk", + // authToken: process.env.SENTRY_AUTH_TOKEN, + // url: process.env.SENTRY_URL, + // release: { + // name: "0.2", + // uploadLegacySourcemaps: { + // paths: ["dist"], + // }, + // }, + // }), ], module: { rules: [