Gene_Braintree - Version 1.0.4

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 1.0.4
Comparing to
See all releases


Code changes from version 1.0.3.2 to 1.0.4

Files changed (85) hide show
  1. app/code/community/Gene/Braintree/Model/Observer.php +18 -0
  2. app/code/community/Gene/Braintree/etc/config.xml +1 -1
  3. app/design/adminhtml/default/default/template/gene/braintree/js.phtml +3 -1
  4. app/design/frontend/base/default/layout/gene/braintree.xml +69 -2
  5. app/design/frontend/base/default/template/gene/braintree/creditcard.phtml +4 -4
  6. app/design/frontend/base/default/template/gene/braintree/js/aheadworks.phtml +353 -0
  7. app/design/frontend/base/default/template/gene/braintree/js/amasty.phtml +22 -15
  8. app/design/frontend/base/default/template/gene/braintree/js/data.phtml +13 -7
  9. app/design/frontend/base/default/template/gene/braintree/js/default.phtml +9 -4
  10. app/design/frontend/base/default/template/gene/braintree/js/idev.phtml +282 -278
  11. app/design/frontend/base/default/template/gene/braintree/js/iwd.phtml +394 -0
  12. app/design/frontend/base/default/template/gene/braintree/js/magestore.phtml +376 -0
  13. app/design/frontend/base/default/template/gene/braintree/js/setup.phtml +17 -14
  14. lib/Braintree.php +13 -55
  15. lib/Braintree/AddOn.php +11 -2
  16. lib/Braintree/AddOnGateway.php +24 -0
  17. lib/Braintree/Address.php +33 -1
  18. lib/Braintree/AddressGateway.php +20 -1
  19. lib/Braintree/AndroidPayCard.php +85 -0
  20. lib/Braintree/ApplePayCard.php +1 -1
  21. lib/Braintree/Base.php +70 -0
  22. lib/Braintree/ClientToken.php +18 -0
  23. lib/Braintree/ClientTokenGateway.php +32 -0
  24. lib/Braintree/CoinbaseAccount.php +1 -1
  25. lib/Braintree/Configuration.php +106 -38
  26. lib/Braintree/CredentialsParser.php +145 -0
  27. lib/Braintree/CreditCard.php +21 -2
  28. lib/Braintree/CreditCardGateway.php +1 -0
  29. lib/Braintree/CreditCardVerificationGateway.php +1 -0
  30. lib/Braintree/CreditCardVerificationSearch.php +44 -24
  31. lib/Braintree/Customer.php +119 -8
  32. lib/Braintree/CustomerGateway.php +38 -13
  33. lib/Braintree/Disbursement.php +1 -1
  34. lib/Braintree/DiscountGateway.php +1 -0
  35. lib/Braintree/Dispute.php +1 -1
  36. lib/Braintree/Error/Codes.php +235 -200
  37. lib/Braintree/Exception/InvalidChallenge.php +5 -0
  38. lib/Braintree/Gateway.php +91 -6
  39. lib/Braintree/Http.php +49 -10
  40. lib/Braintree/Merchant.php +26 -0
  41. lib/Braintree/MerchantAccount.php +1 -1
  42. lib/Braintree/MerchantAccount/BusinessDetails.php +1 -1
  43. lib/Braintree/MerchantAccount/IndividualDetails.php +1 -1
  44. lib/Braintree/MerchantAccountGateway.php +1 -0
  45. lib/Braintree/MerchantGateway.php +40 -0
  46. lib/Braintree/Modification.php +5 -9
  47. lib/Braintree/OAuthCredentials.php +33 -0
  48. lib/Braintree/OAuthGateway.php +102 -0
  49. lib/Braintree/PartnerMerchant.php +1 -1
  50. lib/Braintree/PayPalAccount.php +1 -1
  51. lib/Braintree/PayPalAccountGateway.php +1 -0
  52. lib/Braintree/PaymentInstrumentType.php +4 -2
  53. lib/Braintree/PaymentMethod.php +1 -1
  54. lib/Braintree/PaymentMethodGateway.php +29 -30
  55. lib/Braintree/PaymentMethodNonce.php +12 -6
  56. lib/Braintree/PaymentMethodNonceGateway.php +18 -0
  57. lib/Braintree/Plan.php +1 -1
  58. lib/Braintree/PlanGateway.php +1 -0
  59. lib/Braintree/Result/CreditCardVerification.php +10 -0
  60. lib/Braintree/Result/Error.php +1 -1
  61. lib/Braintree/Result/Successful.php +24 -12
  62. lib/Braintree/RiskData.php +1 -1
  63. lib/Braintree/SettlementBatchSummary.php +14 -3
  64. lib/Braintree/SettlementBatchSummaryGateway.php +38 -0
  65. lib/Braintree/Subscription.php +1 -1
  66. lib/Braintree/SubscriptionGateway.php +1 -0
  67. lib/Braintree/Test/Nonces.php +2 -0
  68. lib/Braintree/ThreeDSecureInfo.php +27 -0
  69. lib/Braintree/Transaction.php +14 -1
  70. lib/Braintree/Transaction/AndroidPayCardDetails.php +44 -0
  71. lib/Braintree/TransactionGateway.php +1 -0
  72. lib/Braintree/TransactionSearch.php +54 -56
  73. lib/Braintree/TransparentRedirectGateway.php +1 -0
  74. lib/Braintree/UnknownPaymentMethod.php +1 -1
  75. lib/Braintree/Util.php +54 -3
  76. lib/Braintree/Version.php +2 -2
  77. lib/Braintree/WebhookNotification.php +8 -2
  78. lib/Braintree/Xml/Generator.php +3 -4
  79. lib/Braintree/Xml/Parser.php +83 -129
  80. package.xml +4 -4
  81. skin/frontend/base/default/css/gene/braintree/aheadworks.css +11 -0
  82. skin/frontend/base/default/css/gene/braintree/amasty.css +9 -0
  83. skin/frontend/base/default/css/gene/braintree/idev.css +8 -0
  84. skin/frontend/base/default/css/gene/braintree/iwd.css +0 -0
  85. skin/frontend/base/default/css/gene/braintree/magestore.css +43 -0
app/code/community/Gene/Braintree/Model/Observer.php CHANGED
@@ -33,6 +33,24 @@ class Gene_Braintree_Model_Observer
33
 
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  return $this;
37
  }
38
 
33
 
34
  }
35
 
36
+ // As some 3rd party checkouts use the same handles, and URL we have to dynamically add new handles
37
+ if($action->getFullActionName() == 'onestepcheckout_index_index') {
38
+
39
+ // Attempt to detect Magestore_Onestepcheckout
40
+ if (Mage::helper('core')->isModuleEnabled('Magestore_Onestepcheckout')) {
41
+ if(Mage::helper('onestepcheckout')->enabledOnestepcheckout()) {
42
+ $layout->getUpdate()->addHandle('magestore_onestepcheckout_index');
43
+ }
44
+ }
45
+
46
+ // Attempt to detect Idev_OneStepCheckout
47
+ // @todo add new handle for idev
48
+ if (Mage::helper('core')->isModuleEnabled('Idev_OneStepCheckout')) {
49
+ $layout->getUpdate()->addHandle('idev_onestepcheckout_index');
50
+ }
51
+
52
+ }
53
+
54
  return $this;
55
  }
56
 
app/code/community/Gene/Braintree/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Gene_Braintree>
5
- <version>1.0.3.2</version>
6
  </Gene_Braintree>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Gene_Braintree>
5
+ <version>1.0.4</version>
6
  </Gene_Braintree>
7
  </modules>
8
  <global>
app/design/adminhtml/default/default/template/gene/braintree/js.phtml CHANGED
@@ -40,7 +40,9 @@
40
  });
41
 
42
  // Always make sure device data is sent with the request
43
- $('device_data').removeAttribute('disabled');
 
 
44
 
45
  // Fire the original event and return the response
46
  adminOrderResponse = adminOrderOriginal.apply(adminThis, adminArgs);
40
  });
41
 
42
  // Always make sure device data is sent with the request
43
+ if($('device_data')) {
44
+ $('device_data').removeAttribute('disabled');
45
+ }
46
 
47
  // Fire the original event and return the response
48
  adminOrderResponse = adminOrderOriginal.apply(adminThis, adminArgs);
app/design/frontend/base/default/layout/gene/braintree.xml CHANGED
@@ -22,6 +22,9 @@
22
 
23
  <!-- We have to use a customized version of the js.phtml file for Amasty's checkout solution -->
24
  <amasty_onestep_checkout>
 
 
 
25
  <reference name="before_body_end">
26
  <remove name="gene_braintree_js" />
27
  <block type="gene_braintree/js" name="gene_braintree_amasty_js" template="gene/braintree/js/amasty.phtml" />
@@ -29,10 +32,11 @@
29
  </amasty_onestep_checkout>
30
 
31
  <!-- Need to include the standard resources for the onestepcheckout.com solution -->
32
- <onestepcheckout_index_index>
33
  <reference name="head">
34
  <action method="addJs"><file>gene/braintree/braintree.js</file></action>
35
  <action method="addJs"><file>gene/braintree/vzero.js</file></action>
 
36
  </reference>
37
  <reference name="before_body_end">
38
  <block type="gene_braintree/js" name="gene_braintree_setup" template="gene/braintree/js/setup.phtml" />
@@ -46,7 +50,70 @@
46
  </action>
47
  </block>
48
  </reference>
49
- </onestepcheckout_index_index>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  <checkout_onepage_paymentmethod>
52
  <reference name="root">
22
 
23
  <!-- We have to use a customized version of the js.phtml file for Amasty's checkout solution -->
24
  <amasty_onestep_checkout>
25
+ <reference name="head">
26
+ <action method="addCss"><file>css/gene/braintree/amasty.css</file></action>
27
+ </reference>
28
  <reference name="before_body_end">
29
  <remove name="gene_braintree_js" />
30
  <block type="gene_braintree/js" name="gene_braintree_amasty_js" template="gene/braintree/js/amasty.phtml" />
32
  </amasty_onestep_checkout>
33
 
34
  <!-- Need to include the standard resources for the onestepcheckout.com solution -->
35
+ <idev_onestepcheckout_index>
36
  <reference name="head">
37
  <action method="addJs"><file>gene/braintree/braintree.js</file></action>
38
  <action method="addJs"><file>gene/braintree/vzero.js</file></action>
39
+ <action method="addCss"><file>css/gene/braintree/idev.css</file></action>
40
  </reference>
41
  <reference name="before_body_end">
42
  <block type="gene_braintree/js" name="gene_braintree_setup" template="gene/braintree/js/setup.phtml" />
50
  </action>
51
  </block>
52
  </reference>
53
+ </idev_onestepcheckout_index>
54
+
55
+ <!-- Add in support for Magestores's one step checkout solution -->
56
+ <magestore_onestepcheckout_index>
57
+ <reference name="head">
58
+ <action method="addJs"><file>gene/braintree/braintree.js</file></action>
59
+ <action method="addJs"><file>gene/braintree/vzero.js</file></action>
60
+ <action method="addCss"><file>css/gene/braintree/magestore.css</file></action>
61
+ </reference>
62
+ <reference name="before_body_end">
63
+ <block type="gene_braintree/js" name="gene_braintree_setup" template="gene/braintree/js/setup.phtml" />
64
+ <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/magestore.phtml" />
65
+
66
+ <!-- We include device data at the end of the larger form -->
67
+ <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
68
+ <action method="setData">
69
+ <key>payment_form_id</key>
70
+ <value>onestepcheckout-form</value>
71
+ </action>
72
+ </block>
73
+ </reference>
74
+ </magestore_onestepcheckout_index>
75
+
76
+ <!-- Add in support for the Aheadworks one step checkout solution -->
77
+ <aw_onestepcheckout_index_index>
78
+ <reference name="head">
79
+ <action method="addJs"><file>gene/braintree/braintree.js</file></action>
80
+ <action method="addJs"><file>gene/braintree/vzero.js</file></action>
81
+ <action method="addCss"><file>css/gene/braintree/aheadworks.css</file></action>
82
+ </reference>
83
+ <reference name="before_body_end">
84
+ <block type="gene_braintree/js" name="gene_braintree_setup" template="gene/braintree/js/setup.phtml" />
85
+ <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/aheadworks.phtml" />
86
+
87
+ <!-- We include device data at the end of the larger form -->
88
+ <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
89
+ <action method="setData">
90
+ <key>payment_form_id</key>
91
+ <value>onestepcheckout-form</value>
92
+ </action>
93
+ </block>
94
+ </reference>
95
+ </aw_onestepcheckout_index_index>
96
+
97
+ <!-- Add in support for IWD's one step checkout solution -->
98
+ <opc_index_index>
99
+ <reference name="head">
100
+ <action method="addJs"><file>gene/braintree/braintree.js</file></action>
101
+ <action method="addJs"><file>gene/braintree/vzero.js</file></action>
102
+ <action method="addCss"><file>css/gene/braintree/iwd.css</file></action>
103
+ </reference>
104
+ <reference name="before_body_end">
105
+ <block type="gene_braintree/js" name="gene_braintree_setup" template="gene/braintree/js/setup.phtml" />
106
+ <block type="gene_braintree/js" name="gene_braintree_js" template="gene/braintree/js/iwd.phtml" />
107
+
108
+ <!-- We include device data at the end of the larger form -->
109
+ <block type="gene_braintree/js" name="gene_braintree_data" template="gene/braintree/js/data.phtml">
110
+ <action method="setData">
111
+ <key>payment_form_id</key>
112
+ <value>onestepcheckout-form</value>
113
+ </action>
114
+ </block>
115
+ </reference>
116
+ </opc_index_index>
117
 
118
  <checkout_onepage_paymentmethod>
119
  <reference name="root">
app/design/frontend/base/default/template/gene/braintree/creditcard.phtml CHANGED
@@ -7,13 +7,13 @@ $_code = $this->getMethodCode()
7
  <?php if($this->hasSavedDetails() && $this->getMethod()->isVaultEnabled()): ?>
8
 
9
  <label><?php echo $this->__('Saved Cards'); ?></label><br />
10
- <p style="padding-left: 0;"><?php echo $this->__('The following credit cards accounts are currently linked with your account.'); ?></p>
11
  <table cellspacing="0" cellpadding="0" id="creditcard-saved-accounts">
12
  <?php
13
  $count = 0;
14
  foreach($this->getSavedDetails() as $savedDetail):
15
  ?>
16
- <tr>
17
  <td width="20">
18
  <?php if($this->getMethod()->is3DEnabled()): ?>
19
  <input type="radio" name="payment[card_payment_method_token]" id="<?php echo $savedDetail->token; ?>" data-token="<?php echo $savedDetail->token; ?>" data-threedsecure-nonce="<?php echo $this->getMethod()->getThreeDSecureVaultNonce($savedDetail->token); ?>" value="threedsecure"<?php echo ($count == 0 ? ' checked="checked"' : ''); ?>/>
@@ -21,9 +21,9 @@ $_code = $this->getMethodCode()
21
  <input type="radio" name="payment[card_payment_method_token]" id="<?php echo $savedDetail->token; ?>" value="<?php echo $savedDetail->token; ?>"<?php echo ($count == 0 ? ' checked="checked"' : ''); ?>/>
22
  <?php endif; ?>
23
  </td>
24
- <td valign="middle">
25
  <label for="<?php echo $savedDetail->token; ?>" style="line-height: 48px;width: auto;">
26
- <img src="<?php echo $this->getSkinUrl('images/gene/braintree/' . $this->getCardIcon($savedDetail->cardType)) ?>" align="left" />&nbsp;&nbsp; xxxx - xxxx - xxxx - <?php echo $savedDetail->last4; ?> &nbsp;&nbsp;&nbsp; <em><?php echo $this->__('Expires:'); ?></em> <?php echo $savedDetail->expirationMonth; ?>/<?php echo $savedDetail->expirationYear; ?>
27
  </label>
28
  </td>
29
  </tr>
7
  <?php if($this->hasSavedDetails() && $this->getMethod()->isVaultEnabled()): ?>
8
 
9
  <label><?php echo $this->__('Saved Cards'); ?></label><br />
10
+ <p style="padding-left: 0;" class="saved-cards-intro"><?php echo $this->__('The following credit cards accounts are currently linked with your account.'); ?></p>
11
  <table cellspacing="0" cellpadding="0" id="creditcard-saved-accounts">
12
  <?php
13
  $count = 0;
14
  foreach($this->getSavedDetails() as $savedDetail):
15
  ?>
16
+ <tr valign="middle">
17
  <td width="20">
18
  <?php if($this->getMethod()->is3DEnabled()): ?>
19
  <input type="radio" name="payment[card_payment_method_token]" id="<?php echo $savedDetail->token; ?>" data-token="<?php echo $savedDetail->token; ?>" data-threedsecure-nonce="<?php echo $this->getMethod()->getThreeDSecureVaultNonce($savedDetail->token); ?>" value="threedsecure"<?php echo ($count == 0 ? ' checked="checked"' : ''); ?>/>
21
  <input type="radio" name="payment[card_payment_method_token]" id="<?php echo $savedDetail->token; ?>" value="<?php echo $savedDetail->token; ?>"<?php echo ($count == 0 ? ' checked="checked"' : ''); ?>/>
22
  <?php endif; ?>
23
  </td>
24
+ <td>
25
  <label for="<?php echo $savedDetail->token; ?>" style="line-height: 48px;width: auto;">
26
+ <img src="<?php echo $this->getSkinUrl('images/gene/braintree/' . $this->getCardIcon($savedDetail->cardType)) ?>" align="left" /><span class="saved-card-number">&nbsp;&nbsp; xxxx - xxxx - xxxx - <?php echo $savedDetail->last4; ?></span> &nbsp;&nbsp;&nbsp; <span class="saved-expiry-date"><em><?php echo $this->__('Expires:'); ?></em> <?php echo $savedDetail->expirationMonth; ?>/<?php echo $savedDetail->expirationYear; ?></span>
27
  </label>
28
  </td>
29
  </tr>
app/design/frontend/base/default/template/gene/braintree/js/aheadworks.phtml ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add in support for Aheadworks One Step Checkout
4
+ * http://ecommerce.aheadworks.com/magento-extensions/one-step-checkout.html
5
+ */
6
+ ?>
7
+ <!-- AHEADWORKS BRAINTREE SUPPORT -->
8
+ <script type="text/javascript">
9
+
10
+ // Wrap this in some error handling, just in case some checkouts attempt to include us twice
11
+ if(awPlaceOrderOriginal === undefined) {
12
+
13
+ // Store the original payment method
14
+ var awPlaceOrderOriginal = AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest;
15
+
16
+ // Intercept the save function
17
+ AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest = function () {
18
+
19
+ if ($('device_data')) {
20
+ // Device data should never be disabled
21
+ $('device_data').removeAttribute('disabled');
22
+ }
23
+
24
+ // Always attempt to update the card type on submission
25
+ if ($$('[data-genebraintree-name="number"]').first() != undefined) {
26
+ vzero.updateCardType($$('[data-genebraintree-name="number"]').first().value);
27
+ }
28
+
29
+ // Are we dealing with the credit card method?
30
+ if (awOSCPayment.currentMethod == 'gene_braintree_creditcard') {
31
+
32
+ // Do we want to pass any extra paramters into the updateData request
33
+ var parameters = {};
34
+
35
+ // If the billing address is selected and we're wanting to ship to that address we need to pass the addressId
36
+ if ($('billing-address-select') != undefined && $('billing-address-select').value != '') {
37
+ parameters.addressId = $('billing-address-select').value;
38
+ }
39
+
40
+ // Update the data as we're in a one step
41
+ vzero.updateData(
42
+ function () {
43
+
44
+ // Verify we're not using a saved address
45
+ if ($('billing-address-select') != undefined && $('billing-address-select').value == '' || $('billing-address-select') == undefined) {
46
+
47
+ // Grab these directly from the form and update
48
+ if ($('billing:firstname') != undefined && $('billing:lastname') != undefined) {
49
+ vzero.setBillingName($('billing:firstname').value + ' ' + $('billing:lastname').value);
50
+ }
51
+ if ($('billing:postcode') != undefined) {
52
+ vzero.setBillingPostcode($('billing:postcode').value);
53
+ }
54
+ }
55
+
56
+ // Process the card
57
+ vzero.process({
58
+ onSuccess: function () {
59
+
60
+ // Disable the standard credit card form so the values don't get passed through to the checkout
61
+ $$('#credit-card-form input, #credit-card-form select').each(function (formElement) {
62
+ if (formElement.id != 'creditcard-payment-nonce' && formElement.getAttribute('data-genebraintree-name') != 'cvv' && formElement.id != 'gene_braintree_creditcard_store_in_vault') {
63
+ formElement.setAttribute('disabled', 'disabled');
64
+ }
65
+ });
66
+
67
+ if ($('device_data')) {
68
+ // Always make sure device data is sent with the request
69
+ $('device_data').removeAttribute('disabled');
70
+ }
71
+
72
+ // Fire the original event and return the response
73
+ completeCheckoutResponse = awPlaceOrderOriginal.apply(this, arguments);
74
+
75
+ // Re-enable any form elements which were disabled
76
+ $$('#credit-card-form input, #credit-card-form select').each(function (formElement) {
77
+ formElement.removeAttribute('disabled');
78
+ });
79
+
80
+ // Run the original function
81
+ return completeCheckoutResponse;
82
+ }.bind(this),
83
+ onFailure: function () {
84
+
85
+ // Reset the waiting for the parent function
86
+ this.enablePlaceOrderButton();
87
+ this.hidePleaseWaitNotice();
88
+ this.hideOverlay();
89
+
90
+ }.bind(this)
91
+ });
92
+
93
+ }.bind(this),
94
+ parameters
95
+ );
96
+
97
+ // We're updating data don't do anything else for now
98
+ return false;
99
+
100
+ }
101
+
102
+ // Stop further processing
103
+ return awPlaceOrderOriginal.apply(this, arguments);
104
+
105
+ };
106
+
107
+ // It's not been ran so set it to false
108
+ var PayPalCompleteRan = false;
109
+
110
+ /**
111
+ * Function to run once PayPal has been completed
112
+ */
113
+ completePayPal = function (obj) {
114
+
115
+ // Check the flag to make sure we're good to run the function
116
+ if (!PayPalCompleteRan) {
117
+
118
+ // Mark the flag as true
119
+ PayPalCompleteRan = true;
120
+
121
+ // Force check
122
+ awOSCPayment.switchToMethod('gene_braintree_paypal');
123
+
124
+ // Re-enable the form
125
+ $('paypal-payment-nonce').removeAttribute('disabled');
126
+ $('paypal-payment-nonce').value = obj.nonce;
127
+
128
+ // Show the button again
129
+ hidePayPalButton();
130
+
131
+ // No longer running
132
+ checkoutRunning = false;
133
+
134
+ // Show the loading thing
135
+ awOSCForm.disablePlaceOrderButton();
136
+
137
+ if ($('device_data')) {
138
+ // Always make sure device data is sent with the request
139
+ $('device_data').removeAttribute('disabled');
140
+ }
141
+
142
+ // Run the complete checkout method
143
+ return awOSCForm.placeOrder();
144
+
145
+ }
146
+
147
+ };
148
+
149
+ // Flag to check if the PayPal button is already loading
150
+ var PayPalButtonLoading = false;
151
+
152
+ /**
153
+ * Easily add the PayPal button into the DOM
154
+ */
155
+ addPayPalButton = function () {
156
+
157
+ // Check we can locate the submit button
158
+ if ($('aw-onestepcheckout-place-order-button') != undefined && $('paypal-complete') == undefined && PayPalButtonLoading == false) {
159
+
160
+ // The button is loading
161
+ PayPalButtonLoading = true;
162
+
163
+ // As the PayPal button has to request data from the server show the loader
164
+ awOSCForm.disablePlaceOrderButton();
165
+
166
+ // Update the data contained within the classes
167
+ vzero.updateData(function () {
168
+
169
+ // The button is no longer loading
170
+ PayPalButtonLoading = false;
171
+
172
+ // Hide it once we're done
173
+ awOSCForm.enablePlaceOrderButton();
174
+
175
+ // Validate the payment method is still correct
176
+ if (awOSCPayment.currentMethod == 'gene_braintree_paypal' && $('paypal-complete') == undefined) {
177
+
178
+ // Set the flag to false as we've created a new button
179
+ PayPalCompleteRan = false;
180
+
181
+ // Hide the submit button
182
+ $('aw-onestepcheckout-place-order-button').hide();
183
+
184
+ // Add in our PayPal button
185
+ $('aw-onestepcheckout-place-order-button').insert({after: '<div id="paypal-complete"><label id="paypal-label"><?php echo $this->__('Complete checkout with'); ?> </label><div id="paypal-container"></div></div>'});
186
+
187
+ // Always stop the window from opening
188
+ $('paypal-complete').observe('click', function (event) {
189
+
190
+ // Validate the form before we open the PayPal modal window
191
+ if (!amscheckoutForm.validator.validate() || checkoutRunning) {
192
+
193
+ // Sadly we're unable to intercept the PayPal window in any other way then just hard closing it
194
+ vzeroPaypal.closePayPalWindow();
195
+ }
196
+ });
197
+
198
+ // Add in the PayPal button
199
+ vzeroPaypal.addPayPalButton({
200
+ onSuccess: completePayPal
201
+ });
202
+
203
+ }
204
+
205
+ });
206
+
207
+ } else if ($('paypal-complete') != undefined) {
208
+
209
+ // The button is loading
210
+ PayPalButtonLoading = true;
211
+
212
+ // As the PayPal button has to request data from the server show the loader
213
+ awOSCForm.disablePlaceOrderButton();
214
+
215
+ // Update the data contained within the classes
216
+ vzero.updateData(function () {
217
+
218
+ // The button is no longer loading
219
+ PayPalButtonLoading = false;
220
+
221
+ // Hide it once we're done
222
+ awOSCForm.enablePlaceOrderButton();
223
+
224
+ // Validate the payment method is still correct
225
+ if (awOSCPayment.currentMethod == 'gene_braintree_paypal') {
226
+
227
+ // Set the flag to false as we've created a new button
228
+ PayPalCompleteRan = false;
229
+
230
+ // Hide the submit button
231
+ $('aw-onestepcheckout-place-order-button').hide();
232
+
233
+ // Add in the PayPal button
234
+ $('paypal-complete').show();
235
+
236
+ }
237
+
238
+ });
239
+
240
+ }
241
+
242
+ };
243
+
244
+ /**
245
+ * As we need to remove the PayPal button in multiple places
246
+ */
247
+ hidePayPalButton = function () {
248
+
249
+ // If the user has selected a different payment method make some modifications
250
+ if ($('aw-onestepcheckout-place-order-button') != undefined) {
251
+ $('aw-onestepcheckout-place-order-button').show();
252
+ }
253
+
254
+ // Remove the PayPal element
255
+ if ($('paypal-complete') != undefined) {
256
+ $('paypal-complete').hide();
257
+ }
258
+
259
+ };
260
+
261
+ // Check if the payment method is the default
262
+ if (awOSCPayment !== undefined) {
263
+ if ((awOSCPayment.currentMethod == 'gene_braintree_paypal' && $('paypal-saved-accounts') == undefined) || ($$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other')) {
264
+
265
+ // Verify that vzero is defined before attempting to use it
266
+ if (typeof vzeroPaypal !== 'undefined') {
267
+
268
+ // Always set the amount as it's needed within 3D secure requests
269
+ vzeroPaypal.setPricing('<?php echo Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getGrandTotal(); ?>', '<?php echo Mage::getSingleton('checkout/cart')->getQuote()->getBaseCurrencyCode(); ?>');
270
+ }
271
+
272
+ addPayPalButton();
273
+ }
274
+ }
275
+
276
+ // Store the original payment method
277
+ var aWPaymentOriginal = AWOnestepcheckoutPayment.prototype.switchToMethod;
278
+
279
+ // Intercept the save function
280
+ AWOnestepcheckoutPayment.prototype.switchToMethod = function (method) {
281
+
282
+ // Make sure the paypal complete action hasn't just ran
283
+ if (PayPalCompleteRan != true) {
284
+
285
+ // Detect PayPal choice
286
+ if (method == 'gene_braintree_paypal') {
287
+
288
+ if ($('paypal-saved-accounts') == undefined) {
289
+ addPayPalButton();
290
+ } else if ($('paypal-saved-accounts') != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other') {
291
+ addPayPalButton();
292
+ } else {
293
+ hidePayPalButton();
294
+ }
295
+
296
+ } else {
297
+ hidePayPalButton();
298
+ }
299
+ }
300
+
301
+
302
+ // Run the original function
303
+ return aWPaymentOriginal.apply(this, arguments);
304
+
305
+ };
306
+
307
+ // What should happen if the user closes the 3D secure window?
308
+ vzero.close3dSecureMethod(function () {
309
+
310
+ // Re-tokenize all the saved cards
311
+ vzero.tokenize3dSavedCards(function () {
312
+
313
+ // Hide the loading
314
+ awOSCForm.enablePlaceOrderButton();
315
+ awOSCForm.hidePleaseWaitNotice();
316
+ awOSCForm.hideOverlay();
317
+
318
+ });
319
+
320
+ });
321
+
322
+ // Observe the card type here as it'll fail within creditCard.phtml
323
+ vzero.observeCardType();
324
+
325
+ // Observe all Ajax requests for changes
326
+ vzero.observeAjaxRequests(function () {
327
+
328
+ // If the method is PayPal remove and re-add the PayPal button
329
+ if (awOSCPayment.currentMethod == 'gene_braintree_paypal') {
330
+ hidePayPalButton();
331
+ addPayPalButton();
332
+ } else {
333
+ vzero.updateData();
334
+ }
335
+
336
+ });
337
+
338
+ }
339
+
340
+ </script>
341
+ <style type="text/css">
342
+ #braintree-paypal-button {
343
+ line-height: unset;
344
+ padding: 0;
345
+ float: left;
346
+ }
347
+ #braintree-paypal-loggedin {
348
+ display: none!important;
349
+ }
350
+ #braintree-paypal-loggedout {
351
+ display: block!important;
352
+ }
353
+ </style>
app/design/frontend/base/default/template/gene/braintree/js/amasty.phtml CHANGED
@@ -4,6 +4,7 @@
4
  * https://amasty.com/single-step-checkout.html
5
  */
6
  ?>
 
7
  <script type="text/javascript">
8
 
9
  // Older versions of the checkout don't contain this variable
@@ -20,8 +21,10 @@
20
  // Re-define the original method so we can do some jazz with it
21
  completeCheckout = function () {
22
 
23
- // Device data should never be disabled
24
- $('device_data').removeAttribute('disabled');
 
 
25
 
26
  // Always attempt to update the card type on submission
27
  if($$('[data-genebraintree-name="number"]').first() != undefined) {
@@ -76,8 +79,10 @@
76
  }
77
  });
78
 
79
- // Always make sure device data is sent with the request
80
- $('device_data').removeAttribute('disabled');
 
 
81
 
82
  // No longer running
83
  checkoutRunning = false;
@@ -153,8 +158,10 @@
153
  // Show the loading thing
154
  showLoading();
155
 
156
- // Always make sure device data is sent with the request
157
- $('device_data').removeAttribute('disabled');
 
 
158
 
159
  // Run the complete checkout method
160
  return completeCheckout();
@@ -351,11 +358,16 @@
351
  // What should happen if the user closes the 3D secure window?
352
  vzero.close3dSecureMethod(function() {
353
 
354
- // Hide the loading
355
- hideLoading();
 
 
 
356
 
357
- // Check is running
358
- checkoutRunning = false;
 
 
359
 
360
  });
361
 
@@ -378,11 +390,6 @@
378
  }
379
  </script>
380
  <style type="text/css">
381
- #paypal-label {
382
- line-height: 44px;
383
- float: left;
384
- margin-right: 12px;
385
- }
386
  #braintree-paypal-button {
387
  line-height: unset;
388
  padding: 0;
4
  * https://amasty.com/single-step-checkout.html
5
  */
6
  ?>
7
+ <!-- AMASTY BRAINTREE SUPPORT -->
8
  <script type="text/javascript">
9
 
10
  // Older versions of the checkout don't contain this variable
21
  // Re-define the original method so we can do some jazz with it
22
  completeCheckout = function () {
23
 
24
+ if($('device_data')) {
25
+ // Device data should never be disabled
26
+ $('device_data').removeAttribute('disabled');
27
+ }
28
 
29
  // Always attempt to update the card type on submission
30
  if($$('[data-genebraintree-name="number"]').first() != undefined) {
79
  }
80
  });
81
 
82
+ if($('device_data')) {
83
+ // Always make sure device data is sent with the request
84
+ $('device_data').removeAttribute('disabled');
85
+ }
86
 
87
  // No longer running
88
  checkoutRunning = false;
158
  // Show the loading thing
159
  showLoading();
160
 
161
+ if($('device_data')) {
162
+ // Always make sure device data is sent with the request
163
+ $('device_data').removeAttribute('disabled');
164
+ }
165
 
166
  // Run the complete checkout method
167
  return completeCheckout();
358
  // What should happen if the user closes the 3D secure window?
359
  vzero.close3dSecureMethod(function() {
360
 
361
+ // Re-tokenize all the saved cards
362
+ vzero.tokenize3dSavedCards(function() {
363
+
364
+ // Hide the loading
365
+ hideLoading();
366
 
367
+ // Check is running
368
+ checkoutRunning = false;
369
+
370
+ });
371
 
372
  });
373
 
390
  }
391
  </script>
392
  <style type="text/css">
 
 
 
 
 
393
  #braintree-paypal-button {
394
  line-height: unset;
395
  padding: 0;
app/design/frontend/base/default/template/gene/braintree/js/data.phtml CHANGED
@@ -4,12 +4,18 @@
4
  */
5
  ?>
6
  <script src="https://js.braintreegateway.com/v1/braintree-data.js"></script>
7
- <script>
8
- <?php if($kountId = Mage::getStoreConfig('payment/gene_braintree_creditcard/kount_merchant_id')): ?>
9
- var env = BraintreeData.environments.production.withId("<?php echo $kountId; ?>");
10
- <?php else: ?>
11
- var env = BraintreeData.environments.<?php echo Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_ENVIRONMENT_PATH); ?>;
12
- <?php endif; ?>
13
- BraintreeData.setup("<?php echo Mage::getStoreConfig(Gene_Braintree_Model_Wrapper_Braintree::BRAINTREE_MERCHANT_ID_PATH); ?>", '<?php echo ($this->getPaymentFormId() ? $this->getPaymentFormId() : 'co-payment-form'); ?>', env);
 
 
 
 
 
 
14
  </script>
15
 
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
+ }
20
  </script>
21
 
app/design/frontend/base/default/template/gene/braintree/js/default.phtml CHANGED
@@ -3,6 +3,7 @@
3
  * Intercept various functions for the default checkout flow
4
  */
5
  ?>
 
6
  <script type="text/javascript">
7
 
8
  // Store the current paymentMethod
@@ -52,8 +53,10 @@
52
  }
53
  });
54
 
55
- // Always make sure device data is sent with the request
56
- $('device_data').removeAttribute('disabled');
 
 
57
 
58
  // Fire the original event and return the response
59
  paymentResponse = paymentOriginal.apply(paymentThis, paymentArgs);
@@ -165,8 +168,10 @@
165
  });
166
  }
167
 
168
- // Always make sure device data is sent with the request
169
- $('device_data').removeAttribute('disabled');
 
 
170
 
171
  // Do the original action
172
  var reviewSaveResponse = reviewSaveOriginal.apply(this, arguments);
3
  * Intercept various functions for the default checkout flow
4
  */
5
  ?>
6
+ <!-- DEFAULT BRAINTREE SUPPORT -->
7
  <script type="text/javascript">
8
 
9
  // Store the current paymentMethod
53
  }
54
  });
55
 
56
+ if($('device_data')) {
57
+ // Always make sure device data is sent with the request
58
+ $('device_data').removeAttribute('disabled');
59
+ }
60
 
61
  // Fire the original event and return the response
62
  paymentResponse = paymentOriginal.apply(paymentThis, paymentArgs);
168
  });
169
  }
170
 
171
+ if($('device_data')) {
172
+ // Always make sure device data is sent with the request
173
+ $('device_data').removeAttribute('disabled');
174
+ }
175
 
176
  // Do the original action
177
  var reviewSaveResponse = reviewSaveOriginal.apply(this, arguments);
app/design/frontend/base/default/template/gene/braintree/js/idev.phtml CHANGED
@@ -4,411 +4,415 @@
4
  * http://onestepcheckout.com
5
  */
6
  ?>
 
7
  <script type="text/javascript">
8
 
9
- // Flag to skip over our interception if needed
10
- var processedVZero = false;
11
 
12
- // Hook onto the event that submits the entire form
13
- // Apparently there may be more than one of these buttons
14
- $$('.onestepcheckout-place-order').each(function(elem){
15
 
16
- // Observe the click event
17
- elem.observe('click', function(e) {
18
 
19
- // Device data should never be disabled
20
- if($('device_data') != undefined) {
21
- $('device_data').removeAttribute('disabled');
22
- }
23
 
24
- // Check to see if we've already processed the form?
25
- if(!processedVZero) {
26
 
27
- // Always attempt to update the card type on submission
28
- if($$('[data-genebraintree-name="number"]').first() != undefined) {
29
- vzero.updateCardType($$('[data-genebraintree-name="number"]').first().value);
30
  }
31
 
32
- // First validate the form
33
- var form = new VarienForm('onestepcheckout-form');
34
 
35
- // Validate the form like the parent method
36
- if(!form.validator.validate()) {
 
 
37
 
38
- // We want to stop any further events
39
- Event.stop(e);
40
 
41
- } else {
 
42
 
43
- // Are we dealing with the credit card method?
44
- if (payment.currentMethod == 'gene_braintree_creditcard') {
45
 
46
- // Set this flag to stop the other function from firing
47
- already_placing_order = true;
48
 
49
- startLoading();
 
50
 
51
- // Do we want to pass any extra paramters into the updateData request
52
- var parameters = {};
53
 
54
- // If the billing address is selected and we're wanting to ship to that address we need to pass the addressId
55
- if($('billing-address-select') != undefined && $('billing-address-select').value != '')
56
- {
57
- parameters.addressId = $('billing-address-select').value;
58
- }
59
 
60
- // Update the data as we're in a one step
61
- vzero.updateData(
62
- function() {
63
 
64
- // Verify we're not using a saved address
65
- if($('billing-address-select') != undefined && $('billing-address-select').value == '' || $('billing-address-select') == undefined) {
 
 
66
 
67
- // Grab these directly from the form and update
68
- if ($('billing:firstname') != undefined && $('billing:lastname') != undefined) {
69
- vzero.setBillingName($('billing:firstname').value + ' ' + $('billing:lastname').value);
70
- }
71
- if ($('billing:postcode') != undefined) {
72
- vzero.setBillingPostcode($('billing:postcode').value);
73
- }
74
 
75
- }
 
76
 
77
- // Process the card
78
- vzero.process({
79
- onSuccess: function () {
 
 
 
 
80
 
81
- // Disable the standard credit card form so the values don't get passed through to the checkout
82
- $$('#credit-card-form input, #credit-card-form select').each(function (formElement) {
83
- if (formElement.id != 'creditcard-payment-nonce' && formElement.getAttribute('data-genebraintree-name') != 'cvv' && formElement.id != 'gene_braintree_creditcard_store_in_vault') {
84
- formElement.setAttribute('disabled', 'disabled');
85
- }
86
- });
87
 
88
- stopLoading();
 
 
89
 
90
- // Always make sure device data is sent with the request
91
- $('device_data').removeAttribute('disabled');
 
 
 
 
92
 
93
- // Set the flag to true
94
- processedVZero = true;
95
 
96
- // We're no longer stopping the events
97
- already_placing_order = false;
98
 
99
- // Fire the same event over again
100
- $(elem).click();
101
- },
102
- onFailure: function() {
103
 
104
- // Set the flag to true
105
- processedVZero = false;
106
 
107
- stopLoading();
 
 
 
108
 
109
- // We're no longer stopping the events
110
- already_placing_order = false;
111
 
112
- }
113
- });
114
- },
115
- parameters
116
- );
117
 
 
 
 
 
 
 
 
118
  }
119
- }
120
 
121
- }
122
 
 
123
  });
124
- });
125
 
126
- // It's not been ran so set it to false
127
- var PayPalCompleteRan = false;
128
 
129
- /**
130
- * Wrap the functionality needed to start loading
131
- **/
132
- startLoading = function(noMessage) {
133
 
134
- var submitElement = $('onestepcheckout-place-order');
135
 
136
- /* Disable button to avoid multiple clicks */
137
- submitElement.removeClassName('orange').addClassName('grey');
138
- submitElement.disabled = true;
139
 
140
- // Add in our loader event
141
- var loaderElement = new Element('span').
142
- addClassName('onestepcheckout-place-order-loading');
143
 
144
- if(noMessage != true) {
145
- loaderElement.update('<?php echo $this->__('Please wait, processing your order...'); ?>');
146
- }
147
 
148
- // Append it into the correct area
149
- submitElement.parentNode.appendChild(loaderElement);
150
 
151
- };
152
 
153
- /**
154
- * Wrap the functionality to stop things loading
155
- **/
156
- stopLoading = function() {
157
 
158
- // Grab the submit button
159
- submitElement = $('onestepcheckout-place-order');
160
 
161
- // Remove the loading stuff on the form
162
- submitElement.addClassName('orange').removeClassName('grey');
163
- submitElement.removeAttribute('disabled');
164
 
165
- // Remove the loader element
166
- if(submitElement.next('.onestepcheckout-place-order-loading') != undefined) {
167
- submitElement.next('.onestepcheckout-place-order-loading').remove();
168
- }
169
 
170
- };
171
 
172
- /**
173
- * Function to run once PayPal has been completed
174
- */
175
- completePayPal = function(obj) {
176
 
177
- // Check the flag to make sure we're good to run the function
178
- if(!PayPalCompleteRan) {
179
 
180
- // Mark the flag as true
181
- PayPalCompleteRan = true;
182
 
183
- // Force check
184
- payment.switchMethod('gene_braintree_paypal');
185
 
186
- // Re-enable the form
187
- $('paypal-payment-nonce').removeAttribute('disabled');
188
- $('paypal-payment-nonce').value = obj.nonce;
189
 
190
- // We have to disable the credit card one
191
- $('creditcard-payment-nonce').setAttribute('disabled', 'disabled');
192
 
193
- // Hide the button
194
- hidePayPalButton();
195
 
196
- // Always make sure device data is sent with the request
197
- $('device_data').removeAttribute('disabled');
198
 
199
- // Submit the checkout
200
- $$('.onestepcheckout-place-order').first().click();
201
 
202
- }
203
 
204
- };
205
 
206
- // Flag to check if the PayPal button is already loading
207
- var PayPalButtonLoading = false;
208
 
209
- /**
210
- * Easily add the PayPal button into the DOM
211
- */
212
- addPayPalButton = function() {
213
 
214
- // Check we can locate the submit button
215
- if($('onestepcheckout-place-order') != undefined && $('paypal-complete') == undefined && PayPalButtonLoading == false) {
216
 
217
- // The button is loading
218
- PayPalButtonLoading = true;
219
 
220
- // Start the loading process
221
- startLoading(true);
222
 
223
- // Update the data contained within the classes
224
- vzero.updateData(function () {
225
 
226
- // Cancel said loading process
227
- stopLoading();
228
 
229
- // The button is no longer loading
230
- PayPalButtonLoading = false;
231
 
232
- // Validate the payment method is still correct
233
- if(payment.currentMethod == 'gene_braintree_paypal' && $('paypal-complete') == undefined) {
234
 
235
- // Set the flag to false as we've created a new button
236
- PayPalCompleteRan = false;
237
 
238
- // Hide the submit button
239
- $('onestepcheckout-place-order').hide();
240
 
241
- // Add in our PayPal button
242
- $('onestepcheckout-place-order').up().insert('<div id="paypal-complete"><div id="paypal-container"></div><label id="paypal-label"><?php echo $this->__('Complete checkout with'); ?> </label></div>');
243
 
244
- // Always stop the window from opening
245
- $('paypal-complete').observe('click', function(event) {
246
 
247
- // First validate the form
248
- var form = new VarienForm('onestepcheckout-form');
249
 
250
- // Validate the form like the parent method
251
- if(!form.validator.validate()) {
252
 
253
- // Sadly we're unable to intercept the PayPal window in any other way then just hard closing it
254
- vzeroPaypal.closePayPalWindow();
255
- }
256
- });
257
 
258
- // Add in the PayPal button
259
- vzeroPaypal.addPayPalButton({
260
- onSuccess: completePayPal
261
- });
262
- }
263
 
264
- });
265
 
266
- } else if($('paypal-complete') != undefined && PayPalButtonLoading == false) {
267
 
268
- // The button is loading
269
- PayPalButtonLoading = true;
270
 
271
- // Start the loading process
272
- startLoading(true);
273
 
274
- // Update the data contained within the classes
275
- vzero.updateData(function () {
276
 
277
- // The button is no longer loading
278
- PayPalButtonLoading = false;
279
 
280
- // Cancel said loading process
281
- stopLoading();
282
 
283
- // Validate the payment method is still correct
284
- if(payment.currentMethod == 'gene_braintree_paypal') {
285
 
286
- // Set the flag to false as we've created a new button
287
- PayPalCompleteRan = false;
288
 
289
- // Hide the submit button
290
- $('onestepcheckout-place-order').hide();
291
 
292
- // Add in our PayPal button
293
- $('paypal-complete').show();
294
- }
295
 
296
- });
297
 
298
- }
299
 
300
- };
301
 
302
- /**
303
- * As we need to remove the PayPal button in multiple places
304
- */
305
- hidePayPalButton = function() {
306
 
307
- // Just in case things are still loading
308
- stopLoading();
309
 
310
- // If the user has selected a different payment method make some modifications
311
- if($('onestepcheckout-place-order') != undefined) {
312
- $('onestepcheckout-place-order').show();
313
- }
314
 
315
- // Remove the PayPal element
316
- if($('paypal-complete') != undefined) {
317
- $('paypal-complete').hide();
318
- }
319
 
320
- };
321
 
322
- // Check if the payment method is the default
323
- if(payment != undefined) {
324
- if((payment.currentMethod == 'gene_braintree_paypal' && $('paypal-saved-accounts') == undefined) || ($$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other')) {
325
 
326
- // Verify that vzero is defined before attempting to use it
327
- if(typeof vzeroPaypal !== 'undefined') {
328
 
329
- // Set the amount for the PayPal modal window
330
- vzeroPaypal.setPricing('<?php echo Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getGrandTotal(); ?>', '<?php echo Mage::getSingleton('checkout/cart')->getQuote()->getBaseCurrencyCode(); ?>');
331
- }
332
 
333
- addPayPalButton();
 
334
  }
335
- }
336
 
337
- // Store the original payment method
338
- var paymentOriginal = Payment.prototype.switchMethod;
339
 
340
- // Intercept the save function
341
- Payment.prototype.switchMethod = function (method) {
342
 
343
- // Detect PayPal choice
344
- if(method == 'gene_braintree_paypal') {
 
 
 
 
 
 
 
 
345
 
346
- if($('paypal-saved-accounts') == undefined) {
347
- addPayPalButton();
348
- } else if($('paypal-saved-accounts') != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other') {
349
- addPayPalButton();
350
  } else {
351
  hidePayPalButton();
352
  }
353
 
354
- } else {
355
- hidePayPalButton();
356
- }
357
 
 
 
358
 
359
- // Run the original function
360
- return paymentOriginal.apply(this, arguments);
361
 
362
- };
 
363
 
364
- // If we have any saved accounts we'll need to do something jammy
365
- if($$('#paypal-saved-accounts input[type=radio]').first() != undefined) {
366
 
367
- // Loop through each radio button
368
- $$('#paypal-saved-accounts input[type=radio]').each(function (savedAccount) {
 
 
 
 
 
 
 
 
369
 
370
- // Observe them changing
371
- Event.observe(savedAccount, 'click', function (ele) {
372
- if(savedAccount.value == 'other') {
373
- addPayPalButton();
374
- } else {
375
- hidePayPalButton();
376
- }
377
  });
 
378
  });
379
- }
380
 
381
- // What should happen if the user closes the 3D secure window?
382
- vzero.close3dSecureMethod(function() {
383
- stopLoading();
384
- });
385
 
386
- // Observe all Ajax requests for changes
387
- vzero.observeAjaxRequests(function() {
 
 
 
 
 
388
 
389
- // If the method is PayPal remove and re-add the PayPal button
390
- if(payment.currentMethod == 'gene_braintree_paypal') {
391
- hidePayPalButton();
392
- addPayPalButton();
393
- } else {
394
- vzero.updateData();
395
- }
396
 
397
- });
398
 
399
  </script>
400
 
401
  <!-- Fix some minor styling issues with our nested form-list -->
402
  <style type="text/css">
403
- #credit-card-form .form-list {
404
- margin: 10px 0 0 0!important;
405
- padding: 0!important;
406
- border: 0!important;
407
- }
408
- #credit-card-form .form-list:before, #credit-card-form .form-list:after {
409
- border: 0!important;
410
- }
411
-
412
  #paypal-container {
413
  float: right;
414
  }
4
  * http://onestepcheckout.com
5
  */
6
  ?>
7
+ <!-- IDEV BRAINTREE SUPPORT -->
8
  <script type="text/javascript">
9
 
10
+ // Wrap this in some error handling, just in case some checkouts attempt to include us twice
11
+ if(iDevInit === undefined) {
12
 
13
+ // Set our flag that we've ran the init for this checkout
14
+ var iDevInit = true;
 
15
 
16
+ // Flag to skip over our interception if needed
17
+ var processedVZero = false;
18
 
19
+ // Hook onto the event that submits the entire form
20
+ // Apparently there may be more than one of these buttons
21
+ $$('.onestepcheckout-place-order').each(function (elem) {
 
22
 
23
+ // Observe the click event
24
+ elem.observe('click', function (e) {
25
 
26
+ // Device data should never be disabled
27
+ if ($('device_data') != undefined) {
28
+ $('device_data').removeAttribute('disabled');
29
  }
30
 
31
+ // Check to see if we've already processed the form?
32
+ if (!processedVZero) {
33
 
34
+ // Always attempt to update the card type on submission
35
+ if ($$('[data-genebraintree-name="number"]').first() != undefined) {
36
+ vzero.updateCardType($$('[data-genebraintree-name="number"]').first().value);
37
+ }
38
 
39
+ // First validate the form
40
+ var form = new VarienForm('onestepcheckout-form');
41
 
42
+ // Validate the form like the parent method
43
+ if (!form.validator.validate()) {
44
 
45
+ // We want to stop any further events
46
+ Event.stop(e);
47
 
48
+ } else {
 
49
 
50
+ // Are we dealing with the credit card method?
51
+ if (payment.currentMethod == 'gene_braintree_creditcard') {
52
 
53
+ // Set this flag to stop the other function from firing
54
+ already_placing_order = true;
55
 
56
+ startLoading();
 
 
 
 
57
 
58
+ // Do we want to pass any extra paramters into the updateData request
59
+ var parameters = {};
 
60
 
61
+ // If the billing address is selected and we're wanting to ship to that address we need to pass the addressId
62
+ if ($('billing-address-select') != undefined && $('billing-address-select').value != '') {
63
+ parameters.addressId = $('billing-address-select').value;
64
+ }
65
 
66
+ // Update the data as we're in a one step
67
+ vzero.updateData(
68
+ function () {
 
 
 
 
69
 
70
+ // Verify we're not using a saved address
71
+ if ($('billing-address-select') != undefined && $('billing-address-select').value == '' || $('billing-address-select') == undefined) {
72
 
73
+ // Grab these directly from the form and update
74
+ if ($('billing:firstname') != undefined && $('billing:lastname') != undefined) {
75
+ vzero.setBillingName($('billing:firstname').value + ' ' + $('billing:lastname').value);
76
+ }
77
+ if ($('billing:postcode') != undefined) {
78
+ vzero.setBillingPostcode($('billing:postcode').value);
79
+ }
80
 
81
+ }
 
 
 
 
 
82
 
83
+ // Process the card
84
+ vzero.process({
85
+ onSuccess: function () {
86
 
87
+ // Disable the standard credit card form so the values don't get passed through to the checkout
88
+ $$('#credit-card-form input, #credit-card-form select').each(function (formElement) {
89
+ if (formElement.id != 'creditcard-payment-nonce' && formElement.getAttribute('data-genebraintree-name') != 'cvv' && formElement.id != 'gene_braintree_creditcard_store_in_vault') {
90
+ formElement.setAttribute('disabled', 'disabled');
91
+ }
92
+ });
93
 
94
+ stopLoading();
 
95
 
96
+ // Always make sure device data is sent with the request
97
+ $('device_data').removeAttribute('disabled');
98
 
99
+ // Set the flag to true
100
+ processedVZero = true;
 
 
101
 
102
+ // We're no longer stopping the events
103
+ already_placing_order = false;
104
 
105
+ // Fire the same event over again
106
+ $(elem).click();
107
+ },
108
+ onFailure: function () {
109
 
110
+ // Set the flag to true
111
+ processedVZero = false;
112
 
113
+ stopLoading();
114
+
115
+ // We're no longer stopping the events
116
+ already_placing_order = false;
 
117
 
118
+ }
119
+ });
120
+ },
121
+ parameters
122
+ );
123
+
124
+ }
125
  }
 
126
 
127
+ }
128
 
129
+ });
130
  });
 
131
 
132
+ // It's not been ran so set it to false
133
+ var PayPalCompleteRan = false;
134
 
135
+ /**
136
+ * Wrap the functionality needed to start loading
137
+ **/
138
+ startLoading = function (noMessage) {
139
 
140
+ var submitElement = $('onestepcheckout-place-order');
141
 
142
+ /* Disable button to avoid multiple clicks */
143
+ submitElement.removeClassName('orange').addClassName('grey');
144
+ submitElement.disabled = true;
145
 
146
+ // Add in our loader event
147
+ var loaderElement = new Element('span').
148
+ addClassName('onestepcheckout-place-order-loading');
149
 
150
+ if (noMessage != true) {
151
+ loaderElement.update('<?php echo $this->__('Please wait, processing your order...'); ?>');
152
+ }
153
 
154
+ // Append it into the correct area
155
+ submitElement.parentNode.appendChild(loaderElement);
156
 
157
+ };
158
 
159
+ /**
160
+ * Wrap the functionality to stop things loading
161
+ **/
162
+ stopLoading = function () {
163
 
164
+ // Grab the submit button
165
+ submitElement = $('onestepcheckout-place-order');
166
 
167
+ // Remove the loading stuff on the form
168
+ submitElement.addClassName('orange').removeClassName('grey');
169
+ submitElement.removeAttribute('disabled');
170
 
171
+ // Remove the loader element
172
+ if (submitElement.next('.onestepcheckout-place-order-loading') != undefined) {
173
+ submitElement.next('.onestepcheckout-place-order-loading').remove();
174
+ }
175
 
176
+ };
177
 
178
+ /**
179
+ * Function to run once PayPal has been completed
180
+ */
181
+ completePayPal = function (obj) {
182
 
183
+ // Check the flag to make sure we're good to run the function
184
+ if (!PayPalCompleteRan) {
185
 
186
+ // Mark the flag as true
187
+ PayPalCompleteRan = true;
188
 
189
+ // Force check
190
+ payment.switchMethod('gene_braintree_paypal');
191
 
192
+ // Re-enable the form
193
+ $('paypal-payment-nonce').removeAttribute('disabled');
194
+ $('paypal-payment-nonce').value = obj.nonce;
195
 
196
+ // We have to disable the credit card one
197
+ $('creditcard-payment-nonce').setAttribute('disabled', 'disabled');
198
 
199
+ // Hide the button
200
+ hidePayPalButton();
201
 
202
+ // Always make sure device data is sent with the request
203
+ $('device_data').removeAttribute('disabled');
204
 
205
+ // Submit the checkout
206
+ $$('.onestepcheckout-place-order').first().click();
207
 
208
+ }
209
 
210
+ };
211
 
212
+ // Flag to check if the PayPal button is already loading
213
+ var PayPalButtonLoading = false;
214
 
215
+ /**
216
+ * Easily add the PayPal button into the DOM
217
+ */
218
+ addPayPalButton = function () {
219
 
220
+ // Check we can locate the submit button
221
+ if ($('onestepcheckout-place-order') != undefined && $('paypal-complete') == undefined && PayPalButtonLoading == false) {
222
 
223
+ // The button is loading
224
+ PayPalButtonLoading = true;
225
 
226
+ // Start the loading process
227
+ startLoading(true);
228
 
229
+ // Update the data contained within the classes
230
+ vzero.updateData(function () {
231
 
232
+ // Cancel said loading process
233
+ stopLoading();
234
 
235
+ // The button is no longer loading
236
+ PayPalButtonLoading = false;
237
 
238
+ // Validate the payment method is still correct
239
+ if (payment.currentMethod == 'gene_braintree_paypal' && $('paypal-complete') == undefined) {
240
 
241
+ // Set the flag to false as we've created a new button
242
+ PayPalCompleteRan = false;
243
 
244
+ // Hide the submit button
245
+ $('onestepcheckout-place-order').hide();
246
 
247
+ // Add in our PayPal button
248
+ $('onestepcheckout-place-order').up().insert('<div id="paypal-complete"><div id="paypal-container"></div><label id="paypal-label"><?php echo $this->__('Complete checkout with'); ?> </label></div>');
249
 
250
+ // Always stop the window from opening
251
+ $('paypal-complete').observe('click', function (event) {
252
 
253
+ // First validate the form
254
+ var form = new VarienForm('onestepcheckout-form');
255
 
256
+ // Validate the form like the parent method
257
+ if (!form.validator.validate()) {
258
 
259
+ // Sadly we're unable to intercept the PayPal window in any other way then just hard closing it
260
+ vzeroPaypal.closePayPalWindow();
261
+ }
262
+ });
263
 
264
+ // Add in the PayPal button
265
+ vzeroPaypal.addPayPalButton({
266
+ onSuccess: completePayPal
267
+ });
268
+ }
269
 
270
+ });
271
 
272
+ } else if ($('paypal-complete') != undefined && PayPalButtonLoading == false) {
273
 
274
+ // The button is loading
275
+ PayPalButtonLoading = true;
276
 
277
+ // Start the loading process
278
+ startLoading(true);
279
 
280
+ // Update the data contained within the classes
281
+ vzero.updateData(function () {
282
 
283
+ // The button is no longer loading
284
+ PayPalButtonLoading = false;
285
 
286
+ // Cancel said loading process
287
+ stopLoading();
288
 
289
+ // Validate the payment method is still correct
290
+ if (payment.currentMethod == 'gene_braintree_paypal') {
291
 
292
+ // Set the flag to false as we've created a new button
293
+ PayPalCompleteRan = false;
294
 
295
+ // Hide the submit button
296
+ $('onestepcheckout-place-order').hide();
297
 
298
+ // Add in our PayPal button
299
+ $('paypal-complete').show();
300
+ }
301
 
302
+ });
303
 
304
+ }
305
 
306
+ };
307
 
308
+ /**
309
+ * As we need to remove the PayPal button in multiple places
310
+ */
311
+ hidePayPalButton = function () {
312
 
313
+ // Just in case things are still loading
314
+ stopLoading();
315
 
316
+ // If the user has selected a different payment method make some modifications
317
+ if ($('onestepcheckout-place-order') != undefined) {
318
+ $('onestepcheckout-place-order').show();
319
+ }
320
 
321
+ // Remove the PayPal element
322
+ if ($('paypal-complete') != undefined) {
323
+ $('paypal-complete').hide();
324
+ }
325
 
326
+ };
327
 
328
+ // Check if the payment method is the default
329
+ if (payment != undefined) {
330
+ if ((payment.currentMethod == 'gene_braintree_paypal' && $('paypal-saved-accounts') == undefined) || ($$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other')) {
331
 
332
+ // Verify that vzero is defined before attempting to use it
333
+ if (typeof vzeroPaypal !== 'undefined') {
334
 
335
+ // Set the amount for the PayPal modal window
336
+ vzeroPaypal.setPricing('<?php echo Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getGrandTotal(); ?>', '<?php echo Mage::getSingleton('checkout/cart')->getQuote()->getBaseCurrencyCode(); ?>');
337
+ }
338
 
339
+ addPayPalButton();
340
+ }
341
  }
 
342
 
343
+ // Store the original payment method
344
+ var paymentOriginal = Payment.prototype.switchMethod;
345
 
346
+ // Intercept the save function
347
+ Payment.prototype.switchMethod = function (method) {
348
 
349
+ // Detect PayPal choice
350
+ if (method == 'gene_braintree_paypal') {
351
+
352
+ if ($('paypal-saved-accounts') == undefined) {
353
+ addPayPalButton();
354
+ } else if ($('paypal-saved-accounts') != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other') {
355
+ addPayPalButton();
356
+ } else {
357
+ hidePayPalButton();
358
+ }
359
 
 
 
 
 
360
  } else {
361
  hidePayPalButton();
362
  }
363
 
 
 
 
364
 
365
+ // Run the original function
366
+ return paymentOriginal.apply(this, arguments);
367
 
368
+ };
 
369
 
370
+ // If we have any saved accounts we'll need to do something jammy
371
+ if ($$('#paypal-saved-accounts input[type=radio]').first() != undefined) {
372
 
373
+ // Loop through each radio button
374
+ $$('#paypal-saved-accounts input[type=radio]').each(function (savedAccount) {
375
 
376
+ // Observe them changing
377
+ Event.observe(savedAccount, 'click', function (ele) {
378
+ if (savedAccount.value == 'other') {
379
+ addPayPalButton();
380
+ } else {
381
+ hidePayPalButton();
382
+ }
383
+ });
384
+ });
385
+ }
386
 
387
+ // What should happen if the user closes the 3D secure window?
388
+ vzero.close3dSecureMethod(function () {
389
+
390
+ // Re-tokenize all the saved cards
391
+ vzero.tokenize3dSavedCards(function () {
392
+ stopLoading();
 
393
  });
394
+
395
  });
 
396
 
397
+ // Observe all Ajax requests for changes
398
+ vzero.observeAjaxRequests(function () {
 
 
399
 
400
+ // If the method is PayPal remove and re-add the PayPal button
401
+ if (payment.currentMethod == 'gene_braintree_paypal') {
402
+ hidePayPalButton();
403
+ addPayPalButton();
404
+ } else {
405
+ vzero.updateData();
406
+ }
407
 
408
+ });
 
 
 
 
 
 
409
 
410
+ }
411
 
412
  </script>
413
 
414
  <!-- Fix some minor styling issues with our nested form-list -->
415
  <style type="text/css">
 
 
 
 
 
 
 
 
 
416
  #paypal-container {
417
  float: right;
418
  }
app/design/frontend/base/default/template/gene/braintree/js/iwd.phtml ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add in support for IWD One Step Checkout
4
+ * https://www.iwdagency.com/extensions/one-step-page-checkout.html
5
+ */
6
+ ?>
7
+ <!-- IWD BRAINTREE SUPPORT -->
8
+ <script type="text/javascript">
9
+
10
+ // Wrap this in some error handling, just in case some checkouts attempt to include us twice
11
+ if(iwdOriginalSavePayment === undefined) {
12
+
13
+ // Make sure the credit card fields don't get sent to the server
14
+ var iwdOriginalSavePayment = IWD.OPC.savePayment;
15
+ IWD.OPC.savePayment = function () {
16
+
17
+ // Never call this bizarre function for our method
18
+ if (payment.currentMethod == 'gene_braintree_creditcard') {
19
+
20
+ // Are we actually trying to save the order?
21
+ if (IWD.OPC.saveOrderStatus === true){
22
+
23
+ // The original IWD checkout runs these various functions in the payment response
24
+ IWD.OPC.Checkout.xhr = null;
25
+ IWD.OPC.agreements = $j('#checkout-agreements').serializeArray();
26
+ IWD.OPC.getSubscribe();
27
+
28
+ // Save the order
29
+ IWD.OPC.saveOrder();
30
+ }
31
+
32
+ return false;
33
+ }
34
+
35
+ // Run the original method
36
+ return iwdOriginalSavePayment.apply(this, arguments);
37
+
38
+ };
39
+
40
+ // Intercept the save order to process the credit card
41
+ var iwdOriginalSaveOrder = IWD.OPC.saveOrder;
42
+ IWD.OPC.saveOrder = function() {
43
+
44
+ if ($('device_data')) {
45
+ // Device data should never be disabled
46
+ $('device_data').removeAttribute('disabled');
47
+ }
48
+
49
+ // Always attempt to update the card type on submission
50
+ if ($$('[data-genebraintree-name="number"]').first() != undefined) {
51
+ vzero.updateCardType($$('[data-genebraintree-name="number"]').first().value);
52
+ }
53
+
54
+ // Are we dealing with the credit card method?
55
+ if (payment.currentMethod == 'gene_braintree_creditcard') {
56
+
57
+ // Do we want to pass any extra paramters into the updateData request
58
+ var parameters = {};
59
+
60
+ // If the billing address is selected and we're wanting to ship to that address we need to pass the addressId
61
+ if ($('billing-address-select') != undefined && $('billing-address-select').value != '') {
62
+ parameters.addressId = $('billing-address-select').value;
63
+ }
64
+
65
+ // Update the data as we're in a one step
66
+ vzero.updateData(
67
+ function () {
68
+
69
+ // Verify we're not using a saved address
70
+ if ($('billing-address-select') != undefined && $('billing-address-select').value == '' || $('billing-address-select') == undefined) {
71
+
72
+ // Grab these directly from the form and update
73
+ if ($('billing:firstname') != undefined && $('billing:lastname') != undefined) {
74
+ vzero.setBillingName($('billing:firstname').value + ' ' + $('billing:lastname').value);
75
+ }
76
+ if ($('billing:postcode') != undefined) {
77
+ vzero.setBillingPostcode($('billing:postcode').value);
78
+ }
79
+ }
80
+
81
+ // Check is running
82
+ checkoutRunning = true;
83
+
84
+ // Show the loading
85
+ IWD.OPC.Checkout.showLoader();
86
+
87
+ // Process the card
88
+ vzero.process({
89
+ onSuccess: function () {
90
+
91
+ // Disable the standard credit card form so the values don't get passed through to the checkout
92
+ $$('#credit-card-form input, #credit-card-form select').each(function (formElement) {
93
+ if (formElement.id != 'creditcard-payment-nonce' && formElement.getAttribute('data-genebraintree-name') != 'cvv' && formElement.id != 'gene_braintree_creditcard_store_in_vault') {
94
+ formElement.setAttribute('disabled', 'disabled');
95
+ }
96
+ });
97
+
98
+ if ($('device_data')) {
99
+ // Always make sure device data is sent with the request
100
+ $('device_data').removeAttribute('disabled');
101
+ }
102
+
103
+ // Fire the original event and return the response
104
+ completeCheckoutResponse = iwdOriginalSaveOrder.apply(this, arguments);
105
+
106
+ // Re-enable any form elements which were disabled
107
+ $$('#credit-card-form input, #credit-card-form select').each(function (formElement) {
108
+ formElement.removeAttribute('disabled');
109
+ });
110
+
111
+ return completeCheckoutResponse;
112
+
113
+ }.bind(this),
114
+ onFailure: function () {
115
+ IWD.OPC.Checkout.hideLoader();
116
+ IWD.OPC.Checkout.unlockPlaceOrder();
117
+ }
118
+ });
119
+
120
+ }.bind(this),
121
+ parameters
122
+ );
123
+
124
+ // We're updating data don't do anything else for now
125
+ return false;
126
+ }
127
+
128
+ return iwdOriginalSaveOrder.apply(this, arguments);
129
+ };
130
+
131
+ // It's not been ran so set it to false
132
+ var PayPalCompleteRan = false;
133
+
134
+ /**
135
+ * Function to run once PayPal has been completed
136
+ */
137
+ completePayPal = function (obj) {
138
+
139
+ // Check the flag to make sure we're good to run the function
140
+ if (!PayPalCompleteRan) {
141
+
142
+ // Mark the flag as true
143
+ PayPalCompleteRan = true;
144
+
145
+ // Force check
146
+ payment.switchMethod('gene_braintree_paypal', true);
147
+
148
+ // Re-enable the form
149
+ $('paypal-payment-nonce').removeAttribute('disabled');
150
+ $('paypal-payment-nonce').value = obj.nonce;
151
+
152
+ // Show the button again
153
+ hidePayPalButton();
154
+
155
+ // No longer running
156
+ checkoutRunning = false;
157
+
158
+ // Show the loading thing
159
+ IWD.OPC.Checkout.showLoader();
160
+
161
+ if ($('device_data')) {
162
+ // Always make sure device data is sent with the request
163
+ $('device_data').removeAttribute('disabled');
164
+ }
165
+
166
+ // Run the complete checkout method
167
+ $j_opc('.opc-btn-checkout').click();
168
+
169
+ }
170
+
171
+ };
172
+
173
+ // Flag to check if the PayPal button is already loading
174
+ var PayPalButtonLoading = false;
175
+
176
+ /**
177
+ * Easily add the PayPal button into the DOM
178
+ */
179
+ addPayPalButton = function () {
180
+
181
+ // Check we can locate the submit button
182
+ if ($$('.opc-btn-checkout').first() != undefined && $('paypal-complete') == undefined && PayPalButtonLoading == false) {
183
+
184
+ // The button is loading
185
+ PayPalButtonLoading = true;
186
+
187
+ // As the PayPal button has to request data from the server show the loader
188
+ IWD.OPC.Checkout.showLoader();
189
+
190
+ // Update the data contained within the classes
191
+ vzero.updateData(function () {
192
+
193
+ // The button is no longer loading
194
+ PayPalButtonLoading = false;
195
+
196
+ // Hide it once we're done
197
+ IWD.OPC.Checkout.hideLoader();
198
+ IWD.OPC.Checkout.unlockPlaceOrder();
199
+
200
+ // Validate the payment method is still correct
201
+ if (payment.currentMethod == 'gene_braintree_paypal' && $('paypal-complete') == undefined) {
202
+
203
+ // Set the flag to false as we've created a new button
204
+ PayPalCompleteRan = false;
205
+
206
+ // Hide the submit button
207
+ $$('.opc-btn-checkout').first().hide();
208
+
209
+ // Add in our PayPal button
210
+ $$('.opc-btn-checkout').first().insert({after: '<div id="paypal-complete"><label id="paypal-label"><?php echo $this->__('Complete checkout with'); ?> </label><div id="paypal-container"></div></div>'});
211
+
212
+ // Always stop the window from opening
213
+ $('paypal-complete').observe('click', function (event) {
214
+
215
+ // Validate the form before we open the PayPal modal window
216
+ if (!amscheckoutForm.validator.validate() || checkoutRunning) {
217
+
218
+ // Sadly we're unable to intercept the PayPal window in any other way then just hard closing it
219
+ vzeroPaypal.closePayPalWindow();
220
+ }
221
+ });
222
+
223
+ // Add in the PayPal button
224
+ vzeroPaypal.addPayPalButton({
225
+ onSuccess: completePayPal
226
+ });
227
+
228
+ }
229
+
230
+ });
231
+
232
+ } else if ($('paypal-complete') != undefined) {
233
+
234
+ // The button is loading
235
+ PayPalButtonLoading = true;
236
+
237
+ // As the PayPal button has to request data from the server show the loader
238
+ IWD.OPC.Checkout.showLoader();
239
+
240
+ // Update the data contained within the classes
241
+ vzero.updateData(function () {
242
+
243
+ // The button is no longer loading
244
+ PayPalButtonLoading = false;
245
+
246
+ // Hide it once we're done
247
+ IWD.OPC.Checkout.hideLoader();
248
+ IWD.OPC.Checkout.unlockPlaceOrder();
249
+
250
+ // Validate the payment method is still correct
251
+ if (payment.currentMethod == 'gene_braintree_paypal') {
252
+
253
+ // Set the flag to false as we've created a new button
254
+ PayPalCompleteRan = false;
255
+
256
+ // Hide the submit button
257
+ $$('.opc-btn-checkout').first().hide();
258
+
259
+ // Add in the PayPal button
260
+ $('paypal-complete').show();
261
+
262
+ }
263
+
264
+ });
265
+
266
+ }
267
+
268
+ };
269
+
270
+ /**
271
+ * As we need to remove the PayPal button in multiple places
272
+ */
273
+ hidePayPalButton = function () {
274
+
275
+ // If the user has selected a different payment method make some modifications
276
+ if ($$('.opc-btn-checkout').first() != undefined) {
277
+ $$('.opc-btn-checkout').first().show();
278
+ }
279
+
280
+ // Remove the PayPal element
281
+ if ($('paypal-complete') != undefined) {
282
+ $('paypal-complete').hide();
283
+ }
284
+
285
+ };
286
+
287
+ // Check if the payment method is the default
288
+ if (payment !== undefined) {
289
+ if ((payment.currentMethod == 'gene_braintree_paypal' && $('paypal-saved-accounts') == undefined) || ($$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other')) {
290
+
291
+ // Verify that vzero is defined before attempting to use it
292
+ if (typeof vzeroPaypal !== 'undefined') {
293
+
294
+ // Always set the amount as it's needed within 3D secure requests
295
+ vzeroPaypal.setPricing('<?php echo Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getGrandTotal(); ?>', '<?php echo Mage::getSingleton('checkout/cart')->getQuote()->getBaseCurrencyCode(); ?>');
296
+ }
297
+
298
+ addPayPalButton();
299
+ }
300
+ }
301
+
302
+ // Store the original payment method
303
+ var paymentOriginal = Payment.prototype.switchMethod;
304
+
305
+ // Intercept the save function
306
+ Payment.prototype.switchMethod = function (method) {
307
+
308
+ // Make sure the paypal complete action hasn't just ran
309
+ if (PayPalCompleteRan != true) {
310
+
311
+ // Detect PayPal choice
312
+ if (method == 'gene_braintree_paypal') {
313
+
314
+ if ($('paypal-saved-accounts') == undefined) {
315
+ addPayPalButton();
316
+ } else if ($('paypal-saved-accounts') != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other') {
317
+ addPayPalButton();
318
+ } else {
319
+ hidePayPalButton();
320
+ }
321
+
322
+ } else {
323
+ hidePayPalButton();
324
+ }
325
+ }
326
+
327
+
328
+ // Run the original function
329
+ return paymentOriginal.apply(this, arguments);
330
+
331
+ };
332
+
333
+ // If we have any saved accounts we'll need to do something jammy
334
+ if ($$('#paypal-saved-accounts input[type=radio]').first() != undefined) {
335
+
336
+ // Loop through each radio button
337
+ $$('#paypal-saved-accounts input[type=radio]').each(function (savedAccount) {
338
+
339
+ // Observe them changing
340
+ Event.observe(savedAccount, 'click', function (ele) {
341
+ if (savedAccount.value == 'other') {
342
+ addPayPalButton();
343
+ } else {
344
+ hidePayPalButton();
345
+ }
346
+ });
347
+ });
348
+ }
349
+
350
+ // What should happen if the user closes the 3D secure window?
351
+ vzero.close3dSecureMethod(function () {
352
+
353
+ // Re-tokenize all the saved cards
354
+ vzero.tokenize3dSavedCards(function () {
355
+
356
+ // Hide the loading
357
+ IWD.OPC.Checkout.hideLoader();
358
+ IWD.OPC.Checkout.unlockPlaceOrder();
359
+
360
+ });
361
+
362
+ });
363
+
364
+ // Observe the card type here as it'll fail within creditCard.phtml
365
+ vzero.observeCardType();
366
+
367
+ // Observe all Ajax requests for changes
368
+ vzero.observeAjaxRequests(function () {
369
+
370
+ // If the method is PayPal remove and re-add the PayPal button
371
+ if (payment.currentMethod == 'gene_braintree_paypal') {
372
+ hidePayPalButton();
373
+ addPayPalButton();
374
+ } else {
375
+ vzero.updateData();
376
+ }
377
+
378
+ });
379
+
380
+ }
381
+ </script>
382
+ <style type="text/css">
383
+ #braintree-paypal-button {
384
+ line-height: unset;
385
+ padding: 0;
386
+ float: left;
387
+ }
388
+ #braintree-paypal-loggedin {
389
+ display: none!important;
390
+ }
391
+ #braintree-paypal-loggedout {
392
+ display: block!important;
393
+ }
394
+ </style>
app/design/frontend/base/default/template/gene/braintree/js/magestore.phtml ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Add in support for Magestore One Step Checkout
4
+ * http://ecommerce.aheadworks.com/magento-extensions/one-step-checkout.html
5
+ */
6
+ ?>
7
+ <!-- MAGESTORE BRAINTREE SUPPORT -->
8
+ <script type="text/javascript">
9
+
10
+ // Wrap this in some error handling, just in case some checkouts attempt to include us twice
11
+ if(mageStoreOriginalPlaceOrder === undefined) {
12
+
13
+ /**
14
+ * Wrap this functionality up in easy to call function
15
+ */
16
+ showCheckoutLoading = function () {
17
+ $('onestepcheckout-place-order-loading').show();
18
+ $('onestepcheckout-button-place-order').removeClassName('onestepcheckout-btn-checkout');
19
+ $('onestepcheckout-button-place-order').addClassName('place-order-loader');
20
+ };
21
+ hideCheckoutLoading = function () {
22
+ $('onestepcheckout-place-order-loading').hide();
23
+ $('onestepcheckout-button-place-order').addClassName('onestepcheckout-btn-checkout');
24
+ $('onestepcheckout-button-place-order').removeClassName('place-order-loader');
25
+ };
26
+ getCheckoutPaymentMethod = function () {
27
+ return $RF($('one-step-checkout-form'), 'payment[method]');
28
+ };
29
+
30
+ // Store the old complete checkout function
31
+ var mageStoreOriginalPlaceOrder = oscPlaceOrder;
32
+
33
+ // Re-define the original method so we can do some jazz with it
34
+ oscPlaceOrder = function (element) {
35
+
36
+ // Store the arguments
37
+ var originalArguments = arguments;
38
+
39
+ if ($('device_data')) {
40
+ // Device data should never be disabled
41
+ $('device_data').removeAttribute('disabled');
42
+ }
43
+
44
+ // Always attempt to update the card type on submission
45
+ if ($$('[data-genebraintree-name="number"]').first() != undefined) {
46
+ vzero.updateCardType($$('[data-genebraintree-name="number"]').first().value);
47
+ }
48
+
49
+ // Run the original validation functions
50
+ var validator = new Validation('one-step-checkout-form');
51
+ if (validator.validate()) {
52
+
53
+ // Are we dealing with the credit card method?
54
+ if (getCheckoutPaymentMethod() == 'gene_braintree_creditcard') {
55
+
56
+ // Do we want to pass any extra paramters into the updateData request
57
+ var parameters = {};
58
+
59
+ // If the billing address is selected and we're wanting to ship to that address we need to pass the addressId
60
+ if ($('billing-address-select') != undefined && $('billing-address-select').value != '') {
61
+ parameters.addressId = $('billing-address-select').value;
62
+ }
63
+
64
+ // Update the data as we're in a one step
65
+ vzero.updateData(
66
+ function () {
67
+
68
+ // Verify we're not using a saved address
69
+ if ($('billing-address-select') != undefined && $('billing-address-select').value == '' || $('billing-address-select') == undefined) {
70
+
71
+ // Grab these directly from the form and update
72
+ if ($('billing:firstname') != undefined && $('billing:lastname') != undefined) {
73
+ vzero.setBillingName($('billing:firstname').value + ' ' + $('billing:lastname').value);
74
+ }
75
+ if ($('billing:postcode') != undefined) {
76
+ vzero.setBillingPostcode($('billing:postcode').value);
77
+ }
78
+ }
79
+
80
+ // Check is running
81
+ already_placing_order = true;
82
+
83
+ // Show the loading
84
+ showCheckoutLoading();
85
+
86
+ // Process the card
87
+ vzero.process({
88
+ onSuccess: function () {
89
+
90
+ // Disable the standard credit card form so the values don't get passed through to the checkout
91
+ $$('#credit-card-form input, #credit-card-form select').each(function (formElement) {
92
+ if (formElement.id != 'creditcard-payment-nonce' && formElement.getAttribute('data-genebraintree-name') != 'cvv' && formElement.id != 'gene_braintree_creditcard_store_in_vault') {
93
+ formElement.setAttribute('disabled', 'disabled');
94
+ }
95
+ });
96
+
97
+ if ($('device_data')) {
98
+ // Always make sure device data is sent with the request
99
+ $('device_data').removeAttribute('disabled');
100
+ }
101
+
102
+ // No longer running
103
+ already_placing_order = false;
104
+
105
+ // Fire the original event and return the response
106
+ completeCheckoutResponse = mageStoreOriginalPlaceOrder.apply(this, originalArguments);
107
+
108
+ // Re-enable any form elements which were disabled
109
+ $$('#credit-card-form input, #credit-card-form select').each(function (formElement) {
110
+ formElement.removeAttribute('disabled');
111
+ });
112
+
113
+ // Run the original function
114
+ return completeCheckoutResponse;
115
+ },
116
+ onFailure: function () {
117
+
118
+ // Reset the waiting for the parent function
119
+ hideCheckoutLoading();
120
+
121
+ // No longer running
122
+ already_placing_order = false;
123
+
124
+ }
125
+ });
126
+
127
+ },
128
+ parameters
129
+ );
130
+
131
+ // We're updating data don't do anything else for now
132
+ return false;
133
+
134
+ }
135
+
136
+ }
137
+
138
+ // Stop further processing
139
+ return mageStoreOriginalPlaceOrder.apply(this, arguments);
140
+ };
141
+
142
+
143
+ // It's not been ran so set it to false
144
+ var PayPalCompleteRan = false;
145
+
146
+ /**
147
+ * Function to run once PayPal has been completed
148
+ */
149
+ completePayPal = function (obj) {
150
+
151
+ // Check the flag to make sure we're good to run the function
152
+ if (!PayPalCompleteRan) {
153
+
154
+ // Mark the flag as true
155
+ PayPalCompleteRan = true;
156
+
157
+ // Force check
158
+ $('p_method_gene_braintree_paypal').checked = true;
159
+
160
+ // Re-enable the form
161
+ $('paypal-payment-nonce').removeAttribute('disabled');
162
+ $('paypal-payment-nonce').value = obj.nonce;
163
+
164
+ // Show the button again
165
+ hidePayPalButton();
166
+
167
+ showCheckoutLoading();
168
+
169
+ if ($('device_data')) {
170
+ // Always make sure device data is sent with the request
171
+ $('device_data').removeAttribute('disabled');
172
+ }
173
+
174
+ // Run the complete checkout method
175
+ return oscPlaceOrder($('onestepcheckout-button-place-order'));
176
+
177
+ }
178
+
179
+ };
180
+
181
+ // Flag to check if the PayPal button is already loading
182
+ var PayPalButtonLoading = false;
183
+
184
+ /**
185
+ * Easily add the PayPal button into the DOM
186
+ */
187
+ addPayPalButton = function () {
188
+
189
+ // Check we can locate the submit button
190
+ if ($('onestepcheckout-button-place-order') != undefined && $('paypal-complete') == undefined && PayPalButtonLoading == false) {
191
+
192
+ // The button is loading
193
+ PayPalButtonLoading = true;
194
+
195
+ // As the PayPal button has to request data from the server show the loader
196
+ showCheckoutLoading();
197
+
198
+ // Update the data contained within the classes
199
+ vzero.updateData(function () {
200
+
201
+ // The button is no longer loading
202
+ PayPalButtonLoading = false;
203
+
204
+ // Hide it once we're done
205
+ hideCheckoutLoading();
206
+
207
+ // Validate the payment method is still correct
208
+ if (getCheckoutPaymentMethod() == 'gene_braintree_paypal' && $('paypal-complete') == undefined) {
209
+
210
+ // Set the flag to false as we've created a new button
211
+ PayPalCompleteRan = false;
212
+
213
+ // Hide the submit button
214
+ $('onestepcheckout-button-place-order').hide();
215
+
216
+ // Add in our PayPal button
217
+ $('onestepcheckout-button-place-order').insert({after: '<div id="paypal-complete"><label id="paypal-label"><?php echo $this->__('Complete checkout with'); ?> </label><div id="paypal-container"></div></div>'});
218
+
219
+ // Always stop the window from opening
220
+ $('paypal-complete').observe('click', function (event) {
221
+
222
+ // Validate the form before we open the PayPal modal window
223
+ if (!amscheckoutForm.validator.validate() || checkoutRunning) {
224
+
225
+ // Sadly we're unable to intercept the PayPal window in any other way then just hard closing it
226
+ vzeroPaypal.closePayPalWindow();
227
+ }
228
+ });
229
+
230
+ // Add in the PayPal button
231
+ vzeroPaypal.addPayPalButton({
232
+ onSuccess: completePayPal
233
+ });
234
+
235
+ }
236
+
237
+ });
238
+
239
+ } else if ($('paypal-complete') != undefined) {
240
+
241
+ // The button is loading
242
+ PayPalButtonLoading = true;
243
+
244
+ // As the PayPal button has to request data from the server show the loader
245
+ showCheckoutLoading();
246
+
247
+ // Update the data contained within the classes
248
+ vzero.updateData(function () {
249
+
250
+ // The button is no longer loading
251
+ PayPalButtonLoading = false;
252
+
253
+ // Hide it once we're done
254
+ hideCheckoutLoading();
255
+
256
+ // Validate the payment method is still correct
257
+ if (getCheckoutPaymentMethod() == 'gene_braintree_paypal') {
258
+
259
+ // Set the flag to false as we've created a new button
260
+ PayPalCompleteRan = false;
261
+
262
+ // Hide the submit button
263
+ $('onestepcheckout-button-place-order').hide();
264
+
265
+ // Add in the PayPal button
266
+ $('paypal-complete').show();
267
+
268
+ }
269
+
270
+ });
271
+
272
+ }
273
+
274
+ };
275
+
276
+ /**
277
+ * As we need to remove the PayPal button in multiple places
278
+ */
279
+ hidePayPalButton = function () {
280
+
281
+ // If the user has selected a different payment method make some modifications
282
+ if ($('onestepcheckout-button-place-order') != undefined) {
283
+ $('onestepcheckout-button-place-order').show();
284
+ }
285
+
286
+ // Remove the PayPal element
287
+ if ($('paypal-complete') != undefined) {
288
+ $('paypal-complete').hide();
289
+ }
290
+
291
+ };
292
+
293
+ // Check if the payment method is the default
294
+ if (getCheckoutPaymentMethod()) {
295
+ if ((getCheckoutPaymentMethod() == 'gene_braintree_paypal' && $('paypal-saved-accounts') == undefined) || ($$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other')) {
296
+
297
+ // Verify that vzero is defined before attempting to use it
298
+ if (typeof vzeroPaypal !== 'undefined') {
299
+
300
+ // Always set the amount as it's needed within 3D secure requests
301
+ vzeroPaypal.setPricing('<?php echo Mage::getSingleton('checkout/cart')->getQuote()->collectTotals()->getGrandTotal(); ?>', '<?php echo Mage::getSingleton('checkout/cart')->getQuote()->getBaseCurrencyCode(); ?>');
302
+ }
303
+
304
+ addPayPalButton();
305
+ }
306
+ }
307
+
308
+ // Intercept people swapping methods
309
+ var originalSaveShippingMethod = save_shipping_method;
310
+ save_shipping_method = function (shipping_method_url, update_shipping_payment, update_shipping_review) {
311
+
312
+ // Make sure the paypal complete action hasn't just ran
313
+ if (PayPalCompleteRan != true) {
314
+
315
+ // Detect PayPal choice
316
+ if (getCheckoutPaymentMethod() == 'gene_braintree_paypal') {
317
+
318
+ if ($('paypal-saved-accounts') == undefined) {
319
+ addPayPalButton();
320
+ } else if ($('paypal-saved-accounts') != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first() != undefined && $$('#paypal-saved-accounts input:checked[type=radio]').first().value == 'other') {
321
+ addPayPalButton();
322
+ } else {
323
+ hidePayPalButton();
324
+ }
325
+
326
+ } else {
327
+ hidePayPalButton();
328
+ }
329
+ }
330
+
331
+ return originalSaveShippingMethod.apply(this, arguments);
332
+ };
333
+
334
+ // What should happen if the user closes the 3D secure window?
335
+ vzero.close3dSecureMethod(function () {
336
+
337
+ // Re-tokenize all the saved cards
338
+ vzero.tokenize3dSavedCards(function () {
339
+
340
+ // Reset the waiting for the parent function
341
+ hideCheckoutLoading();
342
+
343
+ // No longer running
344
+ already_placing_order = false;
345
+
346
+ });
347
+
348
+ });
349
+
350
+ // Observe the card type here as it'll fail within creditCard.phtml
351
+ vzero.observeCardType();
352
+
353
+ // Observe all Ajax requests for changes
354
+ vzero.observeAjaxRequests(function () {
355
+
356
+ // If the method is PayPal remove and re-add the PayPal button
357
+ if (getCheckoutPaymentMethod() == 'gene_braintree_paypal') {
358
+ hidePayPalButton();
359
+ addPayPalButton();
360
+ } else {
361
+ vzero.updateData();
362
+ }
363
+
364
+ });
365
+
366
+ }
367
+
368
+ </script>
369
+ <style type="text/css">
370
+ #braintree-paypal-loggedin {
371
+ display: none!important;
372
+ }
373
+ #braintree-paypal-loggedout {
374
+ display: block!important;
375
+ }
376
+ </style>
app/design/frontend/base/default/template/gene/braintree/js/setup.phtml CHANGED
@@ -6,19 +6,21 @@
6
  ?>
7
  <script type="text/javascript">
8
 
9
- // Pass some data over to vZero integration JS
10
- var vzero = new vZero(
11
- 'gene_braintree_creditcard',
12
- '<?php echo $this->getClientToken(); ?>',
13
- <?php echo $this->is3DEnabled(); ?>,
14
- false,
15
- false,
16
- '<?php echo Mage::getUrl('braintree/checkout/quoteTotal', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())); ?>',
17
- '<?php echo Mage::getUrl('braintree/checkout/tokenizeCard', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure())); ?>'
18
- );
19
 
20
- <?php if($this->isPayPalActive()): ?>
 
 
 
 
 
 
 
 
 
21
 
 
22
  // Pass some data through to the PayPal integration
23
  var vzeroPaypal = new vZeroPayPalButton(
24
  '<?php echo $this->getClientToken(); ?>',
@@ -27,10 +29,11 @@
27
  '<?php echo $this->getLocale(); ?>',
28
  <?php echo $this->getSingleFutureUse(); ?>
29
  );
 
30
 
31
- <?php endif; ?>
 
32
 
33
- // Init the environment
34
- vzero.init();
35
 
36
  </script>
6
  ?>
7
  <script type="text/javascript">
8
 
9
+ // Only init the vzero class once
10
+ if(vzero === undefined) {
 
 
 
 
 
 
 
 
11
 
12
+ // Pass some data over to vZero integration JS
13
+ var vzero = new vZero(
14
+ 'gene_braintree_creditcard',
15
+ '<?php echo $this->getClientToken(); ?>',
16
+ <?php echo $this->is3DEnabled(); ?>,
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->isPayPalActive()): ?>
24
  // Pass some data through to the PayPal integration
25
  var vzeroPaypal = new vZeroPayPalButton(
26
  '<?php echo $this->getClientToken(); ?>',
29
  '<?php echo $this->getLocale(); ?>',
30
  <?php echo $this->getSingleFutureUse(); ?>
31
  );
32
+ <?php endif; ?>
33
 
34
+ // Init the environment
35
+ vzero.init();
36
 
37
+ }
 
38
 
39
  </script>
lib/Braintree.php CHANGED
@@ -13,71 +13,23 @@
13
 
14
  set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__)));
15
 
16
- abstract class Braintree
17
- {
18
- /**
19
- * @ignore
20
- * don't permit an explicit call of the constructor!
21
- * (like $t = new Braintree_Transaction())
22
- */
23
- protected function __construct()
24
- {
25
- }
26
- /**
27
- * @ignore
28
- * don't permit cloning the instances (like $x = clone $v)
29
- */
30
- protected function __clone()
31
- {
32
- }
33
-
34
- /**
35
- * returns private/nonexistent instance properties
36
- * @ignore
37
- * @access public
38
- * @param string $name property name
39
- * @return mixed contents of instance properties
40
- */
41
- public function __get($name)
42
- {
43
- if (array_key_exists($name, $this->_attributes)) {
44
- return $this->_attributes[$name];
45
- }
46
- else {
47
- trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
48
- return null;
49
- }
50
- }
51
-
52
- /**
53
- * used by isset() and empty()
54
- * @access public
55
- * @param string $name property name
56
- * @return boolean
57
- */
58
- public function __isset($name)
59
- {
60
- return array_key_exists($name, $this->_attributes);
61
- }
62
-
63
- public function _set($key, $value)
64
- {
65
- $this->_attributes[$key] = $value;
66
- }
67
- }
68
  require_once('Braintree/Modification.php');
69
  require_once('Braintree/Instance.php');
70
 
 
71
  require_once('Braintree/Address.php');
72
  require_once('Braintree/AddressGateway.php');
73
  require_once('Braintree/AddOn.php');
74
  require_once('Braintree/AddOnGateway.php');
 
75
  require_once('Braintree/ApplePayCard.php');
76
  require_once('Braintree/ClientToken.php');
77
  require_once('Braintree/ClientTokenGateway.php');
78
  require_once('Braintree/CoinbaseAccount.php');
79
  require_once('Braintree/Collection.php');
80
  require_once('Braintree/Configuration.php');
 
81
  require_once('Braintree/CreditCard.php');
82
  require_once('Braintree/CreditCardGateway.php');
83
  require_once('Braintree/Customer.php');
@@ -96,6 +48,8 @@ require_once('Braintree/Exception.php');
96
  require_once('Braintree/Gateway.php');
97
  require_once('Braintree/Http.php');
98
  require_once('Braintree/KeyValueNode.php');
 
 
99
  require_once('Braintree/MerchantAccount.php');
100
  require_once('Braintree/MerchantAccountGateway.php');
101
  require_once('Braintree/MerchantAccount/BusinessDetails.php');
@@ -104,12 +58,14 @@ require_once('Braintree/MerchantAccount/IndividualDetails.php');
104
  require_once('Braintree/MerchantAccount/AddressDetails.php');
105
  require_once('Braintree/MultipleValueNode.php');
106
  require_once('Braintree/MultipleValueOrTextNode.php');
 
107
  require_once('Braintree/PartialMatchNode.php');
108
  require_once('Braintree/Plan.php');
109
  require_once('Braintree/PlanGateway.php');
110
  require_once('Braintree/RangeNode.php');
111
  require_once('Braintree/ResourceCollection.php');
112
  require_once('Braintree/RiskData.php');
 
113
  require_once('Braintree/SettlementBatchSummary.php');
114
  require_once('Braintree/SettlementBatchSummaryGateway.php');
115
  require_once('Braintree/SignatureService.php');
@@ -136,6 +92,7 @@ require_once('Braintree/Exception/Authorization.php');
136
  require_once('Braintree/Exception/Configuration.php');
137
  require_once('Braintree/Exception/DownForMaintenance.php');
138
  require_once('Braintree/Exception/ForgedQueryString.php');
 
139
  require_once('Braintree/Exception/InvalidSignature.php');
140
  require_once('Braintree/Exception/NotFound.php');
141
  require_once('Braintree/Exception/ServerError.php');
@@ -153,6 +110,7 @@ require_once('Braintree/Test/TransactionAmounts.php');
153
  require_once('Braintree/Test/VenmoSdk.php');
154
  require_once('Braintree/Test/Nonces.php');
155
  require_once('Braintree/Transaction/AddressDetails.php');
 
156
  require_once('Braintree/Transaction/ApplePayCardDetails.php');
157
  require_once('Braintree/Transaction/CoinbaseDetails.php');
158
  require_once('Braintree/Transaction/CreditCardDetails.php');
@@ -177,13 +135,13 @@ require_once('Braintree/PaymentMethodNonceGateway.php');
177
  require_once('Braintree/PaymentInstrumentType.php');
178
  require_once('Braintree/UnknownPaymentMethod.php');
179
 
180
- if (version_compare(PHP_VERSION, '5.2.1', '<')) {
181
- throw new Braintree_Exception('PHP version >= 5.2.1 required');
182
  }
183
 
184
 
185
  function requireDependencies() {
186
- $requiredExtensions = array('xmlwriter', 'SimpleXML', 'openssl', 'dom', 'hash', 'curl');
187
  foreach ($requiredExtensions AS $ext) {
188
  if (!extension_loaded($ext)) {
189
  throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.');
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');
48
  require_once('Braintree/Gateway.php');
49
  require_once('Braintree/Http.php');
50
  require_once('Braintree/KeyValueNode.php');
51
+ require_once('Braintree/Merchant.php');
52
+ require_once('Braintree/MerchantGateway.php');
53
  require_once('Braintree/MerchantAccount.php');
54
  require_once('Braintree/MerchantAccountGateway.php');
55
  require_once('Braintree/MerchantAccount/BusinessDetails.php');
58
  require_once('Braintree/MerchantAccount/AddressDetails.php');
59
  require_once('Braintree/MultipleValueNode.php');
60
  require_once('Braintree/MultipleValueOrTextNode.php');
61
+ require_once('Braintree/OAuthGateway.php');
62
  require_once('Braintree/PartialMatchNode.php');
63
  require_once('Braintree/Plan.php');
64
  require_once('Braintree/PlanGateway.php');
65
  require_once('Braintree/RangeNode.php');
66
  require_once('Braintree/ResourceCollection.php');
67
  require_once('Braintree/RiskData.php');
68
+ require_once('Braintree/ThreeDSecureInfo.php');
69
  require_once('Braintree/SettlementBatchSummary.php');
70
  require_once('Braintree/SettlementBatchSummaryGateway.php');
71
  require_once('Braintree/SignatureService.php');
92
  require_once('Braintree/Exception/Configuration.php');
93
  require_once('Braintree/Exception/DownForMaintenance.php');
94
  require_once('Braintree/Exception/ForgedQueryString.php');
95
+ require_once('Braintree/Exception/InvalidChallenge.php');
96
  require_once('Braintree/Exception/InvalidSignature.php');
97
  require_once('Braintree/Exception/NotFound.php');
98
  require_once('Braintree/Exception/ServerError.php');
110
  require_once('Braintree/Test/VenmoSdk.php');
111
  require_once('Braintree/Test/Nonces.php');
112
  require_once('Braintree/Transaction/AddressDetails.php');
113
+ require_once('Braintree/Transaction/AndroidPayCardDetails.php');
114
  require_once('Braintree/Transaction/ApplePayCardDetails.php');
115
  require_once('Braintree/Transaction/CoinbaseDetails.php');
116
  require_once('Braintree/Transaction/CreditCardDetails.php');
135
  require_once('Braintree/PaymentInstrumentType.php');
136
  require_once('Braintree/UnknownPaymentMethod.php');
137
 
138
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
139
+ throw new Braintree_Exception('PHP version >= 5.4.0 required');
140
  }
141
 
142
 
143
  function requireDependencies() {
144
+ $requiredExtensions = array('xmlwriter', 'openssl', 'dom', 'hash', 'curl');
145
  foreach ($requiredExtensions AS $ext) {
146
  if (!extension_loaded($ext)) {
147
  throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.');
lib/Braintree/AddOn.php CHANGED
@@ -1,6 +1,12 @@
1
  <?php
 
2
  class Braintree_AddOn extends Braintree_Modification
3
  {
 
 
 
 
 
4
  public static function factory($attributes)
5
  {
6
  $instance = new self();
@@ -9,8 +15,11 @@ class Braintree_AddOn extends Braintree_Modification
9
  }
10
 
11
 
12
- // static methods redirecting to gateway
13
-
 
 
 
14
  public static function all()
15
  {
16
  return Braintree_Configuration::gateway()->addOn()->all();
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
  {
12
  $instance = new self();
15
  }
16
 
17
 
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();
lib/Braintree/AddOnGateway.php CHANGED
@@ -1,17 +1,41 @@
1
  <?php
 
2
  class Braintree_AddOnGateway
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->_http = new Braintree_Http($gateway->config);
13
  }
14
 
 
 
 
 
15
  public function all()
16
  {
17
  $path = $this->_config->merchantPath() . '/add_ons';
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';
lib/Braintree/Address.php CHANGED
@@ -25,7 +25,7 @@
25
  * @property-read string $streetAddress
26
  * @property-read string $updatedAt
27
  */
28
- class Braintree_Address extends Braintree
29
  {
30
  /**
31
  * returns false if comparing object is not a Braintree_Address,
@@ -84,26 +84,58 @@ class Braintree_Address extends Braintree
84
 
85
  // static methods redirecting to gateway
86
 
 
 
 
 
 
87
  public static function create($attribs)
88
  {
89
  return Braintree_Configuration::gateway()->address()->create($attribs);
90
  }
91
 
 
 
 
 
 
92
  public static function createNoValidate($attribs)
93
  {
94
  return Braintree_Configuration::gateway()->address()->createNoValidate($attribs);
95
  }
96
 
 
 
 
 
 
 
 
97
  public static function delete($customerOrId = null, $addressId = null)
98
  {
99
  return Braintree_Configuration::gateway()->address()->delete($customerOrId, $addressId);
100
  }
101
 
 
 
 
 
 
 
 
102
  public static function find($customerOrId, $addressId)
103
  {
104
  return Braintree_Configuration::gateway()->address()->find($customerOrId, $addressId);
105
  }
106
 
 
 
 
 
 
 
 
 
107
  public static function update($customerOrId, $addressId, $attributes)
108
  {
109
  return Braintree_Configuration::gateway()->address()->update($customerOrId, $addressId, $attributes);
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,
84
 
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);
lib/Braintree/AddressGateway.php CHANGED
@@ -13,14 +13,33 @@
13
  */
14
  class Braintree_AddressGateway
15
  {
 
 
 
 
16
  private $_gateway;
 
 
 
 
 
17
  private $_config;
 
 
 
 
 
18
  private $_http;
19
 
 
 
 
 
20
  public function __construct($gateway)
21
  {
22
  $this->_gateway = $gateway;
23
  $this->_config = $gateway->config;
 
24
  $this->_http = new Braintree_Http($gateway->config);
25
  }
26
 
@@ -264,7 +283,7 @@ class Braintree_AddressGateway
264
  *
265
  * @ignore
266
  * @param array $response gateway response values
267
- * @return object Result_Successful or Result_Error
268
  * @throws Braintree_Exception_Unexpected
269
  */
270
  private function _verifyGatewayResponse($response)
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
 
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)
lib/Braintree/AndroidPayCard.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Braintree AndroidPayCard module
4
+ * Creates and manages Braintree Android Pay cards
5
+ *
6
+ * <b>== More information ==</b>
7
+ *
8
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br />
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
20
+ * @property-read string $googleTransactionId
21
+ * @property-read string $imageUrl
22
+ * @property-read string $last4
23
+ * @property-read string $sourceCardLast4
24
+ * @property-read string $sourceCardType
25
+ * @property-read string $token
26
+ * @property-read string $updatedAt
27
+ * @property-read string $virtualCardLast4
28
+ * @property-read string $virtualCardType
29
+ */
30
+ class Braintree_AndroidPayCard extends Braintree_Base
31
+ {
32
+ /* instance methods */
33
+ /**
34
+ * returns false if default is null or false
35
+ *
36
+ * @return boolean
37
+ */
38
+ public function isDefault()
39
+ {
40
+ return $this->default;
41
+ }
42
+
43
+ /**
44
+ * factory method: returns an instance of Braintree_AndroidPayCard
45
+ * to the requesting method, with populated properties
46
+ *
47
+ * @ignore
48
+ * @return object instance of Braintree_AndroidPayCard
49
+ */
50
+ public static function factory($attributes)
51
+ {
52
+ $defaultAttributes = array(
53
+ 'expirationMonth' => '',
54
+ 'expirationYear' => '',
55
+ 'last4' => $attributes['virtualCardLast4'],
56
+ 'cardType' => $attributes['virtualCardType'],
57
+ );
58
+
59
+ $instance = new self();
60
+ $instance->_initialize(array_merge($defaultAttributes, $attributes));
61
+ return $instance;
62
+ }
63
+
64
+ /**
65
+ * sets instance properties from an array of values
66
+ *
67
+ * @access protected
68
+ * @param array $androidPayCardAttribs array of Android Pay card properties
69
+ * @return none
70
+ */
71
+ protected function _initialize($androidPayCardAttribs)
72
+ {
73
+ // set the attributes
74
+ $this->_attributes = $androidPayCardAttribs;
75
+
76
+ $subscriptionArray = array();
77
+ if (isset($androidPayCardAttribs['subscriptions'])) {
78
+ foreach ($androidPayCardAttribs['subscriptions'] AS $subscription) {
79
+ $subscriptionArray[] = Braintree_Subscription::factory($subscription);
80
+ }
81
+ }
82
+
83
+ $this->_set('subscriptions', $subscriptionArray);
84
+ }
85
+ }
lib/Braintree/ApplePayCard.php CHANGED
@@ -22,7 +22,7 @@
22
  * @property-read string $paymentInstrumentName
23
  * @property-read string $updatedAt
24
  */
25
- class Braintree_ApplePayCard extends Braintree
26
  {
27
  // Card Type
28
  const AMEX = 'Apple Pay - American Express';
22
  * @property-read string $paymentInstrumentName
23
  * @property-read string $updatedAt
24
  */
25
+ class Braintree_ApplePayCard extends Braintree_Base
26
  {
27
  // Card Type
28
  const AMEX = 'Apple Pay - American Express';
lib/Braintree/Base.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {
18
+ }
19
+
20
+ /**
21
+ * Disable cloning of objects
22
+ *
23
+ * @ignore
24
+ */
25
+ protected function __clone()
26
+ {
27
+ }
28
+
29
+ /**
30
+ * Accessor for instance properties stored in the private $_attributes property
31
+ *
32
+ * @ignore
33
+ * @param string $name
34
+ * @return mixed
35
+ */
36
+ public function __get($name)
37
+ {
38
+ if (array_key_exists($name, $this->_attributes)) {
39
+ return $this->_attributes[$name];
40
+ }
41
+ else {
42
+ trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
43
+ return null;
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Checks for the existance of a property stored in the private $_attributes property
49
+ *
50
+ * @ignore
51
+ * @param string $name
52
+ * @return boolean
53
+ */
54
+ public function __isset($name)
55
+ {
56
+ return array_key_exists($name, $this->_attributes);
57
+ }
58
+
59
+ /**
60
+ * Mutator for instance properties stored in the private $_attributes property
61
+ *
62
+ * @ignore
63
+ * @param string $key
64
+ * @param mixed $value
65
+ */
66
+ public function _set($key, $value)
67
+ {
68
+ $this->_attributes[$key] = $value;
69
+ }
70
+ }
lib/Braintree/ClientToken.php CHANGED
@@ -7,21 +7,39 @@ class Braintree_ClientToken
7
 
8
  // static methods redirecting to gateway
9
 
 
 
 
 
 
10
  public static function generate($params=array())
11
  {
12
  return Braintree_Configuration::gateway()->clientToken()->generate($params);
13
  }
14
 
 
 
 
 
 
15
  public static function conditionallyVerifyKeys($params)
16
  {
17
  return Braintree_Configuration::gateway()->clientToken()->conditionallyVerifyKeys($params);
18
  }
19
 
 
 
 
 
20
  public static function generateWithCustomerIdSignature()
21
  {
22
  return Braintree_Configuration::gateway()->clientToken()->generateWithCustomerIdSignature();
23
  }
24
 
 
 
 
 
25
  public static function generateWithoutCustomerIdSignature()
26
  {
27
  return Braintree_Configuration::gateway()->clientToken()->generateWithoutCustomerIdSignature();
7
 
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();
lib/Braintree/ClientTokenGateway.php CHANGED
@@ -2,14 +2,33 @@
2
 
3
  class Braintree_ClientTokenGateway
4
  {
 
 
 
 
5
  private $_gateway;
 
 
 
 
 
6
  private $_config;
 
 
 
 
 
7
  private $_http;
8
 
 
 
 
 
9
  public function __construct($gateway)
10
  {
11
  $this->_gateway = $gateway;
12
  $this->_config = $gateway->config;
 
13
  $this->_http = new Braintree_Http($gateway->config);
14
  }
15
 
@@ -41,6 +60,11 @@ class Braintree_ClientTokenGateway
41
  return $this->_verifyGatewayResponse($response);
42
  }
43
 
 
 
 
 
 
44
  public function conditionallyVerifyKeys($params)
45
  {
46
  if (array_key_exists("customerId", $params)) {
@@ -50,11 +74,19 @@ class Braintree_ClientTokenGateway
50
  }
51
  }
52
 
 
 
 
 
53
  public function generateWithCustomerIdSignature()
54
  {
55
  return array("version", "customerId", "proxyMerchantId", array("options" => array("makeDefault", "verifyCard", "failOnDuplicatePaymentMethod")), "merchantAccountId");
56
  }
57
 
 
 
 
 
58
  public function generateWithoutCustomerIdSignature()
59
  {
60
  return array("version", "proxyMerchantId", "merchantAccountId");
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
 
60
  return $this->_verifyGatewayResponse($response);
61
  }
62
 
63
+ /**
64
+ *
65
+ * @param array $params
66
+ * @throws InvalidArgumentException
67
+ */
68
  public function conditionallyVerifyKeys($params)
69
  {
70
  if (array_key_exists("customerId", $params)) {
74
  }
75
  }
76
 
77
+ /**
78
+ *
79
+ * @return mixed[]
80
+ */
81
  public function generateWithCustomerIdSignature()
82
  {
83
  return array("version", "customerId", "proxyMerchantId", array("options" => array("makeDefault", "verifyCard", "failOnDuplicatePaymentMethod")), "merchantAccountId");
84
  }
85
 
86
+ /**
87
+ *
88
+ * @return string[]
89
+ */
90
  public function generateWithoutCustomerIdSignature()
91
  {
92
  return array("version", "proxyMerchantId", "merchantAccountId");
lib/Braintree/CoinbaseAccount.php CHANGED
@@ -22,7 +22,7 @@
22
  * @property-read string $userName
23
  * @property-read string $userEmail
24
  */
25
- class Braintree_CoinbaseAccount extends Braintree
26
  {
27
  /**
28
  * factory method: returns an instance of Braintree_CoinbaseAccount
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
lib/Braintree/Configuration.php CHANGED
@@ -16,6 +16,9 @@ class Braintree_Configuration
16
  private $_merchantId = null;
17
  private $_publicKey = null;
18
  private $_privateKey = null;
 
 
 
19
 
20
  /**
21
  * Braintree API version to use
@@ -27,18 +30,32 @@ class Braintree_Configuration
27
  {
28
  foreach ($attribs as $kind => $value) {
29
  if ($kind == 'environment') {
30
- $this->setEnvironment($value);
 
31
  }
32
  if ($kind == 'merchantId') {
33
- $this->setMerchantId($value);
34
  }
35
  if ($kind == 'publicKey') {
36
- $this->setPublicKey($value);
37
  }
38
  if ($kind == 'privateKey') {
39
- $this->setPrivateKey($value);
40
  }
41
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
44
  /**
@@ -55,29 +72,12 @@ class Braintree_Configuration
55
  return new Braintree_Gateway(self::$global);
56
  }
57
 
58
- /**
59
- *
60
- * @access protected
61
- * @static
62
- * @var array valid environments, used for validation
63
- */
64
- private static $_validEnvironments = array(
65
- 'development',
66
- 'sandbox',
67
- 'production',
68
- 'qa',
69
- );
70
-
71
- /**
72
- * resets configuration to default
73
- * @access public
74
- * @static
75
- */
76
  public static function environment($value=null)
77
  {
78
  if (empty($value)) {
79
  return self::$global->getEnvironment();
80
  }
 
81
  self::$global->setEnvironment($value);
82
  }
83
 
@@ -105,31 +105,56 @@ class Braintree_Configuration
105
  self::$global->setPrivateKey($value);
106
  }
107
 
108
- public function assertValid()
109
  {
110
- if (empty($this->_environment)) {
111
- throw new Braintree_Exception_Configuration('environment needs to be set.');
112
- } else if (empty($this->_merchantId)) {
113
- throw new Braintree_Exception_Configuration('merchantId needs to be set.');
114
- } else if (empty($this->_publicKey)) {
115
- throw new Braintree_Exception_Configuration('publicKey needs to be set.');
116
- } else if (empty($this->_privateKey)) {
117
- throw new Braintree_Exception_Configuration('privateKey needs to be set.');
 
 
 
 
 
 
 
118
  }
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
  public function getEnvironment()
123
  {
124
  return $this->_environment;
125
  }
126
 
 
 
 
127
  public function setEnvironment($value)
128
  {
129
- if (!in_array($value, self::$_validEnvironments)) {
130
- throw new Braintree_Exception_Configuration('"' .
131
- $value . '" is not a valid environment.');
132
- }
133
  $this->_environment = $value;
134
  }
135
 
@@ -138,6 +163,9 @@ class Braintree_Configuration
138
  return $this->_merchantId;
139
  }
140
 
 
 
 
141
  public function setMerchantId($value)
142
  {
143
  $this->_merchantId = $value;
@@ -148,6 +176,14 @@ class Braintree_Configuration
148
  return $this->_publicKey;
149
  }
150
 
 
 
 
 
 
 
 
 
151
  public function setPublicKey($value)
152
  {
153
  $this->_publicKey = $value;
@@ -158,11 +194,33 @@ class Braintree_Configuration
158
  return $this->_privateKey;
159
  }
160
 
 
 
 
 
 
 
 
 
161
  public function setPrivateKey($value)
162
  {
163
  $this->_privateKey = $value;
164
  }
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  /**
167
  * returns the base braintree gateway URL based on config values
168
  *
@@ -172,9 +230,16 @@ class Braintree_Configuration
172
  */
173
  public function baseUrl()
174
  {
175
- return $this->protocol() . '://' .
176
- $this->serverName() . ':' .
177
- $this->portNumber();
 
 
 
 
 
 
 
178
  }
179
 
180
  /**
@@ -261,6 +326,7 @@ class Braintree_Configuration
261
  $serverName = 'api.sandbox.braintreegateway.com';
262
  break;
263
  case 'development':
 
264
  default:
265
  $serverName = 'localhost';
266
  break;
@@ -282,6 +348,7 @@ class Braintree_Configuration
282
  $serverName = 'https://auth.sandbox.venmo.com';
283
  break;
284
  case 'development':
 
285
  default:
286
  $serverName = 'http://auth.venmo.dev:9292';
287
  break;
@@ -301,6 +368,7 @@ class Braintree_Configuration
301
  public function sslOn()
302
  {
303
  switch($this->_environment) {
 
304
  case 'development':
305
  $ssl = false;
306
  break;
16
  private $_merchantId = null;
17
  private $_publicKey = null;
18
  private $_privateKey = null;
19
+ private $_clientId = null;
20
+ private $_clientSecret = null;
21
+ private $_accessToken = null;
22
 
23
  /**
24
  * Braintree API version to use
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') {
37
+ $this->_merchantId = $value;
38
  }
39
  if ($kind == 'publicKey') {
40
+ $this->_publicKey = $value;
41
  }
42
  if ($kind == 'privateKey') {
43
+ $this->_privateKey = $value;
44
  }
45
  }
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();
55
+ $this->_clientId = $parsedCredentials->getClientId();
56
+ $this->_clientSecret = $parsedCredentials->getClientSecret();
57
+ $this->_accessToken = $parsedCredentials->getAccessToken();
58
+ }
59
  }
60
 
61
  /**
72
  return new Braintree_Gateway(self::$global);
73
  }
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  public static function environment($value=null)
76
  {
77
  if (empty($value)) {
78
  return self::$global->getEnvironment();
79
  }
80
+ Braintree_CredentialsParser::assertValidEnvironment($value);
81
  self::$global->setEnvironment($value);
82
  }
83
 
105
  self::$global->setPrivateKey($value);
106
  }
107
 
108
+ public static function assertGlobalHasAccessTokenOrKeys()
109
  {
110
+ self::$global->assertHasAccessTokenOrKeys();
111
+ }
112
+
113
+ public function assertHasAccessTokenOrKeys()
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
  }
127
 
128
+ public function assertHasClientCredentials()
129
+ {
130
+ $this->assertHasClientId();
131
+ $this->assertHasClientSecret();
132
+ }
133
+
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
 
148
  public function getEnvironment()
149
  {
150
  return $this->_environment;
151
  }
152
 
153
+ /**
154
+ * Do not use this method directly. Pass in the environment to the constructor.
155
+ */
156
  public function setEnvironment($value)
157
  {
 
 
 
 
158
  $this->_environment = $value;
159
  }
160
 
163
  return $this->_merchantId;
164
  }
165
 
166
+ /**
167
+ * Do not use this method directly. Pass in the merchantId to the constructor.
168
+ */
169
  public function setMerchantId($value)
170
  {
171
  $this->_merchantId = $value;
176
  return $this->_publicKey;
177
  }
178
 
179
+ public function getClientId()
180
+ {
181
+ return $this->_clientId;
182
+ }
183
+
184
+ /**
185
+ * Do not use this method directly. Pass in the publicKey to the constructor.
186
+ */
187
  public function setPublicKey($value)
188
  {
189
  $this->_publicKey = $value;
194
  return $this->_privateKey;
195
  }
196
 
197
+ public function getClientSecret()
198
+ {
199
+ return $this->_clientSecret;
200
+ }
201
+
202
+ /**
203
+ * Do not use this method directly. Pass in the privateKey to the constructor.
204
+ */
205
  public function setPrivateKey($value)
206
  {
207
  $this->_privateKey = $value;
208
  }
209
 
210
+ public function getAccessToken()
211
+ {
212
+ return $this->_accessToken;
213
+ }
214
+
215
+ public function isAccessToken()
216
+ {
217
+ return !empty($this->_accessToken);
218
+ }
219
+
220
+ public function isClientCredentials()
221
+ {
222
+ return !empty($this->_clientId);
223
+ }
224
  /**
225
  * returns the base braintree gateway URL based on config values
226
  *
230
  */
231
  public function baseUrl()
232
  {
233
+ static $defaultPorts = array(
234
+ 'http' => 80,
235
+ 'https' => 443,
236
+ );
237
+
238
+ if ($this->portNumber() === $defaultPorts[$this->protocol()]) {
239
+ return sprintf('%s://%s', $this->protocol(), $this->serverName());
240
+ } else {
241
+ return sprintf('%s://%s:%d', $this->protocol(), $this->serverName(), $this->portNumber());
242
+ }
243
  }
244
 
245
  /**
326
  $serverName = 'api.sandbox.braintreegateway.com';
327
  break;
328
  case 'development':
329
+ case 'integration':
330
  default:
331
  $serverName = 'localhost';
332
  break;
348
  $serverName = 'https://auth.sandbox.venmo.com';
349
  break;
350
  case 'development':
351
+ case 'integration':
352
  default:
353
  $serverName = 'http://auth.venmo.dev:9292';
354
  break;
368
  public function sslOn()
369
  {
370
  switch($this->_environment) {
371
+ case 'integration':
372
  case 'development':
373
  $ssl = false;
374
  break;
lib/Braintree/CredentialsParser.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
15
+ private $_accessToken;
16
+ private $_environment;
17
+ private $_merchantId;
18
+
19
+ public function __construct($attribs)
20
+ {
21
+ foreach ($attribs as $kind => $value) {
22
+ if ($kind == 'clientId') {
23
+ $this->_clientId = $value;
24
+ }
25
+ if ($kind == 'clientSecret') {
26
+ $this->_clientSecret = $value;
27
+ }
28
+ if ($kind == 'accessToken') {
29
+ $this->_accessToken = $value;
30
+ }
31
+ }
32
+ $this->parse();
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @access protected
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
+ }
70
+ }
71
+
72
+ self::assertValidEnvironment($checkEnv[1]);
73
+ $this->_environment = $checkEnv[1];
74
+ }
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
+ }
82
+
83
+ private function _parseClientCredential($credentialType, $value, $expectedValuePrefix)
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];
91
+ $environment = $explodedCredential[1];
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;
99
+ }
100
+
101
+ private function _parseAccessToken()
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];
109
+ $environment = $accessTokenExploded[1];
110
+ $merchantId = $accessTokenExploded[2];
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;
118
+ return $environment;
119
+ }
120
+
121
+ public function getClientId()
122
+ {
123
+ return $this->_clientId;
124
+ }
125
+
126
+ public function getClientSecret()
127
+ {
128
+ return $this->_clientSecret;
129
+ }
130
+
131
+ public function getAccessToken()
132
+ {
133
+ return $this->_accessToken;
134
+ }
135
+
136
+ public function getEnvironment()
137
+ {
138
+ return $this->_environment;
139
+ }
140
+
141
+ public function getMerchantId()
142
+ {
143
+ return $this->_merchantId;
144
+ }
145
+ }
lib/Braintree/CreditCard.php CHANGED
@@ -27,7 +27,7 @@
27
  * @property-read string $token
28
  * @property-read string $updatedAt
29
  */
30
- class Braintree_CreditCard extends Braintree
31
  {
32
  // Card Type
33
  const AMEX = 'American Express';
@@ -44,7 +44,7 @@ class Braintree_CreditCard extends Braintree
44
  const VISA = 'Visa';
45
  const UNKNOWN = 'Unknown';
46
 
47
- // Credit card origination location
48
  const INTERNATIONAL = "international";
49
  const US = "us";
50
 
@@ -289,4 +289,23 @@ class Braintree_CreditCard extends Braintree
289
  {
290
  return Braintree_Configuration::gateway()->creditCard()->delete($token);
291
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  }
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';
44
  const VISA = 'Visa';
45
  const UNKNOWN = 'Unknown';
46
 
47
+ // Credit card origination location
48
  const INTERNATIONAL = "international";
49
  const US = "us";
50
 
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
  }
lib/Braintree/CreditCardGateway.php CHANGED
@@ -22,6 +22,7 @@ class Braintree_CreditCardGateway
22
  {
23
  $this->_gateway = $gateway;
24
  $this->_config = $gateway->config;
 
25
  $this->_http = new Braintree_Http($gateway->config);
26
  }
27
 
22
  {
23
  $this->_gateway = $gateway;
24
  $this->_config = $gateway->config;
25
+ $this->_config->assertHasAccessTokenOrKeys();
26
  $this->_http = new Braintree_Http($gateway->config);
27
  }
28
 
lib/Braintree/CreditCardVerificationGateway.php CHANGED
@@ -9,6 +9,7 @@ class Braintree_CreditCardVerificationGateway
9
  {
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
 
12
  $this->_http = new Braintree_Http($gateway->config);
13
  }
14
 
9
  {
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
12
+ $this->_config->assertHasAccessTokenOrKeys();
13
  $this->_http = new Braintree_Http($gateway->config);
14
  }
15
 
lib/Braintree/CreditCardVerificationSearch.php CHANGED
@@ -1,33 +1,53 @@
1
  <?php
2
  class Braintree_CreditCardVerificationSearch
3
  {
4
- static function id() { return new Braintree_TextNode('id'); }
5
- static function creditCardCardholderName() { return new Braintree_TextNode('credit_card_cardholder_name'); }
 
 
 
 
 
6
 
7
- static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); }
8
- static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); }
 
 
 
 
 
9
 
10
- static function ids() { return new Braintree_MultipleValueNode('ids'); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  static function creditCardCardType()
13
  {
14
- return new Braintree_MultipleValueNode("credit_card_card_type", array(
15
- Braintree_CreditCard::AMEX,
16
- Braintree_CreditCard::CARTE_BLANCHE,
17
- Braintree_CreditCard::CHINA_UNION_PAY,
18
- Braintree_CreditCard::DINERS_CLUB_INTERNATIONAL,
19
- Braintree_CreditCard::DISCOVER,
20
- Braintree_CreditCard::JCB,
21
- Braintree_CreditCard::LASER,
22
- Braintree_CreditCard::MAESTRO,
23
- Braintree_CreditCard::MASTER_CARD,
24
- Braintree_CreditCard::SOLO,
25
- Braintree_CreditCard::SWITCH_TYPE,
26
- Braintree_CreditCard::VISA,
27
- Braintree_CreditCard::UNKNOWN
28
- ));
29
- }
30
-
31
-
32
- static function createdAt() { return new Braintree_RangeNode("created_at"); }
33
  }
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/Braintree/Customer.php CHANGED
@@ -12,12 +12,13 @@
12
  * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read array $addresses
15
- * @property-read array $applePayCards
16
  * @property-read string $company
17
  * @property-read string $createdAt
18
  * @property-read array $creditCards
19
- * @property-read array $coinbaseAccounts
20
  * @property-read array $paypalAccounts
 
 
21
  * @property-read array $customFields custom fields passed with the request
22
  * @property-read string $email
23
  * @property-read string $fax
@@ -28,88 +29,185 @@
28
  * @property-read string $updatedAt
29
  * @property-read string $website
30
  */
31
- class Braintree_Customer extends Braintree
32
  {
 
 
 
 
33
  public static function all()
34
  {
35
  return Braintree_Configuration::gateway()->customer()->all();
36
  }
37
 
 
 
 
 
 
 
38
  public static function fetch($query, $ids)
39
  {
40
  return Braintree_Configuration::gateway()->customer()->fetch($query, $ids);
41
  }
42
 
 
 
 
 
 
43
  public static function create($attribs = array())
44
  {
45
  return Braintree_Configuration::gateway()->customer()->create($attribs);
46
  }
47
 
 
 
 
 
 
48
  public static function createNoValidate($attribs = array())
49
  {
50
  return Braintree_Configuration::gateway()->customer()->createNoValidate($attribs);
51
  }
52
 
 
 
 
 
 
53
  public static function createFromTransparentRedirect($queryString)
54
  {
55
  return Braintree_Configuration::gateway()->customer()->createFromTransparentRedirect($queryString);
56
  }
57
 
 
 
 
 
58
  public static function createCustomerUrl()
59
  {
60
  return Braintree_Configuration::gateway()->customer()->createCustomerUrl();
61
  }
62
 
 
 
 
 
 
 
63
  public static function find($id)
64
  {
65
  return Braintree_Configuration::gateway()->customer()->find($id);
66
  }
67
 
 
 
 
 
 
 
68
  public static function credit($customerId, $transactionAttribs)
69
  {
70
  return Braintree_Configuration::gateway()->customer()->credit($customerId, $transactionAttribs);
71
  }
72
 
 
 
 
 
 
 
 
73
  public static function creditNoValidate($customerId, $transactionAttribs)
74
  {
75
  return Braintree_Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs);
76
  }
77
 
 
 
 
 
 
 
78
  public static function delete($customerId)
79
  {
80
  return Braintree_Configuration::gateway()->customer()->delete($customerId);
81
  }
82
 
 
 
 
 
 
 
83
  public static function sale($customerId, $transactionAttribs)
84
  {
85
  return Braintree_Configuration::gateway()->customer()->sale($customerId, $transactionAttribs);
86
  }
87
 
 
 
 
 
 
 
88
  public static function saleNoValidate($customerId, $transactionAttribs)
89
  {
90
  return Braintree_Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs);
91
  }
92
 
 
 
 
 
 
 
93
  public static function search($query)
94
  {
95
  return Braintree_Configuration::gateway()->customer()->search($query);
96
  }
97
 
 
 
 
 
 
 
 
98
  public static function update($customerId, $attributes)
99
  {
100
  return Braintree_Configuration::gateway()->customer()->update($customerId, $attributes);
101
  }
102
 
 
 
 
 
 
 
 
103
  public static function updateNoValidate($customerId, $attributes)
104
  {
105
  return Braintree_Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes);
106
  }
107
 
 
 
 
 
 
108
  public static function updateCustomerUrl()
109
  {
110
  return Braintree_Configuration::gateway()->customer()->updateCustomerUrl();
111
  }
112
 
 
 
 
 
 
 
113
  public static function updateFromTransparentRedirect($queryString)
114
  {
115
  return Braintree_Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString);
@@ -123,7 +221,6 @@ class Braintree_Customer extends Braintree
123
  * @ignore
124
  * @access protected
125
  * @param array $customerAttribs array of customer data
126
- * @return none
127
  */
128
  protected function _initialize($customerAttribs)
129
  {
@@ -171,10 +268,21 @@ class Braintree_Customer extends Braintree
171
  $applePayCardArray = array();
172
  if (isset($customerAttribs['applePayCards'])) {
173
  foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
174
- $applePayCardArray[] = Braintree_applePayCard::factory($applePayCard);
175
  }
176
  }
177
  $this->_set('applePayCards', $applePayCardArray);
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
 
180
  /**
@@ -202,11 +310,13 @@ class Braintree_Customer extends Braintree
202
  /**
203
  * returns an array containt all of the customer's payment methods
204
  *
 
 
205
  * @return array
206
  */
207
  public function paymentMethods()
208
  {
209
- return array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts);
210
  }
211
 
212
  /**
@@ -216,7 +326,7 @@ class Braintree_Customer extends Braintree
216
  */
217
  public function defaultPaymentMethod()
218
  {
219
- $defaultPaymentMethods = array_filter($this->paymentMethods(), 'Braintree_Customer::_defaultPaymentMethodFilter');
220
  return current($defaultPaymentMethods);
221
  }
222
 
@@ -251,7 +361,8 @@ class Braintree_Customer extends Braintree
251
  * to the requesting method, with populated properties
252
  *
253
  * @ignore
254
- * @return object instance of Braintree_Customer
 
255
  */
256
  public static function factory($attributes)
257
  {
12
  * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  *
14
  * @property-read array $addresses
15
+ * @property-read array $paymentMethods
16
  * @property-read string $company
17
  * @property-read string $createdAt
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
24
  * @property-read string $fax
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
+ /**
85
+ * @deprecated since version 2.3.0
86
+ * @return string
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);
221
  * @ignore
222
  * @access protected
223
  * @param array $customerAttribs array of customer data
 
224
  */
225
  protected function _initialize($customerAttribs)
226
  {
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
  /**
310
  /**
311
  * returns an array containt all of the customer's payment methods
312
  *
313
+ * @deprecated since version 3.1.0 - use the paymentMethods property directly
314
+ *
315
  * @return array
316
  */
317
  public function paymentMethods()
318
  {
319
+ return $this->paymentMethods;
320
  }
321
 
322
  /**
326
  */
327
  public function defaultPaymentMethod()
328
  {
329
+ $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree_Customer::_defaultPaymentMethodFilter');
330
  return current($defaultPaymentMethods);
331
  }
332
 
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
  {
lib/Braintree/CustomerGateway.php CHANGED
@@ -21,6 +21,7 @@ class Braintree_CustomerGateway
21
  {
22
  $this->_gateway = $gateway;
23
  $this->_config = $gateway->config;
 
24
  $this->_http = new Braintree_Http($gateway->config);
25
  }
26
 
@@ -101,6 +102,7 @@ class Braintree_CustomerGateway
101
  /**
102
  * create a customer from a TransparentRedirect operation
103
  *
 
104
  * @access public
105
  * @param array $attribs
106
  * @return object
@@ -119,6 +121,7 @@ class Braintree_CustomerGateway
119
 
120
  /**
121
  *
 
122
  * @access public
123
  * @param none
124
  * @return string
@@ -139,7 +142,7 @@ class Braintree_CustomerGateway
139
  {
140
 
141
  $creditCardSignature = Braintree_CreditCardGateway::createSignature();
142
- unset($creditCardSignature['customerId']);
143
  $signature = array(
144
  'id', 'company', 'email', 'fax', 'firstName',
145
  'lastName', 'phone', 'website', 'deviceData',
@@ -202,8 +205,9 @@ class Braintree_CustomerGateway
202
  * credit a customer for the passed transaction
203
  *
204
  * @access public
205
- * @param array $attribs
206
- * @return object Braintree_Result_Successful or Braintree_Result_Error
 
207
  */
208
  public function credit($customerId, $transactionAttribs)
209
  {
@@ -221,8 +225,9 @@ class Braintree_CustomerGateway
221
  * returns a Braintree_Transaction object on success
222
  *
223
  * @access public
224
- * @param array $attribs
225
- * @return object Braintree_Transaction
 
226
  * @throws Braintree_Exception_ValidationError
227
  */
228
  public function creditNoValidate($customerId, $transactionAttribs)
@@ -287,7 +292,6 @@ class Braintree_CustomerGateway
287
  * For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/customer-api#searching http://www.braintreepaymentsolutions.com/gateway/customer-api}
288
  *
289
  * @param mixed $query search query
290
- * @param array $options options such as page number
291
  * @return object Braintree_ResourceCollection
292
  * @throws InvalidArgumentException
293
  */
@@ -321,8 +325,8 @@ class Braintree_CustomerGateway
321
  * is the 2nd attribute. customerId is not sent in object context.
322
  *
323
  * @access public
324
- * @param array $attributes
325
  * @param string $customerId (optional)
 
326
  * @return object Braintree_Result_Successful or Braintree_Result_Error
327
  */
328
  public function update($customerId, $attributes)
@@ -344,8 +348,8 @@ class Braintree_CustomerGateway
344
  * returns a Braintree_Customer object on success
345
  *
346
  * @access public
347
- * @param array $attributes
348
  * @param string $customerId
 
349
  * @return object Braintree_Customer
350
  * @throws Braintree_Exception_ValidationsFailed
351
  */
@@ -356,8 +360,8 @@ class Braintree_CustomerGateway
356
  }
357
  /**
358
  *
 
359
  * @access public
360
- * @param none
361
  * @return string
362
  */
363
  public function updateCustomerUrl()
@@ -370,8 +374,9 @@ class Braintree_CustomerGateway
370
  /**
371
  * update a customer from a TransparentRedirect operation
372
  *
 
373
  * @access public
374
- * @param array $attribs
375
  * @return object
376
  */
377
  public function updateFromTransparentRedirect($queryString)
@@ -421,6 +426,15 @@ class Braintree_CustomerGateway
421
  }
422
  $this->_set('creditCards', $creditCardArray);
423
 
 
 
 
 
 
 
 
 
 
424
  // map each paypalAccount into its own object
425
  $paypalAccountArray = array();
426
  if (isset($customerAttribs['paypalAccounts'])) {
@@ -438,6 +452,17 @@ class Braintree_CustomerGateway
438
  }
439
  }
440
  $this->_set('applePayCards', $applePayCardArray);
 
 
 
 
 
 
 
 
 
 
 
441
  }
442
 
443
  /**
@@ -469,17 +494,17 @@ class Braintree_CustomerGateway
469
  */
470
  public function paymentMethods()
471
  {
472
- return array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards);
473
  }
474
 
475
  /**
476
  * returns the customer's default payment method
477
  *
478
- * @return object Braintree_CreditCard or Braintree_PayPalAccount
479
  */
480
  public function defaultPaymentMethod()
481
  {
482
- $defaultPaymentMethods = array_filter($this->paymentMethods(), 'Braintree_Customer::_defaultPaymentMethodFilter');
483
  return current($defaultPaymentMethods);
484
  }
485
 
21
  {
22
  $this->_gateway = $gateway;
23
  $this->_config = $gateway->config;
24
+ $this->_config->assertHasAccessTokenOrKeys();
25
  $this->_http = new Braintree_Http($gateway->config);
26
  }
27
 
102
  /**
103
  * create a customer from a TransparentRedirect operation
104
  *
105
+ * @deprecated since version 2.3.0
106
  * @access public
107
  * @param array $attribs
108
  * @return object
121
 
122
  /**
123
  *
124
+ * @deprecated since version 2.3.0
125
  * @access public
126
  * @param none
127
  * @return string
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',
205
  * credit a customer for the passed transaction
206
  *
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
  {
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)
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
  */
325
  * is the 2nd attribute. customerId is not sent in object context.
326
  *
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)
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
  */
360
  }
361
  /**
362
  *
363
+ * @deprecated since version 2.3.0
364
  * @access public
 
365
  * @return string
366
  */
367
  public function updateCustomerUrl()
374
  /**
375
  * update a customer from a TransparentRedirect operation
376
  *
377
+ * @deprecated since version 2.3.0
378
  * @access public
379
+ * @param string $queryString
380
  * @return object
381
  */
382
  public function updateFromTransparentRedirect($queryString)
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'])) {
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);
464
+
465
+ $this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards));
466
  }
467
 
468
  /**
494
  */
495
  public function paymentMethods()
496
  {
497
+ return $this->paymentMethods;
498
  }
499
 
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
 
