PHPackages                             sdkcodes/lara-paystack - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. sdkcodes/lara-paystack

ActiveLaravel-package[Payment Processing](/categories/payments)

sdkcodes/lara-paystack
======================

A simple package for using paystack with laravel

v1.0.3(5y ago)6537MITPHP

Since May 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sdkcodes/lara-paystack)[ Packagist](https://packagist.org/packages/sdkcodes/lara-paystack)[ RSS](/packages/sdkcodes-lara-paystack/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

LaraPaystack
============

[](#larapaystack)

A laravel 5 sdk to interface with paystack endpoints
----------------------------------------------------

[](#a-laravel-5-sdk-to-interface-with-paystack-endpoints)

### About

[](#about)

---

This package abstracts Paystack's endpoints into simple methods You can find all paystack's endpoints at

### Requirements

[](#requirements)

- PHP &gt;= 7.0
- Composer
- Laravel &gt;= 5.4

### Installation

[](#installation)

- Run `composer require sdkcodes/lara-paystack` to install the latest version of LaraPaystack

### Features

[](#features)

- Flexibility: This package basically gives you total control and flexibility over the data you pass to paystack with a few helper methods here and there to help you when needed.

### How payment on Paystack works

[](#how-payment-on-paystack-works)

In order to collect payments with paystack from your customers, this is how the flow generally looks like:

1. You initialize a transaction with paystack by sending certain to the paystack api, this data usually contains things like the \[amount and email (and also name and phone number of the customer)\]
2. Paystack responds with a payment url (or authorization url) which is a page on paystack's site that you must redirect your customer to. The actual payment will happen on this page
3. Once payment is complete and successful on this page (i.e your customer has been debited by paystack), paystack redirects the customer back to your site (to a url \[callback url\] you already specified while initiating transaction from step 1). When redirecting the customer back to your site, paystack will also send the transaction reference of the just concluded transaction as a query parameter.
4. On your callback url now, you should then use the transaction reference returned to verify if the transaction was actually genuine or not before you then proceed to give value to the customer.

### Basic Usage

[](#basic-usage)

- You can create a new instance of the Paystack class as such `$paystack = new PaystackService()`, and immediately start to use all methods offered by the SDK.
- You can as well inject it into your constructors or methods e.g

```
public function talkToPaystack(Request $request, PaystackService $paystack){
        // Laravel automatically does the instantiation for you through its Service Container
        // and you can start to use the paystack object in your method
}

```

- With LaraPaystack, you can initiate transaction and redirect to payment url in just one line:

`$paystack->initializeTransaction($data)->redirectNow(); `

Below is a sample route and controller that uses the LaraPaystack package to make and verify payment

```
