Skip to content

Commit d495379

Browse files
Merge pull request #69 from Abraham-Flutterwave/dev
General Update: Enhanced Features and Improved Performance
2 parents 16e9f8a + 1432b78 commit d495379

31 files changed

+564
-125
lines changed

.docker/.gitpod.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM gitpod/workspace-full
2+
3+
RUN sudo install-packages php-xdebug

.env.example

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
PUBLIC_KEY=FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X
2-
SECRET_KEY=FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X
3-
ENCRYPTION_KEY=FLWSECK_XXXXXXXXXXXXXXXX
4-
ENV=staging
1+
FLW_PUBLIC_KEY=FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X
2+
FLW_SECRET_KEY=FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X
3+
FLW_ENCRYPTION_KEY=FLWSECK_XXXXXXXXXXXXXXXX
4+
FLW_ENV=staging
5+
FLW_LOG_DIR=logs
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build and Upload PHP Artifacts
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+' # Match tags like 1.2.3
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
php: ['7.4', '8.1', '8.2', '8.3', '8.4']
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Set up PHP ${{ matrix.php }}
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
25+
26+
- name: Install dependencies
27+
run: composer install --no-dev --optimize-autoloader
28+
29+
- name: Get tag version
30+
id: tag
31+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV"
32+
33+
- name: Create release artifact
34+
run: |
35+
mkdir -p build
36+
cp -r vendor src tests assets composer.json composer.lock .gitignore LICENSE phpunit.xml.dist .env.example processPayment.php paymentForm.php setup.php README.md CHANGELOG.md build/
37+
cd build && zip -r ../flutterwave-php-${VERSION}-php${{ matrix.php }}.zip . && cd ..
38+
39+
- name: Upload artifact to release
40+
uses: softprops/action-gh-release@v1
41+
with:
42+
files: flutterwave-php-${{ env.VERSION }}-php${{ matrix.php }}.zip
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/change-review.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php: [7.4, 8.1, 8.2]
17+
php: [7.4, 8.1, 8.2, 8.3]
1818

1919
env:
2020
XDEBUG_MODE: coverage
@@ -48,17 +48,13 @@ jobs:
4848
- name: Install dependencies
4949
run: composer install --prefer-dist --no-progress
5050

51-
- name: 'Create env file'
52-
run: |
53-
touch .env
54-
echo PUBLIC_KEY=${PUBLIC_KEY} >> .env
55-
echo SECRET_KEY=${SECRET_KEY} >> .env
56-
echo ENCRYPTION_KEY=${ENCRYPTION_KEY} >> .env
57-
echo ENV=${ENV} >> .env
58-
ls -a ${{ github.workspace }}
59-
6051
- name: run unit tests and coverage scan
6152
run: ./vendor/bin/pest --coverage --min=20 --coverage-clover ./coverage.xml
53+
env:
54+
PUBLIC_KEY: ${{ secrets.PUBLIC_KEY }}
55+
SECRET_KEY: ${{ secrets.SECRET_KEY }}
56+
ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }}
57+
ENV: ${{ secrets.ENV }}
6258

6359
- name: Upload to Codecov
6460
uses: codecov/codecov-action@v2

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,6 @@ example.php
198198
.phpunit.cache
199199
coverage.xml
200200
.env.local
201-
.php-cs-fixer.cache
201+
.php-cs-fixer.cache
202+
.idx/
203+
.vscode/

.gitpod.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This configuration file was automatically generated by Gitpod.
2+
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
3+
# and commit this file to your remote git repository to share the goodness with others.
4+
5+
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
6+
7+
image:
8+
file: .docker/.gitpod.Dockerfile
9+
10+
tasks:
11+
- init: make
12+
13+
vscode:
14+
extensions:
15+
- felixfbecker.php-debug

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
.PHONY: init
2-
test:
2+
check:
33
@echo "Installing dependencies..."
44
@composer install
55
@echo "Installing dependencies... Done"
66
@./vendor/bin/pest --coverage --min=0 --coverage-clover ./coverage.xml
77

88

9+
test:
10+
@./vendor/bin/pest --coverage --min=0 --coverage-clover ./coverage.xml
11+
12+
debug:
13+
XDEBUG_MODE=coverage ./vendor/bin/pest --coverage --coverage-html .log
14+
15+

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Available features include:
4747

4848
## Installation
4949

50+
### Download Release Artifact
51+
If you do not want to make use of composer. each [release](https://github.com/Flutterwave/PHP-v3/releases/) contains a zip with all the dependencies installed. Simply download the one that supports your php version.
52+
5053
### Installation via Composer.
5154

5255
To install the package via Composer, run the following command.
@@ -67,10 +70,11 @@ cp .env.example .env
6770
Your `.env` file should look this.
6871

6972
```env
70-
PUBLIC_KEY=FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X
71-
SECRET_KEY=FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X
72-
ENCRYPTION_KEY=FLWSECK_XXXXXXXXXXXXXXXX
73-
ENV='staging/production'
73+
FLW_PUBLIC_KEY=FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X
74+
FLW_SECRET_KEY=FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X
75+
FLW_ENCRYPTION_KEY=FLWSECK_XXXXXXXXXXXXXXXX
76+
FLW_ENV='staging/production'
77+
FLW_LOG_DIR=logs
7478
```
7579

7680
### Render Payment Modal

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"ext-openssl": "*",
2222
"guzzlehttp/guzzle": "^7.5",
2323
"psr/http-client": "^1.0",
24+
"psr/log": "^1.1 || ^2.0 || ^3.0",
2425
"php-http/guzzle7-adapter": "^1.0",
2526
"composer/ca-bundle": "^1.3"
2627
},

examples/card.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@
44

55
use Flutterwave\Util\AuthMode;
66
use Flutterwave\Util\Currency;
7-
\Flutterwave\Flutterwave::bootstrap();
7+
use Flutterwave\Config\ForkConfig;
8+
use Dotenv\Dotenv;
9+
// custom config.
10+
11+
if(!file_exists( '.env' )) {
12+
$dotenv = Dotenv::createImmutable(__DIR__."/../");
13+
} else {
14+
$dotenv = Dotenv::createImmutable(__DIR__."/");
15+
}
16+
17+
$dotenv->safeLoad();
18+
19+
$config = ForkConfig::setUp(
20+
$_ENV['SECRET_KEY'],
21+
$_ENV['PUBLIC_KEY'],
22+
$_ENV['ENV'],
23+
$_ENV['ENCRYPTION_KEY']
24+
);
25+
26+
\Flutterwave\Flutterwave::bootstrap($config);
827

928
try {
1029

@@ -48,6 +67,8 @@
4867
$data['customer'] = $customerObj;
4968
$payload = $cardpayment->payload->create($data);
5069

70+
71+
5172
if(!empty($_REQUEST))
5273
{
5374
$request = $_REQUEST;
@@ -59,7 +80,7 @@
5980

6081
if(isset($request['make'])){
6182
$result = $cardpayment->initiate($payload);
62-
83+
dd($cardpayment);
6384
if($result['mode'] === AuthMode::PIN){
6485
$instruction = $result['instruction'];
6586
require __DIR__."/view/form/pin.php";

0 commit comments

Comments
 (0)