File manager - Edit - /home/opticamezl/www/newok/pin.tar
Back
runtests.sh 0000604 00000001015 15173220523 0006760 0 ustar 00 #!/bin/sh # # Command line runner for unit tests for composer projects # (c) Del 2015 http://www.babel.com.au/ # No Rights Reserved # # # Clean up after any previous test runs # mkdir -p documents rm -rf documents/coverage-html-new rm -f documents/coverage.xml # # Run phpunit # vendor/bin/phpunit --coverage-html documents/coverage-html-new --coverage-clover documents/coverage.xml if [ -d documents/coverage-html-new ]; then rm -rf documents/coverage-html mv documents/coverage-html-new documents/coverage-html fi .travis.yml 0000604 00000000317 15173220523 0006652 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 makedoc.sh 0000604 00000007562 15173220523 0006511 0 ustar 00 #!/bin/sh # # Smart little documentation generator. # GPL/LGPL # (c) Del 2015 http://www.babel.com.au/ # APPNAME='Omnipay Pin Gateway Module' CMDFILE=apigen.cmd.$$ DESTDIR=./documents # # Find apigen, either in the path or as a local phar file # if [ -f apigen.phar ]; then APIGEN="php apigen.phar" else APIGEN=`which apigen` if [ ! -f "$APIGEN" ]; then # Search for phpdoc if apigen is not found. if [ -f phpDocumentor.phar ]; then PHPDOC="php phpDocumentor.phar" else PHPDOC=`which phpdoc` if [ ! -f "$PHPDOC" ]; then echo "Neither apigen nor phpdoc is installed in the path or locally, please install one of them" echo "see http://www.apigen.org/ or http://www.phpdoc.org/" exit 1 fi fi fi fi # # As of version 4 of apigen need to use the generate subcommand # if [ ! -z "$APIGEN" ]; then APIGEN="$APIGEN generate" fi # # Without any arguments this builds the entire system documentation, # making the cache file first if required. # if [ -z "$1" ]; then # # Check to see that the cache has been made. # if [ ! -f dirlist.cache ]; then echo "Making dirlist.cache file" $0 makecache fi # # Build the apigen/phpdoc command in a file. # if [ ! -z "$APIGEN" ]; then echo "$APIGEN --php --tree --title '$APPNAME API Documentation' --destination $DESTDIR/main \\" > $CMDFILE cat dirlist.cache | while read dir; do echo "--source $dir \\" >> $CMDFILE done echo "" >> $CMDFILE elif [ ! -z "$PHPDOC" ]; then echo "$PHPDOC --sourcecode --title '$APPNAME API Documentation' --target $DESTDIR/main --directory \\" > $CMDFILE cat dirlist.cache | while read dir; do echo "${dir},\\" >> $CMDFILE done echo "" >> $CMDFILE else "Neither apigen nor phpdoc are found, how did I get here?" exit 1 fi # # Run the apigen command # rm -rf $DESTDIR/main mkdir -p $DESTDIR/main . ./$CMDFILE /bin/rm -f ./$CMDFILE # # The "makecache" argument causes the script to just make the cache file # elif [ "$1" = "makecache" ]; then echo "Find application source directories" find src -name \*.php -print | \ ( while read file; do grep -q 'class' $file && dirname $file done ) | sort -u | \ grep -v -E 'config|docs|migrations|phpunit|test|Test|views|web' > dirlist.app echo "Find vendor source directories" find vendor -name \*.php -print | \ ( while read file; do grep -q 'class' $file && dirname $file done ) | sort -u | \ grep -v -E 'config|docs|migrations|phpunit|codesniffer|test|Test|views' > dirlist.vendor # # Filter out any vendor directories for which apigen fails # echo "Filter source directories" mkdir -p $DESTDIR/tmp cat dirlist.app dirlist.vendor | while read dir; do if [ ! -z "$APIGEN" ]; then $APIGEN --quiet --title "Test please ignore" \ --source $dir \ --destination $DESTDIR/tmp && ( echo "Including $dir" echo $dir >> dirlist.cache ) || ( echo "Excluding $dir" ) elif [ ! -z "$PHPDOC" ]; then $PHPDOC --quiet --title "Test please ignore" \ --directory $dir \ --target $DESTDIR/tmp && ( echo "Including $dir" echo $dir >> dirlist.cache ) || ( echo "Excluding $dir" ) fi done echo "Documentation cache dirlist.cache built OK" # # Clean up # /bin/rm -rf $DESTDIR/tmp fi LICENSE 0000604 00000002047 15173220523 0005550 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. README.md 0000604 00000003510 15173220523 0006016 0 ustar 00 # Omnipay: Pin Payments **Pin Payments driver for the Omnipay PHP payment processing library** [](https://travis-ci.org/thephpleague/omnipay-pin) [](https://packagist.org/packages/omnipay/pin) [](https://packagist.org/packages/omnipay/pin) [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements [Pin](https://pin.net.au/) 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/pin": "~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: * Pin 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-pin/issues), or better yet, fork the library and submit a pull request. .gitignore 0000604 00000000167 15173220523 0006534 0 ustar 00 /vendor composer.lock composer.phar phpunit.xml .directory /documents/ .idea/ dirlist.app dirlist.cache dirlist.vendor composer.json 0000604 00000001625 15173220523 0007266 0 ustar 00 { "name": "omnipay/pin", "type": "library", "description": "Pin Payments driver for the Omnipay payment processing library", "keywords": [ "gateway", "merchant", "omnipay", "pay", "payment", "pin" ], "homepage": "https://github.com/thephpleague/omnipay-pin", "license": "MIT", "authors": [ { "name": "Adrian Macneil", "email": "adrian@adrianmacneil.com" }, { "name": "Omnipay Contributors", "homepage": "https://github.com/thephpleague/omnipay-pin/contributors" } ], "autoload": { "psr-4": { "Omnipay\\Pin\\" : "src/" } }, "require": { "omnipay/common": "~2.0" }, "require-dev": { "omnipay/tests": "~2.0" }, "extra": { "branch-alias": { "dev-master": "2.0.x-dev" } } } tests/Message/RefundRequestTest.php 0000604 00000002304 15173220523 0013432 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class RefundRequestTest extends TestCase { public function setUp() { $this->request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->setTransactionReference('ch_bZ3RhJnIUZ8HhfvH8CCvfA') ->setAmount('400.00'); } public function testSendSuccess() { $this->setMockHttpResponse('RefundSuccess.txt'); $response = $this->request->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('rf_ERCQy--Ay6o-NKGiUVcKKA', $response->getTransactionReference()); $this->assertSame('Pending', $response->getMessage()); } public function testSendError() { $this->setMockHttpResponse('RefundFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('Refund amount is more than your available Pin Payments balance.', $response->getMessage()); } } tests/Message/CaptureResponseTest.php 0000604 00000002065 15173220523 0013764 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class CaptureResponseTest extends TestCase { public function testCaptureSuccess() { $httpResponse = $this->getMockHttpResponse('CaptureSuccess.txt'); $response = new CaptureResponse($this->getMockRequest(), $httpResponse->json()); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ch_lfUYEBK14zotCTykezJkfg', $response->getTransactionReference()); $this->assertTrue($response->getCaptured()); } public function testCaptureFailure() { $httpResponse = $this->getMockHttpResponse('CaptureFailure.txt'); $response = new CaptureResponse($this->getMockRequest(), $httpResponse->json()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('The authorisation has expired and can not be captured.', $response->getMessage()); $this->assertNull($response->getCaptured()); } } tests/Message/CreateCardRequestTest.php 0000604 00000002636 15173220523 0014214 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class CreateCardRequestTest extends TestCase { public function setUp() { $this->request = new CreateCardRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'card' => $this->getValidCard(), ) ); } public function testDataWithCard() { $card = $this->getValidCard(); $this->request->setCard($card); $data = $this->request->getData(); $this->assertSame($card['number'], $data['number']); } public function testSendSuccess() { $this->setMockHttpResponse('CardSuccess.txt'); $response = $this->request->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('card_8LmnNMTYWG4zQZ4YnYQhBg', $response->getCardReference()); $this->assertTrue($response->getMessage()); } public function testSendError() { $this->setMockHttpResponse('CardFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCardReference()); $this->assertSame('One or more parameters were missing or invalid', $response->getMessage()); } } tests/Message/CreateCustomerRequestTest.php 0000604 00000003300 15173220523 0015131 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class CreateCustomerRequestTest extends TestCase { public function setUp() { $this->request = new CreateCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'email' => 'roland@pin.net.au', 'card' => $this->getValidCard(), ) ); } public function testDataWithCardReference() { $this->request->setToken('card_abc'); $data = $this->request->getData(); $this->assertSame('card_abc', $data['card_token']); } public function testDataWithCard() { $card = $this->getValidCard(); $this->request->setCard($card); $data = $this->request->getData(); $this->assertSame($card['number'], $data['card']['number']); } public function testSendSuccess() { $this->setMockHttpResponse('CustomerSuccess.txt'); $response = $this->request->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('cus_Mb-8S1ZgEbLUUUJ97dfhfQ', $response->getCustomerReference()); $this->assertTrue($response->getMessage()); } public function testSendError() { $this->setMockHttpResponse('CustomerFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCustomerReference()); $this->assertSame('One or more parameters were missing or invalid', $response->getMessage()); } } tests/Message/CaptureRequestTest.php 0000604 00000002340 15173220523 0013612 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class CaptureRequestTest extends TestCase { public function setUp() { $this->request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->setTransactionReference('ch_bZ3RhJnIUZ8HhfvH8CCvfA') ->setAmount('400.00'); } public function testSendSuccess() { $this->setMockHttpResponse('CaptureSuccess.txt'); $response = $this->request->send(); $data = $response->getData(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ch_lfUYEBK14zotCTykezJkfg', $response->getTransactionReference()); $this->assertTrue($data['response']['captured']); } public function testSendError() { $this->setMockHttpResponse('CaptureFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('The authorisation has expired and can not be captured.', $response->getMessage()); } } tests/Message/ResponseTest.php 0000604 00000005602 15173220523 0012440 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class ResponseTest extends TestCase { public function testPurchaseSuccess() { $httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt'); $response = new Response($this->getMockRequest(), $httpResponse->json()); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('ch_fXIxWf0gj1yFHJcV1W-d-w', $response->getTransactionReference()); $this->assertSame('Success!', $response->getMessage()); } public function testPurchaseFailure() { $httpResponse = $this->getMockHttpResponse('PurchaseFailure.txt'); $response = new Response($this->getMockRequest(), $httpResponse->json()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('The current resource was deemed invalid.', $response->getMessage()); } public function testCardSuccess() { $httpResponse = $this->getMockHttpResponse('CardSuccess.txt'); $response = new Response($this->getMockRequest(), $httpResponse->json()); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('card_8LmnNMTYWG4zQZ4YnYQhBg', $response->getCardReference()); $this->assertTrue($response->getMessage()); } public function testCardFailure() { $httpResponse = $this->getMockHttpResponse('CardFailure.txt'); $response = new Response($this->getMockRequest(), $httpResponse->json()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCardReference()); $this->assertSame('One or more parameters were missing or invalid', $response->getMessage()); } public function testCustomerSuccess() { $httpResponse = $this->getMockHttpResponse('CustomerSuccess.txt'); $response = new Response($this->getMockRequest(), $httpResponse->json()); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('cus_Mb-8S1ZgEbLUUUJ97dfhfQ', $response->getCustomerReference()); $this->assertTrue($response->getMessage()); } public function testCustomerFailure() { $httpResponse = $this->getMockHttpResponse('CustomerFailure.txt'); $response = new Response($this->getMockRequest(), $httpResponse->json()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCustomerReference()); $this->assertSame('One or more parameters were missing or invalid', $response->getMessage()); } } tests/Message/PurchaseRequestTest.php 0000604 00000004036 15173220523 0013765 0 ustar 00 <?php namespace Omnipay\Pin\Message; use Omnipay\Tests\TestCase; class PurchaseRequestTest extends TestCase { public function setUp() { $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( array( 'amount' => '10.00', 'currency' => 'AUD', 'card' => $this->getValidCard(), 'email' => 'roland@pin.net.au', 'description' => 'test charge' ) ); } public function testDataWithCardToken() { $this->request->setToken('card_abc'); $data = $this->request->getData(); $this->assertSame('card_abc', $data['card_token']); } public function testDataWithCustomerToken() { $this->request->setToken('cus_abc'); $data = $this->request->getData(); $this->assertSame('cus_abc', $data['customer_token']); } public function testDataWithCard() { $card = $this->getValidCard(); $this->request->setCard($card); $data = $this->request->getData(); $this->assertSame($card['number'], $data['card']['number']); } public function testSendSuccess() { $this->setMockHttpResponse('PurchaseSuccess.txt'); $response = $this->request->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ch_fXIxWf0gj1yFHJcV1W-d-w', $response->getTransactionReference()); $this->assertSame('Success!', $response->getMessage()); } public function testSendError() { $this->setMockHttpResponse('PurchaseFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('The current resource was deemed invalid.', $response->getMessage()); } } tests/GatewayTest.php 0000604 00000012255 15173220523 0010661 0 ustar 00 <?php namespace Omnipay\Pin; use Omnipay\Tests\GatewayTestCase; class GatewayTest extends GatewayTestCase { public function setUp() { parent::setUp(); $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); $this->options = array( 'amount' => '10.00', 'card' => $this->getValidCard(), 'email' => 'roland@pin.net.au', 'description' => 'test charge' ); } public function testPurchaseSuccess() { $this->setMockHttpResponse('PurchaseSuccess.txt'); $response = $this->gateway->purchase($this->options)->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ch_fXIxWf0gj1yFHJcV1W-d-w', $response->getTransactionReference()); $this->assertSame('Success!', $response->getMessage()); } public function testPurchaseError() { $this->setMockHttpResponse('PurchaseFailure.txt'); $response = $this->gateway->purchase($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('The current resource was deemed invalid.', $response->getMessage()); } public function testRefundSuccess() { $this->setMockHttpResponse('RefundSuccess.txt'); $response = $this->gateway->refund(array('amount' => '400.00', 'transactionReference' => 'ch_bZ3RhJnIUZ8HhfvH8CCvfA'))->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('rf_ERCQy--Ay6o-NKGiUVcKKA', $response->getTransactionReference()); $this->assertSame('Pending', $response->getMessage()); } public function testRefundError() { $this->setMockHttpResponse('RefundFailure.txt'); $response = $this->gateway->refund(array('amount' => '500.00', 'transactionReference' => 'ch_bZ3RhJnIUZ8HhfvH8CCvfA'))->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('Refund amount is more than your available Pin Payments balance.', $response->getMessage()); } public function testGetCardReferenceSuccess() { $this->setMockHttpResponse('CardSuccess.txt'); $response = $this->gateway->createCard($this->options)->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('card_8LmnNMTYWG4zQZ4YnYQhBg', $response->getCardReference()); $this->assertTrue($response->getMessage()); } public function testCreateCardError() { $this->setMockHttpResponse('CardFailure.txt'); $response = $this->gateway->createCard($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCardReference()); $this->assertSame('One or more parameters were missing or invalid', $response->getMessage()); } public function testCreateCustomerSuccess() { $this->setMockHttpResponse('CustomerSuccess.txt'); $response = $this->gateway->createCustomer($this->options)->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('cus_Mb-8S1ZgEbLUUUJ97dfhfQ', $response->getCustomerReference()); $this->assertTrue($response->getMessage()); } public function testCreateCustomerError() { $this->setMockHttpResponse('CustomerFailure.txt'); $response = $this->gateway->createCustomer($this->options)->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getCustomerReference()); $this->assertSame('One or more parameters were missing or invalid', $response->getMessage()); } public function testCaptureSuccess() { $this->setMockHttpResponse('CaptureSuccess.txt'); $response = $this->gateway->capture(array('amount' => '400.00', 'transactionReference' => 'ch_bZ3RhJnIUZ8HhfvH8CCvfA'))->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertEquals('ch_lfUYEBK14zotCTykezJkfg', $response->getTransactionReference()); $this->assertTrue($response->getCaptured()); } public function testCaptureError() { $this->setMockHttpResponse('CaptureFailure.txt'); $response = $this->gateway->capture(array('amount' => '400.00', 'transactionReference' => 'ch_lfUYEBK14zotCTykezJkfg'))->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertSame('The authorisation has expired and can not be captured.', $response->getMessage()); } } tests/Mock/CustomerSuccess.txt 0000604 00000001704 15173220523 0012470 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response":{"token":"cus_Mb-8S1ZgEbLUUUJ97dfhfQ","email":"roland@pin.net.au","created_at":"2014-05-16T11:59:13Z","card":{"token":"card_ooPYTNYmvVr8gswiBwE8kQ","scheme":"master","display_number":"XXXX-XXXX-XXXX-0000","expiry_month":5,"expiry_year":2015,"name":"Roland Robot","address_line1":"42 Sevenoaks St","address_line2":"","address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"}}} tests/Mock/CaptureSuccess.txt 0000604 00000002426 15173220523 0012274 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response":{"token":"ch_lfUYEBK14zotCTykezJkfg","success":true,"amount":400,"currency":"USD","description":"test charge","email":"roland@pin.net.au","ip_address":"203.192.1.172","created_at":"2012-06-20T03:10:49Z","status_message":"Success","error_message":null,"card":{"token":"card_pIQJKMs93GsCc9vLSLevbw","scheme":"master","display_number":"XXXX-XXXX-XXXX-0000","expiry_month":6,"expiry_year":2020,"name":"RolandRobot","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia","primary":null},"captured":true,"authorisation_expired":false,"transfer":[],"amount_refunded":0,"total_fees":42,"merchant_entitlement":358,"refund_pending":false,"settlement_currency":"AUD"}} tests/Mock/RefundSuccess.txt 0000604 00000001363 15173220523 0012113 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response": {"token": "rf_ERCQy--Ay6o-NKGiUVcKKA","success": null,"amount": 400,"currency": "AUD","charge": "ch_bZ3RhJnIUZ8HhfvH8CCvfA","created_at": "2012-10-27T13:00:00Z","error_message": null,"status_message": "Pending"}} tests/Mock/CardFailure.txt 0000604 00000001340 15173220523 0011513 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"error":"invalid_resource","error_description":"One or more parameters were missing or invalid","messages":[{"param":"expiry_month","code":"expiry_month_invalid","message":"Expiry month can't be blank"}]} tests/Mock/PurchaseFailure.txt 0000604 00000001171 15173220523 0012416 0 ustar 00 HTTP/1.1 422 Unprocessable Entity Cache-Control: no-cache Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:54:18 GMT Server: Apache/2.2.20 (Ubuntu) Status: 422 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 293436e475bfc6face410e6ed241efe9 X-Runtime: 0.161746 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 152 Connection: keep-alive {"error":"invalid_resource","error_description":"The current resource was deemed invalid.","messages":[{"code":"invalid","message":"Processing error"}]} tests/Mock/RefundFailure.txt 0000604 00000001135 15173220523 0012067 0 ustar 00 HTTP/1.1 422 Unprocessable Entity Cache-Control: no-cache Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:54:18 GMT Server: Apache/2.2.20 (Ubuntu) Status: 422 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 293436e475bfc6face410e6ed241efe9 X-Runtime: 0.161746 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 152 Connection: keep-alive {"error": "insufficient_pin_balance","error_description": "Refund amount is more than your available Pin Payments balance."} tests/Mock/PurchaseSuccess.txt 0000604 00000002133 15173220523 0012436 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response":{"token":"ch_fXIxWf0gj1yFHJcV1W-d-w","success":true,"amount":1000,"currency":"USD","description":"first purchase","email":"fads","ip_address":"","created_at":"2013-02-15T15:42:42Z","status_message":"Success!","error_message":null,"card":{"token":"card_vRGOXvw3NSGR59-TSzVEiw","display_number":"XXXX-XXXX-XXXX-0000","scheme":"visa","address_line1":"jkl","address_line2":"jkl","address_city":"jkl","address_postcode":"jkl","address_state":"jkl","address_country":"jkl"},"transfer":[],"amount_refunded":0,"total_fees":null,"merchant_entitlement":null,"refund_pending":false}} tests/Mock/CardSuccess.txt 0000604 00000001562 15173220523 0011542 0 ustar 00 HTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"response":{"token":"card_8LmnNMTYWG4zQZ4YnYQhBg","scheme":"master","display_number":"XXXX-XXXX-XXXX-0000","expiry_month":5,"expiry_year":2015,"name":"Roland Robot","address_line1":"42 Sevenoaks St","address_line2":"","address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"},"ip_address":"27.32.236.92"} tests/Mock/CaptureFailure.txt 0000604 00000001275 15173220523 0012254 0 ustar 00 HTTP/1.1 400 AUTHORISATION_EXPIRED Cache-Control: max-age=0, private, must-revalidate Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:42:42 GMT ETag: "e0b6339dc44a19a2901de1447ec94ebb" Server: Apache/2.2.20 (Ubuntu) Status: 200 Strict-Transport-Security: max-age=31536000 Vary: Use-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 6444d2d9467ed2a7ace471522f2d439b X-Runtime: 0.245244 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 584 Connection: keep-alive {"error":"authorisation_expired","error_description":"The authorisation has expired and can not be captured.","charge_token":"ch_lfUYEBK14zotCTykezJkfg"} tests/Mock/CustomerFailure.txt 0000604 00000001356 15173220523 0012452 0 ustar 00 HTTP/1.1 422 Unprocessable Entity Cache-Control: no-cache Content-Type: application/json; charset=utf-8 Date: Fri, 15 Feb 2013 15:54:18 GMT Server: Apache/2.2.20 (Ubuntu) Status: 422 Strict-Transport-Security: max-age=31536000 Vary: User-Agent X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 X-Rack-Cache: invalidate, pass X-Request-Id: 293436e475bfc6face410e6ed241efe9 X-Runtime: 0.161746 X-UA-Compatible: IE=Edge,chrome=1 Content-Length: 152 Connection: keep-alive {"error":"invalid_resource","error_description":"One or more parameters were missing or invalid","messages":[{"param":"email","code":"email_invalid","message":"Email can't be blank"},{"param":"email","code":"email_invalid","message":"Email is not formatted properly"}]} src/Message/AuthorizeRequest.php 0000604 00000010062 15173220523 0012746 0 ustar 00 <?php /** * Pin Authorize Request */ namespace Omnipay\Pin\Message; /** * Pin Authorize Request * * The charges API allows you to create new credit card charges, and to retrieve * details of previous charges. * * This message creates a new charge and returns its details. This may be a * long-running request. * * Gateway Parameters * * * email Email address of the customer. Obtained from the card data. * * description Description of the item purchased (e.g. "500g of single origin beans"). * * amount Amount to charge in the currency’s base unit (e.g. cents * for AUD, yen for JPY). There is a minimum charge amount for each * currency; refer to the documentation on supported currencies. * * ip_address IP address of the person submitting the payment. * Obtained from getClientIp. * * Optional currency The three-character ISO 4217 currency code of one * of our supported currencies, e.g. AUD or USD. Default value is "AUD". * * Optional capture Whether or not to immediately capture the charge * ("true" or "false"). If capture is false an authorisation is created. * Later you can capture. Authorised charges automatically expire after * 5 days. Default value is "true". * * and one of the following: * * * card The full details of the credit card to be charged (CreditCard object) * * card_token Token of the card to be charged, as returned from the card * tokens API or customer API. * * customer_token Token of the customer to be charged, as returned * from the customers API. * * ### Example * * <code> * // Create a gateway for the Pin REST Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('PinGateway'); * * // Initialise the gateway * $gateway->initialize(array( * 'secretKey' => 'TEST', * 'testMode' => true, // Or false when you are ready for live transactions * )); * * // Create a credit card object * // This card can be used for testing. * // See https://pin.net.au/docs/api/test-cards for a list of card * // numbers that can be used for testing. * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4200000000000000', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * // Do an authorize transaction on the gateway * $transaction = $gateway->authorize(array( * 'description' => 'Your order for widgets', * 'amount' => '10.00', * 'currency' => 'AUD', * 'clientIp' => $_SERVER['REMOTE_ADDR'], * 'card' => $card, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Authorize transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> * * @see \Omnipay\Pin\Gateway * @link https://pin.net.au/docs/api/charges */ class AuthorizeRequest extends PurchaseRequest { /** * Get the Capture flag. * * Returns the capture parameter, which states whether the charge is * just an authorisation or it is captured instantly. By default all * charges are captured. Please note that the return has to be a string * and not a boolean or Pin's API will disregard it and consider it set * to 'true' * * By default for authorize transactions we return "false". * * @return string */ public function getCapture() { $capture = $this->getParameter('capture'); // By default with Pin a transaction is captured. return $capture === true ? 'true' : 'false'; } } src/Message/AbstractRequest.php 0000604 00000006636 15173220523 0012553 0 ustar 00 <?php /** * Pin Abstract REST Request */ namespace Omnipay\Pin\Message; use Guzzle\Http\Message\RequestInterface; /** * Pin Abstract REST Request * * This is the parent class for all Pin REST requests. * * Test modes: * * The API has two endpoint host names: * * * api.pin.net.au (live) * * test-api.pin.net.au (test) * * The live host is for processing live transactions, whereas the test * host can be used for integration testing and development. * * Each endpoint requires a different set of API keys, which can be * found in your account settings. * * Currently this class makes the assumption that if the testMode * flag is set then the Test Endpoint is being used. * * @see \Omnipay\Pin\Gateway * @link https://pin.net.au/docs/api */ abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest { const API_VERSION = '1'; /** * Test Endpoint URL * * @var string URL */ protected $testEndpoint = 'https://test-api.pin.net.au/'; /** * Live Endpoint URL * * @var string URL */ protected $liveEndpoint = 'https://api.pin.net.au/'; /** * Get secret key * * Calls to the Pin Payments API must be authenticated using HTTP * basic authentication, with your API key as the username, and * a blank string as the password. * * @return string */ public function getSecretKey() { return $this->getParameter('secretKey'); } /** * Set secret key * * Calls to the Pin Payments API must be authenticated using HTTP * basic authentication, with your API key as the username, and * a blank string as the password. * * @param string $value * @return AbstractRequest implements a fluent interface */ public function setSecretKey($value) { return $this->setParameter('secretKey', $value); } /** * Get the request email. * * @return string */ public function getEmail() { return $this->getParameter('email'); } /** * Sets the request email. * * @param string $value * @return AbstractRequest Provides a fluent interface */ public function setEmail($value) { return $this->setParameter('email', $value); } /** * Get API endpoint URL * * @return string */ protected function getEndpoint() { $base = $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; return $base . self::API_VERSION; } /** * Send a request to the gateway. * * @param string $action * @param array $data * @param string $method * * @return HttpResponse */ public function sendRequest($action, $data = null, $method = RequestInterface::POST) { // don't throw exceptions for 4xx errors $this->httpClient->getEventDispatcher()->addListener( 'request.error', function ($event) { if ($event['response']->isClientError()) { $event->stopPropagation(); } } ); // Return the response we get back from Pin Payments return $this->httpClient->createRequest( $method, $this->getEndpoint() . $action, array('Authorization' => 'Basic ' . base64_encode($this->getSecretKey() . ':')), $data )->send(); } } src/Message/CaptureRequest.php 0000604 00000001376 15173220523 0012407 0 ustar 00 <?php /** * Pin Capture Request */ namespace Omnipay\Pin\Message; use Guzzle\Http\Message\RequestInterface; /** * Pin Capture Request */ class CaptureRequest extends AbstractRequest { public function getData() { $this->validate('transactionReference'); // Amount is the only possible optional parameter $amount = $this->getAmountInteger(); return $amount ? array('amount' => $amount) : array(); } public function sendData($data) { $httpResponse = $this->sendRequest( '/charges/' . $this->getTransactionReference() . '/capture', $data, RequestInterface::PUT ); return $this->response = new CaptureResponse($this, $httpResponse->json()); } } src/Message/RefundRequest.php 0000604 00000002753 15173220523 0012227 0 ustar 00 <?php /** * Pin Refund Request */ namespace Omnipay\Pin\Message; /** * Pin Refund Request * * The refunds API allows you to refund a charge, and retrieve the details * of previous refunds. * * This message creates a new refund, and returns its details. * * Example -- this example assumes that the charge has been successful and the * transaction ID is stored in $sale_id. See PurchaseRequest for the first part * of this transaction. * * <code> * // Do a refund transaction on the gateway * $transaction = $gateway->refund(array( * 'transactionReference' => $sale_id, * 'amount' => '10.00', * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Refund transaction was successful!\n"; * $refund_id = $response->getTransactionReference(); * echo "Transaction reference = " . $refund_id . "\n"; * } * </code> * * @see \Omnipay\Pin\Gateway * @link https://pin.net.au/docs/api/refunds#post-refunds */ class RefundRequest extends AbstractRequest { public function getData() { $this->validate('transactionReference', 'amount'); $data = array(); $data['amount'] = $this->getAmountInteger(); return $data; } public function sendData($data) { $httpResponse = $this->sendRequest('/charges/' . $this->getTransactionReference() . '/refunds', $data); return $this->response = new Response($this, $httpResponse->json()); } } src/Message/Response.php 0000604 00000003526 15173220523 0011230 0 ustar 00 <?php /** * Pin Response */ namespace Omnipay\Pin\Message; use Omnipay\Common\Message\AbstractResponse; /** * Pin Response * * This is the response class for all Pin REST requests. * * @see \Omnipay\Pin\Gateway */ class Response extends AbstractResponse { public function isSuccessful() { return !isset($this->data['error']); } public function getTransactionReference() { if (isset($this->data['response']['token'])) { return $this->data['response']['token']; } } /** * Get Card Reference * * This is used after createCard to get the credit card token to be * used in future transactions. * * @return string */ public function getCardReference() { if (isset($this->data['response']['token'])) { return $this->data['response']['token']; } } /** * @deprecated */ public function getCardToken() { return $this->getCardReference(); } /** * Get Customer Reference * * This is used after createCustomer to get the customer token to be * used in future transactions. * * @return string */ public function getCustomerReference() { if (isset($this->data['response']['token'])) { return $this->data['response']['token']; } } /** * @deprecated */ public function getCustomerToken() { return $this->getCustomerReference(); } public function getMessage() { if ($this->isSuccessful()) { if (isset($this->data['response']['status_message'])) { return $this->data['response']['status_message']; } else { return true; } } else { return $this->data['error_description']; } } } src/Message/PurchaseRequest.php 0000604 00000015221 15173220523 0012550 0 ustar 00 <?php /** * Pin Purchase Request */ namespace Omnipay\Pin\Message; /** * Pin Purchase Request * * The charges API allows you to create new credit card charges, and to retrieve * details of previous charges. * * This message creates a new charge and returns its details. This may be a * long-running request. * * Gateway Parameters * * * email Email address of the customer. Obtained from the card data. * * description Description of the item purchased (e.g. "500g of single origin beans"). * * amount Amount to charge in the currency’s base unit (e.g. cents * for AUD, yen for JPY). There is a minimum charge amount for each * currency; refer to the documentation on supported currencies. * * ip_address IP address of the person submitting the payment. * Obtained from getClientIp. * * Optional currency The three-character ISO 4217 currency code of one * of our supported currencies, e.g. AUD or USD. Default value is "AUD". * * Optional capture Whether or not to immediately capture the charge * ("true" or "false"). If capture is false an authorisation is created. * Later you can capture. Authorised charges automatically expire after * 5 days. Default value is "true". * * and one of the following: * * * card The full details of the credit card to be charged (CreditCard object) * * card_token Token of the card to be charged, as returned from the card * tokens API or customer API. * * customer_token Token of the customer to be charged, as returned * from the customers API. * * Example: * * <code> * // Create a gateway for the Pin REST Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('PinGateway'); * * // Initialise the gateway * $gateway->initialize(array( * 'secretKey' => 'TEST', * 'testMode' => true, // Or false when you are ready for live transactions * )); * * // Create a credit card object * // This card can be used for testing. * // See https://pin.net.au/docs/api/test-cards for a list of card * // numbers that can be used for testing. * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4200000000000000', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * // Do a purchase transaction on the gateway * $transaction = $gateway->purchase(array( * 'description' => 'Your order for widgets', * 'amount' => '10.00', * 'currency' => 'AUD', * 'clientIp' => $_SERVER['REMOTE_ADDR'], * 'card' => $card, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Purchase transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> * * @see \Omnipay\Pin\Gateway * @link https://pin.net.au/docs/api/charges */ class PurchaseRequest extends AbstractRequest { public function getData() { $data = array(); $this->validate('amount', 'description'); $data = array(); $data['amount'] = $this->getAmountInteger(); $data['currency'] = strtolower($this->getCurrency()); $data['description'] = $this->getDescription(); $data['ip_address'] = $this->getClientIp(); $data['capture'] = $this->getCapture(); // Token payments if ($token = $this->getToken()) { if (strpos($token, 'card_') !== false) { $data['card_token'] = $token; } else { $data['customer_token'] = $token; } // Supply an email address if provided, but it is not required if ($this->getEmail()) { $data['email'] = $this->getEmail(); } // Card payments } else { $this->validate('card'); $this->getCard()->validate(); // An email address is required if ($this->getCard()->getEmail()) { $data['email'] = $this->getCard()->getEmail(); } elseif ($this->getEmail()) { $data['email'] = $this->getEmail(); } else { $this->validate('email'); } $data['card']['number'] = $this->getCard()->getNumber(); $data['card']['expiry_month'] = $this->getCard()->getExpiryMonth(); $data['card']['expiry_year'] = $this->getCard()->getExpiryYear(); $data['card']['cvc'] = $this->getCard()->getCvv(); $data['card']['name'] = $this->getCard()->getName(); $data['card']['address_line1'] = $this->getCard()->getAddress1(); $data['card']['address_line2'] = $this->getCard()->getAddress2(); $data['card']['address_city'] = $this->getCard()->getCity(); $data['card']['address_postcode'] = $this->getCard()->getPostcode(); $data['card']['address_state'] = $this->getCard()->getState(); $data['card']['address_country'] = $this->getCard()->getCountry(); } return $data; } public function sendData($data) { $httpResponse = $this->sendRequest('/charges', $data); return $this->response = new Response($this, $httpResponse->json()); } /** * Get the Capture flag. * * Returns the capture parameter, which states whether the charge is * just an authorisation or it is captured instantly. By default all * charges are captured. Please note that the return has to be a string * and not a boolean or Pin's API will disregard it and consider it set * to 'true' * * @return string */ public function getCapture() { $capture = $this->getParameter('capture'); // By default with Pin a transaction is captured. return $capture === false ? 'false' : 'true'; } /** * Set the capture flag. * * This flag states whether the charge is just an authorisation or it is * captured instantly. By default all charges are captured. * * @param $value * * @return PurchaseRequest provides a fluent interface */ public function setCapture($value) { return $this->setParameter('capture', $value); } } src/Message/CreateCardRequest.php 0000604 00000006705 15173220523 0013002 0 ustar 00 <?php /** * Pin Create Card Request */ namespace Omnipay\Pin\Message; /** * Pin Create Card Request * * The card tokens API allows you to securely store credit card details * in exchange for a card token. This card token can then be used to * create a single charge with the charges API, or to create multiple * charges over time using the customers API. * * Returned card information contains a member called primary, which * says whether the card is a customer’s primary card. Its value is * true if the card is a customer’s primary card, false if it is a * non-primary card of the customer, and null if it is not associated * with a customer. * * A card token can only be used once, to create either a charge or * a customer. If no charge or customer is created within 1 month, * the token is automatically expired. * * Example: * * <code> * // Create a gateway for the Pin REST Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('PinGateway'); * * // Initialise the gateway * $gateway->initialize(array( * 'secretKey' => 'TEST', * 'testMode' => true, // Or false when you are ready for live transactions * )); * * // Create a credit card object * // This card can be used for testing. * // See https://pin.net.au/docs/api/test-cards for a list of card * // numbers that can be used for testing. * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4200000000000000', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * $response = $gateway->createCard(array( * 'card' => $card, * ))->send(); * if ($response->isSuccessful()) { * // Find the card ID * $card_id = $response->getCardReference(); * } else { * echo "Gateway createCard failed.\n"; * echo "Error message == " . $response->getMessage() . "\n"; * } * </code> * * @link https://pin.net.au/docs/api/cards */ class CreateCardRequest extends AbstractRequest { public function getData() { $data = array(); $this->getCard()->validate(); $data['number'] = $this->getCard()->getNumber(); $data['expiry_month'] = $this->getCard()->getExpiryMonth(); $data['expiry_year'] = $this->getCard()->getExpiryYear(); $data['cvc'] = $this->getCard()->getCvv(); $data['name'] = $this->getCard()->getName(); $data['address_line1'] = $this->getCard()->getAddress1(); $data['address_line2'] = $this->getCard()->getAddress2(); $data['address_city'] = $this->getCard()->getCity(); $data['address_postcode'] = $this->getCard()->getPostcode(); $data['address_state'] = $this->getCard()->getState(); $data['address_country'] = $this->getCard()->getCountry(); return $data; } public function sendData($data) { $httpResponse = $this->sendRequest('/cards', $data); return $this->response = new Response($this, $httpResponse->json()); } } src/Message/CreateCustomerRequest.php 0000604 00000007137 15173220523 0013732 0 ustar 00 <?php /** * Pin Create Customer Request */ namespace Omnipay\Pin\Message; /** * Pin Create Customer Request * * The customers API allows you to store a customer’s email * and credit card details. A customer can then be used with * the charges API to create multiple charges over time. * * Customers can have multiple cards associated with them, * and one will be considered the customer’s primary card. * The card object in returned customer information represents * this primary card. It contains a member called primary, * which says whether the card is a customer’s primary card; * its value will always be true. * * Example: * * <code> * // Create a gateway for the Pin REST Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('PinGateway'); * * // Initialise the gateway * $gateway->initialize(array( * 'secretKey' => 'TEST', * 'testMode' => true, // Or false when you are ready for live transactions * )); * * // Create a credit card object * // This card can be used for testing. * // See https://pin.net.au/docs/api/test-cards for a list of card * // numbers that can be used for testing. * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4200000000000000', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * $response = $gateway->createCustomer(array( * 'card' => $card, * ))->send(); * if ($response->isSuccessful()) { * // Find the customer ID * $customer_id = $response->getCustomerToken(); * } else { * echo "Gateway createCustomer failed.\n"; * echo "Error message == " . $response->getMessage() . "\n"; * } * </code> * * @link https://pin.net.au/docs/api/customers */ class CreateCustomerRequest extends AbstractRequest { public function getData() { $this->validate('email'); $data = array(); $data['email'] = $this->getEmail(); if ($this->getToken()) { $data['card_token'] = $this->getToken(); } else { $this->getCard()->validate(); $data['card']['number'] = $this->getCard()->getNumber(); $data['card']['expiry_month'] = $this->getCard()->getExpiryMonth(); $data['card']['expiry_year'] = $this->getCard()->getExpiryYear(); $data['card']['cvc'] = $this->getCard()->getCvv(); $data['card']['name'] = $this->getCard()->getName(); $data['card']['address_line1'] = $this->getCard()->getAddress1(); $data['card']['address_line2'] = $this->getCard()->getAddress2(); $data['card']['address_city'] = $this->getCard()->getCity(); $data['card']['address_postcode'] = $this->getCard()->getPostcode(); $data['card']['address_state'] = $this->getCard()->getState(); $data['card']['address_country'] = $this->getCard()->getCountry(); } return $data; } public function sendData($data) { $httpResponse = $this->sendRequest('/customers', $data); return $this->response = new Response($this, $httpResponse->json()); } } src/Message/CaptureResponse.php 0000604 00000001155 15173220523 0012550 0 ustar 00 <?php /** * Pin Capture Response */ namespace Omnipay\Pin\Message; /** * Pin Capture Response * * This is the response class for Pin Capture REST requests. * * @see \Omnipay\Pin\Gateway */ class CaptureResponse extends Response { /** * Get Captured value * * This is used after an attempt to capture the charge is made. * If the capture was successful then it will return true. * * @return string */ public function getCaptured() { if (isset($this->data['response']['captured'])) { return $this->data['response']['captured']; } } } src/Gateway.php 0000604 00000014105 15173220523 0007442 0 ustar 00 <?php /** * Pin Gateway */ namespace Omnipay\Pin; use Omnipay\Common\AbstractGateway; /** * Pin Gateway * * Pin Payments is an Australian all-in-one payment system, allowing you * to accept multi-currency credit card payments without a security * deposit or a merchant account. * * ### Example * * <code> * // Create a gateway for the Pin REST Gateway * // (routes to GatewayFactory::create) * $gateway = Omnipay::create('PinGateway'); * * // Initialise the gateway * $gateway->initialize(array( * 'secretKey' => 'TEST', * 'testMode' => true, // Or false when you are ready for live transactions * )); * * // Create a credit card object * // This card can be used for testing. * // See https://pin.net.au/docs/api/test-cards for a list of card * // numbers that can be used for testing. * $card = new CreditCard(array( * 'firstName' => 'Example', * 'lastName' => 'Customer', * 'number' => '4200000000000000', * 'expiryMonth' => '01', * 'expiryYear' => '2020', * 'cvv' => '123', * 'email' => 'customer@example.com', * 'billingAddress1' => '1 Scrubby Creek Road', * 'billingCountry' => 'AU', * 'billingCity' => 'Scrubby Creek', * 'billingPostcode' => '4999', * 'billingState' => 'QLD', * )); * * // Do a purchase transaction on the gateway * $transaction = $gateway->purchase(array( * 'description' => 'Your order for widgets', * 'amount' => '10.00', * 'currency' => 'AUD', * 'clientIp' => $_SERVER['REMOTE_ADDR'], * 'card' => $card, * )); * $response = $transaction->send(); * if ($response->isSuccessful()) { * echo "Purchase transaction was successful!\n"; * $sale_id = $response->getTransactionReference(); * echo "Transaction reference = " . $sale_id . "\n"; * } * </code> * * ### Test modes * * The API has two endpoint host names: * * * api.pin.net.au (live) * * test-api.pin.net.au (test) * * The live host is for processing live transactions, whereas the test * host can be used for integration testing and development. * * Each endpoint requires a different set of API keys, which can be * found in your account settings. * * ### Authentication * * Calls to the Pin Payments API must be authenticated using HTTP * basic authentication, with your API key as the username, and * a blank string as the password. * * #### Keys * * Your account has two types of keys: * * * publishable * * secret * * You can find your keys on the account settings page of the dashboard * after you have created an account at pin.net.au and logged in. * * Your secret key can be used with all of the API, and must be kept * secure and secret at all times. You use your secret key from your * server to create charges and refunds. * * Your publishable key can be used from insecure locations (such as * browsers or mobile apps) to create cards with the cards API. This * is the key you use with Pin.js to create secure payment forms in * the browser. * * @see \Omnipay\Common\AbstractGateway * @link https://pin.net.au/docs/api */ class Gateway extends AbstractGateway { public function getName() { return 'Pin'; } public function getDefaultParameters() { return array( 'secretKey' => '', 'testMode' => false, ); } /** * Get secret key * * Calls to the Pin Payments API must be authenticated using HTTP * basic authentication, with your API key as the username, and * a blank string as the password. * * @return string */ public function getSecretKey() { return $this->getParameter('secretKey'); } /** * Set secret key * * Calls to the Pin Payments API must be authenticated using HTTP * basic authentication, with your API key as the username, and * a blank string as the password. * * @param string $value * @return Gateway implements a fluent interface */ public function setSecretKey($value) { return $this->setParameter('secretKey', $value); } /** * Create a purchase request * * @param array $parameters * @return \Omnipay\Pin\Message\PurchaseRequest */ public function purchase(array $parameters = array()) { return $this->createRequest('\Omnipay\Pin\Message\PurchaseRequest', $parameters); } /** * Create an authorize request * * @param array $parameters * @return \Omnipay\Pin\Message\AuthorizeRequest */ public function authorize(array $parameters = array()) { return $this->createRequest('\Omnipay\Pin\Message\AuthorizeRequest', $parameters); } /** * Create a capture request * * @param array $parameters * @return \Omnipay\Pin\Message\CaptureRequest */ public function capture(array $parameters = array()) { return $this->createRequest('\Omnipay\Pin\Message\CaptureRequest', $parameters); } /** * Create a refund request * * @param array $parameters * @return \Omnipay\Pin\Message\RefundRequest */ public function refund(array $parameters = array()) { return $this->createRequest('\Omnipay\Pin\Message\RefundRequest', $parameters); } /** * Create a createCustomer request * * @param array $parameters * @return \Omnipay\Pin\Message\CreateCustomerRequest */ public function createCustomer(array $parameters = array()) { return $this->createRequest('\Omnipay\Pin\Message\CreateCustomerRequest', $parameters); } /** * Create a createCard request * * @param array $parameters * @return \Omnipay\Pin\Message\CreateCardRequest */ public function createCard(array $parameters = array()) { return $this->createRequest('\Omnipay\Pin\Message\CreateCardRequest', $parameters); } } phpunit.xml.dist 0000604 00000001512 15173220523 0007712 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 15173220523 0006764 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.
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings