Permalink
Browse files

braintree php client library 1.0.0

  • Loading branch information...
0 parents commit f2d8d7cfb2b8b88d4006de93cc982b9222f4b87d @braintreeps braintreeps committed Feb 26, 2010
Showing with 7,931 additions and 0 deletions.
  1. +22 −0 LICENSE
  2. +37 −0 README.md
  3. +14 −0 Rakefile
  4. +101 −0 lib/Braintree.php
  5. +384 −0 lib/Braintree/Address.php
  6. +159 −0 lib/Braintree/Collection.php
  7. +364 −0 lib/Braintree/Configuration.php
  8. +535 −0 lib/Braintree/CreditCard.php
  9. +545 −0 lib/Braintree/Customer.php
  10. +62 −0 lib/Braintree/Digest.php
  11. +117 −0 lib/Braintree/Error/Codes.php
  12. +73 −0 lib/Braintree/Error/ErrorCollection.php
  13. +59 −0 lib/Braintree/Error/Validation.php
  14. +97 −0 lib/Braintree/Error/ValidationErrorCollection.php
  15. +25 −0 lib/Braintree/Exception.php
  16. +21 −0 lib/Braintree/Exception/Authentication.php
  17. +23 −0 lib/Braintree/Exception/Authorization.php
  18. +21 −0 lib/Braintree/Exception/Configuration.php
  19. +20 −0 lib/Braintree/Exception/DownForMaintenance.php
  20. +23 −0 lib/Braintree/Exception/ForgedQueryString.php
  21. +20 −0 lib/Braintree/Exception/NotFound.php
  22. +20 −0 lib/Braintree/Exception/SSLCertificate.php
  23. +20 −0 lib/Braintree/Exception/ServerError.php
  24. +21 −0 lib/Braintree/Exception/Unexpected.php
  25. +21 −0 lib/Braintree/Exception/ValidationsFailed.php
  26. +156 −0 lib/Braintree/Http.php
  27. +72 −0 lib/Braintree/Instance.php
  28. +264 −0 lib/Braintree/PagedCollection.php
  29. +63 −0 lib/Braintree/Result/CreditCardVerification.php
  30. +95 −0 lib/Braintree/Result/Error.php
  31. +78 −0 lib/Braintree/Result/Successful.php
  32. +53 −0 lib/Braintree/SSLExpirationCheck.php
  33. +76 −0 lib/Braintree/Test/CreditCardNumbers.php
  34. +24 −0 lib/Braintree/Test/TransactionAmounts.php
  35. +701 −0 lib/Braintree/Transaction.php
  36. +32 −0 lib/Braintree/Transaction/AddressDetails.php
  37. +40 −0 lib/Braintree/Transaction/CreditCardDetails.php
  38. +30 −0 lib/Braintree/Transaction/CustomerDetails.php
  39. +26 −0 lib/Braintree/Transaction/StatusDetails.php
  40. +289 −0 lib/Braintree/TransparentRedirect.php
  41. +252 −0 lib/Braintree/Util.php
  42. +43 −0 lib/Braintree/Version.php
  43. +48 −0 lib/Braintree/Xml.php
  44. +145 −0 lib/Braintree/Xml/Generator.php
  45. +185 −0 lib/Braintree/Xml/Parser.php
  46. +44 −0 lib/ssl/securetrust_ca.crt
  47. +18 −0 lib/ssl/valicert_ca.crt
  48. +56 −0 tests/TestHelper.php
  49. +225 −0 tests/integration/AddressTest.php
  50. +27 −0 tests/integration/AllTests.php
  51. +465 −0 tests/integration/CreditCardTest.php
  52. +541 −0 tests/integration/CustomerTest.php
  53. +319 −0 tests/integration/TransactionTest.php
  54. +56 −0 tests/unit/AddressTest.php
  55. +40 −0 tests/unit/AllTests.php
  56. +24 −0 tests/unit/BraintreeTest.php
  57. +192 −0 tests/unit/ConfigurationTest.php
  58. +46 −0 tests/unit/CreditCardTest.php
  59. +13 −0 tests/unit/CustomerTest.php
  60. +23 −0 tests/unit/DigestTest.php
  61. +9 −0 tests/unit/HttpTest.php
  62. +19 −0 tests/unit/TransactionTest.php
  63. +149 −0 tests/unit/UtilTest.php
  64. +189 −0 tests/unit/Xml_ParserTest.php
22 LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2010 Braintree Payment Solutions
+
+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.
@@ -0,0 +1,37 @@
+# Braintree PHP Client Library
+
+The Braintree PHP library provides integration access to the Braintree Gateway.
+
+## Dependencies
+
+* Zend Framework
+
+## Quick Start Example
+
+ <?php
+
+ // ensure Zend_Framework is in your load path
+ require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';
+
+ // validates and sets config statically
+ Braintree_Configuration::environment('sandbox');
+ Braintree_Configuration::merchantId('the_merchant_id');
+ Braintree_Configuration::publicKey('the_public_key');
+ Braintree_Configuration::privateKey('the_private_key');
+
+ $transaction = Braintree_Transaction::saleNoValidate(array(
+ 'amount' => '100.00',
+ 'creditCard' => array(
+ 'number' => '5105105105105100',
+ 'expirationDate' => '05/12',
+ )
+ ));
+
+ print 'Transaction ID: ' . $transaction->id;
+ print 'Status: ' . $transaction->status;
+ ?>
+
+## License
+
+See the LICENSE file.
+
@@ -0,0 +1,14 @@
+task :default => %w[test:unit test:integration]
+
+namespace :test do
+ desc "run unit tests"
+ task :unit do
+ sh "phpunit tests/unit/AllTests.php"
+ end
+
+ desc "run integration tests"
+ task :integration do
+ sh "phpunit tests/integration/AllTests.php"
+ end
+end
+
@@ -0,0 +1,101 @@
+<?php
+/**
+ * Braintree base class and initialization
+ *
+ * PHP version 5
+ *
+ * @package Braintree
+ * @copyright 2010 Braintree Payment Solutions
+ */
+
+
+/*
+ * append the include path
+*/
+set_include_path(get_include_path() .
+ PATH_SEPARATOR . realpath(dirname(__FILE__))
+ );
+
+/**
+ * set up autoloader
+ */
+require_once 'Zend/Loader/Autoloader.php';
+$loader = Zend_Loader_Autoloader::getInstance();
+$loader->registerNamespace('Braintree_');
+
+
+/**
+ * Braintree PHP Library
+ *
+ * Provides methods to child classes. This class cannot be instantiated.
+ *
+ * @package Braintree
+ * @copyright 2010 Braintree Payment Solutions
+ */
+abstract class Braintree
+{
+ /**
+ * @ignore
+ * don't permit an explicit call of the constructor!
+ * (like $t = new Braintree_Transaction())
+ */
+ protected function __construct()
+ {
+ }
+ /**
+ * @ignore
+ * don't permit cloning the instances (like $x = clone $v)
+ */
+ protected function __clone()
+ {
+ }
+
+ public function __get($name)
+ {
+ trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
+ return null;
+ }
+
+ /**
+ *
+ * @param string $className
+ * @param object $resultObj
+ * @return object returns the passed object if successful
+ * @throws Braintree_Exception_ValidationsFailed
+ */
+ public static function returnObjectOrThrowException($className, $resultObj)
+ {
+ $resultObjName = Braintree_Util::cleanClassName($className);
+ if ($resultObj->success) {
+ return $resultObj->$resultObjName;
+ } else {
+ throw new Braintree_Exception_ValidationsFailed();
+ }
+ }
+}
+
+/**
+ * requirements and version checks
+ */
+// check PHP version
+if (version_compare(PHP_VERSION, '5.2.1', '<')) {
+ throw new Braintree_Exception('PHP version >= 5.2.1 required');
+}
+
+// check for extensions
+$requiredExtensions = array('xmlwriter', 'SimpleXML', 'openssl', 'dom', 'hash');
+foreach ($requiredExtensions AS $ext) {
+ if (!extension_loaded($ext)) {
+ throw new Braintree_Exception(
+ 'The Braintree library requires the ' . $ext . ' extension.'
+ );
+ }
+}
+
+
+//
+//
+// check ssl certificate
+Braintree_SSLExpirationCheck::checkDates();
+
+
Oops, something went wrong.

0 comments on commit f2d8d7c

Please sign in to comment.