Last active
September 29, 2017 15:06
-
-
Save kingisaac95/68714aa983bc8e25f8d4ed1fe282c0c4 to your computer and use it in GitHub Desktop.
A simple script for rave-payment library that + a little button for triggering the modal.
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, { Component } from 'react' | |
// import the library | |
import RavePaymentModal from 'react-ravepayment' | |
class App extends Component { | |
state = { | |
key: "FLWPUBK-XXXXXXXXXXXXXXXXXXXXXXXXXX-X", // RavePay PUBLIC KEY | |
email: "[email protected]", // customer email | |
amount: "1000" // equals NGN 1000. Minimum amount allow of NGN500, | |
} | |
callback = (response) => console.log(response); | |
close = () => console.log("Payment closed"); | |
getReference = () => { | |
let text = ""; | |
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.="; | |
for( let i=0; i < 10; i++ ) | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
return text; | |
} | |
makePayment = () => { | |
return ( | |
<RavePaymentModal | |
text="Make Payment" | |
class="payButton" | |
reference={this.getReference()} | |
email={this.state.email} | |
amount={this.state.amount} | |
ravePubKey={this.state.key} | |
callback={this.callback} | |
close={this.close} | |
/> | |
); | |
} | |
render () { | |
return ( | |
<div className='App'> | |
<p className='App-intro'> | |
<button className={this.state.class} onClick={this.payWithRave} > | |
{this.state.text} | |
</button> | |
</p> | |
</div> | |
) | |
} | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment