Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
composer.lock
.DS_Store
.idea
index.php
index.php
vendor
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
# Laravel Payfast

A dead simple Laravel payment processing class for payments through payfast.co.za. This package only supports ITN transactions. Laravel Payfast is strictly use at own risk.

## important notice
this is a focked version of ``billowapp/payfast`` package, this package is not update for long with so i have create a fork and give support to laravel 9 and publish it in packagist so that i can use it in my private packages.
all credit to main author "Warren Hansen".

## Installation

Add Laravel Payfast to your composer.json

```bash
composer require billowapp/payfast
composer require sharifur/payfast
```

Add the PayfastServiceProvider to your providers array in config/app.php

```php
'providers' => [
//

'Billow\PayfastServiceProvider'
];
```
### Config
publish default configuration file.

Expand All @@ -27,7 +21,6 @@ publish default configuration file.
IMPORTANT: You will need to edit App\Http\Middleware\VerifyCsrfToken by adding the route, which handles the ITN response to the $excepted array. Validation is done via the ITN response.



```php

/*
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "billowapp/payfast",
"name": "sharifur/payfast",
"authors": [
{
"name": "Warren Hansen",
"email": "warren@billow.co.za"
"name": "Sharifur Rahman",
"email": "dvrobin4@gmail.com"
}
],
"description": "Laravel 5.4+|6+|7+|8+ package for processing ITN payments through payfast.co.za",
"description": "Laravel 10+ package for processing ITN payments through payfast.co.za",
"keywords": ["package", "laravel", "payfast"],
"license": "MIT",
"require": {
"illuminate/support": "^5.4|^6.0|^7.0|^8.0",
"illuminate/http": "^5.4|^6.0|^7.0|^8.0",
"illuminate/support": "^10.0|^11.0|^12.0",
"illuminate/http": "^10.0|^11.0|^12.0",
"billowapp/show-me-the-money": "^0.1.2|^0.2|^0.4"
},
"autoload": {
Expand All @@ -20,7 +20,7 @@
}
},
"require-dev": {
"symfony/var-dumper": "^3.0"
"symfony/var-dumper": "^5.4|^6.0|^7.0"
},
"extra": {
"laravel": {
Expand Down
68 changes: 68 additions & 0 deletions src/Money.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace Billow;

use Illuminate\Support\Facades\Config;
use NumberFormatter;

class Money
{
protected $amount;
protected $sub_unit = 100;
protected $default_fraction_digits = 2;
protected $currency_format = NumberFormatter::CURRENCY;

public function __construct($amount = 0)
{
$this->amount = $amount;
}

/*
* Create new Money Object from a string value
* @param $amount
* return static
*/
public function fromString($amount = 0)
{
return new static(intval(
round($this->sub_unit * round((float) $amount, $this->default_fraction_digits, PHP_ROUND_HALF_UP), 0, PHP_ROUND_HALF_UP)
));
}

public function amount()
{
return intval($this->amount);
}

public function convertedAmount($amount = null)
{
if ($amount) $this->amount = $amount;

return round($this->amount / $this->sub_unit, $this->default_fraction_digits);
}

public function asCurrency($amount = null, $currencySymbol = 'ZAR')
{
if ($amount) $this->amount = $amount;
return $this->getFormatter()->formatCurrency($amount, $currencySymbol);
}

public function newMoney(int $amount)
{
return new static($amount);
}

public function setCurrencyFormat($format): Money
{
$this->currency_format = $format;
return $this;
}

public function getFormatter(): NumberFormatter
{
return (new NumberFormatter(
Config::get('app.locale'),
$this->currency_format
));
}
}
2 changes: 1 addition & 1 deletion src/Payfast.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Billow;

use Billow\Contracts\PaymentProcessor;
use Billow\Utilities\Money;
use Billow\Money;
use Illuminate\Http\Request;

class Payfast implements PaymentProcessor
Expand Down