Skip to content

Commit 3d0c6c9

Browse files
author
Toyeeb
committed
Updated SDK for recurring payments
1 parent 36f9ffb commit 3d0c6c9

19 files changed

+276
-20
lines changed

README.md

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,88 @@ export class AppComponent{
278278

279279
```
280280

281+
Recurring payment (Payment Plans) Example:
282+
See [here](https://developer.flutterwave.com/docs/payment-plans) for how to create and fetch payment plans.
283+
```typescript
284+
import {Component, OnInit} from '@angular/core';
285+
import {Flutterwave, InlinePaymentOptions, PaymentSuccessResponse} from "flutterwave-angular-v3"
286+
@Component({
287+
selector: 'app-root',
288+
template: ` <flutterwave-make-payment
289+
[public_key]="publicKey"
290+
amount='10'
291+
currency='NGN'
292+
payment_options="card"
293+
payment_plan="6341"
294+
redirect_url=""
295+
text="Pay for Payment Plan"
296+
[customer]="customerDetails"
297+
[customizations]="customizations"
298+
[meta]="meta"
299+
[tx_ref]="generateReference()"
300+
(callback)="makePaymentCallback($event)"
301+
(close)="closedPaymentModal()" >
302+
</flutterwave-make-payment>`
303+
})
304+
export class AppComponent{
305+
//use your PUBLIC_KEY here
306+
publicKey = "FLWPUBK_TEST-XXXXX-X";
307+
308+
customerDetails = { name: 'Demo Customer Name', email: 'customer@mail.com', phone_number: '08100000000'}
309+
310+
customizations = {title: 'Customization Title', description: 'Customization Description', logo: 'https://flutterwave.com/images/logo-colored.svg'}
311+
312+
meta = {'counsumer_id': '7898', 'consumer_mac': 'kjs9s8ss7dd'}
313+
314+
constructor( private flutterwave: Flutterwave) {}
315+
316+
makePaymentCallback(response: PaymentSuccessResponse): void {
317+
console.log("Pay", response);
318+
this.flutterwave.closePaymentModal(5)
319+
}
320+
closedPaymentModal(): void {
321+
console.log('payment is closed');
322+
}
323+
generateReference(): string {
324+
let date = new Date();
325+
return date.getTime().toString();
326+
}
327+
}
328+
329+
```
330+
Payment option parameters and descriptions:
331+
332+
| Parameter | Always Required ? | Description |
333+
| ------------- | ------------- | ------------- |
334+
| public_key | True | Your API public key |
335+
| tx_ref | True | Your transaction reference. This MUST be unique for every transaction |
336+
| amount | True | Amount to charge the customer. |
337+
| currency | False | currency to charge in. Defaults to NGN
338+
|
339+
| integrity_hash | False | This is a sha256 hash of your FlutterwaveCheckout values, it is used for passing secured values to the payment gateway. |
340+
| payment_options | True | This specifies the payment options to be displayed e.g - card, mobilemoney, ussd and so on. |
341+
| payment_plan | False | This is the payment plan ID used for Recurring billing
342+
|
343+
| redirect_url | False | URL to redirect to when a transaction is completed. This is useful for 3DSecure payments so we can redirect your customer back to a custom page you want to show them. |
344+
| customer | True | This is an object that can contains your customer details: e.g - 'customer': {'email': 'example@example.com','phonenumber': '08012345678','name': 'Takeshi Kovacs' } |
345+
| subaccounts | False | This is an array of objects containing the subaccount IDs to split the payment into. Check our Split Payment page for more info |
346+
| meta | False | This is an object that helps you include additional payment information to your request e.g {'consumer_id': 23,'consumer_mac': '92a3-912ba-1192a' } |
347+
| customizations | True | This is an object that contains title, logo, and description you want to display on the modal e.g{'title': 'Pied Piper Payments','description': 'Middleout isn't free. Pay the price','logo': 'https://assets.piedpiper.com/logo.png' } |
348+
| callback (function) | False | This is the function that runs after payment is completed |
349+
| close (function) | False | This is the function that runs after payment modal is closed |
350+
351+
352+
Methods provided by Flutterwave service and descriptions:
353+
354+
| Method Name | Parameters | Returns |Description |
355+
| ------------- | ------------- | ------------- | ------------- |
356+
| inlinePay | InlinePaymentOptions : Object | Null | This methods allows you to setup and open the payment modal via code |
357+
| asyncInlinePay | AsyncPaymentOptions : Object | Promise | This methods allows you to setup and open the payment modal via code and returns a promise containing the payment response |
358+
| closePaymentModal | waitDuration : number (Optional, default = 0) | Null | This methods allows you to close the payment modal via code. You can setup the wait time before modal close |
359+
360+
361+
362+
281363
<a id="deployment"></a>
282364
## Deployment
283365

@@ -303,4 +385,4 @@ export class AppComponent{
303385

304386

305387

306-
388+

dist/README.md

Lines changed: 104 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
## 📝 Table of Contents
1+
<p align="center">
2+
<img title="Flutterwave" height="200" src="https://flutterwave.com/images/logo-colored.svg" width="50%"/>
3+
</p>
4+
5+
6+
# Flutterwave v3 Angular Library
7+
![Node.js Package](https://github.com/Flutterwave/Flutterwave-Angular-v3/workflows/Node.js%20Package/badge.svg)
8+
![npm](https://img.shields.io/npm/v/flutterwave-angular-v3)
9+
![npm](https://img.shields.io/npm/dt/flutterwave-angular-v3)
10+
![NPM](https://img.shields.io/npm/l/flutterwave-angular-v3)
11+
12+
## Table of Contents
213

314
- [About](#about)
415
- [Getting Started](#getting-started)
@@ -15,7 +26,7 @@ Flutterwave official Angular library to accept payment via card , USSD, QrCode
1526

1627
<a id="getting-started"></a>
1728

18-
## 🏁 Getting Started
29+
## Getting Started
1930

2031
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [deployment](#deployment) for notes on how to deploy the project on a live system.
2132
See [references](#references) for links to dashboard and API documentation.
@@ -45,7 +56,7 @@ $ yarn add flutterwave-angular-v3
4556

4657
<a id="usage"></a>
4758

48-
## 🔧 Usage
59+
## Usage
4960

5061
Import FlutterwaveModule to the app root module
5162

@@ -267,14 +278,96 @@ export class AppComponent{
267278

268279
```
269280

281+
Recurring payment (Payment Plans) Example:
282+
See [here](https://developer.flutterwave.com/docs/payment-plans) for how to create and fetch payment plans.
283+
```typescript
284+
import {Component, OnInit} from '@angular/core';
285+
import {Flutterwave, InlinePaymentOptions, PaymentSuccessResponse} from "flutterwave-angular-v3"
286+
@Component({
287+
selector: 'app-root',
288+
template: ` <flutterwave-make-payment
289+
[public_key]="publicKey"
290+
amount='10'
291+
currency='NGN'
292+
payment_options="card"
293+
payment_plan="6341"
294+
redirect_url=""
295+
text="Pay for Payment Plan"
296+
[customer]="customerDetails"
297+
[customizations]="customizations"
298+
[meta]="meta"
299+
[tx_ref]="generateReference()"
300+
(callback)="makePaymentCallback($event)"
301+
(close)="closedPaymentModal()" >
302+
</flutterwave-make-payment>`
303+
})
304+
export class AppComponent{
305+
//use your PUBLIC_KEY here
306+
publicKey = "FLWPUBK_TEST-XXXXX-X";
307+
308+
customerDetails = { name: 'Demo Customer Name', email: 'customer@mail.com', phone_number: '08100000000'}
309+
310+
customizations = {title: 'Customization Title', description: 'Customization Description', logo: 'https://flutterwave.com/images/logo-colored.svg'}
311+
312+
meta = {'counsumer_id': '7898', 'consumer_mac': 'kjs9s8ss7dd'}
313+
314+
constructor( private flutterwave: Flutterwave) {}
315+
316+
makePaymentCallback(response: PaymentSuccessResponse): void {
317+
console.log("Pay", response);
318+
this.flutterwave.closePaymentModal(5)
319+
}
320+
closedPaymentModal(): void {
321+
console.log('payment is closed');
322+
}
323+
generateReference(): string {
324+
let date = new Date();
325+
return date.getTime().toString();
326+
}
327+
}
328+
329+
```
330+
Payment option parameters and descriptions:
331+
332+
| Parameter | Always Required ? | Description |
333+
| ------------- | ------------- | ------------- |
334+
| public_key | True | Your API public key |
335+
| tx_ref | True | Your transaction reference. This MUST be unique for every transaction |
336+
| amount | True | Amount to charge the customer. |
337+
| currency | False | currency to charge in. Defaults to NGN
338+
|
339+
| integrity_hash | False | This is a sha256 hash of your FlutterwaveCheckout values, it is used for passing secured values to the payment gateway. |
340+
| payment_options | True | This specifies the payment options to be displayed e.g - card, mobilemoney, ussd and so on. |
341+
| payment_plan | False | This is the payment plan ID used for Recurring billing
342+
|
343+
| redirect_url | False | URL to redirect to when a transaction is completed. This is useful for 3DSecure payments so we can redirect your customer back to a custom page you want to show them. |
344+
| customer | True | This is an object that can contains your customer details: e.g - 'customer': {'email': 'example@example.com','phonenumber': '08012345678','name': 'Takeshi Kovacs' } |
345+
| subaccounts | False | This is an array of objects containing the subaccount IDs to split the payment into. Check our Split Payment page for more info |
346+
| meta | False | This is an object that helps you include additional payment information to your request e.g {'consumer_id': 23,'consumer_mac': '92a3-912ba-1192a' } |
347+
| customizations | True | This is an object that contains title, logo, and description you want to display on the modal e.g{'title': 'Pied Piper Payments','description': 'Middleout isn't free. Pay the price','logo': 'https://assets.piedpiper.com/logo.png' } |
348+
| callback (function) | False | This is the function that runs after payment is completed |
349+
| close (function) | False | This is the function that runs after payment modal is closed |
350+
351+
352+
Methods provided by Flutterwave service and descriptions:
353+
354+
| Method Name | Parameters | Returns |Description |
355+
| ------------- | ------------- | ------------- | ------------- |
356+
| inlinePay | InlinePaymentOptions : Object | Null | This methods allows you to setup and open the payment modal via code |
357+
| asyncInlinePay | AsyncPaymentOptions : Object | Promise | This methods allows you to setup and open the payment modal via code and returns a promise containing the payment response |
358+
| closePaymentModal | waitDuration : number (Optional, default = 0) | Null | This methods allows you to close the payment modal via code. You can setup the wait time before modal close |
359+
360+
361+
362+
270363
<a id="deployment"></a>
271-
## 🚀 Deployment
364+
## Deployment
272365

273366
- Switch to Live Mode on the Dashboard settings page
274-
- Use the Live Public API key
367+
- Use the Live Public API key from the API tab
275368

276369
<a id="build-tools"></a>
277-
## ⛏️ Built Using
370+
## Built Using
278371

279372
- [Angular CLI](https://cli.angular.io/)
280373
- [Typescript](https://www.typescriptlang.org/)
@@ -284,8 +377,12 @@ export class AppComponent{
284377

285378

286379
<a id="references"></a>
287-
## 🎉 Flutterwave API References
380+
## Flutterwave API References
288381

289382
- [Flutterwave API Doc](https://developer.flutterwave.com/docs)
290383
- [Flutterwave Inline Payment Doc](https://developer.flutterwave.com/docs/flutterwave-inline)
291384
- [Flutterwave Dashboard](https://dashboard.flutterwave.com/login)
385+
386+
387+
388+

dist/bundles/flutterwave-angular-v3.umd.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundles/flutterwave-angular-v3.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)