lib/Braintree/Disbursement.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- final class Braintree_Disbursement extends Braintree
3
  {
4
  private $_merchantAccount;
5
 
1
  <?php
2
+ final class Braintree_Disbursement extends Braintree_Base
3
  {
4
  private $_merchantAccount;
5
 
lib/Braintree/DiscountGateway.php CHANGED
@@ -9,6 +9,7 @@ class Braintree_DiscountGateway
9
  {
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
 
12
  $this->_http = new Braintree_Http($gateway->config);
13
  }
14
 
9
  {
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
12
+ $this->_config->assertHasAccessTokenOrKeys();
13
  $this->_http = new Braintree_Http($gateway->config);
14
  }
15
 
lib/Braintree/Dispute.php CHANGED
@@ -14,7 +14,7 @@
14
  * @property-read string $disbursementDate
15
  * @property-read object $transactionDetails
16
  */
17
- final class Braintree_Dispute extends Braintree
18
  {
19
  protected $_attributes = array();
20
 
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
 
lib/Braintree/Error/Codes.php CHANGED
@@ -16,51 +16,52 @@
16
  */
17
  class Braintree_Error_Codes
18
  {
19
- const ADDRESS_CANNOT_BE_BLANK = '81801';
20
- const ADDRESS_COMPANY_IS_TOO_LONG = '81802';
21
- const ADDRESS_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED = '91814';
22
- const ADDRESS_COUNTRY_CODE_ALPHA3_IS_NOT_ACCEPTED = '91816';
23
- const ADDRESS_COUNTRY_CODE_NUMERIC_IS_NOT_ACCEPTED = '91817';
24
- const ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED = '91803';
25
- const ADDRESS_EXTENDED_ADDRESS_IS_TOO_LONG = '81804';
26
- const ADDRESS_FIRST_NAME_IS_TOO_LONG = '81805';
27
- const ADDRESS_INCONSISTENT_COUNTRY = '91815';
28
- const ADDRESS_LAST_NAME_IS_TOO_LONG = '81806';
29
- const ADDRESS_LOCALITY_IS_TOO_LONG = '81807';
30
- const ADDRESS_POSTAL_CODE_INVALID_CHARACTERS = '81813';
31
- const ADDRESS_POSTAL_CODE_IS_REQUIRED = '81808';
32
- const ADDRESS_POSTAL_CODE_IS_TOO_LONG = '81809';
33
- const ADDRESS_REGION_IS_TOO_LONG = '81810';
34
- const ADDRESS_STREET_ADDRESS_IS_REQUIRED = '81811';
35
- const ADDRESS_STREET_ADDRESS_IS_TOO_LONG = '81812';
36
- const ADDRESS_TOO_MANY_ADDRESSES_PER_CUSTOMER = '91818';
37
- const ADDRESS_COMPANY_IS_INVALID = '91821';
38
- const ADDRESS_REGION_IS_INVALID = '91825';
39
- const ADDRESS_POSTAL_CODE_IS_INVALID = '91826';
40
- const ADDRESS_LAST_NAME_IS_INVALID = '91820';
41
- const ADDRESS_EXTENDED_ADDRESS_IS_INVALID = '91823';
42
- const ADDRESS_STREET_ADDRESS_IS_INVALID = '91822';
43
- const ADDRESS_LOCALITY_IS_INVALID = '91824';
44
- const ADDRESS_FIRST_NAME_IS_INVALID = '91819';
 
45
 
46
- const APPLE_PAY_CARDS_ARE_NOT_ACCEPTED = "83501";
47
- const APPLE_PAY_CUSTOMER_ID_IS_REQUIRED_FOR_VAULTING = "83502";
48
- const APPLE_PAY_TOKEN_IS_IN_USE = "93503";
49
- const APPLE_PAY_PAYMENT_METHOD_NONCE_CONSUMED = "93504";
50
- const APPLE_PAY_PAYMENT_METHOD_NONCE_UNKNOWN = "93505";
51
- const APPLE_PAY_PAYMENT_METHOD_NONCE_UNLOCKED = "93506";
52
- const APPLE_PAY_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = "83518";
53
- const APPLE_PAY_CANNOT_UPDATE_APPLE_PAY_CARD_USING_PAYMENT_METHOD_NONCE = "93507";
54
- const APPLE_PAY_NUMBER_IS_REQUIRED = "93508";
55
- const APPLE_PAY_EXPIRATION_MONTH_IS_REQUIRED = "93509";
56
- const APPLE_PAY_EXPIRATION_YEAR_IS_REQUIRED = "93510";
57
- const APPLE_PAY_CRYPTOGRAM_IS_REQUIRED = "93511";
58
- const APPLE_PAY_DECRYPTION_FAILED = "83512";
59
- const APPLE_PAY_DISABLED = "93513";
60
- const APPLE_PAY_MERCHANT_NOT_CONFIGURED = "93514";
61
- const APPLE_PAY_MERCHANT_KEYS_ALREADY_CONFIGURED = "93515";
62
- const APPLE_PAY_MERCHANT_KEYS_NOT_CONFIGURED = "93516";
63
- const APPLE_PAY_CERTIFICATE_INVALID = "93517";
64
  const APPLE_PAY_CERTIFICATE_MISMATCH = '93519';
65
  const APPLE_PAY_INVALID_TOKEN = '83520';
66
  const APPLE_PAY_PRIVATE_KEY_MISMATCH = '93521';
@@ -83,6 +84,7 @@ class Braintree_Error_Codes
83
  const CLIENT_TOKEN_MERCHANT_ACCOUNT_DOES_NOT_EXIST = '92807';
84
 
85
  const CREDIT_CARD_BILLING_ADDRESS_CONFLICT = '91701';
 
86
  const CREDIT_CARD_BILLING_ADDRESS_ID_IS_INVALID = '91702';
87
  const CREDIT_CARD_CANNOT_UPDATE_CARD_USING_PAYMENT_METHOD_NONCE = '91735';
88
  const CREDIT_CARD_CARDHOLDER_NAME_IS_TOO_LONG = '81723';
@@ -100,6 +102,7 @@ class Braintree_Error_Codes
100
  const CREDIT_CARD_EXPIRATION_DATE_YEAR_IS_INVALID = '81711';
101
  const CREDIT_CARD_EXPIRATION_MONTH_IS_INVALID = '81712';
102
  const CREDIT_CARD_EXPIRATION_YEAR_IS_INVALID = '81713';
 
103
  const CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE = '91727';
104
  const CREDIT_CARD_NUMBER_INVALID_LENGTH = '81716';
105
  const CREDIT_CARD_NUMBER_IS_INVALID = '81715';
@@ -108,16 +111,18 @@ class Braintree_Error_Codes
108
  const CREDIT_CARD_NUMBER_MUST_BE_TEST_NUMBER = '81717';
109
  const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_IS_INVALID = '91723';
110
  const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_NOT_ALLOWED = '91729';
111
- const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91728';
112
  const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_CANNOT_BE_NEGATIVE = '91739';
113
  const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_FORMAT_IS_INVALID = '91740';
114
  const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = '91741';
 
 
 
115
  const CREDIT_CARD_PAYMENT_METHOD_CONFLICT = '81725';
 
116
  const CREDIT_CARD_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91734';
117
  const CREDIT_CARD_PAYMENT_METHOD_NONCE_CONSUMED = '91731';
118
  const CREDIT_CARD_PAYMENT_METHOD_NONCE_LOCKED = '91733';
119
  const CREDIT_CARD_PAYMENT_METHOD_NONCE_UNKNOWN = '91732';
120
- const CREDIT_CARD_PAYMENT_METHOD_IS_NOT_A_CREDIT_CARD = '91738';
121
  const CREDIT_CARD_POSTAL_CODE_VERIFICATION_FAILED = '81737';
122
  const CREDIT_CARD_TOKEN_FORMAT_IS_INVALID = '91718';
123
  const CREDIT_CARD_TOKEN_INVALID = '91718';
@@ -128,26 +133,27 @@ class Braintree_Error_Codes
128
  const CREDIT_CARD_VENMO_SDK_PAYMENT_METHOD_CODE_CARD_TYPE_IS_NOT_ACCEPTED = '91726';
129
  const CREDIT_CARD_VERIFICATION_NOT_SUPPORTED_ON_THIS_MERCHANT_ACCOUNT = '91730';
130
 
131
- const CUSTOMER_COMPANY_IS_TOO_LONG = '81601';
132
- const CUSTOMER_CUSTOM_FIELD_IS_INVALID = '91602';
133
- const CUSTOMER_CUSTOM_FIELD_IS_TOO_LONG = '81603';
134
- const CUSTOMER_EMAIL_IS_INVALID = '81604';
135
- const CUSTOMER_EMAIL_FORMAT_IS_INVALID = '81604';
136
- const CUSTOMER_EMAIL_IS_REQUIRED = '81606';
137
- const CUSTOMER_EMAIL_IS_TOO_LONG = '81605';
138
- const CUSTOMER_FAX_IS_TOO_LONG = '81607';
139
- const CUSTOMER_FIRST_NAME_IS_TOO_LONG = '81608';
140
- const CUSTOMER_ID_IS_INVAILD = '91610'; //Deprecated
141
- const CUSTOMER_ID_IS_INVALID = '91610';
142
- const CUSTOMER_ID_IS_IN_USE = '91609';
143
- const CUSTOMER_ID_IS_NOT_ALLOWED = '91611';
144
- const CUSTOMER_ID_IS_REQUIRED = '91613';
145
- const CUSTOMER_ID_IS_TOO_LONG = '91612';
146
- const CUSTOMER_LAST_NAME_IS_TOO_LONG = '81613';
147
- const CUSTOMER_PHONE_IS_TOO_LONG = '81614';
148
- const CUSTOMER_WEBSITE_IS_INVALID = '81616';
149
- const CUSTOMER_WEBSITE_FORMAT_IS_INVALID = '81616';
150
- const CUSTOMER_WEBSITE_IS_TOO_LONG = '81615';
 
151
 
152
  const DESCRIPTOR_NAME_FORMAT_IS_INVALID = '92201';
153
  const DESCRIPTOR_PHONE_FORMAT_IS_INVALID = '92202';
@@ -163,12 +169,26 @@ class Braintree_Error_Codes
163
  const INDUSTRY_DATA_LODGING_CHECK_OUT_DATE_IS_INVALID = '93405';
164
  const INDUSTRY_DATA_LODGING_CHECK_OUT_DATE_MUST_FOLLOW_CHECK_IN_DATE = '93406';
165
  const INDUSTRY_DATA_LODGING_UNKNOWN_DATA_FIELD = '93407';
166
- const INDUSTRY_DATA_TRAVEL_CRUISE_EMPTY_DATA = "93408";
167
- const INDUSTRY_DATA_TRAVEL_CRUISE_UNKNOWN_DATA_FIELD = "93409";
168
- const INDUSTRY_DATA_TRAVEL_CRUISE_TRAVEL_PACKAGE_IS_INVALID = "93410";
169
- const INDUSTRY_DATA_TRAVEL_CRUISE_DEPARTURE_DATE_IS_INVALID = "93411";
170
- const INDUSTRY_DATA_TRAVEL_CRUISE_LODGING_CHECK_IN_DATE_IS_INVALID = "93412";
171
- const INDUSTRY_DATA_TRAVEL_CRUISE_LODGING_CHECK_OUT_DATE_IS_INVALID = "93413";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
  const MERCHANT_ACCOUNT_ID_FORMAT_IS_INVALID = '82603';
174
  const MERCHANT_ACCOUNT_ID_IS_IN_USE = '82604';
@@ -262,6 +282,12 @@ class Braintree_Error_Codes
262
  const MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_REQUIRED = '82682';
263
  const MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_INVALID = '82683';
264
 
 
 
 
 
 
 
265
  const PAYMENT_METHOD_CANNOT_FORWARD_PAYMENT_METHOD_TYPE = '93106';
266
  const PAYMENT_METHOD_CUSTOMER_ID_IS_INVALID = '93105';
267
  const PAYMENT_METHOD_CUSTOMER_ID_IS_REQUIRED = '93104';
@@ -272,20 +298,21 @@ class Braintree_Error_Codes
272
  const PAYMENT_METHOD_PAYMENT_METHOD_NONCE_LOCKED = '93109';
273
  const PAYMENT_METHOD_PAYMENT_METHOD_PARAMS_ARE_REQUIRED = '93101';
274
 
275
- const PAYPAL_ACCOUNT_CANNOT_HAVE_BOTH_ACCESS_TOKEN_AND_CONSENT_CODE = '82903';
276
- const PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT = '82902';
277
- const PAYPAL_ACCOUNT_CONSENT_CODE_OR_ACCESS_TOKEN_IS_REQUIRED = '82901';
278
- const PAYPAL_ACCOUNT_CUSTOMER_ID_IS_REQUIRED_FOR_VAULTING = '82905';
279
- const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_CONSUMED = '92907';
280
- const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_LOCKED = '92909';
281
- const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_UNKNOWN = '92908';
282
- const PAYPAL_ACCOUNT_PAYPAL_ACCOUNTS_ARE_NOT_ACCEPTED = '82904';
283
- const PAYPAL_ACCOUNT_PAYPAL_COMMUNICATION_ERROR = '92910';
284
- const PAYPAL_ACCOUNT_TOKEN_IS_IN_USE = '92906';
285
- const PAYPAL_ACCOUNT_AUTH_EXPIRED = '92911';
286
- const PAYPAL_ACCOUNT_CANNOT_HAVE_FUNDING_SOURCE_WITHOUT_ACCESS_TOKEN = '92912';
287
- const PAYPAL_ACCOUNT_INVALID_FUNDING_SOURCE_SELECTION = '92913';
288
  const PAYPAL_ACCOUNT_CANNOT_UPDATE_PAYPAL_ACCOUNT_USING_PAYMENT_METHOD_NONCE = '92914';
 
 
 
 
 
 
 
 
 
 
 
289
 
290
  const SEPA_BANK_ACCOUNT_ACCOUNT_HOLDER_NAME_IS_REQUIRED = '93003';
291
  const SEPA_BANK_ACCOUNT_BIC_IS_REQUIRED = '93002';
@@ -309,43 +336,46 @@ class Braintree_Error_Codes
309
  const SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_REQUIRED = '82301';
310
  const SETTLEMENT_BATCH_SUMMARY_CUSTOM_FIELD_IS_INVALID = '82303';
311
 
312
- const SUBSCRIPTION_BILLING_DAY_OF_MONTH_CANNOT_BE_UPDATED = '91918';
313
- const SUBSCRIPTION_BILLING_DAY_OF_MONTH_IS_INVALID = '91914';
314
- const SUBSCRIPTION_BILLING_DAY_OF_MONTH_MUST_BE_NUMERIC = '91913';
315
- const SUBSCRIPTION_CANNOT_ADD_DUPLICATE_ADDON_OR_DISCOUNT = '91911';
316
- const SUBSCRIPTION_CANNOT_EDIT_CANCELED_SUBSCRIPTION = '81901';
317
- const SUBSCRIPTION_CANNOT_EDIT_EXPIRED_SUBSCRIPTION = '81910';
318
- const SUBSCRIPTION_CANNOT_EDIT_PRICE_CHANGING_FIELDS_ON_PAST_DUE_SUBSCRIPTION = '91920';
319
- const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_IN_THE_PAST = '91916';
320
- const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_UPDATED = '91919';
321
- const SUBSCRIPTION_FIRST_BILLING_DATE_IS_INVALID = '91915';
322
- const SUBSCRIPTION_ID_IS_IN_USE = '81902';
323
- const SUBSCRIPTION_INCONSISTENT_NUMBER_OF_BILLING_CYCLES = '91908';
324
- const SUBSCRIPTION_INCONSISTENT_START_DATE = '91917';
325
- const SUBSCRIPTION_INVALID_REQUEST_FORMAT = '91921';
326
- const SUBSCRIPTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91901';
327
- const SUBSCRIPTION_MISMATCH_CURRENCY_ISO_CODE = '91923';
328
- const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_CANNOT_BE_BLANK = '91912';
329
- const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_IS_TOO_SMALL = '91909';
330
- const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_GREATER_THAN_ZERO = '91907';
331
- const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_NUMERIC = '91906';
332
- const SUBSCRIPTION_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91924';
333
- const SUBSCRIPTION_PAYMENT_METHOD_NONCE_IS_INVALID = '91925';
334
- const SUBSCRIPTION_PAYMENT_METHOD_NONCE_NOT_ASSOCIATED_WITH_CUSTOMER = '91926';
335
- const SUBSCRIPTION_PAYMENT_METHOD_NONCE_UNVAULTED_CARD_IS_NOT_ACCEPTED = '91927';
336
- const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91902';
337
- const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91903';
338
- const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_NOT_ASSOCIATED_WITH_CUSTOMER = '91905';
339
- const SUBSCRIPTION_PLAN_BILLING_FREQUENCY_CANNOT_BE_UPDATED = '91922';
340
- const SUBSCRIPTION_PLAN_ID_IS_INVALID = '91904';
341
- const SUBSCRIPTION_PRICE_CANNOT_BE_BLANK = '81903';
342
- const SUBSCRIPTION_PRICE_FORMAT_IS_INVALID = '81904';
343
- const SUBSCRIPTION_PRICE_IS_TOO_LARGE = '81923';
344
- const SUBSCRIPTION_STATUS_IS_CANCELED = '81905';
345
- const SUBSCRIPTION_TOKEN_FORMAT_IS_INVALID = '81906';
346
- const SUBSCRIPTION_TRIAL_DURATION_FORMAT_IS_INVALID = '81907';
347
- const SUBSCRIPTION_TRIAL_DURATION_IS_REQUIRED = '81908';
348
- const SUBSCRIPTION_TRIAL_DURATION_UNIT_IS_INVALID = '81909';
 
 
 
349
 
350
  const SUBSCRIPTION_MODIFICATION_AMOUNT_CANNOT_BE_BLANK = '92003';
351
  const SUBSCRIPTION_MODIFICATION_AMOUNT_IS_INVALID = '92002';
@@ -369,84 +399,89 @@ class Braintree_Error_Codes
369
  const SUBSCRIPTION_MODIFICATION_QUANTITY_IS_INVALID = '92001';
370
  const SUBSCRIPTION_MODIFICATION_QUANTITY_MUST_BE_GREATER_THAN_ZERO = '92010';
371
 
372
- const TRANSACTION_AMOUNT_CANNOT_BE_NEGATIVE = '81501';
373
- const TRANSACTION_AMOUNT_FORMAT_IS_INVALID = '81503';
374
- const TRANSACTION_AMOUNT_IS_INVALID = '81503';
375
- const TRANSACTION_AMOUNT_IS_REQUIRED = '81502';
376
- const TRANSACTION_AMOUNT_IS_TOO_LARGE = '81528';
377
- const TRANSACTION_AMOUNT_MUST_BE_GREATER_THAN_ZERO = '81531';
378
- const TRANSACTION_BILLING_ADDRESS_CONFLICT = '91530';
379
- const TRANSACTION_CANNOT_BE_VOIDED = '91504';
380
- const TRANSACTION_CANNOT_CLONE_CREDIT = '91543';
381
- const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_PAYPAL_ACCOUNT = '91573';
382
- const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_VAULT_CREDIT_CARD = '91540';
383
- const TRANSACTION_CANNOT_CLONE_UNSUCCESSFUL_TRANSACTION = '91542';
384
- const TRANSACTION_CANNOT_CLONE_VOICE_AUTHORIZATIONS = '91541';
385
- const TRANSACTION_CANNOT_HOLD_IN_ESCROW = '91560';
386
- const TRANSACTION_CANNOT_PARTIALLY_REFUND_ESCROWED_TRANSACTION = '91563';
387
- const TRANSACTION_CANNOT_REFUND_CREDIT = '91505';
388
- const TRANSACTION_CANNOT_REFUND_SETTLING_TRANSACTION = '91574';
389
- const TRANSACTION_CANNOT_REFUND_UNLESS_SETTLED = '91506';
390
- const TRANSACTION_CANNOT_REFUND_WITH_PENDING_MERCHANT_ACCOUNT = '91559';
391
- const TRANSACTION_CANNOT_REFUND_WITH_SUSPENDED_MERCHANT_ACCOUNT = '91538';
392
- const TRANSACTION_CANNOT_CANCEL_RELEASE = '91562';
393
- const TRANSACTION_CANNOT_RELEASE_FROM_ESCROW = '91561';
394
- const TRANSACTION_CANNOT_SUBMIT_FOR_SETTLEMENT = '91507';
395
- const TRANSACTION_CANNOT_SIMULATE_SETTLEMENT = '91575';
396
- const TRANSACTION_CHANNEL_IS_TOO_LONG = '91550';
397
- const TRANSACTION_CREDIT_CARD_IS_REQUIRED = '91508';
398
- const TRANSACTION_CUSTOMER_DEFAULT_PAYMENT_METHOD_CARD_TYPE_IS_NOT_ACCEPTED = '81509';
399
- const TRANSACTION_CUSTOMER_DOES_NOT_HAVE_CREDIT_CARD = '91511';
400
- const TRANSACTION_CUSTOMER_ID_IS_INVALID = '91510';
401
- const TRANSACTION_CUSTOM_FIELD_IS_INVALID = '91526';
402
- const TRANSACTION_CUSTOM_FIELD_IS_TOO_LONG = '81527';
403
- const TRANSACTION_HAS_ALREADY_BEEN_REFUNDED = '91512';
404
- const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_MOTO = '91558';
405
- const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_REFUNDS = '91547';
406
- const TRANSACTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91513';
407
- const TRANSACTION_MERCHANT_ACCOUNT_IS_SUSPENDED = '91514';
408
- const TRANSACTION_MERCHANT_ACCOUNT_NAME_IS_INVALID = '91513'; //Deprecated
409
- const TRANSACTION_OPTIONS_SUBMIT_FOR_SETTLEMENT_IS_REQUIRED_FOR_CLONING = '91544';
410
- const TRANSACTION_OPTIONS_USE_BILLING_FOR_SHIPPING_DISABLED = '91572';
411
- const TRANSACTION_OPTIONS_VAULT_IS_DISABLED = '91525';
412
- const TRANSACTION_OPTIONS_PAY_PAL_CUSTOM_FIELD_TOO_LONG = '91580';
413
- const TRANSACTION_ORDER_ID_IS_TOO_LONG = '91501';
414
- const TRANSACTION_PAYMENT_INSTRUMENT_NOT_SUPPORTED_BY_MERCHANT_ACCOUNT = '91577';
415
- const TRANSACTION_PAYMENT_METHOD_CONFLICT = '91515';
416
- const TRANSACTION_PAYMENT_METHOD_CONFLICT_WITH_VENMO_SDK = '91549';
417
- const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_CUSTOMER = '91516';
418
- const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_SUBSCRIPTION = '91527';
419
- const TRANSACTION_PAYMENT_METHOD_NONCE_CONSUMED = '91564';
420
- const TRANSACTION_PAYMENT_METHOD_NONCE_UNKNOWN = '91565';
421
- const TRANSACTION_PAYMENT_METHOD_NONCE_LOCKED = '91566';
422
- const TRANSACTION_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91567';
423
- const TRANSACTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91517';
424
- const TRANSACTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91518';
425
- const TRANSACTION_PAYPAL_NOT_ENABLED = '91576';
426
- const TRANSACTION_PAY_PAL_AUTH_EXPIRED = '91579';
427
- const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_CANNOT_BE_SET = '91519';
428
- const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_IS_INVALID = '81520';
429
- const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_CREDITS = '91546';
430
- const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_VOICE_AUTHORIZATIONS = '91545';
431
- const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_INVALID = '91548';
432
- const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_TOO_LONG = '91537';
433
- const TRANSACTION_REFUND_AMOUNT_IS_TOO_LARGE = '91521';
434
- const TRANSACTION_SERVICE_FEE_AMOUNT_CANNOT_BE_NEGATIVE = '91554';
435
- const TRANSACTION_SERVICE_FEE_AMOUNT_FORMAT_IS_INVALID = '91555';
436
- const TRANSACTION_SERVICE_FEE_AMOUNT_IS_TOO_LARGE = '91556';
437
- const TRANSACTION_SERVICE_FEE_AMOUNT_NOT_ALLOWED_ON_MASTER_MERCHANT_ACCOUNT = '91557';
438
- const TRANSACTION_SERVICE_FEE_IS_NOT_ALLOWED_ON_CREDITS = '91552';
439
- const TRANSACTION_SERVICE_FEE_NOT_ACCEPTED_FOR_PAYPAL = '91578';
440
- const TRANSACTION_SETTLEMENT_AMOUNT_IS_LESS_THAN_SERVICE_FEE_AMOUNT = '91551';
441
- const TRANSACTION_SETTLEMENT_AMOUNT_IS_TOO_LARGE = '91522';
442
- const TRANSACTION_SHIPPING_ADDRESS_DOESNT_MATCH_CUSTOMER = '91581';
443
- const TRANSACTION_SUBSCRIPTION_DOES_NOT_BELONG_TO_CUSTOMER = '91529';
444
- const TRANSACTION_SUBSCRIPTION_ID_IS_INVALID = '91528';
445
- const TRANSACTION_SUBSCRIPTION_STATUS_MUST_BE_PAST_DUE = '91531';
446
- const TRANSACTION_SUB_MERCHANT_ACCOUNT_REQUIRES_SERVICE_FEE_AMOUNT = '91553';
447
- const TRANSACTION_TAX_AMOUNT_CANNOT_BE_NEGATIVE = '81534';
448
- const TRANSACTION_TAX_AMOUNT_FORMAT_IS_INVALID = '81535';
449
- const TRANSACTION_TAX_AMOUNT_IS_TOO_LARGE = '81536';
 
 
 
 
 
450
 
451
  const TRANSACTION_THREE_D_SECURE_AUTHENTICATION_FAILED = '81571';
452
  const TRANSACTION_THREE_D_SECURE_TOKEN_IS_INVALID = '91568';
16
  */
17
  class Braintree_Error_Codes
18
  {
19
+ const ADDRESS_CANNOT_BE_BLANK = '81801';
20
+ const ADDRESS_COMPANY_IS_INVALID = '91821';
21
+ const ADDRESS_COMPANY_IS_TOO_LONG = '81802';
22
+ const ADDRESS_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED = '91814';
23
+ const ADDRESS_COUNTRY_CODE_ALPHA3_IS_NOT_ACCEPTED = '91816';
24
+ const ADDRESS_COUNTRY_CODE_NUMERIC_IS_NOT_ACCEPTED = '91817';
25
+ const ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED = '91803';
26
+ const ADDRESS_EXTENDED_ADDRESS_IS_INVALID = '91823';
27
+ const ADDRESS_EXTENDED_ADDRESS_IS_TOO_LONG = '81804';
28
+ const ADDRESS_FIRST_NAME_IS_INVALID = '91819';
29
+ const ADDRESS_FIRST_NAME_IS_TOO_LONG = '81805';
30
+ const ADDRESS_INCONSISTENT_COUNTRY = '91815';
31
+ const ADDRESS_LAST_NAME_IS_INVALID = '91820';
32
+ const ADDRESS_LAST_NAME_IS_TOO_LONG = '81806';
33
+ const ADDRESS_LOCALITY_IS_INVALID = '91824';
34
+ const ADDRESS_LOCALITY_IS_TOO_LONG = '81807';
35
+ const ADDRESS_POSTAL_CODE_INVALID_CHARACTERS = '81813';
36
+ const ADDRESS_POSTAL_CODE_IS_INVALID = '91826';
37
+ const ADDRESS_POSTAL_CODE_IS_REQUIRED = '81808';
38
+ const ADDRESS_POSTAL_CODE_IS_TOO_LONG = '81809';
39
+ const ADDRESS_REGION_IS_INVALID = '91825';
40
+ const ADDRESS_REGION_IS_TOO_LONG = '81810';
41
+ const ADDRESS_STATE_IS_INVALID_FOR_SELLER_PROTECTION = '81827';
42
+ const ADDRESS_STREET_ADDRESS_IS_INVALID = '91822';
43
+ const ADDRESS_STREET_ADDRESS_IS_REQUIRED = '81811';
44
+ const ADDRESS_STREET_ADDRESS_IS_TOO_LONG = '81812';
45
+ const ADDRESS_TOO_MANY_ADDRESSES_PER_CUSTOMER = '91818';
46
 
47
+ const APPLE_PAY_CARDS_ARE_NOT_ACCEPTED = '83501';
48
+ const APPLE_PAY_CUSTOMER_ID_IS_REQUIRED_FOR_VAULTING = '83502';
49
+ const APPLE_PAY_TOKEN_IS_IN_USE = '93503';
50
+ const APPLE_PAY_PAYMENT_METHOD_NONCE_CONSUMED = '93504';
51
+ const APPLE_PAY_PAYMENT_METHOD_NONCE_UNKNOWN = '93505';
52
+ const APPLE_PAY_PAYMENT_METHOD_NONCE_UNLOCKED = '93506';
53
+ const APPLE_PAY_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '83518';
54
+ const APPLE_PAY_CANNOT_UPDATE_APPLE_PAY_CARD_USING_PAYMENT_METHOD_NONCE = '93507';
55
+ const APPLE_PAY_NUMBER_IS_REQUIRED = '93508';
56
+ const APPLE_PAY_EXPIRATION_MONTH_IS_REQUIRED = '93509';
57
+ const APPLE_PAY_EXPIRATION_YEAR_IS_REQUIRED = '93510';
58
+ const APPLE_PAY_CRYPTOGRAM_IS_REQUIRED = '93511';
59
+ const APPLE_PAY_DECRYPTION_FAILED = '83512';
60
+ const APPLE_PAY_DISABLED = '93513';
61
+ const APPLE_PAY_MERCHANT_NOT_CONFIGURED = '93514';
62
+ const APPLE_PAY_MERCHANT_KEYS_ALREADY_CONFIGURED = '93515';
63
+ const APPLE_PAY_MERCHANT_KEYS_NOT_CONFIGURED = '93516';
64
+ const APPLE_PAY_CERTIFICATE_INVALID = '93517';
65
  const APPLE_PAY_CERTIFICATE_MISMATCH = '93519';
66
  const APPLE_PAY_INVALID_TOKEN = '83520';
67
  const APPLE_PAY_PRIVATE_KEY_MISMATCH = '93521';
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';
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';
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';
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';
138
+ const CUSTOMER_CUSTOM_FIELD_IS_TOO_LONG = '81603';
139
+ const CUSTOMER_EMAIL_FORMAT_IS_INVALID = '81604';
140
+ const CUSTOMER_EMAIL_IS_INVALID = '81604';
141
+ const CUSTOMER_EMAIL_IS_REQUIRED = '81606';
142
+ const CUSTOMER_EMAIL_IS_TOO_LONG = '81605';
143
+ const CUSTOMER_FAX_IS_TOO_LONG = '81607';
144
+ const CUSTOMER_FIRST_NAME_IS_TOO_LONG = '81608';
145
+ const CUSTOMER_ID_IS_INVAILD = '91610'; //Deprecated
146
+ const CUSTOMER_ID_IS_INVALID = '91610';
147
+ const CUSTOMER_ID_IS_IN_USE = '91609';
148
+ const CUSTOMER_ID_IS_NOT_ALLOWED = '91611';
149
+ const CUSTOMER_ID_IS_REQUIRED = '91613';
150
+ const CUSTOMER_ID_IS_TOO_LONG = '91612';
151
+ const CUSTOMER_LAST_NAME_IS_TOO_LONG = '81613';
152
+ const CUSTOMER_PHONE_IS_TOO_LONG = '81614';
153
+ const CUSTOMER_VAULTED_PAYMENT_INSTRUMENT_NONCE_BELONGS_TO_DIFFERENT_CUSTOMER = '91617';
154
+ const CUSTOMER_WEBSITE_FORMAT_IS_INVALID = '81616';
155
+ const CUSTOMER_WEBSITE_IS_INVALID = '81616';
156
+ const CUSTOMER_WEBSITE_IS_TOO_LONG = '81615';
157
 
158
  const DESCRIPTOR_NAME_FORMAT_IS_INVALID = '92201';
159
  const DESCRIPTOR_PHONE_FORMAT_IS_INVALID = '92202';
169
  const INDUSTRY_DATA_LODGING_CHECK_OUT_DATE_IS_INVALID = '93405';
170
  const INDUSTRY_DATA_LODGING_CHECK_OUT_DATE_MUST_FOLLOW_CHECK_IN_DATE = '93406';
171
  const INDUSTRY_DATA_LODGING_UNKNOWN_DATA_FIELD = '93407';
172
+ const INDUSTRY_DATA_TRAVEL_CRUISE_EMPTY_DATA = '93408';
173
+ const INDUSTRY_DATA_TRAVEL_CRUISE_UNKNOWN_DATA_FIELD = '93409';
174
+ const INDUSTRY_DATA_TRAVEL_CRUISE_TRAVEL_PACKAGE_IS_INVALID = '93410';
175
+ const INDUSTRY_DATA_TRAVEL_CRUISE_DEPARTURE_DATE_IS_INVALID = '93411';
176
+ const INDUSTRY_DATA_TRAVEL_CRUISE_LODGING_CHECK_IN_DATE_IS_INVALID = '93412';
177
+ const INDUSTRY_DATA_TRAVEL_CRUISE_LODGING_CHECK_OUT_DATE_IS_INVALID = '93413';
178
+
179
+ const MERCHANT_COUNTRY_CANNOT_BE_BLANK = '83603';
180
+ const MERCHANT_COUNTRY_CODE_ALPHA2_IS_INVALID = '93607';
181
+ const MERCHANT_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED = '93606';
182
+ const MERCHANT_COUNTRY_CODE_ALPHA3_IS_INVALID = '93605';
183
+ const MERCHANT_COUNTRY_CODE_ALPHA3_IS_NOT_ACCEPTED = '93604';
184
+ const MERCHANT_COUNTRY_CODE_NUMERIC_IS_INVALID = '93609';
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';
282
  const MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_REQUIRED = '82682';
283
  const MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_INVALID = '82683';
284
 
285
+ const OAUTH_INVALID_GRANT = '93801';
286
+ const OAUTH_INVALID_CREDENTIALS = '93802';
287
+ const OAUTH_INVALID_SCOPE = '93803';
288
+ const OAUTH_INVALID_REQUEST = '93804';
289
+ const OAUTH_UNSUPPORTED_GRANT_TYPE = '93805';
290
+
291
  const PAYMENT_METHOD_CANNOT_FORWARD_PAYMENT_METHOD_TYPE = '93106';
292
  const PAYMENT_METHOD_CUSTOMER_ID_IS_INVALID = '93105';
293
  const PAYMENT_METHOD_CUSTOMER_ID_IS_REQUIRED = '93104';
298
  const PAYMENT_METHOD_PAYMENT_METHOD_NONCE_LOCKED = '93109';
299
  const PAYMENT_METHOD_PAYMENT_METHOD_PARAMS_ARE_REQUIRED = '93101';
300
 
301
+ const PAYPAL_ACCOUNT_AUTH_EXPIRED = '92911';
302
+ const PAYPAL_ACCOUNT_CANNOT_HAVE_BOTH_ACCESS_TOKEN_AND_CONSENT_CODE = '82903';
303
+ const PAYPAL_ACCOUNT_CANNOT_HAVE_FUNDING_SOURCE_WITHOUT_ACCESS_TOKEN = '92912';
 
 
 
 
 
 
 
 
 
 
304
  const PAYPAL_ACCOUNT_CANNOT_UPDATE_PAYPAL_ACCOUNT_USING_PAYMENT_METHOD_NONCE = '92914';
305
+ const PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT = '82902';
306
+ const PAYPAL_ACCOUNT_CONSENT_CODE_OR_ACCESS_TOKEN_IS_REQUIRED = '82901';
307
+ const PAYPAL_ACCOUNT_CUSTOMER_ID_IS_REQUIRED_FOR_VAULTING = '82905';
308
+ const PAYPAL_ACCOUNT_INVALID_FUNDING_SOURCE_SELECTION = '92913';
309
+ const PAYPAL_ACCOUNT_INVALID_PARAMS_FOR_PAYPAL_ACCOUNT_UPDATE = '92915';
310
+ const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_CONSUMED = '92907';
311
+ const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_LOCKED = '92909';
312
+ const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_UNKNOWN = '92908';
313
+ const PAYPAL_ACCOUNT_PAYPAL_ACCOUNTS_ARE_NOT_ACCEPTED = '82904';
314
+ const PAYPAL_ACCOUNT_PAYPAL_COMMUNICATION_ERROR = '92910';
315
+ const PAYPAL_ACCOUNT_TOKEN_IS_IN_USE = '92906';
316
 
317
  const SEPA_BANK_ACCOUNT_ACCOUNT_HOLDER_NAME_IS_REQUIRED = '93003';
318
  const SEPA_BANK_ACCOUNT_BIC_IS_REQUIRED = '93002';
336
  const SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_REQUIRED = '82301';
337
  const SETTLEMENT_BATCH_SUMMARY_CUSTOM_FIELD_IS_INVALID = '82303';
338
 
339
+ const SUBSCRIPTION_BILLING_DAY_OF_MONTH_CANNOT_BE_UPDATED = '91918';
340
+ const SUBSCRIPTION_BILLING_DAY_OF_MONTH_IS_INVALID = '91914';
341
+ const SUBSCRIPTION_BILLING_DAY_OF_MONTH_MUST_BE_NUMERIC = '91913';
342
+ const SUBSCRIPTION_CANNOT_ADD_DUPLICATE_ADDON_OR_DISCOUNT = '91911';
343
+ const SUBSCRIPTION_CANNOT_EDIT_CANCELED_SUBSCRIPTION = '81901';
344
+ const SUBSCRIPTION_CANNOT_EDIT_EXPIRED_SUBSCRIPTION = '81910';
345
+ const SUBSCRIPTION_CANNOT_EDIT_PRICE_CHANGING_FIELDS_ON_PAST_DUE_SUBSCRIPTION = '91920';
346
+ const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_IN_THE_PAST = '91916';
347
+ const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_UPDATED = '91919';
348
+ const SUBSCRIPTION_FIRST_BILLING_DATE_IS_INVALID = '91915';
349
+ const SUBSCRIPTION_ID_IS_IN_USE = '81902';
350
+ const SUBSCRIPTION_INCONSISTENT_NUMBER_OF_BILLING_CYCLES = '91908';
351
+ const SUBSCRIPTION_INCONSISTENT_START_DATE = '91917';
352
+ const SUBSCRIPTION_INVALID_REQUEST_FORMAT = '91921';
353
+ const SUBSCRIPTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91901';
354
+ const SUBSCRIPTION_MISMATCH_CURRENCY_ISO_CODE = '91923';
355
+ const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_CANNOT_BE_BLANK = '91912';
356
+ const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_IS_TOO_SMALL = '91909';
357
+ const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_GREATER_THAN_ZERO = '91907';
358
+ const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_NUMERIC = '91906';
359
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91924';
360
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_IS_INVALID = '91925';
361
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_NOT_ASSOCIATED_WITH_CUSTOMER = '91926';
362
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_UNVAULTED_CARD_IS_NOT_ACCEPTED = '91927';
363
+ const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91902';
364
+ const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91903';
365
+ const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_NOT_ASSOCIATED_WITH_CUSTOMER = '91905';
366
+ const SUBSCRIPTION_PLAN_BILLING_FREQUENCY_CANNOT_BE_UPDATED = '91922';
367
+ const SUBSCRIPTION_PLAN_ID_IS_INVALID = '91904';
368
+ const SUBSCRIPTION_PRICE_CANNOT_BE_BLANK = '81903';
369
+ const SUBSCRIPTION_PRICE_FORMAT_IS_INVALID = '81904';
370
+ const SUBSCRIPTION_PRICE_IS_TOO_LARGE = '81923';
371
+ const SUBSCRIPTION_STATUS_IS_CANCELED = '81905';
372
+ const SUBSCRIPTION_TOKEN_FORMAT_IS_INVALID = '81906';
373
+ const SUBSCRIPTION_TRIAL_DURATION_FORMAT_IS_INVALID = '81907';
374
+ const SUBSCRIPTION_TRIAL_DURATION_IS_REQUIRED = '81908';
375
+ const SUBSCRIPTION_TRIAL_DURATION_UNIT_IS_INVALID = '81909';
376
+ const SUBSCRIPTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_INSTRUMENT_TYPE = '91930';
377
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_INSTRUMENT_TYPE_DOES_NOT_SUPPORT_SUBSCRIPTIONS = '91929';
378
+ const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_INSTRUMENT_TYPE_DOES_NOT_SUPPORT_SUBSCRIPTIONS = '91928';
379
 
380
  const SUBSCRIPTION_MODIFICATION_AMOUNT_CANNOT_BE_BLANK = '92003';
381
  const SUBSCRIPTION_MODIFICATION_AMOUNT_IS_INVALID = '92002';
399
  const SUBSCRIPTION_MODIFICATION_QUANTITY_IS_INVALID = '92001';
400
  const SUBSCRIPTION_MODIFICATION_QUANTITY_MUST_BE_GREATER_THAN_ZERO = '92010';
401
 
402
+ const TRANSACTION_AMOUNT_CANNOT_BE_NEGATIVE = '81501';
403
+ const TRANSACTION_AMOUNT_DOES_NOT_MATCH3_D_SECURE_AMOUNT = '91585';
404
+ const TRANSACTION_AMOUNT_FORMAT_IS_INVALID = '81503';
405
+ const TRANSACTION_AMOUNT_IS_INVALID = '81503';
406
+ const TRANSACTION_AMOUNT_IS_REQUIRED = '81502';
407
+ const TRANSACTION_AMOUNT_IS_TOO_LARGE = '81528';
408
+ const TRANSACTION_AMOUNT_MUST_BE_GREATER_THAN_ZERO = '81531';
409
+ const TRANSACTION_BILLING_ADDRESS_CONFLICT = '91530';
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';
416
+ const TRANSACTION_CANNOT_CLONE_VOICE_AUTHORIZATIONS = '91541';
417
+ const TRANSACTION_CANNOT_HOLD_IN_ESCROW = '91560';
418
+ const TRANSACTION_CANNOT_PARTIALLY_REFUND_ESCROWED_TRANSACTION = '91563';
419
+ const TRANSACTION_CANNOT_REFUND_CREDIT = '91505';
420
+ const TRANSACTION_CANNOT_REFUND_SETTLING_TRANSACTION = '91574';
421
+ const TRANSACTION_CANNOT_REFUND_UNLESS_SETTLED = '91506';
422
+ const TRANSACTION_CANNOT_REFUND_WITH_PENDING_MERCHANT_ACCOUNT = '91559';
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';
430
+ const TRANSACTION_CUSTOMER_DOES_NOT_HAVE_CREDIT_CARD = '91511';
431
+ const TRANSACTION_CUSTOMER_ID_IS_INVALID = '91510';
432
+ const TRANSACTION_CUSTOM_FIELD_IS_INVALID = '91526';
433
+ const TRANSACTION_CUSTOM_FIELD_IS_TOO_LONG = '81527';
434
+ const TRANSACTION_HAS_ALREADY_BEEN_REFUNDED = '91512';
435
+ const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_MATCH3_D_SECURE_MERCHANT_ACCOUNT = '91584';
436
+ const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_MOTO = '91558';
437
+ const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_REFUNDS = '91547';
438
+ const TRANSACTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91513';
439
+ const TRANSACTION_MERCHANT_ACCOUNT_IS_SUSPENDED = '91514';
440
+ const TRANSACTION_MERCHANT_ACCOUNT_NAME_IS_INVALID = '91513'; //Deprecated
441
+ const TRANSACTION_OPTIONS_PAY_PAL_CUSTOM_FIELD_TOO_LONG = '91580';
442
+ const TRANSACTION_OPTIONS_SUBMIT_FOR_SETTLEMENT_IS_REQUIRED_FOR_CLONING = '91544';
443
+ const TRANSACTION_OPTIONS_SUBMIT_FOR_SETTLEMENT_IS_REQUIRED_FOR_PAYPAL_UNILATERAL = '91582';
444
+ const TRANSACTION_OPTIONS_USE_BILLING_FOR_SHIPPING_DISABLED = '91572';
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';
451
+ const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_SUBSCRIPTION = '91527';
452
+ const TRANSACTION_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91567';
453
+ const TRANSACTION_PAYMENT_METHOD_NONCE_CONSUMED = '91564';
454
+ const TRANSACTION_PAYMENT_METHOD_NONCE_HAS_NO_VALID_PAYMENT_INSTRUMENT_TYPE = '91569';
455
+ const TRANSACTION_PAYMENT_METHOD_NONCE_LOCKED = '91566';
456
+ const TRANSACTION_PAYMENT_METHOD_NONCE_UNKNOWN = '91565';
457
+ const TRANSACTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91517';
458
+ const TRANSACTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91518';
459
+ const TRANSACTION_PAYPAL_NOT_ENABLED = '91576';
460
+ const TRANSACTION_PAY_PAL_AUTH_EXPIRED = '91579';
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';
468
+ const TRANSACTION_REFUND_AMOUNT_IS_TOO_LARGE = '91521';
469
+ const TRANSACTION_SERVICE_FEE_AMOUNT_CANNOT_BE_NEGATIVE = '91554';
470
+ const TRANSACTION_SERVICE_FEE_AMOUNT_FORMAT_IS_INVALID = '91555';
471
+ const TRANSACTION_SERVICE_FEE_AMOUNT_IS_TOO_LARGE = '91556';
472
+ const TRANSACTION_SERVICE_FEE_AMOUNT_NOT_ALLOWED_ON_MASTER_MERCHANT_ACCOUNT = '91557';
473
+ const TRANSACTION_SERVICE_FEE_IS_NOT_ALLOWED_ON_CREDITS = '91552';
474
+ const TRANSACTION_SERVICE_FEE_NOT_ACCEPTED_FOR_PAYPAL = '91578';
475
+ const TRANSACTION_SETTLEMENT_AMOUNT_IS_LESS_THAN_SERVICE_FEE_AMOUNT = '91551';
476
+ const TRANSACTION_SETTLEMENT_AMOUNT_IS_TOO_LARGE = '91522';
477
+ const TRANSACTION_SHIPPING_ADDRESS_DOESNT_MATCH_CUSTOMER = '91581';
478
+ const TRANSACTION_SUBSCRIPTION_DOES_NOT_BELONG_TO_CUSTOMER = '91529';
479
+ const TRANSACTION_SUBSCRIPTION_ID_IS_INVALID = '91528';
480
+ const TRANSACTION_SUBSCRIPTION_STATUS_MUST_BE_PAST_DUE = '91531';
481
+ const TRANSACTION_SUB_MERCHANT_ACCOUNT_REQUIRES_SERVICE_FEE_AMOUNT = '91553';
482
+ const TRANSACTION_TAX_AMOUNT_CANNOT_BE_NEGATIVE = '81534';
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';
lib/Braintree/Exception/InvalidChallenge.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Braintree_Exception_InvalidChallenge extends Braintree_Exception
3
+ {
4
+
5
+ }
lib/Braintree/Gateway.php CHANGED
@@ -8,6 +8,10 @@
8
  */
9
  class Braintree_Gateway
10
  {
 
 
 
 
11
  public $config;
12
 
13
  public function __construct($config)
@@ -15,85 +19,166 @@ class Braintree_Gateway
15
  if (is_array($config)) {
16
  $config = new Braintree_Configuration($config);
17
  }
18
- $config->assertValid();
19
  $this->config = $config;
20
  }
21
 
22
- public function customer()
23
- {
24
- return new Braintree_CustomerGateway($this);
25
- }
26
-
27
  public function addOn()
28
  {
29
  return new Braintree_AddOnGateway($this);
30
  }
31
 
 
 
 
 
32
  public function address()
33
  {
34
  return new Braintree_AddressGateway($this);
35
  }
36
 
 
 
 
 
37
  public function clientToken()
38
  {
39
  return new Braintree_ClientTokenGateway($this);
40
  }
41
 
 
 
 
 
42
  public function creditCard()
43
  {
44
  return new Braintree_CreditCardGateway($this);
45
  }
46
 
 
 
 
 
47
  public function creditCardVerification()
48
  {
49
  return new Braintree_CreditCardVerificationGateway($this);
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  public function discount()
53
  {
54
  return new Braintree_DiscountGateway($this);
55
  }
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  public function merchantAccount()
58
  {
59
  return new Braintree_MerchantAccountGateway($this);
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  public function paymentMethod()
63
  {
64
  return new Braintree_PaymentMethodGateway($this);
65
  }
66
 
 
 
 
 
67
  public function paymentMethodNonce()
68
  {
69
  return new Braintree_PaymentMethodNonceGateway($this);
70
  }
71
 
 
 
 
 
72
  public function payPalAccount()
73
  {
74
  return new Braintree_PayPalAccountGateway($this);
75
  }
76
 
 
 
 
 
77
  public function plan()
78
  {
79
  return new Braintree_PlanGateway($this);
80
  }
81
 
 
 
 
 
82
  public function settlementBatchSummary()
83
  {
84
  return new Braintree_SettlementBatchSummaryGateway($this);
85
  }
86
 
 
 
 
 
87
  public function subscription()
88
  {
89
  return new Braintree_SubscriptionGateway($this);
90
  }
91
 
 
 
 
 
92
  public function transaction()
93
  {
94
  return new Braintree_TransactionGateway($this);
95
  }
96
 
 
 
 
 
97
  public function transparentRedirect()
98
  {
99
  return new Braintree_TransparentRedirectGateway($this);
8
  */
9
  class Braintree_Gateway
10
  {
11
+ /**
12
+ *
13
+ * @var Braintree_Configuration
14
+ */
15
  public $config;
16
 
17
  public function __construct($config)
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_TransactionGateway
172
+ */
173
  public function transaction()
174
  {
175
  return new Braintree_TransactionGateway($this);
176
  }
177
 
178
+ /**
179
+ *
180
+ * @return \Braintree_TransparentRedirectGateway
181
+ */
182
  public function transparentRedirect()
183
  {
184
  return new Braintree_TransparentRedirectGateway($this);
lib/Braintree/Http.php CHANGED
@@ -8,6 +8,7 @@
8
  class Braintree_Http
9
  {
10
  protected $_config;
 
11
 
12
  public function __construct($config)
13
  {
@@ -38,7 +39,7 @@ class Braintree_Http
38
  {
39
  $response = $this->_doRequest('POST', $path, $this->_buildXml($params));
40
  $responseCode = $response['status'];
41
- if($responseCode === 200 || $responseCode === 201 || $responseCode === 422) {
42
  return Braintree_Xml::buildArrayFromXml($response['body']);
43
  } else {
44
  Braintree_Util::throwStatusCodeException($responseCode);
@@ -49,7 +50,7 @@ class Braintree_Http
49
  {
50
  $response = $this->_doRequest('PUT', $path, $this->_buildXml($params));
51
  $responseCode = $response['status'];
52
- if($responseCode === 200 || $responseCode === 201 || $responseCode === 422) {
53
  return Braintree_Xml::buildArrayFromXml($response['body']);
54
  } else {
55
  Braintree_Util::throwStatusCodeException($responseCode);
@@ -61,6 +62,38 @@ class Braintree_Http
61
  return empty($params) ? null : Braintree_Xml::buildXmlFromArray($params);
62
  }
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  private function _doRequest($httpVerb, $path, $requestBody = null)
65
  {
66
  return $this->_doUrlRequest($httpVerb, $this->_config->baseUrl() . $path, $requestBody);
@@ -73,14 +106,20 @@ class Braintree_Http
73
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb);
74
  curl_setopt($curl, CURLOPT_URL, $url);
75
  curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
76
- curl_setopt($curl, CURLOPT_HTTPHEADER, array(
77
- 'Accept: application/xml',
78
- 'Content-Type: application/xml',
79
- 'User-Agent: Braintree PHP Library ' . Braintree_Version::get(),
80
- 'X-ApiVersion: ' . Braintree_Configuration::API_VERSION
81
- ));
82
- curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
83
- curl_setopt($curl, CURLOPT_USERPWD, $this->_config->getPublicKey() . ':' . $this->_config->getPrivateKey());
 
 
 
 
 
 
84
  // curl_setopt($curl, CURLOPT_VERBOSE, true);
85
  if ($this->_config->sslOn()) {
86
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
8
  class Braintree_Http
9
  {
10
  protected $_config;
11
+ private $_useClientCredentials = false;
12
 
13
  public function __construct($config)
14
  {
39
  {
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);
50
  {
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);
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
+
92
+ public function useClientCredentials()
93
+ {
94
+ $this->_useClientCredentials = true;
95
+ }
96
+
97
  private function _doRequest($httpVerb, $path, $requestBody = null)
98
  {
99
  return $this->_doUrlRequest($httpVerb, $this->_config->baseUrl() . $path, $requestBody);
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'])) {
116
+ curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
117
+ curl_setopt($curl, CURLOPT_USERPWD, $authorization['user'] . ':' . $authorization['password']);
118
+ } else if (isset($authorization['token'])) {
119
+ $headers[] = 'Authorization: Bearer ' . $authorization['token'];
120
+ }
121
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
122
+
123
  // curl_setopt($curl, CURLOPT_VERBOSE, true);
124
  if ($this->_config->sslOn()) {
125
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
lib/Braintree/Merchant.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/Braintree/MerchantAccount.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- final class Braintree_MerchantAccount extends Braintree
4
  {
5
  const STATUS_ACTIVE = 'active';
6
  const STATUS_PENDING = 'pending';
1
  <?php
2
 
3
+ final class Braintree_MerchantAccount extends Braintree_Base
4
  {
5
  const STATUS_ACTIVE = 'active';
6
  const STATUS_PENDING = 'pending';
lib/Braintree/MerchantAccount/BusinessDetails.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- final class Braintree_MerchantAccount_BusinessDetails extends Braintree
4
  {
5
  protected function _initialize($businessAttribs)
6
  {
1
  <?php
2
 
3
+ final class Braintree_MerchantAccount_BusinessDetails extends Braintree_Base
4
  {
5
  protected function _initialize($businessAttribs)
6
  {
lib/Braintree/MerchantAccount/IndividualDetails.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- final class Braintree_MerchantAccount_IndividualDetails extends Braintree
4
  {
5
  protected function _initialize($individualAttribs)
6
  {
1
  <?php
2
 
3
+ final class Braintree_MerchantAccount_IndividualDetails extends Braintree_Base
4
  {
5
  protected function _initialize($individualAttribs)
6
  {
lib/Braintree/MerchantAccountGateway.php CHANGED
@@ -10,6 +10,7 @@ final class Braintree_MerchantAccountGateway
10
  {
11
  $this->_gateway = $gateway;
12
  $this->_config = $gateway->config;
 
13
  $this->_http = new Braintree_Http($gateway->config);
14
  }
15
 
10
  {
11
  $this->_gateway = $gateway;
12
  $this->_config = $gateway->config;
13
+ $this->_config->assertHasAccessTokenOrKeys();
14
  $this->_http = new Braintree_Http($gateway->config);
15
  }
16
 
lib/Braintree/MerchantGateway.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ final class Braintree_MerchantGateway
4
+ {
5
+ private $_gateway;
6
+ private $_config;
7
+ private $_http;
8
+
9
+ public function __construct($gateway)
10
+ {
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
+ }
lib/Braintree/Modification.php CHANGED
@@ -1,17 +1,9 @@
1
  <?php
2
- class Braintree_Modification extends Braintree
3
  {
4
  protected function _initialize($attributes)
5
  {
6
  $this->_attributes = $attributes;
7
-
8
- $addOnArray = array();
9
- if (isset($attributes['addOns'])) {
10
- foreach ($attributes['addOns'] AS $addOn) {
11
- $addOnArray[] = Braintree_addOn::factory($addOn);
12
- }
13
- }
14
- $this->_attributes['addOns'] = $addOnArray;
15
  }
16
 
17
  public static function factory($attributes)
@@ -20,4 +12,8 @@ class Braintree_Modification extends Braintree
20
  $instance->_initialize($attributes);
21
  return $instance;
22
  }
 
 
 
 
23
  }
1
  <?php
2
+ class Braintree_Modification extends Braintree_Base
3
  {
4
  protected function _initialize($attributes)
5
  {
6
  $this->_attributes = $attributes;
 
 
 
 
 
 
 
 
7
  }
8
 
9
  public static function factory($attributes)
12
  $instance->_initialize($attributes);
13
  return $instance;
14
  }
15
+
16
+ public function __toString() {
17
+ return get_called_class() . '[' . Braintree_Util::attributesToString($this->_attributes) . ']';
18
+ }
19
  }
lib/Braintree/OAuthCredentials.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {
14
+ $this->_attributes = $attribs;
15
+ }
16
+
17
+ public static function factory($attributes)
18
+ {
19
+ $instance = new self();
20
+ $instance->_initialize($attributes);
21
+ return $instance;
22
+ }
23
+
24
+ /**
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
+ }
lib/Braintree/OAuthGateway.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
14
+ private $_http;
15
+
16
+ public function __construct($gateway)
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();
24
+ }
25
+
26
+ public function createTokenFromCode($params)
27
+ {
28
+ $params['grantType'] = "authorization_code";
29
+ return $this->_createToken($params);
30
+ }
31
+
32
+ public function createTokenFromRefreshToken($params)
33
+ {
34
+ $params['grantType'] = "refresh_token";
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
+ }
44
+
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
+ }
60
+ }
61
+
62
+ public function _mapError($result)
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;
80
+ $result->accessToken = $credentials->accessToken;
81
+ $result->refreshToken = $credentials->refreshToken;
82
+ $result->tokenType = $credentials->tokenType;
83
+ $result->expiresAt = $credentials->expiresAt;
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;
93
+
94
+ return $this->signUrl($url);
95
+ }
96
+
97
+ private function signUrl($url)
98
+ {
99
+ $key = hash('sha256', $this->_config->getClientSecret(), true);
100
+ return $url . '&signature=' . hash_hmac('sha256', $url, $key) . '&algorithm=SHA256';
101
+ }
102
+ }
lib/Braintree/PartnerMerchant.php CHANGED
@@ -15,7 +15,7 @@
15
  * @property-read string $partnerMerchantId
16
  * @uses Braintree_Instance inherits methods
17
  */
18
- class Braintree_PartnerMerchant extends Braintree
19
  {
20
  protected $_attributes = array();
21
 
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
 
lib/Braintree/PayPalAccount.php CHANGED
@@ -21,7 +21,7 @@
21
  * @property-read string $token
22
  * @property-read string $imageUrl
23
  */
24
- class Braintree_PayPalAccount extends Braintree
25
  {
26
  /**
27
  * factory method: returns an instance of Braintree_PayPalAccount
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
lib/Braintree/PayPalAccountGateway.php CHANGED
@@ -27,6 +27,7 @@ class Braintree_PayPalAccountGateway
27
  {
28
  $this->_gateway = $gateway;
29
  $this->_config = $gateway->config;
 
30
  $this->_http = new Braintree_Http($gateway->config);
31
  }
32
 
27
  {
28
  $this->_gateway = $gateway;
29
  $this->_config = $gateway->config;
30
+ $this->_config->assertHasAccessTokenOrKeys();
31
  $this->_http = new Braintree_Http($gateway->config);
32
  }
33
 
lib/Braintree/PaymentInstrumentType.php CHANGED
@@ -3,7 +3,9 @@
3
  final class Braintree_PaymentInstrumentType
4
  {
5
  const PAYPAL_ACCOUNT = 'paypal_account';
6
- const COINBASE_ACCOUNT = 'coinbase_account';
7
- const SEPA_BANK_ACCOUNT = 'sepa_bank_account';
8
  const CREDIT_CARD = 'credit_card';
 
 
9
  }
3
  final class Braintree_PaymentInstrumentType
4
  {
5
  const PAYPAL_ACCOUNT = 'paypal_account';
6
+ const COINBASE_ACCOUNT = 'coinbase_account';
7
+ const EUROPE_BANK_ACCOUNT = 'europe_bank_account';
8
  const CREDIT_CARD = 'credit_card';
9
+ const APPLE_PAY_CARD = 'apple_pay_card';
10
+ const ANDROID_PAY_CARD = 'android_pay_card';
11
  }
lib/Braintree/PaymentMethod.php CHANGED
@@ -18,7 +18,7 @@
18
  * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  *
20
  */
21
- class Braintree_PaymentMethod extends Braintree
22
  {
23
  // static methods redirecting to gateway
24
 
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
 
lib/Braintree/PaymentMethodGateway.php CHANGED
@@ -28,6 +28,7 @@ class Braintree_PaymentMethodGateway
28
  {
29
  $this->_gateway = $gateway;
30
  $this->_config = $gateway->config;
 
31
  $this->_http = new Braintree_Http($gateway->config);
32
  }
33
 
@@ -60,6 +61,8 @@ class Braintree_PaymentMethodGateway
60
  return Braintree_CoinbaseAccount::factory($response['coinbaseAccount']);
61
  } else if (isset($response['applePayCard'])) {
62
  return Braintree_ApplePayCard::factory($response['applePayCard']);
 
 
63
  } else if (is_array($response)) {
64
  return Braintree_UnknownPaymentMethod::factory($response);
65
  }
@@ -85,29 +88,34 @@ class Braintree_PaymentMethodGateway
85
  return new Braintree_Result_Successful();
86
  }
87
 
88
- private static function baseSignature($options)
89
  {
90
  $billingAddressSignature = Braintree_AddressGateway::createSignature();
 
 
 
 
 
 
91
  return array(
92
- 'customerId',
93
- 'paymentMethodNonce',
94
- 'token',
95
  'billingAddressId',
 
 
96
  'deviceData',
97
- array('options' => $options),
 
 
 
 
 
 
98
  array('billingAddress' => $billingAddressSignature)
99
  );
100
  }
101
 
102
  public static function createSignature()
103
  {
104
- $options = array(
105
- 'makeDefault',
106
- 'verifyCard',
107
- 'failOnDuplicatePaymentMethod',
108
- 'verificationMerchantAccountId'
109
- );
110
- $signature = self::baseSignature($options);
111
  return $signature;
112
  }
113
 
@@ -119,28 +127,13 @@ class Braintree_PaymentMethodGateway
119
  'updateExisting'
120
  )
121
  ));
122
- return array(
123
- 'billingAddressId',
124
- 'cardholderName',
125
- 'cvv',
126
  'deviceSessionId',
127
- 'expirationDate',
128
- 'expirationMonth',
129
- 'expirationYear',
130
- 'number',
131
- 'token',
132
  'venmoSdkPaymentMethodCode',
133
- 'deviceData',
134
  'fraudMerchantId',
135
- 'paymentMethodNonce',
136
- array('options' => array(
137
- 'makeDefault',
138
- 'verificationMerchantAccountId',
139
- 'verifyCard',
140
- 'venmoSdkSession'
141
- )),
142
  array('billingAddress' => $billingAddressSignature)
143
- );
 
144
  }
145
 
146
  /**
@@ -214,6 +207,12 @@ class Braintree_PaymentMethodGateway
214
  Braintree_ApplePayCard::factory($response['applePayCard']),
215
  "paymentMethod"
216
  );
 
 
 
 
 
 
217
  } else if (isset($response['apiErrorResponse'])) {
218
  return new Braintree_Result_Error($response['apiErrorResponse']);
219
  } else if (is_array($response)) {
28
  {
29
  $this->_gateway = $gateway;
30
  $this->_config = $gateway->config;
31
+ $this->_config->assertHasAccessTokenOrKeys();
32
  $this->_http = new Braintree_Http($gateway->config);
33
  }
34
 
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 (is_array($response)) {
67
  return Braintree_UnknownPaymentMethod::factory($response);
68
  }
88
  return new Braintree_Result_Successful();
89
  }
90
 
91
+ private static function baseSignature()
92
  {
93
  $billingAddressSignature = Braintree_AddressGateway::createSignature();
94
+ $optionsSignature = array(
95
+ 'failOnDuplicatePaymentMethod',
96
+ 'makeDefault',
97
+ 'verificationMerchantAccountId',
98
+ 'verifyCard'
99
+ );
100
  return array(
 
 
 
101
  'billingAddressId',
102
+ 'cardholderName',
103
+ 'cvv',
104
  'deviceData',
105
+ 'expirationDate',
106
+ 'expirationMonth',
107
+ 'expirationYear',
108
+ 'number',
109
+ 'paymentMethodNonce',
110
+ 'token',
111
+ array('options' => $optionsSignature),
112
  array('billingAddress' => $billingAddressSignature)
113
  );
114
  }
115
 
116
  public static function createSignature()
117
  {
118
+ $signature = array_merge(self::baseSignature(), array('customerId'));
 
 
 
 
 
 
119
  return $signature;
120
  }
121
 
127
  'updateExisting'
128
  )
129
  ));
130
+ $signature = array_merge(self::baseSignature(), array(
 
 
 
131
  'deviceSessionId',
 
 
 
 
 
132
  'venmoSdkPaymentMethodCode',
 
133
  'fraudMerchantId',
 
 
 
 
 
 
 
134
  array('billingAddress' => $billingAddressSignature)
135
+ ));
136
+ return $signature;
137
  }
138
 
139
  /**
207
  Braintree_ApplePayCard::factory($response['applePayCard']),
208
  "paymentMethod"
209
  );
210
+ } else if (isset($response['androidPayCard'])) {
211
+ // return a populated instance of Braintree_AndroidPayCard
212
+ return new Braintree_Result_Successful(
213
+ Braintree_AndroidPayCard::factory($response['androidPayCard']),
214
+ "paymentMethod"
215
+ );
216
  } else if (isset($response['apiErrorResponse'])) {
217
  return new Braintree_Result_Error($response['apiErrorResponse']);
218
  } else if (is_array($response)) {
lib/Braintree/PaymentMethodNonce.php CHANGED
@@ -18,7 +18,7 @@
18
  * @copyright 2014 Braintree, a division of PayPal, Inc.
19
  *
20
  */
21
- class Braintree_PaymentMethodNonce extends Braintree
22
  {
23
  // static methods redirecting to gateway
24
 
@@ -27,14 +27,15 @@ class Braintree_PaymentMethodNonce extends Braintree
27
  return Braintree_Configuration::gateway()->paymentMethodNonce()->create($token);
28
  }
29
 
30
- public static function factory($attributes)
31
  {
32
- $defaultAttributes = array(
33
- 'nonce' => '',
34
- );
35
 
 
 
36
  $instance = new self();
37
- $instance->_initialize(array_merge($defaultAttributes, $attributes));
38
  return $instance;
39
  }
40
 
@@ -42,5 +43,10 @@ class Braintree_PaymentMethodNonce extends Braintree
42
  {
43
  $this->_attributes = $nonceAttributes;
44
  $this->_set('nonce', $nonceAttributes['nonce']);
 
 
 
 
 
45
  }
46
  }
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
 
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)
36
+ {
37
  $instance = new self();
38
+ $instance->_initialize($attributes);
39
  return $instance;
40
  }
41
 
43
  {
44
  $this->_attributes = $nonceAttributes;
45
  $this->_set('nonce', $nonceAttributes['nonce']);
46
+ $this->_set('type', $nonceAttributes['type']);
47
+
48
+ if(isset($nonceAttributes['threeDSecureInfo'])) {
49
+ $this->_set('threeDSecureInfo', Braintree_ThreeDSecureInfo::factory($nonceAttributes['threeDSecureInfo']));
50
+ }
51
  }
52
  }
lib/Braintree/PaymentMethodNonceGateway.php CHANGED
@@ -43,4 +43,22 @@ class Braintree_PaymentMethodNonceGateway
43
  "paymentMethodNonce"
44
  );
45
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
43
  "paymentMethodNonce"
44
  );
45
  }
46
+
47
+ /**
48
+ * @access public
49
+ *
50
+ */
51
+ public function find($nonce)
52
+ {
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
  }
lib/Braintree/Plan.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- class Braintree_Plan extends Braintree
3
  {
4
  public static function factory($attributes)
5
  {
1
  <?php
2
+ class Braintree_Plan extends Braintree_Base
3
  {
4
  public static function factory($attributes)
5
  {
lib/Braintree/PlanGateway.php CHANGED
@@ -9,6 +9,7 @@ class Braintree_PlanGateway
9
  {
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
 
12
  $this->_http = new Braintree_Http($gateway->config);
13
  }
14
 
9
  {
10
  $this->_gateway = $gateway;
11
  $this->_config = $gateway->config;
12
+ $this->_config->assertHasAccessTokenOrKeys();
13
  $this->_http = new Braintree_Http($gateway->config);
14
  }
15
 
lib/Braintree/Result/CreditCardVerification.php CHANGED
@@ -81,4 +81,14 @@ class Braintree_Result_CreditCardVerification
81
  return __CLASS__ . '[' .
82
  Braintree_Util::attributesToString($this->_attributes) .']';
83
  }
 
 
 
 
 
 
 
 
 
 
84
  }
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
  }
lib/Braintree/Result/Error.php CHANGED
@@ -25,7 +25,7 @@
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
29
  {
30
  /**
31
  *
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
  *
lib/Braintree/Result/Successful.php CHANGED
@@ -34,26 +34,26 @@ class Braintree_Result_Successful extends Braintree_Instance
34
  *
35
  * @var string stores the internal name of the object providing access to
36
  */
37
- private $_returnObjectName;
38
 
39
  /**
40
  * @ignore
41
  * @param string $classToReturn name of class to instantiate
42
  */
43
- public function __construct($objToReturn = null, $propertyName = null)
44
  {
45
- $this->_attributes = array();
 
 
46
 
47
- if(!empty($objToReturn)) {
 
 
48
 
49
- if(empty($propertyName)) {
50
- $propertyName = Braintree_Util::cleanClassName(
51
- get_class($objToReturn)
52
- );
53
- }
54
 
55
  // save the name for indirect access
56
- $this->_returnObjectName = $propertyName;
57
 
58
  // create the property!
59
  $this->$propertyName = $objToReturn;
@@ -67,8 +67,20 @@ class Braintree_Result_Successful extends Braintree_Instance
67
  */
68
  public function __toString()
69
  {
70
- $returnObject = $this->_returnObjectName;
71
- return __CLASS__ . '['.$this->$returnObject->__toString().']';
 
 
 
72
  }
73
 
 
 
 
 
 
 
 
 
 
74
  }
34
  *
35
  * @var string stores the internal name of the object providing access to
36
  */
37
+ private $_returnObjectNames;
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
 
55
  // save the name for indirect access
56
+ array_push($this->_returnObjectNames, $propertyName);
57
 
58
  // create the property!
59
  $this->$propertyName = $objToReturn;
67
  */
68
  public function __toString()
69
  {
70
+ $objects = array();
71
+ foreach ($this->_returnObjectNames as $returnObjectName) {
72
+ array_push($objects, $this->$returnObjectName);
73
+ }
74
+ return __CLASS__ . '[' . implode(', ', $objects) . ']';
75
  }
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
  }
lib/Braintree/RiskData.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- class Braintree_RiskData extends Braintree
3
  {
4
  public static function factory($attributes)
5
  {
1
  <?php
2
+ class Braintree_RiskData extends Braintree_Base
3
  {
4
  public static function factory($attributes)
5
  {
lib/Braintree/SettlementBatchSummary.php CHANGED
@@ -1,6 +1,11 @@
1
  <?php
2
- class Braintree_SettlementBatchSummary extends Braintree
3
  {
 
 
 
 
 
4
  public static function factory($attributes)
5
  {
6
  $instance = new self();
@@ -10,6 +15,7 @@ class Braintree_SettlementBatchSummary extends Braintree
10
 
11
  /**
12
  * @ignore
 
13
  */
14
  protected function _initialize($attributes)
15
  {
@@ -22,8 +28,13 @@ class Braintree_SettlementBatchSummary extends Braintree
22
  }
23
 
24
 
25
- // static methods redirecting to gateway
26
-
 
 
 
 
 
27
  public static function generate($settlement_date, $groupByCustomField = NULL)
28
  {
29
  return Braintree_Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField);
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
  {
11
  $instance = new self();
15
 
16
  /**
17
  * @ignore
18
+ * @param array $attributes
19
  */
20
  protected function _initialize($attributes)
21
  {
28
  }
29
 
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);
lib/Braintree/SettlementBatchSummaryGateway.php CHANGED
@@ -1,17 +1,43 @@
1
  <?php
 
2
  class Braintree_SettlementBatchSummaryGateway
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->_http = new Braintree_Http($gateway->config);
13
  }
14
 
 
 
 
 
 
 
15
  public function generate($settlement_date, $groupByCustomField = NULL)
16
  {
17
  $criteria = array('settlement_date' => $settlement_date);
@@ -34,6 +60,12 @@ class Braintree_SettlementBatchSummaryGateway
34
  return $this->_verifyGatewayResponse($response);
35
  }
36
 
 
 
 
 
 
 
37
  private function _underscoreCustomField($groupByCustomField, $records)
38
  {
39
  $updatedRecords = array();
@@ -49,6 +81,12 @@ class Braintree_SettlementBatchSummaryGateway
49
  return $updatedRecords;
50
  }
51
 
 
 
 
 
 
 
52
  private function _verifyGatewayResponse($response)
53
  {
54
  if (isset($response['settlementBatchSummary'])) {
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);
60
  return $this->_verifyGatewayResponse($response);
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();
81
  return $updatedRecords;
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'])) {
lib/Braintree/Subscription.php CHANGED
@@ -11,7 +11,7 @@
11
  * @package Braintree
12
  * @copyright 2014 Braintree, a division of PayPal, Inc.
13
  */
14
- class Braintree_Subscription extends Braintree
15
  {
16
  const ACTIVE = 'Active';
17
  const CANCELED = 'Canceled';
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';
lib/Braintree/SubscriptionGateway.php CHANGED
@@ -21,6 +21,7 @@ class Braintree_SubscriptionGateway
21
  {
22
  $this->_gateway = $gateway;
23
  $this->_config = $gateway->config;
 
24
  $this->_http = new Braintree_Http($gateway->config);
25
  }
26
 
21
  {
22
  $this->_gateway = $gateway;
23
  $this->_config = $gateway->config;
24
+ $this->_config->assertHasAccessTokenOrKeys();
25
  $this->_http = new Braintree_Http($gateway->config);
26
  }
27
 
lib/Braintree/Test/Nonces.php CHANGED
@@ -26,6 +26,8 @@ class Braintree_Test_Nonces
26
  public static $applePayVisa = "fake-apple-pay-visa-nonce";
27
  public static $applePayMasterCard = "fake-apple-pay-visa-nonce";
28
  public static $applePayAmEx = "fake-apple-pay-amex-nonce";
 
29
  public static $abstractTransactable = "fake-abstract-transactable-nonce";
 
30
  public static $coinbase = "fake-coinbase-nonce";
31
  }
26
  public static $applePayVisa = "fake-apple-pay-visa-nonce";
27
  public static $applePayMasterCard = "fake-apple-pay-visa-nonce";
28
  public static $applePayAmEx = "fake-apple-pay-amex-nonce";
29
+ public static $androidPay = "fake-android-pay-nonce";
30
  public static $abstractTransactable = "fake-abstract-transactable-nonce";
31
+ public static $europe = "fake-europe-bank-account-nonce";
32
  public static $coinbase = "fake-coinbase-nonce";
33
  }
lib/Braintree/ThreeDSecureInfo.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Braintree_ThreeDSecureInfo extends Braintree_Base
3
+ {
4
+ public static function factory($attributes)
5
+ {
6
+ $instance = new self();
7
+ $instance->_initialize($attributes);
8
+
9
+ return $instance;
10
+ }
11
+
12
+ protected function _initialize($attributes)
13
+ {
14
+ $this->_attributes = $attributes;
15
+ }
16
+
17
+ /**
18
+ * returns a string representation of the three d secure info
19
+ * @return string
20
+ */
21
+ public function __toString()
22
+ {
23
+ return __CLASS__ . '[' .
24
+ Braintree_Util::attributesToString($this->_attributes) .']';
25
+ }
26
+
27
+ }
lib/Braintree/Transaction.php CHANGED
@@ -149,6 +149,7 @@
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 $creditCardDetails transaction credit card info
153
  * @property-read object $coinbaseDetails transaction Coinbase account info
154
  * @property-read object $paypalDetails transaction paypal account info
@@ -166,7 +167,7 @@
166
  *
167
  */
168
 
169
- final class Braintree_Transaction extends Braintree
170
  {
171
  // Transaction Status
172
  const AUTHORIZATION_EXPIRED = 'authorization_expired';
@@ -210,6 +211,7 @@ final class Braintree_Transaction extends Braintree
210
  const DUPLICATE = 'duplicate';
211
  const FRAUD = 'fraud';
212
  const THREE_D_SECURE = 'three_d_secure';
 
213
 
214
  // Industry Types
215
  const LODGING_INDUSTRY = 'lodging';
@@ -235,6 +237,14 @@ final class Braintree_Transaction extends Braintree
235
  );
236
  }
237
 
 
 
 
 
 
 
 
 
238
  if (isset($transactionAttribs['creditCard'])) {
239
  $this->_set('creditCardDetails',
240
  new Braintree_Transaction_CreditCardDetails(
@@ -342,6 +352,9 @@ final class Braintree_Transaction extends Braintree
342
  if(isset($transactionAttribs['riskData'])) {
343
  $this->_set('riskData', Braintree_RiskData::factory($transactionAttribs['riskData']));
344
  }
 
 
 
345
  }
346
 
347
  /**
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
167
  *
168
  */
169
 
170
+ final class Braintree_Transaction extends Braintree_Base
171
  {
172
  // Transaction Status
173
  const AUTHORIZATION_EXPIRED = 'authorization_expired';
211
  const DUPLICATE = 'duplicate';
212
  const FRAUD = 'fraud';
213
  const THREE_D_SECURE = 'three_d_secure';
214
+ const APPLICATION_INCOMPLETE = 'application_incomplete';
215
 
216
  // Industry Types
217
  const LODGING_INDUSTRY = 'lodging';
237
  );
238
  }
239
 
240
+ if (isset($transactionAttribs['androidPayCard'])) {
241
+ $this->_set('androidPayCardDetails',
242
+ new Braintree_Transaction_AndroidPayCardDetails(
243
+ $transactionAttribs['androidPayCard']
244
+ )
245
+ );
246
+ }
247
+
248
  if (isset($transactionAttribs['creditCard'])) {
249
  $this->_set('creditCardDetails',
250
  new Braintree_Transaction_CreditCardDetails(
352
  if(isset($transactionAttribs['riskData'])) {
353
  $this->_set('riskData', Braintree_RiskData::factory($transactionAttribs['riskData']));
354
  }
355
+ if(isset($transactionAttribs['threeDSecureInfo'])) {
356
+ $this->_set('threeDSecureInfo', Braintree_ThreeDSecureInfo::factory($transactionAttribs['threeDSecureInfo']));
357
+ }
358
  }
359
 
360
  /**
lib/Braintree/Transaction/AndroidPayCardDetails.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
11
+ * creates an instance of AndroidPayCardDetails
12
+ *
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
20
+ * @property-read string $expirationMonth
21
+ * @property-read string $expirationYear
22
+ * @property-read string $googleTransactionId
23
+ * @property-read string $imageUrl
24
+ * @property-read string $sourceCardLast4
25
+ * @property-read string $sourceCardType
26
+ * @property-read string $token
27
+ * @property-read string $virtualCardLast4
28
+ * @property-read string $virtualCardType
29
+ * @uses Braintree_Instance inherits methods
30
+ */
31
+ class Braintree_Transaction_AndroidPayCardDetails extends Braintree_Instance
32
+ {
33
+ protected $_attributes = array();
34
+
35
+ /**
36
+ * @ignore
37
+ */
38
+ public function __construct($attributes)
39
+ {
40
+ parent::__construct($attributes);
41
+ $this->_attributes['cardType'] = $this->virtualCardType;
42
+ $this->_attributes['last4'] = $this->virtualCardLast4;
43
+ }
44
+ }
lib/Braintree/TransactionGateway.php CHANGED
@@ -23,6 +23,7 @@ final class Braintree_TransactionGateway
23
  {
24
  $this->_gateway = $gateway;
25
  $this->_config = $gateway->config;
 
26
  $this->_http = new Braintree_Http($gateway->config);
27
  }
28
 
23
  {
24
  $this->_gateway = $gateway;
25
  $this->_config = $gateway->config;
26
+ $this->_config->assertHasAccessTokenOrKeys();
27
  $this->_http = new Braintree_Http($gateway->config);
28
  }
29
 
lib/Braintree/TransactionSearch.php CHANGED
@@ -1,63 +1,61 @@
1
  <?php
2
  class Braintree_TransactionSearch
3
  {
4
- static function billingCompany() { return new Braintree_TextNode('billing_company'); }
5
- static function billingCountryName() { return new Braintree_TextNode('billing_country_name'); }
6
- static function billingExtendedAddress() { return new Braintree_TextNode('billing_extended_address'); }
7
- static function billingFirstName() { return new Braintree_TextNode('billing_first_name'); }
8
- static function billingLastName() { return new Braintree_TextNode('billing_last_name'); }
9
- static function billingLocality() { return new Braintree_TextNode('billing_locality'); }
10
- static function billingPostalCode() { return new Braintree_TextNode('billing_postal_code'); }
11
- static function billingRegion() { return new Braintree_TextNode('billing_region'); }
12
- static function billingStreetAddress() { return new Braintree_TextNode('billing_street_address'); }
13
- static function creditCardCardholderName() { return new Braintree_TextNode('credit_card_cardholderName'); }
14
- static function customerCompany() { return new Braintree_TextNode('customer_company'); }
15
- static function customerEmail() { return new Braintree_TextNode('customer_email'); }
16
- static function customerFax() { return new Braintree_TextNode('customer_fax'); }
17
- static function customerFirstName() { return new Braintree_TextNode('customer_first_name'); }
18
- static function customerId() { return new Braintree_TextNode('customer_id'); }
19
- static function customerLastName() { return new Braintree_TextNode('customer_last_name'); }
20
- static function customerPhone() { return new Braintree_TextNode('customer_phone'); }
21
- static function customerWebsite() { return new Braintree_TextNode('customer_website'); }
22
- static function id() { return new Braintree_TextNode('id'); }
23
- static function ids() { return new Braintree_MultipleValueNode('ids'); }
24
- static function orderId() { return new Braintree_TextNode('order_id'); }
25
- static function paymentMethodToken() { return new Braintree_TextNode('payment_method_token'); }
26
- static function processorAuthorizationCode() { return new Braintree_TextNode('processor_authorization_code'); }
27
- static function settlementBatchId() { return new Braintree_TextNode('settlement_batch_id'); }
28
- static function shippingCompany() { return new Braintree_TextNode('shipping_company'); }
29
- static function shippingCountryName() { return new Braintree_TextNode('shipping_country_name'); }
30
- static function shippingExtendedAddress() { return new Braintree_TextNode('shipping_extended_address'); }
31
- static function shippingFirstName() { return new Braintree_TextNode('shipping_first_name'); }
32
- static function shippingLastName() { return new Braintree_TextNode('shipping_last_name'); }
33
- static function shippingLocality() { return new Braintree_TextNode('shipping_locality'); }
34
- static function shippingPostalCode() { return new Braintree_TextNode('shipping_postal_code'); }
35
- static function shippingRegion() { return new Braintree_TextNode('shipping_region'); }
36
- static function shippingStreetAddress() { return new Braintree_TextNode('shipping_street_address'); }
37
- static function paypalPaymentId() { return new Braintree_TextNode('paypal_payment_id'); }
38
- static function paypalAuthorizationId() { return new Braintree_TextNode('paypal_authorization_id'); }
39
- static function paypalPayerEmail() { return new Braintree_TextNode('paypal_payer_email'); }
40
-
41
- static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); }
42
-
43
- static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); }
44
-
45
- static function refund() { return new Braintree_KeyValueNode("refund"); }
46
-
47
- static function amount() { return new Braintree_RangeNode("amount"); }
48
- static function authorizedAt() { return new Braintree_RangeNode("authorizedAt"); }
49
- static function authorizationExpiredAt() { return new Braintree_RangeNode("authorizationExpiredAt"); }
50
- static function createdAt() { return new Braintree_RangeNode("createdAt"); }
51
- static function failedAt() { return new Braintree_RangeNode("failedAt"); }
52
- static function gatewayRejectedAt() { return new Braintree_RangeNode("gatewayRejectedAt"); }
53
- static function processorDeclinedAt() { return new Braintree_RangeNode("processorDeclinedAt"); }
54
- static function settledAt() { return new Braintree_RangeNode("settledAt"); }
55
- static function submittedForSettlementAt() { return new Braintree_RangeNode("submittedForSettlementAt"); }
56
- static function voidedAt() { return new Braintree_RangeNode("voidedAt"); }
57
- static function disbursementDate() { return new Braintree_RangeNode("disbursementDate"); }
58
- static function disputeDate() { return new Braintree_RangeNode("disputeDate"); }
59
-
60
  static function merchantAccountId() { return new Braintree_MultipleValueNode("merchant_account_id"); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  static function createdUsing()
63
  {
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 failedAt() { return new Braintree_RangeNode("failedAt"); }
32
+ static function gatewayRejectedAt() { return new Braintree_RangeNode("gatewayRejectedAt"); }
33
+ static function id() { return new Braintree_TextNode('id'); }
34
+ static function ids() { return new Braintree_MultipleValueNode('ids'); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  static function merchantAccountId() { return new Braintree_MultipleValueNode("merchant_account_id"); }
36
+ static function orderId() { return new Braintree_TextNode('order_id'); }
37
+ static function paymentInstrumentType() { return new Braintree_MultipleValueNode('paymentInstrumentType'); }
38
+ static function paymentMethodToken() { return new Braintree_TextNode('payment_method_token'); }
39
+ static function paypalAuthorizationId() { return new Braintree_TextNode('paypal_authorization_id'); }
40
+ static function paypalPayerEmail() { return new Braintree_TextNode('paypal_payer_email'); }
41
+ static function paypalPaymentId() { return new Braintree_TextNode('paypal_payment_id'); }
42
+ static function processorAuthorizationCode() { return new Braintree_TextNode('processor_authorization_code'); }
43
+ static function processorDeclinedAt() { return new Braintree_RangeNode("processorDeclinedAt"); }
44
+ static function refund() { return new Braintree_KeyValueNode("refund"); }
45
+ static function settledAt() { return new Braintree_RangeNode("settledAt"); }
46
+ static function settlementBatchId() { return new Braintree_TextNode('settlement_batch_id'); }
47
+ static function shippingCompany() { return new Braintree_TextNode('shipping_company'); }
48
+ static function shippingCountryName() { return new Braintree_TextNode('shipping_country_name'); }
49
+ static function shippingExtendedAddress() { return new Braintree_TextNode('shipping_extended_address'); }
50
+ static function shippingFirstName() { return new Braintree_TextNode('shipping_first_name'); }
51
+ static function shippingLastName() { return new Braintree_TextNode('shipping_last_name'); }
52
+ static function shippingLocality() { return new Braintree_TextNode('shipping_locality'); }
53
+ static function shippingPostalCode() { return new Braintree_TextNode('shipping_postal_code'); }
54
+ static function shippingRegion() { return new Braintree_TextNode('shipping_region'); }
55
+ static function shippingStreetAddress() { return new Braintree_TextNode('shipping_street_address'); }
56
+ static function submittedForSettlementAt() { return new Braintree_RangeNode("submittedForSettlementAt"); }
57
+ static function user() { return new Braintree_MultipleValueNode('user'); }
58
+ static function voidedAt() { return new Braintree_RangeNode("voidedAt"); }
59
 
60
  static function createdUsing()
61
  {
lib/Braintree/TransparentRedirectGateway.php CHANGED
@@ -16,6 +16,7 @@ class Braintree_TransparentRedirectGateway
16
  {
17
  $this->_gateway = $gateway;
18
  $this->_config = $gateway->config;
 
19
  }
20
 
21
  /**
16
  {
17
  $this->_gateway = $gateway;
18
  $this->_config = $gateway->config;
19
+ $this->_config->assertHasAccessTokenOrKeys();
20
  }
21
 
22
  /**
lib/Braintree/UnknownPaymentMethod.php CHANGED
@@ -20,7 +20,7 @@
20
  * @property-read string $token
21
  * @property-read string $imageUrl
22
  */
23
- class Braintree_UnknownPaymentMethod extends Braintree
24
  {
25
 
26
 
20
  * @property-read string $token
21
  * @property-read string $imageUrl
22
  */
23
+ class Braintree_UnknownPaymentMethod extends Braintree_Base
24
  {
25
 
26
 
lib/Braintree/Util.php CHANGED
@@ -17,7 +17,6 @@ class Braintree_Util
17
  *
18
  * @param array $attribArray attributes from a search response
19
  * @param string $attributeName indicates which element of the passed array to extract
20
- *
21
  * @return array array of Braintree_$attributeName objects, or a single element array
22
  */
23
  public static function extractAttributeAsArray(& $attribArray, $attributeName)
@@ -119,8 +118,11 @@ class Braintree_Util
119
  'AddressGateway' => 'address',
120
  'SettlementBatchSummary' => 'settlementBatchSummary',
121
  'SettlementBatchSummaryGateway' => 'settlementBatchSummary',
 
 
122
  'MerchantAccount' => 'merchantAccount',
123
  'MerchantAccountGateway' => 'merchantAccount',
 
124
  'PayPalAccount' => 'paypalAccount',
125
  'PayPalAccountGateway' => 'paypalAccount'
126
  );
@@ -206,6 +208,53 @@ class Braintree_Util
206
  return preg_replace_callback('/([A-Z])/', $callbacks[$delimiter], $string);
207
  }
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  /**
210
  *
211
  * @param array $array associative array to implode
@@ -217,8 +266,10 @@ class Braintree_Util
217
  // build a new array with joined keys and values
218
  $tmpArray = null;
219
  foreach ($array AS $key => $value) {
220
- $tmpArray[] = $key . $separator . $value;
221
-
 
 
222
  }
223
  // implode and return the new array
224
  return (is_array($tmpArray)) ? implode($glue, $tmpArray) : false;
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)
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
  );
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);
217
+ }
218
+
219
+ if (is_array($value)) {
220
+ // Make an exception for custom fields, which must be underscore (can't be
221
+ // camelCase).
222
+ if ($key === 'customFields') {
223
+ $value = self::delimiterToUnderscoreArray($value);
224
+ } else {
225
+ $value = self::delimiterToCamelCaseArray($value, $delimiter);
226
+ }
227
+ }
228
+ $converted[$key] = $value;
229
+ }
230
+ return $converted;
231
+ }
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);
239
+ }
240
+ if (is_array($value)) {
241
+ $value = self::camelCaseToDelimiterArray($value, $delimiter);
242
+ }
243
+ $converted[$key] = $value;
244
+ }
245
+ return $converted;
246
+ }
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;
254
+ }
255
+ return $converted;
256
+ }
257
+
258
  /**
259
  *
260
  * @param array $array associative array to implode
266
  // build a new array with joined keys and values
267
  $tmpArray = null;
268
  foreach ($array AS $key => $value) {
269
+ if ($value instanceof DateTime) {
270
+ $value = $value->format('r');
271
+ }
272
+ $tmpArray[] = $key . $separator . $value;
273
  }
274
  // implode and return the new array
275
  return (is_array($tmpArray)) ? implode($glue, $tmpArray) : false;
lib/Braintree/Version.php CHANGED
@@ -10,8 +10,8 @@ final class Braintree_Version
10
  /**
11
  * class constants
12
  */
13
- const MAJOR = 2;
14
- const MINOR = 37;
15
  const TINY = 0;
16
 
17
  /**
10
  /**
11
  * class constants
12
  */
13
+ const MAJOR = 3;
14
+ const MINOR = 2;
15
  const TINY = 0;
16
 
17
  /**
lib/Braintree/WebhookNotification.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- class Braintree_WebhookNotification extends Braintree
3
  {
4
  const SUBSCRIPTION_CANCELED = 'subscription_canceled';
5
  const SUBSCRIPTION_CHARGED_SUCCESSFULLY = 'subscription_charged_successfully';
@@ -25,6 +25,8 @@ class Braintree_WebhookNotification extends Braintree
25
  if (preg_match("/[^A-Za-z0-9+=\/\n]/", $payload) === 1) {
26
  throw new Braintree_Exception_InvalidSignature("payload contains illegal characters");
27
  }
 
 
28
  self::_validateSignature($signature, $payload);
29
 
30
  $xml = base64_decode($payload);
@@ -34,6 +36,10 @@ class Braintree_WebhookNotification extends Braintree
34
 
35
  public static function verify($challenge)
36
  {
 
 
 
 
37
  $publicKey = Braintree_Configuration::publicKey();
38
  $digest = Braintree_Digest::hexDigestSha1(Braintree_Configuration::privateKey(), $challenge);
39
  return "{$publicKey}|{$digest}";
@@ -109,7 +115,7 @@ class Braintree_WebhookNotification extends Braintree
109
  }
110
 
111
  if (isset($wrapperNode['dispute'])) {
112
- $this->_set('dispute', Braintree_PartnerMerchant::factory($wrapperNode['dispute']));
113
  }
114
 
115
  if (isset($wrapperNode['errors'])) {
1
  <?php
2
+ class Braintree_WebhookNotification extends Braintree_Base
3
  {
4
  const SUBSCRIPTION_CANCELED = 'subscription_canceled';
5
  const SUBSCRIPTION_CHARGED_SUCCESSFULLY = 'subscription_charged_successfully';
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);
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}";
115
  }
116
 
117
  if (isset($wrapperNode['dispute'])) {
118
+ $this->_set('dispute', Braintree_Dispute::factory($wrapperNode['dispute']));
119
  }
120
 
121
  if (isset($wrapperNode['errors'])) {
lib/Braintree/Xml/Generator.php CHANGED
@@ -21,6 +21,7 @@ class Braintree_Xml_Generator
21
  */
22
  public static function arrayToXml($aData)
23
  {
 
24
  // set up the XMLWriter
25
  $writer = new XMLWriter();
26
  $writer->openMemory();
@@ -33,7 +34,7 @@ class Braintree_Xml_Generator
33
  $aKeys = array_keys($aData);
34
  $rootElementName = $aKeys[0];
35
  // open the root element
36
- $writer->startElement(Braintree_Util::camelCaseToDelimiter($rootElementName));
37
  // create the body
38
  self::_createElementsFromArray($writer, $aData[$rootElementName], $rootElementName);
39
 
@@ -64,9 +65,7 @@ class Braintree_Xml_Generator
64
  }
65
  return;
66
  }
67
- foreach ($aData AS $index => $element) {
68
- // convert the style back to gateway format
69
- $elementName = Braintree_Util::camelCaseToDelimiter($index, '-');
70
  // handle child elements
71
  $writer->startElement($elementName);
72
  if (is_array($element)) {
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();
34
  $aKeys = array_keys($aData);
35
  $rootElementName = $aKeys[0];
36
  // open the root element
37
+ $writer->startElement($rootElementName);
38
  // create the body
39
  self::_createElementsFromArray($writer, $aData[$rootElementName], $rootElementName);
40
 
65
  }
66
  return;
67
  }
68
+ foreach ($aData AS $elementName => $element) {
 
 
69
  // handle child elements
70
  $writer->startElement($elementName);
71
  if (is_array($element)) {
lib/Braintree/Xml/Parser.php CHANGED
@@ -5,173 +5,127 @@
5
  *
6
  * @copyright 2014 Braintree, a division of PayPal, Inc.
7
  */
8
- /**
9
- * Parses incoming Xml into arrays using PHP's
10
- * built-in SimpleXML, and its extension via
11
- * Iterator, SimpleXMLIterator
12
- *
13
- * @copyright 2014 Braintree, a division of PayPal, Inc.
14
- */
15
  class Braintree_Xml_Parser
16
  {
17
-
18
- private static $_xmlRoot;
19
- private static $_responseType;
20
-
21
  /**
22
- * sets up the SimpleXMLIterator and starts the parsing
23
- * @access public
24
  * @param string $xml
25
- * @return array array mapped to the passed xml
26
  */
27
  public static function arrayFromXml($xml)
28
  {
29
- // SimpleXML provides the root information on construct
30
- $iterator = new SimpleXMLIterator($xml);
31
- $xmlRoot = Braintree_Util::delimiterToCamelCase($iterator->getName());
32
- $type = $iterator->attributes()->type;
33
 
34
- self::$_xmlRoot = $iterator->getName();
35
- self::$_responseType = $type;
36
-
37
- // return the mapped array with the root element as the header
38
- return array($xmlRoot => self::_iteratorToArray($iterator));
39
 
 
 
 
40
  }
41
 
42
  /**
43
- * processes SimpleXMLIterator objects recursively
44
  *
45
- * @access protected
46
- * @param object $iterator
47
- * @return array xml converted to array
48
  */
49
- private static function _iteratorToArray($iterator)
50
  {
51
- $xmlArray = array();
52
- $value = null;
53
-
54
- // rewind the iterator and check if the position is valid
55
- // if not, return the string it contains
56
- $iterator->rewind();
57
- if (!$iterator->valid()) {
58
- return self::_typecastXmlValue($iterator);
59
  }
60
- for ($iterator->rewind(); $iterator->valid(); $iterator->next()) {
61
-
62
- $tmpArray = null;
63
- $value = null;
64
-
65
- // get the attribute type string for use in conditions below
66
- $attributeType = $iterator->attributes()->type;
67
-
68
- // extract the parent element via xpath query
69
- $parentElement = $iterator->xpath($iterator->key() . '/..');
70
- if ($parentElement[0] instanceof SimpleXMLIterator) {
71
- $parentElement = $parentElement[0];
72
- $parentKey = Braintree_Util::delimiterToCamelCase($parentElement->getName());
73
- } else {
74
- $parentElement = null;
75
- }
76
-
77
-
78
- if ($parentKey == "customFields") {
79
- $key = Braintree_Util::delimiterToUnderscore($iterator->key());
80
- } else {
81
- $key = Braintree_Util::delimiterToCamelCase($iterator->key());
82
- }
83
 
84
- // process children recursively
85
- if ($iterator->hasChildren()) {
86
- // return the child elements
87
- $value = self::_iteratorToArray($iterator->current());
88
-
89
- // if the element is an array type,
90
- // use numeric keys to allow multiple values
91
- if ($attributeType != 'array') {
92
- $tmpArray[$key] = $value;
93
  }
94
- } else {
95
- // cast values according to attributes
96
- $tmpArray[$key] = self::_typecastXmlValue($iterator->current());
97
  }
98
-
99
- // set the output string
100
- $output = isset($value) ? $value : $tmpArray[$key];
101
-
102
- // determine if there are multiple tags of this name at the same level
103
- if (isset($parentElement) &&
104
- ($parentElement->attributes()->type == 'collection') &&
105
- $iterator->hasChildren()) {
106
- $xmlArray[$key][] = $output;
107
- continue;
 
108
  }
109
-
110
- // if the element was an array type, output to a numbered key
111
- // otherwise, use the element name
112
- if ($attributeType == 'array') {
113
- $xmlArray[] = $output;
114
  } else {
115
- $xmlArray[$key] = $output;
 
 
 
 
 
116
  }
117
  }
118
-
119
- return $xmlArray;
120
  }
121
 
122
  /**
123
- * typecast xml value based on attributes
124
- * @param object $valueObj SimpleXMLElement
125
- * @return mixed value for placing into array
 
126
  */
127
- private static function _typecastXmlValue($valueObj)
128
  {
129
- // get the element attributes
130
- $attribs = $valueObj->attributes();
131
- // the element is null, so jump out here
132
- if (isset($attribs->nil) && $attribs->nil) {
133
- return null;
134
- }
135
- // switch on the type attribute
136
- // switch works even if $attribs->type isn't set
137
- switch ($attribs->type) {
138
- case 'datetime':
139
- return self::_timestampToUTC((string) $valueObj);
140
- break;
141
- case 'date':
142
- return new DateTime((string)$valueObj);
143
- break;
144
- case 'integer':
145
- return (int) $valueObj;
146
- break;
147
- case 'boolean':
148
- $value = (string) $valueObj;
149
- // look for a number inside the string
150
- if(is_numeric($value)) {
151
- return (bool) $value;
152
- } else {
153
- // look for the string "true", return false in all other cases
154
- return ($value != "true") ? FALSE : TRUE;
155
- }
156
- break;
157
- case 'array':
158
- return array();
159
- default:
160
- return (string) $valueObj;
161
  }
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  }
164
 
 
165
  /**
166
- * convert xml timestamps into DateTime
 
167
  * @param string $timestamp
168
- * @return string UTC formatted datetime string
169
  */
170
  private static function _timestampToUTC($timestamp)
171
  {
172
  $tz = new DateTimeZone('UTC');
173
- // strangely DateTime requires an explicit set below
174
- // to show the proper time zone
175
  $dateTime = new DateTime($timestamp, $tz);
176
  $dateTime->setTimezone($tz);
177
  return $dateTime;
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
12
+ *
13
  * @param string $xml
14
+ * @return array
15
  */
16
  public static function arrayFromXml($xml)
17
  {
18
+ $document = new DOMDocument('1.0', 'UTF-8');
19
+ $document->loadXML($xml);
 
 
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
  /**
29
+ * Converts a node to an array of values or nodes
30
  *
31
+ * @param DOMNode @node
32
+ * @return mixed
 
33
  */
34
+ private static function _nodeToArray($node)
35
  {
36
+ $type = null;
37
+ if ($node instanceof DOMElement) {
38
+ $type = $node->getAttribute('type');
 
 
 
 
 
39
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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) {
47
+ $array[] = $value;
 
 
48
  }
 
 
 
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 {
68
+ foreach ($node->childNodes as $child) {
69
+ if (!$child instanceof DOMText) {
70
+ $values[$child->nodeName] = self::_nodeToValue($child);
71
+ }
72
+ }
73
+ return $values;
74
  }
75
  }
 
 
76
  }
77
 
78
  /**
79
+ * Converts a node to a PHP value
80
+ *
81
+ * @param DOMNode $node
82
+ * @return mixed
83
  */
84
+ private static function _nodeToValue($node)
85
  {
86
+ $type = null;
87
+ if ($node instanceof DOMElement) {
88
+ $type = $node->getAttribute('type');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
90
 
91
+ switch($type) {
92
+ case 'datetime':
93
+ return self::_timestampToUTC((string) $node->nodeValue);
94
+ case 'date':
95
+ return new DateTime((string) $node->nodeValue);
96
+ case 'integer':
97
+ return (int) $node->nodeValue;
98
+ case 'boolean':
99
+ $value = (string) $node->nodeValue;
100
+ if(is_numeric($value)) {
101
+ return (bool) $value;
102
+ } else {
103
+ return ($value !== "true") ? false : true;
104
+ }
105
+ case 'array':
106
+ case 'collection':
107
+ return self::_nodeToArray($node);
108
+ default:
109
+ if ($node->hasChildNodes()) {
110
+ return self::_nodeToArray($node);
111
+ } elseif (trim($node->nodeValue) === '') {
112
+ return null;
113
+ } else {
114
+ return $node->nodeValue;
115
+ }
116
+ }
117
  }
118
 
119
+
120
  /**
121
+ * Converts XML timestamps into DateTime instances
122
+ *
123
  * @param string $timestamp
124
+ * @return DateTime
125
  */
126
  private static function _timestampToUTC($timestamp)
127
  {
128
  $tz = new DateTimeZone('UTC');
 
 
129
  $dateTime = new DateTime($timestamp, $tz);
130
  $dateTime->setTimezone($tz);
131
  return $dateTime;
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Gene_Braintree</name>
4
- <version>1.0.3.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/mit-license.php">MIT License</license>
7
  <channel>community</channel>
@@ -36,9 +36,9 @@ Easily add PayPal to your checkout. We've built the best PayPal integration arou
36
  &lt;/ul&gt;</description>
37
  <notes>Connect your Magento store to Braintree to accept Credit Cards &amp;amp; PayPal using V.Zero SDK</notes>
38
  <authors><author><name>Dave Macaulay</name><user>dave</user><email>magento@gene.co.uk</email></author></authors>
39
- <date>2015-06-16</date>
40
- <time>09:19:48</time>
41
- <contents><target name="magecommunity"><dir name="Gene"><dir name="Braintree"><dir name="Block"><dir name="Adminhtml"><dir name="Report"><dir name="Transactions"><file name="Grid.php" hash="32b32086548f62ae4aca4baf456b9ed2"/><file name="Search.php" hash="81d57c3744530f36c37782ce9d0f3a70"/></dir><file name="Transactions.php" hash="7afe45b49353e52b432aa0392d76a08e"/></dir><dir name="System"><dir name="Config"><dir name="Braintree"><file name="Config.php" hash="eaaf6c74be4233a315d5aa5932f7c9ca"/><file name="Currency.php" hash="9ffa8a2ded53be75e88a60a024883b07"/><file name="Moduleversion.php" hash="fe3836bde24bb31c4c4585f2cd2f20ed"/><file name="Version.php" hash="ce58278a4faf965301cc2d8b2da4483c"/></dir></dir></dir></dir><dir name="Cart"><file name="Totals.php" hash="a03c441e8143896f92d02931a809f666"/></dir><dir name="Creditcard"><file name="Info.php" hash="8050c4c5321535fe93e62b47eab97b82"/><file name="Threedsecure.php" hash="7848d4ecac743be985f328fa969318bf"/></dir><file name="Creditcard.php" hash="989678324ff3fcddcc99cbe4613019fa"/><file name="Info.php" hash="2a8367489959ba9c1de4fe4c9afa62e4"/><file name="Js.php" hash="50cdd6d01eddfbdcc0061f4369cbeb58"/><dir name="Paypal"><file name="Info.php" hash="0874c0839a27c14ec9be47fed152e880"/></dir><file name="Paypal.php" hash="36294a461378cceee66e99d45753c6e1"/><file name="Saved.php" hash="74ed8e70a404a814b94f21f88c1ca737"/></dir><dir name="Helper"><file name="Data.php" hash="7ab1dba0f90dc067f0293e3f34bdf387"/></dir><dir name="Model"><file name="Debug.php" hash="f3360f71e2346881f93424792ed9f209"/><file name="Observer.php" hash="176b48ac3b74bfaa3c28f4126093b49b"/><dir name="Paymentmethod"><file name="Abstract.php" hash="f6f818eb5720ceee4e43cff281209a88"/><file name="Creditcard.php" hash="c0c1307ada89f675ff97b96412205615"/><file name="Paypal.php" hash="6523279bdc21c8b047d85b99d251a26a"/></dir><file name="Saved.php" hash="3b235b454a3692d1c3d5343e2a1c91e9"/><dir name="Source"><file name="Cctype.php" hash="d76aa6c3a4bd798e3a47695f579d21d4"/><dir name="Creditcard"><file name="CaptureAction.php" hash="6444cfc430de44f06e85bd9c8b80d77b"/><file name="PaymentAction.php" hash="a2f3f3d36a98df4d12f76b6ab77f9c47"/></dir><file name="Environment.php" hash="02567d2ddba74d06ac000b4ddb12723a"/><dir name="Paypal"><file name="Locale.php" hash="8988ca77f9c2aa2d19ff0b614a4b7621"/><file name="Paymenttype.php" hash="fe1fe4ee89d5b7a87c7c28716bb2f1cb"/></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Currency.php" hash="73cb15b1de303e88c487db4c585ef94e"/></dir></dir></dir><dir name="Wrapper"><file name="Braintree.php" hash="b176325a312062bcf82127aef2da546a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="BraintreeController.php" hash="7c621fa1548c04e24bb1136bcbbe1d72"/></dir><file name="CheckoutController.php" hash="19551187f161f5df4e49a9a009c0adaf"/><file name="SavedController.php" hash="036e97703c853a5bae064dd7cf5030a8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="c9c940beffa0ec19e4a1499a66f7fd12"/><file name="config.xml" hash="e4ce70356c9ec5e7c45085c902ac61ed"/><file name="system.xml" hash="01fc95e2c590d2fad81b007e361cfa63"/></dir><dir name="sql"><dir name="gene_braintree_setup"><file name="install-0.1.0.php" hash="7ef62b7c19b9da5990974da6edb3e77c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="gene"><file name="braintree.xml" hash="1ded19331e4656bd31d052eb729ff7c2"/></dir></dir><dir name="template"><dir name="gene"><dir name="braintree"><dir name="creditcard"><file name="info.phtml" hash="2ae1e397b3a633dd305bc26c7b9c1065"/><file name="threedsecure.phtml" hash="ee8ad689afde041c39dd92ffa5274883"/></dir><file name="creditcard.phtml" hash="e741bce943fe9dbed1b4170ead312ed8"/><dir name="customer"><file name="methods.phtml" hash="eb5e2d8f4a0f419fcf720c12062f808a"/><file name="saved.phtml" hash="691162b89ed085599f76072226ca2307"/></dir><dir name="js"><file name="amasty.phtml" hash="371b707e57225d5ed1b40ebaa5d6aeac"/><file name="data.phtml" hash="7c77e2c13c9037ab993b7c7f8aa72d98"/><file name="default.phtml" hash="f66705b89a41ed730a457ed6cdb464df"/><file name="idev.phtml" hash="6879086713cc3360c4e0643e77b375ff"/><file name="setup.phtml" hash="86a6da43f073b5fc75ce170a50af3bcd"/></dir><dir name="paypal"><file name="info.phtml" hash="5149b273730121e4dec3c3179820f747"/></dir><file name="paypal.phtml" hash="4280fcf89509eb959171f2214779de35"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="gene"><file name="braintree.xml" hash="1995e85eb47b909120ce8b9b537bf5db"/></dir></dir><dir name="template"><dir name="gene"><dir name="braintree"><dir name="creditcard"><file name="info.phtml" hash="24c67bab482ea7383ce57d9a06bb9d6f"/></dir><file name="creditcard.phtml" hash="0c6b7806732c336ead14fab596f1b923"/><file name="js.phtml" hash="110f5074c5671659cdd3239ac36b094b"/><dir name="paypal"><file name="info.phtml" hash="a8f92f312f8aa5a9463f1d5c2a38cd1b"/></dir><dir name="transactions"><file name="index.phtml" hash="1791b6393f319616dd79c0b46e391847"/><file name="search.phtml" hash="1682ce6200681681f0ce3c848e2e6694"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gene_Braintree.xml" hash="8c0ffda8566dca2f0b98a999921e3e55"/></dir></target><target name="mageweb"><dir name="js"><dir name="gene"><dir name="braintree"><file name="braintree.js" hash="4a074b2952d6e3c0052f85442b284abc"/><file name="vzero.js" hash="0ea7d83df34c94eae8fa9d1c112d6824"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="gene"><dir name="braintree"><file name="AE.png" hash="6b6f405105413b0723a62ee498f88bf6"/><file name="DI.png" hash="d8e3c3022dda9e723f466b8976ae428f"/><file name="JCB.png" hash="3aa9a71ed8a1d6610bbe0dfe2040e29e"/><file name="MC.png" hash="1fcd14928245139962b72f9368bdbe32"/><file name="ME.png" hash="b9389913c47b9546a67f907fcca73706"/><file name="PP.png" hash="b4946bccba574e86c9716a4986e21c36"/><file name="VI.png" hash="c9f74d1d54e61ab2c748f45a4bdface0"/><file name="card.png" hash="66e16f8c573fad93bb0d62258dce28bb"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Braintree"><file name="AddOn.php" hash="07bc690cf426276dfdd802c49cfd72a3"/><file name="AddOnGateway.php" hash="ed9a94155c1c13ba37910fd48bdad40a"/><file name="Address.php" hash="1d4e7f964ed208a381b352d21fc370b8"/><file name="AddressGateway.php" hash="11716dc4ede8b7455197d08b88c91568"/><file name="ApplePayCard.php" hash="6fdbe99722514408f613c417e0e48711"/><file name="ClientToken.php" hash="f606f4bbafaea470333290be52b0030d"/><file name="ClientTokenGateway.php" hash="ede93fa63f0e96d296f315180f5ff1ad"/><file name="CoinbaseAccount.php" hash="7a4992ed13c26ad3785cf7d3455ef5fb"/><file name="Collection.php" hash="0e7d31ffcbd9780fb554186bd2c194b0"/><file name="Configuration.php" hash="6414dae20a80d926c28bd681bb535934"/><file name="CreditCard.php" hash="cf0aab2bcdcc7c231ccedc05a0f853e4"/><file name="CreditCardGateway.php" hash="3c5c3d9cee27da71e338b51d42b685ee"/><file name="CreditCardVerification.php" hash="48d6ea546914278f4bea2fefb75e7836"/><file name="CreditCardVerificationGateway.php" hash="e020dd1c26cd8c3bd7eb55eed2f72346"/><file name="CreditCardVerificationSearch.php" hash="baa6ed22471ea1f142a4195d1e36f89a"/><file name="Customer.php" hash="69d834344b93277dbeadb4ee6a881a60"/><file name="CustomerGateway.php" hash="bde59d4c6d7418fcbd87d4484384705b"/><file name="CustomerSearch.php" hash="8aacc83dac341cd9afec5a3deab17593"/><file name="Descriptor.php" hash="3f5db5e817280ce7f2fa18a205281ad9"/><file name="Digest.php" hash="9d12d067770f55b123b8498fce4478fa"/><file name="Disbursement.php" hash="589534043e466d17fede916fd7986edc"/><file name="DisbursementDetails.php" hash="ae632207d0982e288a83aed401c880d9"/><file name="Discount.php" hash="763b3f9cde0ff3af3e8795cac4097595"/><file name="DiscountGateway.php" hash="42ca6f2f11074ec18eecd1506996a393"/><dir name="Dispute"><file name="TransactionDetails.php" hash="7fdea673a1295055508f42286ad57f4e"/></dir><file name="Dispute.php" hash="2ee0f4a77b7cfec4763b55627a57e348"/><file name="EqualityNode.php" hash="cfd6aa184186233b8d6d1ec0f0e79298"/><dir name="Error"><file name="Codes.php" hash="d0d1007255af20889a4874d028ebeab2"/><file name="ErrorCollection.php" hash="e28d638db56524f5bf3609fa725e6d55"/><file name="Validation.php" hash="bf4e2198300019c52ba56f16269d66ce"/><file name="ValidationErrorCollection.php" hash="9ef25d0126a0b4f6951da5334ae6f0dc"/></dir><dir name="Exception"><file name="Authentication.php" hash="f9e13654988452cca2ac5228a80adae4"/><file name="Authorization.php" hash="5f8c017c6e9fd79a556dade8e15a72e8"/><file name="Configuration.php" hash="b50f67e8ea36cff0d9f6ad718126c6fc"/><file name="DownForMaintenance.php" hash="7fd30b1f8976ed7e38b7e9fae5c20f03"/><file name="ForgedQueryString.php" hash="6884dbae1e86767834b77c821df2db62"/><file name="InvalidSignature.php" hash="b83f5b16735cb3a8e0a8111c4f32711e"/><file name="NotFound.php" hash="f832f771d20b381c2780eb2a572b9f44"/><file name="SSLCaFileNotFound.php" hash="e927c7307bf1761814dc8a755238070d"/><file name="SSLCertificate.php" hash="d509b6a6206bd7c5563ac142dfe3801f"/><file name="ServerError.php" hash="b4645290229ab228a257047d08ef63d7"/><file name="Unexpected.php" hash="01ea2800fb91995ec2a15aee5024611e"/><file name="UpgradeRequired.php" hash="7f40b174df891cc3b3e206d1be884a58"/><file name="ValidationsFailed.php" hash="cd2d30c69911f81b55279c3d6bf88c61"/></dir><file name="Exception.php" hash="f14c94bf67206184eb3e4e7aeb4a608a"/><file name="Gateway.php" hash="8b214a63ed50539e75031caff78d4560"/><file name="Http.php" hash="5f6a9990a14684c82b6952937889412b"/><file name="Instance.php" hash="f0603b3f9213b53687e079c5621ac8f3"/><file name="IsNode.php" hash="e4b1f7bbfcbd24b1d08b97f94df592be"/><file name="KeyValueNode.php" hash="255595ec01a16906dd0c49faf67d9efb"/><dir name="MerchantAccount"><file name="AddressDetails.php" hash="1d265d864a884ebcf2504f55207cc0dd"/><file name="BusinessDetails.php" hash="c9ae627c4a4b526c2ecb0c07d70b3017"/><file name="FundingDetails.php" hash="7368f653fcbcc3d87924447b1763e616"/><file name="IndividualDetails.php" hash="68daf00759335cde82f176f0844e0d9b"/></dir><file name="MerchantAccount.php" hash="489844cfd91dcc6a53024af97b85f3c7"/><file name="MerchantAccountGateway.php" hash="6a9033758b8c02501fd835a96fc385b7"/><file name="Modification.php" hash="fcce6784af2e658affe4a67ca75d8230"/><file name="MultipleValueNode.php" hash="92700fa03011eaa9561010b3a160449c"/><file name="MultipleValueOrTextNode.php" hash="ef06bac18e2bc40974bdc0bcb854890f"/><file name="PartialMatchNode.php" hash="370c7e0ab8a445cfeef6b19ef1755f4d"/><file name="PartnerMerchant.php" hash="20c87322d040eac1abcdf12b8838ec1c"/><file name="PayPalAccount.php" hash="1bbe86a33bbf3e3620364ba0c2e9b6fe"/><file name="PayPalAccountGateway.php" hash="bdf94548085765927368c49bcf028f47"/><file name="PaymentInstrumentType.php" hash="84e2d2fcfe45cf7cf188dc46f302fac8"/><file name="PaymentMethod.php" hash="8aca88278367fcbd5404a0abae848a45"/><file name="PaymentMethodGateway.php" hash="ed81d66dcb097021c4f6518b9ea5e5cf"/><file name="PaymentMethodNonce.php" hash="a72e8ed6506327cdac92d8b082e4dd74"/><file name="PaymentMethodNonceGateway.php" hash="e8ee61d15b73bd2ef9efef8a6b5f4132"/><file name="Plan.php" hash="f73f24fcc57cfeb2e6f0e6312e531073"/><file name="PlanGateway.php" hash="8392fc6b714b30d16fe0308a1e81db4f"/><file name="RangeNode.php" hash="4ad9a92547423b3d54d69097114c3daf"/><file name="ResourceCollection.php" hash="8f437cb5014148c0e2f6049347ae795c"/><dir name="Result"><file name="CreditCardVerification.php" hash="27b965f1e197b0392879e24cccf6dd9c"/><file name="Error.php" hash="81b616e25f182c0c571ad4e9e6fbc611"/><file name="Successful.php" hash="56c6f9a3e5996d18e01a8d382cc03cde"/></dir><file name="RiskData.php" hash="dd74658f351fe8af26cee3016a076fb9"/><file name="SettlementBatchSummary.php" hash="0dcc2b5dd7071d9037cf5970fafe8668"/><file name="SettlementBatchSummaryGateway.php" hash="4ec1a7a1c8875693123430aa51410b22"/><file name="SignatureService.php" hash="4b78d3e5897e715dcc877c5f65b3cfae"/><dir name="Subscription"><file name="StatusDetails.php" hash="29e375f02150bfd7147591f0eb27cb4f"/></dir><file name="Subscription.php" hash="96db82b5b67a72d4287d79b7c691b3d7"/><file name="SubscriptionGateway.php" hash="34118ee95b83d8904a47b388cbb8cfea"/><file name="SubscriptionSearch.php" hash="1874ebe5cb42d7d2836617810cced1af"/><dir name="Test"><file name="CreditCardNumbers.php" hash="676a9100354eb679e7ca1e0f0d67293f"/><file name="MerchantAccount.php" hash="612e7e30cca364c0d14cbff3b54ebf3f"/><file name="Nonces.php" hash="89bb29ef4552037973fe04d344f657ef"/><file name="TransactionAmounts.php" hash="ed9bf1f57d871542c32d11de9e031f05"/><file name="VenmoSdk.php" hash="6ce94deccd1f968596011487c7e69cc7"/></dir><file name="TextNode.php" hash="94c95ec9645de57acace2179fef7fb43"/><dir name="Transaction"><file name="AddressDetails.php" hash="ff52a4a48248085b7ea92e992160e413"/><file name="ApplePayCardDetails.php" hash="c4dd87cd46fe7269e1bd51c867adf7cb"/><file name="CoinbaseDetails.php" hash="d19a625f8de98698b8277c25660358f0"/><file name="CreditCardDetails.php" hash="aac5eb1f5804d4f979b9c71f7b98cb36"/><file name="CustomerDetails.php" hash="e137895c646127312be44292c84a2d81"/><file name="PayPalDetails.php" hash="ede299e376bce7714838d79ca3d40842"/><file name="StatusDetails.php" hash="7c6e719c51bf13bdfd07615030100ac6"/><file name="SubscriptionDetails.php" hash="1cf1f511d1545a2e27b8d3f4bee800ca"/></dir><file name="Transaction.php" hash="9970a0fa9d6af3e543703426da99a3c4"/><file name="TransactionGateway.php" hash="37500b8a181a18375c171d4a5a4938c6"/><file name="TransactionSearch.php" hash="41dd086066fa57582161032249b3d8ee"/><file name="TransparentRedirect.php" hash="154c9850be5175a5cd1b35bdf78ae939"/><file name="TransparentRedirectGateway.php" hash="89f002df5a2abafcaa9676a3e2935c75"/><file name="UnknownPaymentMethod.php" hash="811394ea4bee98a651dc5e1cba8223da"/><file name="Util.php" hash="2cf47c3acd49da4a6c2b0a9a55701d7b"/><file name="Version.php" hash="1ebf13fcec95da846f917f74e030714b"/><file name="WebhookNotification.php" hash="f58be59156e5728f491da4235a58e994"/><file name="WebhookTesting.php" hash="c40311458bb64e37b4c08eb88df37805"/><dir name="Xml"><file name="Generator.php" hash="f82af40e5759c3d46909f3dec2498d02"/><file name="Parser.php" hash="4e6df3327a04915715333460733df93c"/></dir><file name="Xml.php" hash="dc69e05bea21e3d1185d45d53e4747db"/></dir><dir name="."><file name="Braintree.php" hash="ee3e665877882e5b5076ff51dc8111bd"/></dir><dir name="ssl"><file name="api_braintreegateway_com.ca.crt" hash="04beb23c767547e980c76eb68c7eab15"/><file name="sandbox_braintreegateway_com.ca.crt" hash="f1b529883c7c2cbb4251658f5da7b4c9"/></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Gene_Braintree.csv" hash="00ae6dc359bc0d9c48bfc90a865232a3"/></dir></dir></target></contents>
42
  <compatible/>
43
  <dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php><package><name/><channel>connect.magentocommerce.com/core</channel><min/><max/></package></required></dependencies>
44
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Gene_Braintree</name>
4
+ <version>1.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/mit-license.php">MIT License</license>
7
  <channel>community</channel>
36
  &lt;/ul&gt;</description>
37
  <notes>Connect your Magento store to Braintree to accept Credit Cards &amp;amp; PayPal using V.Zero SDK</notes>
38
  <authors><author><name>Dave Macaulay</name><user>dave</user><email>magento@gene.co.uk</email></author></authors>
39
+ <date>2015-08-14</date>
40
+ <time>15:48:17</time>
41
+ <contents><target name="magecommunity"><dir name="Gene"><dir name="Braintree"><dir name="Block"><dir name="Adminhtml"><dir name="Report"><dir name="Transactions"><file name="Grid.php" hash="32b32086548f62ae4aca4baf456b9ed2"/><file name="Search.php" hash="81d57c3744530f36c37782ce9d0f3a70"/></dir><file name="Transactions.php" hash="7afe45b49353e52b432aa0392d76a08e"/></dir><dir name="System"><dir name="Config"><dir name="Braintree"><file name="Config.php" hash="eaaf6c74be4233a315d5aa5932f7c9ca"/><file name="Currency.php" hash="9ffa8a2ded53be75e88a60a024883b07"/><file name="Moduleversion.php" hash="fe3836bde24bb31c4c4585f2cd2f20ed"/><file name="Version.php" hash="ce58278a4faf965301cc2d8b2da4483c"/></dir></dir></dir></dir><dir name="Cart"><file name="Totals.php" hash="a03c441e8143896f92d02931a809f666"/></dir><dir name="Creditcard"><file name="Info.php" hash="8050c4c5321535fe93e62b47eab97b82"/><file name="Threedsecure.php" hash="7848d4ecac743be985f328fa969318bf"/></dir><file name="Creditcard.php" hash="989678324ff3fcddcc99cbe4613019fa"/><file name="Info.php" hash="2a8367489959ba9c1de4fe4c9afa62e4"/><file name="Js.php" hash="50cdd6d01eddfbdcc0061f4369cbeb58"/><dir name="Paypal"><file name="Info.php" hash="0874c0839a27c14ec9be47fed152e880"/></dir><file name="Paypal.php" hash="36294a461378cceee66e99d45753c6e1"/><file name="Saved.php" hash="74ed8e70a404a814b94f21f88c1ca737"/></dir><dir name="Helper"><file name="Data.php" hash="7ab1dba0f90dc067f0293e3f34bdf387"/></dir><dir name="Model"><file name="Debug.php" hash="f3360f71e2346881f93424792ed9f209"/><file name="Observer.php" hash="7d312de6cfb4c1683493a5a085260a7a"/><dir name="Paymentmethod"><file name="Abstract.php" hash="f6f818eb5720ceee4e43cff281209a88"/><file name="Creditcard.php" hash="c0c1307ada89f675ff97b96412205615"/><file name="Paypal.php" hash="6523279bdc21c8b047d85b99d251a26a"/></dir><file name="Saved.php" hash="3b235b454a3692d1c3d5343e2a1c91e9"/><dir name="Source"><file name="Cctype.php" hash="d76aa6c3a4bd798e3a47695f579d21d4"/><dir name="Creditcard"><file name="CaptureAction.php" hash="6444cfc430de44f06e85bd9c8b80d77b"/><file name="PaymentAction.php" hash="a2f3f3d36a98df4d12f76b6ab77f9c47"/></dir><file name="Environment.php" hash="02567d2ddba74d06ac000b4ddb12723a"/><dir name="Paypal"><file name="Locale.php" hash="8988ca77f9c2aa2d19ff0b614a4b7621"/><file name="Paymenttype.php" hash="fe1fe4ee89d5b7a87c7c28716bb2f1cb"/></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Currency.php" hash="73cb15b1de303e88c487db4c585ef94e"/></dir></dir></dir><dir name="Wrapper"><file name="Braintree.php" hash="b176325a312062bcf82127aef2da546a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="BraintreeController.php" hash="7c621fa1548c04e24bb1136bcbbe1d72"/></dir><file name="CheckoutController.php" hash="19551187f161f5df4e49a9a009c0adaf"/><file name="SavedController.php" hash="036e97703c853a5bae064dd7cf5030a8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="c9c940beffa0ec19e4a1499a66f7fd12"/><file name="config.xml" hash="0c8baa0bab1a100d1ffd2d97307a2a0a"/><file name="system.xml" hash="01fc95e2c590d2fad81b007e361cfa63"/></dir><dir name="sql"><dir name="gene_braintree_setup"><file name="install-0.1.0.php" hash="7ef62b7c19b9da5990974da6edb3e77c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="gene"><file name="braintree.xml" hash="e1b91850fd2e5d630679417f08f3ac91"/></dir></dir><dir name="template"><dir name="gene"><dir name="braintree"><dir name="creditcard"><file name="info.phtml" hash="2ae1e397b3a633dd305bc26c7b9c1065"/><file name="threedsecure.phtml" hash="ee8ad689afde041c39dd92ffa5274883"/></dir><file name="creditcard.phtml" hash="281f2fe022232deda152d2a625f2a532"/><dir name="customer"><file name="methods.phtml" hash="eb5e2d8f4a0f419fcf720c12062f808a"/><file name="saved.phtml" hash="691162b89ed085599f76072226ca2307"/></dir><dir name="js"><file name="aheadworks.phtml" hash="6672a0897c08e4e8344f40df7006e7a4"/><file name="amasty.phtml" hash="d8a4f779eb6c40c87982a53cc6d4519b"/><file name="data.phtml" hash="2d575380d05455c6eae90d3644b525dc"/><file name="default.phtml" hash="c1099fa33d538f65481caf984368ddbf"/><file name="idev.phtml" hash="6cc487985b26f29203016c6ccfc7286a"/><file name="iwd.phtml" hash="26d78161949bed430156eaf45d3b8e7a"/><file name="magestore.phtml" hash="4371f4898cc6e01eceb1acdff7327672"/><file name="setup.phtml" hash="5d15d864c0fe783061679716273d4300"/></dir><dir name="paypal"><file name="info.phtml" hash="5149b273730121e4dec3c3179820f747"/></dir><file name="paypal.phtml" hash="4280fcf89509eb959171f2214779de35"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="gene"><file name="braintree.xml" hash="1995e85eb47b909120ce8b9b537bf5db"/></dir></dir><dir name="template"><dir name="gene"><dir name="braintree"><dir name="creditcard"><file name="info.phtml" hash="24c67bab482ea7383ce57d9a06bb9d6f"/></dir><file name="creditcard.phtml" hash="0c6b7806732c336ead14fab596f1b923"/><file name="js.phtml" hash="0f3e0b631726c2faf9b119beb2f2ffc6"/><dir name="paypal"><file name="info.phtml" hash="a8f92f312f8aa5a9463f1d5c2a38cd1b"/></dir><dir name="transactions"><file name="index.phtml" hash="1791b6393f319616dd79c0b46e391847"/><file name="search.phtml" hash="1682ce6200681681f0ce3c848e2e6694"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gene_Braintree.xml" hash="8c0ffda8566dca2f0b98a999921e3e55"/></dir></target><target name="mageweb"><dir name="js"><dir name="gene"><dir name="braintree"><file name="braintree.js" hash="4a074b2952d6e3c0052f85442b284abc"/><file name="vzero.js" hash="0ea7d83df34c94eae8fa9d1c112d6824"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="gene"><dir name="braintree"><file name="AE.png" hash="6b6f405105413b0723a62ee498f88bf6"/><file name="DI.png" hash="d8e3c3022dda9e723f466b8976ae428f"/><file name="JCB.png" hash="3aa9a71ed8a1d6610bbe0dfe2040e29e"/><file name="MC.png" hash="1fcd14928245139962b72f9368bdbe32"/><file name="ME.png" hash="b9389913c47b9546a67f907fcca73706"/><file name="PP.png" hash="b4946bccba574e86c9716a4986e21c36"/><file name="VI.png" hash="c9f74d1d54e61ab2c748f45a4bdface0"/><file name="card.png" hash="66e16f8c573fad93bb0d62258dce28bb"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir><dir name="css"><dir name="gene"><dir name="braintree"><file name="aheadworks.css" hash="af097f350d4562bbb73c872da3d23909"/><file name="amasty.css" hash="7d7fdc2aec5ac9ce4e5028ae4801dd0b"/><file name="idev.css" hash="281ace41595b904a80836d938ee7d28b"/><file name="iwd.css" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="magestore.css" hash="b5190c300305e2e85623b2e7ba23b025"/></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Braintree"><file name="AddOn.php" hash="e8bbb6db343ba99192346b1dcbf45677"/><file name="AddOnGateway.php" hash="d8698ffe89c01fba78a8a06a2fc68122"/><file name="Address.php" hash="004d3d36d39fc6fcc3d510f4b15b1fca"/><file name="AddressGateway.php" hash="41b5a3be7bdb2fe326a49a1554e1b0c3"/><file name="AndroidPayCard.php" hash="7a1de1da0aa0733277a87b75307bb201"/><file name="ApplePayCard.php" hash="06eea10b110792c18d692e482445ffe4"/><file name="Base.php" hash="60d52fd1bef5655bcb607fba45bb4c1c"/><file name="ClientToken.php" hash="358c0a1dba687baf635db818cb7d1dac"/><file name="ClientTokenGateway.php" hash="6f2259a51415a779a072719288811c16"/><file name="CoinbaseAccount.php" hash="ee5cb6963f675a9a71293c453b128866"/><file name="Collection.php" hash="0e7d31ffcbd9780fb554186bd2c194b0"/><file name="Configuration.php" hash="cce5e6b7e215c73767127d3d8441cc8f"/><file name="CredentialsParser.php" hash="c4bb2248a33129d8523a6120ce44108b"/><file name="CreditCard.php" hash="d32b8d8e64b2d046d3d9e4f00c67f1ed"/><file name="CreditCardGateway.php" hash="0d120ed06f06fd614468d6e3f0ad22d2"/><file name="CreditCardVerification.php" hash="48d6ea546914278f4bea2fefb75e7836"/><file name="CreditCardVerificationGateway.php" hash="6a07430c9437f6e6c1516d5b4572a749"/><file name="CreditCardVerificationSearch.php" hash="18efe7d508c2bd5fea1c0e68fc26182f"/><file name="Customer.php" hash="62d0937de86f7a14a512ad66edba7569"/><file name="CustomerGateway.php" hash="1232a22dd6de6ad1446c6fbb9b0f79c3"/><file name="CustomerSearch.php" hash="8aacc83dac341cd9afec5a3deab17593"/><file name="Descriptor.php" hash="3f5db5e817280ce7f2fa18a205281ad9"/><file name="Digest.php" hash="9d12d067770f55b123b8498fce4478fa"/><file name="Disbursement.php" hash="ad122f0f33b27dfd98bcdd38ea138ae4"/><file name="DisbursementDetails.php" hash="ae632207d0982e288a83aed401c880d9"/><file name="Discount.php" hash="763b3f9cde0ff3af3e8795cac4097595"/><file name="DiscountGateway.php" hash="47796edb8ac2fa68e9af8fb8a13aacb1"/><dir name="Dispute"><file name="TransactionDetails.php" hash="7fdea673a1295055508f42286ad57f4e"/></dir><file name="Dispute.php" hash="c3a4e93fa2b3b0e20ddcb593dcdc7b2b"/><file name="EqualityNode.php" hash="cfd6aa184186233b8d6d1ec0f0e79298"/><dir name="Error"><file name="Codes.php" hash="a7f98ff690e725b7fcd198b4b22d0637"/><file name="ErrorCollection.php" hash="e28d638db56524f5bf3609fa725e6d55"/><file name="Validation.php" hash="bf4e2198300019c52ba56f16269d66ce"/><file name="ValidationErrorCollection.php" hash="9ef25d0126a0b4f6951da5334ae6f0dc"/></dir><dir name="Exception"><file name="Authentication.php" hash="f9e13654988452cca2ac5228a80adae4"/><file name="Authorization.php" hash="5f8c017c6e9fd79a556dade8e15a72e8"/><file name="Configuration.php" hash="b50f67e8ea36cff0d9f6ad718126c6fc"/><file name="DownForMaintenance.php" hash="7fd30b1f8976ed7e38b7e9fae5c20f03"/><file name="ForgedQueryString.php" hash="6884dbae1e86767834b77c821df2db62"/><file name="InvalidChallenge.php" hash="1c283a1c9dac65feb137594d0dcf0e35"/><file name="InvalidSignature.php" hash="b83f5b16735cb3a8e0a8111c4f32711e"/><file name="NotFound.php" hash="f832f771d20b381c2780eb2a572b9f44"/><file name="SSLCaFileNotFound.php" hash="e927c7307bf1761814dc8a755238070d"/><file name="SSLCertificate.php" hash="d509b6a6206bd7c5563ac142dfe3801f"/><file name="ServerError.php" hash="b4645290229ab228a257047d08ef63d7"/><file name="Unexpected.php" hash="01ea2800fb91995ec2a15aee5024611e"/><file name="UpgradeRequired.php" hash="7f40b174df891cc3b3e206d1be884a58"/><file name="ValidationsFailed.php" hash="cd2d30c69911f81b55279c3d6bf88c61"/></dir><file name="Exception.php" hash="f14c94bf67206184eb3e4e7aeb4a608a"/><file name="Gateway.php" hash="103156f5646a8193ed548405f5ac476f"/><file name="Http.php" hash="1baa32e0efcae13c4d6294d1233512a1"/><file name="Instance.php" hash="f0603b3f9213b53687e079c5621ac8f3"/><file name="IsNode.php" hash="e4b1f7bbfcbd24b1d08b97f94df592be"/><file name="KeyValueNode.php" hash="255595ec01a16906dd0c49faf67d9efb"/><file name="Merchant.php" hash="5053ebe889c854d11f2686bffdeb58be"/><dir name="MerchantAccount"><file name="AddressDetails.php" hash="1d265d864a884ebcf2504f55207cc0dd"/><file name="BusinessDetails.php" hash="3e80148bac9fda676844aa19d5b2dc28"/><file name="FundingDetails.php" hash="7368f653fcbcc3d87924447b1763e616"/><file name="IndividualDetails.php" hash="777b6f28f643e78616c7ed753a39c0cd"/></dir><file name="MerchantAccount.php" hash="496c93182d824bb2967cc9366dec1ac3"/><file name="MerchantAccountGateway.php" hash="e2073aff6f8b3c5f2e64b23b210c44f7"/><file name="MerchantGateway.php" hash="e0a2e3a28c68dac8bd082973b269ed1b"/><file name="Modification.php" hash="0abe992d4f821327f617ca883c4eb2d1"/><file name="MultipleValueNode.php" hash="92700fa03011eaa9561010b3a160449c"/><file name="MultipleValueOrTextNode.php" hash="ef06bac18e2bc40974bdc0bcb854890f"/><file name="OAuthCredentials.php" hash="e992dca9dfedb27e3d050af55971a968"/><file name="OAuthGateway.php" hash="e2e238d067f43c0f28fcb25c2de4a274"/><file name="PartialMatchNode.php" hash="370c7e0ab8a445cfeef6b19ef1755f4d"/><file name="PartnerMerchant.php" hash="bdb69ebdc75d67009710be9703a47e80"/><file name="PayPalAccount.php" hash="672a7d424f94e590c5e66a21e62d7bc2"/><file name="PayPalAccountGateway.php" hash="d73f5744ebaca6cc882c42d0e9c1a05e"/><file name="PaymentInstrumentType.php" hash="be97a30c7d8fbbb180864dc4efea71f2"/><file name="PaymentMethod.php" hash="5bc31d3e97610e7218c95aba2422cc9a"/><file name="PaymentMethodGateway.php" hash="1ce13a8b1ec93cf32b8029c55ea26fa2"/><file name="PaymentMethodNonce.php" hash="e99302e2468f55c8fb4b2ceeb1bce68e"/><file name="PaymentMethodNonceGateway.php" hash="22a0d89eee071a28b530c6be477dcc6e"/><file name="Plan.php" hash="22ab0117d462352aecb9531d4a26619e"/><file name="PlanGateway.php" hash="95e093b55ad20f8b652ee5f2fc2a0fcf"/><file name="RangeNode.php" hash="4ad9a92547423b3d54d69097114c3daf"/><file name="ResourceCollection.php" hash="8f437cb5014148c0e2f6049347ae795c"/><dir name="Result"><file name="CreditCardVerification.php" hash="7c41787025ec7cffb269f53e3ce479e2"/><file name="Error.php" hash="0e0460f1eea017bc7591e05351f51eb0"/><file name="Successful.php" hash="03f1c379fcedaef499296ab7778d1e36"/></dir><file name="RiskData.php" hash="8bef1074f9f1c50c841a7c7cf627c9cf"/><file name="SettlementBatchSummary.php" hash="388d88e8cea7bec61ee78f388fb78c2c"/><file name="SettlementBatchSummaryGateway.php" hash="bc54658b75fa0505e072331799c2d9ad"/><file name="SignatureService.php" hash="4b78d3e5897e715dcc877c5f65b3cfae"/><dir name="Subscription"><file name="StatusDetails.php" hash="29e375f02150bfd7147591f0eb27cb4f"/></dir><file name="Subscription.php" hash="cde05aa61192d5b930b57330db308835"/><file name="SubscriptionGateway.php" hash="bd1b2aa2d4d41a595463bead64ed34e0"/><file name="SubscriptionSearch.php" hash="1874ebe5cb42d7d2836617810cced1af"/><dir name="Test"><file name="CreditCardNumbers.php" hash="676a9100354eb679e7ca1e0f0d67293f"/><file name="MerchantAccount.php" hash="612e7e30cca364c0d14cbff3b54ebf3f"/><file name="Nonces.php" hash="230dc3687abaf95e9f516573b1836f4a"/><file name="TransactionAmounts.php" hash="ed9bf1f57d871542c32d11de9e031f05"/><file name="VenmoSdk.php" hash="6ce94deccd1f968596011487c7e69cc7"/></dir><file name="TextNode.php" hash="94c95ec9645de57acace2179fef7fb43"/><file name="ThreeDSecureInfo.php" hash="542550c4e03a24551d00e8aad5493035"/><dir name="Transaction"><file name="AddressDetails.php" hash="ff52a4a48248085b7ea92e992160e413"/><file name="AndroidPayCardDetails.php" hash="4dab3acc0cc35b5a6f12f95004074374"/><file name="ApplePayCardDetails.php" hash="c4dd87cd46fe7269e1bd51c867adf7cb"/><file name="CoinbaseDetails.php" hash="d19a625f8de98698b8277c25660358f0"/><file name="CreditCardDetails.php" hash="aac5eb1f5804d4f979b9c71f7b98cb36"/><file name="CustomerDetails.php" hash="e137895c646127312be44292c84a2d81"/><file name="PayPalDetails.php" hash="ede299e376bce7714838d79ca3d40842"/><file name="StatusDetails.php" hash="7c6e719c51bf13bdfd07615030100ac6"/><file name="SubscriptionDetails.php" hash="1cf1f511d1545a2e27b8d3f4bee800ca"/></dir><file name="Transaction.php" hash="09b9e7a574d304e9edebe578173f2994"/><file name="TransactionGateway.php" hash="4282d7497100c26afcd709fd77eae0bd"/><file name="TransactionSearch.php" hash="3101c79514520a1a500e4623f4ca1c32"/><file name="TransparentRedirect.php" hash="154c9850be5175a5cd1b35bdf78ae939"/><file name="TransparentRedirectGateway.php" hash="5ead181bf0d5484db5eb305efa13bec4"/><file name="UnknownPaymentMethod.php" hash="9107498774ab5bc2b25de98838736b47"/><file name="Util.php" hash="9832a44da18b97a55248cadc4bb9a4ad"/><file name="Version.php" hash="2f088b43efe46edb3262b89b7d40d051"/><file name="WebhookNotification.php" hash="4097fb57d46368d903c42bb20fbd49ca"/><file name="WebhookTesting.php" hash="c40311458bb64e37b4c08eb88df37805"/><dir name="Xml"><file name="Generator.php" hash="19f9c9b9b61d4f97f65775f527ac408d"/><file name="Parser.php" hash="c06b1ae155ac7687eaa856fac472656d"/></dir><file name="Xml.php" hash="dc69e05bea21e3d1185d45d53e4747db"/></dir><dir name="."><file name="Braintree.php" hash="424b8ccb072fda0ddf3459be6279734a"/></dir><dir name="ssl"><file name="api_braintreegateway_com.ca.crt" hash="04beb23c767547e980c76eb68c7eab15"/><file name="sandbox_braintreegateway_com.ca.crt" hash="f1b529883c7c2cbb4251658f5da7b4c9"/></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Gene_Braintree.csv" hash="00ae6dc359bc0d9c48bfc90a865232a3"/></dir></dir></target></contents>
42
  <compatible/>
43
  <dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php><package><name/><channel>connect.magentocommerce.com/core</channel><min/><max/></package></required></dependencies>
44
  </package>
skin/frontend/base/default/css/gene/braintree/aheadworks.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /* This checkout extension has lots of fixed widths, leaving styling as default */
2
+
3
+ #paypal-complete {
4
+ position: relative;
5
+ background: #fbfaf6;
6
+ text-align: center;
7
+ z-index: 6;
8
+ }
9
+ #paypal-complete label {
10
+ margin-bottom: 8px;
11
+ }
skin/frontend/base/default/css/gene/braintree/amasty.css ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ #paypal-label {
2
+ line-height: 44px;
3
+ float: left;
4
+ margin-right: 12px;
5
+ }
6
+
7
+ #creditcard-saved-accounts td {
8
+ vertical-align: middle;
9
+ }
skin/frontend/base/default/css/gene/braintree/idev.css ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ #credit-card-form .form-list {
2
+ margin: 10px 0 0 0!important;
3
+ padding: 0!important;
4
+ border: 0!important;
5
+ }
6
+ #credit-card-form .form-list:before, #credit-card-form .form-list:after {
7
+ border: 0!important;
8
+ }
skin/frontend/base/default/css/gene/braintree/iwd.css ADDED
File without changes
skin/frontend/base/default/css/gene/braintree/magestore.css ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #paypal-complete {
2
+ padding: 20px 0;
3
+ }
4
+ #paypal-complete label {
5
+ margin-right: 16px;
6
+ }
7
+ #braintree-paypal-button {
8
+ line-height: unset;
9
+ padding: 0;
10
+ float: left;
11
+ }
12
+ .one-step-checkout .input-text[name="payment[cc_number]"] {
13
+ height: 46px!important;
14
+ text-indent: 56px!important;
15
+ }
16
+
17
+ .saved-cards-intro {
18
+ float: left;
19
+ }
20
+
21
+ #creditcard-saved-accounts .saved-card-number {
22
+ float: left;
23
+ }
24
+ #creditcard-saved-accounts .saved-expiry-date {
25
+ float: right;
26
+ display: block;
27
+ font-weight: normal;
28
+ }
29
+
30
+ #credit-card-form {
31
+ padding-bottom: 12px;
32
+ float: left;
33
+ }
34
+ #credit-card-form .form-list, #payment_form_gene_braintree_creditcard {
35
+ width: 100%;
36
+ padding: 0;
37
+ }
38
+ #credit-card-form label {
39
+ margin-top: 8px;
40
+ }
41
+ #credit-card-form #gene_braintree_creditcard_store_in_vault_div {
42
+ float: left;
43
+ }