Petra React Library
Table of Contents
About
This is a react package for implementing Petra checkout with different payment methods.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. See references for links to dashboard and API documentation.
Installation
$ npm install @thepetra/react
Usage
import React from 'react'
import { useThePetra } from '@thepetra/react'
// ...
export default function App() {
const config = {
key: 'PUBLIC_KEY',
amount: 9000,
email: 'john@thepetra.co',
currency: 'USD',
metadata: {
first_name: 'John',
last_name : 'Legend'
},
onSuccess: (data) => {
console.log('🚀 onSuccess', data)
},
onError: (error) => {
console.log('🚀 onError', error)
},
onClose: (error) => {
console.log(`🚀 onClose: SDK closed by ${error}`)
}
}
const handlePayment = useThePetra(config)
return (
<div className='App'>
<h1>ThePetra SDK</h1>
<button onClick={handlePayment}>Pay with Petra</button>
</div>
)
}
Please checkout The Petra Documentation for other information.
Deployment
- Switch to Live Mode on the Dashboard
- Use the Live Public API key
Built Using
- Typescript
- React