File manager - Edit - /home/opticamezl/www/newok/coinbase.tar
Back
CONTRIBUTING.md 0000604 00000001040 15173246223 0006771 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. phpunit.xml.dist 0000604 00000001512 15173246223 0007717 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> LICENSE 0000604 00000002042 15173246223 0005550 0 ustar 00 Copyright (c) 2014 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 00000001652 15173246223 0007273 0 ustar 00 { "name": "omnipay/coinbase", "type": "library", "description": "Coinbase driver for the Omnipay payment processing library", "keywords": [ "coinbase", "gateway", "merchant", "omnipay", "pay", "payment" ], "homepage": "https://github.com/thephpleague/omnipay-coinbase", "license": "MIT", "authors": [ { "name": "Adrian Macneil", "email": "adrian@adrianmacneil.com" }, { "name": "Omnipay Contributors", "homepage": "https://github.com/thephpleague/omnipay-coinbase/contributors" } ], "autoload": { "psr-4": { "Omnipay\\Coinbase\\" : "src/" } }, "require": { "omnipay/common": "~2.0" }, "require-dev": { "omnipay/tests": "~2.0" }, "extra": { "branch-alias": { "dev-master": "2.0.x-dev" } } } .gitignore 0000604 00000000060 15173246223 0006531 0 ustar 00 /vendor composer.lock composer.phar phpunit.xml README.md 0000604 00000003533 15173246223 0006030 0 ustar 00 # Omnipay: Coinbase **Coinbase driver for the Omnipay PHP payment processing library** [](https://travis-ci.org/thephpleague/omnipay-coinbase) [](https://packagist.org/packages/omnipay/coinbase) [](https://packagist.org/packages/omnipay/coinbase) [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements Coinbase 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/coinbase": "~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: * Coinbase 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-coinbase/issues), or better yet, fork the library and submit a pull request. tests/GatewayTest.php 0000604 00000002201 15173246223 0010654 0 ustar 00 <?php namespace Omnipay\Coinbase; 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' => '10.00')); $this->assertInstanceOf('Omnipay\Coinbase\Message\PurchaseRequest', $request); $this->assertSame('10.00', $request->getAmount()); } public function testCompletePurchase() { $request = $this->gateway->completePurchase(array('amount' => '10.00')); $this->assertInstanceOf('Omnipay\Coinbase\Message\CompletePurchaseRequest', $request); $this->assertSame('10.00', $request->getAmount()); } public function testFetchTransaction() { $request = $this->gateway->fetchTransaction(array('transactionReference' => 'abc123')); $this->assertInstanceOf('Omnipay\Coinbase\Message\FetchTransactionRequest', $request); $this->assertSame('abc123', $request->getTransactionReference()); } } tests/Mock/PurchaseSuccess.txt 0000604 00000002266 15173246223 0012452 0 ustar 00 HTTP/1.1 200 OK Server: cloudflare-nginx Date: Sun, 11 May 2014 21:17:31 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Set-Cookie: __cfduid=d2616ea01666569cafccf501cbea6d2be1399843050822; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly, request_method=POST; path=/; secure Cache-Control: no-cache, no-store, max-age=0, must-revalidate Etag: "4b486ed3e49c8c0990deed71af7d2c5d" Expires: -1 Pragma: no-cache Status: 200 OK Strict-Transport-Security: max-age=31536000 Vary: Accept-Encoding X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Rack-Cache: invalidate, pass X-Request-Id: 1bfac74c-04d6-4c52-9f4a-d543cdd3875c X-Runtime: 0.109415 X-Ua-Compatible: IE=Edge,chrome=1 CF-RAY: 1291675ba0b00669-SJC {"success":true,"button":{"code":"30dae91b81299066ba126e3858f89fd8","type":"buy_now","style":"buy_now_large","text":"Pay With Bitcoin","name":"Socks","description":"","custom":"","callback_url":null,"success_url":null,"cancel_url":null,"info_url":null,"auto_redirect":false,"price":{"cents":1000,"currency_iso":"USD"},"variable_price":false,"choose_price":false,"include_address":false,"include_email":false}} tests/Mock/FetchTransactionFailure.txt 0000604 00000001510 15173246223 0014105 0 ustar 00 HTTP/1.1 200 OK Server: cloudflare-nginx Date: Mon, 12 May 2014 00:32:53 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Set-Cookie: __cfduid=dbd9a9997b37405d3448b2d39cf9222811399854773232; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly, request_method=GET; path=/; secure Cache-Control: no-cache, no-store, max-age=0, must-revalidate Etag: "79b74a4dbbb350563282c434324082cf" Expires: -1 Pragma: no-cache Status: 200 OK Strict-Transport-Security: max-age=31536000 Vary: Accept-Encoding X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Rack-Cache: miss X-Request-Id: f6eb9aba-981f-441a-a255-3902f7734efc X-Runtime: 0.062876 X-Ua-Compatible: IE=Edge,chrome=1 CF-RAY: 1292858cb7990669-SJC {"success":false,"error":"Order not found with that id"} tests/Mock/PurchaseUnauthorized.txt 0000604 00000001466 15173246223 0013524 0 ustar 00 HTTP/1.1 401 Unauthorized Server: cloudflare-nginx Date: Sun, 11 May 2014 21:16:06 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Set-Cookie: __cfduid=d4655ff60ac6d25f4cf1b61d91a2f4c941399842965827; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly, request_method=POST; path=/; secure Cache-Control: no-cache, no-store, max-age=0, must-revalidate Expires: -1 Pragma: no-cache Status: 401 Unauthorized Strict-Transport-Security: max-age=31536000 Vary: Accept-Encoding X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Rack-Cache: invalidate, pass X-Request-Id: a67ce0e3-fa12-4238-91fd-aa3e82912c8a X-Runtime: 0.053423 X-Ua-Compatible: IE=Edge,chrome=1 CF-RAY: 1291654599e70669-SJC {"error":"ACCESS_SIGNATURE does not validate"} tests/Mock/FetchTransactionSuccess.txt 0000604 00000002457 15173246223 0014141 0 ustar 00 HTTP/1.1 200 OK Server: cloudflare-nginx Date: Mon, 12 May 2014 00:32:14 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Set-Cookie: __cfduid=dd39ff662c7fcde30fd149dceb550afdb1399854734458; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly, request_method=GET; path=/; secure Cache-Control: no-cache, no-store, max-age=0, must-revalidate Etag: "d551971d78d873d05334f1cb97348400" Expires: -1 Pragma: no-cache Status: 200 OK Strict-Transport-Security: max-age=31536000 Vary: Accept-Encoding X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Rack-Cache: miss X-Request-Id: 538d444f-f9cf-48ea-b3f0-b6f46479cc46 X-Runtime: 0.174142 X-Ua-Compatible: IE=Edge,chrome=1 CF-RAY: 1292849a5e6a0669-SJC {"order":{"id":"9XMWP4YG","created_at":"2014-05-11T15:46:54-07:00","status":"completed","total_btc":{"cents":100000,"currency_iso":"BTC"},"total_native":{"cents":100000,"currency_iso":"BTC"},"total_payout":{"cents":0,"currency_iso":"USD"},"custom":null,"receive_address":"1JUHoDocLWReabF1Qc3jL8bB6Zy6Z2xayV","button":{"type":"buy_now","name":"Socks","description":null,"id":"2016572d538165cb1e2a04f9942c9c54"},"refund_address":"1ArFhi7wsDCfZxk88RykW6BE7Cv7nsXmAk","transaction":{"id":"536ffdf55d905debc8000041","hash":null,"confirmations":0}}} tests/Mock/PurchaseFailure.txt 0000604 00000002323 15173246223 0012423 0 ustar 00 HTTP/1.1 200 OK Server: cloudflare-nginx Date: Sun, 11 May 2014 21:16:47 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Set-Cookie: __cfduid=d7dcdb1d9bcf6956196803df5114745281399843007383; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly, request_method=POST; path=/; secure Cache-Control: no-cache, no-store, max-age=0, must-revalidate Etag: "11a8b7215eb13fb4b06266ac86b7bbf6" Expires: -1 Pragma: no-cache Status: 200 OK Strict-Transport-Security: max-age=31536000 Vary: Accept-Encoding X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Rack-Cache: invalidate, pass X-Request-Id: 0bfa5456-4866-417f-90cd-1d4583863a9f X-Runtime: 0.172405 X-Ua-Compatible: IE=Edge,chrome=1 CF-RAY: 1291664bc8790669-SJC {"success":false,"errors":["Name can't be blank"],"button":{"code":"c777f2ca6e01b8c116b267a053603e62","type":"buy_now","style":"buy_now_large","text":"Pay With Bitcoin","name":"","description":"","custom":"","callback_url":null,"success_url":null,"cancel_url":null,"info_url":null,"auto_redirect":false,"price":{"cents":1000,"currency_iso":"USD"},"variable_price":false,"choose_price":false,"include_address":false,"include_email":false}} tests/Message/PurchaseResponseTest.php 0000604 00000003404 15173246223 0014136 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; use Omnipay\Tests\TestCase; class PurchaseResponseTest extends TestCase { public function testSuccess() { $httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt'); $response = new PurchaseResponse($this->getMockRequest(), $httpResponse->json()); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getMessage()); $this->assertSame('GET', $response->getRedirectMethod()); $this->assertSame('https://coinbase.com/checkouts/30dae91b81299066ba126e3858f89fd8', $response->getRedirectUrl()); $this->assertNull($response->getRedirectData()); $this->assertSame('30dae91b81299066ba126e3858f89fd8', $response->getTransactionReference()); } public function testFailure() { $httpResponse = $this->getMockHttpResponse('PurchaseFailure.txt'); $response = new PurchaseResponse($this->getMockRequest(), $httpResponse->json()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame("Name can't be blank", $response->getMessage()); $this->assertNull($response->getRedirectUrl()); $this->assertNull($response->getRedirectData()); $this->assertSame('c777f2ca6e01b8c116b267a053603e62', $response->getTransactionReference()); } public function testEmpty() { $response = new PurchaseResponse($this->getMockRequest(), array()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); } } tests/Message/CompletePurchaseRequestTest.php 0000604 00000005257 15173246223 0015471 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; use Omnipay\Tests\TestCase; use Symfony\Component\HttpFoundation\Request as HttpRequest; class CompletePurchaseRequestTest extends TestCase { public function setUp() { $this->httpRequest = $this->getHttpRequest(); $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->httpRequest); $this->request->initialize( array( 'apiKey' => 'abc123', 'secret' => 'shhh', ) ); } public function testGetDataGet() { $this->httpRequest->query->replace( array('order' => array('id' => '9XMWP4YG')) ); $data = $this->request->getData(); $this->assertSame('9XMWP4YG', $data['id']); } public function testGetDataPost() { // post data is sent as JSON $content = '{"order":{"id":"9XMWP4YG","created_at":"2014-05-11T22:15:41-07:00","status":"completed"}}'; $this->httpRequest = new HttpRequest(array(), array(), array(), array(), array(), array(), $content); $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->httpRequest); $this->request->initialize( array( 'apiKey' => 'abc123', 'secret' => 'shhh', ) ); $data = $this->request->getData(); $this->assertSame('9XMWP4YG', $data['id']); } /** * @expectedException \Omnipay\Common\Exception\InvalidRequestException * @expectedExceptionMessage Missing Order ID */ public function testGetDataInvalid() { $this->request->getData(); } public function testSendSuccess() { $this->httpRequest->query->replace( array('order' => array('id' => '9XMWP4YG')) ); $this->setMockHttpResponse('FetchTransactionSuccess.txt'); $response = $this->request->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('completed', $response->getMessage()); $this->assertSame('9XMWP4YG', $response->getTransactionReference()); } public function testSendFailure() { $this->httpRequest->query->replace( array('order' => array('id' => '9XMWP4YG')) ); $this->setMockHttpResponse('FetchTransactionFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('Order not found with that id', $response->getMessage()); $this->assertNull($response->getTransactionReference()); } } tests/Message/AbstractRequestTest.php 0000604 00000001613 15173246223 0013761 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; use Mockery as m; use Omnipay\Tests\TestCase; class AbstractRequestTest extends TestCase { public function setUp() { $this->request = m::mock('\Omnipay\Coinbase\Message\AbstractRequest')->makePartial(); $this->request->initialize(); } public function testGenerateNonce() { // nonce should increment every time $n1 = $this->request->generateNonce(); $n2 = $this->request->generateNonce(); $this->assertGreaterThan($n1, $n2); } public function testGenerateSignature() { $url = 'exampleurl'; $body = 'examplebody'; $nonce = '12345'; $this->request->setSecret('shhh'); $expected = hash_hmac('sha256', '12345exampleurlexamplebody', 'shhh'); $this->assertSame($expected, $this->request->generateSignature($url, $body, $nonce)); } } tests/Message/ResponseTest.php 0000604 00000002547 15173246223 0012452 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; use Omnipay\Tests\TestCase; class ResponseTest extends TestCase { public function testSuccess() { $httpResponse = $this->getMockHttpResponse('FetchTransactionSuccess.txt'); $response = new Response($this->getMockRequest(), $httpResponse->json()); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('completed', $response->getMessage()); $this->assertSame('9XMWP4YG', $response->getTransactionReference()); } public function testFailure() { $httpResponse = $this->getMockHttpResponse('FetchTransactionFailure.txt'); $response = new Response($this->getMockRequest(), $httpResponse->json()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('Order not found with that id', $response->getMessage()); $this->assertNull($response->getTransactionReference()); } public function testEmpty() { $response = new Response($this->getMockRequest(), array()); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); } } tests/Message/FetchTransactionRequestTest.php 0000604 00000003240 15173246223 0015453 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; use Omnipay\Tests\TestCase; class FetchTransactionRequestTest extends TestCase { public function setUp() { $this->httpRequest = $this->getHttpRequest(); $this->request = new FetchTransactionRequest($this->getHttpClient(), $this->httpRequest); $this->request->initialize( array( 'transactionReference' => '9XMWP4YG', 'apiKey' => 'abc123', 'secret' => 'shhh', ) ); } public function testGetDataGet() { $this->request->initialize(array('transactionReference' => 'abc123')); $data = $this->request->getData(); $this->assertSame('abc123', $data['id']); } public function testSendSuccess() { $this->setMockHttpResponse('FetchTransactionSuccess.txt'); $response = $this->request->send(); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('completed', $response->getMessage()); $this->assertSame('9XMWP4YG', $response->getTransactionReference()); } public function testSendFailure() { $this->httpRequest->request->replace( array('order' => array('id' => '9XMWP4YG')) ); $this->setMockHttpResponse('FetchTransactionFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('Order not found with that id', $response->getMessage()); $this->assertNull($response->getTransactionReference()); } } tests/Message/PurchaseRequestTest.php 0000604 00000006760 15173246223 0014000 0 ustar 00 <?php namespace Omnipay\Coinbase\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' => 'USD', 'description' => 'Socks', 'apiKey' => 'abc123', 'secret' => 'shhh', ) ); } public function testGetData() { $this->request->initialize( array( 'accountId' => 'abc123', 'amount' => '0.001', 'currency' => 'BTC', 'description' => 'Socks', 'returnUrl' => 'https://example.com/return', 'cancelUrl' => 'https://example.com/cancel', 'notifyUrl' => 'https://example.com/notify', ) ); $data = $this->request->getData(); $this->assertSame('abc123', $data['account_id']); $this->assertSame('0.00100000', $data['button']['price_string']); $this->assertSame('BTC', $data['button']['price_currency_iso']); $this->assertSame('Socks', $data['button']['name']); $this->assertSame('https://example.com/return', $data['button']['success_url']); $this->assertSame('https://example.com/cancel', $data['button']['cancel_url']); $this->assertSame('https://example.com/notify', $data['button']['callback_url']); } public function testGetDataAccountIdNull() { // empty string must be converted to null $this->request->setAccountId(''); $data = $this->request->getData(); $this->assertNull($data['account_id']); } public function testSendSuccess() { $this->setMockHttpResponse('PurchaseSuccess.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getMessage()); $this->assertSame('GET', $response->getRedirectMethod()); $this->assertSame('https://coinbase.com/checkouts/30dae91b81299066ba126e3858f89fd8', $response->getRedirectUrl()); $this->assertNull($response->getRedirectData()); $this->assertSame('30dae91b81299066ba126e3858f89fd8', $response->getTransactionReference()); } public function testSendFailure() { $this->setMockHttpResponse('PurchaseFailure.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame("Name can't be blank", $response->getMessage()); $this->assertNull($response->getRedirectUrl()); $this->assertNull($response->getRedirectData()); $this->assertSame('c777f2ca6e01b8c116b267a053603e62', $response->getTransactionReference()); } public function testSendUnauthorized() { $this->setMockHttpResponse('PurchaseUnauthorized.txt'); $response = $this->request->send(); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); $this->assertSame('ACCESS_SIGNATURE does not validate', $response->getMessage()); $this->assertNull($response->getRedirectUrl()); $this->assertNull($response->getRedirectData()); $this->assertNull($response->getTransactionReference()); } } src/Gateway.php 0000604 00000003753 15173246223 0007456 0 ustar 00 <?php namespace Omnipay\Coinbase; use Omnipay\Common\AbstractGateway; /** * Coinbase Gateway * * @link https://coinbase.com/docs/api/overview */ class Gateway extends AbstractGateway { public function getName() { return 'Coinbase'; } public function getDefaultParameters() { return array( 'apiKey' => '', 'secret' => '', 'accountId' => '', ); } public function getApiKey() { return $this->getParameter('apiKey'); } public function setApiKey($value) { return $this->setParameter('apiKey', $value); } public function getSecret() { return $this->getParameter('secret'); } public function setSecret($value) { return $this->setParameter('secret', $value); } public function getAccountId() { return $this->getParameter('accountId'); } public function setAccountId($value) { return $this->setParameter('accountId', $value); } /** * @param array $parameters * @return \Omnipay\Coinbase\Message\PurchaseRequest */ public function purchase(array $parameters = array()) { return $this->createRequest('\Omnipay\Coinbase\Message\PurchaseRequest', $parameters); } /** * @param array $parameters * @return \Omnipay\Coinbase\Message\CompletePurchaseRequest */ public function completePurchase(array $parameters = array()) { return $this->createRequest('\Omnipay\Coinbase\Message\CompletePurchaseRequest', $parameters); } /** * @param array $parameters * @return \Omnipay\Coinbase\Message\FetchTransactionRequest */ public function fetchTransaction(array $parameters = array()) { return $this->createRequest('\Omnipay\Coinbase\Message\FetchTransactionRequest', $parameters); } } src/Message/FetchTransactionRequest.php 0000604 00000001062 15173246223 0014240 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; /** * Coinbase Fetch Transaction Request * * @method \Omnipay\Coinbase\Message\Response send() */ class FetchTransactionRequest extends AbstractRequest { public function getData() { $this->validate('transactionReference'); return array('id' => $this->getTransactionReference()); } public function sendData($data) { $httpResponse = $this->sendRequest('GET', '/orders/'.$data['id']); return $this->response = new Response($this, $httpResponse->json()); } } src/Message/PurchaseResponse.php 0000604 00000001710 15173246223 0012721 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; use Omnipay\Common\Message\RedirectResponseInterface; /** * Coinbase Purchase Response */ class PurchaseResponse extends Response implements RedirectResponseInterface { protected $redirectEndpoint = 'https://coinbase.com/checkouts'; public function isSuccessful() { return false; } public function isRedirect() { return isset($this->data['success']) && $this->data['success']; } public function getRedirectMethod() { return 'GET'; } public function getRedirectUrl() { if ($this->isRedirect()) { return $this->redirectEndpoint.'/'.$this->getTransactionReference(); } } public function getRedirectData() { return null; } public function getTransactionReference() { if (isset($this->data['button']['code'])) { return $this->data['button']['code']; } } } src/Message/PurchaseRequest.php 0000604 00000002011 15173246223 0012546 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; /** * Coinbase Purchase Request * * @method \Omnipay\Coinbase\Message\PurchaseResponse send() */ class PurchaseRequest extends AbstractRequest { public function getData() { $this->validate('amount', 'currency', 'description'); $data = array(); $data['account_id'] = $this->getAccountId() ?: null; $data['button'] = array(); $data['button']['name'] = $this->getDescription(); $data['button']['price_string'] = $this->getAmount(); $data['button']['price_currency_iso'] = $this->getCurrency(); $data['button']['success_url'] = $this->getReturnUrl(); $data['button']['cancel_url'] = $this->getCancelUrl(); $data['button']['callback_url'] = $this->getNotifyUrl(); return $data; } public function sendData($data) { $httpResponse = $this->sendRequest('POST', '/buttons', $data); return $this->response = new PurchaseResponse($this, $httpResponse->json()); } } src/Message/CompletePurchaseRequest.php 0000604 00000001472 15173246223 0014251 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; use Omnipay\Common\Exception\InvalidRequestException; /** * Coinbase Complete Purchase Request * * @method \Omnipay\Coinbase\Message\Response send() */ class CompletePurchaseRequest extends FetchTransactionRequest { public function getData() { // check GET $order = $this->httpRequest->query->get('order'); // check JSON POST data if (!$order && $this->httpRequest->getContent()) { $content = json_decode($this->httpRequest->getContent(), true); if (isset($content['order'])) { $order = $content['order']; } } if (empty($order['id'])) { throw new InvalidRequestException('Missing Order ID'); } return array('id' => $order['id']); } } src/Message/AbstractRequest.php 0000604 00000004134 15173246223 0012547 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; /** * Coinbase Abstract Request * * @method \Omnipay\Coinbase\Message\Response send() */ abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest { protected $endpoint = 'https://api.coinbase.com/v1'; public function getApiKey() { return $this->getParameter('apiKey'); } public function setApiKey($value) { return $this->setParameter('apiKey', $value); } public function getSecret() { return $this->getParameter('secret'); } public function setSecret($value) { return $this->setParameter('secret', $value); } public function getAccountId() { return $this->getParameter('accountId'); } public function setAccountId($value) { return $this->setParameter('accountId', $value); } public function sendRequest($method, $action, $data = null) { // don't throw exceptions for 4xx errors $this->httpClient->getEventDispatcher()->addListener( 'request.error', function ($event) { if ($event['response']->isClientError()) { $event->stopPropagation(); } } ); $nonce = $this->generateNonce(); $url = $this->endpoint.$action; $body = $data ? http_build_query($data) : null; $httpRequest = $this->httpClient->createRequest($method, $url, null, $body); $httpRequest->setHeader('Content-Type', 'application/x-www-form-urlencoded'); $httpRequest->setHeader('ACCESS_KEY', $this->getApiKey()); $httpRequest->setHeader('ACCESS_SIGNATURE', $this->generateSignature($url, $body, $nonce)); $httpRequest->setHeader('ACCESS_NONCE', $nonce); return $httpRequest->send(); } public function generateNonce() { return sprintf('%0.0f', round(microtime(true) * 1000000)); } public function generateSignature($url, $body, $nonce) { $message = $nonce.$url.$body; return hash_hmac('sha256', $message, $this->getSecret()); } } src/Message/Response.php 0000604 00000001520 15173246223 0011225 0 ustar 00 <?php namespace Omnipay\Coinbase\Message; use Omnipay\Common\Message\AbstractResponse; /** * Coinbase Response */ class Response extends AbstractResponse { public function isSuccessful() { return isset($this->data['order']['status']) && 'completed' === $this->data['order']['status']; } public function getMessage() { if (isset($this->data['error'])) { return $this->data['error']; } elseif (isset($this->data['errors'])) { return implode(', ', $this->data['errors']); } elseif (isset($this->data['order']['status'])) { return $this->data['order']['status']; } } public function getTransactionReference() { if (isset($this->data['order']['id'])) { return $this->data['order']['id']; } } } .travis.yml 0000604 00000000317 15173246223 0006657 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