11# Flexpay PHP
22
33![ Lint] ( https://github.com/devscast/flexpay/actions/workflows/lint.yaml/badge.svg )
4- ![ Test] ( https://github.com/devscast/flexpay/actions/workflows/lint .yaml/badge.svg )
4+ ![ Test] ( https://github.com/devscast/flexpay/actions/workflows/test .yaml/badge.svg )
55[ ![ Latest Stable Version] ( https://poser.pugx.org/devscast/flexpay/version )] ( https://packagist.org/packages/devscast/flexpay )
66[ ![ Total Downloads] ( https://poser.pugx.org/devscast/flexpay/downloads )] ( https://packagist.org/packages/devscast/flexpay )
77[ ![ License] ( https://poser.pugx.org/devscast/flexpay/license )] ( https://packagist.org/packages/devscast/flexpay )
@@ -35,30 +35,51 @@ $flexpay = new Flexpay(
3535);
3636```
3737
38- ### Create a Payment (Intention)
38+ ### Create a Payment Request
3939
4040``` php
41- use Devscast\Flexpay\Data\Currency;use Devscast\Flexpay\Request\MobileRequest;
41+ use Devscast\Flexpay\Data\Currency;
42+ use Devscast\Flexpay\Request\VposRequest;
43+ use Devscast\Flexpay\Request\MobileRequest;
4244
43- $entry = new MobileRequest(
45+ $mobile = new MobileRequest(
4446 amount: 10, // 10 USD
4547 currency: Currency::USD,
46- phone: "243999999999", // mandatory for mobile money
48+ phone: "243999999999",
4749 reference: "your_unique_transaction_reference",
4850 description: "your_transaction_description",
4951 callbackUrl: "your_website_webhook_url",
5052);
53+
54+ $card = new VposRequest(
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+ )
5162```
5263
5364> ** Note** : we highly recommend your ` callbacks ` urls to be unique for each transaction.
5465
55- ### Process a payment ( Mobile Money)
66+ ### Mobile Payment
5667Once 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.
5768after that the payment will be processed and the callback url will be called with the transaction details.
5869
5970``` php
60- $payment = $flexpay->pay($entry );
71+ $response = $flexpay->pay($mobile );
6172```
73+
74+ ### Virtual POS 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+
6283#### ** handling callback (callbackUrl, approveUrl, cancelUrl, declineUrl)**
6384Flexpay will send a POST request to the defined callbackUrl and the response will contain the transaction details.
6485you can use the following code to handle the callback by providing incoming data as array.
@@ -75,8 +96,3 @@ You don't trust webhook ? you can always check the transaction state by providin
7596$state = $flexpay->check($payment->orderNumber);
7697$state->isSuccessful(); // true or false
7798```
78-
79- ## Features supported
80- - [x] Mobile Payment Service
81- - [x] Check Transaction
82- - [ ] Card Payment (unstable)
0 commit comments