Created
October 18, 2021 18:55
-
-
Save arvindrajnaidu/dd2400a524336043d4c2268aeeacdc7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { PayPalButtons } from "@paypal/react-paypal-js"; | |
| const PayPalButton = ({ order, saveToServer }) => { | |
| return ( | |
| <PayPalButtons | |
| fundingSource={"paypal"} | |
| style={{ layout: "horizontal" }} | |
| createOrder={(data, actions) => { | |
| return actions.order.create({ | |
| purchase_units: [ | |
| { | |
| amount: { | |
| value: `${(centsAmount / 100).toFixed(2)}`, | |
| }, | |
| }, | |
| ], | |
| }); | |
| }} | |
| onApprove={(details) => { | |
| saveToServer({ | |
| id: details.orderID, | |
| paymentProvider: "paypal", | |
| }).then(() => { | |
| console.log('Paid') | |
| }); | |
| }} | |
| /> | |
| ); | |
| }; | |
| export default PayPalButton; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment