File manager - Edit - /home/opticamezl/www/newok/gocardless.tar
Back
phpunit.xml.dist 0000604 00000001512 15173205526 0007720 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> CONTRIBUTING.md 0000604 00000001040 15173205526 0006772 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. composer.json 0000604 00000001715 15173205526 0007274 0 ustar 00 { "name": "omnipay/gocardless", "type": "library", "description": "GoCardless driver for the Omnipay payment processing library", "keywords": [ "gateway", "go cardless", "gocardless", "merchant", "omnipay", "pay", "payment" ], "homepage": "https://github.com/thephpleague/omnipay-gocardless", "license": "MIT", "authors": [ { "name": "Adrian Macneil", "email": "adrian@adrianmacneil.com" }, { "name": "Omnipay Contributors", "homepage": "https://github.com/thephpleague/omnipay-gocardless/contributors" } ], "autoload": { "psr-4": { "Omnipay\\GoCardless\\" : "src/" } }, "require": { "omnipay/common": "~2.0" }, "require-dev": { "omnipay/tests": "~2.0" }, "extra": { "branch-alias": { "dev-master": "2.0.x-dev" } } } src/Gateway.php 0000604 00000006501 15173205526 0007451 0 ustar 00 <?php namespace Omnipay\GoCardless; use Omnipay\Common\AbstractGateway; use Omnipay\GoCardless\Message\PurchaseRequest; use Omnipay\GoCardless\Message\CompletePurchaseRequest; /** * GoCardless Gateway * * @link https://sandbox.gocardless.com/docs */ class Gateway extends AbstractGateway { public function getName() { return 'GoCardless'; } public function getDefaultParameters() { return array( 'appId' => '', 'appSecret' => '', 'merchantId' => '', 'accessToken' => '', 'testMode' => false, ); } public function getAppId() { return $this->getParameter('appId'); } public function setAppId($value) { return $this->setParameter('appId', $value); } public function getAppSecret() { return $this->getParameter('appSecret'); } public function setAppSecret($value) { return $this->setParameter('appSecret', $value); } public function getMerchantId() { return $this->getParameter('merchantId'); } public function setMerchantId($value) { return $this->setParameter('merchantId', $value); } public function getAccessToken() { return $this->getParameter('accessToken'); } public function setAccessToken($value) { return $this->setParameter('accessToken', $value); } public function purchase(array $parameters = array()) { return $this->createRequest('\Omnipay\GoCardless\Message\PurchaseRequest', $parameters); } public function completePurchase(array $parameters = array()) { return $this->createRequest('\Omnipay\GoCardless\Message\CompletePurchaseRequest', $parameters); } public function authorize(array $parameters = array()) { return $this->createRequest('\Omnipay\GoCardless\Message\AuthorizeRequest', $parameters); } public function completeAuthorize(array $parameters = array()) { return $this->createRequest('\Omnipay\GoCardless\Message\CompleteAuthorizeRequest', $parameters); } public function capture(array $parameters = array()) { return $this->createRequest('\Omnipay\GoCardless\Message\CaptureRequest', $parameters); } /** * Generate a query string for the data array (this is some kind of sick joke) * * @link https://github.com/gocardless/gocardless-php/blob/v0.3.3/lib/GoCardless/Utils.php#L39 */ public static function generateQueryString($data, &$pairs = array(), $namespace = null) { if (is_array($data)) { foreach ($data as $k => $v) { if (is_int($k)) { static::generateQueryString($v, $pairs, $namespace.'[]'); } else { static::generateQueryString($v, $pairs, $namespace !== null ? $namespace."[$k]" : $k); } } if ($namespace !== null) { return $pairs; } if (empty($pairs)) { return ''; } sort($pairs); $strs = array_map('implode', array_fill(0, count($pairs), '='), $pairs); return implode('&', $strs); } else { $pairs[] = array(rawurlencode($namespace), rawurlencode($data)); } } } src/Message/CompletePurchaseRequest.php 0000604 00000003262 15173205526 0014251 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Exception\InvalidResponseException; use Omnipay\GoCardless\Gateway; /** * GoCardless Complete Purchase Request */ class CompletePurchaseRequest extends AbstractRequest { public function getData() { $data = array(); $data['resource_uri'] = $this->httpRequest->get('resource_uri'); $data['resource_id'] = $this->httpRequest->get('resource_id'); $data['resource_type'] = $this->httpRequest->get('resource_type'); if ($this->httpRequest->get('state')) { $data['state'] = $this->httpRequest->get('state'); } if ($this->generateSignature($data) !== $this->httpRequest->get('signature')) { throw new InvalidResponseException; } unset($data['resource_uri']); return $data; } public function sendData($data) { // don't throw exceptions for 4xx errors $this->httpClient->getEventDispatcher()->addListener( 'request.error', function ($event) { if ($event['response']->isClientError()) { $event->stopPropagation(); } } ); $httpRequest = $this->httpClient->post( $this->getEndpoint().'/api/v1/confirm', array('Accept' => 'application/json'), Gateway::generateQueryString($data) ); $httpResponse = $httpRequest->setAuth($this->getAppId(), $this->getAppSecret())->send(); return $this->response = new CompletePurchaseResponse( $this, $httpResponse->json(), $this->httpRequest->get('resource_id') ); } } src/Message/AuthorizeResponse.php 0000604 00000001363 15173205526 0013126 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RedirectResponseInterface; use Omnipay\GoCardless\Gateway; class AuthorizeResponse extends AbstractResponse implements RedirectResponseInterface { public function isSuccessful() { return false; } public function isRedirect() { return true; } public function getRedirectUrl() { return $this->getRequest()->getEndpoint(). '/connect/pre_authorizations/new?'. Gateway::generateQueryString($this->data); } public function getRedirectMethod() { return 'GET'; } public function getRedirectData() { return null; } } src/Message/AbstractRequest.php 0000604 00000006755 15173205526 0012563 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; use Omnipay\GoCardless\Gateway; /** * GoCardless Abstract Request */ abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest { protected $liveEndpoint = 'https://gocardless.com'; protected $testEndpoint = 'https://sandbox.gocardless.com'; public function getAppId() { return $this->getParameter('appId'); } public function setAppId($value) { return $this->setParameter('appId', $value); } public function getAppSecret() { return $this->getParameter('appSecret'); } public function setAppSecret($value) { return $this->setParameter('appSecret', $value); } public function getMerchantId() { return $this->getParameter('merchantId'); } public function setMerchantId($value) { return $this->setParameter('merchantId', $value); } public function getAccessToken() { return $this->getParameter('accessToken'); } public function setAccessToken($value) { return $this->setParameter('accessToken', $value); } public function getChargeCustomerAt() { return $this->getParameter('chargeCustomerAt'); } public function setChargeCustomerAt($value) { return $this->setParameter('chargeCustomerAt', $value); } public function getState() { return $this->getParameter('state'); } public function setState($value) { return $this->setParameter('state', $value); } public function getIntervalLength() { return $this->getParameter('intervalLength'); } public function setIntervalLength($value) { return $this->setParameter('intervalLength', $value); } public function getIntervalUnit() { return $this->getParameter('intervalUnit'); } public function setIntervalUnit($value) { return $this->setParameter('intervalUnit', $value); } public function getCalendarInterval() { return $this->getParameter('calendarInterval'); } public function setCalendarInterval($value) { return $this->setParameter('calendarInterval', $value); } public function getSetupFee() { return $this->getParameter('setupFee'); } public function setSetupFee($value) { return $this->setParameter('setupFee', $value); } public function getPreAuthExpire() { return $this->getParameter('preAuthExpire'); } public function setPreAuthExpire($value) { return $this->setParameter('preAuthExpire', $value); } public function getIntervalCount() { return $this->getParameter('intervalCount'); } public function setIntervalCount($value) { return $this->setParameter('intervalCount', $value); } /** * Generate a signature for the data array */ public function generateSignature($data) { return hash_hmac('sha256', Gateway::generateQueryString($data), $this->getAppSecret()); } public function getEndpoint() { return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; } /** * Generate a nonce for each request */ protected function generateNonce() { $nonce = ''; for ($i = 0; $i < 64; $i++) { // append random ASCII character $nonce .= chr(mt_rand(33, 126)); } return base64_encode($nonce); } } src/Message/CompletePurchaseResponse.php 0000604 00000001476 15173205526 0014424 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; /** * GoCardless Complete Purchase Response */ class CompletePurchaseResponse extends AbstractResponse { protected $transactionReference; public function __construct(RequestInterface $request, $data, $transactionReference) { parent::__construct($request, $data); $this->transactionReference = $transactionReference; } public function isSuccessful() { return !isset($this->data['error']); } public function getTransactionReference() { return $this->transactionReference; } public function getMessage() { if (!$this->isSuccessful()) { return reset($this->data['error']); } } } src/Message/CompleteAuthorizeRequest.php 0000604 00000003166 15173205526 0014454 0 ustar 00 <?php /** * GoCardless Complete Authorize Request */ namespace Omnipay\GoCardless\Message; use Omnipay\Common\Exception\InvalidResponseException; use Omnipay\GoCardless\Gateway; /** * This completes and confirms that the auth is going to be used. It has a 3 hour * life from the moment we create the pre-auth request. * * * @package Omnipay\GoCardless\Message * @link https://developer.gocardless.com/#confirm-a-new-pre-auth */ class CompleteAuthorizeRequest extends AbstractRequest { public function getData() { $data = array(); $data['resource_uri'] = $this->httpRequest->get('resource_uri'); $data['resource_id'] = $this->httpRequest->get('resource_id'); $data['resource_type'] = $this->httpRequest->get('resource_type'); if ($this->httpRequest->get('state')) { $data['state'] = $this->httpRequest->get('state'); } if ($this->generateSignature($data) !== $this->httpRequest->get('signature')) { throw new InvalidResponseException; } unset($data['resource_uri']); return $data; } public function sendData($data) { $httpRequest = $this->httpClient->post( $this->getEndpoint().'/api/v1/confirm', array('Accept' => 'application/json'), Gateway::generateQueryString($data) ); $httpResponse = $httpRequest->setAuth($this->getAppId(), $this->getAppSecret())->send(); return $this->response = new CompleteAuthorizeResponse( $this, $httpResponse->json(), $this->httpRequest->get('resource_id') ); } } src/Message/PurchaseResponse.php 0000604 00000001363 15173205526 0012726 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RedirectResponseInterface; use Omnipay\GoCardless\Gateway; /** * GoCardless Purchase Response */ class PurchaseResponse extends AbstractResponse implements RedirectResponseInterface { public function isSuccessful() { return false; } public function isRedirect() { return true; } public function getRedirectUrl() { return $this->getRequest()->getEndpoint().'/connect/bills/new?'.Gateway::generateQueryString($this->data); } public function getRedirectMethod() { return 'GET'; } public function getRedirectData() { return null; } } src/Message/CaptureRequest.php 0000604 00000002714 15173205526 0012412 0 ustar 00 <?php /** * GoCardless Capture Request */ namespace Omnipay\GoCardless\Message; use Omnipay\GoCardless\Gateway; /** * GoCardless Capture Request - this captures an existing pre-authorization. * * All you need for this method is the pre_authorization_id that we expect to be the transactionReference. * This is a very similar call to just creating a standard bill - but doesnt require a hand off to the * payment provider. * * @see AuthorizeRequest * @link https://developer.gocardless.com/#create-a-bill-under-a-pre-auth */ class CaptureRequest extends AbstractRequest { public function getData() { $this->validate('amount', 'transactionReference'); $data = array(); $bill = array(); $bill['amount'] = $this->getAmount(); $bill['pre_authorization_id'] = $this->getTransactionReference(); $bill['name'] = $this->getDescription(); $bill['charge_customer_at'] = $this->getChargeCustomerAt(); $data['bill'] = $bill; return $data; } public function sendData($data) { $httpRequest = $this->httpClient->post( $this->getEndpoint().'/api/v1/bills', array('Accept' => 'application/json'), Gateway::generateQueryString($data) ); $httpResponse = $httpRequest->setHeader('Authorization', 'bearer '.$this->getAccessToken())->send(); return $this->response = new CaptureResponse($this, $httpResponse->json()); } } src/Message/AuthorizeRequest.php 0000604 00000006511 15173205526 0012760 0 ustar 00 <?php /** * GoCardless Authorize Request */ namespace Omnipay\GoCardless\Message; /** * GoCardless Authorize Request * * Use this method to create a pre- authorization for a charge. Because we are dealing with direct debits we can do * a few things that other providers don't or can't do. It also means we some extra parameters. * * Required parameters: * - amount - we're using this as the max_amount for the authorization, * you have the ability to capture less then this later * - intervalLength - the number of intervalUnits that make up an interval (1 month) would be monthly charge * - intervalUnit - string of `day` `week` or `month` * * Optional Parameters: * see documentation. * * * @see \Omnipay\GoCardless\Gateway * @link https://developer.gocardless.com/#create-a-pre-auth */ class AuthorizeRequest extends AbstractRequest { public function getData() { $this->validate('amount', 'intervalLength', 'intervalUnit'); $data = array(); //Required Items from the API $data['client_id'] = $this->getAppId(); $data['nonce'] = $this->generateNonce(); $data['timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); $data['pre_authorization']['max_amount'] = $this->getAmount(); $data['pre_authorization']['interval_length'] = $this->getIntervalLength(); $data['pre_authorization']['interval_unit'] = $this->getIntervalUnit(); $data['pre_authorization']['merchant_id'] = $this->getMerchantId(); $data['redirect_uri'] = $this->getReturnUrl(); //Nice to haves. if ($this->getCancelUrl()) { $data['cancel_uri'] = $this->getCancelUrl(); } if ($this->getState()) { $data['state'] = $this->getState(); } if ($this->getDescription()) { $data['name'] = $this->getDescription(); } if ($this->getCalendarInterval()) { $data['pre_authorization']['calendar_intervals'] = $this->getCalendarInterval(); } if ($this->getSetupFee()) { $data['pre_authorization']['setup_fee'] = $this->getSetupFee(); } if ($this->getIntervalCount()) { $data['pre_authorization']['interval_count'] = $this->getIntervalCount(); } if ($this->getPreAuthExpire()) { $data['pre_authorization']['expires_at'] = $this->getPreAuthExpire(); } if ($this->getCard()) { $data['bill']['user'] = array(); $data['bill']['user']['first_name'] = $this->getCard()->getFirstName(); $data['bill']['user']['last_name'] = $this->getCard()->getLastName(); $data['bill']['user']['email'] = $this->getCard()->getEmail(); $data['bill']['user']['billing_address1'] = $this->getCard()->getAddress1(); $data['bill']['user']['billing_address2'] = $this->getCard()->getAddress2(); $data['bill']['user']['billing_town'] = $this->getCard()->getCity(); $data['bill']['user']['billing_county'] = $this->getCard()->getCountry(); $data['bill']['user']['billing_postcode'] = $this->getCard()->getPostcode(); } $data['signature'] = $this->generateSignature($data); return $data; } public function sendData($data) { return $this->response = new AuthorizeResponse($this, $data); } } src/Message/PurchaseRequest.php 0000604 00000003264 15173205526 0012562 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; /** * GoCardless Purchase Request */ class PurchaseRequest extends AbstractRequest { public function getData() { $this->validate('amount'); $data = array(); $data['client_id'] = $this->getAppId(); $data['nonce'] = $this->generateNonce(); $data['timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); $data['redirect_uri'] = $this->getReturnUrl(); $data['cancel_uri'] = $this->getCancelUrl(); $data['state'] = $this->getState(); $data['bill'] = array(); $data['bill']['merchant_id'] = $this->getMerchantId(); $data['bill']['amount'] = $this->getAmount(); $data['bill']['name'] = $this->getDescription(); if ($this->getCard()) { $data['bill']['user'] = array(); $data['bill']['user']['first_name'] = $this->getCard()->getFirstName(); $data['bill']['user']['last_name'] = $this->getCard()->getLastName(); $data['bill']['user']['email'] = $this->getCard()->getEmail(); $data['bill']['user']['billing_address1'] = $this->getCard()->getAddress1(); $data['bill']['user']['billing_address2'] = $this->getCard()->getAddress2(); $data['bill']['user']['billing_town'] = $this->getCard()->getCity(); $data['bill']['user']['billing_county'] = $this->getCard()->getCountry(); $data['bill']['user']['billing_postcode'] = $this->getCard()->getPostcode(); } $data['signature'] = $this->generateSignature($data); return $data; } public function sendData($data) { return $this->response = new PurchaseResponse($this, $data); } } src/Message/CaptureResponse.php 0000604 00000000675 15173205526 0012564 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; class CaptureResponse extends AbstractResponse { public function isSuccessful() { return !isset($this->data['error']); } public function getMessage() { if (!$this->isSuccessful()) { return reset($this->data['error']); } return null; } } src/Message/CompleteAuthorizeResponse.php 0000604 00000001443 15173205526 0014616 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; use Omnipay\Common\Message\AbstractResponse; use Omnipay\Common\Message\RequestInterface; class CompleteAuthorizeResponse extends AbstractResponse { protected $transactionReference; public function __construct(RequestInterface $request, $data, $transactionReference) { parent::__construct($request, $data); $this->transactionReference = $transactionReference; } public function isSuccessful() { return !isset($this->data['error']); } public function getTransactionReference() { return $this->transactionReference; } public function getMessage() { if (!$this->isSuccessful()) { return reset($this->data['error']); } return null; } } README.md 0000604 00000003563 15173205526 0006034 0 ustar 00 # Omnipay: GoCardless **GoCardless driver for the Omnipay PHP payment processing library** [](https://travis-ci.org/thephpleague/omnipay-gocardless) [](https://packagist.org/packages/omnipay/gocardless) [](https://packagist.org/packages/omnipay/gocardless) [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements GoCardless 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/gocardless": "~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: * GoCardless 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-gocardless/issues), or better yet, fork the library and submit a pull request. .gitignore 0000604 00000000060 15173205526 0006532 0 ustar 00 /vendor composer.lock composer.phar phpunit.xml tests/Message/CompletePurchaseResponseTest.php 0000604 00000002017 15173205526 0015627 0 ustar 00 <?php namespace Omnipay\GoCardless\Message; use Omnipay\Tests\TestCase; class CompletePurchaseResponseTest extends TestCase { public function testCompletePurchaseSuccess() { $httpResponse = $this->getMockHttpResponse('CompletePurchaseSuccess.txt'); $response = new CompletePurchaseResponse($this->getMockRequest(), $httpResponse->json(), 'abc123'); $this->assertTrue($response->isSuccessful()); $this->assertSame('abc123', $response->getTransactionReference()); $this->assertNull($response->getMessage()); } public function testCompletePurchaseFailure() { $httpResponse = $this->getMockHttpResponse('CompletePurchaseFailure.txt'); $response = new CompletePurchaseResponse($this->getMockRequest(), $httpResponse->json(), 'abc123'); $this->assertFalse($response->isSuccessful()); $this->assertSame('abc123', $response->getTransactionReference()); $this->assertSame('The resource cannot be confirmed', $response->getMessage()); } } tests/Mock/CapturePaymentFailure.txt 0000604 00000000100 15173205526 0013602 0 ustar 00 HTTP/1.1 200 OK {"error":["The authorization cannot be found"]} tests/Mock/CompletePurchaseSuccess.txt 0000604 00000000042 15173205526 0014132 0 ustar 00 HTTP/1.1 200 OK {"success":true} tests/Mock/CompletePurchaseFailure.txt 0000604 00000000100 15173205526 0014104 0 ustar 00 HTTP/1.1 200 OK {"error":["The resource cannot be confirmed"]} tests/Mock/CapturePaymentSuccess.txt 0000604 00000000042 15173205526 0013630 0 ustar 00 HTTP/1.1 200 OK {"success":true} tests/GatewayTest.php 0000604 00000012655 15173205526 0010673 0 ustar 00 <?php namespace Omnipay\GoCardless; use Omnipay\Tests\GatewayTestCase; class GatewayTest extends GatewayTestCase { public function setUp() { parent::setUp(); $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); $this->gateway->setAppId('abc'); $this->gateway->setAppSecret('123'); $this->options = array( 'amount' => '10.00', 'returnUrl' => 'https://www.example.com/return', ); } public function testPurchase() { $response = $this->gateway->purchase($this->options)->send(); $this->assertInstanceOf('\Omnipay\GoCardless\Message\PurchaseResponse', $response); $this->assertTrue($response->isRedirect()); $this->assertStringStartsWith('https://gocardless.com/connect/bills/new?', $response->getRedirectUrl()); } public function testCompletePurchaseSuccess() { $this->getHttpRequest()->request->replace( array( 'resource_uri' => 'a', 'resource_id' => 'b', 'resource_type' => 'c', 'state' => 'd', 'signature' => 'cdc9e0cdb88114976dd18f597cb0a8f46cb26be6c8c17094b6394e76a7fc5732', ) ); $this->setMockHttpResponse('CompletePurchaseSuccess.txt'); $response = $this->gateway->completePurchase($this->options)->send(); $this->assertTrue($response->isSuccessful()); $this->assertEquals('b', $response->getTransactionReference()); } public function testCompletePurchaseError() { $this->getHttpRequest()->request->replace( array( 'resource_uri' => 'a', 'resource_id' => 'b', 'resource_type' => 'c', 'signature' => '416f52e7d287dab49fa8445c1cd0957ca8ddf1c04a6300e00117dc0bedabc7d7', ) ); $this->setMockHttpResponse('CompletePurchaseFailure.txt'); $response = $this->gateway->completePurchase($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertSame('The resource cannot be confirmed', $response->getMessage()); } /** * @expectedException Omnipay\Common\Exception\InvalidResponseException */ public function testCompletePurchaseInvalid() { $this->getHttpRequest()->request->replace( array( 'resource_uri' => 'a', 'resource_id' => 'b', 'resource_type' => 'c', 'signature' => 'd', ) ); $response = $this->gateway->completePurchase($this->options)->send(); } public function testAuthorization() { $params = array( 'amount' => '10.00', 'intervalLength' => 12, 'intervalUnit' => 'week', 'returnUrl' => 'foo.bar/baz' ); $response = $this->gateway->authorize($params)->send(); $this->assertInstanceOf('Omnipay\GoCardless\Message\AuthorizeResponse', $response); $this->assertStringStartsWith('https://gocardless.com/connect/pre_authorizations/new?', $response->getRedirectUrl()); //NB: These are here for a potential refactor. $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertSame('GET', $response->getRedirectMethod()); $this->assertNull($response->getRedirectData()); } public function testCompleteAuthorizeSuccess() { $this->getHttpRequest()->request->replace( array( 'resource_uri' => 'a', 'resource_id' => 'b', 'resource_type' => 'c', 'state' => 'd', 'signature' => 'cdc9e0cdb88114976dd18f597cb0a8f46cb26be6c8c17094b6394e76a7fc5732', ) ); $this->setMockHttpResponse('CompletePurchaseSuccess.txt'); $response = $this->gateway->completeAuthorize($this->options)->send(); $this->assertTrue($response->isSuccessful()); $this->assertEquals('b', $response->getTransactionReference()); } public function testCapture() { $response = $this->gateway->capture(array('amount' => '10.00')); $this->assertInstanceOf('Omnipay\GoCardless\Message\CaptureRequest', $response); } public function testCaptureSuccess() { $params = array( 'amount' => '10.00', 'transactionReference' => 'abc', 'description' => 'fyi' ); $transaction = $this->gateway->capture($params); $transaction->setChargeCustomerAt('2015-12-12'); $this->setMockHttpResponse('CapturePaymentSuccess.txt'); $response = $transaction->send(); $this->assertInstanceOf('Omnipay\GoCardless\Message\CaptureResponse', $response); $this->assertTrue($response->isSuccessful()); $this->assertNull($response->getMessage()); } public function testCaptureFailure() { $params = array( 'amount' => '10.00', 'transactionReference' => '12v' ); $this->setMockHttpResponse('CapturePaymentFailure.txt'); $response = $this->gateway->capture($params)->send(); $this->assertInstanceOf('Omnipay\GoCardless\Message\CaptureResponse', $response); $this->assertFalse($response->isSuccessful()); $this->assertSame('The authorization cannot be found', $response->getMessage()); } } LICENSE 0000604 00000002047 15173205526 0005556 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. .travis.yml 0000604 00000000317 15173205526 0006660 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
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings