React.js hooks for making payments using SendWyre. https://docs.sendwyre.com
- Buy and sell fiat and crypto currency in both React and React Native
- Exports an
axios
-inspireduseWyre
hook to aid rapid prototyping against the SendWyre API - Provides a high-level
useDebitCard
hook to rapidly introduce debit card payments - Provides an easy-to-use
useApplePay
hook to make payments using Apple Pay a breeze 🌊 - Permits a
baseUrl
prop which does not conflict with request signing- This can be used as a workaround to CORS issues on the Web
Before starting, please make sure that you've collected an API key against the environment you wish to target.
Note: Both the test environment and production environment require a different set of credentials!
Using yarn:
yarn add react-use-wyre
Using npm:
npm install --save react-use-wyre
The default export of the library is the SendWyre
top-level Provider, which is used to configure your API credentials and operating environment:
import React from "react";
import SendWyre from "react-use-wyre";
export default function App({...extras}) {
return (
<SendWyre
apiKey={apiKey}
secretKey={secretKey}
partnerId={partnerId}
baseUrl="https://cors-anywhere.herokuapp.com/"
>
{/* your app here */}
<React.Fragment {...extras} />
</SendWyre>
);
}
By default, the SendWyre
Provider is configured to use the test API, TestWyre. You must manually specify the apiUrl
prop if you want to hit the Production API.
The exported useWyre
hook aids the rapid prototyping of new API calls against SendWyre. All supported client requests are defined in the API Specification. The interface for this call mimics that of axios
.
Below, we show an example of how to hit the Exchange Rates API:
import { useWyre } from "react-use-wyre";
const { wyre } = useWyre();
const {data} = await wyre(
{
url: "v3/rates",
method: "get",
},
);