Easy Implementation of RavePay Payment gateway using typescript
npm install iamraphson/typescript-ravepayment --save
or
yarn add iamraphson/typescript-ravepayment
import RavePayment from 'typescript-ravepayment'
class DemoClass {
private rave:RavePayment;
constructor(){
this.rave = new RavePayment(false) // if production, true else false
}
payMe(): void {
let raveOption: any = {
PBFPubKey: 'FLWPUBK-xxxxxxxxxxx-X',
txref: this.computeReference(),
amount: 1000,
customer_email: "FooBar@rave.com",
callback : (response: object) => this.callback(response),
onclose: () => this.onclose()
}
this.rave.pay(raveOption)
}
callback(response: object): void {
console.log(response)
}
onclose(): void {
console.log("close")
}
computeReference () : string {
let text = "";
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( let i=0; i < 10; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
}
let RavePayment = require('typescript-ravepayment')
class DemoClass {
private rave:any;
constructor(){
this.rave = RavePayment.Ravepay(true) // if production, true else false
}
payMe(): void {
let raveOption: any = {
PBFPubKey: 'FLWPUBK-xxxxxxxxxxx-X',
txref: this.computeReference(),
amount: 1000,
customer_email: "FooBar@rave.com",
callback : (response: object) => this.callback(response),
onclose: () => this.onclose()
}
this.rave.pay(raveOption)
}
callback(response: object): void {
console.log(response)
}
onclose(): void {
console.log("close")
}
computeReference () : string {
let text = "";
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( let i=0; i < 10; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
}
WHEN DEPLOYING TO PRODUCTION/LIVE SYSTEM, take note of the following;
- Pass in
true
to this functionRavepay
or constructorRavePayment
. E.gRavePayment.Ravepay(true)
ornew RavePayment(true)
- Change RavePay PUBLIC KEY
- Fork it!
- Create your feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -am 'Some commit message'
- Push to the branch:
git push origin feature-name
- Submit a pull request 😉😉
Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or Any Social Media? Spread the word!
Don't forget to follow me on twitter!
Thanks! Ayeni Olusegun.
This project is licensed under the MIT License - see the LICENSE.md file for details