Gene_Braintree - Version 2.1.3

Version Notes

Connect your Magento store to Braintree to accept Credit Cards & PayPal using V.Zero SDK

Download this release

Release Info

Developer Dave Macaulay
Extension Gene_Braintree
Version 2.1.3
Comparing to
See all releases


Code changes from version 2.1.2 to 2.1.3

Files changed (259) hide show
  1. app/code/community/Gene/Braintree/Block/Creditcard.php +25 -13
  2. app/code/community/Gene/Braintree/Block/Express/Abstract.php +40 -0
  3. app/code/community/Gene/Braintree/Block/Express/Button.php +7 -54
  4. app/code/community/Gene/Braintree/Block/Express/Checkout.php +1 -2
  5. app/code/community/Gene/Braintree/Block/Express/Setup.php +2 -46
  6. app/code/community/Gene/Braintree/Block/Js.php +50 -7
  7. app/code/community/Gene/Braintree/Block/Paypal.php +9 -6
  8. app/code/community/Gene/Braintree/Model/Observer.php +1 -4
  9. app/code/community/Gene/Braintree/Model/Paymentmethod/Creditcard.php +28 -14
  10. app/code/community/Gene/Braintree/Model/Paymentmethod/Paypal.php +24 -0
  11. app/code/community/Gene/Braintree/Model/System/Config/Source/Payment/Threedsecurecountries.php +25 -0
  12. app/code/community/Gene/Braintree/Model/Wrapper/Braintree.php +61 -46
  13. app/code/community/Gene/Braintree/controllers/CheckoutController.php +9 -5
  14. app/code/community/Gene/Braintree/controllers/ExpressController.php +11 -12
  15. app/code/community/Gene/Braintree/etc/config.xml +2 -1
  16. app/code/community/Gene/Braintree/etc/system.xml +135 -36
  17. app/design/adminhtml/default/default/layout/gene/braintree.xml +3 -3
  18. app/design/adminhtml/default/default/template/gene/braintree/creditcard.phtml +0 -108
  19. app/design/adminhtml/default/default/template/gene/braintree/creditcard/hostedfields.phtml +10 -2
  20. app/design/adminhtml/default/default/template/gene/braintree/js.phtml +23 -17
  21. app/design/frontend/base/default/layout/gene/braintree.xml +26 -114
  22. app/design/frontend/base/default/template/gene/braintree/creditcard.phtml +0 -188
  23. app/design/frontend/base/default/template/gene/braintree/express/button.phtml +3 -1
  24. app/design/frontend/base/default/template/gene/braintree/express/cart.phtml +5 -1
  25. app/design/frontend/base/default/template/gene/braintree/express/catalog.phtml +15 -1
  26. app/design/frontend/base/default/template/gene/braintree/js/aheadworks.phtml +10 -5
  27. app/design/frontend/base/default/template/gene/braintree/js/amasty.phtml +10 -5
  28. app/design/frontend/base/default/template/gene/braintree/js/awesomecheckout.phtml +12 -4
  29. app/design/frontend/base/default/template/gene/braintree/js/data.phtml +0 -25
  30. app/design/frontend/base/default/template/gene/braintree/js/default.phtml +27 -17
  31. app/design/frontend/base/default/template/gene/braintree/js/firecheckout.phtml +16 -7
  32. app/design/frontend/base/default/template/gene/braintree/js/fme.phtml +10 -5
  33. app/design/frontend/base/default/template/gene/braintree/js/idev.phtml +10 -3
  34. app/design/frontend/base/default/template/gene/braintree/js/iwd.phtml +16 -12
  35. app/design/frontend/base/default/template/gene/braintree/js/magestore.phtml +10 -5
  36. app/design/frontend/base/default/template/gene/braintree/js/multishipping.phtml +10 -3
  37. app/design/frontend/base/default/template/gene/braintree/js/oye.phtml +12 -7
  38. app/design/frontend/base/default/template/gene/braintree/js/setup.phtml +14 -12
  39. app/design/frontend/base/default/template/gene/braintree/js/unicode.phtml +10 -5
  40. js/gene/braintree/2.1.3/express/abstract-min.js +1 -0
  41. js/gene/braintree/{express → 2.1.3/express}/paypal-min.js +0 -0
  42. js/gene/braintree/2.1.3/vzero-integration-min.js +1 -0
  43. js/gene/braintree/2.1.3/vzero-min.js +1 -0
  44. js/gene/braintree/2.1.3/vzero-paypal-min.js +1 -0
  45. js/gene/braintree/config.codekit +39 -50
  46. js/gene/braintree/express.js +0 -427
  47. js/gene/braintree/express/abstract-min.js +1 -1
  48. js/gene/braintree/source/vzero-integration.js +103 -7
  49. js/gene/braintree/source/vzero-paypal.js +31 -5
  50. js/gene/braintree/source/vzero.js +90 -21
  51. js/gene/braintree/vzero-integration-min.js +0 -1
  52. js/gene/braintree/vzero-min.js +0 -1
  53. js/gene/braintree/vzero-paypal-min.js +0 -1
  54. lib/Gene/Braintree.php +0 -156
  55. lib/Gene/Braintree/CreditCardVerification.php +0 -22
  56. lib/Gene/Braintree/CreditCardVerificationGateway.php +0 -49
  57. lib/Gene/Braintree/CreditCardVerificationSearch.php +0 -53
  58. lib/Gene/Braintree/CustomerSearch.php +0 -31
  59. lib/Gene/Braintree/Descriptor.php +0 -4
  60. lib/Gene/Braintree/Exception.php +0 -11
  61. lib/Gene/Braintree/Exception/Authentication.php +0 -13
  62. lib/Gene/Braintree/Exception/Configuration.php +0 -12
  63. lib/Gene/Braintree/Exception/DownForMaintenance.php +0 -12
  64. lib/Gene/Braintree/Exception/InvalidChallenge.php +0 -5
  65. lib/Gene/Braintree/Exception/InvalidSignature.php +0 -5
  66. lib/Gene/Braintree/Exception/NotFound.php +0 -12
  67. lib/Gene/Braintree/Exception/SSLCaFileNotFound.php +0 -12
  68. lib/Gene/Braintree/Exception/SSLCertificate.php +0 -12
  69. lib/Gene/Braintree/Exception/ServerError.php +0 -12
  70. lib/Gene/Braintree/Exception/TestOperationPerformedInProduction.php +0 -11
  71. lib/Gene/Braintree/Exception/Unexpected.php +0 -13
  72. lib/Gene/Braintree/Exception/UpgradeRequired.php +0 -12
  73. lib/Gene/Braintree/Exception/ValidationsFailed.php +0 -12
  74. lib/Gene/Braintree/Gateway.php +0 -195
  75. lib/Gene/Braintree/IsNode.php +0 -21
  76. lib/Gene/Braintree/Merchant.php +0 -26
  77. lib/Gene/Braintree/MerchantAccount/AddressDetails.php +0 -5
  78. lib/Gene/Braintree/MerchantAccount/FundingDetails.php +0 -6
  79. lib/Gene/Braintree/PartialMatchNode.php +0 -16
  80. lib/Gene/Braintree/PaymentMethod.php +0 -44
  81. lib/Gene/Braintree/SubscriptionSearch.php +0 -64
  82. lib/Gene/Braintree/Test/Transaction.php +0 -51
  83. lib/Gene/Braintree/TextNode.php +0 -10
  84. lib/Gene/Braintree/TransactionSearch.php +0 -130
  85. lib/Gene/Braintree/autoload.php +7 -0
  86. lib/Gene/Braintree/braintree/braintree_php/.gitignore +6 -0
  87. lib/Gene/Braintree/braintree/braintree_php/CHANGELOG.md +438 -0
  88. lib/Gene/Braintree/braintree/braintree_php/LICENSE +22 -0
  89. lib/Gene/Braintree/braintree/braintree_php/README.md +77 -0
  90. lib/Gene/Braintree/braintree/braintree_php/Rakefile +81 -0
  91. lib/Gene/Braintree/braintree/braintree_php/ci.sh +11 -0
  92. lib/Gene/Braintree/braintree/braintree_php/composer.json +36 -0
  93. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree.php +25 -0
  94. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/AccountUpdaterDailyReport.php +45 -0
  95. lib/Gene/Braintree/{AddOn.php → braintree/braintree_php/lib/Braintree/AddOn.php} +6 -4
  96. lib/Gene/Braintree/{AddOnGateway.php → braintree/braintree_php/lib/Braintree/AddOnGateway.php} +15 -13
  97. lib/Gene/Braintree/{Address.php → braintree/braintree_php/lib/Braintree/Address.php} +34 -31
  98. lib/Gene/Braintree/{AddressGateway.php → braintree/braintree_php/lib/Braintree/AddressGateway.php} +59 -49
  99. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/AmexExpressCheckoutCard.php +81 -0
  100. lib/Gene/Braintree/{AndroidPayCard.php → braintree/braintree_php/lib/Braintree/AndroidPayCard.php} +13 -9
  101. lib/Gene/Braintree/{ApplePayCard.php → braintree/braintree_php/lib/Braintree/ApplePayCard.php} +13 -9
  102. lib/Gene/Braintree/{Base.php → braintree/braintree_php/lib/Braintree/Base.php} +14 -7
  103. lib/Gene/Braintree/{ClientToken.php → braintree/braintree_php/lib/Braintree/ClientToken.php} +12 -10
  104. lib/Gene/Braintree/{ClientTokenGateway.php → braintree/braintree_php/lib/Braintree/ClientTokenGateway.php} +20 -16
  105. lib/Gene/Braintree/{CoinbaseAccount.php → braintree/braintree_php/lib/Braintree/CoinbaseAccount.php} +17 -13
  106. lib/Gene/Braintree/{Collection.php → braintree/braintree_php/lib/Braintree/Collection.php} +13 -4
  107. lib/Gene/Braintree/{Configuration.php → braintree/braintree_php/lib/Braintree/Configuration.php} +186 -23
  108. lib/Gene/Braintree/{CredentialsParser.php → braintree/braintree_php/lib/Braintree/CredentialsParser.php} +17 -14
  109. lib/Gene/Braintree/{CreditCard.php → braintree/braintree_php/lib/Braintree/CreditCard.php} +55 -50
  110. lib/Gene/Braintree/{CreditCardGateway.php → braintree/braintree_php/lib/Braintree/CreditCardGateway.php} +131 -116
  111. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/CreditCardVerification.php +43 -0
  112. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/CreditCardVerificationGateway.php +74 -0
  113. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/CreditCardVerificationSearch.php +56 -0
  114. lib/Gene/Braintree/{Customer.php → braintree/braintree_php/lib/Braintree/Customer.php} +112 -89
  115. lib/Gene/Braintree/{CustomerGateway.php → braintree/braintree_php/lib/Braintree/CustomerGateway.php} +116 -109
  116. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/CustomerSearch.php +34 -0
  117. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Descriptor.php +7 -0
  118. lib/Gene/Braintree/{Digest.php → braintree/braintree_php/lib/Braintree/Digest.php} +5 -2
  119. lib/Gene/Braintree/{Disbursement.php → braintree/braintree_php/lib/Braintree/Disbursement.php} +12 -9
  120. lib/Gene/Braintree/{DisbursementDetails.php → braintree/braintree_php/lib/Braintree/DisbursementDetails.php} +6 -6
  121. lib/Gene/Braintree/{Discount.php → braintree/braintree_php/lib/Braintree/Discount.php} +5 -2
  122. lib/Gene/Braintree/{DiscountGateway.php → braintree/braintree_php/lib/Braintree/DiscountGateway.php} +7 -4
  123. lib/Gene/Braintree/{Dispute.php → braintree/braintree_php/lib/Braintree/Dispute.php} +15 -8
  124. lib/Gene/Braintree/{Dispute → braintree/braintree_php/lib/Braintree/Dispute}/TransactionDetails.php +7 -2
  125. lib/Gene/Braintree/{EqualityNode.php → braintree/braintree_php/lib/Braintree/EqualityNode.php} +3 -1
  126. lib/Gene/Braintree/{Error → braintree/braintree_php/lib/Braintree/Error}/Codes.php +88 -57
  127. lib/Gene/Braintree/{Error → braintree/braintree_php/lib/Braintree/Error}/ErrorCollection.php +22 -7
  128. lib/Gene/Braintree/{Error → braintree/braintree_php/lib/Braintree/Error}/Validation.php +12 -7
  129. lib/Gene/Braintree/{Error → braintree/braintree_php/lib/Braintree/Error}/ValidationErrorCollection.php +14 -9
  130. lib/Gene/Braintree/{EuropeBankAccount.php → braintree/braintree_php/lib/Braintree/EuropeBankAccount.php} +16 -12
  131. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception.php +14 -0
  132. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/Authentication.php +18 -0
  133. lib/Gene/Braintree/{Exception → braintree/braintree_php/lib/Braintree/Exception}/Authorization.php +7 -2
  134. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/Configuration.php +17 -0
  135. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/DownForMaintenance.php +17 -0
  136. lib/Gene/Braintree/{Exception → braintree/braintree_php/lib/Braintree/Exception}/ForgedQueryString.php +7 -2
  137. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/InvalidChallenge.php +9 -0
  138. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/InvalidSignature.php +9 -0
  139. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/NotFound.php +17 -0
  140. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/SSLCaFileNotFound.php +17 -0
  141. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/SSLCertificate.php +17 -0
  142. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/ServerError.php +17 -0
  143. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/TestOperationPerformedInProduction.php +16 -0
  144. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/Timeout.php +17 -0
  145. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/TooManyRequests.php +17 -0
  146. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/Unexpected.php +18 -0
  147. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/UpgradeRequired.php +17 -0
  148. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/ValidationsFailed.php +17 -0
  149. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/FacilitatorDetails.php +30 -0
  150. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Gateway.php +208 -0
  151. lib/Gene/Braintree/{Http.php → braintree/braintree_php/lib/Braintree/Http.php} +73 -25
  152. lib/Gene/Braintree/{Instance.php → braintree/braintree_php/lib/Braintree/Instance.php} +14 -11
  153. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/IsNode.php +24 -0
  154. lib/Gene/Braintree/{KeyValueNode.php → braintree/braintree_php/lib/Braintree/KeyValueNode.php} +6 -5
  155. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Merchant.php +36 -0
  156. lib/Gene/Braintree/{MerchantAccount.php → braintree/braintree_php/lib/Braintree/MerchantAccount.php} +10 -8
  157. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/MerchantAccount/AddressDetails.php +10 -0
  158. lib/Gene/Braintree/{MerchantAccount → braintree/braintree_php/lib/Braintree/MerchantAccount}/BusinessDetails.php +6 -2
  159. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/MerchantAccount/FundingDetails.php +10 -0
  160. lib/Gene/Braintree/{MerchantAccount → braintree/braintree_php/lib/Braintree/MerchantAccount}/IndividualDetails.php +6 -2
  161. lib/Gene/Braintree/{MerchantAccountGateway.php → braintree/braintree_php/lib/Braintree/MerchantAccountGateway.php} +37 -35
  162. lib/Gene/Braintree/{MerchantGateway.php → braintree/braintree_php/lib/Braintree/MerchantGateway.php} +12 -10
  163. lib/Gene/Braintree/{Modification.php → braintree/braintree_php/lib/Braintree/Modification.php} +5 -2
  164. lib/Gene/Braintree/{MultipleValueNode.php → braintree/braintree_php/lib/Braintree/MultipleValueNode.php} +11 -7
  165. lib/Gene/Braintree/{MultipleValueOrTextNode.php → braintree/braintree_php/lib/Braintree/MultipleValueOrTextNode.php} +11 -9
  166. lib/Gene/Braintree/{OAuthCredentials.php → braintree/braintree_php/lib/Braintree/OAuthCredentials.php} +7 -4
  167. lib/Gene/Braintree/{OAuthGateway.php → braintree/braintree_php/lib/Braintree/OAuthGateway.php} +34 -13
  168. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/OAuthResult.php +36 -0
  169. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/PartialMatchNode.php +18 -0
  170. lib/Gene/Braintree/{PartnerMerchant.php → braintree/braintree_php/lib/Braintree/PartnerMerchant.php} +6 -4
  171. lib/Gene/Braintree/{PayPalAccount.php → braintree/braintree_php/lib/Braintree/PayPalAccount.php} +17 -13
  172. lib/Gene/Braintree/{PayPalAccountGateway.php → braintree/braintree_php/lib/Braintree/PayPalAccountGateway.php} +35 -30
  173. lib/Gene/Braintree/{PaymentInstrumentType.php → braintree/braintree_php/lib/Braintree/PaymentInstrumentType.php} +4 -1
  174. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/PaymentMethod.php +47 -0
  175. lib/Gene/Braintree/{PaymentMethodGateway.php → braintree/braintree_php/lib/Braintree/PaymentMethodGateway.php} +116 -67
  176. lib/Gene/Braintree/{PaymentMethodNonce.php → braintree/braintree_php/lib/Braintree/PaymentMethodNonce.php} +9 -6
  177. lib/Gene/Braintree/{PaymentMethodNonceGateway.php → braintree/braintree_php/lib/Braintree/PaymentMethodNonceGateway.php} +12 -9
  178. lib/Gene/Braintree/{Plan.php → braintree/braintree_php/lib/Braintree/Plan.php} +11 -8
  179. lib/Gene/Braintree/{PlanGateway.php → braintree/braintree_php/lib/Braintree/PlanGateway.php} +8 -5
  180. lib/Gene/Braintree/{RangeNode.php → braintree/braintree_php/lib/Braintree/RangeNode.php} +10 -8
  181. lib/Gene/Braintree/{ResourceCollection.php → braintree/braintree_php/lib/Braintree/ResourceCollection.php} +27 -11
  182. lib/Gene/Braintree/{Result → braintree/braintree_php/lib/Braintree/Result}/CreditCardVerification.php +17 -12
  183. lib/Gene/Braintree/{Result → braintree/braintree_php/lib/Braintree/Result}/Error.php +34 -19
  184. lib/Gene/Braintree/{Result → braintree/braintree_php/lib/Braintree/Result}/Successful.php +22 -15
  185. lib/Gene/Braintree/{RiskData.php → braintree/braintree_php/lib/Braintree/RiskData.php} +6 -3
  186. lib/Gene/Braintree/{SettlementBatchSummary.php → braintree/braintree_php/lib/Braintree/SettlementBatchSummary.php} +9 -6
  187. lib/Gene/Braintree/{SettlementBatchSummaryGateway.php → braintree/braintree_php/lib/Braintree/SettlementBatchSummaryGateway.php} +26 -24
  188. lib/Gene/Braintree/{SignatureService.php → braintree/braintree_php/lib/Braintree/SignatureService.php} +3 -1
  189. lib/Gene/Braintree/{Subscription.php → braintree/braintree_php/lib/Braintree/Subscription.php} +24 -21
  190. lib/Gene/Braintree/{Subscription → braintree/braintree_php/lib/Braintree/Subscription}/StatusDetails.php +9 -3
  191. lib/Gene/Braintree/{SubscriptionGateway.php → braintree/braintree_php/lib/Braintree/SubscriptionGateway.php} +59 -54
  192. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/SubscriptionSearch.php +72 -0
  193. lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/CreditCardNumbers.php +26 -19
  194. lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/MerchantAccount.php +5 -2
  195. lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/Nonces.php +8 -3
  196. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Test/Transaction.php +64 -0
  197. lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/TransactionAmounts.php +4 -2
  198. lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/VenmoSdk.php +5 -2
  199. lib/Gene/Braintree/{TestingGateway.php → braintree/braintree_php/lib/Braintree/TestingGateway.php} +8 -5
  200. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/TextNode.php +12 -0
  201. lib/Gene/Braintree/{ThreeDSecureInfo.php → braintree/braintree_php/lib/Braintree/ThreeDSecureInfo.php} +5 -2
  202. lib/Gene/Braintree/{Transaction.php → braintree/braintree_php/lib/Braintree/Transaction.php} +112 -69
  203. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/AddressDetails.php +8 -4
  204. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php +45 -0
  205. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/AndroidPayCardDetails.php +9 -5
  206. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/ApplePayCardDetails.php +9 -5
  207. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/CoinbaseDetails.php +9 -5
  208. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/CreditCardDetails.php +8 -4
  209. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/CustomerDetails.php +7 -3
  210. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/EuropeBankAccountDetails.php +7 -3
  211. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/PayPalDetails.php +9 -5
  212. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/StatusDetails.php +7 -3
  213. lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/SubscriptionDetails.php +7 -2
  214. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Transaction/UsBankAccountDetails.php +35 -0
  215. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Transaction/VenmoAccountDetails.php +40 -0
  216. lib/Gene/Braintree/{TransactionGateway.php → braintree/braintree_php/lib/Braintree/TransactionGateway.php} +175 -110
  217. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/TransactionSearch.php +130 -0
  218. lib/Gene/Braintree/{TransparentRedirect.php → braintree/braintree_php/lib/Braintree/TransparentRedirect.php} +16 -15
  219. lib/Gene/Braintree/{TransparentRedirectGateway.php → braintree/braintree_php/lib/Braintree/TransparentRedirectGateway.php} +59 -52
  220. lib/Gene/Braintree/{UnknownPaymentMethod.php → braintree/braintree_php/lib/Braintree/UnknownPaymentMethod.php} +9 -6
  221. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/UsBankAccount.php +85 -0
  222. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/UsBankAccountGateway.php +108 -0
  223. lib/Gene/Braintree/{Util.php → braintree/braintree_php/lib/Braintree/Util.php} +121 -88
  224. lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/VenmoAccount.php +75 -0
  225. lib/Gene/Braintree/{Version.php → braintree/braintree_php/lib/Braintree/Version.php} +7 -4
  226. lib/Gene/Braintree/{WebhookNotification.php → braintree/braintree_php/lib/Braintree/WebhookNotification.php} +31 -20
  227. lib/Gene/Braintree/{WebhookTesting.php → braintree/braintree_php/lib/Braintree/WebhookTesting.php} +123 -15
  228. lib/Gene/Braintree/{Xml.php → braintree/braintree_php/lib/Braintree/Xml.php} +7 -4
  229. lib/Gene/Braintree/{Xml → braintree/braintree_php/lib/Braintree/Xml}/Generator.php +23 -13
  230. lib/Gene/Braintree/{Xml → braintree/braintree_php/lib/Braintree/Xml}/Parser.php +17 -8
  231. lib/Gene/Braintree/braintree/braintree_php/lib/autoload.php +21 -0
  232. lib/Gene/Braintree/braintree/braintree_php/lib/ssl/api_braintreegateway_com.ca.crt +191 -0
  233. lib/Gene/Braintree/braintree/braintree_php/phpunit.xml.dist +24 -0
  234. lib/Gene/Braintree/braintree/braintree_php/tests/Braintree/CreditCardDefaults.php +8 -0
  235. lib/Gene/Braintree/braintree/braintree_php/tests/Braintree/CreditCardNumbers/CardTypeIndicators.php +15 -0
  236. lib/Gene/Braintree/braintree/braintree_php/tests/Braintree/OAuthTestHelper.php +35 -0
  237. lib/Gene/Braintree/braintree/braintree_php/tests/Helper.php +193 -0
  238. lib/Gene/Braintree/braintree/braintree_php/tests/SanityTest.php +20 -0
  239. lib/Gene/Braintree/braintree/braintree_php/tests/Setup.php +32 -0
  240. lib/Gene/Braintree/braintree/braintree_php/tests/integration/AddOnsTest.php +88 -0
  241. lib/Gene/Braintree/braintree/braintree_php/tests/integration/AddressTest.php +311 -0
  242. lib/Gene/Braintree/braintree/braintree_php/tests/integration/ClientTokenTest.php +188 -0
  243. lib/Gene/Braintree/braintree/braintree_php/tests/integration/CreditCardTest.php +1323 -0
  244. lib/Gene/Braintree/braintree/braintree_php/tests/integration/CreditCardVerificationAdvancedSearchTest.php +259 -0
  245. lib/Gene/Braintree/braintree/braintree_php/tests/integration/CreditCardVerificationTest.php +56 -0
  246. lib/Gene/Braintree/braintree/braintree_php/tests/integration/CustomerAdvancedSearchTest.php +199 -0
  247. lib/Gene/Braintree/braintree/braintree_php/tests/integration/CustomerTest.php +1435 -0
  248. lib/Gene/Braintree/braintree/braintree_php/tests/integration/DisbursementTest.php +39 -0
  249. lib/Gene/Braintree/braintree/braintree_php/tests/integration/DiscountTest.php +88 -0
  250. lib/Gene/Braintree/braintree/braintree_php/tests/integration/Error/ErrorCollectionTest.php +96 -0
  251. lib/Gene/Braintree/braintree/braintree_php/tests/integration/Error/ValidationErrorCollectionTest.php +75 -0
  252. lib/Gene/Braintree/braintree/braintree_php/tests/integration/EuropeBankAccountTest.php +54 -0
  253. lib/Gene/Braintree/braintree/braintree_php/tests/integration/HttpClientApi.php +116 -0
  254. lib/Gene/Braintree/braintree/braintree_php/tests/integration/HttpTest.php +66 -0
  255. lib/Gene/Braintree/braintree/braintree_php/tests/integration/MerchantAccountTest.php +431 -0
  256. lib/Gene/Braintree/braintree/braintree_php/tests/integration/MerchantTest.php +240 -0
  257. lib/Gene/Braintree/braintree/braintree_php/tests/integration/MultipleValueNodeTest.php +94 -0
  258. lib/Gene/Braintree/braintree/braintree_php/tests/integration/OAuthTest.php +324 -0
  259. lib/Gene/Braintree/braintree/braintree_php/tests/integration/PayPalAccountTest.php +282 -0
app/code/community/Gene/Braintree/Block/Creditcard.php CHANGED
@@ -9,6 +9,7 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
9
  {
10
  /**
11
  * We can use the same token twice
 
12
  * @var bool
13
  */
14
  protected $_token = false;
@@ -34,8 +35,13 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
34
  // Validate that the vault is enabled and that the user is either logged in or registering
35
  if ($this->getMethod()->isVaultEnabled()
36
  && (Mage::getSingleton('customer/session')->isLoggedIn()
37
- || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER))
38
- {
 
 
 
 
 
39
  return true;
40
  }
41
 
@@ -54,6 +60,7 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
54
  return sizeof($this->getSavedDetails());
55
  }
56
  }
 
57
  return false;
58
  }
59
 
@@ -64,9 +71,10 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
64
  */
65
  public function getSavedDetails()
66
  {
67
- if(!$this->_savedDetails) {
68
  $this->_savedDetails = Mage::getSingleton('gene_braintree/saved')->getSavedMethodsByType(Gene_Braintree_Model_Saved::SAVED_CREDITCARD_ID);
69
  }
 
70
  return $this->_savedDetails;
71
  }
72
 
@@ -79,6 +87,7 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
79
  {
80
  $html = $this->getChildHtml('saved', false);
81
  $this->unsetChild('saved');
 
82
  return $html;
83
  }
84
 
@@ -126,29 +135,29 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
126
  static public function getCardIcon($cardType)
127
  {
128
  // Convert the card type to lower case, no spaces
129
- switch(str_replace(' ', '', strtolower($cardType))) {
130
  case 'mastercard':
131
  return 'MC.png';
132
- break;
133
  case 'visa':
134
  return 'VI.png';
135
- break;
136
  case 'americanexpress':
137
  case 'amex':
138
  return 'AE.png';
139
- break;
140
  case 'discover':
141
  return 'DI.png';
142
- break;
143
  case 'jcb':
144
  return 'JCB.png';
145
- break;
146
  case 'maestro':
147
  return 'ME.png';
148
- break;
149
  case 'paypal':
150
  return 'PP.png';
151
- break;
152
  }
153
 
154
  // Otherwise return the standard card image
@@ -162,14 +171,16 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
162
  */
163
  protected function getClientToken()
164
  {
165
- if(!$this->_token) {
166
  $this->_token = Mage::getSingleton('gene_braintree/wrapper_braintree')->init()->generateToken();
167
  }
 
168
  return $this->_token;
169
  }
170
 
171
  /**
172
  * Config setting to show accepted cards on the checkout
 
173
  * @return boolean
174
  */
175
  protected function showAcceptedCards()
@@ -179,6 +190,7 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
179
 
180
  /**
181
  * Allowed payment cards
 
182
  * @return array
183
  */
184
  protected function getAllowedCards()
@@ -205,7 +217,7 @@ class Gene_Braintree_Block_Creditcard extends Mage_Payment_Block_Form_Cc
205
  */
206
  protected function getHostedDescriptor()
207
  {
208
- if( Mage::getModel('gene_braintree/paymentmethod_creditcard')->getConfigData('form_integration') == Gene_Braintree_Model_Source_Creditcard_FormIntegration::INTEGRATION_HOSTED ) {
209
  return Mage::getModel('gene_braintree/paymentmethod_creditcard')->getConfigData('hostedfields_descriptor');
210
  }
211
 
9
  {
10
  /**
11
  * We can use the same token twice
12
+ *
13
  * @var bool
14
  */
15
  protected $_token = false;
35
  // Validate that the vault is enabled and that the user is either logged in or registering
36
  if ($this->getMethod()->isVaultEnabled()
37
  && (Mage::getSingleton('customer/session')->isLoggedIn()
38
+ || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER)
39
+ ) {
40
+ return true;
41
+ }
42
+
43
+ // Is the vault enabled, and is the transaction occuring in the admin?
44
+ if ($this->getMethod()->isVaultEnabled() && Mage::app()->getStore()->isAdmin()) {
45
  return true;
46
  }
47
 
60
  return sizeof($this->getSavedDetails());
61
  }
62
  }
63
+
64
  return false;
65
  }
66
 
71
  */
72
  public function getSavedDetails()
73
  {
74
+ if (!$this->_savedDetails) {
75
  $this->_savedDetails = Mage::getSingleton('gene_braintree/saved')->getSavedMethodsByType(Gene_Braintree_Model_Saved::SAVED_CREDITCARD_ID);
76
  }
77
+
78
  return $this->_savedDetails;
79
  }
80
 
87
  {
88
  $html = $this->getChildHtml('saved', false);
89
  $this->unsetChild('saved');
90
+
91
  return $html;
92
  }
93
 
135
  static public function getCardIcon($cardType)
136
  {
137
  // Convert the card type to lower case, no spaces
138
+ switch (str_replace(' ', '', strtolower($cardType))) {
139
  case 'mastercard':
140
  return 'MC.png';
141
+ break;
142
  case 'visa':
143
  return 'VI.png';
144
+ break;
145
  case 'americanexpress':
146
  case 'amex':
147
  return 'AE.png';
148
+ break;
149
  case 'discover':
150
  return 'DI.png';
151
+ break;
152
  case 'jcb':
153
  return 'JCB.png';
154
+ break;
155
  case 'maestro':
156
  return 'ME.png';
157
+ break;
158
  case 'paypal':
159
  return 'PP.png';
160
+ break;
161
  }
162
 
163
  // Otherwise return the standard card image
171
  */
172
  protected function getClientToken()
173
  {
174
+ if (!$this->_token) {
175
  $this->_token = Mage::getSingleton('gene_braintree/wrapper_braintree')->init()->generateToken();
176
  }
177
+
178
  return $this->_token;
179
  }
180
 
181
  /**
182
  * Config setting to show accepted cards on the checkout
183
+ *
184
  * @return boolean
185
  */
186
  protected function showAcceptedCards()
190
 
191
  /**
192
  * Allowed payment cards
193
+ *
194
  * @return array
195
  */
196
  protected function getAllowedCards()
217
  */
218
  protected function getHostedDescriptor()
219
  {
220
+ if (Mage::getModel('gene_braintree/paymentmethod_creditcard')->getConfigData('form_integration') == Gene_Braintree_Model_Source_Creditcard_FormIntegration::INTEGRATION_HOSTED) {
221
  return Mage::getModel('gene_braintree/paymentmethod_creditcard')->getConfigData('hostedfields_descriptor');
222
  }
223
 
app/code/community/Gene/Braintree/Block/Express/Abstract.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Gene_Braintree_Block_Express_Abstract
5
+ *
6
+ * @author Dave Macaulay <dave@gene.co.uk>
7
+ */
8
+ class Gene_Braintree_Block_Express_Abstract extends Mage_Core_Block_Template
9
+ {
10
+ /**
11
+ * Is the express mode enabled
12
+ *
13
+ * @return bool
14
+ */
15
+ public function isEnabled()
16
+ {
17
+ return Mage::getStoreConfig('payment/gene_braintree_paypal/active')
18
+ && Mage::getStoreConfig('payment/gene_braintree_paypal/express_active');
19
+ }
20
+
21
+ /**
22
+ * Is express enabled on the product page?
23
+ *
24
+ * @return bool
25
+ */
26
+ public function isEnabledPdp()
27
+ {
28
+ return $this->isEnabled() && Mage::getStoreConfig('payment/gene_braintree_paypal/express_pdp');
29
+ }
30
+
31
+ /**
32
+ * Is express enabled in the cart?
33
+ *
34
+ * @return bool
35
+ */
36
+ public function isEnabledCart()
37
+ {
38
+ return $this->isEnabled() && Mage::getStoreConfig('payment/gene_braintree_paypal/express_cart');
39
+ }
40
+ }
app/code/community/Gene/Braintree/Block/Express/Button.php CHANGED
@@ -5,59 +5,10 @@
5
  *
6
  * @author Dave Macaulay <dave@gene.co.uk>
7
  */
8
- class Gene_Braintree_Block_Express_Button extends Mage_Core_Block_Template
9
  {
10
- /**
11
- * Generate braintree token
12
- */
13
- protected function _construct()
14
- {
15
- parent::_construct();
16
- }
17
-
18
- /**
19
- * Is the express mode enabled
20
- *
21
- * @return bool
22
- */
23
- public function isEnabled()
24
- {
25
- if (Mage::getStoreConfig('payment/gene_braintree_paypal/active')
26
- && Mage::getStoreConfig('payment/gene_braintree_paypal/express_active')
27
- ) {
28
- return true;
29
- }
30
-
31
- return false;
32
- }
33
-
34
- /**
35
- * Is express enabled on the product page?
36
- *
37
- * @return bool
38
- */
39
- public function isEnabledPdp()
40
- {
41
- if ($this->isEnabled() && Mage::getStoreConfig('payment/gene_braintree_paypal/express_pdp')) {
42
- return true;
43
- }
44
-
45
- return false;
46
- }
47
-
48
- /**
49
- * Is express enabled in the cart?
50
- *
51
- * @return bool
52
- */
53
- public function isEnabledCart()
54
- {
55
- if ($this->isEnabled() && Mage::getStoreConfig('payment/gene_braintree_paypal/express_cart')) {
56
- return true;
57
- }
58
-
59
- return false;
60
- }
61
 
62
  /**
63
  * Registry entry to mark this block as instantiated
@@ -68,10 +19,12 @@ class Gene_Braintree_Block_Express_Button extends Mage_Core_Block_Template
68
  */
69
  public function _afterToHtml($html)
70
  {
71
- if ($this->isEnabled()) {
 
 
72
  return $html;
73
  }
74
 
75
  return '';
76
  }
77
- }
5
  *
6
  * @author Dave Macaulay <dave@gene.co.uk>
7
  */
8
+ class Gene_Braintree_Block_Express_Button extends Gene_Braintree_Block_Express_Abstract
9
  {
10
+ const TYPE_CART = 'cart';
11
+ const TYPE_CATALOG = 'catalog';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  /**
14
  * Registry entry to mark this block as instantiated
19
  */
20
  public function _afterToHtml($html)
21
  {
22
+ if ($this->getExpressType() == self::TYPE_CART && $this->isEnabledCart()) {
23
+ return $html;
24
+ } elseif ($this->getExpressType() == self::TYPE_CATALOG && $this->isEnabledPdp()) {
25
  return $html;
26
  }
27
 
28
  return '';
29
  }
30
+ }
app/code/community/Gene/Braintree/Block/Express/Checkout.php CHANGED
@@ -35,5 +35,4 @@ class Gene_Braintree_Block_Express_Checkout extends Mage_Core_Block_Template
35
  {
36
  return $this->getData('quote');
37
  }
38
-
39
- }
35
  {
36
  return $this->getData('quote');
37
  }
38
+ }
 
app/code/community/Gene/Braintree/Block/Express/Setup.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * @author Aidan Threadgold <aidan@gene.co.uk>
7
  */
8
- class Gene_Braintree_Block_Express_Setup extends Mage_Core_Block_Template
9
  {
10
  /**
11
  * Braintree token
@@ -33,50 +33,6 @@ class Gene_Braintree_Block_Express_Setup extends Mage_Core_Block_Template
33
  return $this->_token;
34
  }
35
 
36
- /**
37
- * Is the express mode enabled
38
- *
39
- * @return bool
40
- */
41
- public function isEnabled()
42
- {
43
- if (Mage::getStoreConfig('payment/gene_braintree_paypal/active')
44
- && Mage::getStoreConfig('payment/gene_braintree_paypal/express_active')
45
- ) {
46
- return true;
47
- }
48
-
49
- return false;
50
- }
51
-
52
- /**
53
- * Is express enabled on the product page?
54
- *
55
- * @return bool
56
- */
57
- public function isEnabledPdp()
58
- {
59
- if ($this->isEnabled() && Mage::getStoreConfig('payment/gene_braintree_paypal/express_pdp')) {
60
- return true;
61
- }
62
-
63
- return false;
64
- }
65
-
66
- /**
67
- * Is express enabled in the cart?
68
- *
69
- * @return bool
70
- */
71
- public function isEnabledCart()
72
- {
73
- if ($this->isEnabled() && Mage::getStoreConfig('payment/gene_braintree_paypal/express_cart')) {
74
- return true;
75
- }
76
-
77
- return false;
78
- }
79
-
80
  /**
81
  * Shall we do a single use payment?
82
  *
@@ -153,4 +109,4 @@ class Gene_Braintree_Block_Express_Setup extends Mage_Core_Block_Template
153
 
154
  return $html;
155
  }
156
- }
5
  *
6
  * @author Aidan Threadgold <aidan@gene.co.uk>
7
  */
8
+ class Gene_Braintree_Block_Express_Setup extends Gene_Braintree_Block_Express_Abstract
9
  {
10
  /**
11
  * Braintree token
33
  return $this->_token;
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Shall we do a single use payment?
38
  *
109
 
110
  return $html;
111
  }
112
+ }
app/code/community/Gene/Braintree/Block/Js.php CHANGED
@@ -9,6 +9,7 @@ class Gene_Braintree_Block_Js extends Mage_Core_Block_Template
9
  {
10
  /**
11
  * We can use the same token twice
 
12
  * @var bool
13
  */
14
  private $token = false;
@@ -28,7 +29,7 @@ class Gene_Braintree_Block_Js extends Mage_Core_Block_Template
28
  */
29
  protected function isCreditCardActive()
30
  {
31
- if(is_null($this->creditCardActive)) {
32
  $this->creditCardActive = Mage::getModel('gene_braintree/paymentmethod_creditcard')->isAvailable();
33
  }
34
 
@@ -42,7 +43,7 @@ class Gene_Braintree_Block_Js extends Mage_Core_Block_Template
42
  */
43
  protected function isPayPalActive()
44
  {
45
- if(is_null($this->payPalActive)) {
46
  $this->payPalActive = Mage::getModel('gene_braintree/paymentmethod_paypal')->isAvailable();
47
  }
48
 
@@ -59,6 +60,30 @@ class Gene_Braintree_Block_Js extends Mage_Core_Block_Template
59
  return var_export(Mage::getModel('gene_braintree/paymentmethod_creditcard')->is3DEnabled(), true);
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**
63
  * Is the system set to use hosted fields for credit card processing?
64
  * Hosted Fields is currently the only integration option
@@ -77,9 +102,10 @@ class Gene_Braintree_Block_Js extends Mage_Core_Block_Template
77
  */
78
  protected function getClientToken()
79
  {
80
- if(!$this->token) {
81
  $this->token = Mage::getSingleton('gene_braintree/wrapper_braintree')->init()->generateToken();
82
  }
 
83
  return $this->token;
84
  }
85
 
@@ -91,7 +117,9 @@ class Gene_Braintree_Block_Js extends Mage_Core_Block_Template
91
  protected function getSingleUse()
92
  {
93
  // We prefer to do future payments, so anything else is future
94
- if(Mage::getSingleton('gene_braintree/paymentmethod_paypal')->getPaymentType() == Gene_Braintree_Model_Source_Paypal_Paymenttype::GENE_BRAINTREE_PAYPAL_SINGLE_PAYMENT) {
 
 
95
  return 'true';
96
  }
97
 
@@ -106,14 +134,26 @@ class Gene_Braintree_Block_Js extends Mage_Core_Block_Template
106
  protected function getSingleFutureUse()
107
  {
108
  // We prefer to do future payments, so anything else is future
109
- if(Mage::getSingleton('gene_braintree/paymentmethod_paypal')->getPaymentType() == Gene_Braintree_Model_Source_Paypal_Paymenttype::GENE_BRAINTREE_PAYPAL_FUTURE_PAYMENTS
110
- && !Mage::getModel('gene_braintree/paymentmethod_paypal')->isVaultEnabled()) {
 
111
  return 'true';
112
  }
113
 
114
  return 'false';
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * Return the locale for PayPal
119
  *
@@ -132,8 +172,11 @@ class Gene_Braintree_Block_Js extends Mage_Core_Block_Template
132
  protected function _toHtml()
133
  {
134
  // Check the payment method is active, block duplicate rendering of this block
135
- if(($this->isCreditCardActive() || $this->isPayPalActive()) && !Mage::registry('gene_js_loaded_' . $this->getTemplate())) {
 
 
136
  Mage::register('gene_js_loaded_' . $this->getTemplate(), true);
 
137
  return parent::_toHtml();
138
  }
139
 
9
  {
10
  /**
11
  * We can use the same token twice
12
+ *
13
  * @var bool
14
  */
15
  private $token = false;
29
  */
30
  protected function isCreditCardActive()
31
  {
32
+ if (is_null($this->creditCardActive)) {
33
  $this->creditCardActive = Mage::getModel('gene_braintree/paymentmethod_creditcard')->isAvailable();
34
  }
35
 
43
  */
44
  protected function isPayPalActive()
45
  {
46
+ if (is_null($this->payPalActive)) {
47
  $this->payPalActive = Mage::getModel('gene_braintree/paymentmethod_paypal')->isAvailable();
48
  }
49
 
60
  return var_export(Mage::getModel('gene_braintree/paymentmethod_creditcard')->is3DEnabled(), true);
61
  }
62
 
63
+ /**
64
+ * Is 3D secure limited to specific countries?
65
+ *
66
+ * @return bool
67
+ */
68
+ protected function isThreeDSpecificCountries()
69
+ {
70
+ return Mage::getStoreConfigFlag('payment/gene_braintree_creditcard/threedsecure_allowspecific');
71
+ }
72
+
73
+ /**
74
+ * Return the countries that 3D secure should be present for
75
+ *
76
+ * @return array|mixed
77
+ */
78
+ protected function getThreeDSpecificCountries()
79
+ {
80
+ if (!$this->isThreeDSpecificCountries()) {
81
+ return '';
82
+ }
83
+
84
+ return Mage::getStoreConfig('payment/gene_braintree_creditcard/threedsecure_specificcountry');
85
+ }
86
+
87
  /**
88
  * Is the system set to use hosted fields for credit card processing?
89
  * Hosted Fields is currently the only integration option
102
  */
103
  protected function getClientToken()
104
  {
105
+ if (!$this->token) {
106
  $this->token = Mage::getSingleton('gene_braintree/wrapper_braintree')->init()->generateToken();
107
  }
108
+
109
  return $this->token;
110
  }
111
 
117
  protected function getSingleUse()
118
  {
119
  // We prefer to do future payments, so anything else is future
120
+ if (Mage::getSingleton('gene_braintree/paymentmethod_paypal')->getPaymentType() ==
121
+ Gene_Braintree_Model_Source_Paypal_Paymenttype::GENE_BRAINTREE_PAYPAL_SINGLE_PAYMENT
122
+ ) {
123
  return 'true';
124
  }
125
 
134
  protected function getSingleFutureUse()
135
  {
136
  // We prefer to do future payments, so anything else is future
137
+ if (Mage::getSingleton('gene_braintree/paymentmethod_paypal')->getPaymentType() == Gene_Braintree_Model_Source_Paypal_Paymenttype::GENE_BRAINTREE_PAYPAL_FUTURE_PAYMENTS
138
+ && !Mage::getModel('gene_braintree/paymentmethod_paypal')->isVaultEnabled()
139
+ ) {
140
  return 'true';
141
  }
142
 
143
  return 'false';
144
  }
145
 
146
+ /**
147
+ * Shall we only use Vault flow when the customer selects to store their PayPal account?
148
+ *
149
+ * @return bool
150
+ */
151
+ public function shouldOnlyVaultOnVault()
152
+ {
153
+ return $this->getSingleUse() == 'false' &&
154
+ Mage::getStoreConfigFlag('payment/gene_braintree_paypal/use_vault_only_on_vault');
155
+ }
156
+
157
  /**
158
  * Return the locale for PayPal
159
  *
172
  protected function _toHtml()
173
  {
174
  // Check the payment method is active, block duplicate rendering of this block
175
+ if (($this->isCreditCardActive() || $this->isPayPalActive()) &&
176
+ !Mage::registry('gene_js_loaded_' . $this->getTemplate())
177
+ ) {
178
  Mage::register('gene_js_loaded_' . $this->getTemplate(), true);
179
+
180
  return parent::_toHtml();
181
  }
182
 
app/code/community/Gene/Braintree/Block/Paypal.php CHANGED
@@ -40,7 +40,7 @@ class Gene_Braintree_Block_Paypal extends Mage_Payment_Block_Form
40
  public function getSingleUse()
41
  {
42
  // We prefer to do future payments, so anything else is future
43
- if(Mage::getSingleton('gene_braintree/paymentmethod_paypal')->getPaymentType() == Gene_Braintree_Model_Source_Paypal_Paymenttype::GENE_BRAINTREE_PAYPAL_SINGLE_PAYMENT) {
44
  return 'true';
45
  }
46
 
@@ -54,11 +54,12 @@ class Gene_Braintree_Block_Paypal extends Mage_Payment_Block_Form
54
  */
55
  public function hasSavedDetails()
56
  {
57
- if(Mage::getSingleton('customer/session')->isLoggedIn() || Mage::app()->getStore()->isAdmin()) {
58
- if($this->getSavedDetails()) {
59
  return sizeof($this->getSavedDetails());
60
  }
61
  }
 
62
  return false;
63
  }
64
 
@@ -69,9 +70,10 @@ class Gene_Braintree_Block_Paypal extends Mage_Payment_Block_Form
69
  */
70
  public function getSavedDetails()
71
  {
72
- if(!$this->_savedDetails) {
73
  $this->_savedDetails = Mage::getSingleton('gene_braintree/saved')->getSavedMethodsByType(Gene_Braintree_Model_Saved::SAVED_PAYPAL_ID);
74
  }
 
75
  return $this->_savedDetails;
76
  }
77
 
@@ -84,6 +86,7 @@ class Gene_Braintree_Block_Paypal extends Mage_Payment_Block_Form
84
  {
85
  $html = $this->getChildHtml('saved', false);
86
  $this->unsetChild('saved');
 
87
  return $html;
88
  }
89
 
@@ -96,8 +99,8 @@ class Gene_Braintree_Block_Paypal extends Mage_Payment_Block_Form
96
  {
97
  if ($this->getMethod()->isVaultEnabled()
98
  && (Mage::getSingleton('customer/session')->isLoggedIn()
99
- || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER))
100
- {
101
  return true;
102
  }
103
 
40
  public function getSingleUse()
41
  {
42
  // We prefer to do future payments, so anything else is future
43
+ if (Mage::getSingleton('gene_braintree/paymentmethod_paypal')->getPaymentType() == Gene_Braintree_Model_Source_Paypal_Paymenttype::GENE_BRAINTREE_PAYPAL_SINGLE_PAYMENT) {
44
  return 'true';
45
  }
46
 
54
  */
55
  public function hasSavedDetails()
56
  {
57
+ if (Mage::getSingleton('customer/session')->isLoggedIn() || Mage::app()->getStore()->isAdmin()) {
58
+ if ($this->getSavedDetails()) {
59
  return sizeof($this->getSavedDetails());
60
  }
61
  }
62
+
63
  return false;
64
  }
65
 
70
  */
71
  public function getSavedDetails()
72
  {
73
+ if (!$this->_savedDetails) {
74
  $this->_savedDetails = Mage::getSingleton('gene_braintree/saved')->getSavedMethodsByType(Gene_Braintree_Model_Saved::SAVED_PAYPAL_ID);
75
  }
76
+
77
  return $this->_savedDetails;
78
  }
79
 
86
  {
87
  $html = $this->getChildHtml('saved', false);
88
  $this->unsetChild('saved');
89
+
90
  return $html;
91
  }
92
 
99
  {
100
  if ($this->getMethod()->isVaultEnabled()
101
  && (Mage::getSingleton('customer/session')->isLoggedIn()
102
+ || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER)
103
+ ) {
104
  return true;
105
  }
106
 
app/code/community/Gene/Braintree/Model/Observer.php CHANGED
@@ -262,9 +262,6 @@ class Gene_Braintree_Model_Observer
262
  */
263
  public static function initIncludePath()
264
  {
265
- // Check to see if the system can resolve the Braintree_Version class
266
- if (!stream_resolve_include_path('Braintree/Version.php')) {
267
- set_include_path(BP . DS . 'lib' . DS . 'Gene' . PS . get_include_path());
268
- }
269
  }
270
  }
262
  */
263
  public static function initIncludePath()
264
  {
265
+ require_once(Mage::getBaseDir('lib') . DS . 'Gene' . DS . 'Braintree' . DS . 'autoload.php');
 
 
 
266
  }
267
  }
app/code/community/Gene/Braintree/Model/Paymentmethod/Creditcard.php CHANGED
@@ -120,24 +120,33 @@ class Gene_Braintree_Model_Paymentmethod_Creditcard extends Gene_Braintree_Model
120
  return false;
121
  }
122
 
123
- // Is 3Ds enabled within the configuration?
124
- if ($this->_getConfig('threedsecure')) {
125
- // Do we have a requirement on the threshold
126
- if ($this->_getConfig('threedsecure_threshold') > 0) {
127
- // Check to see if the base grand total is bigger then the threshold
128
- if (Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getBaseGrandTotal() >
129
- $this->_getConfig('threedsecure_threshold')
130
- ) {
131
- return true;
132
- }
133
 
134
- return false;
135
- }
136
 
137
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  }
139
 
140
- return false;
141
  }
142
 
143
  /**
@@ -275,6 +284,11 @@ class Gene_Braintree_Model_Paymentmethod_Creditcard extends Gene_Braintree_Model
275
  );
276
 
277
  } catch (Exception $e) {
 
 
 
 
 
278
  // Handle an exception being thrown
279
  Mage::dispatchEvent('gene_braintree_creditcard_failed_exception', array(
280
  'payment' => $payment,
120
  return false;
121
  }
122
 
123
+ /* @var $quote Mage_Sales_Model_Quote */
124
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
 
 
 
 
 
 
 
 
125
 
126
+ // Is 3D secure currently enabled?
127
+ $result = $this->_getConfig('threedsecure');
128
 
129
+ // Do we have a requirement on the threshold
130
+ if ($result && $this->_getConfig('threedsecure_threshold') > 0) {
131
+ // Check to see if the base grand total is bigger then the threshold
132
+ $result = $quote->collectTotals()->getBaseGrandTotal() >
133
+ $this->_getConfig('threedsecure_threshold');
134
+ }
135
+
136
+ // Do we only want to enable 3Ds for specific countries?
137
+ if ($result && $this->_getConfig('threedsecure_allowspecific') ==
138
+ Gene_Braintree_Model_System_Config_Source_Payment_Threedsecurecountries::SPECIFIC_COUNTRIES
139
+ ) {
140
+ $countries = $this->_getConfig('threedsecure_specificcountry');
141
+ if ($countries) {
142
+ $countriesArray = explode(',', $countries);
143
+ if (count($countriesArray) >= 1) {
144
+ $result = in_array($quote->getBillingAddress()->getCountryId(), $countriesArray);
145
+ }
146
+ }
147
  }
148
 
149
+ return ($result == 1 ? true : false);
150
  }
151
 
152
  /**
284
  );
285
 
286
  } catch (Exception $e) {
287
+ // If we're in developer mode return the message error
288
+ if (Mage::getIsDeveloperMode()) {
289
+ return $this->_processFailedResult($e->getMessage());
290
+ }
291
+
292
  // Handle an exception being thrown
293
  Mage::dispatchEvent('gene_braintree_creditcard_failed_exception', array(
294
  'payment' => $payment,
app/code/community/Gene/Braintree/Model/Paymentmethod/Paypal.php CHANGED
@@ -231,12 +231,22 @@ class Gene_Braintree_Model_Paymentmethod_Paypal extends Gene_Braintree_Model_Pay
231
  $this->shouldSaveMethod($payment)
232
  );
233
 
 
 
 
 
 
234
  // Attempt to make the sale, firstly dispatching an event
235
  $result = $this->_getWrapper()->makeSale(
236
  $this->_dispatchSaleArrayEvent('gene_braintree_paypal_sale_array', $saleArray, $payment)
237
  );
238
 
239
  } catch (Exception $e) {
 
 
 
 
 
240
  // Dispatch an event for when a payment fails
241
  Mage::dispatchEvent('gene_braintree_paypal_failed_exception', array('payment' => $payment, 'exception' => $e));
242
 
@@ -259,6 +269,20 @@ class Gene_Braintree_Model_Paymentmethod_Paypal extends Gene_Braintree_Model_Pay
259
  return $this;
260
  }
261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  /**
263
  * Build up the payment request
264
  *
231
  $this->shouldSaveMethod($payment)
232
  );
233
 
234
+ // Detect a custom payee email from the configuration
235
+ if ($email = $this->hasCustomPayeeEmail()) {
236
+ $saleArray['options']['payeeEmail'] = $email;
237
+ }
238
+
239
  // Attempt to make the sale, firstly dispatching an event
240
  $result = $this->_getWrapper()->makeSale(
241
  $this->_dispatchSaleArrayEvent('gene_braintree_paypal_sale_array', $saleArray, $payment)
242
  );
243
 
244
  } catch (Exception $e) {
245
+ // If we're in developer mode return the message error
246
+ if (Mage::getIsDeveloperMode()) {
247
+ return $this->_processFailedResult($e->getMessage());
248
+ }
249
+
250
  // Dispatch an event for when a payment fails
251
  Mage::dispatchEvent('gene_braintree_paypal_failed_exception', array('payment' => $payment, 'exception' => $e));
252
 
269
  return $this;
270
  }
271
 
272
+ /**
273
+ * Does the current store have a custom payee email attached?
274
+ *
275
+ * @return bool|mixed
276
+ */
277
+ protected function hasCustomPayeeEmail()
278
+ {
279
+ if ($this->_getConfig('payee_email_active') && ($email = $this->_getConfig('payee_email'))) {
280
+ return $email;
281
+ }
282
+
283
+ return false;
284
+ }
285
+
286
  /**
287
  * Build up the payment request
288
  *
app/code/community/Gene/Braintree/Model/System/Config/Source/Payment/Threedsecurecountries.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Gene_Braintree_Model_System_Config_Source_Payment_Threedsecurecountries
5
+ *
6
+ * @author Dave Macaulay <dave@gene.co.uk>
7
+ */
8
+ class Gene_Braintree_Model_System_Config_Source_Payment_Threedsecurecountries
9
+ {
10
+ const ALL_COUNTRIES = 0;
11
+ const SPECIFIC_COUNTRIES = 1;
12
+
13
+ /**
14
+ * Return options for 3D secure specific countries option
15
+ *
16
+ * @return array
17
+ */
18
+ public function toOptionArray()
19
+ {
20
+ return array(
21
+ array('value' => self::ALL_COUNTRIES, 'label' => Mage::helper('adminhtml')->__('All Countries')),
22
+ array('value' => self::SPECIFIC_COUNTRIES, 'label' => Mage::helper('adminhtml')->__('Specific Countries')),
23
+ );
24
+ }
25
+ }
app/code/community/Gene/Braintree/Model/Wrapper/Braintree.php CHANGED
@@ -154,7 +154,6 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
154
  try {
155
  // Check to see that we can generate a braintree ID
156
  if ($braintreeId = $this->getBraintreeId()) {
157
-
158
  // Proxy this request to the other method which has caching
159
  return $this->getCustomer($braintreeId);
160
  }
@@ -233,12 +232,27 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
233
  */
234
  protected function getBraintreeId()
235
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  // Some basic caching
237
  if (!$this->_braintreeId) {
238
-
239
  // Is the customer already logged in
240
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
241
-
242
  // Retrieve the current customer
243
  $customer = Mage::getSingleton('customer/session')->getCustomer();
244
 
@@ -252,8 +266,9 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
252
  }
253
 
254
  } else {
255
- if ((Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == 'login_in' || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER)) {
256
-
 
257
  // Check to see if we've already generated an ID
258
  if ($braintreeId = Mage::getSingleton('checkout/session')->getBraintreeCustomerId()) {
259
  $this->_braintreeId = $braintreeId;
@@ -311,12 +326,12 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
311
  * @return bool|string
312
  * @throws \Exception
313
  */
314
- public function validateCredentials($prettyResponse = false, $alreadyInit = false, $merchantAccountId = false, $throwException = false)
315
- {
 
316
  // Try to init the environment
317
  try {
318
  if (!$alreadyInit) {
319
-
320
  // If we're within the admin we want to grab these values from whichever store we're modifying
321
  if (Mage::app()->getStore()->isAdmin()) {
322
  // Setup the various configuration variables
@@ -344,7 +359,6 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
344
  Braintree_Configuration::gateway()->plan()->all();
345
 
346
  } catch (Exception $e) {
347
-
348
  // Do we want to rethrow the exception?
349
  if ($throwException) {
350
  throw $e;
@@ -381,7 +395,6 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
381
  try {
382
  Braintree_Configuration::gateway()->merchantAccount()->find($merchantAccountId);
383
  } catch (Exception $e) {
384
-
385
  // Do we want to rethrow the exception?
386
  if ($throwException) {
387
  throw $e;
@@ -416,12 +429,10 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
416
  {
417
  // Check to see if it's been validated yet
418
  if (is_null($this->_validated)) {
419
-
420
  // Check the Braintree lib version is above 2.32, as this is when 3D secure appeared
421
  if (Braintree_Version::get() < 2.32) {
422
  $this->_validated = false;
423
  } else {
424
-
425
  // Check that the module is fully setup
426
  if (!$this->_validateConfiguration()) {
427
  // If not the payment methods aren't available
@@ -451,7 +462,7 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
451
  return Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_MERCHANT_ID_PATH)
452
  && Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_PUBLIC_KEY_PATH)
453
  && Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_PRIVATE_KEY_PATH);
454
- } else if ($environment == Gene_Braintree_Model_Source_Environment::SANDBOX) {
455
  return Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_SANDBOX_MERCHANT_ID_PATH)
456
  && Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_SANDBOX_PUBLIC_KEY_PATH)
457
  && Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_SANDBOX_PRIVATE_KEY_PATH);
@@ -485,13 +496,11 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
485
 
486
  // Include billing address information into the payment method
487
  if ($billingAddress) {
488
-
489
  // Add in the billing address
490
  $paymentMethodCreate['billingAddress'] = $billingAddress;
491
 
492
  // Pass over some extra details from the billing address
493
  $paymentMethodCreate['cardholderName'] = $billingAddress['firstName'] . ' ' . $billingAddress['lastName'];
494
-
495
  }
496
 
497
  // Dispatch an event to allow modification of the store in vault
@@ -527,7 +536,6 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
527
 
528
  // Include billing address information into the customer
529
  if ($billingAddress) {
530
-
531
  // Add in the billing address
532
  $guestCustomerCreate['creditCard']['cardholderName'] = $billingAddress['firstName'] . ' ' . $billingAddress['lastName'];
533
  $guestCustomerCreate['creditCard']['billingAddress'] = $billingAddress;
@@ -546,7 +554,6 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
546
  if (isset($billingAddress['phone']) && !empty($billingAddress['phone'])) {
547
  $guestCustomerCreate['phone'] = $billingAddress['phone'];
548
  }
549
-
550
  }
551
 
552
  // Dispatch an event to allow modification of the store in vault
@@ -612,8 +619,7 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
612
  $storeInVault = false,
613
  $threeDSecure = false,
614
  $extra = array()
615
- )
616
- {
617
  // Check we always have an ID
618
  if (!$order->getIncrementId()) {
619
  Mage::throwException('Your order has become invalid, please try refreshing.');
@@ -623,10 +629,11 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
623
  $createdMethod = false;
624
 
625
  // Are we storing in the vault, from a guest customer account?
626
- if ($storeInVault && Mage::getSingleton('checkout/session')->getGuestBraintreeCustomerId() && ($token = Mage::getSingleton('checkout/session')->getGuestPaymentToken())) {
627
-
 
 
628
  if ($this->checkPaymentMethod($token)) {
629
-
630
  // Remove this from the session so it doesn't get deleted at the end of checkout
631
  Mage::getSingleton('checkout/session')->unsGuestBraintreeCustomerId();
632
  Mage::getSingleton('checkout/session')->unsGuestPaymentToken();
@@ -639,25 +646,30 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
639
 
640
  // Create a flag for other methods
641
  $createdMethod = true;
642
-
643
  } else {
644
  // If the method doesn't exist, clear the token and re-build the sale
645
  Mage::getSingleton('checkout/session')->unsGuestPaymentToken();
646
 
647
- return $this->buildSale($amount, $paymentDataArray, $order, $submitForSettlement, $deviceData, $storeInVault, $threeDSecure, $extra);
 
 
 
 
 
 
 
 
 
648
  }
649
-
650
- } else if ($storeInVault && $this->checkIsCustomer() && isset($paymentDataArray['paymentMethodNonce'])) {
651
  // If the user is already a customer and wants to store in the vault we've gotta do something a bit special
652
-
653
  // Do we already have a saved token in the session?
654
  if ($token = Mage::getSingleton('checkout/session')->getTemporaryPaymentToken()) {
655
-
656
  if ($this->checkPaymentMethod($token)) {
657
-
658
  // Is the submitted nonce different?
659
  if (Mage::getSingleton('checkout/session')->getVaultedNonce() == $paymentDataArray['paymentMethodNonce']) {
660
-
661
  // Remove this from the session so it doesn't get deleted at the end of checkout
662
  Mage::getSingleton('checkout/session')->unsTemporaryPaymentToken();
663
 
@@ -671,10 +683,8 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
671
  $createdMethod = true;
672
 
673
  } else {
674
-
675
  // Store it again with the 3Ds information
676
  $storeInVault = true;
677
-
678
  }
679
 
680
  } else {
@@ -685,7 +695,7 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
685
  }
686
 
687
  } else {
688
-
689
  // Create the payment method with this data
690
  $paymentMethodCreate = array(
691
  'customerId' => $this->getBraintreeId(),
@@ -704,13 +714,10 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
704
 
705
  // Verify the storing of the card was a success
706
  if (isset($result->success) && $result->success == true) {
707
-
708
  /* @var $paymentMethod Braintree_CreditCard */
709
  $paymentMethod = $result->paymentMethod;
710
-
711
  // Check to see if the token is set
712
  if (isset($paymentMethod->token) && !empty($paymentMethod->token)) {
713
-
714
  // We no longer need this nonce
715
  unset($paymentDataArray['paymentMethodNonce']);
716
 
@@ -720,20 +727,21 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
720
  // Create a flag for other methods
721
  $createdMethod = true;
722
  }
723
-
724
  } else {
725
  Mage::throwException($result->message . Mage::helper('gene_braintree')->__(' Please try again or attempt refreshing the page.'));
726
  }
727
-
728
  }
729
  }
730
 
 
 
 
731
  // Build up the initial request parameters
732
  $request = array(
733
  'amount' => $amount,
734
  'orderId' => $order->getIncrementId(),
735
  'merchantAccountId' => $this->getMerchantAccountId($order),
736
- 'channel' => 'MagentoVZero',
737
  'options' => array(
738
  'submitForSettlement' => $submitForSettlement,
739
  'storeInVault' => $storeInVault
@@ -759,6 +767,9 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
759
  (Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == 'login_in' || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER))
760
  ) {
761
  $request['customer'] = $this->buildCustomer($order);
 
 
 
762
  } else {
763
  // If the customer exists but we aren't using the vault we want to pass a customer object with no ID
764
  $request['customer'] = $this->buildCustomer($order, false);
@@ -781,7 +792,7 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
781
 
782
  // Is 3D secure enabled?
783
  if ($threeDSecure !== false && !$createdMethod) {
784
- $request['options']['three_d_secure']['required'] = true;
785
  }
786
 
787
  // Include level 2 data if the user has provided a VAT ID
@@ -791,6 +802,11 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
791
  $request['purchaseOrderNumber'] = $order->getIncrementId();
792
  }
793
 
 
 
 
 
 
794
  // Any extra information we want to supply
795
  if (!empty($extra) && is_array($extra)) {
796
  $request = array_merge($request, $extra);
@@ -1191,9 +1207,9 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
1191
  $apiStatus->setPlainValue($status)->save();
1192
  } else {
1193
  Mage::getModel('core/variable')->setData(array(
1194
- 'code' => self::BRAINTREE_API_CONFIG_STATUS,
1195
- 'name' => self::BRAINTREE_API_CONFIG_STATUS,
1196
- 'store_id' => $storeId,
1197
  'plain_value' => $status
1198
  ))->save();
1199
  }
@@ -1219,7 +1235,6 @@ class Gene_Braintree_Model_Wrapper_Braintree extends Mage_Core_Model_Abstract
1219
  return $this->validateCredentials();
1220
  }
1221
 
1222
- return (bool) $apiStatus;
1223
  }
1224
-
1225
- }
154
  try {
155
  // Check to see that we can generate a braintree ID
156
  if ($braintreeId = $this->getBraintreeId()) {
 
157
  // Proxy this request to the other method which has caching
158
  return $this->getCustomer($braintreeId);
159
  }
232
  */
233
  protected function getBraintreeId()
234
  {
235
+ // Retrieve the Braintree ID from the admin quote
236
+ if (Mage::app()->getStore()->isAdmin()) {
237
+ // Get the admin quote
238
+ $quote = $this->getQuote();
239
+ $customer = $quote->getCustomer();
240
+
241
+ // Determine whether they have a Braintree customer ID already
242
+ if ($brainteeId = $customer->getBraintreeCustomerId()) {
243
+ return $brainteeId;
244
+ }
245
+
246
+ // If not let's create them one
247
+ $brainteeId = $this->buildCustomerId();
248
+ $customer->setBraintreeCustomerId($brainteeId)->save();
249
+ return $brainteeId;
250
+ }
251
+
252
  // Some basic caching
253
  if (!$this->_braintreeId) {
 
254
  // Is the customer already logged in
255
  if (Mage::getSingleton('customer/session')->isLoggedIn()) {
 
256
  // Retrieve the current customer
257
  $customer = Mage::getSingleton('customer/session')->getCustomer();
258
 
266
  }
267
 
268
  } else {
269
+ if ((Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == 'login_in' ||
270
+ Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER)
271
+ ) {
272
  // Check to see if we've already generated an ID
273
  if ($braintreeId = Mage::getSingleton('checkout/session')->getBraintreeCustomerId()) {
274
  $this->_braintreeId = $braintreeId;
326
  * @return bool|string
327
  * @throws \Exception
328
  */
329
+ public function validateCredentials(
330
+ $prettyResponse = false, $alreadyInit = false, $merchantAccountId = false, $throwException = false
331
+ ) {
332
  // Try to init the environment
333
  try {
334
  if (!$alreadyInit) {
 
335
  // If we're within the admin we want to grab these values from whichever store we're modifying
336
  if (Mage::app()->getStore()->isAdmin()) {
337
  // Setup the various configuration variables
359
  Braintree_Configuration::gateway()->plan()->all();
360
 
361
  } catch (Exception $e) {
 
362
  // Do we want to rethrow the exception?
363
  if ($throwException) {
364
  throw $e;
395
  try {
396
  Braintree_Configuration::gateway()->merchantAccount()->find($merchantAccountId);
397
  } catch (Exception $e) {
 
398
  // Do we want to rethrow the exception?
399
  if ($throwException) {
400
  throw $e;
429
  {
430
  // Check to see if it's been validated yet
431
  if (is_null($this->_validated)) {
 
432
  // Check the Braintree lib version is above 2.32, as this is when 3D secure appeared
433
  if (Braintree_Version::get() < 2.32) {
434
  $this->_validated = false;
435
  } else {
 
436
  // Check that the module is fully setup
437
  if (!$this->_validateConfiguration()) {
438
  // If not the payment methods aren't available
462
  return Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_MERCHANT_ID_PATH)
463
  && Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_PUBLIC_KEY_PATH)
464
  && Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_PRIVATE_KEY_PATH);
465
+ } elseif ($environment == Gene_Braintree_Model_Source_Environment::SANDBOX) {
466
  return Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_SANDBOX_MERCHANT_ID_PATH)
467
  && Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_SANDBOX_PUBLIC_KEY_PATH)
468
  && Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_SANDBOX_PRIVATE_KEY_PATH);
496
 
497
  // Include billing address information into the payment method
498
  if ($billingAddress) {
 
499
  // Add in the billing address
500
  $paymentMethodCreate['billingAddress'] = $billingAddress;
501
 
502
  // Pass over some extra details from the billing address
503
  $paymentMethodCreate['cardholderName'] = $billingAddress['firstName'] . ' ' . $billingAddress['lastName'];
 
504
  }
505
 
506
  // Dispatch an event to allow modification of the store in vault
536
 
537
  // Include billing address information into the customer
538
  if ($billingAddress) {
 
539
  // Add in the billing address
540
  $guestCustomerCreate['creditCard']['cardholderName'] = $billingAddress['firstName'] . ' ' . $billingAddress['lastName'];
541
  $guestCustomerCreate['creditCard']['billingAddress'] = $billingAddress;
554
  if (isset($billingAddress['phone']) && !empty($billingAddress['phone'])) {
555
  $guestCustomerCreate['phone'] = $billingAddress['phone'];
556
  }
 
557
  }
558
 
559
  // Dispatch an event to allow modification of the store in vault
619
  $storeInVault = false,
620
  $threeDSecure = false,
621
  $extra = array()
622
+ ) {
 
623
  // Check we always have an ID
624
  if (!$order->getIncrementId()) {
625
  Mage::throwException('Your order has become invalid, please try refreshing.');
629
  $createdMethod = false;
630
 
631
  // Are we storing in the vault, from a guest customer account?
632
+ if ($storeInVault && Mage::getSingleton('checkout/session')->getGuestBraintreeCustomerId() &&
633
+ ($token = Mage::getSingleton('checkout/session')->getGuestPaymentToken())
634
+ ) {
635
+ echo '1';
636
  if ($this->checkPaymentMethod($token)) {
 
637
  // Remove this from the session so it doesn't get deleted at the end of checkout
638
  Mage::getSingleton('checkout/session')->unsGuestBraintreeCustomerId();
639
  Mage::getSingleton('checkout/session')->unsGuestPaymentToken();
646
 
647
  // Create a flag for other methods
648
  $createdMethod = true;
 
649
  } else {
650
  // If the method doesn't exist, clear the token and re-build the sale
651
  Mage::getSingleton('checkout/session')->unsGuestPaymentToken();
652
 
653
+ return $this->buildSale(
654
+ $amount,
655
+ $paymentDataArray,
656
+ $order,
657
+ $submitForSettlement,
658
+ $deviceData,
659
+ $storeInVault,
660
+ $threeDSecure,
661
+ $extra
662
+ );
663
  }
664
+ } elseif ($storeInVault && $this->checkIsCustomer() && isset($paymentDataArray['paymentMethodNonce'])) {
665
+ echo '2';
666
  // If the user is already a customer and wants to store in the vault we've gotta do something a bit special
 
667
  // Do we already have a saved token in the session?
668
  if ($token = Mage::getSingleton('checkout/session')->getTemporaryPaymentToken()) {
669
+ echo '3';
670
  if ($this->checkPaymentMethod($token)) {
 
671
  // Is the submitted nonce different?
672
  if (Mage::getSingleton('checkout/session')->getVaultedNonce() == $paymentDataArray['paymentMethodNonce']) {
 
673
  // Remove this from the session so it doesn't get deleted at the end of checkout
674
  Mage::getSingleton('checkout/session')->unsTemporaryPaymentToken();
675
 
683
  $createdMethod = true;
684
 
685
  } else {
 
686
  // Store it again with the 3Ds information
687
  $storeInVault = true;
 
688
  }
689
 
690
  } else {
695
  }
696
 
697
  } else {
698
+ echo '4';
699
  // Create the payment method with this data
700
  $paymentMethodCreate = array(
701
  'customerId' => $this->getBraintreeId(),
714
 
715
  // Verify the storing of the card was a success
716
  if (isset($result->success) && $result->success == true) {
 
717
  /* @var $paymentMethod Braintree_CreditCard */
718
  $paymentMethod = $result->paymentMethod;
 
719
  // Check to see if the token is set
720
  if (isset($paymentMethod->token) && !empty($paymentMethod->token)) {
 
721
  // We no longer need this nonce
722
  unset($paymentDataArray['paymentMethodNonce']);
723
 
727
  // Create a flag for other methods
728
  $createdMethod = true;
729
  }
 
730
  } else {
731
  Mage::throwException($result->message . Mage::helper('gene_braintree')->__(' Please try again or attempt refreshing the page.'));
732
  }
 
733
  }
734
  }
735
 
736
+ // Pass the version through in the channel parameter
737
+ $channel = 'GeneVZero_' . Mage::getConfig()->getModuleConfig('Gene_Braintree')->version;
738
+
739
  // Build up the initial request parameters
740
  $request = array(
741
  'amount' => $amount,
742
  'orderId' => $order->getIncrementId(),
743
  'merchantAccountId' => $this->getMerchantAccountId($order),
744
+ 'channel' => $channel,
745
  'options' => array(
746
  'submitForSettlement' => $submitForSettlement,
747
  'storeInVault' => $storeInVault
767
  (Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == 'login_in' || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER))
768
  ) {
769
  $request['customer'] = $this->buildCustomer($order);
770
+ } elseif (!$this->checkIsCustomer() && Mage::app()->getStore()->isAdmin() && $storeInVault) {
771
+ // Do we need to build a customer account from an admin request?
772
+ $request['customer'] = $this->buildCustomer($order);
773
  } else {
774
  // If the customer exists but we aren't using the vault we want to pass a customer object with no ID
775
  $request['customer'] = $this->buildCustomer($order, false);
792
 
793
  // Is 3D secure enabled?
794
  if ($threeDSecure !== false && !$createdMethod) {
795
+ $request['options']['threeDSecure']['required'] = true;
796
  }
797
 
798
  // Include level 2 data if the user has provided a VAT ID
802
  $request['purchaseOrderNumber'] = $order->getIncrementId();
803
  }
804
 
805
+ // If the order is being created in the admin, set the source as moto
806
+ if (Mage::app()->getStore()->isAdmin()) {
807
+ $request['transactionSource'] = 'moto';
808
+ }
809
+
810
  // Any extra information we want to supply
811
  if (!empty($extra) && is_array($extra)) {
812
  $request = array_merge($request, $extra);
1207
  $apiStatus->setPlainValue($status)->save();
1208
  } else {
1209
  Mage::getModel('core/variable')->setData(array(
1210
+ 'code' => self::BRAINTREE_API_CONFIG_STATUS,
1211
+ 'name' => self::BRAINTREE_API_CONFIG_STATUS,
1212
+ 'store_id' => $storeId,
1213
  'plain_value' => $status
1214
  ))->save();
1215
  }
1235
  return $this->validateCredentials();
1236
  }
1237
 
1238
+ return (bool)$apiStatus;
1239
  }
1240
+ }
 
app/code/community/Gene/Braintree/controllers/CheckoutController.php CHANGED
@@ -15,11 +15,13 @@ class Gene_Braintree_CheckoutController extends Mage_Core_Controller_Front_Actio
15
  public function quoteTotalAction()
16
  {
17
  // Grab the quote
 
18
  $quote = Mage::getSingleton('checkout/type_onepage')->getQuote();
19
 
20
  // Retrieve the billing information from the quote
21
  $billingName = $quote->getBillingAddress()->getName();
22
  $billingPostcode = $quote->getBillingAddress()->getPostcode();
 
23
 
24
  // Has the request supplied the billing address ID?
25
  if ($addressId = $this->getRequest()->getParam('addressId') &&
@@ -32,6 +34,7 @@ class Gene_Braintree_CheckoutController extends Mage_Core_Controller_Front_Actio
32
  if ($billingAddress && $billingAddress->getId()) {
33
  $billingName = $billingAddress->getName();
34
  $billingPostcode = $billingAddress->getPostcode();
 
35
  }
36
 
37
  }
@@ -47,11 +50,12 @@ class Gene_Braintree_CheckoutController extends Mage_Core_Controller_Front_Actio
47
 
48
  // Build up our JSON response
49
  $jsonResponse = array(
50
- 'billingName' => $billingName,
51
- 'billingPostcode' => $billingPostcode,
52
- 'grandTotal' => Mage::helper('gene_braintree')->formatPrice($grandTotal),
53
- 'currencyCode' => $currencyCode,
54
- 'threeDSecure' => Mage::getSingleton('gene_braintree/paymentmethod_creditcard')->is3DEnabled()
 
55
  );
56
 
57
  return $this->_returnJson($jsonResponse);
15
  public function quoteTotalAction()
16
  {
17
  // Grab the quote
18
+ /* @var $quote Mage_Sales_Model_Quote */
19
  $quote = Mage::getSingleton('checkout/type_onepage')->getQuote();
20
 
21
  // Retrieve the billing information from the quote
22
  $billingName = $quote->getBillingAddress()->getName();
23
  $billingPostcode = $quote->getBillingAddress()->getPostcode();
24
+ $billingCountryId = $quote->getBillingAddress()->getCountryId();
25
 
26
  // Has the request supplied the billing address ID?
27
  if ($addressId = $this->getRequest()->getParam('addressId') &&
34
  if ($billingAddress && $billingAddress->getId()) {
35
  $billingName = $billingAddress->getName();
36
  $billingPostcode = $billingAddress->getPostcode();
37
+ $billingCountryId = $billingAddress->getCountryId();
38
  }
39
 
40
  }
50
 
51
  // Build up our JSON response
52
  $jsonResponse = array(
53
+ 'billingName' => $billingName,
54
+ 'billingPostcode' => $billingPostcode,
55
+ 'billingCountryId' => $billingCountryId,
56
+ 'grandTotal' => Mage::helper('gene_braintree')->formatPrice($grandTotal),
57
+ 'currencyCode' => $currencyCode,
58
+ 'threeDSecure' => Mage::getSingleton('gene_braintree/paymentmethod_creditcard')->is3DEnabled()
59
  );
60
 
61
  return $this->_returnJson($jsonResponse);
app/code/community/Gene/Braintree/controllers/ExpressController.php CHANGED
@@ -192,17 +192,21 @@ class Gene_Braintree_ExpressController extends Mage_Core_Controller_Front_Action
192
  $quote = $this->_getQuote();
193
  $quote->setTotalsCollectedFlag(false)->collectTotals()->save();
194
 
195
- // collect shipping rates
196
- $quote->getShippingAddress()->removeAllShippingRates();
197
- $quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates();
 
 
 
198
 
199
- // Get the shipping rates
200
- $shippingRates = $quote->getShippingAddress()->getShippingRatesCollection();
 
 
201
 
202
  // Save the shipping method
203
  $submitShipping = $this->getRequest()->getParam('submit_shipping');
204
  if (!empty($submitShipping)) {
205
-
206
  // If the quote is virtual process the order without a shipping method
207
  if ($quote->isVirtual()) {
208
  return $this->_redirect("braintree/express/process");
@@ -222,9 +226,6 @@ class Gene_Braintree_ExpressController extends Mage_Core_Controller_Front_Action
222
  Mage::getSingleton('core/session')->addWarning(Mage::helper('gene_braintree')->__('Please select a shipping method.'));
223
  }
224
 
225
- // Recollect the totals
226
- $quote->setTotalsCollectedFlag(false)->collectTotals();
227
-
228
  // Build up the totals block
229
  /* @var $totals Mage_Checkout_Block_Cart_Totals */
230
  $totals = $this->getLayout()->createBlock('checkout/cart_totals')
@@ -258,7 +259,6 @@ class Gene_Braintree_ExpressController extends Mage_Core_Controller_Front_Action
258
  // Save the shipping method
259
  $submitShipping = $this->getRequest()->getParam('submit_shipping');
260
  if (!empty($submitShipping)) {
261
-
262
  // Check the shipping rate we want to use is available
263
  $method = $this->getRequest()->getParam('shipping_method');
264
  if (!empty($method) && $quote->getShippingAddress()->getShippingRateByCode($method)) {
@@ -452,5 +452,4 @@ class Gene_Braintree_ExpressController extends Mage_Core_Controller_Front_Action
452
 
453
  return $this;
454
  }
455
-
456
- }
192
  $quote = $this->_getQuote();
193
  $quote->setTotalsCollectedFlag(false)->collectTotals()->save();
194
 
195
+ // Recollect all totals for the quote
196
+ $quote->setTotalsCollectedFlag(false);
197
+ $quote->getBillingAddress();
198
+ $quote->getShippingAddress()->setCollectShippingRates(true);
199
+ $quote->collectTotals();
200
+ $quote->save();
201
 
202
+ // Pull out the shipping rates
203
+ $shippingRates = $quote->getShippingAddress()
204
+ ->collectShippingRates()
205
+ ->getAllShippingRates();
206
 
207
  // Save the shipping method
208
  $submitShipping = $this->getRequest()->getParam('submit_shipping');
209
  if (!empty($submitShipping)) {
 
210
  // If the quote is virtual process the order without a shipping method
211
  if ($quote->isVirtual()) {
212
  return $this->_redirect("braintree/express/process");
226
  Mage::getSingleton('core/session')->addWarning(Mage::helper('gene_braintree')->__('Please select a shipping method.'));
227
  }
228
 
 
 
 
229
  // Build up the totals block
230
  /* @var $totals Mage_Checkout_Block_Cart_Totals */
231
  $totals = $this->getLayout()->createBlock('checkout/cart_totals')
259
  // Save the shipping method
260
  $submitShipping = $this->getRequest()->getParam('submit_shipping');
261
  if (!empty($submitShipping)) {
 
262
  // Check the shipping rate we want to use is available
263
  $method = $this->getRequest()->getParam('shipping_method');
264
  if (!empty($method) && $quote->getShippingAddress()->getShippingRateByCode($method)) {
452
 
453
  return $this;
454
  }
455
+ }
 
app/code/community/Gene/Braintree/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Gene_Braintree>
5
- <version>2.1.2</version>
6
  </Gene_Braintree>
7
  </modules>
8
  <global>
@@ -90,6 +90,7 @@
90
  <payment_type>single</payment_type>
91
  <use_vault>0</use_vault>
92
  <locale>en_gb</locale>
 
93
  </gene_braintree_paypal>
94
 
95
  <!-- Credit Card method -->
2
  <config>
3
  <modules>
4
  <Gene_Braintree>
5
+ <version>2.1.3</version>
6
  </Gene_Braintree>
7
  </modules>
8
  <global>
90
  <payment_type>single</payment_type>
91
  <use_vault>0</use_vault>
92
  <locale>en_gb</locale>
93
+ <payee_email_active>0</payee_email_active>
94
  </gene_braintree_paypal>
95
 
96
  <!-- Credit Card method -->
app/code/community/Gene/Braintree/etc/system.xml CHANGED
@@ -4,16 +4,23 @@
4
  <payment>
5
  <groups>
6
  <gene_braintree translate="label comment" module="gene_braintree">
7
- <label>Braintree v.zero - Configuration</label>
8
  <sort_order>1498</sort_order>
9
  <show_in_default>1</show_in_default>
10
  <show_in_website>1</show_in_website>
11
  <show_in_store>1</show_in_store>
12
- <comment><![CDATA[<img src="https://i.imgur.com/JR1BJTr.png" style="margin: 4px 0 8px 0;" border="0"/><br />To use this module you will need an existing production or sandbox Braintree account. You can apply at <a href="https://www.braintreepayments.com">braintreepayments.com</a>.<br />Braintree v.zero integration provided by <a href="http://gene.co.uk/" target="_blank">Gene Commerce</a>.]]></comment>
 
 
 
 
 
 
 
13
  <fields>
14
 
15
  <module_version translate="label">
16
- <label>Magento Braintree v.zero Version</label>
17
  <frontend_model>gene_braintree/adminhtml_system_config_braintree_moduleversion</frontend_model>
18
  <sort_order>20</sort_order>
19
  <show_in_default>1</show_in_default>
@@ -248,12 +255,15 @@
248
  </gene_braintree>
249
 
250
  <gene_braintree_paypal translate="label comment" module="gene_braintree">
251
- <label>Braintree v.zero - PayPal</label>
252
  <sort_order>1499</sort_order>
253
  <show_in_default>1</show_in_default>
254
  <show_in_website>1</show_in_website>
255
  <show_in_store>1</show_in_store>
256
- <comment><![CDATA[<img src="https://i.imgur.com/sitDbHA.png" style="margin: 6px 0;" /><br />You must first configure the <strong>Braintree v.zero - Configuration</strong> section with your Braintree account details.]]></comment>
 
 
 
257
  <fields>
258
 
259
  <active translate="label">
@@ -275,7 +285,6 @@
275
  <show_in_store>1</show_in_store>
276
  </title>
277
 
278
-
279
  <express_heading translate="label">
280
  <label>Paypal Express</label>
281
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -381,6 +390,34 @@
381
  <show_in_store>1</show_in_store>
382
  </order_status>
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  <features_heading translate="label">
385
  <label>Features</label>
386
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -421,6 +458,23 @@
421
  ]]></comment>
422
  </use_vault>
423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
424
  <locale translate="label comment">
425
  <label>Locale</label>
426
  <frontend_type>select</frontend_type>
@@ -476,12 +530,18 @@
476
  </gene_braintree_paypal>
477
 
478
  <gene_braintree_creditcard translate="label comment" module="gene_braintree">
479
- <label>Braintree v.zero - Credit Card</label>
480
  <sort_order>1500</sort_order>
481
  <show_in_default>1</show_in_default>
482
  <show_in_website>1</show_in_website>
483
  <show_in_store>1</show_in_store>
484
- <comment><![CDATA[You must first configure the <strong>Braintree v.zero - Configuration</strong> section with your Braintree account details.]]></comment>
 
 
 
 
 
 
485
  <fields>
486
 
487
  <active translate="label">
@@ -612,34 +672,6 @@
612
  ]]></comment>
613
  </use_vault>
614
 
615
- <threedsecure translate="label comment">
616
- <label>Enable 3D Secure</label>
617
- <frontend_type>select</frontend_type>
618
- <source_model>adminhtml/system_config_source_yesno</source_model>
619
- <sort_order>76</sort_order>
620
- <show_in_default>1</show_in_default>
621
- <show_in_website>1</show_in_website>
622
- <show_in_store>1</show_in_store>
623
- <comment><![CDATA[
624
- The 3D Secure feature enables the shopper to enter a password to confirm their identity with the card issuer. If accepted they then complete their order, and when received by you, you have much more confidence that is genuine and real.<br /><strong>Notice:</strong> To use 3D secure your checkout must run over HTTPs, this is required for both production and sandbox configurations.
625
- ]]></comment>
626
- </threedsecure>
627
-
628
- <threedsecure_threshold translate="label comment">
629
- <label>3D Secure Threshold</label>
630
- <frontend_type>text</frontend_type>
631
- <sort_order>77</sort_order>
632
- <show_in_default>1</show_in_default>
633
- <show_in_website>1</show_in_website>
634
- <show_in_store>1</show_in_store>
635
- <comment><![CDATA[
636
- The threshold which requires a transaction to be passed through 3D secure. Set this to 0 to pass all transactions through 3D secure.
637
- ]]></comment>
638
- <depends>
639
- <threedsecure>1</threedsecure>
640
- </depends>
641
- </threedsecure_threshold>
642
-
643
  <useccv translate="label comment">
644
  <label>CVV Verification</label>
645
  <frontend_type>select</frontend_type>
@@ -711,6 +743,73 @@
711
  <!--]]></comment>-->
712
  <!--</dynamic_descriptors>-->
713
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
714
  <kount translate="label">
715
  <label>Kount</label>
716
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
4
  <payment>
5
  <groups>
6
  <gene_braintree translate="label comment" module="gene_braintree">
7
+ <label>Braintree Payments - Configuration</label>
8
  <sort_order>1498</sort_order>
9
  <show_in_default>1</show_in_default>
10
  <show_in_website>1</show_in_website>
11
  <show_in_store>1</show_in_store>
12
+ <comment><![CDATA[
13
+ <div class="braintree-logos" style="float: left;width: 100%;margin: 8px 0 24px 0;">
14
+ <img src="https://www.braintreepayments.com/images/bt-logo-black-d9116046.png" height="36" style="display: inline-block; vertical-align: middle;" border="0" />
15
+ <div style="display: inline-block;padding: 0 14px;vertical-align: middle;opacity: 0.7;">by</div>
16
+ <a href="http://gene.co.uk/" title="Gene Commerce" target="_blank"><img src="https://i.imgur.com/OAXtYNg.png" style="display: inline-block;vertical-align: middle;" height="36" /></a>
17
+ </div>
18
+ To use this module you will need an existing production or sandbox Braintree account. You can apply at <a href="https://www.braintreepayments.com">braintreepayments.com</a>.<br />Braintree Payments integration provided by <a href="http://gene.co.uk/" target="_blank">Gene Commerce</a>.
19
+ ]]></comment>
20
  <fields>
21
 
22
  <module_version translate="label">
23
+ <label>Magento Braintree Payments Version</label>
24
  <frontend_model>gene_braintree/adminhtml_system_config_braintree_moduleversion</frontend_model>
25
  <sort_order>20</sort_order>
26
  <show_in_default>1</show_in_default>
255
  </gene_braintree>
256
 
257
  <gene_braintree_paypal translate="label comment" module="gene_braintree">
258
+ <label>Braintree Payments - PayPal</label>
259
  <sort_order>1499</sort_order>
260
  <show_in_default>1</show_in_default>
261
  <show_in_website>1</show_in_website>
262
  <show_in_store>1</show_in_store>
263
+ <comment><![CDATA[
264
+ <img alt="PayPal powered by Braintree" width="220" src="https://s3-us-west-1.amazonaws.com/bt-partner-assets/paypal-braintree.png" style="margin: 8px 0 10px 0;" /><br />
265
+ You must first configure the <strong>Braintree Payments - Configuration</strong> section with your Braintree account details.]]>
266
+ </comment>
267
  <fields>
268
 
269
  <active translate="label">
285
  <show_in_store>1</show_in_store>
286
  </title>
287
 
 
288
  <express_heading translate="label">
289
  <label>Paypal Express</label>
290
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
390
  <show_in_store>1</show_in_store>
391
  </order_status>
392
 
393
+ <!--<payee_email_active translate="label comment">-->
394
+ <!--<label>Enable Custom Payee Email</label>-->
395
+ <!--<frontend_type>select</frontend_type>-->
396
+ <!--<source_model>adminhtml/system_config_source_yesno</source_model>-->
397
+ <!--<sort_order>111</sort_order>-->
398
+ <!--<show_in_default>1</show_in_default>-->
399
+ <!--<show_in_website>1</show_in_website>-->
400
+ <!--<show_in_store>1</show_in_store>-->
401
+ <!--<comment><![CDATA[-->
402
+ <!--This allows you to have PayPal payments paid into a specific PayPal account different from the one connected to your Braintree account. This feature requires specific permissions to be enabled on your Braintree account, please contact your Braintree account manager if you're interested in this feature.-->
403
+ <!--]]></comment>-->
404
+ <!--</payee_email_active>-->
405
+
406
+ <!--<payee_email translate="label comment">-->
407
+ <!--<label>Payee Email</label>-->
408
+ <!--<frontend_type>text</frontend_type>-->
409
+ <!--<sort_order>112</sort_order>-->
410
+ <!--<show_in_default>1</show_in_default>-->
411
+ <!--<show_in_website>1</show_in_website>-->
412
+ <!--<show_in_store>1</show_in_store>-->
413
+ <!--<comment><![CDATA[-->
414
+ <!--The PayPal email address for PayPal payments to be deposited into.-->
415
+ <!--]]></comment>-->
416
+ <!--<depends>-->
417
+ <!--<payee_email_active>1</payee_email_active>-->
418
+ <!--</depends>-->
419
+ <!--</payee_email>-->
420
+
421
  <features_heading translate="label">
422
  <label>Features</label>
423
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
458
  ]]></comment>
459
  </use_vault>
460
 
461
+ <use_vault_only_on_vault translate="label comment">
462
+ <label>Vault Flow only for Vault Requests</label>
463
+ <frontend_type>select</frontend_type>
464
+ <source_model>adminhtml/system_config_source_yesno</source_model>
465
+ <sort_order>145</sort_order>
466
+ <show_in_default>1</show_in_default>
467
+ <show_in_website>1</show_in_website>
468
+ <show_in_store>1</show_in_store>
469
+ <depends>
470
+ <payment_type>future</payment_type>
471
+ <use_vault>1</use_vault>
472
+ </depends>
473
+ <comment><![CDATA[
474
+ Use the checkout flow for all transactions that the customer has not opted into having their PayPal account saved. This can improve conversion rates as the Vault flow requests the customer setup a billing agreement.
475
+ ]]></comment>
476
+ </use_vault_only_on_vault>
477
+
478
  <locale translate="label comment">
479
  <label>Locale</label>
480
  <frontend_type>select</frontend_type>
530
  </gene_braintree_paypal>
531
 
532
  <gene_braintree_creditcard translate="label comment" module="gene_braintree">
533
+ <label>Braintree Payments - Credit Card</label>
534
  <sort_order>1500</sort_order>
535
  <show_in_default>1</show_in_default>
536
  <show_in_website>1</show_in_website>
537
  <show_in_store>1</show_in_store>
538
+ <comment>
539
+ <![CDATA[
540
+ <img src="https://www.braintreepayments.com/images/bt-logo-black-d9116046.png" height="30" style="margin-top: 6px; display: inline-block; vertical-align: middle;" border="0" /><br />
541
+ <img src="https://s3-us-west-1.amazonaws.com/bt-partner-assets/payment-method-cards.png" style="margin: 12px 0 10px 0;" alt="Accept Visa, Mastercard, Discover, and American Express payments" width="140"><br />
542
+ You must first configure the <strong>Braintree Payments - Configuration</strong> section with your Braintree account details.
543
+ ]]>
544
+ </comment>
545
  <fields>
546
 
547
  <active translate="label">
672
  ]]></comment>
673
  </use_vault>
674
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
675
  <useccv translate="label comment">
676
  <label>CVV Verification</label>
677
  <frontend_type>select</frontend_type>
743
  <!--]]></comment>-->
744
  <!--</dynamic_descriptors>-->
745
 
746
+ <threedsecure_heading translate="label">
747
+ <label>3D Secure</label>
748
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
749
+ <sort_order>99</sort_order>
750
+ <show_in_default>1</show_in_default>
751
+ <show_in_website>1</show_in_website>
752
+ <show_in_store>1</show_in_store>
753
+ </threedsecure_heading>
754
+
755
+ <threedsecure translate="label comment">
756
+ <label>Enable 3D Secure</label>
757
+ <frontend_type>select</frontend_type>
758
+ <source_model>adminhtml/system_config_source_yesno</source_model>
759
+ <sort_order>100</sort_order>
760
+ <show_in_default>1</show_in_default>
761
+ <show_in_website>1</show_in_website>
762
+ <show_in_store>1</show_in_store>
763
+ <comment><![CDATA[
764
+ The 3D Secure feature enables the shopper to enter a password to confirm their identity with the card issuer. If accepted they then complete their order, and when received by you, you have much more confidence that is genuine and real.<br /><strong>Notice:</strong> To use 3D secure your checkout must run over HTTPs, this is required for both production and sandbox configurations.
765
+ ]]></comment>
766
+ </threedsecure>
767
+
768
+ <threedsecure_threshold translate="label comment">
769
+ <label>3D Secure Threshold</label>
770
+ <frontend_type>text</frontend_type>
771
+ <sort_order>101</sort_order>
772
+ <show_in_default>1</show_in_default>
773
+ <show_in_website>1</show_in_website>
774
+ <show_in_store>1</show_in_store>
775
+ <comment><![CDATA[
776
+ The threshold which requires a transaction to be passed through 3D secure. Set this to 0 to pass all transactions through 3D secure.
777
+ ]]></comment>
778
+ <depends>
779
+ <threedsecure>1</threedsecure>
780
+ </depends>
781
+ </threedsecure_threshold>
782
+
783
+ <threedsecure_allowspecific translate="label comment">
784
+ <label>3D Secure for Applicable Countries</label>
785
+ <frontend_type>allowspecific</frontend_type>
786
+ <sort_order>102</sort_order>
787
+ <source_model>gene_braintree/system_config_source_payment_threedsecurecountries</source_model>
788
+ <show_in_default>1</show_in_default>
789
+ <show_in_website>1</show_in_website>
790
+ <show_in_store>0</show_in_store>
791
+ <comment><![CDATA[
792
+ Determine when 3D secure should display based on the customers billing country. Cards vaulted using 3D secure will ignore this option.
793
+ ]]></comment>
794
+ <depends>
795
+ <threedsecure>1</threedsecure>
796
+ </depends>
797
+ </threedsecure_allowspecific>
798
+
799
+ <threedsecure_specificcountry translate="label">
800
+ <label>3D Secure for Specific Countries</label>
801
+ <frontend_type>multiselect</frontend_type>
802
+ <sort_order>103</sort_order>
803
+ <source_model>adminhtml/system_config_source_country</source_model>
804
+ <show_in_default>1</show_in_default>
805
+ <show_in_website>1</show_in_website>
806
+ <show_in_store>0</show_in_store>
807
+ <depends>
808
+ <threedsecure>1</threedsecure>
809
+ <threedsecure_allowspecific>1</threedsecure_allowspecific>
810
+ </depends>
811
+ </threedsecure_specificcountry>
812
+
813
  <kount translate="label">
814
  <label>Kount</label>
815
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
app/design/adminhtml/default/default/layout/gene/braintree.xml CHANGED
@@ -17,9 +17,9 @@
17
  <adminhtml_sales_order_create_index>
18
  <reference name="head">
19
  <action method="addCss"><file>css/gene/braintree/adminhtml.css</file></action>
20
- <action method="addJs"><file>gene/braintree/vzero-min.js</file></action>
21
- <action method="addJs"><file>gene/braintree/vzero-paypal-min.js</file></action>
22
- <action method="addJs"><file>gene/braintree/vzero-integration-min.js</file></action>
23
 
24
  <!-- If Braintree_Payments is enabled remove the JS -->
25
  <action method="removeItem"><type>js</type><name>braintree/braintree-1.3.4.js</name></action>
17
  <adminhtml_sales_order_create_index>
18
  <reference name="head">
19
  <action method="addCss"><file>css/gene/braintree/adminhtml.css</file></action>
20
+ <action method="addJs"><file>gene/braintree/2.1.3/vzero-min.js</file></action>
21
+ <action method="addJs"><file>gene/braintree/2.1.3/vzero-paypal-min.js</file></action>
22
+ <action method="addJs"><file>gene/braintree/2.1.3/vzero-integration-min.js</file></action>
23
 
24
  <!-- If Braintree_Payments is enabled remove the JS -->
25
  <action method="removeItem"><type>js</type><name>braintree/braintree-1.3.4.js</name></action>
app/design/adminhtml/default/default/template/gene/braintree/creditcard.phtml DELETED
@@ -1,108 +0,0 @@
1
- <?php
2
- /* @var $this Gene_Braintree_Block_Creditcard */
3
- $_code = $this->getMethodCode()
4
- ?>
5
- <div id="payment_form_<?php echo $_code ?>" style="display:none;" class="form-list">
6
-
7
- <?php echo $this->getSavedChildHtml(); ?>
8
-
9
- <div id="credit-card-form">
10
- <ul class="form-list">
11
- <li>
12
- <div class="input-box">
13
- <label for="<?php echo $_code ?>_cc_type"><?php echo Mage::helper('payment')->__('Credit Card Type') ?> <span class="required">*</span></label><br/>
14
- <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
15
- <?php $_ccType = $this->getInfoData('cc_type') ?>
16
- <option value=""></option>
17
- <?php foreach ($this->getOriginalCcAvailableTypes() as $_typeCode => $_typeName): ?>
18
- <option value="<?php echo $_typeCode ?>" <?php if($_typeCode==$_ccType): ?>selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
19
- <?php endforeach ?>
20
- </select>
21
- </div>
22
- </li>
23
- <li>
24
- <div class="input-box">
25
- <label for="<?php echo $_code ?>_cc_number"><?php echo Mage::helper('payment')->__('Credit Card Number') ?> <span class="required">*</span></label><br/>
26
- <input type="text" data-genebraintree-name="number" name="payment[cc_number]" id="<?php echo $_code ?>_cc_number" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value=""/>
27
- </div>
28
- </li>
29
- <li>
30
- <div class="input-box">
31
- <label for="<?php echo $_code ?>_expiration"><?php echo Mage::helper('payment')->__('Expiration Date') ?> <span class="required">*</span></label><br/>
32
- <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" data-genebraintree-name="expiration_month" class="validate-cc-exp required-entry">
33
- <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
34
- <?php foreach ($this->getCcMonths() as $k=>$v): ?>
35
- <option value="<?php echo $k ?>" <?php if($k==$_ccExpMonth): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
36
- <?php endforeach ?>
37
- </select>
38
- <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
39
- <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" data-genebraintree-name="expiration_year" class="required-entry">
40
- <?php foreach ($this->getCcYears() as $k=>$v): ?>
41
- <option value="<?php echo $k ? $k : '' ?>" <?php if($k==$_ccExpYear): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
42
- <?php endforeach ?>
43
- </select>
44
- </div>
45
- </li>
46
- <?php echo $this->getChildHtml() ?>
47
- <?php if($this->hasVerification()): ?>
48
- <li>
49
- <div class="input-box">
50
- <label for="<?php echo $_code ?>_cc_cid"><?php echo Mage::helper('payment')->__('Card Verification Number') ?> <span class="required">*</span></label><br/>
51
- <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" data-genebraintree-name="cvv" value="" />
52
- </div>
53
- </li>
54
- <?php endif; ?>
55
-
56
- </ul>
57
-
58
- <!-- Fields for the payment method -->
59
- <input type="hidden" name="payment[payment_method_nonce]" id="creditcard-payment-nonce" />
60
-
61
- <input type="hidden" id="<?php echo $_code ?>_cc_type" value="" />
62
- </div>
63
-
64
- </div>
65
-
66
- <style type="text/css">
67
- .card-number {
68
- position: relative;
69
- }
70
-
71
- .card-type {
72
- position: absolute;
73
- top: 0;
74
- left: 6px;
75
- }
76
-
77
- .card-number input {
78
- height: 46px;
79
- text-indent: 54px;
80
- }
81
- </style>
82
-
83
- <script type="text/javascript">
84
- //<![CDATA[
85
- Validation.creditCartTypes = $H({
86
- 'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],
87
- 'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],
88
- 'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],
89
- 'DI': [new RegExp('^6011[0-9]{12}$'), new RegExp('^[0-9]{3}$'), true],
90
- 'JCB': [new RegExp('^(3[0-9]{15}|(2131|1800)[0-9]{11})$'), new RegExp('^[0-9]{4}$'), true],
91
- 'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false]
92
- });
93
- //]]>
94
- </script>
95
-
96
- <!-- Attach an event onto all radio buttons -->
97
- <script type="text/javascript">
98
-
99
- // Verify that vzero is defined before attempting to use it
100
- if(typeof vzero !== 'undefined') {
101
-
102
- // Only needed for 3DS transactions but still helpful
103
- vzero.setAmount('<?php echo Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getGrandTotal(); ?>');
104
-
105
- vzero.creditCardLoaded();
106
- }
107
-
108
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/gene/braintree/creditcard/hostedfields.phtml CHANGED
@@ -31,13 +31,21 @@ $_code = $this->getMethodCode()
31
  <label for="cvv"><?php echo $this->__('CVV'); ?></label>
32
  <div id="cvv" class="braintree-input-field braintree-cvv"></div>
33
  </li>
 
 
 
 
 
 
 
 
 
 
34
  </ul>
35
  </div>
36
 
37
  <?php /* Do not remove or modify this code, the div is hidden and used to fire the hosted fields tokenization */ ?>
38
  <div id="braintree-hosted-submit">
39
- <button type="submit" data-blockCapture="true"></button>
40
-
41
  <!-- Fields for the payment method -->
42
  <input type="text" name="payment[payment_method_nonce]" value="" id="creditcard-payment-nonce" class="validate-fire-hosted" />
43
  </div>
31
  <label for="cvv"><?php echo $this->__('CVV'); ?></label>
32
  <div id="cvv" class="braintree-input-field braintree-cvv"></div>
33
  </li>
34
+ <?php if ($this->canSaveCard()) : ?>
35
+ <li id="<?php echo $_code ?>_store_in_vault_div">
36
+ <input type="checkbox" title="<?php echo $this->__('Save card against customers account') ?>"
37
+ class="input-checkbox" id="<?php echo $_code ?>_store_in_vault" name="payment[save_card]"
38
+ value="1" style="display: inline-block;"/>
39
+ <label for="<?php echo $_code ?>_store_in_vault" style="display: inline-block;margin-left: 2px;">
40
+ <?php echo $this->__('Save card against customers account') ?>
41
+ </label>
42
+ </li>
43
+ <?php endif; ?>
44
  </ul>
45
  </div>
46
 
47
  <?php /* Do not remove or modify this code, the div is hidden and used to fire the hosted fields tokenization */ ?>
48
  <div id="braintree-hosted-submit">
 
 
49
  <!-- Fields for the payment method -->
50
  <input type="text" name="payment[payment_method_nonce]" value="" id="creditcard-payment-nonce" class="validate-fire-hosted" />
51
  </div>
app/design/adminhtml/default/default/template/gene/braintree/js.phtml CHANGED
@@ -42,6 +42,27 @@
42
  enableElements('save');
43
  },
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  /**
46
  * Attach observer events for the submission of the page
47
  */
@@ -50,9 +71,6 @@
50
  // Store a pointer to the vZero integration
51
  var vzeroIntegration = this;
52
 
53
- // Store the original payment method
54
- var _originalAdminOrderSubmit = AdminOrder.prototype.submit;
55
-
56
  // Intercept the save function
57
  AdminOrder.prototype.submit = function() {
58
 
@@ -65,27 +83,15 @@
65
 
66
  // If everything was a success on the checkout end, let's submit the vZero integration
67
  vzeroIntegration.submit('creditcard', function () {
68
- return _originalAdminOrderSubmit.apply(paymentThis, paymentArguments);
69
  });
70
 
71
  } else {
72
- return _originalAdminOrderSubmit.apply(this, arguments);
73
  }
74
 
75
  };
76
 
77
- // On dom load init hosted fields if it's enabled
78
- document.observe("dom:loaded", function () {
79
- vzeroIntegration.paymentMethodSwitch();
80
- vzeroIntegration.initSavedMethods();
81
- }.bind(this));
82
-
83
- // Intercept any area of the checkout being updated
84
- this.vzero.observeAjaxRequests(function() {
85
- vzeroIntegration.paymentMethodSwitch();
86
- vzeroIntegration.initSavedMethods();
87
- });
88
-
89
  },
90
 
91
  /**
42
  enableElements('save');
43
  },
44
 
45
+ /**
46
+ * Capture the original submit function
47
+ */
48
+ captureOriginalSubmitFn: function () {
49
+ this._originalSubmitFn = AdminOrder.prototype.submit;
50
+
51
+ // On dom load init hosted fields if it's enabled
52
+ document.observe("dom:loaded", function () {
53
+ this.paymentMethodSwitch();
54
+ this.initSavedMethods();
55
+ }.bind(this));
56
+
57
+ // Intercept any area of the checkout being updated
58
+ this.vzero.observeAjaxRequests(function() {
59
+ this.paymentMethodSwitch();
60
+ this.initSavedMethods();
61
+ }.bind(this));
62
+
63
+ return true;
64
+ },
65
+
66
  /**
67
  * Attach observer events for the submission of the page
68
  */
71
  // Store a pointer to the vZero integration
72
  var vzeroIntegration = this;
73
 
 
 
 
74
  // Intercept the save function
75
  AdminOrder.prototype.submit = function() {
76
 
83
 
84
  // If everything was a success on the checkout end, let's submit the vZero integration
85
  vzeroIntegration.submit('creditcard', function () {
86
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
87
  });
88
 
89
  } else {
90
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
91
  }
92
 
93
  };
94
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  },
96
 
97
  /**
app/design/frontend/base/default/layout/gene/braintree.xml CHANGED
@@ -13,14 +13,15 @@
13
  <script src="https://js.braintreegateway.com/web/3.5.0/js/data-collector.min.js"></script>
14
  ]]></text></action>
15
  </block>
16
- <action method="addJs"><file>gene/braintree/vzero-min.js</file></action>
17
- <action method="addJs"><file>gene/braintree/vzero-paypal-min.js</file></action>
18
- <action method="addJs"><file>gene/braintree/vzero-integration-min.js</file></action>
19
  <!-- If Braintree_Payments is enabled remove their JS -->
20
  <action method="removeItem"><type>js</type><name>braintree/braintree-1.3.4.js</name></action>
21
  </reference>
22
  <reference name="before_body_end">
23
  <block type="gene_braintree/js" name="gene_braintree_setup" template="gene/braintree/js/setup.phtml" />
 
24
  </reference>
25
  </gene_braintree_assets>
26
 
@@ -32,14 +33,6 @@
32
  </reference>
33
  <reference name="before_body_end">
34
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/default.phtml" />
35
-
36
- <!-- Set the payment form ID for the fraud prevention -->
37
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
38
- <action method="setData">
39
- <key>payment_form_id</key>
40
- <value>co-payment-form</value>
41
- </action>
42
- </block>
43
  </reference>
44
  </checkout_onepage_index>
45
 
@@ -53,14 +46,6 @@
53
  <reference name="before_body_end">
54
  <remove name="gene_braintree_js" />
55
  <block type="gene_braintree/js" name="gene_braintree_amasty_js" template="gene/braintree/js/amasty.phtml" />
56
-
57
- <!-- We include device data at the end of the larger form -->
58
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
59
- <action method="setData">
60
- <key>payment_form_id</key>
61
- <value>amscheckout-onepage</value>
62
- </action>
63
- </block>
64
  </reference>
65
  </amasty_onestep_checkout>
66
 
@@ -72,14 +57,6 @@
72
  </reference>
73
  <reference name="before_body_end">
74
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/idev.phtml" />
75
-
76
- <!-- We include device data at the end of the larger form -->
77
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
78
- <action method="setData">
79
- <key>payment_form_id</key>
80
- <value>onestepcheckout-form</value>
81
- </action>
82
- </block>
83
  </reference>
84
  </idev_onestepcheckout_index>
85
 
@@ -91,14 +68,6 @@
91
  </reference>
92
  <reference name="before_body_end">
93
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/magestore.phtml" />
94
-
95
- <!-- We include device data at the end of the larger form -->
96
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
97
- <action method="setData">
98
- <key>payment_form_id</key>
99
- <value>one-step-checkout-form</value>
100
- </action>
101
- </block>
102
  </reference>
103
  </magestore_onestepcheckout_index>
104
 
@@ -110,14 +79,6 @@
110
  </reference>
111
  <reference name="before_body_end">
112
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/aheadworks.phtml" />
113
-
114
- <!-- We include device data at the end of the larger form -->
115
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
116
- <action method="setData">
117
- <key>payment_form_id</key>
118
- <value>aw-onestepcheckout-general-form</value>
119
- </action>
120
- </block>
121
  </reference>
122
  </aw_onestepcheckout_index_index>
123
 
@@ -132,14 +93,6 @@
132
  </reference>
133
  <reference name="before_body_end">
134
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/iwd.phtml" />
135
-
136
- <!-- We include device data at the end of the larger form -->
137
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
138
- <action method="setData">
139
- <key>payment_form_id</key>
140
- <value>co-payment-form</value>
141
- </action>
142
- </block>
143
  </reference>
144
  </opc_index_index>
145
 
@@ -154,14 +107,6 @@
154
  </reference>
155
  <reference name="before_body_end">
156
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/firecheckout.phtml" />
157
-
158
- <!-- We include device data at the end of the larger form -->
159
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
160
- <action method="setData">
161
- <key>payment_form_id</key>
162
- <value>firecheckout-form</value>
163
- </action>
164
- </block>
165
  </reference>
166
  </firecheckout_index_index>
167
 
@@ -177,14 +122,6 @@
177
  </reference>
178
  <reference name="before_body_end">
179
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/unicode.phtml" />
180
-
181
- <!-- We include device data at the end of the larger form -->
182
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
183
- <action method="setData">
184
- <key>payment_form_id</key>
185
- <value>co-payment-form</value>
186
- </action>
187
- </block>
188
  </reference>
189
  </unicode_onestep_checkout>
190
 
@@ -197,14 +134,6 @@
197
  </reference>
198
  <reference name="before_body_end">
199
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/oye.phtml" />
200
-
201
- <!-- We include device data at the end of the larger form -->
202
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
203
- <action method="setData">
204
- <key>payment_form_id</key>
205
- <value>custom-checkout-form</value>
206
- </action>
207
- </block>
208
  </reference>
209
  </oye_onestep_checkout>
210
 
@@ -216,14 +145,6 @@
216
  </reference>
217
  <reference name="before_body_end">
218
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/fme.phtml" />
219
-
220
- <!-- We include device data at the end of the larger form -->
221
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
222
- <action method="setData">
223
- <key>payment_form_id</key>
224
- <value>onestepcheckout-form</value>
225
- </action>
226
- </block>
227
  </reference>
228
  </checkout_onestep_index>
229
 
@@ -238,14 +159,6 @@
238
  <remove name="gene_braintree_data" />
239
  <reference name="before_body_end">
240
  <block type="gene_braintree/js" name="gene_braintree_js_ac" template="gene/braintree/js/awesomecheckout.phtml" />
241
-
242
- <!-- We include device data at the end of the larger form -->
243
- <block type="gene_braintree/js" name="gene_braintree_data_ac" template="gene/braintree/js/data.phtml">
244
- <action method="setData">
245
- <key>payment_form_id</key>
246
- <value>co-payment-form</value>
247
- </action>
248
- </block>
249
  </reference>
250
  </anattadesign_awesomecheckout_onepage_index>
251
 
@@ -257,14 +170,6 @@
257
  </reference>
258
  <reference name="before_body_end">
259
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/fancycheckout.phtml" />
260
-
261
- <!-- We include device data at the end of the larger form -->
262
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
263
- <action method="setData">
264
- <key>payment_form_id</key>
265
- <value>fancycheckout_orderform</value>
266
- </action>
267
- </block>
268
  </reference>
269
  </fancycheckout_index_index>
270
 
@@ -276,14 +181,6 @@
276
  </reference>
277
  <reference name="before_body_end">
278
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/multishipping.phtml" />
279
-
280
- <!-- Set the payment form ID for the fraud prevention -->
281
- <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
282
- <action method="setData">
283
- <key>payment_form_id</key>
284
- <value>multishipping-billing-form</value>
285
- </action>
286
- </block>
287
  </reference>
288
  </checkout_multishipping_billing>
289
 
@@ -341,8 +238,8 @@
341
  <catalog_product_view>
342
  <update handle="gene_braintree_assets" />
343
  <reference name="head">
344
- <action method="addJs"><file>gene/braintree/express/abstract-min.js</file></action>
345
- <action method="addJs"><file>gene/braintree/express/paypal-min.js</file></action>
346
  <action method="addCss"><file>css/gene/braintree/default.css</file></action>
347
  <action method="addCss"><file>css/gene/braintree/express.css</file></action>
348
  </reference>
@@ -350,7 +247,12 @@
350
  <block type="gene_braintree/express_setup" name="gene_braintree_express_catalog_button" template="gene/braintree/express/catalog.phtml" />
351
  </reference>
352
  <reference name="product.info.addtocart">
353
- <block type="gene_braintree/express_button" name="product.info.extrabuttons.paypal.express" template="gene/braintree/express/button.phtml" after="-" />
 
 
 
 
 
354
  </reference>
355
  </catalog_product_view>
356
 
@@ -358,8 +260,8 @@
358
  <checkout_cart_index>
359
  <update handle="gene_braintree_assets" />
360
  <reference name="head">
361
- <action method="addJs"><file>gene/braintree/express/abstract-min.js</file></action>
362
- <action method="addJs"><file>gene/braintree/express/paypal-min.js</file></action>
363
  <action method="addCss"><file>css/gene/braintree/default.css</file></action>
364
  <action method="addCss"><file>css/gene/braintree/express.css</file></action>
365
  </reference>
@@ -367,10 +269,20 @@
367
  <block type="gene_braintree/express_setup" name="gene_braintree_express_cart_button" template="gene/braintree/express/cart.phtml" />
368
  </reference>
369
  <reference name="checkout.cart.top_methods">
370
- <block type="gene_braintree/express_button" name="checkout.cart.methods.onepage.top.paypal.express" template="gene/braintree/express/button.phtml" after="-" />
 
 
 
 
 
371
  </reference>
372
  <reference name="checkout.cart.methods">
373
- <block type="gene_braintree/express_button" name="checkout.cart.methods.onepage.top.paypal.express" template="gene/braintree/express/button.phtml" after="checkout.cart.methods.onepage.bottom" />
 
 
 
 
 
374
  </reference>
375
  </checkout_cart_index>
376
 
13
  <script src="https://js.braintreegateway.com/web/3.5.0/js/data-collector.min.js"></script>
14
  ]]></text></action>
15
  </block>
16
+ <action method="addJs"><file>gene/braintree/2.1.3/vzero-min.js</file></action>
17
+ <action method="addJs"><file>gene/braintree/2.1.3/vzero-paypal-min.js</file></action>
18
+ <action method="addJs"><file>gene/braintree/2.1.3/vzero-integration-min.js</file></action>
19
  <!-- If Braintree_Payments is enabled remove their JS -->
20
  <action method="removeItem"><type>js</type><name>braintree/braintree-1.3.4.js</name></action>
21
  </reference>
22
  <reference name="before_body_end">
23
  <block type="gene_braintree/js" name="gene_braintree_setup" template="gene/braintree/js/setup.phtml" />
24
+ <remove name="braintree_payments_data_js" />
25
  </reference>
26
  </gene_braintree_assets>
27
 
33
  </reference>
34
  <reference name="before_body_end">
35
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/default.phtml" />
 
 
 
 
 
 
 
 
36
  </reference>
37
  </checkout_onepage_index>
38
 
46
  <reference name="before_body_end">
47
  <remove name="gene_braintree_js" />
48
  <block type="gene_braintree/js" name="gene_braintree_amasty_js" template="gene/braintree/js/amasty.phtml" />
 
 
 
 
 
 
 
 
49
  </reference>
50
  </amasty_onestep_checkout>
51
 
57
  </reference>
58
  <reference name="before_body_end">
59
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/idev.phtml" />
 
 
 
 
 
 
 
 
60
  </reference>
61
  </idev_onestepcheckout_index>
62
 
68
  </reference>
69
  <reference name="before_body_end">
70
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/magestore.phtml" />
 
 
 
 
 
 
 
 
71
  </reference>
72
  </magestore_onestepcheckout_index>
73
 
79
  </reference>
80
  <reference name="before_body_end">
81
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/aheadworks.phtml" />
 
 
 
 
 
 
 
 
82
  </reference>
83
  </aw_onestepcheckout_index_index>
84
 
93
  </reference>
94
  <reference name="before_body_end">
95
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/iwd.phtml" />
 
 
 
 
 
 
 
 
96
  </reference>
97
  </opc_index_index>
98
 
107
  </reference>
108
  <reference name="before_body_end">
109
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/firecheckout.phtml" />
 
 
 
 
 
 
 
 
110
  </reference>
111
  </firecheckout_index_index>
112
 
122
  </reference>
123
  <reference name="before_body_end">
124
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/unicode.phtml" />
 
 
 
 
 
 
 
 
125
  </reference>
126
  </unicode_onestep_checkout>
127
 
134
  </reference>
135
  <reference name="before_body_end">
136
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/oye.phtml" />
 
 
 
 
 
 
 
 
137
  </reference>
138
  </oye_onestep_checkout>
139
 
145
  </reference>
146
  <reference name="before_body_end">
147
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/fme.phtml" />
 
 
 
 
 
 
 
 
148
  </reference>
149
  </checkout_onestep_index>
150
 
159
  <remove name="gene_braintree_data" />
160
  <reference name="before_body_end">
161
  <block type="gene_braintree/js" name="gene_braintree_js_ac" template="gene/braintree/js/awesomecheckout.phtml" />
 
 
 
 
 
 
 
 
162
  </reference>
163
  </anattadesign_awesomecheckout_onepage_index>
164
 
170
  </reference>
171
  <reference name="before_body_end">
172
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/fancycheckout.phtml" />
 
 
 
 
 
 
 
 
173
  </reference>
174
  </fancycheckout_index_index>
175
 
181
  </reference>
182
  <reference name="before_body_end">
183
  <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/multishipping.phtml" />
 
 
 
 
 
 
 
 
184
  </reference>
185
  </checkout_multishipping_billing>
186
 
238
  <catalog_product_view>
239
  <update handle="gene_braintree_assets" />
240
  <reference name="head">
241
+ <action method="addJs"><file>gene/braintree/2.1.3/express/abstract-min.js</file></action>
242
+ <action method="addJs"><file>gene/braintree/2.1.3/express/paypal-min.js</file></action>
243
  <action method="addCss"><file>css/gene/braintree/default.css</file></action>
244
  <action method="addCss"><file>css/gene/braintree/express.css</file></action>
245
  </reference>
247
  <block type="gene_braintree/express_setup" name="gene_braintree_express_catalog_button" template="gene/braintree/express/catalog.phtml" />
248
  </reference>
249
  <reference name="product.info.addtocart">
250
+ <block type="gene_braintree/express_button" name="product.info.extrabuttons.paypal.express" template="gene/braintree/express/button.phtml" after="-">
251
+ <action method="setData">
252
+ <name>express_type</name>
253
+ <value>catalog</value>
254
+ </action>
255
+ </block>
256
  </reference>
257
  </catalog_product_view>
258
 
260
  <checkout_cart_index>
261
  <update handle="gene_braintree_assets" />
262
  <reference name="head">
263
+ <action method="addJs"><file>gene/braintree/2.1.3/express/abstract-min.js</file></action>
264
+ <action method="addJs"><file>gene/braintree/2.1.3/express/paypal-min.js</file></action>
265
  <action method="addCss"><file>css/gene/braintree/default.css</file></action>
266
  <action method="addCss"><file>css/gene/braintree/express.css</file></action>
267
  </reference>
269
  <block type="gene_braintree/express_setup" name="gene_braintree_express_cart_button" template="gene/braintree/express/cart.phtml" />
270
  </reference>
271
  <reference name="checkout.cart.top_methods">
272
+ <block type="gene_braintree/express_button" name="checkout.cart.methods.onepage.top.paypal.express" template="gene/braintree/express/button.phtml" after="-">
273
+ <action method="setData">
274
+ <name>express_type</name>
275
+ <value>cart</value>
276
+ </action>
277
+ </block>
278
  </reference>
279
  <reference name="checkout.cart.methods">
280
+ <block type="gene_braintree/express_button" name="checkout.cart.methods.onepage.top.paypal.express" template="gene/braintree/express/button.phtml" after="checkout.cart.methods.onepage.bottom">
281
+ <action method="setData">
282
+ <name>express_type</name>
283
+ <value>cart</value>
284
+ </action>
285
+ </block>
286
  </reference>
287
  </checkout_cart_index>
288
 
app/design/frontend/base/default/template/gene/braintree/creditcard.phtml DELETED
@@ -1,188 +0,0 @@
1
- <?php
2
- /* @var $this Gene_Braintree_Block_Creditcard */
3
- $_code = $this->getMethodCode()
4
- ?>
5
- <div id="payment_form_<?php echo $_code ?>" style="display:none;" class="form-list">
6
-
7
- <?php echo $this->getSavedChildHtml(); ?>
8
-
9
- <div id="credit-card-form"<?php echo ($this->hasSavedDetails() && $this->getMethod()->isVaultEnabled() ? ' style="display: none;"' : ''); ?>>
10
- <ul class="form-list">
11
-
12
- <?php if($this->showAcceptedCards()): ?>
13
- <li id="braintree-accepted-cards">
14
- <label for="<?php echo $_code ?>_cc_number">
15
- <?php echo $this->__('We Accept'); ?>
16
- <div>
17
- <?php foreach($this->getAllowedCards() as $card): ?>
18
- <img src="<?php echo $this->getSkinUrl('images/gene/braintree/' . $card['value'] . '.png') ?>" alt="<?php echo $card['label']; ?>" />
19
- <?php endforeach; ?>
20
- </div>
21
- </label>
22
- </li>
23
- <?php endif; ?>
24
-
25
- <li>
26
- <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
27
- <div class="input-box card-number">
28
- <input type="tel" data-genebraintree-name="number" name="payment[cc_number]" id="<?php echo $_code ?>_cc_number" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type validate-accepted-type" autocomplete="cc-number" />
29
-
30
- <div class="card-type"><img src="<?php echo $this->getSkinUrl('images/gene/braintree/card.png') ?>" id="card-type-image" /></div>
31
- </div>
32
- </li>
33
- <li id="<?php echo $_code ?>_cc_type_exp_div">
34
- <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
35
- <div class="input-box">
36
- <div class="v-fix">
37
- <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" data-genebraintree-name="expiration_month" class="month validate-cc-exp required-entry">
38
- <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
39
- <?php foreach ($this->getCcMonths() as $k=>$v): ?>
40
- <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
41
- <?php endforeach ?>
42
- </select>
43
- </div>
44
- <div class="v-fix">
45
- <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
46
- <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" data-genebraintree-name="expiration_year" class="year required-entry">
47
- <?php foreach ($this->getCcYears() as $k=>$v): ?>
48
- <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
49
- <?php endforeach ?>
50
- </select>
51
- </div>
52
- </div>
53
- </li>
54
- <?php echo $this->getChildHtml() ?>
55
- <?php if($this->hasVerification()): ?>
56
- <li id="<?php echo $_code ?>_cc_type_cvv_div">
57
- <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
58
- <div class="input-box">
59
- <div class="v-fix">
60
- <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" data-genebraintree-name="cvv" autocomplete="off" />
61
- </div>
62
- <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
63
- </div>
64
- </li>
65
- <?php endif; ?>
66
-
67
- <?php if ($this->canSaveCard()): ?>
68
- <li id="<?php echo $_code ?>_store_in_vault_div">
69
- <input type="checkbox" title="<?php echo $this->__('Save this card for future use') ?>"
70
- class="input-checkbox" id="<?php echo $_code ?>_store_in_vault" name="payment[save_card]"
71
- value="1"/>
72
- <label for="<?php echo $_code ?>_store_in_vault" style="float:none;"><?php echo $this->__(
73
- 'Save this card for future use'
74
- ) ?></label>
75
- </li>
76
- <?php endif; ?>
77
-
78
- </ul>
79
-
80
- <!-- Fields for the payment method -->
81
- <input type="hidden" name="payment[payment_method_nonce]" id="creditcard-payment-nonce" />
82
-
83
- <input type="hidden" id="<?php echo $_code ?>_cc_type" />
84
- </div>
85
-
86
- </div>
87
-
88
- <style type="text/css">
89
- .card-number {
90
- position: relative;
91
- }
92
-
93
- .card-type {
94
- position: absolute;
95
- top: 0;
96
- left: 6px;
97
- }
98
-
99
- .card-number input {
100
- height: 46px!important;
101
- text-indent: 56px!important;
102
- }
103
- </style>
104
-
105
- <script type="text/javascript">
106
- //<![CDATA[
107
- Validation.creditCartTypes = $H({
108
- 'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],
109
- 'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],
110
- 'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],
111
- 'DI': [new RegExp('^6011[0-9]{12}$'), new RegExp('^[0-9]{3}$'), true],
112
- 'JCB': [new RegExp('^(3[0-9]{15}|(2131|1800)[0-9]{11})$'), new RegExp('^[0-9]{4}$'), true],
113
- 'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false],
114
- 'ME': [new RegExp('^(?:5[0678][0-9]{2}|6304|6390|67[0-9]{2})[0-9]{8,15}$'), new RegExp('^[0-9]{3}$'), true]
115
- });
116
- //]]>
117
- </script>
118
-
119
- <!-- Attach an event onto all radio buttons -->
120
- <script type="text/javascript">
121
-
122
- // Set a flag to determine whether the PayPal flag is initialized
123
- var CreditCardInit = false;
124
-
125
- // Wrap our logic in a function so we can init in different ways
126
- initCreditCard = function() {
127
-
128
- // Verify that vzero is defined before attempting to use it
129
- if (typeof vzero !== 'undefined') {
130
-
131
- // Tell the system we're init
132
- CreditCardInit = true;
133
-
134
- // Always set the amount as it's needed within 3D secure requests
135
- vzero.setAmount('<?php echo Mage::helper('gene_braintree')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getGrandTotal()); ?>');
136
-
137
- // We now need to set this information into the browser
138
- vzero.setBillingName("<?php echo $this->jsQuoteEscape(Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getName(), '"'); ?>");
139
- vzero.setBillingPostcode("<?php echo $this->jsQuoteEscape(Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getPostcode(), '"'); ?>");
140
-
141
- // Set the accepted cards
142
- vzero.setAcceptedCards(<?php echo $this->getCcAvailableTypes(); ?>);
143
-
144
- <?php
145
- // Dynamically swap the 3Ds flag in the JS class
146
- if($this->getMethod()->is3DEnabled()): ?>
147
- vzero.setThreeDSecure(true);
148
- <?php else: ?>
149
- vzero.setThreeDSecure(false);
150
- <?php endif; ?>
151
- }
152
-
153
- // Observe the card type
154
- if(typeof vzero !== "undefined") {
155
- vzero.observeCardType();
156
- vzero.creditCardLoaded();
157
- }
158
-
159
- };
160
-
161
- // Load up credit card
162
- initCreditCard();
163
-
164
- // If the function didn't run on the load of the payment method do it on dom:loaded
165
- if(!CreditCardInit) {
166
- document.observe('dom:loaded', function () {
167
- initCreditCard();
168
- });
169
- }
170
-
171
- // Add our new validation type
172
- Validation.add('validate-accepted-type', 'Sadly, we\'re unable to accept this type of card, please try another.', function(v) {
173
- if($('<?php echo $_code ?>_cc_type') != undefined) {
174
- if (vzero.getAcceptedCards().indexOf($('<?php echo $_code ?>_cc_type').value) == -1) {
175
- return false;
176
- }
177
- }
178
- return true;
179
- });
180
-
181
- // Update a couple of the messages
182
- if(Validation.get('validate-cc-type') != undefined) {
183
- Validation.get('validate-cc-type').error = "<?php echo $this->__('We cannot detect the card type for this card number, please try re-entering your card details.'); ?>";
184
- }
185
- if(Validation.get('validate-cc-number') != undefined) {
186
- Validation.get('validate-cc-number').error = "<?php echo $this->__('We cannot match this card number to any of our accepted payment methods, please try re-entering your details.'); ?>"
187
- }
188
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/gene/braintree/express/button.phtml CHANGED
@@ -1 +1,3 @@
1
- <button class="button pp-express-buy-btn braintree-paypal-loading" disabled="disabled" data-paypalexpress="true"><?php echo $this->__('Checkout with PayPal'); ?></button>
 
 
1
+ <button type="button" class="button pp-express-buy-btn braintree-paypal-loading" disabled="disabled" data-paypalexpress="true">
2
+ <?php echo $this->__('Checkout with PayPal'); ?>
3
+ </button>
app/design/frontend/base/default/template/gene/braintree/express/cart.phtml CHANGED
@@ -1,4 +1,8 @@
1
- <?php if (!$this->isEnabled() || !$this->isEnabledCart()) return; ?>
 
 
 
 
2
 
3
  <script type="text/javascript">
4
  if (typeof Translator !== 'object' && typeof Translate == 'object') {
1
+ <?php
2
+ if (!$this->isEnabledCart()) {
3
+ return;
4
+ }
5
+ ?>
6
 
7
  <script type="text/javascript">
8
  if (typeof Translator !== 'object' && typeof Translate == 'object') {
app/design/frontend/base/default/template/gene/braintree/express/catalog.phtml CHANGED
@@ -1,4 +1,8 @@
1
- <?php if (!$this->isEnabled() || !$this->isEnabledPdp()) return; ?>
 
 
 
 
2
 
3
  <script type="text/javascript">
4
  if (typeof Translator !== 'object' && typeof Translate == 'object') {
@@ -12,6 +16,16 @@
12
  })
13
  }
14
 
 
 
 
 
 
 
 
 
 
 
15
  (function () {
16
  document.observe("dom:loaded", function() {
17
  var express = new BraintreePayPalExpress(
1
+ <?php
2
+ if (!$this->isEnabledPdp()) {
3
+ return;
4
+ }
5
+ ?>
6
 
7
  <script type="text/javascript">
8
  if (typeof Translator !== 'object' && typeof Translate == 'object') {
16
  })
17
  }
18
 
19
+ // Override the setStockData function to exclude our PayPal button
20
+ if (typeof Product.ConfigurableSwatches === 'function') {
21
+ var originSetStockData = Product.ConfigurableSwatches.prototype.setStockData;
22
+ Product.ConfigurableSwatches.prototype.setStockData = function () {
23
+ originSetStockData.apply(this, arguments);
24
+
25
+ this._E.cartBtn.btn = $$('.add-to-cart button.button:not([data-paypalexpress]):not(.not-btn-cart)');
26
+ };
27
+ }
28
+
29
  (function () {
30
  document.observe("dom:loaded", function() {
31
  var express = new BraintreePayPalExpress(
app/design/frontend/base/default/template/gene/braintree/js/aheadworks.phtml CHANGED
@@ -45,6 +45,14 @@
45
  checkoutRunning = false;
46
  },
47
 
 
 
 
 
 
 
 
 
48
  /**
49
  * Attach an observer to the submit action of the checkout to tokenize the card details
50
  */
@@ -53,9 +61,6 @@
53
  // Store a pointer to the vZero integration
54
  var vzeroIntegration = this;
55
 
56
- // Store the original payment method
57
- var _originalSendPlaceOrderRequest = AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest;
58
-
59
  // Intercept the save function
60
  AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest = function () {
61
 
@@ -67,12 +72,12 @@
67
 
68
  // If everything was a success on the checkout end, let's submit the vZero integration
69
  vzeroIntegration.submit('creditcard', function () {
70
- return _originalSendPlaceOrderRequest.apply(paymentThis, paymentArguments);
71
  });
72
 
73
  } else {
74
  // If not run the original code
75
- return _originalSendPlaceOrderRequest.apply(this, arguments);
76
  }
77
 
78
  };
45
  checkoutRunning = false;
46
  },
47
 
48
+ /**
49
+ * Capture the original submit function
50
+ */
51
+ captureOriginalSubmitFn: function () {
52
+ this._originalSubmitFn = AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest;
53
+ return true;
54
+ },
55
+
56
  /**
57
  * Attach an observer to the submit action of the checkout to tokenize the card details
58
  */
61
  // Store a pointer to the vZero integration
62
  var vzeroIntegration = this;
63
 
 
 
 
64
  // Intercept the save function
65
  AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest = function () {
66
 
72
 
73
  // If everything was a success on the checkout end, let's submit the vZero integration
74
  vzeroIntegration.submit('creditcard', function () {
75
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
76
  });
77
 
78
  } else {
79
  // If not run the original code
80
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
81
  }
82
 
83
  };
app/design/frontend/base/default/template/gene/braintree/js/amasty.phtml CHANGED
@@ -36,6 +36,14 @@
36
  checkoutRunning = false;
37
  },
38
 
 
 
 
 
 
 
 
 
39
  /**
40
  * Attach an observer to the submit action of the checkout to tokenize the card details
41
  */
@@ -44,9 +52,6 @@
44
  // Store a pointer to the vZero integration
45
  var vzeroIntegration = this;
46
 
47
- // Store the old complete checkout function
48
- var _originalCompleteCheckout = completeCheckout;
49
-
50
  // Re-define the original method so we can do some jazz with it
51
  completeCheckout = function () {
52
 
@@ -58,12 +63,12 @@
58
 
59
  // If everything was a success on the checkout end, let's submit the vZero integration
60
  vzeroIntegration.submit('creditcard', function () {
61
- return _originalCompleteCheckout.apply(paymentThis, paymentArguments);
62
  });
63
 
64
  } else {
65
  // If not run the original code
66
- return _originalCompleteCheckout.apply(this, arguments);
67
  }
68
 
69
  };
36
  checkoutRunning = false;
37
  },
38
 
39
+ /**
40
+ * Capture the original submit function
41
+ */
42
+ captureOriginalSubmitFn: function () {
43
+ this._originalSubmitFn = completeCheckout;
44
+ return true;
45
+ },
46
+
47
  /**
48
  * Attach an observer to the submit action of the checkout to tokenize the card details
49
  */
52
  // Store a pointer to the vZero integration
53
  var vzeroIntegration = this;
54
 
 
 
 
55
  // Re-define the original method so we can do some jazz with it
56
  completeCheckout = function () {
57
 
63
 
64
  // If everything was a success on the checkout end, let's submit the vZero integration
65
  vzeroIntegration.submit('creditcard', function () {
66
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
67
  });
68
 
69
  } else {
70
  // If not run the original code
71
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
72
  }
73
 
74
  };
app/design/frontend/base/default/template/gene/braintree/js/awesomecheckout.phtml CHANGED
@@ -17,6 +17,14 @@
17
  checkout.setLoadWaiting(false);
18
  },
19
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Attach observer events for saving the payment step, alongside the review step
22
  */
@@ -25,8 +33,8 @@
25
  // Store a pointer to the vZero integration
26
  var vzeroIntegration = this;
27
 
28
- // As the default checkout submits more data on the review step, we need to make sure various elements are disabled
29
- var _originalReviewSave = Review.prototype.save;
30
  Review.prototype.save = function () {
31
 
32
  if (vzeroIntegration.shouldInterceptSubmit('creditcard')) {
@@ -37,12 +45,12 @@
37
 
38
  // If everything was a success on the checkout end, let's submit the vZero integration
39
  vzeroIntegration.submit('creditcard', function () {
40
- return _originalReviewSave.apply(paymentThis, paymentArguments);
41
  });
42
 
43
  } else {
44
  // If not run the original code
45
- return _originalReviewSave.apply(this, arguments);
46
  }
47
  };
48
 
17
  checkout.setLoadWaiting(false);
18
  },
19
 
20
+ /**
21
+ * Capture the original submit function
22
+ */
23
+ captureOriginalSubmitFn: function () {
24
+ this._originalSubmitFn = Review.prototype.save;
25
+ return true;
26
+ },
27
+
28
  /**
29
  * Attach observer events for saving the payment step, alongside the review step
30
  */
33
  // Store a pointer to the vZero integration
34
  var vzeroIntegration = this;
35
 
36
+ // As the default checkout submits more data on the review step, we need to make sure various elements are
37
+ // disabled
38
  Review.prototype.save = function () {
39
 
40
  if (vzeroIntegration.shouldInterceptSubmit('creditcard')) {
45
 
46
  // If everything was a success on the checkout end, let's submit the vZero integration
47
  vzeroIntegration.submit('creditcard', function () {
48
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
49
  });
50
 
51
  } else {
52
  // If not run the original code
53
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
54
  }
55
  };
56
 
app/design/frontend/base/default/template/gene/braintree/js/data.phtml DELETED
@@ -1,25 +0,0 @@
1
- <?php
2
- /**
3
- * Include the crucial braintree-data.js for fraud protection
4
- */
5
- ?>
6
- <script src="https://js.braintreegateway.com/v1/braintree-data.js"></script>
7
- <script type="text/javascript">
8
-
9
- // Only include the setup call once
10
- if(braintreeDataEnv === undefined) {
11
-
12
- <?php if($kountId = Mage::getStoreConfig('payment/gene_braintree_creditcard/kount_merchant_id')): ?>
13
- var braintreeDataEnv = BraintreeData.environments.production.withId("<?php echo $kountId; ?>");
14
- <?php else: ?>
15
- var braintreeDataEnv = BraintreeData.environments.<?php echo Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_ENVIRONMENT_PATH); ?>;
16
- <?php endif; ?>
17
- BraintreeData.setup("<?php echo Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_MERCHANT_ID_PATH); ?>", '<?php echo ($this->getPaymentFormId() ? $this->getPaymentFormId() : 'co-payment-form'); ?>', braintreeDataEnv);
18
-
19
- // Update the device_data's field name to contain payment
20
- if ($('device_data')) {
21
- $('device_data').setAttribute('name', 'payment[device_data]');
22
- }
23
- }
24
- </script>
25
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/gene/braintree/js/default.phtml CHANGED
@@ -9,6 +9,15 @@
9
 
10
  vZeroIntegration.addMethods({
11
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * Attach observer events for saving the payment step, alongside the review step
14
  */
@@ -19,7 +28,6 @@
19
 
20
  // As the default checkout submits more data on the review step, we need to make sure various elements
21
  // are disabled
22
- var _originalReviewSave = Review.prototype.save;
23
  Review.prototype.save = function() {
24
 
25
  // Do the standard validation
@@ -31,18 +39,18 @@
31
 
32
  // If everything was a success on the checkout end, let's submit the vZero integration
33
  vzeroIntegration.submit('creditcard', function () {
34
- return _originalReviewSave.apply(paymentThis, paymentArguments);
35
  });
36
 
37
  } else {
38
  // If not run the original code
39
- return _originalReviewSave.apply(this, arguments);
40
  }
41
  };
42
 
43
  // Override the next step functionality to handle failed payments
44
- var _originalNextStep = Review.prototype.nextStep;
45
  Review.prototype.nextStep = function (transport) {
 
46
  // Parse the transport
47
  var response;
48
  if (transport && transport.responseText) {
@@ -55,23 +63,25 @@
55
  }
56
 
57
  // Retrieve any error messages
58
- var errorMessage = response.error_messages;
59
- if (typeof(errorMessage)=='object') {
60
- errorMessage = errorMessage.join("\n");
61
- }
 
62
 
63
- // Determine if the error message contains a generic message from a payment failure
64
- if (errorMessage.indexOf('attempt refreshing the page') !== -1 ||
65
- errorMessage.indexOf('please try another payment method or contacting your issuing bank') !== -1 ||
66
- errorMessage.indexOf('please try again or consider using an alternate payment method') !== -1 ||
67
- errorMessage.indexOf('Your card payment has failed') !== -1
68
- ) {
69
- response.goto_section = 'payment';
70
- transport.responseText = JSON.stringify(response);
 
71
  }
72
 
73
  // Run the original action
74
- return _originalNextStep.call(this, transport);
75
  };
76
  },
77
 
9
 
10
  vZeroIntegration.addMethods({
11
 
12
+ /**
13
+ * Capture the original submit function
14
+ */
15
+ captureOriginalSubmitFn: function () {
16
+ this._originalSubmitFn = Review.prototype.save;
17
+ this._originalNextStep = Review.prototype.nextStep;
18
+ return true;
19
+ },
20
+
21
  /**
22
  * Attach observer events for saving the payment step, alongside the review step
23
  */
28
 
29
  // As the default checkout submits more data on the review step, we need to make sure various elements
30
  // are disabled
 
31
  Review.prototype.save = function() {
32
 
33
  // Do the standard validation
39
 
40
  // If everything was a success on the checkout end, let's submit the vZero integration
41
  vzeroIntegration.submit('creditcard', function () {
42
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
43
  });
44
 
45
  } else {
46
  // If not run the original code
47
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
48
  }
49
  };
50
 
51
  // Override the next step functionality to handle failed payments
 
52
  Review.prototype.nextStep = function (transport) {
53
+
54
  // Parse the transport
55
  var response;
56
  if (transport && transport.responseText) {
63
  }
64
 
65
  // Retrieve any error messages
66
+ if (typeof response.error_messages !== 'undefined') {
67
+ var errorMessage = response.error_messages;
68
+ if (typeof errorMessage === 'object') {
69
+ errorMessage = errorMessage.join("\n");
70
+ }
71
 
72
+ // Determine if the error message contains a generic message from a payment failure
73
+ if (errorMessage.indexOf('attempt refreshing the page') !== -1 ||
74
+ errorMessage.indexOf('please try another payment method or contacting your issuing bank') !== -1 ||
75
+ errorMessage.indexOf('please try again or consider using an alternate payment method') !== -1 ||
76
+ errorMessage.indexOf('Your card payment has failed') !== -1
77
+ ) {
78
+ response.goto_section = 'payment';
79
+ transport.responseText = JSON.stringify(response);
80
+ }
81
  }
82
 
83
  // Run the original action
84
+ return vzeroIntegration._originalNextStep.call(this, transport);
85
  };
86
  },
87
 
app/design/frontend/base/default/template/gene/braintree/js/firecheckout.phtml CHANGED
@@ -17,6 +17,14 @@
17
  return checkout.validate();
18
  },
19
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Attach an observer to the submit action of the checkout to tokenize the card details
22
  */
@@ -25,9 +33,6 @@
25
  // Store a pointer to the vZero integration
26
  var vzeroIntegration = this;
27
 
28
- // Store the old complete checkout function
29
- var _originalSave = FireCheckout.prototype.save;
30
-
31
  // Re-define the original method so we can do some jazz with it
32
  FireCheckout.prototype.save = function () {
33
 
@@ -37,14 +42,17 @@
37
  var paymentThis = this;
38
  var paymentArguments = arguments;
39
 
 
 
 
40
  // If everything was a success on the checkout end, let's submit the vZero integration
41
  vzeroIntegration.submit('creditcard', function () {
42
- return _originalSave.apply(paymentThis, paymentArguments);
43
  });
44
 
45
  } else {
46
  // If not run the original code
47
- return _originalSave.apply(this, arguments);
48
  }
49
 
50
  };
@@ -56,7 +64,8 @@
56
  */
57
  submitCheckout: function() {
58
  // Run the original checkouts submit action
59
- return checkout.save();
 
60
  },
61
 
62
  /**
@@ -87,7 +96,7 @@
87
  (window.vzeroPaypal || false),
88
  '<div id="paypal-complete"><div id="paypal-container"></div></div>',
89
  '#review-buttons-container .btn-checkout',
90
- true,
91
  {
92
  ignoreAjax: ['firecheckout/index/saveOrder']
93
  }
17
  return checkout.validate();
18
  },
19
 
20
+ /**
21
+ * Capture the original submit function
22
+ */
23
+ captureOriginalSubmitFn: function () {
24
+ this._originalSubmitFn = FireCheckout.prototype.save;
25
+ return true;
26
+ },
27
+
28
  /**
29
  * Attach an observer to the submit action of the checkout to tokenize the card details
30
  */
33
  // Store a pointer to the vZero integration
34
  var vzeroIntegration = this;
35
 
 
 
 
36
  // Re-define the original method so we can do some jazz with it
37
  FireCheckout.prototype.save = function () {
38
 
42
  var paymentThis = this;
43
  var paymentArguments = arguments;
44
 
45
+ // Store last arguments to make a proper request from submitCheckout method
46
+ vzeroIntegration.fireCheckoutArguments = arguments;
47
+
48
  // If everything was a success on the checkout end, let's submit the vZero integration
49
  vzeroIntegration.submit('creditcard', function () {
50
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
51
  });
52
 
53
  } else {
54
  // If not run the original code
55
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
56
  }
57
 
58
  };
64
  */
65
  submitCheckout: function() {
66
  // Run the original checkouts submit action
67
+ var fireCheckoutArguments = this.fireCheckoutArguments || [];
68
+ return checkout.save.apply(checkout, fireCheckoutArguments);
69
  },
70
 
71
  /**
96
  (window.vzeroPaypal || false),
97
  '<div id="paypal-complete"><div id="paypal-container"></div></div>',
98
  '#review-buttons-container .btn-checkout',
99
+ $$('.firecheckout-set.onecolumn').length === 0,
100
  {
101
  ignoreAjax: ['firecheckout/index/saveOrder']
102
  }
app/design/frontend/base/default/template/gene/braintree/js/fme.phtml CHANGED
@@ -28,6 +28,14 @@
28
  return onestepcheckout.setLoadWaitingPayment(false);
29
  },
30
 
 
 
 
 
 
 
 
 
31
  /**
32
  * Attach an observer to the submit action of the checkout to tokenize the card details
33
  */
@@ -36,9 +44,6 @@
36
  // Store a pointer to the vZero integration
37
  var vzeroIntegration = this;
38
 
39
- // Store the old complete checkout function
40
- var _originalSave = Review.prototype.save;
41
-
42
  // Re-define the original method so we can do some jazz with it
43
  Review.prototype.save = function () {
44
 
@@ -50,12 +55,12 @@
50
 
51
  // If everything was a success on the checkout end, let's submit the vZero integration
52
  vzeroIntegration.submit('creditcard', function () {
53
- return _originalSave.apply(paymentThis, paymentArguments);
54
  });
55
 
56
  } else {
57
  // If not run the original code
58
- return _originalSave.apply(this, arguments);
59
  }
60
 
61
  };
28
  return onestepcheckout.setLoadWaitingPayment(false);
29
  },
30
 
31
+ /**
32
+ * Capture the original submit function
33
+ */
34
+ captureOriginalSubmitFn: function () {
35
+ this._originalSubmitFn = Review.prototype.save;
36
+ return true;
37
+ },
38
+
39
  /**
40
  * Attach an observer to the submit action of the checkout to tokenize the card details
41
  */
44
  // Store a pointer to the vZero integration
45
  var vzeroIntegration = this;
46
 
 
 
 
47
  // Re-define the original method so we can do some jazz with it
48
  Review.prototype.save = function () {
49
 
55
 
56
  // If everything was a success on the checkout end, let's submit the vZero integration
57
  vzeroIntegration.submit('creditcard', function () {
58
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
59
  });
60
 
61
  } else {
62
  // If not run the original code
63
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
64
  }
65
 
66
  };
app/design/frontend/base/default/template/gene/braintree/js/idev.phtml CHANGED
@@ -60,6 +60,14 @@
60
  }
61
  },
62
 
 
 
 
 
 
 
 
 
63
  /**
64
  * Attach an observer to the submit action of the checkout to tokenize the card details
65
  */
@@ -69,7 +77,6 @@
69
  var vzeroIntegration = this;
70
 
71
  // Observe the click event
72
- var _originalSubmitEvent = $('onestepcheckout-form').submit;
73
  $('onestepcheckout-form').submit = function braintreeOverride(forceOriginal) {
74
  forceOriginal = forceOriginal || false;
75
 
@@ -77,11 +84,11 @@
77
 
78
  // If everything was a success on the checkout end, let's submit the vZero integration
79
  vzeroIntegration.submit('creditcard', function () {
80
- return _originalSubmitEvent.call($('onestepcheckout-form'), arguments);
81
  });
82
 
83
  } else {
84
- return _originalSubmitEvent.call($('onestepcheckout-form'), arguments);
85
  }
86
 
87
  };
60
  }
61
  },
62
 
63
+ /**
64
+ * Capture the original submit function
65
+ */
66
+ captureOriginalSubmitFn: function () {
67
+ this._originalSubmitFn = $('onestepcheckout-form').submit;
68
+ return true;
69
+ },
70
+
71
  /**
72
  * Attach an observer to the submit action of the checkout to tokenize the card details
73
  */
77
  var vzeroIntegration = this;
78
 
79
  // Observe the click event
 
80
  $('onestepcheckout-form').submit = function braintreeOverride(forceOriginal) {
81
  forceOriginal = forceOriginal || false;
82
 
84
 
85
  // If everything was a success on the checkout end, let's submit the vZero integration
86
  vzeroIntegration.submit('creditcard', function () {
87
+ return vzeroIntegration._originalSubmitFn.call($('onestepcheckout-form'), arguments);
88
  });
89
 
90
  } else {
91
+ return vzeroIntegration._originalSubmitFn.call($('onestepcheckout-form'), arguments);
92
  }
93
 
94
  };
app/design/frontend/base/default/template/gene/braintree/js/iwd.phtml CHANGED
@@ -80,6 +80,17 @@
80
  IWD.OPC.Checkout.unlockPlaceOrder();
81
  },
82
 
 
 
 
 
 
 
 
 
 
 
 
83
  /**
84
  * Attach an observer to the submit action of the checkout to tokenize the card details
85
  */
@@ -88,7 +99,6 @@
88
  // Store a pointer to the vZero integration
89
  var vzeroIntegration = this;
90
 
91
- var _originalSavePayment = IWD.OPC.savePayment;
92
  IWD.OPC.savePayment = function () {
93
 
94
  // Never call this bizarre function for our method
@@ -115,12 +125,11 @@
115
  }
116
 
117
  // Run the original method
118
- return _originalSavePayment.apply(this, arguments);
119
 
120
  };
121
 
122
  // Intercept the save order to process the credit card
123
- var _originalSaveOrder = IWD.OPC.saveOrder;
124
  IWD.OPC.saveOrder = function() {
125
 
126
  if (vzeroIntegration.shouldInterceptSubmit('creditcard')) {
@@ -131,30 +140,26 @@
131
 
132
  // If everything was a success on the checkout end, let's submit the vZero integration
133
  vzeroIntegration.submit('creditcard', function () {
134
- return _originalSaveOrder.apply(paymentThis, paymentArguments);
135
  });
136
 
137
  } else {
138
  // If not run the original code
139
- return _originalSaveOrder.apply(this, arguments);
140
  }
141
 
142
  };
143
 
144
  // When IWD binds payment fields we wanna init
145
- var _originalBindChangePaymentFields = IWD.OPC.bindChangePaymentFields;
146
  IWD.OPC.bindChangePaymentFields = function() {
147
-
148
  vzeroIntegration.paymentMethodSwitch();
149
-
150
- return _originalBindChangePaymentFields.apply(this, arguments);
151
  };
152
 
153
  // Stop the system from validating the credit card hosted fields form for hosted fields
154
- var _originalValidatePayment = IWD.OPC.validatePayment;
155
  IWD.OPC.validatePayment = function() {
156
  if (IWD.OPC.saveOrderStatus === true || vzeroIntegration.getPaymentMethod() != 'gene_braintree_creditcard' || (vzeroIntegration.getPaymentMethod() == 'gene_braintree_creditcard' && !vzeroIntegration.vzero.hostedFields)) {
157
- return _originalValidatePayment.apply(this, arguments);
158
  }
159
  };
160
 
@@ -182,7 +187,6 @@
182
  '.opc-btn-checkout',
183
  true,
184
  {
185
- /* This checkout performs a number of Ajax requests that shouldn't cause Braintree to need a new quote total */
186
  ignoreAjax: [
187
  'onepage/json/saveOrder',
188
  'onepage/json/review'
80
  IWD.OPC.Checkout.unlockPlaceOrder();
81
  },
82
 
83
+ /**
84
+ * Capture the original submit function
85
+ */
86
+ captureOriginalSubmitFn: function () {
87
+ this._originalSavePaymentFn = IWD.OPC.savePayment;
88
+ this._originalSubmitFn = IWD.OPC.saveOrder;
89
+ this._originalBindChangePaymentFieldsFn = IWD.OPC.bindChangePaymentFields;
90
+ this._originalValidatePaymentFn = IWD.OPC.validatePayment;
91
+ return true;
92
+ },
93
+
94
  /**
95
  * Attach an observer to the submit action of the checkout to tokenize the card details
96
  */
99
  // Store a pointer to the vZero integration
100
  var vzeroIntegration = this;
101
 
 
102
  IWD.OPC.savePayment = function () {
103
 
104
  // Never call this bizarre function for our method
125
  }
126
 
127
  // Run the original method
128
+ return vzeroIntegration._originalSavePaymentFn.apply(this, arguments);
129
 
130
  };
131
 
132
  // Intercept the save order to process the credit card
 
133
  IWD.OPC.saveOrder = function() {
134
 
135
  if (vzeroIntegration.shouldInterceptSubmit('creditcard')) {
140
 
141
  // If everything was a success on the checkout end, let's submit the vZero integration
142
  vzeroIntegration.submit('creditcard', function () {
143
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
144
  });
145
 
146
  } else {
147
  // If not run the original code
148
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
149
  }
150
 
151
  };
152
 
153
  // When IWD binds payment fields we wanna init
 
154
  IWD.OPC.bindChangePaymentFields = function() {
 
155
  vzeroIntegration.paymentMethodSwitch();
156
+ return vzeroIntegration._originalBindChangePaymentFieldsFn.apply(this, arguments);
 
157
  };
158
 
159
  // Stop the system from validating the credit card hosted fields form for hosted fields
 
160
  IWD.OPC.validatePayment = function() {
161
  if (IWD.OPC.saveOrderStatus === true || vzeroIntegration.getPaymentMethod() != 'gene_braintree_creditcard' || (vzeroIntegration.getPaymentMethod() == 'gene_braintree_creditcard' && !vzeroIntegration.vzero.hostedFields)) {
162
+ return vzeroIntegration._originalValidatePaymentFn.apply(this, arguments);
163
  }
164
  };
165
 
187
  '.opc-btn-checkout',
188
  true,
189
  {
 
190
  ignoreAjax: [
191
  'onepage/json/saveOrder',
192
  'onepage/json/review'
app/design/frontend/base/default/template/gene/braintree/js/magestore.phtml CHANGED
@@ -54,6 +54,14 @@
54
  $('onestepcheckout-place-order-loading').hide();
55
  },
56
 
 
 
 
 
 
 
 
 
57
  /**
58
  * Attach an observer to the submit action of the checkout to tokenize the card details
59
  */
@@ -62,9 +70,6 @@
62
  // Store a pointer to the vZero integration
63
  var vzeroIntegration = this;
64
 
65
- // Store the old complete checkout function
66
- var _originalOscPlaceOrder = oscPlaceOrder;
67
-
68
  // Re-define the original method so we can do some jazz with it
69
  oscPlaceOrder = function (element) {
70
 
@@ -76,12 +81,12 @@
76
 
77
  // If everything was a success on the checkout end, let's submit the vZero integration
78
  vzeroIntegration.submit('creditcard', function () {
79
- return _originalOscPlaceOrder.apply(paymentThis, paymentArguments);
80
  });
81
 
82
  } else {
83
  // If not run the original code
84
- return _originalOscPlaceOrder.apply(this, arguments);
85
  }
86
 
87
  };
54
  $('onestepcheckout-place-order-loading').hide();
55
  },
56
 
57
+ /**
58
+ * Capture the original submit function
59
+ */
60
+ captureOriginalSubmitFn: function () {
61
+ this._originalSubmitFn = oscPlaceOrder;
62
+ return true;
63
+ },
64
+
65
  /**
66
  * Attach an observer to the submit action of the checkout to tokenize the card details
67
  */
70
  // Store a pointer to the vZero integration
71
  var vzeroIntegration = this;
72
 
 
 
 
73
  // Re-define the original method so we can do some jazz with it
74
  oscPlaceOrder = function (element) {
75
 
81
 
82
  // If everything was a success on the checkout end, let's submit the vZero integration
83
  vzeroIntegration.submit('creditcard', function () {
84
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
85
  });
86
 
87
  } else {
88
  // If not run the original code
89
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
90
  }
91
 
92
  };
app/design/frontend/base/default/template/gene/braintree/js/multishipping.phtml CHANGED
@@ -21,6 +21,14 @@
21
  $('payment-continue').removeClassName('loading');
22
  },
23
 
 
 
 
 
 
 
 
 
24
  /**
25
  * Attach an observer to the submit action of the checkout to tokenize the card details
26
  */
@@ -30,7 +38,6 @@
30
  var vzeroIntegration = this;
31
 
32
  // Observe the click event
33
- var _originalSubmitEvent = $('multishipping-billing-form').submit;
34
  $('multishipping-billing-form').onsubmit = function braintreeOverride(event) {
35
 
36
  // Stop the event
@@ -40,11 +47,11 @@
40
 
41
  // If everything was a success on the checkout end, let's submit the vZero integration
42
  vzeroIntegration.submit('creditcard', function () {
43
- return _originalSubmitEvent.call($('multishipping-billing-form'), arguments);
44
  });
45
 
46
  } else {
47
- return _originalSubmitEvent.call($('multishipping-billing-form'), arguments);
48
  }
49
 
50
  };
21
  $('payment-continue').removeClassName('loading');
22
  },
23
 
24
+ /**
25
+ * Capture the original submit function
26
+ */
27
+ captureOriginalSubmitFn: function () {
28
+ this._originalSubmitFn = $('multishipping-billing-form').submit;
29
+ return true;
30
+ },
31
+
32
  /**
33
  * Attach an observer to the submit action of the checkout to tokenize the card details
34
  */
38
  var vzeroIntegration = this;
39
 
40
  // Observe the click event
 
41
  $('multishipping-billing-form').onsubmit = function braintreeOverride(event) {
42
 
43
  // Stop the event
47
 
48
  // If everything was a success on the checkout end, let's submit the vZero integration
49
  vzeroIntegration.submit('creditcard', function () {
50
+ return vzeroIntegration._originalSubmitFn.call($('multishipping-billing-form'), arguments);
51
  });
52
 
53
  } else {
54
+ return vzeroIntegration._originalSubmitFn.call($('multishipping-billing-form'), arguments);
55
  }
56
 
57
  };
app/design/frontend/base/default/template/gene/braintree/js/oye.phtml CHANGED
@@ -25,6 +25,15 @@
25
  checkout.resetLoadWaiting();
26
  },
27
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Attach an observer to the submit action of the checkout to tokenize the card details
30
  */
@@ -33,9 +42,6 @@
33
  // Store a pointer to the vZero integration
34
  var vzeroIntegration = this;
35
 
36
- // Store the old complete checkout function
37
- var _originalSaveOrder = Checkout.prototype.saveOrder;
38
-
39
  // Re-define the original method so we can do some jazz with it
40
  Checkout.prototype.saveOrder = function () {
41
 
@@ -47,12 +53,12 @@
47
 
48
  // If everything was a success on the checkout end, let's submit the vZero integration
49
  vzeroIntegration.submit('creditcard', function () {
50
- return _originalSaveOrder.apply(paymentThis, paymentArguments);
51
  });
52
 
53
  } else {
54
  // If not run the original code
55
- return _originalSaveOrder.apply(this, arguments);
56
  }
57
 
58
  };
@@ -61,10 +67,9 @@
61
  Review.prototype.save = function() { return false; };
62
 
63
  // Fix the system that updates the contents
64
- var _originalUpdateContents = Checkout.prototype.updateContents;
65
  Checkout.prototype.updateContents = function(contents, updateError){
66
 
67
- var response = _originalUpdateContents.apply(this, arguments);
68
 
69
  // Only run these functions if we're updating the review block
70
  if (typeof contents.blocks == 'object' && 'review' in contents.blocks) {
25
  checkout.resetLoadWaiting();
26
  },
27
 
28
+ /**
29
+ * Capture the original submit function
30
+ */
31
+ captureOriginalSubmitFn: function () {
32
+ this._originalSubmitFn = Checkout.prototype.saveOrder;
33
+ this._originalUpdateContents = Checkout.prototype.updateContents;
34
+ return true;
35
+ },
36
+
37
  /**
38
  * Attach an observer to the submit action of the checkout to tokenize the card details
39
  */
42
  // Store a pointer to the vZero integration
43
  var vzeroIntegration = this;
44
 
 
 
 
45
  // Re-define the original method so we can do some jazz with it
46
  Checkout.prototype.saveOrder = function () {
47
 
53
 
54
  // If everything was a success on the checkout end, let's submit the vZero integration
55
  vzeroIntegration.submit('creditcard', function () {
56
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
57
  });
58
 
59
  } else {
60
  // If not run the original code
61
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
62
  }
63
 
64
  };
67
  Review.prototype.save = function() { return false; };
68
 
69
  // Fix the system that updates the contents
 
70
  Checkout.prototype.updateContents = function(contents, updateError){
71
 
72
+ var response = vzeroIntegration._originalUpdateContents.apply(this, arguments);
73
 
74
  // Only run these functions if we're updating the review block
75
  if (typeof contents.blocks == 'object' && 'review' in contents.blocks) {
app/design/frontend/base/default/template/gene/braintree/js/setup.phtml CHANGED
@@ -17,22 +17,24 @@
17
  false,
18
  false,
19
  '<?php echo Mage::getUrl('braintree/checkout/quoteTotal', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())); ?>',
20
- '<?php echo Mage::getUrl('braintree/checkout/tokenizeCard', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())); ?>',
21
- '<?php echo Mage::getUrl('braintree/checkout/vaultToNonce', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())); ?>'
22
  );
23
 
24
- <?php if ($this->isPayPalActive()) : ?>
25
- // Pass some data through to the PayPal integration
26
- var vzeroPaypal = new vZeroPayPalButton(
27
- '<?php echo $this->getClientToken(); ?>',
28
- '<?php echo Mage::app()->getStore()->getFrontendName(); ?>',
29
- <?php echo $this->getSingleUse(); ?>,
30
- '<?php echo $this->getLocale(); ?>',
31
- <?php echo $this->getSingleFutureUse(); ?>,
32
- vzero
33
- );
34
  <?php endif; ?>
35
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
  </script>
38
 
17
  false,
18
  false,
19
  '<?php echo Mage::getUrl('braintree/checkout/quoteTotal', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())); ?>',
20
+ '<?php echo Mage::getUrl('braintree/checkout/tokenizeCard', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())); ?>'
 
21
  );
22
 
23
+ <?php if ($this->isThreeDSpecificCountries()) : ?>
24
+ vzero.setThreeDCountries('<?php echo $this->getThreeDSpecificCountries(); ?>');
 
 
 
 
 
 
 
 
25
  <?php endif; ?>
26
 
27
+ <?php if ($this->isPayPalActive()) : ?>
28
+ // Pass some data through to the PayPal integration
29
+ var vzeroPaypal = new vZeroPayPalButton(
30
+ '<?php echo $this->getClientToken(); ?>',
31
+ '<?php echo Mage::app()->getStore()->getFrontendName(); ?>',
32
+ <?php echo $this->getSingleUse(); ?>,
33
+ '<?php echo $this->getLocale(); ?>',
34
+ <?php echo $this->getSingleFutureUse(); ?>,
35
+ <?php echo $this->shouldOnlyVaultOnVault() ? $this->shouldOnlyVaultOnVault() : 'false'; ?>
36
+ );
37
+ <?php endif; ?>
38
  }
39
  </script>
40
 
app/design/frontend/base/default/template/gene/braintree/js/unicode.phtml CHANGED
@@ -22,6 +22,14 @@
22
  return (validators[0].validate() && validators[1].validate() && checkout.shippingMethodValidate() && checkout.paymentMethodValidate() && (validators[3] ? validators[3].validate() : true));
23
  },
24
 
 
 
 
 
 
 
 
 
25
  /**
26
  * Attach an observer to the submit action of the checkout to tokenize the card details
27
  */
@@ -30,9 +38,6 @@
30
  // Store a pointer to the vZero integration
31
  var vzeroIntegration = this;
32
 
33
- // Store the old complete checkout function
34
- var _originalSave = CheckoutMain.prototype.save;
35
-
36
  // Re-define the original method so we can do some jazz with it
37
  CheckoutMain.prototype.save = function () {
38
 
@@ -44,12 +49,12 @@
44
 
45
  // If everything was a success on the checkout end, let's submit the vZero integration
46
  vzeroIntegration.submit('creditcard', function () {
47
- return _originalSave.apply(paymentThis, paymentArguments);
48
  });
49
 
50
  } else {
51
  // If not run the original code
52
- return _originalSave.apply(this, arguments);
53
  }
54
 
55
  };
22
  return (validators[0].validate() && validators[1].validate() && checkout.shippingMethodValidate() && checkout.paymentMethodValidate() && (validators[3] ? validators[3].validate() : true));
23
  },
24
 
25
+ /**
26
+ * Capture the original submit function
27
+ */
28
+ captureOriginalSubmitFn: function () {
29
+ this._originalSubmitFn = CheckoutMain.prototype.save;
30
+ return true;
31
+ },
32
+
33
  /**
34
  * Attach an observer to the submit action of the checkout to tokenize the card details
35
  */
38
  // Store a pointer to the vZero integration
39
  var vzeroIntegration = this;
40
 
 
 
 
41
  // Re-define the original method so we can do some jazz with it
42
  CheckoutMain.prototype.save = function () {
43
 
49
 
50
  // If everything was a success on the checkout end, let's submit the vZero integration
51
  vzeroIntegration.submit('creditcard', function () {
52
+ return vzeroIntegration._originalSubmitFn.apply(paymentThis, paymentArguments);
53
  });
54
 
55
  } else {
56
  // If not run the original code
57
+ return vzeroIntegration._originalSubmitFn.apply(this, arguments);
58
  }
59
 
60
  };
js/gene/braintree/2.1.3/express/abstract-min.js ADDED
@@ -0,0 +1 @@
 
1
+ var BraintreeExpressAbstract=Class.create();BraintreeExpressAbstract.prototype={initialize:function(e,t,o,s,a,n){this.clientToken=e,this.storeFrontName=t,this.formKey=o,this.source=s,this.urls=a,this.config=n||{},this._init(),this.insertDom()},_init:function(){return!1},insertDom:function(){this.getModal()||$$("body").first().insert('<div id="pp-express-overlay"></div><div id="pp-express-modal"></div><div id="pp-express-container"></div>')},getOverlay:function(){return document.getElementById("pp-express-overlay")},getModal:function(){return document.getElementById("pp-express-modal")},hideModal:function(){this.getOverlay().style.display="none",this.getModal().style.display="none",this.getModal().innerHTML=""},showModal:function(){this.getModal().innerHTML="",this.getModal().classList.add("loading"),this.getOverlay().style.display="block",this.getModal().style.display="block"},initModal:function(e){"undefined"==typeof e.form_key&&(e.form_key=this.formKey),"undefined"==typeof e.source&&(e.source=this.source),this.showModal(),new Ajax.Request(this.urls.authUrl,{method:"POST",parameters:e,onSuccess:function(e){this.getModal().classList.remove("loading"),this.getModal().innerHTML=e.responseText,this.prepareCoupon(),this.ajaxHandler()}.bind(this),onFailure:function(){this.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}.bind(this)})},updateShipping:function(e){this._setLoading($("paypal-express-submit")),new Ajax.Request(this.urls.shippingSaveUrl,{method:"POST",parameters:{submit_shipping:!0,shipping_method:e},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-submit")),this._updateTotals(t)}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}})},prepareCoupon:function(){$("paypal-express-coupon")&&$("paypal-express-coupon").observe("keypress",function(e){var t=e.which||e.keyCode;t==Event.KEY_RETURN&&(Event.stop(e),this.updateCoupon())}.bind(this))},updateCoupon:function(e){return $("paypal-express-coupon-error").hide(),!e&&$("paypal-express-coupon")&&(e=$("paypal-express-coupon").value),""!=e&&(this._setLoading($("paypal-express-coupon-apply")),new Ajax.Request(this.urls.couponSaveUrl,{method:"POST",parameters:{coupon:e},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-coupon-apply")),this._updateTotals(t),1==t.success?($("paypal-express-coupon-remove").show(),$("paypal-express-coupon-apply").hide()):t.message&&$("paypal-express-coupon-error").update(t.message).show()}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-coupon-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}}),!1)},removeCoupon:function(){$("paypal-express-coupon-error").hide(),this._setLoading($("paypal-express-coupon-remove")),new Ajax.Request(this.urls.couponSaveUrl,{method:"POST",parameters:{remove:!0},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-coupon-remove")),this._updateTotals(t),1==t.success?($("paypal-express-coupon-remove").hide(),$("paypal-express-coupon-apply").show(),$("paypal-express-coupon").value="",$("paypal-express-coupon").focus()):t.message&&$("paypal-express-coupon-error").update(t.message).show()}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-coupon-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}})},_updateTotals:function(e){"undefined"!=typeof e.totals&&$("paypal-express-totals").update(e.totals)},_getJson:function(e){return"undefined"!=typeof e.responseJSON?e.responseJSON:"string"==typeof e.responseText?e.responseText.evalJSON():void 0},_setLoading:function(e){return!!e&&(e.setAttribute("disabled","disabled"),void e.addClassName("loading"))},_unsetLoading:function(e){return!!e&&(e.removeAttribute("disabled"),void e.removeClassName("loading"))},ajaxHandler:function(){var e=this.getModal().getElementsByTagName("form"),t=0;if(e.length>0)for(t=0;t<e.length;t++)Element.observe(e[t],"submit",function(e){return Event.stop(e),this.getModal().classList.add("loading"),this.getModal().innerHTML="",new Ajax.Request(e.target.getAttribute("action"),{method:"POST",parameters:$(e.target).serialize(!0),onSuccess:function(e){return"complete"==e.responseText?void(document.location=this.urls.successUrl):(this.getModal().classList.remove("loading"),this.getModal().innerHTML=e.responseText,void this.ajaxHandler())}.bind(this),onFailure:function(){this.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}.bind(this)}),!1}.bind(this))},validateForm:function(){if("object"==typeof productAddToCartForm&&productAddToCartForm.validator.validate()){if("object"==typeof productAddToCartFormOld&&productAddToCartFormOld.validator.validate())return!0;if("object"!=typeof productAddToCartFormOld)return!0}return"object"!=typeof productAddToCartForm&&"object"!=typeof productAddToCartFormOld},attachToButtons:function(e){console.warn("This method cannot be called directly.")}};
js/gene/braintree/{express → 2.1.3/express}/paypal-min.js RENAMED
File without changes
js/gene/braintree/2.1.3/vzero-integration-min.js ADDED
@@ -0,0 +1 @@
 
1
+ var vZeroIntegration=Class.create();vZeroIntegration.prototype={initialize:function(e,t,i,n,a,o,s){return vZeroIntegration.prototype.loaded?(console.error("Your checkout is including the Braintree resources multiple times, please resolve this."),!1):(vZeroIntegration.prototype.loaded=!0,this.vzero=e||!1,this.vzeroPaypal=t||!1,this.vzero===!1&&this.vzeroPaypal===!1?(console.warn("The vzero and vzeroPaypal objects are not initiated."),!1):(this.paypalWrapperMarkUp=i||!1,this.paypalButtonClass=n||!1,this.submitButtonClass=this.paypalButtonClass,this.isOnepage=a||!1,this.config=o||{},this.submitAfterPayment=s||!1,this._methodSwitchTimeout=!1,this._originalSubmitFn=!1,document.observe("dom:loaded",function(){this.captureOriginalSubmitFn()&&this.observeSubmissionOverride(),this.prepareSubmitObserver(),this.preparePaymentMethodSwitchObserver()}.bind(this)),this.hostedFieldsGenerated=!1,this.isOnepage&&(this.observeAjaxRequests(),document.observe("dom:loaded",function(){this.initSavedPayPal(),this.initDefaultMethod(),null!==$("braintree-hosted-submit")&&this.initHostedFields()}.bind(this))),document.observe("dom:loaded",function(){this.initSavedMethods(),null!==$("braintree-hosted-submit")&&this.initHostedFields()}.bind(this)),this._deviceDataInit=!1,this.vzero.observeEvent(["onHandleAjaxRequest","integration.onInitSavedMethods"],this.initDeviceData,this),this.vzero.observeEvent("integration.onBeforeSubmit",function(){null!=$("braintree-device-data")&&$("braintree-device-data").writeAttribute("disabled",!1)},this),void this.vzero.fireEvent(this,"integration.onInit",{integration:this})))},initDeviceData:function(e,t){if(null!=$("credit-card-form")){var i=$("credit-card-form").up("form");if(void 0!=i&&0==i.select("#braintree-device-data").length){if(t._deviceDataInit===!0)return!1;t._deviceDataInit=!0;var n=new Element("input",{type:"hidden",name:"payment[device_data]",id:"braintree-device-data"});i.insert(n),t.populateDeviceData(n)}}},populateDeviceData:function(e){this.vzero.getClient(function(t){braintree.dataCollector.create({client:t,kount:!0,paypal:!0},function(t,i){return t?void console.warn(t):(e.value=i.deviceData,e.writeAttribute("disabled",!1),void(this._deviceDataInit=!1))}.bind(this))}.bind(this))},initSavedMethods:function(){$$('#creditcard-saved-accounts input[type="radio"], #paypal-saved-accounts input[type="radio"]').each(function(e){var t="",i="";void 0!==e.up("#creditcard-saved-accounts")?(t="#creditcard-saved-accounts",i="#credit-card-form"):void 0!==e.up("#paypal-saved-accounts")&&(t="#paypal-saved-accounts",i=".paypal-info"),$(e).stopObserving("change").observe("change",function(e){return this.showHideOtherMethod(t,i)}.bind(this))}.bind(this)),this.vzero.fireEvent(this,"integration.onInitSavedMethods")},showHideOtherMethod:function(e,t){void 0!==$$(e+" input:checked[type=radio]").first()&&"other"==$$(e+" input:checked[type=radio]").first().value?void 0!==$$(t).first()&&($$(t).first().show(),$$(t+" input, "+t+" select").each(function(e){e.removeAttribute("disabled")})):void 0!==$$(e+" input:checked[type=radio]").first()&&void 0!==$$(t).first()&&($$(t).first().hide(),$$(t+" input, "+t+" select").each(function(e){e.setAttribute("disabled","disabled")})),this.vzero.fireEvent(this,"integration.onShowHideOtherMethod",{parentElement:e,targetElement:t})},checkSavedOther:function(){var e="",t="";"gene_braintree_creditcard"==this.getPaymentMethod()?(e="#creditcard-saved-accounts",t="#credit-card-form"):"gene_braintree_paypal"==this.getPaymentMethod()&&(e="#paypal-saved-accounts",t=".paypal-info"),void 0!==$$(e).first()&&this.showHideOtherMethod(e,t),this.vzero.fireEvent(this,"integration.onCheckSavedOther")},afterPaymentMethodSwitch:function(){return!0},initHostedFields:function(){this.vzero.hostedFields&&null!==$("braintree-hosted-submit")&&(void 0!==$("braintree-hosted-submit").up("form")?(this.form=$("braintree-hosted-submit").up("form"),this.vzero.initHostedFields(this)):console.error("Hosted Fields cannot be initialized as we're unable to locate the parent form."))},initDefaultMethod:function(){this.shouldAddPayPalButton(!1)&&(this.setLoading(),this.vzero.updateData(function(){this.resetLoading(),this.updatePayPalButton("add")}.bind(this))),this.afterPaymentMethodSwitch(),this.vzero.fireEvent(this,"integration.onInitDefaultMethod")},observeAjaxRequests:function(){this.vzero.observeAjaxRequests(function(){this.vzero.updateData(function(){this.isOnepage&&(this.initSavedPayPal(),this.rebuildPayPalButton(),this.checkSavedOther(),this.vzero.hostedFields&&this.initHostedFields()),this.initSavedMethods(),this.afterPaymentMethodSwitch(),this.vzero.fireEvent(this,"integration.onObserveAjaxRequests")}.bind(this))}.bind(this),"undefined"!=typeof this.config.ignoreAjax&&this.config.ignoreAjax)},rebuildPayPalButton:function(){null==$("paypal-container")&&this.updatePayPalButton()},initSavedPayPal:function(){void 0!==$$("#paypal-saved-accounts input[type=radio]").first()&&$("paypal-saved-accounts").on("change","input[type=radio]",function(e){this.updatePayPalButton(!1,"gene_braintree_paypal")}.bind(this))},captureOriginalSubmitFn:function(){return!1},observeSubmissionOverride:function(){setInterval(function(){this._originalSubmitFn&&this.prepareSubmitObserver()}.bind(this),500)},prepareSubmitObserver:function(){return!1},beforeSubmit:function(e){return this._beforeSubmit(e)},_beforeSubmit:function(e){this.vzero.fireEvent(this,"integration.onBeforeSubmit"),this.submitAfterPayment&&$("braintree-submit-after-payment")&&$("braintree-submit-after-payment").remove(),e()},afterSubmit:function(){return this.vzero.fireEvent(this,"integration.onAfterSubmit"),!1},submit:function(e,t,i,n){this.vzero._hostedFieldsTokenGenerated=!1,this.hostedFieldsGenerated=!1,this.shouldInterceptSubmit(e)&&(this.validateAll()?(this.setLoading(),this.beforeSubmit(function(){void 0!=$$('[data-genebraintree-name="number"]').first()&&this.vzero.updateCardType($$('[data-genebraintree-name="number"]').first().value),this.vzero.updateData(function(){this.updateBilling(),this.vzero.process({onSuccess:function(){if(this.enableDeviceData(),this.resetLoading(),this.afterSubmit(),this.enableDisableNonce(),this.vzero._hostedFieldsTokenGenerated=!0,this.hostedFieldsGenerated=!0,"function"==typeof t)var e=t();return this.setLoading(),e}.bind(this),onFailure:function(){if(this.vzero._hostedFieldsTokenGenerated=!1,this.hostedFieldsGenerated=!1,this.resetLoading(),this.afterSubmit(),"function"==typeof i)return i()}.bind(this)})}.bind(this),this.getUpdateDataParams())}.bind(this))):(this.vzero._hostedFieldsTokenGenerated=!1,this.hostedFieldsGenerated=!1,this.resetLoading(),"function"==typeof n&&n()))},submitCheckout:function(){window.review&&review.save()},submitPayment:function(){payment.save&&payment.save()},enableDisableNonce:function(){"gene_braintree_creditcard"==this.getPaymentMethod()?(null!==$("creditcard-payment-nonce")&&$("creditcard-payment-nonce").removeAttribute("disabled"),null!==$("paypal-payment-nonce")&&$("paypal-payment-nonce").setAttribute("disabled","disabled")):"gene_braintree_paypal"==this.getPaymentMethod()&&(null!==$("creditcard-payment-nonce")&&$("creditcard-payment-nonce").setAttribute("disabled","disabled"),null!==$("paypal-payment-nonce")&&$("paypal-payment-nonce").removeAttribute("disabled"))},preparePaymentMethodSwitchObserver:function(){return this.defaultPaymentMethodSwitch()},defaultPaymentMethodSwitch:function(){var e=this,t=Payment.prototype.switchMethod;Payment.prototype.switchMethod=function(i){return e.paymentMethodSwitch(i),t.apply(this,arguments)}},paymentMethodSwitch:function(e){clearTimeout(this._methodSwitchTimeout),this._methodSwitchTimeout=setTimeout(function(){this.shouldAddPayPalButton(e)?this.updatePayPalButton("add",e):this.updatePayPalButton("remove",e),"gene_braintree_creditcard"==(e?e:this.getPaymentMethod())&&this.initHostedFields(),this.checkSavedOther(),this.afterPaymentMethodSwitch(),this.vzero.fireEvent(this,"integration.onPaymentMethodSwitch",{method:e})}.bind(this),50)},completePayPal:function(e){return this.enableDisableNonce(),this.enableDeviceData(),e.nonce&&null!==$("paypal-payment-nonce")?($("paypal-payment-nonce").value=e.nonce,$("paypal-payment-nonce").setAttribute("value",e.nonce)):console.warn("Unable to update PayPal nonce, please verify that the nonce input field has the ID: paypal-payment-nonce"),this.afterPayPalComplete(),!1},afterPayPalComplete:function(){return this.resetLoading(),this.submitCheckout()},getPayPalMarkUp:function(){return $("braintree-paypal-button").innerHTML},updatePayPalButton:function(e,t){if(this.paypalWrapperMarkUp===!1)return!1;if("refresh"==e)return!0;if(this.shouldAddPayPalButton(t)&&"remove"!=e||"add"==e)if(void 0!==$$(this.paypalButtonClass).first()){if($$(this.paypalButtonClass).first().hide(),void 0!==$$("#paypal-complete").first())return $$("#paypal-complete").first().show(),!0;$$(this.paypalButtonClass).first().insert({after:this.paypalWrapperMarkUp}),this.vzeroPaypal.addPayPalButton({validate:this.validateAll.bind(this),onSuccess:this.completePayPal.bind(this),onReady:this.paypalOnReady.bind(this)},this.getPayPalMarkUp(),"#paypal-container")}else console.warn("We're unable to find the element "+this.paypalButtonClass+". Please check your integration.");else void 0!==$$(this.paypalButtonClass).first()&&$$(this.paypalButtonClass).first().show(),void 0!==$$("#paypal-complete").first()&&$("paypal-complete").hide()},onReviewInit:function(){this.isOnepage||this.updatePayPalButton(),this.vzero.fireEvent(this,"integration.onReviewInit")},paypalOnReady:function(e){return!0},setLoading:function(){checkout.setLoadWaiting("payment")},resetLoading:function(){checkout.setLoadWaiting(!1)},enableDeviceData:function(){null!==$("device_data")&&$("device_data").removeAttribute("disabled")},updateBilling:function(){(null!==$("billing-address-select")&&""==$("billing-address-select").value||null===$("billing-address-select"))&&(null!==$("billing:firstname")&&null!==$("billing:lastname")&&this.vzero.setBillingName($("billing:firstname").value+" "+$("billing:lastname").value),null!==$("billing:postcode")&&this.vzero.setBillingPostcode($("billing:postcode").value))},getUpdateDataParams:function(){var e={};return null!==$("billing-address-select")&&""!=$("billing-address-select").value&&(e.addressId=$("billing-address-select").value),e},getPaymentMethod:function(){return payment.currentMethod},shouldInterceptSubmit:function(e){switch(e){case"creditcard":return"gene_braintree_creditcard"==this.getPaymentMethod()&&this.vzero.shouldInterceptCreditCard();break;case"paypal":return"gene_braintree_paypal"==this.getPaymentMethod()&&this.vzero.shouldInterceptCreditCard()}return!1},shouldAddPayPalButton:function(e){return"gene_braintree_paypal"==(e?e:this.getPaymentMethod())&&null===$("paypal-saved-accounts")||"gene_braintree_paypal"==(e?e:this.getPaymentMethod())&&void 0!==$$("#paypal-saved-accounts input:checked[type=radio]").first()&&"other"==$$("#paypal-saved-accounts input:checked[type=radio]").first().value},threeDTokenizationComplete:function(){this.resetLoading()},validateAll:function(){return!0},disableCreditCardForm:function(){},enableCreditCardForm:function(){}};
js/gene/braintree/2.1.3/vzero-min.js ADDED
@@ -0,0 +1 @@
 
1
+ var vZero=Class.create();vZero.prototype={initialize:function(e,t,i,n,o,s,r,a){this.code=e,this.clientToken=t,this.threeDSecure=i,this.hostedFields=n,o&&(this.billingName=o),s&&(this.billingPostcode=s),this.billingCountryId=!1,r&&(this.quoteUrl=r),a&&(this.tokenizeUrl=a),this._hostedFieldsTokenGenerated=!1,this.acceptedCards=!1,this._hostedFieldsTimeout=!1,this._updateDataXhr=!1,this._updateDataCallbacks=[],this._updateDataParams={},this.client=!1,this.threeDSpecificCountries=!1,this.threeDCountries=[],this.initEvents()},initEvents:function(){this.events={onBeforeUpdateData:[],onAfterUpdateData:[],onHandleAjaxRequest:[],integration:{onInit:[],onInitDefaultMethod:[],onInitSavedMethods:[],onShowHideOtherMethod:[],onCheckSavedOther:[],onPaymentMethodSwitch:[],onReviewInit:[],onBeforeSubmit:[],onAfterSubmit:[],onObserveAjaxRequests:[]}}},setThreeDCountries:function(e){"string"==typeof e&&(e=e.split(",")),this.threeDSpecificCountries=!0,this.threeDCountries=e},observeEvent:function(e,t,i){Array.isArray(e)||(e=[e]),e.each(function(e){var n=this._resolveEvent(e);void 0===n?console.warn("Event for "+e+" does not exist."):n.push({fn:t,params:i})}.bind(this))},fireEvent:function(e,t,i){var n=this._resolveEvent(t);void 0!==n&&n.length>0&&n.each(function(t){if("function"==typeof t.fn){var arguments=[i];"object"==typeof t.params&&arguments.push(t.params),t.fn.apply(e,arguments)}})},_resolveEvent:function(e){return e.split(".").reduce(function(e,t){return e?e[t]:void 0},this.events)},getClient:function(e){this.client!==!1?"function"==typeof e&&e(this.client):braintree.client.create({authorization:this.clientToken},function(t,i){return t?void console.error(t):(this.client=i,void e(this.client))}.bind(this))},initHostedFields:function(e){return!($$('iframe[name^="braintree-"]').length>0)&&(null!==$("braintree-hosted-submit")&&(this.integration=e,this._hostedFieldsTokenGenerated=!1,clearTimeout(this._hostedFieldsTimeout),void(this._hostedFieldsTimeout=setTimeout(function(){if(this._hostedIntegration!==!1)try{this._hostedIntegration.teardown(function(){this._hostedIntegration=!1,this.setupHostedFieldsClient()}.bind(this))}catch(e){this.setupHostedFieldsClient()}else this.setupHostedFieldsClient()}.bind(this),50))))},teardownHostedFields:function(e){"undefined"!=typeof this._hostedIntegration&&this._hostedIntegration!==!1?this._hostedIntegration.teardown(function(){this._hostedIntegration=!1,"function"==typeof e&&e()}.bind(this)):"function"==typeof e&&e()},setupHostedFieldsClient:function(){return!($$('iframe[name^="braintree-"]').length>0)&&(this._hostedIntegration=!1,void this.getClient(function(e){var t={client:e,styles:this.getHostedFieldsStyles(),fields:{number:{selector:"#card-number",placeholder:"0000 0000 0000 0000"},expirationMonth:{selector:"#expiration-month",placeholder:"MM"},expirationYear:{selector:"#expiration-year",placeholder:"YY"}}};null!==$("cvv")&&(t.fields.cvv={selector:"#cvv"}),braintree.hostedFields.create(t,function(e,t){if(e){if("HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME"==e.code)return;return void console.error(e)}return this.hostedFieldsOnReady(t)}.bind(this))}.bind(this)))},hostedFieldsOnReady:function(e){if(this._hostedIntegration=e,$$("#credit-card-form.loading").length&&$$("#credit-card-form.loading").first().removeClassName("loading"),this.integration.submitAfterPayment){var t=new Element("input",{type:"hidden",name:"payment[submit_after_payment]",value:1,id:"braintree-submit-after-payment"});$("payment_form_gene_braintree_creditcard").insert(t)}else $("braintree-submit-after-payment")&&$("braintree-submit-after-payment").remove();e.on("cardTypeChange",this.hostedFieldsCardTypeChange.bind(this))},getHostedFieldsStyles:function(){return"function"==typeof this.integration.getHostedFieldsStyles?this.integration.getHostedFieldsStyles():{input:{"font-size":"14pt",color:"#3A3A3A"},":focus":{color:"black"},".valid":{color:"green"},".invalid":{color:"red"}}},hostedFieldsCardTypeChange:function(e){if("undefined"!=typeof e.cards){var t={visa:"VI","american-express":"AE","master-card":"MC",discover:"DI",jcb:"JCB",maestro:"ME"};void 0!==typeof t[e.cards[0].type]?this.updateCardType(!1,t[e.cards[0].type]):this.updateCardType(!1,"card")}},getBillingCountryId:function(){if(null==$("billing-address-select")||""==$("billing-address-select").value){var e=this.getBillingAddress();if("undefined"!=typeof e["billing[country_id]"])return e["billing[country_id]"]}return!!this.billingCountryId&&this.billingCountryId},shouldInvokeThreeDSecure:function(){if(this.threeDSpecificCountries&&this.threeDCountries.length>0){var e;if(e=this.getBillingCountryId())return this.threeDCountries.indexOf(e)!==-1}return this.threeDSecure},hostedFieldsNonceReceived:function(e,t){this.shouldInvokeThreeDSecure()?("function"==typeof this.integration.setLoading&&this.integration.setLoading(),this.updateData(function(){this.verify3dSecureNonce(e,{onSuccess:function(e){this.updateNonce(e.nonce),"function"==typeof t.onSuccess&&t.onSuccess()}.bind(this),onFailure:function(){"function"==typeof t.onFailure&&t.onFailure()}.bind(this)})}.bind(this))):(this.updateNonce(e),"function"==typeof t.onSuccess&&t.onSuccess())},updateNonce:function(e){$("creditcard-payment-nonce").value=e,$("creditcard-payment-nonce").setAttribute("value",e),"function"==typeof this.integration.resetLoading&&this.integration.resetLoading(),this._hostedFieldsTokenGenerated=!0},hostedFieldsError:function(e){return"function"==typeof this.integration.resetLoading&&this.integration.resetLoading(),"undefined"!=typeof e.message&&e.message.indexOf("Cannot place two elements in")==-1&&e.message.indexOf("Unable to find element with selector")==-1&&e.message.indexOf("User did not enter a payment method")==-1&&alert(e.message),this._hostedFieldsTokenGenerated=!1,"function"==typeof this.integration.afterHostedFieldsError&&this.integration.afterHostedFieldsError(e.message),!1},usingSavedCard:function(){return void 0!=$("creditcard-saved-accounts")&&void 0!=$$("#creditcard-saved-accounts input:checked[type=radio]").first()&&"other"!==$$("#creditcard-saved-accounts input:checked[type=radio]").first().value},usingSavedThreeDCard:function(){return this.usingSavedCard()&&$$("#creditcard-saved-accounts input:checked[type=radio]").first().hasAttribute("data-threedsecure-nonce")},setThreeDSecure:function(e){this.threeDSecure=e},setAmount:function(e){this.amount=parseFloat(e)},setBillingName:function(e){this.billingName=e},getBillingName:function(){return"object"==typeof this.billingName?this.combineElementsValues(this.billingName):this.billingName},setBillingPostcode:function(e){this.billingPostcode=e},getBillingPostcode:function(){return"object"==typeof this.billingPostcode?this.combineElementsValues(this.billingPostcode):this.billingPostcode},setAcceptedCards:function(e){this.acceptedCards=e},getBillingAddress:function(){if("function"==typeof this.integration.getBillingAddress)return this.integration.getBillingAddress();var e={};return null!==$("co-billing-form")?e="FORM"==$("co-billing-form").tagName?$("co-billing-form").serialize(!0):this.extractBilling($("co-billing-form").up("form").serialize(!0)):null!==$("billing:firstname")&&(e=this.extractBilling($("billing:firstname").up("form").serialize(!0))),e?e:void 0},extractBilling:function(e){var t={};return $H(e).each(function(e){0==e.key.indexOf("billing")&&e.key.indexOf("password")==-1&&(t[e.key]=e.value)}),t},getAcceptedCards:function(){return this.acceptedCards},combineElementsValues:function(e,t){t||(t=" ");var i=[];return e.each(function(e,t){void 0!==$(e)&&(i[t]=$(e).value)}),i.join(t)},updateCardType:function(e,t){if(void 0!=$("card-type-image")){var i=$("card-type-image").src.substring(0,$("card-type-image").src.lastIndexOf("/"));$("card-type-image").setAttribute("src",i+"/"+t+".png")}},observeAjaxRequests:function(e,t){return!vZero.prototype.observingAjaxRequests&&(vZero.prototype.observingAjaxRequests=!0,Ajax.Responders.register({onComplete:function(i){return this.handleAjaxRequest(i.url,e,t)}.bind(this)}),void(window.jQuery&&jQuery(document).ajaxComplete(function(i,n,o){return this.handleAjaxRequest(o.url,e,t)}.bind(this))))},handleAjaxRequest:function(e,t,i){if("undefined"!=typeof i&&i instanceof Array&&i.length>0){var n=!1;if(i.each(function(t){e&&e.indexOf(t)!=-1&&(n=!0)}),n===!0)return!1}e&&e.indexOf("/braintree/")==-1&&(this.fireEvent(this,"onHandleAjaxRequest",{url:e}),t?t(e):this.updateData())},updateData:function(e,t){this.fireEvent(this,"integration.onBeforeUpdateData",{params:t}),this._updateDataCallbacks.push(e),this._updateDataParams=t,this._updateDataXhr!==!1&&this._updateDataXhr.transport.abort(),this._updateDataXhr=new Ajax.Request(this.quoteUrl,{method:"post",parameters:this._updateDataParams,onSuccess:function(e){if(e&&(e.responseJSON||e.responseText)){var t=this._parseTransportAsJson(e);void 0!=t.billingName&&(this.billingName=t.billingName),void 0!=t.billingPostcode&&(this.billingPostcode=t.billingPostcode),void 0!=t.billingCountryId&&(this.billingCountryId=t.billingCountryId),void 0!=t.grandTotal&&(this.amount=t.grandTotal),void 0!=t.threeDSecure&&this.setThreeDSecure(t.threeDSecure),"undefined"!=typeof vzeroPaypal&&void 0!=t.grandTotal&&void 0!=t.currencyCode&&vzeroPaypal.setPricing(t.grandTotal,t.currencyCode),this._updateDataParams={},this._updateDataXhr=!1,this._updateDataCallbacks.length&&(this._updateDataCallbacks.each(function(e){e(t)}.bind(this)),this._updateDataCallbacks=[]),this.fireEvent(this,"onAfterUpdateData",{response:t})}}.bind(this),onFailure:function(){this._updateDataParams={},this._updateDataXhr=!1,this._updateDataCallbacks=[]}.bind(this)})},tokenize3dSavedCards:function(e){if(this.threeDSecure)if(void 0!==$$("[data-token]").first()){var t=[];$$("[data-token]").each(function(e,i){t[i]=e.getAttribute("data-token")}),new Ajax.Request(this.tokenizeUrl,{method:"post",onSuccess:function(t){if(t&&(t.responseJSON||t.responseText)){var i=this._parseTransportAsJson(t);i.success&&$H(i.tokens).each(function(e){void 0!=$$('[data-token="'+e.key+'"]').first()&&$$('[data-token="'+e.key+'"]').first().setAttribute("data-threedsecure-nonce",e.value)}),e&&e(i)}}.bind(this),parameters:{tokens:Object.toJSON(t)}})}else e();else e()},verify3dSecureNonce:function(e,t){this.getClient(function(i){braintree.threeDSecure.create({client:i},function(i,n){if(i)return void console.error(i);var o={amount:this.amount,nonce:e,addFrame:function(e,t){$$("#three-d-modal .bt-modal-body").first().insert(t),$("three-d-modal").removeClassName("hidden")},removeFrame:function(){$$("#three-d-modal .bt-modal-body iframe").first().remove(),$("three-d-modal").addClassName("hidden")}.bind(this)};n.verifyCard(o,function(e,i){e?t.onFailure&&t.onFailure(i,e):i.liabilityShifted?t.onSuccess&&t.onSuccess(i):i.liabilityShiftPossible?t.onSuccess&&t.onSuccess(i):t.onSuccess&&t.onSuccess(i)})}.bind(this))}.bind(this))},verify3dSecureVault:function(e){var t=$$("#creditcard-saved-accounts input:checked[type=radio]").first().getAttribute("data-threedsecure-nonce");t?this.verify3dSecureNonce(t,{onSuccess:function(t){$("creditcard-payment-nonce").removeAttribute("disabled"),$("creditcard-payment-nonce").value=t.nonce,$("creditcard-payment-nonce").setAttribute("value",t.nonce),"function"==typeof e.onSuccess&&e.onSuccess()},onFailure:function(t,i){alert(i),"function"==typeof e.onFailure?e.onFailure():checkout.setLoadWaiting(!1)}}):(alert("No payment nonce present."),"function"==typeof e.onFailure?e.onFailure():checkout.setLoadWaiting(!1))},processCard:function(e){this._hostedIntegration.tokenize(function(t,i){return t?("function"==typeof e.onFailure?e.onFailure():checkout.setLoadWaiting(!1),void("string"==typeof t.message&&alert(t.message))):this.hostedFieldsNonceReceived(i.nonce,e)}.bind(this))},shouldInterceptCreditCard:function(){return"0.00"!=this.amount},shouldInterceptPayPal:function(){return!0},process:function(e){return e=e||{},this._hostedFieldsTokenGenerated||this.usingSavedCard()&&!this.usingSavedThreeDCard()?void("function"==typeof e.onSuccess&&e.onSuccess()):this.usingSavedThreeDCard()?this.verify3dSecureVault(e):this.processCard(e)},creditCardLoaded:function(){return!1},paypalLoaded:function(){return!1},_parseTransportAsJson:function(transport){return transport.responseJSON&&"object"==typeof transport.responseJSON?transport.responseJSON:transport.responseText?"object"==typeof JSON&&"function"==typeof JSON.parse?JSON.parse(transport.responseText):eval("("+transport.responseText+")"):{}}},function(){for(var e,t=function(){},i=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],n=i.length,o=window.console=window.console||{};n--;)e=i[n],o[e]||(o[e]=t)}();
js/gene/braintree/2.1.3/vzero-paypal-min.js ADDED
@@ -0,0 +1 @@
 
1
+ var vZeroPayPalButton=Class.create();vZeroPayPalButton.prototype={initialize:function(t,e,n,i,a,o){this.clientToken=t,this.storeFrontName=e,this.singleUse=n,this.locale=i,this.amount=0,this.currency=!1,this.client=!1,this.onlyVaultOnVault=o||!1},getClient:function(t){this.client!==!1?"function"==typeof t&&t(this.client):braintree.client.create({authorization:this.clientToken},function(e,n){return e?void console.log(e):(this.client=n,void t(this.client))}.bind(this))},setPricing:function(t,e){this.amount=parseFloat(t),this.currency=e},rebuildButton:function(){return!1},addPayPalButton:function(t,e,n,i){var a;if(e=e||$("braintree-paypal-button").innerHTML,n=n||"#paypal-container",i=i||!1,a="string"==typeof n?$$(n).first():n,!a)return console.warn("Unable to locate container "+n+" for PayPal button."),!1;if(i?a.insert(e):a.update(e),!a.select(">button").length)return console.warn("Unable to find valid <button /> element within container."),!1;var o=a.select(">button").first();o.addClassName("braintree-paypal-loading"),o.setAttribute("disabled","disabled"),this.attachPayPalButtonEvent(o,t)},attachPayPalButtonEvent:function(t,e){this.getClient(function(n){braintree.paypal.create({client:n},function(n,i){return n?void console.error("Error creating PayPal:",n):("function"==typeof e.onReady&&e.onReady(i),this._attachPayPalButtonEvent(t,i,e))}.bind(this))}.bind(this))},_attachPayPalButtonEvent:function(t,e,n){t&&e&&(Array.isArray(t)||(t=[t]),t.each(function(t){t.removeClassName("braintree-paypal-loading"),t.removeAttribute("disabled"),Event.stopObserving(t,"click"),Event.observe(t,"click",function(t){return Event.stop(t),"function"!=typeof n.validate?this._tokenizePayPal(e,n):n.validate()?this._tokenizePayPal(e,n):void 0}.bind(this))}.bind(this)))},_tokenizePayPal:function(t,e){var n=this._buildOptions();"object"==typeof e.tokenizeRequest&&(n=Object.extend(n,e.tokenizeRequest)),t.tokenize(n,function(t,n){return t?void("CUSTOMER"!==t.type&&console.error("Error tokenizing:",t)):void("function"==typeof e.onSuccess&&e.onSuccess(n))}.bind(this))},_buildOptions:function(){var t={displayName:this.storeFrontName,amount:this.amount,currency:this.currency,useraction:"commit",flow:this._getFlow()};return this.locale&&(t.locale=this.locale),t},_getFlow:function(){var t;return t=this.singleUse===!0?"checkout":"vault",null!==$("gene_braintree_paypal_store_in_vault")&&this.onlyVaultOnVault&&"vault"==t&&!$("gene_braintree_paypal_store_in_vault").checked&&(t="checkout"),t}};
js/gene/braintree/config.codekit CHANGED
@@ -1,35 +1,57 @@
1
  {
2
  "CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit",
3
- "creatorBuild": "19137",
4
  "files": {
5
- "\/express.js": {
6
  "fileType": 64,
7
  "ignore": 1,
8
- "ignoreWasSetByUser": 1,
9
- "inputAbbreviatedPath": "\/express.js",
10
- "outputAbbreviatedPath": "\/min\/express-min.js",
11
  "outputPathIsOutsideProject": 0,
12
  "outputPathIsSetByUser": 0,
13
  "outputStyle": 1,
14
- "syntaxCheckerStyle": 0
 
 
 
 
 
 
 
 
 
 
 
15
  },
16
- "\/express\/abstract-min.js": {
17
  "fileType": 64,
18
  "ignore": 1,
19
  "ignoreWasSetByUser": 0,
20
- "inputAbbreviatedPath": "\/express\/abstract-min.js",
21
- "outputAbbreviatedPath": "\/express\/min\/abstract-min-min.js",
22
  "outputPathIsOutsideProject": 0,
23
  "outputPathIsSetByUser": 0,
24
  "outputStyle": 1,
25
  "syntaxCheckerStyle": 1
26
  },
27
- "\/express\/paypal-min.js": {
28
  "fileType": 64,
29
  "ignore": 1,
30
  "ignoreWasSetByUser": 0,
31
- "inputAbbreviatedPath": "\/express\/paypal-min.js",
32
- "outputAbbreviatedPath": "\/express\/min\/paypal-min-min.js",
 
 
 
 
 
 
 
 
 
 
 
33
  "outputPathIsOutsideProject": 0,
34
  "outputPathIsSetByUser": 0,
35
  "outputStyle": 1,
@@ -40,7 +62,7 @@
40
  "ignore": 0,
41
  "ignoreWasSetByUser": 0,
42
  "inputAbbreviatedPath": "\/source\/express\/abstract.js",
43
- "outputAbbreviatedPath": "\/express\/abstract-min.js",
44
  "outputPathIsOutsideProject": 0,
45
  "outputPathIsSetByUser": 1,
46
  "outputStyle": 1,
@@ -51,7 +73,7 @@
51
  "ignore": 0,
52
  "ignoreWasSetByUser": 0,
53
  "inputAbbreviatedPath": "\/source\/express\/paypal.js",
54
- "outputAbbreviatedPath": "\/express\/paypal-min.js",
55
  "outputPathIsOutsideProject": 0,
56
  "outputPathIsSetByUser": 1,
57
  "outputStyle": 1,
@@ -62,7 +84,7 @@
62
  "ignore": 0,
63
  "ignoreWasSetByUser": 0,
64
  "inputAbbreviatedPath": "\/source\/vzero-integration.js",
65
- "outputAbbreviatedPath": "\/vzero-integration-min.js",
66
  "outputPathIsOutsideProject": 0,
67
  "outputPathIsSetByUser": 1,
68
  "outputStyle": 1,
@@ -73,7 +95,7 @@
73
  "ignore": 0,
74
  "ignoreWasSetByUser": 0,
75
  "inputAbbreviatedPath": "\/source\/vzero-paypal.js",
76
- "outputAbbreviatedPath": "\/vzero-paypal-min.js",
77
  "outputPathIsOutsideProject": 0,
78
  "outputPathIsSetByUser": 1,
79
  "outputStyle": 1,
@@ -84,44 +106,11 @@
84
  "ignore": 0,
85
  "ignoreWasSetByUser": 0,
86
  "inputAbbreviatedPath": "\/source\/vzero.js",
87
- "outputAbbreviatedPath": "\/vzero-min.js",
88
  "outputPathIsOutsideProject": 0,
89
  "outputPathIsSetByUser": 1,
90
  "outputStyle": 1,
91
  "syntaxCheckerStyle": 0
92
- },
93
- "\/vzero-integration-min.js": {
94
- "fileType": 64,
95
- "ignore": 1,
96
- "ignoreWasSetByUser": 0,
97
- "inputAbbreviatedPath": "\/vzero-integration-min.js",
98
- "outputAbbreviatedPath": "\/min\/vzero-integration-min-min.js",
99
- "outputPathIsOutsideProject": 0,
100
- "outputPathIsSetByUser": 0,
101
- "outputStyle": 1,
102
- "syntaxCheckerStyle": 1
103
- },
104
- "\/vzero-min.js": {
105
- "fileType": 64,
106
- "ignore": 1,
107
- "ignoreWasSetByUser": 0,
108
- "inputAbbreviatedPath": "\/vzero-min.js",
109
- "outputAbbreviatedPath": "\/min\/vzero-min-min.js",
110
- "outputPathIsOutsideProject": 0,
111
- "outputPathIsSetByUser": 0,
112
- "outputStyle": 1,
113
- "syntaxCheckerStyle": 1
114
- },
115
- "\/vzero-paypal-min.js": {
116
- "fileType": 64,
117
- "ignore": 1,
118
- "ignoreWasSetByUser": 0,
119
- "inputAbbreviatedPath": "\/vzero-paypal-min.js",
120
- "outputAbbreviatedPath": "\/min\/vzero-paypal-min-min.js",
121
- "outputPathIsOutsideProject": 0,
122
- "outputPathIsSetByUser": 0,
123
- "outputStyle": 1,
124
- "syntaxCheckerStyle": 1
125
  }
126
  },
127
  "hooks": [
1
  {
2
  "CodeKitInfo": "This is a CodeKit 2.x project configuration file. It is designed to sync project settings across multiple machines. MODIFYING THE CONTENTS OF THIS FILE IS A POOR LIFE DECISION. If you do so, you will likely cause CodeKit to crash. This file is not useful unless accompanied by the project that created it in CodeKit 2. This file is not backwards-compatible with CodeKit 1.x. For more information, see: http:\/\/incident57.com\/codekit",
3
+ "creatorBuild": "19142",
4
  "files": {
5
+ "\/2.1.3\/express\/abstract-min.js": {
6
  "fileType": 64,
7
  "ignore": 1,
8
+ "ignoreWasSetByUser": 0,
9
+ "inputAbbreviatedPath": "\/2.1.3\/express\/abstract-min.js",
10
+ "outputAbbreviatedPath": "\/2.1.3\/express\/min\/abstract-min-min.js",
11
  "outputPathIsOutsideProject": 0,
12
  "outputPathIsSetByUser": 0,
13
  "outputStyle": 1,
14
+ "syntaxCheckerStyle": 1
15
+ },
16
+ "\/2.1.3\/express\/paypal-min.js": {
17
+ "fileType": 64,
18
+ "ignore": 1,
19
+ "ignoreWasSetByUser": 0,
20
+ "inputAbbreviatedPath": "\/2.1.3\/express\/paypal-min.js",
21
+ "outputAbbreviatedPath": "\/2.1.3\/express\/min\/paypal-min-min.js",
22
+ "outputPathIsOutsideProject": 0,
23
+ "outputPathIsSetByUser": 0,
24
+ "outputStyle": 1,
25
+ "syntaxCheckerStyle": 1
26
  },
27
+ "\/2.1.3\/vzero-integration-min.js": {
28
  "fileType": 64,
29
  "ignore": 1,
30
  "ignoreWasSetByUser": 0,
31
+ "inputAbbreviatedPath": "\/2.1.3\/vzero-integration-min.js",
32
+ "outputAbbreviatedPath": "\/2.1.3\/min\/vzero-integration-min-min.js",
33
  "outputPathIsOutsideProject": 0,
34
  "outputPathIsSetByUser": 0,
35
  "outputStyle": 1,
36
  "syntaxCheckerStyle": 1
37
  },
38
+ "\/2.1.3\/vzero-min.js": {
39
  "fileType": 64,
40
  "ignore": 1,
41
  "ignoreWasSetByUser": 0,
42
+ "inputAbbreviatedPath": "\/2.1.3\/vzero-min.js",
43
+ "outputAbbreviatedPath": "\/2.1.3\/min\/vzero-min-min.js",
44
+ "outputPathIsOutsideProject": 0,
45
+ "outputPathIsSetByUser": 0,
46
+ "outputStyle": 1,
47
+ "syntaxCheckerStyle": 1
48
+ },
49
+ "\/2.1.3\/vzero-paypal-min.js": {
50
+ "fileType": 64,
51
+ "ignore": 1,
52
+ "ignoreWasSetByUser": 0,
53
+ "inputAbbreviatedPath": "\/2.1.3\/vzero-paypal-min.js",
54
+ "outputAbbreviatedPath": "\/2.1.3\/min\/vzero-paypal-min-min.js",
55
  "outputPathIsOutsideProject": 0,
56
  "outputPathIsSetByUser": 0,
57
  "outputStyle": 1,
62
  "ignore": 0,
63
  "ignoreWasSetByUser": 0,
64
  "inputAbbreviatedPath": "\/source\/express\/abstract.js",
65
+ "outputAbbreviatedPath": "\/2.1.3\/express\/abstract-min.js",
66
  "outputPathIsOutsideProject": 0,
67
  "outputPathIsSetByUser": 1,
68
  "outputStyle": 1,
73
  "ignore": 0,
74
  "ignoreWasSetByUser": 0,
75
  "inputAbbreviatedPath": "\/source\/express\/paypal.js",
76
+ "outputAbbreviatedPath": "\/2.1.3\/express\/paypal-min.js",
77
  "outputPathIsOutsideProject": 0,
78
  "outputPathIsSetByUser": 1,
79
  "outputStyle": 1,
84
  "ignore": 0,
85
  "ignoreWasSetByUser": 0,
86
  "inputAbbreviatedPath": "\/source\/vzero-integration.js",
87
+ "outputAbbreviatedPath": "\/2.1.3\/vzero-integration-min.js",
88
  "outputPathIsOutsideProject": 0,
89
  "outputPathIsSetByUser": 1,
90
  "outputStyle": 1,
95
  "ignore": 0,
96
  "ignoreWasSetByUser": 0,
97
  "inputAbbreviatedPath": "\/source\/vzero-paypal.js",
98
+ "outputAbbreviatedPath": "\/2.1.3\/vzero-paypal-min.js",
99
  "outputPathIsOutsideProject": 0,
100
  "outputPathIsSetByUser": 1,
101
  "outputStyle": 1,
106
  "ignore": 0,
107
  "ignoreWasSetByUser": 0,
108
  "inputAbbreviatedPath": "\/source\/vzero.js",
109
+ "outputAbbreviatedPath": "\/2.1.3\/vzero-min.js",
110
  "outputPathIsOutsideProject": 0,
111
  "outputPathIsSetByUser": 1,
112
  "outputStyle": 1,
113
  "syntaxCheckerStyle": 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
  },
116
  "hooks": [
js/gene/braintree/express.js DELETED
@@ -1,427 +0,0 @@
1
- /**
2
- * Express paypal button for the Braintree module
3
- *
4
- * @author Aidan Threadgold <aidan@gene.co.uk>
5
- */
6
- var ppExpress = (function() {
7
-
8
- var config;
9
-
10
- /**
11
- * Hold the paypal integration object
12
- */
13
- var paypalIntegration;
14
-
15
- /**
16
- * API to return
17
- */
18
- var api = {
19
- addBtn: function(secondConfig) {
20
-
21
- /**
22
- * Required config keys
23
- */
24
- config = {
25
- /**
26
- * Braintree token
27
- */
28
- token: null,
29
-
30
- /**
31
- * Currency code
32
- */
33
- currency: null,
34
-
35
- /**
36
- * Locale code
37
- */
38
- locale: null,
39
-
40
- /**
41
- * Magento price format json
42
- */
43
- priceFormat: null,
44
-
45
- /**
46
- * Product ID
47
- */
48
- productId: null,
49
-
50
- /**
51
- * Url to the braintree authorization action within the express controller
52
- */
53
- authUrl: null,
54
-
55
- /**
56
- * Url to redirect to on successful order
57
- */
58
- successUrl: null,
59
-
60
- /**
61
- * Buy button will validate product add form if it's present
62
- */
63
- validateProductForm: true,
64
-
65
- /**
66
- * Optional
67
- * Buy now button element
68
- * @returns {Element}
69
- */
70
- buyButton: function() {
71
- var button = document.createElement('button');
72
- button.innerHTML = typeof Translator === "object" ? Translator.translate("Checkout with PayPal") : "Checkout with PayPal";
73
- button.className = "button pp-express-buy-btn";
74
-
75
- return button;
76
- },
77
-
78
- /**
79
- * Optional
80
- * Dom element to append the buy now button to
81
- * @returns {*}
82
- */
83
- buyButtonPlacement: function() {
84
- return '.add-to-cart';
85
- }
86
- };
87
-
88
- config = $H(config).merge(secondConfig);
89
- for(var key in config) {
90
- if( config[key] === null ) {
91
- console.error('Invalid value for ' + key);
92
- return false;
93
- }
94
- }
95
-
96
- initBraintree(config);
97
- return true;
98
- },
99
-
100
- /**
101
- * Get modal's overlay element
102
- * @returns {Element}
103
- */
104
- getOverlay: function() {
105
- return document.getElementById('pp-express-overlay');
106
- },
107
-
108
- /**
109
- * Get the modal element
110
- * @returns {Element}
111
- */
112
- getModal: function() {
113
- return document.getElementById('pp-express-modal');
114
- },
115
-
116
- /**
117
- * Hide the modal
118
- */
119
- hideModal: function() {
120
- this.getOverlay().style.display = 'none';
121
- this.getModal().style.display = 'none';
122
-
123
- this.getModal().innerHTML = '';
124
- },
125
-
126
- /**
127
- * Show the modal
128
- */
129
- showModal: function() {
130
- this.getModal().innerHTML = '';
131
- this.getModal().classList.add('loading');
132
-
133
- this.getOverlay().style.display = 'block';
134
- this.getModal().style.display = 'block';
135
- },
136
-
137
- /**
138
- * Update the grand total display within the modal
139
- */
140
- updateShipping: function (method) {
141
- this._setLoading($('paypal-express-submit'));
142
- new Ajax.Request(config.get('shippingSaveUrl'), {
143
- method: 'POST',
144
- parameters: {
145
- 'submit_shipping': true,
146
- 'shipping_method': method
147
- },
148
-
149
- onSuccess: function (data) {
150
- var response = this._getJson(data);
151
- this._unsetLoading($('paypal-express-submit'));
152
- this._updateTotals(response);
153
- }.bind(this),
154
-
155
- onFailure: function () {
156
- this._unsetLoading($('paypal-express-submit'));
157
- api.hideModal();
158
- alert( typeof Translator === "object" ? Translator.translate("We were unable to complete the request. Please try again.") : "We were unable to complete the request. Please try again." );
159
- }
160
- });
161
- },
162
-
163
- /**
164
- * Prepare the coupon form by handling users hitting enter
165
- */
166
- prepareCoupon: function () {
167
- if ($('paypal-express-coupon')) {
168
- $('paypal-express-coupon').observe('keypress', function (event) {
169
- var key = event.which || event.keyCode;
170
- if (key == Event.KEY_RETURN) {
171
- Event.stop(event);
172
- this.updateCoupon();
173
- }
174
- }.bind(this));
175
- }
176
- },
177
-
178
- /**
179
- * Allow customers to add coupons into their basket
180
- *
181
- * @param coupon
182
- */
183
- updateCoupon: function (coupon) {
184
- $('paypal-express-coupon-error').hide();
185
- if (!coupon && $('paypal-express-coupon')) {
186
- coupon = $('paypal-express-coupon').value;
187
- }
188
-
189
- // Only update if the coupon is set to something
190
- if (coupon == '') {
191
- return false;
192
- }
193
-
194
- this._setLoading($('paypal-express-coupon-apply'));
195
- new Ajax.Request(config.get('couponSaveUrl'), {
196
- method: 'POST',
197
- parameters: {
198
- 'coupon': coupon
199
- },
200
-
201
- onSuccess: function (data) {
202
- var response = this._getJson(data);
203
- this._unsetLoading($('paypal-express-coupon-apply'));
204
- this._updateTotals(response);
205
- if (response.success == true) {
206
- $('paypal-express-coupon-remove').show();
207
- $('paypal-express-coupon-apply').hide();
208
- } else if (response.message) {
209
- $('paypal-express-coupon-error').update(response.message).show();
210
- }
211
- }.bind(this),
212
-
213
- onFailure: function () {
214
- this._unsetLoading($('paypal-express-coupon-submit'));
215
- api.hideModal();
216
- alert( typeof Translator === "object" ? Translator.translate("We were unable to complete the request. Please try again.") : "We were unable to complete the request. Please try again." );
217
- }
218
- });
219
- return false;
220
- },
221
-
222
- /**
223
- * Allow the user the ability to remove the coupon code from their quote
224
- */
225
- removeCoupon: function () {
226
- $('paypal-express-coupon-error').hide();
227
- this._setLoading($('paypal-express-coupon-remove'));
228
- new Ajax.Request(config.get('couponSaveUrl'), {
229
- method: 'POST',
230
- parameters: {
231
- 'remove': true
232
- },
233
-
234
- onSuccess: function (data) {
235
- var response = this._getJson(data);
236
- this._unsetLoading($('paypal-express-coupon-remove'));
237
- this._updateTotals(response);
238
- if (response.success == true) {
239
- $('paypal-express-coupon-remove').hide();
240
- $('paypal-express-coupon-apply').show();
241
- $('paypal-express-coupon').value = '';
242
- $('paypal-express-coupon').focus();
243
- } else if (response.message) {
244
- $('paypal-express-coupon-error').update(response.message).show();
245
- }
246
- }.bind(this),
247
-
248
- onFailure: function () {
249
- this._unsetLoading($('paypal-express-coupon-submit'));
250
- api.hideModal();
251
- alert( typeof Translator === "object" ? Translator.translate("We were unable to complete the request. Please try again.") : "We were unable to complete the request. Please try again." );
252
- }
253
- });
254
- },
255
-
256
- /**
257
- * Update the totals from the response
258
- *
259
- * @param response
260
- * @private
261
- */
262
- _updateTotals: function (response) {
263
- if (typeof response.totals !== 'undefined') {
264
- $('paypal-express-totals').update(response.totals);
265
- }
266
- },
267
-
268
- /**
269
- * Return the JSON from the request
270
- *
271
- * @param data
272
- * @returns {*}
273
- * @private
274
- */
275
- _getJson: function (data) {
276
- if (typeof data.responseJSON !== 'undefined') {
277
- return data.responseJSON;
278
- } else if (typeof data.responseText === 'string') {
279
- return data.responseText.evalJSON();
280
- }
281
- },
282
-
283
- /**
284
- * Set an element to a loading state
285
- *
286
- * @param element
287
- * @private
288
- */
289
- _setLoading: function (element) {
290
- if (!element) {
291
- return false;
292
- }
293
- element.setAttribute('disabled', 'disabled');
294
- element.addClassName('loading');
295
- },
296
-
297
- /**
298
- * Unset the loading state
299
- *
300
- * @param element
301
- * @private
302
- */
303
- _unsetLoading: function (element) {
304
- if (!element) {
305
- return false;
306
- }
307
- element.removeAttribute('disabled');
308
- element.removeClassName('loading');
309
- }
310
- };
311
-
312
- /**
313
- * Setup braintree
314
- */
315
- function initBraintree(config) {
316
- var vzeroPaypal = new vZeroPayPalButton(
317
- config.get('token'),
318
- '',
319
- false,
320
- config.get('locale')
321
- );
322
-
323
- var options = {
324
- validate: validateForm(),
325
- onSuccess: function (payload) {
326
- api.showModal();
327
-
328
- /* Build the order */
329
- new Ajax.Request(config.get('authUrl'), {
330
- method: 'POST',
331
- parameters: {
332
- 'paypal': JSON.stringify(payload),
333
- 'product_id': config.get('productId'),
334
- 'form_data': $('product_addtocart_form') ? $('product_addtocart_form').serialize() : $('pp_express_form').serialize()
335
- },
336
-
337
- onSuccess: function (data) {
338
- api.getModal().classList.remove('loading');
339
- api.getModal().innerHTML = data.responseText;
340
- api.prepareCoupon();
341
- ajaxHandler();
342
- },
343
-
344
- onFailure: function () {
345
- api.hideModal();
346
- alert(typeof Translator === "object" ? Translator.translate("We were unable to complete the request. Please try again.") : "We were unable to complete the request. Please try again.");
347
- }
348
- });
349
- },
350
- onReady: function (integration) {
351
- paypalIntegration = integration;
352
- }
353
- };
354
-
355
- // Initialize the PayPal button logic on any valid buttons on the page
356
- $$('[data-paypalexpress]').each(function (button) {
357
- vzeroPaypal.attachPayPalButtonEvent(button, options);
358
- });
359
- }
360
-
361
- /**
362
- * Attach an event to forms loaded through ajax to submit them again as ajax
363
- * */
364
- function ajaxHandler() {
365
- var forms = api.getModal().getElementsByTagName('form'),
366
- i = 0;
367
-
368
- if (forms.length > 0) {
369
- for (i = 0; i < forms.length; i++) {
370
- forms[i].addEventListener('submit', function (e) {
371
- e.preventDefault();
372
-
373
- api.getModal().classList.add('loading');
374
- api.getModal().innerHTML = '';
375
-
376
- new Ajax.Request(this.getAttribute('action'), {
377
- method: 'POST',
378
- parameters: $(this).serialize(true),
379
-
380
- onSuccess: function (data) {
381
- if (data.responseText == 'complete') {
382
- document.location = config.get('successUrl');
383
- return;
384
- }
385
-
386
- api.getModal().classList.remove('loading');
387
- api.getModal().innerHTML = data.responseText;
388
- ajaxHandler();
389
- },
390
-
391
- onFailure: function () {
392
- api.hideModal();
393
- alert( typeof Translator === "object" ? Translator.translate("We were unable to complete the request. Please try again.") : "We were unable to complete the request. Please try again." );
394
- }
395
- });
396
-
397
- return false;
398
- });
399
- }
400
- }
401
- }
402
-
403
- /**
404
- * Validate the form
405
- *
406
- * @returns {boolean}
407
- */
408
- function validateForm()
409
- {
410
- if (config.get("validateProductForm") === false) {
411
- return true;
412
- }
413
-
414
- // Validate the product add to cart form
415
- if (typeof productAddToCartForm === 'object' && productAddToCartForm.validator.validate()) {
416
- if (typeof productAddToCartFormOld === 'object' && productAddToCartFormOld.validator.validate()) {
417
- return true;
418
- } else if (typeof productAddToCartFormOld !== 'object') {
419
- return true;
420
- }
421
- }
422
-
423
- return (typeof productAddToCartForm !== 'object' && typeof productAddToCartFormOld !== 'object');
424
- }
425
-
426
- return api;
427
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/gene/braintree/express/abstract-min.js CHANGED
@@ -1 +1 @@
1
- var BraintreeExpressAbstract=Class.create();BraintreeExpressAbstract.prototype={initialize:function(e,t,o,s,a,n){this.clientToken=e,this.storeFrontName=t,this.formKey=o,this.source=s,this.urls=a,this.config=n||{},this._init(),this.insertDom()},_init:function(){return!1},insertDom:function(){this.getModal()||$$("body").first().insert('<div id="pp-express-overlay"></div><div id="pp-express-modal"></div><div id="pp-express-container"></div>')},getOverlay:function(){return document.getElementById("pp-express-overlay")},getModal:function(){return document.getElementById("pp-express-modal")},hideModal:function(){this.getOverlay().style.display="none",this.getModal().style.display="none",this.getModal().innerHTML=""},showModal:function(){this.getModal().innerHTML="",this.getModal().classList.add("loading"),this.getOverlay().style.display="block",this.getModal().style.display="block"},initModal:function(e){"undefined"==typeof e.form_key&&(e.form_key=this.formKey),"undefined"==typeof e.source&&(e.source=this.source),this.showModal(),new Ajax.Request(this.urls.authUrl,{method:"POST",parameters:e,onSuccess:function(e){this.getModal().classList.remove("loading"),this.getModal().innerHTML=e.responseText,this.prepareCoupon(),this.ajaxHandler()}.bind(this),onFailure:function(){this.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}.bind(this)})},updateShipping:function(e){this._setLoading($("paypal-express-submit")),new Ajax.Request(this.urls.shippingSaveUrl,{method:"POST",parameters:{submit_shipping:!0,shipping_method:e},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-submit")),this._updateTotals(t)}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}})},prepareCoupon:function(){$("paypal-express-coupon")&&$("paypal-express-coupon").observe("keypress",function(e){var t=e.which||e.keyCode;t==Event.KEY_RETURN&&(Event.stop(e),this.updateCoupon())}.bind(this))},updateCoupon:function(e){return $("paypal-express-coupon-error").hide(),!e&&$("paypal-express-coupon")&&(e=$("paypal-express-coupon").value),""==e?!1:(this._setLoading($("paypal-express-coupon-apply")),new Ajax.Request(this.urls.couponSaveUrl,{method:"POST",parameters:{coupon:e},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-coupon-apply")),this._updateTotals(t),1==t.success?($("paypal-express-coupon-remove").show(),$("paypal-express-coupon-apply").hide()):t.message&&$("paypal-express-coupon-error").update(t.message).show()}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-coupon-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}}),!1)},removeCoupon:function(){$("paypal-express-coupon-error").hide(),this._setLoading($("paypal-express-coupon-remove")),new Ajax.Request(this.urls.couponSaveUrl,{method:"POST",parameters:{remove:!0},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-coupon-remove")),this._updateTotals(t),1==t.success?($("paypal-express-coupon-remove").hide(),$("paypal-express-coupon-apply").show(),$("paypal-express-coupon").value="",$("paypal-express-coupon").focus()):t.message&&$("paypal-express-coupon-error").update(t.message).show()}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-coupon-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}})},_updateTotals:function(e){"undefined"!=typeof e.totals&&$("paypal-express-totals").update(e.totals)},_getJson:function(e){return"undefined"!=typeof e.responseJSON?e.responseJSON:"string"==typeof e.responseText?e.responseText.evalJSON():void 0},_setLoading:function(e){return e?(e.setAttribute("disabled","disabled"),void e.addClassName("loading")):!1},_unsetLoading:function(e){return e?(e.removeAttribute("disabled"),void e.removeClassName("loading")):!1},ajaxHandler:function(){var e=this.getModal().getElementsByTagName("form"),t=0;if(e.length>0)for(t=0;t<e.length;t++)Element.observe(e[t],"submit",function(e){return Event.stop(e),this.getModal().classList.add("loading"),this.getModal().innerHTML="",new Ajax.Request(e.target.getAttribute("action"),{method:"POST",parameters:$(e.target).serialize(!0),onSuccess:function(e){return"complete"==e.responseText?void(document.location=this.urls.successUrl):(this.getModal().classList.remove("loading"),this.getModal().innerHTML=e.responseText,void this.ajaxHandler())}.bind(this),onFailure:function(){this.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}.bind(this)}),!1}.bind(this))},validateForm:function(){if("object"==typeof productAddToCartForm&&productAddToCartForm.validator.validate()){if("object"==typeof productAddToCartFormOld&&productAddToCartFormOld.validator.validate())return!0;if("object"!=typeof productAddToCartFormOld)return!0}return"object"!=typeof productAddToCartForm&&"object"!=typeof productAddToCartFormOld},attachToButtons:function(e){console.warn("This method cannot be called directly.")}};
1
+ var BraintreeExpressAbstract=Class.create();BraintreeExpressAbstract.prototype={initialize:function(e,t,o,s,a,n){this.clientToken=e,this.storeFrontName=t,this.formKey=o,this.source=s,this.urls=a,this.config=n||{},this._init(),this.insertDom()},_init:function(){return!1},insertDom:function(){this.getModal()||$$("body").first().insert('<div id="pp-express-overlay"></div><div id="pp-express-modal"></div><div id="pp-express-container"></div>')},getOverlay:function(){return document.getElementById("pp-express-overlay")},getModal:function(){return document.getElementById("pp-express-modal")},hideModal:function(){this.getOverlay().style.display="none",this.getModal().style.display="none",this.getModal().innerHTML=""},showModal:function(){this.getModal().innerHTML="",this.getModal().classList.add("loading"),this.getOverlay().style.display="block",this.getModal().style.display="block"},initModal:function(e){"undefined"==typeof e.form_key&&(e.form_key=this.formKey),"undefined"==typeof e.source&&(e.source=this.source),this.showModal(),new Ajax.Request(this.urls.authUrl,{method:"POST",parameters:e,onSuccess:function(e){this.getModal().classList.remove("loading"),this.getModal().innerHTML=e.responseText,this.prepareCoupon(),this.ajaxHandler()}.bind(this),onFailure:function(){this.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}.bind(this)})},updateShipping:function(e){this._setLoading($("paypal-express-submit")),new Ajax.Request(this.urls.shippingSaveUrl,{method:"POST",parameters:{submit_shipping:!0,shipping_method:e},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-submit")),this._updateTotals(t)}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}})},prepareCoupon:function(){$("paypal-express-coupon")&&$("paypal-express-coupon").observe("keypress",function(e){var t=e.which||e.keyCode;t==Event.KEY_RETURN&&(Event.stop(e),this.updateCoupon())}.bind(this))},updateCoupon:function(e){return $("paypal-express-coupon-error").hide(),!e&&$("paypal-express-coupon")&&(e=$("paypal-express-coupon").value),""!=e&&(this._setLoading($("paypal-express-coupon-apply")),new Ajax.Request(this.urls.couponSaveUrl,{method:"POST",parameters:{coupon:e},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-coupon-apply")),this._updateTotals(t),1==t.success?($("paypal-express-coupon-remove").show(),$("paypal-express-coupon-apply").hide()):t.message&&$("paypal-express-coupon-error").update(t.message).show()}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-coupon-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}}),!1)},removeCoupon:function(){$("paypal-express-coupon-error").hide(),this._setLoading($("paypal-express-coupon-remove")),new Ajax.Request(this.urls.couponSaveUrl,{method:"POST",parameters:{remove:!0},onSuccess:function(e){var t=this._getJson(e);this._unsetLoading($("paypal-express-coupon-remove")),this._updateTotals(t),1==t.success?($("paypal-express-coupon-remove").hide(),$("paypal-express-coupon-apply").show(),$("paypal-express-coupon").value="",$("paypal-express-coupon").focus()):t.message&&$("paypal-express-coupon-error").update(t.message).show()}.bind(this),onFailure:function(){this._unsetLoading($("paypal-express-coupon-submit")),api.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}})},_updateTotals:function(e){"undefined"!=typeof e.totals&&$("paypal-express-totals").update(e.totals)},_getJson:function(e){return"undefined"!=typeof e.responseJSON?e.responseJSON:"string"==typeof e.responseText?e.responseText.evalJSON():void 0},_setLoading:function(e){return!!e&&(e.setAttribute("disabled","disabled"),void e.addClassName("loading"))},_unsetLoading:function(e){return!!e&&(e.removeAttribute("disabled"),void e.removeClassName("loading"))},ajaxHandler:function(){var e=this.getModal().getElementsByTagName("form"),t=0;if(e.length>0)for(t=0;t<e.length;t++)Element.observe(e[t],"submit",function(e){return Event.stop(e),this.getModal().classList.add("loading"),this.getModal().innerHTML="",new Ajax.Request(e.target.getAttribute("action"),{method:"POST",parameters:$(e.target).serialize(!0),onSuccess:function(e){return"complete"==e.responseText?void(document.location=this.urls.successUrl):(this.getModal().classList.remove("loading"),this.getModal().innerHTML=e.responseText,void this.ajaxHandler())}.bind(this),onFailure:function(){this.hideModal(),alert("object"==typeof Translator?Translator.translate("We were unable to complete the request. Please try again."):"We were unable to complete the request. Please try again.")}.bind(this)}),!1}.bind(this))},validateForm:function(){if("object"==typeof productAddToCartForm&&productAddToCartForm.validator.validate()){if("object"==typeof productAddToCartFormOld&&productAddToCartFormOld.validator.validate())return!0;if("object"!=typeof productAddToCartFormOld)return!0}return"object"!=typeof productAddToCartForm&&"object"!=typeof productAddToCartFormOld},attachToButtons:function(e){console.warn("This method cannot be called directly.")}};
js/gene/braintree/source/vzero-integration.js CHANGED
@@ -38,7 +38,7 @@ vZeroIntegration.prototype = {
38
 
39
  this.paypalWrapperMarkUp = paypalWrapperMarkUp || false;
40
  this.paypalButtonClass = paypalButtonClass || false;
41
- this.submitButtonClass = this.paypalButtonClass;
42
 
43
  this.isOnepage = isOnepage || false;
44
 
@@ -48,12 +48,16 @@ vZeroIntegration.prototype = {
48
 
49
  this._methodSwitchTimeout = false;
50
 
51
- // Hosted fields hasn't been initialized yet
52
- this._hostedFieldsInit = false;
53
 
54
  // Wait for the DOM to finish loading before creating observers
55
  document.observe("dom:loaded", function () {
56
 
 
 
 
 
 
57
  // Call the function which is going to intercept the submit event
58
  this.prepareSubmitObserver();
59
  this.preparePaymentMethodSwitchObserver();
@@ -86,10 +90,75 @@ vZeroIntegration.prototype = {
86
  }
87
  }.bind(this));
88
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  // Fire our onInit event
90
  this.vzero.fireEvent(this, 'integration.onInit', {integration: this});
91
  },
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  /**
94
  * Init the saved method events
95
  */
@@ -116,6 +185,7 @@ vZeroIntegration.prototype = {
116
 
117
  }.bind(this));
118
 
 
119
  },
120
 
121
  /**
@@ -183,9 +253,14 @@ vZeroIntegration.prototype = {
183
  this.showHideOtherMethod(parentElement, targetElement);
184
  }
185
 
186
- this.vzero.fireEvent(this, 'integration.checkSavedOther');
187
  },
188
 
 
 
 
 
 
189
  afterPaymentMethodSwitch: function () {
190
  return true;
191
  },
@@ -204,9 +279,6 @@ vZeroIntegration.prototype = {
204
  // Verify this checkout has a form (would be weird to have a formless checkout, but you never know!)
205
  if ($('braintree-hosted-submit').up('form') !== undefined) {
206
 
207
- // Flag hosted fields being init
208
- this._hostedFieldsInit = true;
209
-
210
  // Store the form in the integration class
211
  this.form = $('braintree-hosted-submit').up('form');
212
 
@@ -299,6 +371,26 @@ vZeroIntegration.prototype = {
299
 
300
  },
301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  /**
303
  * Set the submit function to be used
304
  *
@@ -358,6 +450,10 @@ vZeroIntegration.prototype = {
358
  */
359
  submit: function (type, successCallback, failedCallback, validateFailedCallback) {
360
 
 
 
 
 
361
  // Check we actually want to intercept this credit card transaction?
362
  if (this.shouldInterceptSubmit(type)) {
363
 
38
 
39
  this.paypalWrapperMarkUp = paypalWrapperMarkUp || false;
40
  this.paypalButtonClass = paypalButtonClass || false;
41
+ this.submitButtonClass = this.paypalButtonClass; /* Used for other integrations */
42
 
43
  this.isOnepage = isOnepage || false;
44
 
48
 
49
  this._methodSwitchTimeout = false;
50
 
51
+ this._originalSubmitFn = false;
 
52
 
53
  // Wait for the DOM to finish loading before creating observers
54
  document.observe("dom:loaded", function () {
55
 
56
+ // Capture the original submit function
57
+ if (this.captureOriginalSubmitFn()) {
58
+ this.observeSubmissionOverride();
59
+ }
60
+
61
  // Call the function which is going to intercept the submit event
62
  this.prepareSubmitObserver();
63
  this.preparePaymentMethodSwitchObserver();
90
  }
91
  }.bind(this));
92
 
93
+ // Initialize device data events
94
+ this._deviceDataInit = false;
95
+ this.vzero.observeEvent([
96
+ 'onHandleAjaxRequest',
97
+ 'integration.onInitSavedMethods'
98
+ ], this.initDeviceData, this);
99
+ this.vzero.observeEvent('integration.onBeforeSubmit', function () {
100
+ if ($('braintree-device-data') != null) {
101
+ $('braintree-device-data').writeAttribute('disabled', false);
102
+ }
103
+ }, this);
104
+
105
  // Fire our onInit event
106
  this.vzero.fireEvent(this, 'integration.onInit', {integration: this});
107
  },
108
 
109
+ /**
110
+ * Add device_data into the session
111
+ */
112
+ initDeviceData: function (params, self) {
113
+ if ($('credit-card-form') != null) {
114
+ var form = $('credit-card-form').up('form');
115
+ if (form != undefined) {
116
+ if (form.select('#braintree-device-data').length == 0) {
117
+ if (self._deviceDataInit === true) {
118
+ return false;
119
+ }
120
+ self._deviceDataInit = true;
121
+
122
+ // Create a new element and insert it into the DOM
123
+ var input = new Element('input', {
124
+ type: 'hidden',
125
+ name: 'payment[device_data]',
126
+ id: 'braintree-device-data'
127
+ });
128
+ form.insert(input);
129
+
130
+ // Populate the new input with the device data
131
+ self.populateDeviceData(input);
132
+ }
133
+ }
134
+ }
135
+ },
136
+
137
+ /**
138
+ * Populate device data using the data collector
139
+ *
140
+ * @param input
141
+ */
142
+ populateDeviceData: function (input) {
143
+ this.vzero.getClient(function (clientInstance) {
144
+ braintree.dataCollector.create({
145
+ client: clientInstance,
146
+ kount: true,
147
+ paypal: true
148
+ }, function (err, dataCollectorInstance) {
149
+ if (err) {
150
+ // Handle error in creation of data collector
151
+ console.warn(err);
152
+ return;
153
+ }
154
+
155
+ input.value = dataCollectorInstance.deviceData;
156
+ input.writeAttribute('disabled', false);
157
+ this._deviceDataInit = false;
158
+ }.bind(this));
159
+ }.bind(this));
160
+ },
161
+
162
  /**
163
  * Init the saved method events
164
  */
185
 
186
  }.bind(this));
187
 
188
+ this.vzero.fireEvent(this, 'integration.onInitSavedMethods');
189
  },
190
 
191
  /**
253
  this.showHideOtherMethod(parentElement, targetElement);
254
  }
255
 
256
+ this.vzero.fireEvent(this, 'integration.onCheckSavedOther');
257
  },
258
 
259
+ /**
260
+ * After the payment methods have switched run this
261
+ *
262
+ * @returns {boolean}
263
+ */
264
  afterPaymentMethodSwitch: function () {
265
  return true;
266
  },
279
  // Verify this checkout has a form (would be weird to have a formless checkout, but you never know!)
280
  if ($('braintree-hosted-submit').up('form') !== undefined) {
281
 
 
 
 
282
  // Store the form in the integration class
283
  this.form = $('braintree-hosted-submit').up('form');
284
 
371
 
372
  },
373
 
374
+ /**
375
+ * Capture the original submit function
376
+ *
377
+ * @returns {boolean}
378
+ */
379
+ captureOriginalSubmitFn: function () {
380
+ return false;
381
+ },
382
+
383
+ /**
384
+ * Start an interval to ensure the submit function has been correctly overidden
385
+ */
386
+ observeSubmissionOverride: function () {
387
+ setInterval(function () {
388
+ if (this._originalSubmitFn) {
389
+ this.prepareSubmitObserver();
390
+ }
391
+ }.bind(this), 500);
392
+ },
393
+
394
  /**
395
  * Set the submit function to be used
396
  *
450
  */
451
  submit: function (type, successCallback, failedCallback, validateFailedCallback) {
452
 
453
+ // Set the token being generated back to false on a new submission
454
+ this.vzero._hostedFieldsTokenGenerated = false;
455
+ this.hostedFieldsGenerated = false;
456
+
457
  // Check we actually want to intercept this credit card transaction?
458
  if (this.shouldInterceptSubmit(type)) {
459
 
js/gene/braintree/source/vzero-paypal.js CHANGED
@@ -15,8 +15,9 @@ vZeroPayPalButton.prototype = {
15
  * @param singleUse Should the system attempt to open in single payment mode?
16
  * @param locale The locale for the payment
17
  * @param futureSingleUse When using future payments should we process the transaction as a single payment?
 
18
  */
19
- initialize: function (clientToken, storeFrontName, singleUse, locale, futureSingleUse) {
20
  this.clientToken = clientToken;
21
  this.storeFrontName = storeFrontName;
22
  this.singleUse = singleUse;
@@ -27,6 +28,8 @@ vZeroPayPalButton.prototype = {
27
  this.currency = false;
28
 
29
  this.client = false;
 
 
30
  },
31
 
32
  /**
@@ -246,7 +249,8 @@ vZeroPayPalButton.prototype = {
246
  displayName: this.storeFrontName,
247
  amount: this.amount,
248
  currency: this.currency,
249
- useraction: 'commit' /* The user is committing to the order on submission of PayPal */
 
250
  };
251
 
252
  // Pass over the locale
@@ -254,13 +258,35 @@ vZeroPayPalButton.prototype = {
254
  options.locale = this.locale;
255
  }
256
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  // Determine the flow based on the singleUse parameter
258
  if (this.singleUse === true) {
259
- options.flow = 'checkout';
260
  } else {
261
- options.flow = 'vault';
262
  }
263
 
264
- return options;
 
 
 
 
 
 
 
 
 
 
265
  }
266
  };
15
  * @param singleUse Should the system attempt to open in single payment mode?
16
  * @param locale The locale for the payment
17
  * @param futureSingleUse When using future payments should we process the transaction as a single payment?
18
+ * @param onlyVaultOnVault Should we only show the Vault flow if the customer has opted into saving their details?
19
  */
20
+ initialize: function (clientToken, storeFrontName, singleUse, locale, futureSingleUse, onlyVaultOnVault) {
21
  this.clientToken = clientToken;
22
  this.storeFrontName = storeFrontName;
23
  this.singleUse = singleUse;
28
  this.currency = false;
29
 
30
  this.client = false;
31
+
32
+ this.onlyVaultOnVault = onlyVaultOnVault || false;
33
  },
34
 
35
  /**
249
  displayName: this.storeFrontName,
250
  amount: this.amount,
251
  currency: this.currency,
252
+ useraction: 'commit', /* The user is committing to the order on submission of PayPal */
253
+ flow: this._getFlow()
254
  };
255
 
256
  // Pass over the locale
258
  options.locale = this.locale;
259
  }
260
 
261
+ return options;
262
+ },
263
+
264
+ /**
265
+ * Determine the flow for the PayPal window
266
+ *
267
+ * @returns {*}
268
+ * @private
269
+ */
270
+ _getFlow: function () {
271
+ var flow;
272
+
273
  // Determine the flow based on the singleUse parameter
274
  if (this.singleUse === true) {
275
+ flow = 'checkout';
276
  } else {
277
+ flow = 'vault';
278
  }
279
 
280
+ // Determine if the user should be forced back to the checkout flow
281
+ if ($('gene_braintree_paypal_store_in_vault') !== null) {
282
+ if (this.onlyVaultOnVault && /* Are we set to only vault when the customer requests */
283
+ flow == 'vault' && /* Has the flow been set to vault already? */
284
+ !$('gene_braintree_paypal_store_in_vault').checked /* The user has opted not to save their details */
285
+ ) {
286
+ flow = 'checkout';
287
+ }
288
+ }
289
+
290
+ return flow;
291
  }
292
  };
js/gene/braintree/source/vzero.js CHANGED
@@ -18,9 +18,8 @@ vZero.prototype = {
18
  * @param billingPostcode Billing postcode also needed to verify the card
19
  * @param quoteUrl The URL to update the quote totals
20
  * @param tokenizeUrl The URL to re-tokenize 3D secure cards
21
- * @param vaultToNonceUrl The end point to vault a nonce then return a new nonce - deprecated
22
  */
23
- initialize: function (code, clientToken, threeDSecure, hostedFields, billingName, billingPostcode, quoteUrl, tokenizeUrl, vaultToNonceUrl) {
24
  this.code = code;
25
  this.clientToken = clientToken;
26
  this.threeDSecure = threeDSecure;
@@ -32,6 +31,7 @@ vZero.prototype = {
32
  if (billingPostcode) {
33
  this.billingPostcode = billingPostcode;
34
  }
 
35
  if (quoteUrl) {
36
  this.quoteUrl = quoteUrl;
37
  }
@@ -53,6 +53,9 @@ vZero.prototype = {
53
 
54
  this.client = false;
55
 
 
 
 
56
  this.initEvents();
57
  },
58
 
@@ -67,6 +70,7 @@ vZero.prototype = {
67
  integration: {
68
  onInit: [],
69
  onInitDefaultMethod: [],
 
70
  onShowHideOtherMethod: [],
71
  onCheckSavedOther: [],
72
  onPaymentMethodSwitch: [],
@@ -78,20 +82,40 @@ vZero.prototype = {
78
  };
79
  },
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  /**
82
  * Add an event into the system
83
  *
84
- * @param path
85
  * @param eventFn
86
  * @param params
87
  */
88
- observeEvent: function (path, eventFn, params) {
89
- var event = this._resolveEvent(path);
90
- if (event === undefined) {
91
- console.warn('Event for ' + path + ' does not exist.');
92
- } else {
93
- event.push({fn: eventFn, params: params});
94
  }
 
 
 
 
 
 
 
 
 
 
95
  },
96
 
97
  /**
@@ -105,13 +129,13 @@ vZero.prototype = {
105
  var events = this._resolveEvent(path);
106
  if (events !== undefined) {
107
  if (events.length > 0) {
108
- events.each(function (item) {
109
- if (typeof item.fn === 'function') {
110
  var arguments = [params];
111
- if (typeof item.params === 'object') {
112
- arguments.push(item.params);
113
  }
114
- item.fn.apply(caller, arguments);
115
  }
116
  });
117
  }
@@ -148,7 +172,7 @@ vZero.prototype = {
148
  }, function (clientErr, clientInstance) {
149
  if (clientErr) {
150
  // Handle error in client creation
151
- console.log(clientErr);
152
  return;
153
  }
154
 
@@ -270,8 +294,13 @@ vZero.prototype = {
270
  braintree.hostedFields.create(options, function (hostedFieldsErr, hostedFieldsInstance) {
271
  // Handle hosted fields errors
272
  if (hostedFieldsErr) {
 
 
 
 
 
273
  // Handle error in Hosted Fields creation
274
- console.log(hostedFieldsErr);
275
  return;
276
  }
277
 
@@ -366,6 +395,43 @@ vZero.prototype = {
366
  }
367
  },
368
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
  /**
370
  * Once the nonce has been received update the field
371
  *
@@ -374,7 +440,7 @@ vZero.prototype = {
374
  */
375
  hostedFieldsNonceReceived: function (nonce, options) {
376
 
377
- if (this.threeDSecure) {
378
  // Show the loading state
379
  if (typeof this.integration.setLoading === 'function') {
380
  this.integration.setLoading();
@@ -464,8 +530,8 @@ vZero.prototype = {
464
  */
465
  usingSavedCard: function () {
466
  return ($('creditcard-saved-accounts') != undefined
467
- && $$('#creditcard-saved-accounts input:checked[type=radio]').first() != undefined
468
- && $$('#creditcard-saved-accounts input:checked[type=radio]').first().value !== 'other');
469
  },
470
 
471
  /**
@@ -728,7 +794,7 @@ vZero.prototype = {
728
  // Check the transport object has a URL and that it wasn't to our own controller
729
  if (url && url.indexOf('/braintree/') == -1) {
730
 
731
- this.fireEvent(this, 'integration.onHandleAjaxRequest', {url: url});
732
 
733
  // Some checkout implementations may require custom callbacks
734
  if (callback) {
@@ -778,6 +844,9 @@ vZero.prototype = {
778
  if (response.billingPostcode != undefined) {
779
  this.billingPostcode = response.billingPostcode;
780
  }
 
 
 
781
  if (response.grandTotal != undefined) {
782
  this.amount = response.grandTotal;
783
  }
@@ -903,7 +972,7 @@ vZero.prototype = {
903
  client: clientInstance
904
  }, function (threeDSecureError, threeDSecureInstance) {
905
  if (threeDSecureError) {
906
- console.log(threeDSecureError);
907
  return;
908
  }
909
 
18
  * @param billingPostcode Billing postcode also needed to verify the card
19
  * @param quoteUrl The URL to update the quote totals
20
  * @param tokenizeUrl The URL to re-tokenize 3D secure cards
 
21
  */
22
+ initialize: function (code, clientToken, threeDSecure, hostedFields, billingName, billingPostcode, quoteUrl, tokenizeUrl) {
23
  this.code = code;
24
  this.clientToken = clientToken;
25
  this.threeDSecure = threeDSecure;
31
  if (billingPostcode) {
32
  this.billingPostcode = billingPostcode;
33
  }
34
+ this.billingCountryId = false;
35
  if (quoteUrl) {
36
  this.quoteUrl = quoteUrl;
37
  }
53
 
54
  this.client = false;
55
 
56
+ this.threeDSpecificCountries = false;
57
+ this.threeDCountries = [];
58
+
59
  this.initEvents();
60
  },
61
 
70
  integration: {
71
  onInit: [],
72
  onInitDefaultMethod: [],
73
+ onInitSavedMethods: [],
74
  onShowHideOtherMethod: [],
75
  onCheckSavedOther: [],
76
  onPaymentMethodSwitch: [],
82
  };
83
  },
84
 
85
+ /**
86
+ * Set the 3D secure specific countries
87
+ *
88
+ * @param countries
89
+ */
90
+ setThreeDCountries: function (countries) {
91
+ if (typeof countries === 'string') {
92
+ countries = countries.split(',');
93
+ }
94
+ this.threeDSpecificCountries = true;
95
+ this.threeDCountries = countries;
96
+ },
97
+
98
  /**
99
  * Add an event into the system
100
  *
101
+ * @param paths
102
  * @param eventFn
103
  * @param params
104
  */
105
+ observeEvent: function (paths, eventFn, params) {
106
+ if (!Array.isArray(paths)) {
107
+ paths = [paths];
 
 
 
108
  }
109
+
110
+ // Handle multiple paths
111
+ paths.each(function (path) {
112
+ var event = this._resolveEvent(path);
113
+ if (event === undefined) {
114
+ console.warn('Event for ' + path + ' does not exist.');
115
+ } else {
116
+ event.push({fn: eventFn, params: params});
117
+ }
118
+ }.bind(this));
119
  },
120
 
121
  /**
129
  var events = this._resolveEvent(path);
130
  if (events !== undefined) {
131
  if (events.length > 0) {
132
+ events.each(function (event) {
133
+ if (typeof event.fn === 'function') {
134
  var arguments = [params];
135
+ if (typeof event.params === 'object') {
136
+ arguments.push(event.params);
137
  }
138
+ event.fn.apply(caller, arguments);
139
  }
140
  });
141
  }
172
  }, function (clientErr, clientInstance) {
173
  if (clientErr) {
174
  // Handle error in client creation
175
+ console.error(clientErr);
176
  return;
177
  }
178
 
294
  braintree.hostedFields.create(options, function (hostedFieldsErr, hostedFieldsInstance) {
295
  // Handle hosted fields errors
296
  if (hostedFieldsErr) {
297
+ // Duplicate IFRAME error can occur with certain checkouts implementations
298
+ if (hostedFieldsErr.code == 'HOSTED_FIELDS_FIELD_DUPLICATE_IFRAME') {
299
+ return;
300
+ }
301
+
302
  // Handle error in Hosted Fields creation
303
+ console.error(hostedFieldsErr);
304
  return;
305
  }
306
 
395
  }
396
  },
397
 
398
+ /**
399
+ * Retrieve the billing country ID
400
+ *
401
+ * @returns {*}
402
+ */
403
+ getBillingCountryId: function () {
404
+ if ($('billing-address-select') == null || $('billing-address-select').value == '') {
405
+ var billing = this.getBillingAddress();
406
+ if (typeof billing['billing[country_id]'] !== 'undefined') {
407
+ return billing['billing[country_id]'];
408
+ }
409
+ }
410
+
411
+ if (this.billingCountryId) {
412
+ return this.billingCountryId;
413
+ }
414
+
415
+ return false;
416
+ },
417
+
418
+ /**
419
+ * Should we invoke the 3Ds flow
420
+ *
421
+ * @returns {*}
422
+ */
423
+ shouldInvokeThreeDSecure: function () {
424
+ // Are we invoking 3D secure for specific countries only?
425
+ if (this.threeDSpecificCountries && this.threeDCountries.length > 0) {
426
+ var countryId;
427
+ if (countryId = this.getBillingCountryId()) {
428
+ return this.threeDCountries.indexOf(countryId) !== -1;
429
+ }
430
+ }
431
+
432
+ return this.threeDSecure;
433
+ },
434
+
435
  /**
436
  * Once the nonce has been received update the field
437
  *
440
  */
441
  hostedFieldsNonceReceived: function (nonce, options) {
442
 
443
+ if (this.shouldInvokeThreeDSecure()) {
444
  // Show the loading state
445
  if (typeof this.integration.setLoading === 'function') {
446
  this.integration.setLoading();
530
  */
531
  usingSavedCard: function () {
532
  return ($('creditcard-saved-accounts') != undefined
533
+ && $$('#creditcard-saved-accounts input:checked[type=radio]').first() != undefined
534
+ && $$('#creditcard-saved-accounts input:checked[type=radio]').first().value !== 'other');
535
  },
536
 
537
  /**
794
  // Check the transport object has a URL and that it wasn't to our own controller
795
  if (url && url.indexOf('/braintree/') == -1) {
796
 
797
+ this.fireEvent(this, 'onHandleAjaxRequest', {url: url});
798
 
799
  // Some checkout implementations may require custom callbacks
800
  if (callback) {
844
  if (response.billingPostcode != undefined) {
845
  this.billingPostcode = response.billingPostcode;
846
  }
847
+ if (response.billingCountryId != undefined) {
848
+ this.billingCountryId = response.billingCountryId;
849
+ }
850
  if (response.grandTotal != undefined) {
851
  this.amount = response.grandTotal;
852
  }
972
  client: clientInstance
973
  }, function (threeDSecureError, threeDSecureInstance) {
974
  if (threeDSecureError) {
975
+ console.error(threeDSecureError);
976
  return;
977
  }
978
 
js/gene/braintree/vzero-integration-min.js DELETED
@@ -1 +0,0 @@
1
- var vZeroIntegration=Class.create();vZeroIntegration.prototype={initialize:function(t,e,i,n,a,s,o){return vZeroIntegration.prototype.loaded?(console.error("Your checkout is including the Braintree resources multiple times, please resolve this."),!1):(vZeroIntegration.prototype.loaded=!0,this.vzero=t||!1,this.vzeroPaypal=e||!1,this.vzero===!1&&this.vzeroPaypal===!1?(console.warn("The vzero and vzeroPaypal objects are not initiated."),!1):(this.paypalWrapperMarkUp=i||!1,this.paypalButtonClass=n||!1,this.submitButtonClass=this.paypalButtonClass,this.isOnepage=a||!1,this.config=s||{},this.submitAfterPayment=o||!1,this._methodSwitchTimeout=!1,this._hostedFieldsInit=!1,document.observe("dom:loaded",function(){this.prepareSubmitObserver(),this.preparePaymentMethodSwitchObserver()}.bind(this)),this.hostedFieldsGenerated=!1,this.isOnepage&&(this.observeAjaxRequests(),document.observe("dom:loaded",function(){this.initSavedPayPal(),this.initDefaultMethod(),null!==$("braintree-hosted-submit")&&this.initHostedFields()}.bind(this))),document.observe("dom:loaded",function(){this.initSavedMethods(),null!==$("braintree-hosted-submit")&&this.initHostedFields()}.bind(this)),void this.vzero.fireEvent(this,"integration.onInit",{integration:this})))},initSavedMethods:function(){$$('#creditcard-saved-accounts input[type="radio"], #paypal-saved-accounts input[type="radio"]').each(function(t){var e="",i="";void 0!==t.up("#creditcard-saved-accounts")?(e="#creditcard-saved-accounts",i="#credit-card-form"):void 0!==t.up("#paypal-saved-accounts")&&(e="#paypal-saved-accounts",i=".paypal-info"),$(t).stopObserving("change").observe("change",function(t){return this.showHideOtherMethod(e,i)}.bind(this))}.bind(this))},showHideOtherMethod:function(t,e){void 0!==$$(t+" input:checked[type=radio]").first()&&"other"==$$(t+" input:checked[type=radio]").first().value?void 0!==$$(e).first()&&($$(e).first().show(),$$(e+" input, "+e+" select").each(function(t){t.removeAttribute("disabled")})):void 0!==$$(t+" input:checked[type=radio]").first()&&void 0!==$$(e).first()&&($$(e).first().hide(),$$(e+" input, "+e+" select").each(function(t){t.setAttribute("disabled","disabled")})),this.vzero.fireEvent(this,"integration.onShowHideOtherMethod",{parentElement:t,targetElement:e})},checkSavedOther:function(){var t="",e="";"gene_braintree_creditcard"==this.getPaymentMethod()?(t="#creditcard-saved-accounts",e="#credit-card-form"):"gene_braintree_paypal"==this.getPaymentMethod()&&(t="#paypal-saved-accounts",e=".paypal-info"),void 0!==$$(t).first()&&this.showHideOtherMethod(t,e),this.vzero.fireEvent(this,"integration.checkSavedOther")},afterPaymentMethodSwitch:function(){return!0},initHostedFields:function(){this.vzero.hostedFields&&null!==$("braintree-hosted-submit")&&(void 0!==$("braintree-hosted-submit").up("form")?(this._hostedFieldsInit=!0,this.form=$("braintree-hosted-submit").up("form"),this.vzero.initHostedFields(this)):console.error("Hosted Fields cannot be initialized as we're unable to locate the parent form."))},initDefaultMethod:function(){this.shouldAddPayPalButton(!1)&&(this.setLoading(),this.vzero.updateData(function(){this.resetLoading(),this.updatePayPalButton("add")}.bind(this))),this.afterPaymentMethodSwitch(),this.vzero.fireEvent(this,"integration.onInitDefaultMethod")},observeAjaxRequests:function(){this.vzero.observeAjaxRequests(function(){this.vzero.updateData(function(){this.isOnepage&&(this.initSavedPayPal(),this.rebuildPayPalButton(),this.checkSavedOther(),this.vzero.hostedFields&&this.initHostedFields()),this.initSavedMethods(),this.afterPaymentMethodSwitch(),this.vzero.fireEvent(this,"integration.onObserveAjaxRequests")}.bind(this))}.bind(this),"undefined"!=typeof this.config.ignoreAjax?this.config.ignoreAjax:!1)},rebuildPayPalButton:function(){null==$("paypal-container")&&this.updatePayPalButton()},initSavedPayPal:function(){void 0!==$$("#paypal-saved-accounts input[type=radio]").first()&&$("paypal-saved-accounts").on("change","input[type=radio]",function(t){this.updatePayPalButton(!1,"gene_braintree_paypal")}.bind(this))},prepareSubmitObserver:function(){return!1},beforeSubmit:function(t){return this._beforeSubmit(t)},_beforeSubmit:function(t){this.vzero.fireEvent(this,"integration.onBeforeSubmit"),this.submitAfterPayment&&$("braintree-submit-after-payment")&&$("braintree-submit-after-payment").remove(),t()},afterSubmit:function(){return this.vzero.fireEvent(this,"integration.onAfterSubmit"),!1},submit:function(t,e,i,n){this.shouldInterceptSubmit(t)&&(this.validateAll()?(this.setLoading(),this.beforeSubmit(function(){void 0!=$$('[data-genebraintree-name="number"]').first()&&this.vzero.updateCardType($$('[data-genebraintree-name="number"]').first().value),this.vzero.updateData(function(){this.updateBilling(),this.vzero.process({onSuccess:function(){if(this.enableDeviceData(),this.resetLoading(),this.afterSubmit(),this.enableDisableNonce(),this.vzero._hostedFieldsTokenGenerated=!0,this.hostedFieldsGenerated=!0,"function"==typeof e)var t=e();return this.setLoading(),t}.bind(this),onFailure:function(){return this.vzero._hostedFieldsTokenGenerated=!1,this.hostedFieldsGenerated=!1,this.resetLoading(),this.afterSubmit(),"function"==typeof i?i():void 0}.bind(this)})}.bind(this),this.getUpdateDataParams())}.bind(this))):(this.vzero._hostedFieldsTokenGenerated=!1,this.hostedFieldsGenerated=!1,this.resetLoading(),"function"==typeof n&&n()))},submitCheckout:function(){window.review&&review.save()},submitPayment:function(){payment.save&&payment.save()},enableDisableNonce:function(){"gene_braintree_creditcard"==this.getPaymentMethod()?(null!==$("creditcard-payment-nonce")&&$("creditcard-payment-nonce").removeAttribute("disabled"),null!==$("paypal-payment-nonce")&&$("paypal-payment-nonce").setAttribute("disabled","disabled")):"gene_braintree_paypal"==this.getPaymentMethod()&&(null!==$("creditcard-payment-nonce")&&$("creditcard-payment-nonce").setAttribute("disabled","disabled"),null!==$("paypal-payment-nonce")&&$("paypal-payment-nonce").removeAttribute("disabled"))},preparePaymentMethodSwitchObserver:function(){return this.defaultPaymentMethodSwitch()},defaultPaymentMethodSwitch:function(){var t=this,e=Payment.prototype.switchMethod;Payment.prototype.switchMethod=function(i){return t.paymentMethodSwitch(i),e.apply(this,arguments)}},paymentMethodSwitch:function(t){clearTimeout(this._methodSwitchTimeout),this._methodSwitchTimeout=setTimeout(function(){this.shouldAddPayPalButton(t)?this.updatePayPalButton("add",t):this.updatePayPalButton("remove",t),"gene_braintree_creditcard"==(t?t:this.getPaymentMethod())&&this.initHostedFields(),this.checkSavedOther(),this.afterPaymentMethodSwitch(),this.vzero.fireEvent(this,"integration.onPaymentMethodSwitch",{method:t})}.bind(this),50)},completePayPal:function(t){return this.enableDisableNonce(),this.enableDeviceData(),t.nonce&&null!==$("paypal-payment-nonce")?($("paypal-payment-nonce").value=t.nonce,$("paypal-payment-nonce").setAttribute("value",t.nonce)):console.warn("Unable to update PayPal nonce, please verify that the nonce input field has the ID: paypal-payment-nonce"),this.afterPayPalComplete(),!1},afterPayPalComplete:function(){return this.resetLoading(),this.submitCheckout()},getPayPalMarkUp:function(){return $("braintree-paypal-button").innerHTML},updatePayPalButton:function(t,e){if(this.paypalWrapperMarkUp===!1)return!1;if("refresh"==t)return!0;if(this.shouldAddPayPalButton(e)&&"remove"!=t||"add"==t)if(void 0!==$$(this.paypalButtonClass).first()){if($$(this.paypalButtonClass).first().hide(),void 0!==$$("#paypal-complete").first())return $$("#paypal-complete").first().show(),!0;$$(this.paypalButtonClass).first().insert({after:this.paypalWrapperMarkUp}),this.vzeroPaypal.addPayPalButton({validate:this.validateAll.bind(this),onSuccess:this.completePayPal.bind(this),onReady:this.paypalOnReady.bind(this)},this.getPayPalMarkUp(),"#paypal-container")}else console.warn("We're unable to find the element "+this.paypalButtonClass+". Please check your integration.");else void 0!==$$(this.paypalButtonClass).first()&&$$(this.paypalButtonClass).first().show(),void 0!==$$("#paypal-complete").first()&&$("paypal-complete").hide()},onReviewInit:function(){this.isOnepage||this.updatePayPalButton(),this.vzero.fireEvent(this,"integration.onReviewInit")},paypalOnReady:function(t){return!0},setLoading:function(){checkout.setLoadWaiting("payment")},resetLoading:function(){checkout.setLoadWaiting(!1)},enableDeviceData:function(){null!==$("device_data")&&$("device_data").removeAttribute("disabled")},updateBilling:function(){(null!==$("billing-address-select")&&""==$("billing-address-select").value||null===$("billing-address-select"))&&(null!==$("billing:firstname")&&null!==$("billing:lastname")&&this.vzero.setBillingName($("billing:firstname").value+" "+$("billing:lastname").value),null!==$("billing:postcode")&&this.vzero.setBillingPostcode($("billing:postcode").value))},getUpdateDataParams:function(){var t={};return null!==$("billing-address-select")&&""!=$("billing-address-select").value&&(t.addressId=$("billing-address-select").value),t},getPaymentMethod:function(){return payment.currentMethod},shouldInterceptSubmit:function(t){switch(t){case"creditcard":return"gene_braintree_creditcard"==this.getPaymentMethod()&&this.vzero.shouldInterceptCreditCard();break;case"paypal":return"gene_braintree_paypal"==this.getPaymentMethod()&&this.vzero.shouldInterceptCreditCard()}return!1},shouldAddPayPalButton:function(t){return"gene_braintree_paypal"==(t?t:this.getPaymentMethod())&&null===$("paypal-saved-accounts")||"gene_braintree_paypal"==(t?t:this.getPaymentMethod())&&void 0!==$$("#paypal-saved-accounts input:checked[type=radio]").first()&&"other"==$$("#paypal-saved-accounts input:checked[type=radio]").first().value},threeDTokenizationComplete:function(){this.resetLoading()},validateAll:function(){return!0},disableCreditCardForm:function(){},enableCreditCardForm:function(){}};
 
js/gene/braintree/vzero-min.js DELETED
@@ -1 +0,0 @@
1
- var vZero=Class.create();vZero.prototype={initialize:function(e,t,i,n,o,s,a,r,d){this.code=e,this.clientToken=t,this.threeDSecure=i,this.hostedFields=n,o&&(this.billingName=o),s&&(this.billingPostcode=s),a&&(this.quoteUrl=a),r&&(this.tokenizeUrl=r),this._hostedFieldsTokenGenerated=!1,this.acceptedCards=!1,this._hostedFieldsTimeout=!1,this._updateDataXhr=!1,this._updateDataCallbacks=[],this._updateDataParams={},this.client=!1,this.initEvents()},initEvents:function(){this.events={onBeforeUpdateData:[],onAfterUpdateData:[],onHandleAjaxRequest:[],integration:{onInit:[],onInitDefaultMethod:[],onShowHideOtherMethod:[],onCheckSavedOther:[],onPaymentMethodSwitch:[],onReviewInit:[],onBeforeSubmit:[],onAfterSubmit:[],onObserveAjaxRequests:[]}}},observeEvent:function(e,t,i){var n=this._resolveEvent(e);void 0===n?console.warn("Event for "+e+" does not exist."):n.push({fn:t,params:i})},fireEvent:function(e,t,i){var n=this._resolveEvent(t);void 0!==n&&n.length>0&&n.each(function(t){if("function"==typeof t.fn){var arguments=[i];"object"==typeof t.params&&arguments.push(t.params),t.fn.apply(e,arguments)}})},_resolveEvent:function(e){return e.split(".").reduce(function(e,t){return e?e[t]:void 0},this.events)},getClient:function(e){this.client!==!1?"function"==typeof e&&e(this.client):braintree.client.create({authorization:this.clientToken},function(t,i){return t?void console.log(t):(this.client=i,void e(this.client))}.bind(this))},initHostedFields:function(e){return $$('iframe[name^="braintree-"]').length>0?!1:null===$("braintree-hosted-submit")?!1:(this.integration=e,this._hostedFieldsTokenGenerated=!1,clearTimeout(this._hostedFieldsTimeout),void(this._hostedFieldsTimeout=setTimeout(function(){if(this._hostedIntegration!==!1)try{this._hostedIntegration.teardown(function(){this._hostedIntegration=!1,this.setupHostedFieldsClient()}.bind(this))}catch(e){this.setupHostedFieldsClient()}else this.setupHostedFieldsClient()}.bind(this),50)))},teardownHostedFields:function(e){"undefined"!=typeof this._hostedIntegration&&this._hostedIntegration!==!1?this._hostedIntegration.teardown(function(){this._hostedIntegration=!1,"function"==typeof e&&e()}.bind(this)):"function"==typeof e&&e()},setupHostedFieldsClient:function(){return $$('iframe[name^="braintree-"]').length>0?!1:(this._hostedIntegration=!1,void this.getClient(function(e){var t={client:e,styles:this.getHostedFieldsStyles(),fields:{number:{selector:"#card-number",placeholder:"0000 0000 0000 0000"},expirationMonth:{selector:"#expiration-month",placeholder:"MM"},expirationYear:{selector:"#expiration-year",placeholder:"YY"}}};null!==$("cvv")&&(t.fields.cvv={selector:"#cvv"}),braintree.hostedFields.create(t,function(e,t){return e?void console.log(e):this.hostedFieldsOnReady(t)}.bind(this))}.bind(this)))},hostedFieldsOnReady:function(e){if(this._hostedIntegration=e,$$("#credit-card-form.loading").length&&$$("#credit-card-form.loading").first().removeClassName("loading"),this.integration.submitAfterPayment){var t=new Element("input",{type:"hidden",name:"payment[submit_after_payment]",value:1,id:"braintree-submit-after-payment"});$("payment_form_gene_braintree_creditcard").insert(t)}else $("braintree-submit-after-payment")&&$("braintree-submit-after-payment").remove();e.on("cardTypeChange",this.hostedFieldsCardTypeChange.bind(this))},getHostedFieldsStyles:function(){return"function"==typeof this.integration.getHostedFieldsStyles?this.integration.getHostedFieldsStyles():{input:{"font-size":"14pt",color:"#3A3A3A"},":focus":{color:"black"},".valid":{color:"green"},".invalid":{color:"red"}}},hostedFieldsCardTypeChange:function(e){if("undefined"!=typeof e.cards){var t={visa:"VI","american-express":"AE","master-card":"MC",discover:"DI",jcb:"JCB",maestro:"ME"};void 0!==typeof t[e.cards[0].type]?this.updateCardType(!1,t[e.cards[0].type]):this.updateCardType(!1,"card")}},hostedFieldsNonceReceived:function(e,t){this.threeDSecure?("function"==typeof this.integration.setLoading&&this.integration.setLoading(),this.updateData(function(){this.verify3dSecureNonce(e,{onSuccess:function(e){this.updateNonce(e.nonce),"function"==typeof t.onSuccess&&t.onSuccess()}.bind(this),onFailure:function(){"function"==typeof t.onFailure&&t.onFailure()}.bind(this)})}.bind(this))):(this.updateNonce(e),"function"==typeof t.onSuccess&&t.onSuccess())},updateNonce:function(e){$("creditcard-payment-nonce").value=e,$("creditcard-payment-nonce").setAttribute("value",e),"function"==typeof this.integration.resetLoading&&this.integration.resetLoading(),this._hostedFieldsTokenGenerated=!0},hostedFieldsError:function(e){return"function"==typeof this.integration.resetLoading&&this.integration.resetLoading(),"undefined"!=typeof e.message&&-1==e.message.indexOf("Cannot place two elements in")&&-1==e.message.indexOf("Unable to find element with selector")&&-1==e.message.indexOf("User did not enter a payment method")&&alert(e.message),this._hostedFieldsTokenGenerated=!1,"function"==typeof this.integration.afterHostedFieldsError&&this.integration.afterHostedFieldsError(e.message),!1},usingSavedCard:function(){return void 0!=$("creditcard-saved-accounts")&&void 0!=$$("#creditcard-saved-accounts input:checked[type=radio]").first()&&"other"!==$$("#creditcard-saved-accounts input:checked[type=radio]").first().value},usingSavedThreeDCard:function(){return this.usingSavedCard()&&$$("#creditcard-saved-accounts input:checked[type=radio]").first().hasAttribute("data-threedsecure-nonce")},setThreeDSecure:function(e){this.threeDSecure=e},setAmount:function(e){this.amount=parseFloat(e)},setBillingName:function(e){this.billingName=e},getBillingName:function(){return"object"==typeof this.billingName?this.combineElementsValues(this.billingName):this.billingName},setBillingPostcode:function(e){this.billingPostcode=e},getBillingPostcode:function(){return"object"==typeof this.billingPostcode?this.combineElementsValues(this.billingPostcode):this.billingPostcode},setAcceptedCards:function(e){this.acceptedCards=e},getBillingAddress:function(){if("function"==typeof this.integration.getBillingAddress)return this.integration.getBillingAddress();var e={};return null!==$("co-billing-form")?e="FORM"==$("co-billing-form").tagName?$("co-billing-form").serialize(!0):this.extractBilling($("co-billing-form").up("form").serialize(!0)):null!==$("billing:firstname")&&(e=this.extractBilling($("billing:firstname").up("form").serialize(!0))),e?e:void 0},extractBilling:function(e){var t={};return $H(e).each(function(e){0==e.key.indexOf("billing")&&-1==e.key.indexOf("password")&&(t[e.key]=e.value)}),t},getAcceptedCards:function(){return this.acceptedCards},combineElementsValues:function(e,t){t||(t=" ");var i=[];return e.each(function(e,t){void 0!==$(e)&&(i[t]=$(e).value)}),i.join(t)},updateCardType:function(e,t){if(void 0!=$("card-type-image")){var i=$("card-type-image").src.substring(0,$("card-type-image").src.lastIndexOf("/"));$("card-type-image").setAttribute("src",i+"/"+t+".png")}},observeAjaxRequests:function(e,t){return vZero.prototype.observingAjaxRequests?!1:(vZero.prototype.observingAjaxRequests=!0,Ajax.Responders.register({onComplete:function(i){return this.handleAjaxRequest(i.url,e,t)}.bind(this)}),void(window.jQuery&&jQuery(document).ajaxComplete(function(i,n,o){return this.handleAjaxRequest(o.url,e,t)}.bind(this))))},handleAjaxRequest:function(e,t,i){if("undefined"!=typeof i&&i instanceof Array&&i.length>0){var n=!1;if(i.each(function(t){e&&-1!=e.indexOf(t)&&(n=!0)}),n===!0)return!1}e&&-1==e.indexOf("/braintree/")&&(this.fireEvent(this,"integration.onHandleAjaxRequest",{url:e}),t?t(e):this.updateData())},updateData:function(e,t){this.fireEvent(this,"integration.onBeforeUpdateData",{params:t}),this._updateDataCallbacks.push(e),this._updateDataParams=t,this._updateDataXhr!==!1&&this._updateDataXhr.transport.abort(),this._updateDataXhr=new Ajax.Request(this.quoteUrl,{method:"post",parameters:this._updateDataParams,onSuccess:function(e){if(e&&(e.responseJSON||e.responseText)){var t=this._parseTransportAsJson(e);void 0!=t.billingName&&(this.billingName=t.billingName),void 0!=t.billingPostcode&&(this.billingPostcode=t.billingPostcode),void 0!=t.grandTotal&&(this.amount=t.grandTotal),void 0!=t.threeDSecure&&this.setThreeDSecure(t.threeDSecure),"undefined"!=typeof vzeroPaypal&&void 0!=t.grandTotal&&void 0!=t.currencyCode&&vzeroPaypal.setPricing(t.grandTotal,t.currencyCode),this._updateDataParams={},this._updateDataXhr=!1,this._updateDataCallbacks.length&&(this._updateDataCallbacks.each(function(e){e(t)}.bind(this)),this._updateDataCallbacks=[]),this.fireEvent(this,"onAfterUpdateData",{response:t})}}.bind(this),onFailure:function(){this._updateDataParams={},this._updateDataXhr=!1,this._updateDataCallbacks=[]}.bind(this)})},tokenize3dSavedCards:function(e){if(this.threeDSecure)if(void 0!==$$("[data-token]").first()){var t=[];$$("[data-token]").each(function(e,i){t[i]=e.getAttribute("data-token")}),new Ajax.Request(this.tokenizeUrl,{method:"post",onSuccess:function(t){if(t&&(t.responseJSON||t.responseText)){var i=this._parseTransportAsJson(t);i.success&&$H(i.tokens).each(function(e){void 0!=$$('[data-token="'+e.key+'"]').first()&&$$('[data-token="'+e.key+'"]').first().setAttribute("data-threedsecure-nonce",e.value)}),e&&e(i)}}.bind(this),parameters:{tokens:Object.toJSON(t)}})}else e();else e()},verify3dSecureNonce:function(e,t){this.getClient(function(i){braintree.threeDSecure.create({client:i},function(i,n){if(i)return void console.log(i);var o={amount:this.amount,nonce:e,addFrame:function(e,t){$$("#three-d-modal .bt-modal-body").first().insert(t),$("three-d-modal").removeClassName("hidden")},removeFrame:function(){$$("#three-d-modal .bt-modal-body iframe").first().remove(),$("three-d-modal").addClassName("hidden")}.bind(this)};n.verifyCard(o,function(e,i){e?t.onFailure&&t.onFailure(i,e):i.liabilityShifted?t.onSuccess&&t.onSuccess(i):i.liabilityShiftPossible?t.onSuccess&&t.onSuccess(i):t.onSuccess&&t.onSuccess(i)})}.bind(this))}.bind(this))},verify3dSecureVault:function(e){var t=$$("#creditcard-saved-accounts input:checked[type=radio]").first().getAttribute("data-threedsecure-nonce");t?this.verify3dSecureNonce(t,{onSuccess:function(t){$("creditcard-payment-nonce").removeAttribute("disabled"),$("creditcard-payment-nonce").value=t.nonce,$("creditcard-payment-nonce").setAttribute("value",t.nonce),"function"==typeof e.onSuccess&&e.onSuccess()},onFailure:function(t,i){alert(i),"function"==typeof e.onFailure?e.onFailure():checkout.setLoadWaiting(!1)}}):(alert("No payment nonce present."),"function"==typeof e.onFailure?e.onFailure():checkout.setLoadWaiting(!1))},processCard:function(e){this._hostedIntegration.tokenize(function(t,i){return t?("function"==typeof e.onFailure?e.onFailure():checkout.setLoadWaiting(!1),void("string"==typeof t.message&&alert(t.message))):this.hostedFieldsNonceReceived(i.nonce,e)}.bind(this))},shouldInterceptCreditCard:function(){return"0.00"!=this.amount},shouldInterceptPayPal:function(){return!0},process:function(e){return e=e||{},this._hostedFieldsTokenGenerated||this.usingSavedCard()&&!this.usingSavedThreeDCard()?void("function"==typeof e.onSuccess&&e.onSuccess()):this.usingSavedThreeDCard()?this.verify3dSecureVault(e):this.processCard(e)},creditCardLoaded:function(){return!1},paypalLoaded:function(){return!1},_parseTransportAsJson:function(transport){return transport.responseJSON&&"object"==typeof transport.responseJSON?transport.responseJSON:transport.responseText?"object"==typeof JSON&&"function"==typeof JSON.parse?JSON.parse(transport.responseText):eval("("+transport.responseText+")"):{}}},function(){for(var e,t=function(){},i=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],n=i.length,o=window.console=window.console||{};n--;)e=i[n],o[e]||(o[e]=t)}();
 
js/gene/braintree/vzero-paypal-min.js DELETED
@@ -1 +0,0 @@
1
- var vZeroPayPalButton=Class.create();vZeroPayPalButton.prototype={initialize:function(t,n,e,i,o){this.clientToken=t,this.storeFrontName=n,this.singleUse=e,this.locale=i,this.amount=0,this.currency=!1,this.client=!1},getClient:function(t){this.client!==!1?"function"==typeof t&&t(this.client):braintree.client.create({authorization:this.clientToken},function(n,e){return n?void console.log(n):(this.client=e,void t(this.client))}.bind(this))},setPricing:function(t,n){this.amount=parseFloat(t),this.currency=n},rebuildButton:function(){return!1},addPayPalButton:function(t,n,e,i){var o;if(n=n||$("braintree-paypal-button").innerHTML,e=e||"#paypal-container",i=i||!1,o="string"==typeof e?$$(e).first():e,!o)return console.warn("Unable to locate container "+e+" for PayPal button."),!1;if(i?o.insert(n):o.update(n),!o.select(">button").length)return console.warn("Unable to find valid <button /> element within container."),!1;var a=o.select(">button").first();a.addClassName("braintree-paypal-loading"),a.setAttribute("disabled","disabled"),this.attachPayPalButtonEvent(a,t)},attachPayPalButtonEvent:function(t,n){this.getClient(function(e){braintree.paypal.create({client:e},function(e,i){return e?void console.error("Error creating PayPal:",e):("function"==typeof n.onReady&&n.onReady(i),this._attachPayPalButtonEvent(t,i,n))}.bind(this))}.bind(this))},_attachPayPalButtonEvent:function(t,n,e){t&&n&&(Array.isArray(t)||(t=[t]),t.each(function(t){t.removeClassName("braintree-paypal-loading"),t.removeAttribute("disabled"),Event.stopObserving(t,"click"),Event.observe(t,"click",function(t){return Event.stop(t),"function"!=typeof e.validate?this._tokenizePayPal(n,e):e.validate()?this._tokenizePayPal(n,e):void 0}.bind(this))}.bind(this)))},_tokenizePayPal:function(t,n){var e=this._buildOptions();"object"==typeof n.tokenizeRequest&&(e=Object.extend(e,n.tokenizeRequest)),t.tokenize(e,function(t,e){return t?void("CUSTOMER"!==t.type&&console.error("Error tokenizing:",t)):void("function"==typeof n.onSuccess&&n.onSuccess(e))}.bind(this))},_buildOptions:function(){var t={displayName:this.storeFrontName,amount:this.amount,currency:this.currency,useraction:"commit"};return this.locale&&(t.locale=this.locale),this.singleUse===!0?t.flow="checkout":t.flow="vault",t}};
 
lib/Gene/Braintree.php DELETED
@@ -1,156 +0,0 @@
1
- <?php
2
- /**
3
- * Braintree PHP Library
4
- *
5
- * Braintree base class and initialization
6
- * Provides methods to child classes. This class cannot be instantiated.
7
- *
8
- * PHP version 5
9
- *
10
- * @copyright 2014 Braintree, a division of PayPal, Inc.
11
- */
12
-
13
-
14
- set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__)));
15
-
16
- require_once('Braintree/Base.php');
17
- require_once('Braintree/Modification.php');
18
- require_once('Braintree/Instance.php');
19
-
20
- require_once('Braintree/OAuthCredentials.php');
21
- require_once('Braintree/Address.php');
22
- require_once('Braintree/AddressGateway.php');
23
- require_once('Braintree/AddOn.php');
24
- require_once('Braintree/AddOnGateway.php');
25
- require_once('Braintree/AndroidPayCard.php');
26
- require_once('Braintree/ApplePayCard.php');
27
- require_once('Braintree/ClientToken.php');
28
- require_once('Braintree/ClientTokenGateway.php');
29
- require_once('Braintree/CoinbaseAccount.php');
30
- require_once('Braintree/Collection.php');
31
- require_once('Braintree/Configuration.php');
32
- require_once('Braintree/CredentialsParser.php');
33
- require_once('Braintree/CreditCard.php');
34
- require_once('Braintree/CreditCardGateway.php');
35
- require_once('Braintree/Customer.php');
36
- require_once('Braintree/CustomerGateway.php');
37
- require_once('Braintree/CustomerSearch.php');
38
- require_once('Braintree/DisbursementDetails.php');
39
- require_once('Braintree/Dispute.php');
40
- require_once('Braintree/Dispute/TransactionDetails.php');
41
- require_once('Braintree/Descriptor.php');
42
- require_once('Braintree/Digest.php');
43
- require_once('Braintree/Discount.php');
44
- require_once('Braintree/DiscountGateway.php');
45
- require_once('Braintree/IsNode.php');
46
- require_once('Braintree/EuropeBankAccount.php');
47
- require_once('Braintree/EqualityNode.php');
48
- require_once('Braintree/Exception.php');
49
- require_once('Braintree/Gateway.php');
50
- require_once('Braintree/Http.php');
51
- require_once('Braintree/KeyValueNode.php');
52
- require_once('Braintree/Merchant.php');
53
- require_once('Braintree/MerchantGateway.php');
54
- require_once('Braintree/MerchantAccount.php');
55
- require_once('Braintree/MerchantAccountGateway.php');
56
- require_once('Braintree/MerchantAccount/BusinessDetails.php');
57
- require_once('Braintree/MerchantAccount/FundingDetails.php');
58
- require_once('Braintree/MerchantAccount/IndividualDetails.php');
59
- require_once('Braintree/MerchantAccount/AddressDetails.php');
60
- require_once('Braintree/MultipleValueNode.php');
61
- require_once('Braintree/MultipleValueOrTextNode.php');
62
- require_once('Braintree/OAuthGateway.php');
63
- require_once('Braintree/PartialMatchNode.php');
64
- require_once('Braintree/Plan.php');
65
- require_once('Braintree/PlanGateway.php');
66
- require_once('Braintree/RangeNode.php');
67
- require_once('Braintree/ResourceCollection.php');
68
- require_once('Braintree/RiskData.php');
69
- require_once('Braintree/ThreeDSecureInfo.php');
70
- require_once('Braintree/SettlementBatchSummary.php');
71
- require_once('Braintree/SettlementBatchSummaryGateway.php');
72
- require_once('Braintree/SignatureService.php');
73
- require_once('Braintree/Subscription.php');
74
- require_once('Braintree/SubscriptionGateway.php');
75
- require_once('Braintree/SubscriptionSearch.php');
76
- require_once('Braintree/Subscription/StatusDetails.php');
77
- require_once('Braintree/TextNode.php');
78
- require_once('Braintree/Transaction.php');
79
- require_once('Braintree/TransactionGateway.php');
80
- require_once('Braintree/Disbursement.php');
81
- require_once('Braintree/TransactionSearch.php');
82
- require_once('Braintree/TransparentRedirect.php');
83
- require_once('Braintree/TransparentRedirectGateway.php');
84
- require_once('Braintree/Util.php');
85
- require_once('Braintree/Version.php');
86
- require_once('Braintree/Xml.php');
87
- require_once('Braintree/Error/Codes.php');
88
- require_once('Braintree/Error/ErrorCollection.php');
89
- require_once('Braintree/Error/Validation.php');
90
- require_once('Braintree/Error/ValidationErrorCollection.php');
91
- require_once('Braintree/Exception/Authentication.php');
92
- require_once('Braintree/Exception/Authorization.php');
93
- require_once('Braintree/Exception/Configuration.php');
94
- require_once('Braintree/Exception/DownForMaintenance.php');
95
- require_once('Braintree/Exception/ForgedQueryString.php');
96
- require_once('Braintree/Exception/InvalidChallenge.php');
97
- require_once('Braintree/Exception/InvalidSignature.php');
98
- require_once('Braintree/Exception/NotFound.php');
99
- require_once('Braintree/Exception/ServerError.php');
100
- require_once('Braintree/Exception/SSLCertificate.php');
101
- require_once('Braintree/Exception/SSLCaFileNotFound.php');
102
- require_once('Braintree/Exception/Unexpected.php');
103
- require_once('Braintree/Exception/UpgradeRequired.php');
104
- require_once('Braintree/Exception/ValidationsFailed.php');
105
- require_once('Braintree/Result/CreditCardVerification.php');
106
- require_once('Braintree/Result/Error.php');
107
- require_once('Braintree/Result/Successful.php');
108
- require_once('Braintree/Test/CreditCardNumbers.php');
109
- require_once('Braintree/Test/MerchantAccount.php');
110
- require_once('Braintree/Test/TransactionAmounts.php');
111
- require_once('Braintree/Test/VenmoSdk.php');
112
- require_once('Braintree/Test/Nonces.php');
113
- require_once('Braintree/Transaction/AddressDetails.php');
114
- require_once('Braintree/Transaction/AndroidPayCardDetails.php');
115
- require_once('Braintree/Transaction/ApplePayCardDetails.php');
116
- require_once('Braintree/Transaction/CoinbaseDetails.php');
117
- require_once('Braintree/Transaction/EuropeBankAccountDetails.php');
118
- require_once('Braintree/Transaction/CreditCardDetails.php');
119
- require_once('Braintree/Transaction/PayPalDetails.php');
120
- require_once('Braintree/Transaction/CustomerDetails.php');
121
- require_once('Braintree/Transaction/StatusDetails.php');
122
- require_once('Braintree/Transaction/SubscriptionDetails.php');
123
- require_once('Braintree/WebhookNotification.php');
124
- require_once('Braintree/WebhookTesting.php');
125
- require_once('Braintree/Xml/Generator.php');
126
- require_once('Braintree/Xml/Parser.php');
127
- require_once('Braintree/CreditCardVerification.php');
128
- require_once('Braintree/CreditCardVerificationGateway.php');
129
- require_once('Braintree/CreditCardVerificationSearch.php');
130
- require_once('Braintree/PartnerMerchant.php');
131
- require_once('Braintree/PayPalAccount.php');
132
- require_once('Braintree/PayPalAccountGateway.php');
133
- require_once('Braintree/PaymentMethod.php');
134
- require_once('Braintree/PaymentMethodGateway.php');
135
- require_once('Braintree/PaymentMethodNonce.php');
136
- require_once('Braintree/PaymentMethodNonceGateway.php');
137
- require_once('Braintree/PaymentInstrumentType.php');
138
- require_once('Braintree/UnknownPaymentMethod.php');
139
- require_once('Braintree/Exception/TestOperationPerformedInProduction.php');
140
- require_once('Braintree/Test/Transaction.php');
141
-
142
- if (version_compare(PHP_VERSION, '5.4.0', '<')) {
143
- throw new Braintree_Exception('PHP version >= 5.4.0 required');
144
- }
145
-
146
-
147
- function requireDependencies() {
148
- $requiredExtensions = array('xmlwriter', 'openssl', 'dom', 'hash', 'curl');
149
- foreach ($requiredExtensions AS $ext) {
150
- if (!extension_loaded($ext)) {
151
- throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.');
152
- }
153
- }
154
- }
155
-
156
- requireDependencies();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/CreditCardVerification.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- class Braintree_CreditCardVerification extends Braintree_Result_CreditCardVerification
3
- {
4
- public static function factory($attributes)
5
- {
6
- $instance = new self($attributes);
7
- return $instance;
8
- }
9
-
10
-
11
- // static methods redirecting to gateway
12
-
13
- public static function fetch($query, $ids)
14
- {
15
- return Braintree_Configuration::gateway()->creditCardVerification()->fetch($query, $ids);
16
- }
17
-
18
- public static function search($query)
19
- {
20
- return Braintree_Configuration::gateway()->creditCardVerification()->search($query);
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/CreditCardVerificationGateway.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- class Braintree_CreditCardVerificationGateway
3
- {
4
- private $_gateway;
5
- private $_config;
6
- private $_http;
7
-
8
- public function __construct($gateway)
9
- {
10
- $this->_gateway = $gateway;
11
- $this->_config = $gateway->config;
12
- $this->_config->assertHasAccessTokenOrKeys();
13
- $this->_http = new Braintree_Http($gateway->config);
14
- }
15
-
16
- public function fetch($query, $ids)
17
- {
18
- $criteria = array();
19
- foreach ($query as $term) {
20
- $criteria[$term->name] = $term->toparam();
21
- }
22
- $criteria["ids"] = Braintree_CreditCardVerificationSearch::ids()->in($ids)->toparam();
23
- $path = $this->_config->merchantPath() . '/verifications/advanced_search';
24
- $response = $this->_http->post($path, array('search' => $criteria));
25
-
26
- return Braintree_Util::extractattributeasarray(
27
- $response['creditCardVerifications'],
28
- 'verification'
29
- );
30
- }
31
-
32
- public function search($query)
33
- {
34
- $criteria = array();
35
- foreach ($query as $term) {
36
- $criteria[$term->name] = $term->toparam();
37
- }
38
-
39
- $path = $this->_config->merchantPath() . '/verifications/advanced_search_ids';
40
- $response = $this->_http->post($path, array('search' => $criteria));
41
- $pager = array(
42
- 'object' => $this,
43
- 'method' => 'fetch',
44
- 'methodArgs' => array($query)
45
- );
46
-
47
- return new Braintree_ResourceCollection($response, $pager);
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/CreditCardVerificationSearch.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
- class Braintree_CreditCardVerificationSearch
3
- {
4
- static function id() {
5
- return new Braintree_TextNode('id');
6
- }
7
-
8
- static function creditCardCardholderName() {
9
- return new Braintree_TextNode('credit_card_cardholder_name');
10
- }
11
-
12
- static function billingAddressDetailsPostalCode() {
13
- return new Braintree_TextNode('billing_address_details_postal_code');
14
- }
15
-
16
- static function customerEmail() {
17
- return new Braintree_TextNode('customer_email');
18
- }
19
-
20
- static function customerId() {
21
- return new Braintree_TextNode('customer_id');
22
- }
23
-
24
- static function paymentMethodToken(){
25
- return new Braintree_TextNode('payment_method_token');
26
- }
27
-
28
- static function creditCardExpirationDate() {
29
- return new Braintree_EqualityNode('credit_card_expiration_date');
30
- }
31
-
32
- static function creditCardNumber() {
33
- return new Braintree_PartialMatchNode('credit_card_number');
34
- }
35
-
36
- static function ids() {
37
- return new Braintree_MultipleValueNode('ids');
38
- }
39
-
40
- static function createdAt() {
41
- return new Braintree_RangeNode("created_at");
42
- }
43
-
44
- static function creditCardCardType()
45
- {
46
- return new Braintree_MultipleValueNode("credit_card_card_type", Braintree_CreditCard::allCardTypes());
47
- }
48
-
49
- static function status()
50
- {
51
- return new Braintree_MultipleValueNode("status", Braintree_Result_CreditCardVerification::allStatuses());
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/CustomerSearch.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- class Braintree_CustomerSearch
3
- {
4
- static function addressCountryName() { return new Braintree_TextNode('address_country_name'); }
5
- static function addressExtendedAddress() { return new Braintree_TextNode('address_extended_address'); }
6
- static function addressFirstName() { return new Braintree_TextNode('address_first_name'); }
7
- static function addressLastName() { return new Braintree_TextNode('address_last_name'); }
8
- static function addressLocality() { return new Braintree_TextNode('address_locality'); }
9
- static function addressPostalCode() { return new Braintree_TextNode('address_postal_code'); }
10
- static function addressRegion() { return new Braintree_TextNode('address_region'); }
11
- static function addressStreetAddress() { return new Braintree_TextNode('address_street_address'); }
12
- static function cardholderName() { return new Braintree_TextNode('cardholder_name'); }
13
- static function company() { return new Braintree_TextNode('company'); }
14
- static function email() { return new Braintree_TextNode('email'); }
15
- static function fax() { return new Braintree_TextNode('fax'); }
16
- static function firstName() { return new Braintree_TextNode('first_name'); }
17
- static function id() { return new Braintree_TextNode('id'); }
18
- static function lastName() { return new Braintree_TextNode('last_name'); }
19
- static function paymentMethodToken() { return new Braintree_TextNode('payment_method_token'); }
20
- static function paymentMethodTokenWithDuplicates() { return new Braintree_IsNode('payment_method_token_with_duplicates'); }
21
- static function paypalAccountEmail() { return new Braintree_IsNode('paypal_account_email'); }
22
- static function phone() { return new Braintree_TextNode('phone'); }
23
- static function website() { return new Braintree_TextNode('website'); }
24
-
25
- static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); }
26
- static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); }
27
-
28
- static function ids() { return new Braintree_MultipleValueNode('ids'); }
29
-
30
- static function createdAt() { return new Braintree_RangeNode("created_at"); }
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Descriptor.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- class Braintree_Descriptor extends Braintree_Instance
3
- {
4
- }
 
 
 
 
lib/Gene/Braintree/Exception.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- /**
3
- * super class for all Braintree exceptions
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception extends Exception
10
- {
11
- }
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/Authentication.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when authentication fails.
4
- * This may be caused by an incorrect Braintree_Configuration
5
- *
6
- * @package Braintree
7
- * @subpackage Exception
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
- */
10
- class Braintree_Exception_Authentication extends Braintree_Exception
11
- {
12
-
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/Configuration.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when the Braintree library is not completely configured.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @see Braintree_Configuration
8
- */
9
- class Braintree_Exception_Configuration extends Braintree_Exception
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/DownForMaintenance.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when the gateway is down for maintenance.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception_DownForMaintenance extends Braintree_Exception
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/InvalidChallenge.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
- class Braintree_Exception_InvalidChallenge extends Braintree_Exception
3
- {
4
-
5
- }
 
 
 
 
 
lib/Gene/Braintree/Exception/InvalidSignature.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
- class Braintree_Exception_InvalidSignature extends Braintree_Exception
3
- {
4
-
5
- }
 
 
 
 
 
lib/Gene/Braintree/Exception/NotFound.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when a record could not be found.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception_NotFound extends Braintree_Exception
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/SSLCaFileNotFound.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when the SSL CaFile is not found.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception_SSLCaFileNotFound extends Braintree_Exception
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/SSLCertificate.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when the SSL certificate fails verification.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception_SSLCertificate extends Braintree_Exception
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/ServerError.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when an unexpected server error occurs.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception_ServerError extends Braintree_Exception
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/TestOperationPerformedInProduction.php DELETED
@@ -1,11 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when a test method is used in production.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception_TestOperationPerformedInProduction extends Braintree_Exception
10
- {
11
- }
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/Unexpected.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when an error occurs that the client library is not built to handle.
4
- * This shouldn't happen.
5
- *
6
- * @package Braintree
7
- * @subpackage Exception
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
- */
10
- class Braintree_Exception_Unexpected extends Braintree_Exception
11
- {
12
-
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/UpgradeRequired.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * Raised when a client library must be upgraded.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception_UpgradeRequired extends Braintree_Exception
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Exception/ValidationsFailed.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- /**
3
- * Raised from non-validating methods when gateway validations fail.
4
- *
5
- * @package Braintree
6
- * @subpackage Exception
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Exception_ValidationsFailed extends Braintree_Exception
10
- {
11
-
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Gateway.php DELETED
@@ -1,195 +0,0 @@
1
- <?php
2
- /**
3
- * Braintree Gateway module
4
- *
5
- * @package Braintree
6
- * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
- class Braintree_Gateway
10
- {
11
- /**
12
- *
13
- * @var Braintree_Configuration
14
- */
15
- public $config;
16
-
17
- public function __construct($config)
18
- {
19
- if (is_array($config)) {
20
- $config = new Braintree_Configuration($config);
21
- }
22
- $this->config = $config;
23
- }
24
-
25
- /**
26
- *
27
- * @return \Braintree_AddOnGateway
28
- */
29
- public function addOn()
30
- {
31
- return new Braintree_AddOnGateway($this);
32
- }
33
-
34
- /**
35
- *
36
- * @return \Braintree_AddressGateway
37
- */
38
- public function address()
39
- {
40
- return new Braintree_AddressGateway($this);
41
- }
42
-
43
- /**
44
- *
45
- * @return \Braintree_ClientTokenGateway
46
- */
47
- public function clientToken()
48
- {
49
- return new Braintree_ClientTokenGateway($this);
50
- }
51
-
52
- /**
53
- *
54
- * @return \Braintree_CreditCardGateway
55
- */
56
- public function creditCard()
57
- {
58
- return new Braintree_CreditCardGateway($this);
59
- }
60
-
61
- /**
62
- *
63
- * @return \Braintree_CreditCardVerificationGateway
64
- */
65
- public function creditCardVerification()
66
- {
67
- return new Braintree_CreditCardVerificationGateway($this);
68
- }
69
-
70
- /**
71
- *
72
- * @return \Braintree_CustomerGateway
73
- */
74
- public function customer()
75
- {
76
- return new Braintree_CustomerGateway($this);
77
- }
78
-
79
- /**
80
- *
81
- * @return \Braintree_DiscountGateway
82
- */
83
- public function discount()
84
- {
85
- return new Braintree_DiscountGateway($this);
86
- }
87
-
88
- /**
89
- *
90
- * @return \Braintree_MerchantGateway
91
- */
92
- public function merchant()
93
- {
94
- return new Braintree_MerchantGateway($this);
95
- }
96
-
97
- /**
98
- *
99
- * @return \Braintree_MerchantAccountGateway
100
- */
101
- public function merchantAccount()
102
- {
103
- return new Braintree_MerchantAccountGateway($this);
104
- }
105
-
106
- /**
107
- *
108
- * @return \Braintree_OAuthGateway
109
- */
110
- public function oauth()
111
- {
112
- return new Braintree_OAuthGateway($this);
113
- }
114
-
115
- /**
116
- *
117
- * @return \Braintree_PaymentMethodGateway
118
- */
119
- public function paymentMethod()
120
- {
121
- return new Braintree_PaymentMethodGateway($this);
122
- }
123
-
124
- /**
125
- *
126
- * @return \Braintree_PaymentMethodNonceGateway
127
- */
128
- public function paymentMethodNonce()
129
- {
130
- return new Braintree_PaymentMethodNonceGateway($this);
131
- }
132
-
133
- /**
134
- *
135
- * @return \Braintree_PayPalAccountGateway
136
- */
137
- public function payPalAccount()
138
- {
139
- return new Braintree_PayPalAccountGateway($this);
140
- }
141
-
142
- /**
143
- *
144
- * @return \Braintree_PlanGateway
145
- */
146
- public function plan()
147
- {
148
- return new Braintree_PlanGateway($this);
149
- }
150
-
151
- /**
152
- *
153
- * @return \Braintree_SettlementBatchSummaryGateway
154
- */
155
- public function settlementBatchSummary()
156
- {
157
- return new Braintree_SettlementBatchSummaryGateway($this);
158
- }
159
-
160
- /**
161
- *
162
- * @return \Braintree_SubscriptionGateway
163
- */
164
- public function subscription()
165
- {
166
- return new Braintree_SubscriptionGateway($this);
167
- }
168
-
169
- /**
170
- *
171
- * @return \Braintree_TestingGateway
172
- */
173
- public function testing()
174
- {
175
- return new Braintree_TestingGateway($this);
176
- }
177
-
178
- /**
179
- *
180
- * @return \Braintree_TransactionGateway
181
- */
182
- public function transaction()
183
- {
184
- return new Braintree_TransactionGateway($this);
185
- }
186
-
187
- /**
188
- *
189
- * @return \Braintree_TransparentRedirectGateway
190
- */
191
- public function transparentRedirect()
192
- {
193
- return new Braintree_TransparentRedirectGateway($this);
194
- }
195
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/IsNode.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Braintree_IsNode
4
- {
5
- function __construct($name)
6
- {
7
- $this->name = $name;
8
- $this->searchTerms = array();
9
- }
10
-
11
- function is($value)
12
- {
13
- $this->searchTerms['is'] = strval($value);
14
- return $this;
15
- }
16
-
17
- function toParam()
18
- {
19
- return $this->searchTerms;
20
- }
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Merchant.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- final class Braintree_Merchant extends Braintree_Base
4
- {
5
- protected function _initialize($attribs)
6
- {
7
- $this->_attributes = $attribs;
8
- }
9
-
10
- public static function factory($attributes)
11
- {
12
- $instance = new self();
13
- $instance->_initialize($attributes);
14
- return $instance;
15
- }
16
-
17
- /**
18
- * returns a string representation of the merchant
19
- * @return string
20
- */
21
- public function __toString()
22
- {
23
- return __CLASS__ . '[' .
24
- Braintree_Util::attributesToString($this->_attributes) .']';
25
- }
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/MerchantAccount/AddressDetails.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
-
3
- final class Braintree_MerchantAccount_AddressDetails extends Braintree_Instance {
4
- protected $_attributes = array();
5
- }
 
 
 
 
 
lib/Gene/Braintree/MerchantAccount/FundingDetails.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- final class Braintree_MerchantAccount_FundingDetails extends Braintree_Instance
4
- {
5
- protected $_attributes = array();
6
- }
 
 
 
 
 
 
lib/Gene/Braintree/PartialMatchNode.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
-
3
- class Braintree_PartialMatchNode extends Braintree_EqualityNode
4
- {
5
- function startsWith($value)
6
- {
7
- $this->searchTerms["starts_with"] = strval($value);
8
- return $this;
9
- }
10
-
11
- function endsWith($value)
12
- {
13
- $this->searchTerms["ends_with"] = strval($value);
14
- return $this;
15
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/PaymentMethod.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
- /**
3
- * Braintree PaymentMethod module
4
- *
5
- * @package Braintree
6
- * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
- */
9
-
10
- /**
11
- * Creates and manages Braintree PaymentMethods
12
- *
13
- * <b>== More information ==</b>
14
- *
15
- *
16
- * @package Braintree
17
- * @category Resources
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
- *
20
- */
21
- class Braintree_PaymentMethod extends Braintree_Base
22
- {
23
- // static methods redirecting to gateway
24
-
25
- public static function create($attribs)
26
- {
27
- return Braintree_Configuration::gateway()->paymentMethod()->create($attribs);
28
- }
29
-
30
- public static function find($token)
31
- {
32
- return Braintree_Configuration::gateway()->paymentMethod()->find($token);
33
- }
34
-
35
- public static function update($token, $attribs)
36
- {
37
- return Braintree_Configuration::gateway()->paymentMethod()->update($token, $attribs);
38
- }
39
-
40
- public static function delete($token)
41
- {
42
- return Braintree_Configuration::gateway()->paymentMethod()->delete($token);
43
- }
44
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/SubscriptionSearch.php DELETED
@@ -1,64 +0,0 @@
1
- <?php
2
- class Braintree_SubscriptionSearch
3
- {
4
- static function billingCyclesRemaining()
5
- {
6
- return new Braintree_RangeNode('billing_cycles_remaining');
7
- }
8
-
9
- static function daysPastDue()
10
- {
11
- return new Braintree_RangeNode('days_past_due');
12
- }
13
-
14
- static function id()
15
- {
16
- return new Braintree_TextNode('id');
17
- }
18
-
19
- static function inTrialPeriod()
20
- {
21
- return new Braintree_MultipleValueNode('in_trial_period', array(true, false));
22
- }
23
-
24
- static function merchantAccountId()
25
- {
26
- return new Braintree_MultipleValueNode('merchant_account_id');
27
- }
28
-
29
- static function nextBillingDate()
30
- {
31
- return new Braintree_RangeNode('next_billing_date');
32
- }
33
-
34
- static function planId()
35
- {
36
- return new Braintree_MultipleValueOrTextNode('plan_id');
37
- }
38
-
39
- static function price()
40
- {
41
- return new Braintree_RangeNode('price');
42
- }
43
-
44
- static function status()
45
- {
46
- return new Braintree_MultipleValueNode("status", array(
47
- Braintree_Subscription::ACTIVE,
48
- Braintree_Subscription::CANCELED,
49
- Braintree_Subscription::EXPIRED,
50
- Braintree_Subscription::PAST_DUE,
51
- Braintree_Subscription::PENDING
52
- ));
53
- }
54
-
55
- static function transactionId()
56
- {
57
- return new Braintree_TextNode('transaction_id');
58
- }
59
-
60
- static function ids()
61
- {
62
- return new Braintree_MultipleValueNode('ids');
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/Test/Transaction.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
- final class Braintree_Test_Transaction
3
- {
4
- /**
5
- * settle a transaction by id in sandbox
6
- *
7
- * @param string $id transaction id
8
- * @param Braintree_Configuration $config gateway config
9
- * @return object Braintree_Transaction
10
- */
11
- public static function settle($transactionId)
12
- {
13
- return Braintree_Configuration::gateway()->testing()->settle($transactionId);
14
- }
15
-
16
- /**
17
- * settlement confirm a transaction by id in sandbox
18
- *
19
- * @param string $id transaction id
20
- * @param Braintree_Configuration $config gateway config
21
- * @return object Braintree_Transaction
22
- */
23
- public static function settlementConfirm($transactionId)
24
- {
25
- return Braintree_Configuration::gateway()->testing()->settlementConfirm($transactionId);
26
- }
27
-
28
- /**
29
- * settlement decline a transaction by id in sandbox
30
- *
31
- * @param string $id transaction id
32
- * @param Braintree_Configuration $config gateway config
33
- * @return object Braintree_Transaction
34
- */
35
- public static function settlementDecline($transactionId)
36
- {
37
- return Braintree_Configuration::gateway()->testing()->settlementDecline($transactionId);
38
- }
39
-
40
- /**
41
- * settlement pending a transaction by id in sandbox
42
- *
43
- * @param string $id transaction id
44
- * @param Braintree_Configuration $config gateway config
45
- * @return object Braintree_Transaction
46
- */
47
- public static function settlementPending($transactionId)
48
- {
49
- return Braintree_Configuration::gateway()->testing()->settlementPending($transactionId);
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/TextNode.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- class Braintree_TextNode extends Braintree_PartialMatchNode
4
- {
5
- function contains($value)
6
- {
7
- $this->searchTerms["contains"] = strval($value);
8
- return $this;
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/TransactionSearch.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
- class Braintree_TransactionSearch
3
- {
4
- static function amount() { return new Braintree_RangeNode("amount"); }
5
- static function authorizationExpiredAt() { return new Braintree_RangeNode("authorizationExpiredAt"); }
6
- static function authorizedAt() { return new Braintree_RangeNode("authorizedAt"); }
7
- static function billingCompany() { return new Braintree_TextNode('billing_company'); }
8
- static function billingCountryName() { return new Braintree_TextNode('billing_country_name'); }
9
- static function billingExtendedAddress() { return new Braintree_TextNode('billing_extended_address'); }
10
- static function billingFirstName() { return new Braintree_TextNode('billing_first_name'); }
11
- static function billingLastName() { return new Braintree_TextNode('billing_last_name'); }
12
- static function billingLocality() { return new Braintree_TextNode('billing_locality'); }
13
- static function billingPostalCode() { return new Braintree_TextNode('billing_postal_code'); }
14
- static function billingRegion() { return new Braintree_TextNode('billing_region'); }
15
- static function billingStreetAddress() { return new Braintree_TextNode('billing_street_address'); }
16
- static function createdAt() { return new Braintree_RangeNode("createdAt"); }
17
- static function creditCardCardholderName() { return new Braintree_TextNode('credit_card_cardholderName'); }
18
- static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); }
19
- static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); }
20
- static function creditCardUniqueIdentifier() { return new Braintree_TextNode('credit_card_unique_identifier'); }
21
- static function customerCompany() { return new Braintree_TextNode('customer_company'); }
22
- static function customerEmail() { return new Braintree_TextNode('customer_email'); }
23
- static function customerFax() { return new Braintree_TextNode('customer_fax'); }
24
- static function customerFirstName() { return new Braintree_TextNode('customer_first_name'); }
25
- static function customerId() { return new Braintree_TextNode('customer_id'); }
26
- static function customerLastName() { return new Braintree_TextNode('customer_last_name'); }
27
- static function customerPhone() { return new Braintree_TextNode('customer_phone'); }
28
- static function customerWebsite() { return new Braintree_TextNode('customer_website'); }
29
- static function disbursementDate() { return new Braintree_RangeNode("disbursementDate"); }
30
- static function disputeDate() { return new Braintree_RangeNode("disputeDate"); }
31
- static function europeBankAccountIban() { return new Braintree_TextNode("europeBankAccountIban"); }
32
- static function failedAt() { return new Braintree_RangeNode("failedAt"); }
33
- static function gatewayRejectedAt() { return new Braintree_RangeNode("gatewayRejectedAt"); }
34
- static function id() { return new Braintree_TextNode('id'); }
35
- static function ids() { return new Braintree_MultipleValueNode('ids'); }
36
- static function merchantAccountId() { return new Braintree_MultipleValueNode("merchant_account_id"); }
37
- static function orderId() { return new Braintree_TextNode('order_id'); }
38
- static function paymentInstrumentType() { return new Braintree_MultipleValueNode('paymentInstrumentType'); }
39
- static function paymentMethodToken() { return new Braintree_TextNode('payment_method_token'); }
40
- static function paypalAuthorizationId() { return new Braintree_TextNode('paypal_authorization_id'); }
41
- static function paypalPayerEmail() { return new Braintree_TextNode('paypal_payer_email'); }
42
- static function paypalPaymentId() { return new Braintree_TextNode('paypal_payment_id'); }
43
- static function processorAuthorizationCode() { return new Braintree_TextNode('processor_authorization_code'); }
44
- static function processorDeclinedAt() { return new Braintree_RangeNode("processorDeclinedAt"); }
45
- static function refund() { return new Braintree_KeyValueNode("refund"); }
46
- static function settledAt() { return new Braintree_RangeNode("settledAt"); }
47
- static function settlementBatchId() { return new Braintree_TextNode('settlement_batch_id'); }
48
- static function shippingCompany() { return new Braintree_TextNode('shipping_company'); }
49
- static function shippingCountryName() { return new Braintree_TextNode('shipping_country_name'); }
50
- static function shippingExtendedAddress() { return new Braintree_TextNode('shipping_extended_address'); }
51
- static function shippingFirstName() { return new Braintree_TextNode('shipping_first_name'); }
52
- static function shippingLastName() { return new Braintree_TextNode('shipping_last_name'); }
53
- static function shippingLocality() { return new Braintree_TextNode('shipping_locality'); }
54
- static function shippingPostalCode() { return new Braintree_TextNode('shipping_postal_code'); }
55
- static function shippingRegion() { return new Braintree_TextNode('shipping_region'); }
56
- static function shippingStreetAddress() { return new Braintree_TextNode('shipping_street_address'); }
57
- static function submittedForSettlementAt() { return new Braintree_RangeNode("submittedForSettlementAt"); }
58
- static function user() { return new Braintree_MultipleValueNode('user'); }
59
- static function voidedAt() { return new Braintree_RangeNode("voidedAt"); }
60
-
61
- static function createdUsing()
62
- {
63
- return new Braintree_MultipleValueNode("created_using", array(
64
- Braintree_Transaction::FULL_INFORMATION,
65
- Braintree_Transaction::TOKEN
66
- ));
67
- }
68
-
69
- static function creditCardCardType()
70
- {
71
- return new Braintree_MultipleValueNode("credit_card_card_type", array(
72
- Braintree_CreditCard::AMEX,
73
- Braintree_CreditCard::CARTE_BLANCHE,
74
- Braintree_CreditCard::CHINA_UNION_PAY,
75
- Braintree_CreditCard::DINERS_CLUB_INTERNATIONAL,
76
- Braintree_CreditCard::DISCOVER,
77
- Braintree_CreditCard::JCB,
78
- Braintree_CreditCard::LASER,
79
- Braintree_CreditCard::MAESTRO,
80
- Braintree_CreditCard::MASTER_CARD,
81
- Braintree_CreditCard::SOLO,
82
- Braintree_CreditCard::SWITCH_TYPE,
83
- Braintree_CreditCard::VISA,
84
- Braintree_CreditCard::UNKNOWN
85
- ));
86
- }
87
-
88
- static function creditCardCustomerLocation()
89
- {
90
- return new Braintree_MultipleValueNode("credit_card_customer_location", array(
91
- Braintree_CreditCard::INTERNATIONAL,
92
- Braintree_CreditCard::US
93
- ));
94
- }
95
-
96
- static function source()
97
- {
98
- return new Braintree_MultipleValueNode("source", array(
99
- Braintree_Transaction::API,
100
- Braintree_Transaction::CONTROL_PANEL,
101
- Braintree_Transaction::RECURRING,
102
- ));
103
- }
104
-
105
- static function status()
106
- {
107
- return new Braintree_MultipleValueNode("status", array(
108
- Braintree_Transaction::AUTHORIZATION_EXPIRED,
109
- Braintree_Transaction::AUTHORIZING,
110
- Braintree_Transaction::AUTHORIZED,
111
- Braintree_Transaction::GATEWAY_REJECTED,
112
- Braintree_Transaction::FAILED,
113
- Braintree_Transaction::PROCESSOR_DECLINED,
114
- Braintree_Transaction::SETTLED,
115
- Braintree_Transaction::SETTLING,
116
- Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT,
117
- Braintree_Transaction::VOIDED,
118
- Braintree_Transaction::SETTLEMENT_DECLINED,
119
- Braintree_Transaction::SETTLEMENT_PENDING
120
- ));
121
- }
122
-
123
- static function type()
124
- {
125
- return new Braintree_MultipleValueNode("type", array(
126
- Braintree_Transaction::SALE,
127
- Braintree_Transaction::CREDIT
128
- ));
129
- }
130
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/Gene/Braintree/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer' . '/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit1cd38e0f29a1c6b6e1f3050b1abed83f::getLoader();
lib/Gene/Braintree/braintree/braintree_php/.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /vendor
2
+ /docs
3
+ /tags
4
+ composer.lock
5
+ composer.phar
6
+ *.tgz
lib/Gene/Braintree/braintree/braintree_php/CHANGELOG.md ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 3.17.0
2
+ * Add 'UsBankAccount' payment method
3
+
4
+ ## 3.16.0
5
+ * Add authenticated proxy functionality
6
+ * Add constant for Venmo Account payment instrument type
7
+ * Add validation error for verifications with submerchants
8
+
9
+ ## 3.15.0
10
+ * Add 'default_payment_method' option for Customer
11
+
12
+ ## 3.14.0
13
+ * Add OrderId to refund
14
+ * Add 3DS Pass thru support
15
+ * Expose IDs in resource collections
16
+ * Add leading slash to the namespace. Thanks, @bocharsky-bw
17
+ * Stop modifying DateTime parameters during XML generation. Thanks, @jodarove
18
+
19
+ ## 3.13.0
20
+ * Add method of revoking OAuth access tokens.
21
+
22
+ ## 3.12.0
23
+ * Add Transaction `update_details`
24
+ * Support for Too Many Requests response codes
25
+ * Add ability to count errors in ErrorCollection object. Thanks, @bocharsky-bw
26
+ * Improve Type Hinting
27
+
28
+ ## 3.11.0
29
+ * Remove final from classes. Thanks, @ibrahimlawal!
30
+ * Add currency to Transaction search
31
+
32
+ ## 3.10.0
33
+ * Add timeout attribute
34
+ * Add start-date and end-date to SUBSCRIPTION_CHARGED_SUCCESSFULLY test webhook response
35
+
36
+ ## 3.9.0
37
+ * Add AccountUpdaterDailyReport webhook parsing
38
+
39
+ ## 3.8.0
40
+ * Add payment method revoke
41
+ * Add support for options in `submit_for_settlement` transaction flows
42
+ * Add verification create API
43
+ * Update https certificate bundle
44
+
45
+ ## 3.7.0
46
+ * Add VenmoAccount
47
+ * Allow order_id and descriptor to be passed in for Transaction submit_for_settlement
48
+ * Add facilitator details onto transactions
49
+ * Add check webhook constant
50
+
51
+ ## 3.6.1
52
+ * Fix PSR-0 style namespacing when using Symfony
53
+
54
+ ## 3.6.0
55
+ * Add support for proxy servers
56
+ * Add PSR-4 namespacing support
57
+ * Add support for AMEX Express Checkout
58
+ * Add support for new fields in dispute webhooks (`dateWon`, `dateOpened`, `kind`)
59
+ * Add transaction data to sucessful subscription webhook
60
+
61
+ ## 3.5.0
62
+ * Add support for raw ApplePay params on Transaction create
63
+
64
+ ## 3.4.0
65
+ * Add sourceDescription method to Android Pay and Apple Pay payment methods
66
+ * Add new Android Pay test nonces
67
+ * Add billing agreement ID to PayPal Account
68
+ * Support amex rewards transactions
69
+
70
+ ## 3.3.0
71
+ * Add new test payment method nonces
72
+ * Allow passing description on PayPal transactions
73
+ * Add methods to change transaction settlement status in sandbox
74
+ * Fix issue where customer with an id of 0 could not be found
75
+ * Add Europe Bank Account functionality
76
+
77
+ ## 3.2.0
78
+ * Add additional search criteria
79
+
80
+ ## 3.1.0
81
+ * Add support for HHVM
82
+ * Validate that configuration is valid before verifying webhooks
83
+ * Make OAuth methods conform more to existing API
84
+ * Expose customer paymentMethods as an attribute
85
+
86
+ ## 3.0.1
87
+ * Add support for Android Pay
88
+
89
+ ## 3.0.0
90
+ * Deprecate PHP 5.2 and 5.3
91
+ * Validate webhook challenge payload
92
+ * Bugfix for calling `__toString()` on objects that contain a `\DateTime`
93
+
94
+ ## 2.40.0
95
+ * Add missing criteria to credit card verification search
96
+ * Bugfix for autoloading files with Composer
97
+
98
+ ## 2.39.0
99
+ * Add oauth functionality
100
+ * Add 3DS info to the server side
101
+
102
+ ## 2.38.0
103
+ * Update payment instrument types and test nonces
104
+ * Add missing valid params to PaymentMethodGateway
105
+
106
+ ## 2.37.0
107
+ * Add 3D Secure transaction fields
108
+ * Add ability to create nonce from vaulted payment methods
109
+
110
+ ## 2.36.0
111
+ * Surface Apple Pay payment instrument name in responses
112
+ * Support Coinbase payment instruments
113
+
114
+ ## 2.35.2
115
+ * Fix E_STRICT errors
116
+ * Expose subscription status details
117
+
118
+ ## 2.35.1
119
+ * Bugfix for auto loading files
120
+
121
+ ## 2.35.0
122
+ * Allow PayPal fields in transaction.options.paypal
123
+ * Add error code constants
124
+ * Internal refactoring
125
+
126
+ ## 2.34.0
127
+ * Add risk_data to Transaction and Verification with Kount decision and id
128
+ * Add verification_amount an option when creating a credit card
129
+ * Add TravelCruise industry type to Transaction
130
+ * Add room_rate to Lodging industry type
131
+ * Add CreditCard#verification as the latest verification on that credit card
132
+ * Add ApplePay support to all endpoints that may return ApplePayCard objects
133
+ * Add prefix to sample Webhook to simulate webhook query params
134
+
135
+ ## 2.33.0
136
+ * Allow descriptor to be passed in Funding Details options params for Merchant Account create and update.
137
+
138
+ ## 2.32.0
139
+ * Add additionalProcessorResponse to Transaction
140
+
141
+ ## 2.31.1
142
+ * Allow payee_email to be passed in options params for Transaction create
143
+
144
+ ## 2.31.0
145
+ * Added paypal specific fields to transaction calls
146
+ * Added SettlementPending, SettlementDeclined transaction statuses
147
+
148
+ ## 2.30.0
149
+ * Add descriptor url support
150
+
151
+ ## 2.29.0
152
+ * Allow credit card verification options to be passed outside of the nonce for PaymentMethod.create
153
+ * Allow billing_address parameters and billing_address_id to be passed outside of the nonce for PaymentMethod.create
154
+ * Add Subscriptions to paypal accounts
155
+ * Add PaymentMethod.update
156
+ * Add fail_on_duplicate_payment_method option to PaymentMethod.create
157
+
158
+ ## 2.28.0
159
+ * Adds support for v.zero SDKs.
160
+
161
+ ## 2.27.2
162
+
163
+ * Make webhook parsing more robust with newlines
164
+ * Add messages to InvalidSignature exceptions
165
+
166
+ ## 2.27.1
167
+
168
+ * Updated secureCompare to correctly compare strings in consistent time
169
+ * Add better error messages around webhook verification
170
+
171
+ ## 2.27.0
172
+
173
+ * Include Dispute information on Transaction
174
+ * Search for Transactions disputed on a certain date
175
+
176
+ ## 2.26.0
177
+
178
+ * Disbursement Webhooks
179
+
180
+ ## 2.25.1
181
+
182
+ * Fix factories on AddOn and Discount (thanks [stewe](https://github.com/stewe))
183
+ * Allow billingAddressId on transaction create
184
+
185
+ ## 2.25.0
186
+
187
+ * Merchant account find API
188
+
189
+ ## 2.24.0
190
+
191
+ * Merchant account update API
192
+ * Merchant account create API v2
193
+
194
+ ## 2.23.1
195
+
196
+ * Update configuration URLs
197
+
198
+ ## 2.23.0
199
+
200
+ * Official Partnership support
201
+
202
+ ## 2.22.2
203
+
204
+ * Add Partner Merchant Declined webhook
205
+ * use preg_callback_replace instead of preg_replace (thanks [jonthornton](https://github.com/jonthornton)!)
206
+
207
+ ## 2.22.1
208
+
209
+ * Adds missing test contstant to library namespace
210
+
211
+ ## 2.22.0
212
+
213
+ * Adds holdInEscrow method
214
+ * Add error codes for verification not supported error
215
+ * Add companyName and taxId to merchant account create
216
+ * Adds cancelRelease method
217
+ * Adds releaseFromEscrow functionality
218
+ * Adds phone to merchant account signature.
219
+ * Adds merchant account phone error code.
220
+ * Fix casing issues with Braintree\_Http and Braintree\_Util references (thanks [steven-hadfield](https://github.com/steven-hadfield)!)
221
+ * Fixed transaction initialization arguments to be optional (thanks [karolsojko](https://github.com/karolsojko)!)
222
+
223
+ ## 2.21.0
224
+
225
+ * Enable device data.
226
+
227
+ ## 2.20.0
228
+
229
+ * Fixed getting custom fields with valueForHtmlField. [Thanks to Miguel Manso for the fix.](https://github.com/mumia)
230
+ * Adds disbursement details to transactions.
231
+ * Adds image url to transactions.
232
+
233
+ ## 2.19.0
234
+
235
+ * Adds channel field to transactions.
236
+
237
+ ## 2.18.0
238
+
239
+ * Adds country of issuance and issuing bank bin database fields
240
+
241
+ ## 2.17.0
242
+
243
+ * Adds verification search
244
+
245
+ ## 2.16.0
246
+
247
+ * Additional card information, such as prepaid, debit, commercial, Durbin regulated, healthcare, and payroll, are returned on credit card responses
248
+ * Allows transactions to be specified as recurring
249
+
250
+ ## 2.15.0
251
+
252
+ * Adds prepaid field to credit cards (possible values include Yes, No, Unknown)
253
+
254
+ ## 2.14.1
255
+
256
+ * Adds composer support (thanks [till](https://github.com/till))
257
+ * Fixes erroneous version number
258
+ * Braintree_Plan::all() returns empty array if no plans exist
259
+
260
+ ## 2.14.0
261
+
262
+ * Adds webhook gateways for parsing, verifying, and testing notifications
263
+
264
+ ## 2.13.0
265
+
266
+ * Adds search for duplicate credit cards given a payment method token
267
+ * Adds flag to fail saving credit card to vault if card is duplicate
268
+
269
+ ## 2.12.5
270
+
271
+ * Exposes plan_id on transactions
272
+
273
+ ## 2.12.4
274
+
275
+ * Added error code for invalid purchase order number
276
+
277
+ ## 2.12.3
278
+
279
+ * Fixed problematic case in ResourceCollection when no results are returned from a search.
280
+
281
+ ## 2.12.2
282
+
283
+ * Fixed customer search, which returned customers when no customers matched search criteria
284
+
285
+ ## 2.12.1
286
+
287
+ * Added new error message for merchant accounts that do not support refunds
288
+
289
+ ## 2.12.0
290
+
291
+ * Added ability to retrieve all Plans, AddOns, and Discounts
292
+ * Added Transaction cloning
293
+
294
+ ## 2.11.0
295
+
296
+ * Added Braintree_SettlementBatchSummary
297
+
298
+ ## 2.10.1
299
+
300
+ * Wrap dependency requirement in a function, to prevent pollution of the global namespace
301
+
302
+ ## 2.10.0
303
+
304
+ * Added subscriptionDetails to Transaction
305
+ * Added flag to store in vault only when a transaction is successful
306
+ * Added new error code
307
+
308
+ ## 2.9.0
309
+
310
+ * Added a new transaction state, AUTHORIZATION_EXPIRED.
311
+ * Enabled searching by authorizationExpiredAt.
312
+
313
+ ## 2.8.0
314
+
315
+ * Added next_billing_date and transaction_id to subscription search
316
+ * Added address_country_name to customer search
317
+ * Added new error codes
318
+
319
+ ## 2.7.0
320
+
321
+ * Added Customer search
322
+ * Added dynamic descriptors to Subscriptions and Transactions
323
+ * Added level 2 fields to Transactions:
324
+ * tax_amount
325
+ * tax_exempt
326
+ * purchase_order_number
327
+
328
+ ## 2.6.1
329
+
330
+ * Added billingAddressId to allowed parameters for credit cards create and update
331
+ * Allow searching on subscriptions that are currently in a trial period using inTrialPeriod
332
+
333
+ ## 2.6.0
334
+
335
+ * Added ability to perform multiple partial refunds on Braintree_Transactions
336
+ * Allow passing expirationMonth and expirationYear separately when creating Braintree_Transactions
337
+ * Added revertSubscriptionOnProrationFailure flag to Braintree_Subscription update that specifies how a Subscription should react to a failed proration charge
338
+ * Deprecated Braintree_Subscription nextBillAmount in favor of nextBillingPeriodAmount
339
+ * Deprecated Braintree_Transaction refundId in favor of refundIds
340
+ * Added new fields to Braintree_Subscription:
341
+ * balance
342
+ * paidThroughDate
343
+ * nextBillingPeriodAmount
344
+
345
+ ## 2.5.0
346
+
347
+ * Added Braintree_AddOns/Braintree_Discounts
348
+ * Enhanced Braintree_Subscription search
349
+ * Enhanced Braintree_Transaction search
350
+ * Added constants for Braintree_Result_CreditCardVerification statuses
351
+ * Added EXPIRED and PENDING statuses to Braintree_Subscription
352
+ * Allowed prorateCharges to be specified on Braintree_Subscription update
353
+ * Added Braintree_AddOn/Braintree_Discount details to Braintree_Transactions that were created from a Braintree_Subscription
354
+ * Removed 13 digit Visa Sandbox Credit Card number and replaced it with a 16 digit Visa
355
+ * Added new fields to Braintree_Subscription:
356
+ * billingDayOfMonth
357
+ * daysPastDue
358
+ * firstBillingDate
359
+ * neverExpires
360
+ * numberOfBillingCycles
361
+
362
+ ## 2.4.0
363
+
364
+ * Added ability to specify country using countryName, countryCodeAlpha2, countryCodeAlpha3, or countryCodeNumeric (see [ISO_3166-1](http://en.wikipedia.org/wiki/ISO_3166-1))
365
+ * Added gatewayRejectionReason to Braintree_Transaction and Braintree_Verification
366
+ * Added unified message to result objects
367
+
368
+ ## 2.3.0
369
+
370
+ * Added unified Braintree_TransparentRedirect url and confirm methods and deprecated old methods
371
+ * Added functions to Braintree_CreditCard to allow searching on expiring and expired credit cards
372
+ * Allow card verification against a specified merchant account
373
+ * Added ability to update a customer, credit card, and billing address in one request
374
+ * Allow updating the paymentMethodToken on a subscription
375
+
376
+ ## 2.2.0
377
+
378
+ * Prevent race condition when pulling back collection results -- search results represent the state of the data at the time the query was run
379
+ * Rename ResourceCollection's approximate_size to maximum_size because items that no longer match the query will not be returned in the result set
380
+ * Correctly handle HTTP error 426 (Upgrade Required) -- the error code is returned when your client library version is no long compatible with the gateway
381
+ * Add the ability to specify merchant_account_id when verifying credit cards
382
+ * Add subscription_id to transactions created from subscriptions
383
+
384
+ ## 2.1.0
385
+
386
+ * Added transaction advanced search
387
+ * Added ability to partially refund transactions
388
+ * Added ability to manually retry past-due subscriptions
389
+ * Added new transaction error codes
390
+ * Allow merchant account to be specified when creating transactions
391
+ * Allow creating a transaction with a vault customer and new payment method
392
+ * Allow existing billing address to be updated when updating credit card
393
+ * Correctly handle xml with nil=true
394
+
395
+ ## 2.0.0
396
+
397
+ * Updated success? on transaction responses to return false on declined transactions
398
+ * Search results now include Enumerable and will automatically paginate data
399
+ * Added credit_card[cardholder_name] to allowed transaction params and CreditCardDetails (thanks [chrismcc](http://github.com/chrismcc))
400
+ * Fixed a bug with Customer::all
401
+ * Added constants for error codes
402
+
403
+ ## 1.2.1
404
+
405
+ * Added methods to get both shallow and deep errors from a Braintree_ValidationErrorCollection
406
+ * Added the ability to make a credit card the default card for a customer
407
+ * Added constants for transaction statuses
408
+ * Updated Quick Start in README.md to show a workflow with error checking
409
+
410
+ ## 1.2.0
411
+
412
+ * Added subscription search
413
+ * Provide access to associated subscriptions from CreditCard
414
+ * Switched from using Zend framework for HTTP requests to using curl extension
415
+ * Fixed a bug in Transparent Redirect when arg_separator.output is configured as &amp; instead of &
416
+ * Increased http request timeout
417
+ * Fixed a bug where ForgedQueryString exception was being raised instead of DownForMaintenance
418
+ * Updated SSL CA files
419
+
420
+ ## 1.1.1
421
+
422
+ * Added Braintree_Transaction::refund
423
+ * Added Braintree_Transaction::submitForSettlementNoValidate
424
+ * Fixed a bug in errors->onHtmlField when checking for errors on custom fields when there are none
425
+ * Added support for passing merchantAccountId for Transaction and Subscription
426
+
427
+ ## 1.1.0
428
+
429
+ * Added recurring billing support
430
+
431
+ ## 1.0.1
432
+
433
+ * Fixed bug with Braintree_Error_ErrorCollection.deepSize
434
+ * Added methods for accessing validation errors and params by html field name
435
+
436
+ ## 1.0.0
437
+
438
+ * Initial release
lib/Gene/Braintree/braintree/braintree_php/LICENSE ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2014 Braintree, a division of PayPal, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
lib/Gene/Braintree/braintree/braintree_php/README.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Braintree PHP Client Library
2
+
3
+ The Braintree PHP library provides integration access to the Braintree Gateway.
4
+
5
+ ## Please Note
6
+ > **The Payment Card Industry (PCI) Council has [mandated](http://blog.pcisecuritystandards.org/migrating-from-ssl-and-early-tls) that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, Braintree is updating its services to require TLS 1.2 for all HTTPS connections. Braintree will also require HTTP/1.1 for all connections. Please see our [technical documentation](https://github.com/paypal/tls-update) for more information.**
7
+
8
+ ## Dependencies
9
+
10
+ PHP version >= 5.4.0 is required.
11
+
12
+ The following PHP extensions are required:
13
+
14
+ * curl
15
+ * dom
16
+ * hash
17
+ * openssl
18
+ * xmlwriter
19
+
20
+ ## Quick Start Example
21
+
22
+ ```php
23
+ <?php
24
+
25
+ require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';
26
+
27
+ Braintree_Configuration::environment('sandbox');
28
+ Braintree_Configuration::merchantId('your_merchant_id');
29
+ Braintree_Configuration::publicKey('your_public_key');
30
+ Braintree_Configuration::privateKey('your_private_key');
31
+
32
+ $result = Braintree_Transaction::sale([
33
+ 'amount' => '1000.00',
34
+ 'paymentMethodNonce' => 'nonceFromTheClient',
35
+ 'options' => [ 'submitForSettlement' => true ]
36
+ ]);
37
+
38
+ if ($result->success) {
39
+ print_r("success!: " . $result->transaction->id);
40
+ } else if ($result->transaction) {
41
+ print_r("Error processing transaction:");
42
+ print_r("\n code: " . $result->transaction->processorResponseCode);
43
+ print_r("\n text: " . $result->transaction->processorResponseText);
44
+ } else {
45
+ print_r("Validation errors: \n");
46
+ print_r($result->errors->deepAll());
47
+ }
48
+ ```
49
+
50
+ ## HHVM Support
51
+
52
+ The Braintree PHP library will run on HHVM >= 3.4.2.
53
+
54
+ ## Legacy PHP Support
55
+
56
+ Version [2.40.0](https://github.com/braintree/braintree_php/releases/tag/2.40.0) is compatible with PHP 5.2 and 5.3. You can find it on our releases page.
57
+
58
+ ## Documentation
59
+
60
+ * [Official documentation](https://developers.braintreepayments.com/php/sdk/server/overview)
61
+
62
+ ## Testing
63
+
64
+ The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on your system. To run unit tests use rake: `rake test:unit`.
65
+
66
+ The benefit of the `rake` tasks is that testing covers default `hhvm` and `php` interpreters. However, if you want to run tests manually simply use the following command:
67
+ ```
68
+ phpunit tests/unit/
69
+ ```
70
+
71
+ ## Open Source Attribution
72
+
73
+ A list of open source projects that help power Braintree can be found [here](https://www.braintreepayments.com/developers/open-source).
74
+
75
+ ## License
76
+
77
+ See the LICENSE file.
lib/Gene/Braintree/braintree/braintree_php/Rakefile ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ task :default => :test
2
+ task :test => %w[test:unit test:integration]
3
+
4
+ namespace :test do
5
+ task :unit => %w[test:php:unit test:hhvm:unit]
6
+ task :integration => %w[test:php:integration test:hhvm:integration]
7
+
8
+ namespace :php do
9
+ desc "print PHP version"
10
+ task :version do
11
+ print_php_version("php")
12
+ end
13
+
14
+ desc "run unit tests under PHP"
15
+ task :unit => :version do
16
+ run_php_test_suite("php", "unit")
17
+ end
18
+
19
+ desc "run integration tests under PHP"
20
+ task :integration do
21
+ run_php_test_suite("php", "integration")
22
+ end
23
+ end
24
+
25
+ namespace :hhvm do
26
+ desc "print HHVM version"
27
+ task :version do
28
+ print_php_version("hhvm")
29
+ end
30
+
31
+ desc "run tests under HHVM"
32
+ task :test => [:unit, :integration]
33
+
34
+ desc "run unit tests under HHVM"
35
+ task :unit => :version do
36
+ run_php_test_suite("hhvm", "unit")
37
+ end
38
+
39
+ desc "run integration tests under HHVM"
40
+ task :integration do
41
+ run_php_test_suite("hhvm", "integration")
42
+ end
43
+ end
44
+
45
+ desc "run tests under PHP"
46
+ task :php => %w[php:unit php:integration]
47
+
48
+ desc "run tests under HHVM"
49
+ task :hhvm => %w[hhvm:unit hhvm:integration]
50
+
51
+ desc "run a single test file"
52
+ task :file, :file_path do |t, args|
53
+ run_php_test_file(args[:file_path])
54
+ end
55
+
56
+ desc "run a single test"
57
+ task :single, :test_name do |t, args|
58
+ run_php_test(args[:test_name])
59
+ end
60
+ end
61
+
62
+ desc "update the copyright year"
63
+ task :copyright, :from_year, :to_year do |t, args|
64
+ sh "find tests lib -type f -name '*.php' -exec sed -i 's/#{args[:from_year]} Braintree/#{args[:to_year]} Braintree/g' {} +"
65
+ end
66
+
67
+ def print_php_version(interpreter)
68
+ sh "#{interpreter} --version"
69
+ end
70
+
71
+ def run_php_test_suite(interpreter, test_suite)
72
+ sh "#{interpreter} ./vendor/bin/phpunit --testsuite #{test_suite}"
73
+ end
74
+
75
+ def run_php_test_file(test_file)
76
+ sh "./vendor/bin/phpunit #{test_file}"
77
+ end
78
+
79
+ def run_php_test(test_name)
80
+ sh "./vendor/bin/phpunit --filter #{test_name}"
81
+ end
lib/Gene/Braintree/braintree/braintree_php/ci.sh ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ curl -sS https://getcomposer.org/installer | php -d suhosin.executor.include.whitelist=phar
4
+
5
+ php -d suhosin.executor.include.whitelist=phar ./composer.phar install
6
+
7
+ if [ "$1" == "hhvm" ]; then
8
+ rake test:hhvm --trace
9
+ else
10
+ rake test:php --trace
11
+ fi
lib/Gene/Braintree/braintree/braintree_php/composer.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "braintree/braintree_php",
3
+ "type": "library",
4
+ "description": "Braintree PHP Client Library",
5
+ "license": "MIT",
6
+ "authors": [
7
+ {
8
+ "name": "Braintree",
9
+ "homepage": "http://www.braintreepayments.com"
10
+ }
11
+ ],
12
+ "require": {
13
+ "php": ">=5.4.0",
14
+ "ext-curl": "*",
15
+ "ext-dom": "*",
16
+ "ext-hash": "*",
17
+ "ext-openssl": "*",
18
+ "ext-xmlwriter": "*"
19
+ },
20
+ "require-dev": {
21
+ "phpunit/phpunit": "3.7.*"
22
+ },
23
+ "autoload": {
24
+ "psr-0": {
25
+ "Braintree": "lib/"
26
+ },
27
+ "psr-4": {
28
+ "Braintree\\": "lib/Braintree"
29
+ }
30
+ },
31
+ "autoload-dev": {
32
+ "psr-4": {
33
+ "Test\\": "tests"
34
+ }
35
+ }
36
+ }
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Braintree PHP Library
4
+ * Creates class_aliases for old class names replaced by PSR-4 Namespaces
5
+ *
6
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
7
+ */
8
+
9
+ require_once(__DIR__ . DIRECTORY_SEPARATOR . 'autoload.php');
10
+
11
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
12
+ throw new Braintree_Exception('PHP version >= 5.4.0 required');
13
+ }
14
+
15
+
16
+ function requireDependencies() {
17
+ $requiredExtensions = ['xmlwriter', 'openssl', 'dom', 'hash', 'curl'];
18
+ foreach ($requiredExtensions AS $ext) {
19
+ if (!extension_loaded($ext)) {
20
+ throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.');
21
+ }
22
+ }
23
+ }
24
+
25
+ requireDependencies();
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/AccountUpdaterDailyReport.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Creates an instance of AccountUpdaterDailyReport
6
+ *
7
+ *
8
+ * @package Braintree
9
+ * @copyright 2016 Braintree, a division of PayPal, Inc.
10
+ *
11
+ * @property-read string $reportUrl
12
+ * @property-read date $reportDate
13
+ * @property-read date $receivedDate
14
+ */
15
+ class AccountUpdaterDailyReport extends Base
16
+ {
17
+ protected $_attributes = [];
18
+
19
+ protected function _initialize($disputeAttribs)
20
+ {
21
+ $this->_attributes = $disputeAttribs;
22
+ }
23
+
24
+ public static function factory($attributes)
25
+ {
26
+ $instance = new self();
27
+ $instance->_initialize($attributes);
28
+ return $instance;
29
+ }
30
+
31
+ public function __toString()
32
+ {
33
+ $display = [
34
+ 'reportDate', 'reportUrl'
35
+ ];
36
+
37
+ $displayAttributes = [];
38
+ foreach ($display AS $attrib) {
39
+ $displayAttributes[$attrib] = $this->$attrib;
40
+ }
41
+ return __CLASS__ . '[' .
42
+ Util::attributesToString($displayAttributes) .']';
43
+ }
44
+ }
45
+ class_alias('Braintree\AccountUpdaterDailyReport', 'Braintree_AccountUpdaterDailyReport');
lib/Gene/Braintree/{AddOn.php → braintree/braintree_php/lib/Braintree/AddOn.php} RENAMED
@@ -1,11 +1,12 @@
1
  <?php
 
2
 
3
- class Braintree_AddOn extends Braintree_Modification
4
  {
5
  /**
6
  *
7
  * @param array $attributes
8
- * @return Braintree_AddOn
9
  */
10
  public static function factory($attributes)
11
  {
@@ -18,10 +19,11 @@ class Braintree_AddOn extends Braintree_Modification
18
  /**
19
  * static methods redirecting to gateway
20
  *
21
- * @return Braintree_AddOn[]
22
  */
23
  public static function all()
24
  {
25
- return Braintree_Configuration::gateway()->addOn()->all();
26
  }
27
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class AddOn extends Modification
5
  {
6
  /**
7
  *
8
  * @param array $attributes
9
+ * @return AddOn
10
  */
11
  public static function factory($attributes)
12
  {
19
  /**
20
  * static methods redirecting to gateway
21
  *
22
+ * @return AddOn[]
23
  */
24
  public static function all()
25
  {
26
+ return Configuration::gateway()->addOn()->all();
27
  }
28
  }
29
+ class_alias('Braintree\AddOn', 'Braintree_AddOn');
lib/Gene/Braintree/{AddOnGateway.php → braintree/braintree_php/lib/Braintree/AddOnGateway.php} RENAMED
@@ -1,51 +1,53 @@
1
  <?php
 
2
 
3
- class Braintree_AddOnGateway
4
  {
5
  /**
6
  *
7
- * @var Braintree_Gateway
8
  */
9
  private $_gateway;
10
-
11
  /**
12
  *
13
- * @var Braintree_Configuration
14
  */
15
  private $_config;
16
-
17
  /**
18
  *
19
- * @var Braintree_Http
20
  */
21
  private $_http;
22
 
23
  /**
24
- *
25
- * @param Braintree_Gateway $gateway
26
  */
27
  public function __construct($gateway)
28
  {
29
  $this->_gateway = $gateway;
30
  $this->_config = $gateway->config;
31
  $this->_config->assertHasAccessTokenOrKeys();
32
- $this->_http = new Braintree_Http($gateway->config);
33
  }
34
 
35
  /**
36
- *
37
- * @return Braintree_AddOn[]
38
  */
39
  public function all()
40
  {
41
  $path = $this->_config->merchantPath() . '/add_ons';
42
  $response = $this->_http->get($path);
43
 
44
- $addOns = array("addOn" => $response['addOns']);
45
 
46
- return Braintree_Util::extractAttributeAsArray(
47
  $addOns,
48
  'addOn'
49
  );
50
  }
51
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class AddOnGateway
5
  {
6
  /**
7
  *
8
+ * @var Gateway
9
  */
10
  private $_gateway;
11
+
12
  /**
13
  *
14
+ * @var Configuration
15
  */
16
  private $_config;
17
+
18
  /**
19
  *
20
+ * @var Http
21
  */
22
  private $_http;
23
 
24
  /**
25
+ *
26
+ * @param Gateway $gateway
27
  */
28
  public function __construct($gateway)
29
  {
30
  $this->_gateway = $gateway;
31
  $this->_config = $gateway->config;
32
  $this->_config->assertHasAccessTokenOrKeys();
33
+ $this->_http = new Http($gateway->config);
34
  }
35
 
36
  /**
37
+ *
38
+ * @return AddOn[]
39
  */
40
  public function all()
41
  {
42
  $path = $this->_config->merchantPath() . '/add_ons';
43
  $response = $this->_http->get($path);
44
 
45
+ $addOns = ["addOn" => $response['addOns']];
46
 
47
+ return Util::extractAttributeAsArray(
48
  $addOns,
49
  'addOn'
50
  );
51
  }
52
  }
53
+ class_alias('Braintree\AddOnGateway', 'Braintree_AddOnGateway');
lib/Gene/Braintree/{Address.php → braintree/braintree_php/lib/Braintree/Address.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Braintree Address module
4
  * PHP Version 5
@@ -9,7 +11,7 @@
9
  * as the shipping address when creating a Transaction.
10
  *
11
  * @package Braintree
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $company
15
  * @property-read string $countryName
@@ -25,18 +27,18 @@
25
  * @property-read string $streetAddress
26
  * @property-read string $updatedAt
27
  */
28
- class Braintree_Address extends Braintree_Base
29
  {
30
  /**
31
- * returns false if comparing object is not a Braintree_Address,
32
- * or is a Braintree_Address with a different id
33
  *
34
  * @param object $other address to compare against
35
  * @return boolean
36
  */
37
  public function isEqual($other)
38
  {
39
- return !($other instanceof Braintree_Address) ?
40
  false :
41
  ($this->id === $other->id && $this->customerId === $other->customerId);
42
  }
@@ -45,12 +47,12 @@ class Braintree_Address extends Braintree_Base
45
  * create a printable representation of the object as:
46
  * ClassName[property=value, property=value]
47
  * @ignore
48
- * @return var
49
  */
50
  public function __toString()
51
  {
52
  return __CLASS__ . '[' .
53
- Braintree_Util::attributesToString($this->_attributes) .']';
54
  }
55
 
56
  /**
@@ -59,7 +61,7 @@ class Braintree_Address extends Braintree_Base
59
  * @ignore
60
  * @access protected
61
  * @param array $addressAttribs array of address data
62
- * @return none
63
  */
64
  protected function _initialize($addressAttribs)
65
  {
@@ -68,10 +70,10 @@ class Braintree_Address extends Braintree_Base
68
  }
69
 
70
  /**
71
- * factory method: returns an instance of Braintree_Address
72
  * to the requesting method, with populated properties
73
  * @ignore
74
- * @return object instance of Braintree_Address
75
  */
76
  public static function factory($attributes)
77
  {
@@ -85,64 +87,65 @@ class Braintree_Address extends Braintree_Base
85
  // static methods redirecting to gateway
86
 
87
  /**
88
- *
89
  * @param array $attribs
90
- * @return Braintree_Address
91
  */
92
  public static function create($attribs)
93
  {
94
- return Braintree_Configuration::gateway()->address()->create($attribs);
95
  }
96
 
97
  /**
98
- *
99
  * @param array $attribs
100
- * @return Braintree_Address
101
  */
102
  public static function createNoValidate($attribs)
103
  {
104
- return Braintree_Configuration::gateway()->address()->createNoValidate($attribs);
105
  }
106
 
107
  /**
108
- *
109
- * @param Braintree_Customer|int $customerOrId
110
  * @param int $addressId
111
  * @throws InvalidArgumentException
112
- * @return Braintree_Result_Successful
113
  */
114
  public static function delete($customerOrId = null, $addressId = null)
115
  {
116
- return Braintree_Configuration::gateway()->address()->delete($customerOrId, $addressId);
117
  }
118
 
119
  /**
120
- *
121
- * @param Braintree_Customer|int $customerOrId
122
  * @param int $addressId
123
- * @throws Braintree_Exception_NotFound
124
- * @return Braintree_Address
125
  */
126
  public static function find($customerOrId, $addressId)
127
  {
128
- return Braintree_Configuration::gateway()->address()->find($customerOrId, $addressId);
129
  }
130
 
131
  /**
132
- *
133
- * @param Braintree_Customer|int $customerOrId
134
  * @param int $addressId
135
  * @param array $attributes
136
- * @throws Braintree_Exception_Unexpected
137
- * @return Braintree_Result_Successful|Braintree_Result_Error
138
  */
139
  public static function update($customerOrId, $addressId, $attributes)
140
  {
141
- return Braintree_Configuration::gateway()->address()->update($customerOrId, $addressId, $attributes);
142
  }
143
 
144
  public static function updateNoValidate($customerOrId, $addressId, $attributes)
145
  {
146
- return Braintree_Configuration::gateway()->address()->updateNoValidate($customerOrId, $addressId, $attributes);
147
  }
148
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree Address module
6
  * PHP Version 5
11
  * as the shipping address when creating a Transaction.
12
  *
13
  * @package Braintree
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  *
16
  * @property-read string $company
17
  * @property-read string $countryName
27
  * @property-read string $streetAddress
28
  * @property-read string $updatedAt
29
  */
30
+ class Address extends Base
31
  {
32
  /**
33
+ * returns false if comparing object is not a Address,
34
+ * or is a Address with a different id
35
  *
36
  * @param object $other address to compare against
37
  * @return boolean
38
  */
39
  public function isEqual($other)
40
  {
41
+ return !($other instanceof self) ?
42
  false :
43
  ($this->id === $other->id && $this->customerId === $other->customerId);
44
  }
47
  * create a printable representation of the object as:
48
  * ClassName[property=value, property=value]
49
  * @ignore
50
+ * @return string
51
  */
52
  public function __toString()
53
  {
54
  return __CLASS__ . '[' .
55
+ Util::attributesToString($this->_attributes) . ']';
56
  }
57
 
58
  /**
61
  * @ignore
62
  * @access protected
63
  * @param array $addressAttribs array of address data
64
+ * @return void
65
  */
66
  protected function _initialize($addressAttribs)
67
  {
70
  }
71
 
72
  /**
73
+ * factory method: returns an instance of Address
74
  * to the requesting method, with populated properties
75
  * @ignore
76
+ * @return Address
77
  */
78
  public static function factory($attributes)
79
  {
87
  // static methods redirecting to gateway
88
 
89
  /**
90
+ *
91
  * @param array $attribs
92
+ * @return Address
93
  */
94
  public static function create($attribs)
95
  {
96
+ return Configuration::gateway()->address()->create($attribs);
97
  }
98
 
99
  /**
100
+ *
101
  * @param array $attribs
102
+ * @return Address
103
  */
104
  public static function createNoValidate($attribs)
105
  {
106
+ return Configuration::gateway()->address()->createNoValidate($attribs);
107
  }
108
 
109
  /**
110
+ *
111
+ * @param Customer|int $customerOrId
112
  * @param int $addressId
113
  * @throws InvalidArgumentException
114
+ * @return Result\Successful
115
  */
116
  public static function delete($customerOrId = null, $addressId = null)
117
  {
118
+ return Configuration::gateway()->address()->delete($customerOrId, $addressId);
119
  }
120
 
121
  /**
122
+ *
123
+ * @param Customer|int $customerOrId
124
  * @param int $addressId
125
+ * @throws Exception\NotFound
126
+ * @return Address
127
  */
128
  public static function find($customerOrId, $addressId)
129
  {
130
+ return Configuration::gateway()->address()->find($customerOrId, $addressId);
131
  }
132
 
133
  /**
134
+ *
135
+ * @param Customer|int $customerOrId
136
  * @param int $addressId
137
  * @param array $attributes
138
+ * @throws Exception\Unexpected
139
+ * @return Result\Successful|Result\Error
140
  */
141
  public static function update($customerOrId, $addressId, $attributes)
142
  {
143
+ return Configuration::gateway()->address()->update($customerOrId, $addressId, $attributes);
144
  }
145
 
146
  public static function updateNoValidate($customerOrId, $addressId, $attributes)
147
  {
148
+ return Configuration::gateway()->address()->updateNoValidate($customerOrId, $addressId, $attributes);
149
  }
150
  }
151
+ class_alias('Braintree\Address', 'Braintree_Address');
lib/Gene/Braintree/{AddressGateway.php → braintree/braintree_php/lib/Braintree/AddressGateway.php} RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Braintree AddressGateway module
4
  * PHP Version 5
@@ -9,38 +13,38 @@
9
  * as the shipping address when creating a Transaction.
10
  *
11
  * @package Braintree
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  */
14
- class Braintree_AddressGateway
15
  {
16
  /**
17
  *
18
- * @var Braintree_Gateway
19
  */
20
  private $_gateway;
21
-
22
  /**
23
  *
24
- * @var Braintree_Configuration
25
  */
26
  private $_config;
27
-
28
  /**
29
  *
30
- * @var Braintree_Http
31
  */
32
  private $_http;
33
 
34
  /**
35
- *
36
- * @param Braintree_Gateway $gateway
37
  */
38
  public function __construct($gateway)
39
  {
40
  $this->_gateway = $gateway;
41
  $this->_config = $gateway->config;
42
  $this->_config->assertHasAccessTokenOrKeys();
43
- $this->_http = new Braintree_Http($gateway->config);
44
  }
45
 
46
 
@@ -49,36 +53,42 @@ class Braintree_AddressGateway
49
  *
50
  * @access public
51
  * @param array $attribs
52
- * @return object Result, either Successful or Error
53
  */
54
  public function create($attribs)
55
  {
56
- Braintree_Util::verifyKeys(self::createSignature(), $attribs);
57
  $customerId = isset($attribs['customerId']) ?
58
  $attribs['customerId'] :
59
  null;
60
 
61
  $this->_validateCustomerId($customerId);
62
  unset($attribs['customerId']);
63
- return $this->_doCreate(
64
- '/customers/' . $customerId . '/addresses',
65
- array('address' => $attribs)
66
- );
 
 
 
 
 
 
67
  }
68
 
69
  /**
70
  * attempts the create operation assuming all data will validate
71
- * returns a Braintree_Address object instead of a Result
72
  *
73
  * @access public
74
  * @param array $attribs
75
- * @return object
76
- * @throws Braintree_Exception_ValidationError
77
  */
78
  public function createNoValidate($attribs)
79
  {
80
  $result = $this->create($attribs);
81
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
82
 
83
  }
84
 
@@ -94,7 +104,7 @@ class Braintree_AddressGateway
94
  $customerId = $this->_determineCustomerId($customerOrId);
95
  $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
96
  $this->_http->delete($path);
97
- return new Braintree_Result_Successful();
98
  }
99
 
100
  /**
@@ -108,8 +118,8 @@ class Braintree_AddressGateway
108
  * @access public
109
  * @param mixed $customerOrId
110
  * @param string $addressId
111
- * @return object Braintree_Address
112
- * @throws Braintree_Exception_NotFound
113
  */
114
  public function find($customerOrId, $addressId)
115
  {
@@ -120,9 +130,9 @@ class Braintree_AddressGateway
120
  try {
121
  $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
122
  $response = $this->_http->get($path);
123
- return Braintree_Address::factory($response['address']);
124
- } catch (Braintree_Exception_NotFound $e) {
125
- throw new Braintree_Exception_NotFound(
126
  'address for customer ' . $customerId .
127
  ' with id ' . $addressId . ' not found.'
128
  );
@@ -142,16 +152,16 @@ class Braintree_AddressGateway
142
  * @param array $attributes
143
  * @param mixed $customerOrId (only used in call)
144
  * @param string $addressId (only used in call)
145
- * @return object Braintree_Result_Successful or Braintree_Result_Error
146
  */
147
  public function update($customerOrId, $addressId, $attributes)
148
  {
149
  $this->_validateId($addressId);
150
  $customerId = $this->_determineCustomerId($customerOrId);
151
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
152
 
153
  $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
154
- $response = $this->_http->put($path, array('address' => $attributes));
155
 
156
  return $this->_verifyGatewayResponse($response);
157
 
@@ -167,14 +177,14 @@ class Braintree_AddressGateway
167
  * @access public
168
  * @param array $transactionAttribs
169
  * @param string $customerId
170
- * @return object Braintree_Transaction
171
- * @throws Braintree_Exception_ValidationsFailed
172
- * @see Braintree_Address::update()
173
  */
174
  public function updateNoValidate($customerOrId, $addressId, $attributes)
175
  {
176
  $result = $this->update($customerOrId, $addressId, $attributes);
177
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
178
  }
179
 
180
  /**
@@ -183,11 +193,11 @@ class Braintree_AddressGateway
183
  */
184
  public static function createSignature()
185
  {
186
- return array(
187
  'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
188
  'countryName', 'customerId', 'extendedAddress', 'firstName',
189
  'lastName', 'locality', 'postalCode', 'region', 'streetAddress'
190
- );
191
  }
192
 
193
  /**
@@ -250,7 +260,7 @@ class Braintree_AddressGateway
250
  */
251
  private function _determineCustomerId($customerOrId)
252
  {
253
- $customerId = ($customerOrId instanceof Braintree_Customer) ? $customerOrId->id : $customerOrId;
254
  $this->_validateCustomerId($customerId);
255
  return $customerId;
256
 
@@ -262,7 +272,7 @@ class Braintree_AddressGateway
262
  * @ignore
263
  * @param string $subPath
264
  * @param array $params
265
- * @return mixed
266
  */
267
  private function _doCreate($subPath, $params)
268
  {
@@ -270,36 +280,36 @@ class Braintree_AddressGateway
270
  $response = $this->_http->post($fullPath, $params);
271
 
272
  return $this->_verifyGatewayResponse($response);
273
-
274
  }
275
 
276
  /**
277
  * generic method for validating incoming gateway responses
278
  *
279
- * creates a new Braintree_Address object and encapsulates
280
- * it inside a Braintree_Result_Successful object, or
281
- * encapsulates a Braintree_Errors object inside a Result_Error
282
- * alternatively, throws an Unexpected exception if the response is invalid.
283
  *
284
  * @ignore
285
  * @param array $response gateway response values
286
- * @return object Result_Successful|Result_Error
287
- * @throws Braintree_Exception_Unexpected
288
  */
289
  private function _verifyGatewayResponse($response)
290
  {
291
  if (isset($response['address'])) {
292
- // return a populated instance of Braintree_Address
293
- return new Braintree_Result_Successful(
294
- Braintree_Address::factory($response['address'])
295
  );
296
  } else if (isset($response['apiErrorResponse'])) {
297
- return new Braintree_Result_Error($response['apiErrorResponse']);
298
  } else {
299
- throw new Braintree_Exception_Unexpected(
300
  "Expected address or apiErrorResponse"
301
  );
302
  }
303
 
304
  }
305
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
  /**
7
  * Braintree AddressGateway module
8
  * PHP Version 5
13
  * as the shipping address when creating a Transaction.
14
  *
15
  * @package Braintree
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
  */
18
+ class AddressGateway
19
  {
20
  /**
21
  *
22
+ * @var Gateway
23
  */
24
  private $_gateway;
25
+
26
  /**
27
  *
28
+ * @var Configuration
29
  */
30
  private $_config;
31
+
32
  /**
33
  *
34
+ * @var Http
35
  */
36
  private $_http;
37
 
38
  /**
39
+ *
40
+ * @param Gateway $gateway
41
  */
42
  public function __construct($gateway)
43
  {
44
  $this->_gateway = $gateway;
45
  $this->_config = $gateway->config;
46
  $this->_config->assertHasAccessTokenOrKeys();
47
+ $this->_http = new Http($gateway->config);
48
  }
49
 
50
 
53
  *
54
  * @access public
55
  * @param array $attribs
56
+ * @return Result\Successful|Result\Error
57
  */
58
  public function create($attribs)
59
  {
60
+ Util::verifyKeys(self::createSignature(), $attribs);
61
  $customerId = isset($attribs['customerId']) ?
62
  $attribs['customerId'] :
63
  null;
64
 
65
  $this->_validateCustomerId($customerId);
66
  unset($attribs['customerId']);
67
+ try {
68
+ return $this->_doCreate(
69
+ '/customers/' . $customerId . '/addresses',
70
+ ['address' => $attribs]
71
+ );
72
+ } catch (Exception\NotFound $e) {
73
+ throw new Exception\NotFound(
74
+ 'Customer ' . $customerId . ' not found.'
75
+ );
76
+ }
77
  }
78
 
79
  /**
80
  * attempts the create operation assuming all data will validate
81
+ * returns a Address object instead of a Result
82
  *
83
  * @access public
84
  * @param array $attribs
85
+ * @return self
86
+ * @throws Exception\ValidationError
87
  */
88
  public function createNoValidate($attribs)
89
  {
90
  $result = $this->create($attribs);
91
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
92
 
93
  }
94
 
104
  $customerId = $this->_determineCustomerId($customerOrId);
105
  $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
106
  $this->_http->delete($path);
107
+ return new Result\Successful();
108
  }
109
 
110
  /**
118
  * @access public
119
  * @param mixed $customerOrId
120
  * @param string $addressId
121
+ * @return Address
122
+ * @throws Exception\NotFound
123
  */
124
  public function find($customerOrId, $addressId)
125
  {
130
  try {
131
  $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
132
  $response = $this->_http->get($path);
133
+ return Address::factory($response['address']);
134
+ } catch (Exception\NotFound $e) {
135
+ throw new Exception\NotFound(
136
  'address for customer ' . $customerId .
137
  ' with id ' . $addressId . ' not found.'
138
  );
152
  * @param array $attributes
153
  * @param mixed $customerOrId (only used in call)
154
  * @param string $addressId (only used in call)
155
+ * @return Result\Successful|Result\Error
156
  */
157
  public function update($customerOrId, $addressId, $attributes)
158
  {
159
  $this->_validateId($addressId);
160
  $customerId = $this->_determineCustomerId($customerOrId);
161
+ Util::verifyKeys(self::updateSignature(), $attributes);
162
 
163
  $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
164
+ $response = $this->_http->put($path, ['address' => $attributes]);
165
 
166
  return $this->_verifyGatewayResponse($response);
167
 
177
  * @access public
178
  * @param array $transactionAttribs
179
  * @param string $customerId
180
+ * @return Transaction
181
+ * @throws Exception\ValidationsFailed
182
+ * @see Address::update()
183
  */
184
  public function updateNoValidate($customerOrId, $addressId, $attributes)
185
  {
186
  $result = $this->update($customerOrId, $addressId, $attributes);
187
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
188
  }
189
 
190
  /**
193
  */
194
  public static function createSignature()
195
  {
196
+ return [
197
  'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
198
  'countryName', 'customerId', 'extendedAddress', 'firstName',
199
  'lastName', 'locality', 'postalCode', 'region', 'streetAddress'
200
+ ];
201
  }
202
 
203
  /**
260
  */
261
  private function _determineCustomerId($customerOrId)
262
  {
263
+ $customerId = ($customerOrId instanceof Customer) ? $customerOrId->id : $customerOrId;
264
  $this->_validateCustomerId($customerId);
265
  return $customerId;
266
 
272
  * @ignore
273
  * @param string $subPath
274
  * @param array $params
275
+ * @return Result\Successful|Result\Error
276
  */
277
  private function _doCreate($subPath, $params)
278
  {
280
  $response = $this->_http->post($fullPath, $params);
281
 
282
  return $this->_verifyGatewayResponse($response);
 
283
  }
284
 
285
  /**
286
  * generic method for validating incoming gateway responses
287
  *
288
+ * creates a new Address object and encapsulates
289
+ * it inside a Result\Successful object, or
290
+ * encapsulates an Errors object inside a Result\Error
291
+ * alternatively, throws an Unexpected exception if the response is invalid
292
  *
293
  * @ignore
294
  * @param array $response gateway response values
295
+ * @return Result\Successful|Result\Error
296
+ * @throws Exception\Unexpected
297
  */
298
  private function _verifyGatewayResponse($response)
299
  {
300
  if (isset($response['address'])) {
301
+ // return a populated instance of Address
302
+ return new Result\Successful(
303
+ Address::factory($response['address'])
304
  );
305
  } else if (isset($response['apiErrorResponse'])) {
306
+ return new Result\Error($response['apiErrorResponse']);
307
  } else {
308
+ throw new Exception\Unexpected(
309
  "Expected address or apiErrorResponse"
310
  );
311
  }
312
 
313
  }
314
  }
315
+ class_alias('Braintree\AddressGateway', 'Braintree_AddressGateway');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/AmexExpressCheckoutCard.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree AmexExpressCheckoutCard module
6
+ * Creates and manages Braintree Amex Express Checkout cards
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br />
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read string $createdAt
17
+ * @property-read string $default
18
+ * @property-read string $updatedAt
19
+ * @property-read string $customerId
20
+ * @property-read string $cardType
21
+ * @property-read string $bin
22
+ * @property-read string $cardMemberExpiryDate
23
+ * @property-read string $cardMemberNumber
24
+ * @property-read string $cardType
25
+ * @property-read string $sourceDescription
26
+ * @property-read string $token
27
+ * @property-read string $imageUrl
28
+ * @property-read string $expirationMonth
29
+ * @property-read string $expirationYear
30
+ */
31
+ class AmexExpressCheckoutCard extends Base
32
+ {
33
+ /* instance methods */
34
+ /**
35
+ * returns false if default is null or false
36
+ *
37
+ * @return boolean
38
+ */
39
+ public function isDefault()
40
+ {
41
+ return $this->default;
42
+ }
43
+
44
+ /**
45
+ * factory method: returns an instance of AmexExpressCheckoutCard
46
+ * to the requesting method, with populated properties
47
+ *
48
+ * @ignore
49
+ * @return AmexExpressCheckoutCard
50
+ */
51
+ public static function factory($attributes)
52
+ {
53
+
54
+ $instance = new self();
55
+ $instance->_initialize($attributes);
56
+ return $instance;
57
+ }
58
+
59
+ /**
60
+ * sets instance properties from an array of values
61
+ *
62
+ * @access protected
63
+ * @param array $amexExpressCheckoutCardAttribs array of Amex Express Checkout card properties
64
+ * @return void
65
+ */
66
+ protected function _initialize($amexExpressCheckoutCardAttribs)
67
+ {
68
+ // set the attributes
69
+ $this->_attributes = $amexExpressCheckoutCardAttribs;
70
+
71
+ $subscriptionArray = [];
72
+ if (isset($amexExpressCheckoutCardAttribs['subscriptions'])) {
73
+ foreach ($amexExpressCheckoutCardAttribs['subscriptions'] AS $subscription) {
74
+ $subscriptionArray[] = Subscription::factory($subscription);
75
+ }
76
+ }
77
+
78
+ $this->_set('subscriptions', $subscriptionArray);
79
+ }
80
+ }
81
+ class_alias('Braintree\AmexExpressCheckoutCard', 'Braintree_AmexExpressCheckoutCard');
lib/Gene/Braintree/{AndroidPayCard.php → braintree/braintree_php/lib/Braintree/AndroidPayCard.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Braintree AndroidPayCard module
4
  * Creates and manages Braintree Android Pay cards
@@ -9,11 +11,12 @@
9
  *
10
  * @package Braintree
11
  * @category Resources
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $bin
15
  * @property-read string $cardType
16
  * @property-read string $createdAt
 
17
  * @property-read string $default
18
  * @property-read string $expirationMonth
19
  * @property-read string $expirationYear
@@ -28,7 +31,7 @@
28
  * @property-read string $virtualCardLast4
29
  * @property-read string $virtualCardType
30
  */
31
- class Braintree_AndroidPayCard extends Braintree_Base
32
  {
33
  /* instance methods */
34
  /**
@@ -42,20 +45,20 @@ class Braintree_AndroidPayCard extends Braintree_Base
42
  }
43
 
44
  /**
45
- * factory method: returns an instance of Braintree_AndroidPayCard
46
  * to the requesting method, with populated properties
47
  *
48
  * @ignore
49
- * @return object instance of Braintree_AndroidPayCard
50
  */
51
  public static function factory($attributes)
52
  {
53
- $defaultAttributes = array(
54
  'expirationMonth' => '',
55
  'expirationYear' => '',
56
  'last4' => $attributes['virtualCardLast4'],
57
  'cardType' => $attributes['virtualCardType'],
58
- );
59
 
60
  $instance = new self();
61
  $instance->_initialize(array_merge($defaultAttributes, $attributes));
@@ -67,20 +70,21 @@ class Braintree_AndroidPayCard extends Braintree_Base
67
  *
68
  * @access protected
69
  * @param array $androidPayCardAttribs array of Android Pay card properties
70
- * @return none
71
  */
72
  protected function _initialize($androidPayCardAttribs)
73
  {
74
  // set the attributes
75
  $this->_attributes = $androidPayCardAttribs;
76
 
77
- $subscriptionArray = array();
78
  if (isset($androidPayCardAttribs['subscriptions'])) {
79
  foreach ($androidPayCardAttribs['subscriptions'] AS $subscription) {
80
- $subscriptionArray[] = Braintree_Subscription::factory($subscription);
81
  }
82
  }
83
 
84
  $this->_set('subscriptions', $subscriptionArray);
85
  }
86
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree AndroidPayCard module
6
  * Creates and manages Braintree Android Pay cards
11
  *
12
  * @package Braintree
13
  * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  *
16
  * @property-read string $bin
17
  * @property-read string $cardType
18
  * @property-read string $createdAt
19
+ * @property-read string $customerId
20
  * @property-read string $default
21
  * @property-read string $expirationMonth
22
  * @property-read string $expirationYear
31
  * @property-read string $virtualCardLast4
32
  * @property-read string $virtualCardType
33
  */
34
+ class AndroidPayCard extends Base
35
  {
36
  /* instance methods */
37
  /**
45
  }
46
 
47
  /**
48
+ * factory method: returns an instance of AndroidPayCard
49
  * to the requesting method, with populated properties
50
  *
51
  * @ignore
52
+ * @return AndroidPayCard
53
  */
54
  public static function factory($attributes)
55
  {
56
+ $defaultAttributes = [
57
  'expirationMonth' => '',
58
  'expirationYear' => '',
59
  'last4' => $attributes['virtualCardLast4'],
60
  'cardType' => $attributes['virtualCardType'],
61
+ ];
62
 
63
  $instance = new self();
64
  $instance->_initialize(array_merge($defaultAttributes, $attributes));
70
  *
71
  * @access protected
72
  * @param array $androidPayCardAttribs array of Android Pay card properties
73
+ * @return void
74
  */
75
  protected function _initialize($androidPayCardAttribs)
76
  {
77
  // set the attributes
78
  $this->_attributes = $androidPayCardAttribs;
79
 
80
+ $subscriptionArray = [];
81
  if (isset($androidPayCardAttribs['subscriptions'])) {
82
  foreach ($androidPayCardAttribs['subscriptions'] AS $subscription) {
83
+ $subscriptionArray[] = Subscription::factory($subscription);
84
  }
85
  }
86
 
87
  $this->_set('subscriptions', $subscriptionArray);
88
  }
89
  }
90
+ class_alias('Braintree\AndroidPayCard', 'Braintree_AndroidPayCard');
lib/Gene/Braintree/{ApplePayCard.php → braintree/braintree_php/lib/Braintree/ApplePayCard.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Braintree ApplePayCard module
4
  * Creates and manages Braintree Apple Pay cards
@@ -9,10 +11,11 @@
9
  *
10
  * @package Braintree
11
  * @category Resources
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $cardType
15
  * @property-read string $createdAt
 
16
  * @property-read string $expirationDate
17
  * @property-read string $expirationMonth
18
  * @property-read string $expirationYear
@@ -23,7 +26,7 @@
23
  * @property-read string $sourceDescription
24
  * @property-read string $updatedAt
25
  */
26
- class Braintree_ApplePayCard extends Braintree_Base
27
  {
28
  // Card Type
29
  const AMEX = 'Apple Pay - American Express';
@@ -52,19 +55,19 @@ class Braintree_ApplePayCard extends Braintree_Base
52
  }
53
 
54
  /**
55
- * factory method: returns an instance of Braintree_ApplePayCard
56
  * to the requesting method, with populated properties
57
  *
58
  * @ignore
59
- * @return object instance of Braintree_ApplePayCard
60
  */
61
  public static function factory($attributes)
62
  {
63
- $defaultAttributes = array(
64
  'expirationMonth' => '',
65
  'expirationYear' => '',
66
  'last4' => '',
67
- );
68
 
69
  $instance = new self();
70
  $instance->_initialize(array_merge($defaultAttributes, $attributes));
@@ -76,17 +79,17 @@ class Braintree_ApplePayCard extends Braintree_Base
76
  *
77
  * @access protected
78
  * @param array $applePayCardAttribs array of Apple Pay card properties
79
- * @return none
80
  */
81
  protected function _initialize($applePayCardAttribs)
82
  {
83
  // set the attributes
84
  $this->_attributes = $applePayCardAttribs;
85
 
86
- $subscriptionArray = array();
87
  if (isset($applePayCardAttribs['subscriptions'])) {
88
  foreach ($applePayCardAttribs['subscriptions'] AS $subscription) {
89
- $subscriptionArray[] = Braintree_Subscription::factory($subscription);
90
  }
91
  }
92
 
@@ -94,3 +97,4 @@ class Braintree_ApplePayCard extends Braintree_Base
94
  $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
95
  }
96
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree ApplePayCard module
6
  * Creates and manages Braintree Apple Pay cards
11
  *
12
  * @package Braintree
13
  * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  *
16
  * @property-read string $cardType
17
  * @property-read string $createdAt
18
+ * @property-read string $customerId
19
  * @property-read string $expirationDate
20
  * @property-read string $expirationMonth
21
  * @property-read string $expirationYear
26
  * @property-read string $sourceDescription
27
  * @property-read string $updatedAt
28
  */
29
+ class ApplePayCard extends Base
30
  {
31
  // Card Type
32
  const AMEX = 'Apple Pay - American Express';
55
  }
56
 
57
  /**
58
+ * factory method: returns an instance of ApplePayCard
59
  * to the requesting method, with populated properties
60
  *
61
  * @ignore
62
+ * @return ApplePayCard
63
  */
64
  public static function factory($attributes)
65
  {
66
+ $defaultAttributes = [
67
  'expirationMonth' => '',
68
  'expirationYear' => '',
69
  'last4' => '',
70
+ ];
71
 
72
  $instance = new self();
73
  $instance->_initialize(array_merge($defaultAttributes, $attributes));
79
  *
80
  * @access protected
81
  * @param array $applePayCardAttribs array of Apple Pay card properties
82
+ * @return void
83
  */
84
  protected function _initialize($applePayCardAttribs)
85
  {
86
  // set the attributes
87
  $this->_attributes = $applePayCardAttribs;
88
 
89
+ $subscriptionArray = [];
90
  if (isset($applePayCardAttribs['subscriptions'])) {
91
  foreach ($applePayCardAttribs['subscriptions'] AS $subscription) {
92
+ $subscriptionArray[] = Subscription::factory($subscription);
93
  }
94
  }
95
 
97
  $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
98
  }
99
  }
100
+ class_alias('Braintree\ApplePayCard', 'Braintree_ApplePayCard');
lib/Gene/Braintree/{Base.php → braintree/braintree_php/lib/Braintree/Base.php} RENAMED
@@ -1,17 +1,24 @@
1
  <?php
 
2
 
3
  /**
4
- * Base functionality for library classes
 
 
 
 
 
 
 
5
  */
6
- abstract class Braintree_Base
7
  {
 
 
8
  /**
9
- * Disable the default constructor
10
- *
11
- * Objects that inherit from Braintree_Base should be constructed with
12
- * the static factory() method.
13
- *
14
  * @ignore
 
 
15
  */
16
  protected function __construct()
17
  {
1
  <?php
2
+ namespace Braintree;
3
 
4
  /**
5
+ * Braintree PHP Library.
6
+ *
7
+ * Braintree base class and initialization
8
+ * Provides methods to child classes. This class cannot be instantiated.
9
+ *
10
+ * PHP version 5
11
+ *
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
  */
14
+ abstract class Base
15
  {
16
+ protected $_attributes = [];
17
+
18
  /**
 
 
 
 
 
19
  * @ignore
20
+ * don't permit an explicit call of the constructor!
21
+ * (like $t = new Transaction())
22
  */
23
  protected function __construct()
24
  {
lib/Gene/Braintree/{ClientToken.php → braintree/braintree_php/lib/Braintree/ClientToken.php} RENAMED
@@ -1,6 +1,7 @@
1
  <?php
 
2
 
3
- class Braintree_ClientToken
4
  {
5
  const DEFAULT_VERSION = 2;
6
 
@@ -8,40 +9,41 @@ class Braintree_ClientToken
8
  // static methods redirecting to gateway
9
 
10
  /**
11
- *
12
  * @param array $params
13
  * @return array
14
  */
15
- public static function generate($params=array())
16
  {
17
- return Braintree_Configuration::gateway()->clientToken()->generate($params);
18
  }
19
 
20
  /**
21
- *
22
  * @param type $params
23
  * @throws InvalidArgumentException
24
  */
25
  public static function conditionallyVerifyKeys($params)
26
  {
27
- return Braintree_Configuration::gateway()->clientToken()->conditionallyVerifyKeys($params);
28
  }
29
 
30
  /**
31
- *
32
  * @return string client token retrieved from server
33
  */
34
  public static function generateWithCustomerIdSignature()
35
  {
36
- return Braintree_Configuration::gateway()->clientToken()->generateWithCustomerIdSignature();
37
  }
38
 
39
  /**
40
- *
41
  * @return string client token retrieved from server
42
  */
43
  public static function generateWithoutCustomerIdSignature()
44
  {
45
- return Braintree_Configuration::gateway()->clientToken()->generateWithoutCustomerIdSignature();
46
  }
47
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class ClientToken
5
  {
6
  const DEFAULT_VERSION = 2;
7
 
9
  // static methods redirecting to gateway
10
 
11
  /**
12
+ *
13
  * @param array $params
14
  * @return array
15
  */
16
+ public static function generate($params=[])
17
  {
18
+ return Configuration::gateway()->clientToken()->generate($params);
19
  }
20
 
21
  /**
22
+ *
23
  * @param type $params
24
  * @throws InvalidArgumentException
25
  */
26
  public static function conditionallyVerifyKeys($params)
27
  {
28
+ return Configuration::gateway()->clientToken()->conditionallyVerifyKeys($params);
29
  }
30
 
31
  /**
32
+ *
33
  * @return string client token retrieved from server
34
  */
35
  public static function generateWithCustomerIdSignature()
36
  {
37
+ return Configuration::gateway()->clientToken()->generateWithCustomerIdSignature();
38
  }
39
 
40
  /**
41
+ *
42
  * @return string client token retrieved from server
43
  */
44
  public static function generateWithoutCustomerIdSignature()
45
  {
46
+ return Configuration::gateway()->clientToken()->generateWithoutCustomerIdSignature();
47
  }
48
  }
49
+ class_alias('Braintree\ClientToken', 'Braintree_ClientToken');
lib/Gene/Braintree/{ClientTokenGateway.php → braintree/braintree_php/lib/Braintree/ClientTokenGateway.php} RENAMED
@@ -1,45 +1,48 @@
1
  <?php
 
2
 
3
- class Braintree_ClientTokenGateway
 
 
4
  {
5
  /**
6
  *
7
- * @var Braintree_Gateway
8
  */
9
  private $_gateway;
10
 
11
  /**
12
  *
13
- * @var Braintree_Configuration
14
  */
15
  private $_config;
16
 
17
  /**
18
  *
19
- * @var Braintree_Http
20
  */
21
  private $_http;
22
 
23
  /**
24
  *
25
- * @param Braintree_Gateway $gateway
26
  */
27
  public function __construct($gateway)
28
  {
29
  $this->_gateway = $gateway;
30
  $this->_config = $gateway->config;
31
  $this->_config->assertHasAccessTokenOrKeys();
32
- $this->_http = new Braintree_Http($gateway->config);
33
  }
34
 
35
- public function generate($params=array())
36
  {
37
  if (!array_key_exists("version", $params)) {
38
- $params["version"] = Braintree_ClientToken::DEFAULT_VERSION;
39
  }
40
 
41
  $this->conditionallyVerifyKeys($params);
42
- $generateParams = array("client_token" => $params);
43
 
44
  return $this->_doGenerate('/client_token', $generateParams);
45
  }
@@ -68,9 +71,9 @@ class Braintree_ClientTokenGateway
68
  public function conditionallyVerifyKeys($params)
69
  {
70
  if (array_key_exists("customerId", $params)) {
71
- Braintree_Util::verifyKeys($this->generateWithCustomerIdSignature(), $params);
72
  } else {
73
- Braintree_Util::verifyKeys($this->generateWithoutCustomerIdSignature(), $params);
74
  }
75
  }
76
 
@@ -80,10 +83,10 @@ class Braintree_ClientTokenGateway
80
  */
81
  public function generateWithCustomerIdSignature()
82
  {
83
- return array(
84
  "version", "customerId", "proxyMerchantId",
85
- array("options" => array("makeDefault", "verifyCard", "failOnDuplicatePaymentMethod")),
86
- "merchantAccountId", "sepaMandateType", "sepaMandateAcceptanceLocation");
87
  }
88
 
89
  /**
@@ -92,7 +95,7 @@ class Braintree_ClientTokenGateway
92
  */
93
  public function generateWithoutCustomerIdSignature()
94
  {
95
- return array("version", "proxyMerchantId", "merchantAccountId");
96
  }
97
 
98
  /**
@@ -116,10 +119,11 @@ class Braintree_ClientTokenGateway
116
  $response['apiErrorResponse']['message']
117
  );
118
  } else {
119
- throw new Braintree_Exception_Unexpected(
120
  "Expected clientToken or apiErrorResponse"
121
  );
122
  }
123
  }
124
 
125
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ use InvalidArgumentException;
5
+
6
+ class ClientTokenGateway
7
  {
8
  /**
9
  *
10
+ * @var Gateway
11
  */
12
  private $_gateway;
13
 
14
  /**
15
  *
16
+ * @var Configuration
17
  */
18
  private $_config;
19
 
20
  /**
21
  *
22
+ * @var Http
23
  */
24
  private $_http;
25
 
26
  /**
27
  *
28
+ * @param Gateway $gateway
29
  */
30
  public function __construct($gateway)
31
  {
32
  $this->_gateway = $gateway;
33
  $this->_config = $gateway->config;
34
  $this->_config->assertHasAccessTokenOrKeys();
35
+ $this->_http = new Http($gateway->config);
36
  }
37
 
38
+ public function generate($params=[])
39
  {
40
  if (!array_key_exists("version", $params)) {
41
+ $params["version"] = ClientToken::DEFAULT_VERSION;
42
  }
43
 
44
  $this->conditionallyVerifyKeys($params);
45
+ $generateParams = ["client_token" => $params];
46
 
47
  return $this->_doGenerate('/client_token', $generateParams);
48
  }
71
  public function conditionallyVerifyKeys($params)
72
  {
73
  if (array_key_exists("customerId", $params)) {
74
+ Util::verifyKeys($this->generateWithCustomerIdSignature(), $params);
75
  } else {
76
+ Util::verifyKeys($this->generateWithoutCustomerIdSignature(), $params);
77
  }
78
  }
79
 
83
  */
84
  public function generateWithCustomerIdSignature()
85
  {
86
+ return [
87
  "version", "customerId", "proxyMerchantId",
88
+ ["options" => ["makeDefault", "verifyCard", "failOnDuplicatePaymentMethod"]],
89
+ "merchantAccountId", "sepaMandateType", "sepaMandateAcceptanceLocation"];
90
  }
91
 
92
  /**
95
  */
96
  public function generateWithoutCustomerIdSignature()
97
  {
98
+ return ["version", "proxyMerchantId", "merchantAccountId"];
99
  }
100
 
101
  /**
119
  $response['apiErrorResponse']['message']
120
  );
121
  } else {
122
+ throw new Exception\Unexpected(
123
  "Expected clientToken or apiErrorResponse"
124
  );
125
  }
126
  }
127
 
128
  }
129
+ class_alias('Braintree\ClientTokenGateway', 'Braintree_ClientTokenGateway');
lib/Gene/Braintree/{CoinbaseAccount.php → braintree/braintree_php/lib/Braintree/CoinbaseAccount.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
 
 
2
  /**
3
  * Braintree CoinbaseAccount module
4
  *
5
  * @package Braintree
6
  * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -15,21 +17,22 @@
15
  *
16
  * @package Braintree
17
  * @category Resources
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  *
 
20
  * @property-read string $token
21
  * @property-read string $userId
22
  * @property-read string $userName
23
  * @property-read string $userEmail
24
  */
25
- class Braintree_CoinbaseAccount extends Braintree_Base
26
  {
27
  /**
28
- * factory method: returns an instance of Braintree_CoinbaseAccount
29
  * to the requesting method, with populated properties
30
  *
31
  * @ignore
32
- * @return object instance of Braintree_CoinbaseAccount
33
  */
34
  public static function factory($attributes)
35
  {
@@ -55,17 +58,17 @@ class Braintree_CoinbaseAccount extends Braintree_Base
55
  *
56
  * @access protected
57
  * @param array $coinbaseAccountAttribs array of coinbaseAccount data
58
- * @return none
59
  */
60
  protected function _initialize($coinbaseAccountAttribs)
61
  {
62
  // set the attributes
63
  $this->_attributes = $coinbaseAccountAttribs;
64
 
65
- $subscriptionArray = array();
66
  if (isset($coinbaseAccountAttribs['subscriptions'])) {
67
  foreach ($coinbaseAccountAttribs['subscriptions'] AS $subscription) {
68
- $subscriptionArray[] = Braintree_Subscription::factory($subscription);
69
  }
70
  }
71
 
@@ -80,7 +83,7 @@ class Braintree_CoinbaseAccount extends Braintree_Base
80
  public function __toString()
81
  {
82
  return __CLASS__ . '[' .
83
- Braintree_Util::attributesToString($this->_attributes) .']';
84
  }
85
 
86
 
@@ -88,21 +91,22 @@ class Braintree_CoinbaseAccount extends Braintree_Base
88
 
89
  public static function find($token)
90
  {
91
- return Braintree_Configuration::gateway()->coinbaseAccount()->find($token);
92
  }
93
 
94
  public static function update($token, $attributes)
95
  {
96
- return Braintree_Configuration::gateway()->coinbaseAccount()->update($token, $attributes);
97
  }
98
 
99
  public static function delete($token)
100
  {
101
- return Braintree_Configuration::gateway()->coinbaseAccount()->delete($token);
102
  }
103
 
104
  public static function sale($token, $transactionAttribs)
105
  {
106
- return Braintree_Configuration::gateway()->coinbaseAccount()->sale($token, $transactionAttribs);
107
  }
108
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree CoinbaseAccount module
6
  *
7
  * @package Braintree
8
  * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
 
12
  /**
17
  *
18
  * @package Braintree
19
  * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
+ * @property-read string $customerId
23
  * @property-read string $token
24
  * @property-read string $userId
25
  * @property-read string $userName
26
  * @property-read string $userEmail
27
  */
28
+ class CoinbaseAccount extends Base
29
  {
30
  /**
31
+ * factory method: returns an instance of CoinbaseAccount
32
  * to the requesting method, with populated properties
33
  *
34
  * @ignore
35
+ * @return CoinbaseAccount
36
  */
37
  public static function factory($attributes)
38
  {
58
  *
59
  * @access protected
60
  * @param array $coinbaseAccountAttribs array of coinbaseAccount data
61
+ * @return void
62
  */
63
  protected function _initialize($coinbaseAccountAttribs)
64
  {
65
  // set the attributes
66
  $this->_attributes = $coinbaseAccountAttribs;
67
 
68
+ $subscriptionArray = [];
69
  if (isset($coinbaseAccountAttribs['subscriptions'])) {
70
  foreach ($coinbaseAccountAttribs['subscriptions'] AS $subscription) {
71
+ $subscriptionArray[] = Subscription::factory($subscription);
72
  }
73
  }
74
 
83
  public function __toString()
84
  {
85
  return __CLASS__ . '[' .
86
+ Util::attributesToString($this->_attributes) .']';
87
  }
88
 
89
 
91
 
92
  public static function find($token)
93
  {
94
+ return Configuration::gateway()->coinbaseAccount()->find($token);
95
  }
96
 
97
  public static function update($token, $attributes)
98
  {
99
+ return Configuration::gateway()->coinbaseAccount()->update($token, $attributes);
100
  }
101
 
102
  public static function delete($token)
103
  {
104
+ return Configuration::gateway()->coinbaseAccount()->delete($token);
105
  }
106
 
107
  public static function sale($token, $transactionAttribs)
108
  {
109
+ return Configuration::gateway()->coinbaseAccount()->sale($token, $transactionAttribs);
110
  }
111
  }
112
+ class_alias('Braintree\CoinbaseAccount', 'Braintree_CoinbaseAccount');
lib/Gene/Braintree/{Collection.php → braintree/braintree_php/lib/Braintree/Collection.php} RENAMED
@@ -1,4 +1,12 @@
1
  <?php
 
 
 
 
 
 
 
 
2
  /**
3
  * Braintree Generic collection
4
  *
@@ -9,16 +17,16 @@
9
  *
10
  * @package Braintree
11
  * @subpackage Utility
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  */
14
 
15
- class Braintree_Collection implements Countable, IteratorAggregate, ArrayAccess
16
  {
17
  /**
18
  *
19
- * @var array $_collection collection storage
20
  */
21
- protected $_collection = array();
22
 
23
  /**
24
  * Add a value into the collection
@@ -151,3 +159,4 @@ class Braintree_Collection implements Countable, IteratorAggregate, ArrayAccess
151
  }
152
 
153
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use Countable;
5
+ use IteratorAggregate;
6
+ use ArrayAccess;
7
+ use OutOfRangeException;
8
+ use ArrayIterator;
9
+
10
  /**
11
  * Braintree Generic collection
12
  *
17
  *
18
  * @package Braintree
19
  * @subpackage Utility
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  */
22
 
23
+ class Collection implements Countable, IteratorAggregate, ArrayAccess
24
  {
25
  /**
26
  *
27
+ * @var array collection storage
28
  */
29
+ protected $_collection = [];
30
 
31
  /**
32
  * Add a value into the collection
159
  }
160
 
161
  }
162
+ class_alias('Braintree\Collection', 'Braintree_Collection');
lib/Gene/Braintree/{Configuration.php → braintree/braintree_php/lib/Braintree/Configuration.php} RENAMED
@@ -1,14 +1,16 @@
1
  <?php
 
 
2
  /**
3
  *
4
  * Configuration registry
5
  *
6
  * @package Braintree
7
  * @subpackage Utility
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  */
10
 
11
- class Braintree_Configuration
12
  {
13
  public static $global;
14
 
@@ -19,6 +21,12 @@ class Braintree_Configuration
19
  private $_clientId = null;
20
  private $_clientSecret = null;
21
  private $_accessToken = null;
 
 
 
 
 
 
22
 
23
  /**
24
  * Braintree API version to use
@@ -26,11 +34,11 @@ class Braintree_Configuration
26
  */
27
  const API_VERSION = 4;
28
 
29
- public function __construct($attribs = array())
30
  {
31
  foreach ($attribs as $kind => $value) {
32
  if ($kind == 'environment') {
33
- Braintree_CredentialsParser::assertValidEnvironment($value);
34
  $this->_environment = $value;
35
  }
36
  if ($kind == 'merchantId') {
@@ -46,9 +54,9 @@ class Braintree_Configuration
46
 
47
  if (isset($attribs['clientId']) || isset($attribs['accessToken'])) {
48
  if (isset($attribs['environment']) || isset($attribs['merchantId']) || isset($attribs['publicKey']) || isset($attribs['privateKey'])) {
49
- throw new Braintree_Exception_Configuration('Cannot mix OAuth credentials (clientId, clientSecret, accessToken) with key credentials (publicKey, privateKey, environment, merchantId).');
50
  }
51
- $parsedCredentials = new Braintree_CredentialsParser($attribs);
52
 
53
  $this->_environment = $parsedCredentials->getEnvironment();
54
  $this->_merchantId = $parsedCredentials->getMerchantId();
@@ -64,12 +72,12 @@ class Braintree_Configuration
64
  */
65
  public static function reset()
66
  {
67
- self::$global = new Braintree_Configuration();
68
  }
69
 
70
  public static function gateway()
71
  {
72
- return new Braintree_Gateway(self::$global);
73
  }
74
 
75
  public static function environment($value=null)
@@ -77,7 +85,7 @@ class Braintree_Configuration
77
  if (empty($value)) {
78
  return self::$global->getEnvironment();
79
  }
80
- Braintree_CredentialsParser::assertValidEnvironment($value);
81
  self::$global->setEnvironment($value);
82
  }
83
 
@@ -105,6 +113,104 @@ class Braintree_Configuration
105
  self::$global->setPrivateKey($value);
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  public static function assertGlobalHasAccessTokenOrKeys()
109
  {
110
  self::$global->assertHasAccessTokenOrKeys();
@@ -114,13 +220,13 @@ class Braintree_Configuration
114
  {
115
  if (empty($this->_accessToken)) {
116
  if (empty($this->_merchantId)) {
117
- throw new Braintree_Exception_Configuration('Braintree_Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree_Gateway).');
118
  } else if (empty($this->_environment)) {
119
- throw new Braintree_Exception_Configuration('Braintree_Configuration::environment needs to be set.');
120
  } else if (empty($this->_publicKey)) {
121
- throw new Braintree_Exception_Configuration('Braintree_Configuration::publicKey needs to be set.');
122
  } else if (empty($this->_privateKey)) {
123
- throw new Braintree_Exception_Configuration('Braintree_Configuration::privateKey needs to be set.');
124
  }
125
  }
126
  }
@@ -134,14 +240,14 @@ class Braintree_Configuration
134
  public function assertHasClientId()
135
  {
136
  if (empty($this->_clientId)) {
137
- throw new Braintree_Exception_Configuration('clientId needs to be passed to Braintree_Gateway.');
138
  }
139
  }
140
 
141
  public function assertHasClientSecret()
142
  {
143
  if (empty($this->_clientSecret)) {
144
- throw new Braintree_Exception_Configuration('clientSecret needs to be passed to Braintree_Gateway.');
145
  }
146
  }
147
 
@@ -207,6 +313,66 @@ class Braintree_Configuration
207
  $this->_privateKey = $value;
208
  }
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  public function getAccessToken()
211
  {
212
  return $this->_accessToken;
@@ -242,7 +408,7 @@ class Braintree_Configuration
242
  */
243
  public function merchantPath()
244
  {
245
- return '/merchants/'.$this->_merchantId;
246
  }
247
 
248
  /**
@@ -256,15 +422,11 @@ class Braintree_Configuration
256
  {
257
  $sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
258
  'ssl' . DIRECTORY_SEPARATOR;
259
-
260
- $caPath = realpath(
261
- dirname(__FILE__) .
262
- $sslPath . 'api_braintreegateway_com.ca.crt'
263
- );
264
 
265
  if (!file_exists($caPath))
266
  {
267
- throw new Braintree_Exception_SSLCaFileNotFound();
268
  }
269
 
270
  return $caPath;
@@ -385,4 +547,5 @@ class Braintree_Configuration
385
  error_log('[Braintree] ' . $message);
386
  }
387
  }
388
- Braintree_Configuration::reset();
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  *
6
  * Configuration registry
7
  *
8
  * @package Braintree
9
  * @subpackage Utility
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
  */
12
 
13
+ class Configuration
14
  {
15
  public static $global;
16
 
21
  private $_clientId = null;
22
  private $_clientSecret = null;
23
  private $_accessToken = null;
24
+ private $_proxyHost = null;
25
+ private $_proxyPort = null;
26
+ private $_proxyType = null;
27
+ private $_proxyUser = null;
28
+ private $_proxyPassword = null;
29
+ private $_timeout = 60;
30
 
31
  /**
32
  * Braintree API version to use
34
  */
35
  const API_VERSION = 4;
36
 
37
+ public function __construct($attribs = [])
38
  {
39
  foreach ($attribs as $kind => $value) {
40
  if ($kind == 'environment') {
41
+ CredentialsParser::assertValidEnvironment($value);
42
  $this->_environment = $value;
43
  }
44
  if ($kind == 'merchantId') {
54
 
55
  if (isset($attribs['clientId']) || isset($attribs['accessToken'])) {
56
  if (isset($attribs['environment']) || isset($attribs['merchantId']) || isset($attribs['publicKey']) || isset($attribs['privateKey'])) {
57
+ throw new Exception\Configuration('Cannot mix OAuth credentials (clientId, clientSecret, accessToken) with key credentials (publicKey, privateKey, environment, merchantId).');
58
  }
59
+ $parsedCredentials = new CredentialsParser($attribs);
60
 
61
  $this->_environment = $parsedCredentials->getEnvironment();
62
  $this->_merchantId = $parsedCredentials->getMerchantId();
72
  */
73
  public static function reset()
74
  {
75
+ self::$global = new Configuration();
76
  }
77
 
78
  public static function gateway()
79
  {
80
+ return new Gateway(self::$global);
81
  }
82
 
83
  public static function environment($value=null)
85
  if (empty($value)) {
86
  return self::$global->getEnvironment();
87
  }
88
+ CredentialsParser::assertValidEnvironment($value);
89
  self::$global->setEnvironment($value);
90
  }
91
 
113
  self::$global->setPrivateKey($value);
114
  }
115
 
116
+ /**
117
+ * Sets or gets the read timeout to use for making requests.
118
+ *
119
+ * @param integer $value If provided, sets the read timeout
120
+ * @return integer The read timeout used for connecting to Braintree
121
+ */
122
+ public static function timeout($value=null)
123
+ {
124
+ if (empty($value)) {
125
+ return self::$global->getTimeout();
126
+ }
127
+ self::$global->setTimeout($value);
128
+ }
129
+
130
+ /**
131
+ * Sets or gets the proxy host to use for connecting to Braintree
132
+ *
133
+ * @param string $value If provided, sets the proxy host
134
+ * @return string The proxy host used for connecting to Braintree
135
+ */
136
+ public static function proxyHost($value = null)
137
+ {
138
+ if (empty($value)) {
139
+ return self::$global->getProxyHost();
140
+ }
141
+ self::$global->setProxyHost($value);
142
+ }
143
+
144
+ /**
145
+ * Sets or gets the port of the proxy to use for connecting to Braintree
146
+ *
147
+ * @param string $value If provided, sets the port of the proxy
148
+ * @return string The port of the proxy used for connecting to Braintree
149
+ */
150
+ public static function proxyPort($value = null)
151
+ {
152
+ if (empty($value)) {
153
+ return self::$global->getProxyPort();
154
+ }
155
+ self::$global->setProxyPort($value);
156
+ }
157
+
158
+ /**
159
+ * Sets or gets the proxy type to use for connecting to Braintree. This value
160
+ * can be any of the CURLOPT_PROXYTYPE options in PHP cURL.
161
+ *
162
+ * @param string $value If provided, sets the proxy type
163
+ * @return string The proxy type used for connecting to Braintree
164
+ */
165
+ public static function proxyType($value = null)
166
+ {
167
+ if (empty($value)) {
168
+ return self::$global->getProxyType();
169
+ }
170
+ self::$global->setProxyType($value);
171
+ }
172
+
173
+ /**
174
+ * Specifies whether or not a proxy is properly configured
175
+ *
176
+ * @return bool true if a proxy is configured properly, false if not
177
+ */
178
+ public static function isUsingProxy()
179
+ {
180
+ $proxyHost = self::$global->getProxyHost();
181
+ $proxyPort = self::$global->getProxyPort();
182
+ return !empty($proxyHost) && !empty($proxyPort);
183
+ }
184
+
185
+ public static function proxyUser($value = null)
186
+ {
187
+ if (empty($value)) {
188
+ return self::$global->getProxyUser();
189
+ }
190
+ self::$global->setProxyUser($value);
191
+ }
192
+
193
+ public static function proxyPassword($value = null)
194
+ {
195
+ if (empty($value)) {
196
+ return self::$global->getProxyPassword();
197
+ }
198
+ self::$global->setProxyPassword($value);
199
+ }
200
+
201
+ /**
202
+ * Specified whether or not a username and password have been provided for
203
+ * use with an authenticated proxy
204
+ *
205
+ * @return bool true if both proxyUser and proxyPassword are present
206
+ */
207
+ public static function isAuthenticatedProxy()
208
+ {
209
+ $proxyUser = self::$global->getProxyUser();
210
+ $proxyPwd = self::$global->getProxyPassword();
211
+ return !empty($proxyUser) && !empty($proxyPwd);
212
+ }
213
+
214
  public static function assertGlobalHasAccessTokenOrKeys()
215
  {
216
  self::$global->assertHasAccessTokenOrKeys();
220
  {
221
  if (empty($this->_accessToken)) {
222
  if (empty($this->_merchantId)) {
223
+ throw new Exception\Configuration('Braintree\\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\\Gateway).');
224
  } else if (empty($this->_environment)) {
225
+ throw new Exception\Configuration('Braintree\\Configuration::environment needs to be set.');
226
  } else if (empty($this->_publicKey)) {
227
+ throw new Exception\Configuration('Braintree\\Configuration::publicKey needs to be set.');
228
  } else if (empty($this->_privateKey)) {
229
+ throw new Exception\Configuration('Braintree\\Configuration::privateKey needs to be set.');
230
  }
231
  }
232
  }
240
  public function assertHasClientId()
241
  {
242
  if (empty($this->_clientId)) {
243
+ throw new Exception\Configuration('clientId needs to be passed to Braintree\\Gateway.');
244
  }
245
  }
246
 
247
  public function assertHasClientSecret()
248
  {
249
  if (empty($this->_clientSecret)) {
250
+ throw new Exception\Configuration('clientSecret needs to be passed to Braintree\\Gateway.');
251
  }
252
  }
253
 
313
  $this->_privateKey = $value;
314
  }
315
 
316
+ private function setProxyHost($value)
317
+ {
318
+ $this->_proxyHost = $value;
319
+ }
320
+
321
+ public function getProxyHost()
322
+ {
323
+ return $this->_proxyHost;
324
+ }
325
+
326
+ private function setProxyPort($value)
327
+ {
328
+ $this->_proxyPort = $value;
329
+ }
330
+
331
+ public function getProxyPort()
332
+ {
333
+ return $this->_proxyPort;
334
+ }
335
+
336
+ private function setProxyType($value)
337
+ {
338
+ $this->_proxyType = $value;
339
+ }
340
+
341
+ public function getProxyType()
342
+ {
343
+ return $this->_proxyType;
344
+ }
345
+
346
+ private function setProxyUser($value)
347
+ {
348
+ $this->_proxyUser = $value;
349
+ }
350
+
351
+ public function getProxyUser()
352
+ {
353
+ return $this->_proxyUser;
354
+ }
355
+
356
+ private function setProxyPassword($value)
357
+ {
358
+ $this->_proxyPassword = $value;
359
+ }
360
+
361
+ public function getProxyPassword()
362
+ {
363
+ return $this->_proxyPassword;
364
+ }
365
+
366
+ private function setTimeout($value)
367
+ {
368
+ $this->_timeout = $value;
369
+ }
370
+
371
+ public function getTimeout()
372
+ {
373
+ return $this->_timeout;
374
+ }
375
+
376
  public function getAccessToken()
377
  {
378
  return $this->_accessToken;
408
  */
409
  public function merchantPath()
410
  {
411
+ return '/merchants/' . $this->_merchantId;
412
  }
413
 
414
  /**
422
  {
423
  $sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
424
  'ssl' . DIRECTORY_SEPARATOR;
425
+ $caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt';
 
 
 
 
426
 
427
  if (!file_exists($caPath))
428
  {
429
+ throw new Exception\SSLCaFileNotFound();
430
  }
431
 
432
  return $caPath;
547
  error_log('[Braintree] ' . $message);
548
  }
549
  }
550
+ Configuration::reset();
551
+ class_alias('Braintree\Configuration', 'Braintree_Configuration');
lib/Gene/Braintree/{CredentialsParser.php → braintree/braintree_php/lib/Braintree/CredentialsParser.php} RENAMED
@@ -1,14 +1,16 @@
1
  <?php
 
 
2
  /**
3
  *
4
  * CredentialsParser registry
5
  *
6
  * @package Braintree
7
  * @subpackage Utility
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  */
10
 
11
- class Braintree_CredentialsParser
12
  {
13
  private $_clientId;
14
  private $_clientSecret;
@@ -38,32 +40,32 @@ class Braintree_CredentialsParser
38
  * @static
39
  * @var array valid environments, used for validation
40
  */
41
- private static $_validEnvironments = array(
42
  'development',
43
  'integration',
44
  'sandbox',
45
  'production',
46
  'qa',
47
- );
48
 
49
 
50
  public function parse()
51
  {
52
- $environments = array();
53
  if (!empty($this->_clientId)) {
54
- $environments[] = array('clientId', $this->_parseClientCredential('clientId', $this->_clientId, 'client_id'));
55
  }
56
  if (!empty($this->_clientSecret)) {
57
- $environments[] = array('clientSecret', $this->_parseClientCredential('clientSecret', $this->_clientSecret, 'client_secret'));
58
  }
59
  if (!empty($this->_accessToken)) {
60
- $environments[] = array('accessToken', $this->_parseAccessToken());
61
  }
62
 
63
  $checkEnv = $environments[0];
64
  foreach ($environments as $env) {
65
  if ($env[1] !== $checkEnv[1]) {
66
- throw new Braintree_Exception_Configuration(
67
  'Mismatched credential environments: ' . $checkEnv[0] . ' environment is ' . $checkEnv[1] .
68
  ' and ' . $env[0] . ' environment is ' . $env[1]);
69
  }
@@ -75,7 +77,7 @@ class Braintree_CredentialsParser
75
 
76
  public static function assertValidEnvironment($environment) {
77
  if (!in_array($environment, self::$_validEnvironments)) {
78
- throw new Braintree_Exception_Configuration('"' .
79
  $environment . '" is not a valid environment.');
80
  }
81
  }
@@ -84,7 +86,7 @@ class Braintree_CredentialsParser
84
  {
85
  $explodedCredential = explode('$', $value);
86
  if (sizeof($explodedCredential) != 3) {
87
- throw new Braintree_Exception_Configuration('Incorrect ' . $credentialType . ' format. Expected: type$environment$token');
88
  }
89
 
90
  $gotValuePrefix = $explodedCredential[0];
@@ -92,7 +94,7 @@ class Braintree_CredentialsParser
92
  $token = $explodedCredential[2];
93
 
94
  if ($gotValuePrefix != $expectedValuePrefix) {
95
- throw new Braintree_Exception_Configuration('Value passed for ' . $credentialType . ' is not a ' . $credentialType);
96
  }
97
 
98
  return $environment;
@@ -102,7 +104,7 @@ class Braintree_CredentialsParser
102
  {
103
  $accessTokenExploded = explode('$', $this->_accessToken);
104
  if (sizeof($accessTokenExploded) != 4) {
105
- throw new Braintree_Exception_Configuration('Incorrect accessToken syntax. Expected: type$environment$merchant_id$token');
106
  }
107
 
108
  $gotValuePrefix = $accessTokenExploded[0];
@@ -111,7 +113,7 @@ class Braintree_CredentialsParser
111
  $token = $accessTokenExploded[3];
112
 
113
  if ($gotValuePrefix != 'access_token') {
114
- throw new Braintree_Exception_Configuration('Value passed for accessToken is not an accessToken');
115
  }
116
 
117
  $this->_merchantId = $merchantId;
@@ -143,3 +145,4 @@ class Braintree_CredentialsParser
143
  return $this->_merchantId;
144
  }
145
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  *
6
  * CredentialsParser registry
7
  *
8
  * @package Braintree
9
  * @subpackage Utility
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
  */
12
 
13
+ class CredentialsParser
14
  {
15
  private $_clientId;
16
  private $_clientSecret;
40
  * @static
41
  * @var array valid environments, used for validation
42
  */
43
+ private static $_validEnvironments = [
44
  'development',
45
  'integration',
46
  'sandbox',
47
  'production',
48
  'qa',
49
+ ];
50
 
51
 
52
  public function parse()
53
  {
54
+ $environments = [];
55
  if (!empty($this->_clientId)) {
56
+ $environments[] = ['clientId', $this->_parseClientCredential('clientId', $this->_clientId, 'client_id')];
57
  }
58
  if (!empty($this->_clientSecret)) {
59
+ $environments[] = ['clientSecret', $this->_parseClientCredential('clientSecret', $this->_clientSecret, 'client_secret')];
60
  }
61
  if (!empty($this->_accessToken)) {
62
+ $environments[] = ['accessToken', $this->_parseAccessToken()];
63
  }
64
 
65
  $checkEnv = $environments[0];
66
  foreach ($environments as $env) {
67
  if ($env[1] !== $checkEnv[1]) {
68
+ throw new Exception\Configuration(
69
  'Mismatched credential environments: ' . $checkEnv[0] . ' environment is ' . $checkEnv[1] .
70
  ' and ' . $env[0] . ' environment is ' . $env[1]);
71
  }
77
 
78
  public static function assertValidEnvironment($environment) {
79
  if (!in_array($environment, self::$_validEnvironments)) {
80
+ throw new Exception\Configuration('"' .
81
  $environment . '" is not a valid environment.');
82
  }
83
  }
86
  {
87
  $explodedCredential = explode('$', $value);
88
  if (sizeof($explodedCredential) != 3) {
89
+ throw new Exception\Configuration('Incorrect ' . $credentialType . ' format. Expected: type$environment$token');
90
  }
91
 
92
  $gotValuePrefix = $explodedCredential[0];
94
  $token = $explodedCredential[2];
95
 
96
  if ($gotValuePrefix != $expectedValuePrefix) {
97
+ throw new Exception\Configuration('Value passed for ' . $credentialType . ' is not a ' . $credentialType);
98
  }
99
 
100
  return $environment;
104
  {
105
  $accessTokenExploded = explode('$', $this->_accessToken);
106
  if (sizeof($accessTokenExploded) != 4) {
107
+ throw new Exception\Configuration('Incorrect accessToken syntax. Expected: type$environment$merchant_id$token');
108
  }
109
 
110
  $gotValuePrefix = $accessTokenExploded[0];
113
  $token = $accessTokenExploded[3];
114
 
115
  if ($gotValuePrefix != 'access_token') {
116
+ throw new Exception\Configuration('Value passed for accessToken is not an accessToken');
117
  }
118
 
119
  $this->_merchantId = $merchantId;
145
  return $this->_merchantId;
146
  }
147
  }
148
+ class_alias('Braintree\CredentialsParser', 'Braintree_CredentialsParser');
lib/Gene/Braintree/{CreditCard.php → braintree/braintree_php/lib/Braintree/CreditCard.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Braintree CreditCard module
4
  * Creates and manages Braintree CreditCards
@@ -10,7 +12,7 @@
10
  *
11
  * @package Braintree
12
  * @category Resources
13
- * @copyright 2014 Braintree, a division of PayPal, Inc.
14
  *
15
  * @property-read string $billingAddress
16
  * @property-read string $bin
@@ -27,7 +29,7 @@
27
  * @property-read string $token
28
  * @property-read string $updatedAt
29
  */
30
- class Braintree_CreditCard extends Braintree_Base
31
  {
32
  // Card Type
33
  const AMEX = 'American Express';
@@ -74,6 +76,7 @@ class Braintree_CreditCard extends Braintree_Base
74
 
75
  const COUNTRY_OF_ISSUANCE_UNKNOWN = "Unknown";
76
  const ISSUING_BANK_UNKNOWN = "Unknown";
 
77
 
78
  /* instance methods */
79
  /**
@@ -111,7 +114,7 @@ class Braintree_CreditCard extends Braintree_Base
111
  *
112
  * @access protected
113
  * @param array $creditCardAttribs array of creditcard data
114
- * @return none
115
  */
116
  protected function _initialize($creditCardAttribs)
117
  {
@@ -120,13 +123,13 @@ class Braintree_CreditCard extends Braintree_Base
120
 
121
  // map each address into its own object
122
  $billingAddress = isset($creditCardAttribs['billingAddress']) ?
123
- Braintree_Address::factory($creditCardAttribs['billingAddress']) :
124
  null;
125
 
126
- $subscriptionArray = array();
127
  if (isset($creditCardAttribs['subscriptions'])) {
128
  foreach ($creditCardAttribs['subscriptions'] AS $subscription) {
129
- $subscriptionArray[] = Braintree_Subscription::factory($subscription);
130
  }
131
  }
132
 
@@ -137,9 +140,9 @@ class Braintree_CreditCard extends Braintree_Base
137
 
138
  if(isset($creditCardAttribs['verifications']) && count($creditCardAttribs['verifications']) > 0) {
139
  $verifications = $creditCardAttribs['verifications'];
140
- usort($verifications, array($this, '_compareCreatedAtOnVerifications'));
141
 
142
- $this->_set('verification', Braintree_CreditCardVerification::factory($verifications[0]));
143
  }
144
  }
145
 
@@ -149,15 +152,15 @@ class Braintree_CreditCard extends Braintree_Base
149
  }
150
 
151
  /**
152
- * returns false if comparing object is not a Braintree_CreditCard,
153
- * or is a Braintree_CreditCard with a different id
154
  *
155
  * @param object $otherCreditCard customer to compare against
156
  * @return boolean
157
  */
158
  public function isEqual($otherCreditCard)
159
  {
160
- return !($otherCreditCard instanceof Braintree_CreditCard) ? false : $this->token === $otherCreditCard->token;
161
  }
162
 
163
  /**
@@ -168,24 +171,24 @@ class Braintree_CreditCard extends Braintree_Base
168
  public function __toString()
169
  {
170
  return __CLASS__ . '[' .
171
- Braintree_Util::attributesToString($this->_attributes) .']';
172
  }
173
 
174
  /**
175
- * factory method: returns an instance of Braintree_CreditCard
176
  * to the requesting method, with populated properties
177
  *
178
  * @ignore
179
- * @return object instance of Braintree_CreditCard
180
  */
181
  public static function factory($attributes)
182
  {
183
- $defaultAttributes = array(
184
  'bin' => '',
185
  'expirationMonth' => '',
186
  'expirationYear' => '',
187
  'last4' => '',
188
- );
189
 
190
  $instance = new self();
191
  $instance->_initialize(array_merge($defaultAttributes, $attributes));
@@ -197,115 +200,117 @@ class Braintree_CreditCard extends Braintree_Base
197
 
198
  public static function create($attribs)
199
  {
200
- return Braintree_Configuration::gateway()->creditCard()->create($attribs);
201
  }
202
 
203
  public static function createNoValidate($attribs)
204
  {
205
- return Braintree_Configuration::gateway()->creditCard()->createNoValidate($attribs);
206
  }
207
 
208
  public static function createFromTransparentRedirect($queryString)
209
  {
210
- return Braintree_Configuration::gateway()->creditCard()->createFromTransparentRedirect($queryString);
211
  }
212
 
213
  public static function createCreditCardUrl()
214
  {
215
- return Braintree_Configuration::gateway()->creditCard()->createCreditCardUrl();
216
  }
217
 
218
  public static function expired()
219
  {
220
- return Braintree_Configuration::gateway()->creditCard()->expired();
221
  }
222
 
223
  public static function fetchExpired($ids)
224
  {
225
- return Braintree_Configuration::gateway()->creditCard()->fetchExpired($ids);
226
  }
227
 
228
  public static function expiringBetween($startDate, $endDate)
229
  {
230
- return Braintree_Configuration::gateway()->creditCard()->expiringBetween($startDate, $endDate);
231
  }
232
 
233
  public static function fetchExpiring($startDate, $endDate, $ids)
234
  {
235
- return Braintree_Configuration::gateway()->creditCard()->fetchExpiring($startDate, $endDate, $ids);
236
  }
237
 
238
  public static function find($token)
239
  {
240
- return Braintree_Configuration::gateway()->creditCard()->find($token);
241
  }
242
 
243
  public static function fromNonce($nonce)
244
  {
245
- return Braintree_Configuration::gateway()->creditCard()->fromNonce($nonce);
246
  }
247
 
248
  public static function credit($token, $transactionAttribs)
249
  {
250
- return Braintree_Configuration::gateway()->creditCard()->credit($token, $transactionAttribs);
251
  }
252
 
253
  public static function creditNoValidate($token, $transactionAttribs)
254
  {
255
- return Braintree_Configuration::gateway()->creditCard()->creditNoValidate($token, $transactionAttribs);
256
  }
257
 
258
  public static function sale($token, $transactionAttribs)
259
  {
260
- return Braintree_Configuration::gateway()->creditCard()->sale($token, $transactionAttribs);
261
  }
262
 
263
  public static function saleNoValidate($token, $transactionAttribs)
264
  {
265
- return Braintree_Configuration::gateway()->creditCard()->saleNoValidate($token, $transactionAttribs);
266
  }
267
 
268
  public static function update($token, $attributes)
269
  {
270
- return Braintree_Configuration::gateway()->creditCard()->update($token, $attributes);
271
  }
272
 
273
  public static function updateNoValidate($token, $attributes)
274
  {
275
- return Braintree_Configuration::gateway()->creditCard()->updateNoValidate($token, $attributes);
276
  }
277
 
278
  public static function updateCreditCardUrl()
279
  {
280
- return Braintree_Configuration::gateway()->creditCard()->updateCreditCardUrl();
281
  }
282
 
283
  public static function updateFromTransparentRedirect($queryString)
284
  {
285
- return Braintree_Configuration::gateway()->creditCard()->updateFromTransparentRedirect($queryString);
286
  }
287
 
288
  public static function delete($token)
289
  {
290
- return Braintree_Configuration::gateway()->creditCard()->delete($token);
291
  }
292
 
 
293
  public static function allCardTypes()
294
  {
295
- return array(
296
- Braintree_CreditCard::AMEX,
297
- Braintree_CreditCard::CARTE_BLANCHE,
298
- Braintree_CreditCard::CHINA_UNION_PAY,
299
- Braintree_CreditCard::DINERS_CLUB_INTERNATIONAL,
300
- Braintree_CreditCard::DISCOVER,
301
- Braintree_CreditCard::JCB,
302
- Braintree_CreditCard::LASER,
303
- Braintree_CreditCard::MAESTRO,
304
- Braintree_CreditCard::MASTER_CARD,
305
- Braintree_CreditCard::SOLO,
306
- Braintree_CreditCard::SWITCH_TYPE,
307
- Braintree_CreditCard::VISA,
308
- Braintree_CreditCard::UNKNOWN
309
- );
310
  }
311
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree CreditCard module
6
  * Creates and manages Braintree CreditCards
12
  *
13
  * @package Braintree
14
  * @category Resources
15
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
16
  *
17
  * @property-read string $billingAddress
18
  * @property-read string $bin
29
  * @property-read string $token
30
  * @property-read string $updatedAt
31
  */
32
+ class CreditCard extends Base
33
  {
34
  // Card Type
35
  const AMEX = 'American Express';
76
 
77
  const COUNTRY_OF_ISSUANCE_UNKNOWN = "Unknown";
78
  const ISSUING_BANK_UNKNOWN = "Unknown";
79
+ const PRODUCT_ID_UNKNOWN = "Unknown";
80
 
81
  /* instance methods */
82
  /**
114
  *
115
  * @access protected
116
  * @param array $creditCardAttribs array of creditcard data
117
+ * @return void
118
  */
119
  protected function _initialize($creditCardAttribs)
120
  {
123
 
124
  // map each address into its own object
125
  $billingAddress = isset($creditCardAttribs['billingAddress']) ?
126
+ Address::factory($creditCardAttribs['billingAddress']) :
127
  null;
128
 
129
+ $subscriptionArray = [];
130
  if (isset($creditCardAttribs['subscriptions'])) {
131
  foreach ($creditCardAttribs['subscriptions'] AS $subscription) {
132
+ $subscriptionArray[] = Subscription::factory($subscription);
133
  }
134
  }
135
 
140
 
141
  if(isset($creditCardAttribs['verifications']) && count($creditCardAttribs['verifications']) > 0) {
142
  $verifications = $creditCardAttribs['verifications'];
143
+ usort($verifications, [$this, '_compareCreatedAtOnVerifications']);
144
 
145
+ $this->_set('verification', CreditCardVerification::factory($verifications[0]));
146
  }
147
  }
148
 
152
  }
153
 
154
  /**
155
+ * returns false if comparing object is not a CreditCard,
156
+ * or is a CreditCard with a different id
157
  *
158
  * @param object $otherCreditCard customer to compare against
159
  * @return boolean
160
  */
161
  public function isEqual($otherCreditCard)
162
  {
163
+ return !($otherCreditCard instanceof self) ? false : $this->token === $otherCreditCard->token;
164
  }
165
 
166
  /**
171
  public function __toString()
172
  {
173
  return __CLASS__ . '[' .
174
+ Util::attributesToString($this->_attributes) .']';
175
  }
176
 
177
  /**
178
+ * factory method: returns an instance of CreditCard
179
  * to the requesting method, with populated properties
180
  *
181
  * @ignore
182
+ * @return CreditCard
183
  */
184
  public static function factory($attributes)
185
  {
186
+ $defaultAttributes = [
187
  'bin' => '',
188
  'expirationMonth' => '',
189
  'expirationYear' => '',
190
  'last4' => '',
191
+ ];
192
 
193
  $instance = new self();
194
  $instance->_initialize(array_merge($defaultAttributes, $attributes));
200
 
201
  public static function create($attribs)
202
  {
203
+ return Configuration::gateway()->creditCard()->create($attribs);
204
  }
205
 
206
  public static function createNoValidate($attribs)
207
  {
208
+ return Configuration::gateway()->creditCard()->createNoValidate($attribs);
209
  }
210
 
211
  public static function createFromTransparentRedirect($queryString)
212
  {
213
+ return Configuration::gateway()->creditCard()->createFromTransparentRedirect($queryString);
214
  }
215
 
216
  public static function createCreditCardUrl()
217
  {
218
+ return Configuration::gateway()->creditCard()->createCreditCardUrl();
219
  }
220
 
221
  public static function expired()
222
  {
223
+ return Configuration::gateway()->creditCard()->expired();
224
  }
225
 
226
  public static function fetchExpired($ids)
227
  {
228
+ return Configuration::gateway()->creditCard()->fetchExpired($ids);
229
  }
230
 
231
  public static function expiringBetween($startDate, $endDate)
232
  {
233
+ return Configuration::gateway()->creditCard()->expiringBetween($startDate, $endDate);
234
  }
235
 
236
  public static function fetchExpiring($startDate, $endDate, $ids)
237
  {
238
+ return Configuration::gateway()->creditCard()->fetchExpiring($startDate, $endDate, $ids);
239
  }
240
 
241
  public static function find($token)
242
  {
243
+ return Configuration::gateway()->creditCard()->find($token);
244
  }
245
 
246
  public static function fromNonce($nonce)
247
  {
248
+ return Configuration::gateway()->creditCard()->fromNonce($nonce);
249
  }
250
 
251
  public static function credit($token, $transactionAttribs)
252
  {
253
+ return Configuration::gateway()->creditCard()->credit($token, $transactionAttribs);
254
  }
255
 
256
  public static function creditNoValidate($token, $transactionAttribs)
257
  {
258
+ return Configuration::gateway()->creditCard()->creditNoValidate($token, $transactionAttribs);
259
  }
260
 
261
  public static function sale($token, $transactionAttribs)
262
  {
263
+ return Configuration::gateway()->creditCard()->sale($token, $transactionAttribs);
264
  }
265
 
266
  public static function saleNoValidate($token, $transactionAttribs)
267
  {
268
+ return Configuration::gateway()->creditCard()->saleNoValidate($token, $transactionAttribs);
269
  }
270
 
271
  public static function update($token, $attributes)
272
  {
273
+ return Configuration::gateway()->creditCard()->update($token, $attributes);
274
  }
275
 
276
  public static function updateNoValidate($token, $attributes)
277
  {
278
+ return Configuration::gateway()->creditCard()->updateNoValidate($token, $attributes);
279
  }
280
 
281
  public static function updateCreditCardUrl()
282
  {
283
+ return Configuration::gateway()->creditCard()->updateCreditCardUrl();
284
  }
285
 
286
  public static function updateFromTransparentRedirect($queryString)
287
  {
288
+ return Configuration::gateway()->creditCard()->updateFromTransparentRedirect($queryString);
289
  }
290
 
291
  public static function delete($token)
292
  {
293
+ return Configuration::gateway()->creditCard()->delete($token);
294
  }
295
 
296
+ /** @return array */
297
  public static function allCardTypes()
298
  {
299
+ return [
300
+ CreditCard::AMEX,
301
+ CreditCard::CARTE_BLANCHE,
302
+ CreditCard::CHINA_UNION_PAY,
303
+ CreditCard::DINERS_CLUB_INTERNATIONAL,
304
+ CreditCard::DISCOVER,
305
+ CreditCard::JCB,
306
+ CreditCard::LASER,
307
+ CreditCard::MAESTRO,
308
+ CreditCard::MASTER_CARD,
309
+ CreditCard::SOLO,
310
+ CreditCard::SWITCH_TYPE,
311
+ CreditCard::VISA,
312
+ CreditCard::UNKNOWN
313
+ ];
314
  }
315
  }
316
+ class_alias('Braintree\CreditCard', 'Braintree_CreditCard');
lib/Gene/Braintree/{CreditCardGateway.php → braintree/braintree_php/lib/Braintree/CreditCardGateway.php} RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Braintree CreditCardGateway module
4
  * Creates and manages Braintree CreditCards
@@ -10,9 +14,9 @@
10
  *
11
  * @package Braintree
12
  * @category Resources
13
- * @copyright 2014 Braintree, a division of PayPal, Inc.
14
  */
15
- class Braintree_CreditCardGateway
16
  {
17
  private $_gateway;
18
  private $_config;
@@ -23,84 +27,86 @@ class Braintree_CreditCardGateway
23
  $this->_gateway = $gateway;
24
  $this->_config = $gateway->config;
25
  $this->_config->assertHasAccessTokenOrKeys();
26
- $this->_http = new Braintree_Http($gateway->config);
27
  }
28
 
29
  public function create($attribs)
30
  {
31
- Braintree_Util::verifyKeys(self::createSignature(), $attribs);
32
- return $this->_doCreate('/payment_methods', array('credit_card' => $attribs));
33
  }
34
 
35
  /**
36
  * attempts the create operation assuming all data will validate
37
- * returns a Braintree_CreditCard object instead of a Result
38
  *
39
  * @access public
40
  * @param array $attribs
41
- * @return object
42
- * @throws Braintree_Exception_ValidationError
43
  */
44
  public function createNoValidate($attribs)
45
  {
46
  $result = $this->create($attribs);
47
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
48
  }
49
  /**
50
  * create a customer from a TransparentRedirect operation
51
  *
 
52
  * @access public
53
  * @param array $attribs
54
- * @return object
55
  */
56
  public function createFromTransparentRedirect($queryString)
57
  {
58
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
59
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString(
60
  $queryString
61
  );
62
  return $this->_doCreate(
63
  '/payment_methods/all/confirm_transparent_redirect_request',
64
- array('id' => $params['id'])
65
  );
66
  }
67
 
68
  /**
69
  *
 
70
  * @access public
71
  * @param none
72
  * @return string
73
  */
74
  public function createCreditCardUrl()
75
  {
76
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
77
- return $this->_config->baseUrl() . $this->_config->merchantPath() .
78
  '/payment_methods/all/create_via_transparent_redirect_request';
79
  }
80
 
81
  /**
82
  * returns a ResourceCollection of expired credit cards
83
- * @return object ResourceCollection
84
  */
85
  public function expired()
86
  {
87
  $path = $this->_config->merchantPath() . '/payment_methods/all/expired_ids';
88
  $response = $this->_http->post($path);
89
- $pager = array(
90
  'object' => $this,
91
  'method' => 'fetchExpired',
92
- 'methodArgs' => array()
93
- );
94
 
95
- return new Braintree_ResourceCollection($response, $pager);
96
  }
97
 
98
  public function fetchExpired($ids)
99
  {
100
  $path = $this->_config->merchantPath() . "/payment_methods/all/expired";
101
- $response = $this->_http->post($path, array('search' => array('ids' => $ids)));
102
 
103
- return Braintree_Util::extractattributeasarray(
104
  $response['paymentMethods'],
105
  'creditCard'
106
  );
@@ -108,27 +114,27 @@ class Braintree_CreditCardGateway
108
  /**
109
  * returns a ResourceCollection of credit cards expiring between start/end
110
  *
111
- * @return object ResourceCollection
112
  */
113
  public function expiringBetween($startDate, $endDate)
114
  {
115
  $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring_ids?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
116
  $response = $this->_http->post($queryPath);
117
- $pager = array(
118
  'object' => $this,
119
  'method' => 'fetchExpiring',
120
- 'methodArgs' => array($startDate, $endDate)
121
- );
122
 
123
- return new Braintree_ResourceCollection($response, $pager);
124
  }
125
 
126
  public function fetchExpiring($startDate, $endDate, $ids)
127
  {
128
  $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
129
- $response = $this->_http->post($queryPath, array('search' => array('ids' => $ids)));
130
 
131
- return Braintree_Util::extractAttributeAsArray(
132
  $response['paymentMethods'],
133
  'creditCard'
134
  );
@@ -139,8 +145,8 @@ class Braintree_CreditCardGateway
139
  *
140
  * @access public
141
  * @param string $token credit card unique id
142
- * @return object Braintree_CreditCard
143
- * @throws Braintree_Exception_NotFound
144
  */
145
  public function find($token)
146
  {
@@ -148,9 +154,9 @@ class Braintree_CreditCardGateway
148
  try {
149
  $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
150
  $response = $this->_http->get($path);
151
- return Braintree_CreditCard::factory($response['creditCard']);
152
- } catch (Braintree_Exception_NotFound $e) {
153
- throw new Braintree_Exception_NotFound(
154
  'credit card with token ' . $token . ' not found'
155
  );
156
  }
@@ -162,8 +168,8 @@ class Braintree_CreditCardGateway
162
  *
163
  * @access public
164
  * @param string $nonce payment method nonce
165
- * @return object Braintree_CreditCard
166
- * @throws Braintree_Exception_NotFound
167
  */
168
  public function fromNonce($nonce)
169
  {
@@ -171,9 +177,9 @@ class Braintree_CreditCardGateway
171
  try {
172
  $path = $this->_config->merchantPath() . '/payment_methods/from_nonce/' . $nonce;
173
  $response = $this->_http->get($path);
174
- return Braintree_CreditCard::factory($response['creditCard']);
175
- } catch (Braintree_Exception_NotFound $e) {
176
- throw new Braintree_Exception_NotFound(
177
  'credit card with nonce ' . $nonce . ' locked, consumed or not found'
178
  );
179
  }
@@ -185,15 +191,15 @@ class Braintree_CreditCardGateway
185
  *
186
  * @access public
187
  * @param array $attribs
188
- * @return object Braintree_Result_Successful or Braintree_Result_Error
189
  */
190
  public function credit($token, $transactionAttribs)
191
  {
192
  $this->_validateId($token);
193
- return Braintree_Transaction::credit(
194
  array_merge(
195
  $transactionAttribs,
196
- array('paymentMethodToken' => $token)
197
  )
198
  );
199
  }
@@ -201,17 +207,17 @@ class Braintree_CreditCardGateway
201
  /**
202
  * create a credit on this card, assuming validations will pass
203
  *
204
- * returns a Braintree_Transaction object on success
205
  *
206
  * @access public
207
  * @param array $attribs
208
- * @return object Braintree_Transaction
209
- * @throws Braintree_Exception_ValidationError
210
  */
211
  public function creditNoValidate($token, $transactionAttribs)
212
  {
213
  $result = $this->credit($token, $transactionAttribs);
214
- return Braintree_Util::returnObjectOrThrowException('Transaction', $result);
215
  }
216
 
217
  /**
@@ -219,16 +225,16 @@ class Braintree_CreditCardGateway
219
  *
220
  * @param string $token
221
  * @param array $transactionAttribs
222
- * @return object Braintree_Result_Successful or Braintree_Result_Error
223
- * @see Braintree_Transaction::sale()
224
  */
225
  public function sale($token, $transactionAttribs)
226
  {
227
  $this->_validateId($token);
228
- return Braintree_Transaction::sale(
229
  array_merge(
230
  $transactionAttribs,
231
- array('paymentMethodToken' => $token)
232
  )
233
  );
234
  }
@@ -236,19 +242,19 @@ class Braintree_CreditCardGateway
236
  /**
237
  * create a new sale using this card, assuming validations will pass
238
  *
239
- * returns a Braintree_Transaction object on success
240
  *
241
  * @access public
242
  * @param array $transactionAttribs
243
  * @param string $token
244
- * @return object Braintree_Transaction
245
- * @throws Braintree_Exception_ValidationsFailed
246
- * @see Braintree_Transaction::sale()
247
  */
248
  public function saleNoValidate($token, $transactionAttribs)
249
  {
250
  $result = $this->sale($token, $transactionAttribs);
251
- return Braintree_Util::returnObjectOrThrowException('Transaction', $result);
252
  }
253
 
254
  /**
@@ -260,13 +266,13 @@ class Braintree_CreditCardGateway
260
  * @access public
261
  * @param array $attributes
262
  * @param string $token (optional)
263
- * @return object Braintree_Result_Successful or Braintree_Result_Error
264
  */
265
  public function update($token, $attributes)
266
  {
267
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
268
  $this->_validateId($token);
269
- return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, array('creditCard' => $attributes));
270
  }
271
 
272
  /**
@@ -274,18 +280,18 @@ class Braintree_CreditCardGateway
274
  *
275
  * if calling this method in context, $token
276
  * is the 2nd attribute. $token is not sent in object context.
277
- * returns a Braintree_CreditCard object on success
278
  *
279
  * @access public
280
  * @param array $attributes
281
  * @param string $token
282
- * @return object Braintree_CreditCard
283
- * @throws Braintree_Exception_ValidationsFailed
284
  */
285
  public function updateNoValidate($token, $attributes)
286
  {
287
  $result = $this->update($token, $attributes);
288
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
289
  }
290
  /**
291
  *
@@ -295,7 +301,7 @@ class Braintree_CreditCardGateway
295
  */
296
  public function updateCreditCardUrl()
297
  {
298
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
299
  return $this->_config->baseUrl() . $this->_config->merchantPath() .
300
  '/payment_methods/all/update_via_transparent_redirect_request';
301
  }
@@ -303,20 +309,21 @@ class Braintree_CreditCardGateway
303
  /**
304
  * update a customer from a TransparentRedirect operation
305
  *
 
306
  * @access public
307
  * @param array $attribs
308
  * @return object
309
  */
310
  public function updateFromTransparentRedirect($queryString)
311
  {
312
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
313
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString(
314
  $queryString
315
  );
316
  return $this->_doUpdate(
317
  'post',
318
  '/payment_methods/all/confirm_transparent_redirect_request',
319
- array('id' => $params['id'])
320
  );
321
  }
322
 
@@ -325,38 +332,43 @@ class Braintree_CreditCardGateway
325
  $this->_validateId($token);
326
  $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
327
  $this->_http->delete($path);
328
- return new Braintree_Result_Successful();
329
  }
330
 
331
  private static function baseOptions()
332
  {
333
- return array('makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount', 'venmoSdkSession');
334
  }
335
 
336
  private static function baseSignature($options)
337
  {
338
- return array(
339
  'billingAddressId', 'cardholderName', 'cvv', 'number', 'deviceSessionId',
340
  'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
341
  'deviceData', 'fraudMerchantId', 'paymentMethodNonce',
342
- array('options' => $options),
343
- array(
344
- 'billingAddress' => array(
345
- 'firstName',
346
- 'lastName',
347
- 'company',
348
- 'countryCodeAlpha2',
349
- 'countryCodeAlpha3',
350
- 'countryCodeNumeric',
351
- 'countryName',
352
- 'extendedAddress',
353
- 'locality',
354
- 'region',
355
- 'postalCode',
356
- 'streetAddress'
357
- ),
358
- ),
359
- );
 
 
 
 
 
360
  }
361
 
362
  public static function createSignature()
@@ -370,23 +382,25 @@ class Braintree_CreditCardGateway
370
 
371
  public static function updateSignature()
372
  {
373
- $signature = self::baseSignature(self::baseOptions());
374
-
375
- $updateExistingBillingSignature = array(
376
- array(
377
- 'options' => array(
378
- 'updateExisting'
379
- )
380
- )
381
- );
382
-
383
- foreach($signature AS $key => $value) {
384
- if(is_array($value) and array_key_exists('billingAddress', $value)) {
385
- $signature[$key]['billingAddress'] = array_merge_recursive($value['billingAddress'], $updateExistingBillingSignature);
386
- }
387
- }
388
-
389
- return $signature;
 
 
390
  }
391
 
392
  /**
@@ -444,29 +458,30 @@ class Braintree_CreditCardGateway
444
  /**
445
  * generic method for validating incoming gateway responses
446
  *
447
- * creates a new Braintree_CreditCard object and encapsulates
448
- * it inside a Braintree_Result_Successful object, or
449
- * encapsulates a Braintree_Errors object inside a Result_Error
450
- * alternatively, throws an Unexpected exception if the response is invalid.
451
  *
452
  * @ignore
453
  * @param array $response gateway response values
454
- * @return object Result_Successful or Result_Error
455
- * @throws Braintree_Exception_Unexpected
456
  */
457
  private function _verifyGatewayResponse($response)
458
  {
459
  if (isset($response['creditCard'])) {
460
- // return a populated instance of Braintree_Address
461
- return new Braintree_Result_Successful(
462
- Braintree_CreditCard::factory($response['creditCard'])
463
  );
464
- } else if (isset($response['apiErrorResponse'])) {
465
- return new Braintree_Result_Error($response['apiErrorResponse']);
466
  } else {
467
- throw new Braintree_Exception_Unexpected(
468
  "Expected address or apiErrorResponse"
469
  );
470
  }
471
  }
472
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
  /**
7
  * Braintree CreditCardGateway module
8
  * Creates and manages Braintree CreditCards
14
  *
15
  * @package Braintree
16
  * @category Resources
17
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
18
  */
19
+ class CreditCardGateway
20
  {
21
  private $_gateway;
22
  private $_config;
27
  $this->_gateway = $gateway;
28
  $this->_config = $gateway->config;
29
  $this->_config->assertHasAccessTokenOrKeys();
30
+ $this->_http = new Http($gateway->config);
31
  }
32
 
33
  public function create($attribs)
34
  {
35
+ Util::verifyKeys(self::createSignature(), $attribs);
36
+ return $this->_doCreate('/payment_methods', ['credit_card' => $attribs]);
37
  }
38
 
39
  /**
40
  * attempts the create operation assuming all data will validate
41
+ * returns a CreditCard object instead of a Result
42
  *
43
  * @access public
44
  * @param array $attribs
45
+ * @return CreditCard
46
+ * @throws Exception\ValidationError
47
  */
48
  public function createNoValidate($attribs)
49
  {
50
  $result = $this->create($attribs);
51
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
52
  }
53
  /**
54
  * create a customer from a TransparentRedirect operation
55
  *
56
+ * @deprecated since version 2.3.0
57
  * @access public
58
  * @param array $attribs
59
+ * @return Result\Successful|Result\Error
60
  */
61
  public function createFromTransparentRedirect($queryString)
62
  {
63
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
64
+ $params = TransparentRedirect::parseAndValidateQueryString(
65
  $queryString
66
  );
67
  return $this->_doCreate(
68
  '/payment_methods/all/confirm_transparent_redirect_request',
69
+ ['id' => $params['id']]
70
  );
71
  }
72
 
73
  /**
74
  *
75
+ * @deprecated since version 2.3.0
76
  * @access public
77
  * @param none
78
  * @return string
79
  */
80
  public function createCreditCardUrl()
81
  {
82
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
83
+ return $this->_config->baseUrl() . $this->_config->merchantPath().
84
  '/payment_methods/all/create_via_transparent_redirect_request';
85
  }
86
 
87
  /**
88
  * returns a ResourceCollection of expired credit cards
89
+ * @return ResourceCollection
90
  */
91
  public function expired()
92
  {
93
  $path = $this->_config->merchantPath() . '/payment_methods/all/expired_ids';
94
  $response = $this->_http->post($path);
95
+ $pager = [
96
  'object' => $this,
97
  'method' => 'fetchExpired',
98
+ 'methodArgs' => []
99
+ ];
100
 
101
+ return new ResourceCollection($response, $pager);
102
  }
103
 
104
  public function fetchExpired($ids)
105
  {
106
  $path = $this->_config->merchantPath() . "/payment_methods/all/expired";
107
+ $response = $this->_http->post($path, ['search' => ['ids' => $ids]]);
108
 
109
+ return Util::extractattributeasarray(
110
  $response['paymentMethods'],
111
  'creditCard'
112
  );
114
  /**
115
  * returns a ResourceCollection of credit cards expiring between start/end
116
  *
117
+ * @return ResourceCollection
118
  */
119
  public function expiringBetween($startDate, $endDate)
120
  {
121
  $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring_ids?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
122
  $response = $this->_http->post($queryPath);
123
+ $pager = [
124
  'object' => $this,
125
  'method' => 'fetchExpiring',
126
+ 'methodArgs' => [$startDate, $endDate]
127
+ ];
128
 
129
+ return new ResourceCollection($response, $pager);
130
  }
131
 
132
  public function fetchExpiring($startDate, $endDate, $ids)
133
  {
134
  $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
135
+ $response = $this->_http->post($queryPath, ['search' => ['ids' => $ids]]);
136
 
137
+ return Util::extractAttributeAsArray(
138
  $response['paymentMethods'],
139
  'creditCard'
140
  );
145
  *
146
  * @access public
147
  * @param string $token credit card unique id
148
+ * @return CreditCard
149
+ * @throws Exception\NotFound
150
  */
151
  public function find($token)
152
  {
154
  try {
155
  $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
156
  $response = $this->_http->get($path);
157
+ return CreditCard::factory($response['creditCard']);
158
+ } catch (Exception\NotFound $e) {
159
+ throw new Exception\NotFound(
160
  'credit card with token ' . $token . ' not found'
161
  );
162
  }
168
  *
169
  * @access public
170
  * @param string $nonce payment method nonce
171
+ * @return CreditCard
172
+ * @throws Exception\NotFound
173
  */
174
  public function fromNonce($nonce)
175
  {
177
  try {
178
  $path = $this->_config->merchantPath() . '/payment_methods/from_nonce/' . $nonce;
179
  $response = $this->_http->get($path);
180
+ return CreditCard::factory($response['creditCard']);
181
+ } catch (Exception\NotFound $e) {
182
+ throw new Exception\NotFound(
183
  'credit card with nonce ' . $nonce . ' locked, consumed or not found'
184
  );
185
  }
191
  *
192
  * @access public
193
  * @param array $attribs
194
+ * @return Result\Successful|Result\Error
195
  */
196
  public function credit($token, $transactionAttribs)
197
  {
198
  $this->_validateId($token);
199
+ return Transaction::credit(
200
  array_merge(
201
  $transactionAttribs,
202
+ ['paymentMethodToken' => $token]
203
  )
204
  );
205
  }
207
  /**
208
  * create a credit on this card, assuming validations will pass
209
  *
210
+ * returns a Transaction object on success
211
  *
212
  * @access public
213
  * @param array $attribs
214
+ * @return Transaction
215
+ * @throws Exception\ValidationError
216
  */
217
  public function creditNoValidate($token, $transactionAttribs)
218
  {
219
  $result = $this->credit($token, $transactionAttribs);
220
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
221
  }
222
 
223
  /**
225
  *
226
  * @param string $token
227
  * @param array $transactionAttribs
228
+ * @return Result\Successful|Result\Error
229
+ * @see Transaction::sale()
230
  */
231
  public function sale($token, $transactionAttribs)
232
  {
233
  $this->_validateId($token);
234
+ return Transaction::sale(
235
  array_merge(
236
  $transactionAttribs,
237
+ ['paymentMethodToken' => $token]
238
  )
239
  );
240
  }
242
  /**
243
  * create a new sale using this card, assuming validations will pass
244
  *
245
+ * returns a Transaction object on success
246
  *
247
  * @access public
248
  * @param array $transactionAttribs
249
  * @param string $token
250
+ * @return Transaction
251
+ * @throws Exception\ValidationsFailed
252
+ * @see Transaction::sale()
253
  */
254
  public function saleNoValidate($token, $transactionAttribs)
255
  {
256
  $result = $this->sale($token, $transactionAttribs);
257
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
258
  }
259
 
260
  /**
266
  * @access public
267
  * @param array $attributes
268
  * @param string $token (optional)
269
+ * @return Result\Successful|Result\Error
270
  */
271
  public function update($token, $attributes)
272
  {
273
+ Util::verifyKeys(self::updateSignature(), $attributes);
274
  $this->_validateId($token);
275
+ return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, ['creditCard' => $attributes]);
276
  }
277
 
278
  /**
280
  *
281
  * if calling this method in context, $token
282
  * is the 2nd attribute. $token is not sent in object context.
283
+ * returns a CreditCard object on success
284
  *
285
  * @access public
286
  * @param array $attributes
287
  * @param string $token
288
+ * @return CreditCard
289
+ * @throws Exception\ValidationsFailed
290
  */
291
  public function updateNoValidate($token, $attributes)
292
  {
293
  $result = $this->update($token, $attributes);
294
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
295
  }
296
  /**
297
  *
301
  */
302
  public function updateCreditCardUrl()
303
  {
304
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
305
  return $this->_config->baseUrl() . $this->_config->merchantPath() .
306
  '/payment_methods/all/update_via_transparent_redirect_request';
307
  }
309
  /**
310
  * update a customer from a TransparentRedirect operation
311
  *
312
+ * @deprecated since version 2.3.0
313
  * @access public
314
  * @param array $attribs
315
  * @return object
316
  */
317
  public function updateFromTransparentRedirect($queryString)
318
  {
319
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
320
+ $params = TransparentRedirect::parseAndValidateQueryString(
321
  $queryString
322
  );
323
  return $this->_doUpdate(
324
  'post',
325
  '/payment_methods/all/confirm_transparent_redirect_request',
326
+ ['id' => $params['id']]
327
  );
328
  }
329
 
332
  $this->_validateId($token);
333
  $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
334
  $this->_http->delete($path);
335
+ return new Result\Successful();
336
  }
337
 
338
  private static function baseOptions()
339
  {
340
+ return ['makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount', 'venmoSdkSession'];
341
  }
342
 
343
  private static function baseSignature($options)
344
  {
345
+ return [
346
  'billingAddressId', 'cardholderName', 'cvv', 'number', 'deviceSessionId',
347
  'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
348
  'deviceData', 'fraudMerchantId', 'paymentMethodNonce',
349
+ ['options' => $options],
350
+ [
351
+ 'billingAddress' => self::billingAddressSignature()
352
+ ],
353
+ ];
354
+ }
355
+
356
+ public static function billingAddressSignature()
357
+ {
358
+ return [
359
+ 'firstName',
360
+ 'lastName',
361
+ 'company',
362
+ 'countryCodeAlpha2',
363
+ 'countryCodeAlpha3',
364
+ 'countryCodeNumeric',
365
+ 'countryName',
366
+ 'extendedAddress',
367
+ 'locality',
368
+ 'region',
369
+ 'postalCode',
370
+ 'streetAddress'
371
+ ];
372
  }
373
 
374
  public static function createSignature()
382
 
383
  public static function updateSignature()
384
  {
385
+ $options = self::baseOptions();
386
+ $options[] = "failOnDuplicatePaymentMethod";
387
+ $signature = self::baseSignature($options);
388
+
389
+ $updateExistingBillingSignature = [
390
+ [
391
+ 'options' => [
392
+ 'updateExisting'
393
+ ]
394
+ ]
395
+ ];
396
+
397
+ foreach($signature AS $key => $value) {
398
+ if(is_array($value) and array_key_exists('billingAddress', $value)) {
399
+ $signature[$key]['billingAddress'] = array_merge_recursive($value['billingAddress'], $updateExistingBillingSignature);
400
+ }
401
+ }
402
+
403
+ return $signature;
404
  }
405
 
406
  /**
458
  /**
459
  * generic method for validating incoming gateway responses
460
  *
461
+ * creates a new CreditCard object and encapsulates
462
+ * it inside a Result\Successful object, or
463
+ * encapsulates a Errors object inside a Result\Error
464
+ * alternatively, throws an Unexpected exception if the response is invalid
465
  *
466
  * @ignore
467
  * @param array $response gateway response values
468
+ * @return Result\Successful|Result\Error
469
+ * @throws Exception\Unexpected
470
  */
471
  private function _verifyGatewayResponse($response)
472
  {
473
  if (isset($response['creditCard'])) {
474
+ // return a populated instance of Address
475
+ return new Result\Successful(
476
+ CreditCard::factory($response['creditCard'])
477
  );
478
+ } elseif (isset($response['apiErrorResponse'])) {
479
+ return new Result\Error($response['apiErrorResponse']);
480
  } else {
481
+ throw new Exception\Unexpected(
482
  "Expected address or apiErrorResponse"
483
  );
484
  }
485
  }
486
  }
487
+ class_alias('Braintree\CreditCardGateway', 'Braintree_CreditCardGateway');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/CreditCardVerification.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class CreditCardVerification extends Result\CreditCardVerification
5
+ {
6
+ public static function factory($attributes)
7
+ {
8
+ $instance = new self($attributes);
9
+ return $instance;
10
+ }
11
+
12
+ // static methods redirecting to gateway
13
+ //
14
+ public static function create($attributes)
15
+ {
16
+ Util::verifyKeys(self::createSignature(), $attributes);
17
+ return Configuration::gateway()->creditCardVerification()->create($attributes);
18
+ }
19
+
20
+ public static function fetch($query, $ids)
21
+ {
22
+ return Configuration::gateway()->creditCardVerification()->fetch($query, $ids);
23
+ }
24
+
25
+ public static function search($query)
26
+ {
27
+ return Configuration::gateway()->creditCardVerification()->search($query);
28
+ }
29
+
30
+ public static function createSignature()
31
+ {
32
+ return [
33
+ ['options' => ['amount', 'merchantAccountId']],
34
+ ['creditCard' =>
35
+ [
36
+ 'cardholderName', 'cvv', 'number',
37
+ 'expirationDate', 'expirationMonth', 'expirationYear',
38
+ ['billingAddress' => CreditCardGateway::billingAddressSignature()]
39
+ ]
40
+ ]];
41
+ }
42
+ }
43
+ class_alias('Braintree\CreditCardVerification', 'Braintree_CreditCardVerification');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/CreditCardVerificationGateway.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class CreditCardVerificationGateway
5
+ {
6
+ private $_gateway;
7
+ private $_config;
8
+ private $_http;
9
+
10
+ public function __construct($gateway)
11
+ {
12
+ $this->_gateway = $gateway;
13
+ $this->_config = $gateway->config;
14
+ $this->_config->assertHasAccessTokenOrKeys();
15
+ $this->_http = new Http($gateway->config);
16
+ }
17
+
18
+ public function create($attributes)
19
+ {
20
+ $response = $this->_http->post($this->_config->merchantPath() . "/verifications", ['verification' => $attributes]);
21
+ return $this->_verifyGatewayResponse($response);
22
+ }
23
+
24
+ private function _verifyGatewayResponse($response)
25
+ {
26
+
27
+ if(isset($response['verification'])){
28
+ return new Result\Successful(
29
+ CreditCardVerification::factory($response['verification'])
30
+ );
31
+ } else if (isset($response['apiErrorResponse'])) {
32
+ return new Result\Error($response['apiErrorResponse']);
33
+ } else {
34
+ throw new Exception\Unexpected(
35
+ "Expected transaction or apiErrorResponse"
36
+ );
37
+ }
38
+ }
39
+
40
+ public function fetch($query, $ids)
41
+ {
42
+ $criteria = [];
43
+ foreach ($query as $term) {
44
+ $criteria[$term->name] = $term->toparam();
45
+ }
46
+ $criteria["ids"] = CreditCardVerificationSearch::ids()->in($ids)->toparam();
47
+ $path = $this->_config->merchantPath() . '/verifications/advanced_search';
48
+ $response = $this->_http->post($path, ['search' => $criteria]);
49
+
50
+ return Util::extractattributeasarray(
51
+ $response['creditCardVerifications'],
52
+ 'verification'
53
+ );
54
+ }
55
+
56
+ public function search($query)
57
+ {
58
+ $criteria = [];
59
+ foreach ($query as $term) {
60
+ $criteria[$term->name] = $term->toparam();
61
+ }
62
+
63
+ $path = $this->_config->merchantPath() . '/verifications/advanced_search_ids';
64
+ $response = $this->_http->post($path, ['search' => $criteria]);
65
+ $pager = [
66
+ 'object' => $this,
67
+ 'method' => 'fetch',
68
+ 'methodArgs' => [$query]
69
+ ];
70
+
71
+ return new ResourceCollection($response, $pager);
72
+ }
73
+ }
74
+ class_alias('Braintree\CreditCardVerificationGateway', 'Braintree_CreditCardVerificationGateway');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/CreditCardVerificationSearch.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class CreditCardVerificationSearch
5
+ {
6
+ public static function id() {
7
+ return new TextNode('id');
8
+ }
9
+
10
+ public static function creditCardCardholderName() {
11
+ return new TextNode('credit_card_cardholder_name');
12
+ }
13
+
14
+ public static function billingAddressDetailsPostalCode() {
15
+ return new TextNode('billing_address_details_postal_code');
16
+ }
17
+
18
+ public static function customerEmail() {
19
+ return new TextNode('customer_email');
20
+ }
21
+
22
+ public static function customerId() {
23
+ return new TextNode('customer_id');
24
+ }
25
+
26
+ public static function paymentMethodToken(){
27
+ return new TextNode('payment_method_token');
28
+ }
29
+
30
+ public static function creditCardExpirationDate() {
31
+ return new EqualityNode('credit_card_expiration_date');
32
+ }
33
+
34
+ public static function creditCardNumber() {
35
+ return new PartialMatchNode('credit_card_number');
36
+ }
37
+
38
+ public static function ids() {
39
+ return new MultipleValueNode('ids');
40
+ }
41
+
42
+ public static function createdAt() {
43
+ return new RangeNode("created_at");
44
+ }
45
+
46
+ public static function creditCardCardType()
47
+ {
48
+ return new MultipleValueNode("credit_card_card_type", CreditCard::allCardTypes());
49
+ }
50
+
51
+ public static function status()
52
+ {
53
+ return new MultipleValueNode("status", Result\CreditCardVerification::allStatuses());
54
+ }
55
+ }
56
+ class_alias('Braintree\CreditCardVerificationSearch', 'Braintree_CreditCardVerificationSearch');
lib/Gene/Braintree/{Customer.php → braintree/braintree_php/lib/Braintree/Customer.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Braintree Customer module
4
  * Creates and manages Customers
@@ -9,7 +11,7 @@
9
  *
10
  * @package Braintree
11
  * @category Resources
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read array $addresses
15
  * @property-read array $paymentMethods
@@ -18,6 +20,9 @@
18
  * @property-read array $creditCards
19
  * @property-read array $paypalAccounts
20
  * @property-read array $applePayCards
 
 
 
21
  * @property-read array $coinbaseAccounts
22
  * @property-read array $customFields custom fields passed with the request
23
  * @property-read string $email
@@ -29,56 +34,56 @@
29
  * @property-read string $updatedAt
30
  * @property-read string $website
31
  */
32
- class Braintree_Customer extends Braintree_Base
33
  {
34
  /**
35
- *
36
- * @return Braintree_Customer[]
37
  */
38
  public static function all()
39
  {
40
- return Braintree_Configuration::gateway()->customer()->all();
41
  }
42
 
43
  /**
44
- *
45
  * @param string $query
46
  * @param int[] $ids
47
- * @return Braintree_Customer|Braintree_Customer[]
48
  */
49
  public static function fetch($query, $ids)
50
  {
51
- return Braintree_Configuration::gateway()->customer()->fetch($query, $ids);
52
  }
53
 
54
  /**
55
- *
56
  * @param array $attribs
57
- * @return Braintree_Customer
58
  */
59
- public static function create($attribs = array())
60
  {
61
- return Braintree_Configuration::gateway()->customer()->create($attribs);
62
  }
63
 
64
  /**
65
- *
66
  * @param array $attribs
67
- * @return Braintree_Customer
68
  */
69
- public static function createNoValidate($attribs = array())
70
  {
71
- return Braintree_Configuration::gateway()->customer()->createNoValidate($attribs);
72
  }
73
 
74
  /**
75
  * @deprecated since version 2.3.0
76
  * @param string $queryString
77
- * @return Braintree_Result_Successful
78
  */
79
  public static function createFromTransparentRedirect($queryString)
80
  {
81
- return Braintree_Configuration::gateway()->customer()->createFromTransparentRedirect($queryString);
82
  }
83
 
84
  /**
@@ -87,130 +92,130 @@ class Braintree_Customer extends Braintree_Base
87
  */
88
  public static function createCustomerUrl()
89
  {
90
- return Braintree_Configuration::gateway()->customer()->createCustomerUrl();
91
  }
92
 
93
  /**
94
- *
95
- * @throws Braintree_Exception_NotFound
96
- * @param int $id
97
- * @return Braintree_Customer
98
  */
99
  public static function find($id)
100
  {
101
- return Braintree_Configuration::gateway()->customer()->find($id);
102
  }
103
 
104
  /**
105
- *
106
  * @param int $customerId
107
  * @param array $transactionAttribs
108
- * @return Braintree_Result_Successful|Braintree_Result_Error
109
  */
110
  public static function credit($customerId, $transactionAttribs)
111
  {
112
- return Braintree_Configuration::gateway()->customer()->credit($customerId, $transactionAttribs);
113
  }
114
 
115
  /**
116
- *
117
- * @throws Braintree_Exception_ValidationError
118
  * @param type $customerId
119
  * @param type $transactionAttribs
120
- * @return Braintree_Transaction
121
  */
122
  public static function creditNoValidate($customerId, $transactionAttribs)
123
  {
124
- return Braintree_Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs);
125
  }
126
 
127
  /**
128
- *
129
- * @throws Braintree_Exception on invalid id or non-200 http response code
130
  * @param int $customerId
131
- * @return Braintree_Result_Successful
132
  */
133
  public static function delete($customerId)
134
  {
135
- return Braintree_Configuration::gateway()->customer()->delete($customerId);
136
  }
137
 
138
  /**
139
- *
140
  * @param int $customerId
141
  * @param array $transactionAttribs
142
- * @return Braintree_Transaction
143
  */
144
  public static function sale($customerId, $transactionAttribs)
145
  {
146
- return Braintree_Configuration::gateway()->customer()->sale($customerId, $transactionAttribs);
147
  }
148
 
149
  /**
150
- *
151
  * @param int $customerId
152
  * @param array $transactionAttribs
153
- * @return Braintree_Transaction
154
- */
155
  public static function saleNoValidate($customerId, $transactionAttribs)
156
  {
157
- return Braintree_Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs);
158
  }
159
 
160
  /**
161
- *
162
  * @throws InvalidArgumentException
163
  * @param string $query
164
- * @return Braintree_ResourceCollection
165
  */
166
  public static function search($query)
167
  {
168
- return Braintree_Configuration::gateway()->customer()->search($query);
169
  }
170
 
171
  /**
172
- *
173
- * @throws Braintree_Exception_Unexpected
174
  * @param int $customerId
175
  * @param array $attributes
176
- * @return Braintree_Result_Successful|Braintree_Result_Error
177
  */
178
  public static function update($customerId, $attributes)
179
  {
180
- return Braintree_Configuration::gateway()->customer()->update($customerId, $attributes);
181
  }
182
 
183
  /**
184
- *
185
- * @throws Braintree_Exception_Unexpected
186
  * @param int $customerId
187
  * @param array $attributes
188
- * @return Braintree_CustomerGateway
189
  */
190
  public static function updateNoValidate($customerId, $attributes)
191
  {
192
- return Braintree_Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes);
193
  }
194
 
195
  /**
196
- *
197
  * @deprecated since version 2.3.0
198
  * @return string
199
  */
200
  public static function updateCustomerUrl()
201
  {
202
- return Braintree_Configuration::gateway()->customer()->updateCustomerUrl();
203
  }
204
 
205
  /**
206
- *
207
  * @deprecated since version 2.3.0
208
  * @param string $queryString
209
- * @return Braintree_Result_Successful|Braintree_Result_Error
210
  */
211
  public static function updateFromTransparentRedirect($queryString)
212
  {
213
- return Braintree_Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString);
214
  }
215
 
216
  /* instance methods */
@@ -224,65 +229,82 @@ class Braintree_Customer extends Braintree_Base
224
  */
225
  protected function _initialize($customerAttribs)
226
  {
227
- // set the attributes
228
  $this->_attributes = $customerAttribs;
229
 
230
- // map each address into its own object
231
- $addressArray = array();
232
  if (isset($customerAttribs['addresses'])) {
233
 
234
  foreach ($customerAttribs['addresses'] AS $address) {
235
- $addressArray[] = Braintree_Address::factory($address);
236
  }
237
  }
238
  $this->_set('addresses', $addressArray);
239
 
240
- // map each creditCard into its own object
241
- $creditCardArray = array();
242
  if (isset($customerAttribs['creditCards'])) {
243
  foreach ($customerAttribs['creditCards'] AS $creditCard) {
244
- $creditCardArray[] = Braintree_CreditCard::factory($creditCard);
245
  }
246
  }
247
  $this->_set('creditCards', $creditCardArray);
248
 
249
- // map each coinbaseAccount into its own object
250
- $coinbaseAccountArray = array();
251
  if (isset($customerAttribs['coinbaseAccounts'])) {
252
  foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
253
- $coinbaseAccountArray[] = Braintree_CoinbaseAccount::factory($coinbaseAccount);
254
  }
255
  }
256
  $this->_set('coinbaseAccounts', $coinbaseAccountArray);
257
 
258
- // map each paypalAccount into its own object
259
- $paypalAccountArray = array();
260
  if (isset($customerAttribs['paypalAccounts'])) {
261
  foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
262
- $paypalAccountArray[] = Braintree_PayPalAccount::factory($paypalAccount);
263
  }
264
  }
265
  $this->_set('paypalAccounts', $paypalAccountArray);
266
 
267
- // map each applePayCard into its own object
268
- $applePayCardArray = array();
269
  if (isset($customerAttribs['applePayCards'])) {
270
  foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
271
- $applePayCardArray[] = Braintree_ApplePayCard::factory($applePayCard);
272
  }
273
  }
274
  $this->_set('applePayCards', $applePayCardArray);
275
 
276
- // map each androidPayCard into its own object
277
- $androidPayCardArray = array();
278
  if (isset($customerAttribs['androidPayCards'])) {
279
  foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
280
- $androidPayCardArray[] = Braintree_AndroidPayCard::factory($androidPayCard);
281
  }
282
  }
283
  $this->_set('androidPayCards', $androidPayCardArray);
284
 
285
- $this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  }
287
 
288
  /**
@@ -292,19 +314,19 @@ class Braintree_Customer extends Braintree_Base
292
  public function __toString()
293
  {
294
  return __CLASS__ . '[' .
295
- Braintree_Util::attributesToString($this->_attributes) .']';
296
  }
297
 
298
  /**
299
- * returns false if comparing object is not a Braintree_Customer,
300
- * or is a Braintree_Customer with a different id
301
  *
302
  * @param object $otherCust customer to compare against
303
  * @return boolean
304
  */
305
  public function isEqual($otherCust)
306
  {
307
- return !($otherCust instanceof Braintree_Customer) ? false : $this->id === $otherCust->id;
308
  }
309
 
310
  /**
@@ -322,11 +344,11 @@ class Braintree_Customer extends Braintree_Base
322
  /**
323
  * returns the customer's default payment method
324
  *
325
- * @return object Braintree_CreditCard or Braintree_PayPalAccount
326
  */
327
  public function defaultPaymentMethod()
328
  {
329
- $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree_Customer::_defaultPaymentMethodFilter');
330
  return current($defaultPaymentMethods);
331
  }
332
 
@@ -341,7 +363,7 @@ class Braintree_Customer extends Braintree_Base
341
  * @access protected
342
  * @var array registry of customer data
343
  */
344
- protected $_attributes = array(
345
  'addresses' => '',
346
  'company' => '',
347
  'creditCards' => '',
@@ -354,20 +376,21 @@ class Braintree_Customer extends Braintree_Base
354
  'createdAt' => '',
355
  'updatedAt' => '',
356
  'website' => '',
357
- );
358
 
359
  /**
360
- * factory method: returns an instance of Braintree_Customer
361
  * to the requesting method, with populated properties
362
  *
363
  * @ignore
364
  * @param array $attributes
365
- * @return Braintree_Customer
366
  */
367
  public static function factory($attributes)
368
  {
369
- $instance = new Braintree_Customer();
370
  $instance->_initialize($attributes);
371
  return $instance;
372
  }
373
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree Customer module
6
  * Creates and manages Customers
11
  *
12
  * @package Braintree
13
  * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  *
16
  * @property-read array $addresses
17
  * @property-read array $paymentMethods
20
  * @property-read array $creditCards
21
  * @property-read array $paypalAccounts
22
  * @property-read array $applePayCards
23
+ * @property-read array $androidPayCards
24
+ * @property-read array $amexExpressCheckoutCards
25
+ * @property-read array $venmoAccounts
26
  * @property-read array $coinbaseAccounts
27
  * @property-read array $customFields custom fields passed with the request
28
  * @property-read string $email
34
  * @property-read string $updatedAt
35
  * @property-read string $website
36
  */
37
+ class Customer extends Base
38
  {
39
  /**
40
+ *
41
+ * @return Customer[]
42
  */
43
  public static function all()
44
  {
45
+ return Configuration::gateway()->customer()->all();
46
  }
47
 
48
  /**
49
+ *
50
  * @param string $query
51
  * @param int[] $ids
52
+ * @return Customer|Customer[]
53
  */
54
  public static function fetch($query, $ids)
55
  {
56
+ return Configuration::gateway()->customer()->fetch($query, $ids);
57
  }
58
 
59
  /**
60
+ *
61
  * @param array $attribs
62
+ * @return Result\Successful|Result\Error
63
  */
64
+ public static function create($attribs = [])
65
  {
66
+ return Configuration::gateway()->customer()->create($attribs);
67
  }
68
 
69
  /**
70
+ *
71
  * @param array $attribs
72
+ * @return Customer
73
  */
74
+ public static function createNoValidate($attribs = [])
75
  {
76
+ return Configuration::gateway()->customer()->createNoValidate($attribs);
77
  }
78
 
79
  /**
80
  * @deprecated since version 2.3.0
81
  * @param string $queryString
82
+ * @return Result\Successful
83
  */
84
  public static function createFromTransparentRedirect($queryString)
85
  {
86
+ return Configuration::gateway()->customer()->createFromTransparentRedirect($queryString);
87
  }
88
 
89
  /**
92
  */
93
  public static function createCustomerUrl()
94
  {
95
+ return Configuration::gateway()->customer()->createCustomerUrl();
96
  }
97
 
98
  /**
99
+ *
100
+ * @throws Exception\NotFound
101
+ * @param string $id customer id
102
+ * @return Customer
103
  */
104
  public static function find($id)
105
  {
106
+ return Configuration::gateway()->customer()->find($id);
107
  }
108
 
109
  /**
110
+ *
111
  * @param int $customerId
112
  * @param array $transactionAttribs
113
+ * @return Result\Successful|Result\Error
114
  */
115
  public static function credit($customerId, $transactionAttribs)
116
  {
117
+ return Configuration::gateway()->customer()->credit($customerId, $transactionAttribs);
118
  }
119
 
120
  /**
121
+ *
122
+ * @throws Exception\ValidationError
123
  * @param type $customerId
124
  * @param type $transactionAttribs
125
+ * @return Transaction
126
  */
127
  public static function creditNoValidate($customerId, $transactionAttribs)
128
  {
129
+ return Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs);
130
  }
131
 
132
  /**
133
+ *
134
+ * @throws Exception on invalid id or non-200 http response code
135
  * @param int $customerId
136
+ * @return Result\Successful
137
  */
138
  public static function delete($customerId)
139
  {
140
+ return Configuration::gateway()->customer()->delete($customerId);
141
  }
142
 
143
  /**
144
+ *
145
  * @param int $customerId
146
  * @param array $transactionAttribs
147
+ * @return Transaction
148
  */
149
  public static function sale($customerId, $transactionAttribs)
150
  {
151
+ return Configuration::gateway()->customer()->sale($customerId, $transactionAttribs);
152
  }
153
 
154
  /**
155
+ *
156
  * @param int $customerId
157
  * @param array $transactionAttribs
158
+ * @return Transaction
159
+ */
160
  public static function saleNoValidate($customerId, $transactionAttribs)
161
  {
162
+ return Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs);
163
  }
164
 
165
  /**
166
+ *
167
  * @throws InvalidArgumentException
168
  * @param string $query
169
+ * @return ResourceCollection
170
  */
171
  public static function search($query)
172
  {
173
+ return Configuration::gateway()->customer()->search($query);
174
  }
175
 
176
  /**
177
+ *
178
+ * @throws Exception\Unexpected
179
  * @param int $customerId
180
  * @param array $attributes
181
+ * @return Result\Successful|Result\Error
182
  */
183
  public static function update($customerId, $attributes)
184
  {
185
+ return Configuration::gateway()->customer()->update($customerId, $attributes);
186
  }
187
 
188
  /**
189
+ *
190
+ * @throws Exception\Unexpected
191
  * @param int $customerId
192
  * @param array $attributes
193
+ * @return CustomerGateway
194
  */
195
  public static function updateNoValidate($customerId, $attributes)
196
  {
197
+ return Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes);
198
  }
199
 
200
  /**
201
+ *
202
  * @deprecated since version 2.3.0
203
  * @return string
204
  */
205
  public static function updateCustomerUrl()
206
  {
207
+ return Configuration::gateway()->customer()->updateCustomerUrl();
208
  }
209
 
210
  /**
211
+ *
212
  * @deprecated since version 2.3.0
213
  * @param string $queryString
214
+ * @return Result\Successful|Result\Error
215
  */
216
  public static function updateFromTransparentRedirect($queryString)
217
  {
218
+ return Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString);
219
  }
220
 
221
  /* instance methods */
229
  */
230
  protected function _initialize($customerAttribs)
231
  {
 
232
  $this->_attributes = $customerAttribs;
233
 
234
+ $addressArray = [];
 
235
  if (isset($customerAttribs['addresses'])) {
236
 
237
  foreach ($customerAttribs['addresses'] AS $address) {
238
+ $addressArray[] = Address::factory($address);
239
  }
240
  }
241
  $this->_set('addresses', $addressArray);
242
 
243
+ $creditCardArray = [];
 
244
  if (isset($customerAttribs['creditCards'])) {
245
  foreach ($customerAttribs['creditCards'] AS $creditCard) {
246
+ $creditCardArray[] = CreditCard::factory($creditCard);
247
  }
248
  }
249
  $this->_set('creditCards', $creditCardArray);
250
 
251
+ $coinbaseAccountArray = [];
 
252
  if (isset($customerAttribs['coinbaseAccounts'])) {
253
  foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
254
+ $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
255
  }
256
  }
257
  $this->_set('coinbaseAccounts', $coinbaseAccountArray);
258
 
259
+ $paypalAccountArray = [];
 
260
  if (isset($customerAttribs['paypalAccounts'])) {
261
  foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
262
+ $paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
263
  }
264
  }
265
  $this->_set('paypalAccounts', $paypalAccountArray);
266
 
267
+ $applePayCardArray = [];
 
268
  if (isset($customerAttribs['applePayCards'])) {
269
  foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
270
+ $applePayCardArray[] = ApplePayCard::factory($applePayCard);
271
  }
272
  }
273
  $this->_set('applePayCards', $applePayCardArray);
274
 
275
+ $androidPayCardArray = [];
 
276
  if (isset($customerAttribs['androidPayCards'])) {
277
  foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
278
+ $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
279
  }
280
  }
281
  $this->_set('androidPayCards', $androidPayCardArray);
282
 
283
+ $amexExpressCheckoutCardArray = [];
284
+ if (isset($customerAttribs['amexExpressCheckoutCards'])) {
285
+ foreach ($customerAttribs['amexExpressCheckoutCards'] AS $amexExpressCheckoutCard) {
286
+ $amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard);
287
+ }
288
+ }
289
+ $this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray);
290
+
291
+ $venmoAccountArray = array();
292
+ if (isset($customerAttribs['venmoAccounts'])) {
293
+ foreach ($customerAttribs['venmoAccounts'] AS $venmoAccount) {
294
+ $venmoAccountArray[] = VenmoAccount::factory($venmoAccount);
295
+ }
296
+ }
297
+ $this->_set('venmoAccounts', $venmoAccountArray);
298
+
299
+ $this->_set('paymentMethods', array_merge(
300
+ $this->creditCards,
301
+ $this->paypalAccounts,
302
+ $this->applePayCards,
303
+ $this->coinbaseAccounts,
304
+ $this->androidPayCards,
305
+ $this->amexExpressCheckoutCards,
306
+ $this->venmoAccounts
307
+ ));
308
  }
309
 
310
  /**
314
  public function __toString()
315
  {
316
  return __CLASS__ . '[' .
317
+ Util::attributesToString($this->_attributes) .']';
318
  }
319
 
320
  /**
321
+ * returns false if comparing object is not a Customer,
322
+ * or is a Customer with a different id
323
  *
324
  * @param object $otherCust customer to compare against
325
  * @return boolean
326
  */
327
  public function isEqual($otherCust)
328
  {
329
+ return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id;
330
  }
331
 
332
  /**
344
  /**
345
  * returns the customer's default payment method
346
  *
347
+ * @return CreditCard|PayPalAccount
348
  */
349
  public function defaultPaymentMethod()
350
  {
351
+ $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\Customer::_defaultPaymentMethodFilter');
352
  return current($defaultPaymentMethods);
353
  }
354
 
363
  * @access protected
364
  * @var array registry of customer data
365
  */
366
+ protected $_attributes = [
367
  'addresses' => '',
368
  'company' => '',
369
  'creditCards' => '',
376
  'createdAt' => '',
377
  'updatedAt' => '',
378
  'website' => '',
379
+ ];
380
 
381
  /**
382
+ * factory method: returns an instance of Customer
383
  * to the requesting method, with populated properties
384
  *
385
  * @ignore
386
  * @param array $attributes
387
+ * @return Customer
388
  */
389
  public static function factory($attributes)
390
  {
391
+ $instance = new Customer();
392
  $instance->_initialize($attributes);
393
  return $instance;
394
  }
395
  }
396
+ class_alias('Braintree\Customer', 'Braintree_Customer');
lib/Gene/Braintree/{CustomerGateway.php → braintree/braintree_php/lib/Braintree/CustomerGateway.php} RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Braintree CustomerGateway module
4
  * Creates and manages Customers
@@ -9,9 +13,9 @@
9
  *
10
  * @package Braintree
11
  * @category Resources
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  */
14
- class Braintree_CustomerGateway
15
  {
16
  private $_gateway;
17
  private $_config;
@@ -22,33 +26,33 @@ class Braintree_CustomerGateway
22
  $this->_gateway = $gateway;
23
  $this->_config = $gateway->config;
24
  $this->_config->assertHasAccessTokenOrKeys();
25
- $this->_http = new Braintree_Http($gateway->config);
26
  }
27
 
28
  public function all()
29
  {
30
  $path = $this->_config->merchantPath() . '/customers/advanced_search_ids';
31
  $response = $this->_http->post($path);
32
- $pager = array(
33
  'object' => $this,
34
  'method' => 'fetch',
35
- 'methodArgs' => array(array())
36
- );
37
 
38
- return new Braintree_ResourceCollection($response, $pager);
39
  }
40
 
41
  public function fetch($query, $ids)
42
  {
43
- $criteria = array();
44
  foreach ($query as $term) {
45
  $criteria[$term->name] = $term->toparam();
46
  }
47
- $criteria["ids"] = Braintree_CustomerSearch::ids()->in($ids)->toparam();
48
  $path = $this->_config->merchantPath() . '/customers/advanced_search';
49
- $response = $this->_http->post($path, array('search' => $criteria));
50
 
51
- return Braintree_Util::extractattributeasarray(
52
  $response['customers'],
53
  'customer'
54
  );
@@ -59,7 +63,7 @@ class Braintree_CustomerGateway
59
  * the gateway will generate it.
60
  *
61
  * <code>
62
- * $result = Braintree_Customer::create(array(
63
  * 'first_name' => 'John',
64
  * 'last_name' => 'Smith',
65
  * 'company' => 'Smith Co.',
@@ -77,27 +81,27 @@ class Braintree_CustomerGateway
77
  *
78
  * @access public
79
  * @param array $attribs
80
- * @return object Result, either Successful or Error
81
  */
82
- public function create($attribs = array())
83
  {
84
- Braintree_Util::verifyKeys(self::createSignature(), $attribs);
85
- return $this->_doCreate('/customers', array('customer' => $attribs));
86
  }
87
 
88
  /**
89
  * attempts the create operation assuming all data will validate
90
- * returns a Braintree_Customer object instead of a Result
91
  *
92
  * @access public
93
  * @param array $attribs
94
- * @return object
95
- * @throws Braintree_Exception_ValidationError
96
  */
97
- public function createNoValidate($attribs = array())
98
  {
99
  $result = $this->create($attribs);
100
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
101
  }
102
  /**
103
  * create a customer from a TransparentRedirect operation
@@ -105,17 +109,17 @@ class Braintree_CustomerGateway
105
  * @deprecated since version 2.3.0
106
  * @access public
107
  * @param array $attribs
108
- * @return object
109
  */
110
  public function createFromTransparentRedirect($queryString)
111
  {
112
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
113
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString(
114
  $queryString
115
  );
116
  return $this->_doCreate(
117
  '/customers/all/confirm_transparent_redirect_request',
118
- array('id' => $params['id'])
119
  );
120
  }
121
 
@@ -128,7 +132,7 @@ class Braintree_CustomerGateway
128
  */
129
  public function createCustomerUrl()
130
  {
131
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
132
  return $this->_config->baseUrl() . $this->_config->merchantPath() .
133
  '/customers/all/create_via_transparent_redirect_request';
134
  }
@@ -141,15 +145,18 @@ class Braintree_CustomerGateway
141
  public static function createSignature()
142
  {
143
 
144
- $creditCardSignature = Braintree_CreditCardGateway::createSignature();
145
  unset($creditCardSignature[array_search('customerId', $creditCardSignature)]);
146
- $signature = array(
147
  'id', 'company', 'email', 'fax', 'firstName',
148
  'lastName', 'phone', 'website', 'deviceData',
149
  'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce',
150
- array('creditCard' => $creditCardSignature),
151
- array('customFields' => array('_anyKey_')),
152
- );
 
 
 
153
  return $signature;
154
  }
155
 
@@ -159,7 +166,7 @@ class Braintree_CustomerGateway
159
  */
160
  public static function updateSignature()
161
  {
162
- $creditCardSignature = Braintree_CreditCardGateway::updateSignature();
163
 
164
  foreach($creditCardSignature AS $key => $value) {
165
  if(is_array($value) and array_key_exists('options', $value)) {
@@ -167,13 +174,13 @@ class Braintree_CustomerGateway
167
  }
168
  }
169
 
170
- $signature = array(
171
  'id', 'company', 'email', 'fax', 'firstName',
172
  'lastName', 'phone', 'website', 'deviceData',
173
- 'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce',
174
- array('creditCard' => $creditCardSignature),
175
- array('customFields' => array('_anyKey_')),
176
- );
177
  return $signature;
178
  }
179
 
@@ -183,8 +190,8 @@ class Braintree_CustomerGateway
183
  *
184
  * @access public
185
  * @param string id customer Id
186
- * @return object Braintree_Customer
187
- * @throws Braintree_Exception_NotFound
188
  */
189
  public function find($id)
190
  {
@@ -192,13 +199,12 @@ class Braintree_CustomerGateway
192
  try {
193
  $path = $this->_config->merchantPath() . '/customers/' . $id;
194
  $response = $this->_http->get($path);
195
- return Braintree_Customer::factory($response['customer']);
196
- } catch (Braintree_Exception_NotFound $e) {
197
- throw new Braintree_Exception_NotFound(
198
  'customer with id ' . $id . ' not found'
199
  );
200
  }
201
-
202
  }
203
 
204
  /**
@@ -207,14 +213,14 @@ class Braintree_CustomerGateway
207
  * @access public
208
  * @param int $customerId
209
  * @param array $transactionAttribs
210
- * @return Braintree_Result_Successful|Braintree_Result_Error
211
  */
212
  public function credit($customerId, $transactionAttribs)
213
  {
214
  $this->_validateId($customerId);
215
- return Braintree_Transaction::credit(
216
  array_merge($transactionAttribs,
217
- array('customerId' => $customerId)
218
  )
219
  );
220
  }
@@ -222,18 +228,18 @@ class Braintree_CustomerGateway
222
  /**
223
  * credit a customer, assuming validations will pass
224
  *
225
- * returns a Braintree_Transaction object on success
226
  *
227
  * @access public
228
  * @param int $customerId
229
  * @param array $transactionAttribs
230
- * @return Braintree_Transaction
231
- * @throws Braintree_Exception_ValidationError
232
  */
233
  public function creditNoValidate($customerId, $transactionAttribs)
234
  {
235
  $result = $this->credit($customerId, $transactionAttribs);
236
- return Braintree_Util::returnObjectOrThrowException('Braintree_Transaction', $result);
237
  }
238
 
239
  /**
@@ -246,7 +252,7 @@ class Braintree_CustomerGateway
246
  $this->_validateId($customerId);
247
  $path = $this->_config->merchantPath() . '/customers/' . $customerId;
248
  $this->_http->delete($path);
249
- return new Braintree_Result_Successful();
250
  }
251
 
252
  /**
@@ -254,15 +260,15 @@ class Braintree_CustomerGateway
254
  *
255
  * @param string $customerId
256
  * @param array $transactionAttribs
257
- * @return object Braintree_Result_Successful or Braintree_Result_Error
258
- * @see Braintree_Transaction::sale()
259
  */
260
  public function sale($customerId, $transactionAttribs)
261
  {
262
  $this->_validateId($customerId);
263
- return Braintree_Transaction::sale(
264
  array_merge($transactionAttribs,
265
- array('customerId' => $customerId)
266
  )
267
  );
268
  }
@@ -270,18 +276,18 @@ class Braintree_CustomerGateway
270
  /**
271
  * create a new sale for a customer, assuming validations will pass
272
  *
273
- * returns a Braintree_Transaction object on success
274
  * @access public
275
  * @param string $customerId
276
  * @param array $transactionAttribs
277
- * @return object Braintree_Transaction
278
- * @throws Braintree_Exception_ValidationsFailed
279
- * @see Braintree_Transaction::sale()
280
  */
281
  public function saleNoValidate($customerId, $transactionAttribs)
282
  {
283
  $result = $this->sale($customerId, $transactionAttribs);
284
- return Braintree_Util::returnObjectOrThrowException('Braintree_Transaction', $result);
285
  }
286
 
287
  /**
@@ -292,12 +298,12 @@ class Braintree_CustomerGateway
292
  * For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/customer-api#searching http://www.braintreepaymentsolutions.com/gateway/customer-api}
293
  *
294
  * @param mixed $query search query
295
- * @return object Braintree_ResourceCollection
296
  * @throws InvalidArgumentException
297
  */
298
  public function search($query)
299
  {
300
- $criteria = array();
301
  foreach ($query as $term) {
302
  $result = $term->toparam();
303
  if(is_null($result) || empty($result)) {
@@ -308,14 +314,14 @@ class Braintree_CustomerGateway
308
  }
309
 
310
  $path = $this->_config->merchantPath() . '/customers/advanced_search_ids';
311
- $response = $this->_http->post($path, array('search' => $criteria));
312
- $pager = array(
313
  'object' => $this,
314
  'method' => 'fetch',
315
- 'methodArgs' => array($query)
316
- );
317
 
318
- return new Braintree_ResourceCollection($response, $pager);
319
  }
320
 
321
  /**
@@ -327,16 +333,16 @@ class Braintree_CustomerGateway
327
  * @access public
328
  * @param string $customerId (optional)
329
  * @param array $attributes
330
- * @return object Braintree_Result_Successful or Braintree_Result_Error
331
  */
332
  public function update($customerId, $attributes)
333
  {
334
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
335
  $this->_validateId($customerId);
336
  return $this->_doUpdate(
337
  'put',
338
  '/customers/' . $customerId,
339
- array('customer' => $attributes)
340
  );
341
  }
342
 
@@ -345,18 +351,18 @@ class Braintree_CustomerGateway
345
  *
346
  * if calling this method in static context, customerId
347
  * is the 2nd attribute. customerId is not sent in object context.
348
- * returns a Braintree_Customer object on success
349
  *
350
  * @access public
351
  * @param string $customerId
352
  * @param array $attributes
353
- * @return object Braintree_Customer
354
- * @throws Braintree_Exception_ValidationsFailed
355
  */
356
  public function updateNoValidate($customerId, $attributes)
357
  {
358
  $result = $this->update($customerId, $attributes);
359
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
360
  }
361
  /**
362
  *
@@ -366,7 +372,7 @@ class Braintree_CustomerGateway
366
  */
367
  public function updateCustomerUrl()
368
  {
369
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
370
  return $this->_config->baseUrl() . $this->_config->merchantPath() .
371
  '/customers/all/update_via_transparent_redirect_request';
372
  }
@@ -381,14 +387,14 @@ class Braintree_CustomerGateway
381
  */
382
  public function updateFromTransparentRedirect($queryString)
383
  {
384
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
385
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString(
386
  $queryString
387
  );
388
  return $this->_doUpdate(
389
  'post',
390
  '/customers/all/confirm_transparent_redirect_request',
391
- array('id' => $params['id'])
392
  );
393
  }
394
 
@@ -400,7 +406,7 @@ class Braintree_CustomerGateway
400
  * @ignore
401
  * @access protected
402
  * @param array $customerAttribs array of customer data
403
- * @return none
404
  */
405
  protected function _initialize($customerAttribs)
406
  {
@@ -408,56 +414,56 @@ class Braintree_CustomerGateway
408
  $this->_attributes = $customerAttribs;
409
 
410
  // map each address into its own object
411
- $addressArray = array();
412
  if (isset($customerAttribs['addresses'])) {
413
 
414
  foreach ($customerAttribs['addresses'] AS $address) {
415
- $addressArray[] = Braintree_Address::factory($address);
416
  }
417
  }
418
  $this->_set('addresses', $addressArray);
419
 
420
  // map each creditCard into its own object
421
- $creditCardArray = array();
422
  if (isset($customerAttribs['creditCards'])) {
423
  foreach ($customerAttribs['creditCards'] AS $creditCard) {
424
- $creditCardArray[] = Braintree_CreditCard::factory($creditCard);
425
  }
426
  }
427
  $this->_set('creditCards', $creditCardArray);
428
 
429
  // map each coinbaseAccount into its own object
430
- $coinbaseAccountArray = array();
431
  if (isset($customerAttribs['coinbaseAccounts'])) {
432
  foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
433
- $coinbaseAccountArray[] = Braintree_CoinbaseAccount::factory($coinbaseAccount);
434
  }
435
  }
436
  $this->_set('coinbaseAccounts', $coinbaseAccountArray);
437
 
438
  // map each paypalAccount into its own object
439
- $paypalAccountArray = array();
440
  if (isset($customerAttribs['paypalAccounts'])) {
441
  foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
442
- $paypalAccountArray[] = Braintree_PayPalAccount::factory($paypalAccount);
443
  }
444
  }
445
  $this->_set('paypalAccounts', $paypalAccountArray);
446
 
447
  // map each applePayCard into its own object
448
- $applePayCardArray = array();
449
  if (isset($customerAttribs['applePayCards'])) {
450
  foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
451
- $applePayCardArray[] = Braintree_applePayCard::factory($applePayCard);
452
  }
453
  }
454
  $this->_set('applePayCards', $applePayCardArray);
455
 
456
  // map each androidPayCard into its own object
457
- $androidPayCardArray = array();
458
  if (isset($customerAttribs['androidPayCards'])) {
459
  foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
460
- $androidPayCardArray[] = Braintree_AndroidPayCard::factory($androidPayCard);
461
  }
462
  }
463
  $this->_set('androidPayCards', $androidPayCardArray);
@@ -472,19 +478,19 @@ class Braintree_CustomerGateway
472
  public function __toString()
473
  {
474
  return __CLASS__ . '[' .
475
- Braintree_Util::attributesToString($this->_attributes) .']';
476
  }
477
 
478
  /**
479
- * returns false if comparing object is not a Braintree_Customer,
480
- * or is a Braintree_Customer with a different id
481
  *
482
  * @param object $otherCust customer to compare against
483
  * @return boolean
484
  */
485
  public function isEqual($otherCust)
486
  {
487
- return !($otherCust instanceof Braintree_Customer) ? false : $this->id === $otherCust->id;
488
  }
489
 
490
  /**
@@ -500,11 +506,11 @@ class Braintree_CustomerGateway
500
  /**
501
  * returns the customer's default payment method
502
  *
503
- * @return object Braintree_CreditCard | Braintree_PayPalAccount | Braintree_ApplePayCard | Braintree_AndroidPayCard
504
  */
505
  public function defaultPaymentMethod()
506
  {
507
- $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree_Customer::_defaultPaymentMethodFilter');
508
  return current($defaultPaymentMethods);
509
  }
510
 
@@ -519,7 +525,7 @@ class Braintree_CustomerGateway
519
  * @access protected
520
  * @var array registry of customer data
521
  */
522
- protected $_attributes = array(
523
  'addresses' => '',
524
  'company' => '',
525
  'creditCards' => '',
@@ -532,7 +538,7 @@ class Braintree_CustomerGateway
532
  'createdAt' => '',
533
  'updatedAt' => '',
534
  'website' => '',
535
- );
536
 
537
  /**
538
  * sends the create request to the gateway
@@ -591,29 +597,30 @@ class Braintree_CustomerGateway
591
  /**
592
  * generic method for validating incoming gateway responses
593
  *
594
- * creates a new Braintree_Customer object and encapsulates
595
- * it inside a Braintree_Result_Successful object, or
596
- * encapsulates a Braintree_Errors object inside a Result_Error
597
  * alternatively, throws an Unexpected exception if the response is invalid.
598
  *
599
  * @ignore
600
  * @param array $response gateway response values
601
- * @return object Result_Successful or Result_Error
602
- * @throws Braintree_Exception_Unexpected
603
  */
604
  private function _verifyGatewayResponse($response)
605
  {
606
  if (isset($response['customer'])) {
607
- // return a populated instance of Braintree_Customer
608
- return new Braintree_Result_Successful(
609
- Braintree_Customer::factory($response['customer'])
610
  );
611
  } else if (isset($response['apiErrorResponse'])) {
612
- return new Braintree_Result_Error($response['apiErrorResponse']);
613
  } else {
614
- throw new Braintree_Exception_Unexpected(
615
  "Expected customer or apiErrorResponse"
616
  );
617
  }
618
  }
619
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
  /**
7
  * Braintree CustomerGateway module
8
  * Creates and manages Customers
13
  *
14
  * @package Braintree
15
  * @category Resources
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
  */
18
+ class CustomerGateway
19
  {
20
  private $_gateway;
21
  private $_config;
26
  $this->_gateway = $gateway;
27
  $this->_config = $gateway->config;
28
  $this->_config->assertHasAccessTokenOrKeys();
29
+ $this->_http = new Http($gateway->config);
30
  }
31
 
32
  public function all()
33
  {
34
  $path = $this->_config->merchantPath() . '/customers/advanced_search_ids';
35
  $response = $this->_http->post($path);
36
+ $pager = [
37
  'object' => $this,
38
  'method' => 'fetch',
39
+ 'methodArgs' => [[]]
40
+ ];
41
 
42
+ return new ResourceCollection($response, $pager);
43
  }
44
 
45
  public function fetch($query, $ids)
46
  {
47
+ $criteria = [];
48
  foreach ($query as $term) {
49
  $criteria[$term->name] = $term->toparam();
50
  }
51
+ $criteria["ids"] = CustomerSearch::ids()->in($ids)->toparam();
52
  $path = $this->_config->merchantPath() . '/customers/advanced_search';
53
+ $response = $this->_http->post($path, ['search' => $criteria]);
54
 
55
+ return Util::extractattributeasarray(
56
  $response['customers'],
57
  'customer'
58
  );
63
  * the gateway will generate it.
64
  *
65
  * <code>
66
+ * $result = Customer::create(array(
67
  * 'first_name' => 'John',
68
  * 'last_name' => 'Smith',
69
  * 'company' => 'Smith Co.',
81
  *
82
  * @access public
83
  * @param array $attribs
84
+ * @return Braintree_Result_Successful|Braintree_Result_Error
85
  */
86
+ public function create($attribs = [])
87
  {
88
+ Util::verifyKeys(self::createSignature(), $attribs);
89
+ return $this->_doCreate('/customers', ['customer' => $attribs]);
90
  }
91
 
92
  /**
93
  * attempts the create operation assuming all data will validate
94
+ * returns a Customer object instead of a Result
95
  *
96
  * @access public
97
  * @param array $attribs
98
+ * @return Customer
99
+ * @throws Exception\ValidationError
100
  */
101
+ public function createNoValidate($attribs = [])
102
  {
103
  $result = $this->create($attribs);
104
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
105
  }
106
  /**
107
  * create a customer from a TransparentRedirect operation
109
  * @deprecated since version 2.3.0
110
  * @access public
111
  * @param array $attribs
112
+ * @return Customer
113
  */
114
  public function createFromTransparentRedirect($queryString)
115
  {
116
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
117
+ $params = TransparentRedirect::parseAndValidateQueryString(
118
  $queryString
119
  );
120
  return $this->_doCreate(
121
  '/customers/all/confirm_transparent_redirect_request',
122
+ ['id' => $params['id']]
123
  );
124
  }
125
 
132
  */
133
  public function createCustomerUrl()
134
  {
135
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
136
  return $this->_config->baseUrl() . $this->_config->merchantPath() .
137
  '/customers/all/create_via_transparent_redirect_request';
138
  }
145
  public static function createSignature()
146
  {
147
 
148
+ $creditCardSignature = CreditCardGateway::createSignature();
149
  unset($creditCardSignature[array_search('customerId', $creditCardSignature)]);
150
+ $signature = [
151
  'id', 'company', 'email', 'fax', 'firstName',
152
  'lastName', 'phone', 'website', 'deviceData',
153
  'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce',
154
+ ['riskData' =>
155
+ ['customer_browser', 'customer_ip']
156
+ ],
157
+ ['creditCard' => $creditCardSignature],
158
+ ['customFields' => ['_anyKey_']],
159
+ ];
160
  return $signature;
161
  }
162
 
166
  */
167
  public static function updateSignature()
168
  {
169
+ $creditCardSignature = CreditCardGateway::updateSignature();
170
 
171
  foreach($creditCardSignature AS $key => $value) {
172
  if(is_array($value) and array_key_exists('options', $value)) {
174
  }
175
  }
176
 
177
+ $signature = [
178
  'id', 'company', 'email', 'fax', 'firstName',
179
  'lastName', 'phone', 'website', 'deviceData',
180
+ 'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce', 'defaultPaymentMethodToken',
181
+ ['creditCard' => $creditCardSignature],
182
+ ['customFields' => ['_anyKey_']],
183
+ ];
184
  return $signature;
185
  }
186
 
190
  *
191
  * @access public
192
  * @param string id customer Id
193
+ * @return Customer|boolean The customer object or false if the request fails.
194
+ * @throws Exception\NotFound
195
  */
196
  public function find($id)
197
  {
199
  try {
200
  $path = $this->_config->merchantPath() . '/customers/' . $id;
201
  $response = $this->_http->get($path);
202
+ return Customer::factory($response['customer']);
203
+ } catch (Exception\NotFound $e) {
204
+ throw new Exception\NotFound(
205
  'customer with id ' . $id . ' not found'
206
  );
207
  }
 
208
  }
209
 
210
  /**
213
  * @access public
214
  * @param int $customerId
215
  * @param array $transactionAttribs
216
+ * @return Result\Successful|Result\Error
217
  */
218
  public function credit($customerId, $transactionAttribs)
219
  {
220
  $this->_validateId($customerId);
221
+ return Transaction::credit(
222
  array_merge($transactionAttribs,
223
+ ['customerId' => $customerId]
224
  )
225
  );
226
  }
228
  /**
229
  * credit a customer, assuming validations will pass
230
  *
231
+ * returns a Transaction object on success
232
  *
233
  * @access public
234
  * @param int $customerId
235
  * @param array $transactionAttribs
236
+ * @return Transaction
237
+ * @throws Exception\ValidationError
238
  */
239
  public function creditNoValidate($customerId, $transactionAttribs)
240
  {
241
  $result = $this->credit($customerId, $transactionAttribs);
242
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
243
  }
244
 
245
  /**
252
  $this->_validateId($customerId);
253
  $path = $this->_config->merchantPath() . '/customers/' . $customerId;
254
  $this->_http->delete($path);
255
+ return new Result\Successful();
256
  }
257
 
258
  /**
260
  *
261
  * @param string $customerId
262
  * @param array $transactionAttribs
263
+ * @return Result\Successful|Result\Error
264
+ * @see Transaction::sale()
265
  */
266
  public function sale($customerId, $transactionAttribs)
267
  {
268
  $this->_validateId($customerId);
269
+ return Transaction::sale(
270
  array_merge($transactionAttribs,
271
+ ['customerId' => $customerId]
272
  )
273
  );
274
  }
276
  /**
277
  * create a new sale for a customer, assuming validations will pass
278
  *
279
+ * returns a Transaction object on success
280
  * @access public
281
  * @param string $customerId
282
  * @param array $transactionAttribs
283
+ * @return Transaction
284
+ * @throws Exception\ValidationsFailed
285
+ * @see Transaction::sale()
286
  */
287
  public function saleNoValidate($customerId, $transactionAttribs)
288
  {
289
  $result = $this->sale($customerId, $transactionAttribs);
290
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
291
  }
292
 
293
  /**
298
  * For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/customer-api#searching http://www.braintreepaymentsolutions.com/gateway/customer-api}
299
  *
300
  * @param mixed $query search query
301
+ * @return ResourceCollection
302
  * @throws InvalidArgumentException
303
  */
304
  public function search($query)
305
  {
306
+ $criteria = [];
307
  foreach ($query as $term) {
308
  $result = $term->toparam();
309
  if(is_null($result) || empty($result)) {
314
  }
315
 
316
  $path = $this->_config->merchantPath() . '/customers/advanced_search_ids';
317
+ $response = $this->_http->post($path, ['search' => $criteria]);
318
+ $pager = [
319
  'object' => $this,
320
  'method' => 'fetch',
321
+ 'methodArgs' => [$query]
322
+ ];
323
 
324
+ return new ResourceCollection($response, $pager);
325
  }
326
 
327
  /**
333
  * @access public
334
  * @param string $customerId (optional)
335
  * @param array $attributes
336
+ * @return Result\Successful|Result\Error
337
  */
338
  public function update($customerId, $attributes)
339
  {
340
+ Util::verifyKeys(self::updateSignature(), $attributes);
341
  $this->_validateId($customerId);
342
  return $this->_doUpdate(
343
  'put',
344
  '/customers/' . $customerId,
345
+ ['customer' => $attributes]
346
  );
347
  }
348
 
351
  *
352
  * if calling this method in static context, customerId
353
  * is the 2nd attribute. customerId is not sent in object context.
354
+ * returns a Customer object on success
355
  *
356
  * @access public
357
  * @param string $customerId
358
  * @param array $attributes
359
+ * @return Customer
360
+ * @throws Exception\ValidationsFailed
361
  */
362
  public function updateNoValidate($customerId, $attributes)
363
  {
364
  $result = $this->update($customerId, $attributes);
365
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
366
  }
367
  /**
368
  *
372
  */
373
  public function updateCustomerUrl()
374
  {
375
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
376
  return $this->_config->baseUrl() . $this->_config->merchantPath() .
377
  '/customers/all/update_via_transparent_redirect_request';
378
  }
387
  */
388
  public function updateFromTransparentRedirect($queryString)
389
  {
390
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
391
+ $params = TransparentRedirect::parseAndValidateQueryString(
392
  $queryString
393
  );
394
  return $this->_doUpdate(
395
  'post',
396
  '/customers/all/confirm_transparent_redirect_request',
397
+ ['id' => $params['id']]
398
  );
399
  }
400
 
406
  * @ignore
407
  * @access protected
408
  * @param array $customerAttribs array of customer data
409
+ * @return void
410
  */
411
  protected function _initialize($customerAttribs)
412
  {
414
  $this->_attributes = $customerAttribs;
415
 
416
  // map each address into its own object
417
+ $addressArray = [];
418
  if (isset($customerAttribs['addresses'])) {
419
 
420
  foreach ($customerAttribs['addresses'] AS $address) {
421
+ $addressArray[] = Address::factory($address);
422
  }
423
  }
424
  $this->_set('addresses', $addressArray);
425
 
426
  // map each creditCard into its own object
427
+ $creditCardArray = [];
428
  if (isset($customerAttribs['creditCards'])) {
429
  foreach ($customerAttribs['creditCards'] AS $creditCard) {
430
+ $creditCardArray[] = CreditCard::factory($creditCard);
431
  }
432
  }
433
  $this->_set('creditCards', $creditCardArray);
434
 
435
  // map each coinbaseAccount into its own object
436
+ $coinbaseAccountArray = [];
437
  if (isset($customerAttribs['coinbaseAccounts'])) {
438
  foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
439
+ $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
440
  }
441
  }
442
  $this->_set('coinbaseAccounts', $coinbaseAccountArray);
443
 
444
  // map each paypalAccount into its own object
445
+ $paypalAccountArray = [];
446
  if (isset($customerAttribs['paypalAccounts'])) {
447
  foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
448
+ $paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
449
  }
450
  }
451
  $this->_set('paypalAccounts', $paypalAccountArray);
452
 
453
  // map each applePayCard into its own object
454
+ $applePayCardArray = [];
455
  if (isset($customerAttribs['applePayCards'])) {
456
  foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
457
+ $applePayCardArray[] = ApplePayCard::factory($applePayCard);
458
  }
459
  }
460
  $this->_set('applePayCards', $applePayCardArray);
461
 
462
  // map each androidPayCard into its own object
463
+ $androidPayCardArray = [];
464
  if (isset($customerAttribs['androidPayCards'])) {
465
  foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
466
+ $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
467
  }
468
  }
469
  $this->_set('androidPayCards', $androidPayCardArray);
478
  public function __toString()
479
  {
480
  return __CLASS__ . '[' .
481
+ Util::attributesToString($this->_attributes) .']';
482
  }
483
 
484
  /**
485
+ * returns false if comparing object is not a Customer,
486
+ * or is a Customer with a different id
487
  *
488
  * @param object $otherCust customer to compare against
489
  * @return boolean
490
  */
491
  public function isEqual($otherCust)
492
  {
493
+ return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id;
494
  }
495
 
496
  /**
506
  /**
507
  * returns the customer's default payment method
508
  *
509
+ * @return CreditCard|PayPalAccount|ApplePayCard|AndroidPayCard
510
  */
511
  public function defaultPaymentMethod()
512
  {
513
+ $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\\Customer::_defaultPaymentMethodFilter');
514
  return current($defaultPaymentMethods);
515
  }
516
 
525
  * @access protected
526
  * @var array registry of customer data
527
  */
528
+ protected $_attributes = [
529
  'addresses' => '',
530
  'company' => '',
531
  'creditCards' => '',
538
  'createdAt' => '',
539
  'updatedAt' => '',
540
  'website' => '',
541
+ ];
542
 
543
  /**
544
  * sends the create request to the gateway
597
  /**
598
  * generic method for validating incoming gateway responses
599
  *
600
+ * creates a new Customer object and encapsulates
601
+ * it inside a Result\Successful object, or
602
+ * encapsulates a Errors object inside a Result\Error
603
  * alternatively, throws an Unexpected exception if the response is invalid.
604
  *
605
  * @ignore
606
  * @param array $response gateway response values
607
+ * @return Result\Successful|Result\Error
608
+ * @throws Exception\Unexpected
609
  */
610
  private function _verifyGatewayResponse($response)
611
  {
612
  if (isset($response['customer'])) {
613
+ // return a populated instance of Customer
614
+ return new Result\Successful(
615
+ Customer::factory($response['customer'])
616
  );
617
  } else if (isset($response['apiErrorResponse'])) {
618
+ return new Result\Error($response['apiErrorResponse']);
619
  } else {
620
+ throw new Exception\Unexpected(
621
  "Expected customer or apiErrorResponse"
622
  );
623
  }
624
  }
625
  }
626
+ class_alias('Braintree\CustomerGateway', 'Braintree_CustomerGateway');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/CustomerSearch.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class CustomerSearch
5
+ {
6
+ public static function addressCountryName() { return new TextNode('address_country_name'); }
7
+ public static function addressExtendedAddress() { return new TextNode('address_extended_address'); }
8
+ public static function addressFirstName() { return new TextNode('address_first_name'); }
9
+ public static function addressLastName() { return new TextNode('address_last_name'); }
10
+ public static function addressLocality() { return new TextNode('address_locality'); }
11
+ public static function addressPostalCode() { return new TextNode('address_postal_code'); }
12
+ public static function addressRegion() { return new TextNode('address_region'); }
13
+ public static function addressStreetAddress() { return new TextNode('address_street_address'); }
14
+ public static function cardholderName() { return new TextNode('cardholder_name'); }
15
+ public static function company() { return new TextNode('company'); }
16
+ public static function email() { return new TextNode('email'); }
17
+ public static function fax() { return new TextNode('fax'); }
18
+ public static function firstName() { return new TextNode('first_name'); }
19
+ public static function id() { return new TextNode('id'); }
20
+ public static function lastName() { return new TextNode('last_name'); }
21
+ public static function paymentMethodToken() { return new TextNode('payment_method_token'); }
22
+ public static function paymentMethodTokenWithDuplicates() { return new IsNode('payment_method_token_with_duplicates'); }
23
+ public static function paypalAccountEmail() { return new IsNode('paypal_account_email'); }
24
+ public static function phone() { return new TextNode('phone'); }
25
+ public static function website() { return new TextNode('website'); }
26
+
27
+ public static function creditCardExpirationDate() { return new EqualityNode('credit_card_expiration_date'); }
28
+ public static function creditCardNumber() { return new PartialMatchNode('credit_card_number'); }
29
+
30
+ public static function ids() { return new MultipleValueNode('ids'); }
31
+
32
+ public static function createdAt() { return new RangeNode("created_at"); }
33
+ }
34
+ class_alias('Braintree\CustomerSearch', 'Braintree_CustomerSearch');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Descriptor.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class Descriptor extends Instance
5
+ {
6
+ }
7
+ class_alias('Braintree\Descriptor', 'Braintree_Descriptor');
lib/Gene/Braintree/{Digest.php → braintree/braintree_php/lib/Braintree/Digest.php} RENAMED
@@ -1,11 +1,13 @@
1
  <?php
 
 
2
  /**
3
  * Digest encryption module
4
  * Digest creates an HMAC-SHA1 hash for encrypting messages
5
  *
6
- * @copyright 2014 Braintree, a division of PayPal, Inc.
7
  */
8
- class Braintree_Digest
9
  {
10
  public static function hexDigestSha1($key, $string)
11
  {
@@ -57,3 +59,4 @@ class Braintree_Digest
57
  return sha1($outerPad.pack($pack, sha1($innerPad.$message)));
58
  }
59
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Digest encryption module
6
  * Digest creates an HMAC-SHA1 hash for encrypting messages
7
  *
8
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
9
  */
10
+ class Digest
11
  {
12
  public static function hexDigestSha1($key, $string)
13
  {
59
  return sha1($outerPad.pack($pack, sha1($innerPad.$message)));
60
  }
61
  }
62
+ class_alias('Braintree\Digest', 'Braintree_Digest');
lib/Gene/Braintree/{Disbursement.php → braintree/braintree_php/lib/Braintree/Disbursement.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- final class Braintree_Disbursement extends Braintree_Base
 
 
3
  {
4
  private $_merchantAccount;
5
 
@@ -10,16 +12,16 @@ final class Braintree_Disbursement extends Braintree_Base
10
 
11
  if (isset($disbursementAttribs['merchantAccount'])) {
12
  $this->_set('merchantAccount',
13
- Braintree_MerchantAccount::factory($disbursementAttribs['merchantAccount'])
14
  );
15
  }
16
  }
17
 
18
  public function transactions()
19
  {
20
- $collection = Braintree_Transaction::search(array(
21
- Braintree_TransactionSearch::ids()->in($this->transactionIds)
22
- ));
23
 
24
  return $collection;
25
  }
@@ -33,17 +35,18 @@ final class Braintree_Disbursement extends Braintree_Base
33
 
34
  public function __toString()
35
  {
36
- $display = array(
37
  'id', 'merchantAccountDetails', 'exceptionMessage', 'amount',
38
  'disbursementDate', 'followUpAction', 'retry', 'success',
39
  'transactionIds'
40
- );
41
 
42
- $displayAttributes = array();
43
  foreach ($display AS $attrib) {
44
  $displayAttributes[$attrib] = $this->$attrib;
45
  }
46
  return __CLASS__ . '[' .
47
- Braintree_Util::attributesToString($displayAttributes) .']';
48
  }
49
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class Disbursement extends Base
5
  {
6
  private $_merchantAccount;
7
 
12
 
13
  if (isset($disbursementAttribs['merchantAccount'])) {
14
  $this->_set('merchantAccount',
15
+ MerchantAccount::factory($disbursementAttribs['merchantAccount'])
16
  );
17
  }
18
  }
19
 
20
  public function transactions()
21
  {
22
+ $collection = Transaction::search([
23
+ TransactionSearch::ids()->in($this->transactionIds),
24
+ ]);
25
 
26
  return $collection;
27
  }
35
 
36
  public function __toString()
37
  {
38
+ $display = [
39
  'id', 'merchantAccountDetails', 'exceptionMessage', 'amount',
40
  'disbursementDate', 'followUpAction', 'retry', 'success',
41
  'transactionIds'
42
+ ];
43
 
44
+ $displayAttributes = [];
45
  foreach ($display AS $attrib) {
46
  $displayAttributes[$attrib] = $this->$attrib;
47
  }
48
  return __CLASS__ . '[' .
49
+ Util::attributesToString($displayAttributes) .']';
50
  }
51
  }
52
+ class_alias('Braintree\Disbursement', 'Braintree_Disbursement');
lib/Gene/Braintree/{DisbursementDetails.php → braintree/braintree_php/lib/Braintree/DisbursementDetails.php} RENAMED
@@ -1,11 +1,13 @@
1
  <?php
 
 
2
  /**
3
  * Disbursement details from a transaction
4
  * Creates an instance of DisbursementDetails as returned from a transaction
5
  *
6
  *
7
  * @package Braintree
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  *
10
  * @property-read string $settlementAmount
11
  * @property-read string $settlementCurrencyIsoCode
@@ -13,13 +15,11 @@
13
  * @property-read string $fundsHeld
14
  * @property-read string $success
15
  * @property-read string $disbursementDate
16
- * @uses Braintree_Instance inherits methods
17
  */
18
- class Braintree_DisbursementDetails extends Braintree_Instance
19
  {
20
- protected $_attributes = array();
21
-
22
- function isValid() {
23
  return !is_null($this->disbursementDate);
24
  }
25
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Disbursement details from a transaction
6
  * Creates an instance of DisbursementDetails as returned from a transaction
7
  *
8
  *
9
  * @package Braintree
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
  *
12
  * @property-read string $settlementAmount
13
  * @property-read string $settlementCurrencyIsoCode
15
  * @property-read string $fundsHeld
16
  * @property-read string $success
17
  * @property-read string $disbursementDate
 
18
  */
19
+ class DisbursementDetails extends Instance
20
  {
21
+ public function isValid() {
 
 
22
  return !is_null($this->disbursementDate);
23
  }
24
  }
25
+ class_alias('Braintree\DisbursementDetails', 'Braintree_DisbursementDetails');
lib/Gene/Braintree/{Discount.php → braintree/braintree_php/lib/Braintree/Discount.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- class Braintree_Discount extends Braintree_Modification
 
 
3
  {
4
  public static function factory($attributes)
5
  {
@@ -13,6 +15,7 @@ class Braintree_Discount extends Braintree_Modification
13
 
14
  public static function all()
15
  {
16
- return Braintree_Configuration::gateway()->discount()->all();
17
  }
18
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class Discount extends Modification
5
  {
6
  public static function factory($attributes)
7
  {
15
 
16
  public static function all()
17
  {
18
+ return Configuration::gateway()->discount()->all();
19
  }
20
  }
21
+ class_alias('Braintree\Discount', 'Braintree_Discount');
lib/Gene/Braintree/{DiscountGateway.php → braintree/braintree_php/lib/Braintree/DiscountGateway.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- class Braintree_DiscountGateway
 
 
3
  {
4
  private $_gateway;
5
  private $_config;
@@ -10,7 +12,7 @@ class Braintree_DiscountGateway
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
12
  $this->_config->assertHasAccessTokenOrKeys();
13
- $this->_http = new Braintree_Http($gateway->config);
14
  }
15
 
16
  public function all()
@@ -18,11 +20,12 @@ class Braintree_DiscountGateway
18
  $path = $this->_config->merchantPath() . '/discounts';
19
  $response = $this->_http->get($path);
20
 
21
- $discounts = array("discount" => $response['discounts']);
22
 
23
- return Braintree_Util::extractAttributeAsArray(
24
  $discounts,
25
  'discount'
26
  );
27
  }
28
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class DiscountGateway
5
  {
6
  private $_gateway;
7
  private $_config;
12
  $this->_gateway = $gateway;
13
  $this->_config = $gateway->config;
14
  $this->_config->assertHasAccessTokenOrKeys();
15
+ $this->_http = new Http($gateway->config);
16
  }
17
 
18
  public function all()
20
  $path = $this->_config->merchantPath() . '/discounts';
21
  $response = $this->_http->get($path);
22
 
23
+ $discounts = ["discount" => $response['discounts']];
24
 
25
+ return Util::extractAttributeAsArray(
26
  $discounts,
27
  'discount'
28
  );
29
  }
30
  }
31
+ class_alias('Braintree\DiscountGateway', 'Braintree_DiscountGateway');
lib/Gene/Braintree/{Dispute.php → braintree/braintree_php/lib/Braintree/Dispute.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
 
 
2
  /**
3
  * Creates an instance of Dispute as returned from a transaction
4
  *
5
  *
6
  * @package Braintree
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  *
9
  * @property-read string $amount
10
  * @property-read string $currencyIsoCode
@@ -14,9 +16,9 @@
14
  * @property-read string $disbursementDate
15
  * @property-read object $transactionDetails
16
  */
17
- final class Braintree_Dispute extends Braintree_Base
18
  {
19
- protected $_attributes = array();
20
 
21
  /* Dispute Status */
22
  const OPEN = 'open';
@@ -39,6 +41,10 @@ final class Braintree_Dispute extends Braintree_Base
39
  const TRANSACTION_AMOUNT_DIFFERS = "transaction_amount_differs";
40
  const RETRIEVAL = "retrieval";
41
 
 
 
 
 
42
 
43
  protected function _initialize($disputeAttribs)
44
  {
@@ -46,7 +52,7 @@ final class Braintree_Dispute extends Braintree_Base
46
 
47
  if (isset($disputeAttribs['transaction'])) {
48
  $this->_set('transactionDetails',
49
- new Braintree_Dispute_TransactionDetails($disputeAttribs['transaction'])
50
  );
51
  }
52
  }
@@ -60,16 +66,17 @@ final class Braintree_Dispute extends Braintree_Base
60
 
61
  public function __toString()
62
  {
63
- $display = array(
64
  'amount', 'reason', 'status',
65
  'replyByDate', 'receivedDate', 'currencyIsoCode'
66
- );
67
 
68
- $displayAttributes = array();
69
  foreach ($display AS $attrib) {
70
  $displayAttributes[$attrib] = $this->$attrib;
71
  }
72
  return __CLASS__ . '[' .
73
- Braintree_Util::attributesToString($displayAttributes) .']';
74
  }
75
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Creates an instance of Dispute as returned from a transaction
6
  *
7
  *
8
  * @package Braintree
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  *
11
  * @property-read string $amount
12
  * @property-read string $currencyIsoCode
16
  * @property-read string $disbursementDate
17
  * @property-read object $transactionDetails
18
  */
19
+ class Dispute extends Base
20
  {
21
+ protected $_attributes = [];
22
 
23
  /* Dispute Status */
24
  const OPEN = 'open';
41
  const TRANSACTION_AMOUNT_DIFFERS = "transaction_amount_differs";
42
  const RETRIEVAL = "retrieval";
43
 
44
+ /* Dispute Kind */
45
+ const CHARGEBACK = 'chargeback';
46
+ const PRE_ARBITRATION = 'pre_arbitration';
47
+ // RETRIEVAL for kind already defined under Dispute Reason
48
 
49
  protected function _initialize($disputeAttribs)
50
  {
52
 
53
  if (isset($disputeAttribs['transaction'])) {
54
  $this->_set('transactionDetails',
55
+ new Dispute\TransactionDetails($disputeAttribs['transaction'])
56
  );
57
  }
58
  }
66
 
67
  public function __toString()
68
  {
69
+ $display = [
70
  'amount', 'reason', 'status',
71
  'replyByDate', 'receivedDate', 'currencyIsoCode'
72
+ ];
73
 
74
+ $displayAttributes = [];
75
  foreach ($display AS $attrib) {
76
  $displayAttributes[$attrib] = $this->$attrib;
77
  }
78
  return __CLASS__ . '[' .
79
+ Util::attributesToString($displayAttributes) .']';
80
  }
81
  }
82
+ class_alias('Braintree\Dispute', 'Braintree_Dispute');
lib/Gene/Braintree/{Dispute → braintree/braintree_php/lib/Braintree/Dispute}/TransactionDetails.php RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Transaction details for a dispute
4
  *
@@ -15,8 +19,9 @@
15
  *
16
  * @property-read string $amount
17
  * @property-read string $id
18
- * @uses Braintree_Instance inherits methods
19
  */
20
- class Braintree_Dispute_TransactionDetails extends Braintree_Instance
21
  {
22
  }
 
 
1
  <?php
2
+ namespace Braintree\Dispute;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Transaction details for a dispute
8
  *
19
  *
20
  * @property-read string $amount
21
  * @property-read string $id
 
22
  */
23
+ class TransactionDetails extends Instance
24
  {
25
  }
26
+
27
+ class_alias('Braintree\Dispute\TransactionDetails', 'Braintree_Dispute_TransactionDetails');
lib/Gene/Braintree/{EqualityNode.php → braintree/braintree_php/lib/Braintree/EqualityNode.php} RENAMED
@@ -1,6 +1,7 @@
1
  <?php
 
2
 
3
- class Braintree_EqualityNode extends Braintree_IsNode
4
  {
5
  function isNot($value)
6
  {
@@ -8,3 +9,4 @@ class Braintree_EqualityNode extends Braintree_IsNode
8
  return $this;
9
  }
10
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class EqualityNode extends IsNode
5
  {
6
  function isNot($value)
7
  {
9
  return $this;
10
  }
11
  }
12
+ class_alias('Braintree\EqualityNode', 'Braintree_EqualityNode');
lib/Gene/Braintree/{Error → braintree/braintree_php/lib/Braintree/Error}/Codes.php RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  *
4
  * Validation Error codes and messages
@@ -12,9 +14,9 @@
12
  * @package Braintree
13
  * @subpackage Errors
14
  * @category Validation
15
- * @copyright 2014 Braintree, a division of PayPal, Inc.
16
  */
17
- class Braintree_Error_Codes
18
  {
19
  const ADDRESS_CANNOT_BE_BLANK = '81801';
20
  const ADDRESS_COMPANY_IS_INVALID = '91821';
@@ -83,55 +85,58 @@ class Braintree_Error_Codes
83
  const CLIENT_TOKEN_VERIFY_CARD_REQUIRES_CUSTOMER_ID = '92802';
84
  const CLIENT_TOKEN_MERCHANT_ACCOUNT_DOES_NOT_EXIST = '92807';
85
 
86
- const CREDIT_CARD_BILLING_ADDRESS_CONFLICT = '91701';
87
- const CREDIT_CARD_BILLING_ADDRESS_FORMAT_IS_INVALID = '91744';
88
- const CREDIT_CARD_BILLING_ADDRESS_ID_IS_INVALID = '91702';
89
- const CREDIT_CARD_CANNOT_UPDATE_CARD_USING_PAYMENT_METHOD_NONCE = '91735';
90
- const CREDIT_CARD_CARDHOLDER_NAME_IS_TOO_LONG = '81723';
91
- const CREDIT_CARD_CREDIT_CARD_TYPE_IS_NOT_ACCEPTED = '81703';
92
- const CREDIT_CARD_CREDIT_CARD_TYPE_IS_NOT_ACCEPTED_BY_SUBSCRIPTION_MERCHANT_ACCOUNT = '81718';
93
- const CREDIT_CARD_CUSTOMER_ID_IS_INVALID = '91705';
94
- const CREDIT_CARD_CUSTOMER_ID_IS_REQUIRED = '91704';
95
- const CREDIT_CARD_CVV_IS_INVALID = '81707';
96
- const CREDIT_CARD_CVV_IS_REQUIRED = '81706';
97
- const CREDIT_CARD_CVV_VERIFICATION_FAILED = '81736';
98
- const CREDIT_CARD_DUPLICATE_CARD_EXISTS = '81724';
99
- const CREDIT_CARD_EXPIRATION_DATE_CONFLICT = '91708';
100
- const CREDIT_CARD_EXPIRATION_DATE_IS_INVALID = '81710';
101
- const CREDIT_CARD_EXPIRATION_DATE_IS_REQUIRED = '81709';
102
- const CREDIT_CARD_EXPIRATION_DATE_YEAR_IS_INVALID = '81711';
103
- const CREDIT_CARD_EXPIRATION_MONTH_IS_INVALID = '81712';
104
- const CREDIT_CARD_EXPIRATION_YEAR_IS_INVALID = '81713';
105
- const CREDIT_CARD_INVALID_PARAMS_FOR_CREDIT_CARD_UPDATE = '91745';
106
- const CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE = '91727';
107
- const CREDIT_CARD_NUMBER_INVALID_LENGTH = '81716';
108
- const CREDIT_CARD_NUMBER_IS_INVALID = '81715';
109
- const CREDIT_CARD_NUMBER_IS_REQUIRED = '81714';
110
- const CREDIT_CARD_NUMBER_LENGTH_IS_INVALID = '81716';
111
- const CREDIT_CARD_NUMBER_MUST_BE_TEST_NUMBER = '81717';
112
- const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_IS_INVALID = '91723';
113
- const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_NOT_ALLOWED = '91729';
114
- const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_CANNOT_BE_NEGATIVE = '91739';
115
- const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_FORMAT_IS_INVALID = '91740';
116
- const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = '91741';
117
- const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91728';
118
- const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_IS_FORBIDDEN = '91743';
119
- const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_IS_SUSPENDED = '91742';
120
- const CREDIT_CARD_PAYMENT_METHOD_CONFLICT = '81725';
121
- const CREDIT_CARD_PAYMENT_METHOD_IS_NOT_A_CREDIT_CARD = '91738';
122
- const CREDIT_CARD_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91734';
123
- const CREDIT_CARD_PAYMENT_METHOD_NONCE_CONSUMED = '91731';
124
- const CREDIT_CARD_PAYMENT_METHOD_NONCE_LOCKED = '91733';
125
- const CREDIT_CARD_PAYMENT_METHOD_NONCE_UNKNOWN = '91732';
126
- const CREDIT_CARD_POSTAL_CODE_VERIFICATION_FAILED = '81737';
127
- const CREDIT_CARD_TOKEN_FORMAT_IS_INVALID = '91718';
128
- const CREDIT_CARD_TOKEN_INVALID = '91718';
129
- const CREDIT_CARD_TOKEN_IS_IN_USE = '91719';
130
- const CREDIT_CARD_TOKEN_IS_NOT_ALLOWED = '91721';
131
- const CREDIT_CARD_TOKEN_IS_REQUIRED = '91722';
132
- const CREDIT_CARD_TOKEN_IS_TOO_LONG = '91720';
133
- const CREDIT_CARD_VENMO_SDK_PAYMENT_METHOD_CODE_CARD_TYPE_IS_NOT_ACCEPTED = '91726';
134
- const CREDIT_CARD_VERIFICATION_NOT_SUPPORTED_ON_THIS_MERCHANT_ACCOUNT = '91730';
 
 
 
135
 
136
  const CUSTOMER_COMPANY_IS_TOO_LONG = '81601';
137
  const CUSTOMER_CUSTOM_FIELD_IS_INVALID = '91602';
@@ -185,10 +190,12 @@ class Braintree_Error_Codes
185
  const MERCHANT_COUNTRY_CODE_NUMERIC_IS_NOT_ACCEPTED = '93608';
186
  const MERCHANT_COUNTRY_NAME_IS_INVALID = '93611';
187
  const MERCHANT_COUNTRY_NAME_IS_NOT_ACCEPTED = '93610';
 
188
  const MERCHANT_EMAIL_FORMAT_IS_INVALID = '93602';
189
  const MERCHANT_EMAIL_IS_REQUIRED = '83601';
190
  const MERCHANT_INCONSISTENT_COUNTRY = '93612';
191
  const MERCHANT_ACCOUNT_PAYMENT_METHODS_ARE_INVALID = '93613';
 
192
 
193
  const MERCHANT_ACCOUNT_ID_FORMAT_IS_INVALID = '82603';
194
  const MERCHANT_ACCOUNT_ID_IS_IN_USE = '82604';
@@ -410,6 +417,7 @@ class Braintree_Error_Codes
410
  const TRANSACTION_CANNOT_BE_VOIDED = '91504';
411
  const TRANSACTION_CANNOT_CANCEL_RELEASE = '91562';
412
  const TRANSACTION_CANNOT_CLONE_CREDIT = '91543';
 
413
  const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_PAYPAL_ACCOUNT = '91573';
414
  const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_VAULT_CREDIT_CARD = '91540';
415
  const TRANSACTION_CANNOT_CLONE_UNSUCCESSFUL_TRANSACTION = '91542';
@@ -423,7 +431,9 @@ class Braintree_Error_Codes
423
  const TRANSACTION_CANNOT_REFUND_WITH_SUSPENDED_MERCHANT_ACCOUNT = '91538';
424
  const TRANSACTION_CANNOT_RELEASE_FROM_ESCROW = '91561';
425
  const TRANSACTION_CANNOT_SIMULATE_SETTLEMENT = '91575';
 
426
  const TRANSACTION_CANNOT_SUBMIT_FOR_SETTLEMENT = '91507';
 
427
  const TRANSACTION_CHANNEL_IS_TOO_LONG = '91550';
428
  const TRANSACTION_CREDIT_CARD_IS_REQUIRED = '91508';
429
  const TRANSACTION_CUSTOMER_DEFAULT_PAYMENT_METHOD_CARD_TYPE_IS_NOT_ACCEPTED = '81509';
@@ -445,6 +455,7 @@ class Braintree_Error_Codes
445
  const TRANSACTION_OPTIONS_VAULT_IS_DISABLED = '91525';
446
  const TRANSACTION_ORDER_ID_IS_TOO_LONG = '91501';
447
  const TRANSACTION_PAYMENT_INSTRUMENT_NOT_SUPPORTED_BY_MERCHANT_ACCOUNT = '91577';
 
448
  const TRANSACTION_PAYMENT_METHOD_CONFLICT = '91515';
449
  const TRANSACTION_PAYMENT_METHOD_CONFLICT_WITH_VENMO_SDK = '91549';
450
  const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_CUSTOMER = '91516';
@@ -461,7 +472,12 @@ class Braintree_Error_Codes
461
  const TRANSACTION_PAY_PAL_VAULT_RECORD_MISSING_DATA = '91583';
462
  const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_CANNOT_BE_SET = '91519';
463
  const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_IS_INVALID = '81520';
 
464
  const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_CREDITS = '91546';
 
 
 
 
465
  const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_VOICE_AUTHORIZATIONS = '91545';
466
  const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_INVALID = '91548';
467
  const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_TOO_LONG = '91537';
@@ -483,10 +499,25 @@ class Braintree_Error_Codes
483
  const TRANSACTION_TAX_AMOUNT_FORMAT_IS_INVALID = '81535';
484
  const TRANSACTION_TAX_AMOUNT_IS_TOO_LARGE = '81536';
485
 
486
- const TRANSACTION_THREE_D_SECURE_AUTHENTICATION_FAILED = '81571';
487
- const TRANSACTION_THREE_D_SECURE_TOKEN_IS_INVALID = '91568';
488
- const TRANSACTION_THREE_D_SECURE_TRANSACTION_DATA_DOESNT_MATCH_VERIFY = '91570';
489
- const TRANSACTION_TYPE_IS_INVALID = '91523';
490
- const TRANSACTION_TYPE_IS_REQUIRED = '91524';
491
- const TRANSACTION_UNSUPPORTED_VOICE_AUTHORIZATION = '91539';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
492
  }
 
1
  <?php
2
+ namespace Braintree\Error;
3
+
4
  /**
5
  *
6
  * Validation Error codes and messages
14
  * @package Braintree
15
  * @subpackage Errors
16
  * @category Validation
17
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
18
  */
19
+ class Codes
20
  {
21
  const ADDRESS_CANNOT_BE_BLANK = '81801';
22
  const ADDRESS_COMPANY_IS_INVALID = '91821';
85
  const CLIENT_TOKEN_VERIFY_CARD_REQUIRES_CUSTOMER_ID = '92802';
86
  const CLIENT_TOKEN_MERCHANT_ACCOUNT_DOES_NOT_EXIST = '92807';
87
 
88
+ const CREDIT_CARD_BILLING_ADDRESS_CONFLICT = '91701';
89
+ const CREDIT_CARD_BILLING_ADDRESS_FORMAT_IS_INVALID = '91744';
90
+ const CREDIT_CARD_BILLING_ADDRESS_ID_IS_INVALID = '91702';
91
+ const CREDIT_CARD_CANNOT_UPDATE_CARD_USING_PAYMENT_METHOD_NONCE = '91735';
92
+ const CREDIT_CARD_CARDHOLDER_NAME_IS_TOO_LONG = '81723';
93
+ const CREDIT_CARD_CREDIT_CARD_TYPE_IS_NOT_ACCEPTED = '81703';
94
+ const CREDIT_CARD_CREDIT_CARD_TYPE_IS_NOT_ACCEPTED_BY_SUBSCRIPTION_MERCHANT_ACCOUNT = '81718';
95
+ const CREDIT_CARD_CUSTOMER_ID_IS_INVALID = '91705';
96
+ const CREDIT_CARD_CUSTOMER_ID_IS_REQUIRED = '91704';
97
+ const CREDIT_CARD_CVV_IS_INVALID = '81707';
98
+ const CREDIT_CARD_CVV_IS_REQUIRED = '81706';
99
+ const CREDIT_CARD_CVV_VERIFICATION_FAILED = '81736';
100
+ const CREDIT_CARD_DUPLICATE_CARD_EXISTS = '81724';
101
+ const CREDIT_CARD_EXPIRATION_DATE_CONFLICT = '91708';
102
+ const CREDIT_CARD_EXPIRATION_DATE_IS_INVALID = '81710';
103
+ const CREDIT_CARD_EXPIRATION_DATE_IS_REQUIRED = '81709';
104
+ const CREDIT_CARD_EXPIRATION_DATE_YEAR_IS_INVALID = '81711';
105
+ const CREDIT_CARD_EXPIRATION_MONTH_IS_INVALID = '81712';
106
+ const CREDIT_CARD_EXPIRATION_YEAR_IS_INVALID = '81713';
107
+ const CREDIT_CARD_INVALID_PARAMS_FOR_CREDIT_CARD_UPDATE = '91745';
108
+ const CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE = '91727';
109
+ const CREDIT_CARD_NUMBER_INVALID_LENGTH = '81716';
110
+ const CREDIT_CARD_NUMBER_IS_INVALID = '81715';
111
+ const CREDIT_CARD_NUMBER_IS_PROHIBITED = '81750';
112
+ const CREDIT_CARD_NUMBER_IS_REQUIRED = '81714';
113
+ const CREDIT_CARD_NUMBER_LENGTH_IS_INVALID = '81716';
114
+ const CREDIT_CARD_NUMBER_MUST_BE_TEST_NUMBER = '81717';
115
+ const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_IS_INVALID = '91723';
116
+ const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_NOT_ALLOWED = '91729';
117
+ const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_CANNOT_BE_NEGATIVE = '91739';
118
+ const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_FORMAT_IS_INVALID = '91740';
119
+ const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_IS_TOO_LARGE = '91752';
120
+ const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = '91741';
121
+ const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91728';
122
+ const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_IS_FORBIDDEN = '91743';
123
+ const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_IS_SUSPENDED = '91742';
124
+ const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_CANNOT_BE_SUB_MERCHANT_ACCOUNT = '91755';
125
+ const CREDIT_CARD_PAYMENT_METHOD_CONFLICT = '81725';
126
+ const CREDIT_CARD_PAYMENT_METHOD_IS_NOT_A_CREDIT_CARD = '91738';
127
+ const CREDIT_CARD_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91734';
128
+ const CREDIT_CARD_PAYMENT_METHOD_NONCE_CONSUMED = '91731';
129
+ const CREDIT_CARD_PAYMENT_METHOD_NONCE_LOCKED = '91733';
130
+ const CREDIT_CARD_PAYMENT_METHOD_NONCE_UNKNOWN = '91732';
131
+ const CREDIT_CARD_POSTAL_CODE_VERIFICATION_FAILED = '81737';
132
+ const CREDIT_CARD_TOKEN_FORMAT_IS_INVALID = '91718';
133
+ const CREDIT_CARD_TOKEN_INVALID = '91718';
134
+ const CREDIT_CARD_TOKEN_IS_IN_USE = '91719';
135
+ const CREDIT_CARD_TOKEN_IS_NOT_ALLOWED = '91721';
136
+ const CREDIT_CARD_TOKEN_IS_REQUIRED = '91722';
137
+ const CREDIT_CARD_TOKEN_IS_TOO_LONG = '91720';
138
+ const CREDIT_CARD_VENMO_SDK_PAYMENT_METHOD_CODE_CARD_TYPE_IS_NOT_ACCEPTED = '91726';
139
+ const CREDIT_CARD_VERIFICATION_NOT_SUPPORTED_ON_THIS_MERCHANT_ACCOUNT = '91730';
140
 
141
  const CUSTOMER_COMPANY_IS_TOO_LONG = '81601';
142
  const CUSTOMER_CUSTOM_FIELD_IS_INVALID = '91602';
190
  const MERCHANT_COUNTRY_CODE_NUMERIC_IS_NOT_ACCEPTED = '93608';
191
  const MERCHANT_COUNTRY_NAME_IS_INVALID = '93611';
192
  const MERCHANT_COUNTRY_NAME_IS_NOT_ACCEPTED = '93610';
193
+ const MERCHANT_CURRENCIES_ARE_INVALID = '93614';
194
  const MERCHANT_EMAIL_FORMAT_IS_INVALID = '93602';
195
  const MERCHANT_EMAIL_IS_REQUIRED = '83601';
196
  const MERCHANT_INCONSISTENT_COUNTRY = '93612';
197
  const MERCHANT_ACCOUNT_PAYMENT_METHODS_ARE_INVALID = '93613';
198
+ const MERCHANT_PAYMENT_METHODS_ARE_NOT_ALLOWED = '93615';
199
 
200
  const MERCHANT_ACCOUNT_ID_FORMAT_IS_INVALID = '82603';
201
  const MERCHANT_ACCOUNT_ID_IS_IN_USE = '82604';
417
  const TRANSACTION_CANNOT_BE_VOIDED = '91504';
418
  const TRANSACTION_CANNOT_CANCEL_RELEASE = '91562';
419
  const TRANSACTION_CANNOT_CLONE_CREDIT = '91543';
420
+ const TRANSACTION_CANNOT_CLONE_MARKETPLACE_TRANSACTION = '915137';
421
  const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_PAYPAL_ACCOUNT = '91573';
422
  const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_VAULT_CREDIT_CARD = '91540';
423
  const TRANSACTION_CANNOT_CLONE_UNSUCCESSFUL_TRANSACTION = '91542';
431
  const TRANSACTION_CANNOT_REFUND_WITH_SUSPENDED_MERCHANT_ACCOUNT = '91538';
432
  const TRANSACTION_CANNOT_RELEASE_FROM_ESCROW = '91561';
433
  const TRANSACTION_CANNOT_SIMULATE_SETTLEMENT = '91575';
434
+ const TRANSACTION_CANNOT_SUBMIT_FOR_PARTIAL_SETTLEMENT = '915103';
435
  const TRANSACTION_CANNOT_SUBMIT_FOR_SETTLEMENT = '91507';
436
+ const TRANSACTION_CANNOT_UPDATE_DETAILS_NOT_SUBMITTED_FOR_SETTLEMENT = '915129';
437
  const TRANSACTION_CHANNEL_IS_TOO_LONG = '91550';
438
  const TRANSACTION_CREDIT_CARD_IS_REQUIRED = '91508';
439
  const TRANSACTION_CUSTOMER_DEFAULT_PAYMENT_METHOD_CARD_TYPE_IS_NOT_ACCEPTED = '81509';
455
  const TRANSACTION_OPTIONS_VAULT_IS_DISABLED = '91525';
456
  const TRANSACTION_ORDER_ID_IS_TOO_LONG = '91501';
457
  const TRANSACTION_PAYMENT_INSTRUMENT_NOT_SUPPORTED_BY_MERCHANT_ACCOUNT = '91577';
458
+ const TRANSACTION_PAYMENT_INSTRUMENT_TYPE_IS_NOT_ACCEPTED = '915101';
459
  const TRANSACTION_PAYMENT_METHOD_CONFLICT = '91515';
460
  const TRANSACTION_PAYMENT_METHOD_CONFLICT_WITH_VENMO_SDK = '91549';
461
  const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_CUSTOMER = '91516';
472
  const TRANSACTION_PAY_PAL_VAULT_RECORD_MISSING_DATA = '91583';
473
  const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_CANNOT_BE_SET = '91519';
474
  const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_IS_INVALID = '81520';
475
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_AUTHS = '915104';
476
  const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_CREDITS = '91546';
477
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_PARTIAL_SETTLEMENT = '915102';
478
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_ORDER_ID = '915107';
479
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_DESCRIPTOR = '915108';
480
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_DETAILS = '915130';
481
  const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_VOICE_AUTHORIZATIONS = '91545';
482
  const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_INVALID = '91548';
483
  const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_TOO_LONG = '91537';
499
  const TRANSACTION_TAX_AMOUNT_FORMAT_IS_INVALID = '81535';
500
  const TRANSACTION_TAX_AMOUNT_IS_TOO_LARGE = '81536';
501
 
502
+ const TRANSACTION_THREE_D_SECURE_AUTHENTICATION_FAILED = '81571';
503
+ const TRANSACTION_THREE_D_SECURE_TOKEN_IS_INVALID = '91568';
504
+ const TRANSACTION_THREE_D_SECURE_TRANSACTION_DATA_DOESNT_MATCH_VERIFY = '91570';
505
+ const TRANSACTION_THREE_D_SECURE_ECI_FLAG_IS_REQUIRED = '915113';
506
+ const TRANSACTION_THREE_D_SECURE_CAVV_IS_REQUIRED = '915116';
507
+ const TRANSACTION_THREE_D_SECURE_XID_IS_REQUIRED = '915115';
508
+ const TRANSACTION_THREE_D_SECURE_ECI_FLAG_IS_INVALID = '915114';
509
+ const TRANSACTION_THREE_D_SECURE_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_CARD_TYPE = '915131';
510
+ const TRANSACTION_TYPE_IS_INVALID = '91523';
511
+ const TRANSACTION_TYPE_IS_REQUIRED = '91524';
512
+ const TRANSACTION_UNSUPPORTED_VOICE_AUTHORIZATION = '91539';
513
+
514
+ const VERIFICATION_OPTIONS_AMOUNT_CANNOT_BE_NEGATIVE = '94201';
515
+ const VERIFICATION_OPTIONS_AMOUNT_FORMAT_IS_INVALID = '94202';
516
+ const VERIFICATION_OPTIONS_AMOUNT_IS_TOO_LARGE = '94207';
517
+ const VERIFICATION_OPTIONS_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = '94203';
518
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_ID_IS_INVALID = '94204';
519
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_IS_SUSPENDED = '94205';
520
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_IS_FORBIDDEN = '94206';
521
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_CANNOT_BE_SUB_MERCHANT_ACCOUNT = '94208';
522
  }
523
+ class_alias('Braintree\Error\Codes', 'Braintree_Error_Codes');
lib/Gene/Braintree/{Error → braintree/braintree_php/lib/Braintree/Error}/ErrorCollection.php RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  *
4
  * Error handler
@@ -9,20 +13,30 @@
9
  * @package Braintree
10
  * @subpackage Errors
11
  * @category Errors
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read object $errors
15
  */
16
- class Braintree_Error_ErrorCollection
17
  {
18
  private $_errors;
19
 
20
  public function __construct($errorData)
21
  {
22
  $this->_errors =
23
- new Braintree_Error_ValidationErrorCollection($errorData);
24
  }
25
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  /**
28
  * Returns all of the validation errors at all levels of nesting in a single, flat array.
@@ -68,10 +82,10 @@ class Braintree_Error_ErrorCollection
68
  $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
69
  $errors = $this;
70
  foreach(array_slice($pieces, 0, -1) as $key) {
71
- $errors = $errors->forKey(Braintree_Util::delimiterToCamelCase($key));
72
- if (!isset($errors)) { return array(); }
73
  }
74
- $finalKey = Braintree_Util::delimiterToCamelCase(end($pieces));
75
  return $errors->onAttribute($finalKey);
76
  }
77
 
@@ -79,7 +93,7 @@ class Braintree_Error_ErrorCollection
79
  * Returns the errors at the given nesting level (see forKey) in a single, flat array:
80
  *
81
  * <code>
82
- * $result = Braintree_Customer::create(...);
83
  * $customerErrors = $result->errors->forKey('customer')->shallowAll();
84
  * </code>
85
  */
@@ -107,3 +121,4 @@ class Braintree_Error_ErrorCollection
107
  return sprintf('%s', $this->_errors);
108
  }
109
  }
 
1
  <?php
2
+ namespace Braintree\Error;
3
+
4
+ use Braintree\Util;
5
+
6
  /**
7
  *
8
  * Error handler
13
  * @package Braintree
14
  * @subpackage Errors
15
  * @category Errors
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
  *
18
  * @property-read object $errors
19
  */
20
+ class ErrorCollection implements \Countable
21
  {
22
  private $_errors;
23
 
24
  public function __construct($errorData)
25
  {
26
  $this->_errors =
27
+ new ValidationErrorCollection($errorData);
28
  }
29
 
30
+ /**
31
+ * Return count of items in collection
32
+ * Implements countable
33
+ *
34
+ * @return integer
35
+ */
36
+ public function count()
37
+ {
38
+ return $this->deepSize();
39
+ }
40
 
41
  /**
42
  * Returns all of the validation errors at all levels of nesting in a single, flat array.
82
  $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
83
  $errors = $this;
84
  foreach(array_slice($pieces, 0, -1) as $key) {
85
+ $errors = $errors->forKey(Util::delimiterToCamelCase($key));
86
+ if (!isset($errors)) { return []; }
87
  }
88
+ $finalKey = Util::delimiterToCamelCase(end($pieces));
89
  return $errors->onAttribute($finalKey);
90
  }
91
 
93
  * Returns the errors at the given nesting level (see forKey) in a single, flat array:
94
  *
95
  * <code>
96
+ * $result = Customer::create(...);
97
  * $customerErrors = $result->errors->forKey('customer')->shallowAll();
98
  * </code>
99
  */
121
  return sprintf('%s', $this->_errors);
122
  }
123
  }
124
+ class_alias('Braintree\Error\ErrorCollection', 'Braintree_Error_ErrorCollection');
lib/Gene/Braintree/{Error → braintree/braintree_php/lib/Braintree/Error}/Validation.php RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * error object returned as part of a validation error collection
4
  * provides read-only access to $attribute, $code, and $message
@@ -9,17 +13,17 @@
9
  *
10
  * @package Braintree
11
  * @subpackage Error
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $attribute
15
  * @property-read string $code
16
  * @property-read string $message
17
  */
18
- class Braintree_Error_Validation
19
  {
20
- private $_attribute;
21
- private $_code;
22
- private $_message;
23
 
24
  /**
25
  * @ignore
@@ -34,13 +38,13 @@ class Braintree_Error_Validation
34
  * @ignore
35
  * @access protected
36
  * @param array $attributes array of properties to set - single level
37
- * @return none
38
  */
39
  private function _initializeFromArray($attributes)
40
  {
41
  foreach($attributes AS $name => $value) {
42
  $varName = "_$name";
43
- $this->$varName = Braintree_Util::delimiterToCamelCase($value, '_');
44
  }
45
  }
46
 
@@ -54,3 +58,4 @@ class Braintree_Error_Validation
54
  return isset($this->$varName) ? $this->$varName : null;
55
  }
56
  }
 
1
  <?php
2
+ namespace Braintree\Error;
3
+
4
+ use Braintree\Util;
5
+
6
  /**
7
  * error object returned as part of a validation error collection
8
  * provides read-only access to $attribute, $code, and $message
13
  *
14
  * @package Braintree
15
  * @subpackage Error
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
  *
18
  * @property-read string $attribute
19
  * @property-read string $code
20
  * @property-read string $message
21
  */
22
+ class Validation
23
  {
24
+ private $_attribute;
25
+ private $_code;
26
+ private $_message;
27
 
28
  /**
29
  * @ignore
38
  * @ignore
39
  * @access protected
40
  * @param array $attributes array of properties to set - single level
41
+ * @return void
42
  */
43
  private function _initializeFromArray($attributes)
44
  {
45
  foreach($attributes AS $name => $value) {
46
  $varName = "_$name";
47
+ $this->$varName = Util::delimiterToCamelCase($value, '_');
48
  }
49
  }
50
 
58
  return isset($this->$varName) ? $this->$varName : null;
59
  }
60
  }
61
+ class_alias('Braintree\Error\Validation', 'Braintree_Error_Validation');
lib/Gene/Braintree/{Error → braintree/braintree_php/lib/Braintree/Error}/ValidationErrorCollection.php RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * collection of errors enumerating all validation errors for a given request
4
  *
@@ -8,15 +12,15 @@
8
  *
9
  * @package Braintree
10
  * @subpackage Error
11
- * @copyright 2014 Braintree, a division of PayPal, Inc.
12
  *
13
  * @property-read array $errors
14
  * @property-read array $nested
15
  */
16
- class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
17
  {
18
- private $_errors = array();
19
- private $_nested = array();
20
 
21
  /**
22
  * @ignore
@@ -27,17 +31,17 @@ class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
27
  // map errors to new collections recursively
28
  if ($key == 'errors') {
29
  foreach ($errorData AS $error) {
30
- $this->_errors[] = new Braintree_Error_Validation($error);
31
  }
32
  } else {
33
- $this->_nested[$key] = new Braintree_Error_ValidationErrorCollection($errorData);
34
  }
35
 
36
  }
37
 
38
  public function deepAll()
39
  {
40
- $validationErrors = array_merge(array(), $this->_errors);
41
  foreach($this->_nested as $nestedErrors)
42
  {
43
  $validationErrors = array_merge($validationErrors, $nestedErrors->deepAll());
@@ -67,7 +71,7 @@ class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
67
 
68
  public function onAttribute($attribute)
69
  {
70
- $matches = array();
71
  foreach ($this->_errors AS $key => $error) {
72
  if($error->attribute == $attribute) {
73
  $matches[] = $error;
@@ -97,7 +101,7 @@ class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
97
  */
98
  public function __toString()
99
  {
100
- $output = array();
101
 
102
  // TODO: implement scope
103
  if (!empty($this->_errors)) {
@@ -125,3 +129,4 @@ class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
125
  return $eOutput;
126
  }
127
  }
 
1
  <?php
2
+ namespace Braintree\Error;
3
+
4
+ use Braintree\Collection;
5
+
6
  /**
7
  * collection of errors enumerating all validation errors for a given request
8
  *
12
  *
13
  * @package Braintree
14
  * @subpackage Error
15
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
16
  *
17
  * @property-read array $errors
18
  * @property-read array $nested
19
  */
20
+ class ValidationErrorCollection extends Collection
21
  {
22
+ private $_errors = [];
23
+ private $_nested = [];
24
 
25
  /**
26
  * @ignore
31
  // map errors to new collections recursively
32
  if ($key == 'errors') {
33
  foreach ($errorData AS $error) {
34
+ $this->_errors[] = new Validation($error);
35
  }
36
  } else {
37
+ $this->_nested[$key] = new ValidationErrorCollection($errorData);
38
  }
39
 
40
  }
41
 
42
  public function deepAll()
43
  {
44
+ $validationErrors = array_merge([], $this->_errors);
45
  foreach($this->_nested as $nestedErrors)
46
  {
47
  $validationErrors = array_merge($validationErrors, $nestedErrors->deepAll());
71
 
72
  public function onAttribute($attribute)
73
  {
74
+ $matches = [];
75
  foreach ($this->_errors AS $key => $error) {
76
  if($error->attribute == $attribute) {
77
  $matches[] = $error;
101
  */
102
  public function __toString()
103
  {
104
+ $output = [];
105
 
106
  // TODO: implement scope
107
  if (!empty($this->_errors)) {
129
  return $eOutput;
130
  }
131
  }
132
+ class_alias('Braintree\Error\ValidationErrorCollection', 'Braintree_Error_ValidationErrorCollection');
lib/Gene/Braintree/{EuropeBankAccount.php → braintree/braintree_php/lib/Braintree/EuropeBankAccount.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Braintree EuropeBankAccount module
4
  * Creates and manages Braintree Europe Bank Accounts
@@ -9,17 +11,18 @@
9
  *
10
  * @package Braintree
11
  * @category Resources
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
- * @property-read string $token
15
- * @property-read string $default
16
- * @property-read string $masked-iban
17
- * @property-read string $bic
18
- * @property-read string $mandate-reference-number
19
  * @property-read string $account-holder-name
 
 
 
20
  * @property-read string $image-url
 
 
 
21
  */
22
- class Braintree_EuropeBankAccount extends Braintree_Base
23
  {
24
 
25
  /* instance methods */
@@ -34,16 +37,16 @@ class Braintree_EuropeBankAccount extends Braintree_Base
34
  }
35
 
36
  /**
37
- * factory method: returns an instance of Braintree_EuropeBankAccount
38
  * to the requesting method, with populated properties
39
  *
40
  * @ignore
41
- * @return object instance of Braintree_EuropeBankAccount
42
  */
43
  public static function factory($attributes)
44
  {
45
- $defaultAttributes = array(
46
- );
47
 
48
  $instance = new self();
49
  $instance->_initialize(array_merge($defaultAttributes, $attributes));
@@ -55,10 +58,11 @@ class Braintree_EuropeBankAccount extends Braintree_Base
55
  *
56
  * @access protected
57
  * @param array $europeBankAccountAttribs array of EuropeBankAccount properties
58
- * @return none
59
  */
60
  protected function _initialize($europeBankAccountAttribs)
61
  {
62
  $this->_attributes = $europeBankAccountAttribs;
63
  }
64
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree EuropeBankAccount module
6
  * Creates and manages Braintree Europe Bank Accounts
11
  *
12
  * @package Braintree
13
  * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  *
 
 
 
 
 
16
  * @property-read string $account-holder-name
17
+ * @property-read string $bic
18
+ * @property-read string $customerId
19
+ * @property-read string $default
20
  * @property-read string $image-url
21
+ * @property-read string $mandate-reference-number
22
+ * @property-read string $masked-iban
23
+ * @property-read string $token
24
  */
25
+ class EuropeBankAccount extends Base
26
  {
27
 
28
  /* instance methods */
37
  }
38
 
39
  /**
40
+ * factory method: returns an instance of EuropeBankAccount
41
  * to the requesting method, with populated properties
42
  *
43
  * @ignore
44
+ * @return EuropeBankAccount
45
  */
46
  public static function factory($attributes)
47
  {
48
+ $defaultAttributes = [
49
+ ];
50
 
51
  $instance = new self();
52
  $instance->_initialize(array_merge($defaultAttributes, $attributes));
58
  *
59
  * @access protected
60
  * @param array $europeBankAccountAttribs array of EuropeBankAccount properties
61
+ * @return void
62
  */
63
  protected function _initialize($europeBankAccountAttribs)
64
  {
65
  $this->_attributes = $europeBankAccountAttribs;
66
  }
67
  }
68
+ class_alias('Braintree\EuropeBankAccount', 'Braintree_EuropeBankAccount');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * super class for all Braintree exceptions
6
+ *
7
+ * @package Braintree
8
+ * @subpackage Exception
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+ class Exception extends \Exception
12
+ {
13
+ }
14
+ class_alias('Braintree\Exception', 'Braintree_Exception');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/Authentication.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when authentication fails.
8
+ * This may be caused by an incorrect Configuration
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Exception
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+ class Authentication extends Exception
15
+ {
16
+
17
+ }
18
+ class_alias('Braintree\Exception\Authentication', 'Braintree_Exception_Authentication');
lib/Gene/Braintree/{Exception → braintree/braintree_php/lib/Braintree/Exception}/Authorization.php RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Raised when authorization fails
4
  * Raised when the API key being used is not authorized to perform
@@ -7,9 +11,10 @@
7
  *
8
  * @package Braintree
9
  * @subpackage Exception
10
- * @copyright 2014 Braintree, a division of PayPal, Inc.
11
  */
12
- class Braintree_Exception_Authorization extends Braintree_Exception
13
  {
14
 
15
  }
 
1
  <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
  /**
7
  * Raised when authorization fails
8
  * Raised when the API key being used is not authorized to perform
11
  *
12
  * @package Braintree
13
  * @subpackage Exception
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  */
16
+ class Authorization extends Exception
17
  {
18
 
19
  }
20
+ class_alias('Braintree\Exception\Authorization', 'Braintree_Exception_Authorization');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/Configuration.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the Braintree library is not completely configured.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @see Configuration
12
+ */
13
+ class Configuration extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\Configuration', 'Braintree_Exception_Configuration');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/DownForMaintenance.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the gateway is down for maintenance.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class DownForMaintenance extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\DownForMaintenance', 'Braintree_Exception_DownForMaintenance');
lib/Gene/Braintree/{Exception → braintree/braintree_php/lib/Braintree/Exception}/ForgedQueryString.php RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Raised when a suspected forged query string is present
4
  * Raised from methods that confirm transparent redirect requests
@@ -8,9 +12,10 @@
8
  *
9
  * @package Braintree
10
  * @subpackage Exception
11
- * @copyright 2014 Braintree, a division of PayPal, Inc.
12
  */
13
- class Braintree_Exception_ForgedQueryString extends Braintree_Exception
14
  {
15
 
16
  }
 
1
  <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
  /**
7
  * Raised when a suspected forged query string is present
8
  * Raised from methods that confirm transparent redirect requests
12
  *
13
  * @package Braintree
14
  * @subpackage Exception
15
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
16
  */
17
+ class ForgedQueryString extends Exception
18
  {
19
 
20
  }
21
+ class_alias('Braintree\Exception\ForgedQueryString', 'Braintree_Exception_ForgedQueryString');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/InvalidChallenge.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ class InvalidChallenge extends Exception
7
+ {
8
+ }
9
+ class_alias('Braintree\Exception\InvalidChallenge', 'Braintree_Exception_InvalidChallenge');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/InvalidSignature.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ class InvalidSignature extends Exception
7
+ {
8
+ }
9
+ class_alias('Braintree\Exception\InvalidSignature', 'Braintree_Exception_InvalidSignature');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/NotFound.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a record could not be found.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class NotFound extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\NotFound', 'Braintree_Exception_NotFound');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/SSLCaFileNotFound.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the SSL CaFile is not found.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class SSLCaFileNotFound extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\SSLCaFileNotFound', 'Braintree_Exception_SSLCaFileNotFound');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/SSLCertificate.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the SSL certificate fails verification.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class SSLCertificate extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\SSLCertificate', 'Braintree_Exception_SSLCertificate');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/ServerError.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when an unexpected server error occurs.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class ServerError extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\ServerError', 'Braintree_Exception_ServerError');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/TestOperationPerformedInProduction.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a test method is used in production.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class TestOperationPerformedInProduction extends Exception
14
+ {
15
+ }
16
+ class_alias('Braintree\Exception\TestOperationPerformedInProduction', 'Braintree_Exception_TestOperationPerformedInProduction');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/Timeout.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a Timeout occurs
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2016 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class Timeout extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\Timeout', 'Braintree_Exception_Timeout');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/TooManyRequests.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the gateway request rate-limit is exceeded.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class TooManyRequests extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\TooManyRequests', 'Braintree_Exception_TooManyRequests');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/Unexpected.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when an error occurs that the client library is not built to handle.
8
+ * This shouldn't happen.
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Exception
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+ class Unexpected extends Exception
15
+ {
16
+
17
+ }
18
+ class_alias('Braintree\Exception\Unexpected', 'Braintree_Exception_Unexpected');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/UpgradeRequired.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a client library must be upgraded.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class UpgradeRequired extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\UpgradeRequired', 'Braintree_Exception_UpgradeRequired');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Exception/ValidationsFailed.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised from non-validating methods when gateway validations fail.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class ValidationsFailed extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\ValidationsFailed', 'Braintree_Exception_ValidationsFailed');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/FacilitatorDetails.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class FacilitatorDetails extends Base
5
+ {
6
+ public static function factory($attributes)
7
+ {
8
+ $instance = new self();
9
+ $instance->_initialize($attributes);
10
+
11
+ return $instance;
12
+ }
13
+
14
+ protected function _initialize($attributes)
15
+ {
16
+ $this->_attributes = $attributes;
17
+ }
18
+
19
+ /**
20
+ * returns a string representation of the three d secure info
21
+ * @return string
22
+ */
23
+ public function __toString()
24
+ {
25
+ return __CLASS__ . '[' .
26
+ Util::attributesToString($this->_attributes) .']';
27
+ }
28
+
29
+ }
30
+ class_alias('Braintree\FacilitatorDetails', 'Braintree_FacilitatorDetails');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Gateway.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Gateway module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+ class Gateway
12
+ {
13
+ /**
14
+ *
15
+ * @var Configuration
16
+ */
17
+ public $config;
18
+
19
+ public function __construct($config)
20
+ {
21
+ if (is_array($config)) {
22
+ $config = new Configuration($config);
23
+ }
24
+ $this->config = $config;
25
+ }
26
+
27
+ /**
28
+ *
29
+ * @return AddOnGateway
30
+ */
31
+ public function addOn()
32
+ {
33
+ return new AddOnGateway($this);
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @return AddressGateway
39
+ */
40
+ public function address()
41
+ {
42
+ return new AddressGateway($this);
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @return ClientTokenGateway
48
+ */
49
+ public function clientToken()
50
+ {
51
+ return new ClientTokenGateway($this);
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @return CreditCardGateway
57
+ */
58
+ public function creditCard()
59
+ {
60
+ return new CreditCardGateway($this);
61
+ }
62
+
63
+ /**
64
+ *
65
+ * @return CreditCardVerificationGateway
66
+ */
67
+ public function creditCardVerification()
68
+ {
69
+ return new CreditCardVerificationGateway($this);
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @return CustomerGateway
75
+ */
76
+ public function customer()
77
+ {
78
+ return new CustomerGateway($this);
79
+ }
80
+
81
+ /**
82
+ *
83
+ * @return DiscountGateway
84
+ */
85
+ public function discount()
86
+ {
87
+ return new DiscountGateway($this);
88
+ }
89
+
90
+ /**
91
+ *
92
+ * @return MerchantGateway
93
+ */
94
+ public function merchant()
95
+ {
96
+ return new MerchantGateway($this);
97
+ }
98
+
99
+ /**
100
+ *
101
+ * @return MerchantAccountGateway
102
+ */
103
+ public function merchantAccount()
104
+ {
105
+ return new MerchantAccountGateway($this);
106
+ }
107
+
108
+ /**
109
+ *
110
+ * @return OAuthGateway
111
+ */
112
+ public function oauth()
113
+ {
114
+ return new OAuthGateway($this);
115
+ }
116
+
117
+ /**
118
+ *
119
+ * @return PaymentMethodGateway
120
+ */
121
+ public function paymentMethod()
122
+ {
123
+ return new PaymentMethodGateway($this);
124
+ }
125
+
126
+ /**
127
+ *
128
+ * @return PaymentMethodNonceGateway
129
+ */
130
+ public function paymentMethodNonce()
131
+ {
132
+ return new PaymentMethodNonceGateway($this);
133
+ }
134
+
135
+ /**
136
+ *
137
+ * @return PayPalAccountGateway
138
+ */
139
+ public function payPalAccount()
140
+ {
141
+ return new PayPalAccountGateway($this);
142
+ }
143
+
144
+ /**
145
+ *
146
+ * @return PlanGateway
147
+ */
148
+ public function plan()
149
+ {
150
+ return new PlanGateway($this);
151
+ }
152
+
153
+ /**
154
+ *
155
+ * @return SettlementBatchSummaryGateway
156
+ */
157
+ public function settlementBatchSummary()
158
+ {
159
+ return new SettlementBatchSummaryGateway($this);
160
+ }
161
+
162
+ /**
163
+ *
164
+ * @return SubscriptionGateway
165
+ */
166
+ public function subscription()
167
+ {
168
+ return new SubscriptionGateway($this);
169
+ }
170
+
171
+ /**
172
+ *
173
+ * @return TestingGateway
174
+ */
175
+ public function testing()
176
+ {
177
+ return new TestingGateway($this);
178
+ }
179
+
180
+ /**
181
+ *
182
+ * @return TransactionGateway
183
+ */
184
+ public function transaction()
185
+ {
186
+ return new TransactionGateway($this);
187
+ }
188
+
189
+ /**
190
+ *
191
+ * @return TransparentRedirectGateway
192
+ */
193
+ public function transparentRedirect()
194
+ {
195
+ return new TransparentRedirectGateway($this);
196
+ }
197
+
198
+ /**
199
+ *
200
+ * @return UsBankAccountGateway
201
+ */
202
+ public function usBankAccount()
203
+ {
204
+ return new UsBankAccountGateway($this);
205
+ }
206
+
207
+ }
208
+ class_alias('Braintree\Gateway', 'Braintree_Gateway');
lib/Gene/Braintree/{Http.php → braintree/braintree_php/lib/Braintree/Http.php} RENAMED
@@ -1,11 +1,13 @@
1
  <?php
 
 
2
  /**
3
  * Braintree HTTP Client
4
  * processes Http requests using curl
5
  *
6
- * @copyright 2014 Braintree, a division of PayPal, Inc.
7
  */
8
- class Braintree_Http
9
  {
10
  protected $_config;
11
  private $_useClientCredentials = false;
@@ -21,17 +23,17 @@ class Braintree_Http
21
  if($response['status'] === 200) {
22
  return true;
23
  } else {
24
- Braintree_Util::throwStatusCodeException($response['status']);
25
  }
26
  }
27
 
28
  public function get($path)
29
  {
30
  $response = $this->_doRequest('GET', $path);
31
- if($response['status'] === 200) {
32
- return Braintree_Xml::buildArrayFromXml($response['body']);
33
  } else {
34
- Braintree_Util::throwStatusCodeException($response['status']);
35
  }
36
  }
37
 
@@ -40,9 +42,9 @@ class Braintree_Http
40
  $response = $this->_doRequest('POST', $path, $this->_buildXml($params));
41
  $responseCode = $response['status'];
42
  if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) {
43
- return Braintree_Xml::buildArrayFromXml($response['body']);
44
  } else {
45
- Braintree_Util::throwStatusCodeException($responseCode);
46
  }
47
  }
48
 
@@ -51,41 +53,41 @@ class Braintree_Http
51
  $response = $this->_doRequest('PUT', $path, $this->_buildXml($params));
52
  $responseCode = $response['status'];
53
  if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) {
54
- return Braintree_Xml::buildArrayFromXml($response['body']);
55
  } else {
56
- Braintree_Util::throwStatusCodeException($responseCode);
57
  }
58
  }
59
 
60
  private function _buildXml($params)
61
  {
62
- return empty($params) ? null : Braintree_Xml::buildXmlFromArray($params);
63
  }
64
 
65
  private function _getHeaders()
66
  {
67
- return array(
68
  'Accept: application/xml',
69
  'Content-Type: application/xml',
70
- );
71
  }
72
 
73
  private function _getAuthorization()
74
  {
75
  if ($this->_useClientCredentials) {
76
- return array(
77
  'user' => $this->_config->getClientId(),
78
  'password' => $this->_config->getClientSecret(),
79
- );
80
  } else if ($this->_config->isAccessToken()) {
81
- return array(
82
  'token' => $this->_config->getAccessToken(),
83
- );
84
  } else {
85
- return array(
86
  'user' => $this->_config->getPublicKey(),
87
  'password' => $this->_config->getPrivateKey(),
88
- );
89
  }
90
  }
91
 
@@ -102,14 +104,14 @@ class Braintree_Http
102
  public function _doUrlRequest($httpVerb, $url, $requestBody = null)
103
  {
104
  $curl = curl_init();
105
- curl_setopt($curl, CURLOPT_TIMEOUT, 60);
106
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb);
107
  curl_setopt($curl, CURLOPT_URL, $url);
108
  curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
109
 
110
  $headers = $this->_getHeaders($curl);
111
- $headers[] = 'User-Agent: Braintree PHP Library ' . Braintree_Version::get();
112
- $headers[] = 'X-ApiVersion: ' . Braintree_Configuration::API_VERSION;
113
 
114
  $authorization = $this->_getAuthorization();
115
  if (isset($authorization['user'])) {
@@ -124,22 +126,68 @@ class Braintree_Http
124
  if ($this->_config->sslOn()) {
125
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
126
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
127
- curl_setopt($curl, CURLOPT_CAINFO, $this->_config->caFile());
128
  }
129
 
130
  if(!empty($requestBody)) {
131
  curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
135
  $response = curl_exec($curl);
136
  $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
 
 
 
 
 
 
137
  curl_close($curl);
138
  if ($this->_config->sslOn()) {
139
  if ($httpStatus == 0) {
140
- throw new Braintree_Exception_SSLCertificate();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
 
 
 
 
 
 
 
 
 
142
  }
143
- return array('status' => $httpStatus, 'body' => $response);
 
144
  }
145
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree HTTP Client
6
  * processes Http requests using curl
7
  *
8
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
9
  */
10
+ class Http
11
  {
12
  protected $_config;
13
  private $_useClientCredentials = false;
23
  if($response['status'] === 200) {
24
  return true;
25
  } else {
26
+ Util::throwStatusCodeException($response['status']);
27
  }
28
  }
29
 
30
  public function get($path)
31
  {
32
  $response = $this->_doRequest('GET', $path);
33
+ if ($response['status'] === 200) {
34
+ return Xml::buildArrayFromXml($response['body']);
35
  } else {
36
+ Util::throwStatusCodeException($response['status']);
37
  }
38
  }
39
 
42
  $response = $this->_doRequest('POST', $path, $this->_buildXml($params));
43
  $responseCode = $response['status'];
44
  if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) {
45
+ return Xml::buildArrayFromXml($response['body']);
46
  } else {
47
+ Util::throwStatusCodeException($responseCode);
48
  }
49
  }
50
 
53
  $response = $this->_doRequest('PUT', $path, $this->_buildXml($params));
54
  $responseCode = $response['status'];
55
  if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) {
56
+ return Xml::buildArrayFromXml($response['body']);
57
  } else {
58
+ Util::throwStatusCodeException($responseCode);
59
  }
60
  }
61
 
62
  private function _buildXml($params)
63
  {
64
+ return empty($params) ? null : Xml::buildXmlFromArray($params);
65
  }
66
 
67
  private function _getHeaders()
68
  {
69
+ return [
70
  'Accept: application/xml',
71
  'Content-Type: application/xml',
72
+ ];
73
  }
74
 
75
  private function _getAuthorization()
76
  {
77
  if ($this->_useClientCredentials) {
78
+ return [
79
  'user' => $this->_config->getClientId(),
80
  'password' => $this->_config->getClientSecret(),
81
+ ];
82
  } else if ($this->_config->isAccessToken()) {
83
+ return [
84
  'token' => $this->_config->getAccessToken(),
85
+ ];
86
  } else {
87
+ return [
88
  'user' => $this->_config->getPublicKey(),
89
  'password' => $this->_config->getPrivateKey(),
90
+ ];
91
  }
92
  }
93
 
104
  public function _doUrlRequest($httpVerb, $url, $requestBody = null)
105
  {
106
  $curl = curl_init();
107
+ curl_setopt($curl, CURLOPT_TIMEOUT, $this->_config->timeout());
108
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb);
109
  curl_setopt($curl, CURLOPT_URL, $url);
110
  curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
111
 
112
  $headers = $this->_getHeaders($curl);
113
+ $headers[] = 'User-Agent: Braintree PHP Library ' . Version::get();
114
+ $headers[] = 'X-ApiVersion: ' . Configuration::API_VERSION;
115
 
116
  $authorization = $this->_getAuthorization();
117
  if (isset($authorization['user'])) {
126
  if ($this->_config->sslOn()) {
127
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
128
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
129
+ curl_setopt($curl, CURLOPT_CAINFO, $this->getCaFile());
130
  }
131
 
132
  if(!empty($requestBody)) {
133
  curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
134
  }
135
 
136
+ if($this->_config->isUsingProxy()) {
137
+ $proxyHost = $this->_config->getProxyHost();
138
+ $proxyPort = $this->_config->getProxyPort();
139
+ $proxyType = $this->_config->getProxyType();
140
+ $proxyUser = $this->_config->getProxyUser();
141
+ $proxyPwd= $this->_config->getProxyPassword();
142
+ curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort);
143
+ if(!empty($proxyType)) {
144
+ curl_setopt($curl, CURLOPT_PROXYTYPE, $proxyType);
145
+ }
146
+ if($this->_config->isAuthenticatedProxy()) {
147
+ curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUser . ':' . $proxyPwd);
148
+ }
149
+ }
150
+
151
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
152
  $response = curl_exec($curl);
153
  $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
154
+ $error_code = curl_errno($curl);
155
+
156
+ if ($error_code == 28 && $httpStatus == 0) {
157
+ throw new Exception\Timeout();
158
+ }
159
+
160
  curl_close($curl);
161
  if ($this->_config->sslOn()) {
162
  if ($httpStatus == 0) {
163
+ throw new Exception\SSLCertificate();
164
+ }
165
+ }
166
+ return ['status' => $httpStatus, 'body' => $response];
167
+ }
168
+
169
+ private function getCaFile()
170
+ {
171
+ static $memo;
172
+
173
+ if ($memo === null) {
174
+ $caFile = $this->_config->caFile();
175
+
176
+ if (substr($caFile, 0, 7) !== 'phar://') {
177
+ return $caFile;
178
  }
179
+
180
+ $extractedCaFile = sys_get_temp_dir() . '/api_braintreegateway_com.ca.crt';
181
+
182
+ if (!file_exists($extractedCaFile) || sha1_file($extractedCaFile) != sha1_file($caFile)) {
183
+ if (!copy($caFile, $extractedCaFile)) {
184
+ throw new Exception\SSLCaFileNotFound();
185
+ }
186
+ }
187
+ $memo = $extractedCaFile;
188
  }
189
+
190
+ return $memo;
191
  }
192
  }
193
+ class_alias('Braintree\Http', 'Braintree_Http');
lib/Gene/Braintree/{Instance.php → braintree/braintree_php/lib/Braintree/Instance.php} RENAMED
@@ -1,16 +1,19 @@
1
  <?php
 
 
2
  /**
3
  * Braintree Class Instance template
4
- * @package Braintree
5
- * @subpackage Utility
6
- * @copyright 2014 Braintree, a division of PayPal, Inc.
7
  * @abstract
8
  */
9
- abstract class Braintree_Instance
10
  {
 
 
11
  /**
12
  *
13
- * @param array $aAttribs
14
  */
15
  public function __construct($attributes)
16
  {
@@ -19,11 +22,10 @@ abstract class Braintree_Instance
19
  }
20
  }
21
 
22
-
23
  /**
24
  * returns private/nonexistent instance properties
25
  * @access public
26
- * @param var $name property name
27
  * @return mixed contents of instance properties
28
  */
29
  public function __get($name)
@@ -50,19 +52,19 @@ abstract class Braintree_Instance
50
  /**
51
  * create a printable representation of the object as:
52
  * ClassName[property=value, property=value]
53
- * @return var
54
  */
55
  public function __toString()
56
  {
57
- $objOutput = Braintree_Util::implodeAssociativeArray($this->_attributes);
58
- return get_class($this) .'['.$objOutput.']';
59
  }
60
  /**
61
  * initializes instance properties from the keys/values of an array
62
  * @ignore
63
  * @access protected
64
  * @param <type> $aAttribs array of properties to set - single level
65
- * @return none
66
  */
67
  private function _initializeFromArray($attributes)
68
  {
@@ -70,3 +72,4 @@ abstract class Braintree_Instance
70
  }
71
 
72
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree Class Instance template
6
+ *
7
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
 
8
  * @abstract
9
  */
10
+ abstract class Instance
11
  {
12
+ protected $_attributes = [];
13
+
14
  /**
15
  *
16
+ * @param array $attributes
17
  */
18
  public function __construct($attributes)
19
  {
22
  }
23
  }
24
 
 
25
  /**
26
  * returns private/nonexistent instance properties
27
  * @access public
28
+ * @param string $name property name
29
  * @return mixed contents of instance properties
30
  */
31
  public function __get($name)
52
  /**
53
  * create a printable representation of the object as:
54
  * ClassName[property=value, property=value]
55
+ * @return string
56
  */
57
  public function __toString()
58
  {
59
+ $objOutput = Util::implodeAssociativeArray($this->_attributes);
60
+ return get_class($this) .'[' . $objOutput . ']';
61
  }
62
  /**
63
  * initializes instance properties from the keys/values of an array
64
  * @ignore
65
  * @access protected
66
  * @param <type> $aAttribs array of properties to set - single level
67
+ * @return void
68
  */
69
  private function _initializeFromArray($attributes)
70
  {
72
  }
73
 
74
  }
75
+ class_alias('Braintree\Instance', 'Braintree_Instance');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/IsNode.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class IsNode
5
+ {
6
+ public function __construct($name)
7
+ {
8
+ $this->name = $name;
9
+ $this->searchTerms = [];
10
+ }
11
+
12
+ public function is($value)
13
+ {
14
+ $this->searchTerms['is'] = strval($value);
15
+
16
+ return $this;
17
+ }
18
+
19
+ public function toParam()
20
+ {
21
+ return $this->searchTerms;
22
+ }
23
+ }
24
+ class_alias('Braintree\IsNode', 'Braintree_IsNode');
lib/Gene/Braintree/{KeyValueNode.php → braintree/braintree_php/lib/Braintree/KeyValueNode.php} RENAMED
@@ -1,22 +1,23 @@
1
  <?php
 
2
 
3
- class Braintree_KeyValueNode
4
  {
5
- function __construct($name)
6
  {
7
  $this->name = $name;
8
  $this->searchTerm = True;
9
-
10
  }
11
 
12
- function is($value)
13
  {
14
  $this->searchTerm = $value;
15
  return $this;
16
  }
17
 
18
- function toParam()
19
  {
20
  return $this->searchTerm;
21
  }
22
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class KeyValueNode
5
  {
6
+ public function __construct($name)
7
  {
8
  $this->name = $name;
9
  $this->searchTerm = True;
 
10
  }
11
 
12
+ public function is($value)
13
  {
14
  $this->searchTerm = $value;
15
  return $this;
16
  }
17
 
18
+ public function toParam()
19
  {
20
  return $this->searchTerm;
21
  }
22
  }
23
+ class_alias('Braintree\KeyValueNode', 'Braintree_KeyValueNode');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Merchant.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class Merchant extends Base
5
+ {
6
+ protected function _initialize($attribs)
7
+ {
8
+ $this->_attributes = $attribs;
9
+
10
+ $merchantAccountArray = [];
11
+ if (isset($attribs['merchantAccounts'])) {
12
+ foreach ($attribs['merchantAccounts'] AS $merchantAccount) {
13
+ $merchantAccountArray[] = MerchantAccount::factory($merchantAccount);
14
+ }
15
+ }
16
+ $this->_set('merchantAccounts', $merchantAccountArray);
17
+ }
18
+
19
+ public static function factory($attributes)
20
+ {
21
+ $instance = new self();
22
+ $instance->_initialize($attributes);
23
+ return $instance;
24
+ }
25
+
26
+ /**
27
+ * returns a string representation of the merchant
28
+ * @return string
29
+ */
30
+ public function __toString()
31
+ {
32
+ return __CLASS__ . '[' .
33
+ Util::attributesToString($this->_attributes) .']';
34
+ }
35
+ }
36
+ class_alias('Braintree\Merchant', 'Braintree_Merchant');
lib/Gene/Braintree/{MerchantAccount.php → braintree/braintree_php/lib/Braintree/MerchantAccount.php} RENAMED
@@ -1,6 +1,7 @@
1
  <?php
 
2
 
3
- final class Braintree_MerchantAccount extends Braintree_Base
4
  {
5
  const STATUS_ACTIVE = 'active';
6
  const STATUS_PENDING = 'pending';
@@ -23,22 +24,22 @@ final class Braintree_MerchantAccount extends Braintree_Base
23
 
24
  if (isset($merchantAccountAttribs['individual'])) {
25
  $individual = $merchantAccountAttribs['individual'];
26
- $this->_set('individualDetails', Braintree_MerchantAccount_IndividualDetails::Factory($individual));
27
  }
28
 
29
  if (isset($merchantAccountAttribs['business'])) {
30
  $business = $merchantAccountAttribs['business'];
31
- $this->_set('businessDetails', Braintree_MerchantAccount_BusinessDetails::Factory($business));
32
  }
33
 
34
  if (isset($merchantAccountAttribs['funding'])) {
35
  $funding = $merchantAccountAttribs['funding'];
36
- $this->_set('fundingDetails', new Braintree_MerchantAccount_FundingDetails($funding));
37
  }
38
 
39
  if (isset($merchantAccountAttribs['masterMerchantAccount'])) {
40
  $masterMerchantAccount = $merchantAccountAttribs['masterMerchantAccount'];
41
- $this->_set('masterMerchantAccount', Braintree_MerchantAccount::Factory($masterMerchantAccount));
42
  }
43
  }
44
 
@@ -47,16 +48,17 @@ final class Braintree_MerchantAccount extends Braintree_Base
47
 
48
  public static function create($attribs)
49
  {
50
- return Braintree_Configuration::gateway()->merchantAccount()->create($attribs);
51
  }
52
 
53
  public static function find($merchant_account_id)
54
  {
55
- return Braintree_Configuration::gateway()->merchantAccount()->find($merchant_account_id);
56
  }
57
 
58
  public static function update($merchant_account_id, $attributes)
59
  {
60
- return Braintree_Configuration::gateway()->merchantAccount()->update($merchant_account_id, $attributes);
61
  }
62
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class MerchantAccount extends Base
5
  {
6
  const STATUS_ACTIVE = 'active';
7
  const STATUS_PENDING = 'pending';
24
 
25
  if (isset($merchantAccountAttribs['individual'])) {
26
  $individual = $merchantAccountAttribs['individual'];
27
+ $this->_set('individualDetails', MerchantAccount\IndividualDetails::Factory($individual));
28
  }
29
 
30
  if (isset($merchantAccountAttribs['business'])) {
31
  $business = $merchantAccountAttribs['business'];
32
+ $this->_set('businessDetails', MerchantAccount\BusinessDetails::Factory($business));
33
  }
34
 
35
  if (isset($merchantAccountAttribs['funding'])) {
36
  $funding = $merchantAccountAttribs['funding'];
37
+ $this->_set('fundingDetails', new MerchantAccount\FundingDetails($funding));
38
  }
39
 
40
  if (isset($merchantAccountAttribs['masterMerchantAccount'])) {
41
  $masterMerchantAccount = $merchantAccountAttribs['masterMerchantAccount'];
42
+ $this->_set('masterMerchantAccount', self::Factory($masterMerchantAccount));
43
  }
44
  }
45
 
48
 
49
  public static function create($attribs)
50
  {
51
+ return Configuration::gateway()->merchantAccount()->create($attribs);
52
  }
53
 
54
  public static function find($merchant_account_id)
55
  {
56
+ return Configuration::gateway()->merchantAccount()->find($merchant_account_id);
57
  }
58
 
59
  public static function update($merchant_account_id, $attributes)
60
  {
61
+ return Configuration::gateway()->merchantAccount()->update($merchant_account_id, $attributes);
62
  }
63
  }
64
+ class_alias('Braintree\MerchantAccount', 'Braintree_MerchantAccount');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/MerchantAccount/AddressDetails.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\MerchantAccount;
3
+
4
+ use Braintree\Instance;
5
+
6
+ class AddressDetails extends Instance
7
+ {
8
+ protected $_attributes = [];
9
+ }
10
+ class_alias('Braintree\MerchantAccount\AddressDetails', 'Braintree_MerchantAccount_AddressDetails');
lib/Gene/Braintree/{MerchantAccount → braintree/braintree_php/lib/Braintree/MerchantAccount}/BusinessDetails.php RENAMED
@@ -1,12 +1,15 @@
1
  <?php
 
2
 
3
- final class Braintree_MerchantAccount_BusinessDetails extends Braintree_Base
 
 
4
  {
5
  protected function _initialize($businessAttribs)
6
  {
7
  $this->_attributes = $businessAttribs;
8
  if (isset($businessAttribs['address'])) {
9
- $this->_set('addressDetails', new Braintree_MerchantAccount_AddressDetails($businessAttribs['address']));
10
  }
11
  }
12
 
@@ -17,3 +20,4 @@ final class Braintree_MerchantAccount_BusinessDetails extends Braintree_Base
17
  return $instance;
18
  }
19
  }
 
1
  <?php
2
+ namespace Braintree\MerchantAccount;
3
 
4
+ use Braintree\Base;
5
+
6
+ class BusinessDetails extends Base
7
  {
8
  protected function _initialize($businessAttribs)
9
  {
10
  $this->_attributes = $businessAttribs;
11
  if (isset($businessAttribs['address'])) {
12
+ $this->_set('addressDetails', new AddressDetails($businessAttribs['address']));
13
  }
14
  }
15
 
20
  return $instance;
21
  }
22
  }
23
+ class_alias('Braintree\MerchantAccount\BusinessDetails', 'Braintree_MerchantAccount_BusinessDetails');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/MerchantAccount/FundingDetails.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\MerchantAccount;
3
+
4
+ use Braintree\Instance;
5
+
6
+ class FundingDetails extends Instance
7
+ {
8
+ protected $_attributes = [];
9
+ }
10
+ class_alias('Braintree\MerchantAccount\FundingDetails', 'Braintree_MerchantAccount_FundingDetails');
lib/Gene/Braintree/{MerchantAccount → braintree/braintree_php/lib/Braintree/MerchantAccount}/IndividualDetails.php RENAMED
@@ -1,12 +1,15 @@
1
  <?php
 
2
 
3
- final class Braintree_MerchantAccount_IndividualDetails extends Braintree_Base
 
 
4
  {
5
  protected function _initialize($individualAttribs)
6
  {
7
  $this->_attributes = $individualAttribs;
8
  if (isset($individualAttribs['address'])) {
9
- $this->_set('addressDetails', new Braintree_MerchantAccount_AddressDetails($individualAttribs['address']));
10
  }
11
  }
12
 
@@ -17,3 +20,4 @@ final class Braintree_MerchantAccount_IndividualDetails extends Braintree_Base
17
  return $instance;
18
  }
19
  }
 
1
  <?php
2
+ namespace Braintree\MerchantAccount;
3
 
4
+ use Braintree\Base;
5
+
6
+ class IndividualDetails extends Base
7
  {
8
  protected function _initialize($individualAttribs)
9
  {
10
  $this->_attributes = $individualAttribs;
11
  if (isset($individualAttribs['address'])) {
12
+ $this->_set('addressDetails', new AddressDetails($individualAttribs['address']));
13
  }
14
  }
15
 
20
  return $instance;
21
  }
22
  }
23
+ class_alias('Braintree\MerchantAccount\IndividualDetails', 'Braintree_MerchantAccount_IndividualDetails');
lib/Gene/Braintree/{MerchantAccountGateway.php → braintree/braintree_php/lib/Braintree/MerchantAccountGateway.php} RENAMED
@@ -1,6 +1,7 @@
1
  <?php
 
2
 
3
- final class Braintree_MerchantAccountGateway
4
  {
5
  private $_gateway;
6
  private $_config;
@@ -11,13 +12,13 @@ final class Braintree_MerchantAccountGateway
11
  $this->_gateway = $gateway;
12
  $this->_config = $gateway->config;
13
  $this->_config->assertHasAccessTokenOrKeys();
14
- $this->_http = new Braintree_Http($gateway->config);
15
  }
16
 
17
  public function create($attribs)
18
  {
19
- Braintree_Util::verifyKeys(self::detectSignature($attribs), $attribs);
20
- return $this->_doCreate('/merchant_accounts/create_via_api', array('merchant_account' => $attribs));
21
  }
22
 
23
  public function find($merchant_account_id)
@@ -25,16 +26,16 @@ final class Braintree_MerchantAccountGateway
25
  try {
26
  $path = $this->_config->merchantPath() . '/merchant_accounts/' . $merchant_account_id;
27
  $response = $this->_http->get($path);
28
- return Braintree_MerchantAccount::factory($response['merchantAccount']);
29
- } catch (Braintree_Exception_NotFound $e) {
30
- throw new Braintree_Exception_NotFound('merchant account with id ' . $merchant_account_id . ' not found');
31
  }
32
  }
33
 
34
  public function update($merchant_account_id, $attributes)
35
  {
36
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
37
- return $this->_doUpdate('/merchant_accounts/' . $merchant_account_id . '/update_via_api', array('merchant_account' => $attributes));
38
  }
39
 
40
  public static function detectSignature($attribs)
@@ -56,47 +57,47 @@ final class Braintree_MerchantAccountGateway
56
 
57
  public static function createSignature()
58
  {
59
- $addressSignature = array('streetAddress', 'postalCode', 'locality', 'region');
60
- $individualSignature = array(
61
  'firstName',
62
  'lastName',
63
  'email',
64
  'phone',
65
  'dateOfBirth',
66
  'ssn',
67
- array('address' => $addressSignature)
68
- );
69
 
70
- $businessSignature = array(
71
  'dbaName',
72
  'legalName',
73
  'taxId',
74
- array('address' => $addressSignature)
75
- );
76
 
77
- $fundingSignature = array(
78
  'routingNumber',
79
  'accountNumber',
80
  'destination',
81
  'email',
82
  'mobilePhone',
83
  'descriptor',
84
- );
85
 
86
- return array(
87
  'id',
88
  'tosAccepted',
89
  'masterMerchantAccountId',
90
- array('individual' => $individualSignature),
91
- array('funding' => $fundingSignature),
92
- array('business' => $businessSignature)
93
- );
94
  }
95
 
96
  public static function createDeprecatedSignature()
97
  {
98
- $applicantDetailsAddressSignature = array('streetAddress', 'postalCode', 'locality', 'region');
99
- $applicantDetailsSignature = array(
100
  'companyName',
101
  'firstName',
102
  'lastName',
@@ -107,15 +108,15 @@ final class Braintree_MerchantAccountGateway
107
  'taxId',
108
  'routingNumber',
109
  'accountNumber',
110
- array('address' => $applicantDetailsAddressSignature)
111
- );
112
 
113
- return array(
114
- array('applicantDetails' => $applicantDetailsSignature),
115
  'id',
116
  'tosAccepted',
117
  'masterMerchantAccountId'
118
- );
119
  }
120
 
121
  public function _doCreate($subPath, $params)
@@ -137,16 +138,17 @@ final class Braintree_MerchantAccountGateway
137
  private function _verifyGatewayResponse($response)
138
  {
139
  if (isset($response['merchantAccount'])) {
140
- // return a populated instance of Braintree_merchantAccount
141
- return new Braintree_Result_Successful(
142
- Braintree_MerchantAccount::factory($response['merchantAccount'])
143
  );
144
  } else if (isset($response['apiErrorResponse'])) {
145
- return new Braintree_Result_Error($response['apiErrorResponse']);
146
  } else {
147
- throw new Braintree_Exception_Unexpected(
148
  "Expected merchant account or apiErrorResponse"
149
  );
150
  }
151
  }
152
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class MerchantAccountGateway
5
  {
6
  private $_gateway;
7
  private $_config;
12
  $this->_gateway = $gateway;
13
  $this->_config = $gateway->config;
14
  $this->_config->assertHasAccessTokenOrKeys();
15
+ $this->_http = new Http($gateway->config);
16
  }
17
 
18
  public function create($attribs)
19
  {
20
+ Util::verifyKeys(self::detectSignature($attribs), $attribs);
21
+ return $this->_doCreate('/merchant_accounts/create_via_api', ['merchant_account' => $attribs]);
22
  }
23
 
24
  public function find($merchant_account_id)
26
  try {
27
  $path = $this->_config->merchantPath() . '/merchant_accounts/' . $merchant_account_id;
28
  $response = $this->_http->get($path);
29
+ return MerchantAccount::factory($response['merchantAccount']);
30
+ } catch (Exception\NotFound $e) {
31
+ throw new Exception\NotFound('merchant account with id ' . $merchant_account_id . ' not found');
32
  }
33
  }
34
 
35
  public function update($merchant_account_id, $attributes)
36
  {
37
+ Util::verifyKeys(self::updateSignature(), $attributes);
38
+ return $this->_doUpdate('/merchant_accounts/' . $merchant_account_id . '/update_via_api', ['merchant_account' => $attributes]);
39
  }
40
 
41
  public static function detectSignature($attribs)
57
 
58
  public static function createSignature()
59
  {
60
+ $addressSignature = ['streetAddress', 'postalCode', 'locality', 'region'];
61
+ $individualSignature = [
62
  'firstName',
63
  'lastName',
64
  'email',
65
  'phone',
66
  'dateOfBirth',
67
  'ssn',
68
+ ['address' => $addressSignature]
69
+ ];
70
 
71
+ $businessSignature = [
72
  'dbaName',
73
  'legalName',
74
  'taxId',
75
+ ['address' => $addressSignature]
76
+ ];
77
 
78
+ $fundingSignature = [
79
  'routingNumber',
80
  'accountNumber',
81
  'destination',
82
  'email',
83
  'mobilePhone',
84
  'descriptor',
85
+ ];
86
 
87
+ return [
88
  'id',
89
  'tosAccepted',
90
  'masterMerchantAccountId',
91
+ ['individual' => $individualSignature],
92
+ ['funding' => $fundingSignature],
93
+ ['business' => $businessSignature]
94
+ ];
95
  }
96
 
97
  public static function createDeprecatedSignature()
98
  {
99
+ $applicantDetailsAddressSignature = ['streetAddress', 'postalCode', 'locality', 'region'];
100
+ $applicantDetailsSignature = [
101
  'companyName',
102
  'firstName',
103
  'lastName',
108
  'taxId',
109
  'routingNumber',
110
  'accountNumber',
111
+ ['address' => $applicantDetailsAddressSignature]
112
+ ];
113
 
114
+ return [
115
+ ['applicantDetails' => $applicantDetailsSignature],
116
  'id',
117
  'tosAccepted',
118
  'masterMerchantAccountId'
119
+ ];
120
  }
121
 
122
  public function _doCreate($subPath, $params)
138
  private function _verifyGatewayResponse($response)
139
  {
140
  if (isset($response['merchantAccount'])) {
141
+ // return a populated instance of merchantAccount
142
+ return new Result\Successful(
143
+ MerchantAccount::factory($response['merchantAccount'])
144
  );
145
  } else if (isset($response['apiErrorResponse'])) {
146
+ return new Result\Error($response['apiErrorResponse']);
147
  } else {
148
+ throw new Exception\Unexpected(
149
  "Expected merchant account or apiErrorResponse"
150
  );
151
  }
152
  }
153
  }
154
+ class_alias('Braintree\MerchantAccountGateway', 'Braintree_MerchantAccountGateway');
lib/Gene/Braintree/{MerchantGateway.php → braintree/braintree_php/lib/Braintree/MerchantGateway.php} RENAMED
@@ -1,6 +1,7 @@
1
  <?php
 
2
 
3
- final class Braintree_MerchantGateway
4
  {
5
  private $_gateway;
6
  private $_config;
@@ -11,30 +12,31 @@ final class Braintree_MerchantGateway
11
  $this->_gateway = $gateway;
12
  $this->_config = $gateway->config;
13
  $this->_config->assertHasClientCredentials();
14
- $this->_http = new Braintree_Http($gateway->config);
15
  $this->_http->useClientCredentials();
16
  }
17
 
18
  public function create($attribs)
19
  {
20
- $response = $this->_http->post('/merchants/create_via_api', array('merchant' => $attribs));
21
  return $this->_verifyGatewayResponse($response);
22
  }
23
 
24
  private function _verifyGatewayResponse($response)
25
  {
26
  if (isset($response['response']['merchant'])) {
27
- // return a populated instance of Braintree_merchant
28
- return new Braintree_Result_Successful(array(
29
- Braintree_Merchant::factory($response['response']['merchant']),
30
- Braintree_OAuthCredentials::factory($response['response']['credentials']),
31
- ));
32
  } else if (isset($response['apiErrorResponse'])) {
33
- return new Braintree_Result_Error($response['apiErrorResponse']);
34
  } else {
35
- throw new Braintree_Exception_Unexpected(
36
  "Expected merchant or apiErrorResponse"
37
  );
38
  }
39
  }
40
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class MerchantGateway
5
  {
6
  private $_gateway;
7
  private $_config;
12
  $this->_gateway = $gateway;
13
  $this->_config = $gateway->config;
14
  $this->_config->assertHasClientCredentials();
15
+ $this->_http = new Http($gateway->config);
16
  $this->_http->useClientCredentials();
17
  }
18
 
19
  public function create($attribs)
20
  {
21
+ $response = $this->_http->post('/merchants/create_via_api', ['merchant' => $attribs]);
22
  return $this->_verifyGatewayResponse($response);
23
  }
24
 
25
  private function _verifyGatewayResponse($response)
26
  {
27
  if (isset($response['response']['merchant'])) {
28
+ // return a populated instance of merchant
29
+ return new Result\Successful([
30
+ Merchant::factory($response['response']['merchant']),
31
+ OAuthCredentials::factory($response['response']['credentials']),
32
+ ]);
33
  } else if (isset($response['apiErrorResponse'])) {
34
+ return new Result\Error($response['apiErrorResponse']);
35
  } else {
36
+ throw new Exception\Unexpected(
37
  "Expected merchant or apiErrorResponse"
38
  );
39
  }
40
  }
41
  }
42
+ class_alias('Braintree\MerchantGateway', 'Braintree_MerchantGateway');
lib/Gene/Braintree/{Modification.php → braintree/braintree_php/lib/Braintree/Modification.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- class Braintree_Modification extends Braintree_Base
 
 
3
  {
4
  protected function _initialize($attributes)
5
  {
@@ -14,6 +16,7 @@ class Braintree_Modification extends Braintree_Base
14
  }
15
 
16
  public function __toString() {
17
- return get_called_class() . '[' . Braintree_Util::attributesToString($this->_attributes) . ']';
18
  }
19
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class Modification extends Base
5
  {
6
  protected function _initialize($attributes)
7
  {
16
  }
17
 
18
  public function __toString() {
19
+ return get_called_class() . '[' . Util::attributesToString($this->_attributes) . ']';
20
  }
21
  }
22
+ class_alias('Braintree\Modification', 'Braintree_Modification');
lib/Gene/Braintree/{MultipleValueNode.php → braintree/braintree_php/lib/Braintree/MultipleValueNode.php} RENAMED
@@ -1,15 +1,18 @@
1
  <?php
 
2
 
3
- class Braintree_MultipleValueNode
 
 
4
  {
5
- function __construct($name, $allowedValues = array())
6
  {
7
  $this->name = $name;
8
- $this->items = array();
9
  $this->allowedValues = $allowedValues;
10
  }
11
 
12
- function in($values)
13
  {
14
  $bad_values = array_diff($values, $this->allowedValues);
15
  if (count($this->allowedValues) > 0 && count($bad_values) > 0) {
@@ -25,13 +28,14 @@ class Braintree_MultipleValueNode
25
  return $this;
26
  }
27
 
28
- function is($value)
29
  {
30
- return $this->in(array($value));
31
  }
32
 
33
- function toParam()
34
  {
35
  return $this->items;
36
  }
37
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ use InvalidArgumentException;
5
+
6
+ class MultipleValueNode
7
  {
8
+ public function __construct($name, $allowedValues = [])
9
  {
10
  $this->name = $name;
11
+ $this->items = [];
12
  $this->allowedValues = $allowedValues;
13
  }
14
 
15
+ public function in($values)
16
  {
17
  $bad_values = array_diff($values, $this->allowedValues);
18
  if (count($this->allowedValues) > 0 && count($bad_values) > 0) {
28
  return $this;
29
  }
30
 
31
+ public function is($value)
32
  {
33
+ return $this->in([$value]);
34
  }
35
 
36
+ public function toParam()
37
  {
38
  return $this->items;
39
  }
40
  }
41
+ class_alias('Braintree\MultipleValueNode', 'Braintree_MultipleValueNode');
lib/Gene/Braintree/{MultipleValueOrTextNode.php → braintree/braintree_php/lib/Braintree/MultipleValueOrTextNode.php} RENAMED
@@ -1,45 +1,47 @@
1
  <?php
 
2
 
3
- class Braintree_MultipleValueOrTextNode extends Braintree_MultipleValueNode
4
  {
5
- function __construct($name)
6
  {
7
  parent::__construct($name);
8
- $this->textNode = new Braintree_TextNode($name);
9
  }
10
 
11
- function contains($value)
12
  {
13
  $this->textNode->contains($value);
14
  return $this;
15
  }
16
 
17
- function endsWith($value)
18
  {
19
  $this->textNode->endsWith($value);
20
  return $this;
21
  }
22
 
23
- function is($value)
24
  {
25
  $this->textNode->is($value);
26
  return $this;
27
  }
28
 
29
- function isNot($value)
30
  {
31
  $this->textNode->isNot($value);
32
  return $this;
33
  }
34
 
35
- function startsWith($value)
36
  {
37
  $this->textNode->startsWith($value);
38
  return $this;
39
  }
40
 
41
- function toParam()
42
  {
43
  return array_merge(parent::toParam(), $this->textNode->toParam());
44
  }
45
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class MultipleValueOrTextNode extends MultipleValueNode
5
  {
6
+ public function __construct($name)
7
  {
8
  parent::__construct($name);
9
+ $this->textNode = new TextNode($name);
10
  }
11
 
12
+ public function contains($value)
13
  {
14
  $this->textNode->contains($value);
15
  return $this;
16
  }
17
 
18
+ public function endsWith($value)
19
  {
20
  $this->textNode->endsWith($value);
21
  return $this;
22
  }
23
 
24
+ public function is($value)
25
  {
26
  $this->textNode->is($value);
27
  return $this;
28
  }
29
 
30
+ public function isNot($value)
31
  {
32
  $this->textNode->isNot($value);
33
  return $this;
34
  }
35
 
36
+ public function startsWith($value)
37
  {
38
  $this->textNode->startsWith($value);
39
  return $this;
40
  }
41
 
42
+ public function toParam()
43
  {
44
  return array_merge(parent::toParam(), $this->textNode->toParam());
45
  }
46
  }
47
+ class_alias('Braintree\MultipleValueOrTextNode', 'Braintree_MultipleValueOrTextNode');
lib/Gene/Braintree/{OAuthCredentials.php → braintree/braintree_php/lib/Braintree/OAuthCredentials.php} RENAMED
@@ -1,13 +1,15 @@
1
  <?php
 
 
2
  /**
3
  * Braintree OAuthCredentials module
4
  *
5
  * @package Braintree
6
  * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  *
9
  */
10
- class Braintree_OAuthCredentials extends Braintree_Base
11
  {
12
  protected function _initialize($attribs)
13
  {
@@ -25,9 +27,10 @@ class Braintree_OAuthCredentials extends Braintree_Base
25
  * returns a string representation of the access token
26
  * @return string
27
  */
28
- public function __toString()
29
  {
30
  return __CLASS__ . '[' .
31
- Braintree_Util::attributesToString($this->_attributes) .']';
32
  }
33
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree OAuthCredentials module
6
  *
7
  * @package Braintree
8
  * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  *
11
  */
12
+ class OAuthCredentials extends Base
13
  {
14
  protected function _initialize($attribs)
15
  {
27
  * returns a string representation of the access token
28
  * @return string
29
  */
30
+ public function __toString()
31
  {
32
  return __CLASS__ . '[' .
33
+ Util::attributesToString($this->_attributes) .']';
34
  }
35
  }
36
+ class_alias('Braintree\OAuthCredentials', 'Braintree_OAuthCredentials');
lib/Gene/Braintree/{OAuthGateway.php → braintree/braintree_php/lib/Braintree/OAuthGateway.php} RENAMED
@@ -1,13 +1,15 @@
1
  <?php
 
 
2
  /**
3
  * Braintree OAuthGateway module
4
  * PHP Version 5
5
  * Creates and manages Braintree Addresses
6
  *
7
  * @package Braintree
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  */
10
- class Braintree_OAuthGateway
11
  {
12
  private $_gateway;
13
  private $_config;
@@ -17,7 +19,7 @@ class Braintree_OAuthGateway
17
  {
18
  $this->_gateway = $gateway;
19
  $this->_config = $gateway->config;
20
- $this->_http = new Braintree_Http($gateway->config);
21
  $this->_http->useClientCredentials();
22
 
23
  $this->_config->assertHasClientCredentials();
@@ -35,9 +37,16 @@ class Braintree_OAuthGateway
35
  return $this->_createToken($params);
36
  }
37
 
 
 
 
 
 
 
 
38
  private function _createToken($params)
39
  {
40
- $params = array('credentials' => $params);
41
  $response = $this->_http->post('/oauth/access_tokens', $params);
42
  return $this->_verifyGatewayResponse($response);
43
  }
@@ -45,15 +54,20 @@ class Braintree_OAuthGateway
45
  private function _verifyGatewayResponse($response)
46
  {
47
  if (isset($response['credentials'])) {
48
- $result = new Braintree_Result_Successful(
49
- Braintree_OAuthCredentials::factory($response['credentials'])
50
  );
51
  return $this->_mapSuccess($result);
 
 
 
 
 
52
  } else if (isset($response['apiErrorResponse'])) {
53
- $result = new Braintree_Result_Error($response['apiErrorResponse']);
54
  return $this->_mapError($result);
55
  } else {
56
- throw new Braintree_Exception_Unexpected(
57
  "Expected credentials or apiErrorResponse"
58
  );
59
  }
@@ -63,17 +77,23 @@ class Braintree_OAuthGateway
63
  {
64
  $error = $result->errors->deepAll()[0];
65
 
66
- if ($error->code == Braintree_Error_Codes::OAUTH_INVALID_GRANT) {
67
  $result->error = 'invalid_grant';
68
- } else if ($error->code == Braintree_Error_Codes::OAUTH_INVALID_CREDENTIALS) {
69
  $result->error = 'invalid_credentials';
70
- } else if ($error->code == Braintree_Error_Codes::OAUTH_INVALID_SCOPE) {
71
  $result->error = 'invalid_scope';
72
  }
73
  $result->errorDescription = explode(': ', $error->message)[1];
74
  return $result;
75
  }
76
 
 
 
 
 
 
 
77
  public function _mapSuccess($result)
78
  {
79
  $credentials = $result->credentials;
@@ -84,9 +104,9 @@ class Braintree_OAuthGateway
84
  return $result;
85
  }
86
 
87
- public function connectUrl($params = array())
88
  {
89
- $query = Braintree_Util::camelCaseToDelimiterArray($params, '_');
90
  $query['client_id'] = $this->_config->getClientId();
91
  $queryString = preg_replace('/\%5B\d+\%5D/', '%5B%5D', http_build_query($query));
92
  $url = $this->_config->baseUrl() . '/oauth/connect?' . $queryString;
@@ -100,3 +120,4 @@ class Braintree_OAuthGateway
100
  return hash_hmac('sha256', $url, $key);
101
  }
102
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree OAuthGateway module
6
  * PHP Version 5
7
  * Creates and manages Braintree Addresses
8
  *
9
  * @package Braintree
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
  */
12
+ class OAuthGateway
13
  {
14
  private $_gateway;
15
  private $_config;
19
  {
20
  $this->_gateway = $gateway;
21
  $this->_config = $gateway->config;
22
+ $this->_http = new Http($gateway->config);
23
  $this->_http->useClientCredentials();
24
 
25
  $this->_config->assertHasClientCredentials();
37
  return $this->_createToken($params);
38
  }
39
 
40
+ public function revokeAccessToken($accessToken)
41
+ {
42
+ $params = ['token' => $accessToken];
43
+ $response = $this->_http->post('/oauth/revoke_access_token', $params);
44
+ return $this->_verifyGatewayResponse($response);
45
+ }
46
+
47
  private function _createToken($params)
48
  {
49
+ $params = ['credentials' => $params];
50
  $response = $this->_http->post('/oauth/access_tokens', $params);
51
  return $this->_verifyGatewayResponse($response);
52
  }
54
  private function _verifyGatewayResponse($response)
55
  {
56
  if (isset($response['credentials'])) {
57
+ $result = new Result\Successful(
58
+ OAuthCredentials::factory($response['credentials'])
59
  );
60
  return $this->_mapSuccess($result);
61
+ } else if (isset($response['result'])) {
62
+ $result = new Result\Successful(
63
+ OAuthResult::factory($response['result'])
64
+ );
65
+ return $this->_mapAccessTokenRevokeSuccess($result);
66
  } else if (isset($response['apiErrorResponse'])) {
67
+ $result = new Result\Error($response['apiErrorResponse']);
68
  return $this->_mapError($result);
69
  } else {
70
+ throw new Exception\Unexpected(
71
  "Expected credentials or apiErrorResponse"
72
  );
73
  }
77
  {
78
  $error = $result->errors->deepAll()[0];
79
 
80
+ if ($error->code == Error\Codes::OAUTH_INVALID_GRANT) {
81
  $result->error = 'invalid_grant';
82
+ } else if ($error->code == Error\Codes::OAUTH_INVALID_CREDENTIALS) {
83
  $result->error = 'invalid_credentials';
84
+ } else if ($error->code == Error\Codes::OAUTH_INVALID_SCOPE) {
85
  $result->error = 'invalid_scope';
86
  }
87
  $result->errorDescription = explode(': ', $error->message)[1];
88
  return $result;
89
  }
90
 
91
+ public function _mapAccessTokenRevokeSuccess($result)
92
+ {
93
+ $result->revocationResult = $result->success;
94
+ return $result;
95
+ }
96
+
97
  public function _mapSuccess($result)
98
  {
99
  $credentials = $result->credentials;
104
  return $result;
105
  }
106
 
107
+ public function connectUrl($params = [])
108
  {
109
+ $query = Util::camelCaseToDelimiterArray($params, '_');
110
  $query['client_id'] = $this->_config->getClientId();
111
  $queryString = preg_replace('/\%5B\d+\%5D/', '%5B%5D', http_build_query($query));
112
  $url = $this->_config->baseUrl() . '/oauth/connect?' . $queryString;
120
  return hash_hmac('sha256', $url, $key);
121
  }
122
  }
123
+ class_alias('Braintree\OAuthGateway', 'Braintree_OAuthGateway');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/OAuthResult.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree OAuthCredentials module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ *
11
+ */
12
+ class OAuthResult extends Base
13
+ {
14
+ protected function _initialize($attribs)
15
+ {
16
+ $this->_attributes = $attribs;
17
+ }
18
+
19
+ public static function factory($attributes)
20
+ {
21
+ $instance = new self();
22
+ $instance->_initialize($attributes);
23
+ return $instance;
24
+ }
25
+
26
+ /**
27
+ * returns a string representation of the result
28
+ * @return string
29
+ */
30
+ public function __toString()
31
+ {
32
+ return __CLASS__ . '[' .
33
+ Util::attributesToString($this->_attributes) .']';
34
+ }
35
+ }
36
+ class_alias('Braintree\OAuthResult', 'Braintree_OAuthResult');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/PartialMatchNode.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class PartialMatchNode extends EqualityNode
5
+ {
6
+ public function startsWith($value)
7
+ {
8
+ $this->searchTerms["starts_with"] = strval($value);
9
+ return $this;
10
+ }
11
+
12
+ public function endsWith($value)
13
+ {
14
+ $this->searchTerms["ends_with"] = strval($value);
15
+ return $this;
16
+ }
17
+ }
18
+ class_alias('Braintree\PartialMatchNode', 'Braintree_PartialMatchNode');
lib/Gene/Braintree/{PartnerMerchant.php → braintree/braintree_php/lib/Braintree/PartnerMerchant.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Partner Merchant information that is generated when a partner is connected
4
  * to or disconnected from a user.
@@ -6,18 +8,17 @@
6
  * Creates an instance of PartnerMerchants
7
  *
8
  * @package Braintree
9
- * @copyright 2014 Braintree, a division of PayPal, Inc.
10
  *
11
  * @property-read string $merchantPublicId
12
  * @property-read string $publicKey
13
  * @property-read string $privateKey
14
  * @property-read string $clientSideEncryptionKey
15
  * @property-read string $partnerMerchantId
16
- * @uses Braintree_Instance inherits methods
17
  */
18
- class Braintree_PartnerMerchant extends Braintree_Base
19
  {
20
- protected $_attributes = array();
21
 
22
  /**
23
  * @ignore
@@ -38,3 +39,4 @@ class Braintree_PartnerMerchant extends Braintree_Base
38
  $this->_attributes = $attributes;
39
  }
40
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Partner Merchant information that is generated when a partner is connected
6
  * to or disconnected from a user.
8
  * Creates an instance of PartnerMerchants
9
  *
10
  * @package Braintree
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  *
13
  * @property-read string $merchantPublicId
14
  * @property-read string $publicKey
15
  * @property-read string $privateKey
16
  * @property-read string $clientSideEncryptionKey
17
  * @property-read string $partnerMerchantId
 
18
  */
19
+ class PartnerMerchant extends Base
20
  {
21
+ protected $_attributes = [];
22
 
23
  /**
24
  * @ignore
39
  $this->_attributes = $attributes;
40
  }
41
  }
42
+ class_alias('Braintree\PartnerMerchant', 'Braintree_PartnerMerchant');
lib/Gene/Braintree/{PayPalAccount.php → braintree/braintree_php/lib/Braintree/PayPalAccount.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
 
 
2
  /**
3
  * Braintree PayPalAccount module
4
  *
5
  * @package Braintree
6
  * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -15,20 +17,21 @@
15
  *
16
  * @package Braintree
17
  * @category Resources
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  *
 
20
  * @property-read string $email
21
  * @property-read string $token
22
  * @property-read string $imageUrl
23
  */
24
- class Braintree_PayPalAccount extends Braintree_Base
25
  {
26
  /**
27
- * factory method: returns an instance of Braintree_PayPalAccount
28
  * to the requesting method, with populated properties
29
  *
30
  * @ignore
31
- * @return object instance of Braintree_PayPalAccount
32
  */
33
  public static function factory($attributes)
34
  {
@@ -54,17 +57,17 @@ class Braintree_PayPalAccount extends Braintree_Base
54
  *
55
  * @access protected
56
  * @param array $paypalAccountAttribs array of paypalAccount data
57
- * @return none
58
  */
59
  protected function _initialize($paypalAccountAttribs)
60
  {
61
  // set the attributes
62
  $this->_attributes = $paypalAccountAttribs;
63
 
64
- $subscriptionArray = array();
65
  if (isset($paypalAccountAttribs['subscriptions'])) {
66
  foreach ($paypalAccountAttribs['subscriptions'] AS $subscription) {
67
- $subscriptionArray[] = Braintree_Subscription::factory($subscription);
68
  }
69
  }
70
 
@@ -79,7 +82,7 @@ class Braintree_PayPalAccount extends Braintree_Base
79
  public function __toString()
80
  {
81
  return __CLASS__ . '[' .
82
- Braintree_Util::attributesToString($this->_attributes) .']';
83
  }
84
 
85
 
@@ -87,21 +90,22 @@ class Braintree_PayPalAccount extends Braintree_Base
87
 
88
  public static function find($token)
89
  {
90
- return Braintree_Configuration::gateway()->payPalAccount()->find($token);
91
  }
92
 
93
  public static function update($token, $attributes)
94
  {
95
- return Braintree_Configuration::gateway()->payPalAccount()->update($token, $attributes);
96
  }
97
 
98
  public static function delete($token)
99
  {
100
- return Braintree_Configuration::gateway()->payPalAccount()->delete($token);
101
  }
102
 
103
  public static function sale($token, $transactionAttribs)
104
  {
105
- return Braintree_Configuration::gateway()->payPalAccount()->sale($token, $transactionAttribs);
106
  }
107
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree PayPalAccount module
6
  *
7
  * @package Braintree
8
  * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
 
12
  /**
17
  *
18
  * @package Braintree
19
  * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
+ * @property-read string $customerId
23
  * @property-read string $email
24
  * @property-read string $token
25
  * @property-read string $imageUrl
26
  */
27
+ class PayPalAccount extends Base
28
  {
29
  /**
30
+ * factory method: returns an instance of PayPalAccount
31
  * to the requesting method, with populated properties
32
  *
33
  * @ignore
34
+ * @return PayPalAccount
35
  */
36
  public static function factory($attributes)
37
  {
57
  *
58
  * @access protected
59
  * @param array $paypalAccountAttribs array of paypalAccount data
60
+ * @return void
61
  */
62
  protected function _initialize($paypalAccountAttribs)
63
  {
64
  // set the attributes
65
  $this->_attributes = $paypalAccountAttribs;
66
 
67
+ $subscriptionArray = [];
68
  if (isset($paypalAccountAttribs['subscriptions'])) {
69
  foreach ($paypalAccountAttribs['subscriptions'] AS $subscription) {
70
+ $subscriptionArray[] = Subscription::factory($subscription);
71
  }
72
  }
73
 
82
  public function __toString()
83
  {
84
  return __CLASS__ . '[' .
85
+ Util::attributesToString($this->_attributes) . ']';
86
  }
87
 
88
 
90
 
91
  public static function find($token)
92
  {
93
+ return Configuration::gateway()->payPalAccount()->find($token);
94
  }
95
 
96
  public static function update($token, $attributes)
97
  {
98
+ return Configuration::gateway()->payPalAccount()->update($token, $attributes);
99
  }
100
 
101
  public static function delete($token)
102
  {
103
+ return Configuration::gateway()->payPalAccount()->delete($token);
104
  }
105
 
106
  public static function sale($token, $transactionAttribs)
107
  {
108
+ return Configuration::gateway()->payPalAccount()->sale($token, $transactionAttribs);
109
  }
110
  }
111
+ class_alias('Braintree\PayPalAccount', 'Braintree_PayPalAccount');
lib/Gene/Braintree/{PayPalAccountGateway.php → braintree/braintree_php/lib/Braintree/PayPalAccountGateway.php} RENAMED
@@ -1,10 +1,14 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Braintree PayPalAccountGateway module
4
  *
5
  * @package Braintree
6
  * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -15,9 +19,9 @@
15
  *
16
  * @package Braintree
17
  * @category Resources
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  */
20
- class Braintree_PayPalAccountGateway
21
  {
22
  private $_gateway;
23
  private $_config;
@@ -28,7 +32,7 @@ class Braintree_PayPalAccountGateway
28
  $this->_gateway = $gateway;
29
  $this->_config = $gateway->config;
30
  $this->_config->assertHasAccessTokenOrKeys();
31
- $this->_http = new Braintree_Http($gateway->config);
32
  }
33
 
34
 
@@ -37,8 +41,8 @@ class Braintree_PayPalAccountGateway
37
  *
38
  * @access public
39
  * @param string $token paypal accountunique id
40
- * @return object Braintree_PayPalAccount
41
- * @throws Braintree_Exception_NotFound
42
  */
43
  public function find($token)
44
  {
@@ -46,9 +50,9 @@ class Braintree_PayPalAccountGateway
46
  try {
47
  $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token;
48
  $response = $this->_http->get($path);
49
- return Braintree_PayPalAccount::factory($response['paypalAccount']);
50
- } catch (Braintree_Exception_NotFound $e) {
51
- throw new Braintree_Exception_NotFound(
52
  'paypal account with token ' . $token . ' not found'
53
  );
54
  }
@@ -64,13 +68,13 @@ class Braintree_PayPalAccountGateway
64
  * @access public
65
  * @param array $attributes
66
  * @param string $token (optional)
67
- * @return object Braintree_Result_Successful or Braintree_Result_Error
68
  */
69
  public function update($token, $attributes)
70
  {
71
- Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
72
  $this->_validateId($token);
73
- return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, array('paypalAccount' => $attributes));
74
  }
75
 
76
  public function delete($token)
@@ -78,7 +82,7 @@ class Braintree_PayPalAccountGateway
78
  $this->_validateId($token);
79
  $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token;
80
  $this->_http->delete($path);
81
- return new Braintree_Result_Successful();
82
  }
83
 
84
  /**
@@ -86,26 +90,26 @@ class Braintree_PayPalAccountGateway
86
  *
87
  * @param string $token
88
  * @param array $transactionAttribs
89
- * @return object Braintree_Result_Successful or Braintree_Result_Error
90
- * @see Braintree_Transaction::sale()
91
  */
92
  public function sale($token, $transactionAttribs)
93
  {
94
  $this->_validateId($token);
95
- return Braintree_Transaction::sale(
96
  array_merge(
97
  $transactionAttribs,
98
- array('paymentMethodToken' => $token)
99
  )
100
  );
101
  }
102
 
103
  public static function updateSignature()
104
  {
105
- return array(
106
  'token',
107
- array('options' => array('makeDefault'))
108
- );
109
  }
110
 
111
  /**
@@ -126,27 +130,27 @@ class Braintree_PayPalAccountGateway
126
  /**
127
  * generic method for validating incoming gateway responses
128
  *
129
- * creates a new Braintree_PayPalAccount object and encapsulates
130
- * it inside a Braintree_Result_Successful object, or
131
- * encapsulates a Braintree_Errors object inside a Result_Error
132
  * alternatively, throws an Unexpected exception if the response is invalid.
133
  *
134
  * @ignore
135
  * @param array $response gateway response values
136
- * @return object Result_Successful or Result_Error
137
- * @throws Braintree_Exception_Unexpected
138
  */
139
  private function _verifyGatewayResponse($response)
140
  {
141
  if (isset($response['paypalAccount'])) {
142
- // return a populated instance of Braintree_PayPalAccount
143
- return new Braintree_Result_Successful(
144
- Braintree_PayPalAccount::factory($response['paypalAccount'])
145
  );
146
  } else if (isset($response['apiErrorResponse'])) {
147
- return new Braintree_Result_Error($response['apiErrorResponse']);
148
  } else {
149
- throw new Braintree_Exception_Unexpected(
150
  'Expected paypal account or apiErrorResponse'
151
  );
152
  }
@@ -173,3 +177,4 @@ class Braintree_PayPalAccountGateway
173
  }
174
  }
175
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
  /**
7
  * Braintree PayPalAccountGateway module
8
  *
9
  * @package Braintree
10
  * @category Resources
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  */
13
 
14
  /**
19
  *
20
  * @package Braintree
21
  * @category Resources
22
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
23
  */
24
+ class PayPalAccountGateway
25
  {
26
  private $_gateway;
27
  private $_config;
32
  $this->_gateway = $gateway;
33
  $this->_config = $gateway->config;
34
  $this->_config->assertHasAccessTokenOrKeys();
35
+ $this->_http = new Http($gateway->config);
36
  }
37
 
38
 
41
  *
42
  * @access public
43
  * @param string $token paypal accountunique id
44
+ * @return PayPalAccount
45
+ * @throws Exception\NotFound
46
  */
47
  public function find($token)
48
  {
50
  try {
51
  $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token;
52
  $response = $this->_http->get($path);
53
+ return PayPalAccount::factory($response['paypalAccount']);
54
+ } catch (Exception\NotFound $e) {
55
+ throw new Exception\NotFound(
56
  'paypal account with token ' . $token . ' not found'
57
  );
58
  }
68
  * @access public
69
  * @param array $attributes
70
  * @param string $token (optional)
71
+ * @return Result\Successful or Result\Error
72
  */
73
  public function update($token, $attributes)
74
  {
75
+ Util::verifyKeys(self::updateSignature(), $attributes);
76
  $this->_validateId($token);
77
+ return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, ['paypalAccount' => $attributes]);
78
  }
79
 
80
  public function delete($token)
82
  $this->_validateId($token);
83
  $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token;
84
  $this->_http->delete($path);
85
+ return new Result\Successful();
86
  }
87
 
88
  /**
90
  *
91
  * @param string $token
92
  * @param array $transactionAttribs
93
+ * @return Result\Successful|Result\Error
94
+ * @see Transaction::sale()
95
  */
96
  public function sale($token, $transactionAttribs)
97
  {
98
  $this->_validateId($token);
99
+ return Transaction::sale(
100
  array_merge(
101
  $transactionAttribs,
102
+ ['paymentMethodToken' => $token]
103
  )
104
  );
105
  }
106
 
107
  public static function updateSignature()
108
  {
109
+ return [
110
  'token',
111
+ ['options' => ['makeDefault']]
112
+ ];
113
  }
114
 
115
  /**
130
  /**
131
  * generic method for validating incoming gateway responses
132
  *
133
+ * creates a new PayPalAccount object and encapsulates
134
+ * it inside a Result\Successful object, or
135
+ * encapsulates a Errors object inside a Result\Error
136
  * alternatively, throws an Unexpected exception if the response is invalid.
137
  *
138
  * @ignore
139
  * @param array $response gateway response values
140
+ * @return Result\Successful|Result\Error
141
+ * @throws Exception\Unexpected
142
  */
143
  private function _verifyGatewayResponse($response)
144
  {
145
  if (isset($response['paypalAccount'])) {
146
+ // return a populated instance of PayPalAccount
147
+ return new Result\Successful(
148
+ PayPalAccount::factory($response['paypalAccount'])
149
  );
150
  } else if (isset($response['apiErrorResponse'])) {
151
+ return new Result\Error($response['apiErrorResponse']);
152
  } else {
153
+ throw new Exception\Unexpected(
154
  'Expected paypal account or apiErrorResponse'
155
  );
156
  }
177
  }
178
  }
179
  }
180
+ class_alias('Braintree\PayPalAccountGateway', 'Braintree_PayPalAccountGateway');
lib/Gene/Braintree/{PaymentInstrumentType.php → braintree/braintree_php/lib/Braintree/PaymentInstrumentType.php} RENAMED
@@ -1,6 +1,7 @@
1
  <?php
 
2
 
3
- final class Braintree_PaymentInstrumentType
4
  {
5
  const PAYPAL_ACCOUNT = 'paypal_account';
6
  const COINBASE_ACCOUNT = 'coinbase_account';
@@ -8,4 +9,6 @@ final class Braintree_PaymentInstrumentType
8
  const CREDIT_CARD = 'credit_card';
9
  const APPLE_PAY_CARD = 'apple_pay_card';
10
  const ANDROID_PAY_CARD = 'android_pay_card';
 
11
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class PaymentInstrumentType
5
  {
6
  const PAYPAL_ACCOUNT = 'paypal_account';
7
  const COINBASE_ACCOUNT = 'coinbase_account';
9
  const CREDIT_CARD = 'credit_card';
10
  const APPLE_PAY_CARD = 'apple_pay_card';
11
  const ANDROID_PAY_CARD = 'android_pay_card';
12
+ const VENMO_ACCOUNT = 'venmo_account';
13
  }
14
+ class_alias('Braintree\PaymentInstrumentType', 'Braintree_PaymentInstrumentType');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/PaymentMethod.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree PaymentMethod module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Creates and manages Braintree PaymentMethods
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ */
23
+ class PaymentMethod extends Base
24
+ {
25
+ // static methods redirecting to gateway
26
+
27
+ public static function create($attribs)
28
+ {
29
+ return Configuration::gateway()->paymentMethod()->create($attribs);
30
+ }
31
+
32
+ public static function find($token)
33
+ {
34
+ return Configuration::gateway()->paymentMethod()->find($token);
35
+ }
36
+
37
+ public static function update($token, $attribs)
38
+ {
39
+ return Configuration::gateway()->paymentMethod()->update($token, $attribs);
40
+ }
41
+
42
+ public static function delete($token)
43
+ {
44
+ return Configuration::gateway()->paymentMethod()->delete($token);
45
+ }
46
+ }
47
+ class_alias('Braintree\PaymentMethod', 'Braintree_PaymentMethod');
lib/Gene/Braintree/{PaymentMethodGateway.php → braintree/braintree_php/lib/Braintree/PaymentMethodGateway.php} RENAMED
@@ -1,10 +1,14 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Braintree PaymentMethodGateway module
4
  *
5
  * @package Braintree
6
  * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -15,10 +19,10 @@
15
  *
16
  * @package Braintree
17
  * @category Resources
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  *
20
  */
21
- class Braintree_PaymentMethodGateway
22
  {
23
  private $_gateway;
24
  private $_config;
@@ -29,23 +33,22 @@ class Braintree_PaymentMethodGateway
29
  $this->_gateway = $gateway;
30
  $this->_config = $gateway->config;
31
  $this->_config->assertHasAccessTokenOrKeys();
32
- $this->_http = new Braintree_Http($gateway->config);
33
  }
34
 
35
 
36
  public function create($attribs)
37
  {
38
- Braintree_Util::verifyKeys(self::createSignature(), $attribs);
39
- return $this->_doCreate('/payment_methods', array('payment_method' => $attribs));
40
  }
41
 
42
  /**
43
  * find a PaymentMethod by token
44
  *
45
- * @access public
46
  * @param string $token payment method unique id
47
- * @return object Braintree_CreditCard or Braintree_PayPalAccount
48
- * @throws Braintree_Exception_NotFound
49
  */
50
  public function find($token)
51
  {
@@ -54,32 +57,37 @@ class Braintree_PaymentMethodGateway
54
  $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token;
55
  $response = $this->_http->get($path);
56
  if (isset($response['creditCard'])) {
57
- return Braintree_CreditCard::factory($response['creditCard']);
58
  } else if (isset($response['paypalAccount'])) {
59
- return Braintree_PayPalAccount::factory($response['paypalAccount']);
60
  } else if (isset($response['coinbaseAccount'])) {
61
- return Braintree_CoinbaseAccount::factory($response['coinbaseAccount']);
62
  } else if (isset($response['applePayCard'])) {
63
- return Braintree_ApplePayCard::factory($response['applePayCard']);
64
  } else if (isset($response['androidPayCard'])) {
65
- return Braintree_AndroidPayCard::factory($response['androidPayCard']);
 
 
66
  } else if (isset($response['europeBankAccount'])) {
67
- return Braintree_EuropeBankAccount::factory($response['europeBankAccount']);
 
 
 
 
68
  } else if (is_array($response)) {
69
- return Braintree_UnknownPaymentMethod::factory($response);
70
  }
71
- } catch (Braintree_Exception_NotFound $e) {
72
- throw new Braintree_Exception_NotFound(
73
  'payment method with token ' . $token . ' not found'
74
  );
75
  }
76
-
77
  }
78
 
79
  public function update($token, $attribs)
80
  {
81
- Braintree_Util::verifyKeys(self::updateSignature(), $attribs);
82
- return $this->_doUpdate('/payment_methods/any/' . $token, array('payment_method' => $attribs));
83
  }
84
 
85
  public function delete($token)
@@ -87,19 +95,45 @@ class Braintree_PaymentMethodGateway
87
  $this->_validateId($token);
88
  $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token;
89
  $this->_http->delete($path);
90
- return new Braintree_Result_Successful();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
92
 
93
  private static function baseSignature()
94
  {
95
- $billingAddressSignature = Braintree_AddressGateway::createSignature();
96
- $optionsSignature = array(
97
  'failOnDuplicatePaymentMethod',
98
  'makeDefault',
99
  'verificationMerchantAccountId',
100
- 'verifyCard'
101
- );
102
- return array(
 
103
  'billingAddressId',
104
  'cardholderName',
105
  'cvv',
@@ -110,31 +144,31 @@ class Braintree_PaymentMethodGateway
110
  'number',
111
  'paymentMethodNonce',
112
  'token',
113
- array('options' => $optionsSignature),
114
- array('billingAddress' => $billingAddressSignature)
115
- );
116
  }
117
 
118
  public static function createSignature()
119
  {
120
- $signature = array_merge(self::baseSignature(), array('customerId'));
121
  return $signature;
122
  }
123
 
124
  public static function updateSignature()
125
  {
126
- $billingAddressSignature = Braintree_AddressGateway::updateSignature();
127
- array_push($billingAddressSignature, array(
128
- 'options' => array(
129
  'updateExisting'
130
- )
131
- ));
132
- $signature = array_merge(self::baseSignature(), array(
133
  'deviceSessionId',
134
  'venmoSdkPaymentMethodCode',
135
  'fraudMerchantId',
136
- array('billingAddress' => $billingAddressSignature)
137
- ));
138
  return $signature;
139
  }
140
 
@@ -173,63 +207,77 @@ class Braintree_PaymentMethodGateway
173
  /**
174
  * generic method for validating incoming gateway responses
175
  *
176
- * creates a new Braintree_CreditCard or Braintree_PayPalAccount object
177
- * and encapsulates it inside a Braintree_Result_Successful object, or
178
- * encapsulates a Braintree_Errors object inside a Result_Error
179
  * alternatively, throws an Unexpected exception if the response is invalid.
180
  *
181
  * @ignore
182
  * @param array $response gateway response values
183
- * @return object Result_Successful or Result_Error
184
- * @throws Braintree_Exception_Unexpected
185
  */
186
  private function _verifyGatewayResponse($response)
187
  {
188
  if (isset($response['creditCard'])) {
189
- // return a populated instance of Braintree_CreditCard
190
- return new Braintree_Result_Successful(
191
- Braintree_CreditCard::factory($response['creditCard']),
192
- "paymentMethod"
193
  );
194
  } else if (isset($response['paypalAccount'])) {
195
- // return a populated instance of Braintree_PayPalAccount
196
- return new Braintree_Result_Successful(
197
- Braintree_PayPalAccount::factory($response['paypalAccount']),
198
  "paymentMethod"
199
  );
200
  } else if (isset($response['coinbaseAccount'])) {
201
- // return a populated instance of Braintree_CoinbaseAccount
202
- return new Braintree_Result_Successful(
203
- Braintree_CoinbaseAccount::factory($response['coinbaseAccount']),
204
  "paymentMethod"
205
  );
206
  } else if (isset($response['applePayCard'])) {
207
- // return a populated instance of Braintree_ApplePayCard
208
- return new Braintree_Result_Successful(
209
- Braintree_ApplePayCard::factory($response['applePayCard']),
210
  "paymentMethod"
211
  );
212
  } else if (isset($response['androidPayCard'])) {
213
- // return a populated instance of Braintree_AndroidPayCard
214
- return new Braintree_Result_Successful(
215
- Braintree_AndroidPayCard::factory($response['androidPayCard']),
 
 
 
 
216
  "paymentMethod"
217
  );
218
  } else if (isset($response['europeBankAccount'])) {
219
- // return a populated instance of Braintree_EuropeBankAccount
220
- return new Braintree_Result_Successful(
221
- Braintree_EuropeBankAccount::factory($response['europeBankAccount']),
222
  "paymentMethod"
223
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  } else if (isset($response['apiErrorResponse'])) {
225
- return new Braintree_Result_Error($response['apiErrorResponse']);
226
  } else if (is_array($response)) {
227
- return new Braintree_Result_Successful(
228
- Braintree_UnknownPaymentMethod::factory($response),
229
  "paymentMethod"
230
  );
231
  } else {
232
- throw new Braintree_Exception_Unexpected(
233
  'Expected payment method or apiErrorResponse'
234
  );
235
  }
@@ -256,3 +304,4 @@ class Braintree_PaymentMethodGateway
256
  }
257
  }
258
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
  /**
7
  * Braintree PaymentMethodGateway module
8
  *
9
  * @package Braintree
10
  * @category Resources
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  */
13
 
14
  /**
19
  *
20
  * @package Braintree
21
  * @category Resources
22
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
23
  *
24
  */
25
+ class PaymentMethodGateway
26
  {
27
  private $_gateway;
28
  private $_config;
33
  $this->_gateway = $gateway;
34
  $this->_config = $gateway->config;
35
  $this->_config->assertHasAccessTokenOrKeys();
36
+ $this->_http = new Http($gateway->config);
37
  }
38
 
39
 
40
  public function create($attribs)
41
  {
42
+ Util::verifyKeys(self::createSignature(), $attribs);
43
+ return $this->_doCreate('/payment_methods', ['payment_method' => $attribs]);
44
  }
45
 
46
  /**
47
  * find a PaymentMethod by token
48
  *
 
49
  * @param string $token payment method unique id
50
+ * @return CreditCard|PayPalAccount
51
+ * @throws Exception\NotFound
52
  */
53
  public function find($token)
54
  {
57
  $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token;
58
  $response = $this->_http->get($path);
59
  if (isset($response['creditCard'])) {
60
+ return CreditCard::factory($response['creditCard']);
61
  } else if (isset($response['paypalAccount'])) {
62
+ return PayPalAccount::factory($response['paypalAccount']);
63
  } else if (isset($response['coinbaseAccount'])) {
64
+ return CoinbaseAccount::factory($response['coinbaseAccount']);
65
  } else if (isset($response['applePayCard'])) {
66
+ return ApplePayCard::factory($response['applePayCard']);
67
  } else if (isset($response['androidPayCard'])) {
68
+ return AndroidPayCard::factory($response['androidPayCard']);
69
+ } else if (isset($response['amexExpressCheckoutCard'])) {
70
+ return AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']);
71
  } else if (isset($response['europeBankAccount'])) {
72
+ return EuropeBankAccount::factory($response['europeBankAccount']);
73
+ } else if (isset($response['usBankAccount'])) {
74
+ return UsBankAccount::factory($response['usBankAccount']);
75
+ } else if (isset($response['venmoAccount'])) {
76
+ return VenmoAccount::factory($response['venmoAccount']);
77
  } else if (is_array($response)) {
78
+ return UnknownPaymentMethod::factory($response);
79
  }
80
+ } catch (Exception\NotFound $e) {
81
+ throw new Exception\NotFound(
82
  'payment method with token ' . $token . ' not found'
83
  );
84
  }
 
85
  }
86
 
87
  public function update($token, $attribs)
88
  {
89
+ Util::verifyKeys(self::updateSignature(), $attribs);
90
+ return $this->_doUpdate('/payment_methods/any/' . $token, ['payment_method' => $attribs]);
91
  }
92
 
93
  public function delete($token)
95
  $this->_validateId($token);
96
  $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token;
97
  $this->_http->delete($path);
98
+ return new Result\Successful();
99
+ }
100
+
101
+ public function grant($sharedPaymentMethodToken, $allowVaulting)
102
+ {
103
+ return $this->_doCreate(
104
+ '/payment_methods/grant',
105
+ [
106
+ 'payment_method' => [
107
+ 'shared_payment_method_token' => $sharedPaymentMethodToken,
108
+ 'allow_vaulting' => $allowVaulting
109
+ ]
110
+ ]
111
+ );
112
+ }
113
+
114
+ public function revoke($sharedPaymentMethodToken)
115
+ {
116
+ return $this->_doCreate(
117
+ '/payment_methods/revoke',
118
+ [
119
+ 'payment_method' => [
120
+ 'shared_payment_method_token' => $sharedPaymentMethodToken
121
+ ]
122
+ ]
123
+ );
124
  }
125
 
126
  private static function baseSignature()
127
  {
128
+ $billingAddressSignature = AddressGateway::createSignature();
129
+ $optionsSignature = [
130
  'failOnDuplicatePaymentMethod',
131
  'makeDefault',
132
  'verificationMerchantAccountId',
133
+ 'verifyCard',
134
+ 'verificationAmount'
135
+ ];
136
+ return [
137
  'billingAddressId',
138
  'cardholderName',
139
  'cvv',
144
  'number',
145
  'paymentMethodNonce',
146
  'token',
147
+ ['options' => $optionsSignature],
148
+ ['billingAddress' => $billingAddressSignature]
149
+ ];
150
  }
151
 
152
  public static function createSignature()
153
  {
154
+ $signature = array_merge(self::baseSignature(), ['customerId']);
155
  return $signature;
156
  }
157
 
158
  public static function updateSignature()
159
  {
160
+ $billingAddressSignature = AddressGateway::updateSignature();
161
+ array_push($billingAddressSignature, [
162
+ 'options' => [
163
  'updateExisting'
164
+ ]
165
+ ]);
166
+ $signature = array_merge(self::baseSignature(), [
167
  'deviceSessionId',
168
  'venmoSdkPaymentMethodCode',
169
  'fraudMerchantId',
170
+ ['billingAddress' => $billingAddressSignature]
171
+ ]);
172
  return $signature;
173
  }
174
 
207
  /**
208
  * generic method for validating incoming gateway responses
209
  *
210
+ * creates a new CreditCard or PayPalAccount object
211
+ * and encapsulates it inside a Result\Successful object, or
212
+ * encapsulates a Errors object inside a Result\Error
213
  * alternatively, throws an Unexpected exception if the response is invalid.
214
  *
215
  * @ignore
216
  * @param array $response gateway response values
217
+ * @return Result\Successful|Result\Error
218
+ * @throws Exception\Unexpected
219
  */
220
  private function _verifyGatewayResponse($response)
221
  {
222
  if (isset($response['creditCard'])) {
223
+ return new Result\Successful(
224
+ CreditCard::factory($response['creditCard']),
225
+ 'paymentMethod'
 
226
  );
227
  } else if (isset($response['paypalAccount'])) {
228
+ return new Result\Successful(
229
+ PayPalAccount::factory($response['paypalAccount']),
 
230
  "paymentMethod"
231
  );
232
  } else if (isset($response['coinbaseAccount'])) {
233
+ return new Result\Successful(
234
+ CoinbaseAccount::factory($response['coinbaseAccount']),
 
235
  "paymentMethod"
236
  );
237
  } else if (isset($response['applePayCard'])) {
238
+ return new Result\Successful(
239
+ ApplePayCard::factory($response['applePayCard']),
 
240
  "paymentMethod"
241
  );
242
  } else if (isset($response['androidPayCard'])) {
243
+ return new Result\Successful(
244
+ AndroidPayCard::factory($response['androidPayCard']),
245
+ "paymentMethod"
246
+ );
247
+ } else if (isset($response['amexExpressCheckoutCard'])) {
248
+ return new Result\Successful(
249
+ AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']),
250
  "paymentMethod"
251
  );
252
  } else if (isset($response['europeBankAccount'])) {
253
+ return new Result\Successful(
254
+ EuropeBankAccount::factory($response['europeBankAccount']),
 
255
  "paymentMethod"
256
  );
257
+ } else if (isset($response['usBankAccount'])) {
258
+ return new Result\Successful(
259
+ UsBankAccount::factory($response['usBankAccount']),
260
+ "paymentMethod"
261
+ );
262
+ } else if (isset($response['venmoAccount'])) {
263
+ return new Result\Successful(
264
+ VenmoAccount::factory($response['venmoAccount']),
265
+ "paymentMethod"
266
+ );
267
+ } else if (isset($response['paymentMethodNonce'])) {
268
+ return new Result\Successful(
269
+ PaymentMethodNonce::factory($response['paymentMethodNonce']),
270
+ "paymentMethodNonce"
271
+ );
272
  } else if (isset($response['apiErrorResponse'])) {
273
+ return new Result\Error($response['apiErrorResponse']);
274
  } else if (is_array($response)) {
275
+ return new Result\Successful(
276
+ UnknownPaymentMethod::factory($response),
277
  "paymentMethod"
278
  );
279
  } else {
280
+ throw new Exception\Unexpected(
281
  'Expected payment method or apiErrorResponse'
282
  );
283
  }
304
  }
305
  }
306
  }
307
+ class_alias('Braintree\PaymentMethodGateway', 'Braintree_PaymentMethodGateway');
lib/Gene/Braintree/{PaymentMethodNonce.php → braintree/braintree_php/lib/Braintree/PaymentMethodNonce.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
 
 
2
  /**
3
  * Braintree PaymentMethodNonce module
4
  *
5
  * @package Braintree
6
  * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -15,21 +17,21 @@
15
  *
16
  * @package Braintree
17
  * @category Resources
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  *
20
  */
21
- class Braintree_PaymentMethodNonce extends Braintree_Base
22
  {
23
  // static methods redirecting to gateway
24
 
25
  public static function create($token)
26
  {
27
- return Braintree_Configuration::gateway()->paymentMethodNonce()->create($token);
28
  }
29
 
30
  public static function find($nonce)
31
  {
32
- return Braintree_Configuration::gateway()->paymentMethodNonce()->find($nonce);
33
  }
34
 
35
  public static function factory($attributes)
@@ -46,7 +48,8 @@ class Braintree_PaymentMethodNonce extends Braintree_Base
46
  $this->_set('type', $nonceAttributes['type']);
47
 
48
  if(isset($nonceAttributes['threeDSecureInfo'])) {
49
- $this->_set('threeDSecureInfo', Braintree_ThreeDSecureInfo::factory($nonceAttributes['threeDSecureInfo']));
50
  }
51
  }
52
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree PaymentMethodNonce module
6
  *
7
  * @package Braintree
8
  * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
 
12
  /**
17
  *
18
  * @package Braintree
19
  * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
  */
23
+ class PaymentMethodNonce extends Base
24
  {
25
  // static methods redirecting to gateway
26
 
27
  public static function create($token)
28
  {
29
+ return Configuration::gateway()->paymentMethodNonce()->create($token);
30
  }
31
 
32
  public static function find($nonce)
33
  {
34
+ return Configuration::gateway()->paymentMethodNonce()->find($nonce);
35
  }
36
 
37
  public static function factory($attributes)
48
  $this->_set('type', $nonceAttributes['type']);
49
 
50
  if(isset($nonceAttributes['threeDSecureInfo'])) {
51
+ $this->_set('threeDSecureInfo', ThreeDSecureInfo::factory($nonceAttributes['threeDSecureInfo']));
52
  }
53
  }
54
  }
55
+ class_alias('Braintree\PaymentMethodNonce', 'Braintree_PaymentMethodNonce');
lib/Gene/Braintree/{PaymentMethodNonceGateway.php → braintree/braintree_php/lib/Braintree/PaymentMethodNonceGateway.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
 
 
2
  /**
3
  * Braintree PaymentMethodNonceGateway module
4
  *
5
  * @package Braintree
6
  * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -15,10 +17,10 @@
15
  *
16
  * @package Braintree
17
  * @category Resources
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  *
20
  */
21
- class Braintree_PaymentMethodNonceGateway
22
  {
23
  private $_gateway;
24
  private $_config;
@@ -28,7 +30,7 @@ class Braintree_PaymentMethodNonceGateway
28
  {
29
  $this->_gateway = $gateway;
30
  $this->_config = $gateway->config;
31
- $this->_http = new Braintree_Http($gateway->config);
32
  }
33
 
34
 
@@ -38,8 +40,8 @@ class Braintree_PaymentMethodNonceGateway
38
  $fullPath = $this->_config->merchantPath() . $subPath;
39
  $response = $this->_http->post($fullPath);
40
 
41
- return new Braintree_Result_Successful(
42
- Braintree_PaymentMethodNonce::factory($response['paymentMethodNonce']),
43
  "paymentMethodNonce"
44
  );
45
  }
@@ -53,12 +55,13 @@ class Braintree_PaymentMethodNonceGateway
53
  try {
54
  $path = $this->_config->merchantPath() . '/payment_method_nonces/' . $nonce;
55
  $response = $this->_http->get($path);
56
- return Braintree_PaymentMethodNonce::factory($response['paymentMethodNonce']);
57
- } catch (Braintree_Exception_NotFound $e) {
58
- throw new Braintree_Exception_NotFound(
59
  'payment method nonce with id ' . $nonce . ' not found'
60
  );
61
  }
62
 
63
  }
64
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree PaymentMethodNonceGateway module
6
  *
7
  * @package Braintree
8
  * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
 
12
  /**
17
  *
18
  * @package Braintree
19
  * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
  */
23
+ class PaymentMethodNonceGateway
24
  {
25
  private $_gateway;
26
  private $_config;
30
  {
31
  $this->_gateway = $gateway;
32
  $this->_config = $gateway->config;
33
+ $this->_http = new Http($gateway->config);
34
  }
35
 
36
 
40
  $fullPath = $this->_config->merchantPath() . $subPath;
41
  $response = $this->_http->post($fullPath);
42
 
43
+ return new Result\Successful(
44
+ PaymentMethodNonce::factory($response['paymentMethodNonce']),
45
  "paymentMethodNonce"
46
  );
47
  }
55
  try {
56
  $path = $this->_config->merchantPath() . '/payment_method_nonces/' . $nonce;
57
  $response = $this->_http->get($path);
58
+ return PaymentMethodNonce::factory($response['paymentMethodNonce']);
59
+ } catch (Exception\NotFound $e) {
60
+ throw new Exception\NotFound(
61
  'payment method nonce with id ' . $nonce . ' not found'
62
  );
63
  }
64
 
65
  }
66
  }
67
+ class_alias('Braintree\PaymentMethodNonceGateway', 'Braintree_PaymentMethodNonceGateway');
lib/Gene/Braintree/{Plan.php → braintree/braintree_php/lib/Braintree/Plan.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- class Braintree_Plan extends Braintree_Base
 
 
3
  {
4
  public static function factory($attributes)
5
  {
@@ -13,26 +15,26 @@ class Braintree_Plan extends Braintree_Base
13
  {
14
  $this->_attributes = $attributes;
15
 
16
- $addOnArray = array();
17
  if (isset($attributes['addOns'])) {
18
  foreach ($attributes['addOns'] AS $addOn) {
19
- $addOnArray[] = Braintree_AddOn::factory($addOn);
20
  }
21
  }
22
  $this->_attributes['addOns'] = $addOnArray;
23
 
24
- $discountArray = array();
25
  if (isset($attributes['discounts'])) {
26
  foreach ($attributes['discounts'] AS $discount) {
27
- $discountArray[] = Braintree_Discount::factory($discount);
28
  }
29
  }
30
  $this->_attributes['discounts'] = $discountArray;
31
 
32
- $planArray = array();
33
  if (isset($attributes['plans'])) {
34
  foreach ($attributes['plans'] AS $plan) {
35
- $planArray[] = Braintree_Plan::factory($plan);
36
  }
37
  }
38
  $this->_attributes['plans'] = $planArray;
@@ -43,6 +45,7 @@ class Braintree_Plan extends Braintree_Base
43
 
44
  public static function all()
45
  {
46
- return Braintree_Configuration::gateway()->plan()->all();
47
  }
48
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class Plan extends Base
5
  {
6
  public static function factory($attributes)
7
  {
15
  {
16
  $this->_attributes = $attributes;
17
 
18
+ $addOnArray = [];
19
  if (isset($attributes['addOns'])) {
20
  foreach ($attributes['addOns'] AS $addOn) {
21
+ $addOnArray[] = AddOn::factory($addOn);
22
  }
23
  }
24
  $this->_attributes['addOns'] = $addOnArray;
25
 
26
+ $discountArray = [];
27
  if (isset($attributes['discounts'])) {
28
  foreach ($attributes['discounts'] AS $discount) {
29
+ $discountArray[] = Discount::factory($discount);
30
  }
31
  }
32
  $this->_attributes['discounts'] = $discountArray;
33
 
34
+ $planArray = [];
35
  if (isset($attributes['plans'])) {
36
  foreach ($attributes['plans'] AS $plan) {
37
+ $planArray[] = self::factory($plan);
38
  }
39
  }
40
  $this->_attributes['plans'] = $planArray;
45
 
46
  public static function all()
47
  {
48
+ return Configuration::gateway()->plan()->all();
49
  }
50
  }
51
+ class_alias('Braintree\Plan', 'Braintree_Plan');
lib/Gene/Braintree/{PlanGateway.php → braintree/braintree_php/lib/Braintree/PlanGateway.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- class Braintree_PlanGateway
 
 
3
  {
4
  private $_gateway;
5
  private $_config;
@@ -10,7 +12,7 @@ class Braintree_PlanGateway
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
12
  $this->_config->assertHasAccessTokenOrKeys();
13
- $this->_http = new Braintree_Http($gateway->config);
14
  }
15
 
16
  public function all()
@@ -18,14 +20,15 @@ class Braintree_PlanGateway
18
  $path = $this->_config->merchantPath() . '/plans';
19
  $response = $this->_http->get($path);
20
  if (key_exists('plans', $response)){
21
- $plans = array("plan" => $response['plans']);
22
  } else {
23
- $plans = array("plan" => array());
24
  }
25
 
26
- return Braintree_Util::extractAttributeAsArray(
27
  $plans,
28
  'plan'
29
  );
30
  }
31
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class PlanGateway
5
  {
6
  private $_gateway;
7
  private $_config;
12
  $this->_gateway = $gateway;
13
  $this->_config = $gateway->config;
14
  $this->_config->assertHasAccessTokenOrKeys();
15
+ $this->_http = new Http($gateway->config);
16
  }
17
 
18
  public function all()
20
  $path = $this->_config->merchantPath() . '/plans';
21
  $response = $this->_http->get($path);
22
  if (key_exists('plans', $response)){
23
+ $plans = ["plan" => $response['plans']];
24
  } else {
25
+ $plans = ["plan" => []];
26
  }
27
 
28
+ return Util::extractAttributeAsArray(
29
  $plans,
30
  'plan'
31
  );
32
  }
33
  }
34
+ class_alias('Braintree\PlanGateway', 'Braintree_PlanGateway');
lib/Gene/Braintree/{RangeNode.php → braintree/braintree_php/lib/Braintree/RangeNode.php} RENAMED
@@ -1,38 +1,40 @@
1
  <?php
 
2
 
3
- class Braintree_RangeNode
4
  {
5
- function __construct($name)
6
  {
7
  $this->name = $name;
8
- $this->searchTerms = array();
9
  }
10
 
11
- function greaterThanOrEqualTo($value)
12
  {
13
  $this->searchTerms['min'] = $value;
14
  return $this;
15
  }
16
 
17
- function lessThanOrEqualTo($value)
18
  {
19
  $this->searchTerms['max'] = $value;
20
  return $this;
21
  }
22
 
23
- function is($value)
24
  {
25
  $this->searchTerms['is'] = $value;
26
  return $this;
27
  }
28
 
29
- function between($min, $max)
30
  {
31
  return $this->greaterThanOrEqualTo($min)->lessThanOrEqualTo($max);
32
  }
33
 
34
- function toParam()
35
  {
36
  return $this->searchTerms;
37
  }
38
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class RangeNode
5
  {
6
+ public function __construct($name)
7
  {
8
  $this->name = $name;
9
+ $this->searchTerms = [];
10
  }
11
 
12
+ public function greaterThanOrEqualTo($value)
13
  {
14
  $this->searchTerms['min'] = $value;
15
  return $this;
16
  }
17
 
18
+ public function lessThanOrEqualTo($value)
19
  {
20
  $this->searchTerms['max'] = $value;
21
  return $this;
22
  }
23
 
24
+ public function is($value)
25
  {
26
  $this->searchTerms['is'] = $value;
27
  return $this;
28
  }
29
 
30
+ public function between($min, $max)
31
  {
32
  return $this->greaterThanOrEqualTo($min)->lessThanOrEqualTo($max);
33
  }
34
 
35
+ public function toParam()
36
  {
37
  return $this->searchTerms;
38
  }
39
  }
40
+ class_alias('Braintree\RangeNode', 'Braintree_RangeNode');
lib/Gene/Braintree/{ResourceCollection.php → braintree/braintree_php/lib/Braintree/ResourceCollection.php} RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Braintree ResourceCollection
4
  * ResourceCollection is a container object for result data
@@ -7,7 +11,7 @@
7
  *
8
  * example:
9
  * <code>
10
- * $result = Braintree_Customer::all();
11
  *
12
  * foreach($result as $transaction) {
13
  * print_r($transaction->id);
@@ -16,12 +20,13 @@
16
  *
17
  * @package Braintree
18
  * @subpackage Utility
19
- * @copyright 2014 Braintree, a division of PayPal, Inc.
20
  */
21
- class Braintree_ResourceCollection implements Iterator
22
  {
23
- private $_index;
24
  private $_batchIndex;
 
 
25
  private $_items;
26
  private $_pageSize;
27
  private $_pager;
@@ -31,8 +36,8 @@ class Braintree_ResourceCollection implements Iterator
31
  *
32
  * expects an array of attributes with literal keys
33
  *
34
- * @param array $attributes
35
- * @param array $pagerAttribs
36
  */
37
  public function __construct($response, $pager)
38
  {
@@ -57,7 +62,7 @@ class Braintree_ResourceCollection implements Iterator
57
  public function firstItem()
58
  {
59
  $ids = $this->_ids;
60
- $page = $this->_getPage(array($ids[0]));
61
  return $page[0];
62
  }
63
 
@@ -108,7 +113,7 @@ class Braintree_ResourceCollection implements Iterator
108
  {
109
  if (empty($this->_ids))
110
  {
111
- $this->_items = array();
112
  }
113
  else
114
  {
@@ -121,21 +126,32 @@ class Braintree_ResourceCollection implements Iterator
121
  /**
122
  * requests the next page of results for the collection
123
  *
124
- * @return none
125
  */
126
  private function _getPage($ids)
127
  {
128
  $object = $this->_pager['object'];
129
  $method = $this->_pager['method'];
130
- $methodArgs = array();
131
  foreach ($this->_pager['methodArgs'] as $arg) {
132
  array_push($methodArgs, $arg);
133
  }
134
  array_push($methodArgs, $ids);
135
 
136
  return call_user_func_array(
137
- array($object, $method),
138
  $methodArgs
139
  );
140
  }
 
 
 
 
 
 
 
 
 
 
141
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use Iterator;
5
+
6
  /**
7
  * Braintree ResourceCollection
8
  * ResourceCollection is a container object for result data
11
  *
12
  * example:
13
  * <code>
14
+ * $result = Customer::all();
15
  *
16
  * foreach($result as $transaction) {
17
  * print_r($transaction->id);
20
  *
21
  * @package Braintree
22
  * @subpackage Utility
23
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
24
  */
25
+ class ResourceCollection implements Iterator
26
  {
 
27
  private $_batchIndex;
28
+ private $_ids;
29
+ private $_index;
30
  private $_items;
31
  private $_pageSize;
32
  private $_pager;
36
  *
37
  * expects an array of attributes with literal keys
38
  *
39
+ * @param array $response
40
+ * @param array $pager
41
  */
42
  public function __construct($response, $pager)
43
  {
62
  public function firstItem()
63
  {
64
  $ids = $this->_ids;
65
+ $page = $this->_getPage([$ids[0]]);
66
  return $page[0];
67
  }
68
 
113
  {
114
  if (empty($this->_ids))
115
  {
116
+ $this->_items = [];
117
  }
118
  else
119
  {
126
  /**
127
  * requests the next page of results for the collection
128
  *
129
+ * @return void
130
  */
131
  private function _getPage($ids)
132
  {
133
  $object = $this->_pager['object'];
134
  $method = $this->_pager['method'];
135
+ $methodArgs = [];
136
  foreach ($this->_pager['methodArgs'] as $arg) {
137
  array_push($methodArgs, $arg);
138
  }
139
  array_push($methodArgs, $ids);
140
 
141
  return call_user_func_array(
142
+ [$object, $method],
143
  $methodArgs
144
  );
145
  }
146
+
147
+ /**
148
+ * returns all IDs in the collection
149
+ *
150
+ * @return array
151
+ */
152
+ public function getIds()
153
+ {
154
+ return $this->_ids;
155
+ }
156
  }
157
+ class_alias('Braintree\ResourceCollection', 'Braintree_ResourceCollection');
lib/Gene/Braintree/{Result → braintree/braintree_php/lib/Braintree/Result}/CreditCardVerification.php RENAMED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
  /**
3
  * Braintree Credit Card Verification Result
4
  *
@@ -8,7 +13,7 @@
8
  *
9
  * @package Braintree
10
  * @subpackage Result
11
- * @copyright 2014 Braintree, a division of PayPal, Inc.
12
  *
13
  * @property-read string $avsErrorResponseCode
14
  * @property-read string $avsPostalCodeResponseCode
@@ -17,7 +22,7 @@
17
  * @property-read string $status
18
  *
19
  */
20
- class Braintree_Result_CreditCardVerification
21
  {
22
  // Status
23
  const FAILED = 'failed';
@@ -46,13 +51,13 @@ class Braintree_Result_CreditCardVerification
46
  * @ignore
47
  * @access protected
48
  * @param <type> $aAttribs array of properties to set - single level
49
- * @return none
50
  */
51
  private function _initializeFromArray($attributes)
52
  {
53
  if(isset($attributes['riskData']))
54
  {
55
- $attributes['riskData'] = Braintree_RiskData::factory($attributes['riskData']);
56
  }
57
 
58
  $this->_attributes = $attributes;
@@ -63,7 +68,6 @@ class Braintree_Result_CreditCardVerification
63
  }
64
 
65
  /**
66
- *
67
  * @ignore
68
  */
69
  public function __get($name)
@@ -79,16 +83,17 @@ class Braintree_Result_CreditCardVerification
79
  public function __toString()
80
  {
81
  return __CLASS__ . '[' .
82
- Braintree_Util::attributesToString($this->_attributes) .']';
83
  }
84
 
85
  public static function allStatuses()
86
  {
87
- return array(
88
- Braintree_Result_creditCardVerification::FAILED,
89
- Braintree_Result_creditCardVerification::GATEWAY_REJECTED,
90
- Braintree_Result_creditCardVerification::PROCESSOR_DECLINED,
91
- Braintree_Result_creditCardVerification::VERIFIED,
92
- );
93
  }
94
  }
 
1
  <?php
2
+ namespace Braintree\Result;
3
+
4
+ use Braintree\RiskData;
5
+ use Braintree\Util;
6
+
7
  /**
8
  * Braintree Credit Card Verification Result
9
  *
13
  *
14
  * @package Braintree
15
  * @subpackage Result
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
  *
18
  * @property-read string $avsErrorResponseCode
19
  * @property-read string $avsPostalCodeResponseCode
22
  * @property-read string $status
23
  *
24
  */
25
+ class CreditCardVerification
26
  {
27
  // Status
28
  const FAILED = 'failed';
51
  * @ignore
52
  * @access protected
53
  * @param <type> $aAttribs array of properties to set - single level
54
+ * @return void
55
  */
56
  private function _initializeFromArray($attributes)
57
  {
58
  if(isset($attributes['riskData']))
59
  {
60
+ $attributes['riskData'] = RiskData::factory($attributes['riskData']);
61
  }
62
 
63
  $this->_attributes = $attributes;
68
  }
69
 
70
  /**
 
71
  * @ignore
72
  */
73
  public function __get($name)
83
  public function __toString()
84
  {
85
  return __CLASS__ . '[' .
86
+ Util::attributesToString($this->_attributes) . ']';
87
  }
88
 
89
  public static function allStatuses()
90
  {
91
+ return [
92
+ CreditCardVerification::FAILED,
93
+ CreditCardVerification::GATEWAY_REJECTED,
94
+ CreditCardVerification::PROCESSOR_DECLINED,
95
+ CreditCardVerification::VERIFIED
96
+ ];
97
  }
98
  }
99
+ class_alias('Braintree\Result\CreditCardVerification', 'Braintree_Result_CreditCardVerification');
lib/Gene/Braintree/{Result → braintree/braintree_php/lib/Braintree/Result}/Error.php RENAMED
@@ -1,4 +1,13 @@
1
  <?php
 
 
 
 
 
 
 
 
 
2
  /**
3
  * Braintree Error Result
4
  *
@@ -9,27 +18,26 @@
9
  * respond to the void request if it failed:
10
  *
11
  * <code>
12
- * $result = Braintree_Transaction::void('abc123');
13
  * if ($result->success) {
14
  * // Successful Result
15
  * } else {
16
- * // Braintree_Result_Error
17
  * }
18
  * </code>
19
  *
20
  * @package Braintree
21
  * @subpackage Result
22
- * @copyright 2014 Braintree, a division of PayPal, Inc.
23
  *
24
  * @property-read array $params original passed params
25
- * @property-read object $errors Braintree_Error_ErrorCollection
26
- * @property-read object $creditCardVerification credit card verification data
27
  */
28
- class Braintree_Result_Error extends Braintree_Base
29
  {
30
- /**
31
- *
32
- * @var boolean always false
33
  */
34
  public $success = false;
35
 
@@ -46,10 +54,10 @@ class Braintree_Result_Error extends Braintree_Base
46
  $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
47
  $params = $this->params;
48
  foreach(array_slice($pieces, 0, -1) as $key) {
49
- $params = $params[Braintree_Util::delimiterToCamelCase($key)];
50
  }
51
  if ($key != 'custom_fields') {
52
- $finalKey = Braintree_Util::delimiterToCamelCase(end($pieces));
53
  } else {
54
  $finalKey = end($pieces);
55
  }
@@ -65,45 +73,52 @@ class Braintree_Result_Error extends Braintree_Base
65
  public function __construct($response)
66
  {
67
  $this->_attributes = $response;
68
- $this->_set('errors', new Braintree_Error_ErrorCollection($response['errors']));
69
 
70
  if(isset($response['verification'])) {
71
- $this->_set('creditCardVerification', new Braintree_Result_CreditCardVerification($response['verification']));
72
  } else {
73
  $this->_set('creditCardVerification', null);
74
  }
75
 
76
  if(isset($response['transaction'])) {
77
- $this->_set('transaction', Braintree_Transaction::factory($response['transaction']));
78
  } else {
79
  $this->_set('transaction', null);
80
  }
81
 
82
  if(isset($response['subscription'])) {
83
- $this->_set('subscription', Braintree_Subscription::factory($response['subscription']));
84
  } else {
85
  $this->_set('subscription', null);
86
  }
87
 
88
  if(isset($response['merchantAccount'])) {
89
- $this->_set('merchantAccount', Braintree_MerchantAccount::factory($response['merchantAccount']));
90
  } else {
91
  $this->_set('merchantAccount', null);
92
  }
 
 
 
 
 
 
93
  }
94
 
95
  /**
96
  * create a printable representation of the object as:
97
  * ClassName[property=value, property=value]
98
  * @ignore
99
- * @return var
100
  */
101
  public function __toString()
102
  {
103
- $output = Braintree_Util::attributesToString($this->_attributes);
104
  if (isset($this->_creditCardVerification)) {
105
  $output .= sprintf('%s', $this->_creditCardVerification);
106
  }
107
- return __CLASS__ .'['.$output.']';
108
  }
109
  }
 
1
  <?php
2
+ namespace Braintree\Result;
3
+
4
+ use Braintree\Base;
5
+ use Braintree\Transaction;
6
+ use Braintree\Subscription;
7
+ use Braintree\MerchantAccount;
8
+ use Braintree\Util;
9
+ use Braintree\Error\ErrorCollection;
10
+
11
  /**
12
  * Braintree Error Result
13
  *
18
  * respond to the void request if it failed:
19
  *
20
  * <code>
21
+ * $result = Transaction::void('abc123');
22
  * if ($result->success) {
23
  * // Successful Result
24
  * } else {
25
+ * // Result\Error
26
  * }
27
  * </code>
28
  *
29
  * @package Braintree
30
  * @subpackage Result
31
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
32
  *
33
  * @property-read array $params original passed params
34
+ * @property-read \Braintree\Error\ErrorCollection $errors
35
+ * @property-read \Braintree\Result\CreditCardVerification $creditCardVerification credit card verification data
36
  */
37
+ class Error extends Base
38
  {
39
+ /**
40
+ * @var bool always false
 
41
  */
42
  public $success = false;
43
 
54
  $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
55
  $params = $this->params;
56
  foreach(array_slice($pieces, 0, -1) as $key) {
57
+ $params = $params[Util::delimiterToCamelCase($key)];
58
  }
59
  if ($key != 'custom_fields') {
60
+ $finalKey = Util::delimiterToCamelCase(end($pieces));
61
  } else {
62
  $finalKey = end($pieces);
63
  }
73
  public function __construct($response)
74
  {
75
  $this->_attributes = $response;
76
+ $this->_set('errors', new ErrorCollection($response['errors']));
77
 
78
  if(isset($response['verification'])) {
79
+ $this->_set('creditCardVerification', new CreditCardVerification($response['verification']));
80
  } else {
81
  $this->_set('creditCardVerification', null);
82
  }
83
 
84
  if(isset($response['transaction'])) {
85
+ $this->_set('transaction', Transaction::factory($response['transaction']));
86
  } else {
87
  $this->_set('transaction', null);
88
  }
89
 
90
  if(isset($response['subscription'])) {
91
+ $this->_set('subscription', Subscription::factory($response['subscription']));
92
  } else {
93
  $this->_set('subscription', null);
94
  }
95
 
96
  if(isset($response['merchantAccount'])) {
97
+ $this->_set('merchantAccount', MerchantAccount::factory($response['merchantAccount']));
98
  } else {
99
  $this->_set('merchantAccount', null);
100
  }
101
+
102
+ if(isset($response['verification'])) {
103
+ $this->_set('verification', new CreditCardVerification($response['verification']));
104
+ } else {
105
+ $this->_set('verification', null);
106
+ }
107
  }
108
 
109
  /**
110
  * create a printable representation of the object as:
111
  * ClassName[property=value, property=value]
112
  * @ignore
113
+ * @return string
114
  */
115
  public function __toString()
116
  {
117
+ $output = Util::attributesToString($this->_attributes);
118
  if (isset($this->_creditCardVerification)) {
119
  $output .= sprintf('%s', $this->_creditCardVerification);
120
  }
121
+ return __CLASS__ .'[' . $output . ']';
122
  }
123
  }
124
+ class_alias('Braintree\Result\Error', 'Braintree_Result_Error');
lib/Gene/Braintree/{Result → braintree/braintree_php/lib/Braintree/Result}/Successful.php RENAMED
@@ -1,29 +1,34 @@
1
  <?php
 
 
 
 
 
2
  /**
3
  * Braintree Successful Result
4
  *
5
  * A Successful Result will be returned from gateway methods when
6
  * validations pass. It will provide access to the created resource.
7
  *
8
- * For example, when creating a customer, Braintree_Result_Successful will
9
  * respond to <b>customer</b> like so:
10
  *
11
  * <code>
12
- * $result = Braintree_Customer::create(array('first_name' => "John"));
13
  * if ($result->success) {
14
- * // Braintree_Result_Successful
15
  * echo "Created customer {$result->customer->id}";
16
  * } else {
17
- * // Braintree_Result_Error
18
  * }
19
  * </code>
20
  *
21
  *
22
  * @package Braintree
23
  * @subpackage Result
24
- * @copyright 2014 Braintree, a division of PayPal, Inc.
25
  */
26
- class Braintree_Result_Successful extends Braintree_Instance
27
  {
28
  /**
29
  *
@@ -38,17 +43,18 @@ class Braintree_Result_Successful extends Braintree_Instance
38
 
39
  /**
40
  * @ignore
41
- * @param string $classToReturn name of class to instantiate
 
42
  */
43
- public function __construct($objsToReturn = array(), $propertyNames = array())
44
  {
45
  // Sanitize arguments (preserves backwards compatibility)
46
- if (!is_array($objsToReturn)) { $objsToReturn = array($objsToReturn); }
47
- if (!is_array($propertyNames)) { $propertyNames = array($propertyNames); }
48
 
49
  $objects = $this->_mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn);
50
- $this->_attributes = array();
51
- $this->_returnObjectNames = array();
52
 
53
  foreach ($objects as $propertyName => $objToReturn) {
54
 
@@ -67,7 +73,7 @@ class Braintree_Result_Successful extends Braintree_Instance
67
  */
68
  public function __toString()
69
  {
70
- $objects = array();
71
  foreach ($this->_returnObjectNames as $returnObjectName) {
72
  array_push($objects, $this->$returnObjectName);
73
  }
@@ -76,11 +82,12 @@ class Braintree_Result_Successful extends Braintree_Instance
76
 
77
  private function _mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn) {
78
  if(count($objsToReturn) != count($propertyNames)) {
79
- $propertyNames = array();
80
  foreach ($objsToReturn as $obj) {
81
- array_push($propertyNames, Braintree_Util::cleanClassName(get_class($obj)));
82
  }
83
  }
84
  return array_combine($propertyNames, $objsToReturn);
85
  }
86
  }
 
1
  <?php
2
+ namespace Braintree\Result;
3
+
4
+ use Braintree\Instance;
5
+ use Braintree\Util;
6
+
7
  /**
8
  * Braintree Successful Result
9
  *
10
  * A Successful Result will be returned from gateway methods when
11
  * validations pass. It will provide access to the created resource.
12
  *
13
+ * For example, when creating a customer, Successful will
14
  * respond to <b>customer</b> like so:
15
  *
16
  * <code>
17
+ * $result = Customer::create(array('first_name' => "John"));
18
  * if ($result->success) {
19
+ * // Successful
20
  * echo "Created customer {$result->customer->id}";
21
  * } else {
22
+ * // Error
23
  * }
24
  * </code>
25
  *
26
  *
27
  * @package Braintree
28
  * @subpackage Result
29
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
30
  */
31
+ class Successful extends Instance
32
  {
33
  /**
34
  *
43
 
44
  /**
45
  * @ignore
46
+ * @param array|null $objsToReturn
47
+ * @param array|null $propertyNames
48
  */
49
+ public function __construct($objsToReturn = [], $propertyNames = [])
50
  {
51
  // Sanitize arguments (preserves backwards compatibility)
52
+ if (!is_array($objsToReturn)) { $objsToReturn = [$objsToReturn]; }
53
+ if (!is_array($propertyNames)) { $propertyNames = [$propertyNames]; }
54
 
55
  $objects = $this->_mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn);
56
+ $this->_attributes = [];
57
+ $this->_returnObjectNames = [];
58
 
59
  foreach ($objects as $propertyName => $objToReturn) {
60
 
73
  */
74
  public function __toString()
75
  {
76
+ $objects = [];
77
  foreach ($this->_returnObjectNames as $returnObjectName) {
78
  array_push($objects, $this->$returnObjectName);
79
  }
82
 
83
  private function _mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn) {
84
  if(count($objsToReturn) != count($propertyNames)) {
85
+ $propertyNames = [];
86
  foreach ($objsToReturn as $obj) {
87
+ array_push($propertyNames, Util::cleanClassName(get_class($obj)));
88
  }
89
  }
90
  return array_combine($propertyNames, $objsToReturn);
91
  }
92
  }
93
+ class_alias('Braintree\Result\Successful', 'Braintree_Result_Successful');
lib/Gene/Braintree/{RiskData.php → braintree/braintree_php/lib/Braintree/RiskData.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- class Braintree_RiskData extends Braintree_Base
 
 
3
  {
4
  public static function factory($attributes)
5
  {
@@ -18,10 +20,11 @@ class Braintree_RiskData extends Braintree_Base
18
  * returns a string representation of the risk data
19
  * @return string
20
  */
21
- public function __toString()
22
  {
23
  return __CLASS__ . '[' .
24
- Braintree_Util::attributesToString($this->_attributes) .']';
25
  }
26
 
27
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class RiskData extends Base
5
  {
6
  public static function factory($attributes)
7
  {
20
  * returns a string representation of the risk data
21
  * @return string
22
  */
23
+ public function __toString()
24
  {
25
  return __CLASS__ . '[' .
26
+ Util::attributesToString($this->_attributes) .']';
27
  }
28
 
29
  }
30
+ class_alias('Braintree\RiskData', 'Braintree_RiskData');
lib/Gene/Braintree/{SettlementBatchSummary.php → braintree/braintree_php/lib/Braintree/SettlementBatchSummary.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
2
- class Braintree_SettlementBatchSummary extends Braintree_Base
 
 
3
  {
4
  /**
5
- *
6
  * @param array $attributes
7
- * @return Braintree_SettlementBatchSummary
8
  */
9
  public static function factory($attributes)
10
  {
@@ -30,13 +32,14 @@ class Braintree_SettlementBatchSummary extends Braintree_Base
30
 
31
  /**
32
  * static method redirecting to gateway
33
- *
34
  * @param string $settlement_date Date YYYY-MM-DD
35
  * @param string $groupByCustomField
36
- * @return Braintree_Result_Successful|Braintree_Result_Error
37
  */
38
  public static function generate($settlement_date, $groupByCustomField = NULL)
39
  {
40
- return Braintree_Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField);
41
  }
42
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class SettlementBatchSummary extends Base
5
  {
6
  /**
7
+ *
8
  * @param array $attributes
9
+ * @return SettlementBatchSummary
10
  */
11
  public static function factory($attributes)
12
  {
32
 
33
  /**
34
  * static method redirecting to gateway
35
+ *
36
  * @param string $settlement_date Date YYYY-MM-DD
37
  * @param string $groupByCustomField
38
+ * @return Result\Successful|Result\Error
39
  */
40
  public static function generate($settlement_date, $groupByCustomField = NULL)
41
  {
42
+ return Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField);
43
  }
44
  }
45
+ class_alias('Braintree\SettlementBatchSummary', 'Braintree_SettlementBatchSummary');
lib/Gene/Braintree/{SettlementBatchSummaryGateway.php → braintree/braintree_php/lib/Braintree/SettlementBatchSummaryGateway.php} RENAMED
@@ -1,51 +1,52 @@
1
  <?php
 
2
 
3
- class Braintree_SettlementBatchSummaryGateway
4
  {
5
  /**
6
  *
7
- * @var Braintree_Gateway
8
  */
9
  private $_gateway;
10
-
11
  /**
12
  *
13
- * @var Braintree_Configuration
14
  */
15
  private $_config;
16
-
17
  /**
18
  *
19
- * @var Braintree_Http
20
  */
21
  private $_http;
22
 
23
  /**
24
- *
25
- * @param Braintree_Gateway $gateway
26
  */
27
  public function __construct($gateway)
28
  {
29
  $this->_gateway = $gateway;
30
  $this->_config = $gateway->config;
31
  $this->_config->assertHasAccessTokenOrKeys();
32
- $this->_http = new Braintree_Http($gateway->config);
33
  }
34
 
35
  /**
36
- *
37
  * @param string $settlement_date
38
  * @param string $groupByCustomField
39
- * @return Braintree_SettlementBatchSummary|Braintree_Result_Error
40
  */
41
  public function generate($settlement_date, $groupByCustomField = NULL)
42
  {
43
- $criteria = array('settlement_date' => $settlement_date);
44
  if (isset($groupByCustomField))
45
  {
46
  $criteria['group_by_custom_field'] = $groupByCustomField;
47
  }
48
- $params = array('settlement_batch_summary' => $criteria);
49
  $path = $this->_config->merchantPath() . '/settlement_batch_summary';
50
  $response = $this->_http->post($path, $params);
51
 
@@ -61,18 +62,18 @@ class Braintree_SettlementBatchSummaryGateway
61
  }
62
 
63
  /**
64
- *
65
  * @param string $groupByCustomField
66
  * @param array $records
67
- * @return array
68
  */
69
  private function _underscoreCustomField($groupByCustomField, $records)
70
  {
71
- $updatedRecords = array();
72
 
73
  foreach ($records as $record)
74
  {
75
- $camelized = Braintree_Util::delimiterToCamelCase($groupByCustomField);
76
  $record[$groupByCustomField] = $record[$camelized];
77
  unset($record[$camelized]);
78
  $updatedRecords[] = $record;
@@ -82,23 +83,24 @@ class Braintree_SettlementBatchSummaryGateway
82
  }
83
 
84
  /**
85
- *
86
  * @param array $response
87
- * @return \Braintree_Result_Successful|\Braintree_Result_Error
88
- * @throws Braintree_Exception_Unexpected
89
  */
90
  private function _verifyGatewayResponse($response)
91
  {
92
  if (isset($response['settlementBatchSummary'])) {
93
- return new Braintree_Result_Successful(
94
- Braintree_SettlementBatchSummary::factory($response['settlementBatchSummary'])
95
  );
96
  } else if (isset($response['apiErrorResponse'])) {
97
- return new Braintree_Result_Error($response['apiErrorResponse']);
98
  } else {
99
- throw new Braintree_Exception_Unexpected(
100
  "Expected settlementBatchSummary or apiErrorResponse"
101
  );
102
  }
103
  }
104
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class SettlementBatchSummaryGateway
5
  {
6
  /**
7
  *
8
+ * @var Gateway
9
  */
10
  private $_gateway;
11
+
12
  /**
13
  *
14
+ * @var Configuration
15
  */
16
  private $_config;
17
+
18
  /**
19
  *
20
+ * @var Http
21
  */
22
  private $_http;
23
 
24
  /**
25
+ *
26
+ * @param Gateway $gateway
27
  */
28
  public function __construct($gateway)
29
  {
30
  $this->_gateway = $gateway;
31
  $this->_config = $gateway->config;
32
  $this->_config->assertHasAccessTokenOrKeys();
33
+ $this->_http = new Http($gateway->config);
34
  }
35
 
36
  /**
37
+ *
38
  * @param string $settlement_date
39
  * @param string $groupByCustomField
40
+ * @return SettlementBatchSummary|Result\Error
41
  */
42
  public function generate($settlement_date, $groupByCustomField = NULL)
43
  {
44
+ $criteria = ['settlement_date' => $settlement_date];
45
  if (isset($groupByCustomField))
46
  {
47
  $criteria['group_by_custom_field'] = $groupByCustomField;
48
  }
49
+ $params = ['settlement_batch_summary' => $criteria];
50
  $path = $this->_config->merchantPath() . '/settlement_batch_summary';
51
  $response = $this->_http->post($path, $params);
52
 
62
  }
63
 
64
  /**
65
+ *
66
  * @param string $groupByCustomField
67
  * @param array $records
68
+ * @return array
69
  */
70
  private function _underscoreCustomField($groupByCustomField, $records)
71
  {
72
+ $updatedRecords = [];
73
 
74
  foreach ($records as $record)
75
  {
76
+ $camelized = Util::delimiterToCamelCase($groupByCustomField);
77
  $record[$groupByCustomField] = $record[$camelized];
78
  unset($record[$camelized]);
79
  $updatedRecords[] = $record;
83
  }
84
 
85
  /**
86
+ *
87
  * @param array $response
88
+ * @return Result\Successful|Result\Error
89
+ * @throws Exception\Unexpected
90
  */
91
  private function _verifyGatewayResponse($response)
92
  {
93
  if (isset($response['settlementBatchSummary'])) {
94
+ return new Result\Successful(
95
+ SettlementBatchSummary::factory($response['settlementBatchSummary'])
96
  );
97
  } else if (isset($response['apiErrorResponse'])) {
98
+ return new Result\Error($response['apiErrorResponse']);
99
  } else {
100
+ throw new Exception\Unexpected(
101
  "Expected settlementBatchSummary or apiErrorResponse"
102
  );
103
  }
104
  }
105
  }
106
+ class_alias('Braintree\SettlementBatchSummaryGateway', 'Braintree_SettlementBatchSummaryGateway');
lib/Gene/Braintree/{SignatureService.php → braintree/braintree_php/lib/Braintree/SignatureService.php} RENAMED
@@ -1,6 +1,7 @@
1
  <?php
 
2
 
3
- class Braintree_SignatureService
4
  {
5
 
6
  public function __construct($key, $digest)
@@ -20,3 +21,4 @@ class Braintree_SignatureService
20
  }
21
 
22
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
+ class SignatureService
5
  {
6
 
7
  public function __construct($key, $digest)
21
  }
22
 
23
  }
24
+ class_alias('Braintree\SignatureService', 'Braintree_SignatureService');
lib/Gene/Braintree/{Subscription.php → braintree/braintree_php/lib/Braintree/Subscription.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Braintree Subscription module
4
  *
@@ -9,9 +11,9 @@
9
  * PHP Version 5
10
  *
11
  * @package Braintree
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  */
14
- class Braintree_Subscription extends Braintree_Base
15
  {
16
  const ACTIVE = 'Active';
17
  const CANCELED = 'Canceled';
@@ -42,38 +44,38 @@ class Braintree_Subscription extends Braintree_Base
42
  {
43
  $this->_attributes = $attributes;
44
 
45
- $addOnArray = array();
46
  if (isset($attributes['addOns'])) {
47
  foreach ($attributes['addOns'] AS $addOn) {
48
- $addOnArray[] = Braintree_AddOn::factory($addOn);
49
  }
50
  }
51
  $this->_attributes['addOns'] = $addOnArray;
52
 
53
- $discountArray = array();
54
  if (isset($attributes['discounts'])) {
55
  foreach ($attributes['discounts'] AS $discount) {
56
- $discountArray[] = Braintree_Discount::factory($discount);
57
  }
58
  }
59
  $this->_attributes['discounts'] = $discountArray;
60
 
61
  if (isset($attributes['descriptor'])) {
62
- $this->_set('descriptor', new Braintree_Descriptor($attributes['descriptor']));
63
  }
64
 
65
- $statusHistory = array();
66
  if (isset($attributes['statusHistory'])) {
67
  foreach ($attributes['statusHistory'] AS $history) {
68
- $statusHistory[] = new Braintree_Subscription_StatusDetails($history);
69
  }
70
  }
71
  $this->_attributes['statusHistory'] = $statusHistory;
72
 
73
- $transactionArray = array();
74
  if (isset($attributes['transactions'])) {
75
  foreach ($attributes['transactions'] AS $transaction) {
76
- $transactionArray[] = Braintree_Transaction::factory($transaction);
77
  }
78
  }
79
  $this->_attributes['transactions'] = $transactionArray;
@@ -85,9 +87,9 @@ class Braintree_Subscription extends Braintree_Base
85
  */
86
  public function __toString()
87
  {
88
- $excludedAttributes = array('statusHistory');
89
 
90
- $displayAttributes = array();
91
  foreach($this->_attributes as $key => $val) {
92
  if (!in_array($key, $excludedAttributes)) {
93
  $displayAttributes[$key] = $val;
@@ -95,7 +97,7 @@ class Braintree_Subscription extends Braintree_Base
95
  }
96
 
97
  return __CLASS__ . '[' .
98
- Braintree_Util::attributesToString($displayAttributes) .']';
99
  }
100
 
101
 
@@ -103,36 +105,37 @@ class Braintree_Subscription extends Braintree_Base
103
 
104
  public static function create($attributes)
105
  {
106
- return Braintree_Configuration::gateway()->subscription()->create($attributes);
107
  }
108
 
109
  public static function find($id)
110
  {
111
- return Braintree_Configuration::gateway()->subscription()->find($id);
112
  }
113
 
114
  public static function search($query)
115
  {
116
- return Braintree_Configuration::gateway()->subscription()->search($query);
117
  }
118
 
119
  public static function fetch($query, $ids)
120
  {
121
- return Braintree_Configuration::gateway()->subscription()->fetch($query, $ids);
122
  }
123
 
124
  public static function update($subscriptionId, $attributes)
125
  {
126
- return Braintree_Configuration::gateway()->subscription()->update($subscriptionId, $attributes);
127
  }
128
 
129
  public static function retryCharge($subscriptionId, $amount = null)
130
  {
131
- return Braintree_Configuration::gateway()->subscription()->retryCharge($subscriptionId, $amount);
132
  }
133
 
134
  public static function cancel($subscriptionId)
135
  {
136
- return Braintree_Configuration::gateway()->subscription()->cancel($subscriptionId);
137
  }
138
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree Subscription module
6
  *
11
  * PHP Version 5
12
  *
13
  * @package Braintree
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  */
16
+ class Subscription extends Base
17
  {
18
  const ACTIVE = 'Active';
19
  const CANCELED = 'Canceled';
44
  {
45
  $this->_attributes = $attributes;
46
 
47
+ $addOnArray = [];
48
  if (isset($attributes['addOns'])) {
49
  foreach ($attributes['addOns'] AS $addOn) {
50
+ $addOnArray[] = AddOn::factory($addOn);
51
  }
52
  }
53
  $this->_attributes['addOns'] = $addOnArray;
54
 
55
+ $discountArray = [];
56
  if (isset($attributes['discounts'])) {
57
  foreach ($attributes['discounts'] AS $discount) {
58
+ $discountArray[] = Discount::factory($discount);
59
  }
60
  }
61
  $this->_attributes['discounts'] = $discountArray;
62
 
63
  if (isset($attributes['descriptor'])) {
64
+ $this->_set('descriptor', new Descriptor($attributes['descriptor']));
65
  }
66
 
67
+ $statusHistory = [];
68
  if (isset($attributes['statusHistory'])) {
69
  foreach ($attributes['statusHistory'] AS $history) {
70
+ $statusHistory[] = new Subscription\StatusDetails($history);
71
  }
72
  }
73
  $this->_attributes['statusHistory'] = $statusHistory;
74
 
75
+ $transactionArray = [];
76
  if (isset($attributes['transactions'])) {
77
  foreach ($attributes['transactions'] AS $transaction) {
78
+ $transactionArray[] = Transaction::factory($transaction);
79
  }
80
  }
81
  $this->_attributes['transactions'] = $transactionArray;
87
  */
88
  public function __toString()
89
  {
90
+ $excludedAttributes = ['statusHistory'];
91
 
92
+ $displayAttributes = [];
93
  foreach($this->_attributes as $key => $val) {
94
  if (!in_array($key, $excludedAttributes)) {
95
  $displayAttributes[$key] = $val;
97
  }
98
 
99
  return __CLASS__ . '[' .
100
+ Util::attributesToString($displayAttributes) .']';
101
  }
102
 
103
 
105
 
106
  public static function create($attributes)
107
  {
108
+ return Configuration::gateway()->subscription()->create($attributes);
109
  }
110
 
111
  public static function find($id)
112
  {
113
+ return Configuration::gateway()->subscription()->find($id);
114
  }
115
 
116
  public static function search($query)
117
  {
118
+ return Configuration::gateway()->subscription()->search($query);
119
  }
120
 
121
  public static function fetch($query, $ids)
122
  {
123
+ return Configuration::gateway()->subscription()->fetch($query, $ids);
124
  }
125
 
126
  public static function update($subscriptionId, $attributes)
127
  {
128
+ return Configuration::gateway()->subscription()->update($subscriptionId, $attributes);
129
  }
130
 
131
  public static function retryCharge($subscriptionId, $amount = null)
132
  {
133
+ return Configuration::gateway()->subscription()->retryCharge($subscriptionId, $amount);
134
  }
135
 
136
  public static function cancel($subscriptionId)
137
  {
138
+ return Configuration::gateway()->subscription()->cancel($subscriptionId);
139
  }
140
  }
141
+ class_alias('Braintree\Subscription', 'Braintree_Subscription');
lib/Gene/Braintree/{Subscription → braintree/braintree_php/lib/Braintree/Subscription}/StatusDetails.php RENAMED
@@ -1,19 +1,25 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Status details from a subscription
4
  * Creates an instance of StatusDetails, as part of a subscription response
5
  *
6
  * @package Braintree
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  *
9
  * @property-read string $price
 
 
10
  * @property-read string $balance
11
  * @property-read string $status
12
  * @property-read string $timestamp
13
  * @property-read string $subscriptionSource
14
  * @property-read string $user
15
- * @uses Braintree_Instance inherits methods
16
  */
17
- class Braintree_Subscription_StatusDetails extends Braintree_Instance
18
  {
19
  }
 
1
  <?php
2
+ namespace Braintree\Subscription;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Status details from a subscription
8
  * Creates an instance of StatusDetails, as part of a subscription response
9
  *
10
  * @package Braintree
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  *
13
  * @property-read string $price
14
+ * @property-read string $currencyIsoCode
15
+ * @property-read string $planId
16
  * @property-read string $balance
17
  * @property-read string $status
18
  * @property-read string $timestamp
19
  * @property-read string $subscriptionSource
20
  * @property-read string $user
 
21
  */
22
+ class StatusDetails extends Instance
23
  {
24
  }
25
+ class_alias('Braintree\Subscription\StatusDetails', 'Braintree_Subscription_StatusDetails');
lib/Gene/Braintree/{SubscriptionGateway.php → braintree/braintree_php/lib/Braintree/SubscriptionGateway.php} RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Braintree SubscriptionGateway module
4
  *
@@ -9,9 +13,9 @@
9
  * PHP Version 5
10
  *
11
  * @package Braintree
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  */
14
- class Braintree_SubscriptionGateway
15
  {
16
  private $_gateway;
17
  private $_config;
@@ -22,14 +26,14 @@ class Braintree_SubscriptionGateway
22
  $this->_gateway = $gateway;
23
  $this->_config = $gateway->config;
24
  $this->_config->assertHasAccessTokenOrKeys();
25
- $this->_http = new Braintree_Http($gateway->config);
26
  }
27
 
28
  public function create($attributes)
29
  {
30
- Braintree_Util::verifyKeys(self::_createSignature(), $attributes);
31
  $path = $this->_config->merchantPath() . '/subscriptions';
32
- $response = $this->_http->post($path, array('subscription' => $attributes));
33
  return $this->_verifyGatewayResponse($response);
34
  }
35
 
@@ -40,43 +44,43 @@ class Braintree_SubscriptionGateway
40
  try {
41
  $path = $this->_config->merchantPath() . '/subscriptions/' . $id;
42
  $response = $this->_http->get($path);
43
- return Braintree_Subscription::factory($response['subscription']);
44
- } catch (Braintree_Exception_NotFound $e) {
45
- throw new Braintree_Exception_NotFound('subscription with id ' . $id . ' not found');
46
  }
47
 
48
  }
49
 
50
  public function search($query)
51
  {
52
- $criteria = array();
53
  foreach ($query as $term) {
54
  $criteria[$term->name] = $term->toparam();
55
  }
56
 
57
 
58
  $path = $this->_config->merchantPath() . '/subscriptions/advanced_search_ids';
59
- $response = $this->_http->post($path, array('search' => $criteria));
60
- $pager = array(
61
  'object' => $this,
62
  'method' => 'fetch',
63
- 'methodArgs' => array($query)
64
- );
65
 
66
- return new Braintree_ResourceCollection($response, $pager);
67
  }
68
 
69
  public function fetch($query, $ids)
70
  {
71
- $criteria = array();
72
  foreach ($query as $term) {
73
  $criteria[$term->name] = $term->toparam();
74
  }
75
- $criteria["ids"] = Braintree_SubscriptionSearch::ids()->in($ids)->toparam();
76
  $path = $this->_config->merchantPath() . '/subscriptions/advanced_search';
77
- $response = $this->_http->post($path, array('search' => $criteria));
78
 
79
- return Braintree_Util::extractAttributeAsArray(
80
  $response['subscriptions'],
81
  'subscription'
82
  );
@@ -84,22 +88,22 @@ class Braintree_SubscriptionGateway
84
 
85
  public function update($subscriptionId, $attributes)
86
  {
87
- Braintree_Util::verifyKeys(self::_updateSignature(), $attributes);
88
  $path = $this->_config->merchantPath() . '/subscriptions/' . $subscriptionId;
89
- $response = $this->_http->put($path, array('subscription' => $attributes));
90
  return $this->_verifyGatewayResponse($response);
91
  }
92
 
93
  public function retryCharge($subscriptionId, $amount = null)
94
  {
95
- $transaction_params = array('type' => Braintree_Transaction::SALE,
96
- 'subscriptionId' => $subscriptionId);
97
  if (isset($amount)) {
98
  $transaction_params['amount'] = $amount;
99
  }
100
 
101
  $path = $this->_config->merchantPath() . '/transactions';
102
- $response = $this->_http->post($path, array('transaction' => $transaction_params));
103
  return $this->_verifyGatewayResponse($response);
104
  }
105
 
@@ -113,7 +117,7 @@ class Braintree_SubscriptionGateway
113
  private static function _createSignature()
114
  {
115
  return array_merge(
116
- array(
117
  'billingDayOfMonth',
118
  'firstBillingDate',
119
  'createdAt',
@@ -129,9 +133,9 @@ class Braintree_SubscriptionGateway
129
  'trialDuration',
130
  'trialDurationUnit',
131
  'trialPeriod',
132
- array('descriptor' => array('name', 'phone', 'url')),
133
- array('options' => array('doNotInheritAddOnsOrDiscounts', 'startImmediately')),
134
- ),
135
  self::_addOnDiscountSignature()
136
  );
137
  }
@@ -139,34 +143,34 @@ class Braintree_SubscriptionGateway
139
  private static function _updateSignature()
140
  {
141
  return array_merge(
142
- array(
143
  'merchantAccountId', 'numberOfBillingCycles', 'paymentMethodToken', 'planId',
144
  'paymentMethodNonce', 'id', 'neverExpires', 'price',
145
- array('descriptor' => array('name', 'phone', 'url')),
146
- array('options' => array('prorateCharges', 'replaceAllAddOnsAndDiscounts', 'revertSubscriptionOnProrationFailure')),
147
- ),
148
  self::_addOnDiscountSignature()
149
  );
150
  }
151
 
152
  private static function _addOnDiscountSignature()
153
  {
154
- return array(
155
- array(
156
- 'addOns' => array(
157
- array('add' => array('amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity')),
158
- array('update' => array('amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity')),
159
- array('remove' => array('_anyKey_')),
160
- )
161
- ),
162
- array(
163
- 'discounts' => array(
164
- array('add' => array('amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity')),
165
- array('update' => array('amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity')),
166
- array('remove' => array('_anyKey_')),
167
- )
168
- )
169
- );
170
  }
171
 
172
  /**
@@ -191,20 +195,21 @@ class Braintree_SubscriptionGateway
191
  private function _verifyGatewayResponse($response)
192
  {
193
  if (isset($response['subscription'])) {
194
- return new Braintree_Result_Successful(
195
- Braintree_Subscription::factory($response['subscription'])
196
  );
197
  } else if (isset($response['transaction'])) {
198
- // return a populated instance of Braintree_Transaction, for subscription retryCharge
199
- return new Braintree_Result_Successful(
200
- Braintree_Transaction::factory($response['transaction'])
201
  );
202
  } else if (isset($response['apiErrorResponse'])) {
203
- return new Braintree_Result_Error($response['apiErrorResponse']);
204
  } else {
205
- throw new Braintree_Exception_Unexpected(
206
  "Expected subscription, transaction, or apiErrorResponse"
207
  );
208
  }
209
  }
210
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
  /**
7
  * Braintree SubscriptionGateway module
8
  *
13
  * PHP Version 5
14
  *
15
  * @package Braintree
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
  */
18
+ class SubscriptionGateway
19
  {
20
  private $_gateway;
21
  private $_config;
26
  $this->_gateway = $gateway;
27
  $this->_config = $gateway->config;
28
  $this->_config->assertHasAccessTokenOrKeys();
29
+ $this->_http = new Http($gateway->config);
30
  }
31
 
32
  public function create($attributes)
33
  {
34
+ Util::verifyKeys(self::_createSignature(), $attributes);
35
  $path = $this->_config->merchantPath() . '/subscriptions';
36
+ $response = $this->_http->post($path, ['subscription' => $attributes]);
37
  return $this->_verifyGatewayResponse($response);
38
  }
39
 
44
  try {
45
  $path = $this->_config->merchantPath() . '/subscriptions/' . $id;
46
  $response = $this->_http->get($path);
47
+ return Subscription::factory($response['subscription']);
48
+ } catch (Exception\NotFound $e) {
49
+ throw new Exception\NotFound('subscription with id ' . $id . ' not found');
50
  }
51
 
52
  }
53
 
54
  public function search($query)
55
  {
56
+ $criteria = [];
57
  foreach ($query as $term) {
58
  $criteria[$term->name] = $term->toparam();
59
  }
60
 
61
 
62
  $path = $this->_config->merchantPath() . '/subscriptions/advanced_search_ids';
63
+ $response = $this->_http->post($path, ['search' => $criteria]);
64
+ $pager = [
65
  'object' => $this,
66
  'method' => 'fetch',
67
+ 'methodArgs' => [$query]
68
+ ];
69
 
70
+ return new ResourceCollection($response, $pager);
71
  }
72
 
73
  public function fetch($query, $ids)
74
  {
75
+ $criteria = [];
76
  foreach ($query as $term) {
77
  $criteria[$term->name] = $term->toparam();
78
  }
79
+ $criteria["ids"] = SubscriptionSearch::ids()->in($ids)->toparam();
80
  $path = $this->_config->merchantPath() . '/subscriptions/advanced_search';
81
+ $response = $this->_http->post($path, ['search' => $criteria]);
82
 
83
+ return Util::extractAttributeAsArray(
84
  $response['subscriptions'],
85
  'subscription'
86
  );
88
 
89
  public function update($subscriptionId, $attributes)
90
  {
91
+ Util::verifyKeys(self::_updateSignature(), $attributes);
92
  $path = $this->_config->merchantPath() . '/subscriptions/' . $subscriptionId;
93
+ $response = $this->_http->put($path, ['subscription' => $attributes]);
94
  return $this->_verifyGatewayResponse($response);
95
  }
96
 
97
  public function retryCharge($subscriptionId, $amount = null)
98
  {
99
+ $transaction_params = ['type' => Transaction::SALE,
100
+ 'subscriptionId' => $subscriptionId];
101
  if (isset($amount)) {
102
  $transaction_params['amount'] = $amount;
103
  }
104
 
105
  $path = $this->_config->merchantPath() . '/transactions';
106
+ $response = $this->_http->post($path, ['transaction' => $transaction_params]);
107
  return $this->_verifyGatewayResponse($response);
108
  }
109
 
117
  private static function _createSignature()
118
  {
119
  return array_merge(
120
+ [
121
  'billingDayOfMonth',
122
  'firstBillingDate',
123
  'createdAt',
133
  'trialDuration',
134
  'trialDurationUnit',
135
  'trialPeriod',
136
+ ['descriptor' => ['name', 'phone', 'url']],
137
+ ['options' => ['doNotInheritAddOnsOrDiscounts', 'startImmediately']],
138
+ ],
139
  self::_addOnDiscountSignature()
140
  );
141
  }
143
  private static function _updateSignature()
144
  {
145
  return array_merge(
146
+ [
147
  'merchantAccountId', 'numberOfBillingCycles', 'paymentMethodToken', 'planId',
148
  'paymentMethodNonce', 'id', 'neverExpires', 'price',
149
+ ['descriptor' => ['name', 'phone', 'url']],
150
+ ['options' => ['prorateCharges', 'replaceAllAddOnsAndDiscounts', 'revertSubscriptionOnProrationFailure']],
151
+ ],
152
  self::_addOnDiscountSignature()
153
  );
154
  }
155
 
156
  private static function _addOnDiscountSignature()
157
  {
158
+ return [
159
+ [
160
+ 'addOns' => [
161
+ ['add' => ['amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity']],
162
+ ['update' => ['amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity']],
163
+ ['remove' => ['_anyKey_']],
164
+ ]
165
+ ],
166
+ [
167
+ 'discounts' => [
168
+ ['add' => ['amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity']],
169
+ ['update' => ['amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity']],
170
+ ['remove' => ['_anyKey_']],
171
+ ]
172
+ ]
173
+ ];
174
  }
175
 
176
  /**
195
  private function _verifyGatewayResponse($response)
196
  {
197
  if (isset($response['subscription'])) {
198
+ return new Result\Successful(
199
+ Subscription::factory($response['subscription'])
200
  );
201
  } else if (isset($response['transaction'])) {
202
+ // return a populated instance of Transaction, for subscription retryCharge
203
+ return new Result\Successful(
204
+ Transaction::factory($response['transaction'])
205
  );
206
  } else if (isset($response['apiErrorResponse'])) {
207
+ return new Result\Error($response['apiErrorResponse']);
208
  } else {
209
+ throw new Exception\Unexpected(
210
  "Expected subscription, transaction, or apiErrorResponse"
211
  );
212
  }
213
  }
214
  }
215
+ class_alias('Braintree\SubscriptionGateway', 'Braintree_SubscriptionGateway');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/SubscriptionSearch.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class SubscriptionSearch
5
+ {
6
+ public static function billingCyclesRemaining()
7
+ {
8
+ return new RangeNode('billing_cycles_remaining');
9
+ }
10
+
11
+ public static function daysPastDue()
12
+ {
13
+ return new RangeNode('days_past_due');
14
+ }
15
+
16
+ public static function id()
17
+ {
18
+ return new TextNode('id');
19
+ }
20
+
21
+ public static function inTrialPeriod()
22
+ {
23
+ return new MultipleValueNode('in_trial_period', [true, false]);
24
+ }
25
+
26
+ public static function merchantAccountId()
27
+ {
28
+ return new MultipleValueNode('merchant_account_id');
29
+ }
30
+
31
+ public static function nextBillingDate()
32
+ {
33
+ return new RangeNode('next_billing_date');
34
+ }
35
+
36
+ public static function planId()
37
+ {
38
+ return new MultipleValueOrTextNode('plan_id');
39
+ }
40
+
41
+ public static function price()
42
+ {
43
+ return new RangeNode('price');
44
+ }
45
+
46
+ public static function status()
47
+ {
48
+ return new MultipleValueNode('status', [
49
+ Subscription::ACTIVE,
50
+ Subscription::CANCELED,
51
+ Subscription::EXPIRED,
52
+ Subscription::PAST_DUE,
53
+ Subscription::PENDING,
54
+ ]);
55
+ }
56
+
57
+ public static function transactionId()
58
+ {
59
+ return new TextNode('transaction_id');
60
+ }
61
+
62
+ public static function ids()
63
+ {
64
+ return new MultipleValueNode('ids');
65
+ }
66
+
67
+ public static function createdAt()
68
+ {
69
+ return new RangeNode('created_at');
70
+ }
71
+ }
72
+ class_alias('Braintree\SubscriptionSearch', 'Braintree_SubscriptionSearch');
lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/CreditCardNumbers.php RENAMED
@@ -1,61 +1,67 @@
1
  <?php
 
2
 
3
  /**
4
  * Credit card information used for testing purposes
5
  *
6
- * The constants contained in the Braintree_Test_CreditCardNumbers class provide
7
  * credit card numbers that should be used when working in the sandbox environment.
8
  * The sandbox will not accept any credit card numbers other than the ones listed below.
9
  *
10
  * @package Braintree
11
  * @subpackage Test
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  */
14
- class Braintree_Test_CreditCardNumbers
15
  {
16
- public static $amExes = array(
17
  '378282246310005',
18
  '371449635398431',
19
  '378734493671000',
20
- );
21
- public static $carteBlanches = array('30569309025904',);
22
- public static $dinersClubs = array('38520000023237',);
23
- public static $discoverCards = array(
24
  '6011111111111117',
25
  '6011000990139424',
26
- );
27
- public static $JCBs = array(
28
  '3530111333300000',
29
  '3566002020360505',
30
- );
31
 
32
  public static $masterCard = '5555555555554444';
33
  public static $masterCardInternational = '5105105105105100';
34
- public static $masterCards = array(
35
  '5105105105105100',
36
  '5555555555554444',
37
- );
38
 
39
  public static $visa = '4012888888881881';
40
  public static $visaInternational = '4009348888881881';
41
- public static $visas = array(
42
  '4009348888881881',
43
  '4012888888881881',
44
  '4111111111111111',
45
  '4000111111111115',
46
- );
47
 
48
- public static $unknowns = array(
49
  '1000000000000008',
50
- );
51
 
52
- public static $failsSandboxVerification = array(
53
  'AmEx' => '378734493671000',
54
  'Discover' => '6011000990139424',
55
  'MasterCard' => '5105105105105100',
56
  'Visa' => '4000111111111115',
57
- );
58
 
 
 
 
 
 
59
 
60
  public static function getAll()
61
  {
@@ -67,3 +73,4 @@ class Braintree_Test_CreditCardNumbers
67
  );
68
  }
69
  }
 
1
  <?php
2
+ namespace Braintree\Test;
3
 
4
  /**
5
  * Credit card information used for testing purposes
6
  *
7
+ * The constants contained in the Test\CreditCardNumbers class provide
8
  * credit card numbers that should be used when working in the sandbox environment.
9
  * The sandbox will not accept any credit card numbers other than the ones listed below.
10
  *
11
  * @package Braintree
12
  * @subpackage Test
13
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
14
  */
15
+ class CreditCardNumbers
16
  {
17
+ public static $amExes = [
18
  '378282246310005',
19
  '371449635398431',
20
  '378734493671000',
21
+ ];
22
+ public static $carteBlanches = ['30569309025904',];
23
+ public static $dinersClubs = ['38520000023237',];
24
+ public static $discoverCards = [
25
  '6011111111111117',
26
  '6011000990139424',
27
+ ];
28
+ public static $JCBs = [
29
  '3530111333300000',
30
  '3566002020360505',
31
+ ];
32
 
33
  public static $masterCard = '5555555555554444';
34
  public static $masterCardInternational = '5105105105105100';
35
+ public static $masterCards = [
36
  '5105105105105100',
37
  '5555555555554444',
38
+ ];
39
 
40
  public static $visa = '4012888888881881';
41
  public static $visaInternational = '4009348888881881';
42
+ public static $visas = [
43
  '4009348888881881',
44
  '4012888888881881',
45
  '4111111111111111',
46
  '4000111111111115',
47
+ ];
48
 
49
+ public static $unknowns = [
50
  '1000000000000008',
51
+ ];
52
 
53
+ public static $failsSandboxVerification = [
54
  'AmEx' => '378734493671000',
55
  'Discover' => '6011000990139424',
56
  'MasterCard' => '5105105105105100',
57
  'Visa' => '4000111111111115',
58
+ ];
59
 
60
+ public static $amexPayWithPoints = [
61
+ 'Success' => "371260714673002",
62
+ 'IneligibleCard' => "378267515471109",
63
+ 'InsufficientPoints' => "371544868764018",
64
+ ];
65
 
66
  public static function getAll()
67
  {
73
  );
74
  }
75
  }
76
+ class_alias('Braintree\Test\CreditCardNumbers', 'Braintree_Test_CreditCardNumbers');
lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/MerchantAccount.php RENAMED
@@ -1,12 +1,14 @@
1
  <?php
 
 
2
  /**
3
  * Merchant Account constants used for testing purposes
4
  *
5
  * @package Braintree
6
  * @subpackage Test
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
- class Braintree_Test_MerchantAccount
10
  {
11
  public static $approve = "approve_me";
12
 
@@ -17,3 +19,4 @@ class Braintree_Test_MerchantAccount
17
 
18
 
19
  }
 
1
  <?php
2
+ namespace Braintree\Test;
3
+
4
  /**
5
  * Merchant Account constants used for testing purposes
6
  *
7
  * @package Braintree
8
  * @subpackage Test
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
+ class MerchantAccount
12
  {
13
  public static $approve = "approve_me";
14
 
19
 
20
 
21
  }
22
+ class_alias('Braintree\Test\MerchantAccount', 'Braintree_Test_MerchantAccount');
lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/Nonces.php RENAMED
@@ -1,10 +1,12 @@
1
  <?php
 
 
2
  /**
3
  * Nonces used for testing purposes
4
  *
5
  * @package Braintree
6
  * @subpackage Test
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -15,9 +17,9 @@
15
  *
16
  * @package Braintree
17
  * @subpackage Test
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  */
20
- class Braintree_Test_Nonces
21
  {
22
  public static $transactable = "fake-valid-nonce";
23
  public static $consumed = "fake-consumed-nonce";
@@ -32,6 +34,7 @@ class Braintree_Test_Nonces
32
  public static $androidPayVisa = "fake-android-pay-visa-nonce";
33
  public static $androidPayMasterCard = "fake-android-pay-mastercard-nonce";
34
  public static $androidPayAmEx = "fake-android-pay-amex-nonce";
 
35
  public static $abstractTransactable = "fake-abstract-transactable-nonce";
36
  public static $europe = "fake-europe-bank-account-nonce";
37
  public static $coinbase = "fake-coinbase-nonce";
@@ -62,4 +65,6 @@ class Braintree_Test_Nonces
62
  public static $paypalFuturePaymentRefreshToken = "fake-paypal-future-refresh-token-nonce";
63
  public static $sepa = "fake-sepa-bank-account-nonce";
64
  public static $gatewayRejectedFraud = "fake-gateway-rejected-fraud-nonce";
 
65
  }
 
1
  <?php
2
+ namespace Braintree\Test;
3
+
4
  /**
5
  * Nonces used for testing purposes
6
  *
7
  * @package Braintree
8
  * @subpackage Test
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
 
12
  /**
17
  *
18
  * @package Braintree
19
  * @subpackage Test
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  */
22
+ class Nonces
23
  {
24
  public static $transactable = "fake-valid-nonce";
25
  public static $consumed = "fake-consumed-nonce";
34
  public static $androidPayVisa = "fake-android-pay-visa-nonce";
35
  public static $androidPayMasterCard = "fake-android-pay-mastercard-nonce";
36
  public static $androidPayAmEx = "fake-android-pay-amex-nonce";
37
+ public static $amexExpressCheckout = "fake-amex-express-checkout-nonce";
38
  public static $abstractTransactable = "fake-abstract-transactable-nonce";
39
  public static $europe = "fake-europe-bank-account-nonce";
40
  public static $coinbase = "fake-coinbase-nonce";
65
  public static $paypalFuturePaymentRefreshToken = "fake-paypal-future-refresh-token-nonce";
66
  public static $sepa = "fake-sepa-bank-account-nonce";
67
  public static $gatewayRejectedFraud = "fake-gateway-rejected-fraud-nonce";
68
+ public static $venmoAccount = "fake-venmo-account-nonce";
69
  }
70
+ class_alias('Braintree\Test\Nonces', 'Braintree_Test_Nonces');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Test/Transaction.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Test;
3
+
4
+ use Braintree\Configuration;
5
+
6
+ /**
7
+ * Transaction amounts used for testing purposes
8
+ *
9
+ * The constants in this class can be used to create transactions with
10
+ * the desired status in the sandbox environment.
11
+ *
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+ class Transaction
15
+ {
16
+ /**
17
+ * settle a transaction by id in sandbox
18
+ *
19
+ * @param string $id transaction id
20
+ * @param Configuration $config gateway config
21
+ * @return Transaction
22
+ */
23
+ public static function settle($transactionId)
24
+ {
25
+ return Configuration::gateway()->testing()->settle($transactionId);
26
+ }
27
+
28
+ /**
29
+ * settlement confirm a transaction by id in sandbox
30
+ *
31
+ * @param string $id transaction id
32
+ * @param Configuration $config gateway config
33
+ * @return Transaction
34
+ */
35
+ public static function settlementConfirm($transactionId)
36
+ {
37
+ return Configuration::gateway()->testing()->settlementConfirm($transactionId);
38
+ }
39
+
40
+ /**
41
+ * settlement decline a transaction by id in sandbox
42
+ *
43
+ * @param string $id transaction id
44
+ * @param Configuration $config gateway config
45
+ * @return Transaction
46
+ */
47
+ public static function settlementDecline($transactionId)
48
+ {
49
+ return Configuration::gateway()->testing()->settlementDecline($transactionId);
50
+ }
51
+
52
+ /**
53
+ * settlement pending a transaction by id in sandbox
54
+ *
55
+ * @param string $id transaction id
56
+ * @param Configuration $config gateway config
57
+ * @return Transaction
58
+ */
59
+ public static function settlementPending($transactionId)
60
+ {
61
+ return Configuration::gateway()->testing()->settlementPending($transactionId);
62
+ }
63
+ }
64
+ class_alias('Braintree\Test\Transaction', 'Braintree_Test_Transaction');
lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/TransactionAmounts.php RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
 
3
  /**
4
  * Transaction amounts used for testing purposes
@@ -8,10 +9,11 @@
8
  *
9
  * @package Braintree
10
  * @subpackage Test
11
- * @copyright 2014 Braintree, a division of PayPal, Inc.
12
  */
13
- class Braintree_Test_TransactionAmounts
14
  {
15
  public static $authorize = '1000.00';
16
  public static $decline = '2000.00';
17
  }
 
1
  <?php
2
+ namespace Braintree\Test;
3
 
4
  /**
5
  * Transaction amounts used for testing purposes
9
  *
10
  * @package Braintree
11
  * @subpackage Test
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
  */
14
+ class TransactionAmounts
15
  {
16
  public static $authorize = '1000.00';
17
  public static $decline = '2000.00';
18
  }
19
+ class_alias('Braintree\Test\TransactionAmounts', 'Braintree_Test_TransactionAmounts');
lib/Gene/Braintree/{Test → braintree/braintree_php/lib/Braintree/Test}/VenmoSdk.php RENAMED
@@ -1,12 +1,14 @@
1
  <?php
 
 
2
  /**
3
  * VenmoSdk payment method codes used for testing purposes
4
  *
5
  * @package Braintree
6
  * @subpackage Test
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
- class Braintree_Test_VenmoSdk
10
  {
11
  public static $visaPaymentMethodCode = "stub-4111111111111111";
12
 
@@ -26,3 +28,4 @@ class Braintree_Test_VenmoSdk
26
  return "stub-invalid-session";
27
  }
28
  }
 
1
  <?php
2
+ namespace Braintree\Test;
3
+
4
  /**
5
  * VenmoSdk payment method codes used for testing purposes
6
  *
7
  * @package Braintree
8
  * @subpackage Test
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
+ class VenmoSdk
12
  {
13
  public static $visaPaymentMethodCode = "stub-4111111111111111";
14
 
28
  return "stub-invalid-session";
29
  }
30
  }
31
+ class_alias('Braintree\Test\VenmoSdk', 'Braintree_Test_VenmoSdk');
lib/Gene/Braintree/{TestingGateway.php → braintree/braintree_php/lib/Braintree/TestingGateway.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- final class Braintree_TestingGateway
 
 
3
  {
4
  private $_gateway;
5
  private $_config;
@@ -9,7 +11,7 @@ final class Braintree_TestingGateway
9
  {
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
12
- $this->_http = new Braintree_Http($this->_config);
13
  }
14
 
15
  public function settle($transactionId)
@@ -37,13 +39,14 @@ final class Braintree_TestingGateway
37
  self::_checkEnvironment();
38
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . $testPath;
39
  $response = $this->_http->put($path);
40
- return Braintree_Transaction::factory($response['transaction']);
41
  }
42
 
43
  private function _checkEnvironment()
44
  {
45
- if (Braintree_Configuration::$global->getEnvironment() == 'production') {
46
- throw new Braintree_Exception_TestOperationPerformedInProduction();
47
  }
48
  }
49
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class TestingGateway
5
  {
6
  private $_gateway;
7
  private $_config;
11
  {
12
  $this->_gateway = $gateway;
13
  $this->_config = $gateway->config;
14
+ $this->_http = new Http($this->_config);
15
  }
16
 
17
  public function settle($transactionId)
39
  self::_checkEnvironment();
40
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . $testPath;
41
  $response = $this->_http->put($path);
42
+ return Transaction::factory($response['transaction']);
43
  }
44
 
45
  private function _checkEnvironment()
46
  {
47
+ if (Configuration::$global->getEnvironment() === 'production') {
48
+ throw new Exception\TestOperationPerformedInProduction();
49
  }
50
  }
51
  }
52
+ class_alias('Braintree\TestingGateway', 'Braintree_TestingGateway');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/TextNode.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class TextNode extends PartialMatchNode
5
+ {
6
+ public function contains($value)
7
+ {
8
+ $this->searchTerms["contains"] = strval($value);
9
+ return $this;
10
+ }
11
+ }
12
+ class_alias('Braintree\TextNode', 'Braintree_TextNode');
lib/Gene/Braintree/{ThreeDSecureInfo.php → braintree/braintree_php/lib/Braintree/ThreeDSecureInfo.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- class Braintree_ThreeDSecureInfo extends Braintree_Base
 
 
3
  {
4
  public static function factory($attributes)
5
  {
@@ -21,7 +23,8 @@ class Braintree_ThreeDSecureInfo extends Braintree_Base
21
  public function __toString()
22
  {
23
  return __CLASS__ . '[' .
24
- Braintree_Util::attributesToString($this->_attributes) .']';
25
  }
26
 
27
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class ThreeDSecureInfo extends Base
5
  {
6
  public static function factory($attributes)
7
  {
23
  public function __toString()
24
  {
25
  return __CLASS__ . '[' .
26
+ Util::attributesToString($this->_attributes) .']';
27
  }
28
 
29
  }
30
+ class_alias('Braintree\ThreeDSecureInfo', 'Braintree_ThreeDSecureInfo');
lib/Gene/Braintree/{Transaction.php → braintree/braintree_php/lib/Braintree/Transaction.php} RENAMED
@@ -1,4 +1,6 @@
1
  <?php
 
 
2
  /**
3
  * Braintree Transaction processor
4
  * Creates and manages transactions
@@ -8,7 +10,7 @@
8
  *
9
  * <b>Minimalistic example:</b>
10
  * <code>
11
- * Braintree_Transaction::saleNoValidate(array(
12
  * 'amount' => '100.00',
13
  * 'creditCard' => array(
14
  * 'number' => '5105105105105100',
@@ -19,7 +21,7 @@
19
  *
20
  * <b>Full example:</b>
21
  * <code>
22
- * Braintree_Transaction::saleNoValidate(array(
23
  * 'amount' => '100.00',
24
  * 'orderId' => '123',
25
  * 'channel' => 'MyShoppingCardProvider',
@@ -75,7 +77,7 @@
75
  * a transaction can be stored in the vault by setting
76
  * <i>transaction[options][storeInVault]</i> to true.
77
  * <code>
78
- * $transaction = Braintree_Transaction::saleNoValidate(array(
79
  * 'customer' => array(
80
  * 'firstName' => 'Adam',
81
  * 'lastName' => 'Williams'
@@ -98,7 +100,7 @@
98
  * To also store the billing address in the vault, pass the
99
  * <b>addBillingAddressToPaymentMethod</b> option.
100
  * <code>
101
- * Braintree_Transaction.saleNoValidate(array(
102
  * ...
103
  * 'options' => array(
104
  * 'storeInVault' => true
@@ -119,7 +121,7 @@
119
  * $transaction[options][submitForSettlement] to true.
120
  *
121
  * <code>
122
- * $transaction = Braintree_Transaction::saleNoValidate(array(
123
  * 'amount' => '100.00',
124
  * 'creditCard' => array(
125
  * 'number' => '5105105105105100',
@@ -137,7 +139,7 @@
137
  *
138
  * @package Braintree
139
  * @category Resources
140
- * @copyright 2014 Braintree, a division of PayPal, Inc.
141
  *
142
  *
143
  * @property-read string $avsErrorResponseCode
@@ -146,29 +148,30 @@
146
  * @property-read string $cvvResponseCode
147
  * @property-read string $id transaction id
148
  * @property-read string $amount transaction amount
149
- * @property-read object $billingDetails transaction billing address
150
  * @property-read string $createdAt transaction created timestamp
151
- * @property-read object $applePayCardDetails transaction Apple Pay card info
152
- * @property-read object $androidPayCardDetails transaction Android Pay card info
153
- * @property-read object $creditCardDetails transaction credit card info
154
- * @property-read object $coinbaseDetails transaction Coinbase account info
155
- * @property-read object $paypalDetails transaction paypal account info
156
- * @property-read object $customerDetails transaction customer info
 
 
157
  * @property-read array $customFields custom fields passed with the request
158
  * @property-read string $processorResponseCode gateway response code
159
  * @property-read string $additionalProcessorResponse raw response from processor
160
- * @property-read object $shippingDetails transaction shipping address
161
  * @property-read string $status transaction status
162
  * @property-read array $statusHistory array of StatusDetails objects
163
  * @property-read string $type transaction type
164
  * @property-read string $updatedAt transaction updated timestamp
165
- * @property-read object $disbursementDetails populated when transaction is disbursed
166
- * @property-read object $disputes populated when transaction is disputed
167
- * @property-read string $amexRewardsResponse AmEx Rewards response
168
  *
169
  */
170
 
171
- final class Braintree_Transaction extends Braintree_Base
172
  {
173
  // Transaction Status
174
  const AUTHORIZATION_EXPIRED = 'authorization_expired';
@@ -225,7 +228,7 @@ final class Braintree_Transaction extends Braintree_Base
225
  * @ignore
226
  * @access protected
227
  * @param array $transactionAttribs array of transaction data
228
- * @return none
229
  */
230
  protected function _initialize($transactionAttribs)
231
  {
@@ -233,7 +236,7 @@ final class Braintree_Transaction extends Braintree_Base
233
 
234
  if (isset($transactionAttribs['applePay'])) {
235
  $this->_set('applePayCardDetails',
236
- new Braintree_Transaction_ApplePayCardDetails(
237
  $transactionAttribs['applePay']
238
  )
239
  );
@@ -241,15 +244,31 @@ final class Braintree_Transaction extends Braintree_Base
241
 
242
  if (isset($transactionAttribs['androidPayCard'])) {
243
  $this->_set('androidPayCardDetails',
244
- new Braintree_Transaction_AndroidPayCardDetails(
245
  $transactionAttribs['androidPayCard']
246
  )
247
  );
248
  }
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  if (isset($transactionAttribs['creditCard'])) {
251
  $this->_set('creditCardDetails',
252
- new Braintree_Transaction_CreditCardDetails(
253
  $transactionAttribs['creditCard']
254
  )
255
  );
@@ -257,7 +276,7 @@ final class Braintree_Transaction extends Braintree_Base
257
 
258
  if (isset($transactionAttribs['coinbaseAccount'])) {
259
  $this->_set('coinbaseDetails',
260
- new Braintree_Transaction_CoinbaseDetails(
261
  $transactionAttribs['coinbaseAccount']
262
  )
263
  );
@@ -265,15 +284,23 @@ final class Braintree_Transaction extends Braintree_Base
265
 
266
  if (isset($transactionAttribs['europeBankAccount'])) {
267
  $this->_set('europeBankAccount',
268
- new Braintree_Transaction_EuropeBankAccountDetails(
269
  $transactionAttribs['europeBankAccount']
270
  )
271
  );
272
  }
273
 
 
 
 
 
 
 
 
 
274
  if (isset($transactionAttribs['paypal'])) {
275
  $this->_set('paypalDetails',
276
- new Braintree_Transaction_PayPalDetails(
277
  $transactionAttribs['paypal']
278
  )
279
  );
@@ -281,7 +308,7 @@ final class Braintree_Transaction extends Braintree_Base
281
 
282
  if (isset($transactionAttribs['customer'])) {
283
  $this->_set('customerDetails',
284
- new Braintree_Transaction_CustomerDetails(
285
  $transactionAttribs['customer']
286
  )
287
  );
@@ -289,7 +316,7 @@ final class Braintree_Transaction extends Braintree_Base
289
 
290
  if (isset($transactionAttribs['billing'])) {
291
  $this->_set('billingDetails',
292
- new Braintree_Transaction_AddressDetails(
293
  $transactionAttribs['billing']
294
  )
295
  );
@@ -297,7 +324,7 @@ final class Braintree_Transaction extends Braintree_Base
297
 
298
  if (isset($transactionAttribs['shipping'])) {
299
  $this->_set('shippingDetails',
300
- new Braintree_Transaction_AddressDetails(
301
  $transactionAttribs['shipping']
302
  )
303
  );
@@ -305,7 +332,7 @@ final class Braintree_Transaction extends Braintree_Base
305
 
306
  if (isset($transactionAttribs['subscription'])) {
307
  $this->_set('subscriptionDetails',
308
- new Braintree_Transaction_SubscriptionDetails(
309
  $transactionAttribs['subscription']
310
  )
311
  );
@@ -313,7 +340,7 @@ final class Braintree_Transaction extends Braintree_Base
313
 
314
  if (isset($transactionAttribs['descriptor'])) {
315
  $this->_set('descriptor',
316
- new Braintree_Descriptor(
317
  $transactionAttribs['descriptor']
318
  )
319
  );
@@ -321,49 +348,52 @@ final class Braintree_Transaction extends Braintree_Base
321
 
322
  if (isset($transactionAttribs['disbursementDetails'])) {
323
  $this->_set('disbursementDetails',
324
- new Braintree_DisbursementDetails($transactionAttribs['disbursementDetails'])
325
  );
326
  }
327
 
328
- $disputes = array();
329
  if (isset($transactionAttribs['disputes'])) {
330
  foreach ($transactionAttribs['disputes'] AS $dispute) {
331
- $disputes[] = Braintree_Dispute::factory($dispute);
332
  }
333
  }
334
 
335
  $this->_set('disputes', $disputes);
336
 
337
- $statusHistory = array();
338
  if (isset($transactionAttribs['statusHistory'])) {
339
  foreach ($transactionAttribs['statusHistory'] AS $history) {
340
- $statusHistory[] = new Braintree_Transaction_StatusDetails($history);
341
  }
342
  }
343
 
344
  $this->_set('statusHistory', $statusHistory);
345
 
346
- $addOnArray = array();
347
  if (isset($transactionAttribs['addOns'])) {
348
  foreach ($transactionAttribs['addOns'] AS $addOn) {
349
- $addOnArray[] = Braintree_AddOn::factory($addOn);
350
  }
351
  }
352
  $this->_set('addOns', $addOnArray);
353
 
354
- $discountArray = array();
355
  if (isset($transactionAttribs['discounts'])) {
356
  foreach ($transactionAttribs['discounts'] AS $discount) {
357
- $discountArray[] = Braintree_Discount::factory($discount);
358
  }
359
  }
360
  $this->_set('discounts', $discountArray);
361
 
362
  if(isset($transactionAttribs['riskData'])) {
363
- $this->_set('riskData', Braintree_RiskData::factory($transactionAttribs['riskData']));
364
  }
365
  if(isset($transactionAttribs['threeDSecureInfo'])) {
366
- $this->_set('threeDSecureInfo', Braintree_ThreeDSecureInfo::factory($transactionAttribs['threeDSecureInfo']));
 
 
 
367
  }
368
  }
369
 
@@ -374,17 +404,17 @@ final class Braintree_Transaction extends Braintree_Base
374
  public function __toString()
375
  {
376
  // array of attributes to print
377
- $display = array(
378
  'id', 'type', 'amount', 'status',
379
  'createdAt', 'creditCardDetails', 'customerDetails'
380
- );
381
 
382
- $displayAttributes = array();
383
  foreach ($display AS $attrib) {
384
  $displayAttributes[$attrib] = $this->$attrib;
385
  }
386
  return __CLASS__ . '[' .
387
- Braintree_Util::attributesToString($displayAttributes) .']';
388
  }
389
 
390
  public function isEqual($otherTx)
@@ -399,10 +429,11 @@ final class Braintree_Transaction extends Braintree_Base
399
  return null;
400
  }
401
  else {
402
- return Braintree_CreditCard::find($token);
403
  }
404
  }
405
 
 
406
  public function vaultCustomer()
407
  {
408
  $customerId = $this->customerDetails->id;
@@ -410,20 +441,21 @@ final class Braintree_Transaction extends Braintree_Base
410
  return null;
411
  }
412
  else {
413
- return Braintree_Customer::find($customerId);
414
  }
415
  }
416
 
 
417
  public function isDisbursed() {
418
  return $this->disbursementDetails->isValid();
419
  }
420
 
421
  /**
422
- * factory method: returns an instance of Braintree_Transaction
423
  * to the requesting method, with populated properties
424
  *
425
  * @ignore
426
- * @return object instance of Braintree_Transaction
427
  */
428
  public static function factory($attributes)
429
  {
@@ -437,91 +469,102 @@ final class Braintree_Transaction extends Braintree_Base
437
 
438
  public static function cloneTransaction($transactionId, $attribs)
439
  {
440
- return Braintree_Configuration::gateway()->transaction()->cloneTransaction($transactionId, $attribs);
441
  }
442
 
443
  public static function createFromTransparentRedirect($queryString)
444
  {
445
- return Braintree_Configuration::gateway()->transaction()->createFromTransparentRedirect($queryString);
446
  }
447
 
448
  public static function createTransactionUrl()
449
  {
450
- return Braintree_Configuration::gateway()->transaction()->createTransactionUrl();
451
  }
452
 
453
  public static function credit($attribs)
454
  {
455
- return Braintree_Configuration::gateway()->transaction()->credit($attribs);
456
  }
457
 
458
  public static function creditNoValidate($attribs)
459
  {
460
- return Braintree_Configuration::gateway()->transaction()->creditNoValidate($attribs);
461
  }
462
 
463
  public static function find($id)
464
  {
465
- return Braintree_Configuration::gateway()->transaction()->find($id);
466
  }
467
 
468
  public static function sale($attribs)
469
  {
470
- return Braintree_Configuration::gateway()->transaction()->sale($attribs);
471
  }
472
 
473
  public static function saleNoValidate($attribs)
474
  {
475
- return Braintree_Configuration::gateway()->transaction()->saleNoValidate($attribs);
476
  }
477
 
478
  public static function search($query)
479
  {
480
- return Braintree_Configuration::gateway()->transaction()->search($query);
481
  }
482
 
483
  public static function fetch($query, $ids)
484
  {
485
- return Braintree_Configuration::gateway()->transaction()->fetch($query, $ids);
486
  }
487
 
488
  public static function void($transactionId)
489
  {
490
- return Braintree_Configuration::gateway()->transaction()->void($transactionId);
491
  }
492
 
493
  public static function voidNoValidate($transactionId)
494
  {
495
- return Braintree_Configuration::gateway()->transaction()->voidNoValidate($transactionId);
 
 
 
 
 
 
 
 
 
 
496
  }
497
 
498
- public static function submitForSettlement($transactionId, $amount = null)
499
  {
500
- return Braintree_Configuration::gateway()->transaction()->submitForSettlement($transactionId, $amount);
501
  }
502
 
503
- public static function submitForSettlementNoValidate($transactionId, $amount = null)
504
  {
505
- return Braintree_Configuration::gateway()->transaction()->submitForSettlementNoValidate($transactionId, $amount);
506
  }
507
 
508
  public static function holdInEscrow($transactionId)
509
  {
510
- return Braintree_Configuration::gateway()->transaction()->holdInEscrow($transactionId);
511
  }
512
 
513
  public static function releaseFromEscrow($transactionId)
514
  {
515
- return Braintree_Configuration::gateway()->transaction()->releaseFromEscrow($transactionId);
516
  }
517
 
518
  public static function cancelRelease($transactionId)
519
  {
520
- return Braintree_Configuration::gateway()->transaction()->cancelRelease($transactionId);
521
  }
522
 
523
  public static function refund($transactionId, $amount = null)
524
  {
525
- return Braintree_Configuration::gateway()->transaction()->refund($transactionId, $amount);
526
  }
527
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree Transaction processor
6
  * Creates and manages transactions
10
  *
11
  * <b>Minimalistic example:</b>
12
  * <code>
13
+ * Transaction::saleNoValidate(array(
14
  * 'amount' => '100.00',
15
  * 'creditCard' => array(
16
  * 'number' => '5105105105105100',
21
  *
22
  * <b>Full example:</b>
23
  * <code>
24
+ * Transaction::saleNoValidate(array(
25
  * 'amount' => '100.00',
26
  * 'orderId' => '123',
27
  * 'channel' => 'MyShoppingCardProvider',
77
  * a transaction can be stored in the vault by setting
78
  * <i>transaction[options][storeInVault]</i> to true.
79
  * <code>
80
+ * $transaction = Transaction::saleNoValidate(array(
81
  * 'customer' => array(
82
  * 'firstName' => 'Adam',
83
  * 'lastName' => 'Williams'
100
  * To also store the billing address in the vault, pass the
101
  * <b>addBillingAddressToPaymentMethod</b> option.
102
  * <code>
103
+ * Transaction.saleNoValidate(array(
104
  * ...
105
  * 'options' => array(
106
  * 'storeInVault' => true
121
  * $transaction[options][submitForSettlement] to true.
122
  *
123
  * <code>
124
+ * $transaction = Transaction::saleNoValidate(array(
125
  * 'amount' => '100.00',
126
  * 'creditCard' => array(
127
  * 'number' => '5105105105105100',
139
  *
140
  * @package Braintree
141
  * @category Resources
142
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
143
  *
144
  *
145
  * @property-read string $avsErrorResponseCode
148
  * @property-read string $cvvResponseCode
149
  * @property-read string $id transaction id
150
  * @property-read string $amount transaction amount
151
+ * @property-read Braintree\Transaction\AddressDetails $billingDetails transaction billing address
152
  * @property-read string $createdAt transaction created timestamp
153
+ * @property-read Braintree\ApplePayCardDetails $applePayCardDetails transaction Apple Pay card info
154
+ * @property-read Braintree\AndroidPayCardDetails $androidPayCardDetails transaction Android Pay card info
155
+ * @property-read Braintree\AmexExpressCheckoutCardDetails $amexExpressCheckoutCardDetails transaction Amex Express Checkout card info
156
+ * @property-read Braintree\CreditCardDetails $creditCardDetails transaction credit card info
157
+ * @property-read Braintree\CoinbaseDetails $coinbaseDetails transaction Coinbase account info
158
+ * @property-read Braintree\PayPalDetails $paypalDetails transaction paypal account info
159
+ * @property-read Braintree\Transaction\CustomerDetails $customerDetails transaction customer info
160
+ * @property-read Braintree\VenmoAccount $venmoAccountDetails transaction Venmo Account info
161
  * @property-read array $customFields custom fields passed with the request
162
  * @property-read string $processorResponseCode gateway response code
163
  * @property-read string $additionalProcessorResponse raw response from processor
164
+ * @property-read Braintree\Transaction\AddressDetails $shippingDetails transaction shipping address
165
  * @property-read string $status transaction status
166
  * @property-read array $statusHistory array of StatusDetails objects
167
  * @property-read string $type transaction type
168
  * @property-read string $updatedAt transaction updated timestamp
169
+ * @property-read Braintree\Disbursement $disbursementDetails populated when transaction is disbursed
170
+ * @property-read Braintree\Dispute $disputes populated when transaction is disputed
 
171
  *
172
  */
173
 
174
+ class Transaction extends Base
175
  {
176
  // Transaction Status
177
  const AUTHORIZATION_EXPIRED = 'authorization_expired';
228
  * @ignore
229
  * @access protected
230
  * @param array $transactionAttribs array of transaction data
231
+ * @return void
232
  */
233
  protected function _initialize($transactionAttribs)
234
  {
236
 
237
  if (isset($transactionAttribs['applePay'])) {
238
  $this->_set('applePayCardDetails',
239
+ new Transaction\ApplePayCardDetails(
240
  $transactionAttribs['applePay']
241
  )
242
  );
244
 
245
  if (isset($transactionAttribs['androidPayCard'])) {
246
  $this->_set('androidPayCardDetails',
247
+ new Transaction\AndroidPayCardDetails(
248
  $transactionAttribs['androidPayCard']
249
  )
250
  );
251
  }
252
 
253
+ if (isset($transactionAttribs['amexExpressCheckoutCard'])) {
254
+ $this->_set('amexExpressCheckoutCardDetails',
255
+ new Transaction\AmexExpressCheckoutCardDetails(
256
+ $transactionAttribs['amexExpressCheckoutCard']
257
+ )
258
+ );
259
+ }
260
+
261
+ if (isset($transactionAttribs['venmoAccount'])) {
262
+ $this->_set('venmoAccountDetails',
263
+ new Transaction\VenmoAccountDetails(
264
+ $transactionAttribs['venmoAccount']
265
+ )
266
+ );
267
+ }
268
+
269
  if (isset($transactionAttribs['creditCard'])) {
270
  $this->_set('creditCardDetails',
271
+ new Transaction\CreditCardDetails(
272
  $transactionAttribs['creditCard']
273
  )
274
  );
276
 
277
  if (isset($transactionAttribs['coinbaseAccount'])) {
278
  $this->_set('coinbaseDetails',
279
+ new Transaction\CoinbaseDetails(
280
  $transactionAttribs['coinbaseAccount']
281
  )
282
  );
284
 
285
  if (isset($transactionAttribs['europeBankAccount'])) {
286
  $this->_set('europeBankAccount',
287
+ new Transaction\EuropeBankAccountDetails(
288
  $transactionAttribs['europeBankAccount']
289
  )
290
  );
291
  }
292
 
293
+ if (isset($transactionAttribs['usBankAccount'])) {
294
+ $this->_set('usBankAccount',
295
+ new Transaction\UsBankAccountDetails(
296
+ $transactionAttribs['usBankAccount']
297
+ )
298
+ );
299
+ }
300
+
301
  if (isset($transactionAttribs['paypal'])) {
302
  $this->_set('paypalDetails',
303
+ new Transaction\PayPalDetails(
304
  $transactionAttribs['paypal']
305
  )
306
  );
308
 
309
  if (isset($transactionAttribs['customer'])) {
310
  $this->_set('customerDetails',
311
+ new Transaction\CustomerDetails(
312
  $transactionAttribs['customer']
313
  )
314
  );
316
 
317
  if (isset($transactionAttribs['billing'])) {
318
  $this->_set('billingDetails',
319
+ new Transaction\AddressDetails(
320
  $transactionAttribs['billing']
321
  )
322
  );
324
 
325
  if (isset($transactionAttribs['shipping'])) {
326
  $this->_set('shippingDetails',
327
+ new Transaction\AddressDetails(
328
  $transactionAttribs['shipping']
329
  )
330
  );
332
 
333
  if (isset($transactionAttribs['subscription'])) {
334
  $this->_set('subscriptionDetails',
335
+ new Transaction\SubscriptionDetails(
336
  $transactionAttribs['subscription']
337
  )
338
  );
340
 
341
  if (isset($transactionAttribs['descriptor'])) {
342
  $this->_set('descriptor',
343
+ new Descriptor(
344
  $transactionAttribs['descriptor']
345
  )
346
  );
348
 
349
  if (isset($transactionAttribs['disbursementDetails'])) {
350
  $this->_set('disbursementDetails',
351
+ new DisbursementDetails($transactionAttribs['disbursementDetails'])
352
  );
353
  }
354
 
355
+ $disputes = [];
356
  if (isset($transactionAttribs['disputes'])) {
357
  foreach ($transactionAttribs['disputes'] AS $dispute) {
358
+ $disputes[] = Dispute::factory($dispute);
359
  }
360
  }
361
 
362
  $this->_set('disputes', $disputes);
363
 
364
+ $statusHistory = [];
365
  if (isset($transactionAttribs['statusHistory'])) {
366
  foreach ($transactionAttribs['statusHistory'] AS $history) {
367
+ $statusHistory[] = new Transaction\StatusDetails($history);
368
  }
369
  }
370
 
371
  $this->_set('statusHistory', $statusHistory);
372
 
373
+ $addOnArray = [];
374
  if (isset($transactionAttribs['addOns'])) {
375
  foreach ($transactionAttribs['addOns'] AS $addOn) {
376
+ $addOnArray[] = AddOn::factory($addOn);
377
  }
378
  }
379
  $this->_set('addOns', $addOnArray);
380
 
381
+ $discountArray = [];
382
  if (isset($transactionAttribs['discounts'])) {
383
  foreach ($transactionAttribs['discounts'] AS $discount) {
384
+ $discountArray[] = Discount::factory($discount);
385
  }
386
  }
387
  $this->_set('discounts', $discountArray);
388
 
389
  if(isset($transactionAttribs['riskData'])) {
390
+ $this->_set('riskData', RiskData::factory($transactionAttribs['riskData']));
391
  }
392
  if(isset($transactionAttribs['threeDSecureInfo'])) {
393
+ $this->_set('threeDSecureInfo', ThreeDSecureInfo::factory($transactionAttribs['threeDSecureInfo']));
394
+ }
395
+ if(isset($transactionAttribs['facilitatorDetails'])) {
396
+ $this->_set('facilitatorDetails', FacilitatorDetails::factory($transactionAttribs['facilitatorDetails']));
397
  }
398
  }
399
 
404
  public function __toString()
405
  {
406
  // array of attributes to print
407
+ $display = [
408
  'id', 'type', 'amount', 'status',
409
  'createdAt', 'creditCardDetails', 'customerDetails'
410
+ ];
411
 
412
+ $displayAttributes = [];
413
  foreach ($display AS $attrib) {
414
  $displayAttributes[$attrib] = $this->$attrib;
415
  }
416
  return __CLASS__ . '[' .
417
+ Util::attributesToString($displayAttributes) .']';
418
  }
419
 
420
  public function isEqual($otherTx)
429
  return null;
430
  }
431
  else {
432
+ return CreditCard::find($token);
433
  }
434
  }
435
 
436
+ /** @return void|Braintree\Customer */
437
  public function vaultCustomer()
438
  {
439
  $customerId = $this->customerDetails->id;
441
  return null;
442
  }
443
  else {
444
+ return Customer::find($customerId);
445
  }
446
  }
447
 
448
+ /** @return bool */
449
  public function isDisbursed() {
450
  return $this->disbursementDetails->isValid();
451
  }
452
 
453
  /**
454
+ * factory method: returns an instance of Transaction
455
  * to the requesting method, with populated properties
456
  *
457
  * @ignore
458
+ * @return Transaction
459
  */
460
  public static function factory($attributes)
461
  {
469
 
470
  public static function cloneTransaction($transactionId, $attribs)
471
  {
472
+ return Configuration::gateway()->transaction()->cloneTransaction($transactionId, $attribs);
473
  }
474
 
475
  public static function createFromTransparentRedirect($queryString)
476
  {
477
+ return Configuration::gateway()->transaction()->createFromTransparentRedirect($queryString);
478
  }
479
 
480
  public static function createTransactionUrl()
481
  {
482
+ return Configuration::gateway()->transaction()->createTransactionUrl();
483
  }
484
 
485
  public static function credit($attribs)
486
  {
487
+ return Configuration::gateway()->transaction()->credit($attribs);
488
  }
489
 
490
  public static function creditNoValidate($attribs)
491
  {
492
+ return Configuration::gateway()->transaction()->creditNoValidate($attribs);
493
  }
494
 
495
  public static function find($id)
496
  {
497
+ return Configuration::gateway()->transaction()->find($id);
498
  }
499
 
500
  public static function sale($attribs)
501
  {
502
+ return Configuration::gateway()->transaction()->sale($attribs);
503
  }
504
 
505
  public static function saleNoValidate($attribs)
506
  {
507
+ return Configuration::gateway()->transaction()->saleNoValidate($attribs);
508
  }
509
 
510
  public static function search($query)
511
  {
512
+ return Configuration::gateway()->transaction()->search($query);
513
  }
514
 
515
  public static function fetch($query, $ids)
516
  {
517
+ return Configuration::gateway()->transaction()->fetch($query, $ids);
518
  }
519
 
520
  public static function void($transactionId)
521
  {
522
+ return Configuration::gateway()->transaction()->void($transactionId);
523
  }
524
 
525
  public static function voidNoValidate($transactionId)
526
  {
527
+ return Configuration::gateway()->transaction()->voidNoValidate($transactionId);
528
+ }
529
+
530
+ public static function submitForSettlement($transactionId, $amount = null, $attribs = [])
531
+ {
532
+ return Configuration::gateway()->transaction()->submitForSettlement($transactionId, $amount, $attribs);
533
+ }
534
+
535
+ public static function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = [])
536
+ {
537
+ return Configuration::gateway()->transaction()->submitForSettlementNoValidate($transactionId, $amount, $attribs);
538
  }
539
 
540
+ public static function updateDetails($transactionId, $attribs = [])
541
  {
542
+ return Configuration::gateway()->transaction()->updateDetails($transactionId, $attribs);
543
  }
544
 
545
+ public static function submitForPartialSettlement($transactionId, $amount, $attribs = [])
546
  {
547
+ return Configuration::gateway()->transaction()->submitForPartialSettlement($transactionId, $amount, $attribs);
548
  }
549
 
550
  public static function holdInEscrow($transactionId)
551
  {
552
+ return Configuration::gateway()->transaction()->holdInEscrow($transactionId);
553
  }
554
 
555
  public static function releaseFromEscrow($transactionId)
556
  {
557
+ return Configuration::gateway()->transaction()->releaseFromEscrow($transactionId);
558
  }
559
 
560
  public static function cancelRelease($transactionId)
561
  {
562
+ return Configuration::gateway()->transaction()->cancelRelease($transactionId);
563
  }
564
 
565
  public static function refund($transactionId, $amount = null)
566
  {
567
+ return Configuration::gateway()->transaction()->refund($transactionId, $amount);
568
  }
569
  }
570
+ class_alias('Braintree\Transaction', 'Braintree_Transaction');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/AddressDetails.php RENAMED
@@ -1,11 +1,15 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Creates an instance of AddressDetails as returned from a transaction
4
  *
5
  *
6
  * @package Braintree
7
  * @subpackage Transaction
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  *
10
  * @property-read string $firstName
11
  * @property-read string $lastName
@@ -16,9 +20,9 @@
16
  * @property-read string $region
17
  * @property-read string $postalCode
18
  * @property-read string $countryName
19
- * @uses Braintree_Instance inherits methods
20
  */
21
- class Braintree_Transaction_AddressDetails extends Braintree_Instance
22
  {
23
- protected $_attributes = array();
24
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Creates an instance of AddressDetails as returned from a transaction
8
  *
9
  *
10
  * @package Braintree
11
  * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $firstName
15
  * @property-read string $lastName
20
  * @property-read string $region
21
  * @property-read string $postalCode
22
  * @property-read string $countryName
 
23
  */
24
+ class AddressDetails extends Instance
25
  {
26
+ protected $_attributes = [];
27
  }
28
+ class_alias('Braintree\Transaction\AddressDetails', 'Braintree_Transaction_AddressDetails');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+ /**
6
+ * Amex Express Checkout card details from a transaction
7
+ *
8
+ * @package Braintree
9
+ * @subpackage Transaction
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
+ */
12
+
13
+ /**
14
+ * creates an instance of AmexExpressCheckoutCardDetails
15
+ *
16
+ *
17
+ * @package Braintree
18
+ * @subpackage Transaction
19
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
20
+ *
21
+ * @property-read string $cardType
22
+ * @property-read string $bin
23
+ * @property-read string $cardMemberExpiryDate
24
+ * @property-read string $cardMemberNumber
25
+ * @property-read string $cardType
26
+ * @property-read string $sourceDescription
27
+ * @property-read string $token
28
+ * @property-read string $imageUrl
29
+ * @property-read string $expirationMonth
30
+ * @property-read string $expirationYear
31
+ * @uses Instance inherits methods
32
+ */
33
+ class AmexExpressCheckoutCardDetails extends Instance
34
+ {
35
+ protected $_attributes = [];
36
+
37
+ /**
38
+ * @ignore
39
+ */
40
+ public function __construct($attributes)
41
+ {
42
+ parent::__construct($attributes);
43
+ }
44
+ }
45
+ class_alias('Braintree\Transaction\AmexExpressCheckoutCardDetails', 'Braintree_Transaction_AmexExpressCheckoutCardDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/AndroidPayCardDetails.php RENAMED
@@ -1,10 +1,14 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Android Pay card details from a transaction
4
  *
5
  * @package Braintree
6
  * @subpackage Transaction
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -13,7 +17,7 @@
13
  *
14
  * @package Braintree
15
  * @subpackage Transaction
16
- * @copyright 2014 Braintree, a division of PayPal, Inc.
17
  *
18
  * @property-read string $bin
19
  * @property-read string $default
@@ -27,11 +31,10 @@
27
  * @property-read string $token
28
  * @property-read string $virtualCardLast4
29
  * @property-read string $virtualCardType
30
- * @uses Braintree_Instance inherits methods
31
  */
32
- class Braintree_Transaction_AndroidPayCardDetails extends Braintree_Instance
33
  {
34
- protected $_attributes = array();
35
 
36
  /**
37
  * @ignore
@@ -43,3 +46,4 @@ class Braintree_Transaction_AndroidPayCardDetails extends Braintree_Instance
43
  $this->_attributes['last4'] = $this->virtualCardLast4;
44
  }
45
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Android Pay card details from a transaction
8
  *
9
  * @package Braintree
10
  * @subpackage Transaction
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  */
13
 
14
  /**
17
  *
18
  * @package Braintree
19
  * @subpackage Transaction
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
  * @property-read string $bin
23
  * @property-read string $default
31
  * @property-read string $token
32
  * @property-read string $virtualCardLast4
33
  * @property-read string $virtualCardType
 
34
  */
35
+ class AndroidPayCardDetails extends Instance
36
  {
37
+ protected $_attributes = [];
38
 
39
  /**
40
  * @ignore
46
  $this->_attributes['last4'] = $this->virtualCardLast4;
47
  }
48
  }
49
+ class_alias('Braintree\Transaction\AndroidPayCardDetails', 'Braintree_Transaction_AndroidPayCardDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/ApplePayCardDetails.php RENAMED
@@ -1,10 +1,14 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Apple Pay card details from a transaction
4
  *
5
  * @package Braintree
6
  * @subpackage Transaction
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -13,7 +17,7 @@
13
  *
14
  * @package Braintree
15
  * @subpackage Transaction
16
- * @copyright 2014 Braintree, a division of PayPal, Inc.
17
  *
18
  * @property-read string $cardType
19
  * @property-read string $paymentInstrumentName
@@ -21,11 +25,10 @@
21
  * @property-read string $expirationYear
22
  * @property-read string $cardholderName
23
  * @property-read string $sourceDescription
24
- * @uses Braintree_Instance inherits methods
25
  */
26
- class Braintree_Transaction_ApplePayCardDetails extends Braintree_Instance
27
  {
28
- protected $_attributes = array();
29
 
30
  /**
31
  * @ignore
@@ -35,3 +38,4 @@ class Braintree_Transaction_ApplePayCardDetails extends Braintree_Instance
35
  parent::__construct($attributes);
36
  }
37
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Apple Pay card details from a transaction
8
  *
9
  * @package Braintree
10
  * @subpackage Transaction
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  */
13
 
14
  /**
17
  *
18
  * @package Braintree
19
  * @subpackage Transaction
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
  * @property-read string $cardType
23
  * @property-read string $paymentInstrumentName
25
  * @property-read string $expirationYear
26
  * @property-read string $cardholderName
27
  * @property-read string $sourceDescription
 
28
  */
29
+ class ApplePayCardDetails extends Instance
30
  {
31
+ protected $_attributes = [];
32
 
33
  /**
34
  * @ignore
38
  parent::__construct($attributes);
39
  }
40
  }
41
+ class_alias('Braintree\Transaction\ApplePayCardDetails', 'Braintree_Transaction_ApplePayCardDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/CoinbaseDetails.php RENAMED
@@ -1,10 +1,14 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Coinbase details from a transaction
4
  *
5
  * @package Braintree
6
  * @subpackage Transaction
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -13,18 +17,17 @@
13
  *
14
  * @package Braintree
15
  * @subpackage Transaction
16
- * @copyright 2014 Braintree, a division of PayPal, Inc.
17
  *
18
  * @property-read string $token
19
  * @property-read string $userId
20
  * @property-read string $userName
21
  * @property-read string $userEmail
22
  * @property-read string $imageUrl
23
- * @uses Braintree_Instance inherits methods
24
  */
25
- class Braintree_Transaction_CoinbaseDetails extends Braintree_Instance
26
  {
27
- protected $_attributes = array();
28
 
29
  /**
30
  * @ignore
@@ -34,3 +37,4 @@ class Braintree_Transaction_CoinbaseDetails extends Braintree_Instance
34
  parent::__construct($attributes);
35
  }
36
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Coinbase details from a transaction
8
  *
9
  * @package Braintree
10
  * @subpackage Transaction
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  */
13
 
14
  /**
17
  *
18
  * @package Braintree
19
  * @subpackage Transaction
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
  * @property-read string $token
23
  * @property-read string $userId
24
  * @property-read string $userName
25
  * @property-read string $userEmail
26
  * @property-read string $imageUrl
 
27
  */
28
+ class CoinbaseDetails extends Instance
29
  {
30
+ protected $_attributes = [];
31
 
32
  /**
33
  * @ignore
37
  parent::__construct($attributes);
38
  }
39
  }
40
+ class_alias('Braintree\Transaction\CoinbaseDetails', 'Braintree_Transaction_CoinbaseDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/CreditCardDetails.php RENAMED
@@ -1,11 +1,15 @@
1
  <?php
 
 
 
 
2
  /**
3
  * CreditCard details from a transaction
4
  * creates an instance of CreditCardDetails
5
  *
6
  * @package Braintree
7
  * @subpackage Transaction
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  *
10
  * @property-read string $bin
11
  * @property-read string $cardType
@@ -16,11 +20,10 @@
16
  * @property-read string $last4
17
  * @property-read string $maskedNumber
18
  * @property-read string $token
19
- * @uses Braintree_Instance inherits methods
20
  */
21
- class Braintree_Transaction_CreditCardDetails extends Braintree_Instance
22
  {
23
- protected $_attributes = array();
24
 
25
  /**
26
  * @ignore
@@ -33,3 +36,4 @@ class Braintree_Transaction_CreditCardDetails extends Braintree_Instance
33
 
34
  }
35
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * CreditCard details from a transaction
8
  * creates an instance of CreditCardDetails
9
  *
10
  * @package Braintree
11
  * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $bin
15
  * @property-read string $cardType
20
  * @property-read string $last4
21
  * @property-read string $maskedNumber
22
  * @property-read string $token
 
23
  */
24
+ class CreditCardDetails extends Instance
25
  {
26
+ protected $_attributes = [];
27
 
28
  /**
29
  * @ignore
36
 
37
  }
38
  }
39
+ class_alias('Braintree\Transaction\CreditCardDetails', 'Braintree_Transaction_CreditCardDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/CustomerDetails.php RENAMED
@@ -1,11 +1,15 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Customer details from a transaction
4
  * Creates an instance of customer details as returned from a transaction
5
  *
6
  * @package Braintree
7
  * @subpackage Transaction
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  *
10
  * @property-read string $company
11
  * @property-read string $email
@@ -15,8 +19,8 @@
15
  * @property-read string $lastName
16
  * @property-read string $phone
17
  * @property-read string $website
18
- * @uses Braintree_Instance inherits methods
19
  */
20
- class Braintree_Transaction_CustomerDetails extends Braintree_Instance
21
  {
22
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Customer details from a transaction
8
  * Creates an instance of customer details as returned from a transaction
9
  *
10
  * @package Braintree
11
  * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $company
15
  * @property-read string $email
19
  * @property-read string $lastName
20
  * @property-read string $phone
21
  * @property-read string $website
 
22
  */
23
+ class CustomerDetails extends Instance
24
  {
25
  }
26
+ class_alias('Braintree\Transaction\CustomerDetails', 'Braintree_Transaction_CustomerDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/EuropeBankAccountDetails.php RENAMED
@@ -1,11 +1,15 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Europe bank account details from a transaction
4
  * Creates an instance of europe bank account details as returned from a transaction
5
  *
6
  * @package Braintree
7
  * @subpackage Transaction
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  *
10
  * @property-read string $accountHolderName
11
  * @property-read string $bic
@@ -14,8 +18,8 @@
14
  * @property-read string $mandateReferenceNumber
15
  * @property-read string $maskedIban
16
  * @property-read string $token
17
- * @uses Braintree_Instance inherits methods
18
  */
19
- class Braintree_Transaction_EuropeBankAccountDetails extends Braintree_Instance
20
  {
21
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Europe bank account details from a transaction
8
  * Creates an instance of europe bank account details as returned from a transaction
9
  *
10
  * @package Braintree
11
  * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $accountHolderName
15
  * @property-read string $bic
18
  * @property-read string $mandateReferenceNumber
19
  * @property-read string $maskedIban
20
  * @property-read string $token
 
21
  */
22
+ class EuropeBankAccountDetails extends Instance
23
  {
24
  }
25
+ class_alias('Braintree\Transaction\EuropeBankAccountDetails', 'Braintree_Transaction_EuropeBankAccountDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/PayPalDetails.php RENAMED
@@ -1,10 +1,14 @@
1
  <?php
 
 
 
 
2
  /**
3
  * PayPal details from a transaction
4
  *
5
  * @package Braintree
6
  * @subpackage Transaction
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -13,7 +17,7 @@
13
  *
14
  * @package Braintree
15
  * @subpackage Transaction
16
- * @copyright 2014 Braintree, a division of PayPal, Inc.
17
  *
18
  * @property-read string $payerEmail
19
  * @property-read string $paymentId
@@ -23,11 +27,10 @@
23
  * @property-read string $transactionFeeAmount
24
  * @property-read string $transactionFeeCurrencyIsoCode
25
  * @property-read string $description
26
- * @uses Braintree_Instance inherits methods
27
  */
28
- class Braintree_Transaction_PayPalDetails extends Braintree_Instance
29
  {
30
- protected $_attributes = array();
31
 
32
  /**
33
  * @ignore
@@ -37,3 +40,4 @@ class Braintree_Transaction_PayPalDetails extends Braintree_Instance
37
  parent::__construct($attributes);
38
  }
39
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * PayPal details from a transaction
8
  *
9
  * @package Braintree
10
  * @subpackage Transaction
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  */
13
 
14
  /**
17
  *
18
  * @package Braintree
19
  * @subpackage Transaction
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
  * @property-read string $payerEmail
23
  * @property-read string $paymentId
27
  * @property-read string $transactionFeeAmount
28
  * @property-read string $transactionFeeCurrencyIsoCode
29
  * @property-read string $description
 
30
  */
31
+ class PayPalDetails extends Instance
32
  {
33
+ protected $_attributes = [];
34
 
35
  /**
36
  * @ignore
40
  parent::__construct($attributes);
41
  }
42
  }
43
+ class_alias('Braintree\Transaction\PayPalDetails', 'Braintree_Transaction_PayPalDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/StatusDetails.php RENAMED
@@ -1,18 +1,22 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Status details from a transaction
4
  * Creates an instance of StatusDetails, as part of a transaction response
5
  *
6
  * @package Braintree
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  *
9
  * @property-read string $amount
10
  * @property-read string $status
11
  * @property-read string $timestamp
12
  * @property-read string $transactionSource
13
  * @property-read string $user
14
- * @uses Braintree_Instance inherits methods
15
  */
16
- class Braintree_Transaction_StatusDetails extends Braintree_Instance
17
  {
18
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Status details from a transaction
8
  * Creates an instance of StatusDetails, as part of a transaction response
9
  *
10
  * @package Braintree
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  *
13
  * @property-read string $amount
14
  * @property-read string $status
15
  * @property-read string $timestamp
16
  * @property-read string $transactionSource
17
  * @property-read string $user
 
18
  */
19
+ class StatusDetails extends Instance
20
  {
21
  }
22
+ class_alias('Braintree\Transaction\StatusDetails', 'Braintree_Transaction_StatusDetails');
lib/Gene/Braintree/{Transaction → braintree/braintree_php/lib/Braintree/Transaction}/SubscriptionDetails.php RENAMED
@@ -1,15 +1,20 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Customer details from a transaction
4
  * Creates an instance of customer details as returned from a transaction
5
  *
6
  * @package Braintree
7
  * @subpackage Transaction
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  *
10
  * @property-read string $billing_period_start_date
11
  * @property-read string $billing_period_end_date
12
  */
13
- class Braintree_Transaction_SubscriptionDetails extends Braintree_Instance
14
  {
15
  }
 
1
  <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
  /**
7
  * Customer details from a transaction
8
  * Creates an instance of customer details as returned from a transaction
9
  *
10
  * @package Braintree
11
  * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read string $billing_period_start_date
15
  * @property-read string $billing_period_end_date
16
  */
17
+ class SubscriptionDetails extends Instance
18
  {
19
  }
20
+ class_alias('Braintree\Transaction\SubscriptionDetails', 'Braintree_Transaction_SubscriptionDetails');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Transaction/UsBankAccountDetails.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * CreditCard details from a transaction
8
+ * creates an instance of UsbankAccountDetails
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ *
14
+ * @property-read string $routingNumber
15
+ * @property-read string $last4
16
+ * @property-read string $accountType
17
+ * @property-read string $accountDescription
18
+ * @property-read string $accountHolderName
19
+ * @property-read string $token
20
+ * @property-read string $imageUrl
21
+ */
22
+ class UsBankAccountDetails extends Instance
23
+ {
24
+ protected $_attributes = [];
25
+
26
+ /**
27
+ * @ignore
28
+ */
29
+ public function __construct($attributes)
30
+ {
31
+ parent::__construct($attributes);
32
+
33
+ }
34
+ }
35
+ class_alias('Braintree\Transaction\UsBankAccountDetails', 'Braintree_Transaction_UsBankAccountDetails');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/Transaction/VenmoAccountDetails.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+ /**
6
+ * Venmo account details from a transaction
7
+ *
8
+ * @package Braintree
9
+ * @subpackage Transaction
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
+ */
12
+
13
+ /**
14
+ * creates an instance of VenmoAccountDetails
15
+ *
16
+ *
17
+ * @package Braintree
18
+ * @subpackage Transaction
19
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
20
+ *
21
+ * @property-read string $sourceDescription
22
+ * @property-read string $token
23
+ * @property-read string $imageUrl
24
+ * @property-read string $username
25
+ * @property-read string $venmo_user_id
26
+ * @uses Instance inherits methods
27
+ */
28
+ class VenmoAccountDetails extends Instance
29
+ {
30
+ protected $_attributes = array();
31
+
32
+ /**
33
+ * @ignore
34
+ */
35
+ public function __construct($attributes)
36
+ {
37
+ parent::__construct($attributes);
38
+ }
39
+ }
40
+ class_alias('Braintree\Transaction\VenmoAccountDetails', 'Braintree_Transaction_VenmoAccountDetails');
lib/Gene/Braintree/{TransactionGateway.php → braintree/braintree_php/lib/Braintree/TransactionGateway.php} RENAMED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  /**
3
  * Braintree TransactionGateway processor
4
  * Creates and manages transactions
@@ -10,10 +14,10 @@
10
  *
11
  * @package Braintree
12
  * @category Resources
13
- * @copyright 2014 Braintree, a division of PayPal, Inc.
14
  */
15
 
16
- final class Braintree_TransactionGateway
17
  {
18
  private $_gateway;
19
  private $_config;
@@ -24,13 +28,13 @@ final class Braintree_TransactionGateway
24
  $this->_gateway = $gateway;
25
  $this->_config = $gateway->config;
26
  $this->_config->assertHasAccessTokenOrKeys();
27
- $this->_http = new Braintree_Http($gateway->config);
28
  }
29
 
30
  public function cloneTransaction($transactionId, $attribs)
31
  {
32
- Braintree_Util::verifyKeys(self::cloneSignature(), $attribs);
33
- return $this->_doCreate('/transactions/' . $transactionId . '/clone', array('transactionClone' => $attribs));
34
  }
35
 
36
  /**
@@ -41,56 +45,57 @@ final class Braintree_TransactionGateway
41
  */
42
  private function create($attribs)
43
  {
44
- Braintree_Util::verifyKeys(self::createSignature(), $attribs);
45
- return $this->_doCreate('/transactions', array('transaction' => $attribs));
46
  }
47
 
48
  /**
49
- *
50
  * @ignore
51
  * @access private
52
  * @param array $attribs
53
  * @return object
54
- * @throws Braintree_Exception_ValidationError
55
  */
56
  private function createNoValidate($attribs)
57
  {
58
  $result = $this->create($attribs);
59
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
60
  }
61
  /**
62
  *
 
63
  * @access public
64
  * @param array $attribs
65
  * @return object
66
  */
67
  public function createFromTransparentRedirect($queryString)
68
  {
69
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
70
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString(
71
  $queryString
72
  );
73
  return $this->_doCreate(
74
  '/transactions/all/confirm_transparent_redirect_request',
75
- array('id' => $params['id'])
76
  );
77
  }
78
  /**
79
  *
 
80
  * @access public
81
  * @param none
82
  * @return string
83
  */
84
  public function createTransactionUrl()
85
  {
86
- trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
87
  return $this->_config->baseUrl() . $this->_config->merchantPath() .
88
  '/transactions/all/create_via_transparent_redirect_request';
89
  }
90
 
91
  public static function cloneSignature()
92
  {
93
- return array('amount', 'channel', array('options' => array('submitForSettlement')));
94
  }
95
 
96
  /**
@@ -99,7 +104,7 @@ final class Braintree_TransactionGateway
99
  */
100
  public static function createSignature()
101
  {
102
- return array(
103
  'amount',
104
  'billingAddressId',
105
  'channel',
@@ -114,36 +119,50 @@ final class Braintree_TransactionGateway
114
  'purchaseOrderNumber',
115
  'recurring',
116
  'serviceFeeAmount',
 
 
 
 
117
  'shippingAddressId',
118
  'taxAmount',
119
  'taxExempt',
120
  'threeDSecureToken',
 
121
  'type',
122
  'venmoSdkPaymentMethodCode',
123
- array('creditCard' =>
124
- array('token', 'cardholderName', 'cvv', 'expirationDate', 'expirationMonth', 'expirationYear', 'number'),
125
- ),
126
- array('customer' =>
127
- array(
 
 
 
128
  'id', 'company', 'email', 'fax', 'firstName',
129
- 'lastName', 'phone', 'website'),
130
- ),
131
- array('billing' =>
132
- array(
133
  'firstName', 'lastName', 'company', 'countryName',
134
  'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
135
  'extendedAddress', 'locality', 'postalCode', 'region',
136
- 'streetAddress'),
137
- ),
138
- array('shipping' =>
139
- array(
140
  'firstName', 'lastName', 'company', 'countryName',
141
  'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
142
  'extendedAddress', 'locality', 'postalCode', 'region',
143
- 'streetAddress'),
144
- ),
145
- array('options' =>
146
- array(
 
 
 
 
 
 
147
  'holdInEscrow',
148
  'storeInVault',
149
  'storeInVaultOnSuccess',
@@ -152,35 +171,35 @@ final class Braintree_TransactionGateway
152
  'venmoSdkSession',
153
  'storeShippingAddressInVault',
154
  'payeeEmail',
155
- array('three_d_secure' =>
156
- array('required')
157
- ),
158
- array('paypal' =>
159
- array(
160
  'payeeEmail',
161
  'customField',
162
- 'description'
163
- )
164
- ),
165
- array('amexRewards' =>
166
- array(
 
167
  'requestId',
168
  'points',
169
  'currencyAmount',
170
  'currencyIsoCode'
171
- )
172
- )
173
- ),
174
- ),
175
- array('customFields' => array('_anyKey_')
176
- ),
177
- array('descriptor' => array('name', 'phone', 'url')),
178
- array('paypalAccount' => array('payeeEmail')),
179
- array('apple_pay_card' => array('number', 'cardholder_name', 'cryptogram', 'expiration_month', 'expiration_year')),
180
- array('industry' =>
181
- array('industryType',
182
- array('data' =>
183
- array(
184
  'folioNumber',
185
  'checkInDate',
186
  'checkOutDate',
@@ -190,41 +209,56 @@ final class Braintree_TransactionGateway
190
  'lodgingCheckOutDate',
191
  'lodgingName',
192
  'roomRate'
193
- )
194
- )
195
- )
196
- )
197
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
 
200
  /**
201
  *
202
  * @access public
203
  * @param array $attribs
204
- * @return object
205
  */
206
  public function credit($attribs)
207
  {
208
- return $this->create(array_merge($attribs, array('type' => Braintree_Transaction::CREDIT)));
209
  }
210
 
211
  /**
212
  *
213
  * @access public
214
  * @param array $attribs
215
- * @return object
216
- * @throws Braintree_Exception_ValidationError
217
  */
218
  public function creditNoValidate($attribs)
219
  {
220
  $result = $this->credit($attribs);
221
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
222
  }
223
 
224
-
225
  /**
226
  * @access public
227
- *
 
228
  */
229
  public function find($id)
230
  {
@@ -232,13 +266,12 @@ final class Braintree_TransactionGateway
232
  try {
233
  $path = $this->_config->merchantPath() . '/transactions/' . $id;
234
  $response = $this->_http->get($path);
235
- return Braintree_Transaction::factory($response['transaction']);
236
- } catch (Braintree_Exception_NotFound $e) {
237
- throw new Braintree_Exception_NotFound(
238
  'transaction with id ' . $id . ' not found'
239
  );
240
  }
241
-
242
  }
243
  /**
244
  * new sale
@@ -247,7 +280,7 @@ final class Braintree_TransactionGateway
247
  */
248
  public function sale($attribs)
249
  {
250
- return $this->create(array_merge(array('type' => Braintree_Transaction::SALE), $attribs));
251
  }
252
 
253
  /**
@@ -255,12 +288,12 @@ final class Braintree_TransactionGateway
255
  * @access public
256
  * @param array $attribs
257
  * @return array
258
- * @throws Braintree_Exception_ValidationsFailed
259
  */
260
  public function saleNoValidate($attribs)
261
  {
262
  $result = $this->sale($attribs);
263
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
264
  }
265
 
266
  /**
@@ -272,42 +305,42 @@ final class Braintree_TransactionGateway
272
  *
273
  * @param mixed $query search query
274
  * @param array $options options such as page number
275
- * @return object Braintree_ResourceCollection
276
  * @throws InvalidArgumentException
277
  */
278
  public function search($query)
279
  {
280
- $criteria = array();
281
  foreach ($query as $term) {
282
  $criteria[$term->name] = $term->toparam();
283
  }
284
 
285
  $path = $this->_config->merchantPath() . '/transactions/advanced_search_ids';
286
- $response = $this->_http->post($path, array('search' => $criteria));
287
  if (array_key_exists('searchResults', $response)) {
288
- $pager = array(
289
  'object' => $this,
290
  'method' => 'fetch',
291
- 'methodArgs' => array($query)
292
- );
293
 
294
- return new Braintree_ResourceCollection($response, $pager);
295
  } else {
296
- throw new Braintree_Exception_DownForMaintenance();
297
  }
298
  }
299
 
300
  public function fetch($query, $ids)
301
  {
302
- $criteria = array();
303
  foreach ($query as $term) {
304
  $criteria[$term->name] = $term->toparam();
305
  }
306
- $criteria["ids"] = Braintree_TransactionSearch::ids()->in($ids)->toparam();
307
  $path = $this->_config->merchantPath() . '/transactions/advanced_search';
308
- $response = $this->_http->post($path, array('search' => $criteria));
309
 
310
- return Braintree_Util::extractattributeasarray(
311
  $response['creditCardTransactions'],
312
  'transaction'
313
  );
@@ -317,7 +350,7 @@ final class Braintree_TransactionGateway
317
  * void a transaction by id
318
  *
319
  * @param string $id transaction id
320
- * @return object Braintree_Result_Successful|Braintree_Result_Error
321
  */
322
  public function void($transactionId)
323
  {
@@ -333,22 +366,45 @@ final class Braintree_TransactionGateway
333
  public function voidNoValidate($transactionId)
334
  {
335
  $result = $this->void($transactionId);
336
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
337
  }
338
 
339
- public function submitForSettlement($transactionId, $amount = null)
340
  {
341
  $this->_validateId($transactionId);
 
 
342
 
343
  $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_settlement';
344
- $response = $this->_http->put($path, array('transaction' => array('amount' => $amount)));
345
  return $this->_verifyGatewayResponse($response);
346
  }
347
 
348
- public function submitForSettlementNoValidate($transactionId, $amount = null)
349
  {
350
- $result = $this->submitForSettlement($transactionId, $amount);
351
- return Braintree_Util::returnObjectOrThrowException(__CLASS__, $result);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  }
353
 
354
  public function holdInEscrow($transactionId)
@@ -356,7 +412,7 @@ final class Braintree_TransactionGateway
356
  $this->_validateId($transactionId);
357
 
358
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/hold_in_escrow';
359
- $response = $this->_http->put($path, array());
360
  return $this->_verifyGatewayResponse($response);
361
  }
362
 
@@ -365,7 +421,7 @@ final class Braintree_TransactionGateway
365
  $this->_validateId($transactionId);
366
 
367
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/release_from_escrow';
368
- $response = $this->_http->put($path, array());
369
  return $this->_verifyGatewayResponse($response);
370
  }
371
 
@@ -374,15 +430,24 @@ final class Braintree_TransactionGateway
374
  $this->_validateId($transactionId);
375
 
376
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/cancel_release';
377
- $response = $this->_http->put($path, array());
378
  return $this->_verifyGatewayResponse($response);
379
  }
380
 
381
- public function refund($transactionId, $amount = null)
382
  {
383
  self::_validateId($transactionId);
384
 
385
- $params = array('transaction' => array('amount' => $amount));
 
 
 
 
 
 
 
 
 
386
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/refund';
387
  $response = $this->_http->post($path, $params);
388
  return $this->_verifyGatewayResponse($response);
@@ -423,33 +488,33 @@ final class Braintree_TransactionGateway
423
  }
424
  }
425
 
426
-
427
  /**
428
  * generic method for validating incoming gateway responses
429
  *
430
- * creates a new Braintree_Transaction object and encapsulates
431
- * it inside a Braintree_Result_Successful object, or
432
- * encapsulates a Braintree_Errors object inside a Result_Error
433
  * alternatively, throws an Unexpected exception if the response is invalid.
434
  *
435
  * @ignore
436
  * @param array $response gateway response values
437
- * @return object Result_Successful or Result_Error
438
- * @throws Braintree_Exception_Unexpected
439
  */
440
  private function _verifyGatewayResponse($response)
441
  {
442
  if (isset($response['transaction'])) {
443
- // return a populated instance of Braintree_Transaction
444
- return new Braintree_Result_Successful(
445
- Braintree_Transaction::factory($response['transaction'])
446
  );
447
  } else if (isset($response['apiErrorResponse'])) {
448
- return new Braintree_Result_Error($response['apiErrorResponse']);
449
  } else {
450
- throw new Braintree_Exception_Unexpected(
451
  "Expected transaction or apiErrorResponse"
452
  );
453
  }
454
  }
455
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
  /**
7
  * Braintree TransactionGateway processor
8
  * Creates and manages transactions
14
  *
15
  * @package Braintree
16
  * @category Resources
17
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
18
  */
19
 
20
+ class TransactionGateway
21
  {
22
  private $_gateway;
23
  private $_config;
28
  $this->_gateway = $gateway;
29
  $this->_config = $gateway->config;
30
  $this->_config->assertHasAccessTokenOrKeys();
31
+ $this->_http = new Http($gateway->config);
32
  }
33
 
34
  public function cloneTransaction($transactionId, $attribs)
35
  {
36
+ Util::verifyKeys(self::cloneSignature(), $attribs);
37
+ return $this->_doCreate('/transactions/' . $transactionId . '/clone', ['transactionClone' => $attribs]);
38
  }
39
 
40
  /**
45
  */
46
  private function create($attribs)
47
  {
48
+ Util::verifyKeys(self::createSignature(), $attribs);
49
+ return $this->_doCreate('/transactions', ['transaction' => $attribs]);
50
  }
51
 
52
  /**
 
53
  * @ignore
54
  * @access private
55
  * @param array $attribs
56
  * @return object
57
+ * @throws Exception\ValidationError
58
  */
59
  private function createNoValidate($attribs)
60
  {
61
  $result = $this->create($attribs);
62
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
63
  }
64
  /**
65
  *
66
+ * @deprecated since version 2.3.0
67
  * @access public
68
  * @param array $attribs
69
  * @return object
70
  */
71
  public function createFromTransparentRedirect($queryString)
72
  {
73
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
74
+ $params = TransparentRedirect::parseAndValidateQueryString(
75
  $queryString
76
  );
77
  return $this->_doCreate(
78
  '/transactions/all/confirm_transparent_redirect_request',
79
+ ['id' => $params['id']]
80
  );
81
  }
82
  /**
83
  *
84
+ * @deprecated since version 2.3.0
85
  * @access public
86
  * @param none
87
  * @return string
88
  */
89
  public function createTransactionUrl()
90
  {
91
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
92
  return $this->_config->baseUrl() . $this->_config->merchantPath() .
93
  '/transactions/all/create_via_transparent_redirect_request';
94
  }
95
 
96
  public static function cloneSignature()
97
  {
98
+ return ['amount', 'channel', ['options' => ['submitForSettlement']]];
99
  }
100
 
101
  /**
104
  */
105
  public static function createSignature()
106
  {
107
+ return [
108
  'amount',
109
  'billingAddressId',
110
  'channel',
119
  'purchaseOrderNumber',
120
  'recurring',
121
  'serviceFeeAmount',
122
+ 'sharedPaymentMethodToken',
123
+ 'sharedCustomerId',
124
+ 'sharedShippingAddressId',
125
+ 'sharedBillingAddressId',
126
  'shippingAddressId',
127
  'taxAmount',
128
  'taxExempt',
129
  'threeDSecureToken',
130
+ 'transactionSource',
131
  'type',
132
  'venmoSdkPaymentMethodCode',
133
+ ['riskData' =>
134
+ ['customer_browser', 'customer_ip']
135
+ ],
136
+ ['creditCard' =>
137
+ ['token', 'cardholderName', 'cvv', 'expirationDate', 'expirationMonth', 'expirationYear', 'number'],
138
+ ],
139
+ ['customer' =>
140
+ [
141
  'id', 'company', 'email', 'fax', 'firstName',
142
+ 'lastName', 'phone', 'website'],
143
+ ],
144
+ ['billing' =>
145
+ [
146
  'firstName', 'lastName', 'company', 'countryName',
147
  'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
148
  'extendedAddress', 'locality', 'postalCode', 'region',
149
+ 'streetAddress'],
150
+ ],
151
+ ['shipping' =>
152
+ [
153
  'firstName', 'lastName', 'company', 'countryName',
154
  'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
155
  'extendedAddress', 'locality', 'postalCode', 'region',
156
+ 'streetAddress'],
157
+ ],
158
+ ['threeDSecurePassThru' =>
159
+ [
160
+ 'eciFlag',
161
+ 'cavv',
162
+ 'xid'],
163
+ ],
164
+ ['options' =>
165
+ [
166
  'holdInEscrow',
167
  'storeInVault',
168
  'storeInVaultOnSuccess',
171
  'venmoSdkSession',
172
  'storeShippingAddressInVault',
173
  'payeeEmail',
174
+ ['threeDSecure' =>
175
+ ['required']
176
+ ],
177
+ ['paypal' =>
178
+ [
179
  'payeeEmail',
180
  'customField',
181
+ 'description',
182
+ ['supplementaryData' => ['_anyKey_']],
183
+ ]
184
+ ],
185
+ ['amexRewards' =>
186
+ [
187
  'requestId',
188
  'points',
189
  'currencyAmount',
190
  'currencyIsoCode'
191
+ ]
192
+ ]
193
+ ],
194
+ ],
195
+ ['customFields' => ['_anyKey_']],
196
+ ['descriptor' => ['name', 'phone', 'url']],
197
+ ['paypalAccount' => ['payeeEmail']],
198
+ ['apple_pay_card' => ['number', 'cardholder_name', 'cryptogram', 'expiration_month', 'expiration_year']],
199
+ ['industry' =>
200
+ ['industryType',
201
+ ['data' =>
202
+ [
 
203
  'folioNumber',
204
  'checkInDate',
205
  'checkOutDate',
209
  'lodgingCheckOutDate',
210
  'lodgingName',
211
  'roomRate'
212
+ ]
213
+ ]
214
+ ]
215
+ ]
216
+ ];
217
+ }
218
+
219
+ public static function submitForSettlementSignature()
220
+ {
221
+ return ['orderId', ['descriptor' => ['name', 'phone', 'url']]];
222
+ }
223
+
224
+ public static function updateDetailsSignature()
225
+ {
226
+ return ['amount', 'orderId', ['descriptor' => ['name', 'phone', 'url']]];
227
+ }
228
+
229
+ public static function refundSignature()
230
+ {
231
+ return ['amount', 'orderId'];
232
  }
233
 
234
  /**
235
  *
236
  * @access public
237
  * @param array $attribs
238
+ * @return Result\Successful|Result\Error
239
  */
240
  public function credit($attribs)
241
  {
242
+ return $this->create(array_merge($attribs, ['type' => Transaction::CREDIT]));
243
  }
244
 
245
  /**
246
  *
247
  * @access public
248
  * @param array $attribs
249
+ * @return Result\Successful|Result\Error
250
+ * @throws Exception\ValidationError
251
  */
252
  public function creditNoValidate($attribs)
253
  {
254
  $result = $this->credit($attribs);
255
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
256
  }
257
 
 
258
  /**
259
  * @access public
260
+ * @param string id
261
+ * @return Transaction
262
  */
263
  public function find($id)
264
  {
266
  try {
267
  $path = $this->_config->merchantPath() . '/transactions/' . $id;
268
  $response = $this->_http->get($path);
269
+ return Transaction::factory($response['transaction']);
270
+ } catch (Exception\NotFound $e) {
271
+ throw new Exception\NotFound(
272
  'transaction with id ' . $id . ' not found'
273
  );
274
  }
 
275
  }
276
  /**
277
  * new sale
280
  */
281
  public function sale($attribs)
282
  {
283
+ return $this->create(array_merge(['type' => Transaction::SALE], $attribs));
284
  }
285
 
286
  /**
288
  * @access public
289
  * @param array $attribs
290
  * @return array
291
+ * @throws Exception\ValidationsFailed
292
  */
293
  public function saleNoValidate($attribs)
294
  {
295
  $result = $this->sale($attribs);
296
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
297
  }
298
 
299
  /**
305
  *
306
  * @param mixed $query search query
307
  * @param array $options options such as page number
308
+ * @return ResourceCollection
309
  * @throws InvalidArgumentException
310
  */
311
  public function search($query)
312
  {
313
+ $criteria = [];
314
  foreach ($query as $term) {
315
  $criteria[$term->name] = $term->toparam();
316
  }
317
 
318
  $path = $this->_config->merchantPath() . '/transactions/advanced_search_ids';
319
+ $response = $this->_http->post($path, ['search' => $criteria]);
320
  if (array_key_exists('searchResults', $response)) {
321
+ $pager = [
322
  'object' => $this,
323
  'method' => 'fetch',
324
+ 'methodArgs' => [$query]
325
+ ];
326
 
327
+ return new ResourceCollection($response, $pager);
328
  } else {
329
+ throw new Exception\DownForMaintenance();
330
  }
331
  }
332
 
333
  public function fetch($query, $ids)
334
  {
335
+ $criteria = [];
336
  foreach ($query as $term) {
337
  $criteria[$term->name] = $term->toparam();
338
  }
339
+ $criteria["ids"] = TransactionSearch::ids()->in($ids)->toparam();
340
  $path = $this->_config->merchantPath() . '/transactions/advanced_search';
341
+ $response = $this->_http->post($path, ['search' => $criteria]);
342
 
343
+ return Util::extractattributeasarray(
344
  $response['creditCardTransactions'],
345
  'transaction'
346
  );
350
  * void a transaction by id
351
  *
352
  * @param string $id transaction id
353
+ * @return Result\Successful|Result\Error
354
  */
355
  public function void($transactionId)
356
  {
366
  public function voidNoValidate($transactionId)
367
  {
368
  $result = $this->void($transactionId);
369
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
370
  }
371
 
372
+ public function submitForSettlement($transactionId, $amount = null, $attribs = [])
373
  {
374
  $this->_validateId($transactionId);
375
+ Util::verifyKeys(self::submitForSettlementSignature(), $attribs);
376
+ $attribs['amount'] = $amount;
377
 
378
  $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_settlement';
379
+ $response = $this->_http->put($path, ['transaction' => $attribs]);
380
  return $this->_verifyGatewayResponse($response);
381
  }
382
 
383
+ public function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = [])
384
  {
385
+ $result = $this->submitForSettlement($transactionId, $amount, $attribs);
386
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
387
+ }
388
+
389
+ public function updateDetails($transactionId, $attribs = [])
390
+ {
391
+ $this->_validateId($transactionId);
392
+ Util::verifyKeys(self::updateDetailsSignature(), $attribs);
393
+
394
+ $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/update_details';
395
+ $response = $this->_http->put($path, ['transaction' => $attribs]);
396
+ return $this->_verifyGatewayResponse($response);
397
+ }
398
+
399
+ public function submitForPartialSettlement($transactionId, $amount, $attribs = [])
400
+ {
401
+ $this->_validateId($transactionId);
402
+ Util::verifyKeys(self::submitForSettlementSignature(), $attribs);
403
+ $attribs['amount'] = $amount;
404
+
405
+ $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_partial_settlement';
406
+ $response = $this->_http->post($path, ['transaction' => $attribs]);
407
+ return $this->_verifyGatewayResponse($response);
408
  }
409
 
410
  public function holdInEscrow($transactionId)
412
  $this->_validateId($transactionId);
413
 
414
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/hold_in_escrow';
415
+ $response = $this->_http->put($path, []);
416
  return $this->_verifyGatewayResponse($response);
417
  }
418
 
421
  $this->_validateId($transactionId);
422
 
423
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/release_from_escrow';
424
+ $response = $this->_http->put($path, []);
425
  return $this->_verifyGatewayResponse($response);
426
  }
427
 
430
  $this->_validateId($transactionId);
431
 
432
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/cancel_release';
433
+ $response = $this->_http->put($path, []);
434
  return $this->_verifyGatewayResponse($response);
435
  }
436
 
437
+ public function refund($transactionId, $amount_or_options = null)
438
  {
439
  self::_validateId($transactionId);
440
 
441
+ if(gettype($amount_or_options) == "array") {
442
+ $options = $amount_or_options;
443
+ } else {
444
+ $options = [
445
+ "amount" => $amount_or_options
446
+ ];
447
+ }
448
+ Util::verifyKeys(self::refundSignature(), $options);
449
+
450
+ $params = ['transaction' => $options];
451
  $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/refund';
452
  $response = $this->_http->post($path, $params);
453
  return $this->_verifyGatewayResponse($response);
488
  }
489
  }
490
 
 
491
  /**
492
  * generic method for validating incoming gateway responses
493
  *
494
+ * creates a new Transaction object and encapsulates
495
+ * it inside a Result\Successful object, or
496
+ * encapsulates a Errors object inside a Result\Error
497
  * alternatively, throws an Unexpected exception if the response is invalid.
498
  *
499
  * @ignore
500
  * @param array $response gateway response values
501
+ * @return Result\Successful|Result\Error
502
+ * @throws Exception\Unexpected
503
  */
504
  private function _verifyGatewayResponse($response)
505
  {
506
  if (isset($response['transaction'])) {
507
+ // return a populated instance of Transaction
508
+ return new Result\Successful(
509
+ Transaction::factory($response['transaction'])
510
  );
511
  } else if (isset($response['apiErrorResponse'])) {
512
+ return new Result\Error($response['apiErrorResponse']);
513
  } else {
514
+ throw new Exception\Unexpected(
515
  "Expected transaction or apiErrorResponse"
516
  );
517
  }
518
  }
519
  }
520
+ class_alias('Braintree\TransactionGateway', 'Braintree_TransactionGateway');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/TransactionSearch.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class TransactionSearch
5
+ {
6
+ public static function amount() { return new RangeNode("amount"); }
7
+ public static function authorizationExpiredAt() { return new RangeNode("authorizationExpiredAt"); }
8
+ public static function authorizedAt() { return new RangeNode("authorizedAt"); }
9
+ public static function billingCompany() { return new TextNode('billing_company'); }
10
+ public static function billingCountryName() { return new TextNode('billing_country_name'); }
11
+ public static function billingExtendedAddress() { return new TextNode('billing_extended_address'); }
12
+ public static function billingFirstName() { return new TextNode('billing_first_name'); }
13
+ public static function billingLastName() { return new TextNode('billing_last_name'); }
14
+ public static function billingLocality() { return new TextNode('billing_locality'); }
15
+ public static function billingPostalCode() { return new TextNode('billing_postal_code'); }
16
+ public static function billingRegion() { return new TextNode('billing_region'); }
17
+ public static function billingStreetAddress() { return new TextNode('billing_street_address'); }
18
+ public static function createdAt() { return new RangeNode("createdAt"); }
19
+ public static function creditCardCardholderName() { return new TextNode('credit_card_cardholderName'); }
20
+ public static function creditCardExpirationDate() { return new EqualityNode('credit_card_expiration_date'); }
21
+ public static function creditCardNumber() { return new PartialMatchNode('credit_card_number'); }
22
+ public static function creditCardUniqueIdentifier() { return new TextNode('credit_card_unique_identifier'); }
23
+ public static function currency() { return new TextNode('currency'); }
24
+ public static function customerCompany() { return new TextNode('customer_company'); }
25
+ public static function customerEmail() { return new TextNode('customer_email'); }
26
+ public static function customerFax() { return new TextNode('customer_fax'); }
27
+ public static function customerFirstName() { return new TextNode('customer_first_name'); }
28
+ public static function customerId() { return new TextNode('customer_id'); }
29
+ public static function customerLastName() { return new TextNode('customer_last_name'); }
30
+ public static function customerPhone() { return new TextNode('customer_phone'); }
31
+ public static function customerWebsite() { return new TextNode('customer_website'); }
32
+ public static function disbursementDate() { return new RangeNode("disbursementDate"); }
33
+ public static function disputeDate() { return new RangeNode("disputeDate"); }
34
+ public static function europeBankAccountIban() { return new TextNode("europeBankAccountIban"); }
35
+ public static function failedAt() { return new RangeNode("failedAt"); }
36
+ public static function gatewayRejectedAt() { return new RangeNode("gatewayRejectedAt"); }
37
+ public static function id() { return new TextNode('id'); }
38
+ public static function ids() { return new MultipleValueNode('ids'); }
39
+ public static function merchantAccountId() { return new MultipleValueNode("merchant_account_id"); }
40
+ public static function orderId() { return new TextNode('order_id'); }
41
+ public static function paymentInstrumentType() { return new MultipleValueNode('paymentInstrumentType'); }
42
+ public static function paymentMethodToken() { return new TextNode('payment_method_token'); }
43
+ public static function paypalAuthorizationId() { return new TextNode('paypal_authorization_id'); }
44
+ public static function paypalPayerEmail() { return new TextNode('paypal_payer_email'); }
45
+ public static function paypalPaymentId() { return new TextNode('paypal_payment_id'); }
46
+ public static function processorAuthorizationCode() { return new TextNode('processor_authorization_code'); }
47
+ public static function processorDeclinedAt() { return new RangeNode("processorDeclinedAt"); }
48
+ public static function refund() { return new KeyValueNode("refund"); }
49
+ public static function settledAt() { return new RangeNode("settledAt"); }
50
+ public static function settlementBatchId() { return new TextNode('settlement_batch_id'); }
51
+ public static function shippingCompany() { return new TextNode('shipping_company'); }
52
+ public static function shippingCountryName() { return new TextNode('shipping_country_name'); }
53
+ public static function shippingExtendedAddress() { return new TextNode('shipping_extended_address'); }
54
+ public static function shippingFirstName() { return new TextNode('shipping_first_name'); }
55
+ public static function shippingLastName() { return new TextNode('shipping_last_name'); }
56
+ public static function shippingLocality() { return new TextNode('shipping_locality'); }
57
+ public static function shippingPostalCode() { return new TextNode('shipping_postal_code'); }
58
+ public static function shippingRegion() { return new TextNode('shipping_region'); }
59
+ public static function shippingStreetAddress() { return new TextNode('shipping_street_address'); }
60
+ public static function submittedForSettlementAt() { return new RangeNode("submittedForSettlementAt"); }
61
+ public static function user() { return new MultipleValueNode('user'); }
62
+ public static function voidedAt() { return new RangeNode("voidedAt"); }
63
+
64
+ public static function createdUsing()
65
+ {
66
+ return new MultipleValueNode('created_using', [
67
+ Transaction::FULL_INFORMATION,
68
+ Transaction::TOKEN
69
+ ]);
70
+ }
71
+
72
+ public static function creditCardCardType()
73
+ {
74
+ return new MultipleValueNode('credit_card_card_type', [
75
+ CreditCard::AMEX,
76
+ CreditCard::CARTE_BLANCHE,
77
+ CreditCard::CHINA_UNION_PAY,
78
+ CreditCard::DINERS_CLUB_INTERNATIONAL,
79
+ CreditCard::DISCOVER,
80
+ CreditCard::JCB,
81
+ CreditCard::LASER,
82
+ CreditCard::MAESTRO,
83
+ CreditCard::MASTER_CARD,
84
+ CreditCard::SOLO,
85
+ CreditCard::SWITCH_TYPE,
86
+ CreditCard::VISA,
87
+ CreditCard::UNKNOWN
88
+ ]);
89
+ }
90
+
91
+ public static function creditCardCustomerLocation()
92
+ {
93
+ return new MultipleValueNode('credit_card_customer_location', [
94
+ CreditCard::INTERNATIONAL,
95
+ CreditCard::US
96
+ ]);
97
+ }
98
+
99
+ public static function source()
100
+ {
101
+ return new MultipleValueNode('source', []);
102
+ }
103
+
104
+ public static function status()
105
+ {
106
+ return new MultipleValueNode('status', [
107
+ Transaction::AUTHORIZATION_EXPIRED,
108
+ Transaction::AUTHORIZING,
109
+ Transaction::AUTHORIZED,
110
+ Transaction::GATEWAY_REJECTED,
111
+ Transaction::FAILED,
112
+ Transaction::PROCESSOR_DECLINED,
113
+ Transaction::SETTLED,
114
+ Transaction::SETTLING,
115
+ Transaction::SUBMITTED_FOR_SETTLEMENT,
116
+ Transaction::VOIDED,
117
+ Transaction::SETTLEMENT_DECLINED,
118
+ Transaction::SETTLEMENT_PENDING
119
+ ]);
120
+ }
121
+
122
+ public static function type()
123
+ {
124
+ return new MultipleValueNode('type', [
125
+ Transaction::SALE,
126
+ Transaction::CREDIT
127
+ ]);
128
+ }
129
+ }
130
+ class_alias('Braintree\TransactionSearch', 'Braintree_TransactionSearch');
lib/Gene/Braintree/{TransparentRedirect.php → braintree/braintree_php/lib/Braintree/TransparentRedirect.php} RENAMED
@@ -1,9 +1,9 @@
1
  <?php
2
-
3
 
4
  /**
5
  * Braintree Transparent Redirect module
6
- * Static class providing methods to build Transparent Redirect urls
7
  *
8
  * The TransparentRedirect module provides methods to build the tr_data param
9
  * that must be submitted when using the transparent redirect API.
@@ -14,7 +14,7 @@
14
  * user the action is complete.
15
  *
16
  * <code>
17
- * $trData = Braintree_TransparentRedirect::createCustomerData(array(
18
  * 'redirectUrl => 'http://example.com/redirect_back_to_merchant_site',
19
  * ));
20
  * </code>
@@ -25,7 +25,7 @@
25
  * amount, include the amount in the trData.
26
  *
27
  * <code>
28
- * $trData = Braintree_TransparentRedirect::transactionData(array(
29
  * 'redirectUrl' => 'http://example.com/complete_transaction',
30
  * 'transaction' => array('amount' => '100.00'),
31
  * ));
@@ -34,9 +34,9 @@
34
  *
35
  * @package Braintree
36
  * @category Resources
37
- * @copyright 2014 Braintree, a division of PayPal, Inc.
38
  */
39
- class Braintree_TransparentRedirect
40
  {
41
  // Request Kinds
42
  const CREATE_TRANSACTION = 'create_transaction';
@@ -48,7 +48,7 @@ class Braintree_TransparentRedirect
48
  /**
49
  * @ignore
50
  * don't permit an explicit call of the constructor!
51
- * (like $t = new Braintree_TransparentRedirect())
52
  */
53
  protected function __construct()
54
  {
@@ -60,41 +60,42 @@ class Braintree_TransparentRedirect
60
 
61
  public static function confirm($queryString)
62
  {
63
- return Braintree_Configuration::gateway()->transparentRedirect()->confirm($queryString);
64
  }
65
 
66
  public static function createCreditCardData($params)
67
  {
68
- return Braintree_Configuration::gateway()->transparentRedirect()->createCreditCardData($params);
69
  }
70
 
71
  public static function createCustomerData($params)
72
  {
73
- return Braintree_Configuration::gateway()->transparentRedirect()->createCustomerData($params);
74
  }
75
 
76
  public static function url()
77
  {
78
- return Braintree_Configuration::gateway()->transparentRedirect()->url();
79
  }
80
 
81
  public static function transactionData($params)
82
  {
83
- return Braintree_Configuration::gateway()->transparentRedirect()->transactionData($params);
84
  }
85
 
86
  public static function updateCreditCardData($params)
87
  {
88
- return Braintree_Configuration::gateway()->transparentRedirect()->updateCreditCardData($params);
89
  }
90
 
91
  public static function updateCustomerData($params)
92
  {
93
- return Braintree_Configuration::gateway()->transparentRedirect()->updateCustomerData($params);
94
  }
95
 
96
  public static function parseAndValidateQueryString($queryString)
97
  {
98
- return Braintree_Configuration::gateway()->transparentRedirect()->parseAndValidateQueryString($queryString);
99
  }
100
  }
 
1
  <?php
2
+ namespace Braintree;
3
 
4
  /**
5
  * Braintree Transparent Redirect module
6
+ * Static class providing methods to build Transparent Redirect urls.
7
  *
8
  * The TransparentRedirect module provides methods to build the tr_data param
9
  * that must be submitted when using the transparent redirect API.
14
  * user the action is complete.
15
  *
16
  * <code>
17
+ * $trData = TransparentRedirect::createCustomerData(array(
18
  * 'redirectUrl => 'http://example.com/redirect_back_to_merchant_site',
19
  * ));
20
  * </code>
25
  * amount, include the amount in the trData.
26
  *
27
  * <code>
28
+ * $trData = TransparentRedirect::transactionData(array(
29
  * 'redirectUrl' => 'http://example.com/complete_transaction',
30
  * 'transaction' => array('amount' => '100.00'),
31
  * ));
34
  *
35
  * @package Braintree
36
  * @category Resources
37
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
38
  */
39
+ class TransparentRedirect
40
  {
41
  // Request Kinds
42
  const CREATE_TRANSACTION = 'create_transaction';
48
  /**
49
  * @ignore
50
  * don't permit an explicit call of the constructor!
51
+ * (like $t = new TransparentRedirect())
52
  */
53
  protected function __construct()
54
  {
60
 
61
  public static function confirm($queryString)
62
  {
63
+ return Configuration::gateway()->transparentRedirect()->confirm($queryString);
64
  }
65
 
66
  public static function createCreditCardData($params)
67
  {
68
+ return Configuration::gateway()->transparentRedirect()->createCreditCardData($params);
69
  }
70
 
71
  public static function createCustomerData($params)
72
  {
73
+ return Configuration::gateway()->transparentRedirect()->createCustomerData($params);
74
  }
75
 
76
  public static function url()
77
  {
78
+ return Configuration::gateway()->transparentRedirect()->url();
79
  }
80
 
81
  public static function transactionData($params)
82
  {
83
+ return Configuration::gateway()->transparentRedirect()->transactionData($params);
84
  }
85
 
86
  public static function updateCreditCardData($params)
87
  {
88
+ return Configuration::gateway()->transparentRedirect()->updateCreditCardData($params);
89
  }
90
 
91
  public static function updateCustomerData($params)
92
  {
93
+ return Configuration::gateway()->transparentRedirect()->updateCustomerData($params);
94
  }
95
 
96
  public static function parseAndValidateQueryString($queryString)
97
  {
98
+ return Configuration::gateway()->transparentRedirect()->parseAndValidateQueryString($queryString);
99
  }
100
  }
101
+ class_alias('Braintree\TransparentRedirect', 'Braintree_TransparentRedirect');
lib/Gene/Braintree/{TransparentRedirectGateway.php → braintree/braintree_php/lib/Braintree/TransparentRedirectGateway.php} RENAMED
@@ -1,13 +1,19 @@
1
  <?php
 
 
 
 
 
 
2
  /**
3
  * Braintree Transparent Redirect Gateway module
4
  * Static class providing methods to build Transparent Redirect urls
5
  *
6
  * @package Braintree
7
  * @category Resources
8
- * @copyright 2014 Braintree, a division of PayPal, Inc.
9
  */
10
- class Braintree_TransparentRedirectGateway
11
  {
12
  private $_gateway;
13
  private $_config;
@@ -37,44 +43,44 @@ class Braintree_TransparentRedirectGateway
37
  public static function init()
38
  {
39
 
40
- self::$_createCustomerSignature = array(
41
  self::$_transparentRedirectKeys,
42
- array('customer' => Braintree_CustomerGateway::createSignature()),
43
- );
44
- self::$_updateCustomerSignature = array(
45
  self::$_transparentRedirectKeys,
46
  'customerId',
47
- array('customer' => Braintree_CustomerGateway::updateSignature()),
48
- );
49
- self::$_transactionSignature = array(
50
  self::$_transparentRedirectKeys,
51
- array('transaction' => Braintree_TransactionGateway::createSignature()),
52
- );
53
- self::$_createCreditCardSignature = array(
54
  self::$_transparentRedirectKeys,
55
- array('creditCard' => Braintree_CreditCardGateway::createSignature()),
56
- );
57
- self::$_updateCreditCardSignature = array(
58
  self::$_transparentRedirectKeys,
59
  'paymentMethodToken',
60
- array('creditCard' => Braintree_CreditCardGateway::updateSignature()),
61
- );
62
  }
63
 
64
  public function confirm($queryString)
65
  {
66
- $params = Braintree_TransparentRedirect::parseAndValidateQueryString(
67
  $queryString
68
  );
69
- $confirmationKlasses = array(
70
- Braintree_TransparentRedirect::CREATE_TRANSACTION => 'Braintree_TransactionGateway',
71
- Braintree_TransparentRedirect::CREATE_CUSTOMER => 'Braintree_CustomerGateway',
72
- Braintree_TransparentRedirect::UPDATE_CUSTOMER => 'Braintree_CustomerGateway',
73
- Braintree_TransparentRedirect::CREATE_PAYMENT_METHOD => 'Braintree_CreditCardGateway',
74
- Braintree_TransparentRedirect::UPDATE_PAYMENT_METHOD => 'Braintree_CreditCardGateway'
75
- );
76
  $confirmationGateway = new $confirmationKlasses[$params["kind"]]($this->_gateway);
77
- return $confirmationGateway->_doCreate('/transparent_redirect_requests/' . $params['id'] . '/confirm', array());
78
  }
79
 
80
  /**
@@ -84,11 +90,11 @@ class Braintree_TransparentRedirectGateway
84
  */
85
  public function createCreditCardData($params)
86
  {
87
- Braintree_Util::verifyKeys(
88
  self::$_createCreditCardSignature,
89
  $params
90
  );
91
- $params["kind"] = Braintree_TransparentRedirect::CREATE_PAYMENT_METHOD;
92
  return $this->_data($params);
93
  }
94
 
@@ -99,18 +105,18 @@ class Braintree_TransparentRedirectGateway
99
  */
100
  public function createCustomerData($params)
101
  {
102
- Braintree_Util::verifyKeys(
103
  self::$_createCustomerSignature,
104
  $params
105
  );
106
- $params["kind"] = Braintree_TransparentRedirect::CREATE_CUSTOMER;
107
  return $this->_data($params);
108
 
109
  }
110
 
111
  public function url()
112
  {
113
- return $this->_config->baseUrl() . $this->_config->merchantPath() . "/transparent_redirect_requests";
114
  }
115
 
116
  /**
@@ -120,15 +126,15 @@ class Braintree_TransparentRedirectGateway
120
  */
121
  public function transactionData($params)
122
  {
123
- Braintree_Util::verifyKeys(
124
  self::$_transactionSignature,
125
  $params
126
  );
127
- $params["kind"] = Braintree_TransparentRedirect::CREATE_TRANSACTION;
128
  $transactionType = isset($params['transaction']['type']) ?
129
  $params['transaction']['type'] :
130
  null;
131
- if ($transactionType != Braintree_Transaction::SALE && $transactionType != Braintree_Transaction::CREDIT) {
132
  throw new InvalidArgumentException(
133
  'expected transaction[type] of sale or credit, was: ' .
134
  $transactionType
@@ -144,7 +150,7 @@ class Braintree_TransparentRedirectGateway
144
  * The paymentMethodToken of the credit card to update is required.
145
  *
146
  * <code>
147
- * $trData = Braintree_TransparentRedirect::updateCreditCardData(array(
148
  * 'redirectUrl' => 'http://example.com/redirect_here',
149
  * 'paymentMethodToken' => 'token123',
150
  * ));
@@ -155,7 +161,7 @@ class Braintree_TransparentRedirectGateway
155
  */
156
  public function updateCreditCardData($params)
157
  {
158
- Braintree_Util::verifyKeys(
159
  self::$_updateCreditCardSignature,
160
  $params
161
  );
@@ -164,7 +170,7 @@ class Braintree_TransparentRedirectGateway
164
  'expected params to contain paymentMethodToken.'
165
  );
166
  }
167
- $params["kind"] = Braintree_TransparentRedirect::UPDATE_PAYMENT_METHOD;
168
  return $this->_data($params);
169
  }
170
 
@@ -174,7 +180,7 @@ class Braintree_TransparentRedirectGateway
174
  * The customerId of the customer to update is required.
175
  *
176
  * <code>
177
- * $trData = Braintree_TransparentRedirect::updateCustomerData(array(
178
  * 'redirectUrl' => 'http://example.com/redirect_here',
179
  * 'customerId' => 'customer123',
180
  * ));
@@ -185,7 +191,7 @@ class Braintree_TransparentRedirectGateway
185
  */
186
  public function updateCustomerData($params)
187
  {
188
- Braintree_Util::verifyKeys(
189
  self::$_updateCustomerSignature,
190
  $params
191
  );
@@ -194,7 +200,7 @@ class Braintree_TransparentRedirectGateway
194
  'expected params to contain customerId of customer to update'
195
  );
196
  }
197
- $params["kind"] = Braintree_TransparentRedirect::UPDATE_CUSTOMER;
198
  return $this->_data($params);
199
  }
200
 
@@ -204,7 +210,7 @@ class Braintree_TransparentRedirectGateway
204
  parse_str($queryString, $params);
205
  // remove the hash
206
  $queryStringWithoutHash = null;
207
- if(preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) {
208
  $queryStringWithoutHash = $match[1];
209
  }
210
 
@@ -213,14 +219,14 @@ class Braintree_TransparentRedirectGateway
213
  if(array_key_exists('bt_message', $params)) {
214
  $message = $params['bt_message'];
215
  }
216
- Braintree_Util::throwStatusCodeException($params['http_status'], $message);
217
  }
218
 
219
  // recreate the hash and compare it
220
- if($this->_hash($queryStringWithoutHash) == $params['hash']) {
221
  return $params;
222
  } else {
223
- throw new Braintree_Exception_ForgedQueryString();
224
  }
225
  }
226
 
@@ -239,17 +245,17 @@ class Braintree_TransparentRedirectGateway
239
  $params = $this->_underscoreKeys($params);
240
  $now = new DateTime('now', new DateTimeZone('UTC'));
241
  $trDataParams = array_merge($params,
242
- array(
243
- 'api_version' => Braintree_Configuration::API_VERSION,
244
  'public_key' => $this->_config->publicKey(),
245
  'time' => $now->format('YmdHis'),
246
- )
247
  );
248
  ksort($trDataParams);
249
  $urlEncodedData = http_build_query($trDataParams, null, "&");
250
- $signatureService = new Braintree_SignatureService(
251
  $this->_config->privateKey(),
252
- "Braintree_Digest::hexDigestSha1"
253
  );
254
  return $signatureService->sign($urlEncodedData);
255
  }
@@ -258,7 +264,7 @@ class Braintree_TransparentRedirectGateway
258
  {
259
  foreach($array as $key=>$value)
260
  {
261
- $newKey = Braintree_Util::camelCaseToDelimiter($key, '_');
262
  unset($array[$key]);
263
  if (is_array($value))
264
  {
@@ -277,7 +283,8 @@ class Braintree_TransparentRedirectGateway
277
  */
278
  private function _hash($string)
279
  {
280
- return Braintree_Digest::hexDigestSha1($this->_config->privateKey(), $string);
281
  }
282
  }
283
- Braintree_TransparentRedirectGateway::init();
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+ use DateTime;
6
+ use DateTimeZone;
7
+
8
  /**
9
  * Braintree Transparent Redirect Gateway module
10
  * Static class providing methods to build Transparent Redirect urls
11
  *
12
  * @package Braintree
13
  * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  */
16
+ class TransparentRedirectGateway
17
  {
18
  private $_gateway;
19
  private $_config;
43
  public static function init()
44
  {
45
 
46
+ self::$_createCustomerSignature = [
47
  self::$_transparentRedirectKeys,
48
+ ['customer' => CustomerGateway::createSignature()],
49
+ ];
50
+ self::$_updateCustomerSignature = [
51
  self::$_transparentRedirectKeys,
52
  'customerId',
53
+ ['customer' => CustomerGateway::updateSignature()],
54
+ ];
55
+ self::$_transactionSignature = [
56
  self::$_transparentRedirectKeys,
57
+ ['transaction' => TransactionGateway::createSignature()],
58
+ ];
59
+ self::$_createCreditCardSignature = [
60
  self::$_transparentRedirectKeys,
61
+ ['creditCard' => CreditCardGateway::createSignature()],
62
+ ];
63
+ self::$_updateCreditCardSignature = [
64
  self::$_transparentRedirectKeys,
65
  'paymentMethodToken',
66
+ ['creditCard' => CreditCardGateway::updateSignature()],
67
+ ];
68
  }
69
 
70
  public function confirm($queryString)
71
  {
72
+ $params = TransparentRedirect::parseAndValidateQueryString(
73
  $queryString
74
  );
75
+ $confirmationKlasses = [
76
+ TransparentRedirect::CREATE_TRANSACTION => 'Braintree\TransactionGateway',
77
+ TransparentRedirect::CREATE_CUSTOMER => 'Braintree\CustomerGateway',
78
+ TransparentRedirect::UPDATE_CUSTOMER => 'Braintree\CustomerGateway',
79
+ TransparentRedirect::CREATE_PAYMENT_METHOD => 'Braintree\CreditCardGateway',
80
+ TransparentRedirect::UPDATE_PAYMENT_METHOD => 'Braintree\CreditCardGateway',
81
+ ];
82
  $confirmationGateway = new $confirmationKlasses[$params["kind"]]($this->_gateway);
83
+ return $confirmationGateway->_doCreate('/transparent_redirect_requests/' . $params['id'] . '/confirm', []);
84
  }
85
 
86
  /**
90
  */
91
  public function createCreditCardData($params)
92
  {
93
+ Util::verifyKeys(
94
  self::$_createCreditCardSignature,
95
  $params
96
  );
97
+ $params["kind"] = TransparentRedirect::CREATE_PAYMENT_METHOD;
98
  return $this->_data($params);
99
  }
100
 
105
  */
106
  public function createCustomerData($params)
107
  {
108
+ Util::verifyKeys(
109
  self::$_createCustomerSignature,
110
  $params
111
  );
112
+ $params["kind"] = TransparentRedirect::CREATE_CUSTOMER;
113
  return $this->_data($params);
114
 
115
  }
116
 
117
  public function url()
118
  {
119
+ return $this->_config->baseUrl() . $this->_config->merchantPath() . '/transparent_redirect_requests';
120
  }
121
 
122
  /**
126
  */
127
  public function transactionData($params)
128
  {
129
+ Util::verifyKeys(
130
  self::$_transactionSignature,
131
  $params
132
  );
133
+ $params["kind"] = TransparentRedirect::CREATE_TRANSACTION;
134
  $transactionType = isset($params['transaction']['type']) ?
135
  $params['transaction']['type'] :
136
  null;
137
+ if ($transactionType != Transaction::SALE && $transactionType != Transaction::CREDIT) {
138
  throw new InvalidArgumentException(
139
  'expected transaction[type] of sale or credit, was: ' .
140
  $transactionType
150
  * The paymentMethodToken of the credit card to update is required.
151
  *
152
  * <code>
153
+ * $trData = TransparentRedirect::updateCreditCardData(array(
154
  * 'redirectUrl' => 'http://example.com/redirect_here',
155
  * 'paymentMethodToken' => 'token123',
156
  * ));
161
  */
162
  public function updateCreditCardData($params)
163
  {
164
+ Util::verifyKeys(
165
  self::$_updateCreditCardSignature,
166
  $params
167
  );
170
  'expected params to contain paymentMethodToken.'
171
  );
172
  }
173
+ $params["kind"] = TransparentRedirect::UPDATE_PAYMENT_METHOD;
174
  return $this->_data($params);
175
  }
176
 
180
  * The customerId of the customer to update is required.
181
  *
182
  * <code>
183
+ * $trData = TransparentRedirect::updateCustomerData(array(
184
  * 'redirectUrl' => 'http://example.com/redirect_here',
185
  * 'customerId' => 'customer123',
186
  * ));
191
  */
192
  public function updateCustomerData($params)
193
  {
194
+ Util::verifyKeys(
195
  self::$_updateCustomerSignature,
196
  $params
197
  );
200
  'expected params to contain customerId of customer to update'
201
  );
202
  }
203
+ $params["kind"] = TransparentRedirect::UPDATE_CUSTOMER;
204
  return $this->_data($params);
205
  }
206
 
210
  parse_str($queryString, $params);
211
  // remove the hash
212
  $queryStringWithoutHash = null;
213
+ if (preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) {
214
  $queryStringWithoutHash = $match[1];
215
  }
216
 
219
  if(array_key_exists('bt_message', $params)) {
220
  $message = $params['bt_message'];
221
  }
222
+ Util::throwStatusCodeException(isset($params['http_status']) ? $params['http_status'] : null, $message);
223
  }
224
 
225
  // recreate the hash and compare it
226
+ if ($this->_hash($queryStringWithoutHash) == $params['hash']) {
227
  return $params;
228
  } else {
229
+ throw new Exception\ForgedQueryString();
230
  }
231
  }
232
 
245
  $params = $this->_underscoreKeys($params);
246
  $now = new DateTime('now', new DateTimeZone('UTC'));
247
  $trDataParams = array_merge($params,
248
+ [
249
+ 'api_version' => Configuration::API_VERSION,
250
  'public_key' => $this->_config->publicKey(),
251
  'time' => $now->format('YmdHis'),
252
+ ]
253
  );
254
  ksort($trDataParams);
255
  $urlEncodedData = http_build_query($trDataParams, null, "&");
256
+ $signatureService = new SignatureService(
257
  $this->_config->privateKey(),
258
+ "Braintree\Digest::hexDigestSha1"
259
  );
260
  return $signatureService->sign($urlEncodedData);
261
  }
264
  {
265
  foreach($array as $key=>$value)
266
  {
267
+ $newKey = Util::camelCaseToDelimiter($key, '_');
268
  unset($array[$key]);
269
  if (is_array($value))
270
  {
283
  */
284
  private function _hash($string)
285
  {
286
+ return Digest::hexDigestSha1($this->_config->privateKey(), $string);
287
  }
288
  }
289
+ TransparentRedirectGateway::init();
290
+ class_alias('Braintree\TransparentRedirectGateway', 'Braintree_TransparentRedirectGateway');
lib/Gene/Braintree/{UnknownPaymentMethod.php → braintree/braintree_php/lib/Braintree/UnknownPaymentMethod.php} RENAMED
@@ -1,10 +1,12 @@
1
  <?php
 
 
2
  /**
3
  * Braintree UnknownPaymentMethod module
4
  *
5
  * @package Braintree
6
  * @category Resources
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
 
10
  /**
@@ -15,21 +17,21 @@
15
  *
16
  * @package Braintree
17
  * @category Resources
18
- * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  *
20
  * @property-read string $token
21
  * @property-read string $imageUrl
22
  */
23
- class Braintree_UnknownPaymentMethod extends Braintree_Base
24
  {
25
 
26
 
27
  /**
28
- * factory method: returns an instance of Braintree_UnknownPaymentMethod
29
  * to the requesting method, with populated properties
30
  *
31
  * @ignore
32
- * @return object instance of Braintree_UnknownPaymentMethod
33
  */
34
  public static function factory($attributes)
35
  {
@@ -56,7 +58,7 @@ class Braintree_UnknownPaymentMethod extends Braintree_Base
56
  *
57
  * @access protected
58
  * @param array $unknownPaymentMethodAttribs array of unknownPaymentMethod data
59
- * @return none
60
  */
61
  protected function _initialize($unknownPaymentMethodAttribs)
62
  {
@@ -66,3 +68,4 @@ class Braintree_UnknownPaymentMethod extends Braintree_Base
66
  }
67
 
68
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree UnknownPaymentMethod module
6
  *
7
  * @package Braintree
8
  * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
 
12
  /**
17
  *
18
  * @package Braintree
19
  * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
  *
22
  * @property-read string $token
23
  * @property-read string $imageUrl
24
  */
25
+ class UnknownPaymentMethod extends Base
26
  {
27
 
28
 
29
  /**
30
+ * factory method: returns an instance of UnknownPaymentMethod
31
  * to the requesting method, with populated properties
32
  *
33
  * @ignore
34
+ * @return UnknownPaymentMethod
35
  */
36
  public static function factory($attributes)
37
  {
58
  *
59
  * @access protected
60
  * @param array $unknownPaymentMethodAttribs array of unknownPaymentMethod data
61
+ * @return void
62
  */
63
  protected function _initialize($unknownPaymentMethodAttribs)
64
  {
68
  }
69
 
70
  }
71
+ class_alias('Braintree\UnknownPaymentMethod', 'Braintree_UnknownPaymentMethod');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/UsBankAccount.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree UsBankAccount module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2016 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Manages Braintree UsBankAccounts
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2016 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $customerId
23
+ * @property-read string $email
24
+ * @property-read string $token
25
+ * @property-read string $imageUrl
26
+ */
27
+ class UsBankAccount extends Base
28
+ {
29
+ /**
30
+ * factory method: returns an instance of UsBankAccount
31
+ * to the requesting method, with populated properties
32
+ *
33
+ * @ignore
34
+ * @return UsBankAccount
35
+ */
36
+ public static function factory($attributes)
37
+ {
38
+ $instance = new self();
39
+ $instance->_initialize($attributes);
40
+ return $instance;
41
+ }
42
+
43
+ /* instance methods */
44
+
45
+ /**
46
+ * sets instance properties from an array of values
47
+ *
48
+ * @access protected
49
+ * @param array $usBankAccountAttribs array of usBankAccount data
50
+ * @return void
51
+ */
52
+ protected function _initialize($usBankAccountAttribs)
53
+ {
54
+ // set the attributes
55
+ $this->_attributes = $usBankAccountAttribs;
56
+ }
57
+
58
+ /**
59
+ * create a printable representation of the object as:
60
+ * ClassName[property=value, property=value]
61
+ * @return string
62
+ */
63
+ public function __toString()
64
+ {
65
+ return __CLASS__ . '[' .
66
+ Util::attributesToString($this->_attributes) . ']';
67
+ }
68
+
69
+
70
+ // static methods redirecting to gateway
71
+
72
+ public static function find($token)
73
+ {
74
+ return Configuration::gateway()->usBankAccount()->find($token);
75
+ }
76
+
77
+ public static function sale($token, $transactionAttribs)
78
+ {
79
+ $transactionAttribs['options'] = [
80
+ 'submitForSettlement' => true
81
+ ];
82
+ return Configuration::gateway()->usBankAccount()->sale($token, $transactionAttribs);
83
+ }
84
+ }
85
+ class_alias('Braintree\UsBankAccount', 'Braintree_UsBankAccount');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/UsBankAccountGateway.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree UsBankAccountGateway module
8
+ *
9
+ * @package Braintree
10
+ * @category Resources
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ /**
15
+ * Manages Braintree UsBankAccounts
16
+ *
17
+ * <b>== More information ==</b>
18
+ *
19
+ *
20
+ * @package Braintree
21
+ * @category Resources
22
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
23
+ */
24
+ class UsBankAccountGateway
25
+ {
26
+ private $_gateway;
27
+ private $_config;
28
+ private $_http;
29
+
30
+ public function __construct($gateway)
31
+ {
32
+ $this->_gateway = $gateway;
33
+ $this->_config = $gateway->config;
34
+ $this->_config->assertHasAccessTokenOrKeys();
35
+ $this->_http = new Http($gateway->config);
36
+ }
37
+
38
+
39
+ /**
40
+ * find a usBankAccount by token
41
+ *
42
+ * @access public
43
+ * @param string $token paypal accountunique id
44
+ * @return UsBankAccount
45
+ * @throws Exception\NotFound
46
+ */
47
+ public function find($token)
48
+ {
49
+ try {
50
+ $path = $this->_config->merchantPath() . '/payment_methods/us_bank_account/' . $token;
51
+ $response = $this->_http->get($path);
52
+ return UsBankAccount::factory($response['usBankAccount']);
53
+ } catch (Exception\NotFound $e) {
54
+ throw new Exception\NotFound(
55
+ 'US bank account with token ' . $token . ' not found'
56
+ );
57
+ }
58
+
59
+ }
60
+
61
+ /**
62
+ * create a new sale for the current UsBank account
63
+ *
64
+ * @param string $token
65
+ * @param array $transactionAttribs
66
+ * @return Result\Successful|Result\Error
67
+ * @see Transaction::sale()
68
+ */
69
+ public function sale($token, $transactionAttribs)
70
+ {
71
+ return Transaction::sale(
72
+ array_merge(
73
+ $transactionAttribs,
74
+ ['paymentMethodToken' => $token]
75
+ )
76
+ );
77
+ }
78
+
79
+ /**
80
+ * generic method for validating incoming gateway responses
81
+ *
82
+ * creates a new UsBankAccount object and encapsulates
83
+ * it inside a Result\Successful object, or
84
+ * encapsulates a Errors object inside a Result\Error
85
+ * alternatively, throws an Unexpected exception if the response is invalid.
86
+ *
87
+ * @ignore
88
+ * @param array $response gateway response values
89
+ * @return Result\Successful|Result\Error
90
+ * @throws Exception\Unexpected
91
+ */
92
+ private function _verifyGatewayResponse($response)
93
+ {
94
+ if (isset($response['usBankAccount'])) {
95
+ // return a populated instance of UsBankAccount
96
+ return new Result\Successful(
97
+ UsBankAccount::factory($response['usBankAccount'])
98
+ );
99
+ } else if (isset($response['apiErrorResponse'])) {
100
+ return new Result\Error($response['apiErrorResponse']);
101
+ } else {
102
+ throw new Exception\Unexpected(
103
+ 'Expected US bank account or apiErrorResponse'
104
+ );
105
+ }
106
+ }
107
+ }
108
+ class_alias('Braintree\UsBankAccountGateway', 'Braintree_UsBankAccountGateway');
lib/Gene/Braintree/{Util.php → braintree/braintree_php/lib/Braintree/Util.php} RENAMED
@@ -1,28 +1,33 @@
1
  <?php
 
 
 
 
 
2
  /**
3
  * Braintree Utility methods
4
  * PHP version 5
5
  *
6
- * @copyright 2014 Braintree, a division of PayPal, Inc.
7
  */
8
 
9
- class Braintree_Util
10
  {
11
  /**
12
  * extracts an attribute and returns an array of objects
13
  *
14
  * extracts the requested element from an array, and converts the contents
15
- * of its child arrays to objects of type Braintree_$attributeName, or returns
16
  * an array with a single element containing the value of that array element
17
  *
18
- * @param array $attribArray attributes from a search response
19
  * @param string $attributeName indicates which element of the passed array to extract
20
- * @return array array of Braintree_$attributeName objects, or a single element array
21
  */
22
- public static function extractAttributeAsArray(& $attribArray, $attributeName)
23
  {
24
  if(!isset($attribArray[$attributeName])):
25
- return array();
26
  endif;
27
 
28
  // get what should be an array from the passed array
@@ -33,7 +38,7 @@ class Braintree_Util
33
  // create an object from the data in each element
34
  $objectArray = array_map($classFactory, $data);
35
  else:
36
- return array($data);
37
  endif;
38
 
39
  unset($attribArray[$attributeName]);
@@ -42,32 +47,36 @@ class Braintree_Util
42
  /**
43
  * throws an exception based on the type of error
44
  * @param string $statusCode HTTP status code to throw exception from
45
- * @throws Braintree_Exception multiple types depending on the error
46
- *
 
47
  */
48
  public static function throwStatusCodeException($statusCode, $message=null)
49
  {
50
  switch($statusCode) {
51
  case 401:
52
- throw new Braintree_Exception_Authentication();
53
  break;
54
  case 403:
55
- throw new Braintree_Exception_Authorization($message);
56
  break;
57
  case 404:
58
- throw new Braintree_Exception_NotFound();
59
  break;
60
  case 426:
61
- throw new Braintree_Exception_UpgradeRequired();
 
 
 
62
  break;
63
  case 500:
64
- throw new Braintree_Exception_ServerError();
65
  break;
66
  case 503:
67
- throw new Braintree_Exception_DownForMaintenance();
68
  break;
69
  default:
70
- throw new Braintree_Exception_Unexpected('Unexpected HTTP_RESPONSE #'.$statusCode);
71
  break;
72
  }
73
  }
@@ -77,82 +86,110 @@ class Braintree_Util
77
  * @param string $className
78
  * @param object $resultObj
79
  * @return object returns the passed object if successful
80
- * @throws Braintree_Exception_ValidationsFailed
81
  */
82
  public static function returnObjectOrThrowException($className, $resultObj)
83
  {
84
- $resultObjName = Braintree_Util::cleanClassName($className);
85
  if ($resultObj->success) {
86
  return $resultObj->$resultObjName;
87
  } else {
88
- throw new Braintree_Exception_ValidationsFailed();
89
  }
90
  }
91
 
92
  /**
93
- * removes the Braintree_ header from a classname
94
  *
95
- * @param string $name Braintree_ClassName
96
- * @return camelCased classname minus Braintree_ header
97
  */
98
  public static function cleanClassName($name)
99
  {
100
- $classNamesToResponseKeys = array(
101
- 'CreditCard' => 'creditCard',
102
- 'CreditCardGateway' => 'creditCard',
103
- 'Customer' => 'customer',
104
- 'CustomerGateway' => 'customer',
105
- 'Subscription' => 'subscription',
106
- 'SubscriptionGateway' => 'subscription',
107
- 'Transaction' => 'transaction',
108
- 'TransactionGateway' => 'transaction',
109
- 'CreditCardVerification' => 'verification',
110
- 'CreditCardVerificationGateway' => 'verification',
111
- 'AddOn' => 'addOn',
112
- 'AddOnGateway' => 'addOn',
113
- 'Discount' => 'discount',
114
- 'DiscountGateway' => 'discount',
115
- 'Plan' => 'plan',
116
- 'PlanGateway' => 'plan',
117
- 'Address' => 'address',
118
- 'AddressGateway' => 'address',
119
- 'SettlementBatchSummary' => 'settlementBatchSummary',
120
- 'SettlementBatchSummaryGateway' => 'settlementBatchSummary',
121
- 'Merchant' => 'merchant',
122
- 'MerchantGateway' => 'merchant',
123
- 'MerchantAccount' => 'merchantAccount',
124
- 'MerchantAccountGateway' => 'merchantAccount',
125
- 'OAuthCredentials' => 'credentials',
126
- 'PayPalAccount' => 'paypalAccount',
127
- 'PayPalAccountGateway' => 'paypalAccount'
128
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
- $name = str_replace('Braintree_', '', $name);
131
  return $classNamesToResponseKeys[$name];
132
  }
133
 
134
  /**
135
  *
136
  * @param string $name className
137
- * @return string Braintree_ClassName
138
  */
139
  public static function buildClassName($name)
140
  {
141
- $responseKeysToClassNames = array(
142
- 'creditCard' => 'CreditCard',
143
- 'customer' => 'Customer',
144
- 'subscription' => 'Subscription',
145
- 'transaction' => 'Transaction',
146
- 'verification' => 'CreditCardVerification',
147
- 'addOn' => 'AddOn',
148
- 'discount' => 'Discount',
149
- 'plan' => 'Plan',
150
- 'address' => 'Address',
151
- 'settlementBatchSummary' => 'SettlementBatchSummary',
152
- 'merchantAccount' => 'MerchantAccount'
153
- );
154
 
155
- return 'Braintree_' . $responseKeysToClassNames[$name];
156
  }
157
 
158
  /**
@@ -160,6 +197,7 @@ class Braintree_Util
160
  *
161
  * @access public
162
  * @param string $string
 
163
  * @return string modified string
164
  */
165
  public static function delimiterToCamelCase($string, $delimiter = '[\-\_]')
@@ -192,25 +230,18 @@ class Braintree_Util
192
  * find capitals and convert to delimiter + lowercase
193
  *
194
  * @access public
195
- * @param var $string
196
- * @return var modified string
 
197
  */
198
  public static function camelCaseToDelimiter($string, $delimiter = '-')
199
  {
200
- // php doesn't garbage collect functions created by create_function()
201
- // so use a static variable to avoid adding a new function to memory
202
- // every time this function is called.
203
- static $callbacks = array();
204
- if (!isset($callbacks[$delimiter])) {
205
- $callbacks[$delimiter] = create_function('$matches', "return '$delimiter' . strtolower(\$matches[1]);");
206
- }
207
-
208
- return preg_replace_callback('/([A-Z])/', $callbacks[$delimiter], $string);
209
  }
210
 
211
  public static function delimiterToCamelCaseArray($array, $delimiter = '[\-\_]')
212
  {
213
- $converted = array();
214
  foreach ($array as $key => $value) {
215
  if (is_string($key)) {
216
  $key = self::delimiterToCamelCase($key, $delimiter);
@@ -232,7 +263,7 @@ class Braintree_Util
232
 
233
  public static function camelCaseToDelimiterArray($array, $delimiter = '-')
234
  {
235
- $converted = array();
236
  foreach ($array as $key => $value) {
237
  if (is_string($key)) {
238
  $key = self::camelCaseToDelimiter($key, $delimiter);
@@ -247,7 +278,7 @@ class Braintree_Util
247
 
248
  public static function delimiterToUnderscoreArray($array)
249
  {
250
- $converted = array();
251
  foreach ($array as $key => $value) {
252
  $key = self::delimiterToUnderscore($key);
253
  $converted[$key] = $value;
@@ -260,6 +291,7 @@ class Braintree_Util
260
  * @param array $array associative array to implode
261
  * @param string $separator (optional, defaults to =)
262
  * @param string $glue (optional, defaults to ', ')
 
263
  */
264
  public static function implodeAssociativeArray($array, $separator = '=', $glue = ', ')
265
  {
@@ -276,10 +308,10 @@ class Braintree_Util
276
  }
277
 
278
  public static function attributesToString($attributes) {
279
- $printableAttribs = array();
280
  foreach ($attributes AS $key => $value) {
281
  if (is_array($value)) {
282
- $pAttrib = Braintree_Util::attributesToString($value);
283
  } else if ($value instanceof DateTime) {
284
  $pAttrib = $value->format(DateTime::RFC850);
285
  } else {
@@ -287,7 +319,7 @@ class Braintree_Util
287
  }
288
  $printableAttribs[$key] = sprintf('%s', $pAttrib);
289
  }
290
- return Braintree_Util::implodeAssociativeArray($printableAttribs);
291
  }
292
 
293
  /**
@@ -309,7 +341,7 @@ class Braintree_Util
309
  if(!empty($invalidKeys)) {
310
  asort($invalidKeys);
311
  $sortedList = join(', ', $invalidKeys);
312
- throw new InvalidArgumentException('invalid keys: '. $sortedList);
313
  }
314
  }
315
  /**
@@ -320,7 +352,7 @@ class Braintree_Util
320
  */
321
  private static function _flattenArray($keys, $namespace = null)
322
  {
323
- $flattenedArray = array();
324
  foreach($keys AS $key) {
325
  if(is_array($key)) {
326
  $theKeys = array_keys($key);
@@ -339,7 +371,7 @@ class Braintree_Util
339
 
340
  private static function _flattenUserKeys($keys, $namespace = null)
341
  {
342
- $flattenedArray = array();
343
 
344
  foreach($keys AS $key => $value) {
345
  $fullKey = empty($namespace) ? $key : $namespace;
@@ -381,3 +413,4 @@ class Braintree_Util
381
  return $invalidKeys;
382
  }
383
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ use DateTime;
5
+ use InvalidArgumentException;
6
+
7
  /**
8
  * Braintree Utility methods
9
  * PHP version 5
10
  *
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
  */
13
 
14
+ class Util
15
  {
16
  /**
17
  * extracts an attribute and returns an array of objects
18
  *
19
  * extracts the requested element from an array, and converts the contents
20
+ * of its child arrays to objects of type $attributeName, or returns
21
  * an array with a single element containing the value of that array element
22
  *
23
+ * @param array $attribArray attributes from a search response
24
  * @param string $attributeName indicates which element of the passed array to extract
25
+ * @return array array of $attributeName objects, or a single element array
26
  */
27
+ public static function extractAttributeAsArray(&$attribArray, $attributeName)
28
  {
29
  if(!isset($attribArray[$attributeName])):
30
+ return [];
31
  endif;
32
 
33
  // get what should be an array from the passed array
38
  // create an object from the data in each element
39
  $objectArray = array_map($classFactory, $data);
40
  else:
41
+ return [$data];
42
  endif;
43
 
44
  unset($attribArray[$attributeName]);
47
  /**
48
  * throws an exception based on the type of error
49
  * @param string $statusCode HTTP status code to throw exception from
50
+ * @param null|string $message
51
+ * @throws Exception multiple types depending on the error
52
+ * @return void
53
  */
54
  public static function throwStatusCodeException($statusCode, $message=null)
55
  {
56
  switch($statusCode) {
57
  case 401:
58
+ throw new Exception\Authentication();
59
  break;
60
  case 403:
61
+ throw new Exception\Authorization($message);
62
  break;
63
  case 404:
64
+ throw new Exception\NotFound();
65
  break;
66
  case 426:
67
+ throw new Exception\UpgradeRequired();
68
+ break;
69
+ case 429:
70
+ throw new Exception\TooManyRequests();
71
  break;
72
  case 500:
73
+ throw new Exception\ServerError();
74
  break;
75
  case 503:
76
+ throw new Exception\DownForMaintenance();
77
  break;
78
  default:
79
+ throw new Exception\Unexpected('Unexpected HTTP_RESPONSE #' . $statusCode);
80
  break;
81
  }
82
  }
86
  * @param string $className
87
  * @param object $resultObj
88
  * @return object returns the passed object if successful
89
+ * @throws Exception\ValidationsFailed
90
  */
91
  public static function returnObjectOrThrowException($className, $resultObj)
92
  {
93
+ $resultObjName = self::cleanClassName($className);
94
  if ($resultObj->success) {
95
  return $resultObj->$resultObjName;
96
  } else {
97
+ throw new Exception\ValidationsFailed();
98
  }
99
  }
100
 
101
  /**
102
+ * removes the header from a classname
103
  *
104
+ * @param string $name ClassName
105
+ * @return camelCased classname minus header
106
  */
107
  public static function cleanClassName($name)
108
  {
109
+ $classNamesToResponseKeys = [
110
+ 'Braintree\CreditCard' => 'creditCard',
111
+ 'Braintree_CreditCard' => 'creditCard',
112
+ 'Braintree\CreditCardGateway' => 'creditCard',
113
+ 'Braintree_CreditCardGateway' => 'creditCard',
114
+ 'Braintree\Customer' => 'customer',
115
+ 'Braintree_Customer' => 'customer',
116
+ 'Braintree\CustomerGateway' => 'customer',
117
+ 'Braintree_CustomerGateway' => 'customer',
118
+ 'Braintree\Subscription' => 'subscription',
119
+ 'Braintree_Subscription' => 'subscription',
120
+ 'Braintree\SubscriptionGateway' => 'subscription',
121
+ 'Braintree_SubscriptionGateway' => 'subscription',
122
+ 'Braintree\Transaction' => 'transaction',
123
+ 'Braintree_Transaction' => 'transaction',
124
+ 'Braintree\TransactionGateway' => 'transaction',
125
+ 'Braintree_TransactionGateway' => 'transaction',
126
+ 'Braintree\CreditCardVerification' => 'verification',
127
+ 'Braintree_CreditCardVerification' => 'verification',
128
+ 'Braintree\CreditCardVerificationGateway' => 'verification',
129
+ 'Braintree_CreditCardVerificationGateway' => 'verification',
130
+ 'Braintree\AddOn' => 'addOn',
131
+ 'Braintree_AddOn' => 'addOn',
132
+ 'Braintree\AddOnGateway' => 'addOn',
133
+ 'Braintree_AddOnGateway' => 'addOn',
134
+ 'Braintree\Discount' => 'discount',
135
+ 'Braintree_Discount' => 'discount',
136
+ 'Braintree\DiscountGateway' => 'discount',
137
+ 'Braintree_DiscountGateway' => 'discount',
138
+ 'Braintree\Plan' => 'plan',
139
+ 'Braintree_Plan' => 'plan',
140
+ 'Braintree\PlanGateway' => 'plan',
141
+ 'Braintree_PlanGateway' => 'plan',
142
+ 'Braintree\Address' => 'address',
143
+ 'Braintree_Address' => 'address',
144
+ 'Braintree\AddressGateway' => 'address',
145
+ 'Braintree_AddressGateway' => 'address',
146
+ 'Braintree\SettlementBatchSummary' => 'settlementBatchSummary',
147
+ 'Braintree_SettlementBatchSummary' => 'settlementBatchSummary',
148
+ 'Braintree\SettlementBatchSummaryGateway' => 'settlementBatchSummary',
149
+ 'Braintree_SettlementBatchSummaryGateway' => 'settlementBatchSummary',
150
+ 'Braintree\Merchant' => 'merchant',
151
+ 'Braintree_Merchant' => 'merchant',
152
+ 'Braintree\MerchantGateway' => 'merchant',
153
+ 'Braintree_MerchantGateway' => 'merchant',
154
+ 'Braintree\MerchantAccount' => 'merchantAccount',
155
+ 'Braintree_MerchantAccount' => 'merchantAccount',
156
+ 'Braintree\MerchantAccountGateway' => 'merchantAccount',
157
+ 'Braintree_MerchantAccountGateway' => 'merchantAccount',
158
+ 'Braintree\OAuthCredentials' => 'credentials',
159
+ 'Braintree_OAuthCredentials' => 'credentials',
160
+ 'Braintree\OAuthResult' => 'result',
161
+ 'Braintree_OAuthResult' => 'result',
162
+ 'Braintree\PayPalAccount' => 'paypalAccount',
163
+ 'Braintree_PayPalAccount' => 'paypalAccount',
164
+ 'Braintree\PayPalAccountGateway' => 'paypalAccount',
165
+ 'Braintree_PayPalAccountGateway' => 'paypalAccount',
166
+ ];
167
 
 
168
  return $classNamesToResponseKeys[$name];
169
  }
170
 
171
  /**
172
  *
173
  * @param string $name className
174
+ * @return string ClassName
175
  */
176
  public static function buildClassName($name)
177
  {
178
+ $responseKeysToClassNames = [
179
+ 'creditCard' => 'Braintree\CreditCard',
180
+ 'customer' => 'Braintree\Customer',
181
+ 'subscription' => 'Braintree\Subscription',
182
+ 'transaction' => 'Braintree\Transaction',
183
+ 'verification' => 'Braintree\CreditCardVerification',
184
+ 'addOn' => 'Braintree\AddOn',
185
+ 'discount' => 'Braintree\Discount',
186
+ 'plan' => 'Braintree\Plan',
187
+ 'address' => 'Braintree\Address',
188
+ 'settlementBatchSummary' => 'Braintree\SettlementBatchSummary',
189
+ 'merchantAccount' => 'Braintree\MerchantAccount',
190
+ ];
191
 
192
+ return (string) $responseKeysToClassNames[$name];
193
  }
194
 
195
  /**
197
  *
198
  * @access public
199
  * @param string $string
200
+ * @param null|string $delimiter
201
  * @return string modified string
202
  */
203
  public static function delimiterToCamelCase($string, $delimiter = '[\-\_]')
230
  * find capitals and convert to delimiter + lowercase
231
  *
232
  * @access public
233
+ * @param string $string
234
+ * @param null|string $delimiter
235
+ * @return string modified string
236
  */
237
  public static function camelCaseToDelimiter($string, $delimiter = '-')
238
  {
239
+ return strtolower(preg_replace('/([A-Z])/', "$delimiter\\1", $string));
 
 
 
 
 
 
 
 
240
  }
241
 
242
  public static function delimiterToCamelCaseArray($array, $delimiter = '[\-\_]')
243
  {
244
+ $converted = [];
245
  foreach ($array as $key => $value) {
246
  if (is_string($key)) {
247
  $key = self::delimiterToCamelCase($key, $delimiter);
263
 
264
  public static function camelCaseToDelimiterArray($array, $delimiter = '-')
265
  {
266
+ $converted = [];
267
  foreach ($array as $key => $value) {
268
  if (is_string($key)) {
269
  $key = self::camelCaseToDelimiter($key, $delimiter);
278
 
279
  public static function delimiterToUnderscoreArray($array)
280
  {
281
+ $converted = [];
282
  foreach ($array as $key => $value) {
283
  $key = self::delimiterToUnderscore($key);
284
  $converted[$key] = $value;
291
  * @param array $array associative array to implode
292
  * @param string $separator (optional, defaults to =)
293
  * @param string $glue (optional, defaults to ', ')
294
+ * @return bool
295
  */
296
  public static function implodeAssociativeArray($array, $separator = '=', $glue = ', ')
297
  {
308
  }
309
 
310
  public static function attributesToString($attributes) {
311
+ $printableAttribs = [];
312
  foreach ($attributes AS $key => $value) {
313
  if (is_array($value)) {
314
+ $pAttrib = self::attributesToString($value);
315
  } else if ($value instanceof DateTime) {
316
  $pAttrib = $value->format(DateTime::RFC850);
317
  } else {
319
  }
320
  $printableAttribs[$key] = sprintf('%s', $pAttrib);
321
  }
322
+ return self::implodeAssociativeArray($printableAttribs);
323
  }
324
 
325
  /**
341
  if(!empty($invalidKeys)) {
342
  asort($invalidKeys);
343
  $sortedList = join(', ', $invalidKeys);
344
+ throw new InvalidArgumentException('invalid keys: ' . $sortedList);
345
  }
346
  }
347
  /**
352
  */
353
  private static function _flattenArray($keys, $namespace = null)
354
  {
355
+ $flattenedArray = [];
356
  foreach($keys AS $key) {
357
  if(is_array($key)) {
358
  $theKeys = array_keys($key);
371
 
372
  private static function _flattenUserKeys($keys, $namespace = null)
373
  {
374
+ $flattenedArray = [];
375
 
376
  foreach($keys AS $key => $value) {
377
  $fullKey = empty($namespace) ? $key : $namespace;
413
  return $invalidKeys;
414
  }
415
  }
416
+ class_alias('Braintree\Util', 'Braintree_Util');
lib/Gene/Braintree/braintree/braintree_php/lib/Braintree/VenmoAccount.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree VenmoAccount module
6
+ * Creates and manages Braintree Venmo accounts
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br />
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read string $createdAt
17
+ * @property-read string $default
18
+ * @property-read string $updatedAt
19
+ * @property-read string $customerId
20
+ * @property-read string $sourceDescription
21
+ * @property-read string $token
22
+ * @property-read string $imageUrl
23
+ * @property-read string $username
24
+ * @property-read string $venmoUserId
25
+ */
26
+ class VenmoAccount extends Base
27
+ {
28
+ /* instance methods */
29
+ /**
30
+ * returns false if default is null or false
31
+ *
32
+ * @return boolean
33
+ */
34
+ public function isDefault()
35
+ {
36
+ return $this->default;
37
+ }
38
+
39
+ /**
40
+ * factory method: returns an instance of VenmoAccount
41
+ * to the requesting method, with populated properties
42
+ *
43
+ * @ignore
44
+ * @return VenmoAccount
45
+ */
46
+ public static function factory($attributes)
47
+ {
48
+
49
+ $instance = new self();
50
+ $instance->_initialize($attributes);
51
+ return $instance;
52
+ }
53
+
54
+ /**
55
+ * sets instance properties from an array of values
56
+ *
57
+ * @access protected
58
+ * @param array $venmoAccountAttribs array of Venmo account properties
59
+ * @return void
60
+ */
61
+ protected function _initialize($venmoAccountAttribs)
62
+ {
63
+ $this->_attributes = $venmoAccountAttribs;
64
+
65
+ $subscriptionArray = array();
66
+ if (isset($venmoAccountAttribs['subscriptions'])) {
67
+ foreach ($venmoAccountAttribs['subscriptions'] AS $subscription) {
68
+ $subscriptionArray[] = Subscription::factory($subscription);
69
+ }
70
+ }
71
+
72
+ $this->_set('subscriptions', $subscriptionArray);
73
+ }
74
+ }
75
+ class_alias('Braintree\VenmoAccount', 'Braintree_VenmoAccount');
lib/Gene/Braintree/{Version.php → braintree/braintree_php/lib/Braintree/Version.php} RENAMED
@@ -1,17 +1,19 @@
1
  <?php
 
 
2
  /**
3
  * Braintree Library Version
4
  * stores version information about the Braintree library
5
  *
6
- * @copyright 2014 Braintree, a division of PayPal, Inc.
7
  */
8
- final class Braintree_Version
9
  {
10
  /**
11
  * class constants
12
  */
13
  const MAJOR = 3;
14
- const MINOR = 5;
15
  const TINY = 0;
16
 
17
  /**
@@ -28,6 +30,7 @@ final class Braintree_Version
28
  */
29
  public static function get()
30
  {
31
- return self::MAJOR.'.'.self::MINOR.'.'.self::TINY;
32
  }
33
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree Library Version
6
  * stores version information about the Braintree library
7
  *
8
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
9
  */
10
+ class Version
11
  {
12
  /**
13
  * class constants
14
  */
15
  const MAJOR = 3;
16
+ const MINOR = 17;
17
  const TINY = 0;
18
 
19
  /**
30
  */
31
  public static function get()
32
  {
33
+ return self::MAJOR . '.' . self::MINOR . '.' . self::TINY;
34
  }
35
  }
36
+ class_alias('Braintree\Version', 'Braintree_Version');
lib/Gene/Braintree/{WebhookNotification.php → braintree/braintree_php/lib/Braintree/WebhookNotification.php} RENAMED
@@ -1,5 +1,7 @@
1
  <?php
2
- class Braintree_WebhookNotification extends Braintree_Base
 
 
3
  {
4
  const SUBSCRIPTION_CANCELED = 'subscription_canceled';
5
  const SUBSCRIPTION_CHARGED_SUCCESSFULLY = 'subscription_charged_successfully';
@@ -11,6 +13,8 @@ class Braintree_WebhookNotification extends Braintree_Base
11
  const SUB_MERCHANT_ACCOUNT_APPROVED = 'sub_merchant_account_approved';
12
  const SUB_MERCHANT_ACCOUNT_DECLINED = 'sub_merchant_account_declined';
13
  const TRANSACTION_DISBURSED = 'transaction_disbursed';
 
 
14
  const DISBURSEMENT_EXCEPTION = 'disbursement_exception';
15
  const DISBURSEMENT = 'disbursement';
16
  const DISPUTE_OPENED = 'dispute_opened';
@@ -19,29 +23,31 @@ class Braintree_WebhookNotification extends Braintree_Base
19
  const PARTNER_MERCHANT_CONNECTED = 'partner_merchant_connected';
20
  const PARTNER_MERCHANT_DISCONNECTED = 'partner_merchant_disconnected';
21
  const PARTNER_MERCHANT_DECLINED = 'partner_merchant_declined';
 
 
22
 
23
  public static function parse($signature, $payload)
24
  {
25
  if (preg_match("/[^A-Za-z0-9+=\/\n]/", $payload) === 1) {
26
- throw new Braintree_Exception_InvalidSignature("payload contains illegal characters");
27
  }
28
 
29
- Braintree_Configuration::assertGlobalHasAccessTokenOrKeys();
30
  self::_validateSignature($signature, $payload);
31
 
32
  $xml = base64_decode($payload);
33
- $attributes = Braintree_Xml::buildArrayFromXml($xml);
34
  return self::factory($attributes['notification']);
35
  }
36
 
37
  public static function verify($challenge)
38
  {
39
  if (!preg_match('/^[a-f0-9]{20,32}$/', $challenge)) {
40
- throw new Braintree_Exception_InvalidChallenge("challenge contains non-hex characters");
41
  }
42
- Braintree_Configuration::assertGlobalHasAccessTokenOrKeys();
43
- $publicKey = Braintree_Configuration::publicKey();
44
- $digest = Braintree_Digest::hexDigestSha1(Braintree_Configuration::privateKey(), $challenge);
45
  return "{$publicKey}|{$digest}";
46
  }
47
 
@@ -57,7 +63,7 @@ class Braintree_WebhookNotification extends Braintree_Base
57
  foreach ($signaturePairs as $pair)
58
  {
59
  $components = preg_split("/\|/", $pair);
60
- if ($components[0] == Braintree_Configuration::publicKey()) {
61
  return $components[1];
62
  }
63
  }
@@ -67,8 +73,8 @@ class Braintree_WebhookNotification extends Braintree_Base
67
 
68
  private static function _payloadMatches($signature, $payload)
69
  {
70
- $payloadSignature = Braintree_Digest::hexDigestSha1(Braintree_Configuration::privateKey(), $payload);
71
- return Braintree_Digest::secureCompare($signature, $payloadSignature);
72
  }
73
 
74
  private static function _validateSignature($signatureString, $payload)
@@ -76,11 +82,11 @@ class Braintree_WebhookNotification extends Braintree_Base
76
  $signaturePairs = preg_split("/&/", $signatureString);
77
  $signature = self::_matchingSignature($signaturePairs);
78
  if (!$signature) {
79
- throw new Braintree_Exception_InvalidSignature("no matching public key");
80
  }
81
 
82
  if (!(self::_payloadMatches($signature, $payload) || self::_payloadMatches($signature, $payload . "\n"))) {
83
- throw new Braintree_Exception_InvalidSignature("signature does not match payload - one has been modified");
84
  }
85
  }
86
 
@@ -95,32 +101,37 @@ class Braintree_WebhookNotification extends Braintree_Base
95
  }
96
 
97
  if (isset($wrapperNode['subscription'])) {
98
- $this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
99
  }
100
 
101
  if (isset($wrapperNode['merchantAccount'])) {
102
- $this->_set('merchantAccount', Braintree_MerchantAccount::factory($wrapperNode['merchantAccount']));
103
  }
104
 
105
  if (isset($wrapperNode['transaction'])) {
106
- $this->_set('transaction', Braintree_Transaction::factory($wrapperNode['transaction']));
107
  }
108
 
109
  if (isset($wrapperNode['disbursement'])) {
110
- $this->_set('disbursement', Braintree_Disbursement::factory($wrapperNode['disbursement']));
111
  }
112
 
113
  if (isset($wrapperNode['partnerMerchant'])) {
114
- $this->_set('partnerMerchant', Braintree_PartnerMerchant::factory($wrapperNode['partnerMerchant']));
115
  }
116
 
117
  if (isset($wrapperNode['dispute'])) {
118
- $this->_set('dispute', Braintree_Dispute::factory($wrapperNode['dispute']));
 
 
 
 
119
  }
120
 
121
  if (isset($wrapperNode['errors'])) {
122
- $this->_set('errors', new Braintree_Error_ValidationErrorCollection($wrapperNode['errors']));
123
  $this->_set('message', $wrapperNode['message']);
124
  }
125
  }
126
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class WebhookNotification extends Base
5
  {
6
  const SUBSCRIPTION_CANCELED = 'subscription_canceled';
7
  const SUBSCRIPTION_CHARGED_SUCCESSFULLY = 'subscription_charged_successfully';
13
  const SUB_MERCHANT_ACCOUNT_APPROVED = 'sub_merchant_account_approved';
14
  const SUB_MERCHANT_ACCOUNT_DECLINED = 'sub_merchant_account_declined';
15
  const TRANSACTION_DISBURSED = 'transaction_disbursed';
16
+ const TRANSACTION_SETTLED = 'transaction_settled';
17
+ const TRANSACTION_SETTLEMENT_DECLINED = 'transaction_settlement_declined';
18
  const DISBURSEMENT_EXCEPTION = 'disbursement_exception';
19
  const DISBURSEMENT = 'disbursement';
20
  const DISPUTE_OPENED = 'dispute_opened';
23
  const PARTNER_MERCHANT_CONNECTED = 'partner_merchant_connected';
24
  const PARTNER_MERCHANT_DISCONNECTED = 'partner_merchant_disconnected';
25
  const PARTNER_MERCHANT_DECLINED = 'partner_merchant_declined';
26
+ const CHECK = 'check';
27
+ const ACCOUNT_UPDATER_DAILY_REPORT = 'account_updater_daily_report';
28
 
29
  public static function parse($signature, $payload)
30
  {
31
  if (preg_match("/[^A-Za-z0-9+=\/\n]/", $payload) === 1) {
32
+ throw new Exception\InvalidSignature("payload contains illegal characters");
33
  }
34
 
35
+ Configuration::assertGlobalHasAccessTokenOrKeys();
36
  self::_validateSignature($signature, $payload);
37
 
38
  $xml = base64_decode($payload);
39
+ $attributes = Xml::buildArrayFromXml($xml);
40
  return self::factory($attributes['notification']);
41
  }
42
 
43
  public static function verify($challenge)
44
  {
45
  if (!preg_match('/^[a-f0-9]{20,32}$/', $challenge)) {
46
+ throw new Exception\InvalidChallenge("challenge contains non-hex characters");
47
  }
48
+ Configuration::assertGlobalHasAccessTokenOrKeys();
49
+ $publicKey = Configuration::publicKey();
50
+ $digest = Digest::hexDigestSha1(Configuration::privateKey(), $challenge);
51
  return "{$publicKey}|{$digest}";
52
  }
53
 
63
  foreach ($signaturePairs as $pair)
64
  {
65
  $components = preg_split("/\|/", $pair);
66
+ if ($components[0] == Configuration::publicKey()) {
67
  return $components[1];
68
  }
69
  }
73
 
74
  private static function _payloadMatches($signature, $payload)
75
  {
76
+ $payloadSignature = Digest::hexDigestSha1(Configuration::privateKey(), $payload);
77
+ return Digest::secureCompare($signature, $payloadSignature);
78
  }
79
 
80
  private static function _validateSignature($signatureString, $payload)
82
  $signaturePairs = preg_split("/&/", $signatureString);
83
  $signature = self::_matchingSignature($signaturePairs);
84
  if (!$signature) {
85
+ throw new Exception\InvalidSignature("no matching public key");
86
  }
87
 
88
  if (!(self::_payloadMatches($signature, $payload) || self::_payloadMatches($signature, $payload . "\n"))) {
89
+ throw new Exception\InvalidSignature("signature does not match payload - one has been modified");
90
  }
91
  }
92
 
101
  }
102
 
103
  if (isset($wrapperNode['subscription'])) {
104
+ $this->_set('subscription', Subscription::factory($attributes['subject']['subscription']));
105
  }
106
 
107
  if (isset($wrapperNode['merchantAccount'])) {
108
+ $this->_set('merchantAccount', MerchantAccount::factory($wrapperNode['merchantAccount']));
109
  }
110
 
111
  if (isset($wrapperNode['transaction'])) {
112
+ $this->_set('transaction', Transaction::factory($wrapperNode['transaction']));
113
  }
114
 
115
  if (isset($wrapperNode['disbursement'])) {
116
+ $this->_set('disbursement', Disbursement::factory($wrapperNode['disbursement']));
117
  }
118
 
119
  if (isset($wrapperNode['partnerMerchant'])) {
120
+ $this->_set('partnerMerchant', PartnerMerchant::factory($wrapperNode['partnerMerchant']));
121
  }
122
 
123
  if (isset($wrapperNode['dispute'])) {
124
+ $this->_set('dispute', Dispute::factory($wrapperNode['dispute']));
125
+ }
126
+
127
+ if (isset($wrapperNode['accountUpdaterDailyReport'])) {
128
+ $this->_set('accountUpdaterDailyReport', AccountUpdaterDailyReport::factory($wrapperNode['accountUpdaterDailyReport']));
129
  }
130
 
131
  if (isset($wrapperNode['errors'])) {
132
+ $this->_set('errors', new Error\ValidationErrorCollection($wrapperNode['errors']));
133
  $this->_set('message', $wrapperNode['message']);
134
  }
135
  }
136
  }
137
+ class_alias('Braintree\WebhookNotification', 'Braintree_WebhookNotification');
lib/Gene/Braintree/{WebhookTesting.php → braintree/braintree_php/lib/Braintree/WebhookTesting.php} RENAMED
@@ -1,53 +1,70 @@
1
  <?php
2
- class Braintree_WebhookTesting
 
 
3
  {
4
  public static function sampleNotification($kind, $id)
5
  {
6
  $payload = base64_encode(self::_sampleXml($kind, $id)) . "\n";
7
- $signature = Braintree_Configuration::publicKey() . "|" . Braintree_Digest::hexDigestSha1(Braintree_Configuration::privateKey(), $payload);
8
 
9
- return array(
10
  'bt_signature' => $signature,
11
  'bt_payload' => $payload
12
- );
13
  }
14
 
15
  private static function _sampleXml($kind, $id)
16
  {
17
  switch ($kind) {
18
- case Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED:
19
  $subjectXml = self::_merchantAccountApprovedSampleXml($id);
20
  break;
21
- case Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_DECLINED:
22
  $subjectXml = self::_merchantAccountDeclinedSampleXml($id);
23
  break;
24
- case Braintree_WebhookNotification::TRANSACTION_DISBURSED:
25
  $subjectXml = self::_transactionDisbursedSampleXml($id);
26
  break;
27
- case Braintree_WebhookNotification::DISBURSEMENT_EXCEPTION:
 
 
 
 
 
 
28
  $subjectXml = self::_disbursementExceptionSampleXml($id);
29
  break;
30
- case Braintree_WebhookNotification::DISBURSEMENT:
31
  $subjectXml = self::_disbursementSampleXml($id);
32
  break;
33
- case Braintree_WebhookNotification::PARTNER_MERCHANT_CONNECTED:
34
  $subjectXml = self::_partnerMerchantConnectedSampleXml($id);
35
  break;
36
- case Braintree_WebhookNotification::PARTNER_MERCHANT_DISCONNECTED:
37
  $subjectXml = self::_partnerMerchantDisconnectedSampleXml($id);
38
  break;
39
- case Braintree_WebhookNotification::PARTNER_MERCHANT_DECLINED:
40
  $subjectXml = self::_partnerMerchantDeclinedSampleXml($id);
41
  break;
42
- case Braintree_WebhookNotification::DISPUTE_OPENED:
43
  $subjectXml = self::_disputeOpenedSampleXml($id);
44
  break;
45
- case Braintree_WebhookNotification::DISPUTE_LOST:
46
  $subjectXml = self::_disputeLostSampleXml($id);
47
  break;
48
- case Braintree_WebhookNotification::DISPUTE_WON:
49
  $subjectXml = self::_disputeWonSampleXml($id);
50
  break;
 
 
 
 
 
 
 
 
 
51
  default:
52
  $subjectXml = self::_subscriptionSampleXml($id);
53
  break;
@@ -118,6 +135,50 @@ class Braintree_WebhookTesting
118
  ";
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  private static function _disbursementExceptionSampleXml($id)
122
  {
123
  return "
@@ -176,6 +237,7 @@ class Braintree_WebhookTesting
176
  <currency-iso-code>USD</currency-iso-code>
177
  <received-date type=\"date\">2014-03-01</received-date>
178
  <reply-by-date type=\"date\">2014-03-21</reply-by-date>
 
179
  <status>open</status>
180
  <reason>fraud</reason>
181
  <id>${id}</id>
@@ -183,6 +245,7 @@ class Braintree_WebhookTesting
183
  <id>${id}</id>
184
  <amount>250.00</amount>
185
  </transaction>
 
186
  </dispute>
187
  ";
188
  }
@@ -195,13 +258,16 @@ class Braintree_WebhookTesting
195
  <currency-iso-code>USD</currency-iso-code>
196
  <received-date type=\"date\">2014-03-01</received-date>
197
  <reply-by-date type=\"date\">2014-03-21</reply-by-date>
 
198
  <status>lost</status>
199
  <reason>fraud</reason>
200
  <id>${id}</id>
201
  <transaction>
202
  <id>${id}</id>
203
  <amount>250.00</amount>
 
204
  </transaction>
 
205
  </dispute>
206
  ";
207
  }
@@ -214,6 +280,7 @@ class Braintree_WebhookTesting
214
  <currency-iso-code>USD</currency-iso-code>
215
  <received-date type=\"date\">2014-03-01</received-date>
216
  <reply-by-date type=\"date\">2014-03-21</reply-by-date>
 
217
  <status>won</status>
218
  <reason>fraud</reason>
219
  <id>${id}</id>
@@ -221,6 +288,8 @@ class Braintree_WebhookTesting
221
  <id>${id}</id>
222
  <amount>250.00</amount>
223
  </transaction>
 
 
224
  </dispute>
225
  ";
226
  }
@@ -240,6 +309,34 @@ class Braintree_WebhookTesting
240
  ";
241
  }
242
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  private static function _partnerMerchantConnectedSampleXml($id)
244
  {
245
  return "
@@ -271,6 +368,16 @@ class Braintree_WebhookTesting
271
  ";
272
  }
273
 
 
 
 
 
 
 
 
 
 
 
274
  private static function _timestamp()
275
  {
276
  $originalZone = date_default_timezone_get();
@@ -281,3 +388,4 @@ class Braintree_WebhookTesting
281
  return $timestamp;
282
  }
283
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
+ class WebhookTesting
5
  {
6
  public static function sampleNotification($kind, $id)
7
  {
8
  $payload = base64_encode(self::_sampleXml($kind, $id)) . "\n";
9
+ $signature = Configuration::publicKey() . "|" . Digest::hexDigestSha1(Configuration::privateKey(), $payload);
10
 
11
+ return [
12
  'bt_signature' => $signature,
13
  'bt_payload' => $payload
14
+ ];
15
  }
16
 
17
  private static function _sampleXml($kind, $id)
18
  {
19
  switch ($kind) {
20
+ case WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED:
21
  $subjectXml = self::_merchantAccountApprovedSampleXml($id);
22
  break;
23
+ case WebhookNotification::SUB_MERCHANT_ACCOUNT_DECLINED:
24
  $subjectXml = self::_merchantAccountDeclinedSampleXml($id);
25
  break;
26
+ case WebhookNotification::TRANSACTION_DISBURSED:
27
  $subjectXml = self::_transactionDisbursedSampleXml($id);
28
  break;
29
+ case WebhookNotification::TRANSACTION_SETTLED:
30
+ $subjectXml = self::_transactionSettledSampleXml($id);
31
+ break;
32
+ case WebhookNotification::TRANSACTION_SETTLEMENT_DECLINED:
33
+ $subjectXml = self::_transactionSettlementDeclinedSampleXml($id);
34
+ break;
35
+ case WebhookNotification::DISBURSEMENT_EXCEPTION:
36
  $subjectXml = self::_disbursementExceptionSampleXml($id);
37
  break;
38
+ case WebhookNotification::DISBURSEMENT:
39
  $subjectXml = self::_disbursementSampleXml($id);
40
  break;
41
+ case WebhookNotification::PARTNER_MERCHANT_CONNECTED:
42
  $subjectXml = self::_partnerMerchantConnectedSampleXml($id);
43
  break;
44
+ case WebhookNotification::PARTNER_MERCHANT_DISCONNECTED:
45
  $subjectXml = self::_partnerMerchantDisconnectedSampleXml($id);
46
  break;
47
+ case WebhookNotification::PARTNER_MERCHANT_DECLINED:
48
  $subjectXml = self::_partnerMerchantDeclinedSampleXml($id);
49
  break;
50
+ case WebhookNotification::DISPUTE_OPENED:
51
  $subjectXml = self::_disputeOpenedSampleXml($id);
52
  break;
53
+ case WebhookNotification::DISPUTE_LOST:
54
  $subjectXml = self::_disputeLostSampleXml($id);
55
  break;
56
+ case WebhookNotification::DISPUTE_WON:
57
  $subjectXml = self::_disputeWonSampleXml($id);
58
  break;
59
+ case WebhookNotification::SUBSCRIPTION_CHARGED_SUCCESSFULLY:
60
+ $subjectXml = self::_subscriptionChargedSuccessfullySampleXml($id);
61
+ break;
62
+ case WebhookNotification::CHECK:
63
+ $subjectXml = self::_checkSampleXml();
64
+ break;
65
+ case WebhookNotification::ACCOUNT_UPDATER_DAILY_REPORT:
66
+ $subjectXml = self::_accountUpdaterDailyReportSampleXml($id);
67
+ break;
68
  default:
69
  $subjectXml = self::_subscriptionSampleXml($id);
70
  break;
135
  ";
136
  }
137
 
138
+ private static function _transactionSettledSampleXml($id)
139
+ {
140
+ return "
141
+ <transaction>
142
+ <id>${id}</id>
143
+ <status>settled</status>
144
+ <type>sale</type>
145
+ <currency-iso-code>USD</currency-iso-code>
146
+ <amount>100.00</amount>
147
+ <merchant-account-id>ogaotkivejpfayqfeaimuktty</merchant-account-id>
148
+ <payment-instrument-type>us_bank_account</payment-instrument-type>
149
+ <us-bank-account>
150
+ <routing-number>123456789</routing-number>
151
+ <last-4>1234</last-4>
152
+ <account-type>checking</account-type>
153
+ <account-description>PayPal Checking - 1234</account-description>
154
+ <account-holder-name>Dan Schulman</account-holder-name>
155
+ </us-bank-account>
156
+ </transaction>
157
+ ";
158
+ }
159
+
160
+ private static function _transactionSettlementDeclinedSampleXml($id)
161
+ {
162
+ return "
163
+ <transaction>
164
+ <id>${id}</id>
165
+ <status>settlement_declined</status>
166
+ <type>sale</type>
167
+ <currency-iso-code>USD</currency-iso-code>
168
+ <amount>100.00</amount>
169
+ <merchant-account-id>ogaotkivejpfayqfeaimuktty</merchant-account-id>
170
+ <payment-instrument-type>us_bank_account</payment-instrument-type>
171
+ <us-bank-account>
172
+ <routing-number>123456789</routing-number>
173
+ <last-4>1234</last-4>
174
+ <account-type>checking</account-type>
175
+ <account-description>PayPal Checking - 1234</account-description>
176
+ <account-holder-name>Dan Schulman</account-holder-name>
177
+ </us-bank-account>
178
+ </transaction>
179
+ ";
180
+ }
181
+
182
  private static function _disbursementExceptionSampleXml($id)
183
  {
184
  return "
237
  <currency-iso-code>USD</currency-iso-code>
238
  <received-date type=\"date\">2014-03-01</received-date>
239
  <reply-by-date type=\"date\">2014-03-21</reply-by-date>
240
+ <kind>chargeback</kind>
241
  <status>open</status>
242
  <reason>fraud</reason>
243
  <id>${id}</id>
245
  <id>${id}</id>
246
  <amount>250.00</amount>
247
  </transaction>
248
+ <date-opened type=\"date\">2014-03-21</date-opened>
249
  </dispute>
250
  ";
251
  }
258
  <currency-iso-code>USD</currency-iso-code>
259
  <received-date type=\"date\">2014-03-01</received-date>
260
  <reply-by-date type=\"date\">2014-03-21</reply-by-date>
261
+ <kind>chargeback</kind>
262
  <status>lost</status>
263
  <reason>fraud</reason>
264
  <id>${id}</id>
265
  <transaction>
266
  <id>${id}</id>
267
  <amount>250.00</amount>
268
+ <next_billing-date type=\"date\">2020-02-10</next_billing-date>
269
  </transaction>
270
+ <date-opened type=\"date\">2014-03-21</date-opened>
271
  </dispute>
272
  ";
273
  }
280
  <currency-iso-code>USD</currency-iso-code>
281
  <received-date type=\"date\">2014-03-01</received-date>
282
  <reply-by-date type=\"date\">2014-03-21</reply-by-date>
283
+ <kind>chargeback</kind>
284
  <status>won</status>
285
  <reason>fraud</reason>
286
  <id>${id}</id>
288
  <id>${id}</id>
289
  <amount>250.00</amount>
290
  </transaction>
291
+ <date-opened type=\"date\">2014-03-21</date-opened>
292
+ <date-won type=\"date\">2014-03-22</date-won>
293
  </dispute>
294
  ";
295
  }
309
  ";
310
  }
311
 
312
+ private static function _subscriptionChargedSuccessfullySampleXml($id)
313
+ {
314
+ return "
315
+ <subscription>
316
+ <id>{$id}</id>
317
+ <billing-period-start-date type=\"date\">2016-03-21</billing-period-start-date>
318
+ <billing-period-end-date type=\"date\">2017-03-31</billing-period-end-date>
319
+ <transactions type=\"array\">
320
+ <transaction>
321
+ <status>submitted_for_settlement</status>
322
+ <amount>49.99</amount>
323
+ </transaction>
324
+ </transactions>
325
+ <add_ons type=\"array\">
326
+ </add_ons>
327
+ <discounts type=\"array\">
328
+ </discounts>
329
+ </subscription>
330
+ ";
331
+ }
332
+
333
+ private static function _checkSampleXml()
334
+ {
335
+ return "
336
+ <check type=\"boolean\">true</check>
337
+ ";
338
+ }
339
+
340
  private static function _partnerMerchantConnectedSampleXml($id)
341
  {
342
  return "
368
  ";
369
  }
370
 
371
+ private static function _accountUpdaterDailyReportSampleXml($id)
372
+ {
373
+ return "
374
+ <account-updater-daily-report>
375
+ <report-date type=\"date\">2016-01-14</report-date>
376
+ <report-url>link-to-csv-report</report-url>
377
+ </account-updater-daily-report>
378
+ ";
379
+ }
380
+
381
  private static function _timestamp()
382
  {
383
  $originalZone = date_default_timezone_get();
388
  return $timestamp;
389
  }
390
  }
391
+ class_alias('Braintree\WebhookTesting', 'Braintree_WebhookTesting');
lib/Gene/Braintree/{Xml.php → braintree/braintree_php/lib/Braintree/Xml.php} RENAMED
@@ -1,12 +1,14 @@
1
  <?php
 
 
2
  /**
3
  * Braintree Xml parser and generator
4
  * PHP version 5
5
  * superclass for Braintree XML parsing and generation
6
  *
7
- * @copyright 2014 Braintree, a division of PayPal, Inc.
8
  */
9
- final class Braintree_Xml
10
  {
11
  /**
12
  * @ignore
@@ -23,7 +25,7 @@ final class Braintree_Xml
23
  */
24
  public static function buildArrayFromXml($xml)
25
  {
26
- return Braintree_Xml_Parser::arrayFromXml($xml);
27
  }
28
 
29
  /**
@@ -33,6 +35,7 @@ final class Braintree_Xml
33
  */
34
  public static function buildXmlFromArray($array)
35
  {
36
- return Braintree_Xml_Generator::arrayToXml($array);
37
  }
38
  }
 
1
  <?php
2
+ namespace Braintree;
3
+
4
  /**
5
  * Braintree Xml parser and generator
6
  * PHP version 5
7
  * superclass for Braintree XML parsing and generation
8
  *
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
  */
11
+ class Xml
12
  {
13
  /**
14
  * @ignore
25
  */
26
  public static function buildArrayFromXml($xml)
27
  {
28
+ return Xml\Parser::arrayFromXml($xml);
29
  }
30
 
31
  /**
35
  */
36
  public static function buildXmlFromArray($array)
37
  {
38
+ return Xml\Generator::arrayToXml($array);
39
  }
40
  }
41
+ class_alias('Braintree\Xml', 'Braintree_Xml');
lib/Gene/Braintree/{Xml → braintree/braintree_php/lib/Braintree/Xml}/Generator.php RENAMED
@@ -1,27 +1,34 @@
1
  <?php
 
 
 
 
 
 
 
2
  /**
3
  * PHP version 5
4
  *
5
- * @copyright 2014 Braintree, a division of PayPal, Inc.
6
  */
7
 
8
  /**
9
  * Generates XML output from arrays using PHP's
10
  * built-in XMLWriter
11
  *
12
- * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  */
14
- class Braintree_Xml_Generator
15
  {
16
  /**
17
  * arrays passed to this method should have a single root element
18
  * with an array as its value
19
  * @param array $aData the array of data
20
- * @return var XML string
21
  */
22
  public static function arrayToXml($aData)
23
  {
24
- $aData = Braintree_Util::camelCaseToDelimiterArray($aData, '-');
25
  // set up the XMLWriter
26
  $writer = new XMLWriter();
27
  $writer->openMemory();
@@ -53,7 +60,7 @@ class Braintree_Xml_Generator
53
  * @static
54
  * @param object $writer XMLWriter object
55
  * @param array $aData contains attributes and values
56
- * @return none
57
  */
58
  private static function _createElementsFromArray(&$writer, $aData)
59
  {
@@ -103,28 +110,30 @@ class Braintree_Xml_Generator
103
  private static function _generateXmlAttribute($value)
104
  {
105
  if ($value instanceof DateTime) {
106
- return array('type', 'datetime', self::_dateTimeToXmlTimestamp($value));
107
  }
108
  if (is_int($value)) {
109
- return array('type', 'integer', $value);
110
  }
111
  if (is_bool($value)) {
112
- return array('type', 'boolean', ($value ? 'true' : 'false'));
113
  }
114
  if ($value === NULL) {
115
- return array('nil', 'true', $value);
116
  }
117
  }
118
  /**
119
  * converts datetime back to xml schema format
120
  * @access protected
121
  * @param object $dateTime
122
- * @return var XML schema formatted timestamp
123
  */
124
  private static function _dateTimeToXmlTimestamp($dateTime)
125
  {
126
- $dateTime->setTimeZone(new DateTimeZone('UTC'));
127
- return ($dateTime->format('Y-m-d\TH:i:s') . 'Z');
 
 
128
  }
129
 
130
  private static function _castDateTime($string)
@@ -141,3 +150,4 @@ class Braintree_Xml_Generator
141
  }
142
  }
143
  }
 
1
  <?php
2
+ namespace Braintree\Xml;
3
+
4
+ use DateTime;
5
+ use DateTimeZone;
6
+ use XMLWriter;
7
+ use Braintree\Util;
8
+
9
  /**
10
  * PHP version 5
11
  *
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
  */
14
 
15
  /**
16
  * Generates XML output from arrays using PHP's
17
  * built-in XMLWriter
18
  *
19
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
20
  */
21
+ class Generator
22
  {
23
  /**
24
  * arrays passed to this method should have a single root element
25
  * with an array as its value
26
  * @param array $aData the array of data
27
+ * @return string XML string
28
  */
29
  public static function arrayToXml($aData)
30
  {
31
+ $aData = Util::camelCaseToDelimiterArray($aData, '-');
32
  // set up the XMLWriter
33
  $writer = new XMLWriter();
34
  $writer->openMemory();
60
  * @static
61
  * @param object $writer XMLWriter object
62
  * @param array $aData contains attributes and values
63
+ * @return void
64
  */
65
  private static function _createElementsFromArray(&$writer, $aData)
66
  {
110
  private static function _generateXmlAttribute($value)
111
  {
112
  if ($value instanceof DateTime) {
113
+ return ['type', 'datetime', self::_dateTimeToXmlTimestamp($value)];
114
  }
115
  if (is_int($value)) {
116
+ return ['type', 'integer', $value];
117
  }
118
  if (is_bool($value)) {
119
+ return ['type', 'boolean', ($value ? 'true' : 'false')];
120
  }
121
  if ($value === NULL) {
122
+ return ['nil', 'true', $value];
123
  }
124
  }
125
  /**
126
  * converts datetime back to xml schema format
127
  * @access protected
128
  * @param object $dateTime
129
+ * @return string XML schema formatted timestamp
130
  */
131
  private static function _dateTimeToXmlTimestamp($dateTime)
132
  {
133
+ $dateTimeForUTC = clone $dateTime;
134
+
135
+ $dateTimeForUTC->setTimeZone(new DateTimeZone('UTC'));
136
+ return ($dateTimeForUTC->format('Y-m-d\TH:i:s') . 'Z');
137
  }
138
 
139
  private static function _castDateTime($string)
150
  }
151
  }
152
  }
153
+ class_alias('Braintree\Xml\Generator', 'Braintree_Xml_Generator');
lib/Gene/Braintree/{Xml → braintree/braintree_php/lib/Braintree/Xml}/Parser.php RENAMED
@@ -1,11 +1,19 @@
1
  <?php
 
 
 
 
 
 
 
 
2
 
3
  /**
4
  * Braintree XML Parser
5
  *
6
- * @copyright 2014 Braintree, a division of PayPal, Inc.
7
  */
8
- class Braintree_Xml_Parser
9
  {
10
  /**
11
  * Converts an XML string into a multidimensional array
@@ -20,9 +28,9 @@ class Braintree_Xml_Parser
20
 
21
  $root = $document->documentElement->nodeName;
22
 
23
- return Braintree_Util::delimiterToCamelCaseArray(array(
24
  $root => self::_nodeToValue($document->childNodes->item(0)),
25
- ));
26
  }
27
 
28
  /**
@@ -40,7 +48,7 @@ class Braintree_Xml_Parser
40
 
41
  switch($type) {
42
  case 'array':
43
- $array = array();
44
  foreach ($node->childNodes as $child) {
45
  $value = self::_nodeToValue($child);
46
  if ($value !== null) {
@@ -49,19 +57,19 @@ class Braintree_Xml_Parser
49
  }
50
  return $array;
51
  case 'collection':
52
- $collection = array();
53
  foreach ($node->childNodes as $child) {
54
  $value = self::_nodetoValue($child);
55
  if ($value !== null) {
56
  if (!isset($collection[$child->nodeName])) {
57
- $collection[$child->nodeName] = array();
58
  }
59
  $collection[$child->nodeName][] = self::_nodeToValue($child);
60
  }
61
  }
62
  return $collection;
63
  default:
64
- $values = array();
65
  if ($node->childNodes->length === 1 && $node->childNodes->item(0) instanceof DOMText) {
66
  return $node->childNodes->item(0)->nodeValue;
67
  } else {
@@ -131,3 +139,4 @@ class Braintree_Xml_Parser
131
  return $dateTime;
132
  }
133
  }
 
1
  <?php
2
+ namespace Braintree\Xml;
3
+
4
+ use DateTime;
5
+ use DateTimeZone;
6
+ use DOMDocument;
7
+ use DOMElement;
8
+ use DOMText;
9
+ use Braintree\Util;
10
 
11
  /**
12
  * Braintree XML Parser
13
  *
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
  */
16
+ class Parser
17
  {
18
  /**
19
  * Converts an XML string into a multidimensional array
28
 
29
  $root = $document->documentElement->nodeName;
30
 
31
+ return Util::delimiterToCamelCaseArray([
32
  $root => self::_nodeToValue($document->childNodes->item(0)),
33
+ ]);
34
  }
35
 
36
  /**
48
 
49
  switch($type) {
50
  case 'array':
51
+ $array = [];
52
  foreach ($node->childNodes as $child) {
53
  $value = self::_nodeToValue($child);
54
  if ($value !== null) {
57
  }
58
  return $array;
59
  case 'collection':
60
+ $collection = [];
61
  foreach ($node->childNodes as $child) {
62
  $value = self::_nodetoValue($child);
63
  if ($value !== null) {
64
  if (!isset($collection[$child->nodeName])) {
65
+ $collection[$child->nodeName] = [];
66
  }
67
  $collection[$child->nodeName][] = self::_nodeToValue($child);
68
  }
69
  }
70
  return $collection;
71
  default:
72
+ $values = [];
73
  if ($node->childNodes->length === 1 && $node->childNodes->item(0) instanceof DOMText) {
74
  return $node->childNodes->item(0)->nodeValue;
75
  } else {
139
  return $dateTime;
140
  }
141
  }
142
+ class_alias('Braintree\Xml\Parser', 'Braintree_Xml_Parser');
lib/Gene/Braintree/braintree/braintree_php/lib/autoload.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ spl_autoload_register(function ($className) {
4
+ if (strpos($className, 'Braintree') !== 0) {
5
+ return;
6
+ }
7
+
8
+ $fileName = dirname(__DIR__) . '/lib/';
9
+
10
+ if ($lastNsPos = strripos($className, '\\')) {
11
+ $namespace = substr($className, 0, $lastNsPos);
12
+ $className = substr($className, $lastNsPos + 1);
13
+ $fileName .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
14
+ }
15
+
16
+ $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
17
+
18
+ if (is_file($fileName)) {
19
+ require_once $fileName;
20
+ }
21
+ });
lib/Gene/Braintree/braintree/braintree_php/lib/ssl/api_braintreegateway_com.ca.crt ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB
3
+ yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
4
+ ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp
5
+ U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW
6
+ ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0
7
+ aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL
8
+ MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW
9
+ ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln
10
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp
11
+ U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y
12
+ aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1
13
+ nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex
14
+ t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz
15
+ SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG
16
+ BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+
17
+ rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/
18
+ NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E
19
+ BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH
20
+ BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
21
+ aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv
22
+ MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE
23
+ p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y
24
+ 5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK
25
+ WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ
26
+ 4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N
27
+ hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
28
+ -----END CERTIFICATE-----
29
+ -----BEGIN CERTIFICATE-----
30
+ MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI
31
+ MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x
32
+ FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz
33
+ MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv
34
+ cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN
35
+ AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz
36
+ Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO
37
+ 0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao
38
+ wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj
39
+ 7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS
40
+ 8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmHursCAwEAAaOBnTCBmjAT
41
+ BgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
42
+ /zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCeg
43
+ JYYjaHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGC
44
+ NxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt3
45
+ 6Z3q059c4EVlew3KW+JwULKUBRSuSceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/
46
+ 3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHfmbx8IVQr5Fiiu1cprp6poxkm
47
+ D5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZnMUFdAvnZyPS
48
+ CPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
49
+ 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
50
+ -----END CERTIFICATE-----
51
+ -----BEGIN CERTIFICATE-----
52
+ MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx
53
+ EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT
54
+ EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp
55
+ ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz
56
+ NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH
57
+ EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE
58
+ AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw
59
+ DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD
60
+ E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH
61
+ /PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy
62
+ DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh
63
+ GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR
64
+ tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA
65
+ AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
66
+ FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX
67
+ WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu
68
+ 9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr
69
+ gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo
70
+ 2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
71
+ LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI
72
+ 4uJEvlz36hz1
73
+ -----END CERTIFICATE-----
74
+ -----BEGIN CERTIFICATE-----
75
+ MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl
76
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
77
+ d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv
78
+ b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG
79
+ EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl
80
+ cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi
81
+ MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c
82
+ JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP
83
+ mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+
84
+ wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4
85
+ VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/
86
+ AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB
87
+ AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW
88
+ BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun
89
+ pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC
90
+ dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf
91
+ fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm
92
+ NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx
93
+ H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
94
+ +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
95
+ -----END CERTIFICATE-----
96
+ -----BEGIN CERTIFICATE-----
97
+ MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
98
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
99
+ d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
100
+ QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT
101
+ MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
102
+ b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG
103
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB
104
+ CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
105
+ nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
106
+ 43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
107
+ T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
108
+ gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
109
+ BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
110
+ TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
111
+ DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr
112
+ hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg
113
+ 06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF
114
+ PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
115
+ YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
116
+ CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
117
+ -----END CERTIFICATE-----
118
+ -----BEGIN CERTIFICATE-----
119
+ MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs
120
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
121
+ d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
122
+ ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL
123
+ MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3
124
+ LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug
125
+ RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm
126
+ +9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW
127
+ PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM
128
+ xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB
129
+ Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3
130
+ hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg
131
+ EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF
132
+ MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA
133
+ FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec
134
+ nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z
135
+ eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF
136
+ hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2
137
+ Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
138
+ vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep
139
+ +OkuE6N36B9K
140
+ -----END CERTIFICATE-----
141
+ -----BEGIN CERTIFICATE-----
142
+ MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW
143
+ MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy
144
+ c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE
145
+ BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0
146
+ IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV
147
+ VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8
148
+ cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT
149
+ QjOgNB0eRXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFh
150
+ F7em6fgemdtzbvQKoiFs7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2v
151
+ c7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d8Lsrlh/eezJS/R27tQahsiFepdaVaH/w
152
+ mZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7VqnJNk22CDtucvc+081xd
153
+ VHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3CgaRr0BHdCX
154
+ teGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZ
155
+ f9hBZ3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfRe
156
+ Bi9Fi1jUIxaS5BZuKGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+
157
+ nhutxx9z3SxPGWX9f5NAEC7S8O08ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB
158
+ /wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0XG0D08DYj3rWMB8GA1UdIwQY
159
+ MBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG
160
+ 9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc
161
+ aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fX
162
+ IwjhmF7DWgh2qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzyn
163
+ ANXH/KttgCJwpQzgXQQpAvvLoJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0z
164
+ uzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsKxr2EoyNB3tZ3b4XUhRxQ4K5RirqN
165
+ Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja
166
+ QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW
167
+ koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9
168
+ ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt
169
+ DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm
170
+ bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw=
171
+ -----END CERTIFICATE-----
172
+ -----BEGIN CERTIFICATE-----
173
+ MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
174
+ MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
175
+ YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG
176
+ EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg
177
+ R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9
178
+ 9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq
179
+ fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv
180
+ iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU
181
+ 1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+
182
+ bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW
183
+ MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA
184
+ ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l
185
+ uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn
186
+ Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS
187
+ tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF
188
+ PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un
189
+ hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV
190
+ 5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==
191
+ -----END CERTIFICATE-----
lib/Gene/Braintree/braintree/braintree_php/phpunit.xml.dist ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit backupGlobals="false"
3
+ backupStaticAttributes="false"
4
+ bootstrap="./vendor/autoload.php"
5
+ convertErrorsToExceptions="true"
6
+ convertNoticesToExceptions="true"
7
+ convertWarningsToExceptions="true"
8
+ processIsolation="false"
9
+ stopOnFailure="false"
10
+ syntaxCheck="false">
11
+
12
+ <php>
13
+ <ini name="error_reporting" value="32767"/>
14
+ </php>
15
+
16
+ <testsuites>
17
+ <testsuite name="unit">
18
+ <directory>./tests/unit</directory>
19
+ </testsuite>
20
+ <testsuite name="integration">
21
+ <directory>./tests/integration</directory>
22
+ </testsuite>
23
+ </testsuites>
24
+ </phpunit>
lib/Gene/Braintree/braintree/braintree_php/tests/Braintree/CreditCardDefaults.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Braintree;
3
+
4
+ class CreditCardDefaults
5
+ {
6
+ const ISSUING_BANK = "NETWORK ONLY";
7
+ const COUNTRY_OF_ISSUANCE = "USA";
8
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/Braintree/CreditCardNumbers/CardTypeIndicators.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Braintree\CreditCardNumbers;
3
+
4
+ class CardTypeIndicators {
5
+ const PREPAID = "4111111111111210";
6
+ const COMMERCIAL = "4111111111131010";
7
+ const PAYROLL = "4111111114101010";
8
+ const HEALTHCARE = "4111111510101010";
9
+ const DURBIN_REGULATED = "4111161010101010";
10
+ const DEBIT = "4117101010101010";
11
+ const UNKNOWN = "4111111111112101";
12
+ const NO = "4111111111310101";
13
+ const ISSUING_BANK = "4111111141010101";
14
+ const COUNTRY_OF_ISSUANCE = "4111111111121102";
15
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/Braintree/OAuthTestHelper.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Braintree;
3
+
4
+ use Braintree;
5
+
6
+ class OAuthTestHelper
7
+ {
8
+ public static function createGrant($gateway, $params)
9
+ {
10
+ $http = new Braintree\Http($gateway->config);
11
+ $http->useClientCredentials();
12
+ $response = $http->post('/oauth_testing/grants', ['grant' => $params]);
13
+ return $response['grant']['code'];
14
+ }
15
+
16
+ public static function createCredentials($params)
17
+ {
18
+ $gateway = new Braintree\Gateway([
19
+ 'clientId' => $params['clientId'],
20
+ 'clientSecret' => $params['clientSecret']
21
+ ]);
22
+
23
+ $code = OAuthTestHelper::createGrant($gateway, [
24
+ 'merchant_public_id' => $params['merchantId'],
25
+ 'scope' => 'read_write'
26
+ ]);
27
+
28
+ $credentials = $gateway->oauth()->createTokenFromCode([
29
+ 'code' => $code,
30
+ 'scope' => 'read_write',
31
+ ]);
32
+
33
+ return $credentials;
34
+ }
35
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/Helper.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test;
3
+
4
+ require_once __DIR__ . '/Setup.php';
5
+
6
+ use DateTime;
7
+ use DateTimeZone;
8
+ use Braintree;
9
+
10
+ class Helper
11
+ {
12
+ public static $valid_nonce_characters = 'bcdfghjkmnpqrstvwxyz23456789';
13
+
14
+ public static function testMerchantConfig()
15
+ {
16
+ Braintree\Configuration::reset();
17
+
18
+ Braintree\Configuration::environment('development');
19
+ Braintree\Configuration::merchantId('test_merchant_id');
20
+ Braintree\Configuration::publicKey('test_public_key');
21
+ Braintree\Configuration::privateKey('test_private_key');
22
+ }
23
+
24
+ public static function defaultMerchantAccountId()
25
+ {
26
+ return 'sandbox_credit_card';
27
+ }
28
+
29
+ public static function nonDefaultMerchantAccountId()
30
+ {
31
+ return 'sandbox_credit_card_non_default';
32
+ }
33
+
34
+ public static function nonDefaultSubMerchantAccountId()
35
+ {
36
+ return 'sandbox_sub_merchant_account';
37
+ }
38
+
39
+ public static function threeDSecureMerchantAccountId()
40
+ {
41
+ return 'three_d_secure_merchant_account';
42
+ }
43
+
44
+ public static function fakeAmexDirectMerchantAccountId()
45
+ {
46
+ return 'fake_amex_direct_usd';
47
+ }
48
+
49
+ public static function fakeVenmoAccountMerchantAccountId()
50
+ {
51
+ return 'fake_first_data_venmo_account';
52
+ }
53
+
54
+ public static function createViaTr($regularParams, $trParams)
55
+ {
56
+ $trData = Braintree\TransparentRedirect::transactionData(
57
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"])
58
+ );
59
+ return self::submitTrRequest(
60
+ Braintree\TransparentRedirect::url(),
61
+ $regularParams,
62
+ $trData
63
+ );
64
+ }
65
+
66
+ public static function submitTrRequest($url, $regularParams, $trData)
67
+ {
68
+ $curl = curl_init();
69
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
70
+ curl_setopt($curl, CURLOPT_URL, $url);
71
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
72
+ curl_setopt($curl, CURLOPT_HEADER, true);
73
+ // curl_setopt($curl, CURLOPT_VERBOSE, true);
74
+ curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array_merge($regularParams, ['tr_data' => $trData])));
75
+ curl_setopt($curl, CURLOPT_HTTPHEADER, [
76
+ 'Content-Type: application/x-www-form-urlencoded'
77
+ ]);
78
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
79
+ $response = curl_exec($curl);
80
+ curl_close($curl);
81
+ preg_match('/Location: .*\?(.*)/i', $response, $match);
82
+ return trim($match[1]);
83
+ }
84
+
85
+ public static function suppressDeprecationWarnings()
86
+ {
87
+ set_error_handler("Test\Helper::_errorHandler", E_USER_NOTICE);
88
+ }
89
+
90
+ public static function _errorHandler($errno, $errstr, $errfile, $errline)
91
+ {
92
+ if (preg_match('/^DEPRECATED/', $errstr) == 0) {
93
+ trigger_error('Unknown error received: ' . $errstr, E_USER_ERROR);
94
+ }
95
+ }
96
+
97
+ public static function includes($collection, $targetItem)
98
+ {
99
+ foreach ($collection AS $item) {
100
+ if ($item->id == $targetItem->id) {
101
+ return true;
102
+ }
103
+ }
104
+ return false;
105
+ }
106
+
107
+ public static function assertPrintable($object)
108
+ {
109
+ " " . $object;
110
+ }
111
+
112
+ public static function escrow($transactionId)
113
+ {
114
+ $http = new Braintree\Http(Braintree\Configuration::$global);
115
+ $path = Braintree\Configuration::$global->merchantPath() . '/transactions/' . $transactionId . '/escrow';
116
+ $http->put($path);
117
+ }
118
+
119
+ public static function create3DSVerification($merchantAccountId, $params)
120
+ {
121
+ $http = new Braintree\Http(Braintree\Configuration::$global);
122
+ $path = Braintree\Configuration::$global->merchantPath() . '/three_d_secure/create_verification/' . $merchantAccountId;
123
+ $response = $http->post($path, ['threeDSecureVerification' => $params]);
124
+ return $response['threeDSecureVerification']['threeDSecureToken'];
125
+ }
126
+
127
+ public static function nowInEastern()
128
+ {
129
+ $eastern = new DateTimeZone('America/New_York');
130
+ $now = new DateTime('now', $eastern);
131
+ return $now->format('Y-m-d');
132
+ }
133
+
134
+ public static function decodedClientToken($params=[]) {
135
+ $encodedClientToken = Braintree\ClientToken::generate($params);
136
+ return base64_decode($encodedClientToken);
137
+ }
138
+
139
+ public static function generateValidUsBankAccountNonce() {
140
+ $client_token = json_decode(Helper::decodedClientToken(), true);
141
+ $url = $client_token['braintree_api']['url'] . '/tokens';
142
+
143
+ $curl = curl_init();
144
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
145
+ curl_setopt($curl, CURLOPT_URL, $url);
146
+
147
+ $headers[] = 'Content-Type: application/json';
148
+ $headers[] = 'Braintree-Version: 2015-11-01';
149
+ $headers[] = 'Authorization: Bearer integratexxxxxx_xxxxxx_xxxxxx_xxxxxx_xx1';
150
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
151
+
152
+ $requestBody = [
153
+ 'type' => 'us_bank_account',
154
+ 'billing_address' => [
155
+ 'street_address' => '123 Ave',
156
+ 'region' => 'CA',
157
+ 'locality' => 'San Francisco',
158
+ 'postal_code' => '94112'
159
+ ],
160
+ 'account_type' => 'checking',
161
+ 'routing_number' => '123456789',
162
+ 'account_number' => '567891234',
163
+ 'account_holder_name' => 'Dan Schulman',
164
+ 'account_description' => 'PayPal Checking - 1234',
165
+ 'ach_mandate' => [
166
+ 'text' => ''
167
+ ]
168
+ ];
169
+
170
+ curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($requestBody));
171
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
172
+
173
+ $response = curl_exec($curl);
174
+ $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
175
+ $error_code = curl_errno($curl);
176
+ curl_close($curl);
177
+ $jsonResponse = json_decode($response, true);
178
+ return $jsonResponse['data']['id'];
179
+ }
180
+
181
+ public static function generateInvalidUsBankAccountNonce() {
182
+ $valid_characters = str_split(self::$valid_nonce_characters);
183
+ $nonce = 'tokenusbankacct';
184
+ for($i=0; $i<4; $i++) {
185
+ $nonce = $nonce . '_';
186
+ for($j=0; $j<6; $j++) {
187
+ $t = rand(0, sizeof($valid_characters)-1);
188
+ $nonce = $nonce . $valid_characters[$t];
189
+ }
190
+ }
191
+ return $nonce . "_xxx";
192
+ }
193
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/SanityTest.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SanityTest extends PHPUnit_Framework_TestCase
4
+ {
5
+ public function testLibraryWorksWithComposer()
6
+ {
7
+ if (version_compare(PHP_VERSION, "5.4.0", "<")) {
8
+ $this->markTestSkipped("Requires PHP >=5.4");
9
+ }
10
+
11
+ $returnValue = null;
12
+
13
+ $testFile = escapeshellarg(realpath(__DIR__ . '/Braintree/fixtures/composer_implementation.php'));
14
+ $command = sprintf('%s %s', PHP_BINARY, $testFile);
15
+
16
+ system($command, $returnValue);
17
+
18
+ $this->assertEquals(0, $returnValue);
19
+ }
20
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/Setup.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test;
3
+
4
+ require_once __DIR__ . '/Helper.php';
5
+ require_once __DIR__ . '/integration/HttpClientApi.php';
6
+ require_once __DIR__ . '/integration/SubscriptionHelper.php';
7
+ require_once __DIR__ . '/Braintree/CreditCardNumbers/CardTypeIndicators.php';
8
+ require_once __DIR__ . '/Braintree/CreditCardDefaults.php';
9
+ require_once __DIR__ . '/Braintree/OAuthTestHelper.php';
10
+
11
+ date_default_timezone_set('UTC');
12
+
13
+ use Braintree\Configuration;
14
+ use PHPUnit_Framework_TestCase;
15
+
16
+ class Setup extends PHPUnit_Framework_TestCase
17
+ {
18
+ public function __construct()
19
+ {
20
+ self::integrationMerchantConfig();
21
+ }
22
+
23
+ public static function integrationMerchantConfig()
24
+ {
25
+ Configuration::reset();
26
+
27
+ Configuration::environment('development');
28
+ Configuration::merchantId('integration_merchant_id');
29
+ Configuration::publicKey('integration_public_key');
30
+ Configuration::privateKey('integration_private_key');
31
+ }
32
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/AddOnsTest.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class AddOnsTest extends Setup
10
+ {
11
+ public function testAll_returnsAllAddOns()
12
+ {
13
+ $newId = strval(rand());
14
+
15
+ $addOnParams = [
16
+ "amount" => "100.00",
17
+ "description" => "some description",
18
+ "id" => $newId,
19
+ "kind" => "add_on",
20
+ "name" => "php_add_on",
21
+ "neverExpires" => "false",
22
+ "numberOfBillingCycles" => "1"
23
+ ];
24
+
25
+ $http = new Braintree\Http(Braintree\Configuration::$global);
26
+ $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests";
27
+ $http->post($path, ["modification" => $addOnParams]);
28
+
29
+ $addOns = Braintree\AddOn::all();
30
+
31
+ foreach ($addOns as $addOn)
32
+ {
33
+ if ($addOn->id == $newId)
34
+ {
35
+ $actualAddOn = $addOn;
36
+ }
37
+ }
38
+
39
+ $this->assertNotNull($actualAddOn);
40
+ $this->assertEquals($addOnParams["amount"], $actualAddOn->amount);
41
+ $this->assertEquals($addOnParams["description"], $actualAddOn->description);
42
+ $this->assertEquals($addOnParams["id"], $actualAddOn->id);
43
+ $this->assertEquals($addOnParams["kind"], $actualAddOn->kind);
44
+ $this->assertEquals($addOnParams["name"], $actualAddOn->name);
45
+ $this->assertFalse($actualAddOn->neverExpires);
46
+ $this->assertEquals($addOnParams["numberOfBillingCycles"], $actualAddOn->numberOfBillingCycles);
47
+ }
48
+
49
+ public function testGatewayAll_returnsAllAddOns()
50
+ {
51
+ $newId = strval(rand());
52
+
53
+ $addOnParams = [
54
+ "amount" => "100.00",
55
+ "description" => "some description",
56
+ "id" => $newId,
57
+ "kind" => "add_on",
58
+ "name" => "php_add_on",
59
+ "neverExpires" => "false",
60
+ "numberOfBillingCycles" => "1"
61
+ ];
62
+
63
+ $http = new Braintree\Http(Braintree\Configuration::$global);
64
+ $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests";
65
+ $http->post($path, ["modification" => $addOnParams]);
66
+
67
+ $gateway = new Braintree\Gateway([
68
+ 'environment' => 'development',
69
+ 'merchantId' => 'integration_merchant_id',
70
+ 'publicKey' => 'integration_public_key',
71
+ 'privateKey' => 'integration_private_key'
72
+ ]);
73
+ $addOns = $gateway->addOn()->all();
74
+
75
+ foreach ($addOns as $addOn)
76
+ {
77
+ if ($addOn->id == $newId)
78
+ {
79
+ $actualAddOn = $addOn;
80
+ }
81
+ }
82
+
83
+ $this->assertNotNull($actualAddOn);
84
+ $this->assertEquals($addOnParams["amount"], $actualAddOn->amount);
85
+ $this->assertEquals($addOnParams["description"], $actualAddOn->description);
86
+ $this->assertEquals($addOnParams["id"], $actualAddOn->id);
87
+ }
88
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/AddressTest.php ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class AddressTest extends Setup
10
+ {
11
+ public function testCreate()
12
+ {
13
+ $customer = Braintree\Customer::createNoValidate();
14
+ $result = Braintree\Address::create([
15
+ 'customerId' => $customer->id,
16
+ 'firstName' => 'Dan',
17
+ 'lastName' => 'Smith',
18
+ 'company' => 'Braintree',
19
+ 'streetAddress' => '1 E Main St',
20
+ 'extendedAddress' => 'Apt 1F',
21
+ 'locality' => 'Chicago',
22
+ 'region' => 'IL',
23
+ 'postalCode' => '60622',
24
+ 'countryName' => 'Vatican City',
25
+ 'countryCodeAlpha2' => 'VA',
26
+ 'countryCodeAlpha3' => 'VAT',
27
+ 'countryCodeNumeric' => '336'
28
+ ]);
29
+ $this->assertTrue($result->success);
30
+ $address = $result->address;
31
+ $this->assertEquals('Dan', $address->firstName);
32
+ $this->assertEquals('Smith', $address->lastName);
33
+ $this->assertEquals('Braintree', $address->company);
34
+ $this->assertEquals('1 E Main St', $address->streetAddress);
35
+ $this->assertEquals('Apt 1F', $address->extendedAddress);
36
+ $this->assertEquals('Chicago', $address->locality);
37
+ $this->assertEquals('IL', $address->region);
38
+ $this->assertEquals('60622', $address->postalCode);
39
+ $this->assertEquals('Vatican City', $address->countryName);
40
+ $this->assertEquals('VA', $address->countryCodeAlpha2);
41
+ $this->assertEquals('VAT', $address->countryCodeAlpha3);
42
+ $this->assertEquals('336', $address->countryCodeNumeric);
43
+ }
44
+
45
+ public function testGatewayCreate()
46
+ {
47
+ $customer = Braintree\Customer::createNoValidate();
48
+
49
+ $gateway = new Braintree\Gateway([
50
+ 'environment' => 'development',
51
+ 'merchantId' => 'integration_merchant_id',
52
+ 'publicKey' => 'integration_public_key',
53
+ 'privateKey' => 'integration_private_key'
54
+ ]);
55
+ $result = $gateway->address()->create([
56
+ 'customerId' => $customer->id,
57
+ 'streetAddress' => '1 E Main St',
58
+ 'locality' => 'Chicago',
59
+ 'region' => 'IL',
60
+ 'postalCode' => '60622',
61
+ ]);
62
+
63
+ $this->assertTrue($result->success);
64
+ $address = $result->address;
65
+ $this->assertEquals('1 E Main St', $address->streetAddress);
66
+ $this->assertEquals('Chicago', $address->locality);
67
+ $this->assertEquals('IL', $address->region);
68
+ $this->assertEquals('60622', $address->postalCode);
69
+ }
70
+
71
+ public function testCreate_withValidationErrors()
72
+ {
73
+ $customer = Braintree\Customer::createNoValidate();
74
+ $result = Braintree\Address::create([
75
+ 'customerId' => $customer->id,
76
+ 'countryName' => 'Invalid States of America'
77
+ ]);
78
+ $this->assertFalse($result->success);
79
+ $countryErrors = $result->errors->forKey('address')->onAttribute('countryName');
80
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $countryErrors[0]->code);
81
+ }
82
+
83
+ public function testCreate_withValidationErrors_onCountryCodes()
84
+ {
85
+ $customer = Braintree\Customer::createNoValidate();
86
+ $result = Braintree\Address::create([
87
+ 'customerId' => $customer->id,
88
+ 'countryCodeAlpha2' => 'ZZ'
89
+ ]);
90
+ $this->assertFalse($result->success);
91
+ $countryErrors = $result->errors->forKey('address')->onAttribute('countryCodeAlpha2');
92
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED, $countryErrors[0]->code);
93
+ }
94
+
95
+ public function testCreate_withNotFoundErrors()
96
+ {
97
+ $this->setExpectedException('Braintree\Exception\NotFound','Customer nonExistentCustomerId not found.');
98
+ $result = Braintree\Address::create([
99
+ 'customerId' => 'nonExistentCustomerId',
100
+ ]);
101
+ }
102
+
103
+ public function testCreateNoValidate()
104
+ {
105
+ $customer = Braintree\Customer::createNoValidate();
106
+ $address = Braintree\Address::createNoValidate([
107
+ 'customerId' => $customer->id,
108
+ 'firstName' => 'Dan',
109
+ 'lastName' => 'Smith',
110
+ 'company' => 'Braintree',
111
+ 'streetAddress' => '1 E Main St',
112
+ 'extendedAddress' => 'Apt 1F',
113
+ 'locality' => 'Chicago',
114
+ 'region' => 'IL',
115
+ 'postalCode' => '60622',
116
+ 'countryName' => 'United States of America'
117
+ ]);
118
+ $this->assertEquals('Dan', $address->firstName);
119
+ $this->assertEquals('Smith', $address->lastName);
120
+ $this->assertEquals('Braintree', $address->company);
121
+ $this->assertEquals('1 E Main St', $address->streetAddress);
122
+ $this->assertEquals('Apt 1F', $address->extendedAddress);
123
+ $this->assertEquals('Chicago', $address->locality);
124
+ $this->assertEquals('IL', $address->region);
125
+ $this->assertEquals('60622', $address->postalCode);
126
+ $this->assertEquals('United States of America', $address->countryName);
127
+ }
128
+
129
+ public function testCreateNoValidate_withValidationErrors()
130
+ {
131
+ $customer = Braintree\Customer::createNoValidate();
132
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed');
133
+ Braintree\Address::createNoValidate([
134
+ 'customerId' => $customer->id,
135
+ 'countryName' => 'Invalid States of America'
136
+ ]);
137
+ }
138
+
139
+ public function testDelete()
140
+ {
141
+ $customer = Braintree\Customer::createNoValidate();
142
+ $address = Braintree\Address::createNoValidate([
143
+ 'customerId' => $customer->id,
144
+ 'streetAddress' => '1 E Main St'
145
+ ]);
146
+ Braintree\Address::find($customer->id, $address->id);
147
+ Braintree\Address::delete($customer->id, $address->id);
148
+ $this->setExpectedException('Braintree\Exception\NotFound');
149
+ Braintree\Address::find($customer->id, $address->id);
150
+ }
151
+
152
+ public function testFind()
153
+ {
154
+ $customer = Braintree\Customer::createNoValidate();
155
+ $result = Braintree\Address::create([
156
+ 'customerId' => $customer->id,
157
+ 'firstName' => 'Dan',
158
+ 'lastName' => 'Smith',
159
+ 'company' => 'Braintree',
160
+ 'streetAddress' => '1 E Main St',
161
+ 'extendedAddress' => 'Apt 1F',
162
+ 'locality' => 'Chicago',
163
+ 'region' => 'IL',
164
+ 'postalCode' => '60622',
165
+ 'countryName' => 'United States of America'
166
+ ]);
167
+ $this->assertTrue($result->success);
168
+ $address = Braintree\Address::find($customer->id, $result->address->id);
169
+ $this->assertEquals('Dan', $address->firstName);
170
+ $this->assertEquals('Smith', $address->lastName);
171
+ $this->assertEquals('Braintree', $address->company);
172
+ $this->assertEquals('1 E Main St', $address->streetAddress);
173
+ $this->assertEquals('Apt 1F', $address->extendedAddress);
174
+ $this->assertEquals('Chicago', $address->locality);
175
+ $this->assertEquals('IL', $address->region);
176
+ $this->assertEquals('60622', $address->postalCode);
177
+ $this->assertEquals('United States of America', $address->countryName);
178
+ }
179
+
180
+ public function testFind_whenNotFound()
181
+ {
182
+ $customer = Braintree\Customer::createNoValidate();
183
+ $this->setExpectedException('Braintree\Exception\NotFound');
184
+ Braintree\Address::find($customer->id, 'does-not-exist');
185
+ }
186
+
187
+ public function testUpdate()
188
+ {
189
+ $customer = Braintree\Customer::createNoValidate();
190
+ $address = Braintree\Address::createNoValidate([
191
+ 'customerId' => $customer->id,
192
+ 'firstName' => 'Old First',
193
+ 'lastName' => 'Old Last',
194
+ 'company' => 'Old Company',
195
+ 'streetAddress' => '1 E Old St',
196
+ 'extendedAddress' => 'Apt Old',
197
+ 'locality' => 'Old Chicago',
198
+ 'region' => 'Old Region',
199
+ 'postalCode' => 'Old Postal',
200
+ 'countryName' => 'United States of America',
201
+ 'countryCodeAlpha2' => 'US',
202
+ 'countryCodeAlpha3' => 'USA',
203
+ 'countryCodeNumeric' => '840'
204
+ ]);
205
+ $result = Braintree\Address::update($customer->id, $address->id, [
206
+ 'firstName' => 'New First',
207
+ 'lastName' => 'New Last',
208
+ 'company' => 'New Company',
209
+ 'streetAddress' => '1 E New St',
210
+ 'extendedAddress' => 'Apt New',
211
+ 'locality' => 'New Chicago',
212
+ 'region' => 'New Region',
213
+ 'postalCode' => 'New Postal',
214
+ 'countryName' => 'Mexico',
215
+ 'countryCodeAlpha2' => 'MX',
216
+ 'countryCodeAlpha3' => 'MEX',
217
+ 'countryCodeNumeric' => '484'
218
+ ]);
219
+ $this->assertTrue($result->success);
220
+ $address = $result->address;
221
+ $this->assertEquals('New First', $address->firstName);
222
+ $this->assertEquals('New Last', $address->lastName);
223
+ $this->assertEquals('New Company', $address->company);
224
+ $this->assertEquals('1 E New St', $address->streetAddress);
225
+ $this->assertEquals('Apt New', $address->extendedAddress);
226
+ $this->assertEquals('New Chicago', $address->locality);
227
+ $this->assertEquals('New Region', $address->region);
228
+ $this->assertEquals('New Postal', $address->postalCode);
229
+ $this->assertEquals('Mexico', $address->countryName);
230
+ $this->assertEquals('MX', $address->countryCodeAlpha2);
231
+ $this->assertEquals('MEX', $address->countryCodeAlpha3);
232
+ $this->assertEquals('484', $address->countryCodeNumeric);
233
+ }
234
+
235
+ public function testUpdate_withValidationErrors()
236
+ {
237
+ $customer = Braintree\Customer::createNoValidate();
238
+ $address = Braintree\Address::createNoValidate([
239
+ 'customerId' => $customer->id,
240
+ 'streetAddress' => '1 E Main St'
241
+ ]);
242
+ $result = Braintree\Address::update(
243
+ $customer->id,
244
+ $address->id,
245
+ [
246
+ 'countryName' => 'Invalid States of America'
247
+ ]
248
+ );
249
+ $this->assertFalse($result->success);
250
+ $countryErrors = $result->errors->forKey('address')->onAttribute('countryName');
251
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $countryErrors[0]->code);
252
+ }
253
+
254
+ public function testUpdate_withValidationErrors_onCountry()
255
+ {
256
+ $customer = Braintree\Customer::createNoValidate();
257
+ $address = Braintree\Address::createNoValidate([
258
+ 'customerId' => $customer->id,
259
+ 'streetAddress' => '1 E Main St'
260
+ ]);
261
+ $result = Braintree\Address::update(
262
+ $customer->id,
263
+ $address->id,
264
+ [
265
+ 'countryCodeAlpha2' => 'MU',
266
+ 'countryCodeAlpha3' => 'MYT'
267
+ ]
268
+ );
269
+ $this->assertFalse($result->success);
270
+ $countryErrors = $result->errors->forKey('address')->onAttribute('base');
271
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_INCONSISTENT_COUNTRY, $countryErrors[0]->code);
272
+ }
273
+
274
+
275
+ public function testUpdateNoValidate()
276
+ {
277
+ $customer = Braintree\Customer::createNoValidate();
278
+ $createdAddress = Braintree\Address::createNoValidate([
279
+ 'customerId' => $customer->id,
280
+ 'firstName' => 'Old First',
281
+ 'lastName' => 'Old Last',
282
+ 'company' => 'Old Company',
283
+ 'streetAddress' => '1 E Old St',
284
+ 'extendedAddress' => 'Apt Old',
285
+ 'locality' => 'Old Chicago',
286
+ 'region' => 'Old Region',
287
+ 'postalCode' => 'Old Postal',
288
+ 'countryName' => 'United States of America'
289
+ ]);
290
+ $address = Braintree\Address::updateNoValidate($customer->id, $createdAddress->id, [
291
+ 'firstName' => 'New First',
292
+ 'lastName' => 'New Last',
293
+ 'company' => 'New Company',
294
+ 'streetAddress' => '1 E New St',
295
+ 'extendedAddress' => 'Apt New',
296
+ 'locality' => 'New Chicago',
297
+ 'region' => 'New Region',
298
+ 'postalCode' => 'New Postal',
299
+ 'countryName' => 'Mexico'
300
+ ]);
301
+ $this->assertEquals('New First', $address->firstName);
302
+ $this->assertEquals('New Last', $address->lastName);
303
+ $this->assertEquals('New Company', $address->company);
304
+ $this->assertEquals('1 E New St', $address->streetAddress);
305
+ $this->assertEquals('Apt New', $address->extendedAddress);
306
+ $this->assertEquals('New Chicago', $address->locality);
307
+ $this->assertEquals('New Region', $address->region);
308
+ $this->assertEquals('New Postal', $address->postalCode);
309
+ $this->assertEquals('Mexico', $address->countryName);
310
+ }
311
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/ClientTokenTest.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class ClientTokenTest extends Setup
11
+ {
12
+ public function test_ClientTokenAuthorizesRequest()
13
+ {
14
+ $clientToken = Test\Helper::decodedClientToken();
15
+ $authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint;
16
+ $http = new HttpClientApi(Braintree\Configuration::$global);
17
+ $response = $http->get_cards([
18
+ "authorization_fingerprint" => $authorizationFingerprint,
19
+ "shared_customer_identifier" => "fake_identifier",
20
+ "shared_customer_identifier_type" => "testing",
21
+ ]);
22
+
23
+ $this->assertEquals(200, $response["status"]);
24
+ }
25
+
26
+ public function test_VersionOptionSupported()
27
+ {
28
+ $clientToken = Braintree\ClientToken::generate(["version" => 1]);
29
+ $version = json_decode($clientToken)->version;
30
+ $this->assertEquals(1, $version);
31
+ }
32
+
33
+ public function test_VersionDefaultsToTwo()
34
+ {
35
+ $encodedClientToken = Braintree\ClientToken::generate();
36
+ $clientToken = base64_decode($encodedClientToken);
37
+ $version = json_decode($clientToken)->version;
38
+ $this->assertEquals(2, $version);
39
+ }
40
+
41
+ public function testGateway_VersionDefaultsToTwo()
42
+ {
43
+ $gateway = new Braintree\Gateway([
44
+ 'environment' => 'development',
45
+ 'merchantId' => 'integration_merchant_id',
46
+ 'publicKey' => 'integration_public_key',
47
+ 'privateKey' => 'integration_private_key',
48
+ ]);
49
+ $encodedClientToken = $gateway->clientToken()->generate();
50
+ $clientToken = base64_decode($encodedClientToken);
51
+ $version = json_decode($clientToken)->version;
52
+ $this->assertEquals(2, $version);
53
+ }
54
+
55
+ public function test_GatewayRespectsVerifyCard()
56
+ {
57
+ $result = Braintree\Customer::create();
58
+ $this->assertTrue($result->success);
59
+ $customerId = $result->customer->id;
60
+
61
+ $clientToken = Test\Helper::decodedClientToken([
62
+ "customerId" => $customerId,
63
+ "options" => [
64
+ "verifyCard" => true
65
+ ]
66
+ ]);
67
+ $authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint;
68
+
69
+ $http = new HttpClientApi(Braintree\Configuration::$global);
70
+ $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode([
71
+ "credit_card" => [
72
+ "number" => "4000111111111115",
73
+ "expirationDate" => "11/2099"
74
+ ],
75
+ "authorization_fingerprint" => $authorizationFingerprint,
76
+ "shared_customer_identifier" => "fake_identifier",
77
+ "shared_customer_identifier_type" => "testing"
78
+ ]));
79
+
80
+ $this->assertEquals(422, $response["status"]);
81
+ }
82
+
83
+ public function test_GatewayRespectsFailOnDuplicatePaymentMethod()
84
+ {
85
+ $result = Braintree\Customer::create();
86
+ $this->assertTrue($result->success);
87
+ $customerId = $result->customer->id;
88
+
89
+ $clientToken = Test\Helper::decodedClientToken([
90
+ "customerId" => $customerId,
91
+ ]);
92
+ $authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint;
93
+
94
+ $http = new HttpClientApi(Braintree\Configuration::$global);
95
+ $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode([
96
+ "credit_card" => [
97
+ "number" => "4242424242424242",
98
+ "expirationDate" => "11/2099"
99
+ ],
100
+ "authorization_fingerprint" => $authorizationFingerprint,
101
+ "shared_customer_identifier" => "fake_identifier",
102
+ "shared_customer_identifier_type" => "testing"
103
+ ]));
104
+ $this->assertEquals(201, $response["status"]);
105
+
106
+ $clientToken = Test\Helper::decodedClientToken([
107
+ "customerId" => $customerId,
108
+ "options" => [
109
+ "failOnDuplicatePaymentMethod" => true
110
+ ]
111
+ ]);
112
+ $authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint;
113
+
114
+ $http = new HttpClientApi(Braintree\Configuration::$global);
115
+ $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode([
116
+ "credit_card" => [
117
+ "number" => "4242424242424242",
118
+ "expirationDate" => "11/2099"
119
+ ],
120
+ "authorization_fingerprint" => $authorizationFingerprint,
121
+ "shared_customer_identifier" => "fake_identifier",
122
+ "shared_customer_identifier_type" => "testing"
123
+ ]));
124
+ $this->assertEquals(422, $response["status"]);
125
+ }
126
+
127
+ public function test_GatewayRespectsMakeDefault()
128
+ {
129
+ $result = Braintree\Customer::create();
130
+ $this->assertTrue($result->success);
131
+ $customerId = $result->customer->id;
132
+
133
+ $result = Braintree\CreditCard::create([
134
+ 'customerId' => $customerId,
135
+ 'number' => '4111111111111111',
136
+ 'expirationDate' => '11/2099'
137
+ ]);
138
+ $this->assertTrue($result->success);
139
+
140
+ $clientToken = Test\Helper::decodedClientToken([
141
+ "customerId" => $customerId,
142
+ "options" => [
143
+ "makeDefault" => true
144
+ ]
145
+ ]);
146
+ $authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint;
147
+
148
+ $http = new HttpClientApi(Braintree\Configuration::$global);
149
+ $response = $http->post('/client_api/v1/payment_methods/credit_cards.json', json_encode([
150
+ "credit_card" => [
151
+ "number" => "4242424242424242",
152
+ "expirationDate" => "11/2099"
153
+ ],
154
+ "authorization_fingerprint" => $authorizationFingerprint,
155
+ "shared_customer_identifier" => "fake_identifier",
156
+ "shared_customer_identifier_type" => "testing"
157
+ ]));
158
+
159
+ $this->assertEquals(201, $response["status"]);
160
+
161
+ $customer = Braintree\Customer::find($customerId);
162
+ $this->assertEquals(2, count($customer->creditCards));
163
+ foreach ($customer->creditCards as $creditCard) {
164
+ if ($creditCard->last4 == "4242") {
165
+ $this->assertTrue($creditCard->default);
166
+ }
167
+ }
168
+ }
169
+
170
+ public function test_ClientTokenAcceptsMerchantAccountId()
171
+ {
172
+ $clientToken = Test\Helper::decodedClientToken([
173
+ 'merchantAccountId' => 'my_merchant_account'
174
+ ]);
175
+ $merchantAccountId = json_decode($clientToken)->merchantAccountId;
176
+
177
+ $this->assertEquals('my_merchant_account', $merchantAccountId);
178
+ }
179
+
180
+ public function test_GenerateRaisesExceptionOnGateway422()
181
+ {
182
+ $this->setExpectedException('InvalidArgumentException', 'customer_id');
183
+
184
+ Braintree\ClientToken::generate([
185
+ "customerId" => "not_a_customer"
186
+ ]);
187
+ }
188
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/CreditCardTest.php ADDED
@@ -0,0 +1,1323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Braintree\CreditCardNumbers\CardTypeIndicators;
8
+ use Test\Setup;
9
+ use Braintree;
10
+
11
+ class CreditCardTest extends Setup
12
+ {
13
+ public function testCreate()
14
+ {
15
+ $customer = Braintree\Customer::createNoValidate();
16
+ $result = Braintree\CreditCard::create([
17
+ 'customerId' => $customer->id,
18
+ 'cardholderName' => 'Cardholder',
19
+ 'number' => '5105105105105100',
20
+ 'expirationDate' => '05/12'
21
+ ]);
22
+ $this->assertTrue($result->success);
23
+ $this->assertEquals($customer->id, $result->creditCard->customerId);
24
+ $this->assertEquals('510510', $result->creditCard->bin);
25
+ $this->assertEquals('5100', $result->creditCard->last4);
26
+ $this->assertEquals('Cardholder', $result->creditCard->cardholderName);
27
+ $this->assertEquals('05/2012', $result->creditCard->expirationDate);
28
+ $this->assertEquals(1, preg_match('/\A\w{32}\z/', $result->creditCard->uniqueNumberIdentifier));
29
+ $this->assertFalse($result->creditCard->isVenmoSdk());
30
+ $this->assertEquals(1, preg_match('/png/', $result->creditCard->imageUrl));
31
+ }
32
+
33
+ public function testGatewayCreate()
34
+ {
35
+ $customer = Braintree\Customer::createNoValidate();
36
+
37
+ $gateway = new Braintree\Gateway([
38
+ 'environment' => 'development',
39
+ 'merchantId' => 'integration_merchant_id',
40
+ 'publicKey' => 'integration_public_key',
41
+ 'privateKey' => 'integration_private_key'
42
+ ]);
43
+ $result = $gateway->creditCard()->create([
44
+ 'customerId' => $customer->id,
45
+ 'cardholderName' => 'Cardholder',
46
+ 'number' => '5105105105105100',
47
+ 'expirationDate' => '05/12'
48
+ ]);
49
+
50
+ $this->assertTrue($result->success);
51
+ $this->assertEquals($customer->id, $result->creditCard->customerId);
52
+ $this->assertEquals('510510', $result->creditCard->bin);
53
+ $this->assertEquals('5100', $result->creditCard->last4);
54
+ $this->assertEquals('Cardholder', $result->creditCard->cardholderName);
55
+ $this->assertEquals('05/2012', $result->creditCard->expirationDate);
56
+ }
57
+
58
+ public function testCreate_withDefault()
59
+ {
60
+ $customer = Braintree\Customer::createNoValidate();
61
+ $card1 = Braintree\CreditCard::create([
62
+ 'customerId' => $customer->id,
63
+ 'cardholderName' => 'Cardholder',
64
+ 'number' => '5105105105105100',
65
+ 'expirationDate' => '05/12'
66
+ ])->creditCard;
67
+ $this->assertTrue($card1->isDefault());
68
+
69
+ $card2 = Braintree\CreditCard::create([
70
+ 'customerId' => $customer->id,
71
+ 'cardholderName' => 'Cardholder',
72
+ 'number' => '5105105105105100',
73
+ 'expirationDate' => '05/12',
74
+ 'options' => [
75
+ 'makeDefault' => true
76
+ ]
77
+ ])->creditCard;
78
+
79
+ $card1 = Braintree\CreditCard::find($card1->token);
80
+ $this->assertFalse($card1->isDefault());
81
+ $this->assertTrue($card2->isDefault());
82
+ }
83
+
84
+ public function testCreateWithVerificationAmount()
85
+ {
86
+ $customer = Braintree\Customer::createNoValidate();
87
+ $result = Braintree\CreditCard::create([
88
+ 'customerId' => $customer->id,
89
+ 'cardholderName' => 'Cardholder',
90
+ 'number' => '4111111111111111',
91
+ 'expirationDate' => '05/12',
92
+ 'options' => [
93
+ 'verificationAmount' => '5.00',
94
+ 'verifyCard' => true
95
+ ]
96
+ ]);
97
+ $this->assertTrue($result->success);
98
+ $this->assertEquals($customer->id, $result->creditCard->customerId);
99
+ $this->assertEquals('411111', $result->creditCard->bin);
100
+ $this->assertEquals('1111', $result->creditCard->last4);
101
+ $this->assertEquals('Cardholder', $result->creditCard->cardholderName);
102
+ $this->assertEquals('05/2012', $result->creditCard->expirationDate);
103
+ $this->assertEquals(1, preg_match('/\A\w{32}\z/', $result->creditCard->uniqueNumberIdentifier));
104
+ $this->assertFalse($result->creditCard->isVenmoSdk());
105
+ $this->assertEquals(1, preg_match('/png/', $result->creditCard->imageUrl));
106
+ }
107
+
108
+ public function testAddCardToExistingCustomerUsingNonce()
109
+ {
110
+ $customer = Braintree\Customer::createNoValidate();
111
+ $http = new HttpClientApi(Braintree\Configuration::$global);
112
+ $nonce = $http->nonce_for_new_card([
113
+ "credit_card" => [
114
+ "number" => "4111111111111111",
115
+ "expirationMonth" => "11",
116
+ "expirationYear" => "2099"
117
+ ],
118
+ "share" => true
119
+ ]);
120
+
121
+ $result = Braintree\CreditCard::create([
122
+ 'customerId' => $customer->id,
123
+ 'paymentMethodNonce' => $nonce
124
+ ]);
125
+
126
+ $this->assertSame("411111", $result->creditCard->bin);
127
+ $this->assertSame("1111", $result->creditCard->last4);
128
+ }
129
+
130
+ public function testCreate_withSecurityParams()
131
+ {
132
+ $customer = Braintree\Customer::createNoValidate();
133
+ $result = Braintree\CreditCard::create([
134
+ 'customerId' => $customer->id,
135
+ 'deviceSessionId' => 'abc_123',
136
+ 'fraudMerchantId' => '456',
137
+ 'cardholderName' => 'Cardholder',
138
+ 'number' => '5105105105105100',
139
+ 'expirationDate' => '05/12'
140
+ ]);
141
+
142
+ $this->assertTrue($result->success);
143
+ }
144
+
145
+ public function testCreate_withExpirationMonthAndYear()
146
+ {
147
+ $customer = Braintree\Customer::createNoValidate();
148
+ $result = Braintree\CreditCard::create([
149
+ 'customerId' => $customer->id,
150
+ 'cardholderName' => 'Cardholder',
151
+ 'number' => '5105105105105100',
152
+ 'expirationMonth' => '05',
153
+ 'expirationYear' => '2011'
154
+ ]);
155
+ $this->assertTrue($result->success);
156
+ $this->assertEquals($customer->id, $result->creditCard->customerId);
157
+ $this->assertEquals('510510', $result->creditCard->bin);
158
+ $this->assertEquals('5100', $result->creditCard->last4);
159
+ $this->assertEquals('Cardholder', $result->creditCard->cardholderName);
160
+ $this->assertEquals('05/2011', $result->creditCard->expirationDate);
161
+ }
162
+
163
+ public function testCreate_withSpecifyingToken()
164
+ {
165
+ $token = strval(rand());
166
+ $customer = Braintree\Customer::createNoValidate();
167
+ $result = Braintree\CreditCard::create([
168
+ 'customerId' => $customer->id,
169
+ 'number' => '5105105105105100',
170
+ 'expirationDate' => '05/2011',
171
+ 'token' => $token
172
+ ]);
173
+ $this->assertTrue($result->success);
174
+ $this->assertEquals($token, $result->creditCard->token);
175
+ $this->assertEquals($token, Braintree\CreditCard::find($token)->token);
176
+ }
177
+
178
+ public function testCreate_withDuplicateCardCheck()
179
+ {
180
+ $customer = Braintree\Customer::createNoValidate();
181
+
182
+ $attributes = [
183
+ 'customerId' => $customer->id,
184
+ 'number' => '5105105105105100',
185
+ 'expirationDate' => '05/2011',
186
+ 'options' => ['failOnDuplicatePaymentMethod' => true]
187
+ ];
188
+ Braintree\CreditCard::create($attributes);
189
+
190
+ $result = Braintree\CreditCard::create($attributes);
191
+ $this->assertFalse($result->success);
192
+ $errors = $result->errors->forKey('creditCard')->onAttribute('number');
193
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_DUPLICATE_CARD_EXISTS, $errors[0]->code);
194
+ $this->assertEquals(1, preg_match('/Duplicate card exists in the vault\./', $result->message));
195
+ }
196
+
197
+ public function testCreate_withCardVerification()
198
+ {
199
+ $customer = Braintree\Customer::createNoValidate();
200
+ $result = Braintree\CreditCard::create([
201
+ 'customerId' => $customer->id,
202
+ 'number' => '5105105105105100',
203
+ 'expirationDate' => '05/2011',
204
+ 'options' => ['verifyCard' => true]
205
+ ]);
206
+ $this->assertFalse($result->success);
207
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status);
208
+ $this->assertEquals('2000', $result->creditCardVerification->processorResponseCode);
209
+ $this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText);
210
+ $this->assertEquals('I', $result->creditCardVerification->cvvResponseCode);
211
+ $this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode);
212
+ $this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode);
213
+ $this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode);
214
+ $this->assertEquals(Braintree\CreditCard::PREPAID_UNKNOWN, $result->creditCardVerification->creditCard['prepaid']);
215
+ }
216
+
217
+ public function testCreate_withCardVerificationReturnsVerificationWithRiskData()
218
+ {
219
+ $customer = Braintree\Customer::createNoValidate();
220
+ $result = Braintree\CreditCard::create([
221
+ 'customerId' => $customer->id,
222
+ 'number' => '4111111111111111',
223
+ 'expirationDate' => '05/2011',
224
+ 'options' => ['verifyCard' => true]
225
+ ]);
226
+ $this->assertTrue($result->success);
227
+ $this->assertNotNull($result->creditCard->verification->riskData);
228
+ $this->assertNotNull($result->creditCard->verification->riskData->decision);
229
+ }
230
+
231
+ public function testCreate_withCardVerificationAndOverriddenAmount()
232
+ {
233
+ $customer = Braintree\Customer::createNoValidate();
234
+ $result = Braintree\CreditCard::create([
235
+ 'customerId' => $customer->id,
236
+ 'number' => '5105105105105100',
237
+ 'expirationDate' => '05/2011',
238
+ 'options' => ['verifyCard' => true, 'verificationAmount' => '1.02']
239
+ ]);
240
+ $this->assertFalse($result->success);
241
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status);
242
+ $this->assertEquals('2000', $result->creditCardVerification->processorResponseCode);
243
+ $this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText);
244
+ $this->assertEquals('I', $result->creditCardVerification->cvvResponseCode);
245
+ $this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode);
246
+ $this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode);
247
+ $this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode);
248
+ $this->assertEquals(Braintree\CreditCard::PREPAID_UNKNOWN, $result->creditCardVerification->creditCard['prepaid']);
249
+ }
250
+
251
+ public function testCreate_withCardVerificationAndSpecificMerchantAccount()
252
+ {
253
+ $customer = Braintree\Customer::createNoValidate();
254
+ $result = Braintree\CreditCard::create([
255
+ 'customerId' => $customer->id,
256
+ 'number' => '5105105105105100',
257
+ 'expirationDate' => '05/2011',
258
+ 'options' => ['verificationMerchantAccountId' => Test\Helper::nonDefaultMerchantAccountId(), 'verifyCard' => true],
259
+ ]);
260
+ $this->assertFalse($result->success);
261
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status);
262
+ $this->assertEquals('2000', $result->creditCardVerification->processorResponseCode);
263
+ $this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText);
264
+ $this->assertEquals('I', $result->creditCardVerification->cvvResponseCode);
265
+ $this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode);
266
+ $this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode);
267
+ $this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode);
268
+ }
269
+
270
+ public function testCreate_withBillingAddress()
271
+ {
272
+ $customer = Braintree\Customer::createNoValidate();
273
+ $result = Braintree\CreditCard::create([
274
+ 'customerId' => $customer->id,
275
+ 'cardholderName' => 'Peter Tomlin',
276
+ 'number' => '5105105105105100',
277
+ 'expirationDate' => '05/12',
278
+ 'billingAddress' => [
279
+ 'firstName' => 'Drew',
280
+ 'lastName' => 'Smith',
281
+ 'company' => 'Smith Co.',
282
+ 'streetAddress' => '1 E Main St',
283
+ 'extendedAddress' => 'Suite 101',
284
+ 'locality' => 'Chicago',
285
+ 'region' => 'IL',
286
+ 'postalCode' => '60622',
287
+ 'countryName' => 'Micronesia',
288
+ 'countryCodeAlpha2' => 'FM',
289
+ 'countryCodeAlpha3' => 'FSM',
290
+ 'countryCodeNumeric' => '583'
291
+ ]
292
+ ]);
293
+ $this->assertTrue($result->success);
294
+ $this->assertEquals($customer->id, $result->creditCard->customerId);
295
+ $this->assertEquals('510510', $result->creditCard->bin);
296
+ $this->assertEquals('5100', $result->creditCard->last4);
297
+ $this->assertEquals('Peter Tomlin', $result->creditCard->cardholderName);
298
+ $this->assertEquals('05/2012', $result->creditCard->expirationDate);
299
+ $address = $result->creditCard->billingAddress;
300
+ $this->assertEquals('Drew', $address->firstName);
301
+ $this->assertEquals('Smith', $address->lastName);
302
+ $this->assertEquals('Smith Co.', $address->company);
303
+ $this->assertEquals('1 E Main St', $address->streetAddress);
304
+ $this->assertEquals('Suite 101', $address->extendedAddress);
305
+ $this->assertEquals('Chicago', $address->locality);
306
+ $this->assertEquals('IL', $address->region);
307
+ $this->assertEquals('60622', $address->postalCode);
308
+ $this->assertEquals('Micronesia', $address->countryName);
309
+ $this->assertEquals('FM', $address->countryCodeAlpha2);
310
+ $this->assertEquals('FSM', $address->countryCodeAlpha3);
311
+ $this->assertEquals('583', $address->countryCodeNumeric);
312
+ }
313
+
314
+ public function testCreate_withExistingBillingAddress()
315
+ {
316
+ $customer = Braintree\Customer::createNoValidate();
317
+ $existingAddress = Braintree\Address::createNoValidate([
318
+ 'customerId' => $customer->id,
319
+ 'firstName' => 'John'
320
+ ]);
321
+ $result = Braintree\CreditCard::create([
322
+ 'customerId' => $customer->id,
323
+ 'number' => '5105105105105100',
324
+ 'expirationDate' => '05/12',
325
+ 'billingAddressId' => $existingAddress->id
326
+ ]);
327
+ $this->assertTrue($result->success);
328
+ $address = $result->creditCard->billingAddress;
329
+ $this->assertEquals($existingAddress->id, $address->id);
330
+ $this->assertEquals('John', $address->firstName);
331
+ }
332
+
333
+ public function testCreate_withValidationErrors()
334
+ {
335
+ $customer = Braintree\Customer::createNoValidate();
336
+ $result = Braintree\CreditCard::create([
337
+ 'expirationDate' => 'invalid',
338
+ 'billingAddress' => [
339
+ 'countryName' => 'Tuvalu',
340
+ 'countryCodeAlpha2' => 'US'
341
+ ]
342
+ ]);
343
+ $this->assertFalse($result->success);
344
+ $errors = $result->errors->forKey('creditCard')->onAttribute('expirationDate');
345
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, $errors[0]->code);
346
+ $this->assertEquals(1, preg_match('/Credit card number is required\./', $result->message));
347
+ $this->assertEquals(1, preg_match('/Customer ID is required\./', $result->message));
348
+ $this->assertEquals(1, preg_match('/Expiration date is invalid\./', $result->message));
349
+
350
+ $errors = $result->errors->forKey('creditCard')->forKey('billingAddress')->onAttribute('base');
351
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_INCONSISTENT_COUNTRY, $errors[0]->code);
352
+ }
353
+
354
+ public function testCreate_withVenmoSdkPaymentMethodCode()
355
+ {
356
+ $customer = Braintree\Customer::createNoValidate();
357
+ $result = Braintree\CreditCard::create([
358
+ 'customerId' => $customer->id,
359
+ 'venmoSdkPaymentMethodCode' => Braintree\Test\VenmoSdk::generateTestPaymentMethodCode('378734493671000')
360
+ ]);
361
+ $this->assertTrue($result->success);
362
+ $this->assertEquals("378734", $result->creditCard->bin);
363
+ }
364
+
365
+ public function testCreate_with_invalid_venmoSdkPaymentMethodCode()
366
+ {
367
+ $customer = Braintree\Customer::createNoValidate();
368
+ $result = Braintree\CreditCard::create([
369
+ 'customerId' => $customer->id,
370
+ 'venmoSdkPaymentMethodCode' => Braintree\Test\VenmoSdk::getInvalidPaymentMethodCode(),
371
+ ]);
372
+ $this->assertFalse($result->success);
373
+ $errors = $result->errors->forKey('creditCard')->onAttribute('venmoSdkPaymentMethodCode');
374
+ $this->assertEquals($errors[0]->code, Braintree\Error\Codes::CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE);
375
+
376
+ }
377
+
378
+ public function testCreate_with_venmoSdkSession()
379
+ {
380
+ $customer = Braintree\Customer::createNoValidate();
381
+ $result = Braintree\CreditCard::create([
382
+ 'customerId' => $customer->id,
383
+ 'number' => '5105105105105100',
384
+ 'expirationDate' => '05/12',
385
+ 'options' => [
386
+ 'venmoSdkSession' => Braintree\Test\VenmoSdk::getTestSession()
387
+ ]
388
+ ]);
389
+ $this->assertTrue($result->success);
390
+ $this->assertTrue($result->creditCard->isVenmoSdk());
391
+ }
392
+
393
+ public function testCreate_with_invalidVenmoSdkSession()
394
+ {
395
+ $customer = Braintree\Customer::createNoValidate();
396
+ $result = Braintree\CreditCard::create([
397
+ 'customerId' => $customer->id,
398
+ 'number' => '5105105105105100',
399
+ 'expirationDate' => '05/12',
400
+ 'options' => [
401
+ 'venmoSdkSession' => Braintree\Test\VenmoSdk::getInvalidTestSession(),
402
+ ]
403
+ ]);
404
+ $this->assertTrue($result->success);
405
+ $this->assertFalse($result->creditCard->isVenmoSdk());
406
+ }
407
+
408
+ public function testCreateNoValidate_throwsIfValidationsFail()
409
+ {
410
+
411
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed');
412
+ $customer = Braintree\Customer::createNoValidate();
413
+ Braintree\CreditCard::createNoValidate([
414
+ 'expirationDate' => 'invalid',
415
+ ]);
416
+ }
417
+
418
+ public function testCreateNoValidate_returnsCreditCardIfValid()
419
+ {
420
+ $customer = Braintree\Customer::createNoValidate();
421
+ $creditCard = Braintree\CreditCard::createNoValidate([
422
+ 'customerId' => $customer->id,
423
+ 'cardholderName' => 'Cardholder',
424
+ 'number' => '5105105105105100',
425
+ 'expirationDate' => '05/12'
426
+ ]);
427
+ $this->assertEquals($customer->id, $creditCard->customerId);
428
+ $this->assertEquals('510510', $creditCard->bin);
429
+ $this->assertEquals('5100', $creditCard->last4);
430
+ $this->assertEquals('Cardholder', $creditCard->cardholderName);
431
+ $this->assertEquals('05/2012', $creditCard->expirationDate);
432
+ }
433
+
434
+ public function testCreateFromTransparentRedirect()
435
+ {
436
+ Test\Helper::suppressDeprecationWarnings();
437
+ $customer = Braintree\Customer::createNoValidate();
438
+ $queryString = $this->createCreditCardViaTr(
439
+ [
440
+ 'credit_card' => [
441
+ 'number' => '5105105105105100',
442
+ 'expiration_date' => '05/12'
443
+ ]
444
+ ],
445
+ [
446
+ 'creditCard' => [
447
+ 'customerId' => $customer->id
448
+ ]
449
+ ]
450
+ );
451
+ $result = Braintree\CreditCard::createFromTransparentRedirect($queryString);
452
+ $this->assertTrue($result->success);
453
+ $this->assertEquals('510510', $result->creditCard->bin);
454
+ $this->assertEquals('5100', $result->creditCard->last4);
455
+ $this->assertEquals('05/2012', $result->creditCard->expirationDate);
456
+ }
457
+
458
+ public function testCreateFromTransparentRedirect_withDefault()
459
+ {
460
+ Test\Helper::suppressDeprecationWarnings();
461
+ $customer = Braintree\Customer::createNoValidate();
462
+ $queryString = $this->createCreditCardViaTr(
463
+ [
464
+ 'credit_card' => [
465
+ 'number' => '5105105105105100',
466
+ 'expiration_date' => '05/12',
467
+ 'options' => ['make_default' => true]
468
+ ]
469
+ ],
470
+ [
471
+ 'creditCard' => [
472
+ 'customerId' => $customer->id
473
+ ]
474
+ ]
475
+ );
476
+ $result = Braintree\CreditCard::createFromTransparentRedirect($queryString);
477
+ $this->assertTrue($result->creditCard->isDefault());
478
+ }
479
+
480
+ public function testUpdateFromTransparentRedirect()
481
+ {
482
+ $customer = Braintree\Customer::createNoValidate();
483
+ $creditCard = Braintree\CreditCard::createNoValidate([
484
+ 'customerId' => $customer->id,
485
+ 'number' => '5105105105105100',
486
+ 'expirationDate' => '05/12'
487
+ ]);
488
+ $queryString = $this->updateCreditCardViaTr(
489
+ [
490
+ 'credit_card' => [
491
+ 'number' => '4111111111111111',
492
+ 'expiration_date' => '01/11'
493
+ ]
494
+ ],
495
+ ['paymentMethodToken' => $creditCard->token]
496
+ );
497
+ $result = Braintree\CreditCard::updateFromTransparentRedirect($queryString);
498
+ $this->assertTrue($result->success);
499
+ $this->assertEquals('411111', $result->creditCard->bin);
500
+ $this->assertEquals('1111', $result->creditCard->last4);
501
+ $this->assertEquals('01/2011', $result->creditCard->expirationDate);
502
+ }
503
+
504
+ public function testUpdateFromTransparentRedirect_withDefault()
505
+ {
506
+ $customer = Braintree\Customer::createNoValidate();
507
+ $card1 = Braintree\CreditCard::createNoValidate([
508
+ 'customerId' => $customer->id,
509
+ 'number' => '5105105105105100',
510
+ 'expirationDate' => '05/12'
511
+ ]);
512
+ $card2 = Braintree\CreditCard::createNoValidate([
513
+ 'customerId' => $customer->id,
514
+ 'number' => '5105105105105100',
515
+ 'expirationDate' => '05/12'
516
+ ]);
517
+ $this->assertFalse($card2->isDefault());
518
+
519
+ $queryString = $this->updateCreditCardViaTr(
520
+ [
521
+ 'credit_card' => [
522
+ 'options' => [
523
+ 'make_default' => true
524
+ ]
525
+ ]
526
+ ],
527
+ ['paymentMethodToken' => $card2->token]
528
+ );
529
+ $result = Braintree\CreditCard::updateFromTransparentRedirect($queryString);
530
+ $this->assertFalse(Braintree\CreditCard::find($card1->token)->isDefault());
531
+ $this->assertTrue(Braintree\CreditCard::find($card2->token)->isDefault());
532
+ }
533
+
534
+ public function testUpdateFromTransparentRedirect_andUpdateExistingBillingAddress()
535
+ {
536
+ $customer = Braintree\Customer::createNoValidate();
537
+ $card = Braintree\CreditCard::createNoValidate([
538
+ 'customerId' => $customer->id,
539
+ 'number' => '5105105105105100',
540
+ 'expirationDate' => '05/12',
541
+ 'billingAddress' => [
542
+ 'firstName' => 'Drew',
543
+ 'lastName' => 'Smith',
544
+ 'company' => 'Smith Co.',
545
+ 'streetAddress' => '123 Old St',
546
+ 'extendedAddress' => 'Suite 101',
547
+ 'locality' => 'Chicago',
548
+ 'region' => 'IL',
549
+ 'postalCode' => '60622',
550
+ 'countryName' => 'United States of America'
551
+ ]
552
+ ]);
553
+
554
+ $queryString = $this->updateCreditCardViaTr(
555
+ [],
556
+ [
557
+ 'paymentMethodToken' => $card->token,
558
+ 'creditCard' => [
559
+ 'billingAddress' => [
560
+ 'streetAddress' => '123 New St',
561
+ 'locality' => 'St. Louis',
562
+ 'region' => 'MO',
563
+ 'postalCode' => '63119',
564
+ 'options' => [
565
+ 'updateExisting' => True
566
+ ]
567
+ ]
568
+ ]
569
+ ]
570
+ );
571
+ $result = Braintree\CreditCard::updateFromTransparentRedirect($queryString);
572
+ $this->assertTrue($result->success);
573
+ $card = $result->creditCard;
574
+ $this->assertEquals(1, sizeof(Braintree\Customer::find($customer->id)->addresses));
575
+ $this->assertEquals('123 New St', $card->billingAddress->streetAddress);
576
+ $this->assertEquals('St. Louis', $card->billingAddress->locality);
577
+ $this->assertEquals('MO', $card->billingAddress->region);
578
+ $this->assertEquals('63119', $card->billingAddress->postalCode);
579
+ }
580
+
581
+ public function testSale_createsASaleUsingGivenToken()
582
+ {
583
+ $customer = Braintree\Customer::createNoValidate([
584
+ 'creditCard' => [
585
+ 'number' => '5105105105105100',
586
+ 'expirationDate' => '05/12'
587
+ ]
588
+ ]);
589
+ $creditCard = $customer->creditCards[0];
590
+ $result = Braintree\CreditCard::sale($creditCard->token, [
591
+ 'amount' => '100.00'
592
+ ]);
593
+ $this->assertTrue($result->success);
594
+ $this->assertEquals('100.00', $result->transaction->amount);
595
+ $this->assertEquals($customer->id, $result->transaction->customerDetails->id);
596
+ $this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token);
597
+ }
598
+
599
+ public function testSaleNoValidate_createsASaleUsingGivenToken()
600
+ {
601
+ $customer = Braintree\Customer::createNoValidate([
602
+ 'creditCard' => [
603
+ 'number' => '5105105105105100',
604
+ 'expirationDate' => '05/12'
605
+ ]
606
+ ]);
607
+ $creditCard = $customer->creditCards[0];
608
+ $transaction = Braintree\CreditCard::saleNoValidate($creditCard->token, [
609
+ 'amount' => '100.00'
610
+ ]);
611
+ $this->assertEquals('100.00', $transaction->amount);
612
+ $this->assertEquals($customer->id, $transaction->customerDetails->id);
613
+ $this->assertEquals($creditCard->token, $transaction->creditCardDetails->token);
614
+ }
615
+
616
+ public function testSaleNoValidate_createsASaleUsingGivenTokenAndCvv()
617
+ {
618
+ $customer = Braintree\Customer::createNoValidate([
619
+ 'creditCard' => [
620
+ 'number' => '5105105105105100',
621
+ 'expirationDate' => '05/12'
622
+ ]
623
+ ]);
624
+ $creditCard = $customer->creditCards[0];
625
+ $transaction = Braintree\CreditCard::saleNoValidate($creditCard->token, [
626
+ 'amount' => '100.00',
627
+ 'creditCard' => [
628
+ 'cvv' => '301'
629
+ ]
630
+ ]);
631
+ $this->assertEquals('100.00', $transaction->amount);
632
+ $this->assertEquals($customer->id, $transaction->customerDetails->id);
633
+ $this->assertEquals($creditCard->token, $transaction->creditCardDetails->token);
634
+ $this->assertEquals('S', $transaction->cvvResponseCode);
635
+ }
636
+
637
+ public function testSaleNoValidate_throwsIfInvalid()
638
+ {
639
+ $customer = Braintree\Customer::createNoValidate([
640
+ 'creditCard' => [
641
+ 'number' => '5105105105105100',
642
+ 'expirationDate' => '05/12'
643
+ ]
644
+ ]);
645
+ $creditCard = $customer->creditCards[0];
646
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed');
647
+ Braintree\CreditCard::saleNoValidate($creditCard->token, [
648
+ 'amount' => 'invalid'
649
+ ]);
650
+ }
651
+
652
+ public function testCredit_createsACreditUsingGivenToken()
653
+ {
654
+ $customer = Braintree\Customer::createNoValidate([
655
+ 'creditCard' => [
656
+ 'number' => '5105105105105100',
657
+ 'expirationDate' => '05/12'
658
+ ]
659
+ ]);
660
+ $creditCard = $customer->creditCards[0];
661
+ $result = Braintree\CreditCard::credit($creditCard->token, [
662
+ 'amount' => '100.00'
663
+ ]);
664
+ $this->assertTrue($result->success);
665
+ $this->assertEquals('100.00', $result->transaction->amount);
666
+ $this->assertEquals(Braintree\Transaction::CREDIT, $result->transaction->type);
667
+ $this->assertEquals($customer->id, $result->transaction->customerDetails->id);
668
+ $this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token);
669
+ }
670
+
671
+ public function testCreditNoValidate_createsACreditUsingGivenToken()
672
+ {
673
+ $customer = Braintree\Customer::createNoValidate([
674
+ 'creditCard' => [
675
+ 'number' => '5105105105105100',
676
+ 'expirationDate' => '05/12'
677
+ ]
678
+ ]);
679
+ $creditCard = $customer->creditCards[0];
680
+ $transaction = Braintree\CreditCard::creditNoValidate($creditCard->token, [
681
+ 'amount' => '100.00'
682
+ ]);
683
+ $this->assertEquals('100.00', $transaction->amount);
684
+ $this->assertEquals(Braintree\Transaction::CREDIT, $transaction->type);
685
+ $this->assertEquals($customer->id, $transaction->customerDetails->id);
686
+ $this->assertEquals($creditCard->token, $transaction->creditCardDetails->token);
687
+ }
688
+
689
+ public function testCreditNoValidate_throwsIfInvalid()
690
+ {
691
+ $customer = Braintree\Customer::createNoValidate([
692
+ 'creditCard' => [
693
+ 'number' => '5105105105105100',
694
+ 'expirationDate' => '05/12'
695
+ ]
696
+ ]);
697
+ $creditCard = $customer->creditCards[0];
698
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed');
699
+ Braintree\CreditCard::creditNoValidate($creditCard->token, [
700
+ 'amount' => 'invalid'
701
+ ]);
702
+ }
703
+
704
+ public function testExpired()
705
+ {
706
+ $collection = Braintree\CreditCard::expired();
707
+ $this->assertTrue($collection->maximumCount() > 1);
708
+
709
+ $arr = [];
710
+ foreach($collection as $creditCard) {
711
+ $this->assertTrue($creditCard->isExpired());
712
+ array_push($arr, $creditCard->token);
713
+ }
714
+ $uniqueCreditCardTokens = array_unique(array_values($arr));
715
+ $this->assertEquals($collection->maximumCount(), count($uniqueCreditCardTokens));
716
+ }
717
+
718
+
719
+ public function testExpiringBetween()
720
+ {
721
+ $collection = Braintree\CreditCard::expiringBetween(
722
+ mktime(0, 0, 0, 1, 1, 2010),
723
+ mktime(23, 59, 59, 12, 31, 2010)
724
+ );
725
+ $this->assertTrue($collection->maximumCount() > 1);
726
+
727
+ $arr = [];
728
+ foreach($collection as $creditCard) {
729
+ $this->assertEquals('2010', $creditCard->expirationYear);
730
+ array_push($arr, $creditCard->token);
731
+ }
732
+ $uniqueCreditCardTokens = array_unique(array_values($arr));
733
+ $this->assertEquals($collection->maximumCount(), count($uniqueCreditCardTokens));
734
+ }
735
+
736
+ public function testExpiringBetween_parsesCreditCardDetailsUnderTransactionsCorrectly()
737
+ {
738
+ $collection = Braintree\CreditCard::expiringBetween(
739
+ mktime(0, 0, 0, 1, 1, 2010),
740
+ mktime(23, 59, 59, 12, 31, 2010)
741
+ );
742
+ $this->assertTrue($collection->maximumCount() > 1);
743
+
744
+ foreach($collection as $creditCard) {
745
+ foreach($creditCard->subscriptions as $subscription) {
746
+ foreach($subscription->transactions as $transaction) {
747
+ $this->assertNotNull($transaction->creditCardDetails->expirationMonth);
748
+ }
749
+ }
750
+ }
751
+ }
752
+
753
+ public function testFind()
754
+ {
755
+ $customer = Braintree\Customer::createNoValidate();
756
+ $result = Braintree\CreditCard::create([
757
+ 'customerId' => $customer->id,
758
+ 'cardholderName' => 'Cardholder',
759
+ 'number' => '5105105105105100',
760
+ 'expirationDate' => '05/12'
761
+ ]);
762
+ $this->assertTrue($result->success);
763
+ $creditCard = Braintree\CreditCard::find($result->creditCard->token);
764
+ $this->assertEquals($customer->id, $creditCard->customerId);
765
+ $this->assertEquals('510510', $creditCard->bin);
766
+ $this->assertEquals('5100', $creditCard->last4);
767
+ $this->assertEquals('Cardholder', $creditCard->cardholderName);
768
+ $this->assertEquals('05/2012', $creditCard->expirationDate);
769
+ $this->assertEquals([], $creditCard->subscriptions);
770
+ }
771
+
772
+ public function testFindReturnsAssociatedSubscriptions()
773
+ {
774
+ $customer = Braintree\Customer::createNoValidate();
775
+ $result = Braintree\CreditCard::create([
776
+ 'customerId' => $customer->id,
777
+ 'cardholderName' => 'Cardholder',
778
+ 'number' => '5105105105105100',
779
+ 'expirationDate' => '05/12',
780
+ 'billingAddress' => [
781
+ 'firstName' => 'Drew',
782
+ 'lastName' => 'Smith',
783
+ 'company' => 'Smith Co.',
784
+ 'streetAddress' => '1 E Main St',
785
+ 'extendedAddress' => 'Suite 101',
786
+ 'locality' => 'Chicago',
787
+ 'region' => 'IL',
788
+ 'postalCode' => '60622',
789
+ 'countryName' => 'United States of America'
790
+ ]
791
+ ]);
792
+ $id = strval(rand());
793
+ Braintree\Subscription::create([
794
+ 'id' => $id,
795
+ 'paymentMethodToken' => $result->creditCard->token,
796
+ 'planId' => 'integration_trialless_plan',
797
+ 'price' => '1.00'
798
+ ]);
799
+ $creditCard = Braintree\CreditCard::find($result->creditCard->token);
800
+ $this->assertEquals($id, $creditCard->subscriptions[0]->id);
801
+ $this->assertEquals('integration_trialless_plan', $creditCard->subscriptions[0]->planId);
802
+ $this->assertEquals('1.00', $creditCard->subscriptions[0]->price);
803
+ }
804
+
805
+ public function testFind_throwsIfCannotBeFound()
806
+ {
807
+ $this->setExpectedException('Braintree\Exception\NotFound');
808
+ Braintree\CreditCard::find('invalid-token');
809
+ }
810
+
811
+ public function testFind_throwsUsefulErrorMessagesWhenEmpty()
812
+ {
813
+ $this->setExpectedException('InvalidArgumentException', 'expected credit card id to be set');
814
+ Braintree\CreditCard::find('');
815
+ }
816
+
817
+ public function testFind_throwsUsefulErrorMessagesWhenInvalid()
818
+ {
819
+ $this->setExpectedException('InvalidArgumentException', '@ is an invalid credit card token');
820
+ Braintree\CreditCard::find('@');
821
+ }
822
+
823
+ public function testFromNonce()
824
+ {
825
+ $customer = Braintree\Customer::createNoValidate();
826
+ $http = new HttpClientApi(Braintree\Configuration::$global);
827
+ $nonce = $http->nonce_for_new_card([
828
+ "credit_card" => [
829
+ "number" => "4009348888881881",
830
+ "expirationMonth" => "11",
831
+ "expirationYear" => "2099"
832
+ ],
833
+ "customerId" => $customer->id
834
+ ]);
835
+
836
+ $creditCard = Braintree\CreditCard::fromNonce($nonce);
837
+
838
+ $customer = Braintree\Customer::find($customer->id);
839
+ $this->assertEquals($customer->creditCards[0], $creditCard);
840
+ }
841
+
842
+ public function testFromNonce_ReturnsErrorWhenNoncePointsToSharedCard()
843
+ {
844
+ $http = new HttpClientApi(Braintree\Configuration::$global);
845
+ $nonce = $http->nonce_for_new_card([
846
+ "credit_card" => [
847
+ "number" => "4009348888881881",
848
+ "expirationMonth" => "11",
849
+ "expirationYear" => "2099"
850
+ ],
851
+ "share" => true
852
+ ]);
853
+
854
+ $this->setExpectedException('Braintree\Exception\NotFound', "not found");
855
+ Braintree\CreditCard::fromNonce($nonce);
856
+ }
857
+
858
+ public function testFromNonce_ReturnsErrorWhenNonceIsConsumed()
859
+ {
860
+ $customer = Braintree\Customer::createNoValidate();
861
+ $http = new HttpClientApi(Braintree\Configuration::$global);
862
+ $nonce = $http->nonce_for_new_card([
863
+ "credit_card" => [
864
+ "number" => "4009348888881881",
865
+ "expirationMonth" => "11",
866
+ "expirationYear" => "2099"
867
+ ],
868
+ "customerId" => $customer->id
869
+ ]);
870
+
871
+ Braintree\CreditCard::fromNonce($nonce);
872
+ $this->setExpectedException('Braintree\Exception\NotFound', "consumed");
873
+ Braintree\CreditCard::fromNonce($nonce);
874
+ }
875
+
876
+ public function testUpdate()
877
+ {
878
+ $customer = Braintree\Customer::createNoValidate();
879
+ $createResult = Braintree\CreditCard::create([
880
+ 'customerId' => $customer->id,
881
+ 'cardholderName' => 'Old Cardholder',
882
+ 'number' => '5105105105105100',
883
+ 'expirationDate' => '05/12'
884
+ ]);
885
+ $this->assertTrue($createResult->success);
886
+ $updateResult = Braintree\CreditCard::update($createResult->creditCard->token, [
887
+ 'cardholderName' => 'New Cardholder',
888
+ 'number' => '4111111111111111',
889
+ 'expirationDate' => '07/14'
890
+ ]);
891
+ $this->assertEquals($customer->id, $updateResult->creditCard->customerId);
892
+ $this->assertEquals('411111', $updateResult->creditCard->bin);
893
+ $this->assertEquals('1111', $updateResult->creditCard->last4);
894
+ $this->assertEquals('New Cardholder', $updateResult->creditCard->cardholderName);
895
+ $this->assertEquals('07/2014', $updateResult->creditCard->expirationDate);
896
+ }
897
+
898
+ public function testUpdate_withCardVerification()
899
+ {
900
+ $customer = Braintree\Customer::createNoValidate();
901
+ $initialCreditCard = Braintree\CreditCard::create([
902
+ 'customerId' => $customer->id,
903
+ 'number' => '5105105105105100',
904
+ 'expirationDate' => '05/12'
905
+ ])->creditCard;
906
+
907
+ $result = Braintree\CreditCard::update($initialCreditCard->token, [
908
+ 'billingAddress' => [
909
+ 'region' => 'IL'
910
+ ],
911
+ 'options' => ['verifyCard' => true]
912
+ ]);
913
+ $this->assertFalse($result->success);
914
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status);
915
+ $this->assertEquals('2000', $result->creditCardVerification->processorResponseCode);
916
+ $this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText);
917
+ $this->assertEquals('I', $result->creditCardVerification->cvvResponseCode);
918
+ $this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode);
919
+ $this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode);
920
+ $this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode);
921
+ $this->assertEquals(Test\Helper::defaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId);
922
+ }
923
+
924
+ public function testUpdate_withCardVerificationAndSpecificMerchantAccount()
925
+ {
926
+ $customer = Braintree\Customer::createNoValidate();
927
+ $initialCreditCard = Braintree\CreditCard::create([
928
+ 'customerId' => $customer->id,
929
+ 'number' => '5105105105105100',
930
+ 'expirationDate' => '05/12'
931
+ ])->creditCard;
932
+
933
+ $result = Braintree\CreditCard::update($initialCreditCard->token, [
934
+ 'billingAddress' => [
935
+ 'region' => 'IL'
936
+ ],
937
+ 'options' => [
938
+ 'verificationMerchantAccountId' => Test\Helper::nonDefaultMerchantAccountId(),
939
+ 'verifyCard' => true
940
+ ]
941
+ ]);
942
+ $this->assertFalse($result->success);
943
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status);
944
+ $this->assertEquals(Test\Helper::nonDefaultMerchantAccountId(), $result->creditCardVerification->merchantAccountId);
945
+ }
946
+
947
+ public function testUpdate_createsNewBillingAddressByDefault()
948
+ {
949
+ $customer = Braintree\Customer::createNoValidate();
950
+ $initialCreditCard = Braintree\CreditCard::create([
951
+ 'customerId' => $customer->id,
952
+ 'number' => '5105105105105100',
953
+ 'expirationDate' => '05/12',
954
+ 'billingAddress' => [
955
+ 'streetAddress' => '123 Nigeria Ave'
956
+ ]
957
+ ])->creditCard;
958
+
959
+ $updatedCreditCard = Braintree\CreditCard::update($initialCreditCard->token, [
960
+ 'billingAddress' => [
961
+ 'region' => 'IL'
962
+ ]
963
+ ])->creditCard;
964
+ $this->assertEquals('IL', $updatedCreditCard->billingAddress->region);
965
+ $this->assertNull($updatedCreditCard->billingAddress->streetAddress);
966
+ $this->assertNotEquals($initialCreditCard->billingAddress->id, $updatedCreditCard->billingAddress->id);
967
+ }
968
+
969
+ public function testUpdate_updatesExistingBillingAddressIfUpdateExistingOptionIsTrue()
970
+ {
971
+ $customer = Braintree\Customer::createNoValidate();
972
+ $initialCreditCard = Braintree\CreditCard::create([
973
+ 'customerId' => $customer->id,
974
+ 'number' => '5105105105105100',
975
+ 'expirationDate' => '05/12',
976
+ 'billingAddress' => [
977
+ 'countryName' => 'Turkey',
978
+ 'countryCodeAlpha2' => 'TR',
979
+ 'countryCodeAlpha3' => 'TUR',
980
+ 'countryCodeNumeric' => '792',
981
+ ]
982
+ ])->creditCard;
983
+
984
+ $updatedCreditCard = Braintree\CreditCard::update($initialCreditCard->token, [
985
+ 'billingAddress' => [
986
+ 'countryName' => 'Thailand',
987
+ 'countryCodeAlpha2' => 'TH',
988
+ 'countryCodeAlpha3' => 'THA',
989
+ 'countryCodeNumeric' => '764',
990
+ 'options' => [
991
+ 'updateExisting' => True
992
+ ]
993
+ ]
994
+ ])->creditCard;
995
+ $this->assertEquals('Thailand', $updatedCreditCard->billingAddress->countryName);
996
+ $this->assertEquals('TH', $updatedCreditCard->billingAddress->countryCodeAlpha2);
997
+ $this->assertEquals('THA', $updatedCreditCard->billingAddress->countryCodeAlpha3);
998
+ $this->assertEquals('764', $updatedCreditCard->billingAddress->countryCodeNumeric);
999
+ $this->assertEquals($initialCreditCard->billingAddress->id, $updatedCreditCard->billingAddress->id);
1000
+ }
1001
+
1002
+ public function testUpdate_canChangeToken()
1003
+ {
1004
+ $oldToken = strval(rand());
1005
+ $newToken = strval(rand());
1006
+
1007
+ $customer = Braintree\Customer::createNoValidate();
1008
+ $createResult = Braintree\CreditCard::create([
1009
+ 'customerId' => $customer->id,
1010
+ 'token' => $oldToken,
1011
+ 'number' => '5105105105105100',
1012
+ 'expirationDate' => '05/12'
1013
+ ]);
1014
+ $this->assertTrue($createResult->success);
1015
+ $updateResult = Braintree\CreditCard::update($oldToken, [
1016
+ 'token' => $newToken
1017
+ ]);
1018
+ $this->assertEquals($customer->id, $updateResult->creditCard->customerId);
1019
+ $this->assertEquals($newToken, $updateResult->creditCard->token);
1020
+ $this->assertEquals($newToken, Braintree\CreditCard::find($newToken)->token);
1021
+ }
1022
+
1023
+ public function testUpdateNoValidate()
1024
+ {
1025
+ $customer = Braintree\Customer::createNoValidate();
1026
+ $creditCard = Braintree\CreditCard::createNoValidate([
1027
+ 'customerId' => $customer->id,
1028
+ 'cardholderName' => 'Old Cardholder',
1029
+ 'number' => '5105105105105100',
1030
+ 'expirationDate' => '05/12'
1031
+ ]);
1032
+ $updatedCard = Braintree\CreditCard::updateNoValidate($creditCard->token, [
1033
+ 'cardholderName' => 'New Cardholder',
1034
+ 'number' => '4111111111111111',
1035
+ 'expirationDate' => '07/14'
1036
+ ]);
1037
+ $this->assertEquals($customer->id, $updatedCard->customerId);
1038
+ $this->assertEquals('411111', $updatedCard->bin);
1039
+ $this->assertEquals('1111', $updatedCard->last4);
1040
+ $this->assertEquals('New Cardholder', $updatedCard->cardholderName);
1041
+ $this->assertEquals('07/2014', $updatedCard->expirationDate);
1042
+ }
1043
+
1044
+ public function testUpdateNoValidate_throwsIfInvalid()
1045
+ {
1046
+ $customer = Braintree\Customer::createNoValidate();
1047
+ $creditCard = Braintree\CreditCard::createNoValidate([
1048
+ 'customerId' => $customer->id,
1049
+ 'cardholderName' => 'Old Cardholder',
1050
+ 'number' => '5105105105105100',
1051
+ 'expirationDate' => '05/12'
1052
+ ]);
1053
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed');
1054
+ Braintree\CreditCard::updateNoValidate($creditCard->token, [
1055
+ 'number' => 'invalid',
1056
+ ]);
1057
+ }
1058
+
1059
+ public function testUpdate_withDefault()
1060
+ {
1061
+ $customer = Braintree\Customer::createNoValidate();
1062
+ $card1 = Braintree\CreditCard::create([
1063
+ 'customerId' => $customer->id,
1064
+ 'cardholderName' => 'Cardholder',
1065
+ 'number' => '5105105105105100',
1066
+ 'expirationDate' => '05/12'
1067
+ ])->creditCard;
1068
+ $card2 = Braintree\CreditCard::create([
1069
+ 'customerId' => $customer->id,
1070
+ 'cardholderName' => 'Cardholder',
1071
+ 'number' => '5105105105105100',
1072
+ 'expirationDate' => '05/12'
1073
+ ])->creditCard;
1074
+
1075
+ $this->assertTrue($card1->isDefault());
1076
+ $this->assertFalse($card2->isDefault());
1077
+
1078
+ Braintree\CreditCard::update($card2->token, [
1079
+ 'options' => ['makeDefault' => true]
1080
+ ])->creditCard;
1081
+
1082
+ $this->assertFalse(Braintree\CreditCard::find($card1->token)->isDefault());
1083
+ $this->assertTrue(Braintree\CreditCard::find($card2->token)->isDefault());
1084
+ }
1085
+
1086
+ public function testDelete_deletesThePaymentMethod()
1087
+ {
1088
+ $customer = Braintree\Customer::createNoValidate([]);
1089
+ $creditCard = Braintree\CreditCard::createNoValidate([
1090
+ 'customerId' => $customer->id,
1091
+ 'number' => '5105105105105100',
1092
+ 'expirationDate' => '05/12'
1093
+ ]);
1094
+ Braintree\CreditCard::find($creditCard->token);
1095
+ Braintree\CreditCard::delete($creditCard->token);
1096
+ $this->setExpectedException('Braintree\Exception\NotFound');
1097
+ Braintree\CreditCard::find($creditCard->token);
1098
+ }
1099
+
1100
+ public function testGatewayRejectionOnCVV()
1101
+ {
1102
+ $old_merchant_id = Braintree\Configuration::merchantId();
1103
+ $old_public_key = Braintree\Configuration::publicKey();
1104
+ $old_private_key = Braintree\Configuration::privateKey();
1105
+
1106
+ Braintree\Configuration::merchantId('processing_rules_merchant_id');
1107
+ Braintree\Configuration::publicKey('processing_rules_public_key');
1108
+ Braintree\Configuration::privateKey('processing_rules_private_key');
1109
+
1110
+ $customer = Braintree\Customer::createNoValidate();
1111
+ $result = Braintree\CreditCard::create([
1112
+ 'customerId' => $customer->id,
1113
+ 'number' => '4111111111111111',
1114
+ 'expirationDate' => '05/2011',
1115
+ 'cvv' => '200',
1116
+ 'options' => ['verifyCard' => true]
1117
+ ]);
1118
+
1119
+ Braintree\Configuration::merchantId($old_merchant_id);
1120
+ Braintree\Configuration::publicKey($old_public_key);
1121
+ Braintree\Configuration::privateKey($old_private_key);
1122
+
1123
+ $this->assertFalse($result->success);
1124
+ $this->assertEquals(Braintree\Transaction::CVV, $result->creditCardVerification->gatewayRejectionReason);
1125
+ }
1126
+
1127
+ public function testGatewayRejectionIsNullOnProcessorDecline()
1128
+ {
1129
+ $old_merchant_id = Braintree\Configuration::merchantId();
1130
+ $old_public_key = Braintree\Configuration::publicKey();
1131
+ $old_private_key = Braintree\Configuration::privateKey();
1132
+
1133
+ Braintree\Configuration::merchantId('processing_rules_merchant_id');
1134
+ Braintree\Configuration::publicKey('processing_rules_public_key');
1135
+ Braintree\Configuration::privateKey('processing_rules_private_key');
1136
+
1137
+ $customer = Braintree\Customer::createNoValidate();
1138
+ $result = Braintree\CreditCard::create([
1139
+ 'customerId' => $customer->id,
1140
+ 'number' => '5105105105105100',
1141
+ 'expirationDate' => '05/2011',
1142
+ 'cvv' => '200',
1143
+ 'options' => ['verifyCard' => true]
1144
+ ]);
1145
+
1146
+ Braintree\Configuration::merchantId($old_merchant_id);
1147
+ Braintree\Configuration::publicKey($old_public_key);
1148
+ Braintree\Configuration::privateKey($old_private_key);
1149
+
1150
+ $this->assertFalse($result->success);
1151
+ $this->assertNull($result->creditCardVerification->gatewayRejectionReason);
1152
+ }
1153
+
1154
+ public function createCreditCardViaTr($regularParams, $trParams)
1155
+ {
1156
+ $trData = Braintree\TransparentRedirect::createCreditCardData(
1157
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"])
1158
+ );
1159
+ return Test\Helper::submitTrRequest(
1160
+ Braintree\CreditCard::createCreditCardUrl(),
1161
+ $regularParams,
1162
+ $trData
1163
+ );
1164
+ }
1165
+
1166
+ public function updateCreditCardViaTr($regularParams, $trParams)
1167
+ {
1168
+ $trData = Braintree\TransparentRedirect::updateCreditCardData(
1169
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"])
1170
+ );
1171
+ return Test\Helper::submitTrRequest(
1172
+ Braintree\CreditCard::updateCreditCardUrl(),
1173
+ $regularParams,
1174
+ $trData
1175
+ );
1176
+ }
1177
+
1178
+ public function testPrepaidCard()
1179
+ {
1180
+ $customer = Braintree\Customer::createNoValidate();
1181
+ $result = Braintree\CreditCard::create([
1182
+ 'customerId' => $customer->id,
1183
+ 'cardholderName' => 'Cardholder',
1184
+ 'number' => CardTypeIndicators::PREPAID,
1185
+ 'expirationDate' => '05/12',
1186
+ 'options' => ['verifyCard' => true]
1187
+ ]);
1188
+ $this->assertEquals(Braintree\CreditCard::PREPAID_YES, $result->creditCard->prepaid);
1189
+ }
1190
+
1191
+ public function testCommercialCard()
1192
+ {
1193
+ $customer = Braintree\Customer::createNoValidate();
1194
+ $result = Braintree\CreditCard::create([
1195
+ 'customerId' => $customer->id,
1196
+ 'cardholderName' => 'Cardholder',
1197
+ 'number' => CardTypeIndicators::COMMERCIAL,
1198
+ 'expirationDate' => '05/12',
1199
+ 'options' => ['verifyCard' => true]
1200
+ ]);
1201
+ $this->assertEquals(Braintree\CreditCard::COMMERCIAL_YES, $result->creditCard->commercial);
1202
+ }
1203
+
1204
+ public function testDebitCard()
1205
+ {
1206
+ $customer = Braintree\Customer::createNoValidate();
1207
+ $result = Braintree\CreditCard::create([
1208
+ 'customerId' => $customer->id,
1209
+ 'cardholderName' => 'Cardholder',
1210
+ 'number' => CardTypeIndicators::DEBIT,
1211
+ 'expirationDate' => '05/12',
1212
+ 'options' => ['verifyCard' => true]
1213
+ ]);
1214
+ $this->assertEquals(Braintree\CreditCard::DEBIT_YES, $result->creditCard->debit);
1215
+ }
1216
+
1217
+ public function testPayrollCard()
1218
+ {
1219
+ $customer = Braintree\Customer::createNoValidate();
1220
+ $result = Braintree\CreditCard::create([
1221
+ 'customerId' => $customer->id,
1222
+ 'cardholderName' => 'Cardholder',
1223
+ 'number' => CardTypeIndicators::PAYROLL,
1224
+ 'expirationDate' => '05/12',
1225
+ 'options' => ['verifyCard' => true]
1226
+ ]);
1227
+ $this->assertEquals(Braintree\CreditCard::PAYROLL_YES, $result->creditCard->payroll);
1228
+ $this->assertEquals('MSA', $result->creditCard->productId);
1229
+ }
1230
+
1231
+ public function testHealthCareCard()
1232
+ {
1233
+ $customer = Braintree\Customer::createNoValidate();
1234
+ $result = Braintree\CreditCard::create([
1235
+ 'customerId' => $customer->id,
1236
+ 'cardholderName' => 'Cardholder',
1237
+ 'number' => CardTypeIndicators::HEALTHCARE,
1238
+ 'expirationDate' => '05/12',
1239
+ 'options' => ['verifyCard' => true]
1240
+ ]);
1241
+ $this->assertEquals(Braintree\CreditCard::HEALTHCARE_YES, $result->creditCard->healthcare);
1242
+ $this->assertEquals('J3', $result->creditCard->productId);
1243
+ }
1244
+
1245
+ public function testDurbinRegulatedCard()
1246
+ {
1247
+ $customer = Braintree\Customer::createNoValidate();
1248
+ $result = Braintree\CreditCard::create([
1249
+ 'customerId' => $customer->id,
1250
+ 'cardholderName' => 'Cardholder',
1251
+ 'number' => CardTypeIndicators::DURBIN_REGULATED,
1252
+ 'expirationDate' => '05/12',
1253
+ 'options' => ['verifyCard' => true]
1254
+ ]);
1255
+ $this->assertEquals(Braintree\CreditCard::DURBIN_REGULATED_YES, $result->creditCard->durbinRegulated);
1256
+ }
1257
+
1258
+ public function testCountryOfIssuanceCard()
1259
+ {
1260
+ $customer = Braintree\Customer::createNoValidate();
1261
+ $result = Braintree\CreditCard::create([
1262
+ 'customerId' => $customer->id,
1263
+ 'cardholderName' => 'Cardholder',
1264
+ 'number' => CardTypeIndicators::COUNTRY_OF_ISSUANCE,
1265
+ 'expirationDate' => '05/12',
1266
+ 'options' => ['verifyCard' => true]
1267
+ ]);
1268
+ $this->assertEquals("USA", $result->creditCard->countryOfIssuance);
1269
+ }
1270
+
1271
+ public function testIssuingBankCard()
1272
+ {
1273
+ $customer = Braintree\Customer::createNoValidate();
1274
+ $result = Braintree\CreditCard::create([
1275
+ 'customerId' => $customer->id,
1276
+ 'cardholderName' => 'Cardholder',
1277
+ 'number' => CardTypeIndicators::ISSUING_BANK,
1278
+ 'expirationDate' => '05/12',
1279
+ 'options' => ['verifyCard' => true]
1280
+ ]);
1281
+ $this->assertEquals("NETWORK ONLY", $result->creditCard->issuingBank);
1282
+ }
1283
+
1284
+ public function testNegativeCardTypeIndicators()
1285
+ {
1286
+ $customer = Braintree\Customer::createNoValidate();
1287
+ $result = Braintree\CreditCard::create([
1288
+ 'customerId' => $customer->id,
1289
+ 'cardholderName' => 'Cardholder',
1290
+ 'number' => CardTypeIndicators::NO,
1291
+ 'expirationDate' => '05/12',
1292
+ 'options' => ['verifyCard' => true]
1293
+ ]);
1294
+ $this->assertEquals(Braintree\CreditCard::PREPAID_NO, $result->creditCard->prepaid);
1295
+ $this->assertEquals(Braintree\CreditCard::DURBIN_REGULATED_NO, $result->creditCard->durbinRegulated);
1296
+ $this->assertEquals(Braintree\CreditCard::PAYROLL_NO, $result->creditCard->payroll);
1297
+ $this->assertEquals(Braintree\CreditCard::DEBIT_NO, $result->creditCard->debit);
1298
+ $this->assertEquals(Braintree\CreditCard::HEALTHCARE_NO, $result->creditCard->healthcare);
1299
+ $this->assertEquals(Braintree\CreditCard::COMMERCIAL_NO, $result->creditCard->commercial);
1300
+ $this->assertEquals('MSB', $result->creditCard->productId);
1301
+ }
1302
+
1303
+ public function testUnknownCardTypeIndicators()
1304
+ {
1305
+ $customer = Braintree\Customer::createNoValidate();
1306
+ $result = Braintree\CreditCard::create([
1307
+ 'customerId' => $customer->id,
1308
+ 'cardholderName' => 'Cardholder',
1309
+ 'number' => CardTypeIndicators::UNKNOWN,
1310
+ 'expirationDate' => '05/12',
1311
+ 'options' => ['verifyCard' => true]
1312
+ ]);
1313
+ $this->assertEquals(Braintree\CreditCard::PREPAID_UNKNOWN, $result->creditCard->prepaid);
1314
+ $this->assertEquals(Braintree\CreditCard::DURBIN_REGULATED_UNKNOWN, $result->creditCard->durbinRegulated);
1315
+ $this->assertEquals(Braintree\CreditCard::PAYROLL_UNKNOWN, $result->creditCard->payroll);
1316
+ $this->assertEquals(Braintree\CreditCard::DEBIT_UNKNOWN, $result->creditCard->debit);
1317
+ $this->assertEquals(Braintree\CreditCard::HEALTHCARE_UNKNOWN, $result->creditCard->healthcare);
1318
+ $this->assertEquals(Braintree\CreditCard::COMMERCIAL_UNKNOWN, $result->creditCard->commercial);
1319
+ $this->assertEquals(Braintree\CreditCard::COUNTRY_OF_ISSUANCE_UNKNOWN, $result->creditCard->countryOfIssuance);
1320
+ $this->assertEquals(Braintree\CreditCard::ISSUING_BANK_UNKNOWN, $result->creditCard->issuingBank);
1321
+ $this->assertEquals(Braintree\CreditCard::PRODUCT_ID_UNKNOWN, $result->creditCard->productId);
1322
+ }
1323
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/CreditCardVerificationAdvancedSearchTest.php ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class CreditCardVerificationAdvancedSearchTest extends Setup
11
+ {
12
+ public function test_searchOnTextFields()
13
+ {
14
+ $searchCriteria = [
15
+ 'creditCardCardholderName' => 'Tim Toole',
16
+ 'creditCardExpirationDate' => '05/2010',
17
+ 'creditCardNumber' => Braintree\Test\CreditCardNumbers::$failsSandboxVerification['Visa'],
18
+ 'billingAddressDetailsPostalCode' => '90210',
19
+ ];
20
+ $result = Braintree\Customer::create([
21
+ 'creditCard' => [
22
+ 'cardholderName' => $searchCriteria['creditCardCardholderName'],
23
+ 'number' => $searchCriteria['creditCardNumber'],
24
+ 'expirationDate' => $searchCriteria['creditCardExpirationDate'],
25
+ 'billingAddress' => [
26
+ 'postalCode' => $searchCriteria['billingAddressDetailsPostalCode']
27
+ ],
28
+ 'options' => ['verifyCard' => true],
29
+ ],
30
+ ]);
31
+ $verification = $result->creditCardVerification;
32
+
33
+ $query = [Braintree\CreditCardVerificationSearch::id()->is($verification->id)];
34
+ foreach ($searchCriteria AS $criterion => $value) {
35
+ $query[] = Braintree\CreditCardVerificationSearch::$criterion()->is($value);
36
+ }
37
+
38
+ $collection = Braintree\CreditCardVerification::search($query);
39
+ $this->assertEquals(1, $collection->maximumCount());
40
+ $this->assertEquals($result->creditCardVerification->id, $collection->firstItem()->id);
41
+
42
+ foreach ($searchCriteria AS $criterion => $value) {
43
+ $collection = Braintree\CreditCardVerification::search([
44
+ Braintree\CreditCardVerificationSearch::$criterion()->is($value),
45
+ Braintree\CreditCardVerificationSearch::id()->is($result->creditCardVerification->id)
46
+ ]);
47
+ $this->assertEquals(1, $collection->maximumCount());
48
+ $this->assertEquals($result->creditCardVerification->id, $collection->firstItem()->id);
49
+
50
+ $collection = Braintree\CreditCardVerification::search([
51
+ Braintree\CreditCardVerificationSearch::$criterion()->is('invalid_attribute'),
52
+ Braintree\CreditCardVerificationSearch::id()->is($result->creditCardVerification->id)
53
+ ]);
54
+ $this->assertEquals(0, $collection->maximumCount());
55
+ }
56
+ }
57
+
58
+ public function test_searchOnSuccessfulCustomerAndPaymentFields()
59
+ {
60
+ $customerId = uniqid();
61
+ $searchCriteria = [
62
+ 'customerId' => $customerId,
63
+ 'customerEmail' => $customerId . 'sandworm@example.com',
64
+ 'paymentMethodToken' => $customerId . 'token',
65
+ ];
66
+ $result = Braintree\Customer::create([
67
+ 'id' => $customerId,
68
+ 'email' => $searchCriteria['customerEmail'],
69
+ 'creditCard' => [
70
+ 'token' => $searchCriteria['paymentMethodToken'],
71
+ 'number' => Braintree\Test\CreditCardNumbers::$visa,
72
+ 'expirationDate' => '05/2017',
73
+ 'options' => ['verifyCard' => true]
74
+ ]
75
+ ]);
76
+ $customer = $result->customer;
77
+
78
+ $query = [];
79
+ foreach ($searchCriteria AS $criterion => $value) {
80
+ $query[] = Braintree\CreditCardVerificationSearch::$criterion()->is($value);
81
+ }
82
+
83
+ $collection = Braintree\CreditCardVerification::search($query);
84
+ $this->assertEquals(1, $collection->maximumCount());
85
+
86
+ foreach ($searchCriteria AS $criterion => $value) {
87
+ $collection = Braintree\CreditCardVerification::search([
88
+ Braintree\CreditCardVerificationSearch::$criterion()->is($value),
89
+ ]);
90
+ $this->assertEquals(1, $collection->maximumCount());
91
+
92
+ $collection = Braintree\CreditCardVerification::search([
93
+ Braintree\CreditCardVerificationSearch::$criterion()->is('invalid_attribute'),
94
+ ]);
95
+ $this->assertEquals(0, $collection->maximumCount());
96
+ }
97
+ }
98
+
99
+ public function testGateway_searchEmpty()
100
+ {
101
+ $query = [];
102
+ $query[] = Braintree\CreditCardVerificationSearch::creditCardCardholderName()->is('Not Found');
103
+
104
+ $gateway = new Braintree\Gateway([
105
+ 'environment' => 'development',
106
+ 'merchantId' => 'integration_merchant_id',
107
+ 'publicKey' => 'integration_public_key',
108
+ 'privateKey' => 'integration_private_key'
109
+ ]);
110
+ $collection = $gateway->creditCardVerification()->search($query);
111
+
112
+ $this->assertEquals(0, $collection->maximumCount());
113
+ }
114
+
115
+ public function test_createdAt()
116
+ {
117
+ $result = Braintree\Customer::create([
118
+ 'creditCard' => [
119
+ 'cardholderName' => 'Joe Smith',
120
+ 'number' => '4000111111111115',
121
+ 'expirationDate' => '12/2016',
122
+ 'options' => ['verifyCard' => true],
123
+ ],
124
+ ]);
125
+
126
+ $verification = $result->creditCardVerification;
127
+
128
+ $past = clone $verification->createdAt;
129
+ $past->modify('-1 hour');
130
+ $future = clone $verification->createdAt;
131
+ $future->modify('+1 hour');
132
+
133
+ $collection = Braintree\CreditCardVerification::search([
134
+ Braintree\CreditCardVerificationSearch::id()->is($verification->id),
135
+ Braintree\CreditCardVerificationSearch::createdAt()->between($past, $future)
136
+ ]);
137
+ $this->assertEquals(1, $collection->maximumCount());
138
+ $this->assertEquals($verification->id, $collection->firstItem()->id);
139
+
140
+ $collection = Braintree\CreditCardVerification::search([
141
+ Braintree\CreditCardVerificationSearch::id()->is($verification->id),
142
+ Braintree\CreditCardVerificationSearch::createdAt()->lessThanOrEqualTo($future)
143
+ ]);
144
+ $this->assertEquals(1, $collection->maximumCount());
145
+ $this->assertEquals($verification->id, $collection->firstItem()->id);
146
+
147
+ $collection = Braintree\CreditCardVerification::search([
148
+ Braintree\CreditCardVerificationSearch::id()->is($verification->id),
149
+ Braintree\CreditCardVerificationSearch::createdAt()->greaterThanOrEqualTo($past)
150
+ ]);
151
+ $this->assertEquals(1, $collection->maximumCount());
152
+ $this->assertEquals($verification->id, $collection->firstItem()->id);
153
+ }
154
+
155
+ public function test_multipleValueNode_ids()
156
+ {
157
+ $result = Braintree\Customer::create([
158
+ 'creditCard' => [
159
+ 'cardholderName' => 'Joe Smith',
160
+ 'number' => '4000111111111115',
161
+ 'expirationDate' => '12/2016',
162
+ 'options' => ['verifyCard' => true],
163
+ ],
164
+ ]);
165
+
166
+ $creditCardVerification = $result->creditCardVerification;
167
+
168
+ $collection = Braintree\CreditCardVerification::search([
169
+ Braintree\CreditCardVerificationSearch::ids()->is($creditCardVerification->id)
170
+ ]);
171
+ $this->assertEquals(1, $collection->maximumCount());
172
+ $this->assertEquals($creditCardVerification->id, $collection->firstItem()->id);
173
+
174
+ $collection = Braintree\CreditCardVerification::search([
175
+ Braintree\CreditCardVerificationSearch::ids()->in(
176
+ [$creditCardVerification->id,'1234']
177
+ )
178
+ ]);
179
+ $this->assertEquals(1, $collection->maximumCount());
180
+ $this->assertEquals($creditCardVerification->id, $collection->firstItem()->id);
181
+
182
+ $collection = Braintree\CreditCardVerification::search([
183
+ Braintree\CreditCardVerificationSearch::ids()->is('1234')
184
+ ]);
185
+ $this->assertEquals(0, $collection->maximumCount());
186
+ }
187
+
188
+ public function test_multipleValueNode_creditCardType()
189
+ {
190
+ $result = Braintree\Customer::create([
191
+ 'creditCard' => [
192
+ 'cardholderName' => 'Joe Smith',
193
+ 'number' => '4000111111111115',
194
+ 'expirationDate' => '12/2016',
195
+ 'options' => ['verifyCard' => true],
196
+ ],
197
+ ]);
198
+
199
+ $creditCardVerification = $result->creditCardVerification;
200
+
201
+ $collection = Braintree\CreditCardVerification::search([
202
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id),
203
+ Braintree\CreditCardVerificationSearch::creditCardCardType()->is($creditCardVerification->creditCard['cardType'])
204
+ ]);
205
+ $this->assertEquals(1, $collection->maximumCount());
206
+ $this->assertEquals($creditCardVerification->id, $collection->firstItem()->id);
207
+
208
+ $collection = Braintree\CreditCardVerification::search([
209
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id),
210
+ Braintree\CreditCardVerificationSearch::creditCardCardType()->in(
211
+ [$creditCardVerification->creditCard['cardType'], Braintree\CreditCard::CHINA_UNION_PAY]
212
+ )
213
+ ]);
214
+ $this->assertEquals(1, $collection->maximumCount());
215
+ $this->assertEquals($creditCardVerification->id, $collection->firstItem()->id);
216
+
217
+ $collection = Braintree\CreditCardVerification::search([
218
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id),
219
+ Braintree\CreditCardVerificationSearch::creditCardCardType()->is(Braintree\CreditCard::CHINA_UNION_PAY)
220
+ ]);
221
+ $this->assertEquals(0, $collection->maximumCount());
222
+ }
223
+
224
+ public function test_multipleValueNode_status()
225
+ {
226
+ $result = Braintree\Customer::create([
227
+ 'creditCard' => [
228
+ 'cardholderName' => 'Joe Smith',
229
+ 'number' => '4000111111111115',
230
+ 'expirationDate' => '12/2016',
231
+ 'options' => ['verifyCard' => true],
232
+ ],
233
+ ]);
234
+
235
+ $creditCardVerification = $result->creditCardVerification;
236
+
237
+ $collection = Braintree\CreditCardVerification::search([
238
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id),
239
+ Braintree\CreditCardVerificationSearch::status()->is($creditCardVerification->status)
240
+ ]);
241
+ $this->assertEquals(1, $collection->maximumCount());
242
+ $this->assertEquals($creditCardVerification->id, $collection->firstItem()->id);
243
+
244
+ $collection = Braintree\CreditCardVerification::search([
245
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id),
246
+ Braintree\CreditCardVerificationSearch::status()->in(
247
+ [$creditCardVerification->status, Braintree\Result\CreditCardVerification::VERIFIED]
248
+ )
249
+ ]);
250
+ $this->assertEquals(1, $collection->maximumCount());
251
+ $this->assertEquals($creditCardVerification->id, $collection->firstItem()->id);
252
+
253
+ $collection = Braintree\CreditCardVerification::search([
254
+ Braintree\CreditCardVerificationSearch::id()->is($creditCardVerification->id),
255
+ Braintree\CreditCardVerificationSearch::status()->is(Braintree\Result\CreditCardVerification::VERIFIED)
256
+ ]);
257
+ $this->assertEquals(0, $collection->maximumCount());
258
+ }
259
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/CreditCardVerificationTest.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class CreditCardVerificationTest extends Setup
11
+ {
12
+ public function test_createWithSuccessfulResponse()
13
+ {
14
+ $result = Braintree\CreditCardVerification::create([
15
+ 'creditCard' => [
16
+ 'number' => '4111111111111111',
17
+ 'expirationDate' => '05/2011',
18
+ ],
19
+ ]);
20
+ $this->assertTrue($result->success);
21
+ }
22
+
23
+ public function test_createWithUnsuccessfulResponse()
24
+ {
25
+ $result = Braintree\CreditCardVerification::create([
26
+ 'creditCard' => [
27
+ 'number' => Braintree\Test\CreditCardNumbers::$failsSandboxVerification['Visa'],
28
+ 'expirationDate' => '05/2011',
29
+ ],
30
+ ]);
31
+ $this->assertFalse($result->success);
32
+ $this->assertEquals($result->verification->status, Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED);
33
+
34
+ $verification = $result->verification;
35
+
36
+ $this->assertEquals($verification->processorResponseCode, '2000');
37
+ $this->assertEquals($verification->processorResponseText, 'Do Not Honor');
38
+ }
39
+
40
+ public function test_createWithInvalidRequest()
41
+ {
42
+ $result = Braintree\CreditCardVerification::create([
43
+ 'creditCard' => [
44
+ 'number' => Braintree\Test\CreditCardNumbers::$failsSandboxVerification['Visa'],
45
+ 'expirationDate' => '05/2011',
46
+ ],
47
+ 'options' => [
48
+ 'amount' => '-5.00'
49
+ ],
50
+ ]);
51
+ $this->assertFalse($result->success);
52
+
53
+ $amountErrors = $result->errors->forKey('verification')->forKey('options')->onAttribute('amount');
54
+ $this->assertEquals(Braintree\Error\Codes::VERIFICATION_OPTIONS_AMOUNT_CANNOT_BE_NEGATIVE, $amountErrors[0]->code);
55
+ }
56
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/CustomerAdvancedSearchTest.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class CustomerAdvancedSearchTest extends Setup
10
+ {
11
+ public function test_noMatches()
12
+ {
13
+ $collection = Braintree\Customer::search([
14
+ Braintree\CustomerSearch::company()->is('badname')
15
+ ]);
16
+
17
+ $this->assertEquals(0, $collection->maximumCount());
18
+ }
19
+
20
+ public function test_noRequestsWhenIterating()
21
+ {
22
+ $resultsReturned = false;
23
+ $collection = Braintree\Customer::search([
24
+ Braintree\CustomerSearch::firstName()->is('badname')
25
+ ]);
26
+
27
+ foreach($collection as $customer) {
28
+ $resultsReturned = true;
29
+ break;
30
+ }
31
+
32
+ $this->assertSame(0, $collection->maximumCount());
33
+ $this->assertEquals(false, $resultsReturned);
34
+ }
35
+
36
+ public function test_findDuplicateCardsGivenPaymentMethodToken()
37
+ {
38
+ $creditCardRequest = ['number' => '63049580000009', 'expirationDate' => '05/2012'];
39
+
40
+ $jim = Braintree\Customer::create(['firstName' => 'Jim', 'creditCard' => $creditCardRequest])->customer;
41
+ $joe = Braintree\Customer::create(['firstName' => 'Joe', 'creditCard' => $creditCardRequest])->customer;
42
+
43
+ $query = [Braintree\CustomerSearch::paymentMethodTokenWithDuplicates()->is($jim->creditCards[0]->token)];
44
+ $collection = Braintree\Customer::search($query);
45
+
46
+ $customerIds = [];
47
+ foreach($collection as $customer)
48
+ {
49
+ $customerIds[] = $customer->id;
50
+ }
51
+
52
+ $this->assertTrue(in_array($jim->id, $customerIds));
53
+ $this->assertTrue(in_array($joe->id, $customerIds));
54
+ }
55
+
56
+ public function test_searchOnTextFields()
57
+ {
58
+ $token = 'cctoken' . rand();
59
+
60
+ $search_criteria = [
61
+ 'firstName' => 'Timmy',
62
+ 'lastName' => 'OToole',
63
+ 'company' => 'OToole and Son(s)' . rand(),
64
+ 'email' => 'timmy@example.com',
65
+ 'website' => 'http://example.com',
66
+ 'phone' => '3145551234',
67
+ 'fax' => '3145551235',
68
+ 'cardholderName' => 'Tim Toole',
69
+ 'creditCardExpirationDate' => '05/2010',
70
+ 'creditCardNumber' => '4111111111111111',
71
+ 'paymentMethodToken' => $token,
72
+ 'addressFirstName' => 'Thomas',
73
+ 'addressLastName' => 'Otool',
74
+ 'addressStreetAddress' => '1 E Main St',
75
+ 'addressExtendedAddress' => 'Suite 3',
76
+ 'addressLocality' => 'Chicago',
77
+ 'addressRegion' => 'Illinois',
78
+ 'addressPostalCode' => '60622',
79
+ 'addressCountryName' => 'United States of America'
80
+ ];
81
+
82
+ $customer = Braintree\Customer::createNoValidate([
83
+ 'firstName' => $search_criteria['firstName'],
84
+ 'lastName' => $search_criteria['lastName'],
85
+ 'company' => $search_criteria['company'],
86
+ 'email' => $search_criteria['email'],
87
+ 'fax' => $search_criteria['fax'],
88
+ 'phone' => $search_criteria['phone'],
89
+ 'website' => $search_criteria['website'],
90
+ 'creditCard' => [
91
+ 'cardholderName' => 'Tim Toole',
92
+ 'number' => '4111111111111111',
93
+ 'expirationDate' => $search_criteria['creditCardExpirationDate'],
94
+ 'token' => $token,
95
+ 'billingAddress' => [
96
+ 'firstName' => $search_criteria['addressFirstName'],
97
+ 'lastName' => $search_criteria['addressLastName'],
98
+ 'streetAddress' => $search_criteria['addressStreetAddress'],
99
+ 'extendedAddress' => $search_criteria['addressExtendedAddress'],
100
+ 'locality' => $search_criteria['addressLocality'],
101
+ 'region' => $search_criteria['addressRegion'],
102
+ 'postalCode' => $search_criteria['addressPostalCode'],
103
+ 'countryName' => 'United States of America'
104
+ ]
105
+ ]
106
+ ]);
107
+
108
+ $query = [Braintree\CustomerSearch::id()->is($customer->id)];
109
+ foreach ($search_criteria AS $criterion => $value) {
110
+ $query[] = Braintree\CustomerSearch::$criterion()->is($value);
111
+ }
112
+
113
+ $collection = Braintree\Customer::search($query);
114
+
115
+ $this->assertEquals(1, $collection->maximumCount());
116
+ $this->assertEquals($customer->id, $collection->firstItem()->id);
117
+
118
+ foreach ($search_criteria AS $criterion => $value) {
119
+ $collection = Braintree\Customer::search([
120
+ Braintree\CustomerSearch::$criterion()->is($value),
121
+ Braintree\CustomerSearch::id()->is($customer->id),
122
+ ]);
123
+ $this->assertEquals(1, $collection->maximumCount());
124
+ $this->assertEquals($customer->id, $collection->firstItem()->id);
125
+
126
+ $collection = Braintree\Customer::search([
127
+ Braintree\CustomerSearch::$criterion()->is('invalid_attribute'),
128
+ Braintree\CustomerSearch::id()->is($customer->id),
129
+ ]);
130
+ $this->assertEquals(0, $collection->maximumCount());
131
+ }
132
+ }
133
+
134
+ public function test_createdAt()
135
+ {
136
+ $customer = Braintree\Customer::createNoValidate();
137
+
138
+ $past = clone $customer->createdAt;
139
+ $past->modify("-1 hour");
140
+ $future = clone $customer->createdAt;
141
+ $future->modify("+1 hour");
142
+
143
+ $collection = Braintree\Customer::search([
144
+ Braintree\CustomerSearch::id()->is($customer->id),
145
+ Braintree\CustomerSearch::createdAt()->between($past, $future),
146
+ ]);
147
+ $this->assertEquals(1, $collection->maximumCount());
148
+ $this->assertEquals($customer->id, $collection->firstItem()->id);
149
+
150
+ $collection = Braintree\Customer::search([
151
+ Braintree\CustomerSearch::id()->is($customer->id),
152
+ Braintree\CustomerSearch::createdAt()->lessThanOrEqualTo($future),
153
+ ]);
154
+ $this->assertEquals(1, $collection->maximumCount());
155
+ $this->assertEquals($customer->id, $collection->firstItem()->id);
156
+
157
+ $collection = Braintree\Customer::search([
158
+ Braintree\CustomerSearch::id()->is($customer->id),
159
+ Braintree\CustomerSearch::createdAt()->greaterThanOrEqualTo($past),
160
+ ]);
161
+ $this->assertEquals(1, $collection->maximumCount());
162
+ $this->assertEquals($customer->id, $collection->firstItem()->id);
163
+ }
164
+
165
+ public function test_paypalAccountEmail()
166
+ {
167
+ $http = new HttpClientApi(Braintree\Configuration::$global);
168
+ $nonce = $http->nonceForPayPalAccount([
169
+ 'paypal_account' => [
170
+ 'consent_code' => 'PAYPAL_CONSENT_CODE',
171
+ ]
172
+ ]);
173
+
174
+ $customerId = 'UNIQUE_CUSTOMER_ID-' . strval(rand());
175
+ $customerResult = Braintree\Customer::create([
176
+ 'paymentMethodNonce' => $nonce,
177
+ 'id' => $customerId
178
+ ]);
179
+
180
+ $this->assertTrue($customerResult->success);
181
+
182
+ $customer = $customerResult->customer;
183
+
184
+ $collection = Braintree\Customer::search([
185
+ Braintree\CustomerSearch::id()->is($customer->id),
186
+ Braintree\CustomerSearch::paypalAccountEmail()->is('jane.doe@example.com')
187
+ ]);
188
+ $this->assertEquals(1, $collection->maximumCount());
189
+ $this->assertEquals($customer->id, $collection->firstItem()->id);
190
+ }
191
+
192
+ public function test_throwsIfNoOperatorNodeGiven()
193
+ {
194
+ $this->setExpectedException('InvalidArgumentException', 'Operator must be provided');
195
+ Braintree\Customer::search([
196
+ Braintree\CustomerSearch::creditCardExpirationDate()
197
+ ]);
198
+ }
199
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/CustomerTest.php ADDED
@@ -0,0 +1,1435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class CustomerTest extends Setup
11
+ {
12
+ public function testAll_smokeTest()
13
+ {
14
+ $all = Braintree\Customer::all();
15
+ $this->assertTrue($all->maximumCount() > 0);
16
+ }
17
+
18
+ public function testAllWithManyResults()
19
+ {
20
+ $collection = Braintree\Customer::all();
21
+ $this->assertTrue($collection->maximumCount() > 1);
22
+ $customer = $collection->firstItem();
23
+
24
+ $this->assertTrue(strlen($customer->id) > 0);
25
+ $this->assertTrue($customer instanceof Braintree\Customer);
26
+ }
27
+
28
+ public function testCreate()
29
+ {
30
+ $result = Braintree\Customer::create([
31
+ 'firstName' => 'Mike',
32
+ 'lastName' => 'Jones',
33
+ 'company' => 'Jones Co.',
34
+ 'email' => 'mike.jones@example.com',
35
+ 'phone' => '419.555.1234',
36
+ 'fax' => '419.555.1235',
37
+ 'website' => 'http://example.com'
38
+ ]);
39
+ $this->assertEquals(true, $result->success);
40
+ $customer = $result->customer;
41
+ $this->assertEquals('Mike', $customer->firstName);
42
+ $this->assertEquals('Jones', $customer->lastName);
43
+ $this->assertEquals('Jones Co.', $customer->company);
44
+ $this->assertEquals('mike.jones@example.com', $customer->email);
45
+ $this->assertEquals('419.555.1234', $customer->phone);
46
+ $this->assertEquals('419.555.1235', $customer->fax);
47
+ $this->assertEquals('http://example.com', $customer->website);
48
+ $this->assertNotNull($customer->merchantId);
49
+ }
50
+
51
+ public function testCreateWithIdOfZero()
52
+ {
53
+ $result = Braintree\Customer::create([
54
+ 'id' => '0'
55
+ ]);
56
+
57
+ $this->assertEquals(true, $result->success);
58
+ $this->assertEquals($result->customer->id, '0');
59
+ $customer = Braintree\Customer::find('0');
60
+
61
+ $this->assertEquals('0', $customer->id);
62
+
63
+ Braintree\Customer::delete('0');
64
+ }
65
+
66
+ public function testGatewayCreate()
67
+ {
68
+ $gateway = new Braintree\Gateway([
69
+ 'environment' => 'development',
70
+ 'merchantId' => 'integration_merchant_id',
71
+ 'publicKey' => 'integration_public_key',
72
+ 'privateKey' => 'integration_private_key'
73
+ ]);
74
+ $result = $gateway->customer()->create([
75
+ 'firstName' => 'Mike',
76
+ 'lastName' => 'Jones',
77
+ ]);
78
+ $this->assertEquals(true, $result->success);
79
+ $customer = $result->customer;
80
+ $this->assertEquals('Mike', $customer->firstName);
81
+ $this->assertEquals('Jones', $customer->lastName);
82
+ $this->assertNotNull($customer->merchantId);
83
+ }
84
+
85
+ public function testCreateWithAccessToken()
86
+ {
87
+ $credentials = Test\Braintree\OAuthTestHelper::createCredentials([
88
+ 'clientId' => 'client_id$development$integration_client_id',
89
+ 'clientSecret' => 'client_secret$development$integration_client_secret',
90
+ 'merchantId' => 'integration_merchant_id',
91
+ ]);
92
+
93
+ $gateway = new Braintree\Gateway([
94
+ 'accessToken' => $credentials->accessToken,
95
+ ]);
96
+
97
+ $result = $gateway->customer()->create([
98
+ 'firstName' => 'Mike',
99
+ 'lastName' => 'Jones',
100
+ ]);
101
+ $this->assertEquals(true, $result->success);
102
+ $customer = $result->customer;
103
+ $this->assertEquals('Mike', $customer->firstName);
104
+ $this->assertEquals('Jones', $customer->lastName);
105
+ $this->assertNotNull($customer->merchantId);
106
+ }
107
+
108
+ public function testCreateCustomerWithCardUsingNonce()
109
+ {
110
+ $http = new HttpClientApi(Braintree\Configuration::$global);
111
+ $nonce = $http->nonce_for_new_card([
112
+ "creditCard" => [
113
+ "number" => "4111111111111111",
114
+ "expirationMonth" => "11",
115
+ "expirationYear" => "2099"
116
+ ],
117
+ "share" => true
118
+ ]);
119
+
120
+ $result = Braintree\Customer::create([
121
+ 'creditCard' => [
122
+ 'paymentMethodNonce' => $nonce
123
+ ]
124
+ ]);
125
+
126
+ $this->assertTrue($result->success);
127
+ $this->assertSame("411111", $result->customer->creditCards[0]->bin);
128
+ $this->assertSame("1111", $result->customer->creditCards[0]->last4);
129
+ }
130
+
131
+ public function testCreateCustomerWithApplePayCard()
132
+ {
133
+ $nonce = Braintree\Test\Nonces::$applePayVisa;
134
+ $result = Braintree\Customer::create([
135
+ 'paymentMethodNonce' => $nonce
136
+ ]);
137
+ $this->assertTrue($result->success);
138
+ $customer = $result->customer;
139
+ $this->assertNotNull($customer->applePayCards[0]);
140
+ $this->assertNotNull($customer->paymentMethods[0]);
141
+ }
142
+
143
+ public function testCreateCustomerWithAndroidPayProxyCard()
144
+ {
145
+ $nonce = Braintree\Test\Nonces::$androidPayDiscover;
146
+ $result = Braintree\Customer::create([
147
+ 'paymentMethodNonce' => $nonce
148
+ ]);
149
+ $this->assertTrue($result->success);
150
+ $customer = $result->customer;
151
+ $this->assertNotNull($customer->androidPayCards[0]);
152
+ $this->assertNotNull($customer->paymentMethods[0]);
153
+ $androidPayCard = $customer->androidPayCards[0];
154
+ $this->assertTrue($androidPayCard instanceof Braintree\AndroidPayCard);
155
+ $this->assertNotNull($androidPayCard->token);
156
+ $this->assertNotNull($androidPayCard->expirationYear);
157
+ }
158
+
159
+ public function testCreateCustomerWithAndroidPayNetworkToken()
160
+ {
161
+ $nonce = Braintree\Test\Nonces::$androidPayMasterCard;
162
+ $result = Braintree\Customer::create([
163
+ 'paymentMethodNonce' => $nonce
164
+ ]);
165
+ $this->assertTrue($result->success);
166
+ $customer = $result->customer;
167
+ $this->assertNotNull($customer->androidPayCards[0]);
168
+ $this->assertNotNull($customer->paymentMethods[0]);
169
+ $androidPayCard = $customer->androidPayCards[0];
170
+ $this->assertTrue($androidPayCard instanceof Braintree\AndroidPayCard);
171
+ $this->assertNotNull($androidPayCard->token);
172
+ $this->assertNotNull($androidPayCard->expirationYear);
173
+ }
174
+
175
+ public function testCreateCustomerWithAmexExpressCheckoutCard()
176
+ {
177
+ $nonce = Braintree\Test\Nonces::$amexExpressCheckout;
178
+ $result = Braintree\Customer::create([
179
+ 'paymentMethodNonce' => $nonce
180
+ ]);
181
+ $this->assertTrue($result->success);
182
+ $customer = $result->customer;
183
+ $this->assertNotNull($customer->amexExpressCheckoutCards[0]);
184
+ $this->assertNotNull($customer->paymentMethods[0]);
185
+ $amexExpressCheckoutCard = $customer->amexExpressCheckoutCards[0];
186
+ $this->assertTrue($amexExpressCheckoutCard instanceof Braintree\AmexExpressCheckoutCard);
187
+ $this->assertNotNull($amexExpressCheckoutCard->token);
188
+ $this->assertNotNull($amexExpressCheckoutCard->expirationYear);
189
+ }
190
+
191
+ public function testCreateCustomerWithVenmoAccount()
192
+ {
193
+ $nonce = Braintree\Test\Nonces::$venmoAccount;
194
+ $result = Braintree\Customer::create(array(
195
+ 'paymentMethodNonce' => $nonce
196
+ ));
197
+ $this->assertTrue($result->success);
198
+ $customer = $result->customer;
199
+ $this->assertNotNull($customer->venmoAccounts[0]);
200
+ $this->assertNotNull($customer->paymentMethods[0]);
201
+ $venmoAccount = $customer->venmoAccounts[0];
202
+ $this->assertTrue($venmoAccount instanceof Braintree\VenmoAccount);
203
+ $this->assertNotNull($venmoAccount->token);
204
+ $this->assertNotNull($venmoAccount->username);
205
+ $this->assertNotNull($venmoAccount->venmoUserId);
206
+ }
207
+
208
+ public function testCreateCustomerWithCoinbase()
209
+ {
210
+ $nonce = Braintree\Test\Nonces::$coinbase;
211
+ $result = Braintree\Customer::create([
212
+ 'paymentMethodNonce' => $nonce
213
+ ]);
214
+ $this->assertTrue($result->success);
215
+ $customer = $result->customer;
216
+ $this->assertNotNull($customer->coinbaseAccounts[0]);
217
+ $this->assertNotNull($customer->coinbaseAccounts[0]->userId);
218
+ $this->assertNotNull($customer->coinbaseAccounts[0]->userName);
219
+ $this->assertNotNull($customer->coinbaseAccounts[0]->userEmail);
220
+ $this->assertNotNull($customer->paymentMethods[0]);
221
+ }
222
+
223
+ public function testCreate_withUnicode()
224
+ {
225
+ $result = Braintree\Customer::create([
226
+ 'firstName' => "Здравствуйте",
227
+ 'lastName' => 'Jones',
228
+ 'company' => 'Jones Co.',
229
+ 'email' => 'mike.jones@example.com',
230
+ 'phone' => '419.555.1234',
231
+ 'fax' => '419.555.1235',
232
+ 'website' => 'http://example.com'
233
+ ]);
234
+ $this->assertEquals(true, $result->success);
235
+ $customer = $result->customer;
236
+ $this->assertEquals("Здравствуйте", $customer->firstName);
237
+ $this->assertEquals('Jones', $customer->lastName);
238
+ $this->assertEquals('Jones Co.', $customer->company);
239
+ $this->assertEquals('mike.jones@example.com', $customer->email);
240
+ $this->assertEquals('419.555.1234', $customer->phone);
241
+ $this->assertEquals('419.555.1235', $customer->fax);
242
+ $this->assertEquals('http://example.com', $customer->website);
243
+ $this->assertNotNull($customer->merchantId);
244
+ }
245
+
246
+ public function testCreate_withCountry()
247
+ {
248
+ $result = Braintree\Customer::create([
249
+ 'firstName' => 'Bat',
250
+ 'lastName' => 'Manderson',
251
+ 'creditCard' => [
252
+ 'number' => '5105105105105100',
253
+ 'expirationDate' => '05/12',
254
+ 'billingAddress' => [
255
+ 'countryName' => 'Gabon',
256
+ 'countryCodeAlpha2' => 'GA',
257
+ 'countryCodeAlpha3' => 'GAB',
258
+ 'countryCodeNumeric' => '266'
259
+ ]
260
+ ]
261
+ ]);
262
+ $this->assertEquals(true, $result->success);
263
+ $customer = $result->customer;
264
+ $this->assertEquals('Gabon', $customer->creditCards[0]->billingAddress->countryName);
265
+ $this->assertEquals('GA', $customer->creditCards[0]->billingAddress->countryCodeAlpha2);
266
+ $this->assertEquals('GAB', $customer->creditCards[0]->billingAddress->countryCodeAlpha3);
267
+ $this->assertEquals('266', $customer->creditCards[0]->billingAddress->countryCodeNumeric);
268
+ $this->assertEquals(1, preg_match('/\A\w{32}\z/', $customer->creditCards[0]->uniqueNumberIdentifier));
269
+ }
270
+
271
+ public function testCreate_withVenmoSdkSession()
272
+ {
273
+ $result = Braintree\Customer::create([
274
+ 'firstName' => 'Bat',
275
+ 'lastName' => 'Manderson',
276
+ 'creditCard' => [
277
+ 'number' => '5105105105105100',
278
+ 'expirationDate' => '05/12',
279
+ 'options' => [
280
+ 'venmoSdkSession' => Braintree\Test\VenmoSdk::getTestSession()
281
+ ]
282
+ ]
283
+ ]);
284
+ $this->assertEquals(true, $result->success);
285
+ $customer = $result->customer;
286
+ $this->assertEquals(true, $customer->creditCards[0]->venmoSdk);
287
+ }
288
+
289
+ public function testCreate_withVenmoSdkPaymentMethodCode()
290
+ {
291
+ $result = Braintree\Customer::create([
292
+ 'firstName' => 'Bat',
293
+ 'lastName' => 'Manderson',
294
+ 'creditCard' => [
295
+ 'venmoSdkPaymentMethodCode' => Braintree\Test\VenmoSdk::$visaPaymentMethodCode
296
+ ],
297
+ ]);
298
+ $this->assertEquals(true, $result->success);
299
+ $customer = $result->customer;
300
+ $this->assertEquals("411111", $customer->creditCards[0]->bin);
301
+ }
302
+
303
+ public function testCreate_blankCustomer()
304
+ {
305
+ $result = Braintree\Customer::create();
306
+ $this->assertEquals(true, $result->success);
307
+ $this->assertNotNull($result->customer->id);
308
+
309
+ $result = Braintree\Customer::create([]);
310
+ $this->assertEquals(true, $result->success);
311
+ $this->assertNotNull($result->customer->id);
312
+ }
313
+
314
+ public function testCreate_withSpecialChars()
315
+ {
316
+ $result = Braintree\Customer::create(['firstName' => '<>&"\'']);
317
+ $this->assertEquals(true, $result->success);
318
+ $this->assertEquals('<>&"\'', $result->customer->firstName);
319
+ }
320
+
321
+ public function testCreate_withCustomFields()
322
+ {
323
+ $result = Braintree\Customer::create([
324
+ 'firstName' => 'Mike',
325
+ 'customFields' => [
326
+ 'store_me' => 'some custom value'
327
+ ]
328
+ ]);
329
+ $this->assertEquals(true, $result->success);
330
+ $customFields = $result->customer->customFields;
331
+ $this->assertEquals('some custom value', $customFields['store_me']);
332
+ }
333
+
334
+ public function testCreate_withFraudParams()
335
+ {
336
+ $result = Braintree\Customer::create([
337
+ 'firstName' => 'Mike',
338
+ 'creditCard' => [
339
+ 'number' => '5105105105105100',
340
+ 'expirationDate' => '05/12',
341
+ 'cvv' => '123',
342
+ 'cardholderName' => 'Mike Jones',
343
+ 'deviceSessionId' => 'abc123',
344
+ 'fraudMerchantId' => '456'
345
+ ]
346
+ ]);
347
+ $this->assertEquals(true, $result->success);
348
+ }
349
+
350
+ public function testCreate_withRiskData()
351
+ {
352
+ $result = Braintree\Customer::create([
353
+ 'firstName' => 'Mike',
354
+ 'creditCard' => [
355
+ 'number' => '5105105105105100',
356
+ 'expirationDate' => '05/12',
357
+ 'cvv' => '123',
358
+ 'cardholderName' => 'Mike Jones',
359
+ ],
360
+ 'riskData' => [
361
+ 'customer_browser' => 'IE5',
362
+ 'customer_ip' => '192.168.0.1'
363
+ ]
364
+ ]);
365
+ $this->assertEquals(true, $result->success);
366
+ }
367
+
368
+ public function testCreate_withCreditCard()
369
+ {
370
+ $result = Braintree\Customer::create([
371
+ 'firstName' => 'Mike',
372
+ 'lastName' => 'Jones',
373
+ 'company' => 'Jones Co.',
374
+ 'email' => 'mike.jones@example.com',
375
+ 'phone' => '419.555.1234',
376
+ 'fax' => '419.555.1235',
377
+ 'website' => 'http://example.com',
378
+ 'creditCard' => [
379
+ 'number' => '5105105105105100',
380
+ 'expirationDate' => '05/12',
381
+ 'cvv' => '123',
382
+ 'cardholderName' => 'Mike Jones'
383
+ ]
384
+ ]);
385
+ $this->assertEquals(true, $result->success);
386
+ $customer = $result->customer;
387
+ $this->assertEquals('Mike', $customer->firstName);
388
+ $this->assertEquals('Jones', $customer->lastName);
389
+ $this->assertEquals('Jones Co.', $customer->company);
390
+ $this->assertEquals('mike.jones@example.com', $customer->email);
391
+ $this->assertEquals('419.555.1234', $customer->phone);
392
+ $this->assertEquals('419.555.1235', $customer->fax);
393
+ $this->assertEquals('http://example.com', $customer->website);
394
+ $creditCard = $customer->creditCards[0];
395
+ $this->assertEquals('510510', $creditCard->bin);
396
+ $this->assertEquals('5100', $creditCard->last4);
397
+ $this->assertEquals('Mike Jones', $creditCard->cardholderName);
398
+ $this->assertEquals('05/2012', $creditCard->expirationDate);
399
+ $this->assertEquals('05', $creditCard->expirationMonth);
400
+ $this->assertEquals('2012', $creditCard->expirationYear);
401
+ }
402
+
403
+ public function testCreate_withDuplicateCardCheck()
404
+ {
405
+ $customer = Braintree\Customer::createNoValidate();
406
+
407
+ $attributes = [
408
+ 'firstName' => 'Mike',
409
+ 'lastName' => 'Jones',
410
+ 'company' => 'Jones Co.',
411
+ 'email' => 'mike.jones@example.com',
412
+ 'phone' => '419.555.1234',
413
+ 'fax' => '419.555.1235',
414
+ 'website' => 'http://example.com',
415
+ 'creditCard' => [
416
+ 'number' => '5105105105105100',
417
+ 'expirationDate' => '05/12',
418
+ 'cvv' => '123',
419
+ 'cardholderName' => 'Mike Jones',
420
+ 'options' => [
421
+ 'failOnDuplicatePaymentMethod' => true
422
+ ]
423
+ ]
424
+ ];
425
+ Braintree\Customer::create($attributes);
426
+ $result = Braintree\Customer::create($attributes);
427
+
428
+ $this->assertFalse($result->success);
429
+ $errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('number');
430
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_DUPLICATE_CARD_EXISTS, $errors[0]->code);
431
+ $this->assertEquals(1, preg_match('/Duplicate card exists in the vault\./', $result->message));
432
+ }
433
+
434
+ public function testCreate_withCreditCardAndSpecificVerificationMerchantAccount()
435
+ {
436
+ $result = Braintree\Customer::create([
437
+ 'firstName' => 'Mike',
438
+ 'lastName' => 'Jones',
439
+ 'company' => 'Jones Co.',
440
+ 'email' => 'mike.jones@example.com',
441
+ 'phone' => '419.555.1234',
442
+ 'fax' => '419.555.1235',
443
+ 'website' => 'http://example.com',
444
+ 'creditCard' => [
445
+ 'number' => '5105105105105100',
446
+ 'expirationDate' => '05/12',
447
+ 'cvv' => '123',
448
+ 'cardholderName' => 'Mike Jones',
449
+ 'options' => [
450
+ 'verificationMerchantAccountId' => Test\Helper::nonDefaultMerchantAccountId(),
451
+ 'verifyCard' => true
452
+ ]
453
+ ]
454
+ ]);
455
+ Test\Helper::assertPrintable($result);
456
+ $this->assertFalse($result->success);
457
+ $this->assertEquals(Braintree\Result\CreditCardVerification::PROCESSOR_DECLINED, $result->creditCardVerification->status);
458
+ $this->assertEquals('2000', $result->creditCardVerification->processorResponseCode);
459
+ $this->assertEquals('Do Not Honor', $result->creditCardVerification->processorResponseText);
460
+ $this->assertEquals('M', $result->creditCardVerification->cvvResponseCode);
461
+ $this->assertEquals(null, $result->creditCardVerification->avsErrorResponseCode);
462
+ $this->assertEquals('I', $result->creditCardVerification->avsPostalCodeResponseCode);
463
+ $this->assertEquals('I', $result->creditCardVerification->avsStreetAddressResponseCode);
464
+ }
465
+
466
+ public function testCreate_withCreditCardAndVerificationAmount()
467
+ {
468
+ $result = Braintree\Customer::create([
469
+ 'firstName' => 'Mike',
470
+ 'lastName' => 'Jones',
471
+ 'company' => 'Jones Co.',
472
+ 'email' => 'mike.jones@example.com',
473
+ 'phone' => '419.555.1234',
474
+ 'fax' => '419.555.1235',
475
+ 'website' => 'http://example.com',
476
+ 'creditCard' => [
477
+ 'number' => '5555555555554444',
478
+ 'expirationDate' => '05/12',
479
+ 'cvv' => '123',
480
+ 'cardholderName' => 'Mike Jones',
481
+ 'options' => [
482
+ 'verifyCard' => true,
483
+ 'verificationAmount' => '2.00'
484
+ ]
485
+ ]
486
+ ]);
487
+
488
+ $this->assertTrue($result->success);
489
+ }
490
+
491
+ public function testCreate_withCreditCardAndBillingAddress()
492
+ {
493
+ $result = Braintree\Customer::create([
494
+ 'firstName' => 'Mike',
495
+ 'lastName' => 'Jones',
496
+ 'company' => 'Jones Co.',
497
+ 'email' => 'mike.jones@example.com',
498
+ 'phone' => '419.555.1234',
499
+ 'fax' => '419.555.1235',
500
+ 'website' => 'http://example.com',
501
+ 'creditCard' => [
502
+ 'number' => '5105105105105100',
503
+ 'expirationDate' => '05/12',
504
+ 'cvv' => '123',
505
+ 'cardholderName' => 'Mike Jones',
506
+ 'billingAddress' => [
507
+ 'firstName' => 'Drew',
508
+ 'lastName' => 'Smith',
509
+ 'company' => 'Smith Co.',
510
+ 'streetAddress' => '1 E Main St',
511
+ 'extendedAddress' => 'Suite 101',
512
+ 'locality' => 'Chicago',
513
+ 'region' => 'IL',
514
+ 'postalCode' => '60622',
515
+ 'countryName' => 'United States of America'
516
+ ]
517
+ ]
518
+ ]);
519
+ Test\Helper::assertPrintable($result);
520
+ $this->assertEquals(true, $result->success);
521
+ $customer = $result->customer;
522
+ $this->assertEquals('Mike', $customer->firstName);
523
+ $this->assertEquals('Jones', $customer->lastName);
524
+ $this->assertEquals('Jones Co.', $customer->company);
525
+ $this->assertEquals('mike.jones@example.com', $customer->email);
526
+ $this->assertEquals('419.555.1234', $customer->phone);
527
+ $this->assertEquals('419.555.1235', $customer->fax);
528
+ $this->assertEquals('http://example.com', $customer->website);
529
+ $creditCard = $customer->creditCards[0];
530
+ $this->assertEquals('510510', $creditCard->bin);
531
+ $this->assertEquals('5100', $creditCard->last4);
532
+ $this->assertEquals('Mike Jones', $creditCard->cardholderName);
533
+ $this->assertEquals('05/2012', $creditCard->expirationDate);
534
+ $this->assertEquals('05', $creditCard->expirationMonth);
535
+ $this->assertEquals('2012', $creditCard->expirationYear);
536
+ $address = $customer->addresses[0];
537
+ $this->assertEquals($address, $creditCard->billingAddress);
538
+ $this->assertEquals('Drew', $address->firstName);
539
+ $this->assertEquals('Smith', $address->lastName);
540
+ $this->assertEquals('Smith Co.', $address->company);
541
+ $this->assertEquals('1 E Main St', $address->streetAddress);
542
+ $this->assertEquals('Suite 101', $address->extendedAddress);
543
+ $this->assertEquals('Chicago', $address->locality);
544
+ $this->assertEquals('IL', $address->region);
545
+ $this->assertEquals('60622', $address->postalCode);
546
+ $this->assertEquals('United States of America', $address->countryName);
547
+ }
548
+
549
+ public function testCreate_withValidationErrors()
550
+ {
551
+ $result = Braintree\Customer::create([
552
+ 'email' => 'invalid',
553
+ 'creditCard' => [
554
+ 'number' => 'invalid',
555
+ 'billingAddress' => [
556
+ 'streetAddress' => str_repeat('x', 256)
557
+ ]
558
+ ]
559
+ ]);
560
+ Test\Helper::assertPrintable($result);
561
+ $this->assertEquals(false, $result->success);
562
+ $errors = $result->errors->forKey('customer')->onAttribute('email');
563
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code);
564
+ $errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('number');
565
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code);
566
+ $errors = $result->errors->forKey('customer')->forKey('creditCard')->forKey('billingAddress')->onAttribute('streetAddress');
567
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_STREET_ADDRESS_IS_TOO_LONG, $errors[0]->code);
568
+ }
569
+
570
+ public function testCreate_countryValidations_inconsistency()
571
+ {
572
+ $result = Braintree\Customer::create([
573
+ 'creditCard' => [
574
+ 'billingAddress' => [
575
+ 'countryName' => 'Georgia',
576
+ 'countryCodeAlpha2' => 'TF'
577
+ ]
578
+ ]
579
+ ]);
580
+ $this->assertEquals(false, $result->success);
581
+ $errors = $result->errors->forKey('customer')->forKey('creditCard')->forKey('billingAddress')->onAttribute('base');
582
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_INCONSISTENT_COUNTRY, $errors[0]->code);
583
+ }
584
+
585
+ public function testCreateNoValidate_returnsCustomer()
586
+ {
587
+ $customer = Braintree\Customer::createNoValidate([
588
+ 'firstName' => 'Paul',
589
+ 'lastName' => 'Martin'
590
+ ]);
591
+ $this->assertEquals('Paul', $customer->firstName);
592
+ $this->assertEquals('Martin', $customer->lastName);
593
+ }
594
+
595
+ public function testCreateNoValidate_throwsIfInvalid()
596
+ {
597
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed');
598
+ $customer = Braintree\Customer::createNoValidate(['email' => 'invalid']);
599
+ }
600
+
601
+ public function testCreate_worksWithFuturePayPalNonce()
602
+ {
603
+ $nonce = Braintree\Test\Nonces::$paypalFuturePayment;
604
+
605
+ $result = Braintree\Customer::create([
606
+ 'paymentMethodNonce' => $nonce
607
+ ]);
608
+
609
+ $this->assertTrue($result->success);
610
+ }
611
+
612
+ public function testCreate_doesNotWorkWithOnetimePayPalNonce()
613
+ {
614
+ $nonce = Braintree\Test\Nonces::$paypalOneTimePayment;
615
+
616
+ $result = Braintree\Customer::create([
617
+ 'paymentMethodNonce' => $nonce
618
+ ]);
619
+
620
+ $this->assertFalse($result->success);
621
+ $errors = $result->errors->forKey('customer')->forKey('paypalAccount')->errors;
622
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code);
623
+ }
624
+
625
+ public function testDelete_deletesTheCustomer()
626
+ {
627
+ $result = Braintree\Customer::create([]);
628
+ $this->assertEquals(true, $result->success);
629
+ Braintree\Customer::find($result->customer->id);
630
+ Braintree\Customer::delete($result->customer->id);
631
+ $this->setExpectedException('Braintree\Exception\NotFound');
632
+ Braintree\Customer::find($result->customer->id);
633
+ }
634
+
635
+ public function testFind()
636
+ {
637
+ $result = Braintree\Customer::create([
638
+ 'firstName' => 'Mike',
639
+ 'lastName' => 'Jones',
640
+ 'company' => 'Jones Co.',
641
+ 'email' => 'mike.jones@example.com',
642
+ 'phone' => '419.555.1234',
643
+ 'fax' => '419.555.1235',
644
+ 'website' => 'http://example.com'
645
+ ]);
646
+ $this->assertEquals(true, $result->success);
647
+ $customer = Braintree\Customer::find($result->customer->id);
648
+ $this->assertEquals('Mike', $customer->firstName);
649
+ $this->assertEquals('Jones', $customer->lastName);
650
+ $this->assertEquals('Jones Co.', $customer->company);
651
+ $this->assertEquals('mike.jones@example.com', $customer->email);
652
+ $this->assertEquals('419.555.1234', $customer->phone);
653
+ $this->assertEquals('419.555.1235', $customer->fax);
654
+ $this->assertEquals('http://example.com', $customer->website);
655
+ }
656
+
657
+ public function testFind_throwsExceptionIfNotFound()
658
+ {
659
+ $this->setExpectedException('Braintree\Exception\NotFound');
660
+ Braintree\Customer::find("does-not-exist");
661
+ }
662
+
663
+ public function testUpdate()
664
+ {
665
+ $result = Braintree\Customer::create([
666
+ 'firstName' => 'Old First',
667
+ 'lastName' => 'Old Last',
668
+ 'company' => 'Old Company',
669
+ 'email' => 'old.email@example.com',
670
+ 'phone' => 'old phone',
671
+ 'fax' => 'old fax',
672
+ 'website' => 'http://old.example.com'
673
+ ]);
674
+ $this->assertEquals(true, $result->success);
675
+ $customer = $result->customer;
676
+ $updateResult = Braintree\Customer::update($customer->id, [
677
+ 'firstName' => 'New First',
678
+ 'lastName' => 'New Last',
679
+ 'company' => 'New Company',
680
+ 'email' => 'new.email@example.com',
681
+ 'phone' => 'new phone',
682
+ 'fax' => 'new fax',
683
+ 'website' => 'http://new.example.com'
684
+ ]);
685
+ $this->assertEquals(true, $updateResult->success);
686
+ $this->assertEquals('New First', $updateResult->customer->firstName);
687
+ $this->assertEquals('New Last', $updateResult->customer->lastName);
688
+ $this->assertEquals('New Company', $updateResult->customer->company);
689
+ $this->assertEquals('new.email@example.com', $updateResult->customer->email);
690
+ $this->assertEquals('new phone', $updateResult->customer->phone);
691
+ $this->assertEquals('new fax', $updateResult->customer->fax);
692
+ $this->assertEquals('http://new.example.com', $updateResult->customer->website);
693
+ }
694
+
695
+ public function testUpdate_withCountry()
696
+ {
697
+ $customer = Braintree\Customer::create([
698
+ 'firstName' => 'Bat',
699
+ 'lastName' => 'Manderson',
700
+ 'creditCard' => [
701
+ 'number' => '5105105105105100',
702
+ 'expirationDate' => '05/12',
703
+ 'billingAddress' => [
704
+ 'countryName' => 'United States of America',
705
+ 'countryCodeAlpha2' => 'US',
706
+ 'countryCodeAlpha3' => 'USA',
707
+ 'countryCodeNumeric' => '840'
708
+ ]
709
+ ]
710
+ ])->customer;
711
+
712
+ $result = Braintree\Customer::update($customer->id, [
713
+ 'firstName' => 'Bat',
714
+ 'lastName' => 'Manderson',
715
+ 'creditCard' => [
716
+ 'options' => [
717
+ 'updateExistingToken' => $customer->creditCards[0]->token
718
+ ],
719
+ 'billingAddress' => [
720
+ 'countryName' => 'Gabon',
721
+ 'countryCodeAlpha2' => 'GA',
722
+ 'countryCodeAlpha3' => 'GAB',
723
+ 'countryCodeNumeric' => '266',
724
+ 'options' => [
725
+ 'updateExisting' => true
726
+ ]
727
+ ]
728
+ ]
729
+ ]);
730
+
731
+ $this->assertEquals(true, $result->success);
732
+ $updatedCustomer = $result->customer;
733
+ $this->assertEquals('Gabon', $updatedCustomer->creditCards[0]->billingAddress->countryName);
734
+ $this->assertEquals('GA', $updatedCustomer->creditCards[0]->billingAddress->countryCodeAlpha2);
735
+ $this->assertEquals('GAB', $updatedCustomer->creditCards[0]->billingAddress->countryCodeAlpha3);
736
+ $this->assertEquals('266', $updatedCustomer->creditCards[0]->billingAddress->countryCodeNumeric);
737
+ }
738
+
739
+ public function testUpdate_withUpdatingExistingCreditCard()
740
+ {
741
+ $create_result = Braintree\Customer::create([
742
+ 'firstName' => 'Old First',
743
+ 'lastName' => 'Old Last',
744
+ 'website' => 'http://old.example.com',
745
+ 'creditCard' => [
746
+ 'number' => '5105105105105100',
747
+ 'expirationDate' => '05/12',
748
+ 'cardholderName' => 'Old Cardholder'
749
+ ]
750
+ ]);
751
+ $this->assertEquals(true, $create_result->success);
752
+ $customer = $create_result->customer;
753
+ $creditCard = $customer->creditCards[0];
754
+ $result = Braintree\Customer::update($customer->id, [
755
+ 'firstName' => 'New First',
756
+ 'lastName' => 'New Last',
757
+ 'creditCard' => [
758
+ 'number' => '4111111111111111',
759
+ 'expirationDate' => '11/14',
760
+ 'cardholderName' => 'New Cardholder',
761
+ 'options' => [
762
+ 'updateExistingToken' => $creditCard->token
763
+ ]
764
+ ]
765
+ ]);
766
+ $this->assertEquals(true, $result->success);
767
+ $this->assertEquals('New First', $result->customer->firstName);
768
+ $this->assertEquals('New Last', $result->customer->lastName);
769
+ $this->assertEquals(1, sizeof($result->customer->creditCards));
770
+ $creditCard = $result->customer->creditCards[0];
771
+ $this->assertEquals('411111', $creditCard->bin);
772
+ $this->assertEquals('11/2014', $creditCard->expirationDate);
773
+ $this->assertEquals('New Cardholder', $creditCard->cardholderName);
774
+ }
775
+
776
+ public function testUpdate_failOnDuplicatePaymentMethod()
777
+ {
778
+ $create_result = Braintree\Customer::create([
779
+ 'creditCard' => [
780
+ 'number' => '4111111111111111',
781
+ 'expirationDate' => '11/14',
782
+ ]
783
+ ]);
784
+ $this->assertEquals(true, $create_result->success);
785
+ $result = Braintree\Customer::update($create_result->customer->id, [
786
+ 'creditCard' => [
787
+ 'number' => '4111111111111111',
788
+ 'expirationDate' => '11/14',
789
+ 'options' => [
790
+ 'failOnDuplicatePaymentMethod' => true
791
+ ]
792
+ ]
793
+ ]);
794
+ $this->assertFalse($result->success);
795
+ $errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('number');
796
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_DUPLICATE_CARD_EXISTS, $errors[0]->code);
797
+ $this->assertEquals(1, preg_match('/Duplicate card exists in the vault\./', $result->message));
798
+ }
799
+
800
+ public function testUpdate_forBillingAddressAndExistingCreditCardAndCustomerDetailsTogether()
801
+ {
802
+ $create_result = Braintree\Customer::create([
803
+ 'firstName' => 'Old First',
804
+ 'lastName' => 'Old Last',
805
+ 'creditCard' => [
806
+ 'number' => '5105105105105100',
807
+ 'expirationDate' => '05/12',
808
+ 'cvv' => '123',
809
+ 'cardholderName' => 'Old Cardholder',
810
+ 'billingAddress' => [
811
+ 'firstName' => 'Drew',
812
+ 'lastName' => 'Smith'
813
+ ]
814
+ ]
815
+ ]);
816
+ $this->assertEquals(true, $create_result->success);
817
+ $customer = $create_result->customer;
818
+ $creditCard = $customer->creditCards[0];
819
+ $result = Braintree\Customer::update($customer->id, [
820
+ 'firstName' => 'New Customer First',
821
+ 'lastName' => 'New Customer Last',
822
+ 'creditCard' => [
823
+ 'number' => '4111111111111111',
824
+ 'expirationDate' => '11/14',
825
+ 'options' => [
826
+ 'updateExistingToken' => $creditCard->token
827
+ ],
828
+ 'billingAddress' => [
829
+ 'firstName' => 'New Billing First',
830
+ 'lastName' => 'New Billing Last',
831
+ 'options' => [
832
+ 'updateExisting' => true
833
+ ]
834
+ ]
835
+ ]
836
+ ]);
837
+ $this->assertEquals(true, $result->success);
838
+ $this->assertEquals('New Customer First', $result->customer->firstName);
839
+ $this->assertEquals('New Customer Last', $result->customer->lastName);
840
+ $this->assertEquals(1, sizeof($result->customer->creditCards));
841
+ $this->assertEquals(1, sizeof($result->customer->addresses));
842
+
843
+ $creditCard = $result->customer->creditCards[0];
844
+ $this->assertEquals('411111', $creditCard->bin);
845
+ $this->assertEquals('11/2014', $creditCard->expirationDate);
846
+
847
+ $billingAddress = $creditCard->billingAddress;
848
+ $this->assertEquals('New Billing First', $billingAddress->firstName);
849
+ $this->assertEquals('New Billing Last', $billingAddress->lastName);
850
+ }
851
+
852
+ public function testUpdate_withNewCreditCardAndExistingBillingAddress()
853
+ {
854
+ $customer = Braintree\Customer::create()->customer;
855
+ $address = Braintree\Address::create([
856
+ 'customerId' => $customer->id,
857
+ 'firstName' => 'Dan'
858
+ ])->address;
859
+
860
+ $result = Braintree\Customer::update($customer->id, [
861
+ 'creditCard' => [
862
+ 'number' => '4111111111111111',
863
+ 'expirationDate' => '11/14',
864
+ 'billingAddressId' => $address->id
865
+ ]
866
+ ]);
867
+
868
+ $billingAddress = $result->customer->creditCards[0]->billingAddress;
869
+ $this->assertEquals($address->id, $billingAddress->id);
870
+ $this->assertEquals('Dan', $billingAddress->firstName);
871
+ }
872
+
873
+ public function testUpdate_withNewCreditCardAndVerificationAmount()
874
+ {
875
+ $customer = Braintree\Customer::create()->customer;
876
+ $result = Braintree\Customer::update($customer->id, [
877
+ 'creditCard' => [
878
+ 'number' => '4111111111111111',
879
+ 'expirationDate' => '11/14',
880
+ 'options' => [
881
+ 'verifyCard' => true,
882
+ 'verificationAmount' => '2.00'
883
+ ]
884
+ ]
885
+ ]);
886
+
887
+ $this->assertTrue($result->success);
888
+ }
889
+
890
+ public function testUpdate_worksWithFuturePayPalNonce()
891
+ {
892
+ $customerResult = Braintree\Customer::create([
893
+ 'creditCard' => [
894
+ 'number' => '5105105105105100',
895
+ 'expirationDate' => '05/12',
896
+ 'options' => [
897
+ 'makeDefault' => true
898
+ ]
899
+ ]
900
+ ]);
901
+ $paypalAccountToken = 'PAYPALToken-' . strval(rand());
902
+ $http = new HttpClientApi(Braintree\Configuration::$global);
903
+ $nonce = $http->nonceForPayPalAccount([
904
+ 'paypal_account' => [
905
+ 'consent_code' => 'PAYPAL_CONSENT_CODE',
906
+ 'token' => $paypalAccountToken,
907
+ 'options' => [
908
+ 'makeDefault' => true
909
+ ]
910
+ ]
911
+ ]);
912
+
913
+ $result = Braintree\Customer::update($customerResult->customer->id, [
914
+ 'paymentMethodNonce' => $nonce
915
+ ]);
916
+
917
+ $this->assertTrue($result->success);
918
+ $this->assertEquals($result->customer->defaultPaymentMethod()->token, $paypalAccountToken);
919
+
920
+ }
921
+
922
+ public function testUpdateDefaultPaymentMethod()
923
+ {
924
+ $result = Braintree\Customer::create([
925
+ 'firstName' => 'Old First',
926
+ 'lastName' => 'Old Last',
927
+ ]);
928
+
929
+ $this->assertEquals(true, $result->success);
930
+ $customer = $result->customer;
931
+
932
+ $token1 = 'TOKEN-' . strval(rand());
933
+
934
+ $result = Braintree\PaymentMethod::create([
935
+ 'customerId' => $customer->id,
936
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$transactableVisa,
937
+ 'token' => $token1
938
+ ]);
939
+
940
+ $updateResult = Braintree\Customer::update($customer->id, [
941
+ 'defaultPaymentMethodToken' => $token1
942
+ ]);
943
+
944
+ $this->assertEquals(true, $updateResult->success);
945
+ $this->assertEquals($updateResult->customer->defaultPaymentMethod()->token, $token1);
946
+
947
+ $token2 = 'TOKEN-' . strval(rand());
948
+
949
+ $result = Braintree\PaymentMethod::create([
950
+ 'customerId' => $customer->id,
951
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$transactableMasterCard,
952
+ 'token' => $token2
953
+ ]);
954
+
955
+ $updateResult = Braintree\Customer::update($customer->id, [
956
+ 'defaultPaymentMethodToken' => $token2
957
+ ]);
958
+
959
+ $this->assertEquals(true, $updateResult->success);
960
+ $this->assertEquals($updateResult->customer->defaultPaymentMethod()->token, $token2);
961
+ }
962
+
963
+
964
+ public function testUpdateDefaultPaymentMethodFromOptions()
965
+ {
966
+ $result = Braintree\Customer::create([
967
+ 'firstName' => 'Old First',
968
+ 'lastName' => 'Old Last',
969
+ ]);
970
+
971
+ $this->assertEquals(true, $result->success);
972
+ $customer = $result->customer;
973
+
974
+ $token1 = 'TOKEN-' . strval(rand());
975
+
976
+ $result = Braintree\PaymentMethod::create([
977
+ 'customerId' => $customer->id,
978
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$transactableVisa,
979
+ 'token' => $token1
980
+ ]);
981
+
982
+ $updateResult = Braintree\Customer::update($customer->id, [
983
+ 'creditCard' => [
984
+ 'options' => [
985
+ 'updateExistingToken' => $token1,
986
+ 'makeDefault' => true
987
+ ]
988
+ ]
989
+ ]);
990
+
991
+ $this->assertEquals(true, $updateResult->success);
992
+ $this->assertEquals($updateResult->customer->defaultPaymentMethod()->token, $token1);
993
+
994
+ $token2 = 'TOKEN-' . strval(rand());
995
+
996
+ $result = Braintree\PaymentMethod::create([
997
+ 'customerId' => $customer->id,
998
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$transactableMasterCard,
999
+ 'token' => $token2
1000
+ ]);
1001
+
1002
+ $updateResult = Braintree\Customer::update($customer->id, [
1003
+ 'creditCard' => [
1004
+ 'options' => [
1005
+ 'updateExistingToken' => $token2,
1006
+ 'makeDefault' => true
1007
+ ]
1008
+ ]
1009
+ ]);
1010
+
1011
+ $this->assertEquals(true, $updateResult->success);
1012
+ $this->assertEquals($updateResult->customer->defaultPaymentMethod()->token, $token2);
1013
+ }
1014
+ public function testUpdate_doesNotWorkWithOnetimePayPalNonce()
1015
+ {
1016
+ $customerResult = Braintree\Customer::create([
1017
+ 'creditCard' => [
1018
+ 'number' => '5105105105105100',
1019
+ 'expirationDate' => '05/12',
1020
+ 'options' => [
1021
+ 'makeDefault' => true
1022
+ ]
1023
+ ]
1024
+ ]);
1025
+ $paypalAccountToken = 'PAYPALToken-' . strval(rand());
1026
+ $http = new HttpClientApi(Braintree\Configuration::$global);
1027
+ $nonce = $http->nonceForPayPalAccount([
1028
+ 'paypal_account' => [
1029
+ 'access_token' => 'PAYPAL_ACCESS_TOKEN',
1030
+ 'token' => $paypalAccountToken,
1031
+ 'options' => [
1032
+ 'makeDefault' => true
1033
+ ]
1034
+ ]
1035
+ ]);
1036
+
1037
+ $result = Braintree\Customer::update($customerResult->customer->id, [
1038
+ 'paymentMethodNonce' => $nonce
1039
+ ]);
1040
+
1041
+ $this->assertFalse($result->success);
1042
+ $errors = $result->errors->forKey('customer')->forKey('paypalAccount')->errors;
1043
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code);
1044
+
1045
+ }
1046
+
1047
+ public function testUpdateNoValidate()
1048
+ {
1049
+ $result = Braintree\Customer::create([
1050
+ 'firstName' => 'Old First',
1051
+ 'lastName' => 'Old Last',
1052
+ 'company' => 'Old Company',
1053
+ 'email' => 'old.email@example.com',
1054
+ 'phone' => 'old phone',
1055
+ 'fax' => 'old fax',
1056
+ 'website' => 'http://old.example.com'
1057
+ ]);
1058
+ $this->assertEquals(true, $result->success);
1059
+ $customer = $result->customer;
1060
+ $updated = Braintree\Customer::updateNoValidate($customer->id, [
1061
+ 'firstName' => 'New First',
1062
+ 'lastName' => 'New Last',
1063
+ 'company' => 'New Company',
1064
+ 'email' => 'new.email@example.com',
1065
+ 'phone' => 'new phone',
1066
+ 'fax' => 'new fax',
1067
+ 'website' => 'http://new.example.com'
1068
+ ]);
1069
+ $this->assertEquals('New First', $updated->firstName);
1070
+ $this->assertEquals('New Last', $updated->lastName);
1071
+ $this->assertEquals('New Company', $updated->company);
1072
+ $this->assertEquals('new.email@example.com', $updated->email);
1073
+ $this->assertEquals('new phone', $updated->phone);
1074
+ $this->assertEquals('new fax', $updated->fax);
1075
+ $this->assertEquals('http://new.example.com', $updated->website);
1076
+ }
1077
+
1078
+ public function testCreateFromTransparentRedirect()
1079
+ {
1080
+ Test\Helper::suppressDeprecationWarnings();
1081
+ $queryString = $this->createCustomerViaTr(
1082
+ [
1083
+ 'customer' => [
1084
+ 'first_name' => 'Joe',
1085
+ 'last_name' => 'Martin',
1086
+ 'credit_card' => [
1087
+ 'number' => '5105105105105100',
1088
+ 'expiration_date' => '05/12'
1089
+ ]
1090
+ ]
1091
+ ],
1092
+ [
1093
+ ]
1094
+ );
1095
+ $result = Braintree\Customer::createFromTransparentRedirect($queryString);
1096
+ $this->assertTrue($result->success);
1097
+ $this->assertEquals('Joe', $result->customer->firstName);
1098
+ $this->assertEquals('Martin', $result->customer->lastName);
1099
+ $creditCard = $result->customer->creditCards[0];
1100
+ $this->assertEquals('510510', $creditCard->bin);
1101
+ $this->assertEquals('5100', $creditCard->last4);
1102
+ $this->assertEquals('05/2012', $creditCard->expirationDate);
1103
+ }
1104
+
1105
+ public function testCreateFromTransparentRedirect_withParamsInTrData()
1106
+ {
1107
+ Test\Helper::suppressDeprecationWarnings();
1108
+ $queryString = $this->createCustomerViaTr(
1109
+ [
1110
+ ],
1111
+ [
1112
+ 'customer' => [
1113
+ 'firstName' => 'Joe',
1114
+ 'lastName' => 'Martin',
1115
+ 'creditCard' => [
1116
+ 'number' => '5105105105105100',
1117
+ 'expirationDate' => '05/12'
1118
+ ]
1119
+ ]
1120
+ ]
1121
+ );
1122
+ $result = Braintree\Customer::createFromTransparentRedirect($queryString);
1123
+ $this->assertTrue($result->success);
1124
+ $this->assertEquals('Joe', $result->customer->firstName);
1125
+ $this->assertEquals('Martin', $result->customer->lastName);
1126
+ $creditCard = $result->customer->creditCards[0];
1127
+ $this->assertEquals('510510', $creditCard->bin);
1128
+ $this->assertEquals('5100', $creditCard->last4);
1129
+ $this->assertEquals('05/2012', $creditCard->expirationDate);
1130
+ }
1131
+
1132
+ public function testCreateFromTransparentRedirect_withValidationErrors()
1133
+ {
1134
+ Test\Helper::suppressDeprecationWarnings();
1135
+ $queryString = $this->createCustomerViaTr(
1136
+ [
1137
+ 'customer' => [
1138
+ 'first_name' => str_repeat('x', 256),
1139
+ 'credit_card' => [
1140
+ 'number' => 'invalid',
1141
+ 'expiration_date' => ''
1142
+ ]
1143
+ ]
1144
+ ],
1145
+ [
1146
+ ]
1147
+ );
1148
+ $result = Braintree\Customer::createFromTransparentRedirect($queryString);
1149
+ $this->assertFalse($result->success);
1150
+ $errors = $result->errors->forKey('customer')->onAttribute('firstName');
1151
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_FIRST_NAME_IS_TOO_LONG, $errors[0]->code);
1152
+ $errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('number');
1153
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code);
1154
+ $errors = $result->errors->forKey('customer')->forKey('creditCard')->onAttribute('expirationDate');
1155
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_REQUIRED, $errors[0]->code);
1156
+ }
1157
+
1158
+ public function testCreateWithInvalidUTF8Bytes()
1159
+ {
1160
+ $result = Braintree\Customer::create([
1161
+ 'firstName' => "Jos\xe8 Maria"
1162
+ ]);
1163
+ $this->assertEquals(true, $result->success);
1164
+ $customer = $result->customer;
1165
+ $this->assertEquals("Jos\xc3\xa8 Maria", $customer->firstName);
1166
+ }
1167
+
1168
+ public function testCreateWithValidUTF8Bytes()
1169
+ {
1170
+ $result = Braintree\Customer::create([
1171
+ 'firstName' => "Jos\303\251"
1172
+ ]);
1173
+ $this->assertEquals(true, $result->success);
1174
+ $customer = $result->customer;
1175
+ $this->assertEquals("Jos\303\251", $customer->firstName);
1176
+ }
1177
+
1178
+ public function testUpdateFromTransparentRedirect()
1179
+ {
1180
+ Test\Helper::suppressDeprecationWarnings();
1181
+ $customer = Braintree\Customer::createNoValidate();
1182
+ $queryString = $this->updateCustomerViaTr(
1183
+ [
1184
+ 'customer' => [
1185
+ 'first_name' => 'Joe',
1186
+ 'last_name' => 'Martin',
1187
+ 'email' => 'joe.martin@example.com'
1188
+ ]
1189
+ ],
1190
+ [
1191
+ 'customerId' => $customer->id
1192
+ ]
1193
+ );
1194
+ $result = Braintree\Customer::updateFromTransparentRedirect($queryString);
1195
+ $this->assertTrue($result->success);
1196
+ $this->assertEquals('Joe', $result->customer->firstName);
1197
+ $this->assertEquals('Martin', $result->customer->lastName);
1198
+ $this->assertEquals('joe.martin@example.com', $result->customer->email);
1199
+ }
1200
+
1201
+ public function testUpdateFromTransparentRedirect_withParamsInTrData()
1202
+ {
1203
+ Test\Helper::suppressDeprecationWarnings();
1204
+ $customer = Braintree\Customer::createNoValidate();
1205
+ $queryString = $this->updateCustomerViaTr(
1206
+ [
1207
+ ],
1208
+ [
1209
+ 'customerId' => $customer->id,
1210
+ 'customer' => [
1211
+ 'firstName' => 'Joe',
1212
+ 'lastName' => 'Martin',
1213
+ 'email' => 'joe.martin@example.com'
1214
+ ]
1215
+ ]
1216
+ );
1217
+ $result = Braintree\Customer::updateFromTransparentRedirect($queryString);
1218
+ $this->assertTrue($result->success);
1219
+ $this->assertEquals('Joe', $result->customer->firstName);
1220
+ $this->assertEquals('Martin', $result->customer->lastName);
1221
+ $this->assertEquals('joe.martin@example.com', $result->customer->email);
1222
+ }
1223
+
1224
+ public function testUpdateFromTransparentRedirect_withValidationErrors()
1225
+ {
1226
+ Test\Helper::suppressDeprecationWarnings();
1227
+ $customer = Braintree\Customer::createNoValidate();
1228
+ $queryString = $this->updateCustomerViaTr(
1229
+ [
1230
+ 'customer' => [
1231
+ 'first_name' => str_repeat('x', 256),
1232
+ ]
1233
+ ],
1234
+ [
1235
+ 'customerId' => $customer->id
1236
+ ]
1237
+ );
1238
+ $result = Braintree\Customer::updateFromTransparentRedirect($queryString);
1239
+ $this->assertFalse($result->success);
1240
+ $errors = $result->errors->forKey('customer')->onAttribute('firstName');
1241
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_FIRST_NAME_IS_TOO_LONG, $errors[0]->code);
1242
+ }
1243
+
1244
+ public function testUpdateFromTransparentRedirect_withUpdateExisting()
1245
+ {
1246
+ Test\Helper::suppressDeprecationWarnings();
1247
+ $customer = Braintree\Customer::create([
1248
+ 'firstName' => 'Mike',
1249
+ 'lastName' => 'Jones',
1250
+ 'creditCard' => [
1251
+ 'number' => '5105105105105100',
1252
+ 'expirationDate' => '05/12',
1253
+ 'cardholderName' => 'Mike Jones',
1254
+ 'billingAddress' => [
1255
+ 'firstName' => 'Drew',
1256
+ 'lastName' => 'Smith'
1257
+ ]
1258
+ ]
1259
+ ])->customer;
1260
+
1261
+ $queryString = $this->updateCustomerViaTr(
1262
+ [],
1263
+ [
1264
+ 'customerId' => $customer->id,
1265
+ 'customer' => [
1266
+ 'firstName' => 'New First',
1267
+ 'lastName' => 'New Last',
1268
+ 'creditCard' => [
1269
+ 'number' => '4111111111111111',
1270
+ 'expirationDate' => '05/13',
1271
+ 'cardholderName' => 'New Cardholder',
1272
+ 'options' => [
1273
+ 'updateExistingToken' => $customer->creditCards[0]->token
1274
+ ],
1275
+ 'billingAddress' => [
1276
+ 'firstName' => 'New First Billing',
1277
+ 'lastName' => 'New Last Billing',
1278
+ 'options' => [
1279
+ 'updateExisting' => true
1280
+ ]
1281
+ ]
1282
+ ]
1283
+ ]
1284
+ ]
1285
+ );
1286
+ $result = Braintree\Customer::updateFromTransparentRedirect($queryString);
1287
+ $this->assertTrue($result->success);
1288
+
1289
+ $this->assertEquals(true, $result->success);
1290
+ $customer = $result->customer;
1291
+ $this->assertEquals('New First', $customer->firstName);
1292
+ $this->assertEquals('New Last', $customer->lastName);
1293
+
1294
+ $this->assertEquals(1, sizeof($result->customer->creditCards));
1295
+ $creditCard = $customer->creditCards[0];
1296
+ $this->assertEquals('411111', $creditCard->bin);
1297
+ $this->assertEquals('1111', $creditCard->last4);
1298
+ $this->assertEquals('New Cardholder', $creditCard->cardholderName);
1299
+ $this->assertEquals('05/2013', $creditCard->expirationDate);
1300
+
1301
+ $this->assertEquals(1, sizeof($result->customer->addresses));
1302
+ $address = $customer->addresses[0];
1303
+ $this->assertEquals($address, $creditCard->billingAddress);
1304
+ $this->assertEquals('New First Billing', $address->firstName);
1305
+ $this->assertEquals('New Last Billing', $address->lastName);
1306
+ }
1307
+
1308
+ public function testSale_createsASaleUsingGivenToken()
1309
+ {
1310
+ $customer = Braintree\Customer::createNoValidate([
1311
+ 'creditCard' => [
1312
+ 'number' => '5105105105105100',
1313
+ 'expirationDate' => '05/12'
1314
+ ]
1315
+ ]);
1316
+ $creditCard = $customer->creditCards[0];
1317
+ $result = Braintree\Customer::sale($customer->id, [
1318
+ 'amount' => '100.00'
1319
+ ]);
1320
+ $this->assertTrue($result->success);
1321
+ $this->assertEquals('100.00', $result->transaction->amount);
1322
+ $this->assertEquals($customer->id, $result->transaction->customerDetails->id);
1323
+ $this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token);
1324
+ }
1325
+
1326
+ public function testSaleNoValidate_createsASaleUsingGivenToken()
1327
+ {
1328
+ $customer = Braintree\Customer::createNoValidate([
1329
+ 'creditCard' => [
1330
+ 'number' => '5105105105105100',
1331
+ 'expirationDate' => '05/12'
1332
+ ]
1333
+ ]);
1334
+ $creditCard = $customer->creditCards[0];
1335
+ $transaction = Braintree\Customer::saleNoValidate($customer->id, [
1336
+ 'amount' => '100.00'
1337
+ ]);
1338
+ $this->assertEquals('100.00', $transaction->amount);
1339
+ $this->assertEquals($customer->id, $transaction->customerDetails->id);
1340
+ $this->assertEquals($creditCard->token, $transaction->creditCardDetails->token);
1341
+ }
1342
+
1343
+ public function testSaleNoValidate_throwsIfInvalid()
1344
+ {
1345
+ $customer = Braintree\Customer::createNoValidate([
1346
+ 'creditCard' => [
1347
+ 'number' => '5105105105105100',
1348
+ 'expirationDate' => '05/12'
1349
+ ]
1350
+ ]);
1351
+ $creditCard = $customer->creditCards[0];
1352
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed');
1353
+ Braintree\Customer::saleNoValidate($customer->id, [
1354
+ 'amount' => 'invalid'
1355
+ ]);
1356
+ }
1357
+
1358
+ public function testCredit_createsACreditUsingGivenCustomerId()
1359
+ {
1360
+ $customer = Braintree\Customer::createNoValidate([
1361
+ 'creditCard' => [
1362
+ 'number' => '5105105105105100',
1363
+ 'expirationDate' => '05/12'
1364
+ ]
1365
+ ]);
1366
+ $creditCard = $customer->creditCards[0];
1367
+ $result = Braintree\Customer::credit($customer->id, [
1368
+ 'amount' => '100.00'
1369
+ ]);
1370
+ $this->assertTrue($result->success);
1371
+ $this->assertEquals('100.00', $result->transaction->amount);
1372
+ $this->assertEquals(Braintree\Transaction::CREDIT, $result->transaction->type);
1373
+ $this->assertEquals($customer->id, $result->transaction->customerDetails->id);
1374
+ $this->assertEquals($creditCard->token, $result->transaction->creditCardDetails->token);
1375
+ }
1376
+
1377
+ public function testCreditNoValidate_createsACreditUsingGivenId()
1378
+ {
1379
+ $customer = Braintree\Customer::createNoValidate([
1380
+ 'creditCard' => [
1381
+ 'number' => '5105105105105100',
1382
+ 'expirationDate' => '05/12'
1383
+ ]
1384
+ ]);
1385
+ $creditCard = $customer->creditCards[0];
1386
+ $transaction = Braintree\Customer::creditNoValidate($customer->id, [
1387
+ 'amount' => '100.00'
1388
+ ]);
1389
+ $this->assertEquals('100.00', $transaction->amount);
1390
+ $this->assertEquals(Braintree\Transaction::CREDIT, $transaction->type);
1391
+ $this->assertEquals($customer->id, $transaction->customerDetails->id);
1392
+ $this->assertEquals($creditCard->token, $transaction->creditCardDetails->token);
1393
+ }
1394
+
1395
+ public function testCreditNoValidate_throwsIfInvalid()
1396
+ {
1397
+ $customer = Braintree\Customer::createNoValidate([
1398
+ 'creditCard' => [
1399
+ 'number' => '5105105105105100',
1400
+ 'expirationDate' => '05/12'
1401
+ ]
1402
+ ]);
1403
+ $creditCard = $customer->creditCards[0];
1404
+ $this->setExpectedException('Braintree\Exception\ValidationsFailed');
1405
+ Braintree\Customer::creditNoValidate($customer->id, [
1406
+ 'amount' => 'invalid'
1407
+ ]);
1408
+ }
1409
+
1410
+ public function createCustomerViaTr($regularParams, $trParams)
1411
+ {
1412
+ Test\Helper::suppressDeprecationWarnings();
1413
+ $trData = Braintree\TransparentRedirect::createCustomerData(
1414
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"])
1415
+ );
1416
+ return Test\Helper::submitTrRequest(
1417
+ Braintree\Customer::createCustomerUrl(),
1418
+ $regularParams,
1419
+ $trData
1420
+ );
1421
+ }
1422
+
1423
+ public function updateCustomerViaTr($regularParams, $trParams)
1424
+ {
1425
+ Test\Helper::suppressDeprecationWarnings();
1426
+ $trData = Braintree\TransparentRedirect::updateCustomerData(
1427
+ array_merge($trParams, ["redirectUrl" => "http://www.example.com"])
1428
+ );
1429
+ return Test\Helper::submitTrRequest(
1430
+ Braintree\Customer::updateCustomerUrl(),
1431
+ $regularParams,
1432
+ $trData
1433
+ );
1434
+ }
1435
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/DisbursementTest.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use DateTime;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class DisbursementTest extends Setup
11
+ {
12
+ public function testTransactions()
13
+ {
14
+ $disbursement = Braintree\Disbursement::factory([
15
+ "id" => "123456",
16
+ "merchantAccount" => [
17
+ "id" => "sandbox_sub_merchant_account",
18
+ "masterMerchantAccount" => [
19
+ "id" => "sandbox_master_merchant_account",
20
+ "status" => "active"
21
+ ],
22
+ "status" => "active"
23
+ ],
24
+ "transactionIds" => ["sub_merchant_transaction"],
25
+ "exceptionMessage" => "invalid_account_number",
26
+ "amount" => "100.00",
27
+ "disbursementDate" => new DateTime("2013-04-10"),
28
+ "followUpAction" => "update",
29
+ "retry" => false,
30
+ "success" => false
31
+ ]);
32
+
33
+ $transactions = $disbursement->transactions();
34
+
35
+ $this->assertNotNull($transactions);
36
+ $this->assertEquals(sizeOf($transactions), 1);
37
+ $this->assertEquals($transactions->firstItem()->id, 'sub_merchant_transaction');
38
+ }
39
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/DiscountTest.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class DiscountTest extends Setup
10
+ {
11
+ public function testAll_returnsAllDiscounts()
12
+ {
13
+ $newId = strval(rand());
14
+
15
+ $discountParams = [
16
+ "amount" => "100.00",
17
+ "description" => "some description",
18
+ "id" => $newId,
19
+ "kind" => "discount",
20
+ "name" => "php_discount",
21
+ "neverExpires" => "false",
22
+ "numberOfBillingCycles" => "1"
23
+ ];
24
+
25
+ $http = new Braintree\Http(Braintree\Configuration::$global);
26
+ $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests";
27
+ $http->post($path, ["modification" => $discountParams]);
28
+
29
+ $discounts = Braintree\Discount::all();
30
+
31
+ foreach ($discounts as $discount)
32
+ {
33
+ if ($discount->id == $newId)
34
+ {
35
+ $actualDiscount = $discount;
36
+ }
37
+ }
38
+
39
+ $this->assertNotNull($actualDiscount);
40
+ $this->assertEquals($discountParams["amount"], $actualDiscount->amount);
41
+ $this->assertEquals($discountParams["description"], $actualDiscount->description);
42
+ $this->assertEquals($discountParams["id"], $actualDiscount->id);
43
+ $this->assertEquals($discountParams["kind"], $actualDiscount->kind);
44
+ $this->assertEquals($discountParams["name"], $actualDiscount->name);
45
+ $this->assertFalse($actualDiscount->neverExpires);
46
+ $this->assertEquals($discountParams["numberOfBillingCycles"], $actualDiscount->numberOfBillingCycles);
47
+ }
48
+
49
+ public function testGatewayAll_returnsAllDiscounts()
50
+ {
51
+ $newId = strval(rand());
52
+
53
+ $discountParams = [
54
+ "amount" => "100.00",
55
+ "description" => "some description",
56
+ "id" => $newId,
57
+ "kind" => "discount",
58
+ "name" => "php_discount",
59
+ "neverExpires" => "false",
60
+ "numberOfBillingCycles" => "1"
61
+ ];
62
+
63
+ $http = new Braintree\Http(Braintree\Configuration::$global);
64
+ $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests";
65
+ $http->post($path, ["modification" => $discountParams]);
66
+
67
+ $gateway = new Braintree\Gateway([
68
+ 'environment' => 'development',
69
+ 'merchantId' => 'integration_merchant_id',
70
+ 'publicKey' => 'integration_public_key',
71
+ 'privateKey' => 'integration_private_key'
72
+ ]);
73
+ $discounts = $gateway->discount()->all();
74
+
75
+ foreach ($discounts as $discount)
76
+ {
77
+ if ($discount->id == $newId)
78
+ {
79
+ $actualDiscount = $discount;
80
+ }
81
+ }
82
+
83
+ $this->assertNotNull($actualDiscount);
84
+ $this->assertEquals($discountParams["amount"], $actualDiscount->amount);
85
+ $this->assertEquals($discountParams["id"], $actualDiscount->id);
86
+ $this->assertEquals($discountParams["kind"], $actualDiscount->kind);
87
+ }
88
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/Error/ErrorCollectionTest.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration\Error;
3
+
4
+ require_once dirname(dirname(__DIR__)) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class ErrorCollectionTest extends Setup
10
+ {
11
+ public function testDeepSize_withNestedErrors()
12
+ {
13
+ $result = Braintree\Customer::create([
14
+ 'email' => 'invalid',
15
+ 'creditCard' => [
16
+ 'number' => 'invalid',
17
+ 'expirationDate' => 'invalid',
18
+ 'billingAddress' => [
19
+ 'countryName' => 'invaild'
20
+ ]
21
+ ]
22
+ ]);
23
+ $this->assertEquals(false, $result->success);
24
+ $this->assertEquals(4, $result->errors->deepSize());
25
+ }
26
+
27
+ public function testOnHtmlField()
28
+ {
29
+ $result = Braintree\Customer::create([
30
+ 'email' => 'invalid',
31
+ 'creditCard' => [
32
+ 'number' => 'invalid',
33
+ 'expirationDate' => 'invalid',
34
+ 'billingAddress' => [
35
+ 'countryName' => 'invaild'
36
+ ]
37
+ ]
38
+ ]);
39
+ $this->assertEquals(false, $result->success);
40
+ $errors = $result->errors->onHtmlField('customer[email]');
41
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code);
42
+ $errors = $result->errors->onHtmlField('customer[credit_card][number]');
43
+ $this->assertEquals(Braintree\Error\Codes::CREDIT_CARD_NUMBER_INVALID_LENGTH, $errors[0]->code);
44
+ $errors = $result->errors->onHtmlField('customer[credit_card][billing_address][country_name]');
45
+ $this->assertEquals(Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED, $errors[0]->code);
46
+ }
47
+
48
+ public function testOnHtmlField_returnsEmptyArrayIfNone()
49
+ {
50
+ $result = Braintree\Customer::create([
51
+ 'email' => 'invalid',
52
+ 'creditCard' => [
53
+ 'number' => '5105105105105100',
54
+ 'expirationDate' => '05/12',
55
+ 'billingAddress' => [
56
+ 'streetAddress' => '1 E Main St'
57
+ ]
58
+ ]
59
+ ]);
60
+ $this->assertEquals(false, $result->success);
61
+ $errors = $result->errors->onHtmlField('customer[email]');
62
+ $this->assertEquals(Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID, $errors[0]->code);
63
+ $this->assertEquals([], $result->errors->onHtmlField('customer[credit_card][number]'));
64
+ $this->assertEquals([], $result->errors->onHtmlField('customer[credit_card][billing_address][country_name]'));
65
+ }
66
+
67
+ public function testOnHtmlField_returnsEmptyForCustomFieldsIfNoErrors()
68
+ {
69
+ $result = Braintree\Customer::create([
70
+ 'email' => 'invalid',
71
+ 'creditCard' => [
72
+ 'number' => '5105105105105100',
73
+ 'expirationDate' => '05/12',
74
+ ],
75
+ 'customFields' => ['storeMe' => 'value']
76
+ ]);
77
+ $this->assertEquals(false, $result->success);
78
+ $this->assertEquals([], $result->errors->onHtmlField('customer[custom_fields][store_me]'));
79
+ }
80
+
81
+ public function testCount_returnsTheNumberOfErrors()
82
+ {
83
+ $result = Braintree\Customer::create([
84
+ 'email' => 'invalid',
85
+ 'creditCard' => [
86
+ 'number' => 'invalid',
87
+ 'expirationDate' => 'invalid',
88
+ 'billingAddress' => [
89
+ 'countryName' => 'invaild'
90
+ ]
91
+ ]
92
+ ]);
93
+ $this->assertEquals(false, $result->success);
94
+ $this->assertEquals(4, count($result->errors));
95
+ }
96
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/Error/ValidationErrorCollectionTest.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration\Error;
3
+
4
+ require_once dirname(dirname(__DIR__)) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class ValidationErrorCollectionTest extends Setup
10
+ {
11
+ public function mapValidationErrorsToCodes($validationErrors)
12
+ {
13
+ $codes = array_map(create_function('$validationError', 'return $validationError->code;'), $validationErrors);
14
+ sort($codes);
15
+ return $codes;
16
+ }
17
+
18
+ public function test_shallowAll_givesAllErrorsShallowly()
19
+ {
20
+ $result = Braintree\Customer::create([
21
+ 'email' => 'invalid',
22
+ 'creditCard' => [
23
+ 'number' => '1234123412341234',
24
+ 'expirationDate' => 'invalid',
25
+ 'billingAddress' => [
26
+ 'countryName' => 'invalid'
27
+ ]
28
+ ]
29
+ ]);
30
+
31
+ $this->assertEquals([], $result->errors->shallowAll());
32
+
33
+ $expectedCustomerErrors = [Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID];
34
+ $actualCustomerErrors = $result->errors->forKey('customer')->shallowAll();
35
+ $this->assertEquals($expectedCustomerErrors, self::mapValidationErrorsToCodes($actualCustomerErrors));
36
+
37
+ $expectedCreditCardErrors = [
38
+ Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID,
39
+ Braintree\Error\Codes::CREDIT_CARD_NUMBER_IS_INVALID,
40
+ ];
41
+ $actualCreditCardErrors = $result->errors->forKey('customer')->forKey('creditCard')->shallowAll();
42
+ $this->assertEquals($expectedCreditCardErrors, self::mapValidationErrorsToCodes($actualCreditCardErrors));
43
+ }
44
+
45
+ public function test_deepAll_givesAllErrorsDeeply()
46
+ {
47
+ $result = Braintree\Customer::create([
48
+ 'email' => 'invalid',
49
+ 'creditCard' => [
50
+ 'number' => '1234123412341234',
51
+ 'expirationDate' => 'invalid',
52
+ 'billingAddress' => [
53
+ 'countryName' => 'invalid'
54
+ ]
55
+ ]
56
+ ]);
57
+
58
+ $expectedErrors = [
59
+ Braintree\Error\Codes::CUSTOMER_EMAIL_IS_INVALID,
60
+ Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID,
61
+ Braintree\Error\Codes::CREDIT_CARD_NUMBER_IS_INVALID,
62
+ Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED,
63
+ ];
64
+ $actualErrors = $result->errors->deepAll();
65
+ $this->assertEquals($expectedErrors, self::mapValidationErrorsToCodes($actualErrors));
66
+
67
+ $expectedErrors = [
68
+ Braintree\Error\Codes::CREDIT_CARD_EXPIRATION_DATE_IS_INVALID,
69
+ Braintree\Error\Codes::CREDIT_CARD_NUMBER_IS_INVALID,
70
+ Braintree\Error\Codes::ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED,
71
+ ];
72
+ $actualErrors = $result->errors->forKey('customer')->forKey('creditCard')->deepAll();
73
+ $this->assertEquals($expectedErrors, self::mapValidationErrorsToCodes($actualErrors));
74
+ }
75
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/EuropeBankAccountTest.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class EuropeBankAccountTest extends Setup
10
+ {
11
+ public function testCanExchangeNonceForEuropeBankAccount()
12
+ {
13
+ $gateway = new Braintree\Gateway([
14
+ 'environment' => 'development',
15
+ 'merchantId' => 'altpay_merchant',
16
+ 'publicKey' => 'altpay_merchant_public_key',
17
+ 'privateKey' => 'altpay_merchant_private_key'
18
+ ]);
19
+
20
+ $result = $gateway->customer()->create();
21
+ $this->assertTrue($result->success);
22
+ $customer = $result->customer;
23
+ $clientApi = new HttpClientApi($gateway->config);
24
+ $nonce = $clientApi->nonceForNewEuropeanBankAccount([
25
+ "customerId" => $customer->id,
26
+ "sepa_mandate" => [
27
+ "locale" => "de-DE",
28
+ "bic" => "DEUTDEFF",
29
+ "iban" => "DE89370400440532013000",
30
+ "accountHolderName" => "Bob Holder",
31
+ "billingAddress" => [
32
+ "streetAddress" => "123 Currywurst Way",
33
+ "extendedAddress" => "Lager Suite",
34
+ "firstName" => "Wilhelm",
35
+ "lastName" => "Dix",
36
+ "locality" => "Frankfurt",
37
+ "postalCode" => "60001",
38
+ "countryCodeAlpha2" => "DE",
39
+ "region" => "Hesse"
40
+ ]
41
+ ]
42
+ ]);
43
+ $result = $gateway->paymentMethod()->create([
44
+ "customerId" => $customer->id,
45
+ "paymentMethodNonce" => $nonce
46
+ ]);
47
+
48
+ $this->assertTrue($result->success);
49
+ $paymentMethod = $result->paymentMethod;
50
+ $account = $gateway->paymentMethod()->find($paymentMethod->token);
51
+ $this->assertEquals($paymentMethod->token, $account->token);
52
+ $this->assertEquals($account->bic, "DEUTDEFF");
53
+ }
54
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/HttpClientApi.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Braintree;
7
+ use Test;
8
+
9
+ class HttpClientApi extends Braintree\Http
10
+ {
11
+ protected function _doRequest($httpVerb, $path, $requestBody = null)
12
+ {
13
+ return $this->_doUrlRequest($httpVerb, $this->_config->baseUrl() . "/merchants/" . $this->_config->getMerchantId() . $path, $requestBody);
14
+ }
15
+
16
+ public function get($path)
17
+ {
18
+ return $this->_doRequest('GET', $path);
19
+ }
20
+
21
+ public function post($path, $body = null)
22
+ {
23
+ return $this->_doRequest('POST', $path, $body);
24
+ }
25
+
26
+ public function _doUrlRequest($httpVerb, $url, $requestBody = null)
27
+ {
28
+ $curl = curl_init();
29
+ curl_setopt($curl, CURLOPT_TIMEOUT, 60);
30
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb);
31
+ curl_setopt($curl, CURLOPT_URL, $url);
32
+ curl_setopt($curl, CURLOPT_HTTPHEADER, [
33
+ 'Content-Type: application/json',
34
+ 'X-ApiVersion: ' . Braintree\Configuration::API_VERSION,
35
+ ]);
36
+ curl_setopt($curl, CURLOPT_USERPWD, $this->_config->publicKey() . ':' . $this->_config->privateKey());
37
+
38
+ if(!empty($requestBody)) {
39
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
40
+ }
41
+
42
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
43
+ $response = curl_exec($curl);
44
+ $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
45
+ curl_close($curl);
46
+ return ['status' => $httpStatus, 'body' => $response];
47
+ }
48
+
49
+ public function get_cards($options) {
50
+ $encoded_fingerprint = urlencode($options["authorization_fingerprint"]);
51
+ $url = "/client_api/v1/payment_methods.json?";
52
+ $url .= "authorizationFingerprint=" . $encoded_fingerprint;
53
+ $url .= "&sharedCustomerIdentifier=" . $options["shared_customer_identifier"];
54
+ $url .= "&sharedCustomerIdentifierType=" . $options["shared_customer_identifier_type"];
55
+
56
+ return $this->get($url);
57
+ }
58
+
59
+ public function nonce_for_new_card($options) {
60
+ $clientTokenOptions = [];
61
+ if (array_key_exists("customerId", $options)) {
62
+ $clientTokenOptions["customerId"] = $options["customerId"];
63
+ unset($options["customerId"]);
64
+ }
65
+
66
+ $clientToken = json_decode(Test\Helper::decodedClientToken($clientTokenOptions));
67
+
68
+ $options["authorization_fingerprint"] = $clientToken->authorizationFingerprint;
69
+ $options["shared_customer_identifier"] = "fake_identifier_" . rand();
70
+ $options["shared_customer_identifier_type"] = "testing";
71
+ $response = $this->post('/client_api/v1/payment_methods/credit_cards.json', json_encode($options));
72
+ if ($response["status"] == 201 || $response["status"] == 202) {
73
+ $body = json_decode($response["body"]);
74
+ return $body->creditCards[0]->nonce;
75
+ } else {
76
+ throw new Exception(var_dump($response));
77
+ }
78
+ }
79
+
80
+ public function nonceForNewEuropeanBankAccount($options) {
81
+ $clientTokenOptions = [
82
+ 'sepaMandateType' => 'business',
83
+ 'sepaMandateAcceptanceLocation' => 'Rostock, Germany'
84
+ ];
85
+
86
+ if (array_key_exists("customerId", $options)) {
87
+ $clientTokenOptions["customerId"] = $options["customerId"];
88
+ unset($options["customerId"]);
89
+ }
90
+
91
+ $gateway = new Braintree\Gateway($this->_config);
92
+
93
+ $clientToken = json_decode(base64_decode($gateway->clientToken()->generate($clientTokenOptions)));
94
+ $options["authorization_fingerprint"] = $clientToken->authorizationFingerprint;
95
+
96
+ $response = $this->post('/client_api/v1/sepa_mandates/', json_encode($options));
97
+ if ($response["status"] == 201 || $response["status"] == 202) {
98
+ $body = json_decode($response["body"]);
99
+ return $body->europeBankAccounts[0]->nonce;
100
+ } else {
101
+ throw new Exception(var_dump($response));
102
+ }
103
+ }
104
+
105
+ public function nonceForPayPalAccount($options) {
106
+ $clientToken = json_decode(Test\Helper::decodedClientToken());
107
+ $options["authorization_fingerprint"] = $clientToken->authorizationFingerprint;
108
+ $response = $this->post('/client_api/v1/payment_methods/paypal_accounts.json', json_encode($options));
109
+ if ($response["status"] == 201 || $response["status"] == 202) {
110
+ $body = json_decode($response["body"], true);
111
+ return $body["paypalAccounts"][0]["nonce"];
112
+ } else {
113
+ throw new Exception(var_dump($response));
114
+ }
115
+ }
116
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/HttpTest.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class HttpTest extends Setup
10
+ {
11
+ public function testProductionSSL()
12
+ {
13
+ try {
14
+ Braintree\Configuration::environment('production');
15
+ $this->setExpectedException('Braintree\Exception\Authentication');
16
+ $http = new Braintree\Http(Braintree\Configuration::$global);
17
+ $http->get('/');
18
+ } catch (Braintree\Exception $e) {
19
+ Braintree\Configuration::environment('development');
20
+ throw $e;
21
+ }
22
+ Braintree\Configuration::environment('development');
23
+ }
24
+
25
+ public function testSandboxSSL()
26
+ {
27
+ try {
28
+ Braintree\Configuration::environment('sandbox');
29
+ $this->setExpectedException('Braintree\Exception\Authentication');
30
+ $http = new Braintree\Http(Braintree\Configuration::$global);
31
+ $http->get('/');
32
+ } catch (Braintree\Exception $e) {
33
+ Braintree\Configuration::environment('development');
34
+ throw $e;
35
+ }
36
+ Braintree\Configuration::environment('development');
37
+ }
38
+
39
+ public function testSslError()
40
+ {
41
+ try {
42
+ Braintree\Configuration::environment('sandbox');
43
+ $this->setExpectedException('Braintree\Exception\SSLCertificate');
44
+ $http = new Braintree\Http(Braintree\Configuration::$global);
45
+ $http->_doUrlRequest('get', '/malformed_url');
46
+ } catch (Braintree\Exception $e) {
47
+ Braintree\Configuration::environment('development');
48
+ throw $e;
49
+ }
50
+ Braintree\Configuration::environment('development');
51
+ }
52
+
53
+ public function testAuthorizationWithConfig()
54
+ {
55
+ $config = new Braintree\Configuration([
56
+ 'environment' => 'development',
57
+ 'merchant_id' => 'integration_merchant_id',
58
+ 'publicKey' => 'badPublicKey',
59
+ 'privateKey' => 'badPrivateKey'
60
+ ]);
61
+
62
+ $http = new Braintree\Http($config);
63
+ $result = $http->_doUrlRequest('GET', $config->baseUrl() . '/merchants/integration_merchant_id/customers');
64
+ $this->assertEquals(401, $result['status']);
65
+ }
66
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/MerchantAccountTest.php ADDED
@@ -0,0 +1,431 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class MerchantAccountTest extends Setup
11
+ {
12
+ private static $deprecatedValidParams = [
13
+ 'applicantDetails' => [
14
+ 'companyName' => "Robot City",
15
+ 'firstName' => "Joe",
16
+ 'lastName' => "Bloggs",
17
+ 'email' => "joe@bloggs.com",
18
+ 'phone' => "555-555-5555",
19
+ 'address' => [
20
+ 'streetAddress' => "123 Credibility St.",
21
+ 'postalCode' => "60606",
22
+ 'locality' => "Chicago",
23
+ 'region' => "IL",
24
+ ],
25
+ 'dateOfBirth' => "10/9/1980",
26
+ 'ssn' => "123-00-1234",
27
+ 'taxId' => "123456789",
28
+ 'routingNumber' => "122100024",
29
+ 'accountNumber' => "43759348798"
30
+ ],
31
+ 'tosAccepted' => true,
32
+ 'masterMerchantAccountId' => "sandbox_master_merchant_account"
33
+ ];
34
+
35
+ private static $validParams = [
36
+ 'individual' => [
37
+ 'firstName' => "Joe",
38
+ 'lastName' => "Bloggs",
39
+ 'email' => "joe@bloggs.com",
40
+ 'phone' => "555-555-5555",
41
+ 'address' => [
42
+ 'streetAddress' => "123 Credibility St.",
43
+ 'postalCode' => "60606",
44
+ 'locality' => "Chicago",
45
+ 'region' => "IL",
46
+ ],
47
+ 'dateOfBirth' => "10/9/1980",
48
+ 'ssn' => "123-00-1234",
49
+ ],
50
+ 'business' => [
51
+ 'dbaName' => "Robot City",
52
+ 'legalName' => "Robot City INC",
53
+ 'taxId' => "123456789",
54
+ ],
55
+ 'funding' => [
56
+ 'routingNumber' => "122100024",
57
+ 'accountNumber' => "43759348798",
58
+ 'destination' => Braintree\MerchantAccount::FUNDING_DESTINATION_BANK,
59
+ 'descriptor' => 'Joes Bloggs MI',
60
+ ],
61
+ 'tosAccepted' => true,
62
+ 'masterMerchantAccountId' => "sandbox_master_merchant_account"
63
+ ];
64
+
65
+ public function testCreate()
66
+ {
67
+ $result = Braintree\MerchantAccount::create(self::$validParams);
68
+ $this->assertEquals(true, $result->success);
69
+ $merchantAccount = $result->merchantAccount;
70
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status);
71
+ $this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id);
72
+ }
73
+
74
+ public function testGatewayCreate()
75
+ {
76
+ $gateway = new Braintree\Gateway([
77
+ 'environment' => 'development',
78
+ 'merchantId' => 'integration_merchant_id',
79
+ 'publicKey' => 'integration_public_key',
80
+ 'privateKey' => 'integration_private_key'
81
+ ]);
82
+ $result = $gateway->merchantAccount()->create(self::$validParams);
83
+ $this->assertEquals(true, $result->success);
84
+ $merchantAccount = $result->merchantAccount;
85
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status);
86
+ $this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id);
87
+ }
88
+
89
+ public function testCreateWithDeprecatedParameters()
90
+ {
91
+ Test\Helper::suppressDeprecationWarnings();
92
+ $result = Braintree\MerchantAccount::create(self::$deprecatedValidParams);
93
+ $this->assertEquals(true, $result->success);
94
+ $merchantAccount = $result->merchantAccount;
95
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status);
96
+ $this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id);
97
+ }
98
+
99
+ public function testCreateWithId()
100
+ {
101
+ $rand = rand(1, 1000);
102
+ $subMerchantAccountId = "sub_merchant_account_id" + $rand;
103
+ $validParamsWithId = array_merge([], self::$validParams);
104
+ $validParamsWithId['id'] = $subMerchantAccountId;
105
+ $result = Braintree\MerchantAccount::create($validParamsWithId);
106
+ $this->assertEquals(true, $result->success);
107
+ $merchantAccount = $result->merchantAccount;
108
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $merchantAccount->status);
109
+ $this->assertEquals("sandbox_master_merchant_account", $merchantAccount->masterMerchantAccount->id);
110
+ $this->assertEquals("sub_merchant_account_id" + $rand, $merchantAccount->id);
111
+ }
112
+
113
+ public function testFailedCreate()
114
+ {
115
+ $result = Braintree\MerchantAccount::create([]);
116
+ $this->assertEquals(false, $result->success);
117
+ $errors = $result->errors->forKey('merchantAccount')->onAttribute('masterMerchantAccountId');
118
+ $this->assertEquals(Braintree\Error\Codes::MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_IS_REQUIRED, $errors[0]->code);
119
+ }
120
+
121
+ public function testCreateWithFundingDestination()
122
+ {
123
+ $params = array_merge([], self::$validParams);
124
+ $params['funding']['destination'] = Braintree\MerchantAccount::FUNDING_DESTINATION_BANK;
125
+ $result = Braintree\MerchantAccount::create($params);
126
+ $this->assertEquals(true, $result->success);
127
+
128
+ $params = array_merge([], self::$validParams);
129
+ $params['funding']['destination'] = Braintree\MerchantAccount::FUNDING_DESTINATION_EMAIL;
130
+ $params['funding']['email'] = "billgates@outlook.com";
131
+ $result = Braintree\MerchantAccount::create($params);
132
+ $this->assertEquals(true, $result->success);
133
+
134
+ $params = array_merge([], self::$validParams);
135
+ $params['funding']['destination'] = Braintree\MerchantAccount::FUNDING_DESTINATION_MOBILE_PHONE;
136
+ $params['funding']['mobilePhone'] = "1112224444";
137
+ $result = Braintree\MerchantAccount::create($params);
138
+ $this->assertEquals(true, $result->success);
139
+ }
140
+
141
+ public function testFind()
142
+ {
143
+ $params = array_merge([], self::$validParams);
144
+ $result = Braintree\MerchantAccount::create(self::$validParams);
145
+ $this->assertEquals(true, $result->success);
146
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_PENDING, $result->merchantAccount->status);
147
+
148
+ $id = $result->merchantAccount->id;
149
+ $merchantAccount = Braintree\MerchantAccount::find($id);
150
+
151
+ $this->assertEquals(Braintree\MerchantAccount::STATUS_ACTIVE, $merchantAccount->status);
152
+ $this->assertEquals($params['individual']['firstName'], $merchantAccount->individualDetails->firstName);
153
+ $this->assertEquals($params['individual']['lastName'], $merchantAccount->individualDetails->lastName);
154
+ }
155
+
156
+ public function testRetrievesMasterMerchantAccountCurrencyIsoCode()
157
+ {
158
+ $merchantAccount = Braintree\MerchantAccount::find("sandbox_master_merchant_account");
159
+
160
+ $this->assertEquals("USD", $merchantAccount->currencyIsoCode);
161
+ }
162
+
163
+ public function testFind_throwsIfNotFound()
164
+ {
165
+ $this->setExpectedException('Braintree\Exception\NotFound', 'merchant account with id does-not-exist not found');
166
+ Braintree\MerchantAccount::find('does-not-exist');
167
+ }
168
+
169
+ public function testUpdate()
170
+ {
171
+ $params = array_merge([], self::$validParams);
172
+ unset($params["tosAccepted"]);
173
+ unset($params["masterMerchantAccountId"]);
174
+ $params["individual"]["firstName"] = "John";
175
+ $params["individual"]["lastName"] = "Doe";
176
+ $params["individual"]["email"] = "john.doe@example.com";
177
+ $params["individual"]["dateOfBirth"] = "1970-01-01";
178
+ $params["individual"]["phone"] = "3125551234";
179
+ $params["individual"]["address"]["streetAddress"] = "123 Fake St";
180
+ $params["individual"]["address"]["locality"] = "Chicago";
181
+ $params["individual"]["address"]["region"] = "IL";
182
+ $params["individual"]["address"]["postalCode"] = "60622";
183
+ $params["business"]["dbaName"] = "James's Bloggs";
184
+ $params["business"]["legalName"] = "James's Bloggs Inc";
185
+ $params["business"]["taxId"] = "123456789";
186
+ $params["business"]["address"]["streetAddress"] = "999 Fake St";
187
+ $params["business"]["address"]["locality"] = "Miami";
188
+ $params["business"]["address"]["region"] = "FL";
189
+ $params["business"]["address"]["postalCode"] = "99999";
190
+ $params["funding"]["accountNumber"] = "43759348798";
191
+ $params["funding"]["routingNumber"] = "071000013";
192
+ $params["funding"]["email"] = "check@this.com";
193
+ $params["funding"]["mobilePhone"] = "1234567890";
194
+ $params["funding"]["destination"] = Braintree\MerchantAccount::FUNDING_DESTINATION_BANK;
195
+ $params["funding"]["descriptor"] = "Joes Bloggs FL";
196
+
197
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params);
198
+ $this->assertEquals(true, $result->success);
199
+
200
+ $updatedMerchantAccount = $result->merchantAccount;
201
+ $this->assertEquals("active", $updatedMerchantAccount->status);
202
+ $this->assertEquals("sandbox_sub_merchant_account", $updatedMerchantAccount->id);
203
+ $this->assertEquals("sandbox_master_merchant_account", $updatedMerchantAccount->masterMerchantAccount->id);
204
+ $this->assertEquals("John", $updatedMerchantAccount->individualDetails->firstName);
205
+ $this->assertEquals("Doe", $updatedMerchantAccount->individualDetails->lastName);
206
+ $this->assertEquals("john.doe@example.com", $updatedMerchantAccount->individualDetails->email);
207
+ $this->assertEquals("1970-01-01", $updatedMerchantAccount->individualDetails->dateOfBirth);
208
+ $this->assertEquals("3125551234", $updatedMerchantAccount->individualDetails->phone);
209
+ $this->assertEquals("123 Fake St", $updatedMerchantAccount->individualDetails->addressDetails->streetAddress);
210
+ $this->assertEquals("Chicago", $updatedMerchantAccount->individualDetails->addressDetails->locality);
211
+ $this->assertEquals("IL", $updatedMerchantAccount->individualDetails->addressDetails->region);
212
+ $this->assertEquals("60622", $updatedMerchantAccount->individualDetails->addressDetails->postalCode);
213
+ $this->assertEquals("James's Bloggs", $updatedMerchantAccount->businessDetails->dbaName);
214
+ $this->assertEquals("James's Bloggs Inc", $updatedMerchantAccount->businessDetails->legalName);
215
+ $this->assertEquals("123456789", $updatedMerchantAccount->businessDetails->taxId);
216
+ $this->assertEquals("999 Fake St", $updatedMerchantAccount->businessDetails->addressDetails->streetAddress);
217
+ $this->assertEquals("Miami", $updatedMerchantAccount->businessDetails->addressDetails->locality);
218
+ $this->assertEquals("FL", $updatedMerchantAccount->businessDetails->addressDetails->region);
219
+ $this->assertEquals("99999", $updatedMerchantAccount->businessDetails->addressDetails->postalCode);
220
+ $this->assertEquals("8798", $updatedMerchantAccount->fundingDetails->accountNumberLast4);
221
+ $this->assertEquals("071000013", $updatedMerchantAccount->fundingDetails->routingNumber);
222
+ $this->assertEquals("check@this.com", $updatedMerchantAccount->fundingDetails->email);
223
+ $this->assertEquals("1234567890", $updatedMerchantAccount->fundingDetails->mobilePhone);
224
+ $this->assertEquals(Braintree\MerchantAccount::FUNDING_DESTINATION_BANK, $updatedMerchantAccount->fundingDetails->destination);
225
+ $this->assertEquals("Joes Bloggs FL", $updatedMerchantAccount->fundingDetails->descriptor);
226
+ }
227
+
228
+ public function testUpdateDoesNotRequireAllFields()
229
+ {
230
+ $params = [
231
+ 'individual' => [
232
+ 'firstName' => "Joe"
233
+ ]
234
+ ];
235
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params);
236
+ $this->assertEquals(true, $result->success);
237
+ }
238
+
239
+ public function testUpdateWithBlankFields()
240
+ {
241
+ $params = [
242
+ 'individual' => [
243
+ 'firstName' => "",
244
+ 'lastName' => "",
245
+ 'email' => "",
246
+ 'phone' => "",
247
+ 'address' => [
248
+ 'streetAddress' => "",
249
+ 'postalCode' => "",
250
+ 'locality' => "",
251
+ 'region' => "",
252
+ ],
253
+ 'dateOfBirth' => "",
254
+ 'ssn' => "",
255
+ ],
256
+ 'business' => [
257
+ 'dbaName' => "",
258
+ 'legalName' => "",
259
+ 'taxId' => "",
260
+ ],
261
+ 'funding' => [
262
+ 'routingNumber' => "",
263
+ 'accountNumber' => "",
264
+ 'destination' => "",
265
+ ],
266
+ ];
267
+
268
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params);
269
+ $this->assertEquals(false, $result->success);
270
+
271
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("firstName");
272
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_REQUIRED);
273
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("lastName");
274
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_REQUIRED);
275
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("dateOfBirth");
276
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_DATE_OF_BIRTH_IS_REQUIRED);
277
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("email");
278
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_REQUIRED);
279
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("streetAddress");
280
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_REQUIRED);
281
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("postalCode");
282
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_REQUIRED);
283
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("locality");
284
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_LOCALITY_IS_REQUIRED);
285
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("region");
286
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_REQUIRED);
287
+ $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("destination");
288
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_REQUIRED);
289
+ }
290
+
291
+ public function testUpdateWithInvalidFields()
292
+ {
293
+ $params = [
294
+ "individual" => [
295
+ "firstName" => "<>",
296
+ "lastName" => "<>",
297
+ "email" => "bad",
298
+ "phone" => "999",
299
+ "address" => [
300
+ "streetAddress" => "nope",
301
+ "postalCode" => "1",
302
+ "region" => "QQ",
303
+ ],
304
+ "dateOfBirth" => "hah",
305
+ "ssn" => "12345",
306
+ ],
307
+ "business" => [
308
+ "legalName" => "``{}",
309
+ "dbaName" => "{}``",
310
+ "taxId" => "bad",
311
+ "address" => [
312
+ "streetAddress" => "nope",
313
+ "postalCode" => "1",
314
+ "region" => "QQ",
315
+ ],
316
+ ],
317
+ "funding" => [
318
+ "destination" => "MY WALLET",
319
+ "routingNumber" => "LEATHER",
320
+ "accountNumber" => "BACK POCKET",
321
+ "email" => "BILLFOLD",
322
+ "mobilePhone" => "TRIFOLD"
323
+ ],
324
+ ];
325
+
326
+
327
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params);
328
+ $this->assertEquals(false, $result->success);
329
+
330
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("firstName");
331
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_INVALID);
332
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("lastName");
333
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_INVALID);
334
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("email");
335
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_INVALID);
336
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("phone");
337
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_PHONE_IS_INVALID);
338
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("streetAddress");
339
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_INVALID);
340
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("postalCode");
341
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_INVALID);
342
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->forKey("address")->onAttribute("region");
343
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_INVALID);
344
+ $error = $result->errors->forKey("merchantAccount")->forKey("individual")->onAttribute("ssn");
345
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_INDIVIDUAL_SSN_IS_INVALID);
346
+ ;
347
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("legalName");
348
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_INVALID);
349
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("dbaName");
350
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_DBA_NAME_IS_INVALID);
351
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("taxId");
352
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_INVALID);
353
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->forKey("address")->onAttribute("streetAddress");
354
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_STREET_ADDRESS_IS_INVALID);
355
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->forKey("address")->onAttribute("postalCode");
356
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_POSTAL_CODE_IS_INVALID);
357
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->forKey("address")->onAttribute("region");
358
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_ADDRESS_REGION_IS_INVALID);
359
+
360
+ $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("destination");
361
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_INVALID);
362
+ $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("routingNumber");
363
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_ROUTING_NUMBER_IS_INVALID);
364
+ $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("accountNumber");
365
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_ACCOUNT_NUMBER_IS_INVALID);
366
+ $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("email");
367
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_INVALID);
368
+ $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("mobilePhone");
369
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_INVALID);
370
+ }
371
+
372
+ public function testUpdateWithInvalidBusinessFields()
373
+ {
374
+ $params = [
375
+ "business" => [
376
+ "legalName" => "",
377
+ "taxId" => "111223333",
378
+ ]
379
+ ];
380
+
381
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params);
382
+ $this->assertEquals(false, $result->success);
383
+
384
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("legalName");
385
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_REQUIRED_WITH_TAX_ID);
386
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("taxId");
387
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_MUST_BE_BLANK);
388
+
389
+ $params = [
390
+ "business" => [
391
+ "legalName" => "legal name",
392
+ "taxId" => "",
393
+ ]
394
+ ];
395
+
396
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params);
397
+ $this->assertEquals(false, $result->success);
398
+
399
+ $error = $result->errors->forKey("merchantAccount")->forKey("business")->onAttribute("taxId");
400
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_REQUIRED_WITH_LEGAL_NAME);
401
+ }
402
+
403
+ public function testUpdateWithInvalidFundingFields()
404
+ {
405
+ $params = [
406
+ "funding" => [
407
+ "destination" => Braintree\MerchantAccount::FUNDING_DESTINATION_EMAIL,
408
+ "email" => "",
409
+ ]
410
+ ];
411
+
412
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params);
413
+ $this->assertEquals(false, $result->success);
414
+
415
+ $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("email");
416
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_REQUIRED);
417
+
418
+ $params = [
419
+ "funding" => [
420
+ "destination" => Braintree\MerchantAccount::FUNDING_DESTINATION_MOBILE_PHONE,
421
+ "mobilePhone" => "",
422
+ ]
423
+ ];
424
+
425
+ $result = Braintree\MerchantAccount::update("sandbox_sub_merchant_account", $params);
426
+ $this->assertEquals(false, $result->success);
427
+
428
+ $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("mobilePhone");
429
+ $this->assertEquals($error[0]->code, Braintree\Error\Codes::MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_REQUIRED);
430
+ }
431
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/MerchantTest.php ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class MerchantTest extends Setup
11
+ {
12
+ public function testCreateMerchant()
13
+ {
14
+ $gateway = new Braintree\Gateway([
15
+ 'clientId' => 'client_id$development$integration_client_id',
16
+ 'clientSecret' => 'client_secret$development$integration_client_secret',
17
+ ]);
18
+ $result = $gateway->merchant()->create([
19
+ 'email' => 'name@email.com',
20
+ 'countryCodeAlpha3' => 'USA',
21
+ 'paymentMethods' => ['credit_card', 'paypal'],
22
+ ]);
23
+
24
+ $this->assertEquals(true, $result->success);
25
+ $merchant = $result->merchant;
26
+ $this->assertNotNull($merchant->id);
27
+ $credentials = $result->credentials;
28
+ $this->assertNotNull($credentials->accessToken);
29
+ }
30
+
31
+ /**
32
+ * @expectedException Braintree\Exception\Configuration
33
+ * @expectedExceptionMessage clientId needs to be passed to Braintree\Gateway
34
+ */
35
+ public function testAssertsHasCredentials()
36
+ {
37
+ $gateway = new Braintree\Gateway([
38
+ 'clientSecret' => 'client_secret$development$integration_client_secret',
39
+ ]);
40
+ $gateway->merchant()->create([
41
+ 'email' => 'name@email.com',
42
+ 'countryCodeAlpha3' => 'USA',
43
+ ]);
44
+ }
45
+
46
+ public function testBadPaymentMethods()
47
+ {
48
+ $gateway = new Braintree\Gateway([
49
+ 'clientId' => 'client_id$development$integration_client_id',
50
+ 'clientSecret' => 'client_secret$development$integration_client_secret',
51
+ ]);
52
+ $result = $gateway->merchant()->create([
53
+ 'email' => 'name@email.com',
54
+ 'countryCodeAlpha3' => 'USA',
55
+ 'paymentMethods' => ['fake_money'],
56
+ ]);
57
+
58
+ $this->assertEquals(false, $result->success);
59
+ $errors = $result->errors->forKey('merchant')->onAttribute('paymentMethods');
60
+ $this->assertEquals(Braintree\Error\Codes::MERCHANT_ACCOUNT_PAYMENT_METHODS_ARE_INVALID, $errors[0]->code);
61
+ }
62
+
63
+ public function testCreatePaypalOnlyMerchantThatAcceptsMultipleCurrencies()
64
+ {
65
+ $gateway = new Braintree\Gateway([
66
+ 'clientId' => 'client_id$development$signup_client_id',
67
+ 'clientSecret' => 'client_secret$development$signup_client_secret',
68
+ ]);
69
+ $result = $gateway->merchant()->create([
70
+ 'email' => 'name@email.com',
71
+ 'countryCodeAlpha3' => 'USA',
72
+ 'paymentMethods' => ['paypal'],
73
+ 'currencies' => ['GBP', 'USD'],
74
+ 'paypalAccount' => [
75
+ 'clientId' => 'fake_client_id',
76
+ 'clientSecret' => 'fake_client_secret',
77
+ ]
78
+ ]);
79
+
80
+ $this->assertEquals(true, $result->success);
81
+ $merchant = $result->merchant;
82
+ $this->assertNotNull($merchant->id);
83
+ $credentials = $result->credentials;
84
+ $this->assertNotNull($credentials->accessToken);
85
+
86
+ $merchantAccounts = $merchant->merchantAccounts;
87
+ $this->assertEquals(2, count($merchantAccounts));
88
+
89
+ $usdMerchantAccount = $this->getMerchantAccountForCurrency($merchantAccounts, 'USD');
90
+ $this->assertNotNull($usdMerchantAccount);
91
+ $this->assertEquals(true, $usdMerchantAccount->default);
92
+ $this->assertEquals('USD', $usdMerchantAccount->currencyIsoCode);
93
+
94
+ $gbpMerchantAccount = $this->getMerchantAccountForCurrency($merchantAccounts, 'GBP');
95
+ $this->assertNotNull($gbpMerchantAccount);
96
+ $this->assertEquals(false, $gbpMerchantAccount->default);
97
+ $this->assertEquals('GBP', $gbpMerchantAccount->currencyIsoCode);
98
+ }
99
+
100
+ private function getMerchantAccountForCurrency($merchantAccounts, $currency)
101
+ {
102
+ foreach($merchantAccounts as $merchantAccount) {
103
+ if($merchantAccount->id == $currency) {
104
+ return $merchantAccount;
105
+ }
106
+ }
107
+ return null;
108
+ }
109
+
110
+ public function testCreatePaypalOnlyMerchantWithNoCurrenciesProvided()
111
+ {
112
+ $gateway = new Braintree\Gateway([
113
+ 'clientId' => 'client_id$development$signup_client_id',
114
+ 'clientSecret' => 'client_secret$development$signup_client_secret',
115
+ ]);
116
+ $result = $gateway->merchant()->create([
117
+ 'email' => 'name@email.com',
118
+ 'countryCodeAlpha3' => 'JPN',
119
+ 'paymentMethods' => ['paypal'],
120
+ 'paypalAccount' => [
121
+ 'clientId' => 'fake_client_id',
122
+ 'clientSecret' => 'fake_client_secret',
123
+ ]
124
+ ]);
125
+
126
+ $this->assertEquals(true, $result->success);
127
+ $merchant = $result->merchant;
128
+ $this->assertNotNull($merchant->id);
129
+ $credentials = $result->credentials;
130
+ $this->assertNotNull($credentials->accessToken);
131
+
132
+ $merchantAccounts = $merchant->merchantAccounts;
133
+ $this->assertEquals(1, count($merchantAccounts));
134
+
135
+ $jpyMerchantAccount = $merchantAccounts[0];
136
+ $this->assertEquals(true, $jpyMerchantAccount->default);
137
+ $this->assertEquals('JPY', $jpyMerchantAccount->currencyIsoCode);
138
+ }
139
+
140
+ public function testCreatePaypalOnlyMerchantWithUnsupportedCountryCodeProvided()
141
+ {
142
+ $gateway = new Braintree\Gateway([
143
+ 'clientId' => 'client_id$development$signup_client_id',
144
+ 'clientSecret' => 'client_secret$development$signup_client_secret',
145
+ ]);
146
+ $result = $gateway->merchant()->create([
147
+ 'email' => 'name@email.com',
148
+ 'countryCodeAlpha3' => 'YEM',
149
+ 'paymentMethods' => ['paypal'],
150
+ 'paypalAccount' => [
151
+ 'clientId' => 'fake_client_id',
152
+ 'clientSecret' => 'fake_client_secret',
153
+ ]
154
+ ]);
155
+
156
+ $this->assertEquals(true, $result->success);
157
+ $merchant = $result->merchant;
158
+ $this->assertNotNull($merchant->id);
159
+ $credentials = $result->credentials;
160
+ $this->assertNotNull($credentials->accessToken);
161
+
162
+ $merchantAccounts = $merchant->merchantAccounts;
163
+ $this->assertEquals(1, count($merchantAccounts));
164
+
165
+ $usdMerchantAccount = $merchantAccounts[0];
166
+ $this->assertEquals(true, $usdMerchantAccount->default);
167
+ $this->assertEquals('USD', $usdMerchantAccount->currencyIsoCode);
168
+ }
169
+
170
+ public function testCreateMultiCurrencyMerchantIgnoresCurrenciesIfNotInternalApplication()
171
+ {
172
+ $gateway = new Braintree\Gateway([
173
+ 'clientId' => 'client_id$development$integration_client_id',
174
+ 'clientSecret' => 'client_secret$development$integration_client_secret',
175
+ ]);
176
+ $result = $gateway->merchant()->create([
177
+ 'email' => 'name@email.com',
178
+ 'countryCodeAlpha3' => 'USA',
179
+ 'paymentMethods' => ['paypal'],
180
+ 'currencies' => ['GBP', 'USD'],
181
+ 'paypalAccount' => [
182
+ 'clientId' => 'fake_client_id',
183
+ 'clientSecret' => 'fake_client_secret',
184
+ ]
185
+ ]);
186
+
187
+ $this->assertEquals(true, $result->success);
188
+ $merchant = $result->merchant;
189
+ $this->assertNotNull($merchant->id);
190
+ $credentials = $result->credentials;
191
+ $this->assertNotNull($credentials->accessToken);
192
+
193
+ $merchantAccounts = $merchant->merchantAccounts;
194
+ $this->assertEquals(1, count($merchantAccounts));
195
+ }
196
+
197
+ public function testUnallowedPaymentMethodsForMultiCurrency()
198
+ {
199
+ $gateway = new Braintree\Gateway([
200
+ 'clientId' => 'client_id$development$signup_client_id',
201
+ 'clientSecret' => 'client_secret$development$signup_client_secret',
202
+ ]);
203
+ $result = $gateway->merchant()->create([
204
+ 'email' => 'name@email.com',
205
+ 'countryCodeAlpha3' => 'USA',
206
+ 'paymentMethods' => ['credit_card'],
207
+ 'currencies' => ['GBP', 'USD'],
208
+ 'paypalAccount' => [
209
+ 'clientId' => 'fake_client_id',
210
+ 'clientSecret' => 'fake_client_secret',
211
+ ]
212
+ ]);
213
+
214
+ $this->assertEquals(false, $result->success);
215
+ $errors = $result->errors->forKey('merchant')->onAttribute('paymentMethods');
216
+ $this->assertEquals(Braintree\Error\Codes::MERCHANT_PAYMENT_METHODS_ARE_NOT_ALLOWED, $errors[0]->code);
217
+ }
218
+
219
+ public function testInvalidCurrencyForMultiCurrency()
220
+ {
221
+ $gateway = new Braintree\Gateway([
222
+ 'clientId' => 'client_id$development$signup_client_id',
223
+ 'clientSecret' => 'client_secret$development$signup_client_secret',
224
+ ]);
225
+ $result = $gateway->merchant()->create([
226
+ 'email' => 'name@email.com',
227
+ 'countryCodeAlpha3' => 'USA',
228
+ 'paymentMethods' => ['paypal'],
229
+ 'currencies' => ['FAKE', 'USD'],
230
+ 'paypalAccount' => [
231
+ 'clientId' => 'fake_client_id',
232
+ 'clientSecret' => 'fake_client_secret',
233
+ ]
234
+ ]);
235
+
236
+ $this->assertEquals(false, $result->success);
237
+ $errors = $result->errors->forKey('merchant')->onAttribute('currencies');
238
+ $this->assertEquals(Braintree\Error\Codes::MERCHANT_CURRENCIES_ARE_INVALID, $errors[0]->code);
239
+ }
240
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/MultipleValueNodeTest.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class MultipleValueNodeTest extends Setup
11
+ {
12
+ public function testIn_singleValue()
13
+ {
14
+ $creditCard = SubscriptionHelper::createCreditCard();
15
+ $triallessPlan = SubscriptionHelper::triallessPlan();
16
+
17
+ $activeSubscription = Braintree\Subscription::create([
18
+ 'paymentMethodToken' => $creditCard->token,
19
+ 'planId' => $triallessPlan['id'],
20
+ 'price' => '3'
21
+ ])->subscription;
22
+
23
+ $canceledSubscription = Braintree\Subscription::create([
24
+ 'paymentMethodToken' => $creditCard->token,
25
+ 'planId' => $triallessPlan['id'],
26
+ 'price' => '3'
27
+ ])->subscription;
28
+ Braintree\Subscription::cancel($canceledSubscription->id);
29
+
30
+ $collection = Braintree\Subscription::search([
31
+ Braintree\SubscriptionSearch::status()->in([Braintree\Subscription::ACTIVE]),
32
+ Braintree\SubscriptionSearch::price()->is('3'),
33
+ ]);
34
+ foreach ($collection AS $item) {
35
+ $this->assertEquals(Braintree\Subscription::ACTIVE, $item->status);
36
+ }
37
+
38
+ $this->assertTrue(Test\Helper::includes($collection, $activeSubscription));
39
+ $this->assertFalse(Test\Helper::includes($collection, $canceledSubscription));
40
+ }
41
+
42
+ public function testIs()
43
+ {
44
+ $found = false;
45
+ $collection = Braintree\Subscription::search([
46
+ Braintree\SubscriptionSearch::status()->is(Braintree\Subscription::PAST_DUE)
47
+ ]);
48
+ foreach ($collection AS $item) {
49
+ $found = true;
50
+ $this->assertEquals(Braintree\Subscription::PAST_DUE, $item->status);
51
+ }
52
+ $this->assertTrue($found);
53
+ }
54
+
55
+ public function testSearch_statusIsExpired()
56
+ {
57
+ $found = false;
58
+ $collection = Braintree\Subscription::search([
59
+ Braintree\SubscriptionSearch::status()->in([Braintree\Subscription::EXPIRED])
60
+ ]);
61
+ foreach ($collection AS $item) {
62
+ $found = true;
63
+ $this->assertEquals(Braintree\Subscription::EXPIRED, $item->status);
64
+ }
65
+ $this->assertTrue($found);
66
+ }
67
+
68
+ public function testIn_multipleValues()
69
+ {
70
+ $creditCard = SubscriptionHelper::createCreditCard();
71
+ $triallessPlan = SubscriptionHelper::triallessPlan();
72
+
73
+ $activeSubscription = Braintree\Subscription::create([
74
+ 'paymentMethodToken' => $creditCard->token,
75
+ 'planId' => $triallessPlan['id'],
76
+ 'price' => '4'
77
+ ])->subscription;
78
+
79
+ $canceledSubscription = Braintree\Subscription::create([
80
+ 'paymentMethodToken' => $creditCard->token,
81
+ 'planId' => $triallessPlan['id'],
82
+ 'price' => '4'
83
+ ])->subscription;
84
+ Braintree\Subscription::cancel($canceledSubscription->id);
85
+
86
+ $collection = Braintree\Subscription::search([
87
+ Braintree\SubscriptionSearch::status()->in([Braintree\Subscription::ACTIVE, Braintree\Subscription::CANCELED]),
88
+ Braintree\SubscriptionSearch::price()->is('4')
89
+ ]);
90
+
91
+ $this->assertTrue(Test\Helper::includes($collection, $activeSubscription));
92
+ $this->assertTrue(Test\Helper::includes($collection, $canceledSubscription));
93
+ }
94
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/OAuthTest.php ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test;
7
+ use Test\Setup;
8
+ use Braintree;
9
+
10
+ class OAuthTest extends Setup
11
+ {
12
+ public function testCreateTokenFromCode()
13
+ {
14
+ $gateway = new Braintree\Gateway([
15
+ 'clientId' => 'client_id$development$integration_client_id',
16
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
17
+ ]);
18
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [
19
+ 'merchant_public_id' => 'integration_merchant_id',
20
+ 'scope' => 'read_write'
21
+ ]);
22
+ $result = $gateway->oauth()->createTokenFromCode([
23
+ 'code' => $code,
24
+ 'scope' => 'read_write',
25
+ ]);
26
+
27
+ $this->assertEquals(true, $result->success);
28
+ $credentials = $result->credentials;
29
+ $this->assertNotNull($credentials->accessToken);
30
+ $this->assertNotNull($credentials->refreshToken);
31
+ $this->assertEquals('bearer', $credentials->tokenType);
32
+ $this->assertNotNull($credentials->expiresAt);
33
+ }
34
+
35
+ /**
36
+ * @expectedException Braintree\Exception\Configuration
37
+ * @expectedExceptionMessage clientSecret needs to be passed to Braintree\Gateway.
38
+ */
39
+ public function testAssertsHasCredentials()
40
+ {
41
+ $gateway = new Braintree\Gateway([
42
+ 'clientId' => 'client_id$development$integration_client_id'
43
+ ]);
44
+ $gateway->oauth()->createTokenFromCode([
45
+ 'code' => 'integration_oauth_auth_code_' . rand(0,299)
46
+ ]);
47
+ }
48
+
49
+ public function testCreateTokenFromCodeWithMixedCredentials()
50
+ {
51
+ $gateway = new Braintree\Gateway([
52
+ 'clientId' => 'client_id$development$integration_client_id',
53
+ 'clientSecret' => 'client_secret$development$integration_client_secret',
54
+ 'accessToken' => 'access_token$development$integration_merchant_id$f9ac33b3dd',
55
+ ]);
56
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [
57
+ 'merchant_public_id' => 'integration_merchant_id',
58
+ 'scope' => 'read_write'
59
+ ]);
60
+ $result = $gateway->oauth()->createTokenFromCode([
61
+ 'code' => $code,
62
+ 'scope' => 'read_write',
63
+ ]);
64
+
65
+ $this->assertEquals(true, $result->success);
66
+ $credentials = $result->credentials;
67
+ $this->assertNotNull($credentials->accessToken);
68
+ $this->assertNotNull($credentials->refreshToken);
69
+ $this->assertEquals('bearer', $credentials->tokenType);
70
+ $this->assertNotNull($credentials->expiresAt);
71
+ }
72
+
73
+ public function testCreateTokenFromCode_JsonAPI()
74
+ {
75
+ $gateway = new Braintree\Gateway([
76
+ 'clientId' => 'client_id$development$integration_client_id',
77
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
78
+ ]);
79
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [
80
+ 'merchant_public_id' => 'integration_merchant_id',
81
+ 'scope' => 'read_write'
82
+ ]);
83
+ $result = $gateway->oauth()->createTokenFromCode([
84
+ 'code' => $code,
85
+ 'scope' => 'read_write',
86
+ ]);
87
+
88
+ $this->assertEquals(true, $result->success);
89
+ $this->assertNotNull($result->accessToken);
90
+ $this->assertNotNull($result->refreshToken);
91
+ $this->assertEquals('bearer', $result->tokenType);
92
+ $this->assertNotNull($result->expiresAt);
93
+ }
94
+
95
+ public function testRevokeAccessToken()
96
+ {
97
+ $gateway = new Braintree\Gateway([
98
+ 'clientId' => 'client_id$development$integration_client_id',
99
+ 'clientSecret' => 'client_secret$development$integration_client_secret',
100
+ ]);
101
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [
102
+ 'merchant_public_id' => 'integration_merchant_id',
103
+ 'scope' => 'read_write'
104
+ ]);
105
+ $result = $gateway->oauth()->createTokenFromCode([
106
+ 'code' => $code,
107
+ 'scope' => 'read_write',
108
+ ]);
109
+
110
+ $revokeAccessTokenResult = $gateway->oauth()->revokeAccessToken($result->accessToken);
111
+
112
+ $this->assertTrue($revokeAccessTokenResult->success);
113
+ $this->assertTrue($revokeAccessTokenResult->result->success);
114
+
115
+ $gateway = new Braintree\Gateway(['accessToken' => $result->accessToken]);
116
+ $this->setExpectedException('Braintree\Exception\Authentication');
117
+ $gateway->customer()->create();
118
+ }
119
+
120
+ public function testCreateTokenFromCode_ValidationErrorTest()
121
+ {
122
+ $gateway = new Braintree\Gateway([
123
+ 'clientId' => 'client_id$development$integration_client_id',
124
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
125
+ ]);
126
+ $result = $gateway->oauth()->createTokenFromCode([
127
+ 'code' => 'bad_code',
128
+ 'scope' => 'read_write',
129
+ ]);
130
+
131
+ $this->assertEquals(false, $result->success);
132
+ $errors = $result->errors->forKey('credentials')->onAttribute('code');
133
+ $this->assertEquals(Braintree\Error\Codes::OAUTH_INVALID_GRANT, $errors[0]->code);
134
+ $this->assertEquals(1, preg_match('/Invalid grant: code not found/', $result->message));
135
+ }
136
+
137
+ public function testCreateTokenFromCode_OldError()
138
+ {
139
+ $gateway = new Braintree\Gateway([
140
+ 'clientId' => 'client_id$development$integration_client_id',
141
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
142
+ ]);
143
+ $result = $gateway->oauth()->createTokenFromCode([
144
+ 'code' => 'bad_code',
145
+ 'scope' => 'read_write',
146
+ ]);
147
+
148
+ $this->assertEquals(false, $result->success);
149
+ $this->assertEquals('invalid_grant', $result->error);
150
+ $this->assertEquals('code not found', $result->errorDescription);
151
+ }
152
+
153
+ public function testCreateTokenFromRefreshToken()
154
+ {
155
+ $gateway = new Braintree\Gateway([
156
+ 'clientId' => 'client_id$development$integration_client_id',
157
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
158
+ ]);
159
+ $code = Test\Braintree\OAuthTestHelper::createGrant($gateway, [
160
+ 'merchant_public_id' => 'integration_merchant_id',
161
+ 'scope' => 'read_write'
162
+ ]);
163
+ $refreshToken = $gateway->oauth()->createTokenFromCode([
164
+ 'code' => $code,
165
+ 'scope' => 'read_write',
166
+ ])->credentials->refreshToken;
167
+
168
+ $result = $gateway->oauth()->createTokenFromRefreshToken([
169
+ 'refreshToken' => $refreshToken,
170
+ 'scope' => 'read_write',
171
+ ]);
172
+
173
+ $this->assertEquals(true, $result->success);
174
+ $credentials = $result->credentials;
175
+ $this->assertNotNull($credentials->accessToken);
176
+ $this->assertNotNull($credentials->refreshToken);
177
+ $this->assertEquals('bearer', $credentials->tokenType);
178
+ $this->assertNotNull($credentials->expiresAt);
179
+ }
180
+
181
+
182
+ public function testBuildConnectUrl()
183
+ {
184
+ $gateway = new Braintree\Gateway([
185
+ 'clientId' => 'client_id$development$integration_client_id',
186
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
187
+ ]);
188
+ $url = $gateway->oauth()->connectUrl([
189
+ 'merchantId' => 'integration_merchant_id',
190
+ 'redirectUri' => 'http://bar.example.com',
191
+ 'scope' => 'read_write',
192
+ 'state' => 'baz_state',
193
+ 'landingPage' => 'login',
194
+ 'user' => [
195
+ 'country' => 'USA',
196
+ 'email' => 'foo@example.com',
197
+ 'firstName' => 'Bob',
198
+ 'lastName' => 'Jones',
199
+ 'phone' => '555-555-5555',
200
+ 'dobYear' => '1970',
201
+ 'dobMonth' => '01',
202
+ 'dobDay' => '01',
203
+ 'streetAddress' => '222 W Merchandise Mart',
204
+ 'locality' => 'Chicago',
205
+ 'region' => 'IL',
206
+ 'postalCode' => '60606',
207
+ ],
208
+ 'business' => [
209
+ 'name' => '14 Ladders',
210
+ 'registeredAs' => '14.0 Ladders',
211
+ 'industry' => 'Ladders',
212
+ 'description' => 'We sell the best ladders',
213
+ 'streetAddress' => '111 N Canal',
214
+ 'locality' => 'Chicago',
215
+ 'region' => 'IL',
216
+ 'postalCode' => '60606',
217
+ 'country' => 'USA',
218
+ 'annualVolumeAmount' => '1000000',
219
+ 'averageTransactionAmount' => '100',
220
+ 'maximumTransactionAmount' => '10000',
221
+ 'shipPhysicalGoods' => true,
222
+ 'fulfillmentCompletedIn' => 7,
223
+ 'currency' => 'USD',
224
+ 'website' => 'http://example.com',
225
+ ],
226
+ 'paymentMethods' => ['credit_card'],
227
+ ]);
228
+
229
+ $components = parse_url($url);
230
+ $queryString = $components['query'];
231
+ parse_str($queryString, $query);
232
+
233
+ $this->assertEquals('localhost', $components['host']);
234
+ $this->assertEquals('/oauth/connect', $components['path']);
235
+ $this->assertEquals('integration_merchant_id', $query['merchant_id']);
236
+ $this->assertEquals('client_id$development$integration_client_id', $query['client_id']);
237
+ $this->assertEquals('http://bar.example.com', $query['redirect_uri']);
238
+ $this->assertEquals('read_write', $query['scope']);
239
+ $this->assertEquals('baz_state', $query['state']);
240
+ $this->assertEquals('login', $query['landing_page']);
241
+
242
+ $this->assertEquals('USA', $query['user']['country']);
243
+ $this->assertEquals('foo@example.com', $query['user']['email']);
244
+ $this->assertEquals('Bob', $query['user']['first_name']);
245
+ $this->assertEquals('Jones', $query['user']['last_name']);
246
+ $this->assertEquals('555-555-5555', $query['user']['phone']);
247
+ $this->assertEquals('1970', $query['user']['dob_year']);
248
+ $this->assertEquals('01', $query['user']['dob_month']);
249
+ $this->assertEquals('01', $query['user']['dob_day']);
250
+ $this->assertEquals('222 W Merchandise Mart', $query['user']['street_address']);
251
+ $this->assertEquals('Chicago', $query['user']['locality']);
252
+ $this->assertEquals('IL', $query['user']['region']);
253
+ $this->assertEquals('60606', $query['user']['postal_code']);
254
+
255
+ $this->assertEquals('14 Ladders', $query['business']['name']);
256
+ $this->assertEquals('14.0 Ladders', $query['business']['registered_as']);
257
+ $this->assertEquals('Ladders', $query['business']['industry']);
258
+ $this->assertEquals('We sell the best ladders', $query['business']['description']);
259
+ $this->assertEquals('111 N Canal', $query['business']['street_address']);
260
+ $this->assertEquals('Chicago', $query['business']['locality']);
261
+ $this->assertEquals('IL', $query['business']['region']);
262
+ $this->assertEquals('60606', $query['business']['postal_code']);
263
+ $this->assertEquals('USA', $query['business']['country']);
264
+ $this->assertEquals('1000000', $query['business']['annual_volume_amount']);
265
+ $this->assertEquals('100', $query['business']['average_transaction_amount']);
266
+ $this->assertEquals('10000', $query['business']['maximum_transaction_amount']);
267
+ $this->assertEquals(true, $query['business']['ship_physical_goods']);
268
+ $this->assertEquals(7, $query['business']['fulfillment_completed_in']);
269
+ $this->assertEquals('USD', $query['business']['currency']);
270
+ $this->assertEquals('http://example.com', $query['business']['website']);
271
+
272
+ $this->assertCount(1, $query['payment_methods']);
273
+ $this->assertEquals('credit_card', $query['payment_methods'][0]);
274
+
275
+ $this->assertEquals(64, strlen($query['signature']));
276
+ $this->assertEquals('SHA256', $query['algorithm']);
277
+ }
278
+
279
+ public function testBuildConnectUrlWithoutOptionalParams()
280
+ {
281
+ $gateway = new Braintree\Gateway([
282
+ 'clientId' => 'client_id$development$integration_client_id',
283
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
284
+ ]);
285
+ $url = $gateway->oauth()->connectUrl();
286
+
287
+ $queryString = parse_url($url)['query'];
288
+ parse_str($queryString, $query);
289
+
290
+ $this->assertEquals('client_id$development$integration_client_id', $query['client_id']);
291
+ $this->assertArrayNotHasKey('merchant_id', $query);
292
+ $this->assertArrayNotHasKey('redirect_uri', $query);
293
+ $this->assertArrayNotHasKey('scope', $query);
294
+ }
295
+
296
+ public function testBuildConnectUrlWithPaymentMethods()
297
+ {
298
+ $gateway = new Braintree\Gateway([
299
+ 'clientId' => 'client_id$development$integration_client_id',
300
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
301
+ ]);
302
+ $url = $gateway->oauth()->connectUrl([
303
+ 'paymentMethods' => ['credit_card', 'paypal']
304
+ ]);
305
+
306
+ $queryString = parse_url($url)['query'];
307
+ parse_str($queryString, $query);
308
+
309
+ $this->assertEquals(['credit_card', 'paypal'], $query['payment_methods']);
310
+ }
311
+
312
+ public function testComputeSignature()
313
+ {
314
+ $gateway = new Braintree\Gateway([
315
+ 'clientId' => 'client_id$development$integration_client_id',
316
+ 'clientSecret' => 'client_secret$development$integration_client_secret'
317
+ ]);
318
+ $urlToSign = 'http://localhost:3000/oauth/connect?business%5Bname%5D=We+Like+Spaces&client_id=client_id%24development%24integration_client_id';
319
+
320
+ $signature = $gateway->oauth()->computeSignature($urlToSign);
321
+
322
+ $this->assertEquals("a36bcf10dd982e2e47e0d6a2cb930aea47ade73f954b7d59c58dae6167894d41", $signature);
323
+ }
324
+ }
lib/Gene/Braintree/braintree/braintree_php/tests/integration/PayPalAccountTest.php ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Test\Integration;
3
+
4
+ require_once dirname(__DIR__) . '/Setup.php';
5
+
6
+ use Test\Setup;
7
+ use Braintree;
8
+
9
+ class PayPalAccountTest extends Setup
10
+ {
11
+ public function testFind()
12
+ {
13
+ $paymentMethodToken = 'PAYPALToken-' . strval(rand());
14
+ $customer = Braintree\Customer::createNoValidate();
15
+ $http = new HttpClientApi(Braintree\Configuration::$global);
16
+ $nonce = $http->nonceForPayPalAccount([
17
+ 'paypal_account' => [
18
+ 'consent_code' => 'PAYPAL_CONSENT_CODE',
19
+ 'token' => $paymentMethodToken
20
+ ]
21
+ ]);
22
+
23
+ Braintree\PaymentMethod::create([
24
+ 'customerId' => $customer->id,
25
+ 'paymentMethodNonce' => $nonce
26
+ ]);
27
+
28
+ $foundPayPalAccount = Braintree\PayPalAccount::find($paymentMethodToken);
29
+
30
+ $this->assertSame('jane.doe@example.com', $foundPayPalAccount->email);
31
+ $this->assertSame($paymentMethodToken, $foundPayPalAccount->token);
32
+ $this->assertNotNull($foundPayPalAccount->imageUrl);
33
+ }
34
+
35
+ public function testGatewayFind()
36
+ {
37
+ $paymentMethodToken = 'PAYPALToken-' . strval(rand());
38
+ $customer = Braintree\Customer::createNoValidate();
39
+ $http = new HttpClientApi(Braintree\Configuration::$global);
40
+ $nonce = $http->nonceForPayPalAccount([
41
+ 'paypal_account' => [
42
+ 'consent_code' => 'PAYPAL_CONSENT_CODE',
43
+ 'token' => $paymentMethodToken
44
+ ]
45
+ ]);
46
+
47
+ Braintree\PaymentMethod::create([
48
+ 'customerId' => $customer->id,
49
+ 'paymentMethodNonce' => $nonce
50
+ ]);
51
+
52
+ $gateway = new Braintree\Gateway([
53
+ 'environment' => 'development',
54
+ 'merchantId' => 'integration_merchant_id',
55
+ 'publicKey' => 'integration_public_key',
56
+ 'privateKey' => 'integration_private_key'
57
+ ]);
58
+ $foundPayPalAccount = $gateway->paypalAccount()->find($paymentMethodToken);
59
+
60
+ $this->assertSame('jane.doe@example.com', $foundPayPalAccount->email);
61
+ $this->assertSame($paymentMethodToken, $foundPayPalAccount->token);
62
+ $this->assertNotNull($foundPayPalAccount->imageUrl);
63
+ }
64
+
65
+ public function testFind_doesNotReturnIncorrectPaymentMethodType()
66
+ {
67
+ $creditCardToken = 'creditCardToken-' . strval(rand());
68
+ $customer = Braintree\Customer::createNoValidate();
69
+ $result = Braintree\CreditCard::create([
70
+ 'customerId' => $customer->id,
71
+ 'cardholderName' => 'Cardholder',
72
+ 'number' => '5105105105105100',
73
+ 'expirationDate' => '05/12',
74
+ 'token' => $creditCardToken
75
+ ]);
76
+ $this->assertTrue($result->success);
77
+
78
+ $this->setExpectedException('Braintree\Exception\NotFound');
79
+ Braintree\PayPalAccount::find($creditCardToken);
80
+ }
81
+
82
+ public function test_PayPalAccountExposesTimestamps()
83
+ {
84
+ $customer = Braintree\Customer::createNoValidate();
85
+ $result = Braintree\PaymentMethod::create([
86
+ 'customerId' => $customer->id,
87
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$paypalFuturePayment,
88
+ ]);
89
+ $this->assertTrue($result->success);
90
+
91
+ $this->assertNotNull($result->paymentMethod->createdAt);
92
+ $this->assertNotNull($result->paymentMethod->updatedAt);
93
+ }
94
+
95
+ public function test_PayPalAccountExposesBillingAgreementId()
96
+ {
97
+ $customer = Braintree\Customer::createNoValidate();
98
+ $result = Braintree\PaymentMethod::create([
99
+ 'customerId' => $customer->id,
100
+ 'paymentMethodNonce' => Braintree\Test\Nonces::$paypalBillingAgreement
101
+ ]);
102
+ $this->assertTrue($result->success);
103
+
104
+ $foundPayPalAccount = Braintree\PayPalAccount::find($result->paymentMethod->token);
105
+
106
+ $this->assertNotNull($foundPayPalAccount->billingAgreementId);
107
+ }
108
+
109
+ public function testFind_throwsIfCannotBeFound()
110
+ {
111
+ $this->setExpectedException('Braintree\Exception\NotFound');
112
+ Braintree\PayPalAccount::find('invalid-token');
113
+ }
114
+
115
+ public function testFind_throwsUsefulErrorMessagesWhenEmpty()
116
+ {
117
+ $this->setExpectedException('InvalidArgumentException', 'expected paypal account id to be set');
118
+ Braintree\PayPalAccount::find('');
119
+ }
120
+
121
+ public function testFind_throwsUsefulErrorMessagesWhenInvalid()
122
+ {
123
+ $this->setExpectedException('InvalidArgumentException', '@ is an invalid paypal account token');
124
+ Braintree\PayPalAccount::find('@');
125
+ }
126
+
127
+ public function testFind_returnsSubscriptionsAssociatedWithAPaypalAccount()
128
+ {
129
+ $customer = Braintree\Customer::createNoValidate();
130
+ $paymentMethodToken = 'paypal-account-' . strval(rand());
131
+
132
+ $http = new HttpClientApi(Braintree\Configuration::$global);
133
+ $nonce = $http->nonceForPayPalAccount([
134
+ 'paypal_account' => [
135
+ 'consent_code' => 'consent-code',
136
+ 'token' => $paymentMethodToken
137
+ ]
138
+ ]);
139
+
140
+ $result = Braintree\PaymentMethod::create([
141
+ 'paymentMethodNonce' => $nonce,
142
+ 'customerId' => $customer->id
143
+ ]);
144
+ $this->assertTrue($result->success);
145
+
146
+ $token = $result->paymentMethod->token;
147
+ $triallessPlan = SubscriptionHelper::triallessPlan();
148
+
149
+ $subscription1 = Braintree\Subscription::create([
150
+ 'paymentMethodToken' => $token,
151
+ 'planId' => $triallessPlan['id']
152
+ ])->subscription;
153
+
154
+ $subscription2 = Braintree\Subscription::create([
155
+ 'paymentMethodToken' => $token,
156
+ 'planId' => $triallessPlan['id']
157
+ ])->subscription;
158
+
159
+ $paypalAccount = Braintree\PayPalAccount::find($token);
160
+ $getIds = function($sub) { return $sub->id; };
161
+ $subIds = array_map($getIds, $paypalAccount->subscriptions);
162
+ $this->assertTrue(in_array($subscription1->id, $subIds));
163
+ $this->assertTrue(in_array($subscription2->id, $subIds));
164
+ }
165
+
166
+ public function testUpdate()
167
+ {
168
+ $originalToken = 'ORIGINAL_PAYPALToken-' . strval(rand());
169
+ $customer = Braintree\Customer::createNoValidate();
170
+ $http = new HttpClientApi(Braintree\Configuration::$global);
171
+ $nonce = $http->nonceForPayPalAccount([
172
+ 'paypal_account' => [
173
+ 'consent_code' => 'PAYPAL_CONSENT_CODE',
174
+ 'token' => $originalToken
175
+ ]
176
+ ]);
177
+
178
+ $createResult = Braintree\PaymentMethod::create([
179
+ 'customerId' => $customer->id,
180
+ 'paymentMethodNonce' => $nonce
181
+ ]);
182
+ $this->assertTrue($createResult->success);
183
+
184
+ $newToken = 'NEW_PAYPALToken-' . strval(rand());
185
+ $updateResult = Braintree\PayPalAccount::update($originalToken, [
186
+ 'token' => $newToken
187
+ ]);
188
+
189
+ $this->assertTrue($updateResult->success);
190
+ $this->assertEquals($newToken, $updateResult->paypalAccount->token);
191
+
192
+ $this->setExpectedException('Braintree\Exception\NotFound');
193
+ Braintree\PayPalAccount::find($originalToken);
194
+
195
+ }
196
+
197
+ public function testUpdateAndMakeDefault()
198
+ {
199
+ $customer = Braintree\Customer::createNoValidate();
200
+
201
+ $creditCardResult = Braintree\CreditCard::create([
202
+ 'customerId' => $customer->id,
203
+ 'number' => '5105105105105100',
204
+ 'expirationDate' => '05/12'
205
+ ]);
206
+ $this->assertTrue($creditCardResult->success);
207
+
208
+ $http = new HttpClientApi(Braintree\Configuration::$global);
209
+ $nonce = $http->nonceForPayPalAccount([
210
+ 'paypal_account' => [
211
+ 'consent_code' => 'PAYPAL_CONSENT_CODE'
212
+ ]
213
+ ]);
214
+
215
+ $createResult = Braintree\PaymentMethod::create([
216
+ 'customerId' => $customer->id,
217
+ 'paymentMethodNonce' => $nonce
218
+ ]);
219
+ $this->assertTrue($createResult->success);
220
+
221
+ $updateResult = Braintree\PayPalAccount::update($createResult->paymentMethod->token, [
222
+ 'options' => ['makeDefault' => true]
223
+ ]);
224
+
225
+ $this->assertTrue($updateResult->success);
226
+ $this->assertTrue($updateResult->paypalAccount->isDefault());
227
+ }
228
+
229
+ public function testUpdate_handleErrors()
230
+ {
231
+ $customer = Braintree\Customer::createNoValidate();
232
+
233
+ $firstToken = 'FIRST_PAYPALToken-' . strval(rand());
234
+ $http = new HttpClientApi(Braintree\Configuration::$global);
235
+ $firstNonce = $http->nonceForPayPalAccount([
236
+ 'paypal_account' => [
237
+ 'consent_code' => 'PAYPAL_CONSENT_CODE',
238
+ 'token' => $firstToken
239
+ ]
240
+ ]);
241
+ $firstPaypalAccount = Braintree\PaymentMethod::create([
242
+ 'customerId' => $customer->id,
243
+ 'paymentMethodNonce' => $firstNonce
244
+ ]);
245
+ $this->assertTrue($firstPaypalAccount->success);
246
+
247
+ $secondToken = 'SECOND_PAYPALToken-' . strval(rand());
248
+ $http = new HttpClientApi(Braintree\Configuration::$global);
249
+ $secondNonce = $http->nonceForPayPalAccount([
250
+ 'paypal_account' => [
251
+ 'consent_code' => 'PAYPAL_CONSENT_CODE',
252
+ 'token' => $secondToken
253
+ ]
254
+ ]);
255
+ $secondPaypalAccount = Braintree\PaymentMethod::create([
256
+ 'customerId' => $customer->id,
257
+ 'paymentMethodNonce' => $secondNonce
258
+ ]);
259
+ $this->assertTrue($secondPaypalAccount->success);
260
+
261
+ $updateResult = Braintree\PayPalAccount::update($firstToken, [
262
+ 'token' => $secondToken
263
+ ]);
264
+
265
+ $this->assertFalse($updateResult->success);
266
+ $errors = $updateResult->errors->forKey('paypalAccount')->errors;
267
+ $this->assertEquals(Braintree\Error\Codes::PAYPAL_ACCOUNT_TOKEN_IS_IN_USE, $errors[0]->code);
268
+ }
269
+
270
+ public function testDelete()
271
+ {
272
+ $paymentMethodToken = 'PAYPALToken-' . strval(rand());
273
+ $customer = Braintree\Customer::createNoValidate();
274
+ $http = new HttpClientApi(Braintree\Configuration::$global);
275
+ $nonce = $http->nonceForPayPalAccount([
276
+ 'paypal_account' => [
277
+ 'consent_code' => 'PAYPAL_CONSENT_CODE',
278
+ 'token' => $paymentMethodToken
279
+ ]
280
+ ]);
281
+
282
+ Braintree\Paym