Skip to content

Commit 465cd41

Browse files
committed
ci: add Github Actions
1 parent 2626419 commit 465cd41

7 files changed

Lines changed: 379 additions & 5 deletions

File tree

.github/workflows/lint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Lint
2+
3+
on:
4+
workflow_call:
5+
push:
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Cache node modules
15+
uses: actions/cache@v4
16+
with:
17+
path: ~/.npm
18+
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
19+
restore-keys: |
20+
${{ runner.os }}-node-
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 22
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run Prettier check
31+
run: npm run check
32+
33+
- name: Run ESLint
34+
run: npm run lint:check
35+
36+
- name: Run TypeScript check
37+
run: npm run check-types

.github/workflows/publish.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*' # Match semantic versioning tags like 1.0.0
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
lint:
12+
uses: ./.github/workflows/lint.yml
13+
14+
test:
15+
uses: ./.github/workflows/test.yml
16+
needs: [lint]
17+
18+
publish:
19+
runs-on: ubuntu-latest
20+
needs: [test]
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
registry-url: https://registry.npmjs.org/
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Publish to npm
35+
run: npm run release
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Tests
2+
3+
on:
4+
workflow_call:
5+
push:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Cache node modules
15+
uses: actions/cache@v4
16+
with:
17+
path: ~/.npm
18+
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
19+
restore-keys: |
20+
${{ runner.os }}-node-
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 22
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run tests
31+
run: npm run test

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at bernard@devscast.tech. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface, this includes new environment
13+
variables, exposed ports, useful file locations and container parameters.
14+
3. Increase the version numbers in any examples files and the README.md to the new version that this
15+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17+
do not have permission to do that, you may request the second reviewer to merge it for you.
18+
19+
## Code of Conduct
20+
21+
### Our Pledge
22+
23+
In the interest of fostering an open and welcoming environment, we as
24+
contributors and maintainers pledge to making participation in our project and
25+
our community a harassment-free experience for everyone, regardless of age, body
26+
size, disability, ethnicity, gender identity and expression, level of experience,
27+
nationality, personal appearance, race, religion, or sexual identity and
28+
orientation.
29+
30+
### Our Standards
31+
32+
Examples of behavior that contributes to creating a positive environment
33+
include:
34+
35+
* Using welcoming and inclusive language
36+
* Being respectful of differing viewpoints and experiences
37+
* Gracefully accepting constructive criticism
38+
* Focusing on what is best for the community
39+
* Showing empathy towards other community members
40+
41+
Examples of unacceptable behavior by participants include:
42+
43+
* The use of sexualized language or imagery and unwelcome sexual attention or
44+
advances
45+
* Trolling, insulting/derogatory comments, and personal or political attacks
46+
* Public or private harassment
47+
* Publishing others' private information, such as a physical or electronic
48+
address, without explicit permission
49+
* Other conduct which could reasonably be considered inappropriate in a
50+
professional setting
51+
52+
### Our Responsibilities
53+
54+
Project maintainers are responsible for clarifying the standards of acceptable
55+
behavior and are expected to take appropriate and fair corrective action in
56+
response to any instances of unacceptable behavior.
57+
58+
Project maintainers have the right and responsibility to remove, edit, or
59+
reject comments, commits, code, wiki edits, issues, and other contributions
60+
that are not aligned to this Code of Conduct, or to ban temporarily or
61+
permanently any contributor for other behaviors that they deem inappropriate,
62+
threatening, offensive, or harmful.
63+
64+
### Scope
65+
66+
This Code of Conduct applies both within project spaces and in public spaces
67+
when an individual is representing the project or its community. Examples of
68+
representing a project or community include using an official project e-mail
69+
address, posting via an official social media account, or acting as an appointed
70+
representative at an online or offline event. Representation of a project may be
71+
further defined and clarified by project maintainers.
72+
73+
### Enforcement
74+
75+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
76+
reported by contacting the project team at bernard@devscast.tech. All
77+
complaints will be reviewed and investigated and will result in a response that
78+
is deemed necessary and appropriate to the circumstances. The project team is
79+
obligated to maintain confidentiality with regard to the reporter of an incident.
80+
Further details of specific enforcement policies may be posted separately.
81+
82+
Project maintainers who do not follow or enforce the Code of Conduct in good
83+
faith may face temporary or permanent repercussions as determined by other
84+
members of the project's leadership.
85+
86+
### Attribution
87+
88+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89+
available at [http://contributor-covenant.org/version/1/4][version]
90+
91+
[homepage]: http://contributor-covenant.org
92+
[version]: http://contributor-covenant.org/version/1/4/

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Flexpay Typescript
2+
3+
![Lint](https://github.com/devscast/flexpay/actions/workflows/lint.yaml/badge.svg)
4+
![Test](https://github.com/devscast/flexpay/actions/workflows/test.yaml/badge.svg)
5+
[![Latest Stable Version](https://poser.pugx.org/devscast/flexpay/version)](https://packagist.org/packages/devscast/flexpay)
6+
[![Total Downloads](https://poser.pugx.org/devscast/flexpay/downloads)](https://packagist.org/packages/devscast/flexpay)
7+
[![License](https://poser.pugx.org/devscast/flexpay/license)](https://packagist.org/packages/devscast/flexpay)
8+
9+
For privacy reasons, Flexpay original documentation cannot be shared without written permission, for more information about credentials
10+
and implementation details, please reach them at flexpay.cd
11+
12+
## Installation
13+
You can use the PHP client by installing the Composer package and adding it to your application’s dependencies:
14+
15+
```bash
16+
composer require devscast/flexpay
17+
```
18+
## Usage
19+
20+
### Authentication
21+
* **Step 1**. Contact Flexpay to get a Merchant Account
22+
You will receive a Merchant Form to complete in order to provide your business details and preferred Cash out Wallet or Banking Details.
23+
* **Step 2**. Once the paperwork is completed, you will be issued with Live and Sandbox Accounts (Merchant Code and Authorization token)
24+
25+
Then use these credentials to authenticate your client
26+
27+
```php
28+
use Devscast\Flexpay\Client as Flexpay;
29+
use Devscast\Flexpay\Credential;
30+
use Devscast\Flexpay\Environment;
31+
32+
$flexpay = new Flexpay(
33+
new Credential('token', 'merchant_code'),
34+
Environment::SANDBOX // use Environment::LIVE for production
35+
);
36+
```
37+
38+
### Create a Payment Request
39+
40+
```php
41+
use Devscast\Flexpay\Data\Currency;
42+
use Devscast\Flexpay\Request\CardRequest;
43+
use Devscast\Flexpay\Request\MobileRequest;
44+
45+
$mobile = new MobileRequest(
46+
amount: 10, // 10 USD
47+
currency: Currency::USD,
48+
phone: "243999999999",
49+
reference: "your_unique_transaction_reference",
50+
description: "your_transaction_description",
51+
callbackUrl: "your_website_webhook_url",
52+
);
53+
54+
$card = new CardRequest(
55+
amount: 10, // 10 USD
56+
currency: Currency::USD,
57+
reference: "your_unique_transaction_reference",
58+
description: "your_transaction_description",
59+
callbackUrl: "your_website_webhook_url",
60+
homeUrl: "your_website_home_url",
61+
)
62+
```
63+
64+
> **Note**: we highly recommend your `callbacks` urls to be unique for each transaction.
65+
66+
### Mobile Payment
67+
Once called, Flexpay will send a payment request to the user's mobile money account, and the user will have to confirm the payment on their phone.
68+
after that the payment will be processed and the callback url will be called with the transaction details.
69+
70+
```php
71+
$response = $flexpay->pay($mobile);
72+
```
73+
74+
### Visa Card Payment
75+
You can set up card payment via VPOS features, which is typically used for online payments.
76+
it's a gateway that allows you to accept payments from your customers using their credit cards.
77+
78+
```php
79+
$response = $flexpay->pay($card);
80+
// redirect to $response->url to complete the payment
81+
```
82+
83+
#### **handling callback (callbackUrl, approveUrl, cancelUrl, declineUrl)**
84+
Flexpay will send a POST request to the defined callbackUrl and the response will contain the transaction details.
85+
you can use the following code to handle the callback by providing incoming data as array.
86+
87+
```php
88+
$state = $flexpay->handleCallback($_POST);
89+
$state->isSuccessful(); // true or false
90+
````
91+
92+
### Check Transaction state
93+
You don't trust webhook ? you can always check the transaction state by providing the order number.
94+
95+
```php
96+
$state = $flexpay->check($payment->orderNumber);
97+
$state->isSuccessful(); // true or false
98+
```

0 commit comments

Comments
 (0)