diff --git a/.gitignore b/.gitignore index 6539eb3..ad2d8cf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ composer.lock .DS_Store .idea -index.php \ No newline at end of file +index.php +vendor \ No newline at end of file diff --git a/README.md b/README.md index 1ebbd8f..887a59b 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 /* diff --git a/composer.json b/composer.json index eb58fa6..e6d2619 100644 --- a/composer.json +++ b/composer.json @@ -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": { @@ -20,7 +20,7 @@ } }, "require-dev": { - "symfony/var-dumper": "^3.0" + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "extra": { "laravel": { diff --git a/src/Money.php b/src/Money.php new file mode 100644 index 0000000..067bcd6 --- /dev/null +++ b/src/Money.php @@ -0,0 +1,68 @@ +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 + )); + } +} \ No newline at end of file diff --git a/src/Payfast.php b/src/Payfast.php index 53a05c6..e78e19f 100644 --- a/src/Payfast.php +++ b/src/Payfast.php @@ -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