Skip to content

Commit 9f02f89

Browse files
committed
update README
1 parent eea955d commit 9f02f89

File tree

1 file changed

+43
-84
lines changed

1 file changed

+43
-84
lines changed

README.md

Lines changed: 43 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Paystack PHP SDK
22

3-
## RoadMap
4-
- `Use GuzzleHttp`
3+
### Available resources
4+
- Transaction (Initialize, List, Verify)
5+
- Bank (List, Resolve account)
6+
7+
8+
### Roadmap
59
- `Customers`
610
- `Plans`
711
- `Subscription`
@@ -17,7 +21,7 @@ If you find a BUG/Security Issue, do be kind to open an issue or email [me:matsc
1721

1822

1923
## Requirements
20-
List in the making
24+
- GuzzleHttp
2125

2226
## Installation
2327
``` bash
@@ -28,119 +32,74 @@ composer require matscode/paystack-php-sdk
2832
require_once __DIR__ . "/vendor/autoload.php";
2933
```
3034

31-
#### Manual
35+
### Manual
3236
- Download the archive
3337
- Extract into your project
3438
- And lastly
3539
``` php
3640
require_once __DIR__ . "/vendor/autoload.php";
3741
```
3842

39-
## Making Transactions/Receiving Payment
40-
41-
### Starting Up Paystack Transaction
42-
43+
### Initialize Paystack
4344
``` php
44-
use Matscode\Paystack\Transaction;
45-
use Matscode\Paystack\Utility\Debug; // for Debugging purpose
46-
use Matscode\Paystack\Utility\Http;
45+
use Matscode\Paystack\Paystack;
4746

48-
$secretKey = 'sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
49-
50-
// creating the transaction object
51-
$Transaction = new Transaction( $secretKey );
47+
$paystackSecret = 'sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
48+
$Paystack = new Paystack($paystackSecret);
5249
```
5350

54-
### Initializing Transaction
55-
56-
Set data/payload/requestBody to post with initialize request. Minimum required data are email and amount.
57-
58-
``` php
59-
// Set data to post using array
60-
$data =
61-
[
62-
'email' => 'customer@email.com',
63-
'amount' => 500000 // amount is treated in kobo using this method
64-
];
65-
$response = $Transaction->initialize($data);
51+
## Transaction Resource
52+
#### Initialize Charge
53+
```php
54+
$response = $Paystack->trasaction->initialize([
55+
'email' => 'customer.email@gmail.com',
56+
'amount' => 500000, // amount is in kobo
57+
'callback_url' => 'https://www.app.local/paystack/transaction/verify'
58+
]);
6659
```
6760
OR
6861
``` php
6962
// Set data to post using this method
70-
$response =
71-
$Transaction
72-
->setCallbackUrl('http://michaelakanji.com') // to override/set callback_url, it can also be set on your dashboard
63+
$response = $Paystack->trasaction
64+
->setCallbackUrl('https://www.app.local/paystack/transaction/verify')
7365
->setEmail( 'matscode@gmail.com' )
74-
->setAmount( 75000 ) // amount is treated in Naira while using this method
66+
->setAmount( 75000 ) // amount is treated in Naira while using this setAmount() method
7567
->initialize();
7668
```
77-
If you want to get the 200OK raw Object as it is sent by Paystack, Set the 2nd argument of the `initialize()` to `true`, example below
78-
``` php
79-
// Set data to post using this method
80-
$response =
81-
$Transaction
82-
->setEmail( 'matscode@gmail.com' )
83-
->setAmount( 75000 ) // amount is treated in Naira while using this method
84-
->initialize([], true);
85-
```
8669
Now do a redirect to payment page (using authorization_url)
8770
<br>
88-
NOTE: Recommended to Debug `$response` or check if authorizationUrl is set, and save your Transaction reference code. useful to verify Transaction status
71+
NOTE: Recommended to check if authorizationUrl is set, and save your Transaction reference code. useful to verify Transaction status
8972

9073
``` php
9174
// recommend to save Transaction reference in database and do a redirect
92-
$reference = $response->reference;
93-
// redirect
94-
Http::redirect($response->authorizationUrl);
75+
header('Location: ' . $response->data->authorization_url);
9576
```
96-
Using a Framework? It is recommended you use the reverse routing/redirection functions provided by your Framework
97-
9877

99-
### Verifying Transaction
100-
This part would live in your callback file i.e `callback.php` or `whatsoever_you_name.php`
101-
<br>
102-
It is also imperative that you create Transaction Obj once more.
103-
<br>
104-
This method would return the Transaction Obj but `false` if saved `$reference` is not passed in as argument and also cant be guessed. Using `verify()` would require you do a manual check on the response Obj
78+
#### Verifying Transaction
10579
``` php
106-
$response = $Transaction->verify();
107-
// Debuging the $response
108-
Debug::print_r( $response);
80+
$reference_code = $_GET['reference']
81+
$response = $Paystack->trasaction->verify($reference_code);
10982
```
11083
OR
11184
``` php
11285
// This method does the check for you and return `(bool) true|false`
113-
$response = $Transaction->isSuccessful();
114-
```
115-
The two methods above try to guess your Transaction `$reference` but it is highly recommended you pass the Transaction `$reference` as an argument on the method as follows
116-
``` php
117-
// This method does the check for you and return `(bool) true|false`
118-
$response = $Transaction->isSuccessful($reference);
119-
```
120-
More so, you can also compare if amount paid by a customer is the amount expected. This method only works after calling `verify()` or `isSuccessful()` in the same script. It is recommended to do this if you use paystack inline to initialize the transaction.
121-
``` php
122-
$amountExpected = 5000; // amount must be in kobo
123-
// returns `(bool) true|false`
124-
$Transaction->amountEquals($amountExpected);
125-
```
126-
Now you can process Customer Valuable.
127-
<br>
128-
You might wanna save Transaction `$authorizationCode` for the current customer subsequent Transaction but not a nessecity. It would only counts to future updates of this package or if you choose to extend the package.
129-
``` php
130-
// returns Auth_xxxxxxx
131-
$response = $Transaction->authorizationCode($reference); // can also guess Transaction $reference
86+
$response = $Paystack->transaction->isSuccessful($reference_code);
13287
```
13388

134-
## Contact/Portfolio
135-
Visit: [https://inndex.page/matscode](https://inndex.page/matscode)
136-
<br>
137-
Email: [matscode:gmail](mailto:matscode@gmail.com)
89+
## Bank Resource
90+
#### Get list of banks
91+
```php
92+
$response = $Paystack->bank->list();
93+
```
13894

139-
## Contributions
140-
Guide is coming soon. <br>
141-
If you seem to know the wires, you are welcome to dive in
95+
#### Resolve account info
96+
```php
97+
$bank_code='0000';
98+
$account_number='0987654321'
99+
$response = $Paystack->bank->resolve($bank_code, $account_number);
100+
//result: returns account information is found, throws exception otherwise
101+
```
142102

143-
## Licence
144-
GNU GPLV3
145103

146-
Everything about this project is free... If you however made some improvement, you are welcome to shoot a PR.
104+
## Contact/Portfolio
105+
[Personal Home](https://inndex.page/matscode) | [Email](mailto:matscode@gmail.com)

0 commit comments

Comments
 (0)