Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial set up for pay pal #15

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@holonym-foundation/utils": "^1.0.1",
"@holonym-foundation/zokrates-js-fork": "1.1.42",
"@paypal/react-paypal-js": "^7.8.2",
"@paypal/react-paypal-js": "^8.1.3",
"@tanstack/react-query": "^4.22.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
Expand Down
14 changes: 12 additions & 2 deletions src/components/issuance/GovernmentIDIssuance/GovIDPayment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { tokenSymbolToCurrency } from "../../../constants";
import CryptoPaymentScreen from "./CryptoPaymentScreen";
import PaymentOptions from "./PaymentOptions";
import { SupportedChainIdsForIDVPayment } from "../../../types";
import PayPalPaymentScreen from "./PayPalPaymentScreen";

const GovIDPayment = ({
onPaymentSuccess
onPaymentSuccess,
onPayPalSyuccess
}: {
onPaymentSuccess: (data: { chainId?: number, txHash?: string}) => void
onPayPalSyuccess: (data: { username?: string; txId?: string }) => void
}) => {
const [selectedPage, setSelectedPage] = useState<"options" | "fiat" | "crypto">("options");
const [selectedToken, setSelectedToken] = useState<"ETH" | "FTM">();
const [selectedToken, setSelectedToken] = useState<"ETH" | "FTM" | "FIAT">();
const [selectedChainId, setSelectedChainId] = useState<SupportedChainIdsForIDVPayment>();

return (
Expand All @@ -34,6 +37,13 @@ const GovIDPayment = ({
/>
)}

{selectedPage === "fiat" && selectedToken && (
<PayPalPaymentScreen
onPaymentSuccess={onPayPalSyuccess}
onBack={() => setSelectedPage("options")}
/>
)}

</>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { useState } from "react";
import { PayPalScriptProvider, PayPalButtons } from "@paypal/react-paypal-js";

const PayPalPaymentScreen = (props: {
onPaymentSuccess: (data: { username?: string; txId?: string }) => void;
onBack: () => void;
}) => {

return (
<>
<div
className="x-wrapper small-center"
style={{
display: "flex",
height: "95%",
width: "80%",
alignItems: "stretch",
justifyContent: "stretch",
flexDirection: "column",
gap: "50px",
}}
>
<h1>Payment Options</h1>
<PayPalScriptProvider options={{clientId: "test"}}>
<PayPalButtons />
</PayPalScriptProvider>

<div
style={{
marginTop: "20px",
marginBottom: "20px",
display: "flex",
justifyContent: "center",
}}
>
<button
className="export-private-info-button"
onClick={(event) => {
event.preventDefault();
props.onBack();
}}
>
Back
</button>
</div>
</div>
</>
);
};

export default PayPalPaymentScreen;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const PaymentOptions = ({
}: {
onSelectOption: (
fiat: boolean,
symbol: "ETH" | "FTM",
symbol: "ETH" | "FTM" | "FIAT",
chainId: SupportedChainIdsForIDVPayment
) => void;
}) => {
Expand Down Expand Up @@ -74,8 +74,12 @@ const PaymentOptions = ({
})
</a>
<a
className="x-button-blue greyed-out-button"
className="x-button-blue"
style={{ width: "100%", fontSize: "20px" }}
onClick={(event) => {
event.preventDefault();
onSelectOption(true, "FIAT", 0);
}}
>
Pay In Fiat (coming soon)
</a>
Expand Down
4 changes: 4 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export const tokenSymbolToCurrency = {
name: "Fantom",
symbol: "FTM",
},
FIAT: {
name: "PayPal",
symbol: "FIAT",
}
}

export const stateAbbreviations = {
Expand Down
2 changes: 1 addition & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,4 @@ export type Currency = {
symbol: string;
};

export type SupportedChainIdsForIDVPayment = 10 | 250 | 420
export type SupportedChainIdsForIDVPayment = 10 | 250 | 420 | 0
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2344,19 +2344,19 @@
dependencies:
mirada "^0.0.15"

"@paypal/paypal-js@^5.1.6":
version "5.1.6"
resolved "https://registry.yarnpkg.com/@paypal/paypal-js/-/paypal-js-5.1.6.tgz#8ec59f4cc016addb3de41511f70950fd0359ffdb"
integrity sha512-1upF06pv0AUtTftRVSra44p8ibqGa3ruKLArvdhpZla25zcrND7R+nDUIMrJ0iteVYZowhujZStFs6NoruExfg==
"@paypal/paypal-js@^7.0.0":
version "7.0.2"
resolved "https://registry.yarnpkg.com/@paypal/paypal-js/-/paypal-js-7.0.2.tgz#d45e13781be30fcfd707a8a44289d4db67c33b4a"
integrity sha512-ZCOS5P3syfA9MYEq501N93pKpr8ZsXw9jun/rLNS7WNphao0ckfreqTCO5EoXcdceZVPS66H0IgG7PKn/jbBKQ==
dependencies:
promise-polyfill "^8.3.0"

"@paypal/react-paypal-js@^7.8.2":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@paypal/react-paypal-js/-/react-paypal-js-7.8.3.tgz#a5ca30a6db6a16776a447976c168f6b7438b1fb9"
integrity sha512-7sD5JFA0IH9kysyGFv5DTmtPn54vLWZ0DLhdjUvsjqZnoEs11mJJJlTsTA7MkIO3jBAJOWlfoA4wLYzmy68C4g==
"@paypal/react-paypal-js@^8.1.3":
version "8.1.3"
resolved "https://registry.yarnpkg.com/@paypal/react-paypal-js/-/react-paypal-js-8.1.3.tgz#2a46bd864eee02efada370ca50fab5a5bf38f4ff"
integrity sha512-hEm27iYP/UHS3XPBhDdiK2U4PH1FxrOD5O3f9tstAVLJd82l/laCjq751HiESSm63PVOoFeKE41Fe1mYGab+oA==
dependencies:
"@paypal/paypal-js" "^5.1.6"
"@paypal/paypal-js" "^7.0.0"
"@paypal/sdk-constants" "^1.0.122"

"@paypal/sdk-constants@^1.0.122":
Expand Down