Skip to content

Commit 3f2815e

Browse files
committed
Update readme
1 parent 7fd2c50 commit 3f2815e

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

README.md

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ Currently, this package supports the following online payment processors/handler
2929
- [Interswitch](https://www.interswitchgroup.com)**
3030
- [UnifiedPayments](https://unifiedpayments.com)**
3131

32-
_key_:
33-
`** implementation not yet complete for specified payment handler. PRs welcomed if you cannot afford to wait 😉`
32+
> [!NOTE]
33+
> _key_:
34+
> ** for the indicated providers, a few features may be missing. PRs welcomed if you cannot afford the wait 😉
3435
36+
> [!TIP]
3537
> Your preferred payment handler is not yet supported? Please consider [opening the appropriate issue type](https://github.com/damms005/laravel-multipay/issues/new?assignees=&labels=&template=addition-of-new-payment-handler.md&title=Addition+of+new+payment+handler+-+%5Bpayment+handler+name+here%5D).
3638
37-
> Adding a new payment handler is straight-forward. Simply add a class that extends `Damms005\LaravelMultipay\Services\PaymentHandlers\BasePaymentHandler` and implement `Damms005\LaravelMultipay\Contracts\PaymentHandlerInterface`
39+
> [!TIP]
40+
> Adding a new payment handler is straight-forward. Simply add a class that extends `Damms005\LaravelMultipay\Services\PaymentHandlers\BasePaymentHandler` and implement `Damms005\LaravelMultipay\Contracts\PaymentHandlerInterface`
3841
39-
> **Note** <br />
42+
> [!NOTE]
4043
> Payment providers that you so register as described above are resolvable from the [Laravel Container](https://laravel.com/docs/9.x/container) to improve the flexibility of this package and improve DX.
4144
4245
## Installation
@@ -60,7 +63,7 @@ php artisan migrate
6063
```
6164

6265
### Demo Repo
63-
I published an open source app that uses this payment package. It is also an excellent example of a Laravel app that uses [Laravel Vite](https://laravel.com/docs/9.x/vite#main-content) and leverages on [Laravel Echo](https://laravel.com/docs/9.x/broadcasting#client-side-installation) to provide realtime experience via public and private channels using [Laravel Websocket](https://beyondco.de/docs/laravel-websockets), powered by [Livewire](https://laravel-livewire.com/docs). The app is called [NFT Marketplace. Click here to check it out ✌🏼](https://github.com/damms005/nft-marketplace)
66+
I [published an open source app](https://github.com/damms005/nft-marketplace) that uses this payment package. It is also an excellent example of a Laravel app that uses [Laravel Vite](https://laravel.com/docs/9.x/vite#main-content) and leverages on [Laravel Echo](https://laravel.com/docs/9.x/broadcasting#client-side-installation) to provide realtime experience via public and private channels using [Laravel Websocket](https://beyondco.de/docs/laravel-websockets), powered by [Livewire](https://laravel-livewire.com/docs).
6467

6568
### Test drive 🚀
6669

@@ -90,14 +93,14 @@ FLW_SECRET_HASH='My_lovelysite123'
9093
- Paystack: Paystack requires a secret key. Go to [the Paystack dashboard](https://dashboard.paystack.co/#/settings/developer) to obtain one, and use it to set the following variable:
9194

9295
```
93-
PAYSTACK_SECRET_KEY=FLWPUBK-xxxxxxxxxxxxxxxxxxxxx-X
96+
PAYSTACK_SECRET_KEY=sk_test_xxxxxxxxxxxxxxxxxxxxx
9497
```
9598

9699
- Remita: Ensure to set the following environment variables:
97100

98101
```
99-
REMITA_MERCHANT_ID=xxxxxxxxxxxxxxxxxxxxx-X
100-
REMITA_API_KEY=xxxxxxxxxxxxxxxxxxxxx-X
102+
REMITA_MERCHANT_ID=xxxxxxxxxxxxxxxxxxxxx
103+
REMITA_API_KEY=xxxxxxxxxxxxxxxxxxxxx
101104
```
102105

103106
> For most of the above environment variables, you should rather use the (published) config file to set the corresponding values.
@@ -126,17 +129,26 @@ Upon user confirmation of transaction, user is redirected to the appropriate pay
126129
When user is done with the transaction on the payment handler's end (either successfully paid, or declined transaction), user is redirected
127130
back to `/payment/completed` (`route('payment.finished.callback_url')` provided by this package) .
128131

129-
> [!NOTE]
130-
> If the `Payment` has [`metadata`](#step-1) (supplied with the payment initiation request), with a key named `completion_url`, the user will be redirected to that URL instead on successful payment, with the transaction reference included as `transaction_reference` in the URL query string.
132+
### Metadata Usage
131133

132-
> [!NOTE]
133-
> If the `Payment` has [`metadata`](#step-1) (supplied with the payment initiation request), and it contains a key named `payment_processor`, it will be used to dynamically set the payment handler for that particular transaction. Valid value is any of [the providers listed above](#currently-supported-payment-handlers)
134+
In the payment initiation request in [Step 1](#step-1), you can provide a `metadata` field. This field is stored in the `metadata` column of the `payments` table, and available as `AsArrayObject::class` property of the `Payment` model and it provides powerful customization options for individual payments.
134135

135-
> [!NOTE]
136-
> If the `Payment` has [`metadata`](#step-1) (supplied with the payment initiation request), with a key named `split_code`, for Paystack transactions, it will be processed as [Paystack Multi-split Transaction](https://paystack.com/docs/payments/multi-split-payments).
136+
The metadata should be a valid JSON string containing key-value pairs that modify payment behavior.
137137

138-
> [!NOTE]
139-
> If there are additional steps you want to take upon successful payment, listen for `SuccessfulLaravelMultipayPaymentEvent`. It will be fired whenever a successful payment occurs, with its corresponding `Payment` model.
138+
#### Available Metadata Keys
139+
140+
**`completion_url`**
141+
- After successful payment, the user will be redirected to the URL specified by this key instead of the default payment completion page
142+
- When user is redirected to the specified URL, the transaction reference will be included as `transaction_reference` in the URL query string
143+
144+
**`payment_processor`**
145+
- Use this key to dynamically set the payment handler for the specific transaction
146+
- Valid values are any of [the providers listed above](#currently-supported-payment-handlers)
147+
- This will override the default payment processor configuration
148+
149+
**`split_code`** (Paystack only)
150+
- When using Paystack, you can use this key to specify a split code to process the transaction as a [Paystack Multi-split Transaction](https://paystack.com/docs/payments/multi-split-payments)
151+
- This feature is only available when using Paystack as the payment handler
140152

141153
## Payment Conflict Resolution (PCR)
142154

@@ -146,16 +158,24 @@ If for any reason, your user/customer claims that the payment they made was succ
146158
/**
147159
* @var bool //true if payment was successful, false otherwise
148160
**/
149-
$outcome = LaravelMultipay::reQueryUnsuccessfulPayment( $payment )
161+
$outcome = LaravelMultipay::reQueryUnsuccessfulPayment($payment)
150162
```
151163

152164
The payment will be re-resolved and the payment will be updated in the database. If the payment is successful, the `SuccessfulLaravelMultipayPaymentEvent` event will be fired, so you can run any domain/application-specific procedures.
153165

154-
## Payment Notifications (WebHooks)
155-
Some payment handlers provide a means for sending details of successful notifications. Usually, you will need to provide the payment handler with a URL to which the details of such notification will be sent. Should you need this feature, the notification URL is handled by `route('payment.external-webhook-endpoint' provided by this package)`.
166+
## WebHooks Payment Notifications (optional)
167+
One of the benefits of this package is to remove the need for you to have to deal with payment webhooks. Depending on your needs, the event handling may suffice for your use case.
168+
169+
If you need webhook notifications from payment providers, use the webhook endpoint provided by this package: `route('payment.external-webhook-endpoint')`.
156170

157171
> If you use this payment notification URL feature, ensure that in the handler for `SuccessfulLaravelMultipayPaymentEvent`, you have not previously handled the event for that same payment.
158172
173+
## Events
174+
175+
### SuccessfulLaravelMultipayPaymentEvent
176+
177+
If there are additional steps you want to take upon successful payment, listen for `SuccessfulLaravelMultipayPaymentEvent`. This event will be fired whenever a successful payment occurs, with its corresponding `Payment` model.
178+
159179
## Testing
160180

161181
```bash

0 commit comments

Comments
 (0)