Skip to content

getuni/react-use-wyre

Repository files navigation

react-use-wyre

React.js hooks for making payments using SendWyre. https://docs.sendwyre.com

🔥 Features

  • Buy and sell fiat and crypto currency in both React and React Native
  • Exports an axios-inspired useWyre 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

🚀 Getting Started

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!

Installing

Using yarn:

yarn add react-use-wyre

Using npm:

npm install --save react-use-wyre

Declaring SendWyre

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.

Using the useWyre Hook

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",
  },
);

✌️ License

MIT

About

🤑 React.js hooks for making payments using SendWyre. https://docs.sendwyre.com/

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published