File manager - Edit - /home/opticamezl/www/newok/payfast.tar
Back
tests/GatewayTest.php 0000604 00000001476 15174464053 0010675 0 ustar 00 <?php namespace Omnipay\PayFast; use Omnipay\Tests\GatewayTestCase; class GatewayTest extends GatewayTestCase { public function setUp() { parent::setUp(); $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); } public function testPurchase() { $request = $this->gateway->purchase(array('amount' => '12.00')); $this->assertInstanceOf('\Omnipay\PayFast\Message\PurchaseRequest', $request); $this->assertSame('12.00', $request->getAmount()); } public function testCompletePurchase() { $request = $this->gateway->completePurchase(array('amount' => '12.00')); $this->assertInstanceOf('\Omnipay\PayFast\Message\CompletePurchaseRequest', $request); $this->assertSame('12.00', $request->getAmount()); } } tests/Message/PurchaseResponseTest.php 0000604 00000001437 15174464053 0014146 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Tests\TestCase; class PurchaseResponseTest extends TestCase { public function testConstruct() { $data = array('test' => '123'); $response = new PurchaseResponse($this->getMockRequest(), $data, 'https://example.com/'); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertSame($data, $response->getData()); $this->assertSame('https://example.com/', $response->getRedirectUrl()); $this->assertSame('POST', $response->getRedirectMethod()); $this->assertSame($data, $response->getRedirectData()); } } tests/Message/CompletePurchaseRequestTest.php 0000604 00000005752 15174464053 0015475 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Tests\TestCase; class CompletePurchaseRequestTest extends TestCase { public function setUp() { $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); } public function getItnPostData() { return array( 'm_payment_id' => '', 'pf_payment_id' => '61493', 'payment_status' => 'COMPLETE', 'item_name' => 'fjdksl', 'item_description' => '', 'amount_gross' => '12.00', 'amount_fee' => '-0.27', 'amount_net' => '11.73', 'custom_str1' => '', 'custom_str2' => '', 'custom_str3' => '', 'custom_str4' => '', 'custom_str5' => '', 'custom_int1' => '', 'custom_int2' => '', 'custom_int3' => '', 'custom_int4' => '', 'custom_int5' => '', 'name_first' => 'Test', 'name_last' => 'User 01', 'email_address' => 'sbtu01@payfast.co.za', 'merchant_id' => '10000103', 'signature' => '92ac916145511e9050383b008729e162', ); } public function testCompletePurchaseItnSuccess() { $this->getHttpRequest()->request->replace($this->getItnPostData()); $this->setMockHttpResponse('CompletePurchaseItnSuccess.txt'); $response = $this->request->send(); $this->assertInstanceOf('Omnipay\PayFast\Message\CompletePurchaseItnResponse', $response); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('61493', $response->getTransactionReference()); $this->assertSame('COMPLETE', $response->getMessage()); $this->assertNull($response->getCode()); } public function testCompletePurchaseItnInvalid() { $this->getHttpRequest()->request->replace($this->getItnPostData()); $this->setMockHttpResponse('CompletePurchaseItnFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('INVALID', $response->getMessage()); $this->assertNull($response->getCode()); } public function testCompletePurchasePdtSuccess() { $this->getHttpRequest()->query->replace(array('pt' => 'abc')); $this->setMockHttpResponse('CompletePurchasePdtFailure.txt'); $response = $this->request->send(); $this->assertInstanceOf('Omnipay\PayFast\Message\CompletePurchasePdtResponse', $response); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('FAIL', $response->getMessage()); $this->assertNull($response->getCode()); } } tests/Message/PurchaseRequestTest.php 0000604 00000003112 15174464053 0013770 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Tests\TestCase; class PurchaseRequestTest extends TestCase { public function setUp() { $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); } public function testSignature() { $this->request->initialize( array( 'amount' => '12.00', 'description' => 'Test Product', 'transactionId' => 123, 'merchantId' => 'foo', 'merchantKey' => 'bar', 'returnUrl' => 'https://www.example.com/return', 'cancelUrl' => 'https://www.example.com/cancel', ) ); $data = $this->request->getData(); $this->assertSame('ab86df60906e97d3bfb362aff26fd9e6', $data['signature']); } public function testPurchase() { $this->request->setAmount('12.00')->setDescription('Test Product'); $response = $this->request->send(); $this->assertInstanceOf('Omnipay\PayFast\Message\PurchaseResponse', $response); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertNull($response->getCode()); $this->assertSame('https://www.payfast.co.za/eng/process', $response->getRedirectUrl()); $this->assertSame('POST', $response->getRedirectMethod()); $this->assertArrayHasKey('signature', $response->getData()); } } tests/Mock/CompletePurchasePdtSuccess.txt 0000604 00000001276 15174464053 0014617 0 ustar 00 HTTP/1.1 200 OK Date: Thu, 07 Mar 2013 04:50:36 GMT Server: Apache/2.2.3 (CentOS) Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Length: 397 Connection: close Content-Type: text/html; charset=UTF-8 SUCCESS m_payment_id= pf_payment_id=61484 payment_status=COMPLETE item_name=fjdksl item_description= amount_gross=12.00 amount_fee=-0.27 amount_net=11.73 custom_str1= custom_str2= custom_str3= custom_str4= custom_str5= custom_int1= custom_int2= custom_int3= custom_int4= custom_int5= name_first=Test name_last=User+01 email_address=sbtu01%40payfast.co.za merchant_id=10000103 tests/Mock/CompletePurchaseItnSuccess.txt 0000604 00000000512 15174464053 0014612 0 ustar 00 HTTP/1.1 200 OK Date: Thu, 07 Mar 2013 05:30:11 GMT Server: Apache/2.2.3 (CentOS) Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Length: 5 Connection: close Content-Type: text/html; charset=UTF-8 VALID tests/Mock/CompletePurchaseItnFailure.txt 0000604 00000000746 15174464053 0014602 0 ustar 00 HTTP/1.1 200 OK Date: Thu, 07 Mar 2013 04:57:24 GMT Server: Apache/2.2.3 (CentOS) Set-Cookie: refer_session=Direct; path=/; domain=.payfast.co.za, refer_first=Direct; expires=Fri, 07-Mar-2014 04:57:24 GMT; path=/; domain=.payfast.co.za Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Length: 7 Connection: close Content-Type: text/html; charset=UTF-8 INVALID tests/Mock/CompletePurchasePdtFailure.txt 0000604 00000000511 15174464053 0014565 0 ustar 00 HTTP/1.1 200 OK Date: Thu, 07 Mar 2013 05:07:38 GMT Server: Apache/2.2.3 (CentOS) Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding,User-Agent Content-Length: 4 Connection: close Content-Type: text/html; charset=UTF-8 FAIL CONTRIBUTING.md 0000604 00000001040 15174464053 0006775 0 ustar 00 # Contributing Guidelines * Fork the project. * Make your feature addition or bug fix. * Add tests for it. This is important so I don't break it in a future version unintentionally. * Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files. * Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) style and that all tests pass. * Send the pull request. * Check that the Travis CI build passed. If not, rinse and repeat. README.md 0000604 00000003517 15174464053 0006036 0 ustar 00 # Omnipay: PayFast **PayFast driver for the Omnipay PHP payment processing library** [](https://travis-ci.org/thephpleague/omnipay-payfast) [](https://packagist.org/packages/omnipay/payfast) [](https://packagist.org/packages/omnipay/payfast) [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements PayFast support for Omnipay. ## Installation Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it to your `composer.json` file: ```json { "require": { "omnipay/payfast": "~2.0" } } ``` And run composer to update your dependencies: $ curl -s http://getcomposer.org/installer | php $ php composer.phar update ## Basic Usage The following gateways are provided by this package: * PayFast For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository. ## Support If you are having general issues with Omnipay, we suggest posting on [Stack Overflow](http://stackoverflow.com/). Be sure to add the [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found. If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which you can subscribe to. If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/thephpleague/omnipay-payfast/issues), or better yet, fork the library and submit a pull request. .gitignore 0000604 00000000060 15174464053 0006535 0 ustar 00 /vendor composer.lock composer.phar phpunit.xml phpunit.xml.dist 0000604 00000001512 15174464053 0007723 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false"> <testsuites> <testsuite name="Omnipay Test Suite"> <directory>./tests/</directory> </testsuite> </testsuites> <listeners> <listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" /> </listeners> <filter> <whitelist> <directory>./src</directory> </whitelist> </filter> </phpunit> .travis.yml 0000604 00000000317 15174464053 0006663 0 ustar 00 language: php php: - 5.3 - 5.4 - 5.5 - 5.6 - hhvm before_script: - composer install -n --dev --prefer-source script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text LICENSE 0000604 00000002047 15174464053 0005561 0 ustar 00 Copyright (c) 2012-2013 Adrian Macneil Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. composer.json 0000604 00000001644 15174464053 0007300 0 ustar 00 { "name": "omnipay/payfast", "type": "library", "description": "PayFast driver for the Omnipay payment processing library", "keywords": [ "gateway", "merchant", "omnipay", "pay", "payfast", "payment" ], "homepage": "https://github.com/thephpleague/omnipay-payfast", "license": "MIT", "authors": [ { "name": "Adrian Macneil", "email": "adrian@adrianmacneil.com" }, { "name": "Omnipay Contributors", "homepage": "https://github.com/thephpleague/omnipay-payfast/contributors" } ], "autoload": { "psr-4": { "Omnipay\\PayFast\\" : "src/" } }, "require": { "omnipay/common": "~2.0" }, "require-dev": { "omnipay/tests": "~2.0" }, "extra": { "branch-alias": { "dev-master": "2.0.x-dev" } } } src/Message/PurchaseResponse.php 0000604 00000001612 15174464053 0012726 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; use Omnipay\Common\Message\RedirectResponseInterface; /** * PayFast Purchase Response */ class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface { protected $redirectUrl; public function __construct(RequestInterface $request, $data, $redirectUrl) { parent::__construct($request, $data); $this->redirectUrl = $redirectUrl; } public function isSuccessful() { return false; } public function isRedirect() { return true; } public function getRedirectUrl() { return $this->redirectUrl; } public function getRedirectMethod() { return 'POST'; } public function getRedirectData() { return $this->getData(); } } src/Message/PurchaseRequest.php 0000604 00000005142 15174464053 0012562 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Common\Message\AbstractRequest; /** * PayFast Purchase Request */ class PurchaseRequest extends AbstractRequest { protected $liveEndpoint = 'https://www.payfast.co.za/eng'; protected $testEndpoint = 'https://sandbox.payfast.co.za/eng'; public function getMerchantId() { return $this->getParameter('merchantId'); } public function setMerchantId($value) { return $this->setParameter('merchantId', $value); } public function getMerchantKey() { return $this->getParameter('merchantKey'); } public function setMerchantKey($value) { return $this->setParameter('merchantKey', $value); } public function getPdtKey() { return $this->getParameter('pdtKey'); } public function setPdtKey($value) { return $this->setParameter('pdtKey', $value); } public function getData() { $this->validate('amount', 'description'); $data = array(); $data['merchant_id'] = $this->getMerchantId(); $data['merchant_key'] = $this->getMerchantKey(); $data['return_url'] = $this->getReturnUrl(); $data['cancel_url'] = $this->getCancelUrl(); $data['notify_url'] = $this->getReturnUrl(); if ($this->getCard()) { $data['name_first'] = $this->getCard()->getFirstName(); $data['name_last'] = $this->getCard()->getLastName(); $data['email_address'] = $this->getCard()->getEmail(); } $data['m_payment_id'] = $this->getTransactionId(); $data['amount'] = $this->getAmount(); $data['item_name'] = $this->getDescription(); $data['signature'] = $this->generateSignature($data); return $data; } protected function generateSignature($data) { $fields = array(); // specific order required by PayFast foreach (array('merchant_id', 'merchant_key', 'return_url', 'cancel_url', 'notify_url', 'name_first', 'name_last', 'email_address', 'm_payment_id', 'amount', 'item_name', 'item_description', 'email_confirmation', 'confirmation_address') as $key) { if (!empty($data[$key])) { $fields[$key] = $data[$key]; } } return md5(http_build_query($fields)); } public function sendData($data) { return $this->response = new PurchaseResponse($this, $data, $this->getEndpoint().'/process'); } public function getEndpoint() { return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; } } src/Message/CompletePurchaseItnResponse.php 0000604 00000001643 15174464053 0015076 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; /** * PayFast Complete Purchase ITN Response */ class CompletePurchaseItnResponse extends AbstractResponse { public function __construct(RequestInterface $request, $data, $status) { parent::__construct($request, $data); $this->status = $status; } public function isSuccessful() { return 'VALID' === $this->status; } public function getTransactionReference() { if ($this->isSuccessful() && isset($this->data['pf_payment_id'])) { return $this->data['pf_payment_id']; } } public function getMessage() { if ($this->isSuccessful() && isset($this->data['payment_status'])) { return $this->data['payment_status']; } else { return $this->status; } } } src/Message/CompletePurchaseRequest.php 0000604 00000003504 15174464053 0014253 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Common\Exception\InvalidRequestException; /** * PayFast Complete Purchase Request * * We use the same return URL & class to handle both PDT (Payment Data Transfer) * and ITN (Instant Transaction Notification). */ class CompletePurchaseRequest extends PurchaseRequest { public function getData() { if ($this->httpRequest->query->get('pt')) { // this is a Payment Data Transfer request $data = array(); $data['pt'] = $this->httpRequest->query->get('pt'); $data['at'] = $this->getPdtKey(); return $data; } elseif ($signature = $this->httpRequest->request->get('signature')) { // this is an Instant Transaction Notification request $data = $this->httpRequest->request->all(); // signature is completely useless since it has no shared secret // signature must not be posted back to the validate URL, so we unset it unset($data['signature']); return $data; } throw new InvalidRequestException('Missing PDT or ITN variables'); } public function sendData($data) { if (isset($data['pt'])) { // validate PDT $url = $this->getEndpoint().'/query/fetch'; $httpResponse = $this->httpClient->post($url, null, $data)->send(); return $this->response = new CompletePurchasePdtResponse($this, $httpResponse->getBody(true)); } else { // validate ITN $url = $this->getEndpoint().'/query/validate'; $httpResponse = $this->httpClient->post($url, null, $data)->send(); $status = $httpResponse->getBody(true); return $this->response = new CompletePurchaseItnResponse($this, $data, $status); } } } src/Message/CompletePurchasePdtResponse.php 0000604 00000001647 15174464053 0015077 0 ustar 00 <?php namespace Omnipay\PayFast\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; /** * PayFast Complete Purchase PDT Response */ class CompletePurchasePdtResponse extends AbstractResponse { protected $status; public function __construct(RequestInterface $request, $data) { $this->request = $request; $this->data = array(); // parse ridiculous response format $lines = explode('\n', $data); $this->status = $lines[0]; foreach ($lines as $line) { $parts = explode('=', $line, 2); $this->data[$parts[0]] = isset($parts[1]) ? urldecode($parts[1]) : null; } } public function isSuccessful() { return 'SUCCESS' === $this->status; } public function getMessage() { return $this->isSuccessful() ? $this->data['payment_status'] : $this->status; } } src/Gateway.php 0000604 00000003022 15174464053 0007447 0 ustar 00 <?php namespace Omnipay\PayFast; use Omnipay\Common\AbstractGateway; /** * PayFast Gateway * * Quote: The PayFast engine is basically a "black box" which processes a purchaser's payment. * * @link https://www.payfast.co.za/s/std/integration-guide */ class Gateway extends AbstractGateway { public function getName() { return 'PayFast'; } public function getDefaultParameters() { return array( 'merchantId' => '', 'merchantKey' => '', 'pdtKey' => '', 'testMode' => false, ); } public function getMerchantId() { return $this->getParameter('merchantId'); } public function setMerchantId($value) { return $this->setParameter('merchantId', $value); } public function getMerchantKey() { return $this->getParameter('merchantKey'); } public function setMerchantKey($value) { return $this->setParameter('merchantKey', $value); } public function getPdtKey() { return $this->getParameter('pdtKey'); } public function setPdtKey($value) { return $this->setParameter('pdtKey', $value); } public function purchase(array $parameters = array()) { return $this->createRequest('\Omnipay\PayFast\Message\PurchaseRequest', $parameters); } public function completePurchase(array $parameters = array()) { return $this->createRequest('\Omnipay\PayFast\Message\CompletePurchaseRequest', $parameters); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings