项目作者: fedapay

项目描述 :
FedaPay integration for ReactJs applications
高级语言: JavaScript
项目地址: git://github.com/fedapay/fedapay-reactjs.git
创建时间: 2019-09-24T17:26:28Z
项目社区:https://github.com/fedapay/fedapay-reactjs

开源协议:

下载


FedaPay React

FedaPay CheckoutJs integration for React.js projects.

Install

From a command terminal type the following

  1. npm install fedapay-reactjs --save

Add the CheckoutJs script

Add the checkout.js script in your index.html file.

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Fedapay Checkout React.JS Plugin</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. </head>
  8. <body>
  9. <noscript>
  10. You need to enable JavaScript to run this app.
  11. </noscript>
  12. <div id="root"></div>
  13. <!-- Load the FedaPay checkout.js -->
  14. <script src="https://cdn.fedapay.com/checkout.js?v=1.1.2"></script>
  15. </body>
  16. </html>

Usage

```tsx
import React, { Component } from ‘react’;
import { FedaCheckoutButton, FedaCheckoutContainer } from ‘fedapay-reactjs’;

export default class App extends Component {
PUBLIC_KEY = ‘pk_sandbox_XXXXXX’;

checkoutButtonOptions = {
public_key: this.PUBLIC_KEY,
transaction: {
amount: 100,
description: ‘Airtime’
},
currency: {
iso: ‘XOF’
},
button: {
class: ‘btn btn-primary’,
text: ‘Payer 100 FCFA’
},
onComplete(resp) {
const FedaPay = window[‘FedaPay’];
if (resp.reason === FedaPay.DIALOG_DISMISSED) {
alert(‘Vous avez fermé la boite de dialogue’);
} else {
alert(‘Transaction terminée: ‘ + resp.reason);
}

  1. console.log(resp.transaction);
  2. }

};

checkoutEmbedOptions = {
public_key: this.PUBLIC_KEY,
transaction: {
amount: 100,
description: ‘Airtime’
},
currency: {
iso: ‘XOF’
}
};

render() {
return (





)
}
}