Simple Membership - Version 3.3.9

Version Description

  • Deleted the Spanish language files from the plugin folder so it can pull the language from translate.wordpress.org
  • WordPress 4.7 compatibility.
  • Regenerated the POT file.
  • The after login redirection now uses home_url() instead of site_url(). The URL also gets passed via a filter.
  • Added a new filter for the after logout redirection URL.
  • Renamed the swpm-ja_JP language filename to swpmp-ja
  • Added the Braintree payment gateway so you can accept membership payments using Braintree. Details in the following documentation: https://simple-membership-plugin.com/create-braintree-buy-now-button-for-membership-payment/
Download this release

Release Info

Developer mra13
Plugin Icon 128x128 Simple Membership
Version 3.3.9
Comparing to
See all releases

Code changes from version 3.3.8 to 3.3.9

Files changed (158) hide show
  1. classes/class.simple-wp-membership.php +4 -3
  2. classes/class.swpm-init-time-tasks.php +9 -2
  3. classes/shortcode-related/class.swpm-shortcodes-handler.php +1 -0
  4. ipn/swpm-braintree-buy-now-ipn.php +143 -0
  5. languages/swpm-es_ES.mo +0 -0
  6. languages/swpm-es_ES.po +0 -1322
  7. languages/{swpm-ja_JP.mo → swpm-ja.mo} +0 -0
  8. languages/{swpm-ja_JP.po → swpm-ja.po} +0 -0
  9. languages/swpm.pot +186 -127
  10. lib/braintree/index.html +0 -0
  11. lib/braintree/lib/Braintree.php +25 -0
  12. lib/braintree/lib/Braintree/AccountUpdaterDailyReport.php +45 -0
  13. lib/braintree/lib/Braintree/AddOn.php +29 -0
  14. lib/braintree/lib/Braintree/AddOnGateway.php +53 -0
  15. lib/braintree/lib/Braintree/Address.php +151 -0
  16. lib/braintree/lib/Braintree/AddressGateway.php +315 -0
  17. lib/braintree/lib/Braintree/AmexExpressCheckoutCard.php +81 -0
  18. lib/braintree/lib/Braintree/AndroidPayCard.php +90 -0
  19. lib/braintree/lib/Braintree/ApplePayCard.php +100 -0
  20. lib/braintree/lib/Braintree/Base.php +77 -0
  21. lib/braintree/lib/Braintree/ClientToken.php +49 -0
  22. lib/braintree/lib/Braintree/ClientTokenGateway.php +129 -0
  23. lib/braintree/lib/Braintree/CoinbaseAccount.php +112 -0
  24. lib/braintree/lib/Braintree/Collection.php +162 -0
  25. lib/braintree/lib/Braintree/Configuration.php +551 -0
  26. lib/braintree/lib/Braintree/CredentialsParser.php +148 -0
  27. lib/braintree/lib/Braintree/CreditCard.php +316 -0
  28. lib/braintree/lib/Braintree/CreditCardGateway.php +487 -0
  29. lib/braintree/lib/Braintree/CreditCardVerification.php +43 -0
  30. lib/braintree/lib/Braintree/CreditCardVerificationGateway.php +74 -0
  31. lib/braintree/lib/Braintree/CreditCardVerificationSearch.php +56 -0
  32. lib/braintree/lib/Braintree/Customer.php +405 -0
  33. lib/braintree/lib/Braintree/CustomerGateway.php +626 -0
  34. lib/braintree/lib/Braintree/CustomerSearch.php +34 -0
  35. lib/braintree/lib/Braintree/Descriptor.php +7 -0
  36. lib/braintree/lib/Braintree/Digest.php +62 -0
  37. lib/braintree/lib/Braintree/Disbursement.php +52 -0
  38. lib/braintree/lib/Braintree/DisbursementDetails.php +25 -0
  39. lib/braintree/lib/Braintree/Discount.php +21 -0
  40. lib/braintree/lib/Braintree/DiscountGateway.php +31 -0
  41. lib/braintree/lib/Braintree/Dispute.php +82 -0
  42. lib/braintree/lib/Braintree/Dispute/TransactionDetails.php +27 -0
  43. lib/braintree/lib/Braintree/EqualityNode.php +12 -0
  44. lib/braintree/lib/Braintree/Error/Codes.php +523 -0
  45. lib/braintree/lib/Braintree/Error/ErrorCollection.php +124 -0
  46. lib/braintree/lib/Braintree/Error/Validation.php +61 -0
  47. lib/braintree/lib/Braintree/Error/ValidationErrorCollection.php +132 -0
  48. lib/braintree/lib/Braintree/EuropeBankAccount.php +68 -0
  49. lib/braintree/lib/Braintree/Exception.php +14 -0
  50. lib/braintree/lib/Braintree/Exception/Authentication.php +18 -0
  51. lib/braintree/lib/Braintree/Exception/Authorization.php +20 -0
  52. lib/braintree/lib/Braintree/Exception/Configuration.php +17 -0
  53. lib/braintree/lib/Braintree/Exception/DownForMaintenance.php +17 -0
  54. lib/braintree/lib/Braintree/Exception/ForgedQueryString.php +21 -0
  55. lib/braintree/lib/Braintree/Exception/InvalidChallenge.php +9 -0
  56. lib/braintree/lib/Braintree/Exception/InvalidSignature.php +9 -0
  57. lib/braintree/lib/Braintree/Exception/NotFound.php +17 -0
  58. lib/braintree/lib/Braintree/Exception/SSLCaFileNotFound.php +17 -0
  59. lib/braintree/lib/Braintree/Exception/SSLCertificate.php +17 -0
  60. lib/braintree/lib/Braintree/Exception/ServerError.php +17 -0
  61. lib/braintree/lib/Braintree/Exception/TestOperationPerformedInProduction.php +16 -0
  62. lib/braintree/lib/Braintree/Exception/Timeout.php +17 -0
  63. lib/braintree/lib/Braintree/Exception/TooManyRequests.php +17 -0
  64. lib/braintree/lib/Braintree/Exception/Unexpected.php +18 -0
  65. lib/braintree/lib/Braintree/Exception/UpgradeRequired.php +17 -0
  66. lib/braintree/lib/Braintree/Exception/ValidationsFailed.php +17 -0
  67. lib/braintree/lib/Braintree/FacilitatorDetails.php +30 -0
  68. lib/braintree/lib/Braintree/Gateway.php +208 -0
  69. lib/braintree/lib/Braintree/Http.php +193 -0
  70. lib/braintree/lib/Braintree/Instance.php +75 -0
  71. lib/braintree/lib/Braintree/IsNode.php +24 -0
  72. lib/braintree/lib/Braintree/KeyValueNode.php +23 -0
  73. lib/braintree/lib/Braintree/Merchant.php +36 -0
  74. lib/braintree/lib/Braintree/MerchantAccount.php +64 -0
  75. lib/braintree/lib/Braintree/MerchantAccount/AddressDetails.php +10 -0
  76. lib/braintree/lib/Braintree/MerchantAccount/BusinessDetails.php +23 -0
  77. lib/braintree/lib/Braintree/MerchantAccount/FundingDetails.php +10 -0
  78. lib/braintree/lib/Braintree/MerchantAccount/IndividualDetails.php +23 -0
  79. lib/braintree/lib/Braintree/MerchantAccountGateway.php +154 -0
  80. lib/braintree/lib/Braintree/MerchantGateway.php +42 -0
  81. lib/braintree/lib/Braintree/Modification.php +22 -0
  82. lib/braintree/lib/Braintree/MultipleValueNode.php +41 -0
  83. lib/braintree/lib/Braintree/MultipleValueOrTextNode.php +47 -0
  84. lib/braintree/lib/Braintree/OAuthCredentials.php +36 -0
  85. lib/braintree/lib/Braintree/OAuthGateway.php +123 -0
  86. lib/braintree/lib/Braintree/OAuthResult.php +36 -0
  87. lib/braintree/lib/Braintree/PartialMatchNode.php +18 -0
  88. lib/braintree/lib/Braintree/PartnerMerchant.php +42 -0
  89. lib/braintree/lib/Braintree/PayPalAccount.php +111 -0
  90. lib/braintree/lib/Braintree/PayPalAccountGateway.php +180 -0
  91. lib/braintree/lib/Braintree/PaymentInstrumentType.php +15 -0
  92. lib/braintree/lib/Braintree/PaymentMethod.php +47 -0
  93. lib/braintree/lib/Braintree/PaymentMethodGateway.php +309 -0
  94. lib/braintree/lib/Braintree/PaymentMethodNonce.php +55 -0
  95. lib/braintree/lib/Braintree/PaymentMethodNonceGateway.php +67 -0
  96. lib/braintree/lib/Braintree/Plan.php +51 -0
  97. lib/braintree/lib/Braintree/PlanGateway.php +34 -0
  98. lib/braintree/lib/Braintree/RangeNode.php +40 -0
  99. lib/braintree/lib/Braintree/ResourceCollection.php +157 -0
  100. lib/braintree/lib/Braintree/Result/CreditCardVerification.php +99 -0
  101. lib/braintree/lib/Braintree/Result/Error.php +124 -0
  102. lib/braintree/lib/Braintree/Result/Successful.php +93 -0
  103. lib/braintree/lib/Braintree/RiskData.php +30 -0
  104. lib/braintree/lib/Braintree/SettlementBatchSummary.php +45 -0
  105. lib/braintree/lib/Braintree/SettlementBatchSummaryGateway.php +106 -0
  106. lib/braintree/lib/Braintree/SignatureService.php +24 -0
  107. lib/braintree/lib/Braintree/Subscription.php +141 -0
  108. lib/braintree/lib/Braintree/Subscription/StatusDetails.php +25 -0
  109. lib/braintree/lib/Braintree/SubscriptionGateway.php +215 -0
  110. lib/braintree/lib/Braintree/SubscriptionSearch.php +72 -0
  111. lib/braintree/lib/Braintree/Test/CreditCardNumbers.php +76 -0
  112. lib/braintree/lib/Braintree/Test/MerchantAccount.php +22 -0
  113. lib/braintree/lib/Braintree/Test/Nonces.php +70 -0
  114. lib/braintree/lib/Braintree/Test/Transaction.php +64 -0
  115. lib/braintree/lib/Braintree/Test/TransactionAmounts.php +19 -0
  116. lib/braintree/lib/Braintree/Test/VenmoSdk.php +31 -0
  117. lib/braintree/lib/Braintree/TestingGateway.php +52 -0
  118. lib/braintree/lib/Braintree/TextNode.php +12 -0
  119. lib/braintree/lib/Braintree/ThreeDSecureInfo.php +30 -0
  120. lib/braintree/lib/Braintree/Transaction.php +570 -0
  121. lib/braintree/lib/Braintree/Transaction/AddressDetails.php +28 -0
  122. lib/braintree/lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php +45 -0
  123. lib/braintree/lib/Braintree/Transaction/AndroidPayCardDetails.php +49 -0
  124. lib/braintree/lib/Braintree/Transaction/ApplePayCardDetails.php +41 -0
  125. lib/braintree/lib/Braintree/Transaction/CoinbaseDetails.php +40 -0
  126. lib/braintree/lib/Braintree/Transaction/CreditCardDetails.php +39 -0
  127. lib/braintree/lib/Braintree/Transaction/CustomerDetails.php +26 -0
  128. lib/braintree/lib/Braintree/Transaction/EuropeBankAccountDetails.php +25 -0
  129. lib/braintree/lib/Braintree/Transaction/PayPalDetails.php +43 -0
  130. lib/braintree/lib/Braintree/Transaction/StatusDetails.php +22 -0
  131. lib/braintree/lib/Braintree/Transaction/SubscriptionDetails.php +20 -0
  132. lib/braintree/lib/Braintree/Transaction/UsBankAccountDetails.php +36 -0
  133. lib/braintree/lib/Braintree/Transaction/VenmoAccountDetails.php +40 -0
  134. lib/braintree/lib/Braintree/TransactionGateway.php +520 -0
  135. lib/braintree/lib/Braintree/TransactionSearch.php +130 -0
  136. lib/braintree/lib/Braintree/TransparentRedirect.php +101 -0
  137. lib/braintree/lib/Braintree/TransparentRedirectGateway.php +290 -0
  138. lib/braintree/lib/Braintree/UnknownPaymentMethod.php +71 -0
  139. lib/braintree/lib/Braintree/UsBankAccount.php +86 -0
  140. lib/braintree/lib/Braintree/UsBankAccountGateway.php +108 -0
  141. lib/braintree/lib/Braintree/Util.php +416 -0
  142. lib/braintree/lib/Braintree/VenmoAccount.php +75 -0
  143. lib/braintree/lib/Braintree/Version.php +36 -0
  144. lib/braintree/lib/Braintree/WebhookNotification.php +137 -0
  145. lib/braintree/lib/Braintree/WebhookTesting.php +391 -0
  146. lib/braintree/lib/Braintree/Xml.php +41 -0
  147. lib/braintree/lib/Braintree/Xml/Generator.php +153 -0
  148. lib/braintree/lib/Braintree/Xml/Parser.php +142 -0
  149. lib/braintree/lib/Braintree/index.html +0 -0
  150. lib/braintree/lib/autoload.php +21 -0
  151. lib/braintree/lib/index.html +0 -0
  152. lib/braintree/lib/ssl/api_braintreegateway_com.ca.crt +191 -0
  153. readme.txt +12 -2
  154. simple-wp-membership.php +2 -2
  155. views/payments/admin_create_payment_buttons.php +3 -0
  156. views/payments/admin_edit_payment_buttons.php +1 -0
  157. views/payments/payment-gateway/admin_braintree_buy_now_button.php +317 -0
  158. views/payments/payment-gateway/braintree_button_shortcode_view.php +129 -0
classes/class.simple-wp-membership.php CHANGED
@@ -62,7 +62,7 @@ class SimpleWpMembership {
62
  add_action('profile_update', array(&$this, 'sync_with_wp_profile'), 10, 2);
63
  add_action('wp_logout', array(&$this, 'wp_logout'));
64
  add_action('wp_authenticate', array(&$this, 'wp_login'), 1, 2);
65
- add_action('swpm_logout', array(&$this, 'swpm_logout'));
66
 
67
  //AJAX hooks
68
  add_action('wp_ajax_swpm_validate_email', 'SwpmAjax::validate_email_ajax');
@@ -207,12 +207,13 @@ class SimpleWpMembership {
207
  }
208
  do_action('swpm_after_login');
209
  if (!SwpmUtils::is_ajax()) {
210
- wp_redirect(site_url());
 
211
  exit(0);
212
  }
213
  }
214
 
215
- public function swpm_logout() {
216
  if (is_user_logged_in()) {
217
  wp_logout();
218
  wp_set_current_user(0);
62
  add_action('profile_update', array(&$this, 'sync_with_wp_profile'), 10, 2);
63
  add_action('wp_logout', array(&$this, 'wp_logout'));
64
  add_action('wp_authenticate', array(&$this, 'wp_login'), 1, 2);
65
+ add_action('swpm_logout', array(&$this, 'swpm_do_user_logout'));
66
 
67
  //AJAX hooks
68
  add_action('wp_ajax_swpm_validate_email', 'SwpmAjax::validate_email_ajax');
207
  }
208
  do_action('swpm_after_login');
209
  if (!SwpmUtils::is_ajax()) {
210
+ $redirect_url = apply_filters('swpm_after_login_redirect_url',SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL);
211
+ wp_redirect($redirect_url);
212
  exit(0);
213
  }
214
  }
215
 
216
+ public function swpm_do_user_logout() {
217
  if (is_user_logged_in()) {
218
  wp_logout();
219
  wp_set_current_user(0);
classes/class.swpm-init-time-tasks.php CHANGED
@@ -30,8 +30,8 @@ class SwpmInitTimeTasks {
30
  $swpm_logout = filter_input(INPUT_GET, 'swpm-logout');
31
  if (!empty($swpm_logout)) {
32
  SwpmAuth::get_instance()->logout();
33
- $home_url = home_url();
34
- wp_redirect(trailingslashit($home_url));
35
  exit(0);
36
  }
37
  $this->process_password_reset();
@@ -162,6 +162,13 @@ class SwpmInitTimeTasks {
162
  exit;
163
  }
164
 
 
 
 
 
 
 
 
165
  }
166
 
167
  }
30
  $swpm_logout = filter_input(INPUT_GET, 'swpm-logout');
31
  if (!empty($swpm_logout)) {
32
  SwpmAuth::get_instance()->logout();
33
+ $redirect_url = apply_filters('swpm_after_logout_redirect_url',SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL);
34
+ wp_redirect(trailingslashit($redirect_url));
35
  exit(0);
36
  }
37
  $this->process_password_reset();
162
  exit;
163
  }
164
 
165
+ //Listen and handle Braintree Buy Now IPN
166
+ $swpm_process_braintree_buy_now = filter_input(INPUT_GET, 'swpm_process_braintree_buy_now');
167
+ if ($swpm_process_braintree_buy_now == '1') {
168
+ include(SIMPLE_WP_MEMBERSHIP_PATH . 'ipn/swpm-braintree-buy-now-ipn.php');
169
+ exit;
170
+ }
171
+
172
  }
173
 
174
  }
classes/shortcode-related/class.swpm-shortcodes-handler.php CHANGED
@@ -34,6 +34,7 @@ class SwpmShortcodesHandler {
34
 
35
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/paypal_button_shortcode_view.php');
36
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/stripe_button_shortcode_view.php');
 
37
 
38
  $button_code = '';
39
  $button_code = apply_filters('swpm_payment_button_shortcode_for_' . $button_type, $button_code, $args);
34
 
35
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/paypal_button_shortcode_view.php');
36
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/stripe_button_shortcode_view.php');
37
+ include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/braintree_button_shortcode_view.php');
38
 
39
  $button_code = '';
40
  $button_code = apply_filters('swpm_payment_button_shortcode_for_' . $button_type, $button_code, $args);
ipn/swpm-braintree-buy-now-ipn.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ include(SIMPLE_WP_MEMBERSHIP_PATH . 'ipn/swpm_handle_subsc_ipn.php');
4
+
5
+ class SwpmBraintreeBuyNowIpnHandler {
6
+
7
+ public function __construct() {
8
+
9
+ $this->handle_braintree_ipn();
10
+ }
11
+
12
+ public function handle_braintree_ipn(){
13
+ SwpmLog::log_simple_debug("Braintree Buy Now IPN received. Processing request...", true);
14
+ //SwpmLog::log_simple_debug(print_r($_REQUEST, true), true);//Useful for debugging purpose
15
+
16
+ //Include the Braintree library.
17
+ require_once(SIMPLE_WP_MEMBERSHIP_PATH . 'lib/braintree/lib/autoload.php');
18
+
19
+ //Read and sanitize the request parameters.
20
+ $button_id = sanitize_text_field($_REQUEST['item_number']);
21
+ $button_id = absint($button_id);
22
+ $button_title = sanitize_text_field($_REQUEST['item_name']);
23
+ $payment_amount = sanitize_text_field($_REQUEST['item_price']);
24
+
25
+ //Retrieve the CPT for this button
26
+ $button_cpt = get_post($button_id);
27
+ if(!$button_cpt){
28
+ //Fatal error. Could not find this payment button post object.
29
+ SwpmLog::log_simple_debug("Fatal Error! Failed to retrieve the payment button post object for the given button ID: ". $button_id, false);
30
+ wp_die("Fatal Error! Payment button (ID: ".$button_id.") does not exist. This request will fail.");
31
+ }
32
+
33
+ $membership_level_id = get_post_meta($button_id, 'membership_level_id', true);
34
+
35
+ //Validate and verify some of the main values.
36
+ $true_payment_amount = get_post_meta($button_id, 'payment_amount', true);
37
+ if( $payment_amount != $true_payment_amount ) {
38
+ //Fatal error. Payment amount may have been tampered with.
39
+ $error_msg = 'Fatal Error! Received payment amount ('.$payment_amount.') does not match with the original amount ('.$true_payment_amount.')';
40
+ SwpmLog::log_simple_debug($error_msg, false);
41
+ wp_die($error_msg);
42
+ }
43
+
44
+ //Validation passed. Go ahead with the charge.
45
+
46
+ //Sandbox and other settings
47
+ $settings = SwpmSettings::get_instance();
48
+ $sandbox_enabled = $settings->get_value('enable-sandbox-testing');
49
+ if($sandbox_enabled){
50
+ SwpmLog::log_simple_debug("Sandbox payment mode is enabled. Using sandbox enviroment.", true);
51
+ $braintree_env="sandbox"; //Use sandbox environment
52
+ } else {
53
+ $braintree_env="production"; //Use production environment
54
+ }
55
+
56
+ //Set Braintree library environment and keys
57
+ try {
58
+ Braintree_Configuration::environment($braintree_env);
59
+ Braintree_Configuration::merchantId(get_post_meta($button_id, 'braintree_merchant_acc_id', true));
60
+ Braintree_Configuration::publicKey(get_post_meta($button_id, 'braintree_public_key', true));
61
+ Braintree_Configuration::privateKey(get_post_meta($button_id, 'braintree_private_key', true));
62
+
63
+ $braintree_merc_acc_name=get_post_meta($button_id, 'braintree_merchant_acc_name', true);
64
+
65
+
66
+ // Create the charge on Braintree's servers - this will charge the user's card
67
+
68
+ $result = Braintree_Transaction::sale([
69
+ 'amount' => $payment_amount,
70
+ 'paymentMethodNonce' => $_POST['payment_method_nonce'],
71
+ 'channel' => 'TipsandTricks_SP',
72
+ 'options' => [
73
+ 'submitForSettlement' => True
74
+ ],
75
+ 'merchantAccountId' => $braintree_merc_acc_name,
76
+ ]);
77
+ } catch (Exception $e) {
78
+ SwpmLog::log_simple_debug("Braintree library error occured: ".get_class($e).", button ID: ".$button_id, false);
79
+ wp_die('Braintree library error occured: '.get_class($e));
80
+ }
81
+
82
+ if (!$result->success) {
83
+ SwpmLog::log_simple_debug("Braintree transaction error occured: ".$result->transaction->status.", button ID: ".$button_id, false);
84
+ wp_die("Braintree transaction error occured: ".$result->transaction->status);
85
+ }
86
+ else {
87
+
88
+ //Everything went ahead smoothly with the charge.
89
+ SwpmLog::log_simple_debug("Braintree Buy Now charge successful.", true);
90
+
91
+ //Grab the transaction ID.
92
+ $txn_id = $result->transaction->id;//$charge->balance_transaction;
93
+
94
+ $custom = sanitize_text_field($_REQUEST['custom']);
95
+ $custom_var = SwpmTransactions::parse_custom_var($custom);
96
+ $swpm_id = isset($custom_var['swpm_id'])? $custom_var['swpm_id']: '';
97
+
98
+ //Create the $ipn_data array.
99
+ $ipn_data = array();
100
+ $ipn_data['mc_gross'] = $payment_amount;
101
+ $ipn_data['first_name'] = sanitize_text_field($_REQUEST['first_name']);
102
+ $ipn_data['last_name'] = sanitize_text_field($_REQUEST['last_name']);
103
+ $ipn_data['payer_email'] = sanitize_text_field($_REQUEST['member_email']);
104
+ $ipn_data['membership_level'] = $membership_level_id;
105
+ $ipn_data['txn_id'] = $txn_id;
106
+ $ipn_data['subscr_id'] = $txn_id;
107
+ $ipn_data['swpm_id'] = $swpm_id;
108
+ $ipn_data['ip'] = $custom_var['user_ip'];
109
+ $ipn_data['custom'] = $custom;
110
+ $ipn_data['gateway'] = 'braintree';
111
+ $ipn_data['status'] = 'completed';
112
+
113
+ $ipn_data['address_street'] = '';
114
+ $ipn_data['address_city'] = '';
115
+ $ipn_data['address_state'] = '';
116
+ $ipn_data['address_zipcode'] = '';
117
+ $ipn_data['country'] = '';
118
+
119
+ //Handle the membership signup related tasks.
120
+ swpm_handle_subsc_signup_stand_alone($ipn_data,$membership_level_id,$txn_id,$swpm_id);
121
+
122
+ //Save the transaction record
123
+ SwpmTransactions::save_txn_record($ipn_data);
124
+ SwpmLog::log_simple_debug('Transaction data saved.', true);
125
+
126
+ //Trigger the stripe IPN processed action hook (so other plugins can can listen for this event).
127
+ do_action('swpm_braintree_ipn_processed', $ipn_data);
128
+
129
+ do_action('swpm_payment_ipn_processed', $ipn_data);
130
+
131
+ //Redirect the user to the return URL (or to the homepage if a return URL is not specified for this payment button).
132
+ $return_url = get_post_meta($button_id, 'return_url', true);
133
+ if (empty($return_url)) {
134
+ $return_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL;
135
+ }
136
+ SwpmLog::log_simple_debug("Redirecting customer to: ".$return_url, true);
137
+ SwpmLog::log_simple_debug("End of Braintree Buy Now IPN processing.", true, true);
138
+ SwpmMiscUtils::redirect_to_url($return_url);
139
+ }
140
+ }
141
+ }
142
+
143
+ $swpm_braintree_buy_ipn = new SwpmBraintreeBuyNowIpnHandler();
languages/swpm-es_ES.mo DELETED
Binary file
languages/swpm-es_ES.po DELETED
@@ -1,1322 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Simple Membership\n"
4
- "POT-Creation-Date: 2015-09-03 16:04+1000\n"
5
- "PO-Revision-Date: 2015-09-03 16:23+1000\n"
6
- "Last-Translator: \n"
7
- "Language-Team: \n"
8
- "Language: es\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.8.4\n"
13
- "X-Poedit-KeywordsList: __;_e\n"
14
- "X-Poedit-Basepath: .\n"
15
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
- "X-Poedit-SearchPath-0: .\n"
17
-
18
- #: classes/class.simple-wp-membership.php:263
19
- msgid "You are not logged in."
20
- msgstr "Usted no ha iniciado sesión."
21
-
22
- #: classes/class.simple-wp-membership.php:297
23
- msgid "Simple WP Membership Protection"
24
- msgstr "Protección de Simple WP Membership"
25
-
26
- #: classes/class.simple-wp-membership.php:309
27
- msgid "Simple Membership Protection options"
28
- msgstr "Opciones de protección de Simple Membership"
29
-
30
- #: classes/class.simple-wp-membership.php:325
31
- msgid "Do you want to protect this content?"
32
- msgstr "Quieres proteger este contenido?"
33
-
34
- #: classes/class.simple-wp-membership.php:330
35
- msgid "Select the membership level that can access this content:"
36
- msgstr "Selecciona los tipos de usuarios que pueden acceder a este contenido:"
37
-
38
- #: classes/class.simple-wp-membership.php:463
39
- msgid "WP Membership"
40
- msgstr "WP Membership"
41
-
42
- #: classes/class.simple-wp-membership.php:464 classes/class.swpm-members.php:10
43
- #: views/admin_members_menu.php:2
44
- msgid "Members"
45
- msgstr "Usuarios"
46
-
47
- #: classes/class.simple-wp-membership.php:465
48
- #: classes/class.swpm-category-list.php:20
49
- #: classes/class.swpm-membership-levels.php:11
50
- msgid "Membership Levels"
51
- msgstr "Categorías de Usuario"
52
-
53
- #: classes/class.simple-wp-membership.php:466
54
- msgid "Settings"
55
- msgstr "Ajustes"
56
-
57
- #: classes/class.simple-wp-membership.php:467
58
- msgid "Payments"
59
- msgstr "Pagos"
60
-
61
- #: classes/class.simple-wp-membership.php:468
62
- msgid "Add-ons"
63
- msgstr "Extensiones"
64
-
65
- #: classes/class.swpm-access-control.php:21
66
- #: classes/class.swpm-access-control.php:28
67
- #: classes/class.swpm-access-control.php:55
68
- msgid "You need to login to view this content. "
69
- msgstr "Necesita identificarse para ver este contenido"
70
-
71
- #: classes/class.swpm-access-control.php:34
72
- #: classes/class.swpm-access-control.php:60
73
- msgid ""
74
- "Your account has expired. Please renew your account to gain access to this "
75
- "content."
76
- msgstr ""
77
- "Tu cuenta ha caducado. Gracias por renovar tu cuenta para acceder a este "
78
- "contenido."
79
-
80
- #: classes/class.swpm-access-control.php:41
81
- msgid "This content can only be viewed by members who joined on or before "
82
- msgstr ""
83
- "Este contenido sólo puede ser visto por los miembros que se unieron en o "
84
- "antes"
85
-
86
- #: classes/class.swpm-access-control.php:46
87
- #: classes/class.swpm-access-control.php:66
88
- msgid "This content is not permitted for your membership level."
89
- msgstr "Este contenido no está permitido para su nivel de membresía."
90
-
91
- #: classes/class.swpm-access-control.php:84
92
- msgid " The rest of the content is not permitted for your membership level."
93
- msgstr "El resto del contenido no está permitido para su nivel de membresía."
94
-
95
- #: classes/class.swpm-access-control.php:88
96
- #: classes/class.swpm-access-control.php:106
97
- msgid "You need to login to view the rest of the content. "
98
- msgstr "Necesita identificarse antes de ver el resto del contenido."
99
-
100
- #: classes/class.swpm-admin-registration.php:54
101
- msgid "Member record added successfully."
102
- msgstr "Record del Miembro agregado correctamente."
103
-
104
- #: classes/class.swpm-admin-registration.php:59
105
- #: classes/class.swpm-admin-registration.php:100
106
- #: classes/class.swpm-membership-level.php:43
107
- #: classes/class.swpm-membership-level.php:62
108
- msgid "Please correct the following:"
109
- msgstr "Por favor, corrija lo siguiente:"
110
-
111
- #: classes/class.swpm-admin-registration.php:91
112
- msgid "Your current password"
113
- msgstr "Tu contraseña actual"
114
-
115
- #: classes/class.swpm-ajax.php:14
116
- msgid "Invalid Email Address"
117
- msgstr "Dirección de correo electrónico no es válido"
118
-
119
- #: classes/class.swpm-ajax.php:21 classes/class.swpm-ajax.php:32
120
- msgid "Aready taken"
121
- msgstr "No disponible"
122
-
123
- #: classes/class.swpm-ajax.php:33
124
- msgid "Available"
125
- msgstr "Disponible"
126
-
127
- #: classes/class.swpm-auth.php:50
128
- msgid "User Not Found."
129
- msgstr "Usuario no encontrado."
130
-
131
- #: classes/class.swpm-auth.php:57
132
- msgid "Password Empty or Invalid."
133
- msgstr "Contraseña vacía o no válida."
134
-
135
- #: classes/class.swpm-auth.php:82
136
- msgid "Account is inactive."
137
- msgstr "Esta cuenta está inactiva."
138
-
139
- #: classes/class.swpm-auth.php:85
140
- msgid "Account is pending."
141
- msgstr "Cuenta pendiente."
142
-
143
- #: classes/class.swpm-auth.php:88 classes/class.swpm-auth.php:106
144
- msgid "Account has expired."
145
- msgstr "Su cuenta ha expirado."
146
-
147
- #: classes/class.swpm-auth.php:114
148
- msgid "You are logged in as:"
149
- msgstr "Identificado como:"
150
-
151
- #: classes/class.swpm-auth.php:160
152
- msgid "Logged Out Successfully."
153
- msgstr "Se ha Cerrado la Sesión Correctamente."
154
-
155
- #: classes/class.swpm-auth.php:210
156
- msgid "Session Expired."
157
- msgstr "Sesión finalizada."
158
-
159
- #: classes/class.swpm-auth.php:219
160
- msgid "Invalid User Name"
161
- msgstr "Nombre de usuario no es válido"
162
-
163
- #: classes/class.swpm-auth.php:227
164
- msgid "Please login again."
165
- msgstr "Por favor, iniciar la sesión de nuevo."
166
-
167
- #: classes/class.swpm-category-list.php:19 classes/class.swpm-members.php:23
168
- #: classes/class.swpm-membership-levels.php:10
169
- #: classes/class.swpm-membership-levels.php:20
170
- #: classes/admin-includes/class.swpm-payments-list-table.php:53
171
- #: views/add.php:30 views/admin_member_form_common_part.php:2 views/edit.php:52
172
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:36
173
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:217
174
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:37
175
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:310
176
- msgid "Membership Level"
177
- msgstr "Nivel de Membresía"
178
-
179
- #: classes/class.swpm-category-list.php:33 classes/class.swpm-members.php:18
180
- #: classes/class.swpm-membership-levels.php:19
181
- msgid "ID"
182
- msgstr "ID"
183
-
184
- #: classes/class.swpm-category-list.php:34
185
- msgid "Name"
186
- msgstr "Nombre"
187
-
188
- #: classes/class.swpm-category-list.php:35
189
- msgid "Description"
190
- msgstr "Descripción"
191
-
192
- #: classes/class.swpm-category-list.php:36
193
- msgid "Count"
194
- msgstr "Contar"
195
-
196
- #: classes/class.swpm-category-list.php:80
197
- msgid "Category protection updated!"
198
- msgstr "Protección de Categoría actualizada!"
199
-
200
- #: classes/class.swpm-form.php:26
201
- msgid ""
202
- "Wordpress account exists with given user name. But given email doesn't match."
203
- msgstr ""
204
- "Ya existe una cuenta con este nombre de usuario, Pero el correo electrónico "
205
- "proporcionado no coincide."
206
-
207
- #: classes/class.swpm-form.php:31
208
- msgid ""
209
- "Wordpress account exists with given email. But given user name doesn't match."
210
- msgstr ""
211
- "Existe una cuenta con el mail proporcionado, Pero el nombre del usuario no "
212
- "coincide."
213
-
214
- #: classes/class.swpm-form.php:40
215
- msgid "User name is required"
216
- msgstr "Debe de escribir un nombre de usuario."
217
-
218
- #: classes/class.swpm-form.php:44
219
- msgid "User name contains invalid character"
220
- msgstr "El nombre de usuario contiene carácteres no válidos"
221
-
222
- #: classes/class.swpm-form.php:52
223
- msgid "User name already exists."
224
- msgstr "El nombre de usuario ya está en uso."
225
-
226
- #: classes/class.swpm-form.php:75
227
- msgid "Password is required"
228
- msgstr "Debe escribir una contraseña."
229
-
230
- #: classes/class.swpm-form.php:82
231
- msgid "Password mismatch"
232
- msgstr "Contraseña incorrecta"
233
-
234
- #: classes/class.swpm-form.php:93
235
- msgid "Email is required"
236
- msgstr "Debe de proporcionar un email o correo electrónico"
237
-
238
- #: classes/class.swpm-form.php:97
239
- msgid "Email is invalid"
240
- msgstr "El correo electrónico es invalido"
241
-
242
- #: classes/class.swpm-form.php:113
243
- msgid "Email is already used."
244
- msgstr "Correo electrónico ya está en uso."
245
-
246
- #: classes/class.swpm-form.php:170
247
- msgid "Member since field is invalid"
248
- msgstr "Miembro desde campo no es válido"
249
-
250
- #: classes/class.swpm-form.php:181
251
- msgid "Access starts field is invalid"
252
- msgstr "La fecha de comienzo no es válida"
253
-
254
- #: classes/class.swpm-form.php:191
255
- msgid "Gender field is invalid"
256
- msgstr "El valor introducido en el campo \"Genero\" no es válido"
257
-
258
- #: classes/class.swpm-form.php:202
259
- msgid "Account state field is invalid"
260
- msgstr "El valor introducido en el campo \"Estado de la cuenta\" no es válido"
261
-
262
- #: classes/class.swpm-form.php:209
263
- msgid "Invalid membership level"
264
- msgstr "Nivel de membresía no es válido."
265
-
266
- #: classes/class.swpm-front-registration.php:71
267
- msgid "Security check: captcha validation failed."
268
- msgstr "Control de seguridad: la validación captcha falló."
269
-
270
- #: classes/class.swpm-front-registration.php:80
271
- msgid "Registration Successful. "
272
- msgstr "Registro Correcto"
273
-
274
- #: classes/class.swpm-front-registration.php:80
275
- #: classes/class.swpm-settings.php:377
276
- msgid "Please"
277
- msgstr "Por Favor"
278
-
279
- #: classes/class.swpm-front-registration.php:80
280
- #: classes/class.swpm-settings.php:377 views/login.php:21
281
- msgid "Login"
282
- msgstr "Acceder"
283
-
284
- #: classes/class.swpm-front-registration.php:92
285
- #: classes/class.swpm-front-registration.php:179
286
- msgid "Please correct the following"
287
- msgstr "Por favor, corrija lo siguiente:"
288
-
289
- #: classes/class.swpm-front-registration.php:123
290
- msgid "Membership Level Couldn't be found."
291
- msgstr "El nivel de membresía no ha sido encontrado."
292
-
293
- #: classes/class.swpm-front-registration.php:162
294
- msgid "Profile updated successfully."
295
- msgstr "Perfil actualizado correctamente."
296
-
297
- #: classes/class.swpm-front-registration.php:170
298
- msgid ""
299
- "Profile updated successfully. You will need to re-login since you changed "
300
- "your password."
301
- msgstr ""
302
- "Perfil actualizado correctamente. Usted tendrá que volver a iniciar la "
303
- "sesión desde que cambió su contraseña."
304
-
305
- #: classes/class.swpm-front-registration.php:189
306
- msgid "Email address not valid."
307
- msgstr "Dirección de correo electrónico no es válido."
308
-
309
- #: classes/class.swpm-front-registration.php:200
310
- msgid "No user found with that email address."
311
- msgstr ""
312
- "No se han encontrado ningún usuario con esa dirección de correo electrónico."
313
-
314
- #: classes/class.swpm-front-registration.php:201
315
- #: classes/class.swpm-front-registration.php:224
316
- msgid "Email Address: "
317
- msgstr "Dirección de Correo Electrónico:"
318
-
319
- #: classes/class.swpm-front-registration.php:223
320
- msgid "New password has been sent to your email address."
321
- msgstr "La nueva contraseña ha sido enviada a su correo electrónico."
322
-
323
- #: classes/class.swpm-init-time-tasks.php:108
324
- msgid "Sorry, Nonce verification failed."
325
- msgstr "Lo sentimos, la verificación Nonce falló."
326
-
327
- #: classes/class.swpm-init-time-tasks.php:115
328
- msgid "Sorry, Password didn't match."
329
- msgstr "Lo sentimos, la contraseña no coincide."
330
-
331
- #: classes/class.swpm-level-form.php:47
332
- msgid "Date format is not valid."
333
- msgstr "El formato de fecha no es válido."
334
-
335
- #: classes/class.swpm-level-form.php:55
336
- msgid "Access duration must be > 0."
337
- msgstr "La duración del acceso debe ser mayor a 0."
338
-
339
- #: classes/class.swpm-member-utils.php:22
340
- #: classes/class.swpm-member-utils.php:30
341
- #: classes/class.swpm-member-utils.php:38
342
- #: classes/class.swpm-member-utils.php:48
343
- msgid "User is not logged in."
344
- msgstr "El usuario no está conectado."
345
-
346
- #: classes/class.swpm-members.php:9
347
- msgid "Member"
348
- msgstr "Miembro"
349
-
350
- #: classes/class.swpm-members.php:19 views/add.php:6 views/edit.php:4
351
- msgid "User Name"
352
- msgstr "Nombre de Usuario"
353
-
354
- #: classes/class.swpm-members.php:20
355
- #: classes/admin-includes/class.swpm-payments-list-table.php:48
356
- #: views/add.php:22 views/admin_member_form_common_part.php:15
357
- #: views/edit.php:20
358
- msgid "First Name"
359
- msgstr "Nombre"
360
-
361
- #: classes/class.swpm-members.php:21
362
- #: classes/admin-includes/class.swpm-payments-list-table.php:49
363
- #: views/add.php:26 views/admin_member_form_common_part.php:19
364
- #: views/edit.php:24
365
- msgid "Last Name"
366
- msgstr "Apellido"
367
-
368
- #: classes/class.swpm-members.php:22 views/add.php:10 views/edit.php:8
369
- msgid "Email"
370
- msgstr "Correo Electrónico"
371
-
372
- #: classes/class.swpm-members.php:24 views/admin_member_form_common_part.php:11
373
- msgid "Access Starts"
374
- msgstr "El acceso comienza"
375
-
376
- #: classes/class.swpm-members.php:25
377
- msgid "Account State"
378
- msgstr "Estado de la Cuenta"
379
-
380
- #: classes/class.swpm-members.php:38
381
- #: classes/class.swpm-membership-levels.php:35
382
- #: classes/admin-includes/class.swpm-payment-buttons-list-table.php:80
383
- #: classes/admin-includes/class.swpm-payments-list-table.php:68
384
- msgid "Delete"
385
- msgstr "Borrar"
386
-
387
- #: classes/class.swpm-members.php:112
388
- msgid "No Member found."
389
- msgstr "No se han encontrado miembros."
390
-
391
- #: classes/class.swpm-membership-level.php:38
392
- msgid "Membership Level Creation Successful."
393
- msgstr "Tipo de Miembros Creado Con Éxito."
394
-
395
- #: classes/class.swpm-membership-level.php:57
396
- msgid "Updated Successfully."
397
- msgstr "Actualizado Con Éxito."
398
-
399
- #: classes/class.swpm-membership-levels.php:21
400
- msgid "Role"
401
- msgstr "Rol"
402
-
403
- #: classes/class.swpm-membership-levels.php:22
404
- msgid "Access Valid For/Until"
405
- msgstr "Acceso válido para/hasta"
406
-
407
- #: classes/class.swpm-misc-utils.php:50
408
- msgid "Registration"
409
- msgstr "Registro"
410
-
411
- #: classes/class.swpm-misc-utils.php:73
412
- msgid "Member Login"
413
- msgstr "Iniciar Sesión"
414
-
415
- #: classes/class.swpm-misc-utils.php:96
416
- msgid "Profile"
417
- msgstr "Perfil"
418
-
419
- #: classes/class.swpm-misc-utils.php:119
420
- msgid "Password Reset"
421
- msgstr "Restablecer la Contraseña"
422
-
423
- #: classes/class.swpm-settings.php:21 classes/class.swpm-settings.php:39
424
- msgid "General Settings"
425
- msgstr "Ajustes Generales"
426
-
427
- #: classes/class.swpm-settings.php:21
428
- msgid "Payment Settings"
429
- msgstr "Ajustes de Pago"
430
-
431
- #: classes/class.swpm-settings.php:22
432
- msgid "Email Settings"
433
- msgstr "Configuración del Correo Electrónico"
434
-
435
- #: classes/class.swpm-settings.php:22
436
- msgid "Tools"
437
- msgstr "Herramientas"
438
-
439
- #: classes/class.swpm-settings.php:22 classes/class.swpm-settings.php:150
440
- msgid "Advanced Settings"
441
- msgstr "Ajustes Avanzados"
442
-
443
- #: classes/class.swpm-settings.php:22
444
- msgid "Addons Settings"
445
- msgstr "Ajustes de Extensiones"
446
-
447
- #: classes/class.swpm-settings.php:38
448
- msgid "Plugin Documentation"
449
- msgstr "Documentación del Plugin"
450
-
451
- #: classes/class.swpm-settings.php:40
452
- msgid "Enable Free Membership"
453
- msgstr "Activar Membresía Gratis"
454
-
455
- #: classes/class.swpm-settings.php:41
456
- msgid ""
457
- "Enable/disable registration for free membership level. When you enable this "
458
- "option, make sure to specify a free membership level ID in the field below."
459
- msgstr ""
460
- "Activar/desactivar el registro para el nivel de membresía gratis. Al "
461
- "habilitar esta opción, asegúrese de especificar un nivel de membresía ID "
462
- "gratis en el campo de abajo."
463
-
464
- #: classes/class.swpm-settings.php:42
465
- msgid "Free Membership Level ID"
466
- msgstr "ID Categoría de miembros gratuitos"
467
-
468
- #: classes/class.swpm-settings.php:43
469
- msgid "Assign free membership level ID"
470
- msgstr "Asignar nivel ID a los miembros gratuitos"
471
-
472
- #: classes/class.swpm-settings.php:44
473
- msgid "Enable More Tag Protection"
474
- msgstr "Activar más Protección de Etiquetas"
475
-
476
- #: classes/class.swpm-settings.php:45
477
- msgid ""
478
- "Enables or disables \"more\" tag protection in the posts and pages. Anything "
479
- "after the More tag is protected. Anything before the more tag is teaser "
480
- "content."
481
- msgstr ""
482
- "Activar o desactivar más protección en las entradas y páginas. Todo lo que "
483
- "se incluya bajo el tag \"MÁS\" es restringido, el resto es accesible a todos."
484
-
485
- #: classes/class.swpm-settings.php:46
486
- msgid "Hide Adminbar"
487
- msgstr "Esconder Barra superior de inicio de sesión"
488
-
489
- #: classes/class.swpm-settings.php:47
490
- msgid ""
491
- "WordPress shows an admin toolbar to the logged in users of the site. Check "
492
- "this box if you want to hide that admin toolbar in the fronend of your site."
493
- msgstr ""
494
- "WordPress muestra una barra de herramientas de administración para la los "
495
- "usuarios registrados del sitio. Marque esta casilla si desea ocultar esa "
496
- "barra de herramientas de administración en el la parte delantera de su sitio."
497
-
498
- #: classes/class.swpm-settings.php:49
499
- msgid "Default Account Status"
500
- msgstr "Estado de lal cuenta por defecto"
501
-
502
- #: classes/class.swpm-settings.php:52
503
- msgid ""
504
- "Select the default account status for newly registered users. If you want to "
505
- "manually approve the members then you can set the status to \"Pending\"."
506
- msgstr ""
507
- "Seleccionar una cuenta por defecto para nuevos registros. Si desea aprobar "
508
- "manualmente los miembros, establezca el estado a \"Pendiente\"."
509
-
510
- #: classes/class.swpm-settings.php:53
511
- msgid "Allow Account Deletion"
512
- msgstr "Permitir Eliminación de Cuenta"
513
-
514
- #: classes/class.swpm-settings.php:55
515
- msgid "Allow users to delete their accounts."
516
- msgstr "Permitir a los usuarios eliminar sus cuentas."
517
-
518
- #: classes/class.swpm-settings.php:56
519
- msgid "Auto Delete Pending Account"
520
- msgstr "Auto Borrar Cuenta Pendiente"
521
-
522
- #: classes/class.swpm-settings.php:59
523
- msgid "Select how long you want to keep \"pending\" account."
524
- msgstr "Seleccione cuánto tiempo desea mantener \"pendiente\" la cuenta."
525
-
526
- #: classes/class.swpm-settings.php:67
527
- msgid "Pages Settings"
528
- msgstr "Ajustes de las Páguinas"
529
-
530
- #: classes/class.swpm-settings.php:68
531
- msgid "Login Page URL"
532
- msgstr "URL Página de Inicio de sesión"
533
-
534
- #: classes/class.swpm-settings.php:70
535
- msgid "Registration Page URL"
536
- msgstr "URL Página de Registro"
537
-
538
- #: classes/class.swpm-settings.php:72
539
- msgid "Join Us Page URL"
540
- msgstr "URL Página de \"Unete a nosotros\""
541
-
542
- #: classes/class.swpm-settings.php:74
543
- msgid "Edit Profile Page URL"
544
- msgstr "URL Página de Editar Perfil"
545
-
546
- #: classes/class.swpm-settings.php:76
547
- msgid "Password Reset Page URL"
548
- msgstr "URL Página de Restablecer contraseña"
549
-
550
- #: classes/class.swpm-settings.php:79
551
- msgid "Test & Debug Settings"
552
- msgstr "Ajustes de Prueba y Depuración"
553
-
554
- #: classes/class.swpm-settings.php:81
555
- msgid "Check this option to enable debug logging."
556
- msgstr "Marque esta opción para activar el registro de depuración."
557
-
558
- #: classes/class.swpm-settings.php:86
559
- msgid "Enable Sandbox Testing"
560
- msgstr "Permitir Test Sandbox"
561
-
562
- #: classes/class.swpm-settings.php:87
563
- msgid "Enable this option if you want to do sandbox payment testing."
564
- msgstr "Permitir esta opción si quiere hacer la prueba del pago sandbox."
565
-
566
- #: classes/class.swpm-settings.php:97 classes/class.swpm-settings.php:145
567
- #: classes/class.swpm-settings.php:243
568
- msgid "Settings updated!"
569
- msgstr "Ajustes actualizados"
570
-
571
- #: classes/class.swpm-settings.php:102
572
- msgid "Email Misc. Settings"
573
- msgstr "Varios Ajustes del Correo electrónico."
574
-
575
- #: classes/class.swpm-settings.php:103
576
- msgid "From Email Address"
577
- msgstr "CorreoElectrónico Del Remitente"
578
-
579
- #: classes/class.swpm-settings.php:106
580
- msgid "Email Settings (Prompt to Complete Registration )"
581
- msgstr ""
582
- "Configuración del correo electrónico (Solicitud para Completar el Registro)"
583
-
584
- #: classes/class.swpm-settings.php:107 classes/class.swpm-settings.php:113
585
- #: classes/class.swpm-settings.php:125 classes/class.swpm-settings.php:132
586
- msgid "Email Subject"
587
- msgstr "Asunto del Correo Electrónico"
588
-
589
- #: classes/class.swpm-settings.php:109 classes/class.swpm-settings.php:115
590
- #: classes/class.swpm-settings.php:127 classes/class.swpm-settings.php:134
591
- msgid "Email Body"
592
- msgstr "El Cuerpo de Correo Electrónico"
593
-
594
- #: classes/class.swpm-settings.php:112
595
- msgid "Email Settings (Registration Complete)"
596
- msgstr "Configuración del Correo Electrónico (Registro Completo)"
597
-
598
- #: classes/class.swpm-settings.php:117
599
- msgid "Send Notification to Admin"
600
- msgstr "Enviar notificación al Administrador"
601
-
602
- #: classes/class.swpm-settings.php:118
603
- msgid ""
604
- "Enable this option if you want the admin to receive a notification when a "
605
- "member registers."
606
- msgstr ""
607
- "Habilite esta opción si desea que el administrador reciba una notificación "
608
- "cuando un miembro se registre."
609
-
610
- #: classes/class.swpm-settings.php:119
611
- msgid "Admin Email Address"
612
- msgstr "Dirección de correo electrónico del administrador"
613
-
614
- #: classes/class.swpm-settings.php:120
615
- msgid ""
616
- "Enter the email address where you want the admin notification email to be "
617
- "sent to."
618
- msgstr ""
619
- "Introduzca la dirección de correo electrónico donde desea que el correo "
620
- "electrónico de notificación de administración sea envidado. "
621
-
622
- #: classes/class.swpm-settings.php:121
623
- msgid "Send Email to Member When Added via Admin Dashboard"
624
- msgstr "Enviar mail al miembro cuando ha sido añadido por el administrador"
625
-
626
- #: classes/class.swpm-settings.php:124
627
- msgid "Email Settings (Password Reset)"
628
- msgstr "Configuración del correo electrónico (Restablecer contraseña)"
629
-
630
- #: classes/class.swpm-settings.php:131
631
- msgid " Email Settings (Account Upgrade Notification)"
632
- msgstr "Ajustes Mail (Notificación de actualización de la cuenta)"
633
-
634
- #: classes/class.swpm-settings.php:152
635
- msgid "Enable Expired Account Login"
636
- msgstr "Habilitar la Entrada de La Cuenta Caducada"
637
-
638
- #: classes/class.swpm-settings.php:153
639
- msgid ""
640
- "When enabled, expired members will be able to log into the system but won't "
641
- "be able to view any protected content. This allows them to easily renew "
642
- "their account by making another payment."
643
- msgstr ""
644
- "Cuando se activa, los miembros caducados podrán iniciar sesión en el "
645
- "sistema, pero no podrán ver cualquier contenido protegido. Esto les permite "
646
- "renovar fácilmente su cuenta al hacer otro pago."
647
-
648
- #: classes/class.swpm-settings.php:377
649
- msgid "Not a Member?"
650
- msgstr "¿No estas Registrado?"
651
-
652
- #: classes/class.swpm-settings.php:377 views/login.php:27
653
- msgid "Join Us"
654
- msgstr "Únete a Nosotros"
655
-
656
- #: classes/class.swpm-utils.php:67
657
- msgid "Active"
658
- msgstr "Activo"
659
-
660
- #: classes/class.swpm-utils.php:68
661
- msgid "Inactive"
662
- msgstr "Inactivo"
663
-
664
- #: classes/class.swpm-utils.php:69
665
- msgid "Pending"
666
- msgstr "Pendiente"
667
-
668
- #: classes/class.swpm-utils.php:70
669
- msgid "Expired"
670
- msgstr "Caducado"
671
-
672
- #: classes/class.swpm-utils.php:296
673
- msgid "Never"
674
- msgstr "Nunca"
675
-
676
- #: classes/class.swpm-utils.php:370
677
- msgid "Delete Account"
678
- msgstr "Borrar Cuenta"
679
-
680
- #: classes/admin-includes/class.swpm-payment-buttons-list-table.php:63
681
- msgid "Payment Button ID"
682
- msgstr "ID del Botón de Pago"
683
-
684
- #: classes/admin-includes/class.swpm-payment-buttons-list-table.php:64
685
- msgid "Payment Button Title"
686
- msgstr "Título del Botón de Pago"
687
-
688
- #: classes/admin-includes/class.swpm-payment-buttons-list-table.php:65
689
- msgid "Membership Level ID"
690
- msgstr "ID Nivel de Membresía"
691
-
692
- #: classes/admin-includes/class.swpm-payment-buttons-list-table.php:66
693
- msgid "Button Shortcode"
694
- msgstr "Código corto del Botón"
695
-
696
- #: classes/admin-includes/class.swpm-payment-buttons-list-table.php:106
697
- #: views/admin_members_list.php:15
698
- #: views/payments/admin_all_payment_transactions.php:33
699
- msgid "The selected entry was deleted!"
700
- msgstr "¡La entrada seleccionada se borro!"
701
-
702
- #: classes/admin-includes/class.swpm-payments-list-table.php:46
703
- msgid "Row ID"
704
- msgstr "ID de Fila"
705
-
706
- #: classes/admin-includes/class.swpm-payments-list-table.php:47
707
- #: views/forgot_password.php:5
708
- msgid "Email Address"
709
- msgstr "Dirección de Correo Electrónico"
710
-
711
- #: classes/admin-includes/class.swpm-payments-list-table.php:50
712
- msgid "Date"
713
- msgstr "Fecha"
714
-
715
- #: classes/admin-includes/class.swpm-payments-list-table.php:51
716
- msgid "Transaction ID"
717
- msgstr "ID de Transacción"
718
-
719
- #: classes/admin-includes/class.swpm-payments-list-table.php:52
720
- msgid "Amount"
721
- msgstr "Cantidad"
722
-
723
- #: classes/common/class.swpm-list-table.php:137
724
- msgid "List View"
725
- msgstr "Vista de la Lista"
726
-
727
- #: classes/common/class.swpm-list-table.php:138
728
- msgid "Excerpt View"
729
- msgstr "Ver Extracto"
730
-
731
- #: classes/common/class.swpm-list-table.php:305
732
- msgid "No items found."
733
- msgstr "Artículos no encontrados."
734
-
735
- #: classes/common/class.swpm-list-table.php:431
736
- msgid "Select bulk action"
737
- msgstr "Seleccione la mayor acción"
738
-
739
- #: classes/common/class.swpm-list-table.php:433
740
- msgid "Bulk Actions"
741
- msgstr "Acciones Masivas"
742
-
743
- #: classes/common/class.swpm-list-table.php:443
744
- msgid "Apply"
745
- msgstr "Aplicar"
746
-
747
- #: classes/common/class.swpm-list-table.php:543
748
- msgid "Filter by date"
749
- msgstr "Filtrar por fecha"
750
-
751
- #: classes/common/class.swpm-list-table.php:545
752
- msgid "All dates"
753
- msgstr "Todas las fechas"
754
-
755
- #: classes/common/class.swpm-list-table.php:555
756
- #, php-format
757
- msgid "%1$s %2$d"
758
- msgstr "%1$s %2$d"
759
-
760
- #: classes/common/class.swpm-list-table.php:599
761
- #, php-format
762
- msgid "%s pending"
763
- msgstr "%s pendientes"
764
-
765
- #: classes/common/class.swpm-list-table.php:704
766
- msgid "Select Page"
767
- msgstr "Seleccionar Página"
768
-
769
- #: classes/common/class.swpm-list-table.php:848
770
- msgid "Select All"
771
- msgstr "Seleccionar Todo"
772
-
773
- #: classes/shortcode-related/class.swpm-shortcodes-handler.php:47
774
- msgid "Your membership profile will be updated to reflect the payment."
775
- msgstr "Su perfil de membresía se actualizará para reflejar el pago."
776
-
777
- #: classes/shortcode-related/class.swpm-shortcodes-handler.php:48
778
- msgid "Your profile username: "
779
- msgstr "Su perfil de usuario:"
780
-
781
- #: classes/shortcode-related/class.swpm-shortcodes-handler.php:60
782
- msgid "Click on the following link to complete the registration."
783
- msgstr "Haga clic en el siguiente enlace para completar el registro."
784
-
785
- #: classes/shortcode-related/class.swpm-shortcodes-handler.php:61
786
- msgid "Click here to complete your paid registration"
787
- msgstr "Haga clic aquí para completar su inscripción pagada"
788
-
789
- #: classes/shortcode-related/class.swpm-shortcodes-handler.php:66
790
- msgid ""
791
- "If you have just made a membership payment then your payment is yet to be "
792
- "processed. Please check back in a few minutes. An email will be sent to you "
793
- "with the details shortly."
794
- msgstr ""
795
- "Si usted acaba de hacer un pago de membresía a continuación su pago aún no "
796
- "se ha procesado. Por favor, vuelva en unos pocos minutos. En breves momentos "
797
- "un correo electrónico será enviado con los detalles."
798
-
799
- #: views/add.php:14 views/admin_add.php:19 views/admin_edit.php:17
800
- #: views/edit.php:12 views/login.php:11
801
- msgid "Password"
802
- msgstr "Contraseña"
803
-
804
- #: views/add.php:18 views/edit.php:16
805
- msgid "Repeat Password"
806
- msgstr "Repetir Contraseña"
807
-
808
- #: views/add.php:41
809
- msgid "Register"
810
- msgstr "Registrarse"
811
-
812
- #: views/admin_add.php:6
813
- msgid "Add Member"
814
- msgstr "Añadir Miembro"
815
-
816
- #: views/admin_add.php:7
817
- msgid "Create a brand new user and add it to this site."
818
- msgstr "Crear un nuevo usuario y agregarlo a esta web."
819
-
820
- #: views/admin_add.php:11
821
- msgid "User name"
822
- msgstr "Nombre de usuario"
823
-
824
- #: views/admin_add.php:11 views/admin_add.php:15 views/admin_add_level.php:11
825
- #: views/admin_add_level.php:15 views/admin_add_level.php:19
826
- #: views/admin_edit.php:9 views/admin_edit.php:13 views/admin_edit_level.php:10
827
- #: views/admin_edit_level.php:14 views/admin_edit_level.php:18
828
- msgid "(required)"
829
- msgstr "(obligatorio)"
830
-
831
- #: views/admin_add.php:15 views/admin_edit.php:13
832
- msgid "E-mail"
833
- msgstr "Email"
834
-
835
- #: views/admin_add.php:19
836
- msgid "(twice, required)"
837
- msgstr "(escríbalo dos veces, Obligatorio)"
838
-
839
- #: views/admin_add.php:24 views/admin_edit.php:21
840
- msgid "Strength indicator"
841
- msgstr "Indicador de seguridad"
842
-
843
- #: views/admin_add.php:25 views/admin_edit.php:22
844
- msgid ""
845
- "Hint: The password should be at least seven characters long. To make it "
846
- "stronger, use upper and lower case letters, numbers and symbols like ! \" ? "
847
- "$ % ^ &amp; )."
848
- msgstr ""
849
- "Sugerencia: La contraseña debe tener al menos siete caracteres. Para hacerlo "
850
- "más seguro, utilizar letras mayúsculas y minúsculas, números y símbolos "
851
- "como! \" ? $ % ^ &amp; )."
852
-
853
- #: views/admin_add.php:29 views/admin_edit.php:26 views/loggedin.php:7
854
- msgid "Account Status"
855
- msgstr "Estado de la Cuenta"
856
-
857
- #: views/admin_add.php:39
858
- msgid "Add New Member "
859
- msgstr "Añadir Nuevo Miembro"
860
-
861
- #: views/admin_addon_settings.php:3 views/admin_settings.php:3
862
- #: views/admin_tools_settings.php:3 views/payments/admin_payment_settings.php:3
863
- msgid "Simple WP Membership::Settings"
864
- msgstr "Simple WP Membership::Ajustes"
865
-
866
- #: views/admin_addon_settings.php:8
867
- msgid ""
868
- "Some of the simple membership plugin's addon settings and options will be "
869
- "displayed here (if you have them)"
870
- msgstr ""
871
- "Algunas de las extensiones de este plugin y sus opciones se muestran aquí "
872
- "(si estuvieran instalados)"
873
-
874
- #: views/admin_addon_settings.php:13
875
- msgid "Save Changes"
876
- msgstr "Guardar Cambios"
877
-
878
- #: views/admin_add_level.php:6
879
- msgid "Create new membership level."
880
- msgstr "Crear nueva categoría de miembro."
881
-
882
- #: views/admin_add_level.php:11 views/admin_edit_level.php:10
883
- msgid "Membership Level Name"
884
- msgstr "Nombre del Nivel de Membresía"
885
-
886
- #: views/admin_add_level.php:15 views/admin_edit_level.php:14
887
- msgid "Default WordPress Role"
888
- msgstr "Perfil en Wordpress por Defecto"
889
-
890
- #: views/admin_add_level.php:19 views/admin_edit_level.php:18
891
- msgid "Access Duration"
892
- msgstr "Duración del acceso"
893
-
894
- #: views/admin_add_level.php:22
895
- msgid "No Expiry (Access for this level will not expire until cancelled"
896
- msgstr "Sin Expiración (el acceso a este nivel no expirará hasta que se anule"
897
-
898
- #: views/admin_add_level.php:23 views/admin_add_level.php:25
899
- #: views/admin_add_level.php:27 views/admin_add_level.php:29
900
- #: views/admin_edit_level.php:22 views/admin_edit_level.php:25
901
- #: views/admin_edit_level.php:28 views/admin_edit_level.php:31
902
- msgid "Expire After"
903
- msgstr "Después de Caducar"
904
-
905
- #: views/admin_add_level.php:24 views/admin_edit_level.php:23
906
- msgid "Days (Access expires after given number of days)"
907
- msgstr "Días (el acceso expirará después del número establecido de días)"
908
-
909
- #: views/admin_add_level.php:26
910
- msgid "Weeks (Access expires after given number of weeks"
911
- msgstr "Semanas (el acceso expirará después del número establecido de semanas"
912
-
913
- #: views/admin_add_level.php:28 views/admin_edit_level.php:29
914
- msgid "Months (Access expires after given number of months)"
915
- msgstr "Meses (el acceso se caduca después del número establecido de meses)"
916
-
917
- #: views/admin_add_level.php:30 views/admin_edit_level.php:32
918
- msgid "Years (Access expires after given number of years)"
919
- msgstr "Años (el acceso expirará después del número establecido de años)"
920
-
921
- #: views/admin_add_level.php:31 views/admin_edit_level.php:34
922
- msgid "Fixed Date Expiry"
923
- msgstr "Fecha de Expiración"
924
-
925
- #: views/admin_add_level.php:32 views/admin_edit_level.php:35
926
- msgid "(Access expires on a fixed date)"
927
- msgstr "(El acceso expira a una fecha establecida)"
928
-
929
- #: views/admin_add_level.php:38
930
- msgid "Add New Membership Level "
931
- msgstr "Añadir Nuevo Nivel de Membresía"
932
-
933
- #: views/admin_add_ons_page.php:7
934
- msgid "Simple WP Membership::Add-ons"
935
- msgstr "Simple WP Membership::Extensiones"
936
-
937
- #: views/admin_category_list.php:2
938
- msgid "Simple WP Membership::Categories"
939
- msgstr "Simple WP Membership::Categorías"
940
-
941
- #: views/admin_category_list.php:7
942
- msgid ""
943
- "First of all, globally protect the category on your site by selecting "
944
- "\"General Protection\" from the drop-down box below and then select the "
945
- "categories that should be protected from non-logged in users."
946
- msgstr ""
947
- "Primero, proteja las categorías en su wen seleccionando \"General Protection"
948
- "\" desde la siguiente casilla desplegable y marque las categorías que desea "
949
- "proteger de los usuarios no registrados."
950
-
951
- #: views/admin_category_list.php:10
952
- msgid ""
953
- "Next, select an existing membership level from the drop-down box below and "
954
- "then select the categories you want to grant access to (for that particular "
955
- "membership level)."
956
- msgstr ""
957
- "Segundo, seleccione un nivel de membresía existente de la casilla "
958
- "desplegable y seleccione las categorías a las cuales permites acceso (para "
959
- "ese nivel en concreto)."
960
-
961
- #: views/admin_edit.php:5
962
- msgid "Edit Member"
963
- msgstr "Editar Usuario"
964
-
965
- #: views/admin_edit.php:6
966
- msgid "Edit existing member details."
967
- msgstr "Editar detalles de usuario existente"
968
-
969
- #: views/admin_edit.php:9 views/login.php:5
970
- msgid "Username"
971
- msgstr "Nombre de Usuario"
972
-
973
- #: views/admin_edit.php:17
974
- msgid "(twice, leave empty to retain old password)"
975
- msgstr "(dos veces, dejar en blanco pra conservar la actual contraseña)"
976
-
977
- #: views/admin_edit.php:33
978
- msgid "Notify User"
979
- msgstr "Notificar Usuario"
980
-
981
- #: views/admin_edit.php:40
982
- msgid "Subscriber ID/Reference"
983
- msgstr "Identificación del Suscriptor/Referencia"
984
-
985
- #: views/admin_edit.php:44
986
- msgid "Last Accessed From IP"
987
- msgstr "Último Accedido Desde IP"
988
-
989
- #: views/admin_edit.php:52
990
- msgid "Edit User "
991
- msgstr "Editar Usuario"
992
-
993
- #: views/admin_edit_level.php:5
994
- msgid "Edit membership level"
995
- msgstr "Editar categoría de usuario"
996
-
997
- #: views/admin_edit_level.php:6
998
- msgid "Edit membership level."
999
- msgstr "Editar categoría de usuario."
1000
-
1001
- #: views/admin_edit_level.php:21
1002
- msgid "No Expiry (Access for this level will not expire until cancelled)"
1003
- msgstr "Sin Expiración (el acceso a este nivel no expirará hasta que se anule)"
1004
-
1005
- #: views/admin_edit_level.php:26
1006
- msgid "Weeks (Access expires after given number of weeks)"
1007
- msgstr "Semanas (el acceso expirará después del número establecido de semanas)"
1008
-
1009
- #: views/admin_edit_level.php:41
1010
- msgid "Edit Membership Level "
1011
- msgstr "Editar Categoría de Usuario"
1012
-
1013
- #: views/admin_members.php:2
1014
- msgid "Simple WP Membership::Members"
1015
- msgstr "Simple WP Membership::Miembros"
1016
-
1017
- #: views/admin_members.php:3 views/admin_members_list.php:30
1018
- msgid "Add New"
1019
- msgstr "Añadir Nuevo"
1020
-
1021
- #: views/admin_membership_levels.php:2
1022
- msgid "Simple WP Membership::Membership Levels"
1023
- msgstr "Simple WP Membership::Nivel de Membresía"
1024
-
1025
- #: views/admin_membership_levels.php:12 views/admin_members_list.php:6
1026
- msgid "search"
1027
- msgstr "buscar"
1028
-
1029
- #: views/admin_membership_level_menu.php:2
1030
- msgid "Membership level"
1031
- msgstr "Nivel de membresía"
1032
-
1033
- #: views/admin_membership_level_menu.php:3
1034
- msgid "Manage Content Production"
1035
- msgstr "Gestionar la Producción de Contenido"
1036
-
1037
- #: views/admin_membership_level_menu.php:4
1038
- msgid "Category Protection"
1039
- msgstr "Protección de Categoría"
1040
-
1041
- #: views/admin_membership_manage.php:17
1042
- msgid "Example Content Protection Settings"
1043
- msgstr "Ejemplo de Ajustes de contenido protegido"
1044
-
1045
- #: views/admin_member_form_common_part.php:23
1046
- msgid "Gender"
1047
- msgstr "Sexo"
1048
-
1049
- #: views/admin_member_form_common_part.php:30 views/edit.php:28
1050
- msgid "Phone"
1051
- msgstr "Teléfono"
1052
-
1053
- #: views/admin_member_form_common_part.php:34 views/edit.php:32
1054
- msgid "Street"
1055
- msgstr "Calle"
1056
-
1057
- #: views/admin_member_form_common_part.php:38 views/edit.php:36
1058
- msgid "City"
1059
- msgstr "Ciudad"
1060
-
1061
- #: views/admin_member_form_common_part.php:42 views/edit.php:40
1062
- msgid "State"
1063
- msgstr "Estado"
1064
-
1065
- #: views/admin_member_form_common_part.php:46 views/edit.php:44
1066
- msgid "Zipcode"
1067
- msgstr "Código Postal"
1068
-
1069
- #: views/admin_member_form_common_part.php:50 views/edit.php:48
1070
- msgid "Country"
1071
- msgstr "País"
1072
-
1073
- #: views/admin_member_form_common_part.php:54
1074
- msgid "Company"
1075
- msgstr "Empresa o Institución"
1076
-
1077
- #: views/admin_member_form_common_part.php:58
1078
- msgid "Member Since"
1079
- msgstr "Miembro Desde"
1080
-
1081
- #: views/admin_tools_settings.php:9
1082
- msgid "Generate a Registration Completion link"
1083
- msgstr "Generar un vínculo para Completar el Registro"
1084
-
1085
- #: views/admin_tools_settings.php:12
1086
- msgid ""
1087
- "You can manually generate a registration completion link here and give it to "
1088
- "your customer if they have missed the email that was automatically sent out "
1089
- "to them after the payment."
1090
- msgstr ""
1091
- "Puede generar manualmente un enlace para completar el registro aquí y "
1092
- "enviarlo al usuario si ha perdido el correo electrónico que se envía "
1093
- "automáticamente a ellos después del pago."
1094
-
1095
- #: views/admin_tools_settings.php:17
1096
- msgid "Generate Registration Completion Link"
1097
- msgstr "Generar Link Para Completar Registro"
1098
-
1099
- #: views/admin_tools_settings.php:20
1100
- msgid "OR"
1101
- msgstr "O"
1102
-
1103
- #: views/admin_tools_settings.php:21
1104
- msgid "For All Pending Registrations"
1105
- msgstr "Para Todos Los Registros Pendientes"
1106
-
1107
- #: views/admin_tools_settings.php:24
1108
- msgid "Registration Completion Links Will Appear Below:"
1109
- msgstr "Los Enlaces Para Completar el Registro Aparecerán Aparecen por Debajo:"
1110
-
1111
- #: views/admin_tools_settings.php:31
1112
- msgid "Send Registration Reminder Email too"
1113
- msgstr "Enviar también recordatorio del registro del correo electrónico"
1114
-
1115
- #: views/admin_tools_settings.php:34
1116
- msgid "Submit"
1117
- msgstr "Enviar"
1118
-
1119
- #: views/edit.php:58
1120
- msgid "Update"
1121
- msgstr "Actualizar"
1122
-
1123
- #: views/forgot_password.php:12
1124
- msgid "Reset Password"
1125
- msgstr "Restablecer Contraseña"
1126
-
1127
- #: views/loggedin.php:3
1128
- msgid "Logged in as"
1129
- msgstr "Sesión iniciada como"
1130
-
1131
- #: views/loggedin.php:11
1132
- msgid "Membership"
1133
- msgstr "Membresía"
1134
-
1135
- #: views/loggedin.php:15
1136
- msgid "Account Expiry"
1137
- msgstr "Valido hasta"
1138
-
1139
- #: views/loggedin.php:19
1140
- msgid "Logout"
1141
- msgstr "Cerrar Sesión"
1142
-
1143
- #: views/login.php:18
1144
- msgid "Remember Me"
1145
- msgstr "Recordarme"
1146
-
1147
- #: views/login.php:24
1148
- msgid "Forgot Password"
1149
- msgstr "Contraseña Perdida"
1150
-
1151
- #: views/payments/admin_all_payment_transactions.php:7
1152
- msgid "All the payments/transactions of your members are recorded here."
1153
- msgstr "Todos los pagos/transacciones de sus miembros se registran aquí."
1154
-
1155
- #: views/payments/admin_all_payment_transactions.php:14
1156
- msgid "Search for a transaction by using email or name"
1157
- msgstr ""
1158
- "Búsqueda de una transacción mediante el uso de correo electrónico o nombre"
1159
-
1160
- #: views/payments/admin_all_payment_transactions.php:18
1161
- msgid "Search"
1162
- msgstr "Buscar"
1163
-
1164
- #: views/payments/admin_create_payment_buttons.php:13
1165
- msgid ""
1166
- "You can create new payment button for your memberships using this interface."
1167
- msgstr ""
1168
- "Puedes crear un nuevo botón de pago para sus membresías utilizando este "
1169
- "interfaz."
1170
-
1171
- #: views/payments/admin_create_payment_buttons.php:22
1172
- msgid "Select Payment Button Type"
1173
- msgstr "Seleccione el Tipo de Botón de Pago"
1174
-
1175
- #: views/payments/admin_create_payment_buttons.php:34
1176
- msgid "Next"
1177
- msgstr "Siguiente"
1178
-
1179
- #: views/payments/admin_edit_payment_buttons.php:12
1180
- msgid "You can edit a payment button using this interface."
1181
- msgstr "Puede editar un botón de pago utilizando este interfaz."
1182
-
1183
- #: views/payments/admin_payments_page.php:9
1184
- msgid "Simple Membership::Payments"
1185
- msgstr "Simple Membership::Pagos"
1186
-
1187
- #: views/payments/admin_payment_buttons.php:7
1188
- msgid ""
1189
- "All the membership buttons that you created in the plugin are displayed here."
1190
- msgstr ""
1191
- "Todos los botones de miembros que ha creado en el plugin se muestran aquí."
1192
-
1193
- #: views/payments/admin_payment_settings.php:31
1194
- msgid "PayPal Integration Settings"
1195
- msgstr "Ajustes de integración con Paypal"
1196
-
1197
- #: views/payments/admin_payment_settings.php:34
1198
- msgid "Generate the \"Advanced Variables\" Code for your PayPal button"
1199
- msgstr "Generar Código de \"Variables Avanzados\" para su botón de Paypal"
1200
-
1201
- #: views/payments/admin_payment_settings.php:37
1202
- msgid "Enter the Membership Level ID"
1203
- msgstr "Introduzca el ID de la categoría de usuario"
1204
-
1205
- #: views/payments/admin_payment_settings.php:39
1206
- msgid "Generate Code"
1207
- msgstr "Generar el Código"
1208
-
1209
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:18
1210
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:192
1211
- msgid "PayPal Buy Now Button Configuration"
1212
- msgstr "Configuración del botón de PayPal Cómpralo Ya"
1213
-
1214
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:28
1215
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:209
1216
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:29
1217
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:302
1218
- msgid "Button Title"
1219
- msgstr "Titulo del Botón"
1220
-
1221
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:46
1222
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:227
1223
- msgid "Payment Amount"
1224
- msgstr "Cantidad de Pago"
1225
-
1226
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:54
1227
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:235
1228
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:47
1229
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:320
1230
- msgid "Payment Currency"
1231
- msgstr "Moneda de Pago"
1232
-
1233
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:93
1234
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:274
1235
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:173
1236
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:446
1237
- msgid "Return URL"
1238
- msgstr "URL de Retorno"
1239
-
1240
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:101
1241
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:282
1242
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:86
1243
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:359
1244
- msgid "PayPal Email"
1245
- msgstr "Correo Electrónico de PayPal"
1246
-
1247
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:109
1248
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:290
1249
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:181
1250
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:454
1251
- msgid "Button Image URL"
1252
- msgstr "URL de la imagen del Botón"
1253
-
1254
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:119
1255
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:300
1256
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:193
1257
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:466
1258
- msgid "Save Payment Data"
1259
- msgstr "Guardar Datos de Pago"
1260
-
1261
- #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:201
1262
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:294
1263
- msgid "Button ID"
1264
- msgstr "Botón ID"
1265
-
1266
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:20
1267
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:288
1268
- msgid "PayPal Subscription Button Configuration"
1269
- msgstr "Configuración del Botón de Suscripción de PayPal"
1270
-
1271
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:94
1272
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:367
1273
- msgid "Billing Amount Each Cycle"
1274
- msgstr "Cantidad de Facturación de Cada Ciclo"
1275
-
1276
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:102
1277
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:375
1278
- msgid "Billing Cycle"
1279
- msgstr "Ciclo de Facturación"
1280
-
1281
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:115
1282
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:388
1283
- msgid "Billing Cycle Count"
1284
- msgstr "Contador de Facturación de Cada Ciclo"
1285
-
1286
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:123
1287
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:396
1288
- msgid "Re-attempt on Failure"
1289
- msgstr "Re-intento de Insuficiencia"
1290
-
1291
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:136
1292
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:409
1293
- msgid ""
1294
- "Trial Billing Details (Leave empty if you are not offering a trial period)"
1295
- msgstr ""
1296
- "Detalles de facturación de prueba (Dejar en blanco si no está ofreciendo un "
1297
- "período de prueba)"
1298
-
1299
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:142
1300
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:415
1301
- msgid "Trial Billing Amount"
1302
- msgstr "Prueba de facturación de Importe"
1303
-
1304
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:150
1305
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:423
1306
- msgid "Trial Billing Period"
1307
- msgstr "Período de Facturación de prueba"
1308
-
1309
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:167
1310
- #: views/payments/payment-gateway/admin_paypal_subscription_button.php:440
1311
- msgid "Optional Details"
1312
- msgstr "Detalles Opcionales"
1313
-
1314
- #: views/payments/payment-gateway/paypal_button_shortcode_view.php:77
1315
- #: views/payments/payment-gateway/paypal_button_shortcode_view.php:79
1316
- msgid "Buy Now"
1317
- msgstr "Compra Ahora"
1318
-
1319
- #: views/payments/payment-gateway/paypal_button_shortcode_view.php:197
1320
- #: views/payments/payment-gateway/paypal_button_shortcode_view.php:199
1321
- msgid "Subscribe Now"
1322
- msgstr "Suscríbete Ahora"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/{swpm-ja_JP.mo → swpm-ja.mo} RENAMED
File without changes
languages/{swpm-ja_JP.po → swpm-ja.po} RENAMED
File without changes
languages/swpm.pot CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Simple Membershp\n"
4
- "POT-Creation-Date: 2016-08-18 21:30+1000\n"
5
- "PO-Revision-Date: 2016-08-18 21:31+1000\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
@@ -13,21 +13,21 @@ msgstr ""
13
  "X-Poedit-Basepath: .\n"
14
  "X-Poedit-SearchPath-0: .\n"
15
 
16
- #: classes/class.simple-wp-membership.php:295
17
  msgid "You are not logged in."
18
  msgstr ""
19
 
20
- #: classes/class.simple-wp-membership.php:342
21
  msgid ""
22
  "You have the sandbox payment mode enabled in plugin settings. Make sure to "
23
  "turn off the sandbox mode when you want to do live transactions."
24
  msgstr ""
25
 
26
- #: classes/class.simple-wp-membership.php:357
27
  msgid "Simple WP Membership Protection"
28
  msgstr ""
29
 
30
- #: classes/class.simple-wp-membership.php:369
31
  msgid "Simple Membership Protection options"
32
  msgstr ""
33
 
@@ -39,31 +39,31 @@ msgstr ""
39
  msgid "Select the membership level that can access this content:"
40
  msgstr ""
41
 
42
- #: classes/class.simple-wp-membership.php:519
43
  msgid "WP Membership"
44
  msgstr ""
45
 
46
- #: classes/class.simple-wp-membership.php:520
47
- #: classes/class.swpm-members.php:12 classes/class.swpm-members.php:404
48
  msgid "Members"
49
  msgstr ""
50
 
51
- #: classes/class.simple-wp-membership.php:521
52
  #: classes/class.swpm-category-list.php:20
53
  #: classes/class.swpm-membership-levels.php:12
54
- #: classes/class.swpm-membership-levels.php:245
55
  msgid "Membership Levels"
56
  msgstr ""
57
 
58
- #: classes/class.simple-wp-membership.php:522
59
  msgid "Settings"
60
  msgstr ""
61
 
62
- #: classes/class.simple-wp-membership.php:523
63
  msgid "Payments"
64
  msgstr ""
65
 
66
- #: classes/class.simple-wp-membership.php:524
67
  msgid "Add-ons"
68
  msgstr ""
69
 
@@ -96,19 +96,27 @@ msgstr ""
96
  msgid " The rest of the content is not permitted for your membership level."
97
  msgstr ""
98
 
99
- #: classes/class.swpm-admin-registration.php:54
 
 
 
 
100
  msgid "Member record added successfully."
101
  msgstr ""
102
 
103
- #: classes/class.swpm-admin-registration.php:59
104
- #: classes/class.swpm-admin-registration.php:81
105
- #: classes/class.swpm-admin-registration.php:105
106
- #: classes/class.swpm-membership-level.php:43
107
- #: classes/class.swpm-membership-level.php:62
108
  msgid "Please correct the following:"
109
  msgstr ""
110
 
111
- #: classes/class.swpm-admin-registration.php:96
 
 
 
 
112
  msgid "Your current password"
113
  msgstr ""
114
 
@@ -152,43 +160,43 @@ msgid ""
152
  "ONLY for ADMIN user."
153
  msgstr ""
154
 
155
- #: classes/class.swpm-auth.php:64
156
  msgid "User Not Found."
157
  msgstr ""
158
 
159
- #: classes/class.swpm-auth.php:71
160
  msgid "Password Empty or Invalid."
161
  msgstr ""
162
 
163
- #: classes/class.swpm-auth.php:97
164
  msgid "Account is inactive."
165
  msgstr ""
166
 
167
- #: classes/class.swpm-auth.php:100 classes/class.swpm-auth.php:121
168
  msgid "Account has expired."
169
  msgstr ""
170
 
171
- #: classes/class.swpm-auth.php:103
172
  msgid "Account is pending."
173
  msgstr ""
174
 
175
- #: classes/class.swpm-auth.php:129
176
  msgid "You are logged in as:"
177
  msgstr ""
178
 
179
- #: classes/class.swpm-auth.php:175
180
  msgid "Logged Out Successfully."
181
  msgstr ""
182
 
183
- #: classes/class.swpm-auth.php:227
184
  msgid "Session Expired."
185
  msgstr ""
186
 
187
- #: classes/class.swpm-auth.php:236
188
  msgid "Invalid Username"
189
  msgstr ""
190
 
191
- #: classes/class.swpm-auth.php:244
192
  msgid "Please login again."
193
  msgstr ""
194
 
@@ -197,7 +205,7 @@ msgstr ""
197
  #: classes/class.swpm-membership-levels.php:21
198
  #: classes/admin-includes/class.swpm-payments-list-table.php:85
199
  #: views/add.php:30 views/admin_member_form_common_part.php:2
200
- #: views/edit.php:53
201
  #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:34
202
  #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:217
203
  #: views/payments/payment-gateway/admin_paypal_subscription_button.php:35
@@ -227,7 +235,7 @@ msgstr ""
227
  msgid "Count"
228
  msgstr ""
229
 
230
- #: classes/class.swpm-category-list.php:89
231
  msgid "Category protection updated!"
232
  msgstr ""
233
 
@@ -320,61 +328,65 @@ msgstr ""
320
  msgid "Security check: captcha validation failed."
321
  msgstr ""
322
 
323
- #: classes/class.swpm-front-registration.php:86
324
  msgid "Registration Successful. "
325
  msgstr ""
326
 
327
- #: classes/class.swpm-front-registration.php:86
328
  #: classes/class.swpm-utils-misc.php:218 classes/class.swpm-utils-misc.php:230
329
  msgid "Please"
330
  msgstr ""
331
 
332
- #: classes/class.swpm-front-registration.php:86
333
  #: classes/class.swpm-utils-misc.php:218 views/login.php:27
334
  msgid "Login"
335
  msgstr ""
336
 
337
- #: classes/class.swpm-front-registration.php:99
338
- #: classes/class.swpm-front-registration.php:186
339
  msgid "Please correct the following"
340
  msgstr ""
341
 
342
- #: classes/class.swpm-front-registration.php:130
343
  msgid "Membership Level Couldn't be found."
344
  msgstr ""
345
 
346
- #: classes/class.swpm-front-registration.php:169
 
 
 
 
347
  msgid "Profile updated successfully."
348
  msgstr ""
349
 
350
- #: classes/class.swpm-front-registration.php:177
351
  msgid ""
352
  "Profile updated successfully. You will need to re-login since you changed "
353
  "your password."
354
  msgstr ""
355
 
356
- #: classes/class.swpm-front-registration.php:196
357
  msgid "Email address not valid."
358
  msgstr ""
359
 
360
- #: classes/class.swpm-front-registration.php:207
361
  msgid "No user found with that email address."
362
  msgstr ""
363
 
364
- #: classes/class.swpm-front-registration.php:208
365
- #: classes/class.swpm-front-registration.php:234
366
  msgid "Email Address: "
367
  msgstr ""
368
 
369
- #: classes/class.swpm-front-registration.php:233
370
  msgid "New password has been sent to your email address."
371
  msgstr ""
372
 
373
- #: classes/class.swpm-init-time-tasks.php:111
374
  msgid "Sorry, Nonce verification failed."
375
  msgstr ""
376
 
377
- #: classes/class.swpm-init-time-tasks.php:118
378
  msgid "Sorry, Password didn't match."
379
  msgstr ""
380
 
@@ -396,25 +408,25 @@ msgid "ID"
396
  msgstr ""
397
 
398
  #: classes/class.swpm-members.php:21 views/add.php:6 views/admin_add.php:10
399
- #: views/admin_edit.php:13 views/edit.php:5 views/login.php:11
400
  msgid "Username"
401
  msgstr ""
402
 
403
  #: classes/class.swpm-members.php:22
404
  #: classes/admin-includes/class.swpm-payments-list-table.php:78
405
  #: views/add.php:22 views/admin_member_form_common_part.php:15
406
- #: views/edit.php:21
407
  msgid "First Name"
408
  msgstr ""
409
 
410
  #: classes/class.swpm-members.php:23
411
  #: classes/admin-includes/class.swpm-payments-list-table.php:79
412
  #: views/add.php:26 views/admin_member_form_common_part.php:19
413
- #: views/edit.php:25
414
  msgid "Last Name"
415
  msgstr ""
416
 
417
- #: classes/class.swpm-members.php:24 views/add.php:10 views/edit.php:9
418
  msgid "Email"
419
  msgstr ""
420
 
@@ -454,31 +466,46 @@ msgstr ""
454
  msgid "Set Status to Expired"
455
  msgstr ""
456
 
457
- #: classes/class.swpm-members.php:68
458
  msgid "incomplete"
459
  msgstr ""
460
 
461
- #: classes/class.swpm-members.php:183
462
  msgid "No member found."
463
  msgstr ""
464
 
465
- #: classes/class.swpm-members.php:399
 
 
 
 
466
  msgid "Simple WP Membership::Members"
467
  msgstr ""
468
 
469
- #: classes/class.swpm-members.php:400 views/admin_members_list.php:40
470
  msgid "Add New"
471
  msgstr ""
472
 
473
- #: classes/class.swpm-members.php:405 views/admin_add.php:5
474
  msgid "Add Member"
475
  msgstr ""
476
 
477
- #: classes/class.swpm-membership-level.php:38
 
 
 
 
 
 
478
  msgid "Membership Level Creation Successful."
479
  msgstr ""
480
 
481
- #: classes/class.swpm-membership-level.php:57
 
 
 
 
 
482
  msgid "Membership Level Updated Successfully."
483
  msgstr ""
484
 
@@ -490,25 +517,30 @@ msgstr ""
490
  msgid "Access Valid For/Until"
491
  msgstr ""
492
 
493
- #: classes/class.swpm-membership-levels.php:203
494
- #: views/admin_members_list.php:27
 
 
 
 
 
495
  #: views/payments/admin_all_payment_transactions.php:16
496
  msgid "Search"
497
  msgstr ""
498
 
499
- #: classes/class.swpm-membership-levels.php:241
500
  msgid "Simple WP Membership::Membership Levels"
501
  msgstr ""
502
 
503
- #: classes/class.swpm-membership-levels.php:246
504
  msgid "Add Level"
505
  msgstr ""
506
 
507
- #: classes/class.swpm-membership-levels.php:247
508
  msgid "Manage Content Production"
509
  msgstr ""
510
 
511
- #: classes/class.swpm-membership-levels.php:248
512
  msgid "Category Protection"
513
  msgstr ""
514
 
@@ -528,7 +560,7 @@ msgstr ""
528
  msgid "Tools"
529
  msgstr ""
530
 
531
- #: classes/class.swpm-settings.php:31 classes/class.swpm-settings.php:178
532
  msgid "Advanced Settings"
533
  msgstr ""
534
 
@@ -649,8 +681,8 @@ msgstr ""
649
  msgid "Enable this option if you want to do sandbox payment testing."
650
  msgstr ""
651
 
652
- #: classes/class.swpm-settings.php:115 classes/class.swpm-settings.php:173
653
- #: classes/class.swpm-settings.php:290
654
  msgid "Settings updated!"
655
  msgstr ""
656
 
@@ -666,15 +698,15 @@ msgstr ""
666
  msgid "Email Settings (Prompt to Complete Registration )"
667
  msgstr ""
668
 
669
- #: classes/class.swpm-settings.php:126 classes/class.swpm-settings.php:135
670
- #: classes/class.swpm-settings.php:148 classes/class.swpm-settings.php:153
671
- #: classes/class.swpm-settings.php:158
672
  msgid "Email Subject"
673
  msgstr ""
674
 
675
- #: classes/class.swpm-settings.php:128 classes/class.swpm-settings.php:137
676
- #: classes/class.swpm-settings.php:149 classes/class.swpm-settings.php:154
677
- #: classes/class.swpm-settings.php:159
678
  msgid "Email Body"
679
  msgstr ""
680
 
@@ -691,149 +723,160 @@ msgid ""
691
  msgstr ""
692
 
693
  #: classes/class.swpm-settings.php:134
 
 
 
 
 
 
 
694
  msgid "Email Settings (Registration Complete)"
695
  msgstr ""
696
 
697
- #: classes/class.swpm-settings.php:139
698
  msgid "Send Notification to Admin"
699
  msgstr ""
700
 
701
- #: classes/class.swpm-settings.php:140
702
  msgid ""
703
  "Enable this option if you want the admin to receive a notification when a "
704
  "member registers."
705
  msgstr ""
706
 
707
- #: classes/class.swpm-settings.php:141
708
  msgid "Admin Email Address"
709
  msgstr ""
710
 
711
- #: classes/class.swpm-settings.php:143
712
- msgid "Send Email to Member When Added via Admin Dashboard"
713
  msgstr ""
714
 
715
  #: classes/class.swpm-settings.php:147
 
 
 
 
716
  msgid "Email Settings (Password Reset)"
717
  msgstr ""
718
 
719
- #: classes/class.swpm-settings.php:152
720
  msgid " Email Settings (Account Upgrade Notification)"
721
  msgstr ""
722
 
723
- #: classes/class.swpm-settings.php:157
724
  msgid " Email Settings (Bulk Account Activate Notification)"
725
  msgstr ""
726
 
727
- #: classes/class.swpm-settings.php:180
728
  msgid "Enable Expired Account Login"
729
  msgstr ""
730
 
731
- #: classes/class.swpm-settings.php:181
732
  msgid ""
733
  "When enabled, expired members will be able to log into the system but won't "
734
  "be able to view any protected content. This allows them to easily renew "
735
  "their account by making another payment."
736
  msgstr ""
737
 
738
- #: classes/class.swpm-settings.php:183
739
  msgid "Membership Renewal URL"
740
  msgstr ""
741
 
742
- #: classes/class.swpm-settings.php:184
743
  msgid ""
744
  "You can create a renewal page for your site. Read <a href=\"https://simple-"
745
  "membership-plugin.com/creating-membership-renewal-button/\" target=\"_blank"
746
  "\">this documentation</a> to learn how to create a renewal page."
747
  msgstr ""
748
 
749
- #: classes/class.swpm-settings.php:186
750
  msgid "Allow Account Deletion"
751
  msgstr ""
752
 
753
- #: classes/class.swpm-settings.php:187
754
  msgid "Allow users to delete their accounts."
755
  msgstr ""
756
 
757
- #: classes/class.swpm-settings.php:189
758
  msgid "Use WordPress Timezone"
759
  msgstr ""
760
 
761
- #: classes/class.swpm-settings.php:190
762
  msgid ""
763
  "Use this option if you want to use the timezone value specified in your "
764
  "WordPress General Settings interface."
765
  msgstr ""
766
 
767
- #: classes/class.swpm-settings.php:192
768
  msgid "Auto Delete Pending Account"
769
  msgstr ""
770
 
771
- #: classes/class.swpm-settings.php:195
772
  msgid "Select how long you want to keep \"pending\" account."
773
  msgstr ""
774
 
775
- #: classes/class.swpm-settings.php:197
776
  msgid "Admin Dashboard Access Permission"
777
  msgstr ""
778
 
779
- #: classes/class.swpm-settings.php:200
780
  msgid ""
781
  "SWPM admin dashboard is accessible to admin users only (just like any other "
782
  "plugin). You can allow users with other WP user role to access the SWPM "
783
  "admin dashboard by selecting a value here."
784
  msgstr ""
785
 
786
- #: classes/class.swpm-settings.php:295
787
  msgid "General Plugin Settings."
788
  msgstr ""
789
 
790
- #: classes/class.swpm-settings.php:299
791
  msgid "Page Setup and URL Related settings."
792
  msgstr ""
793
 
794
- #: classes/class.swpm-settings.php:303
795
  msgid "Testing and Debug Related Settings."
796
  msgstr ""
797
 
798
- #: classes/class.swpm-settings.php:307
799
  msgid ""
800
  "This email will be sent to your users when they complete the registration "
801
  "and become a member."
802
  msgstr ""
803
 
804
- #: classes/class.swpm-settings.php:311
805
  msgid ""
806
  "This email will be sent to your users when they use the password reset "
807
  "functionality."
808
  msgstr ""
809
 
810
- #: classes/class.swpm-settings.php:315
811
  msgid "Settings in this section apply to all emails."
812
  msgstr ""
813
 
814
- #: classes/class.swpm-settings.php:319
815
  msgid ""
816
  "This email will be sent to your users after account upgrade (when an "
817
  "existing member pays for a new membership level)."
818
  msgstr ""
819
 
820
- #: classes/class.swpm-settings.php:323
821
  msgid ""
822
  "This email will be sent to your members when you use the bulk account "
823
  "activate and notify action."
824
  msgstr ""
825
 
826
- #: classes/class.swpm-settings.php:327
827
  msgid ""
828
  "This email will be sent to prompt users to complete registration after the "
829
  "payment."
830
  msgstr ""
831
 
832
- #: classes/class.swpm-settings.php:331
833
  msgid "This page allows you to configure some advanced features of the plugin."
834
  msgstr ""
835
 
836
- #: classes/class.swpm-settings.php:437
837
  msgid "Simple WP Membership::Settings"
838
  msgstr ""
839
 
@@ -876,31 +919,35 @@ msgstr ""
876
  msgid " your account to gain access to this content."
877
  msgstr ""
878
 
 
 
 
 
879
  #: classes/class.swpm-utils-template.php:38
880
  msgid "Error! Failed to find a template path for the specified template: "
881
  msgstr ""
882
 
883
- #: classes/class.swpm-utils.php:92
 
 
 
 
884
  msgid "Active"
885
  msgstr ""
886
 
887
- #: classes/class.swpm-utils.php:93
888
  msgid "Inactive"
889
  msgstr ""
890
 
891
- #: classes/class.swpm-utils.php:94
892
  msgid "Pending"
893
  msgstr ""
894
 
895
- #: classes/class.swpm-utils.php:95
896
  msgid "Expired"
897
  msgstr ""
898
 
899
- #: classes/class.swpm-utils.php:328
900
- msgid "Never"
901
- msgstr ""
902
-
903
- #: classes/class.swpm-utils.php:420
904
  msgid "Delete Account"
905
  msgstr ""
906
 
@@ -925,7 +972,7 @@ msgid "Button Shortcode"
925
  msgstr ""
926
 
927
  #: classes/admin-includes/class.swpm-payment-buttons-list-table.php:127
928
- #: views/admin_members_list.php:6
929
  #: views/payments/admin_all_payment_transactions.php:32
930
  msgid "The selected entry was deleted!"
931
  msgstr ""
@@ -999,15 +1046,15 @@ msgid "You are not logged-in as a member"
999
  msgstr ""
1000
 
1001
  #: views/add.php:14 views/admin_add.php:18 views/admin_edit.php:38
1002
- #: views/edit.php:13 views/login.php:17
1003
  msgid "Password"
1004
  msgstr ""
1005
 
1006
- #: views/add.php:18 views/edit.php:17
1007
  msgid "Repeat Password"
1008
  msgstr ""
1009
 
1010
- #: views/add.php:41
1011
  msgid "Register"
1012
  msgstr ""
1013
 
@@ -1158,14 +1205,22 @@ msgid "Subscriber ID/Reference"
1158
  msgstr ""
1159
 
1160
  #: views/admin_edit.php:65
 
 
 
 
 
 
 
 
1161
  msgid "Last Accessed From IP"
1162
  msgstr ""
1163
 
1164
- #: views/admin_edit.php:73
1165
  msgid "Edit User "
1166
  msgstr ""
1167
 
1168
- #: views/admin_edit.php:77
1169
  msgid "Delete User Profile"
1170
  msgstr ""
1171
 
@@ -1202,27 +1257,27 @@ msgstr ""
1202
  msgid "Gender"
1203
  msgstr ""
1204
 
1205
- #: views/admin_member_form_common_part.php:30 views/edit.php:29
1206
  msgid "Phone"
1207
  msgstr ""
1208
 
1209
- #: views/admin_member_form_common_part.php:34 views/edit.php:33
1210
  msgid "Street"
1211
  msgstr ""
1212
 
1213
- #: views/admin_member_form_common_part.php:38 views/edit.php:37
1214
  msgid "City"
1215
  msgstr ""
1216
 
1217
- #: views/admin_member_form_common_part.php:42 views/edit.php:41
1218
  msgid "State"
1219
  msgstr ""
1220
 
1221
- #: views/admin_member_form_common_part.php:46 views/edit.php:45
1222
  msgid "Zipcode"
1223
  msgstr ""
1224
 
1225
- #: views/admin_member_form_common_part.php:50 views/edit.php:49
1226
  msgid "Country"
1227
  msgstr ""
1228
 
@@ -1275,7 +1330,7 @@ msgstr ""
1275
  msgid "Registration completion links will appear below"
1276
  msgstr ""
1277
 
1278
- #: views/edit.php:60
1279
  msgid "Update"
1280
  msgstr ""
1281
 
@@ -1299,6 +1354,10 @@ msgstr ""
1299
  msgid "Logout"
1300
  msgstr ""
1301
 
 
 
 
 
1302
  #: views/login.php:24
1303
  msgid "Remember Me"
1304
  msgstr ""
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: Simple Membership\n"
4
+ "POT-Creation-Date: 2016-11-22 14:13+1000\n"
5
+ "PO-Revision-Date: 2016-11-22 14:14+1000\n"
6
  "Last-Translator: \n"
7
  "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
13
  "X-Poedit-Basepath: .\n"
14
  "X-Poedit-SearchPath-0: .\n"
15
 
16
+ #: classes/class.simple-wp-membership.php:293
17
  msgid "You are not logged in."
18
  msgstr ""
19
 
20
+ #: classes/class.simple-wp-membership.php:340
21
  msgid ""
22
  "You have the sandbox payment mode enabled in plugin settings. Make sure to "
23
  "turn off the sandbox mode when you want to do live transactions."
24
  msgstr ""
25
 
26
+ #: classes/class.simple-wp-membership.php:355
27
  msgid "Simple WP Membership Protection"
28
  msgstr ""
29
 
30
+ #: classes/class.simple-wp-membership.php:367
31
  msgid "Simple Membership Protection options"
32
  msgstr ""
33
 
39
  msgid "Select the membership level that can access this content:"
40
  msgstr ""
41
 
42
+ #: classes/class.simple-wp-membership.php:524
43
  msgid "WP Membership"
44
  msgstr ""
45
 
46
+ #: classes/class.simple-wp-membership.php:525
47
+ #: classes/class.swpm-members.php:12 classes/class.swpm-members.php:414
48
  msgid "Members"
49
  msgstr ""
50
 
51
+ #: classes/class.simple-wp-membership.php:526
52
  #: classes/class.swpm-category-list.php:20
53
  #: classes/class.swpm-membership-levels.php:12
54
+ #: classes/class.swpm-membership-levels.php:257
55
  msgid "Membership Levels"
56
  msgstr ""
57
 
58
+ #: classes/class.simple-wp-membership.php:527
59
  msgid "Settings"
60
  msgstr ""
61
 
62
+ #: classes/class.simple-wp-membership.php:528
63
  msgid "Payments"
64
  msgstr ""
65
 
66
+ #: classes/class.simple-wp-membership.php:529
67
  msgid "Add-ons"
68
  msgstr ""
69
 
96
  msgid " The rest of the content is not permitted for your membership level."
97
  msgstr ""
98
 
99
+ #: classes/class.swpm-admin-registration.php:25
100
+ msgid "Error! Nonce verification failed for user registration from admin end."
101
+ msgstr ""
102
+
103
+ #: classes/class.swpm-admin-registration.php:66
104
  msgid "Member record added successfully."
105
  msgstr ""
106
 
107
+ #: classes/class.swpm-admin-registration.php:71
108
+ #: classes/class.swpm-admin-registration.php:102
109
+ #: classes/class.swpm-admin-registration.php:126
110
+ #: classes/class.swpm-membership-level.php:69
111
+ #: classes/class.swpm-membership-level.php:97
112
  msgid "Please correct the following:"
113
  msgstr ""
114
 
115
+ #: classes/class.swpm-admin-registration.php:82
116
+ msgid "Error! Nonce verification failed for user edit from admin end."
117
+ msgstr ""
118
+
119
+ #: classes/class.swpm-admin-registration.php:117
120
  msgid "Your current password"
121
  msgstr ""
122
 
160
  "ONLY for ADMIN user."
161
  msgstr ""
162
 
163
+ #: classes/class.swpm-auth.php:74
164
  msgid "User Not Found."
165
  msgstr ""
166
 
167
+ #: classes/class.swpm-auth.php:81
168
  msgid "Password Empty or Invalid."
169
  msgstr ""
170
 
171
+ #: classes/class.swpm-auth.php:118
172
  msgid "Account is inactive."
173
  msgstr ""
174
 
175
+ #: classes/class.swpm-auth.php:121 classes/class.swpm-auth.php:139
176
  msgid "Account has expired."
177
  msgstr ""
178
 
179
+ #: classes/class.swpm-auth.php:124
180
  msgid "Account is pending."
181
  msgstr ""
182
 
183
+ #: classes/class.swpm-auth.php:147
184
  msgid "You are logged in as:"
185
  msgstr ""
186
 
187
+ #: classes/class.swpm-auth.php:193
188
  msgid "Logged Out Successfully."
189
  msgstr ""
190
 
191
+ #: classes/class.swpm-auth.php:245
192
  msgid "Session Expired."
193
  msgstr ""
194
 
195
+ #: classes/class.swpm-auth.php:254
196
  msgid "Invalid Username"
197
  msgstr ""
198
 
199
+ #: classes/class.swpm-auth.php:262
200
  msgid "Please login again."
201
  msgstr ""
202
 
205
  #: classes/class.swpm-membership-levels.php:21
206
  #: classes/admin-includes/class.swpm-payments-list-table.php:85
207
  #: views/add.php:30 views/admin_member_form_common_part.php:2
208
+ #: views/edit.php:62
209
  #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:34
210
  #: views/payments/payment-gateway/admin_paypal_buy_now_button.php:217
211
  #: views/payments/payment-gateway/admin_paypal_subscription_button.php:35
235
  msgid "Count"
236
  msgstr ""
237
 
238
+ #: classes/class.swpm-category-list.php:92
239
  msgid "Category protection updated!"
240
  msgstr ""
241
 
328
  msgid "Security check: captcha validation failed."
329
  msgstr ""
330
 
331
+ #: classes/class.swpm-front-registration.php:100
332
  msgid "Registration Successful. "
333
  msgstr ""
334
 
335
+ #: classes/class.swpm-front-registration.php:100
336
  #: classes/class.swpm-utils-misc.php:218 classes/class.swpm-utils-misc.php:230
337
  msgid "Please"
338
  msgstr ""
339
 
340
+ #: classes/class.swpm-front-registration.php:100
341
  #: classes/class.swpm-utils-misc.php:218 views/login.php:27
342
  msgid "Login"
343
  msgstr ""
344
 
345
+ #: classes/class.swpm-front-registration.php:113
346
+ #: classes/class.swpm-front-registration.php:220
347
  msgid "Please correct the following"
348
  msgstr ""
349
 
350
+ #: classes/class.swpm-front-registration.php:144
351
  msgid "Membership Level Couldn't be found."
352
  msgstr ""
353
 
354
+ #: classes/class.swpm-front-registration.php:195
355
+ msgid "Error! Nonce verification failed for front end profile edit."
356
+ msgstr ""
357
+
358
+ #: classes/class.swpm-front-registration.php:203
359
  msgid "Profile updated successfully."
360
  msgstr ""
361
 
362
+ #: classes/class.swpm-front-registration.php:211
363
  msgid ""
364
  "Profile updated successfully. You will need to re-login since you changed "
365
  "your password."
366
  msgstr ""
367
 
368
+ #: classes/class.swpm-front-registration.php:230
369
  msgid "Email address not valid."
370
  msgstr ""
371
 
372
+ #: classes/class.swpm-front-registration.php:241
373
  msgid "No user found with that email address."
374
  msgstr ""
375
 
376
+ #: classes/class.swpm-front-registration.php:242
377
+ #: classes/class.swpm-front-registration.php:268
378
  msgid "Email Address: "
379
  msgstr ""
380
 
381
+ #: classes/class.swpm-front-registration.php:267
382
  msgid "New password has been sent to your email address."
383
  msgstr ""
384
 
385
+ #: classes/class.swpm-init-time-tasks.php:112
386
  msgid "Sorry, Nonce verification failed."
387
  msgstr ""
388
 
389
+ #: classes/class.swpm-init-time-tasks.php:119
390
  msgid "Sorry, Password didn't match."
391
  msgstr ""
392
 
408
  msgstr ""
409
 
410
  #: classes/class.swpm-members.php:21 views/add.php:6 views/admin_add.php:10
411
+ #: views/admin_edit.php:13 views/edit.php:14
412
  msgid "Username"
413
  msgstr ""
414
 
415
  #: classes/class.swpm-members.php:22
416
  #: classes/admin-includes/class.swpm-payments-list-table.php:78
417
  #: views/add.php:22 views/admin_member_form_common_part.php:15
418
+ #: views/edit.php:30
419
  msgid "First Name"
420
  msgstr ""
421
 
422
  #: classes/class.swpm-members.php:23
423
  #: classes/admin-includes/class.swpm-payments-list-table.php:79
424
  #: views/add.php:26 views/admin_member_form_common_part.php:19
425
+ #: views/edit.php:34
426
  msgid "Last Name"
427
  msgstr ""
428
 
429
+ #: classes/class.swpm-members.php:24 views/add.php:10 views/edit.php:18
430
  msgid "Email"
431
  msgstr ""
432
 
466
  msgid "Set Status to Expired"
467
  msgstr ""
468
 
469
+ #: classes/class.swpm-members.php:69
470
  msgid "incomplete"
471
  msgstr ""
472
 
473
+ #: classes/class.swpm-members.php:184
474
  msgid "No member found."
475
  msgstr ""
476
 
477
+ #: classes/class.swpm-members.php:331
478
+ msgid "Error! Nonce verification failed for user delete from admin end."
479
+ msgstr ""
480
+
481
+ #: classes/class.swpm-members.php:409
482
  msgid "Simple WP Membership::Members"
483
  msgstr ""
484
 
485
+ #: classes/class.swpm-members.php:410 views/admin_members_list.php:43
486
  msgid "Add New"
487
  msgstr ""
488
 
489
+ #: classes/class.swpm-members.php:415 views/admin_add.php:5
490
  msgid "Add Member"
491
  msgstr ""
492
 
493
+ #: classes/class.swpm-membership-level.php:52
494
+ msgid ""
495
+ "Error! Nonce verification failed for membership level creation from admin "
496
+ "end."
497
+ msgstr ""
498
+
499
+ #: classes/class.swpm-membership-level.php:64
500
  msgid "Membership Level Creation Successful."
501
  msgstr ""
502
 
503
+ #: classes/class.swpm-membership-level.php:80
504
+ msgid ""
505
+ "Error! Nonce verification failed for membership level edit from admin end."
506
+ msgstr ""
507
+
508
+ #: classes/class.swpm-membership-level.php:92
509
  msgid "Membership Level Updated Successfully."
510
  msgstr ""
511
 
517
  msgid "Access Valid For/Until"
518
  msgstr ""
519
 
520
+ #: classes/class.swpm-membership-levels.php:196
521
+ msgid ""
522
+ "Error! Nonce verification failed for membership level delete from admin end."
523
+ msgstr ""
524
+
525
+ #: classes/class.swpm-membership-levels.php:215
526
+ #: views/admin_members_list.php:30
527
  #: views/payments/admin_all_payment_transactions.php:16
528
  msgid "Search"
529
  msgstr ""
530
 
531
+ #: classes/class.swpm-membership-levels.php:253
532
  msgid "Simple WP Membership::Membership Levels"
533
  msgstr ""
534
 
535
+ #: classes/class.swpm-membership-levels.php:258
536
  msgid "Add Level"
537
  msgstr ""
538
 
539
+ #: classes/class.swpm-membership-levels.php:259
540
  msgid "Manage Content Production"
541
  msgstr ""
542
 
543
+ #: classes/class.swpm-membership-levels.php:260
544
  msgid "Category Protection"
545
  msgstr ""
546
 
560
  msgid "Tools"
561
  msgstr ""
562
 
563
+ #: classes/class.swpm-settings.php:31 classes/class.swpm-settings.php:182
564
  msgid "Advanced Settings"
565
  msgstr ""
566
 
681
  msgid "Enable this option if you want to do sandbox payment testing."
682
  msgstr ""
683
 
684
+ #: classes/class.swpm-settings.php:115 classes/class.swpm-settings.php:177
685
+ #: classes/class.swpm-settings.php:294
686
  msgid "Settings updated!"
687
  msgstr ""
688
 
698
  msgid "Email Settings (Prompt to Complete Registration )"
699
  msgstr ""
700
 
701
+ #: classes/class.swpm-settings.php:126 classes/class.swpm-settings.php:136
702
+ #: classes/class.swpm-settings.php:152 classes/class.swpm-settings.php:157
703
+ #: classes/class.swpm-settings.php:162
704
  msgid "Email Subject"
705
  msgstr ""
706
 
707
+ #: classes/class.swpm-settings.php:128 classes/class.swpm-settings.php:138
708
+ #: classes/class.swpm-settings.php:153 classes/class.swpm-settings.php:158
709
+ #: classes/class.swpm-settings.php:163
710
  msgid "Email Body"
711
  msgstr ""
712
 
723
  msgstr ""
724
 
725
  #: classes/class.swpm-settings.php:134
726
+ msgid ""
727
+ "This email will be sent to the admin when a new user completes the "
728
+ "membership registration. Only works if you have enabled the \"Send "
729
+ "Notification to Admin\" option above."
730
+ msgstr ""
731
+
732
+ #: classes/class.swpm-settings.php:135
733
  msgid "Email Settings (Registration Complete)"
734
  msgstr ""
735
 
736
+ #: classes/class.swpm-settings.php:140
737
  msgid "Send Notification to Admin"
738
  msgstr ""
739
 
740
+ #: classes/class.swpm-settings.php:141
741
  msgid ""
742
  "Enable this option if you want the admin to receive a notification when a "
743
  "member registers."
744
  msgstr ""
745
 
746
+ #: classes/class.swpm-settings.php:142
747
  msgid "Admin Email Address"
748
  msgstr ""
749
 
750
+ #: classes/class.swpm-settings.php:144
751
+ msgid "Admin Notification Email Body"
752
  msgstr ""
753
 
754
  #: classes/class.swpm-settings.php:147
755
+ msgid "Send Email to Member When Added via Admin Dashboard"
756
+ msgstr ""
757
+
758
+ #: classes/class.swpm-settings.php:151
759
  msgid "Email Settings (Password Reset)"
760
  msgstr ""
761
 
762
+ #: classes/class.swpm-settings.php:156
763
  msgid " Email Settings (Account Upgrade Notification)"
764
  msgstr ""
765
 
766
+ #: classes/class.swpm-settings.php:161
767
  msgid " Email Settings (Bulk Account Activate Notification)"
768
  msgstr ""
769
 
770
+ #: classes/class.swpm-settings.php:184
771
  msgid "Enable Expired Account Login"
772
  msgstr ""
773
 
774
+ #: classes/class.swpm-settings.php:185
775
  msgid ""
776
  "When enabled, expired members will be able to log into the system but won't "
777
  "be able to view any protected content. This allows them to easily renew "
778
  "their account by making another payment."
779
  msgstr ""
780
 
781
+ #: classes/class.swpm-settings.php:187
782
  msgid "Membership Renewal URL"
783
  msgstr ""
784
 
785
+ #: classes/class.swpm-settings.php:188
786
  msgid ""
787
  "You can create a renewal page for your site. Read <a href=\"https://simple-"
788
  "membership-plugin.com/creating-membership-renewal-button/\" target=\"_blank"
789
  "\">this documentation</a> to learn how to create a renewal page."
790
  msgstr ""
791
 
792
+ #: classes/class.swpm-settings.php:190
793
  msgid "Allow Account Deletion"
794
  msgstr ""
795
 
796
+ #: classes/class.swpm-settings.php:191
797
  msgid "Allow users to delete their accounts."
798
  msgstr ""
799
 
800
+ #: classes/class.swpm-settings.php:193
801
  msgid "Use WordPress Timezone"
802
  msgstr ""
803
 
804
+ #: classes/class.swpm-settings.php:194
805
  msgid ""
806
  "Use this option if you want to use the timezone value specified in your "
807
  "WordPress General Settings interface."
808
  msgstr ""
809
 
810
+ #: classes/class.swpm-settings.php:196
811
  msgid "Auto Delete Pending Account"
812
  msgstr ""
813
 
814
+ #: classes/class.swpm-settings.php:199
815
  msgid "Select how long you want to keep \"pending\" account."
816
  msgstr ""
817
 
818
+ #: classes/class.swpm-settings.php:201
819
  msgid "Admin Dashboard Access Permission"
820
  msgstr ""
821
 
822
+ #: classes/class.swpm-settings.php:204
823
  msgid ""
824
  "SWPM admin dashboard is accessible to admin users only (just like any other "
825
  "plugin). You can allow users with other WP user role to access the SWPM "
826
  "admin dashboard by selecting a value here."
827
  msgstr ""
828
 
829
+ #: classes/class.swpm-settings.php:299
830
  msgid "General Plugin Settings."
831
  msgstr ""
832
 
833
+ #: classes/class.swpm-settings.php:303
834
  msgid "Page Setup and URL Related settings."
835
  msgstr ""
836
 
837
+ #: classes/class.swpm-settings.php:307
838
  msgid "Testing and Debug Related Settings."
839
  msgstr ""
840
 
841
+ #: classes/class.swpm-settings.php:311
842
  msgid ""
843
  "This email will be sent to your users when they complete the registration "
844
  "and become a member."
845
  msgstr ""
846
 
847
+ #: classes/class.swpm-settings.php:315
848
  msgid ""
849
  "This email will be sent to your users when they use the password reset "
850
  "functionality."
851
  msgstr ""
852
 
853
+ #: classes/class.swpm-settings.php:319
854
  msgid "Settings in this section apply to all emails."
855
  msgstr ""
856
 
857
+ #: classes/class.swpm-settings.php:323
858
  msgid ""
859
  "This email will be sent to your users after account upgrade (when an "
860
  "existing member pays for a new membership level)."
861
  msgstr ""
862
 
863
+ #: classes/class.swpm-settings.php:327
864
  msgid ""
865
  "This email will be sent to your members when you use the bulk account "
866
  "activate and notify action."
867
  msgstr ""
868
 
869
+ #: classes/class.swpm-settings.php:331
870
  msgid ""
871
  "This email will be sent to prompt users to complete registration after the "
872
  "payment."
873
  msgstr ""
874
 
875
+ #: classes/class.swpm-settings.php:335
876
  msgid "This page allows you to configure some advanced features of the plugin."
877
  msgstr ""
878
 
879
+ #: classes/class.swpm-settings.php:442
880
  msgid "Simple WP Membership::Settings"
881
  msgstr ""
882
 
919
  msgid " your account to gain access to this content."
920
  msgstr ""
921
 
922
+ #: classes/class.swpm-utils-misc.php:272 classes/class.swpm-utils-misc.php:278
923
+ msgid "Error! This action ("
924
+ msgstr ""
925
+
926
  #: classes/class.swpm-utils-template.php:38
927
  msgid "Error! Failed to find a template path for the specified template: "
928
  msgstr ""
929
 
930
+ #: classes/class.swpm-utils.php:100
931
+ msgid "Never"
932
+ msgstr ""
933
+
934
+ #: classes/class.swpm-utils.php:115
935
  msgid "Active"
936
  msgstr ""
937
 
938
+ #: classes/class.swpm-utils.php:116
939
  msgid "Inactive"
940
  msgstr ""
941
 
942
+ #: classes/class.swpm-utils.php:117
943
  msgid "Pending"
944
  msgstr ""
945
 
946
+ #: classes/class.swpm-utils.php:118
947
  msgid "Expired"
948
  msgstr ""
949
 
950
+ #: classes/class.swpm-utils.php:437
 
 
 
 
951
  msgid "Delete Account"
952
  msgstr ""
953
 
972
  msgstr ""
973
 
974
  #: classes/admin-includes/class.swpm-payment-buttons-list-table.php:127
975
+ #: views/admin_members_list.php:9
976
  #: views/payments/admin_all_payment_transactions.php:32
977
  msgid "The selected entry was deleted!"
978
  msgstr ""
1046
  msgstr ""
1047
 
1048
  #: views/add.php:14 views/admin_add.php:18 views/admin_edit.php:38
1049
+ #: views/edit.php:22 views/login.php:17
1050
  msgid "Password"
1051
  msgstr ""
1052
 
1053
+ #: views/add.php:18 views/edit.php:26
1054
  msgid "Repeat Password"
1055
  msgstr ""
1056
 
1057
+ #: views/add.php:52
1058
  msgid "Register"
1059
  msgstr ""
1060
 
1205
  msgstr ""
1206
 
1207
  #: views/admin_edit.php:65
1208
+ msgid "Last Accessed Date"
1209
+ msgstr ""
1210
+
1211
+ #: views/admin_edit.php:68 views/admin_edit.php:75
1212
+ msgid "This value gets updated when this member logs into your site."
1213
+ msgstr ""
1214
+
1215
+ #: views/admin_edit.php:72
1216
  msgid "Last Accessed From IP"
1217
  msgstr ""
1218
 
1219
+ #: views/admin_edit.php:83
1220
  msgid "Edit User "
1221
  msgstr ""
1222
 
1223
+ #: views/admin_edit.php:88
1224
  msgid "Delete User Profile"
1225
  msgstr ""
1226
 
1257
  msgid "Gender"
1258
  msgstr ""
1259
 
1260
+ #: views/admin_member_form_common_part.php:30 views/edit.php:38
1261
  msgid "Phone"
1262
  msgstr ""
1263
 
1264
+ #: views/admin_member_form_common_part.php:34 views/edit.php:42
1265
  msgid "Street"
1266
  msgstr ""
1267
 
1268
+ #: views/admin_member_form_common_part.php:38 views/edit.php:46
1269
  msgid "City"
1270
  msgstr ""
1271
 
1272
+ #: views/admin_member_form_common_part.php:42 views/edit.php:50
1273
  msgid "State"
1274
  msgstr ""
1275
 
1276
+ #: views/admin_member_form_common_part.php:46 views/edit.php:54
1277
  msgid "Zipcode"
1278
  msgstr ""
1279
 
1280
+ #: views/admin_member_form_common_part.php:50 views/edit.php:58
1281
  msgid "Country"
1282
  msgstr ""
1283
 
1330
  msgid "Registration completion links will appear below"
1331
  msgstr ""
1332
 
1333
+ #: views/edit.php:69
1334
  msgid "Update"
1335
  msgstr ""
1336
 
1354
  msgid "Logout"
1355
  msgstr ""
1356
 
1357
+ #: views/login.php:11
1358
+ msgid "Username or Email"
1359
+ msgstr ""
1360
+
1361
  #: views/login.php:24
1362
  msgid "Remember Me"
1363
  msgstr ""
lib/braintree/index.html ADDED
File without changes
lib/braintree/lib/Braintree.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Braintree PHP Library
4
+ * Creates class_aliases for old class names replaced by PSR-4 Namespaces
5
+ *
6
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
7
+ */
8
+
9
+ require_once(__DIR__ . DIRECTORY_SEPARATOR . 'autoload.php');
10
+
11
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
12
+ throw new Braintree_Exception('PHP version >= 5.4.0 required');
13
+ }
14
+
15
+
16
+ function requireDependencies() {
17
+ $requiredExtensions = ['xmlwriter', 'openssl', 'dom', 'hash', 'curl'];
18
+ foreach ($requiredExtensions AS $ext) {
19
+ if (!extension_loaded($ext)) {
20
+ throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.');
21
+ }
22
+ }
23
+ }
24
+
25
+ requireDependencies();
lib/braintree/lib/Braintree/AccountUpdaterDailyReport.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Creates an instance of AccountUpdaterDailyReport
6
+ *
7
+ *
8
+ * @package Braintree
9
+ * @copyright 2016 Braintree, a division of PayPal, Inc.
10
+ *
11
+ * @property-read string $reportUrl
12
+ * @property-read date $reportDate
13
+ * @property-read date $receivedDate
14
+ */
15
+ class AccountUpdaterDailyReport extends Base
16
+ {
17
+ protected $_attributes = [];
18
+
19
+ protected function _initialize($disputeAttribs)
20
+ {
21
+ $this->_attributes = $disputeAttribs;
22
+ }
23
+
24
+ public static function factory($attributes)
25
+ {
26
+ $instance = new self();
27
+ $instance->_initialize($attributes);
28
+ return $instance;
29
+ }
30
+
31
+ public function __toString()
32
+ {
33
+ $display = [
34
+ 'reportDate', 'reportUrl'
35
+ ];
36
+
37
+ $displayAttributes = [];
38
+ foreach ($display AS $attrib) {
39
+ $displayAttributes[$attrib] = $this->$attrib;
40
+ }
41
+ return __CLASS__ . '[' .
42
+ Util::attributesToString($displayAttributes) .']';
43
+ }
44
+ }
45
+ class_alias('Braintree\AccountUpdaterDailyReport', 'Braintree_AccountUpdaterDailyReport');
lib/braintree/lib/Braintree/AddOn.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class AddOn extends Modification
5
+ {
6
+ /**
7
+ *
8
+ * @param array $attributes
9
+ * @return AddOn
10
+ */
11
+ public static function factory($attributes)
12
+ {
13
+ $instance = new self();
14
+ $instance->_initialize($attributes);
15
+ return $instance;
16
+ }
17
+
18
+
19
+ /**
20
+ * static methods redirecting to gateway
21
+ *
22
+ * @return AddOn[]
23
+ */
24
+ public static function all()
25
+ {
26
+ return Configuration::gateway()->addOn()->all();
27
+ }
28
+ }
29
+ class_alias('Braintree\AddOn', 'Braintree_AddOn');
lib/braintree/lib/Braintree/AddOnGateway.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class AddOnGateway
5
+ {
6
+ /**
7
+ *
8
+ * @var Gateway
9
+ */
10
+ private $_gateway;
11
+
12
+ /**
13
+ *
14
+ * @var Configuration
15
+ */
16
+ private $_config;
17
+
18
+ /**
19
+ *
20
+ * @var Http
21
+ */
22
+ private $_http;
23
+
24
+ /**
25
+ *
26
+ * @param Gateway $gateway
27
+ */
28
+ public function __construct($gateway)
29
+ {
30
+ $this->_gateway = $gateway;
31
+ $this->_config = $gateway->config;
32
+ $this->_config->assertHasAccessTokenOrKeys();
33
+ $this->_http = new Http($gateway->config);
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @return AddOn[]
39
+ */
40
+ public function all()
41
+ {
42
+ $path = $this->_config->merchantPath() . '/add_ons';
43
+ $response = $this->_http->get($path);
44
+
45
+ $addOns = ["addOn" => $response['addOns']];
46
+
47
+ return Util::extractAttributeAsArray(
48
+ $addOns,
49
+ 'addOn'
50
+ );
51
+ }
52
+ }
53
+ class_alias('Braintree\AddOnGateway', 'Braintree_AddOnGateway');
lib/braintree/lib/Braintree/Address.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Address module
6
+ * PHP Version 5
7
+ * Creates and manages Braintree Addresses
8
+ *
9
+ * An Address belongs to a Customer. It can be associated to a
10
+ * CreditCard as the billing address. It can also be used
11
+ * as the shipping address when creating a Transaction.
12
+ *
13
+ * @package Braintree
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read string $company
17
+ * @property-read string $countryName
18
+ * @property-read string $createdAt
19
+ * @property-read string $customerId
20
+ * @property-read string $extendedAddress
21
+ * @property-read string $firstName
22
+ * @property-read string $id
23
+ * @property-read string $lastName
24
+ * @property-read string $locality
25
+ * @property-read string $postalCode
26
+ * @property-read string $region
27
+ * @property-read string $streetAddress
28
+ * @property-read string $updatedAt
29
+ */
30
+ class Address extends Base
31
+ {
32
+ /**
33
+ * returns false if comparing object is not a Address,
34
+ * or is a Address with a different id
35
+ *
36
+ * @param object $other address to compare against
37
+ * @return boolean
38
+ */
39
+ public function isEqual($other)
40
+ {
41
+ return !($other instanceof self) ?
42
+ false :
43
+ ($this->id === $other->id && $this->customerId === $other->customerId);
44
+ }
45
+
46
+ /**
47
+ * create a printable representation of the object as:
48
+ * ClassName[property=value, property=value]
49
+ * @ignore
50
+ * @return string
51
+ */
52
+ public function __toString()
53
+ {
54
+ return __CLASS__ . '[' .
55
+ Util::attributesToString($this->_attributes) . ']';
56
+ }
57
+
58
+ /**
59
+ * sets instance properties from an array of values
60
+ *
61
+ * @ignore
62
+ * @access protected
63
+ * @param array $addressAttribs array of address data
64
+ * @return void
65
+ */
66
+ protected function _initialize($addressAttribs)
67
+ {
68
+ // set the attributes
69
+ $this->_attributes = $addressAttribs;
70
+ }
71
+
72
+ /**
73
+ * factory method: returns an instance of Address
74
+ * to the requesting method, with populated properties
75
+ * @ignore
76
+ * @return Address
77
+ */
78
+ public static function factory($attributes)
79
+ {
80
+ $instance = new self();
81
+ $instance->_initialize($attributes);
82
+ return $instance;
83
+
84
+ }
85
+
86
+
87
+ // static methods redirecting to gateway
88
+
89
+ /**
90
+ *
91
+ * @param array $attribs
92
+ * @return Address
93
+ */
94
+ public static function create($attribs)
95
+ {
96
+ return Configuration::gateway()->address()->create($attribs);
97
+ }
98
+
99
+ /**
100
+ *
101
+ * @param array $attribs
102
+ * @return Address
103
+ */
104
+ public static function createNoValidate($attribs)
105
+ {
106
+ return Configuration::gateway()->address()->createNoValidate($attribs);
107
+ }
108
+
109
+ /**
110
+ *
111
+ * @param Customer|int $customerOrId
112
+ * @param int $addressId
113
+ * @throws InvalidArgumentException
114
+ * @return Result\Successful
115
+ */
116
+ public static function delete($customerOrId = null, $addressId = null)
117
+ {
118
+ return Configuration::gateway()->address()->delete($customerOrId, $addressId);
119
+ }
120
+
121
+ /**
122
+ *
123
+ * @param Customer|int $customerOrId
124
+ * @param int $addressId
125
+ * @throws Exception\NotFound
126
+ * @return Address
127
+ */
128
+ public static function find($customerOrId, $addressId)
129
+ {
130
+ return Configuration::gateway()->address()->find($customerOrId, $addressId);
131
+ }
132
+
133
+ /**
134
+ *
135
+ * @param Customer|int $customerOrId
136
+ * @param int $addressId
137
+ * @param array $attributes
138
+ * @throws Exception\Unexpected
139
+ * @return Result\Successful|Result\Error
140
+ */
141
+ public static function update($customerOrId, $addressId, $attributes)
142
+ {
143
+ return Configuration::gateway()->address()->update($customerOrId, $addressId, $attributes);
144
+ }
145
+
146
+ public static function updateNoValidate($customerOrId, $addressId, $attributes)
147
+ {
148
+ return Configuration::gateway()->address()->updateNoValidate($customerOrId, $addressId, $attributes);
149
+ }
150
+ }
151
+ class_alias('Braintree\Address', 'Braintree_Address');
lib/braintree/lib/Braintree/AddressGateway.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree AddressGateway module
8
+ * PHP Version 5
9
+ * Creates and manages Braintree Addresses
10
+ *
11
+ * An Address belongs to a Customer. It can be associated to a
12
+ * CreditCard as the billing address. It can also be used
13
+ * as the shipping address when creating a Transaction.
14
+ *
15
+ * @package Braintree
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
+ */
18
+ class AddressGateway
19
+ {
20
+ /**
21
+ *
22
+ * @var Gateway
23
+ */
24
+ private $_gateway;
25
+
26
+ /**
27
+ *
28
+ * @var Configuration
29
+ */
30
+ private $_config;
31
+
32
+ /**
33
+ *
34
+ * @var Http
35
+ */
36
+ private $_http;
37
+
38
+ /**
39
+ *
40
+ * @param Gateway $gateway
41
+ */
42
+ public function __construct($gateway)
43
+ {
44
+ $this->_gateway = $gateway;
45
+ $this->_config = $gateway->config;
46
+ $this->_config->assertHasAccessTokenOrKeys();
47
+ $this->_http = new Http($gateway->config);
48
+ }
49
+
50
+
51
+ /* public class methods */
52
+ /**
53
+ *
54
+ * @access public
55
+ * @param array $attribs
56
+ * @return Result\Successful|Result\Error
57
+ */
58
+ public function create($attribs)
59
+ {
60
+ Util::verifyKeys(self::createSignature(), $attribs);
61
+ $customerId = isset($attribs['customerId']) ?
62
+ $attribs['customerId'] :
63
+ null;
64
+
65
+ $this->_validateCustomerId($customerId);
66
+ unset($attribs['customerId']);
67
+ try {
68
+ return $this->_doCreate(
69
+ '/customers/' . $customerId . '/addresses',
70
+ ['address' => $attribs]
71
+ );
72
+ } catch (Exception\NotFound $e) {
73
+ throw new Exception\NotFound(
74
+ 'Customer ' . $customerId . ' not found.'
75
+ );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * attempts the create operation assuming all data will validate
81
+ * returns a Address object instead of a Result
82
+ *
83
+ * @access public
84
+ * @param array $attribs
85
+ * @return self
86
+ * @throws Exception\ValidationError
87
+ */
88
+ public function createNoValidate($attribs)
89
+ {
90
+ $result = $this->create($attribs);
91
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
92
+
93
+ }
94
+
95
+ /**
96
+ * delete an address by id
97
+ *
98
+ * @param mixed $customerOrId
99
+ * @param string $addressId
100
+ */
101
+ public function delete($customerOrId = null, $addressId = null)
102
+ {
103
+ $this->_validateId($addressId);
104
+ $customerId = $this->_determineCustomerId($customerOrId);
105
+ $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
106
+ $this->_http->delete($path);
107
+ return new Result\Successful();
108
+ }
109
+
110
+ /**
111
+ * find an address by id
112
+ *
113
+ * Finds the address with the given <b>addressId</b> that is associated
114
+ * to the given <b>customerOrId</b>.
115
+ * If the address cannot be found, a NotFound exception will be thrown.
116
+ *
117
+ *
118
+ * @access public
119
+ * @param mixed $customerOrId
120
+ * @param string $addressId
121
+ * @return Address
122
+ * @throws Exception\NotFound
123
+ */
124
+ public function find($customerOrId, $addressId)
125
+ {
126
+
127
+ $customerId = $this->_determineCustomerId($customerOrId);
128
+ $this->_validateId($addressId);
129
+
130
+ try {
131
+ $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
132
+ $response = $this->_http->get($path);
133
+ return Address::factory($response['address']);
134
+ } catch (Exception\NotFound $e) {
135
+ throw new Exception\NotFound(
136
+ 'address for customer ' . $customerId .
137
+ ' with id ' . $addressId . ' not found.'
138
+ );
139
+ }
140
+
141
+ }
142
+
143
+ /**
144
+ * updates the address record
145
+ *
146
+ * if calling this method in context,
147
+ * customerOrId is the 2nd attribute, addressId 3rd.
148
+ * customerOrId & addressId are not sent in object context.
149
+ *
150
+ *
151
+ * @access public
152
+ * @param array $attributes
153
+ * @param mixed $customerOrId (only used in call)
154
+ * @param string $addressId (only used in call)
155
+ * @return Result\Successful|Result\Error
156
+ */
157
+ public function update($customerOrId, $addressId, $attributes)
158
+ {
159
+ $this->_validateId($addressId);
160
+ $customerId = $this->_determineCustomerId($customerOrId);
161
+ Util::verifyKeys(self::updateSignature(), $attributes);
162
+
163
+ $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId;
164
+ $response = $this->_http->put($path, ['address' => $attributes]);
165
+
166
+ return $this->_verifyGatewayResponse($response);
167
+
168
+ }
169
+
170
+ /**
171
+ * update an address record, assuming validations will pass
172
+ *
173
+ * if calling this method in context,
174
+ * customerOrId is the 2nd attribute, addressId 3rd.
175
+ * customerOrId & addressId are not sent in object context.
176
+ *
177
+ * @access public
178
+ * @param array $transactionAttribs
179
+ * @param string $customerId
180
+ * @return Transaction
181
+ * @throws Exception\ValidationsFailed
182
+ * @see Address::update()
183
+ */
184
+ public function updateNoValidate($customerOrId, $addressId, $attributes)
185
+ {
186
+ $result = $this->update($customerOrId, $addressId, $attributes);
187
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
188
+ }
189
+
190
+ /**
191
+ * creates a full array signature of a valid create request
192
+ * @return array gateway create request format
193
+ */
194
+ public static function createSignature()
195
+ {
196
+ return [
197
+ 'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
198
+ 'countryName', 'customerId', 'extendedAddress', 'firstName',
199
+ 'lastName', 'locality', 'postalCode', 'region', 'streetAddress'
200
+ ];
201
+ }
202
+
203
+ /**
204
+ * creates a full array signature of a valid update request
205
+ * @return array gateway update request format
206
+ */
207
+ public static function updateSignature()
208
+ {
209
+ // TODO: remove customerId from update signature
210
+ return self::createSignature();
211
+
212
+ }
213
+
214
+ /**
215
+ * verifies that a valid address id is being used
216
+ * @ignore
217
+ * @param string $id address id
218
+ * @throws InvalidArgumentException
219
+ */
220
+ private function _validateId($id = null)
221
+ {
222
+ if (empty($id) || trim($id) == "") {
223
+ throw new InvalidArgumentException(
224
+ 'expected address id to be set'
225
+ );
226
+ }
227
+ if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
228
+ throw new InvalidArgumentException(
229
+ $id . ' is an invalid address id.'
230
+ );
231
+ }
232
+ }
233
+
234
+ /**
235
+ * verifies that a valid customer id is being used
236
+ * @ignore
237
+ * @param string $id customer id
238
+ * @throws InvalidArgumentException
239
+ */
240
+ private function _validateCustomerId($id = null)
241
+ {
242
+ if (empty($id) || trim($id) == "") {
243
+ throw new InvalidArgumentException(
244
+ 'expected customer id to be set'
245
+ );
246
+ }
247
+ if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
248
+ throw new InvalidArgumentException(
249
+ $id . ' is an invalid customer id.'
250
+ );
251
+ }
252
+
253
+ }
254
+
255
+ /**
256
+ * determines if a string id or Customer object was passed
257
+ * @ignore
258
+ * @param mixed $customerOrId
259
+ * @return string customerId
260
+ */
261
+ private function _determineCustomerId($customerOrId)
262
+ {
263
+ $customerId = ($customerOrId instanceof Customer) ? $customerOrId->id : $customerOrId;
264
+ $this->_validateCustomerId($customerId);
265
+ return $customerId;
266
+
267
+ }
268
+
269
+ /* private class methods */
270
+ /**
271
+ * sends the create request to the gateway
272
+ * @ignore
273
+ * @param string $subPath
274
+ * @param array $params
275
+ * @return Result\Successful|Result\Error
276
+ */
277
+ private function _doCreate($subPath, $params)
278
+ {
279
+ $fullPath = $this->_config->merchantPath() . $subPath;
280
+ $response = $this->_http->post($fullPath, $params);
281
+
282
+ return $this->_verifyGatewayResponse($response);
283
+ }
284
+
285
+ /**
286
+ * generic method for validating incoming gateway responses
287
+ *
288
+ * creates a new Address object and encapsulates
289
+ * it inside a Result\Successful object, or
290
+ * encapsulates an Errors object inside a Result\Error
291
+ * alternatively, throws an Unexpected exception if the response is invalid
292
+ *
293
+ * @ignore
294
+ * @param array $response gateway response values
295
+ * @return Result\Successful|Result\Error
296
+ * @throws Exception\Unexpected
297
+ */
298
+ private function _verifyGatewayResponse($response)
299
+ {
300
+ if (isset($response['address'])) {
301
+ // return a populated instance of Address
302
+ return new Result\Successful(
303
+ Address::factory($response['address'])
304
+ );
305
+ } else if (isset($response['apiErrorResponse'])) {
306
+ return new Result\Error($response['apiErrorResponse']);
307
+ } else {
308
+ throw new Exception\Unexpected(
309
+ "Expected address or apiErrorResponse"
310
+ );
311
+ }
312
+
313
+ }
314
+ }
315
+ class_alias('Braintree\AddressGateway', 'Braintree_AddressGateway');
lib/braintree/lib/Braintree/AmexExpressCheckoutCard.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree AmexExpressCheckoutCard module
6
+ * Creates and manages Braintree Amex Express Checkout cards
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br />
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read string $createdAt
17
+ * @property-read string $default
18
+ * @property-read string $updatedAt
19
+ * @property-read string $customerId
20
+ * @property-read string $cardType
21
+ * @property-read string $bin
22
+ * @property-read string $cardMemberExpiryDate
23
+ * @property-read string $cardMemberNumber
24
+ * @property-read string $cardType
25
+ * @property-read string $sourceDescription
26
+ * @property-read string $token
27
+ * @property-read string $imageUrl
28
+ * @property-read string $expirationMonth
29
+ * @property-read string $expirationYear
30
+ */
31
+ class AmexExpressCheckoutCard extends Base
32
+ {
33
+ /* instance methods */
34
+ /**
35
+ * returns false if default is null or false
36
+ *
37
+ * @return boolean
38
+ */
39
+ public function isDefault()
40
+ {
41
+ return $this->default;
42
+ }
43
+
44
+ /**
45
+ * factory method: returns an instance of AmexExpressCheckoutCard
46
+ * to the requesting method, with populated properties
47
+ *
48
+ * @ignore
49
+ * @return AmexExpressCheckoutCard
50
+ */
51
+ public static function factory($attributes)
52
+ {
53
+
54
+ $instance = new self();
55
+ $instance->_initialize($attributes);
56
+ return $instance;
57
+ }
58
+
59
+ /**
60
+ * sets instance properties from an array of values
61
+ *
62
+ * @access protected
63
+ * @param array $amexExpressCheckoutCardAttribs array of Amex Express Checkout card properties
64
+ * @return void
65
+ */
66
+ protected function _initialize($amexExpressCheckoutCardAttribs)
67
+ {
68
+ // set the attributes
69
+ $this->_attributes = $amexExpressCheckoutCardAttribs;
70
+
71
+ $subscriptionArray = [];
72
+ if (isset($amexExpressCheckoutCardAttribs['subscriptions'])) {
73
+ foreach ($amexExpressCheckoutCardAttribs['subscriptions'] AS $subscription) {
74
+ $subscriptionArray[] = Subscription::factory($subscription);
75
+ }
76
+ }
77
+
78
+ $this->_set('subscriptions', $subscriptionArray);
79
+ }
80
+ }
81
+ class_alias('Braintree\AmexExpressCheckoutCard', 'Braintree_AmexExpressCheckoutCard');
lib/braintree/lib/Braintree/AndroidPayCard.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree AndroidPayCard module
6
+ * Creates and manages Braintree Android Pay cards
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br />
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read string $bin
17
+ * @property-read string $cardType
18
+ * @property-read string $createdAt
19
+ * @property-read string $customerId
20
+ * @property-read string $default
21
+ * @property-read string $expirationMonth
22
+ * @property-read string $expirationYear
23
+ * @property-read string $googleTransactionId
24
+ * @property-read string $imageUrl
25
+ * @property-read string $last4
26
+ * @property-read string $sourceCardLast4
27
+ * @property-read string $sourceCardType
28
+ * @property-read string $sourceDescription
29
+ * @property-read string $token
30
+ * @property-read string $updatedAt
31
+ * @property-read string $virtualCardLast4
32
+ * @property-read string $virtualCardType
33
+ */
34
+ class AndroidPayCard extends Base
35
+ {
36
+ /* instance methods */
37
+ /**
38
+ * returns false if default is null or false
39
+ *
40
+ * @return boolean
41
+ */
42
+ public function isDefault()
43
+ {
44
+ return $this->default;
45
+ }
46
+
47
+ /**
48
+ * factory method: returns an instance of AndroidPayCard
49
+ * to the requesting method, with populated properties
50
+ *
51
+ * @ignore
52
+ * @return AndroidPayCard
53
+ */
54
+ public static function factory($attributes)
55
+ {
56
+ $defaultAttributes = [
57
+ 'expirationMonth' => '',
58
+ 'expirationYear' => '',
59
+ 'last4' => $attributes['virtualCardLast4'],
60
+ 'cardType' => $attributes['virtualCardType'],
61
+ ];
62
+
63
+ $instance = new self();
64
+ $instance->_initialize(array_merge($defaultAttributes, $attributes));
65
+ return $instance;
66
+ }
67
+
68
+ /**
69
+ * sets instance properties from an array of values
70
+ *
71
+ * @access protected
72
+ * @param array $androidPayCardAttribs array of Android Pay card properties
73
+ * @return void
74
+ */
75
+ protected function _initialize($androidPayCardAttribs)
76
+ {
77
+ // set the attributes
78
+ $this->_attributes = $androidPayCardAttribs;
79
+
80
+ $subscriptionArray = [];
81
+ if (isset($androidPayCardAttribs['subscriptions'])) {
82
+ foreach ($androidPayCardAttribs['subscriptions'] AS $subscription) {
83
+ $subscriptionArray[] = Subscription::factory($subscription);
84
+ }
85
+ }
86
+
87
+ $this->_set('subscriptions', $subscriptionArray);
88
+ }
89
+ }
90
+ class_alias('Braintree\AndroidPayCard', 'Braintree_AndroidPayCard');
lib/braintree/lib/Braintree/ApplePayCard.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree ApplePayCard module
6
+ * Creates and manages Braintree Apple Pay cards
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br />
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read string $cardType
17
+ * @property-read string $createdAt
18
+ * @property-read string $customerId
19
+ * @property-read string $expirationDate
20
+ * @property-read string $expirationMonth
21
+ * @property-read string $expirationYear
22
+ * @property-read string $imageUrl
23
+ * @property-read string $last4
24
+ * @property-read string $token
25
+ * @property-read string $paymentInstrumentName
26
+ * @property-read string $sourceDescription
27
+ * @property-read string $updatedAt
28
+ */
29
+ class ApplePayCard extends Base
30
+ {
31
+ // Card Type
32
+ const AMEX = 'Apple Pay - American Express';
33
+ const MASTER_CARD = 'Apple Pay - MasterCard';
34
+ const VISA = 'Apple Pay - Visa';
35
+
36
+ /* instance methods */
37
+ /**
38
+ * returns false if default is null or false
39
+ *
40
+ * @return boolean
41
+ */
42
+ public function isDefault()
43
+ {
44
+ return $this->default;
45
+ }
46
+
47
+ /**
48
+ * checks whether the card is expired based on the current date
49
+ *
50
+ * @return boolean
51
+ */
52
+ public function isExpired()
53
+ {
54
+ return $this->expired;
55
+ }
56
+
57
+ /**
58
+ * factory method: returns an instance of ApplePayCard
59
+ * to the requesting method, with populated properties
60
+ *
61
+ * @ignore
62
+ * @return ApplePayCard
63
+ */
64
+ public static function factory($attributes)
65
+ {
66
+ $defaultAttributes = [
67
+ 'expirationMonth' => '',
68
+ 'expirationYear' => '',
69
+ 'last4' => '',
70
+ ];
71
+
72
+ $instance = new self();
73
+ $instance->_initialize(array_merge($defaultAttributes, $attributes));
74
+ return $instance;
75
+ }
76
+
77
+ /**
78
+ * sets instance properties from an array of values
79
+ *
80
+ * @access protected
81
+ * @param array $applePayCardAttribs array of Apple Pay card properties
82
+ * @return void
83
+ */
84
+ protected function _initialize($applePayCardAttribs)
85
+ {
86
+ // set the attributes
87
+ $this->_attributes = $applePayCardAttribs;
88
+
89
+ $subscriptionArray = [];
90
+ if (isset($applePayCardAttribs['subscriptions'])) {
91
+ foreach ($applePayCardAttribs['subscriptions'] AS $subscription) {
92
+ $subscriptionArray[] = Subscription::factory($subscription);
93
+ }
94
+ }
95
+
96
+ $this->_set('subscriptions', $subscriptionArray);
97
+ $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
98
+ }
99
+ }
100
+ class_alias('Braintree\ApplePayCard', 'Braintree_ApplePayCard');
lib/braintree/lib/Braintree/Base.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree PHP Library.
6
+ *
7
+ * Braintree base class and initialization
8
+ * Provides methods to child classes. This class cannot be instantiated.
9
+ *
10
+ * PHP version 5
11
+ *
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+ abstract class Base
15
+ {
16
+ protected $_attributes = [];
17
+
18
+ /**
19
+ * @ignore
20
+ * don't permit an explicit call of the constructor!
21
+ * (like $t = new Transaction())
22
+ */
23
+ protected function __construct()
24
+ {
25
+ }
26
+
27
+ /**
28
+ * Disable cloning of objects
29
+ *
30
+ * @ignore
31
+ */
32
+ protected function __clone()
33
+ {
34
+ }
35
+
36
+ /**
37
+ * Accessor for instance properties stored in the private $_attributes property
38
+ *
39
+ * @ignore
40
+ * @param string $name
41
+ * @return mixed
42
+ */
43
+ public function __get($name)
44
+ {
45
+ if (array_key_exists($name, $this->_attributes)) {
46
+ return $this->_attributes[$name];
47
+ }
48
+ else {
49
+ trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
50
+ return null;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Checks for the existance of a property stored in the private $_attributes property
56
+ *
57
+ * @ignore
58
+ * @param string $name
59
+ * @return boolean
60
+ */
61
+ public function __isset($name)
62
+ {
63
+ return array_key_exists($name, $this->_attributes);
64
+ }
65
+
66
+ /**
67
+ * Mutator for instance properties stored in the private $_attributes property
68
+ *
69
+ * @ignore
70
+ * @param string $key
71
+ * @param mixed $value
72
+ */
73
+ public function _set($key, $value)
74
+ {
75
+ $this->_attributes[$key] = $value;
76
+ }
77
+ }
lib/braintree/lib/Braintree/ClientToken.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class ClientToken
5
+ {
6
+ const DEFAULT_VERSION = 2;
7
+
8
+
9
+ // static methods redirecting to gateway
10
+
11
+ /**
12
+ *
13
+ * @param array $params
14
+ * @return array
15
+ */
16
+ public static function generate($params=[])
17
+ {
18
+ return Configuration::gateway()->clientToken()->generate($params);
19
+ }
20
+
21
+ /**
22
+ *
23
+ * @param type $params
24
+ * @throws InvalidArgumentException
25
+ */
26
+ public static function conditionallyVerifyKeys($params)
27
+ {
28
+ return Configuration::gateway()->clientToken()->conditionallyVerifyKeys($params);
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @return string client token retrieved from server
34
+ */
35
+ public static function generateWithCustomerIdSignature()
36
+ {
37
+ return Configuration::gateway()->clientToken()->generateWithCustomerIdSignature();
38
+ }
39
+
40
+ /**
41
+ *
42
+ * @return string client token retrieved from server
43
+ */
44
+ public static function generateWithoutCustomerIdSignature()
45
+ {
46
+ return Configuration::gateway()->clientToken()->generateWithoutCustomerIdSignature();
47
+ }
48
+ }
49
+ class_alias('Braintree\ClientToken', 'Braintree_ClientToken');
lib/braintree/lib/Braintree/ClientTokenGateway.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ class ClientTokenGateway
7
+ {
8
+ /**
9
+ *
10
+ * @var Gateway
11
+ */
12
+ private $_gateway;
13
+
14
+ /**
15
+ *
16
+ * @var Configuration
17
+ */
18
+ private $_config;
19
+
20
+ /**
21
+ *
22
+ * @var Http
23
+ */
24
+ private $_http;
25
+
26
+ /**
27
+ *
28
+ * @param Gateway $gateway
29
+ */
30
+ public function __construct($gateway)
31
+ {
32
+ $this->_gateway = $gateway;
33
+ $this->_config = $gateway->config;
34
+ $this->_config->assertHasAccessTokenOrKeys();
35
+ $this->_http = new Http($gateway->config);
36
+ }
37
+
38
+ public function generate($params=[])
39
+ {
40
+ if (!array_key_exists("version", $params)) {
41
+ $params["version"] = ClientToken::DEFAULT_VERSION;
42
+ }
43
+
44
+ $this->conditionallyVerifyKeys($params);
45
+ $generateParams = ["client_token" => $params];
46
+
47
+ return $this->_doGenerate('/client_token', $generateParams);
48
+ }
49
+
50
+ /**
51
+ * sends the generate request to the gateway
52
+ *
53
+ * @ignore
54
+ * @param var $url
55
+ * @param array $params
56
+ * @return mixed
57
+ */
58
+ public function _doGenerate($subPath, $params)
59
+ {
60
+ $fullPath = $this->_config->merchantPath() . $subPath;
61
+ $response = $this->_http->post($fullPath, $params);
62
+
63
+ return $this->_verifyGatewayResponse($response);
64
+ }
65
+
66
+ /**
67
+ *
68
+ * @param array $params
69
+ * @throws InvalidArgumentException
70
+ */
71
+ public function conditionallyVerifyKeys($params)
72
+ {
73
+ if (array_key_exists("customerId", $params)) {
74
+ Util::verifyKeys($this->generateWithCustomerIdSignature(), $params);
75
+ } else {
76
+ Util::verifyKeys($this->generateWithoutCustomerIdSignature(), $params);
77
+ }
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @return mixed[]
83
+ */
84
+ public function generateWithCustomerIdSignature()
85
+ {
86
+ return [
87
+ "version", "customerId", "proxyMerchantId",
88
+ ["options" => ["makeDefault", "verifyCard", "failOnDuplicatePaymentMethod"]],
89
+ "merchantAccountId", "sepaMandateType", "sepaMandateAcceptanceLocation"];
90
+ }
91
+
92
+ /**
93
+ *
94
+ * @return string[]
95
+ */
96
+ public function generateWithoutCustomerIdSignature()
97
+ {
98
+ return ["version", "proxyMerchantId", "merchantAccountId"];
99
+ }
100
+
101
+ /**
102
+ * generic method for validating incoming gateway responses
103
+ *
104
+ * If the request is successful, returns a client token string.
105
+ * Otherwise, throws an InvalidArgumentException with the error
106
+ * response from the Gateway or an HTTP status code exception.
107
+ *
108
+ * @ignore
109
+ * @param array $response gateway response values
110
+ * @return string client token
111
+ * @throws InvalidArgumentException | HTTP status code exception
112
+ */
113
+ private function _verifyGatewayResponse($response)
114
+ {
115
+ if (isset($response['clientToken'])) {
116
+ return $response['clientToken']['value'];
117
+ } elseif (isset($response['apiErrorResponse'])) {
118
+ throw new InvalidArgumentException(
119
+ $response['apiErrorResponse']['message']
120
+ );
121
+ } else {
122
+ throw new Exception\Unexpected(
123
+ "Expected clientToken or apiErrorResponse"
124
+ );
125
+ }
126
+ }
127
+
128
+ }
129
+ class_alias('Braintree\ClientTokenGateway', 'Braintree_ClientTokenGateway');
lib/braintree/lib/Braintree/CoinbaseAccount.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree CoinbaseAccount module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Manages Braintree CoinbaseAccounts
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $customerId
23
+ * @property-read string $token
24
+ * @property-read string $userId
25
+ * @property-read string $userName
26
+ * @property-read string $userEmail
27
+ */
28
+ class CoinbaseAccount extends Base
29
+ {
30
+ /**
31
+ * factory method: returns an instance of CoinbaseAccount
32
+ * to the requesting method, with populated properties
33
+ *
34
+ * @ignore
35
+ * @return CoinbaseAccount
36
+ */
37
+ public static function factory($attributes)
38
+ {
39
+ $instance = new self();
40
+ $instance->_initialize($attributes);
41
+ return $instance;
42
+ }
43
+
44
+ /* instance methods */
45
+
46
+ /**
47
+ * returns false if default is null or false
48
+ *
49
+ * @return boolean
50
+ */
51
+ public function isDefault()
52
+ {
53
+ return $this->default;
54
+ }
55
+
56
+ /**
57
+ * sets instance properties from an array of values
58
+ *
59
+ * @access protected
60
+ * @param array $coinbaseAccountAttribs array of coinbaseAccount data
61
+ * @return void
62
+ */
63
+ protected function _initialize($coinbaseAccountAttribs)
64
+ {
65
+ // set the attributes
66
+ $this->_attributes = $coinbaseAccountAttribs;
67
+
68
+ $subscriptionArray = [];
69
+ if (isset($coinbaseAccountAttribs['subscriptions'])) {
70
+ foreach ($coinbaseAccountAttribs['subscriptions'] AS $subscription) {
71
+ $subscriptionArray[] = Subscription::factory($subscription);
72
+ }
73
+ }
74
+
75
+ $this->_set('subscriptions', $subscriptionArray);
76
+ }
77
+
78
+ /**
79
+ * create a printable representation of the object as:
80
+ * ClassName[property=value, property=value]
81
+ * @return string
82
+ */
83
+ public function __toString()
84
+ {
85
+ return __CLASS__ . '[' .
86
+ Util::attributesToString($this->_attributes) .']';
87
+ }
88
+
89
+
90
+ // static methods redirecting to gateway
91
+
92
+ public static function find($token)
93
+ {
94
+ return Configuration::gateway()->coinbaseAccount()->find($token);
95
+ }
96
+
97
+ public static function update($token, $attributes)
98
+ {
99
+ return Configuration::gateway()->coinbaseAccount()->update($token, $attributes);
100
+ }
101
+
102
+ public static function delete($token)
103
+ {
104
+ return Configuration::gateway()->coinbaseAccount()->delete($token);
105
+ }
106
+
107
+ public static function sale($token, $transactionAttribs)
108
+ {
109
+ return Configuration::gateway()->coinbaseAccount()->sale($token, $transactionAttribs);
110
+ }
111
+ }
112
+ class_alias('Braintree\CoinbaseAccount', 'Braintree_CoinbaseAccount');
lib/braintree/lib/Braintree/Collection.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use Countable;
5
+ use IteratorAggregate;
6
+ use ArrayAccess;
7
+ use OutOfRangeException;
8
+ use ArrayIterator;
9
+
10
+ /**
11
+ * Braintree Generic collection
12
+ *
13
+ * PHP Version 5
14
+ *
15
+ * Based on Generic Collection class from:
16
+ * {@link http://codeutopia.net/code/library/CU/Collection.php}
17
+ *
18
+ * @package Braintree
19
+ * @subpackage Utility
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ */
22
+
23
+ class Collection implements Countable, IteratorAggregate, ArrayAccess
24
+ {
25
+ /**
26
+ *
27
+ * @var array collection storage
28
+ */
29
+ protected $_collection = [];
30
+
31
+ /**
32
+ * Add a value into the collection
33
+ * @param string $value
34
+ */
35
+ public function add($value)
36
+ {
37
+ $this->_collection[] = $value;
38
+ }
39
+
40
+ /**
41
+ * Set index's value
42
+ * @param integer $index
43
+ * @param mixed $value
44
+ * @throws OutOfRangeException
45
+ */
46
+ public function set($index, $value)
47
+ {
48
+ if($index >= $this->count())
49
+ throw new OutOfRangeException('Index out of range');
50
+
51
+ $this->_collection[$index] = $value;
52
+ }
53
+
54
+ /**
55
+ * Remove a value from the collection
56
+ * @param integer $index index to remove
57
+ * @throws OutOfRangeException if index is out of range
58
+ */
59
+ public function remove($index)
60
+ {
61
+ if($index >= $this->count())
62
+ throw new OutOfRangeException('Index out of range');
63
+
64
+ array_splice($this->_collection, $index, 1);
65
+ }
66
+
67
+ /**
68
+ * Return value at index
69
+ * @param integer $index
70
+ * @return mixed
71
+ * @throws OutOfRangeException
72
+ */
73
+ public function get($index)
74
+ {
75
+ if($index >= $this->count())
76
+ throw new OutOfRangeException('Index out of range');
77
+
78
+ return $this->_collection[$index];
79
+ }
80
+
81
+ /**
82
+ * Determine if index exists
83
+ * @param integer $index
84
+ * @return boolean
85
+ */
86
+ public function exists($index)
87
+ {
88
+ if($index >= $this->count())
89
+ return false;
90
+
91
+ return true;
92
+ }
93
+ /**
94
+ * Return count of items in collection
95
+ * Implements countable
96
+ * @return integer
97
+ */
98
+ public function count()
99
+ {
100
+ return count($this->_collection);
101
+ }
102
+
103
+
104
+ /**
105
+ * Return an iterator
106
+ * Implements IteratorAggregate
107
+ * @return ArrayIterator
108
+ */
109
+ public function getIterator()
110
+ {
111
+ return new ArrayIterator($this->_collection);
112
+ }
113
+
114
+ /**
115
+ * Set offset to value
116
+ * Implements ArrayAccess
117
+ * @see set
118
+ * @param integer $offset
119
+ * @param mixed $value
120
+ */
121
+ public function offsetSet($offset, $value)
122
+ {
123
+ $this->set($offset, $value);
124
+ }
125
+
126
+ /**
127
+ * Unset offset
128
+ * Implements ArrayAccess
129
+ * @see remove
130
+ * @param integer $offset
131
+ */
132
+ public function offsetUnset($offset)
133
+ {
134
+ $this->remove($offset);
135
+ }
136
+
137
+ /**
138
+ * get an offset's value
139
+ * Implements ArrayAccess
140
+ * @see get
141
+ * @param integer $offset
142
+ * @return mixed
143
+ */
144
+ public function offsetGet($offset)
145
+ {
146
+ return $this->get($offset);
147
+ }
148
+
149
+ /**
150
+ * Determine if offset exists
151
+ * Implements ArrayAccess
152
+ * @see exists
153
+ * @param integer $offset
154
+ * @return boolean
155
+ */
156
+ public function offsetExists($offset)
157
+ {
158
+ return $this->exists($offset);
159
+ }
160
+
161
+ }
162
+ class_alias('Braintree\Collection', 'Braintree_Collection');
lib/braintree/lib/Braintree/Configuration.php ADDED
@@ -0,0 +1,551 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ *
6
+ * Configuration registry
7
+ *
8
+ * @package Braintree
9
+ * @subpackage Utility
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
+ */
12
+
13
+ class Configuration
14
+ {
15
+ public static $global;
16
+
17
+ private $_environment = null;
18
+ private $_merchantId = null;
19
+ private $_publicKey = null;
20
+ private $_privateKey = null;
21
+ private $_clientId = null;
22
+ private $_clientSecret = null;
23
+ private $_accessToken = null;
24
+ private $_proxyHost = null;
25
+ private $_proxyPort = null;
26
+ private $_proxyType = null;
27
+ private $_proxyUser = null;
28
+ private $_proxyPassword = null;
29
+ private $_timeout = 60;
30
+
31
+ /**
32
+ * Braintree API version to use
33
+ * @access public
34
+ */
35
+ const API_VERSION = 4;
36
+
37
+ public function __construct($attribs = [])
38
+ {
39
+ foreach ($attribs as $kind => $value) {
40
+ if ($kind == 'environment') {
41
+ CredentialsParser::assertValidEnvironment($value);
42
+ $this->_environment = $value;
43
+ }
44
+ if ($kind == 'merchantId') {
45
+ $this->_merchantId = $value;
46
+ }
47
+ if ($kind == 'publicKey') {
48
+ $this->_publicKey = $value;
49
+ }
50
+ if ($kind == 'privateKey') {
51
+ $this->_privateKey = $value;
52
+ }
53
+ }
54
+
55
+ if (isset($attribs['clientId']) || isset($attribs['accessToken'])) {
56
+ if (isset($attribs['environment']) || isset($attribs['merchantId']) || isset($attribs['publicKey']) || isset($attribs['privateKey'])) {
57
+ throw new Exception\Configuration('Cannot mix OAuth credentials (clientId, clientSecret, accessToken) with key credentials (publicKey, privateKey, environment, merchantId).');
58
+ }
59
+ $parsedCredentials = new CredentialsParser($attribs);
60
+
61
+ $this->_environment = $parsedCredentials->getEnvironment();
62
+ $this->_merchantId = $parsedCredentials->getMerchantId();
63
+ $this->_clientId = $parsedCredentials->getClientId();
64
+ $this->_clientSecret = $parsedCredentials->getClientSecret();
65
+ $this->_accessToken = $parsedCredentials->getAccessToken();
66
+ }
67
+ }
68
+
69
+ /**
70
+ * resets configuration to default
71
+ * @access public
72
+ */
73
+ public static function reset()
74
+ {
75
+ self::$global = new Configuration();
76
+ }
77
+
78
+ public static function gateway()
79
+ {
80
+ return new Gateway(self::$global);
81
+ }
82
+
83
+ public static function environment($value=null)
84
+ {
85
+ if (empty($value)) {
86
+ return self::$global->getEnvironment();
87
+ }
88
+ CredentialsParser::assertValidEnvironment($value);
89
+ self::$global->setEnvironment($value);
90
+ }
91
+
92
+ public static function merchantId($value=null)
93
+ {
94
+ if (empty($value)) {
95
+ return self::$global->getMerchantId();
96
+ }
97
+ self::$global->setMerchantId($value);
98
+ }
99
+
100
+ public static function publicKey($value=null)
101
+ {
102
+ if (empty($value)) {
103
+ return self::$global->getPublicKey();
104
+ }
105
+ self::$global->setPublicKey($value);
106
+ }
107
+
108
+ public static function privateKey($value=null)
109
+ {
110
+ if (empty($value)) {
111
+ return self::$global->getPrivateKey();
112
+ }
113
+ self::$global->setPrivateKey($value);
114
+ }
115
+
116
+ /**
117
+ * Sets or gets the read timeout to use for making requests.
118
+ *
119
+ * @param integer $value If provided, sets the read timeout
120
+ * @return integer The read timeout used for connecting to Braintree
121
+ */
122
+ public static function timeout($value=null)
123
+ {
124
+ if (empty($value)) {
125
+ return self::$global->getTimeout();
126
+ }
127
+ self::$global->setTimeout($value);
128
+ }
129
+
130
+ /**
131
+ * Sets or gets the proxy host to use for connecting to Braintree
132
+ *
133
+ * @param string $value If provided, sets the proxy host
134
+ * @return string The proxy host used for connecting to Braintree
135
+ */
136
+ public static function proxyHost($value = null)
137
+ {
138
+ if (empty($value)) {
139
+ return self::$global->getProxyHost();
140
+ }
141
+ self::$global->setProxyHost($value);
142
+ }
143
+
144
+ /**
145
+ * Sets or gets the port of the proxy to use for connecting to Braintree
146
+ *
147
+ * @param string $value If provided, sets the port of the proxy
148
+ * @return string The port of the proxy used for connecting to Braintree
149
+ */
150
+ public static function proxyPort($value = null)
151
+ {
152
+ if (empty($value)) {
153
+ return self::$global->getProxyPort();
154
+ }
155
+ self::$global->setProxyPort($value);
156
+ }
157
+
158
+ /**
159
+ * Sets or gets the proxy type to use for connecting to Braintree. This value
160
+ * can be any of the CURLOPT_PROXYTYPE options in PHP cURL.
161
+ *
162
+ * @param string $value If provided, sets the proxy type
163
+ * @return string The proxy type used for connecting to Braintree
164
+ */
165
+ public static function proxyType($value = null)
166
+ {
167
+ if (empty($value)) {
168
+ return self::$global->getProxyType();
169
+ }
170
+ self::$global->setProxyType($value);
171
+ }
172
+
173
+ /**
174
+ * Specifies whether or not a proxy is properly configured
175
+ *
176
+ * @return bool true if a proxy is configured properly, false if not
177
+ */
178
+ public static function isUsingProxy()
179
+ {
180
+ $proxyHost = self::$global->getProxyHost();
181
+ $proxyPort = self::$global->getProxyPort();
182
+ return !empty($proxyHost) && !empty($proxyPort);
183
+ }
184
+
185
+ public static function proxyUser($value = null)
186
+ {
187
+ if (empty($value)) {
188
+ return self::$global->getProxyUser();
189
+ }
190
+ self::$global->setProxyUser($value);
191
+ }
192
+
193
+ public static function proxyPassword($value = null)
194
+ {
195
+ if (empty($value)) {
196
+ return self::$global->getProxyPassword();
197
+ }
198
+ self::$global->setProxyPassword($value);
199
+ }
200
+
201
+ /**
202
+ * Specified whether or not a username and password have been provided for
203
+ * use with an authenticated proxy
204
+ *
205
+ * @return bool true if both proxyUser and proxyPassword are present
206
+ */
207
+ public static function isAuthenticatedProxy()
208
+ {
209
+ $proxyUser = self::$global->getProxyUser();
210
+ $proxyPwd = self::$global->getProxyPassword();
211
+ return !empty($proxyUser) && !empty($proxyPwd);
212
+ }
213
+
214
+ public static function assertGlobalHasAccessTokenOrKeys()
215
+ {
216
+ self::$global->assertHasAccessTokenOrKeys();
217
+ }
218
+
219
+ public function assertHasAccessTokenOrKeys()
220
+ {
221
+ if (empty($this->_accessToken)) {
222
+ if (empty($this->_merchantId)) {
223
+ throw new Exception\Configuration('Braintree\\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\\Gateway).');
224
+ } else if (empty($this->_environment)) {
225
+ throw new Exception\Configuration('Braintree\\Configuration::environment needs to be set.');
226
+ } else if (empty($this->_publicKey)) {
227
+ throw new Exception\Configuration('Braintree\\Configuration::publicKey needs to be set.');
228
+ } else if (empty($this->_privateKey)) {
229
+ throw new Exception\Configuration('Braintree\\Configuration::privateKey needs to be set.');
230
+ }
231
+ }
232
+ }
233
+
234
+ public function assertHasClientCredentials()
235
+ {
236
+ $this->assertHasClientId();
237
+ $this->assertHasClientSecret();
238
+ }
239
+
240
+ public function assertHasClientId()
241
+ {
242
+ if (empty($this->_clientId)) {
243
+ throw new Exception\Configuration('clientId needs to be passed to Braintree\\Gateway.');
244
+ }
245
+ }
246
+
247
+ public function assertHasClientSecret()
248
+ {
249
+ if (empty($this->_clientSecret)) {
250
+ throw new Exception\Configuration('clientSecret needs to be passed to Braintree\\Gateway.');
251
+ }
252
+ }
253
+
254
+ public function getEnvironment()
255
+ {
256
+ return $this->_environment;
257
+ }
258
+
259
+ /**
260
+ * Do not use this method directly. Pass in the environment to the constructor.
261
+ */
262
+ public function setEnvironment($value)
263
+ {
264
+ $this->_environment = $value;
265
+ }
266
+
267
+ public function getMerchantId()
268
+ {
269
+ return $this->_merchantId;
270
+ }
271
+
272
+ /**
273
+ * Do not use this method directly. Pass in the merchantId to the constructor.
274
+ */
275
+ public function setMerchantId($value)
276
+ {
277
+ $this->_merchantId = $value;
278
+ }
279
+
280
+ public function getPublicKey()
281
+ {
282
+ return $this->_publicKey;
283
+ }
284
+
285
+ public function getClientId()
286
+ {
287
+ return $this->_clientId;
288
+ }
289
+
290
+ /**
291
+ * Do not use this method directly. Pass in the publicKey to the constructor.
292
+ */
293
+ public function setPublicKey($value)
294
+ {
295
+ $this->_publicKey = $value;
296
+ }
297
+
298
+ public function getPrivateKey()
299
+ {
300
+ return $this->_privateKey;
301
+ }
302
+
303
+ public function getClientSecret()
304
+ {
305
+ return $this->_clientSecret;
306
+ }
307
+
308
+ /**
309
+ * Do not use this method directly. Pass in the privateKey to the constructor.
310
+ */
311
+ public function setPrivateKey($value)
312
+ {
313
+ $this->_privateKey = $value;
314
+ }
315
+
316
+ private function setProxyHost($value)
317
+ {
318
+ $this->_proxyHost = $value;
319
+ }
320
+
321
+ public function getProxyHost()
322
+ {
323
+ return $this->_proxyHost;
324
+ }
325
+
326
+ private function setProxyPort($value)
327
+ {
328
+ $this->_proxyPort = $value;
329
+ }
330
+
331
+ public function getProxyPort()
332
+ {
333
+ return $this->_proxyPort;
334
+ }
335
+
336
+ private function setProxyType($value)
337
+ {
338
+ $this->_proxyType = $value;
339
+ }
340
+
341
+ public function getProxyType()
342
+ {
343
+ return $this->_proxyType;
344
+ }
345
+
346
+ private function setProxyUser($value)
347
+ {
348
+ $this->_proxyUser = $value;
349
+ }
350
+
351
+ public function getProxyUser()
352
+ {
353
+ return $this->_proxyUser;
354
+ }
355
+
356
+ private function setProxyPassword($value)
357
+ {
358
+ $this->_proxyPassword = $value;
359
+ }
360
+
361
+ public function getProxyPassword()
362
+ {
363
+ return $this->_proxyPassword;
364
+ }
365
+
366
+ private function setTimeout($value)
367
+ {
368
+ $this->_timeout = $value;
369
+ }
370
+
371
+ public function getTimeout()
372
+ {
373
+ return $this->_timeout;
374
+ }
375
+
376
+ public function getAccessToken()
377
+ {
378
+ return $this->_accessToken;
379
+ }
380
+
381
+ public function isAccessToken()
382
+ {
383
+ return !empty($this->_accessToken);
384
+ }
385
+
386
+ public function isClientCredentials()
387
+ {
388
+ return !empty($this->_clientId);
389
+ }
390
+ /**
391
+ * returns the base braintree gateway URL based on config values
392
+ *
393
+ * @access public
394
+ * @param none
395
+ * @return string braintree gateway URL
396
+ */
397
+ public function baseUrl()
398
+ {
399
+ return sprintf('%s://%s:%d', $this->protocol(), $this->serverName(), $this->portNumber());
400
+ }
401
+
402
+ /**
403
+ * sets the merchant path based on merchant ID
404
+ *
405
+ * @access protected
406
+ * @param none
407
+ * @return string merchant path uri
408
+ */
409
+ public function merchantPath()
410
+ {
411
+ return '/merchants/' . $this->_merchantId;
412
+ }
413
+
414
+ /**
415
+ * sets the physical path for the location of the CA certs
416
+ *
417
+ * @access public
418
+ * @param none
419
+ * @return string filepath
420
+ */
421
+ public function caFile($sslPath = NULL)
422
+ {
423
+ $sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
424
+ 'ssl' . DIRECTORY_SEPARATOR;
425
+ $caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt';
426
+
427
+ if (!file_exists($caPath))
428
+ {
429
+ throw new Exception\SSLCaFileNotFound();
430
+ }
431
+
432
+ return $caPath;
433
+ }
434
+
435
+ /**
436
+ * returns the port number depending on environment
437
+ *
438
+ * @access public
439
+ * @param none
440
+ * @return int portnumber
441
+ */
442
+ public function portNumber()
443
+ {
444
+ if ($this->sslOn()) {
445
+ return 443;
446
+ }
447
+ return getenv("GATEWAY_PORT") ? getenv("GATEWAY_PORT") : 3000;
448
+ }
449
+
450
+ /**
451
+ * returns http protocol depending on environment
452
+ *
453
+ * @access public
454
+ * @param none
455
+ * @return string http || https
456
+ */
457
+ public function protocol()
458
+ {
459
+ return $this->sslOn() ? 'https' : 'http';
460
+ }
461
+
462
+ /**
463
+ * returns gateway server name depending on environment
464
+ *
465
+ * @access public
466
+ * @param none
467
+ * @return string server domain name
468
+ */
469
+ public function serverName()
470
+ {
471
+ switch($this->_environment) {
472
+ case 'production':
473
+ $serverName = 'api.braintreegateway.com';
474
+ break;
475
+ case 'qa':
476
+ $serverName = 'gateway.qa.braintreepayments.com';
477
+ break;
478
+ case 'sandbox':
479
+ $serverName = 'api.sandbox.braintreegateway.com';
480
+ break;
481
+ case 'development':
482
+ case 'integration':
483
+ default:
484
+ $serverName = 'localhost';
485
+ break;
486
+ }
487
+
488
+ return $serverName;
489
+ }
490
+
491
+ public function authUrl()
492
+ {
493
+ switch($this->_environment) {
494
+ case 'production':
495
+ $serverName = 'https://auth.venmo.com';
496
+ break;
497
+ case 'qa':
498
+ $serverName = 'https://auth.qa.venmo.com';
499
+ break;
500
+ case 'sandbox':
501
+ $serverName = 'https://auth.sandbox.venmo.com';
502
+ break;
503
+ case 'development':
504
+ case 'integration':
505
+ default:
506
+ $serverName = 'http://auth.venmo.dev:9292';
507
+ break;
508
+ }
509
+
510
+ return $serverName;
511
+ }
512
+
513
+ /**
514
+ * returns boolean indicating SSL is on or off for this session,
515
+ * depending on environment
516
+ *
517
+ * @access public
518
+ * @param none
519
+ * @return boolean
520
+ */
521
+ public function sslOn()
522
+ {
523
+ switch($this->_environment) {
524
+ case 'integration':
525
+ case 'development':
526
+ $ssl = false;
527
+ break;
528
+ case 'production':
529
+ case 'qa':
530
+ case 'sandbox':
531
+ default:
532
+ $ssl = true;
533
+ break;
534
+ }
535
+
536
+ return $ssl;
537
+ }
538
+
539
+ /**
540
+ * log message to default logger
541
+ *
542
+ * @param string $message
543
+ *
544
+ */
545
+ public function logMessage($message)
546
+ {
547
+ error_log('[Braintree] ' . $message);
548
+ }
549
+ }
550
+ Configuration::reset();
551
+ class_alias('Braintree\Configuration', 'Braintree_Configuration');
lib/braintree/lib/Braintree/CredentialsParser.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ *
6
+ * CredentialsParser registry
7
+ *
8
+ * @package Braintree
9
+ * @subpackage Utility
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
+ */
12
+
13
+ class CredentialsParser
14
+ {
15
+ private $_clientId;
16
+ private $_clientSecret;
17
+ private $_accessToken;
18
+ private $_environment;
19
+ private $_merchantId;
20
+
21
+ public function __construct($attribs)
22
+ {
23
+ foreach ($attribs as $kind => $value) {
24
+ if ($kind == 'clientId') {
25
+ $this->_clientId = $value;
26
+ }
27
+ if ($kind == 'clientSecret') {
28
+ $this->_clientSecret = $value;
29
+ }
30
+ if ($kind == 'accessToken') {
31
+ $this->_accessToken = $value;
32
+ }
33
+ }
34
+ $this->parse();
35
+ }
36
+
37
+ /**
38
+ *
39
+ * @access protected
40
+ * @static
41
+ * @var array valid environments, used for validation
42
+ */
43
+ private static $_validEnvironments = [
44
+ 'development',
45
+ 'integration',
46
+ 'sandbox',
47
+ 'production',
48
+ 'qa',
49
+ ];
50
+
51
+
52
+ public function parse()
53
+ {
54
+ $environments = [];
55
+ if (!empty($this->_clientId)) {
56
+ $environments[] = ['clientId', $this->_parseClientCredential('clientId', $this->_clientId, 'client_id')];
57
+ }
58
+ if (!empty($this->_clientSecret)) {
59
+ $environments[] = ['clientSecret', $this->_parseClientCredential('clientSecret', $this->_clientSecret, 'client_secret')];
60
+ }
61
+ if (!empty($this->_accessToken)) {
62
+ $environments[] = ['accessToken', $this->_parseAccessToken()];
63
+ }
64
+
65
+ $checkEnv = $environments[0];
66
+ foreach ($environments as $env) {
67
+ if ($env[1] !== $checkEnv[1]) {
68
+ throw new Exception\Configuration(
69
+ 'Mismatched credential environments: ' . $checkEnv[0] . ' environment is ' . $checkEnv[1] .
70
+ ' and ' . $env[0] . ' environment is ' . $env[1]);
71
+ }
72
+ }
73
+
74
+ self::assertValidEnvironment($checkEnv[1]);
75
+ $this->_environment = $checkEnv[1];
76
+ }
77
+
78
+ public static function assertValidEnvironment($environment) {
79
+ if (!in_array($environment, self::$_validEnvironments)) {
80
+ throw new Exception\Configuration('"' .
81
+ $environment . '" is not a valid environment.');
82
+ }
83
+ }
84
+
85
+ private function _parseClientCredential($credentialType, $value, $expectedValuePrefix)
86
+ {
87
+ $explodedCredential = explode('$', $value);
88
+ if (sizeof($explodedCredential) != 3) {
89
+ throw new Exception\Configuration('Incorrect ' . $credentialType . ' format. Expected: type$environment$token');
90
+ }
91
+
92
+ $gotValuePrefix = $explodedCredential[0];
93
+ $environment = $explodedCredential[1];
94
+ $token = $explodedCredential[2];
95
+
96
+ if ($gotValuePrefix != $expectedValuePrefix) {
97
+ throw new Exception\Configuration('Value passed for ' . $credentialType . ' is not a ' . $credentialType);
98
+ }
99
+
100
+ return $environment;
101
+ }
102
+
103
+ private function _parseAccessToken()
104
+ {
105
+ $accessTokenExploded = explode('$', $this->_accessToken);
106
+ if (sizeof($accessTokenExploded) != 4) {
107
+ throw new Exception\Configuration('Incorrect accessToken syntax. Expected: type$environment$merchant_id$token');
108
+ }
109
+
110
+ $gotValuePrefix = $accessTokenExploded[0];
111
+ $environment = $accessTokenExploded[1];
112
+ $merchantId = $accessTokenExploded[2];
113
+ $token = $accessTokenExploded[3];
114
+
115
+ if ($gotValuePrefix != 'access_token') {
116
+ throw new Exception\Configuration('Value passed for accessToken is not an accessToken');
117
+ }
118
+
119
+ $this->_merchantId = $merchantId;
120
+ return $environment;
121
+ }
122
+
123
+ public function getClientId()
124
+ {
125
+ return $this->_clientId;
126
+ }
127
+
128
+ public function getClientSecret()
129
+ {
130
+ return $this->_clientSecret;
131
+ }
132
+
133
+ public function getAccessToken()
134
+ {
135
+ return $this->_accessToken;
136
+ }
137
+
138
+ public function getEnvironment()
139
+ {
140
+ return $this->_environment;
141
+ }
142
+
143
+ public function getMerchantId()
144
+ {
145
+ return $this->_merchantId;
146
+ }
147
+ }
148
+ class_alias('Braintree\CredentialsParser', 'Braintree_CredentialsParser');
lib/braintree/lib/Braintree/CreditCard.php ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree CreditCard module
6
+ * Creates and manages Braintree CreditCards
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * For more detailed information on CreditCards, see {@link http://www.braintreepayments.com/gateway/credit-card-api http://www.braintreepaymentsolutions.com/gateway/credit-card-api}<br />
11
+ * For more detailed information on CreditCard verifications, see {@link http://www.braintreepayments.com/gateway/credit-card-verification-api http://www.braintreepaymentsolutions.com/gateway/credit-card-verification-api}
12
+ *
13
+ * @package Braintree
14
+ * @category Resources
15
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
16
+ *
17
+ * @property-read string $billingAddress
18
+ * @property-read string $bin
19
+ * @property-read string $cardType
20
+ * @property-read string $cardholderName
21
+ * @property-read string $createdAt
22
+ * @property-read string $customerId
23
+ * @property-read string $expirationDate
24
+ * @property-read string $expirationMonth
25
+ * @property-read string $expirationYear
26
+ * @property-read string $imageUrl
27
+ * @property-read string $last4
28
+ * @property-read string $maskedNumber
29
+ * @property-read string $token
30
+ * @property-read string $updatedAt
31
+ */
32
+ class CreditCard extends Base
33
+ {
34
+ // Card Type
35
+ const AMEX = 'American Express';
36
+ const CARTE_BLANCHE = 'Carte Blanche';
37
+ const CHINA_UNION_PAY = 'China UnionPay';
38
+ const DINERS_CLUB_INTERNATIONAL = 'Diners Club';
39
+ const DISCOVER = 'Discover';
40
+ const JCB = 'JCB';
41
+ const LASER = 'Laser';
42
+ const MAESTRO = 'Maestro';
43
+ const MASTER_CARD = 'MasterCard';
44
+ const SOLO = 'Solo';
45
+ const SWITCH_TYPE = 'Switch';
46
+ const VISA = 'Visa';
47
+ const UNKNOWN = 'Unknown';
48
+
49
+ // Credit card origination location
50
+ const INTERNATIONAL = "international";
51
+ const US = "us";
52
+
53
+ const PREPAID_YES = 'Yes';
54
+ const PREPAID_NO = 'No';
55
+ const PREPAID_UNKNOWN = 'Unknown';
56
+
57
+ const PAYROLL_YES = 'Yes';
58
+ const PAYROLL_NO = 'No';
59
+ const PAYROLL_UNKNOWN = 'Unknown';
60
+
61
+ const HEALTHCARE_YES = 'Yes';
62
+ const HEALTHCARE_NO = 'No';
63
+ const HEALTHCARE_UNKNOWN = 'Unknown';
64
+
65
+ const DURBIN_REGULATED_YES = 'Yes';
66
+ const DURBIN_REGULATED_NO = 'No';
67
+ const DURBIN_REGULATED_UNKNOWN = 'Unknown';
68
+
69
+ const DEBIT_YES = 'Yes';
70
+ const DEBIT_NO = 'No';
71
+ const DEBIT_UNKNOWN = 'Unknown';
72
+
73
+ const COMMERCIAL_YES = 'Yes';
74
+ const COMMERCIAL_NO = 'No';
75
+ const COMMERCIAL_UNKNOWN = 'Unknown';
76
+
77
+ const COUNTRY_OF_ISSUANCE_UNKNOWN = "Unknown";
78
+ const ISSUING_BANK_UNKNOWN = "Unknown";
79
+ const PRODUCT_ID_UNKNOWN = "Unknown";
80
+
81
+ /* instance methods */
82
+ /**
83
+ * returns false if default is null or false
84
+ *
85
+ * @return boolean
86
+ */
87
+ public function isDefault()
88
+ {
89
+ return $this->default;
90
+ }
91
+
92
+ /**
93
+ * checks whether the card is expired based on the current date
94
+ *
95
+ * @return boolean
96
+ */
97
+ public function isExpired()
98
+ {
99
+ return $this->expired;
100
+ }
101
+
102
+ /**
103
+ * checks whether the card is associated with venmo sdk
104
+ *
105
+ * @return boolean
106
+ */
107
+ public function isVenmoSdk()
108
+ {
109
+ return $this->venmoSdk;
110
+ }
111
+
112
+ /**
113
+ * sets instance properties from an array of values
114
+ *
115
+ * @access protected
116
+ * @param array $creditCardAttribs array of creditcard data
117
+ * @return void
118
+ */
119
+ protected function _initialize($creditCardAttribs)
120
+ {
121
+ // set the attributes
122
+ $this->_attributes = $creditCardAttribs;
123
+
124
+ // map each address into its own object
125
+ $billingAddress = isset($creditCardAttribs['billingAddress']) ?
126
+ Address::factory($creditCardAttribs['billingAddress']) :
127
+ null;
128
+
129
+ $subscriptionArray = [];
130
+ if (isset($creditCardAttribs['subscriptions'])) {
131
+ foreach ($creditCardAttribs['subscriptions'] AS $subscription) {
132
+ $subscriptionArray[] = Subscription::factory($subscription);
133
+ }
134
+ }
135
+
136
+ $this->_set('subscriptions', $subscriptionArray);
137
+ $this->_set('billingAddress', $billingAddress);
138
+ $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
139
+ $this->_set('maskedNumber', $this->bin . '******' . $this->last4);
140
+
141
+ if(isset($creditCardAttribs['verifications']) && count($creditCardAttribs['verifications']) > 0) {
142
+ $verifications = $creditCardAttribs['verifications'];
143
+ usort($verifications, [$this, '_compareCreatedAtOnVerifications']);
144
+
145
+ $this->_set('verification', CreditCardVerification::factory($verifications[0]));
146
+ }
147
+ }
148
+
149
+ private function _compareCreatedAtOnVerifications($verificationAttrib1, $verificationAttrib2)
150
+ {
151
+ return ($verificationAttrib2['createdAt'] < $verificationAttrib1['createdAt']) ? -1 : 1;
152
+ }
153
+
154
+ /**
155
+ * returns false if comparing object is not a CreditCard,
156
+ * or is a CreditCard with a different id
157
+ *
158
+ * @param object $otherCreditCard customer to compare against
159
+ * @return boolean
160
+ */
161
+ public function isEqual($otherCreditCard)
162
+ {
163
+ return !($otherCreditCard instanceof self) ? false : $this->token === $otherCreditCard->token;
164
+ }
165
+
166
+ /**
167
+ * create a printable representation of the object as:
168
+ * ClassName[property=value, property=value]
169
+ * @return string
170
+ */
171
+ public function __toString()
172
+ {
173
+ return __CLASS__ . '[' .
174
+ Util::attributesToString($this->_attributes) .']';
175
+ }
176
+
177
+ /**
178
+ * factory method: returns an instance of CreditCard
179
+ * to the requesting method, with populated properties
180
+ *
181
+ * @ignore
182
+ * @return CreditCard
183
+ */
184
+ public static function factory($attributes)
185
+ {
186
+ $defaultAttributes = [
187
+ 'bin' => '',
188
+ 'expirationMonth' => '',
189
+ 'expirationYear' => '',
190
+ 'last4' => '',
191
+ ];
192
+
193
+ $instance = new self();
194
+ $instance->_initialize(array_merge($defaultAttributes, $attributes));
195
+ return $instance;
196
+ }
197
+
198
+
199
+ // static methods redirecting to gateway
200
+
201
+ public static function create($attribs)
202
+ {
203
+ return Configuration::gateway()->creditCard()->create($attribs);
204
+ }
205
+
206
+ public static function createNoValidate($attribs)
207
+ {
208
+ return Configuration::gateway()->creditCard()->createNoValidate($attribs);
209
+ }
210
+
211
+ public static function createFromTransparentRedirect($queryString)
212
+ {
213
+ return Configuration::gateway()->creditCard()->createFromTransparentRedirect($queryString);
214
+ }
215
+
216
+ public static function createCreditCardUrl()
217
+ {
218
+ return Configuration::gateway()->creditCard()->createCreditCardUrl();
219
+ }
220
+
221
+ public static function expired()
222
+ {
223
+ return Configuration::gateway()->creditCard()->expired();
224
+ }
225
+
226
+ public static function fetchExpired($ids)
227
+ {
228
+ return Configuration::gateway()->creditCard()->fetchExpired($ids);
229
+ }
230
+
231
+ public static function expiringBetween($startDate, $endDate)
232
+ {
233
+ return Configuration::gateway()->creditCard()->expiringBetween($startDate, $endDate);
234
+ }
235
+
236
+ public static function fetchExpiring($startDate, $endDate, $ids)
237
+ {
238
+ return Configuration::gateway()->creditCard()->fetchExpiring($startDate, $endDate, $ids);
239
+ }
240
+
241
+ public static function find($token)
242
+ {
243
+ return Configuration::gateway()->creditCard()->find($token);
244
+ }
245
+
246
+ public static function fromNonce($nonce)
247
+ {
248
+ return Configuration::gateway()->creditCard()->fromNonce($nonce);
249
+ }
250
+
251
+ public static function credit($token, $transactionAttribs)
252
+ {
253
+ return Configuration::gateway()->creditCard()->credit($token, $transactionAttribs);
254
+ }
255
+
256
+ public static function creditNoValidate($token, $transactionAttribs)
257
+ {
258
+ return Configuration::gateway()->creditCard()->creditNoValidate($token, $transactionAttribs);
259
+ }
260
+
261
+ public static function sale($token, $transactionAttribs)
262
+ {
263
+ return Configuration::gateway()->creditCard()->sale($token, $transactionAttribs);
264
+ }
265
+
266
+ public static function saleNoValidate($token, $transactionAttribs)
267
+ {
268
+ return Configuration::gateway()->creditCard()->saleNoValidate($token, $transactionAttribs);
269
+ }
270
+
271
+ public static function update($token, $attributes)
272
+ {
273
+ return Configuration::gateway()->creditCard()->update($token, $attributes);
274
+ }
275
+
276
+ public static function updateNoValidate($token, $attributes)
277
+ {
278
+ return Configuration::gateway()->creditCard()->updateNoValidate($token, $attributes);
279
+ }
280
+
281
+ public static function updateCreditCardUrl()
282
+ {
283
+ return Configuration::gateway()->creditCard()->updateCreditCardUrl();
284
+ }
285
+
286
+ public static function updateFromTransparentRedirect($queryString)
287
+ {
288
+ return Configuration::gateway()->creditCard()->updateFromTransparentRedirect($queryString);
289
+ }
290
+
291
+ public static function delete($token)
292
+ {
293
+ return Configuration::gateway()->creditCard()->delete($token);
294
+ }
295
+
296
+ /** @return array */
297
+ public static function allCardTypes()
298
+ {
299
+ return [
300
+ CreditCard::AMEX,
301
+ CreditCard::CARTE_BLANCHE,
302
+ CreditCard::CHINA_UNION_PAY,
303
+ CreditCard::DINERS_CLUB_INTERNATIONAL,
304
+ CreditCard::DISCOVER,
305
+ CreditCard::JCB,
306
+ CreditCard::LASER,
307
+ CreditCard::MAESTRO,
308
+ CreditCard::MASTER_CARD,
309
+ CreditCard::SOLO,
310
+ CreditCard::SWITCH_TYPE,
311
+ CreditCard::VISA,
312
+ CreditCard::UNKNOWN
313
+ ];
314
+ }
315
+ }
316
+ class_alias('Braintree\CreditCard', 'Braintree_CreditCard');
lib/braintree/lib/Braintree/CreditCardGateway.php ADDED
@@ -0,0 +1,487 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree CreditCardGateway module
8
+ * Creates and manages Braintree CreditCards
9
+ *
10
+ * <b>== More information ==</b>
11
+ *
12
+ * For more detailed information on CreditCards, see {@link http://www.braintreepayments.com/gateway/credit-card-api http://www.braintreepaymentsolutions.com/gateway/credit-card-api}<br />
13
+ * For more detailed information on CreditCard verifications, see {@link http://www.braintreepayments.com/gateway/credit-card-verification-api http://www.braintreepaymentsolutions.com/gateway/credit-card-verification-api}
14
+ *
15
+ * @package Braintree
16
+ * @category Resources
17
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
18
+ */
19
+ class CreditCardGateway
20
+ {
21
+ private $_gateway;
22
+ private $_config;
23
+ private $_http;
24
+
25
+ public function __construct($gateway)
26
+ {
27
+ $this->_gateway = $gateway;
28
+ $this->_config = $gateway->config;
29
+ $this->_config->assertHasAccessTokenOrKeys();
30
+ $this->_http = new Http($gateway->config);
31
+ }
32
+
33
+ public function create($attribs)
34
+ {
35
+ Util::verifyKeys(self::createSignature(), $attribs);
36
+ return $this->_doCreate('/payment_methods', ['credit_card' => $attribs]);
37
+ }
38
+
39
+ /**
40
+ * attempts the create operation assuming all data will validate
41
+ * returns a CreditCard object instead of a Result
42
+ *
43
+ * @access public
44
+ * @param array $attribs
45
+ * @return CreditCard
46
+ * @throws Exception\ValidationError
47
+ */
48
+ public function createNoValidate($attribs)
49
+ {
50
+ $result = $this->create($attribs);
51
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
52
+ }
53
+ /**
54
+ * create a customer from a TransparentRedirect operation
55
+ *
56
+ * @deprecated since version 2.3.0
57
+ * @access public
58
+ * @param array $attribs
59
+ * @return Result\Successful|Result\Error
60
+ */
61
+ public function createFromTransparentRedirect($queryString)
62
+ {
63
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
64
+ $params = TransparentRedirect::parseAndValidateQueryString(
65
+ $queryString
66
+ );
67
+ return $this->_doCreate(
68
+ '/payment_methods/all/confirm_transparent_redirect_request',
69
+ ['id' => $params['id']]
70
+ );
71
+ }
72
+
73
+ /**
74
+ *
75
+ * @deprecated since version 2.3.0
76
+ * @access public
77
+ * @param none
78
+ * @return string
79
+ */
80
+ public function createCreditCardUrl()
81
+ {
82
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
83
+ return $this->_config->baseUrl() . $this->_config->merchantPath().
84
+ '/payment_methods/all/create_via_transparent_redirect_request';
85
+ }
86
+
87
+ /**
88
+ * returns a ResourceCollection of expired credit cards
89
+ * @return ResourceCollection
90
+ */
91
+ public function expired()
92
+ {
93
+ $path = $this->_config->merchantPath() . '/payment_methods/all/expired_ids';
94
+ $response = $this->_http->post($path);
95
+ $pager = [
96
+ 'object' => $this,
97
+ 'method' => 'fetchExpired',
98
+ 'methodArgs' => []
99
+ ];
100
+
101
+ return new ResourceCollection($response, $pager);
102
+ }
103
+
104
+ public function fetchExpired($ids)
105
+ {
106
+ $path = $this->_config->merchantPath() . "/payment_methods/all/expired";
107
+ $response = $this->_http->post($path, ['search' => ['ids' => $ids]]);
108
+
109
+ return Util::extractattributeasarray(
110
+ $response['paymentMethods'],
111
+ 'creditCard'
112
+ );
113
+ }
114
+ /**
115
+ * returns a ResourceCollection of credit cards expiring between start/end
116
+ *
117
+ * @return ResourceCollection
118
+ */
119
+ public function expiringBetween($startDate, $endDate)
120
+ {
121
+ $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring_ids?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
122
+ $response = $this->_http->post($queryPath);
123
+ $pager = [
124
+ 'object' => $this,
125
+ 'method' => 'fetchExpiring',
126
+ 'methodArgs' => [$startDate, $endDate]
127
+ ];
128
+
129
+ return new ResourceCollection($response, $pager);
130
+ }
131
+
132
+ public function fetchExpiring($startDate, $endDate, $ids)
133
+ {
134
+ $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
135
+ $response = $this->_http->post($queryPath, ['search' => ['ids' => $ids]]);
136
+
137
+ return Util::extractAttributeAsArray(
138
+ $response['paymentMethods'],
139
+ 'creditCard'
140
+ );
141
+ }
142
+
143
+ /**
144
+ * find a creditcard by token
145
+ *
146
+ * @access public
147
+ * @param string $token credit card unique id
148
+ * @return CreditCard
149
+ * @throws Exception\NotFound
150
+ */
151
+ public function find($token)
152
+ {
153
+ $this->_validateId($token);
154
+ try {
155
+ $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
156
+ $response = $this->_http->get($path);
157
+ return CreditCard::factory($response['creditCard']);
158
+ } catch (Exception\NotFound $e) {
159
+ throw new Exception\NotFound(
160
+ 'credit card with token ' . $token . ' not found'
161
+ );
162
+ }
163
+
164
+ }
165
+
166
+ /**
167
+ * Convert a payment method nonce to a credit card
168
+ *
169
+ * @access public
170
+ * @param string $nonce payment method nonce
171
+ * @return CreditCard
172
+ * @throws Exception\NotFound
173
+ */
174
+ public function fromNonce($nonce)
175
+ {
176
+ $this->_validateId($nonce, "nonce");
177
+ try {
178
+ $path = $this->_config->merchantPath() . '/payment_methods/from_nonce/' . $nonce;
179
+ $response = $this->_http->get($path);
180
+ return CreditCard::factory($response['creditCard']);
181
+ } catch (Exception\NotFound $e) {
182
+ throw new Exception\NotFound(
183
+ 'credit card with nonce ' . $nonce . ' locked, consumed or not found'
184
+ );
185
+ }
186
+
187
+ }
188
+
189
+ /**
190
+ * create a credit on the card for the passed transaction
191
+ *
192
+ * @access public
193
+ * @param array $attribs
194
+ * @return Result\Successful|Result\Error
195
+ */
196
+ public function credit($token, $transactionAttribs)
197
+ {
198
+ $this->_validateId($token);
199
+ return Transaction::credit(
200
+ array_merge(
201
+ $transactionAttribs,
202
+ ['paymentMethodToken' => $token]
203
+ )
204
+ );
205
+ }
206
+
207
+ /**
208
+ * create a credit on this card, assuming validations will pass
209
+ *
210
+ * returns a Transaction object on success
211
+ *
212
+ * @access public
213
+ * @param array $attribs
214
+ * @return Transaction
215
+ * @throws Exception\ValidationError
216
+ */
217
+ public function creditNoValidate($token, $transactionAttribs)
218
+ {
219
+ $result = $this->credit($token, $transactionAttribs);
220
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
221
+ }
222
+
223
+ /**
224
+ * create a new sale for the current card
225
+ *
226
+ * @param string $token
227
+ * @param array $transactionAttribs
228
+ * @return Result\Successful|Result\Error
229
+ * @see Transaction::sale()
230
+ */
231
+ public function sale($token, $transactionAttribs)
232
+ {
233
+ $this->_validateId($token);
234
+ return Transaction::sale(
235
+ array_merge(
236
+ $transactionAttribs,
237
+ ['paymentMethodToken' => $token]
238
+ )
239
+ );
240
+ }
241
+
242
+ /**
243
+ * create a new sale using this card, assuming validations will pass
244
+ *
245
+ * returns a Transaction object on success
246
+ *
247
+ * @access public
248
+ * @param array $transactionAttribs
249
+ * @param string $token
250
+ * @return Transaction
251
+ * @throws Exception\ValidationsFailed
252
+ * @see Transaction::sale()
253
+ */
254
+ public function saleNoValidate($token, $transactionAttribs)
255
+ {
256
+ $result = $this->sale($token, $transactionAttribs);
257
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
258
+ }
259
+
260
+ /**
261
+ * updates the creditcard record
262
+ *
263
+ * if calling this method in context, $token
264
+ * is the 2nd attribute. $token is not sent in object context.
265
+ *
266
+ * @access public
267
+ * @param array $attributes
268
+ * @param string $token (optional)
269
+ * @return Result\Successful|Result\Error
270
+ */
271
+ public function update($token, $attributes)
272
+ {
273
+ Util::verifyKeys(self::updateSignature(), $attributes);
274
+ $this->_validateId($token);
275
+ return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, ['creditCard' => $attributes]);
276
+ }
277
+
278
+ /**
279
+ * update a creditcard record, assuming validations will pass
280
+ *
281
+ * if calling this method in context, $token
282
+ * is the 2nd attribute. $token is not sent in object context.
283
+ * returns a CreditCard object on success
284
+ *
285
+ * @access public
286
+ * @param array $attributes
287
+ * @param string $token
288
+ * @return CreditCard
289
+ * @throws Exception\ValidationsFailed
290
+ */
291
+ public function updateNoValidate($token, $attributes)
292
+ {
293
+ $result = $this->update($token, $attributes);
294
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
295
+ }
296
+ /**
297
+ *
298
+ * @access public
299
+ * @param none
300
+ * @return string
301
+ */
302
+ public function updateCreditCardUrl()
303
+ {
304
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
305
+ return $this->_config->baseUrl() . $this->_config->merchantPath() .
306
+ '/payment_methods/all/update_via_transparent_redirect_request';
307
+ }
308
+
309
+ /**
310
+ * update a customer from a TransparentRedirect operation
311
+ *
312
+ * @deprecated since version 2.3.0
313
+ * @access public
314
+ * @param array $attribs
315
+ * @return object
316
+ */
317
+ public function updateFromTransparentRedirect($queryString)
318
+ {
319
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
320
+ $params = TransparentRedirect::parseAndValidateQueryString(
321
+ $queryString
322
+ );
323
+ return $this->_doUpdate(
324
+ 'post',
325
+ '/payment_methods/all/confirm_transparent_redirect_request',
326
+ ['id' => $params['id']]
327
+ );
328
+ }
329
+
330
+ public function delete($token)
331
+ {
332
+ $this->_validateId($token);
333
+ $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token;
334
+ $this->_http->delete($path);
335
+ return new Result\Successful();
336
+ }
337
+
338
+ private static function baseOptions()
339
+ {
340
+ return ['makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount', 'venmoSdkSession'];
341
+ }
342
+
343
+ private static function baseSignature($options)
344
+ {
345
+ return [
346
+ 'billingAddressId', 'cardholderName', 'cvv', 'number', 'deviceSessionId',
347
+ 'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
348
+ 'deviceData', 'fraudMerchantId', 'paymentMethodNonce',
349
+ ['options' => $options],
350
+ [
351
+ 'billingAddress' => self::billingAddressSignature()
352
+ ],
353
+ ];
354
+ }
355
+
356
+ public static function billingAddressSignature()
357
+ {
358
+ return [
359
+ 'firstName',
360
+ 'lastName',
361
+ 'company',
362
+ 'countryCodeAlpha2',
363
+ 'countryCodeAlpha3',
364
+ 'countryCodeNumeric',
365
+ 'countryName',
366
+ 'extendedAddress',
367
+ 'locality',
368
+ 'region',
369
+ 'postalCode',
370
+ 'streetAddress'
371
+ ];
372
+ }
373
+
374
+ public static function createSignature()
375
+ {
376
+ $options = self::baseOptions();
377
+ $options[] = "failOnDuplicatePaymentMethod";
378
+ $signature = self::baseSignature($options);
379
+ $signature[] = 'customerId';
380
+ return $signature;
381
+ }
382
+
383
+ public static function updateSignature()
384
+ {
385
+ $options = self::baseOptions();
386
+ $options[] = "failOnDuplicatePaymentMethod";
387
+ $signature = self::baseSignature($options);
388
+
389
+ $updateExistingBillingSignature = [
390
+ [
391
+ 'options' => [
392
+ 'updateExisting'
393
+ ]
394
+ ]
395
+ ];
396
+
397
+ foreach($signature AS $key => $value) {
398
+ if(is_array($value) and array_key_exists('billingAddress', $value)) {
399
+ $signature[$key]['billingAddress'] = array_merge_recursive($value['billingAddress'], $updateExistingBillingSignature);
400
+ }
401
+ }
402
+
403
+ return $signature;
404
+ }
405
+
406
+ /**
407
+ * sends the create request to the gateway
408
+ *
409
+ * @ignore
410
+ * @param string $subPath
411
+ * @param array $params
412
+ * @return mixed
413
+ */
414
+ public function _doCreate($subPath, $params)
415
+ {
416
+ $fullPath = $this->_config->merchantPath() . $subPath;
417
+ $response = $this->_http->post($fullPath, $params);
418
+
419
+ return $this->_verifyGatewayResponse($response);
420
+ }
421
+
422
+ /**
423
+ * verifies that a valid credit card identifier is being used
424
+ * @ignore
425
+ * @param string $identifier
426
+ * @param Optional $string $identifierType type of identifier supplied, default "token"
427
+ * @throws InvalidArgumentException
428
+ */
429
+ private function _validateId($identifier = null, $identifierType = "token")
430
+ {
431
+ if (empty($identifier)) {
432
+ throw new InvalidArgumentException(
433
+ 'expected credit card id to be set'
434
+ );
435
+ }
436
+ if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) {
437
+ throw new InvalidArgumentException(
438
+ $identifier . ' is an invalid credit card ' . $identifierType . '.'
439
+ );
440
+ }
441
+ }
442
+
443
+ /**
444
+ * sends the update request to the gateway
445
+ *
446
+ * @ignore
447
+ * @param string $url
448
+ * @param array $params
449
+ * @return mixed
450
+ */
451
+ private function _doUpdate($httpVerb, $subPath, $params)
452
+ {
453
+ $fullPath = $this->_config->merchantPath() . $subPath;
454
+ $response = $this->_http->$httpVerb($fullPath, $params);
455
+ return $this->_verifyGatewayResponse($response);
456
+ }
457
+
458
+ /**
459
+ * generic method for validating incoming gateway responses
460
+ *
461
+ * creates a new CreditCard object and encapsulates
462
+ * it inside a Result\Successful object, or
463
+ * encapsulates a Errors object inside a Result\Error
464
+ * alternatively, throws an Unexpected exception if the response is invalid
465
+ *
466
+ * @ignore
467
+ * @param array $response gateway response values
468
+ * @return Result\Successful|Result\Error
469
+ * @throws Exception\Unexpected
470
+ */
471
+ private function _verifyGatewayResponse($response)
472
+ {
473
+ if (isset($response['creditCard'])) {
474
+ // return a populated instance of Address
475
+ return new Result\Successful(
476
+ CreditCard::factory($response['creditCard'])
477
+ );
478
+ } elseif (isset($response['apiErrorResponse'])) {
479
+ return new Result\Error($response['apiErrorResponse']);
480
+ } else {
481
+ throw new Exception\Unexpected(
482
+ "Expected address or apiErrorResponse"
483
+ );
484
+ }
485
+ }
486
+ }
487
+ class_alias('Braintree\CreditCardGateway', 'Braintree_CreditCardGateway');
lib/braintree/lib/Braintree/CreditCardVerification.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class CreditCardVerification extends Result\CreditCardVerification
5
+ {
6
+ public static function factory($attributes)
7
+ {
8
+ $instance = new self($attributes);
9
+ return $instance;
10
+ }
11
+
12
+ // static methods redirecting to gateway
13
+ //
14
+ public static function create($attributes)
15
+ {
16
+ Util::verifyKeys(self::createSignature(), $attributes);
17
+ return Configuration::gateway()->creditCardVerification()->create($attributes);
18
+ }
19
+
20
+ public static function fetch($query, $ids)
21
+ {
22
+ return Configuration::gateway()->creditCardVerification()->fetch($query, $ids);
23
+ }
24
+
25
+ public static function search($query)
26
+ {
27
+ return Configuration::gateway()->creditCardVerification()->search($query);
28
+ }
29
+
30
+ public static function createSignature()
31
+ {
32
+ return [
33
+ ['options' => ['amount', 'merchantAccountId']],
34
+ ['creditCard' =>
35
+ [
36
+ 'cardholderName', 'cvv', 'number',
37
+ 'expirationDate', 'expirationMonth', 'expirationYear',
38
+ ['billingAddress' => CreditCardGateway::billingAddressSignature()]
39
+ ]
40
+ ]];
41
+ }
42
+ }
43
+ class_alias('Braintree\CreditCardVerification', 'Braintree_CreditCardVerification');
lib/braintree/lib/Braintree/CreditCardVerificationGateway.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class CreditCardVerificationGateway
5
+ {
6
+ private $_gateway;
7
+ private $_config;
8
+ private $_http;
9
+
10
+ public function __construct($gateway)
11
+ {
12
+ $this->_gateway = $gateway;
13
+ $this->_config = $gateway->config;
14
+ $this->_config->assertHasAccessTokenOrKeys();
15
+ $this->_http = new Http($gateway->config);
16
+ }
17
+
18
+ public function create($attributes)
19
+ {
20
+ $response = $this->_http->post($this->_config->merchantPath() . "/verifications", ['verification' => $attributes]);
21
+ return $this->_verifyGatewayResponse($response);
22
+ }
23
+
24
+ private function _verifyGatewayResponse($response)
25
+ {
26
+
27
+ if(isset($response['verification'])){
28
+ return new Result\Successful(
29
+ CreditCardVerification::factory($response['verification'])
30
+ );
31
+ } else if (isset($response['apiErrorResponse'])) {
32
+ return new Result\Error($response['apiErrorResponse']);
33
+ } else {
34
+ throw new Exception\Unexpected(
35
+ "Expected transaction or apiErrorResponse"
36
+ );
37
+ }
38
+ }
39
+
40
+ public function fetch($query, $ids)
41
+ {
42
+ $criteria = [];
43
+ foreach ($query as $term) {
44
+ $criteria[$term->name] = $term->toparam();
45
+ }
46
+ $criteria["ids"] = CreditCardVerificationSearch::ids()->in($ids)->toparam();
47
+ $path = $this->_config->merchantPath() . '/verifications/advanced_search';
48
+ $response = $this->_http->post($path, ['search' => $criteria]);
49
+
50
+ return Util::extractattributeasarray(
51
+ $response['creditCardVerifications'],
52
+ 'verification'
53
+ );
54
+ }
55
+
56
+ public function search($query)
57
+ {
58
+ $criteria = [];
59
+ foreach ($query as $term) {
60
+ $criteria[$term->name] = $term->toparam();
61
+ }
62
+
63
+ $path = $this->_config->merchantPath() . '/verifications/advanced_search_ids';
64
+ $response = $this->_http->post($path, ['search' => $criteria]);
65
+ $pager = [
66
+ 'object' => $this,
67
+ 'method' => 'fetch',
68
+ 'methodArgs' => [$query]
69
+ ];
70
+
71
+ return new ResourceCollection($response, $pager);
72
+ }
73
+ }
74
+ class_alias('Braintree\CreditCardVerificationGateway', 'Braintree_CreditCardVerificationGateway');
lib/braintree/lib/Braintree/CreditCardVerificationSearch.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class CreditCardVerificationSearch
5
+ {
6
+ public static function id() {
7
+ return new TextNode('id');
8
+ }
9
+
10
+ public static function creditCardCardholderName() {
11
+ return new TextNode('credit_card_cardholder_name');
12
+ }
13
+
14
+ public static function billingAddressDetailsPostalCode() {
15
+ return new TextNode('billing_address_details_postal_code');
16
+ }
17
+
18
+ public static function customerEmail() {
19
+ return new TextNode('customer_email');
20
+ }
21
+
22
+ public static function customerId() {
23
+ return new TextNode('customer_id');
24
+ }
25
+
26
+ public static function paymentMethodToken(){
27
+ return new TextNode('payment_method_token');
28
+ }
29
+
30
+ public static function creditCardExpirationDate() {
31
+ return new EqualityNode('credit_card_expiration_date');
32
+ }
33
+
34
+ public static function creditCardNumber() {
35
+ return new PartialMatchNode('credit_card_number');
36
+ }
37
+
38
+ public static function ids() {
39
+ return new MultipleValueNode('ids');
40
+ }
41
+
42
+ public static function createdAt() {
43
+ return new RangeNode("created_at");
44
+ }
45
+
46
+ public static function creditCardCardType()
47
+ {
48
+ return new MultipleValueNode("credit_card_card_type", CreditCard::allCardTypes());
49
+ }
50
+
51
+ public static function status()
52
+ {
53
+ return new MultipleValueNode("status", Result\CreditCardVerification::allStatuses());
54
+ }
55
+ }
56
+ class_alias('Braintree\CreditCardVerificationSearch', 'Braintree_CreditCardVerificationSearch');
lib/braintree/lib/Braintree/Customer.php ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Customer module
6
+ * Creates and manages Customers
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api}
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read array $addresses
17
+ * @property-read array $paymentMethods
18
+ * @property-read string $company
19
+ * @property-read string $createdAt
20
+ * @property-read array $creditCards
21
+ * @property-read array $paypalAccounts
22
+ * @property-read array $applePayCards
23
+ * @property-read array $androidPayCards
24
+ * @property-read array $amexExpressCheckoutCards
25
+ * @property-read array $venmoAccounts
26
+ * @property-read array $coinbaseAccounts
27
+ * @property-read array $customFields custom fields passed with the request
28
+ * @property-read string $email
29
+ * @property-read string $fax
30
+ * @property-read string $firstName
31
+ * @property-read string $id
32
+ * @property-read string $lastName
33
+ * @property-read string $phone
34
+ * @property-read string $updatedAt
35
+ * @property-read string $website
36
+ */
37
+ class Customer extends Base
38
+ {
39
+ /**
40
+ *
41
+ * @return Customer[]
42
+ */
43
+ public static function all()
44
+ {
45
+ return Configuration::gateway()->customer()->all();
46
+ }
47
+
48
+ /**
49
+ *
50
+ * @param string $query
51
+ * @param int[] $ids
52
+ * @return Customer|Customer[]
53
+ */
54
+ public static function fetch($query, $ids)
55
+ {
56
+ return Configuration::gateway()->customer()->fetch($query, $ids);
57
+ }
58
+
59
+ /**
60
+ *
61
+ * @param array $attribs
62
+ * @return Result\Successful|Result\Error
63
+ */
64
+ public static function create($attribs = [])
65
+ {
66
+ return Configuration::gateway()->customer()->create($attribs);
67
+ }
68
+
69
+ /**
70
+ *
71
+ * @param array $attribs
72
+ * @return Customer
73
+ */
74
+ public static function createNoValidate($attribs = [])
75
+ {
76
+ return Configuration::gateway()->customer()->createNoValidate($attribs);
77
+ }
78
+
79
+ /**
80
+ * @deprecated since version 2.3.0
81
+ * @param string $queryString
82
+ * @return Result\Successful
83
+ */
84
+ public static function createFromTransparentRedirect($queryString)
85
+ {
86
+ return Configuration::gateway()->customer()->createFromTransparentRedirect($queryString);
87
+ }
88
+
89
+ /**
90
+ * @deprecated since version 2.3.0
91
+ * @return string
92
+ */
93
+ public static function createCustomerUrl()
94
+ {
95
+ return Configuration::gateway()->customer()->createCustomerUrl();
96
+ }
97
+
98
+ /**
99
+ *
100
+ * @throws Exception\NotFound
101
+ * @param string $id customer id
102
+ * @return Customer
103
+ */
104
+ public static function find($id)
105
+ {
106
+ return Configuration::gateway()->customer()->find($id);
107
+ }
108
+
109
+ /**
110
+ *
111
+ * @param int $customerId
112
+ * @param array $transactionAttribs
113
+ * @return Result\Successful|Result\Error
114
+ */
115
+ public static function credit($customerId, $transactionAttribs)
116
+ {
117
+ return Configuration::gateway()->customer()->credit($customerId, $transactionAttribs);
118
+ }
119
+
120
+ /**
121
+ *
122
+ * @throws Exception\ValidationError
123
+ * @param type $customerId
124
+ * @param type $transactionAttribs
125
+ * @return Transaction
126
+ */
127
+ public static function creditNoValidate($customerId, $transactionAttribs)
128
+ {
129
+ return Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs);
130
+ }
131
+
132
+ /**
133
+ *
134
+ * @throws Exception on invalid id or non-200 http response code
135
+ * @param int $customerId
136
+ * @return Result\Successful
137
+ */
138
+ public static function delete($customerId)
139
+ {
140
+ return Configuration::gateway()->customer()->delete($customerId);
141
+ }
142
+
143
+ /**
144
+ *
145
+ * @param int $customerId
146
+ * @param array $transactionAttribs
147
+ * @return Transaction
148
+ */
149
+ public static function sale($customerId, $transactionAttribs)
150
+ {
151
+ return Configuration::gateway()->customer()->sale($customerId, $transactionAttribs);
152
+ }
153
+
154
+ /**
155
+ *
156
+ * @param int $customerId
157
+ * @param array $transactionAttribs
158
+ * @return Transaction
159
+ */
160
+ public static function saleNoValidate($customerId, $transactionAttribs)
161
+ {
162
+ return Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs);
163
+ }
164
+
165
+ /**
166
+ *
167
+ * @throws InvalidArgumentException
168
+ * @param string $query
169
+ * @return ResourceCollection
170
+ */
171
+ public static function search($query)
172
+ {
173
+ return Configuration::gateway()->customer()->search($query);
174
+ }
175
+
176
+ /**
177
+ *
178
+ * @throws Exception\Unexpected
179
+ * @param int $customerId
180
+ * @param array $attributes
181
+ * @return Result\Successful|Result\Error
182
+ */
183
+ public static function update($customerId, $attributes)
184
+ {
185
+ return Configuration::gateway()->customer()->update($customerId, $attributes);
186
+ }
187
+
188
+ /**
189
+ *
190
+ * @throws Exception\Unexpected
191
+ * @param int $customerId
192
+ * @param array $attributes
193
+ * @return CustomerGateway
194
+ */
195
+ public static function updateNoValidate($customerId, $attributes)
196
+ {
197
+ return Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes);
198
+ }
199
+
200
+ /**
201
+ *
202
+ * @deprecated since version 2.3.0
203
+ * @return string
204
+ */
205
+ public static function updateCustomerUrl()
206
+ {
207
+ return Configuration::gateway()->customer()->updateCustomerUrl();
208
+ }
209
+
210
+ /**
211
+ *
212
+ * @deprecated since version 2.3.0
213
+ * @param string $queryString
214
+ * @return Result\Successful|Result\Error
215
+ */
216
+ public static function updateFromTransparentRedirect($queryString)
217
+ {
218
+ return Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString);
219
+ }
220
+
221
+ /* instance methods */
222
+
223
+ /**
224
+ * sets instance properties from an array of values
225
+ *
226
+ * @ignore
227
+ * @access protected
228
+ * @param array $customerAttribs array of customer data
229
+ */
230
+ protected function _initialize($customerAttribs)
231
+ {
232
+ $this->_attributes = $customerAttribs;
233
+
234
+ $addressArray = [];
235
+ if (isset($customerAttribs['addresses'])) {
236
+
237
+ foreach ($customerAttribs['addresses'] AS $address) {
238
+ $addressArray[] = Address::factory($address);
239
+ }
240
+ }
241
+ $this->_set('addresses', $addressArray);
242
+
243
+ $creditCardArray = [];
244
+ if (isset($customerAttribs['creditCards'])) {
245
+ foreach ($customerAttribs['creditCards'] AS $creditCard) {
246
+ $creditCardArray[] = CreditCard::factory($creditCard);
247
+ }
248
+ }
249
+ $this->_set('creditCards', $creditCardArray);
250
+
251
+ $coinbaseAccountArray = [];
252
+ if (isset($customerAttribs['coinbaseAccounts'])) {
253
+ foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
254
+ $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
255
+ }
256
+ }
257
+ $this->_set('coinbaseAccounts', $coinbaseAccountArray);
258
+
259
+ $paypalAccountArray = [];
260
+ if (isset($customerAttribs['paypalAccounts'])) {
261
+ foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
262
+ $paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
263
+ }
264
+ }
265
+ $this->_set('paypalAccounts', $paypalAccountArray);
266
+
267
+ $applePayCardArray = [];
268
+ if (isset($customerAttribs['applePayCards'])) {
269
+ foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
270
+ $applePayCardArray[] = ApplePayCard::factory($applePayCard);
271
+ }
272
+ }
273
+ $this->_set('applePayCards', $applePayCardArray);
274
+
275
+ $androidPayCardArray = [];
276
+ if (isset($customerAttribs['androidPayCards'])) {
277
+ foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
278
+ $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
279
+ }
280
+ }
281
+ $this->_set('androidPayCards', $androidPayCardArray);
282
+
283
+ $amexExpressCheckoutCardArray = [];
284
+ if (isset($customerAttribs['amexExpressCheckoutCards'])) {
285
+ foreach ($customerAttribs['amexExpressCheckoutCards'] AS $amexExpressCheckoutCard) {
286
+ $amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard);
287
+ }
288
+ }
289
+ $this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray);
290
+
291
+ $venmoAccountArray = array();
292
+ if (isset($customerAttribs['venmoAccounts'])) {
293
+ foreach ($customerAttribs['venmoAccounts'] AS $venmoAccount) {
294
+ $venmoAccountArray[] = VenmoAccount::factory($venmoAccount);
295
+ }
296
+ }
297
+ $this->_set('venmoAccounts', $venmoAccountArray);
298
+
299
+ $usBankAccountArray = array();
300
+ if (isset($customerAttribs['usBankAccounts'])) {
301
+ foreach ($customerAttribs['usBankAccounts'] AS $usBankAccount) {
302
+ $usBankAccountArray[] = UsBankAccount::factory($usBankAccount);
303
+ }
304
+ }
305
+ $this->_set('usBankAccounts', $usBankAccountArray);
306
+
307
+ $this->_set('paymentMethods', array_merge(
308
+ $this->creditCards,
309
+ $this->paypalAccounts,
310
+ $this->applePayCards,
311
+ $this->coinbaseAccounts,
312
+ $this->androidPayCards,
313
+ $this->amexExpressCheckoutCards,
314
+ $this->venmoAccounts,
315
+ $this->usBankAccounts
316
+ ));
317
+ }
318
+
319
+ /**
320
+ * returns a string representation of the customer
321
+ * @return string
322
+ */
323
+ public function __toString()
324
+ {
325
+ return __CLASS__ . '[' .
326
+ Util::attributesToString($this->_attributes) .']';
327
+ }
328
+
329
+ /**
330
+ * returns false if comparing object is not a Customer,
331
+ * or is a Customer with a different id
332
+ *
333
+ * @param object $otherCust customer to compare against
334
+ * @return boolean
335
+ */
336
+ public function isEqual($otherCust)
337
+ {
338
+ return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id;
339
+ }
340
+
341
+ /**
342
+ * returns an array containt all of the customer's payment methods
343
+ *
344
+ * @deprecated since version 3.1.0 - use the paymentMethods property directly
345
+ *
346
+ * @return array
347
+ */
348
+ public function paymentMethods()
349
+ {
350
+ return $this->paymentMethods;
351
+ }
352
+
353
+ /**
354
+ * returns the customer's default payment method
355
+ *
356
+ * @return CreditCard|PayPalAccount
357
+ */
358
+ public function defaultPaymentMethod()
359
+ {
360
+ $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\Customer::_defaultPaymentMethodFilter');
361
+ return current($defaultPaymentMethods);
362
+ }
363
+
364
+ public static function _defaultPaymentMethodFilter($paymentMethod)
365
+ {
366
+ return $paymentMethod->isDefault();
367
+ }
368
+
369
+ /* private class properties */
370
+
371
+ /**
372
+ * @access protected
373
+ * @var array registry of customer data
374
+ */
375
+ protected $_attributes = [
376
+ 'addresses' => '',
377
+ 'company' => '',
378
+ 'creditCards' => '',
379
+ 'email' => '',
380
+ 'fax' => '',
381
+ 'firstName' => '',
382
+ 'id' => '',
383
+ 'lastName' => '',
384
+ 'phone' => '',
385
+ 'createdAt' => '',
386
+ 'updatedAt' => '',
387
+ 'website' => '',
388
+ ];
389
+
390
+ /**
391
+ * factory method: returns an instance of Customer
392
+ * to the requesting method, with populated properties
393
+ *
394
+ * @ignore
395
+ * @param array $attributes
396
+ * @return Customer
397
+ */
398
+ public static function factory($attributes)
399
+ {
400
+ $instance = new Customer();
401
+ $instance->_initialize($attributes);
402
+ return $instance;
403
+ }
404
+ }
405
+ class_alias('Braintree\Customer', 'Braintree_Customer');
lib/braintree/lib/Braintree/CustomerGateway.php ADDED
@@ -0,0 +1,626 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree CustomerGateway module
8
+ * Creates and manages Customers
9
+ *
10
+ * <b>== More information ==</b>
11
+ *
12
+ * For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api}
13
+ *
14
+ * @package Braintree
15
+ * @category Resources
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
+ */
18
+ class CustomerGateway
19
+ {
20
+ private $_gateway;
21
+ private $_config;
22
+ private $_http;
23
+
24
+ public function __construct($gateway)
25
+ {
26
+ $this->_gateway = $gateway;
27
+ $this->_config = $gateway->config;
28
+ $this->_config->assertHasAccessTokenOrKeys();
29
+ $this->_http = new Http($gateway->config);
30
+ }
31
+
32
+ public function all()
33
+ {
34
+ $path = $this->_config->merchantPath() . '/customers/advanced_search_ids';
35
+ $response = $this->_http->post($path);
36
+ $pager = [
37
+ 'object' => $this,
38
+ 'method' => 'fetch',
39
+ 'methodArgs' => [[]]
40
+ ];
41
+
42
+ return new ResourceCollection($response, $pager);
43
+ }
44
+
45
+ public function fetch($query, $ids)
46
+ {
47
+ $criteria = [];
48
+ foreach ($query as $term) {
49
+ $criteria[$term->name] = $term->toparam();
50
+ }
51
+ $criteria["ids"] = CustomerSearch::ids()->in($ids)->toparam();
52
+ $path = $this->_config->merchantPath() . '/customers/advanced_search';
53
+ $response = $this->_http->post($path, ['search' => $criteria]);
54
+
55
+ return Util::extractattributeasarray(
56
+ $response['customers'],
57
+ 'customer'
58
+ );
59
+ }
60
+
61
+ /**
62
+ * Creates a customer using the given +attributes+. If <tt>:id</tt> is not passed,
63
+ * the gateway will generate it.
64
+ *
65
+ * <code>
66
+ * $result = Customer::create(array(
67
+ * 'first_name' => 'John',
68
+ * 'last_name' => 'Smith',
69
+ * 'company' => 'Smith Co.',
70
+ * 'email' => 'john@smith.com',
71
+ * 'website' => 'www.smithco.com',
72
+ * 'fax' => '419-555-1234',
73
+ * 'phone' => '614-555-1234'
74
+ * ));
75
+ * if($result->success) {
76
+ * echo 'Created customer ' . $result->customer->id;
77
+ * } else {
78
+ * echo 'Could not create customer, see result->errors';
79
+ * }
80
+ * </code>
81
+ *
82
+ * @access public
83
+ * @param array $attribs
84
+ * @return Braintree_Result_Successful|Braintree_Result_Error
85
+ */
86
+ public function create($attribs = [])
87
+ {
88
+ Util::verifyKeys(self::createSignature(), $attribs);
89
+ return $this->_doCreate('/customers', ['customer' => $attribs]);
90
+ }
91
+
92
+ /**
93
+ * attempts the create operation assuming all data will validate
94
+ * returns a Customer object instead of a Result
95
+ *
96
+ * @access public
97
+ * @param array $attribs
98
+ * @return Customer
99
+ * @throws Exception\ValidationError
100
+ */
101
+ public function createNoValidate($attribs = [])
102
+ {
103
+ $result = $this->create($attribs);
104
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
105
+ }
106
+ /**
107
+ * create a customer from a TransparentRedirect operation
108
+ *
109
+ * @deprecated since version 2.3.0
110
+ * @access public
111
+ * @param array $attribs
112
+ * @return Customer
113
+ */
114
+ public function createFromTransparentRedirect($queryString)
115
+ {
116
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
117
+ $params = TransparentRedirect::parseAndValidateQueryString(
118
+ $queryString
119
+ );
120
+ return $this->_doCreate(
121
+ '/customers/all/confirm_transparent_redirect_request',
122
+ ['id' => $params['id']]
123
+ );
124
+ }
125
+
126
+ /**
127
+ *
128
+ * @deprecated since version 2.3.0
129
+ * @access public
130
+ * @param none
131
+ * @return string
132
+ */
133
+ public function createCustomerUrl()
134
+ {
135
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
136
+ return $this->_config->baseUrl() . $this->_config->merchantPath() .
137
+ '/customers/all/create_via_transparent_redirect_request';
138
+ }
139
+
140
+
141
+ /**
142
+ * creates a full array signature of a valid create request
143
+ * @return array gateway create request format
144
+ */
145
+ public static function createSignature()
146
+ {
147
+
148
+ $creditCardSignature = CreditCardGateway::createSignature();
149
+ unset($creditCardSignature[array_search('customerId', $creditCardSignature)]);
150
+ $signature = [
151
+ 'id', 'company', 'email', 'fax', 'firstName',
152
+ 'lastName', 'phone', 'website', 'deviceData',
153
+ 'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce',
154
+ ['riskData' =>
155
+ ['customerBrowser', 'customerIp', 'customer_browser', 'customer_ip']
156
+ ],
157
+ ['creditCard' => $creditCardSignature],
158
+ ['customFields' => ['_anyKey_']],
159
+ ];
160
+ return $signature;
161
+ }
162
+
163
+ /**
164
+ * creates a full array signature of a valid update request
165
+ * @return array update request format
166
+ */
167
+ public static function updateSignature()
168
+ {
169
+ $creditCardSignature = CreditCardGateway::updateSignature();
170
+
171
+ foreach($creditCardSignature AS $key => $value) {
172
+ if(is_array($value) and array_key_exists('options', $value)) {
173
+ array_push($creditCardSignature[$key]['options'], 'updateExistingToken');
174
+ }
175
+ }
176
+
177
+ $signature = [
178
+ 'id', 'company', 'email', 'fax', 'firstName',
179
+ 'lastName', 'phone', 'website', 'deviceData',
180
+ 'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce', 'defaultPaymentMethodToken',
181
+ ['creditCard' => $creditCardSignature],
182
+ ['customFields' => ['_anyKey_']],
183
+ ];
184
+ return $signature;
185
+ }
186
+
187
+
188
+ /**
189
+ * find a customer by id
190
+ *
191
+ * @access public
192
+ * @param string id customer Id
193
+ * @return Customer|boolean The customer object or false if the request fails.
194
+ * @throws Exception\NotFound
195
+ */
196
+ public function find($id)
197
+ {
198
+ $this->_validateId($id);
199
+ try {
200
+ $path = $this->_config->merchantPath() . '/customers/' . $id;
201
+ $response = $this->_http->get($path);
202
+ return Customer::factory($response['customer']);
203
+ } catch (Exception\NotFound $e) {
204
+ throw new Exception\NotFound(
205
+ 'customer with id ' . $id . ' not found'
206
+ );
207
+ }
208
+ }
209
+
210
+ /**
211
+ * credit a customer for the passed transaction
212
+ *
213
+ * @access public
214
+ * @param int $customerId
215
+ * @param array $transactionAttribs
216
+ * @return Result\Successful|Result\Error
217
+ */
218
+ public function credit($customerId, $transactionAttribs)
219
+ {
220
+ $this->_validateId($customerId);
221
+ return Transaction::credit(
222
+ array_merge($transactionAttribs,
223
+ ['customerId' => $customerId]
224
+ )
225
+ );
226
+ }
227
+
228
+ /**
229
+ * credit a customer, assuming validations will pass
230
+ *
231
+ * returns a Transaction object on success
232
+ *
233
+ * @access public
234
+ * @param int $customerId
235
+ * @param array $transactionAttribs
236
+ * @return Transaction
237
+ * @throws Exception\ValidationError
238
+ */
239
+ public function creditNoValidate($customerId, $transactionAttribs)
240
+ {
241
+ $result = $this->credit($customerId, $transactionAttribs);
242
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
243
+ }
244
+
245
+ /**
246
+ * delete a customer by id
247
+ *
248
+ * @param string $customerId
249
+ */
250
+ public function delete($customerId)
251
+ {
252
+ $this->_validateId($customerId);
253
+ $path = $this->_config->merchantPath() . '/customers/' . $customerId;
254
+ $this->_http->delete($path);
255
+ return new Result\Successful();
256
+ }
257
+
258
+ /**
259
+ * create a new sale for a customer
260
+ *
261
+ * @param string $customerId
262
+ * @param array $transactionAttribs
263
+ * @return Result\Successful|Result\Error
264
+ * @see Transaction::sale()
265
+ */
266
+ public function sale($customerId, $transactionAttribs)
267
+ {
268
+ $this->_validateId($customerId);
269
+ return Transaction::sale(
270
+ array_merge($transactionAttribs,
271
+ ['customerId' => $customerId]
272
+ )
273
+ );
274
+ }
275
+
276
+ /**
277
+ * create a new sale for a customer, assuming validations will pass
278
+ *
279
+ * returns a Transaction object on success
280
+ * @access public
281
+ * @param string $customerId
282
+ * @param array $transactionAttribs
283
+ * @return Transaction
284
+ * @throws Exception\ValidationsFailed
285
+ * @see Transaction::sale()
286
+ */
287
+ public function saleNoValidate($customerId, $transactionAttribs)
288
+ {
289
+ $result = $this->sale($customerId, $transactionAttribs);
290
+ return Util::returnObjectOrThrowException('Braintree\Transaction', $result);
291
+ }
292
+
293
+ /**
294
+ * Returns a ResourceCollection of customers matching the search query.
295
+ *
296
+ * If <b>query</b> is a string, the search will be a basic search.
297
+ * If <b>query</b> is a hash, the search will be an advanced search.
298
+ * For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/customer-api#searching http://www.braintreepaymentsolutions.com/gateway/customer-api}
299
+ *
300
+ * @param mixed $query search query
301
+ * @return ResourceCollection
302
+ * @throws InvalidArgumentException
303
+ */
304
+ public function search($query)
305
+ {
306
+ $criteria = [];
307
+ foreach ($query as $term) {
308
+ $result = $term->toparam();
309
+ if(is_null($result) || empty($result)) {
310
+ throw new InvalidArgumentException('Operator must be provided');
311
+ }
312
+
313
+ $criteria[$term->name] = $term->toparam();
314
+ }
315
+
316
+ $path = $this->_config->merchantPath() . '/customers/advanced_search_ids';
317
+ $response = $this->_http->post($path, ['search' => $criteria]);
318
+ $pager = [
319
+ 'object' => $this,
320
+ 'method' => 'fetch',
321
+ 'methodArgs' => [$query]
322
+ ];
323
+
324
+ return new ResourceCollection($response, $pager);
325
+ }
326
+
327
+ /**
328
+ * updates the customer record
329
+ *
330
+ * if calling this method in static context, customerId
331
+ * is the 2nd attribute. customerId is not sent in object context.
332
+ *
333
+ * @access public
334
+ * @param string $customerId (optional)
335
+ * @param array $attributes
336
+ * @return Result\Successful|Result\Error
337
+ */
338
+ public function update($customerId, $attributes)
339
+ {
340
+ Util::verifyKeys(self::updateSignature(), $attributes);
341
+ $this->_validateId($customerId);
342
+ return $this->_doUpdate(
343
+ 'put',
344
+ '/customers/' . $customerId,
345
+ ['customer' => $attributes]
346
+ );
347
+ }
348
+
349
+ /**
350
+ * update a customer record, assuming validations will pass
351
+ *
352
+ * if calling this method in static context, customerId
353
+ * is the 2nd attribute. customerId is not sent in object context.
354
+ * returns a Customer object on success
355
+ *
356
+ * @access public
357
+ * @param string $customerId
358
+ * @param array $attributes
359
+ * @return Customer
360
+ * @throws Exception\ValidationsFailed
361
+ */
362
+ public function updateNoValidate($customerId, $attributes)
363
+ {
364
+ $result = $this->update($customerId, $attributes);
365
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
366
+ }
367
+ /**
368
+ *
369
+ * @deprecated since version 2.3.0
370
+ * @access public
371
+ * @return string
372
+ */
373
+ public function updateCustomerUrl()
374
+ {
375
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
376
+ return $this->_config->baseUrl() . $this->_config->merchantPath() .
377
+ '/customers/all/update_via_transparent_redirect_request';
378
+ }
379
+
380
+ /**
381
+ * update a customer from a TransparentRedirect operation
382
+ *
383
+ * @deprecated since version 2.3.0
384
+ * @access public
385
+ * @param string $queryString
386
+ * @return object
387
+ */
388
+ public function updateFromTransparentRedirect($queryString)
389
+ {
390
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
391
+ $params = TransparentRedirect::parseAndValidateQueryString(
392
+ $queryString
393
+ );
394
+ return $this->_doUpdate(
395
+ 'post',
396
+ '/customers/all/confirm_transparent_redirect_request',
397
+ ['id' => $params['id']]
398
+ );
399
+ }
400
+
401
+ /* instance methods */
402
+
403
+ /**
404
+ * sets instance properties from an array of values
405
+ *
406
+ * @ignore
407
+ * @access protected
408
+ * @param array $customerAttribs array of customer data
409
+ * @return void
410
+ */
411
+ protected function _initialize($customerAttribs)
412
+ {
413
+ // set the attributes
414
+ $this->_attributes = $customerAttribs;
415
+
416
+ // map each address into its own object
417
+ $addressArray = [];
418
+ if (isset($customerAttribs['addresses'])) {
419
+
420
+ foreach ($customerAttribs['addresses'] AS $address) {
421
+ $addressArray[] = Address::factory($address);
422
+ }
423
+ }
424
+ $this->_set('addresses', $addressArray);
425
+
426
+ // map each creditCard into its own object
427
+ $creditCardArray = [];
428
+ if (isset($customerAttribs['creditCards'])) {
429
+ foreach ($customerAttribs['creditCards'] AS $creditCard) {
430
+ $creditCardArray[] = CreditCard::factory($creditCard);
431
+ }
432
+ }
433
+ $this->_set('creditCards', $creditCardArray);
434
+
435
+ // map each coinbaseAccount into its own object
436
+ $coinbaseAccountArray = [];
437
+ if (isset($customerAttribs['coinbaseAccounts'])) {
438
+ foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
439
+ $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
440
+ }
441
+ }
442
+ $this->_set('coinbaseAccounts', $coinbaseAccountArray);
443
+
444
+ // map each paypalAccount into its own object
445
+ $paypalAccountArray = [];
446
+ if (isset($customerAttribs['paypalAccounts'])) {
447
+ foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
448
+ $paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
449
+ }
450
+ }
451
+ $this->_set('paypalAccounts', $paypalAccountArray);
452
+
453
+ // map each applePayCard into its own object
454
+ $applePayCardArray = [];
455
+ if (isset($customerAttribs['applePayCards'])) {
456
+ foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
457
+ $applePayCardArray[] = ApplePayCard::factory($applePayCard);
458
+ }
459
+ }
460
+ $this->_set('applePayCards', $applePayCardArray);
461
+
462
+ // map each androidPayCard into its own object
463
+ $androidPayCardArray = [];
464
+ if (isset($customerAttribs['androidPayCards'])) {
465
+ foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
466
+ $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
467
+ }
468
+ }
469
+ $this->_set('androidPayCards', $androidPayCardArray);
470
+
471
+ $this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards));
472
+ }
473
+
474
+ /**
475
+ * returns a string representation of the customer
476
+ * @return string
477
+ */
478
+ public function __toString()
479
+ {
480
+ return __CLASS__ . '[' .
481
+ Util::attributesToString($this->_attributes) .']';
482
+ }
483
+
484
+ /**
485
+ * returns false if comparing object is not a Customer,
486
+ * or is a Customer with a different id
487
+ *
488
+ * @param object $otherCust customer to compare against
489
+ * @return boolean
490
+ */
491
+ public function isEqual($otherCust)
492
+ {
493
+ return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id;
494
+ }
495
+
496
+ /**
497
+ * returns an array containt all of the customer's payment methods
498
+ *
499
+ * @return array
500
+ */
501
+ public function paymentMethods()
502
+ {
503
+ return $this->paymentMethods;
504
+ }
505
+
506
+ /**
507
+ * returns the customer's default payment method
508
+ *
509
+ * @return CreditCard|PayPalAccount|ApplePayCard|AndroidPayCard
510
+ */
511
+ public function defaultPaymentMethod()
512
+ {
513
+ $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\\Customer::_defaultPaymentMethodFilter');
514
+ return current($defaultPaymentMethods);
515
+ }
516
+
517
+ public static function _defaultPaymentMethodFilter($paymentMethod)
518
+ {
519
+ return $paymentMethod->isDefault();
520
+ }
521
+
522
+ /* private class properties */
523
+
524
+ /**
525
+ * @access protected
526
+ * @var array registry of customer data
527
+ */
528
+ protected $_attributes = [
529
+ 'addresses' => '',
530
+ 'company' => '',
531
+ 'creditCards' => '',
532
+ 'email' => '',
533
+ 'fax' => '',
534
+ 'firstName' => '',
535
+ 'id' => '',
536
+ 'lastName' => '',
537
+ 'phone' => '',
538
+ 'createdAt' => '',
539
+ 'updatedAt' => '',
540
+ 'website' => '',
541
+ ];
542
+
543
+ /**
544
+ * sends the create request to the gateway
545
+ *
546
+ * @ignore
547
+ * @param string $subPath
548
+ * @param array $params
549
+ * @return mixed
550
+ */
551
+ public function _doCreate($subPath, $params)
552
+ {
553
+ $fullPath = $this->_config->merchantPath() . $subPath;
554
+ $response = $this->_http->post($fullPath, $params);
555
+
556
+ return $this->_verifyGatewayResponse($response);
557
+ }
558
+
559
+ /**
560
+ * verifies that a valid customer id is being used
561
+ * @ignore
562
+ * @param string customer id
563
+ * @throws InvalidArgumentException
564
+ */
565
+ private function _validateId($id = null) {
566
+ if (is_null($id)) {
567
+ throw new InvalidArgumentException(
568
+ 'expected customer id to be set'
569
+ );
570
+ }
571
+ if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
572
+ throw new InvalidArgumentException(
573
+ $id . ' is an invalid customer id.'
574
+ );
575
+ }
576
+ }
577
+
578
+
579
+ /* private class methods */
580
+
581
+ /**
582
+ * sends the update request to the gateway
583
+ *
584
+ * @ignore
585
+ * @param string $subPath
586
+ * @param array $params
587
+ * @return mixed
588
+ */
589
+ private function _doUpdate($httpVerb, $subPath, $params)
590
+ {
591
+ $fullPath = $this->_config->merchantPath() . $subPath;
592
+ $response = $this->_http->$httpVerb($fullPath, $params);
593
+
594
+ return $this->_verifyGatewayResponse($response);
595
+ }
596
+
597
+ /**
598
+ * generic method for validating incoming gateway responses
599
+ *
600
+ * creates a new Customer object and encapsulates
601
+ * it inside a Result\Successful object, or
602
+ * encapsulates a Errors object inside a Result\Error
603
+ * alternatively, throws an Unexpected exception if the response is invalid.
604
+ *
605
+ * @ignore
606
+ * @param array $response gateway response values
607
+ * @return Result\Successful|Result\Error
608
+ * @throws Exception\Unexpected
609
+ */
610
+ private function _verifyGatewayResponse($response)
611
+ {
612
+ if (isset($response['customer'])) {
613
+ // return a populated instance of Customer
614
+ return new Result\Successful(
615
+ Customer::factory($response['customer'])
616
+ );
617
+ } else if (isset($response['apiErrorResponse'])) {
618
+ return new Result\Error($response['apiErrorResponse']);
619
+ } else {
620
+ throw new Exception\Unexpected(
621
+ "Expected customer or apiErrorResponse"
622
+ );
623
+ }
624
+ }
625
+ }
626
+ class_alias('Braintree\CustomerGateway', 'Braintree_CustomerGateway');
lib/braintree/lib/Braintree/CustomerSearch.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class CustomerSearch
5
+ {
6
+ public static function addressCountryName() { return new TextNode('address_country_name'); }
7
+ public static function addressExtendedAddress() { return new TextNode('address_extended_address'); }
8
+ public static function addressFirstName() { return new TextNode('address_first_name'); }
9
+ public static function addressLastName() { return new TextNode('address_last_name'); }
10
+ public static function addressLocality() { return new TextNode('address_locality'); }
11
+ public static function addressPostalCode() { return new TextNode('address_postal_code'); }
12
+ public static function addressRegion() { return new TextNode('address_region'); }
13
+ public static function addressStreetAddress() { return new TextNode('address_street_address'); }
14
+ public static function cardholderName() { return new TextNode('cardholder_name'); }
15
+ public static function company() { return new TextNode('company'); }
16
+ public static function email() { return new TextNode('email'); }
17
+ public static function fax() { return new TextNode('fax'); }
18
+ public static function firstName() { return new TextNode('first_name'); }
19
+ public static function id() { return new TextNode('id'); }
20
+ public static function lastName() { return new TextNode('last_name'); }
21
+ public static function paymentMethodToken() { return new TextNode('payment_method_token'); }
22
+ public static function paymentMethodTokenWithDuplicates() { return new IsNode('payment_method_token_with_duplicates'); }
23
+ public static function paypalAccountEmail() { return new IsNode('paypal_account_email'); }
24
+ public static function phone() { return new TextNode('phone'); }
25
+ public static function website() { return new TextNode('website'); }
26
+
27
+ public static function creditCardExpirationDate() { return new EqualityNode('credit_card_expiration_date'); }
28
+ public static function creditCardNumber() { return new PartialMatchNode('credit_card_number'); }
29
+
30
+ public static function ids() { return new MultipleValueNode('ids'); }
31
+
32
+ public static function createdAt() { return new RangeNode("created_at"); }
33
+ }
34
+ class_alias('Braintree\CustomerSearch', 'Braintree_CustomerSearch');
lib/braintree/lib/Braintree/Descriptor.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class Descriptor extends Instance
5
+ {
6
+ }
7
+ class_alias('Braintree\Descriptor', 'Braintree_Descriptor');
lib/braintree/lib/Braintree/Digest.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Digest encryption module
6
+ * Digest creates an HMAC-SHA1 hash for encrypting messages
7
+ *
8
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
9
+ */
10
+ class Digest
11
+ {
12
+ public static function hexDigestSha1($key, $string)
13
+ {
14
+ if(function_exists('hash_hmac')) {
15
+ return self::_builtInHmacSha1($string, $key);
16
+ } else {
17
+ return self::_hmacSha1($string, $key);
18
+ }
19
+ }
20
+
21
+ public static function hexDigestSha256($key, $string)
22
+ {
23
+ return hash_hmac('sha256', $string, hash('sha256', $key, true));
24
+ }
25
+
26
+ public static function secureCompare($left, $right)
27
+ {
28
+ if (strlen($left) != strlen($right)) {
29
+ return false;
30
+ }
31
+
32
+ $leftBytes = unpack("C*", $left);
33
+ $rightBytes = unpack("C*", $right);
34
+
35
+ $result = 0;
36
+ for ($i = 1; $i <= count($leftBytes); $i++) {
37
+ $result = $result | ($leftBytes[$i] ^ $rightBytes[$i]);
38
+ }
39
+ return $result == 0;
40
+ }
41
+
42
+ public static function _builtInHmacSha1($message, $key)
43
+ {
44
+ return hash_hmac('sha1', $message, sha1($key, true));
45
+ }
46
+
47
+ public static function _hmacSha1($message, $key)
48
+ {
49
+ $pack = 'H40';
50
+ $keyDigest = sha1($key,true);
51
+ $innerPad = str_repeat(chr(0x36), 64);
52
+ $outerPad = str_repeat(chr(0x5C), 64);
53
+
54
+ for ($i = 0; $i < 20; $i++) {
55
+ $innerPad{$i} = $keyDigest{$i} ^ $innerPad{$i};
56
+ $outerPad{$i} = $keyDigest{$i} ^ $outerPad{$i};
57
+ }
58
+
59
+ return sha1($outerPad.pack($pack, sha1($innerPad.$message)));
60
+ }
61
+ }
62
+ class_alias('Braintree\Digest', 'Braintree_Digest');
lib/braintree/lib/Braintree/Disbursement.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class Disbursement extends Base
5
+ {
6
+ private $_merchantAccount;
7
+
8
+ protected function _initialize($disbursementAttribs)
9
+ {
10
+ $this->_attributes = $disbursementAttribs;
11
+ $this->merchantAccountDetails = $disbursementAttribs['merchantAccount'];
12
+
13
+ if (isset($disbursementAttribs['merchantAccount'])) {
14
+ $this->_set('merchantAccount',
15
+ MerchantAccount::factory($disbursementAttribs['merchantAccount'])
16
+ );
17
+ }
18
+ }
19
+
20
+ public function transactions()
21
+ {
22
+ $collection = Transaction::search([
23
+ TransactionSearch::ids()->in($this->transactionIds),
24
+ ]);
25
+
26
+ return $collection;
27
+ }
28
+
29
+ public static function factory($attributes)
30
+ {
31
+ $instance = new self();
32
+ $instance->_initialize($attributes);
33
+ return $instance;
34
+ }
35
+
36
+ public function __toString()
37
+ {
38
+ $display = [
39
+ 'id', 'merchantAccountDetails', 'exceptionMessage', 'amount',
40
+ 'disbursementDate', 'followUpAction', 'retry', 'success',
41
+ 'transactionIds'
42
+ ];
43
+
44
+ $displayAttributes = [];
45
+ foreach ($display AS $attrib) {
46
+ $displayAttributes[$attrib] = $this->$attrib;
47
+ }
48
+ return __CLASS__ . '[' .
49
+ Util::attributesToString($displayAttributes) .']';
50
+ }
51
+ }
52
+ class_alias('Braintree\Disbursement', 'Braintree_Disbursement');
lib/braintree/lib/Braintree/DisbursementDetails.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Disbursement details from a transaction
6
+ * Creates an instance of DisbursementDetails as returned from a transaction
7
+ *
8
+ *
9
+ * @package Braintree
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
+ *
12
+ * @property-read string $settlementAmount
13
+ * @property-read string $settlementCurrencyIsoCode
14
+ * @property-read string $settlementCurrencyExchangeRate
15
+ * @property-read string $fundsHeld
16
+ * @property-read string $success
17
+ * @property-read string $disbursementDate
18
+ */
19
+ class DisbursementDetails extends Instance
20
+ {
21
+ public function isValid() {
22
+ return !is_null($this->disbursementDate);
23
+ }
24
+ }
25
+ class_alias('Braintree\DisbursementDetails', 'Braintree_DisbursementDetails');
lib/braintree/lib/Braintree/Discount.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class Discount extends Modification
5
+ {
6
+ public static function factory($attributes)
7
+ {
8
+ $instance = new self();
9
+ $instance->_initialize($attributes);
10
+ return $instance;
11
+ }
12
+
13
+
14
+ // static methods redirecting to gateway
15
+
16
+ public static function all()
17
+ {
18
+ return Configuration::gateway()->discount()->all();
19
+ }
20
+ }
21
+ class_alias('Braintree\Discount', 'Braintree_Discount');
lib/braintree/lib/Braintree/DiscountGateway.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class DiscountGateway
5
+ {
6
+ private $_gateway;
7
+ private $_config;
8
+ private $_http;
9
+
10
+ public function __construct($gateway)
11
+ {
12
+ $this->_gateway = $gateway;
13
+ $this->_config = $gateway->config;
14
+ $this->_config->assertHasAccessTokenOrKeys();
15
+ $this->_http = new Http($gateway->config);
16
+ }
17
+
18
+ public function all()
19
+ {
20
+ $path = $this->_config->merchantPath() . '/discounts';
21
+ $response = $this->_http->get($path);
22
+
23
+ $discounts = ["discount" => $response['discounts']];
24
+
25
+ return Util::extractAttributeAsArray(
26
+ $discounts,
27
+ 'discount'
28
+ );
29
+ }
30
+ }
31
+ class_alias('Braintree\DiscountGateway', 'Braintree_DiscountGateway');
lib/braintree/lib/Braintree/Dispute.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Creates an instance of Dispute as returned from a transaction
6
+ *
7
+ *
8
+ * @package Braintree
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ *
11
+ * @property-read string $amount
12
+ * @property-read string $currencyIsoCode
13
+ * @property-read date $receivedDate
14
+ * @property-read string $reason
15
+ * @property-read string $status
16
+ * @property-read string $disbursementDate
17
+ * @property-read object $transactionDetails
18
+ */
19
+ class Dispute extends Base
20
+ {
21
+ protected $_attributes = [];
22
+
23
+ /* Dispute Status */
24
+ const OPEN = 'open';
25
+ const WON = 'won';
26
+ const LOST = 'lost';
27
+
28
+ /* deprecated; for backwards compatibilty */
29
+ const Open = 'open';
30
+
31
+ /* Dispute Reason */
32
+ const CANCELLED_RECURRING_TRANSACTION = "cancelled_recurring_transaction";
33
+ const CREDIT_NOT_PROCESSED = "credit_not_processed";
34
+ const DUPLICATE = "duplicate";
35
+ const FRAUD = "fraud";
36
+ const GENERAL = "general";
37
+ const INVALID_ACCOUNT = "invalid_account";
38
+ const NOT_RECOGNIZED = "not_recognized";
39
+ const PRODUCT_NOT_RECEIVED = "product_not_received";
40
+ const PRODUCT_UNSATISFACTORY = "product_unsatisfactory";
41
+ const TRANSACTION_AMOUNT_DIFFERS = "transaction_amount_differs";
42
+ const RETRIEVAL = "retrieval";
43
+
44
+ /* Dispute Kind */
45
+ const CHARGEBACK = 'chargeback';
46
+ const PRE_ARBITRATION = 'pre_arbitration';
47
+ // RETRIEVAL for kind already defined under Dispute Reason
48
+
49
+ protected function _initialize($disputeAttribs)
50
+ {
51
+ $this->_attributes = $disputeAttribs;
52
+
53
+ if (isset($disputeAttribs['transaction'])) {
54
+ $this->_set('transactionDetails',
55
+ new Dispute\TransactionDetails($disputeAttribs['transaction'])
56
+ );
57
+ }
58
+ }
59
+
60
+ public static function factory($attributes)
61
+ {
62
+ $instance = new self();
63
+ $instance->_initialize($attributes);
64
+ return $instance;
65
+ }
66
+
67
+ public function __toString()
68
+ {
69
+ $display = [
70
+ 'amount', 'reason', 'status',
71
+ 'replyByDate', 'receivedDate', 'currencyIsoCode'
72
+ ];
73
+
74
+ $displayAttributes = [];
75
+ foreach ($display AS $attrib) {
76
+ $displayAttributes[$attrib] = $this->$attrib;
77
+ }
78
+ return __CLASS__ . '[' .
79
+ Util::attributesToString($displayAttributes) .']';
80
+ }
81
+ }
82
+ class_alias('Braintree\Dispute', 'Braintree_Dispute');
lib/braintree/lib/Braintree/Dispute/TransactionDetails.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Dispute;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Transaction details for a dispute
8
+ *
9
+ * @package Braintree
10
+ * @copyright 2010 Braintree Payment Solutions
11
+ */
12
+
13
+ /**
14
+ * Creates an instance of DisbursementDetails as returned from a transaction
15
+ *
16
+ *
17
+ * @package Braintree
18
+ * @copyright 2010 Braintree Payment Solutions
19
+ *
20
+ * @property-read string $amount
21
+ * @property-read string $id
22
+ */
23
+ class TransactionDetails extends Instance
24
+ {
25
+ }
26
+
27
+ class_alias('Braintree\Dispute\TransactionDetails', 'Braintree_Dispute_TransactionDetails');
lib/braintree/lib/Braintree/EqualityNode.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class EqualityNode extends IsNode
5
+ {
6
+ function isNot($value)
7
+ {
8
+ $this->searchTerms['is_not'] = strval($value);
9
+ return $this;
10
+ }
11
+ }
12
+ class_alias('Braintree\EqualityNode', 'Braintree_EqualityNode');
lib/braintree/lib/Braintree/Error/Codes.php ADDED
@@ -0,0 +1,523 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Error;
3
+
4
+ /**
5
+ *
6
+ * Validation Error codes and messages
7
+ *
8
+ * ErrorCodes class provides constants for validation errors.
9
+ * The constants should be used to check for a specific validation
10
+ * error in a ValidationErrorCollection.
11
+ * The error messages returned from the server may change;
12
+ * but the codes will remain the same.
13
+ *
14
+ * @package Braintree
15
+ * @subpackage Errors
16
+ * @category Validation
17
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
18
+ */
19
+ class Codes
20
+ {
21
+ const ADDRESS_CANNOT_BE_BLANK = '81801';
22
+ const ADDRESS_COMPANY_IS_INVALID = '91821';
23
+ const ADDRESS_COMPANY_IS_TOO_LONG = '81802';
24
+ const ADDRESS_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED = '91814';
25
+ const ADDRESS_COUNTRY_CODE_ALPHA3_IS_NOT_ACCEPTED = '91816';
26
+ const ADDRESS_COUNTRY_CODE_NUMERIC_IS_NOT_ACCEPTED = '91817';
27
+ const ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED = '91803';
28
+ const ADDRESS_EXTENDED_ADDRESS_IS_INVALID = '91823';
29
+ const ADDRESS_EXTENDED_ADDRESS_IS_TOO_LONG = '81804';
30
+ const ADDRESS_FIRST_NAME_IS_INVALID = '91819';
31
+ const ADDRESS_FIRST_NAME_IS_TOO_LONG = '81805';
32
+ const ADDRESS_INCONSISTENT_COUNTRY = '91815';
33
+ const ADDRESS_LAST_NAME_IS_INVALID = '91820';
34
+ const ADDRESS_LAST_NAME_IS_TOO_LONG = '81806';
35
+ const ADDRESS_LOCALITY_IS_INVALID = '91824';
36
+ const ADDRESS_LOCALITY_IS_TOO_LONG = '81807';
37
+ const ADDRESS_POSTAL_CODE_INVALID_CHARACTERS = '81813';
38
+ const ADDRESS_POSTAL_CODE_IS_INVALID = '91826';
39
+ const ADDRESS_POSTAL_CODE_IS_REQUIRED = '81808';
40
+ const ADDRESS_POSTAL_CODE_IS_TOO_LONG = '81809';
41
+ const ADDRESS_REGION_IS_INVALID = '91825';
42
+ const ADDRESS_REGION_IS_TOO_LONG = '81810';
43
+ const ADDRESS_STATE_IS_INVALID_FOR_SELLER_PROTECTION = '81827';
44
+ const ADDRESS_STREET_ADDRESS_IS_INVALID = '91822';
45
+ const ADDRESS_STREET_ADDRESS_IS_REQUIRED = '81811';
46
+ const ADDRESS_STREET_ADDRESS_IS_TOO_LONG = '81812';
47
+ const ADDRESS_TOO_MANY_ADDRESSES_PER_CUSTOMER = '91818';
48
+
49
+ const APPLE_PAY_CARDS_ARE_NOT_ACCEPTED = '83501';
50
+ const APPLE_PAY_CUSTOMER_ID_IS_REQUIRED_FOR_VAULTING = '83502';
51
+ const APPLE_PAY_TOKEN_IS_IN_USE = '93503';
52
+ const APPLE_PAY_PAYMENT_METHOD_NONCE_CONSUMED = '93504';
53
+ const APPLE_PAY_PAYMENT_METHOD_NONCE_UNKNOWN = '93505';
54
+ const APPLE_PAY_PAYMENT_METHOD_NONCE_UNLOCKED = '93506';
55
+ const APPLE_PAY_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '83518';
56
+ const APPLE_PAY_CANNOT_UPDATE_APPLE_PAY_CARD_USING_PAYMENT_METHOD_NONCE = '93507';
57
+ const APPLE_PAY_NUMBER_IS_REQUIRED = '93508';
58
+ const APPLE_PAY_EXPIRATION_MONTH_IS_REQUIRED = '93509';
59
+ const APPLE_PAY_EXPIRATION_YEAR_IS_REQUIRED = '93510';
60
+ const APPLE_PAY_CRYPTOGRAM_IS_REQUIRED = '93511';
61
+ const APPLE_PAY_DECRYPTION_FAILED = '83512';
62
+ const APPLE_PAY_DISABLED = '93513';
63
+ const APPLE_PAY_MERCHANT_NOT_CONFIGURED = '93514';
64
+ const APPLE_PAY_MERCHANT_KEYS_ALREADY_CONFIGURED = '93515';
65
+ const APPLE_PAY_MERCHANT_KEYS_NOT_CONFIGURED = '93516';
66
+ const APPLE_PAY_CERTIFICATE_INVALID = '93517';
67
+ const APPLE_PAY_CERTIFICATE_MISMATCH = '93519';
68
+ const APPLE_PAY_INVALID_TOKEN = '83520';
69
+ const APPLE_PAY_PRIVATE_KEY_MISMATCH = '93521';
70
+ const APPLE_PAY_KEY_MISMATCH_STORING_CERTIFICATE = '93522';
71
+
72
+ const AUTHORIZATION_FINGERPRINT_INVALID_CREATED_AT = '93204';
73
+ const AUTHORIZATION_FINGERPRINT_INVALID_FORMAT = '93202';
74
+ const AUTHORIZATION_FINGERPRINT_INVALID_PUBLIC_KEY = '93205';
75
+ const AUTHORIZATION_FINGERPRINT_INVALID_SIGNATURE = '93206';
76
+ const AUTHORIZATION_FINGERPRINT_MISSING_FINGERPRINT = '93201';
77
+ const AUTHORIZATION_FINGERPRINT_OPTIONS_NOT_ALLOWED_WITHOUT_CUSTOMER = '93207';
78
+ const AUTHORIZATION_FINGERPRINT_SIGNATURE_REVOKED = '93203';
79
+
80
+ const CLIENT_TOKEN_CUSTOMER_DOES_NOT_EXIST = '92804';
81
+ const CLIENT_TOKEN_FAIL_ON_DUPLICATE_PAYMENT_METHOD_REQUIRES_CUSTOMER_ID = '92803';
82
+ const CLIENT_TOKEN_MAKE_DEFAULT_REQUIRES_CUSTOMER_ID = '92801';
83
+ const CLIENT_TOKEN_PROXY_MERCHANT_DOES_NOT_EXIST = '92805';
84
+ const CLIENT_TOKEN_UNSUPPORTED_VERSION = '92806';
85
+ const CLIENT_TOKEN_VERIFY_CARD_REQUIRES_CUSTOMER_ID = '92802';
86
+ const CLIENT_TOKEN_MERCHANT_ACCOUNT_DOES_NOT_EXIST = '92807';
87
+
88
+ const CREDIT_CARD_BILLING_ADDRESS_CONFLICT = '91701';
89
+ const CREDIT_CARD_BILLING_ADDRESS_FORMAT_IS_INVALID = '91744';
90
+ const CREDIT_CARD_BILLING_ADDRESS_ID_IS_INVALID = '91702';
91
+ const CREDIT_CARD_CANNOT_UPDATE_CARD_USING_PAYMENT_METHOD_NONCE = '91735';
92
+ const CREDIT_CARD_CARDHOLDER_NAME_IS_TOO_LONG = '81723';
93
+ const CREDIT_CARD_CREDIT_CARD_TYPE_IS_NOT_ACCEPTED = '81703';
94
+ const CREDIT_CARD_CREDIT_CARD_TYPE_IS_NOT_ACCEPTED_BY_SUBSCRIPTION_MERCHANT_ACCOUNT = '81718';
95
+ const CREDIT_CARD_CUSTOMER_ID_IS_INVALID = '91705';
96
+ const CREDIT_CARD_CUSTOMER_ID_IS_REQUIRED = '91704';
97
+ const CREDIT_CARD_CVV_IS_INVALID = '81707';
98
+ const CREDIT_CARD_CVV_IS_REQUIRED = '81706';
99
+ const CREDIT_CARD_CVV_VERIFICATION_FAILED = '81736';
100
+ const CREDIT_CARD_DUPLICATE_CARD_EXISTS = '81724';
101
+ const CREDIT_CARD_EXPIRATION_DATE_CONFLICT = '91708';
102
+ const CREDIT_CARD_EXPIRATION_DATE_IS_INVALID = '81710';
103
+ const CREDIT_CARD_EXPIRATION_DATE_IS_REQUIRED = '81709';
104
+ const CREDIT_CARD_EXPIRATION_DATE_YEAR_IS_INVALID = '81711';
105
+ const CREDIT_CARD_EXPIRATION_MONTH_IS_INVALID = '81712';
106
+ const CREDIT_CARD_EXPIRATION_YEAR_IS_INVALID = '81713';
107
+ const CREDIT_CARD_INVALID_PARAMS_FOR_CREDIT_CARD_UPDATE = '91745';
108
+ const CREDIT_CARD_INVALID_VENMO_SDK_PAYMENT_METHOD_CODE = '91727';
109
+ const CREDIT_CARD_NUMBER_INVALID_LENGTH = '81716';
110
+ const CREDIT_CARD_NUMBER_IS_INVALID = '81715';
111
+ const CREDIT_CARD_NUMBER_IS_PROHIBITED = '81750';
112
+ const CREDIT_CARD_NUMBER_IS_REQUIRED = '81714';
113
+ const CREDIT_CARD_NUMBER_LENGTH_IS_INVALID = '81716';
114
+ const CREDIT_CARD_NUMBER_MUST_BE_TEST_NUMBER = '81717';
115
+ const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_IS_INVALID = '91723';
116
+ const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_NOT_ALLOWED = '91729';
117
+ const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_CANNOT_BE_NEGATIVE = '91739';
118
+ const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_FORMAT_IS_INVALID = '91740';
119
+ const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_IS_TOO_LARGE = '91752';
120
+ const CREDIT_CARD_OPTIONS_VERIFICATION_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = '91741';
121
+ const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91728';
122
+ const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_IS_FORBIDDEN = '91743';
123
+ const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_IS_SUSPENDED = '91742';
124
+ const CREDIT_CARD_OPTIONS_VERIFICATION_MERCHANT_ACCOUNT_CANNOT_BE_SUB_MERCHANT_ACCOUNT = '91755';
125
+ const CREDIT_CARD_PAYMENT_METHOD_CONFLICT = '81725';
126
+ const CREDIT_CARD_PAYMENT_METHOD_IS_NOT_A_CREDIT_CARD = '91738';
127
+ const CREDIT_CARD_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91734';
128
+ const CREDIT_CARD_PAYMENT_METHOD_NONCE_CONSUMED = '91731';
129
+ const CREDIT_CARD_PAYMENT_METHOD_NONCE_LOCKED = '91733';
130
+ const CREDIT_CARD_PAYMENT_METHOD_NONCE_UNKNOWN = '91732';
131
+ const CREDIT_CARD_POSTAL_CODE_VERIFICATION_FAILED = '81737';
132
+ const CREDIT_CARD_TOKEN_FORMAT_IS_INVALID = '91718';
133
+ const CREDIT_CARD_TOKEN_INVALID = '91718';
134
+ const CREDIT_CARD_TOKEN_IS_IN_USE = '91719';
135
+ const CREDIT_CARD_TOKEN_IS_NOT_ALLOWED = '91721';
136
+ const CREDIT_CARD_TOKEN_IS_REQUIRED = '91722';
137
+ const CREDIT_CARD_TOKEN_IS_TOO_LONG = '91720';
138
+ const CREDIT_CARD_VENMO_SDK_PAYMENT_METHOD_CODE_CARD_TYPE_IS_NOT_ACCEPTED = '91726';
139
+ const CREDIT_CARD_VERIFICATION_NOT_SUPPORTED_ON_THIS_MERCHANT_ACCOUNT = '91730';
140
+
141
+ const CUSTOMER_COMPANY_IS_TOO_LONG = '81601';
142
+ const CUSTOMER_CUSTOM_FIELD_IS_INVALID = '91602';
143
+ const CUSTOMER_CUSTOM_FIELD_IS_TOO_LONG = '81603';
144
+ const CUSTOMER_EMAIL_FORMAT_IS_INVALID = '81604';
145
+ const CUSTOMER_EMAIL_IS_INVALID = '81604';
146
+ const CUSTOMER_EMAIL_IS_REQUIRED = '81606';
147
+ const CUSTOMER_EMAIL_IS_TOO_LONG = '81605';
148
+ const CUSTOMER_FAX_IS_TOO_LONG = '81607';
149
+ const CUSTOMER_FIRST_NAME_IS_TOO_LONG = '81608';
150
+ const CUSTOMER_ID_IS_INVAILD = '91610'; //Deprecated
151
+ const CUSTOMER_ID_IS_INVALID = '91610';
152
+ const CUSTOMER_ID_IS_IN_USE = '91609';
153
+ const CUSTOMER_ID_IS_NOT_ALLOWED = '91611';
154
+ const CUSTOMER_ID_IS_REQUIRED = '91613';
155
+ const CUSTOMER_ID_IS_TOO_LONG = '91612';
156
+ const CUSTOMER_LAST_NAME_IS_TOO_LONG = '81613';
157
+ const CUSTOMER_PHONE_IS_TOO_LONG = '81614';
158
+ const CUSTOMER_VAULTED_PAYMENT_INSTRUMENT_NONCE_BELONGS_TO_DIFFERENT_CUSTOMER = '91617';
159
+ const CUSTOMER_WEBSITE_FORMAT_IS_INVALID = '81616';
160
+ const CUSTOMER_WEBSITE_IS_INVALID = '81616';
161
+ const CUSTOMER_WEBSITE_IS_TOO_LONG = '81615';
162
+
163
+ const DESCRIPTOR_NAME_FORMAT_IS_INVALID = '92201';
164
+ const DESCRIPTOR_PHONE_FORMAT_IS_INVALID = '92202';
165
+ const DESCRIPTOR_INTERNATIONAL_NAME_FORMAT_IS_INVALID = '92204';
166
+ const DESCRIPTOR_DYNAMIC_DESCRIPTORS_DISABLED = '92203';
167
+ const DESCRIPTOR_INTERNATIONAL_PHONE_FORMAT_IS_INVALID = '92205';
168
+ const DESCRIPTOR_URL_FORMAT_IS_INVALID = '92206';
169
+
170
+ const INDUSTRY_DATA_INDUSTRY_TYPE_IS_INVALID = '93401';
171
+ const INDUSTRY_DATA_LODGING_EMPTY_DATA = '93402';
172
+ const INDUSTRY_DATA_LODGING_FOLIO_NUMBER_IS_INVALID = '93403';
173
+ const INDUSTRY_DATA_LODGING_CHECK_IN_DATE_IS_INVALID = '93404';
174
+ const INDUSTRY_DATA_LODGING_CHECK_OUT_DATE_IS_INVALID = '93405';
175
+ const INDUSTRY_DATA_LODGING_CHECK_OUT_DATE_MUST_FOLLOW_CHECK_IN_DATE = '93406';
176
+ const INDUSTRY_DATA_LODGING_UNKNOWN_DATA_FIELD = '93407';
177
+ const INDUSTRY_DATA_TRAVEL_CRUISE_EMPTY_DATA = '93408';
178
+ const INDUSTRY_DATA_TRAVEL_CRUISE_UNKNOWN_DATA_FIELD = '93409';
179
+ const INDUSTRY_DATA_TRAVEL_CRUISE_TRAVEL_PACKAGE_IS_INVALID = '93410';
180
+ const INDUSTRY_DATA_TRAVEL_CRUISE_DEPARTURE_DATE_IS_INVALID = '93411';
181
+ const INDUSTRY_DATA_TRAVEL_CRUISE_LODGING_CHECK_IN_DATE_IS_INVALID = '93412';
182
+ const INDUSTRY_DATA_TRAVEL_CRUISE_LODGING_CHECK_OUT_DATE_IS_INVALID = '93413';
183
+
184
+ const MERCHANT_COUNTRY_CANNOT_BE_BLANK = '83603';
185
+ const MERCHANT_COUNTRY_CODE_ALPHA2_IS_INVALID = '93607';
186
+ const MERCHANT_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED = '93606';
187
+ const MERCHANT_COUNTRY_CODE_ALPHA3_IS_INVALID = '93605';
188
+ const MERCHANT_COUNTRY_CODE_ALPHA3_IS_NOT_ACCEPTED = '93604';
189
+ const MERCHANT_COUNTRY_CODE_NUMERIC_IS_INVALID = '93609';
190
+ const MERCHANT_COUNTRY_CODE_NUMERIC_IS_NOT_ACCEPTED = '93608';
191
+ const MERCHANT_COUNTRY_NAME_IS_INVALID = '93611';
192
+ const MERCHANT_COUNTRY_NAME_IS_NOT_ACCEPTED = '93610';
193
+ const MERCHANT_CURRENCIES_ARE_INVALID = '93614';
194
+ const MERCHANT_EMAIL_FORMAT_IS_INVALID = '93602';
195
+ const MERCHANT_EMAIL_IS_REQUIRED = '83601';
196
+ const MERCHANT_INCONSISTENT_COUNTRY = '93612';
197
+ const MERCHANT_ACCOUNT_PAYMENT_METHODS_ARE_INVALID = '93613';
198
+ const MERCHANT_PAYMENT_METHODS_ARE_NOT_ALLOWED = '93615';
199
+
200
+ const MERCHANT_ACCOUNT_ID_FORMAT_IS_INVALID = '82603';
201
+ const MERCHANT_ACCOUNT_ID_IS_IN_USE = '82604';
202
+ const MERCHANT_ACCOUNT_ID_IS_NOT_ALLOWED = '82605';
203
+ const MERCHANT_ACCOUNT_ID_IS_TOO_LONG = '82602';
204
+ const MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_IS_INVALID = '82607';
205
+ const MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_IS_REQUIRED = '82606';
206
+ const MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_MUST_BE_ACTIVE = '82608';
207
+ const MERCHANT_ACCOUNT_TOS_ACCEPTED_IS_REQUIRED = '82610';
208
+ const MERCHANT_ACCOUNT_CANNOT_BE_UPDATED = '82674';
209
+ const MERCHANT_ACCOUNT_DECLINED = '82626';
210
+ const MERCHANT_ACCOUNT_DECLINED_MASTER_CARD_MATCH = '82622';
211
+ const MERCHANT_ACCOUNT_DECLINED_OFAC = '82621';
212
+ const MERCHANT_ACCOUNT_DECLINED_FAILED_KYC = '82623';
213
+ const MERCHANT_ACCOUNT_DECLINED_SSN_INVALID = '82624';
214
+ const MERCHANT_ACCOUNT_DECLINED_SSN_MATCHES_DECEASED = '82625';
215
+ const MERCHANT_ACCOUNT_ID_CANNOT_BE_UPDATED = '82675';
216
+ const MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_CANNOT_BE_UPDATED = '82676';
217
+
218
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ACCOUNT_NUMBER_IS_REQUIRED = '82614';
219
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_COMPANY_NAME_IS_INVALID = '82631';
220
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_COMPANY_NAME_IS_REQUIRED_WITH_TAX_ID = '82633';
221
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DATE_OF_BIRTH_IS_REQUIRED = '82612';
222
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED = '82626'; // Keep for backwards compatibility
223
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_MASTER_CARD_MATCH = '82622'; // Keep for backwards compatibility
224
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_OFAC = '82621'; // Keep for backwards compatibility
225
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_FAILED_KYC = '82623'; // Keep for backwards compatibility
226
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_SSN_INVALID = '82624'; // Keep for backwards compatibility
227
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_SSN_MATCHES_DECEASED = '82625'; // Keep for backwards compatibility
228
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_EMAIL_ADDRESS_IS_INVALID = '82616';
229
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_FIRST_NAME_IS_INVALID = '82627';
230
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_FIRST_NAME_IS_REQUIRED = '82609';
231
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_LAST_NAME_IS_INVALID = '82628';
232
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_LAST_NAME_IS_REQUIRED = '82611';
233
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_PHONE_IS_INVALID = '82636';
234
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ROUTING_NUMBER_IS_INVALID = '82635';
235
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ROUTING_NUMBER_IS_REQUIRED = '82613';
236
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_SSN_IS_INVALID = '82615';
237
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_TAX_ID_IS_INVALID = '82632';
238
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_TAX_ID_IS_REQUIRED_WITH_COMPANY_NAME = '82634';
239
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DATE_OF_BIRTH_IS_INVALID = '82663';
240
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_REGION_IS_INVALID = '82664';
241
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_EMAIL_ADDRESS_IS_REQUIRED = '82665';
242
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ACCOUNT_NUMBER_IS_INVALID = '82670';
243
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_TAX_ID_MUST_BE_BLANK = '82673';
244
+
245
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_LOCALITY_IS_REQUIRED = '82618';
246
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_POSTAL_CODE_IS_INVALID = '82630';
247
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_POSTAL_CODE_IS_REQUIRED = '82619';
248
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_REGION_IS_REQUIRED = '82620';
249
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_STREET_ADDRESS_IS_INVALID = '82629';
250
+ const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_STREET_ADDRESS_IS_REQUIRED = '82617';
251
+
252
+ const MERCHANT_ACCOUNT_BUSINESS_DBA_NAME_IS_INVALID = '82646';
253
+ const MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_INVALID = '82647';
254
+ const MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_REQUIRED_WITH_LEGAL_NAME = '82648';
255
+ const MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_REQUIRED_WITH_TAX_ID = '82669';
256
+ const MERCHANT_ACCOUNT_BUSINESS_TAX_ID_MUST_BE_BLANK = '82672';
257
+ const MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_INVALID = '82677';
258
+ const MERCHANT_ACCOUNT_BUSINESS_ADDRESS_REGION_IS_INVALID = '82684';
259
+ const MERCHANT_ACCOUNT_BUSINESS_ADDRESS_STREET_ADDRESS_IS_INVALID = '82685';
260
+ const MERCHANT_ACCOUNT_BUSINESS_ADDRESS_POSTAL_CODE_IS_INVALID = '82686';
261
+
262
+ const MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_REQUIRED = '82637';
263
+ const MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_REQUIRED = '82638';
264
+ const MERCHANT_ACCOUNT_INDIVIDUAL_DATE_OF_BIRTH_IS_REQUIRED = '82639';
265
+ const MERCHANT_ACCOUNT_INDIVIDUAL_SSN_IS_INVALID = '82642';
266
+ const MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_INVALID = '82643';
267
+ const MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_INVALID = '82644';
268
+ const MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_INVALID = '82645';
269
+ const MERCHANT_ACCOUNT_INDIVIDUAL_PHONE_IS_INVALID = '82656';
270
+ const MERCHANT_ACCOUNT_INDIVIDUAL_DATE_OF_BIRTH_IS_INVALID = '82666';
271
+ const MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_REQUIRED = '82667';
272
+
273
+ const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_REQUIRED = '82657';
274
+ const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_LOCALITY_IS_REQUIRED = '82658';
275
+ const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_REQUIRED = '82659';
276
+ const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_REQUIRED = '82660';
277
+ const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_INVALID = '82661';
278
+ const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_INVALID = '82662';
279
+ const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_INVALID = '82668';
280
+
281
+ const MERCHANT_ACCOUNT_FUNDING_ROUTING_NUMBER_IS_REQUIRED = '82640';
282
+ const MERCHANT_ACCOUNT_FUNDING_ACCOUNT_NUMBER_IS_REQUIRED = '82641';
283
+ const MERCHANT_ACCOUNT_FUNDING_ROUTING_NUMBER_IS_INVALID = '82649';
284
+ const MERCHANT_ACCOUNT_FUNDING_ACCOUNT_NUMBER_IS_INVALID = '82671';
285
+ const MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_REQUIRED = '82678';
286
+ const MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_INVALID = '82679';
287
+ const MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_REQUIRED = '82680';
288
+ const MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_INVALID = '82681';
289
+ const MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_REQUIRED = '82682';
290
+ const MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_INVALID = '82683';
291
+
292
+ const OAUTH_INVALID_GRANT = '93801';
293
+ const OAUTH_INVALID_CREDENTIALS = '93802';
294
+ const OAUTH_INVALID_SCOPE = '93803';
295
+ const OAUTH_INVALID_REQUEST = '93804';
296
+ const OAUTH_UNSUPPORTED_GRANT_TYPE = '93805';
297
+
298
+ const PAYMENT_METHOD_CANNOT_FORWARD_PAYMENT_METHOD_TYPE = '93106';
299
+ const PAYMENT_METHOD_CUSTOMER_ID_IS_INVALID = '93105';
300
+ const PAYMENT_METHOD_CUSTOMER_ID_IS_REQUIRED = '93104';
301
+ const PAYMENT_METHOD_NONCE_IS_INVALID = '93102';
302
+ const PAYMENT_METHOD_NONCE_IS_REQUIRED = '93103';
303
+ const PAYMENT_METHOD_PAYMENT_METHOD_NONCE_CONSUMED = '93107';
304
+ const PAYMENT_METHOD_PAYMENT_METHOD_NONCE_UNKNOWN = '93108';
305
+ const PAYMENT_METHOD_PAYMENT_METHOD_NONCE_LOCKED = '93109';
306
+ const PAYMENT_METHOD_PAYMENT_METHOD_PARAMS_ARE_REQUIRED = '93101';
307
+
308
+ const PAYPAL_ACCOUNT_AUTH_EXPIRED = '92911';
309
+ const PAYPAL_ACCOUNT_CANNOT_HAVE_BOTH_ACCESS_TOKEN_AND_CONSENT_CODE = '82903';
310
+ const PAYPAL_ACCOUNT_CANNOT_HAVE_FUNDING_SOURCE_WITHOUT_ACCESS_TOKEN = '92912';
311
+ const PAYPAL_ACCOUNT_CANNOT_UPDATE_PAYPAL_ACCOUNT_USING_PAYMENT_METHOD_NONCE = '92914';
312
+ const PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT = '82902';
313
+ const PAYPAL_ACCOUNT_CONSENT_CODE_OR_ACCESS_TOKEN_IS_REQUIRED = '82901';
314
+ const PAYPAL_ACCOUNT_CUSTOMER_ID_IS_REQUIRED_FOR_VAULTING = '82905';
315
+ const PAYPAL_ACCOUNT_INVALID_FUNDING_SOURCE_SELECTION = '92913';
316
+ const PAYPAL_ACCOUNT_INVALID_PARAMS_FOR_PAYPAL_ACCOUNT_UPDATE = '92915';
317
+ const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_CONSUMED = '92907';
318
+ const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_LOCKED = '92909';
319
+ const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_UNKNOWN = '92908';
320
+ const PAYPAL_ACCOUNT_PAYPAL_ACCOUNTS_ARE_NOT_ACCEPTED = '82904';
321
+ const PAYPAL_ACCOUNT_PAYPAL_COMMUNICATION_ERROR = '92910';
322
+ const PAYPAL_ACCOUNT_TOKEN_IS_IN_USE = '92906';
323
+
324
+ const SEPA_BANK_ACCOUNT_ACCOUNT_HOLDER_NAME_IS_REQUIRED = '93003';
325
+ const SEPA_BANK_ACCOUNT_BIC_IS_REQUIRED = '93002';
326
+ const SEPA_BANK_ACCOUNT_IBAN_IS_REQUIRED = '93001';
327
+
328
+ const SEPA_MANDATE_ACCOUNT_HOLDER_NAME_IS_REQUIRED = '83301';
329
+ const SEPA_MANDATE_BIC_INVALID_CHARACTER = '83306';
330
+ const SEPA_MANDATE_BIC_IS_REQUIRED = '83302';
331
+ const SEPA_MANDATE_BIC_LENGTH_IS_INVALID = '83307';
332
+ const SEPA_MANDATE_BIC_UNSUPPORTED_COUNTRY = '83308';
333
+ const SEPA_MANDATE_BILLING_ADDRESS_CONFLICT = '93311';
334
+ const SEPA_MANDATE_BILLING_ADDRESS_ID_IS_INVALID = '93312';
335
+ const SEPA_MANDATE_IBAN_INVALID_CHARACTER = '83305';
336
+ const SEPA_MANDATE_IBAN_INVALID_FORMAT = '83310';
337
+ const SEPA_MANDATE_IBAN_IS_REQUIRED = '83303';
338
+ const SEPA_MANDATE_IBAN_UNSUPPORTED_COUNTRY = '83309';
339
+ const SEPA_MANDATE_TYPE_IS_REQUIRED = '93304';
340
+ const SEPA_MANDATE_TYPE_IS_INVALID = '93313';
341
+
342
+ const SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_INVALID = '82302';
343
+ const SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_REQUIRED = '82301';
344
+ const SETTLEMENT_BATCH_SUMMARY_CUSTOM_FIELD_IS_INVALID = '82303';
345
+
346
+ const SUBSCRIPTION_BILLING_DAY_OF_MONTH_CANNOT_BE_UPDATED = '91918';
347
+ const SUBSCRIPTION_BILLING_DAY_OF_MONTH_IS_INVALID = '91914';
348
+ const SUBSCRIPTION_BILLING_DAY_OF_MONTH_MUST_BE_NUMERIC = '91913';
349
+ const SUBSCRIPTION_CANNOT_ADD_DUPLICATE_ADDON_OR_DISCOUNT = '91911';
350
+ const SUBSCRIPTION_CANNOT_EDIT_CANCELED_SUBSCRIPTION = '81901';
351
+ const SUBSCRIPTION_CANNOT_EDIT_EXPIRED_SUBSCRIPTION = '81910';
352
+ const SUBSCRIPTION_CANNOT_EDIT_PRICE_CHANGING_FIELDS_ON_PAST_DUE_SUBSCRIPTION = '91920';
353
+ const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_IN_THE_PAST = '91916';
354
+ const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_UPDATED = '91919';
355
+ const SUBSCRIPTION_FIRST_BILLING_DATE_IS_INVALID = '91915';
356
+ const SUBSCRIPTION_ID_IS_IN_USE = '81902';
357
+ const SUBSCRIPTION_INCONSISTENT_NUMBER_OF_BILLING_CYCLES = '91908';
358
+ const SUBSCRIPTION_INCONSISTENT_START_DATE = '91917';
359
+ const SUBSCRIPTION_INVALID_REQUEST_FORMAT = '91921';
360
+ const SUBSCRIPTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91901';
361
+ const SUBSCRIPTION_MISMATCH_CURRENCY_ISO_CODE = '91923';
362
+ const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_CANNOT_BE_BLANK = '91912';
363
+ const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_IS_TOO_SMALL = '91909';
364
+ const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_GREATER_THAN_ZERO = '91907';
365
+ const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_NUMERIC = '91906';
366
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91924';
367
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_IS_INVALID = '91925';
368
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_NOT_ASSOCIATED_WITH_CUSTOMER = '91926';
369
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_UNVAULTED_CARD_IS_NOT_ACCEPTED = '91927';
370
+ const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91902';
371
+ const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91903';
372
+ const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_NOT_ASSOCIATED_WITH_CUSTOMER = '91905';
373
+ const SUBSCRIPTION_PLAN_BILLING_FREQUENCY_CANNOT_BE_UPDATED = '91922';
374
+ const SUBSCRIPTION_PLAN_ID_IS_INVALID = '91904';
375
+ const SUBSCRIPTION_PRICE_CANNOT_BE_BLANK = '81903';
376
+ const SUBSCRIPTION_PRICE_FORMAT_IS_INVALID = '81904';
377
+ const SUBSCRIPTION_PRICE_IS_TOO_LARGE = '81923';
378
+ const SUBSCRIPTION_STATUS_IS_CANCELED = '81905';
379
+ const SUBSCRIPTION_TOKEN_FORMAT_IS_INVALID = '81906';
380
+ const SUBSCRIPTION_TRIAL_DURATION_FORMAT_IS_INVALID = '81907';
381
+ const SUBSCRIPTION_TRIAL_DURATION_IS_REQUIRED = '81908';
382
+ const SUBSCRIPTION_TRIAL_DURATION_UNIT_IS_INVALID = '81909';
383
+ const SUBSCRIPTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_INSTRUMENT_TYPE = '91930';
384
+ const SUBSCRIPTION_PAYMENT_METHOD_NONCE_INSTRUMENT_TYPE_DOES_NOT_SUPPORT_SUBSCRIPTIONS = '91929';
385
+ const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_INSTRUMENT_TYPE_DOES_NOT_SUPPORT_SUBSCRIPTIONS = '91928';
386
+
387
+ const SUBSCRIPTION_MODIFICATION_AMOUNT_CANNOT_BE_BLANK = '92003';
388
+ const SUBSCRIPTION_MODIFICATION_AMOUNT_IS_INVALID = '92002';
389
+ const SUBSCRIPTION_MODIFICATION_AMOUNT_IS_TOO_LARGE = '92023';
390
+ const SUBSCRIPTION_MODIFICATION_CANNOT_EDIT_MODIFICATIONS_ON_PAST_DUE_SUBSCRIPTION = '92022';
391
+ const SUBSCRIPTION_MODIFICATION_CANNOT_UPDATE_AND_REMOVE = '92015';
392
+ const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_INCORRECT_KIND = '92020';
393
+ const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_INVALID = '92011';
394
+ const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_REQUIRED = '92012';
395
+ const SUBSCRIPTION_MODIFICATION_ID_TO_REMOVE_IS_INCORRECT_KIND = '92021';
396
+ const SUBSCRIPTION_MODIFICATION_ID_TO_REMOVE_IS_INVALID = '92025';
397
+ const SUBSCRIPTION_MODIFICATION_ID_TO_REMOVE_IS_NOT_PRESENT = '92016';
398
+ const SUBSCRIPTION_MODIFICATION_INCONSISTENT_NUMBER_OF_BILLING_CYCLES = '92018';
399
+ const SUBSCRIPTION_MODIFICATION_INHERITED_FROM_ID_IS_INVALID = '92013';
400
+ const SUBSCRIPTION_MODIFICATION_INHERITED_FROM_ID_IS_REQUIRED = '92014';
401
+ const SUBSCRIPTION_MODIFICATION_MISSING = '92024';
402
+ const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_CANNOT_BE_BLANK = '92017';
403
+ const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_IS_INVALID = '92005';
404
+ const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_MUST_BE_GREATER_THAN_ZERO = '92019';
405
+ const SUBSCRIPTION_MODIFICATION_QUANTITY_CANNOT_BE_BLANK = '92004';
406
+ const SUBSCRIPTION_MODIFICATION_QUANTITY_IS_INVALID = '92001';
407
+ const SUBSCRIPTION_MODIFICATION_QUANTITY_MUST_BE_GREATER_THAN_ZERO = '92010';
408
+
409
+ const TRANSACTION_AMOUNT_CANNOT_BE_NEGATIVE = '81501';
410
+ const TRANSACTION_AMOUNT_DOES_NOT_MATCH3_D_SECURE_AMOUNT = '91585';
411
+ const TRANSACTION_AMOUNT_FORMAT_IS_INVALID = '81503';
412
+ const TRANSACTION_AMOUNT_IS_INVALID = '81503';
413
+ const TRANSACTION_AMOUNT_IS_REQUIRED = '81502';
414
+ const TRANSACTION_AMOUNT_IS_TOO_LARGE = '81528';
415
+ const TRANSACTION_AMOUNT_MUST_BE_GREATER_THAN_ZERO = '81531';
416
+ const TRANSACTION_BILLING_ADDRESS_CONFLICT = '91530';
417
+ const TRANSACTION_CANNOT_BE_VOIDED = '91504';
418
+ const TRANSACTION_CANNOT_CANCEL_RELEASE = '91562';
419
+ const TRANSACTION_CANNOT_CLONE_CREDIT = '91543';
420
+ const TRANSACTION_CANNOT_CLONE_MARKETPLACE_TRANSACTION = '915137';
421
+ const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_PAYPAL_ACCOUNT = '91573';
422
+ const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_VAULT_CREDIT_CARD = '91540';
423
+ const TRANSACTION_CANNOT_CLONE_UNSUCCESSFUL_TRANSACTION = '91542';
424
+ const TRANSACTION_CANNOT_CLONE_VOICE_AUTHORIZATIONS = '91541';
425
+ const TRANSACTION_CANNOT_HOLD_IN_ESCROW = '91560';
426
+ const TRANSACTION_CANNOT_PARTIALLY_REFUND_ESCROWED_TRANSACTION = '91563';
427
+ const TRANSACTION_CANNOT_REFUND_CREDIT = '91505';
428
+ const TRANSACTION_CANNOT_REFUND_SETTLING_TRANSACTION = '91574';
429
+ const TRANSACTION_CANNOT_REFUND_UNLESS_SETTLED = '91506';
430
+ const TRANSACTION_CANNOT_REFUND_WITH_PENDING_MERCHANT_ACCOUNT = '91559';
431
+ const TRANSACTION_CANNOT_REFUND_WITH_SUSPENDED_MERCHANT_ACCOUNT = '91538';
432
+ const TRANSACTION_CANNOT_RELEASE_FROM_ESCROW = '91561';
433
+ const TRANSACTION_CANNOT_SIMULATE_SETTLEMENT = '91575';
434
+ const TRANSACTION_CANNOT_SUBMIT_FOR_PARTIAL_SETTLEMENT = '915103';
435
+ const TRANSACTION_CANNOT_SUBMIT_FOR_SETTLEMENT = '91507';
436
+ const TRANSACTION_CANNOT_UPDATE_DETAILS_NOT_SUBMITTED_FOR_SETTLEMENT = '915129';
437
+ const TRANSACTION_CHANNEL_IS_TOO_LONG = '91550';
438
+ const TRANSACTION_CREDIT_CARD_IS_REQUIRED = '91508';
439
+ const TRANSACTION_CUSTOMER_DEFAULT_PAYMENT_METHOD_CARD_TYPE_IS_NOT_ACCEPTED = '81509';
440
+ const TRANSACTION_CUSTOMER_DOES_NOT_HAVE_CREDIT_CARD = '91511';
441
+ const TRANSACTION_CUSTOMER_ID_IS_INVALID = '91510';
442
+ const TRANSACTION_CUSTOM_FIELD_IS_INVALID = '91526';
443
+ const TRANSACTION_CUSTOM_FIELD_IS_TOO_LONG = '81527';
444
+ const TRANSACTION_HAS_ALREADY_BEEN_REFUNDED = '91512';
445
+ const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_MATCH3_D_SECURE_MERCHANT_ACCOUNT = '91584';
446
+ const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_MOTO = '91558';
447
+ const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_REFUNDS = '91547';
448
+ const TRANSACTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91513';
449
+ const TRANSACTION_MERCHANT_ACCOUNT_IS_SUSPENDED = '91514';
450
+ const TRANSACTION_MERCHANT_ACCOUNT_NAME_IS_INVALID = '91513'; //Deprecated
451
+ const TRANSACTION_OPTIONS_PAY_PAL_CUSTOM_FIELD_TOO_LONG = '91580';
452
+ const TRANSACTION_OPTIONS_SUBMIT_FOR_SETTLEMENT_IS_REQUIRED_FOR_CLONING = '91544';
453
+ const TRANSACTION_OPTIONS_SUBMIT_FOR_SETTLEMENT_IS_REQUIRED_FOR_PAYPAL_UNILATERAL = '91582';
454
+ const TRANSACTION_OPTIONS_USE_BILLING_FOR_SHIPPING_DISABLED = '91572';
455
+ const TRANSACTION_OPTIONS_VAULT_IS_DISABLED = '91525';
456
+ const TRANSACTION_ORDER_ID_IS_TOO_LONG = '91501';
457
+ const TRANSACTION_PAYMENT_INSTRUMENT_NOT_SUPPORTED_BY_MERCHANT_ACCOUNT = '91577';
458
+ const TRANSACTION_PAYMENT_INSTRUMENT_TYPE_IS_NOT_ACCEPTED = '915101';
459
+ const TRANSACTION_PAYMENT_METHOD_CONFLICT = '91515';
460
+ const TRANSACTION_PAYMENT_METHOD_CONFLICT_WITH_VENMO_SDK = '91549';
461
+ const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_CUSTOMER = '91516';
462
+ const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_SUBSCRIPTION = '91527';
463
+ const TRANSACTION_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91567';
464
+ const TRANSACTION_PAYMENT_METHOD_NONCE_CONSUMED = '91564';
465
+ const TRANSACTION_PAYMENT_METHOD_NONCE_HAS_NO_VALID_PAYMENT_INSTRUMENT_TYPE = '91569';
466
+ const TRANSACTION_PAYMENT_METHOD_NONCE_LOCKED = '91566';
467
+ const TRANSACTION_PAYMENT_METHOD_NONCE_UNKNOWN = '91565';
468
+ const TRANSACTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91517';
469
+ const TRANSACTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91518';
470
+ const TRANSACTION_PAYPAL_NOT_ENABLED = '91576';
471
+ const TRANSACTION_PAY_PAL_AUTH_EXPIRED = '91579';
472
+ const TRANSACTION_PAY_PAL_VAULT_RECORD_MISSING_DATA = '91583';
473
+ const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_CANNOT_BE_SET = '91519';
474
+ const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_IS_INVALID = '81520';
475
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_AUTHS = '915104';
476
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_CREDITS = '91546';
477
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_PARTIAL_SETTLEMENT = '915102';
478
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_ORDER_ID = '915107';
479
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_DESCRIPTOR = '915108';
480
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_DETAILS = '915130';
481
+ const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_VOICE_AUTHORIZATIONS = '91545';
482
+ const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_INVALID = '91548';
483
+ const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_TOO_LONG = '91537';
484
+ const TRANSACTION_REFUND_AMOUNT_IS_TOO_LARGE = '91521';
485
+ const TRANSACTION_SERVICE_FEE_AMOUNT_CANNOT_BE_NEGATIVE = '91554';
486
+ const TRANSACTION_SERVICE_FEE_AMOUNT_FORMAT_IS_INVALID = '91555';
487
+ const TRANSACTION_SERVICE_FEE_AMOUNT_IS_TOO_LARGE = '91556';
488
+ const TRANSACTION_SERVICE_FEE_AMOUNT_NOT_ALLOWED_ON_MASTER_MERCHANT_ACCOUNT = '91557';
489
+ const TRANSACTION_SERVICE_FEE_IS_NOT_ALLOWED_ON_CREDITS = '91552';
490
+ const TRANSACTION_SERVICE_FEE_NOT_ACCEPTED_FOR_PAYPAL = '91578';
491
+ const TRANSACTION_SETTLEMENT_AMOUNT_IS_LESS_THAN_SERVICE_FEE_AMOUNT = '91551';
492
+ const TRANSACTION_SETTLEMENT_AMOUNT_IS_TOO_LARGE = '91522';
493
+ const TRANSACTION_SHIPPING_ADDRESS_DOESNT_MATCH_CUSTOMER = '91581';
494
+ const TRANSACTION_SUBSCRIPTION_DOES_NOT_BELONG_TO_CUSTOMER = '91529';
495
+ const TRANSACTION_SUBSCRIPTION_ID_IS_INVALID = '91528';
496
+ const TRANSACTION_SUBSCRIPTION_STATUS_MUST_BE_PAST_DUE = '91531';
497
+ const TRANSACTION_SUB_MERCHANT_ACCOUNT_REQUIRES_SERVICE_FEE_AMOUNT = '91553';
498
+ const TRANSACTION_TAX_AMOUNT_CANNOT_BE_NEGATIVE = '81534';
499
+ const TRANSACTION_TAX_AMOUNT_FORMAT_IS_INVALID = '81535';
500
+ const TRANSACTION_TAX_AMOUNT_IS_TOO_LARGE = '81536';
501
+
502
+ const TRANSACTION_THREE_D_SECURE_AUTHENTICATION_FAILED = '81571';
503
+ const TRANSACTION_THREE_D_SECURE_TOKEN_IS_INVALID = '91568';
504
+ const TRANSACTION_THREE_D_SECURE_TRANSACTION_DATA_DOESNT_MATCH_VERIFY = '91570';
505
+ const TRANSACTION_THREE_D_SECURE_ECI_FLAG_IS_REQUIRED = '915113';
506
+ const TRANSACTION_THREE_D_SECURE_CAVV_IS_REQUIRED = '915116';
507
+ const TRANSACTION_THREE_D_SECURE_XID_IS_REQUIRED = '915115';
508
+ const TRANSACTION_THREE_D_SECURE_ECI_FLAG_IS_INVALID = '915114';
509
+ const TRANSACTION_THREE_D_SECURE_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_CARD_TYPE = '915131';
510
+ const TRANSACTION_TYPE_IS_INVALID = '91523';
511
+ const TRANSACTION_TYPE_IS_REQUIRED = '91524';
512
+ const TRANSACTION_UNSUPPORTED_VOICE_AUTHORIZATION = '91539';
513
+
514
+ const VERIFICATION_OPTIONS_AMOUNT_CANNOT_BE_NEGATIVE = '94201';
515
+ const VERIFICATION_OPTIONS_AMOUNT_FORMAT_IS_INVALID = '94202';
516
+ const VERIFICATION_OPTIONS_AMOUNT_IS_TOO_LARGE = '94207';
517
+ const VERIFICATION_OPTIONS_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = '94203';
518
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_ID_IS_INVALID = '94204';
519
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_IS_SUSPENDED = '94205';
520
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_IS_FORBIDDEN = '94206';
521
+ const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_CANNOT_BE_SUB_MERCHANT_ACCOUNT = '94208';
522
+ }
523
+ class_alias('Braintree\Error\Codes', 'Braintree_Error_Codes');
lib/braintree/lib/Braintree/Error/ErrorCollection.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Error;
3
+
4
+ use Braintree\Util;
5
+
6
+ /**
7
+ *
8
+ * Error handler
9
+ * Handles validation errors
10
+ *
11
+ * Contains a read-only property $error which is a ValidationErrorCollection
12
+ *
13
+ * @package Braintree
14
+ * @subpackage Errors
15
+ * @category Errors
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
+ *
18
+ * @property-read object $errors
19
+ */
20
+ class ErrorCollection implements \Countable
21
+ {
22
+ private $_errors;
23
+
24
+ public function __construct($errorData)
25
+ {
26
+ $this->_errors =
27
+ new ValidationErrorCollection($errorData);
28
+ }
29
+
30
+ /**
31
+ * Return count of items in collection
32
+ * Implements countable
33
+ *
34
+ * @return integer
35
+ */
36
+ public function count()
37
+ {
38
+ return $this->deepSize();
39
+ }
40
+
41
+ /**
42
+ * Returns all of the validation errors at all levels of nesting in a single, flat array.
43
+ */
44
+ public function deepAll()
45
+ {
46
+ return $this->_errors->deepAll();
47
+ }
48
+
49
+ /**
50
+ * Returns the total number of validation errors at all levels of nesting. For example,
51
+ *if creating a customer with a credit card and a billing address, and each of the customer,
52
+ * credit card, and billing address has 1 error, this method will return 3.
53
+ *
54
+ * @return int size
55
+ */
56
+ public function deepSize()
57
+ {
58
+ $size = $this->_errors->deepSize();
59
+ return $size;
60
+ }
61
+
62
+ /**
63
+ * return errors for the passed key name
64
+ *
65
+ * @param string $key
66
+ * @return mixed
67
+ */
68
+ public function forKey($key)
69
+ {
70
+ return $this->_errors->forKey($key);
71
+ }
72
+
73
+ /**
74
+ * return errors for the passed html field.
75
+ * For example, $result->errors->onHtmlField("transaction[customer][last_name]")
76
+ *
77
+ * @param string $field
78
+ * @return array
79
+ */
80
+ public function onHtmlField($field)
81
+ {
82
+ $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
83
+ $errors = $this;
84
+ foreach(array_slice($pieces, 0, -1) as $key) {
85
+ $errors = $errors->forKey(Util::delimiterToCamelCase($key));
86
+ if (!isset($errors)) { return []; }
87
+ }
88
+ $finalKey = Util::delimiterToCamelCase(end($pieces));
89
+ return $errors->onAttribute($finalKey);
90
+ }
91
+
92
+ /**
93
+ * Returns the errors at the given nesting level (see forKey) in a single, flat array:
94
+ *
95
+ * <code>
96
+ * $result = Customer::create(...);
97
+ * $customerErrors = $result->errors->forKey('customer')->shallowAll();
98
+ * </code>
99
+ */
100
+ public function shallowAll()
101
+ {
102
+ return $this->_errors->shallowAll();
103
+ }
104
+
105
+ /**
106
+ *
107
+ * @ignore
108
+ */
109
+ public function __get($name)
110
+ {
111
+ $varName = "_$name";
112
+ return isset($this->$varName) ? $this->$varName : null;
113
+ }
114
+
115
+ /**
116
+ *
117
+ * @ignore
118
+ */
119
+ public function __toString()
120
+ {
121
+ return sprintf('%s', $this->_errors);
122
+ }
123
+ }
124
+ class_alias('Braintree\Error\ErrorCollection', 'Braintree_Error_ErrorCollection');
lib/braintree/lib/Braintree/Error/Validation.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Error;
3
+
4
+ use Braintree\Util;
5
+
6
+ /**
7
+ * error object returned as part of a validation error collection
8
+ * provides read-only access to $attribute, $code, and $message
9
+ *
10
+ * <b>== More information ==</b>
11
+ *
12
+ * For more detailed information on Validation errors, see {@link http://www.braintreepayments.com/gateway/validation-errors http://www.braintreepaymentsolutions.com/gateway/validation-errors}
13
+ *
14
+ * @package Braintree
15
+ * @subpackage Error
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
+ *
18
+ * @property-read string $attribute
19
+ * @property-read string $code
20
+ * @property-read string $message
21
+ */
22
+ class Validation
23
+ {
24
+ private $_attribute;
25
+ private $_code;
26
+ private $_message;
27
+
28
+ /**
29
+ * @ignore
30
+ * @param array $attributes
31
+ */
32
+ public function __construct($attributes)
33
+ {
34
+ $this->_initializeFromArray($attributes);
35
+ }
36
+ /**
37
+ * initializes instance properties from the keys/values of an array
38
+ * @ignore
39
+ * @access protected
40
+ * @param array $attributes array of properties to set - single level
41
+ * @return void
42
+ */
43
+ private function _initializeFromArray($attributes)
44
+ {
45
+ foreach($attributes AS $name => $value) {
46
+ $varName = "_$name";
47
+ $this->$varName = Util::delimiterToCamelCase($value, '_');
48
+ }
49
+ }
50
+
51
+ /**
52
+ *
53
+ * @ignore
54
+ */
55
+ public function __get($name)
56
+ {
57
+ $varName = "_$name";
58
+ return isset($this->$varName) ? $this->$varName : null;
59
+ }
60
+ }
61
+ class_alias('Braintree\Error\Validation', 'Braintree_Error_Validation');
lib/braintree/lib/Braintree/Error/ValidationErrorCollection.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Error;
3
+
4
+ use Braintree\Collection;
5
+
6
+ /**
7
+ * collection of errors enumerating all validation errors for a given request
8
+ *
9
+ * <b>== More information ==</b>
10
+ *
11
+ * For more detailed information on Validation errors, see {@link http://www.braintreepayments.com/gateway/validation-errors http://www.braintreepaymentsolutions.com/gateway/validation-errors}
12
+ *
13
+ * @package Braintree
14
+ * @subpackage Error
15
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
16
+ *
17
+ * @property-read array $errors
18
+ * @property-read array $nested
19
+ */
20
+ class ValidationErrorCollection extends Collection
21
+ {
22
+ private $_errors = [];
23
+ private $_nested = [];
24
+
25
+ /**
26
+ * @ignore
27
+ */
28
+ public function __construct($data)
29
+ {
30
+ foreach($data AS $key => $errorData)
31
+ // map errors to new collections recursively
32
+ if ($key == 'errors') {
33
+ foreach ($errorData AS $error) {
34
+ $this->_errors[] = new Validation($error);
35
+ }
36
+ } else {
37
+ $this->_nested[$key] = new ValidationErrorCollection($errorData);
38
+ }
39
+
40
+ }
41
+
42
+ public function deepAll()
43
+ {
44
+ $validationErrors = array_merge([], $this->_errors);
45
+ foreach($this->_nested as $nestedErrors)
46
+ {
47
+ $validationErrors = array_merge($validationErrors, $nestedErrors->deepAll());
48
+ }
49
+ return $validationErrors;
50
+ }
51
+
52
+ public function deepSize()
53
+ {
54
+ $total = sizeof($this->_errors);
55
+ foreach($this->_nested as $_nestedErrors)
56
+ {
57
+ $total = $total + $_nestedErrors->deepSize();
58
+ }
59
+ return $total;
60
+ }
61
+
62
+ public function forIndex($index)
63
+ {
64
+ return $this->forKey("index" . $index);
65
+ }
66
+
67
+ public function forKey($key)
68
+ {
69
+ return isset($this->_nested[$key]) ? $this->_nested[$key] : null;
70
+ }
71
+
72
+ public function onAttribute($attribute)
73
+ {
74
+ $matches = [];
75
+ foreach ($this->_errors AS $key => $error) {
76
+ if($error->attribute == $attribute) {
77
+ $matches[] = $error;
78
+ }
79
+ }
80
+ return $matches;
81
+ }
82
+
83
+
84
+ public function shallowAll()
85
+ {
86
+ return $this->_errors;
87
+ }
88
+
89
+ /**
90
+ *
91
+ * @ignore
92
+ */
93
+ public function __get($name)
94
+ {
95
+ $varName = "_$name";
96
+ return isset($this->$varName) ? $this->$varName : null;
97
+ }
98
+
99
+ /**
100
+ * @ignore
101
+ */
102
+ public function __toString()
103
+ {
104
+ $output = [];
105
+
106
+ // TODO: implement scope
107
+ if (!empty($this->_errors)) {
108
+ $output[] = $this->_inspect($this->_errors);
109
+ }
110
+ if (!empty($this->_nested)) {
111
+ foreach ($this->_nested AS $key => $values) {
112
+ $output[] = $this->_inspect($this->_nested);
113
+ }
114
+ }
115
+ return join(', ', $output);
116
+ }
117
+
118
+ /**
119
+ * @ignore
120
+ */
121
+ private function _inspect($errors, $scope = null)
122
+ {
123
+ $eOutput = '[' . __CLASS__ . '/errors:[';
124
+ foreach($errors AS $error => $errorObj) {
125
+ $outputErrs[] = "({$errorObj->error['code']} {$errorObj->error['message']})";
126
+ }
127
+ $eOutput .= join(', ', $outputErrs) . ']]';
128
+
129
+ return $eOutput;
130
+ }
131
+ }
132
+ class_alias('Braintree\Error\ValidationErrorCollection', 'Braintree_Error_ValidationErrorCollection');
lib/braintree/lib/Braintree/EuropeBankAccount.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree EuropeBankAccount module
6
+ * Creates and manages Braintree Europe Bank Accounts
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br />
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read string $account-holder-name
17
+ * @property-read string $bic
18
+ * @property-read string $customerId
19
+ * @property-read string $default
20
+ * @property-read string $image-url
21
+ * @property-read string $mandate-reference-number
22
+ * @property-read string $masked-iban
23
+ * @property-read string $token
24
+ */
25
+ class EuropeBankAccount extends Base
26
+ {
27
+
28
+ /* instance methods */
29
+ /**
30
+ * returns false if default is null or false
31
+ *
32
+ * @return boolean
33
+ */
34
+ public function isDefault()
35
+ {
36
+ return $this->default;
37
+ }
38
+
39
+ /**
40
+ * factory method: returns an instance of EuropeBankAccount
41
+ * to the requesting method, with populated properties
42
+ *
43
+ * @ignore
44
+ * @return EuropeBankAccount
45
+ */
46
+ public static function factory($attributes)
47
+ {
48
+ $defaultAttributes = [
49
+ ];
50
+
51
+ $instance = new self();
52
+ $instance->_initialize(array_merge($defaultAttributes, $attributes));
53
+ return $instance;
54
+ }
55
+
56
+ /**
57
+ * sets instance properties from an array of values
58
+ *
59
+ * @access protected
60
+ * @param array $europeBankAccountAttribs array of EuropeBankAccount properties
61
+ * @return void
62
+ */
63
+ protected function _initialize($europeBankAccountAttribs)
64
+ {
65
+ $this->_attributes = $europeBankAccountAttribs;
66
+ }
67
+ }
68
+ class_alias('Braintree\EuropeBankAccount', 'Braintree_EuropeBankAccount');
lib/braintree/lib/Braintree/Exception.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * super class for all Braintree exceptions
6
+ *
7
+ * @package Braintree
8
+ * @subpackage Exception
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+ class Exception extends \Exception
12
+ {
13
+ }
14
+ class_alias('Braintree\Exception', 'Braintree_Exception');
lib/braintree/lib/Braintree/Exception/Authentication.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when authentication fails.
8
+ * This may be caused by an incorrect Configuration
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Exception
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+ class Authentication extends Exception
15
+ {
16
+
17
+ }
18
+ class_alias('Braintree\Exception\Authentication', 'Braintree_Exception_Authentication');
lib/braintree/lib/Braintree/Exception/Authorization.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when authorization fails
8
+ * Raised when the API key being used is not authorized to perform
9
+ * the attempted action according to the roles assigned to the user
10
+ * who owns the API key.
11
+ *
12
+ * @package Braintree
13
+ * @subpackage Exception
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ */
16
+ class Authorization extends Exception
17
+ {
18
+
19
+ }
20
+ class_alias('Braintree\Exception\Authorization', 'Braintree_Exception_Authorization');
lib/braintree/lib/Braintree/Exception/Configuration.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the Braintree library is not completely configured.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @see Configuration
12
+ */
13
+ class Configuration extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\Configuration', 'Braintree_Exception_Configuration');
lib/braintree/lib/Braintree/Exception/DownForMaintenance.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the gateway is down for maintenance.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class DownForMaintenance extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\DownForMaintenance', 'Braintree_Exception_DownForMaintenance');
lib/braintree/lib/Braintree/Exception/ForgedQueryString.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a suspected forged query string is present
8
+ * Raised from methods that confirm transparent redirect requests
9
+ * when the given query string cannot be verified. This may indicate
10
+ * an attempted hack on the merchant's transparent redirect
11
+ * confirmation URL.
12
+ *
13
+ * @package Braintree
14
+ * @subpackage Exception
15
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
16
+ */
17
+ class ForgedQueryString extends Exception
18
+ {
19
+
20
+ }
21
+ class_alias('Braintree\Exception\ForgedQueryString', 'Braintree_Exception_ForgedQueryString');
lib/braintree/lib/Braintree/Exception/InvalidChallenge.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ class InvalidChallenge extends Exception
7
+ {
8
+ }
9
+ class_alias('Braintree\Exception\InvalidChallenge', 'Braintree_Exception_InvalidChallenge');
lib/braintree/lib/Braintree/Exception/InvalidSignature.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ class InvalidSignature extends Exception
7
+ {
8
+ }
9
+ class_alias('Braintree\Exception\InvalidSignature', 'Braintree_Exception_InvalidSignature');
lib/braintree/lib/Braintree/Exception/NotFound.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a record could not be found.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class NotFound extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\NotFound', 'Braintree_Exception_NotFound');
lib/braintree/lib/Braintree/Exception/SSLCaFileNotFound.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the SSL CaFile is not found.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class SSLCaFileNotFound extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\SSLCaFileNotFound', 'Braintree_Exception_SSLCaFileNotFound');
lib/braintree/lib/Braintree/Exception/SSLCertificate.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the SSL certificate fails verification.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class SSLCertificate extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\SSLCertificate', 'Braintree_Exception_SSLCertificate');
lib/braintree/lib/Braintree/Exception/ServerError.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when an unexpected server error occurs.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class ServerError extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\ServerError', 'Braintree_Exception_ServerError');
lib/braintree/lib/Braintree/Exception/TestOperationPerformedInProduction.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a test method is used in production.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class TestOperationPerformedInProduction extends Exception
14
+ {
15
+ }
16
+ class_alias('Braintree\Exception\TestOperationPerformedInProduction', 'Braintree_Exception_TestOperationPerformedInProduction');
lib/braintree/lib/Braintree/Exception/Timeout.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a Timeout occurs
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2016 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class Timeout extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\Timeout', 'Braintree_Exception_Timeout');
lib/braintree/lib/Braintree/Exception/TooManyRequests.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when the gateway request rate-limit is exceeded.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class TooManyRequests extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\TooManyRequests', 'Braintree_Exception_TooManyRequests');
lib/braintree/lib/Braintree/Exception/Unexpected.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when an error occurs that the client library is not built to handle.
8
+ * This shouldn't happen.
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Exception
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+ class Unexpected extends Exception
15
+ {
16
+
17
+ }
18
+ class_alias('Braintree\Exception\Unexpected', 'Braintree_Exception_Unexpected');
lib/braintree/lib/Braintree/Exception/UpgradeRequired.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised when a client library must be upgraded.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class UpgradeRequired extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\UpgradeRequired', 'Braintree_Exception_UpgradeRequired');
lib/braintree/lib/Braintree/Exception/ValidationsFailed.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Exception;
3
+
4
+ use Braintree\Exception;
5
+
6
+ /**
7
+ * Raised from non-validating methods when gateway validations fail.
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Exception
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+ class ValidationsFailed extends Exception
14
+ {
15
+
16
+ }
17
+ class_alias('Braintree\Exception\ValidationsFailed', 'Braintree_Exception_ValidationsFailed');
lib/braintree/lib/Braintree/FacilitatorDetails.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class FacilitatorDetails extends Base
5
+ {
6
+ public static function factory($attributes)
7
+ {
8
+ $instance = new self();
9
+ $instance->_initialize($attributes);
10
+
11
+ return $instance;
12
+ }
13
+
14
+ protected function _initialize($attributes)
15
+ {
16
+ $this->_attributes = $attributes;
17
+ }
18
+
19
+ /**
20
+ * returns a string representation of the three d secure info
21
+ * @return string
22
+ */
23
+ public function __toString()
24
+ {
25
+ return __CLASS__ . '[' .
26
+ Util::attributesToString($this->_attributes) .']';
27
+ }
28
+
29
+ }
30
+ class_alias('Braintree\FacilitatorDetails', 'Braintree_FacilitatorDetails');
lib/braintree/lib/Braintree/Gateway.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Gateway module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+ class Gateway
12
+ {
13
+ /**
14
+ *
15
+ * @var Configuration
16
+ */
17
+ public $config;
18
+
19
+ public function __construct($config)
20
+ {
21
+ if (is_array($config)) {
22
+ $config = new Configuration($config);
23
+ }
24
+ $this->config = $config;
25
+ }
26
+
27
+ /**
28
+ *
29
+ * @return AddOnGateway
30
+ */
31
+ public function addOn()
32
+ {
33
+ return new AddOnGateway($this);
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @return AddressGateway
39
+ */
40
+ public function address()
41
+ {
42
+ return new AddressGateway($this);
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @return ClientTokenGateway
48
+ */
49
+ public function clientToken()
50
+ {
51
+ return new ClientTokenGateway($this);
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @return CreditCardGateway
57
+ */
58
+ public function creditCard()
59
+ {
60
+ return new CreditCardGateway($this);
61
+ }
62
+
63
+ /**
64
+ *
65
+ * @return CreditCardVerificationGateway
66
+ */
67
+ public function creditCardVerification()
68
+ {
69
+ return new CreditCardVerificationGateway($this);
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @return CustomerGateway
75
+ */
76
+ public function customer()
77
+ {
78
+ return new CustomerGateway($this);
79
+ }
80
+
81
+ /**
82
+ *
83
+ * @return DiscountGateway
84
+ */
85
+ public function discount()
86
+ {
87
+ return new DiscountGateway($this);
88
+ }
89
+
90
+ /**
91
+ *
92
+ * @return MerchantGateway
93
+ */
94
+ public function merchant()
95
+ {
96
+ return new MerchantGateway($this);
97
+ }
98
+
99
+ /**
100
+ *
101
+ * @return MerchantAccountGateway
102
+ */
103
+ public function merchantAccount()
104
+ {
105
+ return new MerchantAccountGateway($this);
106
+ }
107
+
108
+ /**
109
+ *
110
+ * @return OAuthGateway
111
+ */
112
+ public function oauth()
113
+ {
114
+ return new OAuthGateway($this);
115
+ }
116
+
117
+ /**
118
+ *
119
+ * @return PaymentMethodGateway
120
+ */
121
+ public function paymentMethod()
122
+ {
123
+ return new PaymentMethodGateway($this);
124
+ }
125
+
126
+ /**
127
+ *
128
+ * @return PaymentMethodNonceGateway
129
+ */
130
+ public function paymentMethodNonce()
131
+ {
132
+ return new PaymentMethodNonceGateway($this);
133
+ }
134
+
135
+ /**
136
+ *
137
+ * @return PayPalAccountGateway
138
+ */
139
+ public function payPalAccount()
140
+ {
141
+ return new PayPalAccountGateway($this);
142
+ }
143
+
144
+ /**
145
+ *
146
+ * @return PlanGateway
147
+ */
148
+ public function plan()
149
+ {
150
+ return new PlanGateway($this);
151
+ }
152
+
153
+ /**
154
+ *
155
+ * @return SettlementBatchSummaryGateway
156
+ */
157
+ public function settlementBatchSummary()
158
+ {
159
+ return new SettlementBatchSummaryGateway($this);
160
+ }
161
+
162
+ /**
163
+ *
164
+ * @return SubscriptionGateway
165
+ */
166
+ public function subscription()
167
+ {
168
+ return new SubscriptionGateway($this);
169
+ }
170
+
171
+ /**
172
+ *
173
+ * @return TestingGateway
174
+ */
175
+ public function testing()
176
+ {
177
+ return new TestingGateway($this);
178
+ }
179
+
180
+ /**
181
+ *
182
+ * @return TransactionGateway
183
+ */
184
+ public function transaction()
185
+ {
186
+ return new TransactionGateway($this);
187
+ }
188
+
189
+ /**
190
+ *
191
+ * @return TransparentRedirectGateway
192
+ */
193
+ public function transparentRedirect()
194
+ {
195
+ return new TransparentRedirectGateway($this);
196
+ }
197
+
198
+ /**
199
+ *
200
+ * @return UsBankAccountGateway
201
+ */
202
+ public function usBankAccount()
203
+ {
204
+ return new UsBankAccountGateway($this);
205
+ }
206
+
207
+ }
208
+ class_alias('Braintree\Gateway', 'Braintree_Gateway');
lib/braintree/lib/Braintree/Http.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree HTTP Client
6
+ * processes Http requests using curl
7
+ *
8
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
9
+ */
10
+ class Http
11
+ {
12
+ protected $_config;
13
+ private $_useClientCredentials = false;
14
+
15
+ public function __construct($config)
16
+ {
17
+ $this->_config = $config;
18
+ }
19
+
20
+ public function delete($path)
21
+ {
22
+ $response = $this->_doRequest('DELETE', $path);
23
+ if($response['status'] === 200) {
24
+ return true;
25
+ } else {
26
+ Util::throwStatusCodeException($response['status']);
27
+ }
28
+ }
29
+
30
+ public function get($path)
31
+ {
32
+ $response = $this->_doRequest('GET', $path);
33
+ if ($response['status'] === 200) {
34
+ return Xml::buildArrayFromXml($response['body']);
35
+ } else {
36
+ Util::throwStatusCodeException($response['status']);
37
+ }
38
+ }
39
+
40
+ public function post($path, $params = null)
41
+ {
42
+ $response = $this->_doRequest('POST', $path, $this->_buildXml($params));
43
+ $responseCode = $response['status'];
44
+ if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) {
45
+ return Xml::buildArrayFromXml($response['body']);
46
+ } else {
47
+ Util::throwStatusCodeException($responseCode);
48
+ }
49
+ }
50
+
51
+ public function put($path, $params = null)
52
+ {
53
+ $response = $this->_doRequest('PUT', $path, $this->_buildXml($params));
54
+ $responseCode = $response['status'];
55
+ if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) {
56
+ return Xml::buildArrayFromXml($response['body']);
57
+ } else {
58
+ Util::throwStatusCodeException($responseCode);
59
+ }
60
+ }
61
+
62
+ private function _buildXml($params)
63
+ {
64
+ return empty($params) ? null : Xml::buildXmlFromArray($params);
65
+ }
66
+
67
+ private function _getHeaders()
68
+ {
69
+ return [
70
+ 'Accept: application/xml',
71
+ 'Content-Type: application/xml',
72
+ ];
73
+ }
74
+
75
+ private function _getAuthorization()
76
+ {
77
+ if ($this->_useClientCredentials) {
78
+ return [
79
+ 'user' => $this->_config->getClientId(),
80
+ 'password' => $this->_config->getClientSecret(),
81
+ ];
82
+ } else if ($this->_config->isAccessToken()) {
83
+ return [
84
+ 'token' => $this->_config->getAccessToken(),
85
+ ];
86
+ } else {
87
+ return [
88
+ 'user' => $this->_config->getPublicKey(),
89
+ 'password' => $this->_config->getPrivateKey(),
90
+ ];
91
+ }
92
+ }
93
+
94
+ public function useClientCredentials()
95
+ {
96
+ $this->_useClientCredentials = true;
97
+ }
98
+
99
+ private function _doRequest($httpVerb, $path, $requestBody = null)
100
+ {
101
+ return $this->_doUrlRequest($httpVerb, $this->_config->baseUrl() . $path, $requestBody);
102
+ }
103
+
104
+ public function _doUrlRequest($httpVerb, $url, $requestBody = null)
105
+ {
106
+ $curl = curl_init();
107
+ curl_setopt($curl, CURLOPT_TIMEOUT, $this->_config->timeout());
108
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb);
109
+ curl_setopt($curl, CURLOPT_URL, $url);
110
+ curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
111
+
112
+ $headers = $this->_getHeaders($curl);
113
+ $headers[] = 'User-Agent: Braintree PHP Library ' . Version::get();
114
+ $headers[] = 'X-ApiVersion: ' . Configuration::API_VERSION;
115
+
116
+ $authorization = $this->_getAuthorization();
117
+ if (isset($authorization['user'])) {
118
+ curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
119
+ curl_setopt($curl, CURLOPT_USERPWD, $authorization['user'] . ':' . $authorization['password']);
120
+ } else if (isset($authorization['token'])) {
121
+ $headers[] = 'Authorization: Bearer ' . $authorization['token'];
122
+ }
123
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
124
+
125
+ // curl_setopt($curl, CURLOPT_VERBOSE, true);
126
+ if ($this->_config->sslOn()) {
127
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
128
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
129
+ curl_setopt($curl, CURLOPT_CAINFO, $this->getCaFile());
130
+ }
131
+
132
+ if(!empty($requestBody)) {
133
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
134
+ }
135
+
136
+ if($this->_config->isUsingProxy()) {
137
+ $proxyHost = $this->_config->getProxyHost();
138
+ $proxyPort = $this->_config->getProxyPort();
139
+ $proxyType = $this->_config->getProxyType();
140
+ $proxyUser = $this->_config->getProxyUser();
141
+ $proxyPwd= $this->_config->getProxyPassword();
142
+ curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort);
143
+ if(!empty($proxyType)) {
144
+ curl_setopt($curl, CURLOPT_PROXYTYPE, $proxyType);
145
+ }
146
+ if($this->_config->isAuthenticatedProxy()) {
147
+ curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUser . ':' . $proxyPwd);
148
+ }
149
+ }
150
+
151
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
152
+ $response = curl_exec($curl);
153
+ $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
154
+ $error_code = curl_errno($curl);
155
+
156
+ if ($error_code == 28 && $httpStatus == 0) {
157
+ throw new Exception\Timeout();
158
+ }
159
+
160
+ curl_close($curl);
161
+ if ($this->_config->sslOn()) {
162
+ if ($httpStatus == 0) {
163
+ throw new Exception\SSLCertificate();
164
+ }
165
+ }
166
+ return ['status' => $httpStatus, 'body' => $response];
167
+ }
168
+
169
+ private function getCaFile()
170
+ {
171
+ static $memo;
172
+
173
+ if ($memo === null) {
174
+ $caFile = $this->_config->caFile();
175
+
176
+ if (substr($caFile, 0, 7) !== 'phar://') {
177
+ return $caFile;
178
+ }
179
+
180
+ $extractedCaFile = sys_get_temp_dir() . '/api_braintreegateway_com.ca.crt';
181
+
182
+ if (!file_exists($extractedCaFile) || sha1_file($extractedCaFile) != sha1_file($caFile)) {
183
+ if (!copy($caFile, $extractedCaFile)) {
184
+ throw new Exception\SSLCaFileNotFound();
185
+ }
186
+ }
187
+ $memo = $extractedCaFile;
188
+ }
189
+
190
+ return $memo;
191
+ }
192
+ }
193
+ class_alias('Braintree\Http', 'Braintree_Http');
lib/braintree/lib/Braintree/Instance.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Class Instance template
6
+ *
7
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
8
+ * @abstract
9
+ */
10
+ abstract class Instance
11
+ {
12
+ protected $_attributes = [];
13
+
14
+ /**
15
+ *
16
+ * @param array $attributes
17
+ */
18
+ public function __construct($attributes)
19
+ {
20
+ if (!empty($attributes)) {
21
+ $this->_initializeFromArray($attributes);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * returns private/nonexistent instance properties
27
+ * @access public
28
+ * @param string $name property name
29
+ * @return mixed contents of instance properties
30
+ */
31
+ public function __get($name)
32
+ {
33
+ if (array_key_exists($name, $this->_attributes)) {
34
+ return $this->_attributes[$name];
35
+ } else {
36
+ trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
37
+ return null;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * used by isset() and empty()
43
+ * @access public
44
+ * @param string $name property name
45
+ * @return boolean
46
+ */
47
+ public function __isset($name)
48
+ {
49
+ return array_key_exists($name, $this->_attributes);
50
+ }
51
+
52
+ /**
53
+ * create a printable representation of the object as:
54
+ * ClassName[property=value, property=value]
55
+ * @return string
56
+ */
57
+ public function __toString()
58
+ {
59
+ $objOutput = Util::implodeAssociativeArray($this->_attributes);
60
+ return get_class($this) .'[' . $objOutput . ']';
61
+ }
62
+ /**
63
+ * initializes instance properties from the keys/values of an array
64
+ * @ignore
65
+ * @access protected
66
+ * @param <type> $aAttribs array of properties to set - single level
67
+ * @return void
68
+ */
69
+ private function _initializeFromArray($attributes)
70
+ {
71
+ $this->_attributes = $attributes;
72
+ }
73
+
74
+ }
75
+ class_alias('Braintree\Instance', 'Braintree_Instance');
lib/braintree/lib/Braintree/IsNode.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class IsNode
5
+ {
6
+ public function __construct($name)
7
+ {
8
+ $this->name = $name;
9
+ $this->searchTerms = [];
10
+ }
11
+
12
+ public function is($value)
13
+ {
14
+ $this->searchTerms['is'] = strval($value);
15
+
16
+ return $this;
17
+ }
18
+
19
+ public function toParam()
20
+ {
21
+ return $this->searchTerms;
22
+ }
23
+ }
24
+ class_alias('Braintree\IsNode', 'Braintree_IsNode');
lib/braintree/lib/Braintree/KeyValueNode.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class KeyValueNode
5
+ {
6
+ public function __construct($name)
7
+ {
8
+ $this->name = $name;
9
+ $this->searchTerm = True;
10
+ }
11
+
12
+ public function is($value)
13
+ {
14
+ $this->searchTerm = $value;
15
+ return $this;
16
+ }
17
+
18
+ public function toParam()
19
+ {
20
+ return $this->searchTerm;
21
+ }
22
+ }
23
+ class_alias('Braintree\KeyValueNode', 'Braintree_KeyValueNode');
lib/braintree/lib/Braintree/Merchant.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class Merchant extends Base
5
+ {
6
+ protected function _initialize($attribs)
7
+ {
8
+ $this->_attributes = $attribs;
9
+
10
+ $merchantAccountArray = [];
11
+ if (isset($attribs['merchantAccounts'])) {
12
+ foreach ($attribs['merchantAccounts'] AS $merchantAccount) {
13
+ $merchantAccountArray[] = MerchantAccount::factory($merchantAccount);
14
+ }
15
+ }
16
+ $this->_set('merchantAccounts', $merchantAccountArray);
17
+ }
18
+
19
+ public static function factory($attributes)
20
+ {
21
+ $instance = new self();
22
+ $instance->_initialize($attributes);
23
+ return $instance;
24
+ }
25
+
26
+ /**
27
+ * returns a string representation of the merchant
28
+ * @return string
29
+ */
30
+ public function __toString()
31
+ {
32
+ return __CLASS__ . '[' .
33
+ Util::attributesToString($this->_attributes) .']';
34
+ }
35
+ }
36
+ class_alias('Braintree\Merchant', 'Braintree_Merchant');
lib/braintree/lib/Braintree/MerchantAccount.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class MerchantAccount extends Base
5
+ {
6
+ const STATUS_ACTIVE = 'active';
7
+ const STATUS_PENDING = 'pending';
8
+ const STATUS_SUSPENDED = 'suspended';
9
+
10
+ const FUNDING_DESTINATION_BANK = 'bank';
11
+ const FUNDING_DESTINATION_EMAIL = 'email';
12
+ const FUNDING_DESTINATION_MOBILE_PHONE = 'mobile_phone';
13
+
14
+ public static function factory($attributes)
15
+ {
16
+ $instance = new self();
17
+ $instance->_initialize($attributes);
18
+ return $instance;
19
+ }
20
+
21
+ protected function _initialize($merchantAccountAttribs)
22
+ {
23
+ $this->_attributes = $merchantAccountAttribs;
24
+
25
+ if (isset($merchantAccountAttribs['individual'])) {
26
+ $individual = $merchantAccountAttribs['individual'];
27
+ $this->_set('individualDetails', MerchantAccount\IndividualDetails::Factory($individual));
28
+ }
29
+
30
+ if (isset($merchantAccountAttribs['business'])) {
31
+ $business = $merchantAccountAttribs['business'];
32
+ $this->_set('businessDetails', MerchantAccount\BusinessDetails::Factory($business));
33
+ }
34
+
35
+ if (isset($merchantAccountAttribs['funding'])) {
36
+ $funding = $merchantAccountAttribs['funding'];
37
+ $this->_set('fundingDetails', new MerchantAccount\FundingDetails($funding));
38
+ }
39
+
40
+ if (isset($merchantAccountAttribs['masterMerchantAccount'])) {
41
+ $masterMerchantAccount = $merchantAccountAttribs['masterMerchantAccount'];
42
+ $this->_set('masterMerchantAccount', self::Factory($masterMerchantAccount));
43
+ }
44
+ }
45
+
46
+
47
+ // static methods redirecting to gateway
48
+
49
+ public static function create($attribs)
50
+ {
51
+ return Configuration::gateway()->merchantAccount()->create($attribs);
52
+ }
53
+
54
+ public static function find($merchant_account_id)
55
+ {
56
+ return Configuration::gateway()->merchantAccount()->find($merchant_account_id);
57
+ }
58
+
59
+ public static function update($merchant_account_id, $attributes)
60
+ {
61
+ return Configuration::gateway()->merchantAccount()->update($merchant_account_id, $attributes);
62
+ }
63
+ }
64
+ class_alias('Braintree\MerchantAccount', 'Braintree_MerchantAccount');
lib/braintree/lib/Braintree/MerchantAccount/AddressDetails.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\MerchantAccount;
3
+
4
+ use Braintree\Instance;
5
+
6
+ class AddressDetails extends Instance
7
+ {
8
+ protected $_attributes = [];
9
+ }
10
+ class_alias('Braintree\MerchantAccount\AddressDetails', 'Braintree_MerchantAccount_AddressDetails');
lib/braintree/lib/Braintree/MerchantAccount/BusinessDetails.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\MerchantAccount;
3
+
4
+ use Braintree\Base;
5
+
6
+ class BusinessDetails extends Base
7
+ {
8
+ protected function _initialize($businessAttribs)
9
+ {
10
+ $this->_attributes = $businessAttribs;
11
+ if (isset($businessAttribs['address'])) {
12
+ $this->_set('addressDetails', new AddressDetails($businessAttribs['address']));
13
+ }
14
+ }
15
+
16
+ public static function factory($attributes)
17
+ {
18
+ $instance = new self();
19
+ $instance->_initialize($attributes);
20
+ return $instance;
21
+ }
22
+ }
23
+ class_alias('Braintree\MerchantAccount\BusinessDetails', 'Braintree_MerchantAccount_BusinessDetails');
lib/braintree/lib/Braintree/MerchantAccount/FundingDetails.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\MerchantAccount;
3
+
4
+ use Braintree\Instance;
5
+
6
+ class FundingDetails extends Instance
7
+ {
8
+ protected $_attributes = [];
9
+ }
10
+ class_alias('Braintree\MerchantAccount\FundingDetails', 'Braintree_MerchantAccount_FundingDetails');
lib/braintree/lib/Braintree/MerchantAccount/IndividualDetails.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\MerchantAccount;
3
+
4
+ use Braintree\Base;
5
+
6
+ class IndividualDetails extends Base
7
+ {
8
+ protected function _initialize($individualAttribs)
9
+ {
10
+ $this->_attributes = $individualAttribs;
11
+ if (isset($individualAttribs['address'])) {
12
+ $this->_set('addressDetails', new AddressDetails($individualAttribs['address']));
13
+ }
14
+ }
15
+
16
+ public static function factory($attributes)
17
+ {
18
+ $instance = new self();
19
+ $instance->_initialize($attributes);
20
+ return $instance;
21
+ }
22
+ }
23
+ class_alias('Braintree\MerchantAccount\IndividualDetails', 'Braintree_MerchantAccount_IndividualDetails');
lib/braintree/lib/Braintree/MerchantAccountGateway.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class MerchantAccountGateway
5
+ {
6
+ private $_gateway;
7
+ private $_config;
8
+ private $_http;
9
+
10
+ public function __construct($gateway)
11
+ {
12
+ $this->_gateway = $gateway;
13
+ $this->_config = $gateway->config;
14
+ $this->_config->assertHasAccessTokenOrKeys();
15
+ $this->_http = new Http($gateway->config);
16
+ }
17
+
18
+ public function create($attribs)
19
+ {
20
+ Util::verifyKeys(self::detectSignature($attribs), $attribs);
21
+ return $this->_doCreate('/merchant_accounts/create_via_api', ['merchant_account' => $attribs]);
22
+ }
23
+
24
+ public function find($merchant_account_id)
25
+ {
26
+ try {
27
+ $path = $this->_config->merchantPath() . '/merchant_accounts/' . $merchant_account_id;
28
+ $response = $this->_http->get($path);
29
+ return MerchantAccount::factory($response['merchantAccount']);
30
+ } catch (Exception\NotFound $e) {
31
+ throw new Exception\NotFound('merchant account with id ' . $merchant_account_id . ' not found');
32
+ }
33
+ }
34
+
35
+ public function update($merchant_account_id, $attributes)
36
+ {
37
+ Util::verifyKeys(self::updateSignature(), $attributes);
38
+ return $this->_doUpdate('/merchant_accounts/' . $merchant_account_id . '/update_via_api', ['merchant_account' => $attributes]);
39
+ }
40
+
41
+ public static function detectSignature($attribs)
42
+ {
43
+ if (isset($attribs['applicantDetails'])) {
44
+ trigger_error("DEPRECATED: Passing applicantDetails to create is deprecated. Please use individual, business, and funding", E_USER_NOTICE);
45
+ return self::createDeprecatedSignature();
46
+ } else {
47
+ return self::createSignature();
48
+ }
49
+ }
50
+
51
+ public static function updateSignature()
52
+ {
53
+ $signature = self::createSignature();
54
+ unset($signature['tosAccepted']);
55
+ return $signature;
56
+ }
57
+
58
+ public static function createSignature()
59
+ {
60
+ $addressSignature = ['streetAddress', 'postalCode', 'locality', 'region'];
61
+ $individualSignature = [
62
+ 'firstName',
63
+ 'lastName',
64
+ 'email',
65
+ 'phone',
66
+ 'dateOfBirth',
67
+ 'ssn',
68
+ ['address' => $addressSignature]
69
+ ];
70
+
71
+ $businessSignature = [
72
+ 'dbaName',
73
+ 'legalName',
74
+ 'taxId',
75
+ ['address' => $addressSignature]
76
+ ];
77
+
78
+ $fundingSignature = [
79
+ 'routingNumber',
80
+ 'accountNumber',
81
+ 'destination',
82
+ 'email',
83
+ 'mobilePhone',
84
+ 'descriptor',
85
+ ];
86
+
87
+ return [
88
+ 'id',
89
+ 'tosAccepted',
90
+ 'masterMerchantAccountId',
91
+ ['individual' => $individualSignature],
92
+ ['funding' => $fundingSignature],
93
+ ['business' => $businessSignature]
94
+ ];
95
+ }
96
+
97
+ public static function createDeprecatedSignature()
98
+ {
99
+ $applicantDetailsAddressSignature = ['streetAddress', 'postalCode', 'locality', 'region'];
100
+ $applicantDetailsSignature = [
101
+ 'companyName',
102
+ 'firstName',
103
+ 'lastName',
104
+ 'email',
105
+ 'phone',
106
+ 'dateOfBirth',
107
+ 'ssn',
108
+ 'taxId',
109
+ 'routingNumber',
110
+ 'accountNumber',
111
+ ['address' => $applicantDetailsAddressSignature]
112
+ ];
113
+
114
+ return [
115
+ ['applicantDetails' => $applicantDetailsSignature],
116
+ 'id',
117
+ 'tosAccepted',
118
+ 'masterMerchantAccountId'
119
+ ];
120
+ }
121
+
122
+ public function _doCreate($subPath, $params)
123
+ {
124
+ $fullPath = $this->_config->merchantPath() . $subPath;
125
+ $response = $this->_http->post($fullPath, $params);
126
+
127
+ return $this->_verifyGatewayResponse($response);
128
+ }
129
+
130
+ private function _doUpdate($subPath, $params)
131
+ {
132
+ $fullPath = $this->_config->merchantPath() . $subPath;
133
+ $response = $this->_http->put($fullPath, $params);
134
+
135
+ return $this->_verifyGatewayResponse($response);
136
+ }
137
+
138
+ private function _verifyGatewayResponse($response)
139
+ {
140
+ if (isset($response['merchantAccount'])) {
141
+ // return a populated instance of merchantAccount
142
+ return new Result\Successful(
143
+ MerchantAccount::factory($response['merchantAccount'])
144
+ );
145
+ } else if (isset($response['apiErrorResponse'])) {
146
+ return new Result\Error($response['apiErrorResponse']);
147
+ } else {
148
+ throw new Exception\Unexpected(
149
+ "Expected merchant account or apiErrorResponse"
150
+ );
151
+ }
152
+ }
153
+ }
154
+ class_alias('Braintree\MerchantAccountGateway', 'Braintree_MerchantAccountGateway');
lib/braintree/lib/Braintree/MerchantGateway.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class MerchantGateway
5
+ {
6
+ private $_gateway;
7
+ private $_config;
8
+ private $_http;
9
+
10
+ public function __construct($gateway)
11
+ {
12
+ $this->_gateway = $gateway;
13
+ $this->_config = $gateway->config;
14
+ $this->_config->assertHasClientCredentials();
15
+ $this->_http = new Http($gateway->config);
16
+ $this->_http->useClientCredentials();
17
+ }
18
+
19
+ public function create($attribs)
20
+ {
21
+ $response = $this->_http->post('/merchants/create_via_api', ['merchant' => $attribs]);
22
+ return $this->_verifyGatewayResponse($response);
23
+ }
24
+
25
+ private function _verifyGatewayResponse($response)
26
+ {
27
+ if (isset($response['response']['merchant'])) {
28
+ // return a populated instance of merchant
29
+ return new Result\Successful([
30
+ Merchant::factory($response['response']['merchant']),
31
+ OAuthCredentials::factory($response['response']['credentials']),
32
+ ]);
33
+ } else if (isset($response['apiErrorResponse'])) {
34
+ return new Result\Error($response['apiErrorResponse']);
35
+ } else {
36
+ throw new Exception\Unexpected(
37
+ "Expected merchant or apiErrorResponse"
38
+ );
39
+ }
40
+ }
41
+ }
42
+ class_alias('Braintree\MerchantGateway', 'Braintree_MerchantGateway');
lib/braintree/lib/Braintree/Modification.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class Modification extends Base
5
+ {
6
+ protected function _initialize($attributes)
7
+ {
8
+ $this->_attributes = $attributes;
9
+ }
10
+
11
+ public static function factory($attributes)
12
+ {
13
+ $instance = new self();
14
+ $instance->_initialize($attributes);
15
+ return $instance;
16
+ }
17
+
18
+ public function __toString() {
19
+ return get_called_class() . '[' . Util::attributesToString($this->_attributes) . ']';
20
+ }
21
+ }
22
+ class_alias('Braintree\Modification', 'Braintree_Modification');
lib/braintree/lib/Braintree/MultipleValueNode.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ class MultipleValueNode
7
+ {
8
+ public function __construct($name, $allowedValues = [])
9
+ {
10
+ $this->name = $name;
11
+ $this->items = [];
12
+ $this->allowedValues = $allowedValues;
13
+ }
14
+
15
+ public function in($values)
16
+ {
17
+ $bad_values = array_diff($values, $this->allowedValues);
18
+ if (count($this->allowedValues) > 0 && count($bad_values) > 0) {
19
+ $message = 'Invalid argument(s) for ' . $this->name . ':';
20
+ foreach ($bad_values AS $bad_value) {
21
+ $message .= ' ' . $bad_value;
22
+ }
23
+
24
+ throw new InvalidArgumentException($message);
25
+ }
26
+
27
+ $this->items = $values;
28
+ return $this;
29
+ }
30
+
31
+ public function is($value)
32
+ {
33
+ return $this->in([$value]);
34
+ }
35
+
36
+ public function toParam()
37
+ {
38
+ return $this->items;
39
+ }
40
+ }
41
+ class_alias('Braintree\MultipleValueNode', 'Braintree_MultipleValueNode');
lib/braintree/lib/Braintree/MultipleValueOrTextNode.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class MultipleValueOrTextNode extends MultipleValueNode
5
+ {
6
+ public function __construct($name)
7
+ {
8
+ parent::__construct($name);
9
+ $this->textNode = new TextNode($name);
10
+ }
11
+
12
+ public function contains($value)
13
+ {
14
+ $this->textNode->contains($value);
15
+ return $this;
16
+ }
17
+
18
+ public function endsWith($value)
19
+ {
20
+ $this->textNode->endsWith($value);
21
+ return $this;
22
+ }
23
+
24
+ public function is($value)
25
+ {
26
+ $this->textNode->is($value);
27
+ return $this;
28
+ }
29
+
30
+ public function isNot($value)
31
+ {
32
+ $this->textNode->isNot($value);
33
+ return $this;
34
+ }
35
+
36
+ public function startsWith($value)
37
+ {
38
+ $this->textNode->startsWith($value);
39
+ return $this;
40
+ }
41
+
42
+ public function toParam()
43
+ {
44
+ return array_merge(parent::toParam(), $this->textNode->toParam());
45
+ }
46
+ }
47
+ class_alias('Braintree\MultipleValueOrTextNode', 'Braintree_MultipleValueOrTextNode');
lib/braintree/lib/Braintree/OAuthCredentials.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree OAuthCredentials module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ *
11
+ */
12
+ class OAuthCredentials extends Base
13
+ {
14
+ protected function _initialize($attribs)
15
+ {
16
+ $this->_attributes = $attribs;
17
+ }
18
+
19
+ public static function factory($attributes)
20
+ {
21
+ $instance = new self();
22
+ $instance->_initialize($attributes);
23
+ return $instance;
24
+ }
25
+
26
+ /**
27
+ * returns a string representation of the access token
28
+ * @return string
29
+ */
30
+ public function __toString()
31
+ {
32
+ return __CLASS__ . '[' .
33
+ Util::attributesToString($this->_attributes) .']';
34
+ }
35
+ }
36
+ class_alias('Braintree\OAuthCredentials', 'Braintree_OAuthCredentials');
lib/braintree/lib/Braintree/OAuthGateway.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree OAuthGateway module
6
+ * PHP Version 5
7
+ * Creates and manages Braintree Addresses
8
+ *
9
+ * @package Braintree
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
+ */
12
+ class OAuthGateway
13
+ {
14
+ private $_gateway;
15
+ private $_config;
16
+ private $_http;
17
+
18
+ public function __construct($gateway)
19
+ {
20
+ $this->_gateway = $gateway;
21
+ $this->_config = $gateway->config;
22
+ $this->_http = new Http($gateway->config);
23
+ $this->_http->useClientCredentials();
24
+
25
+ $this->_config->assertHasClientCredentials();
26
+ }
27
+
28
+ public function createTokenFromCode($params)
29
+ {
30
+ $params['grantType'] = "authorization_code";
31
+ return $this->_createToken($params);
32
+ }
33
+
34
+ public function createTokenFromRefreshToken($params)
35
+ {
36
+ $params['grantType'] = "refresh_token";
37
+ return $this->_createToken($params);
38
+ }
39
+
40
+ public function revokeAccessToken($accessToken)
41
+ {
42
+ $params = ['token' => $accessToken];
43
+ $response = $this->_http->post('/oauth/revoke_access_token', $params);
44
+ return $this->_verifyGatewayResponse($response);
45
+ }
46
+
47
+ private function _createToken($params)
48
+ {
49
+ $params = ['credentials' => $params];
50
+ $response = $this->_http->post('/oauth/access_tokens', $params);
51
+ return $this->_verifyGatewayResponse($response);
52
+ }
53
+
54
+ private function _verifyGatewayResponse($response)
55
+ {
56
+ if (isset($response['credentials'])) {
57
+ $result = new Result\Successful(
58
+ OAuthCredentials::factory($response['credentials'])
59
+ );
60
+ return $this->_mapSuccess($result);
61
+ } else if (isset($response['result'])) {
62
+ $result = new Result\Successful(
63
+ OAuthResult::factory($response['result'])
64
+ );
65
+ return $this->_mapAccessTokenRevokeSuccess($result);
66
+ } else if (isset($response['apiErrorResponse'])) {
67
+ $result = new Result\Error($response['apiErrorResponse']);
68
+ return $this->_mapError($result);
69
+ } else {
70
+ throw new Exception\Unexpected(
71
+ "Expected credentials or apiErrorResponse"
72
+ );
73
+ }
74
+ }
75
+
76
+ public function _mapError($result)
77
+ {
78
+ $error = $result->errors->deepAll()[0];
79
+
80
+ if ($error->code == Error\Codes::OAUTH_INVALID_GRANT) {
81
+ $result->error = 'invalid_grant';
82
+ } else if ($error->code == Error\Codes::OAUTH_INVALID_CREDENTIALS) {
83
+ $result->error = 'invalid_credentials';
84
+ } else if ($error->code == Error\Codes::OAUTH_INVALID_SCOPE) {
85
+ $result->error = 'invalid_scope';
86
+ }
87
+ $result->errorDescription = explode(': ', $error->message)[1];
88
+ return $result;
89
+ }
90
+
91
+ public function _mapAccessTokenRevokeSuccess($result)
92
+ {
93
+ $result->revocationResult = $result->success;
94
+ return $result;
95
+ }
96
+
97
+ public function _mapSuccess($result)
98
+ {
99
+ $credentials = $result->credentials;
100
+ $result->accessToken = $credentials->accessToken;
101
+ $result->refreshToken = $credentials->refreshToken;
102
+ $result->tokenType = $credentials->tokenType;
103
+ $result->expiresAt = $credentials->expiresAt;
104
+ return $result;
105
+ }
106
+
107
+ public function connectUrl($params = [])
108
+ {
109
+ $query = Util::camelCaseToDelimiterArray($params, '_');
110
+ $query['client_id'] = $this->_config->getClientId();
111
+ $queryString = preg_replace('/\%5B\d+\%5D/', '%5B%5D', http_build_query($query));
112
+ $url = $this->_config->baseUrl() . '/oauth/connect?' . $queryString;
113
+
114
+ return $url . '&signature=' . $this->computeSignature($url) . '&algorithm=SHA256';
115
+ }
116
+
117
+ public function computeSignature($url)
118
+ {
119
+ $key = hash('sha256', $this->_config->getClientSecret(), true);
120
+ return hash_hmac('sha256', $url, $key);
121
+ }
122
+ }
123
+ class_alias('Braintree\OAuthGateway', 'Braintree_OAuthGateway');
lib/braintree/lib/Braintree/OAuthResult.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree OAuthCredentials module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ *
11
+ */
12
+ class OAuthResult extends Base
13
+ {
14
+ protected function _initialize($attribs)
15
+ {
16
+ $this->_attributes = $attribs;
17
+ }
18
+
19
+ public static function factory($attributes)
20
+ {
21
+ $instance = new self();
22
+ $instance->_initialize($attributes);
23
+ return $instance;
24
+ }
25
+
26
+ /**
27
+ * returns a string representation of the result
28
+ * @return string
29
+ */
30
+ public function __toString()
31
+ {
32
+ return __CLASS__ . '[' .
33
+ Util::attributesToString($this->_attributes) .']';
34
+ }
35
+ }
36
+ class_alias('Braintree\OAuthResult', 'Braintree_OAuthResult');
lib/braintree/lib/Braintree/PartialMatchNode.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class PartialMatchNode extends EqualityNode
5
+ {
6
+ public function startsWith($value)
7
+ {
8
+ $this->searchTerms["starts_with"] = strval($value);
9
+ return $this;
10
+ }
11
+
12
+ public function endsWith($value)
13
+ {
14
+ $this->searchTerms["ends_with"] = strval($value);
15
+ return $this;
16
+ }
17
+ }
18
+ class_alias('Braintree\PartialMatchNode', 'Braintree_PartialMatchNode');
lib/braintree/lib/Braintree/PartnerMerchant.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Partner Merchant information that is generated when a partner is connected
6
+ * to or disconnected from a user.
7
+ *
8
+ * Creates an instance of PartnerMerchants
9
+ *
10
+ * @package Braintree
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ *
13
+ * @property-read string $merchantPublicId
14
+ * @property-read string $publicKey
15
+ * @property-read string $privateKey
16
+ * @property-read string $clientSideEncryptionKey
17
+ * @property-read string $partnerMerchantId
18
+ */
19
+ class PartnerMerchant extends Base
20
+ {
21
+ protected $_attributes = [];
22
+
23
+ /**
24
+ * @ignore
25
+ */
26
+ public static function factory($attributes)
27
+ {
28
+ $instance = new self();
29
+ $instance->_initialize($attributes);
30
+
31
+ return $instance;
32
+ }
33
+
34
+ /**
35
+ * @ignore
36
+ */
37
+ protected function _initialize($attributes)
38
+ {
39
+ $this->_attributes = $attributes;
40
+ }
41
+ }
42
+ class_alias('Braintree\PartnerMerchant', 'Braintree_PartnerMerchant');
lib/braintree/lib/Braintree/PayPalAccount.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree PayPalAccount module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Manages Braintree PayPalAccounts
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $customerId
23
+ * @property-read string $email
24
+ * @property-read string $token
25
+ * @property-read string $imageUrl
26
+ */
27
+ class PayPalAccount extends Base
28
+ {
29
+ /**
30
+ * factory method: returns an instance of PayPalAccount
31
+ * to the requesting method, with populated properties
32
+ *
33
+ * @ignore
34
+ * @return PayPalAccount
35
+ */
36
+ public static function factory($attributes)
37
+ {
38
+ $instance = new self();
39
+ $instance->_initialize($attributes);
40
+ return $instance;
41
+ }
42
+
43
+ /* instance methods */
44
+
45
+ /**
46
+ * returns false if default is null or false
47
+ *
48
+ * @return boolean
49
+ */
50
+ public function isDefault()
51
+ {
52
+ return $this->default;
53
+ }
54
+
55
+ /**
56
+ * sets instance properties from an array of values
57
+ *
58
+ * @access protected
59
+ * @param array $paypalAccountAttribs array of paypalAccount data
60
+ * @return void
61
+ */
62
+ protected function _initialize($paypalAccountAttribs)
63
+ {
64
+ // set the attributes
65
+ $this->_attributes = $paypalAccountAttribs;
66
+
67
+ $subscriptionArray = [];
68
+ if (isset($paypalAccountAttribs['subscriptions'])) {
69
+ foreach ($paypalAccountAttribs['subscriptions'] AS $subscription) {
70
+ $subscriptionArray[] = Subscription::factory($subscription);
71
+ }
72
+ }
73
+
74
+ $this->_set('subscriptions', $subscriptionArray);
75
+ }
76
+
77
+ /**
78
+ * create a printable representation of the object as:
79
+ * ClassName[property=value, property=value]
80
+ * @return string
81
+ */
82
+ public function __toString()
83
+ {
84
+ return __CLASS__ . '[' .
85
+ Util::attributesToString($this->_attributes) . ']';
86
+ }
87
+
88
+
89
+ // static methods redirecting to gateway
90
+
91
+ public static function find($token)
92
+ {
93
+ return Configuration::gateway()->payPalAccount()->find($token);
94
+ }
95
+
96
+ public static function update($token, $attributes)
97
+ {
98
+ return Configuration::gateway()->payPalAccount()->update($token, $attributes);
99
+ }
100
+
101
+ public static function delete($token)
102
+ {
103
+ return Configuration::gateway()->payPalAccount()->delete($token);
104
+ }
105
+
106
+ public static function sale($token, $transactionAttribs)
107
+ {
108
+ return Configuration::gateway()->payPalAccount()->sale($token, $transactionAttribs);
109
+ }
110
+ }
111
+ class_alias('Braintree\PayPalAccount', 'Braintree_PayPalAccount');
lib/braintree/lib/Braintree/PayPalAccountGateway.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree PayPalAccountGateway module
8
+ *
9
+ * @package Braintree
10
+ * @category Resources
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ /**
15
+ * Manages Braintree PayPalAccounts
16
+ *
17
+ * <b>== More information ==</b>
18
+ *
19
+ *
20
+ * @package Braintree
21
+ * @category Resources
22
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
23
+ */
24
+ class PayPalAccountGateway
25
+ {
26
+ private $_gateway;
27
+ private $_config;
28
+ private $_http;
29
+
30
+ public function __construct($gateway)
31
+ {
32
+ $this->_gateway = $gateway;
33
+ $this->_config = $gateway->config;
34
+ $this->_config->assertHasAccessTokenOrKeys();
35
+ $this->_http = new Http($gateway->config);
36
+ }
37
+
38
+
39
+ /**
40
+ * find a paypalAccount by token
41
+ *
42
+ * @access public
43
+ * @param string $token paypal accountunique id
44
+ * @return PayPalAccount
45
+ * @throws Exception\NotFound
46
+ */
47
+ public function find($token)
48
+ {
49
+ $this->_validateId($token);
50
+ try {
51
+ $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token;
52
+ $response = $this->_http->get($path);
53
+ return PayPalAccount::factory($response['paypalAccount']);
54
+ } catch (Exception\NotFound $e) {
55
+ throw new Exception\NotFound(
56
+ 'paypal account with token ' . $token . ' not found'
57
+ );
58
+ }
59
+
60
+ }
61
+
62
+ /**
63
+ * updates the paypalAccount record
64
+ *
65
+ * if calling this method in context, $token
66
+ * is the 2nd attribute. $token is not sent in object context.
67
+ *
68
+ * @access public
69
+ * @param array $attributes
70
+ * @param string $token (optional)
71
+ * @return Result\Successful or Result\Error
72
+ */
73
+ public function update($token, $attributes)
74
+ {
75
+ Util::verifyKeys(self::updateSignature(), $attributes);
76
+ $this->_validateId($token);
77
+ return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, ['paypalAccount' => $attributes]);
78
+ }
79
+
80
+ public function delete($token)
81
+ {
82
+ $this->_validateId($token);
83
+ $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token;
84
+ $this->_http->delete($path);
85
+ return new Result\Successful();
86
+ }
87
+
88
+ /**
89
+ * create a new sale for the current PayPal account
90
+ *
91
+ * @param string $token
92
+ * @param array $transactionAttribs
93
+ * @return Result\Successful|Result\Error
94
+ * @see Transaction::sale()
95
+ */
96
+ public function sale($token, $transactionAttribs)
97
+ {
98
+ $this->_validateId($token);
99
+ return Transaction::sale(
100
+ array_merge(
101
+ $transactionAttribs,
102
+ ['paymentMethodToken' => $token]
103
+ )
104
+ );
105
+ }
106
+
107
+ public static function updateSignature()
108
+ {
109
+ return [
110
+ 'token',
111
+ ['options' => ['makeDefault']]
112
+ ];
113
+ }
114
+
115
+ /**
116
+ * sends the update request to the gateway
117
+ *
118
+ * @ignore
119
+ * @param string $subPath
120
+ * @param array $params
121
+ * @return mixed
122
+ */
123
+ private function _doUpdate($httpVerb, $subPath, $params)
124
+ {
125
+ $fullPath = $this->_config->merchantPath() . $subPath;
126
+ $response = $this->_http->$httpVerb($fullPath, $params);
127
+ return $this->_verifyGatewayResponse($response);
128
+ }
129
+
130
+ /**
131
+ * generic method for validating incoming gateway responses
132
+ *
133
+ * creates a new PayPalAccount object and encapsulates
134
+ * it inside a Result\Successful object, or
135
+ * encapsulates a Errors object inside a Result\Error
136
+ * alternatively, throws an Unexpected exception if the response is invalid.
137
+ *
138
+ * @ignore
139
+ * @param array $response gateway response values
140
+ * @return Result\Successful|Result\Error
141
+ * @throws Exception\Unexpected
142
+ */
143
+ private function _verifyGatewayResponse($response)
144
+ {
145
+ if (isset($response['paypalAccount'])) {
146
+ // return a populated instance of PayPalAccount
147
+ return new Result\Successful(
148
+ PayPalAccount::factory($response['paypalAccount'])
149
+ );
150
+ } else if (isset($response['apiErrorResponse'])) {
151
+ return new Result\Error($response['apiErrorResponse']);
152
+ } else {
153
+ throw new Exception\Unexpected(
154
+ 'Expected paypal account or apiErrorResponse'
155
+ );
156
+ }
157
+ }
158
+
159
+ /**
160
+ * verifies that a valid paypal account identifier is being used
161
+ * @ignore
162
+ * @param string $identifier
163
+ * @param Optional $string $identifierType type of identifier supplied, default 'token'
164
+ * @throws InvalidArgumentException
165
+ */
166
+ private function _validateId($identifier = null, $identifierType = 'token')
167
+ {
168
+ if (empty($identifier)) {
169
+ throw new InvalidArgumentException(
170
+ 'expected paypal account id to be set'
171
+ );
172
+ }
173
+ if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) {
174
+ throw new InvalidArgumentException(
175
+ $identifier . ' is an invalid paypal account ' . $identifierType . '.'
176
+ );
177
+ }
178
+ }
179
+ }
180
+ class_alias('Braintree\PayPalAccountGateway', 'Braintree_PayPalAccountGateway');
lib/braintree/lib/Braintree/PaymentInstrumentType.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class PaymentInstrumentType
5
+ {
6
+ const PAYPAL_ACCOUNT = 'paypal_account';
7
+ const COINBASE_ACCOUNT = 'coinbase_account';
8
+ const EUROPE_BANK_ACCOUNT = 'europe_bank_account';
9
+ const CREDIT_CARD = 'credit_card';
10
+ const APPLE_PAY_CARD = 'apple_pay_card';
11
+ const ANDROID_PAY_CARD = 'android_pay_card';
12
+ const VENMO_ACCOUNT = 'venmo_account';
13
+ const US_BANK_ACCOUNT = 'us_bank_account';
14
+ }
15
+ class_alias('Braintree\PaymentInstrumentType', 'Braintree_PaymentInstrumentType');
lib/braintree/lib/Braintree/PaymentMethod.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree PaymentMethod module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Creates and manages Braintree PaymentMethods
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ */
23
+ class PaymentMethod extends Base
24
+ {
25
+ // static methods redirecting to gateway
26
+
27
+ public static function create($attribs)
28
+ {
29
+ return Configuration::gateway()->paymentMethod()->create($attribs);
30
+ }
31
+
32
+ public static function find($token)
33
+ {
34
+ return Configuration::gateway()->paymentMethod()->find($token);
35
+ }
36
+
37
+ public static function update($token, $attribs)
38
+ {
39
+ return Configuration::gateway()->paymentMethod()->update($token, $attribs);
40
+ }
41
+
42
+ public static function delete($token)
43
+ {
44
+ return Configuration::gateway()->paymentMethod()->delete($token);
45
+ }
46
+ }
47
+ class_alias('Braintree\PaymentMethod', 'Braintree_PaymentMethod');
lib/braintree/lib/Braintree/PaymentMethodGateway.php ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree PaymentMethodGateway module
8
+ *
9
+ * @package Braintree
10
+ * @category Resources
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ /**
15
+ * Creates and manages Braintree PaymentMethods
16
+ *
17
+ * <b>== More information ==</b>
18
+ *
19
+ *
20
+ * @package Braintree
21
+ * @category Resources
22
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
23
+ *
24
+ */
25
+ class PaymentMethodGateway
26
+ {
27
+ private $_gateway;
28
+ private $_config;
29
+ private $_http;
30
+
31
+ public function __construct($gateway)
32
+ {
33
+ $this->_gateway = $gateway;
34
+ $this->_config = $gateway->config;
35
+ $this->_config->assertHasAccessTokenOrKeys();
36
+ $this->_http = new Http($gateway->config);
37
+ }
38
+
39
+
40
+ public function create($attribs)
41
+ {
42
+ Util::verifyKeys(self::createSignature(), $attribs);
43
+ return $this->_doCreate('/payment_methods', ['payment_method' => $attribs]);
44
+ }
45
+
46
+ /**
47
+ * find a PaymentMethod by token
48
+ *
49
+ * @param string $token payment method unique id
50
+ * @return CreditCard|PayPalAccount
51
+ * @throws Exception\NotFound
52
+ */
53
+ public function find($token)
54
+ {
55
+ $this->_validateId($token);
56
+ try {
57
+ $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token;
58
+ $response = $this->_http->get($path);
59
+ if (isset($response['creditCard'])) {
60
+ return CreditCard::factory($response['creditCard']);
61
+ } else if (isset($response['paypalAccount'])) {
62
+ return PayPalAccount::factory($response['paypalAccount']);
63
+ } else if (isset($response['coinbaseAccount'])) {
64
+ return CoinbaseAccount::factory($response['coinbaseAccount']);
65
+ } else if (isset($response['applePayCard'])) {
66
+ return ApplePayCard::factory($response['applePayCard']);
67
+ } else if (isset($response['androidPayCard'])) {
68
+ return AndroidPayCard::factory($response['androidPayCard']);
69
+ } else if (isset($response['amexExpressCheckoutCard'])) {
70
+ return AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']);
71
+ } else if (isset($response['europeBankAccount'])) {
72
+ return EuropeBankAccount::factory($response['europeBankAccount']);
73
+ } else if (isset($response['usBankAccount'])) {
74
+ return UsBankAccount::factory($response['usBankAccount']);
75
+ } else if (isset($response['venmoAccount'])) {
76
+ return VenmoAccount::factory($response['venmoAccount']);
77
+ } else if (is_array($response)) {
78
+ return UnknownPaymentMethod::factory($response);
79
+ }
80
+ } catch (Exception\NotFound $e) {
81
+ throw new Exception\NotFound(
82
+ 'payment method with token ' . $token . ' not found'
83
+ );
84
+ }
85
+ }
86
+
87
+ public function update($token, $attribs)
88
+ {
89
+ Util::verifyKeys(self::updateSignature(), $attribs);
90
+ return $this->_doUpdate('/payment_methods/any/' . $token, ['payment_method' => $attribs]);
91
+ }
92
+
93
+ public function delete($token)
94
+ {
95
+ $this->_validateId($token);
96
+ $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token;
97
+ $this->_http->delete($path);
98
+ return new Result\Successful();
99
+ }
100
+
101
+ public function grant($sharedPaymentMethodToken, $attribs=[])
102
+ {
103
+ if (is_bool($attribs) === true) {
104
+ $attribs = ['allow_vaulting' => $attribs];
105
+ }
106
+ $options = [ 'shared_payment_method_token' => $sharedPaymentMethodToken ];
107
+
108
+ return $this->_doCreate(
109
+ '/payment_methods/grant',
110
+ [
111
+ 'payment_method' => array_merge($attribs, $options)
112
+ ]
113
+ );
114
+ }
115
+
116
+ public function revoke($sharedPaymentMethodToken)
117
+ {
118
+ return $this->_doCreate(
119
+ '/payment_methods/revoke',
120
+ [
121
+ 'payment_method' => [
122
+ 'shared_payment_method_token' => $sharedPaymentMethodToken
123
+ ]
124
+ ]
125
+ );
126
+ }
127
+
128
+ private static function baseSignature()
129
+ {
130
+ $billingAddressSignature = AddressGateway::createSignature();
131
+ $optionsSignature = [
132
+ 'failOnDuplicatePaymentMethod',
133
+ 'makeDefault',
134
+ 'verificationMerchantAccountId',
135
+ 'verifyCard',
136
+ 'verificationAmount'
137
+ ];
138
+ return [
139
+ 'billingAddressId',
140
+ 'cardholderName',
141
+ 'cvv',
142
+ 'deviceData',
143
+ 'expirationDate',
144
+ 'expirationMonth',
145
+ 'expirationYear',
146
+ 'number',
147
+ 'paymentMethodNonce',
148
+ 'token',
149
+ ['options' => $optionsSignature],
150
+ ['billingAddress' => $billingAddressSignature]
151
+ ];
152
+ }
153
+
154
+ public static function createSignature()
155
+ {
156
+ $signature = array_merge(self::baseSignature(), ['customerId']);
157
+ return $signature;
158
+ }
159
+
160
+ public static function updateSignature()
161
+ {
162
+ $billingAddressSignature = AddressGateway::updateSignature();
163
+ array_push($billingAddressSignature, [
164
+ 'options' => [
165
+ 'updateExisting'
166
+ ]
167
+ ]);
168
+ $signature = array_merge(self::baseSignature(), [
169
+ 'deviceSessionId',
170
+ 'venmoSdkPaymentMethodCode',
171
+ 'fraudMerchantId',
172
+ ['billingAddress' => $billingAddressSignature]
173
+ ]);
174
+ return $signature;
175
+ }
176
+
177
+ /**
178
+ * sends the create request to the gateway
179
+ *
180
+ * @ignore
181
+ * @param string $subPath
182
+ * @param array $params
183
+ * @return mixed
184
+ */
185
+ public function _doCreate($subPath, $params)
186
+ {
187
+ $fullPath = $this->_config->merchantPath() . $subPath;
188
+ $response = $this->_http->post($fullPath, $params);
189
+
190
+ return $this->_verifyGatewayResponse($response);
191
+ }
192
+
193
+ /**
194
+ * sends the update request to the gateway
195
+ *
196
+ * @ignore
197
+ * @param string $subPath
198
+ * @param array $params
199
+ * @return mixed
200
+ */
201
+ public function _doUpdate($subPath, $params)
202
+ {
203
+ $fullPath = $this->_config->merchantPath() . $subPath;
204
+ $response = $this->_http->put($fullPath, $params);
205
+
206
+ return $this->_verifyGatewayResponse($response);
207
+ }
208
+
209
+ /**
210
+ * generic method for validating incoming gateway responses
211
+ *
212
+ * creates a new CreditCard or PayPalAccount object
213
+ * and encapsulates it inside a Result\Successful object, or
214
+ * encapsulates a Errors object inside a Result\Error
215
+ * alternatively, throws an Unexpected exception if the response is invalid.
216
+ *
217
+ * @ignore
218
+ * @param array $response gateway response values
219
+ * @return Result\Successful|Result\Error
220
+ * @throws Exception\Unexpected
221
+ */
222
+ private function _verifyGatewayResponse($response)
223
+ {
224
+ if (isset($response['creditCard'])) {
225
+ return new Result\Successful(
226
+ CreditCard::factory($response['creditCard']),
227
+ 'paymentMethod'
228
+ );
229
+ } else if (isset($response['paypalAccount'])) {
230
+ return new Result\Successful(
231
+ PayPalAccount::factory($response['paypalAccount']),
232
+ "paymentMethod"
233
+ );
234
+ } else if (isset($response['coinbaseAccount'])) {
235
+ return new Result\Successful(
236
+ CoinbaseAccount::factory($response['coinbaseAccount']),
237
+ "paymentMethod"
238
+ );
239
+ } else if (isset($response['applePayCard'])) {
240
+ return new Result\Successful(
241
+ ApplePayCard::factory($response['applePayCard']),
242
+ "paymentMethod"
243
+ );
244
+ } else if (isset($response['androidPayCard'])) {
245
+ return new Result\Successful(
246
+ AndroidPayCard::factory($response['androidPayCard']),
247
+ "paymentMethod"
248
+ );
249
+ } else if (isset($response['amexExpressCheckoutCard'])) {
250
+ return new Result\Successful(
251
+ AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']),
252
+ "paymentMethod"
253
+ );
254
+ } else if (isset($response['europeBankAccount'])) {
255
+ return new Result\Successful(
256
+ EuropeBankAccount::factory($response['europeBankAccount']),
257
+ "paymentMethod"
258
+ );
259
+ } else if (isset($response['usBankAccount'])) {
260
+ return new Result\Successful(
261
+ UsBankAccount::factory($response['usBankAccount']),
262
+ "paymentMethod"
263
+ );
264
+ } else if (isset($response['venmoAccount'])) {
265
+ return new Result\Successful(
266
+ VenmoAccount::factory($response['venmoAccount']),
267
+ "paymentMethod"
268
+ );
269
+ } else if (isset($response['paymentMethodNonce'])) {
270
+ return new Result\Successful(
271
+ PaymentMethodNonce::factory($response['paymentMethodNonce']),
272
+ "paymentMethodNonce"
273
+ );
274
+ } else if (isset($response['apiErrorResponse'])) {
275
+ return new Result\Error($response['apiErrorResponse']);
276
+ } else if (is_array($response)) {
277
+ return new Result\Successful(
278
+ UnknownPaymentMethod::factory($response),
279
+ "paymentMethod"
280
+ );
281
+ } else {
282
+ throw new Exception\Unexpected(
283
+ 'Expected payment method or apiErrorResponse'
284
+ );
285
+ }
286
+ }
287
+
288
+ /**
289
+ * verifies that a valid payment method identifier is being used
290
+ * @ignore
291
+ * @param string $identifier
292
+ * @param Optional $string $identifierType type of identifier supplied, default 'token'
293
+ * @throws InvalidArgumentException
294
+ */
295
+ private function _validateId($identifier = null, $identifierType = 'token')
296
+ {
297
+ if (empty($identifier)) {
298
+ throw new InvalidArgumentException(
299
+ 'expected payment method id to be set'
300
+ );
301
+ }
302
+ if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) {
303
+ throw new InvalidArgumentException(
304
+ $identifier . ' is an invalid payment method ' . $identifierType . '.'
305
+ );
306
+ }
307
+ }
308
+ }
309
+ class_alias('Braintree\PaymentMethodGateway', 'Braintree_PaymentMethodGateway');
lib/braintree/lib/Braintree/PaymentMethodNonce.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree PaymentMethodNonce module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Creates and manages Braintree PaymentMethodNonces
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ */
23
+ class PaymentMethodNonce extends Base
24
+ {
25
+ // static methods redirecting to gateway
26
+
27
+ public static function create($token)
28
+ {
29
+ return Configuration::gateway()->paymentMethodNonce()->create($token);
30
+ }
31
+
32
+ public static function find($nonce)
33
+ {
34
+ return Configuration::gateway()->paymentMethodNonce()->find($nonce);
35
+ }
36
+
37
+ public static function factory($attributes)
38
+ {
39
+ $instance = new self();
40
+ $instance->_initialize($attributes);
41
+ return $instance;
42
+ }
43
+
44
+ protected function _initialize($nonceAttributes)
45
+ {
46
+ $this->_attributes = $nonceAttributes;
47
+ $this->_set('nonce', $nonceAttributes['nonce']);
48
+ $this->_set('type', $nonceAttributes['type']);
49
+
50
+ if(isset($nonceAttributes['threeDSecureInfo'])) {
51
+ $this->_set('threeDSecureInfo', ThreeDSecureInfo::factory($nonceAttributes['threeDSecureInfo']));
52
+ }
53
+ }
54
+ }
55
+ class_alias('Braintree\PaymentMethodNonce', 'Braintree_PaymentMethodNonce');
lib/braintree/lib/Braintree/PaymentMethodNonceGateway.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree PaymentMethodNonceGateway module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Creates and manages Braintree PaymentMethodNonces
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ */
23
+ class PaymentMethodNonceGateway
24
+ {
25
+ private $_gateway;
26
+ private $_config;
27
+ private $_http;
28
+
29
+ public function __construct($gateway)
30
+ {
31
+ $this->_gateway = $gateway;
32
+ $this->_config = $gateway->config;
33
+ $this->_http = new Http($gateway->config);
34
+ }
35
+
36
+
37
+ public function create($token)
38
+ {
39
+ $subPath = '/payment_methods/' . $token . '/nonces';
40
+ $fullPath = $this->_config->merchantPath() . $subPath;
41
+ $response = $this->_http->post($fullPath);
42
+
43
+ return new Result\Successful(
44
+ PaymentMethodNonce::factory($response['paymentMethodNonce']),
45
+ "paymentMethodNonce"
46
+ );
47
+ }
48
+
49
+ /**
50
+ * @access public
51
+ *
52
+ */
53
+ public function find($nonce)
54
+ {
55
+ try {
56
+ $path = $this->_config->merchantPath() . '/payment_method_nonces/' . $nonce;
57
+ $response = $this->_http->get($path);
58
+ return PaymentMethodNonce::factory($response['paymentMethodNonce']);
59
+ } catch (Exception\NotFound $e) {
60
+ throw new Exception\NotFound(
61
+ 'payment method nonce with id ' . $nonce . ' not found'
62
+ );
63
+ }
64
+
65
+ }
66
+ }
67
+ class_alias('Braintree\PaymentMethodNonceGateway', 'Braintree_PaymentMethodNonceGateway');
lib/braintree/lib/Braintree/Plan.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class Plan extends Base
5
+ {
6
+ public static function factory($attributes)
7
+ {
8
+ $instance = new self();
9
+ $instance->_initialize($attributes);
10
+
11
+ return $instance;
12
+ }
13
+
14
+ protected function _initialize($attributes)
15
+ {
16
+ $this->_attributes = $attributes;
17
+
18
+ $addOnArray = [];
19
+ if (isset($attributes['addOns'])) {
20
+ foreach ($attributes['addOns'] AS $addOn) {
21
+ $addOnArray[] = AddOn::factory($addOn);
22
+ }
23
+ }
24
+ $this->_attributes['addOns'] = $addOnArray;
25
+
26
+ $discountArray = [];
27
+ if (isset($attributes['discounts'])) {
28
+ foreach ($attributes['discounts'] AS $discount) {
29
+ $discountArray[] = Discount::factory($discount);
30
+ }
31
+ }
32
+ $this->_attributes['discounts'] = $discountArray;
33
+
34
+ $planArray = [];
35
+ if (isset($attributes['plans'])) {
36
+ foreach ($attributes['plans'] AS $plan) {
37
+ $planArray[] = self::factory($plan);
38
+ }
39
+ }
40
+ $this->_attributes['plans'] = $planArray;
41
+ }
42
+
43
+
44
+ // static methods redirecting to gateway
45
+
46
+ public static function all()
47
+ {
48
+ return Configuration::gateway()->plan()->all();
49
+ }
50
+ }
51
+ class_alias('Braintree\Plan', 'Braintree_Plan');
lib/braintree/lib/Braintree/PlanGateway.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class PlanGateway
5
+ {
6
+ private $_gateway;
7
+ private $_config;
8
+ private $_http;
9
+
10
+ public function __construct($gateway)
11
+ {
12
+ $this->_gateway = $gateway;
13
+ $this->_config = $gateway->config;
14
+ $this->_config->assertHasAccessTokenOrKeys();
15
+ $this->_http = new Http($gateway->config);
16
+ }
17
+
18
+ public function all()
19
+ {
20
+ $path = $this->_config->merchantPath() . '/plans';
21
+ $response = $this->_http->get($path);
22
+ if (key_exists('plans', $response)){
23
+ $plans = ["plan" => $response['plans']];
24
+ } else {
25
+ $plans = ["plan" => []];
26
+ }
27
+
28
+ return Util::extractAttributeAsArray(
29
+ $plans,
30
+ 'plan'
31
+ );
32
+ }
33
+ }
34
+ class_alias('Braintree\PlanGateway', 'Braintree_PlanGateway');
lib/braintree/lib/Braintree/RangeNode.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class RangeNode
5
+ {
6
+ public function __construct($name)
7
+ {
8
+ $this->name = $name;
9
+ $this->searchTerms = [];
10
+ }
11
+
12
+ public function greaterThanOrEqualTo($value)
13
+ {
14
+ $this->searchTerms['min'] = $value;
15
+ return $this;
16
+ }
17
+
18
+ public function lessThanOrEqualTo($value)
19
+ {
20
+ $this->searchTerms['max'] = $value;
21
+ return $this;
22
+ }
23
+
24
+ public function is($value)
25
+ {
26
+ $this->searchTerms['is'] = $value;
27
+ return $this;
28
+ }
29
+
30
+ public function between($min, $max)
31
+ {
32
+ return $this->greaterThanOrEqualTo($min)->lessThanOrEqualTo($max);
33
+ }
34
+
35
+ public function toParam()
36
+ {
37
+ return $this->searchTerms;
38
+ }
39
+ }
40
+ class_alias('Braintree\RangeNode', 'Braintree_RangeNode');
lib/braintree/lib/Braintree/ResourceCollection.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use Iterator;
5
+
6
+ /**
7
+ * Braintree ResourceCollection
8
+ * ResourceCollection is a container object for result data
9
+ *
10
+ * stores and retrieves search results and aggregate data
11
+ *
12
+ * example:
13
+ * <code>
14
+ * $result = Customer::all();
15
+ *
16
+ * foreach($result as $transaction) {
17
+ * print_r($transaction->id);
18
+ * }
19
+ * </code>
20
+ *
21
+ * @package Braintree
22
+ * @subpackage Utility
23
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
24
+ */
25
+ class ResourceCollection implements Iterator
26
+ {
27
+ private $_batchIndex;
28
+ private $_ids;
29
+ private $_index;
30
+ private $_items;
31
+ private $_pageSize;
32
+ private $_pager;
33
+
34
+ /**
35
+ * set up the resource collection
36
+ *
37
+ * expects an array of attributes with literal keys
38
+ *
39
+ * @param array $response
40
+ * @param array $pager
41
+ */
42
+ public function __construct($response, $pager)
43
+ {
44
+ $this->_pageSize = $response["searchResults"]["pageSize"];
45
+ $this->_ids = $response["searchResults"]["ids"];
46
+ $this->_pager = $pager;
47
+ }
48
+
49
+ /**
50
+ * returns the current item when iterating with foreach
51
+ */
52
+ public function current()
53
+ {
54
+ return $this->_items[$this->_index];
55
+ }
56
+
57
+ /**
58
+ * returns the first item in the collection
59
+ *
60
+ * @return mixed
61
+ */
62
+ public function firstItem()
63
+ {
64
+ $ids = $this->_ids;
65
+ $page = $this->_getPage([$ids[0]]);
66
+ return $page[0];
67
+ }
68
+
69
+ public function key()
70
+ {
71
+ return null;
72
+ }
73
+
74
+ /**
75
+ * advances to the next item in the collection when iterating with foreach
76
+ */
77
+ public function next()
78
+ {
79
+ ++$this->_index;
80
+ }
81
+
82
+ /**
83
+ * rewinds the testIterateOverResults collection to the first item when iterating with foreach
84
+ */
85
+ public function rewind()
86
+ {
87
+ $this->_batchIndex = 0;
88
+ $this->_getNextPage();
89
+ }
90
+
91
+ /**
92
+ * returns whether the current item is valid when iterating with foreach
93
+ */
94
+ public function valid()
95
+ {
96
+ if ($this->_index == count($this->_items) && $this->_batchIndex < count($this->_ids)) {
97
+ $this->_getNextPage();
98
+ }
99
+
100
+ if ($this->_index < count($this->_items)) {
101
+ return true;
102
+ } else {
103
+ return false;
104
+ }
105
+ }
106
+
107
+ public function maximumCount()
108
+ {
109
+ return count($this->_ids);
110
+ }
111
+
112
+ private function _getNextPage()
113
+ {
114
+ if (empty($this->_ids))
115
+ {
116
+ $this->_items = [];
117
+ }
118
+ else
119
+ {
120
+ $this->_items = $this->_getPage(array_slice($this->_ids, $this->_batchIndex, $this->_pageSize));
121
+ $this->_batchIndex += $this->_pageSize;
122
+ $this->_index = 0;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * requests the next page of results for the collection
128
+ *
129
+ * @return void
130
+ */
131
+ private function _getPage($ids)
132
+ {
133
+ $object = $this->_pager['object'];
134
+ $method = $this->_pager['method'];
135
+ $methodArgs = [];
136
+ foreach ($this->_pager['methodArgs'] as $arg) {
137
+ array_push($methodArgs, $arg);
138
+ }
139
+ array_push($methodArgs, $ids);
140
+
141
+ return call_user_func_array(
142
+ [$object, $method],
143
+ $methodArgs
144
+ );
145
+ }
146
+
147
+ /**
148
+ * returns all IDs in the collection
149
+ *
150
+ * @return array
151
+ */
152
+ public function getIds()
153
+ {
154
+ return $this->_ids;
155
+ }
156
+ }
157
+ class_alias('Braintree\ResourceCollection', 'Braintree_ResourceCollection');
lib/braintree/lib/Braintree/Result/CreditCardVerification.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Result;
3
+
4
+ use Braintree\RiskData;
5
+ use Braintree\Util;
6
+
7
+ /**
8
+ * Braintree Credit Card Verification Result
9
+ *
10
+ * This object is returned as part of an Error Result; it provides
11
+ * access to the credit card verification data from the gateway
12
+ *
13
+ *
14
+ * @package Braintree
15
+ * @subpackage Result
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
+ *
18
+ * @property-read string $avsErrorResponseCode
19
+ * @property-read string $avsPostalCodeResponseCode
20
+ * @property-read string $avsStreetAddressResponseCode
21
+ * @property-read string $cvvResponseCode
22
+ * @property-read string $status
23
+ *
24
+ */
25
+ class CreditCardVerification
26
+ {
27
+ // Status
28
+ const FAILED = 'failed';
29
+ const GATEWAY_REJECTED = 'gateway_rejected';
30
+ const PROCESSOR_DECLINED = 'processor_declined';
31
+ const VERIFIED = 'verified';
32
+
33
+ private $_attributes;
34
+ private $_avsErrorResponseCode;
35
+ private $_avsPostalCodeResponseCode;
36
+ private $_avsStreetAddressResponseCode;
37
+ private $_cvvResponseCode;
38
+ private $_gatewayRejectionReason;
39
+ private $_status;
40
+
41
+ /**
42
+ * @ignore
43
+ */
44
+ public function __construct($attributes)
45
+ {
46
+ $this->_initializeFromArray($attributes);
47
+ }
48
+
49
+ /**
50
+ * initializes instance properties from the keys/values of an array
51
+ * @ignore
52
+ * @access protected
53
+ * @param <type> $aAttribs array of properties to set - single level
54
+ * @return void
55
+ */
56
+ private function _initializeFromArray($attributes)
57
+ {
58
+ if(isset($attributes['riskData']))
59
+ {
60
+ $attributes['riskData'] = RiskData::factory($attributes['riskData']);
61
+ }
62
+
63
+ $this->_attributes = $attributes;
64
+ foreach($attributes AS $name => $value) {
65
+ $varName = "_$name";
66
+ $this->$varName = $value;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * @ignore
72
+ */
73
+ public function __get($name)
74
+ {
75
+ $varName = "_$name";
76
+ return isset($this->$varName) ? $this->$varName : null;
77
+ }
78
+
79
+ /**
80
+ * returns a string representation of the customer
81
+ * @return string
82
+ */
83
+ public function __toString()
84
+ {
85
+ return __CLASS__ . '[' .
86
+ Util::attributesToString($this->_attributes) . ']';
87
+ }
88
+
89
+ public static function allStatuses()
90
+ {
91
+ return [
92
+ CreditCardVerification::FAILED,
93
+ CreditCardVerification::GATEWAY_REJECTED,
94
+ CreditCardVerification::PROCESSOR_DECLINED,
95
+ CreditCardVerification::VERIFIED
96
+ ];
97
+ }
98
+ }
99
+ class_alias('Braintree\Result\CreditCardVerification', 'Braintree_Result_CreditCardVerification');
lib/braintree/lib/Braintree/Result/Error.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Result;
3
+
4
+ use Braintree\Base;
5
+ use Braintree\Transaction;
6
+ use Braintree\Subscription;
7
+ use Braintree\MerchantAccount;
8
+ use Braintree\Util;
9
+ use Braintree\Error\ErrorCollection;
10
+
11
+ /**
12
+ * Braintree Error Result
13
+ *
14
+ * An Error Result will be returned from gateway methods when
15
+ * the gateway responds with an error. It will provide access
16
+ * to the original request.
17
+ * For example, when voiding a transaction, Error Result will
18
+ * respond to the void request if it failed:
19
+ *
20
+ * <code>
21
+ * $result = Transaction::void('abc123');
22
+ * if ($result->success) {
23
+ * // Successful Result
24
+ * } else {
25
+ * // Result\Error
26
+ * }
27
+ * </code>
28
+ *
29
+ * @package Braintree
30
+ * @subpackage Result
31
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
32
+ *
33
+ * @property-read array $params original passed params
34
+ * @property-read \Braintree\Error\ErrorCollection $errors
35
+ * @property-read \Braintree\Result\CreditCardVerification $creditCardVerification credit card verification data
36
+ */
37
+ class Error extends Base
38
+ {
39
+ /**
40
+ * @var bool always false
41
+ */
42
+ public $success = false;
43
+
44
+ /**
45
+ * return original value for a field
46
+ * For example, if a user tried to submit 'invalid-email' in the html field transaction[customer][email],
47
+ * $result->valueForHtmlField("transaction[customer][email]") would yield "invalid-email"
48
+ *
49
+ * @param string $field
50
+ * @return string
51
+ */
52
+ public function valueForHtmlField($field)
53
+ {
54
+ $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
55
+ $params = $this->params;
56
+ foreach(array_slice($pieces, 0, -1) as $key) {
57
+ $params = $params[Util::delimiterToCamelCase($key)];
58
+ }
59
+ if ($key != 'custom_fields') {
60
+ $finalKey = Util::delimiterToCamelCase(end($pieces));
61
+ } else {
62
+ $finalKey = end($pieces);
63
+ }
64
+ $fieldValue = isset($params[$finalKey]) ? $params[$finalKey] : null;
65
+ return $fieldValue;
66
+ }
67
+
68
+ /**
69
+ * overrides default constructor
70
+ * @ignore
71
+ * @param array $response gateway response array
72
+ */
73
+ public function __construct($response)
74
+ {
75
+ $this->_attributes = $response;
76
+ $this->_set('errors', new ErrorCollection($response['errors']));
77
+
78
+ if(isset($response['verification'])) {
79
+ $this->_set('creditCardVerification', new CreditCardVerification($response['verification']));
80
+ } else {
81
+ $this->_set('creditCardVerification', null);
82
+ }
83
+
84
+ if(isset($response['transaction'])) {
85
+ $this->_set('transaction', Transaction::factory($response['transaction']));
86
+ } else {
87
+ $this->_set('transaction', null);
88
+ }
89
+
90
+ if(isset($response['subscription'])) {
91
+ $this->_set('subscription', Subscription::factory($response['subscription']));
92
+ } else {
93
+ $this->_set('subscription', null);
94
+ }
95
+
96
+ if(isset($response['merchantAccount'])) {
97
+ $this->_set('merchantAccount', MerchantAccount::factory($response['merchantAccount']));
98
+ } else {
99
+ $this->_set('merchantAccount', null);
100
+ }
101
+
102
+ if(isset($response['verification'])) {
103
+ $this->_set('verification', new CreditCardVerification($response['verification']));
104
+ } else {
105
+ $this->_set('verification', null);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * create a printable representation of the object as:
111
+ * ClassName[property=value, property=value]
112
+ * @ignore
113
+ * @return string
114
+ */
115
+ public function __toString()
116
+ {
117
+ $output = Util::attributesToString($this->_attributes);
118
+ if (isset($this->_creditCardVerification)) {
119
+ $output .= sprintf('%s', $this->_creditCardVerification);
120
+ }
121
+ return __CLASS__ .'[' . $output . ']';
122
+ }
123
+ }
124
+ class_alias('Braintree\Result\Error', 'Braintree_Result_Error');
lib/braintree/lib/Braintree/Result/Successful.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Result;
3
+
4
+ use Braintree\Instance;
5
+ use Braintree\Util;
6
+
7
+ /**
8
+ * Braintree Successful Result
9
+ *
10
+ * A Successful Result will be returned from gateway methods when
11
+ * validations pass. It will provide access to the created resource.
12
+ *
13
+ * For example, when creating a customer, Successful will
14
+ * respond to <b>customer</b> like so:
15
+ *
16
+ * <code>
17
+ * $result = Customer::create(array('first_name' => "John"));
18
+ * if ($result->success) {
19
+ * // Successful
20
+ * echo "Created customer {$result->customer->id}";
21
+ * } else {
22
+ * // Error
23
+ * }
24
+ * </code>
25
+ *
26
+ *
27
+ * @package Braintree
28
+ * @subpackage Result
29
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
30
+ */
31
+ class Successful extends Instance
32
+ {
33
+ /**
34
+ *
35
+ * @var boolean always true
36
+ */
37
+ public $success = true;
38
+ /**
39
+ *
40
+ * @var string stores the internal name of the object providing access to
41
+ */
42
+ private $_returnObjectNames;
43
+
44
+ /**
45
+ * @ignore
46
+ * @param array|null $objsToReturn
47
+ * @param array|null $propertyNames
48
+ */
49
+ public function __construct($objsToReturn = [], $propertyNames = [])
50
+ {
51
+ // Sanitize arguments (preserves backwards compatibility)
52
+ if (!is_array($objsToReturn)) { $objsToReturn = [$objsToReturn]; }
53
+ if (!is_array($propertyNames)) { $propertyNames = [$propertyNames]; }
54
+
55
+ $objects = $this->_mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn);
56
+ $this->_attributes = [];
57
+ $this->_returnObjectNames = [];
58
+
59
+ foreach ($objects as $propertyName => $objToReturn) {
60
+
61
+ // save the name for indirect access
62
+ array_push($this->_returnObjectNames, $propertyName);
63
+
64
+ // create the property!
65
+ $this->$propertyName = $objToReturn;
66
+ }
67
+ }
68
+
69
+ /**
70
+ *
71
+ * @ignore
72
+ * @return string string representation of the object's structure
73
+ */
74
+ public function __toString()
75
+ {
76
+ $objects = [];
77
+ foreach ($this->_returnObjectNames as $returnObjectName) {
78
+ array_push($objects, $this->$returnObjectName);
79
+ }
80
+ return __CLASS__ . '[' . implode(', ', $objects) . ']';
81
+ }
82
+
83
+ private function _mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn) {
84
+ if(count($objsToReturn) != count($propertyNames)) {
85
+ $propertyNames = [];
86
+ foreach ($objsToReturn as $obj) {
87
+ array_push($propertyNames, Util::cleanClassName(get_class($obj)));
88
+ }
89
+ }
90
+ return array_combine($propertyNames, $objsToReturn);
91
+ }
92
+ }
93
+ class_alias('Braintree\Result\Successful', 'Braintree_Result_Successful');
lib/braintree/lib/Braintree/RiskData.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class RiskData extends Base
5
+ {
6
+ public static function factory($attributes)
7
+ {
8
+ $instance = new self();
9
+ $instance->_initialize($attributes);
10
+
11
+ return $instance;
12
+ }
13
+
14
+ protected function _initialize($attributes)
15
+ {
16
+ $this->_attributes = $attributes;
17
+ }
18
+
19
+ /**
20
+ * returns a string representation of the risk data
21
+ * @return string
22
+ */
23
+ public function __toString()
24
+ {
25
+ return __CLASS__ . '[' .
26
+ Util::attributesToString($this->_attributes) .']';
27
+ }
28
+
29
+ }
30
+ class_alias('Braintree\RiskData', 'Braintree_RiskData');
lib/braintree/lib/Braintree/SettlementBatchSummary.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class SettlementBatchSummary extends Base
5
+ {
6
+ /**
7
+ *
8
+ * @param array $attributes
9
+ * @return SettlementBatchSummary
10
+ */
11
+ public static function factory($attributes)
12
+ {
13
+ $instance = new self();
14
+ $instance->_initialize($attributes);
15
+ return $instance;
16
+ }
17
+
18
+ /**
19
+ * @ignore
20
+ * @param array $attributes
21
+ */
22
+ protected function _initialize($attributes)
23
+ {
24
+ $this->_attributes = $attributes;
25
+ }
26
+
27
+ public function records()
28
+ {
29
+ return $this->_attributes['records'];
30
+ }
31
+
32
+
33
+ /**
34
+ * static method redirecting to gateway
35
+ *
36
+ * @param string $settlement_date Date YYYY-MM-DD
37
+ * @param string $groupByCustomField
38
+ * @return Result\Successful|Result\Error
39
+ */
40
+ public static function generate($settlement_date, $groupByCustomField = NULL)
41
+ {
42
+ return Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField);
43
+ }
44
+ }
45
+ class_alias('Braintree\SettlementBatchSummary', 'Braintree_SettlementBatchSummary');
lib/braintree/lib/Braintree/SettlementBatchSummaryGateway.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class SettlementBatchSummaryGateway
5
+ {
6
+ /**
7
+ *
8
+ * @var Gateway
9
+ */
10
+ private $_gateway;
11
+
12
+ /**
13
+ *
14
+ * @var Configuration
15
+ */
16
+ private $_config;
17
+
18
+ /**
19
+ *
20
+ * @var Http
21
+ */
22
+ private $_http;
23
+
24
+ /**
25
+ *
26
+ * @param Gateway $gateway
27
+ */
28
+ public function __construct($gateway)
29
+ {
30
+ $this->_gateway = $gateway;
31
+ $this->_config = $gateway->config;
32
+ $this->_config->assertHasAccessTokenOrKeys();
33
+ $this->_http = new Http($gateway->config);
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @param string $settlement_date
39
+ * @param string $groupByCustomField
40
+ * @return SettlementBatchSummary|Result\Error
41
+ */
42
+ public function generate($settlement_date, $groupByCustomField = NULL)
43
+ {
44
+ $criteria = ['settlement_date' => $settlement_date];
45
+ if (isset($groupByCustomField))
46
+ {
47
+ $criteria['group_by_custom_field'] = $groupByCustomField;
48
+ }
49
+ $params = ['settlement_batch_summary' => $criteria];
50
+ $path = $this->_config->merchantPath() . '/settlement_batch_summary';
51
+ $response = $this->_http->post($path, $params);
52
+
53
+ if (isset($groupByCustomField))
54
+ {
55
+ $response['settlementBatchSummary']['records'] = $this->_underscoreCustomField(
56
+ $groupByCustomField,
57
+ $response['settlementBatchSummary']['records']
58
+ );
59
+ }
60
+
61
+ return $this->_verifyGatewayResponse($response);
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @param string $groupByCustomField
67
+ * @param array $records
68
+ * @return array
69
+ */
70
+ private function _underscoreCustomField($groupByCustomField, $records)
71
+ {
72
+ $updatedRecords = [];
73
+
74
+ foreach ($records as $record)
75
+ {
76
+ $camelized = Util::delimiterToCamelCase($groupByCustomField);
77
+ $record[$groupByCustomField] = $record[$camelized];
78
+ unset($record[$camelized]);
79
+ $updatedRecords[] = $record;
80
+ }
81
+
82
+ return $updatedRecords;
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @param array $response
88
+ * @return Result\Successful|Result\Error
89
+ * @throws Exception\Unexpected
90
+ */
91
+ private function _verifyGatewayResponse($response)
92
+ {
93
+ if (isset($response['settlementBatchSummary'])) {
94
+ return new Result\Successful(
95
+ SettlementBatchSummary::factory($response['settlementBatchSummary'])
96
+ );
97
+ } else if (isset($response['apiErrorResponse'])) {
98
+ return new Result\Error($response['apiErrorResponse']);
99
+ } else {
100
+ throw new Exception\Unexpected(
101
+ "Expected settlementBatchSummary or apiErrorResponse"
102
+ );
103
+ }
104
+ }
105
+ }
106
+ class_alias('Braintree\SettlementBatchSummaryGateway', 'Braintree_SettlementBatchSummaryGateway');
lib/braintree/lib/Braintree/SignatureService.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class SignatureService
5
+ {
6
+
7
+ public function __construct($key, $digest)
8
+ {
9
+ $this->key = $key;
10
+ $this->digest = $digest;
11
+ }
12
+
13
+ public function sign($payload)
14
+ {
15
+ return $this->hash($payload) . "|" . $payload;
16
+ }
17
+
18
+ public function hash($data)
19
+ {
20
+ return call_user_func($this->digest, $this->key, $data);
21
+ }
22
+
23
+ }
24
+ class_alias('Braintree\SignatureService', 'Braintree_SignatureService');
lib/braintree/lib/Braintree/Subscription.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Subscription module
6
+ *
7
+ * <b>== More information ==</b>
8
+ *
9
+ * For more detailed information on Subscriptions, see {@link http://www.braintreepayments.com/gateway/subscription-api http://www.braintreepaymentsolutions.com/gateway/subscription-api}
10
+ *
11
+ * PHP Version 5
12
+ *
13
+ * @package Braintree
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ */
16
+ class Subscription extends Base
17
+ {
18
+ const ACTIVE = 'Active';
19
+ const CANCELED = 'Canceled';
20
+ const EXPIRED = 'Expired';
21
+ const PAST_DUE = 'Past Due';
22
+ const PENDING = 'Pending';
23
+
24
+ // Subscription Sources
25
+ const API = 'api';
26
+ const CONTROL_PANEL = 'control_panel';
27
+ const RECURRING = 'recurring';
28
+
29
+ /**
30
+ * @ignore
31
+ */
32
+ public static function factory($attributes)
33
+ {
34
+ $instance = new self();
35
+ $instance->_initialize($attributes);
36
+
37
+ return $instance;
38
+ }
39
+
40
+ /**
41
+ * @ignore
42
+ */
43
+ protected function _initialize($attributes)
44
+ {
45
+ $this->_attributes = $attributes;
46
+
47
+ $addOnArray = [];
48
+ if (isset($attributes['addOns'])) {
49
+ foreach ($attributes['addOns'] AS $addOn) {
50
+ $addOnArray[] = AddOn::factory($addOn);
51
+ }
52
+ }
53
+ $this->_attributes['addOns'] = $addOnArray;
54
+
55
+ $discountArray = [];
56
+ if (isset($attributes['discounts'])) {
57
+ foreach ($attributes['discounts'] AS $discount) {
58
+ $discountArray[] = Discount::factory($discount);
59
+ }
60
+ }
61
+ $this->_attributes['discounts'] = $discountArray;
62
+
63
+ if (isset($attributes['descriptor'])) {
64
+ $this->_set('descriptor', new Descriptor($attributes['descriptor']));
65
+ }
66
+
67
+ $statusHistory = [];
68
+ if (isset($attributes['statusHistory'])) {
69
+ foreach ($attributes['statusHistory'] AS $history) {
70
+ $statusHistory[] = new Subscription\StatusDetails($history);
71
+ }
72
+ }
73
+ $this->_attributes['statusHistory'] = $statusHistory;
74
+
75
+ $transactionArray = [];
76
+ if (isset($attributes['transactions'])) {
77
+ foreach ($attributes['transactions'] AS $transaction) {
78
+ $transactionArray[] = Transaction::factory($transaction);
79
+ }
80
+ }
81
+ $this->_attributes['transactions'] = $transactionArray;
82
+ }
83
+
84
+ /**
85
+ * returns a string representation of the customer
86
+ * @return string
87
+ */
88
+ public function __toString()
89
+ {
90
+ $excludedAttributes = ['statusHistory'];
91
+
92
+ $displayAttributes = [];
93
+ foreach($this->_attributes as $key => $val) {
94
+ if (!in_array($key, $excludedAttributes)) {
95
+ $displayAttributes[$key] = $val;
96
+ }
97
+ }
98
+
99
+ return __CLASS__ . '[' .
100
+ Util::attributesToString($displayAttributes) .']';
101
+ }
102
+
103
+
104
+ // static methods redirecting to gateway
105
+
106
+ public static function create($attributes)
107
+ {
108
+ return Configuration::gateway()->subscription()->create($attributes);
109
+ }
110
+
111
+ public static function find($id)
112
+ {
113
+ return Configuration::gateway()->subscription()->find($id);
114
+ }
115
+
116
+ public static function search($query)
117
+ {
118
+ return Configuration::gateway()->subscription()->search($query);
119
+ }
120
+
121
+ public static function fetch($query, $ids)
122
+ {
123
+ return Configuration::gateway()->subscription()->fetch($query, $ids);
124
+ }
125
+
126
+ public static function update($subscriptionId, $attributes)
127
+ {
128
+ return Configuration::gateway()->subscription()->update($subscriptionId, $attributes);
129
+ }
130
+
131
+ public static function retryCharge($subscriptionId, $amount = null)
132
+ {
133
+ return Configuration::gateway()->subscription()->retryCharge($subscriptionId, $amount);
134
+ }
135
+
136
+ public static function cancel($subscriptionId)
137
+ {
138
+ return Configuration::gateway()->subscription()->cancel($subscriptionId);
139
+ }
140
+ }
141
+ class_alias('Braintree\Subscription', 'Braintree_Subscription');
lib/braintree/lib/Braintree/Subscription/StatusDetails.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Subscription;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Status details from a subscription
8
+ * Creates an instance of StatusDetails, as part of a subscription response
9
+ *
10
+ * @package Braintree
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ *
13
+ * @property-read string $price
14
+ * @property-read string $currencyIsoCode
15
+ * @property-read string $planId
16
+ * @property-read string $balance
17
+ * @property-read string $status
18
+ * @property-read string $timestamp
19
+ * @property-read string $subscriptionSource
20
+ * @property-read string $user
21
+ */
22
+ class StatusDetails extends Instance
23
+ {
24
+ }
25
+ class_alias('Braintree\Subscription\StatusDetails', 'Braintree_Subscription_StatusDetails');
lib/braintree/lib/Braintree/SubscriptionGateway.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree SubscriptionGateway module
8
+ *
9
+ * <b>== More information ==</b>
10
+ *
11
+ * For more detailed information on Subscriptions, see {@link http://www.braintreepayments.com/gateway/subscription-api http://www.braintreepaymentsolutions.com/gateway/subscription-api}
12
+ *
13
+ * PHP Version 5
14
+ *
15
+ * @package Braintree
16
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
17
+ */
18
+ class SubscriptionGateway
19
+ {
20
+ private $_gateway;
21
+ private $_config;
22
+ private $_http;
23
+
24
+ public function __construct($gateway)
25
+ {
26
+ $this->_gateway = $gateway;
27
+ $this->_config = $gateway->config;
28
+ $this->_config->assertHasAccessTokenOrKeys();
29
+ $this->_http = new Http($gateway->config);
30
+ }
31
+
32
+ public function create($attributes)
33
+ {
34
+ Util::verifyKeys(self::_createSignature(), $attributes);
35
+ $path = $this->_config->merchantPath() . '/subscriptions';
36
+ $response = $this->_http->post($path, ['subscription' => $attributes]);
37
+ return $this->_verifyGatewayResponse($response);
38
+ }
39
+
40
+ public function find($id)
41
+ {
42
+ $this->_validateId($id);
43
+
44
+ try {
45
+ $path = $this->_config->merchantPath() . '/subscriptions/' . $id;
46
+ $response = $this->_http->get($path);
47
+ return Subscription::factory($response['subscription']);
48
+ } catch (Exception\NotFound $e) {
49
+ throw new Exception\NotFound('subscription with id ' . $id . ' not found');
50
+ }
51
+
52
+ }
53
+
54
+ public function search($query)
55
+ {
56
+ $criteria = [];
57
+ foreach ($query as $term) {
58
+ $criteria[$term->name] = $term->toparam();
59
+ }
60
+
61
+
62
+ $path = $this->_config->merchantPath() . '/subscriptions/advanced_search_ids';
63
+ $response = $this->_http->post($path, ['search' => $criteria]);
64
+ $pager = [
65
+ 'object' => $this,
66
+ 'method' => 'fetch',
67
+ 'methodArgs' => [$query]
68
+ ];
69
+
70
+ return new ResourceCollection($response, $pager);
71
+ }
72
+
73
+ public function fetch($query, $ids)
74
+ {
75
+ $criteria = [];
76
+ foreach ($query as $term) {
77
+ $criteria[$term->name] = $term->toparam();
78
+ }
79
+ $criteria["ids"] = SubscriptionSearch::ids()->in($ids)->toparam();
80
+ $path = $this->_config->merchantPath() . '/subscriptions/advanced_search';
81
+ $response = $this->_http->post($path, ['search' => $criteria]);
82
+
83
+ return Util::extractAttributeAsArray(
84
+ $response['subscriptions'],
85
+ 'subscription'
86
+ );
87
+ }
88
+
89
+ public function update($subscriptionId, $attributes)
90
+ {
91
+ Util::verifyKeys(self::_updateSignature(), $attributes);
92
+ $path = $this->_config->merchantPath() . '/subscriptions/' . $subscriptionId;
93
+ $response = $this->_http->put($path, ['subscription' => $attributes]);
94
+ return $this->_verifyGatewayResponse($response);
95
+ }
96
+
97
+ public function retryCharge($subscriptionId, $amount = null)
98
+ {
99
+ $transaction_params = ['type' => Transaction::SALE,
100
+ 'subscriptionId' => $subscriptionId];
101
+ if (isset($amount)) {
102
+ $transaction_params['amount'] = $amount;
103
+ }
104
+
105
+ $path = $this->_config->merchantPath() . '/transactions';
106
+ $response = $this->_http->post($path, ['transaction' => $transaction_params]);
107
+ return $this->_verifyGatewayResponse($response);
108
+ }
109
+
110
+ public function cancel($subscriptionId)
111
+ {
112
+ $path = $this->_config->merchantPath() . '/subscriptions/' . $subscriptionId . '/cancel';
113
+ $response = $this->_http->put($path);
114
+ return $this->_verifyGatewayResponse($response);
115
+ }
116
+
117
+ private static function _createSignature()
118
+ {
119
+ return array_merge(
120
+ [
121
+ 'billingDayOfMonth',
122
+ 'firstBillingDate',
123
+ 'createdAt',
124
+ 'updatedAt',
125
+ 'id',
126
+ 'merchantAccountId',
127
+ 'neverExpires',
128
+ 'numberOfBillingCycles',
129
+ 'paymentMethodToken',
130
+ 'paymentMethodNonce',
131
+ 'planId',
132
+ 'price',
133
+ 'trialDuration',
134
+ 'trialDurationUnit',
135
+ 'trialPeriod',
136
+ ['descriptor' => ['name', 'phone', 'url']],
137
+ ['options' => ['doNotInheritAddOnsOrDiscounts', 'startImmediately']],
138
+ ],
139
+ self::_addOnDiscountSignature()
140
+ );
141
+ }
142
+
143
+ private static function _updateSignature()
144
+ {
145
+ return array_merge(
146
+ [
147
+ 'merchantAccountId', 'numberOfBillingCycles', 'paymentMethodToken', 'planId',
148
+ 'paymentMethodNonce', 'id', 'neverExpires', 'price',
149
+ ['descriptor' => ['name', 'phone', 'url']],
150
+ ['options' => ['prorateCharges', 'replaceAllAddOnsAndDiscounts', 'revertSubscriptionOnProrationFailure']],
151
+ ],
152
+ self::_addOnDiscountSignature()
153
+ );
154
+ }
155
+
156
+ private static function _addOnDiscountSignature()
157
+ {
158
+ return [
159
+ [
160
+ 'addOns' => [
161
+ ['add' => ['amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity']],
162
+ ['update' => ['amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity']],
163
+ ['remove' => ['_anyKey_']],
164
+ ]
165
+ ],
166
+ [
167
+ 'discounts' => [
168
+ ['add' => ['amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity']],
169
+ ['update' => ['amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity']],
170
+ ['remove' => ['_anyKey_']],
171
+ ]
172
+ ]
173
+ ];
174
+ }
175
+
176
+ /**
177
+ * @ignore
178
+ */
179
+ private function _validateId($id = null) {
180
+ if (empty($id)) {
181
+ throw new InvalidArgumentException(
182
+ 'expected subscription id to be set'
183
+ );
184
+ }
185
+ if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
186
+ throw new InvalidArgumentException(
187
+ $id . ' is an invalid subscription id.'
188
+ );
189
+ }
190
+ }
191
+
192
+ /**
193
+ * @ignore
194
+ */
195
+ private function _verifyGatewayResponse($response)
196
+ {
197
+ if (isset($response['subscription'])) {
198
+ return new Result\Successful(
199
+ Subscription::factory($response['subscription'])
200
+ );
201
+ } else if (isset($response['transaction'])) {
202
+ // return a populated instance of Transaction, for subscription retryCharge
203
+ return new Result\Successful(
204
+ Transaction::factory($response['transaction'])
205
+ );
206
+ } else if (isset($response['apiErrorResponse'])) {
207
+ return new Result\Error($response['apiErrorResponse']);
208
+ } else {
209
+ throw new Exception\Unexpected(
210
+ "Expected subscription, transaction, or apiErrorResponse"
211
+ );
212
+ }
213
+ }
214
+ }
215
+ class_alias('Braintree\SubscriptionGateway', 'Braintree_SubscriptionGateway');
lib/braintree/lib/Braintree/SubscriptionSearch.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class SubscriptionSearch
5
+ {
6
+ public static function billingCyclesRemaining()
7
+ {
8
+ return new RangeNode('billing_cycles_remaining');
9
+ }
10
+
11
+ public static function daysPastDue()
12
+ {
13
+ return new RangeNode('days_past_due');
14
+ }
15
+
16
+ public static function id()
17
+ {
18
+ return new TextNode('id');
19
+ }
20
+
21
+ public static function inTrialPeriod()
22
+ {
23
+ return new MultipleValueNode('in_trial_period', [true, false]);
24
+ }
25
+
26
+ public static function merchantAccountId()
27
+ {
28
+ return new MultipleValueNode('merchant_account_id');
29
+ }
30
+
31
+ public static function nextBillingDate()
32
+ {
33
+ return new RangeNode('next_billing_date');
34
+ }
35
+
36
+ public static function planId()
37
+ {
38
+ return new MultipleValueOrTextNode('plan_id');
39
+ }
40
+
41
+ public static function price()
42
+ {
43
+ return new RangeNode('price');
44
+ }
45
+
46
+ public static function status()
47
+ {
48
+ return new MultipleValueNode('status', [
49
+ Subscription::ACTIVE,
50
+ Subscription::CANCELED,
51
+ Subscription::EXPIRED,
52
+ Subscription::PAST_DUE,
53
+ Subscription::PENDING,
54
+ ]);
55
+ }
56
+
57
+ public static function transactionId()
58
+ {
59
+ return new TextNode('transaction_id');
60
+ }
61
+
62
+ public static function ids()
63
+ {
64
+ return new MultipleValueNode('ids');
65
+ }
66
+
67
+ public static function createdAt()
68
+ {
69
+ return new RangeNode('created_at');
70
+ }
71
+ }
72
+ class_alias('Braintree\SubscriptionSearch', 'Braintree_SubscriptionSearch');
lib/braintree/lib/Braintree/Test/CreditCardNumbers.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Test;
3
+
4
+ /**
5
+ * Credit card information used for testing purposes
6
+ *
7
+ * The constants contained in the Test\CreditCardNumbers class provide
8
+ * credit card numbers that should be used when working in the sandbox environment.
9
+ * The sandbox will not accept any credit card numbers other than the ones listed below.
10
+ *
11
+ * @package Braintree
12
+ * @subpackage Test
13
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
14
+ */
15
+ class CreditCardNumbers
16
+ {
17
+ public static $amExes = [
18
+ '378282246310005',
19
+ '371449635398431',
20
+ '378734493671000',
21
+ ];
22
+ public static $carteBlanches = ['30569309025904',];
23
+ public static $dinersClubs = ['38520000023237',];
24
+ public static $discoverCards = [
25
+ '6011111111111117',
26
+ '6011000990139424',
27
+ ];
28
+ public static $JCBs = [
29
+ '3530111333300000',
30
+ '3566002020360505',
31
+ ];
32
+
33
+ public static $masterCard = '5555555555554444';
34
+ public static $masterCardInternational = '5105105105105100';
35
+ public static $masterCards = [
36
+ '5105105105105100',
37
+ '5555555555554444',
38
+ ];
39
+
40
+ public static $visa = '4012888888881881';
41
+ public static $visaInternational = '4009348888881881';
42
+ public static $visas = [
43
+ '4009348888881881',
44
+ '4012888888881881',
45
+ '4111111111111111',
46
+ '4000111111111115',
47
+ ];
48
+
49
+ public static $unknowns = [
50
+ '1000000000000008',
51
+ ];
52
+
53
+ public static $failsSandboxVerification = [
54
+ 'AmEx' => '378734493671000',
55
+ 'Discover' => '6011000990139424',
56
+ 'MasterCard' => '5105105105105100',
57
+ 'Visa' => '4000111111111115',
58
+ ];
59
+
60
+ public static $amexPayWithPoints = [
61
+ 'Success' => "371260714673002",
62
+ 'IneligibleCard' => "378267515471109",
63
+ 'InsufficientPoints' => "371544868764018",
64
+ ];
65
+
66
+ public static function getAll()
67
+ {
68
+ return array_merge(
69
+ self::$amExes,
70
+ self::$discoverCards,
71
+ self::$masterCards,
72
+ self::$visas
73
+ );
74
+ }
75
+ }
76
+ class_alias('Braintree\Test\CreditCardNumbers', 'Braintree_Test_CreditCardNumbers');
lib/braintree/lib/Braintree/Test/MerchantAccount.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Test;
3
+
4
+ /**
5
+ * Merchant Account constants used for testing purposes
6
+ *
7
+ * @package Braintree
8
+ * @subpackage Test
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+ class MerchantAccount
12
+ {
13
+ public static $approve = "approve_me";
14
+
15
+ public static $insufficientFundsContactUs = "insufficient_funds__contact";
16
+ public static $accountNotAuthorizedContactUs = "account_not_authorized__contact";
17
+ public static $bankRejectedUpdateFundingInformation = "bank_rejected__update";
18
+ public static $bankRejectedNone = "bank_rejected__none";
19
+
20
+
21
+ }
22
+ class_alias('Braintree\Test\MerchantAccount', 'Braintree_Test_MerchantAccount');
lib/braintree/lib/Braintree/Test/Nonces.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Test;
3
+
4
+ /**
5
+ * Nonces used for testing purposes
6
+ *
7
+ * @package Braintree
8
+ * @subpackage Test
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Nonces used for testing purposes
14
+ *
15
+ * The constants in this class can be used to perform nonce operations
16
+ * with the desired status in the sandbox environment.
17
+ *
18
+ * @package Braintree
19
+ * @subpackage Test
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ */
22
+ class Nonces
23
+ {
24
+ public static $transactable = "fake-valid-nonce";
25
+ public static $consumed = "fake-consumed-nonce";
26
+ public static $paypalOneTimePayment = "fake-paypal-one-time-nonce";
27
+ public static $paypalFuturePayment = "fake-paypal-future-nonce";
28
+ public static $paypalBillingAgreement = "fake-paypal-billing-agreement-nonce";
29
+ public static $applePayVisa = "fake-apple-pay-visa-nonce";
30
+ public static $applePayMasterCard = "fake-apple-pay-visa-nonce";
31
+ public static $applePayAmEx = "fake-apple-pay-amex-nonce";
32
+ public static $androidPay = "fake-android-pay-nonce";
33
+ public static $androidPayDiscover = "fake-android-pay-discover-nonce";
34
+ public static $androidPayVisa = "fake-android-pay-visa-nonce";
35
+ public static $androidPayMasterCard = "fake-android-pay-mastercard-nonce";
36
+ public static $androidPayAmEx = "fake-android-pay-amex-nonce";
37
+ public static $amexExpressCheckout = "fake-amex-express-checkout-nonce";
38
+ public static $abstractTransactable = "fake-abstract-transactable-nonce";
39
+ public static $europe = "fake-europe-bank-account-nonce";
40
+ public static $coinbase = "fake-coinbase-nonce";
41
+ public static $transactableVisa = "fake-valid-visa-nonce";
42
+ public static $transactableAmEx = "fake-valid-amex-nonce";
43
+ public static $transactableMasterCard = "fake-valid-mastercard-nonce";
44
+ public static $transactableDiscover = "fake-valid-discover-nonce";
45
+ public static $transactableJCB = "fake-valid-jcb-nonce";
46
+ public static $transactableMaestro = "fake-valid-maestro-nonce";
47
+ public static $transactableDinersClub = "fake-valid-dinersclub-nonce";
48
+ public static $transactablePrepaid = "fake-valid-prepaid-nonce";
49
+ public static $transactableCommercial = "fake-valid-commercial-nonce";
50
+ public static $transactableDurbinRegulated = "fake-valid-durbin-regulated-nonce";
51
+ public static $transactableHealthcare = "fake-valid-healthcare-nonce";
52
+ public static $transactableDebit = "fake-valid-debit-nonce";
53
+ public static $transactablePayroll = "fake-valid-payroll-nonce";
54
+ public static $transactableNoIndicators = "fake-valid-no-indicators-nonce";
55
+ public static $transactableUnknownIndicators = "fake-valid-unknown-indicators-nonce";
56
+ public static $transactableCountryOfIssuanceUSA = "fake-valid-country-of-issuance-usa-nonce";
57
+ public static $transactableCountryOfIssuanceCAD = "fake-valid-country-of-issuance-cad-nonce";
58
+ public static $transactableIssuingBankNetworkOnly = "fake-valid-issuing-bank-network-only-nonce";
59
+ public static $processorDeclinedVisa = "fake-processor-declined-visa-nonce";
60
+ public static $processorDeclinedMasterCard = "fake-processor-declined-mastercard-nonce";
61
+ public static $processorDeclinedAmEx = "fake-processor-declined-amex-nonce";
62
+ public static $processorDeclinedDiscover = "fake-processor-declined-discover-nonce";
63
+ public static $processorFailureJCB = "fake-processor-failure-jcb-nonce";
64
+ public static $luhnInvalid = "fake-luhn-invalid-nonce";
65
+ public static $paypalFuturePaymentRefreshToken = "fake-paypal-future-refresh-token-nonce";
66
+ public static $sepa = "fake-sepa-bank-account-nonce";
67
+ public static $gatewayRejectedFraud = "fake-gateway-rejected-fraud-nonce";
68
+ public static $venmoAccount = "fake-venmo-account-nonce";
69
+ }
70
+ class_alias('Braintree\Test\Nonces', 'Braintree_Test_Nonces');
lib/braintree/lib/Braintree/Test/Transaction.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Test;
3
+
4
+ use Braintree\Configuration;
5
+
6
+ /**
7
+ * Transaction amounts used for testing purposes
8
+ *
9
+ * The constants in this class can be used to create transactions with
10
+ * the desired status in the sandbox environment.
11
+ *
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+ class Transaction
15
+ {
16
+ /**
17
+ * settle a transaction by id in sandbox
18
+ *
19
+ * @param string $id transaction id
20
+ * @param Configuration $config gateway config
21
+ * @return Transaction
22
+ */
23
+ public static function settle($transactionId)
24
+ {
25
+ return Configuration::gateway()->testing()->settle($transactionId);
26
+ }
27
+
28
+ /**
29
+ * settlement confirm a transaction by id in sandbox
30
+ *
31
+ * @param string $id transaction id
32
+ * @param Configuration $config gateway config
33
+ * @return Transaction
34
+ */
35
+ public static function settlementConfirm($transactionId)
36
+ {
37
+ return Configuration::gateway()->testing()->settlementConfirm($transactionId);
38
+ }
39
+
40
+ /**
41
+ * settlement decline a transaction by id in sandbox
42
+ *
43
+ * @param string $id transaction id
44
+ * @param Configuration $config gateway config
45
+ * @return Transaction
46
+ */
47
+ public static function settlementDecline($transactionId)
48
+ {
49
+ return Configuration::gateway()->testing()->settlementDecline($transactionId);
50
+ }
51
+
52
+ /**
53
+ * settlement pending a transaction by id in sandbox
54
+ *
55
+ * @param string $id transaction id
56
+ * @param Configuration $config gateway config
57
+ * @return Transaction
58
+ */
59
+ public static function settlementPending($transactionId)
60
+ {
61
+ return Configuration::gateway()->testing()->settlementPending($transactionId);
62
+ }
63
+ }
64
+ class_alias('Braintree\Test\Transaction', 'Braintree_Test_Transaction');
lib/braintree/lib/Braintree/Test/TransactionAmounts.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Test;
3
+
4
+ /**
5
+ * Transaction amounts used for testing purposes
6
+ *
7
+ * The constants in this class can be used to create transactions with
8
+ * the desired status in the sandbox environment.
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Test
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+ class TransactionAmounts
15
+ {
16
+ public static $authorize = '1000.00';
17
+ public static $decline = '2000.00';
18
+ }
19
+ class_alias('Braintree\Test\TransactionAmounts', 'Braintree_Test_TransactionAmounts');
lib/braintree/lib/Braintree/Test/VenmoSdk.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Test;
3
+
4
+ /**
5
+ * VenmoSdk payment method codes used for testing purposes
6
+ *
7
+ * @package Braintree
8
+ * @subpackage Test
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+ class VenmoSdk
12
+ {
13
+ public static $visaPaymentMethodCode = "stub-4111111111111111";
14
+
15
+ public static function generateTestPaymentMethodCode($number) {
16
+ return "stub-" . $number;
17
+ }
18
+
19
+ public static function getInvalidPaymentMethodCode() {
20
+ return "stub-invalid-payment-method-code";
21
+ }
22
+
23
+ public static function getTestSession() {
24
+ return "stub-session";
25
+ }
26
+
27
+ public static function getInvalidTestSession() {
28
+ return "stub-invalid-session";
29
+ }
30
+ }
31
+ class_alias('Braintree\Test\VenmoSdk', 'Braintree_Test_VenmoSdk');
lib/braintree/lib/Braintree/TestingGateway.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class TestingGateway
5
+ {
6
+ private $_gateway;
7
+ private $_config;
8
+ private $_http;
9
+
10
+ public function __construct($gateway)
11
+ {
12
+ $this->_gateway = $gateway;
13
+ $this->_config = $gateway->config;
14
+ $this->_http = new Http($this->_config);
15
+ }
16
+
17
+ public function settle($transactionId)
18
+ {
19
+ return self::_doTestRequest('/settle', $transactionId);
20
+ }
21
+
22
+ public function settlementPending($transactionId)
23
+ {
24
+ return self::_doTestRequest('/settlement_pending', $transactionId);
25
+ }
26
+
27
+ public function settlementConfirm($transactionId)
28
+ {
29
+ return self::_doTestRequest('/settlement_confirm', $transactionId);
30
+ }
31
+
32
+ public function settlementDecline($transactionId)
33
+ {
34
+ return self::_doTestRequest('/settlement_decline', $transactionId);
35
+ }
36
+
37
+ private function _doTestRequest($testPath, $transactionId)
38
+ {
39
+ self::_checkEnvironment();
40
+ $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . $testPath;
41
+ $response = $this->_http->put($path);
42
+ return Transaction::factory($response['transaction']);
43
+ }
44
+
45
+ private function _checkEnvironment()
46
+ {
47
+ if (Configuration::$global->getEnvironment() === 'production') {
48
+ throw new Exception\TestOperationPerformedInProduction();
49
+ }
50
+ }
51
+ }
52
+ class_alias('Braintree\TestingGateway', 'Braintree_TestingGateway');
lib/braintree/lib/Braintree/TextNode.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class TextNode extends PartialMatchNode
5
+ {
6
+ public function contains($value)
7
+ {
8
+ $this->searchTerms["contains"] = strval($value);
9
+ return $this;
10
+ }
11
+ }
12
+ class_alias('Braintree\TextNode', 'Braintree_TextNode');
lib/braintree/lib/Braintree/ThreeDSecureInfo.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class ThreeDSecureInfo extends Base
5
+ {
6
+ public static function factory($attributes)
7
+ {
8
+ $instance = new self();
9
+ $instance->_initialize($attributes);
10
+
11
+ return $instance;
12
+ }
13
+
14
+ protected function _initialize($attributes)
15
+ {
16
+ $this->_attributes = $attributes;
17
+ }
18
+
19
+ /**
20
+ * returns a string representation of the three d secure info
21
+ * @return string
22
+ */
23
+ public function __toString()
24
+ {
25
+ return __CLASS__ . '[' .
26
+ Util::attributesToString($this->_attributes) .']';
27
+ }
28
+
29
+ }
30
+ class_alias('Braintree\ThreeDSecureInfo', 'Braintree_ThreeDSecureInfo');
lib/braintree/lib/Braintree/Transaction.php ADDED
@@ -0,0 +1,570 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Transaction processor
6
+ * Creates and manages transactions
7
+ *
8
+ * At minimum, an amount, credit card number, and
9
+ * credit card expiration date are required.
10
+ *
11
+ * <b>Minimalistic example:</b>
12
+ * <code>
13
+ * Transaction::saleNoValidate(array(
14
+ * 'amount' => '100.00',
15
+ * 'creditCard' => array(
16
+ * 'number' => '5105105105105100',
17
+ * 'expirationDate' => '05/12',
18
+ * ),
19
+ * ));
20
+ * </code>
21
+ *
22
+ * <b>Full example:</b>
23
+ * <code>
24
+ * Transaction::saleNoValidate(array(
25
+ * 'amount' => '100.00',
26
+ * 'orderId' => '123',
27
+ * 'channel' => 'MyShoppingCardProvider',
28
+ * 'creditCard' => array(
29
+ * // if token is omitted, the gateway will generate a token
30
+ * 'token' => 'credit_card_123',
31
+ * 'number' => '5105105105105100',
32
+ * 'expirationDate' => '05/2011',
33
+ * 'cvv' => '123',
34
+ * ),
35
+ * 'customer' => array(
36
+ * // if id is omitted, the gateway will generate an id
37
+ * 'id' => 'customer_123',
38
+ * 'firstName' => 'Dan',
39
+ * 'lastName' => 'Smith',
40
+ * 'company' => 'Braintree',
41
+ * 'email' => 'dan@example.com',
42
+ * 'phone' => '419-555-1234',
43
+ * 'fax' => '419-555-1235',
44
+ * 'website' => 'http://braintreepayments.com'
45
+ * ),
46
+ * 'billing' => array(
47
+ * 'firstName' => 'Carl',
48
+ * 'lastName' => 'Jones',
49
+ * 'company' => 'Braintree',
50
+ * 'streetAddress' => '123 E Main St',
51
+ * 'extendedAddress' => 'Suite 403',
52
+ * 'locality' => 'Chicago',
53
+ * 'region' => 'IL',
54
+ * 'postalCode' => '60622',
55
+ * 'countryName' => 'United States of America'
56
+ * ),
57
+ * 'shipping' => array(
58
+ * 'firstName' => 'Andrew',
59
+ * 'lastName' => 'Mason',
60
+ * 'company' => 'Braintree',
61
+ * 'streetAddress' => '456 W Main St',
62
+ * 'extendedAddress' => 'Apt 2F',
63
+ * 'locality' => 'Bartlett',
64
+ * 'region' => 'IL',
65
+ * 'postalCode' => '60103',
66
+ * 'countryName' => 'United States of America'
67
+ * ),
68
+ * 'customFields' => array(
69
+ * 'birthdate' => '11/13/1954'
70
+ * )
71
+ * )
72
+ * </code>
73
+ *
74
+ * <b>== Storing in the Vault ==</b>
75
+ *
76
+ * The customer and credit card information used for
77
+ * a transaction can be stored in the vault by setting
78
+ * <i>transaction[options][storeInVault]</i> to true.
79
+ * <code>
80
+ * $transaction = Transaction::saleNoValidate(array(
81
+ * 'customer' => array(
82
+ * 'firstName' => 'Adam',
83
+ * 'lastName' => 'Williams'
84
+ * ),
85
+ * 'creditCard' => array(
86
+ * 'number' => '5105105105105100',
87
+ * 'expirationDate' => '05/2012'
88
+ * ),
89
+ * 'options' => array(
90
+ * 'storeInVault' => true
91
+ * )
92
+ * ));
93
+ *
94
+ * echo $transaction->customerDetails->id
95
+ * // '865534'
96
+ * echo $transaction->creditCardDetails->token
97
+ * // '6b6m'
98
+ * </code>
99
+ *
100
+ * To also store the billing address in the vault, pass the
101
+ * <b>addBillingAddressToPaymentMethod</b> option.
102
+ * <code>
103
+ * Transaction.saleNoValidate(array(
104
+ * ...
105
+ * 'options' => array(
106
+ * 'storeInVault' => true
107
+ * 'addBillingAddressToPaymentMethod' => true
108
+ * )
109
+ * ));
110
+ * </code>
111
+ *
112
+ * <b>== Submitting for Settlement==</b>
113
+ *
114
+ * This can only be done when the transction's
115
+ * status is <b>authorized</b>. If <b>amount</b> is not specified,
116
+ * the full authorized amount will be settled. If you would like to settle
117
+ * less than the full authorized amount, pass the desired amount.
118
+ * You cannot settle more than the authorized amount.
119
+ *
120
+ * A transaction can be submitted for settlement when created by setting
121
+ * $transaction[options][submitForSettlement] to true.
122
+ *
123
+ * <code>
124
+ * $transaction = Transaction::saleNoValidate(array(
125
+ * 'amount' => '100.00',
126
+ * 'creditCard' => array(
127
+ * 'number' => '5105105105105100',
128
+ * 'expirationDate' => '05/2012'
129
+ * ),
130
+ * 'options' => array(
131
+ * 'submitForSettlement' => true
132
+ * )
133
+ * ));
134
+ * </code>
135
+ *
136
+ * <b>== More information ==</b>
137
+ *
138
+ * For more detailed information on Transactions, see {@link http://www.braintreepayments.com/gateway/transaction-api http://www.braintreepaymentsolutions.com/gateway/transaction-api}
139
+ *
140
+ * @package Braintree
141
+ * @category Resources
142
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
143
+ *
144
+ *
145
+ * @property-read string $avsErrorResponseCode
146
+ * @property-read string $avsPostalCodeResponseCode
147
+ * @property-read string $avsStreetAddressResponseCode
148
+ * @property-read string $cvvResponseCode
149
+ * @property-read string $id transaction id
150
+ * @property-read string $amount transaction amount
151
+ * @property-read Braintree\Transaction\AddressDetails $billingDetails transaction billing address
152
+ * @property-read string $createdAt transaction created timestamp
153
+ * @property-read Braintree\ApplePayCardDetails $applePayCardDetails transaction Apple Pay card info
154
+ * @property-read Braintree\AndroidPayCardDetails $androidPayCardDetails transaction Android Pay card info
155
+ * @property-read Braintree\AmexExpressCheckoutCardDetails $amexExpressCheckoutCardDetails transaction Amex Express Checkout card info
156
+ * @property-read Braintree\CreditCardDetails $creditCardDetails transaction credit card info
157
+ * @property-read Braintree\CoinbaseDetails $coinbaseDetails transaction Coinbase account info
158
+ * @property-read Braintree\PayPalDetails $paypalDetails transaction paypal account info
159
+ * @property-read Braintree\Transaction\CustomerDetails $customerDetails transaction customer info
160
+ * @property-read Braintree\VenmoAccount $venmoAccountDetails transaction Venmo Account info
161
+ * @property-read array $customFields custom fields passed with the request
162
+ * @property-read string $processorResponseCode gateway response code
163
+ * @property-read string $additionalProcessorResponse raw response from processor
164
+ * @property-read Braintree\Transaction\AddressDetails $shippingDetails transaction shipping address
165
+ * @property-read string $status transaction status
166
+ * @property-read array $statusHistory array of StatusDetails objects
167
+ * @property-read string $type transaction type
168
+ * @property-read string $updatedAt transaction updated timestamp
169
+ * @property-read Braintree\Disbursement $disbursementDetails populated when transaction is disbursed
170
+ * @property-read Braintree\Dispute $disputes populated when transaction is disputed
171
+ *
172
+ */
173
+
174
+ class Transaction extends Base
175
+ {
176
+ // Transaction Status
177
+ const AUTHORIZATION_EXPIRED = 'authorization_expired';
178
+ const AUTHORIZING = 'authorizing';
179
+ const AUTHORIZED = 'authorized';
180
+ const GATEWAY_REJECTED = 'gateway_rejected';
181
+ const FAILED = 'failed';
182
+ const PROCESSOR_DECLINED = 'processor_declined';
183
+ const SETTLED = 'settled';
184
+ const SETTLING = 'settling';
185
+ const SUBMITTED_FOR_SETTLEMENT = 'submitted_for_settlement';
186
+ const VOIDED = 'voided';
187
+ const UNRECOGNIZED = 'unrecognized';
188
+ const SETTLEMENT_DECLINED = 'settlement_declined';
189
+ const SETTLEMENT_PENDING = 'settlement_pending';
190
+ const SETTLEMENT_CONFIRMED = 'settlement_confirmed';
191
+
192
+ // Transaction Escrow Status
193
+ const ESCROW_HOLD_PENDING = 'hold_pending';
194
+ const ESCROW_HELD = 'held';
195
+ const ESCROW_RELEASE_PENDING = 'release_pending';
196
+ const ESCROW_RELEASED = 'released';
197
+ const ESCROW_REFUNDED = 'refunded';
198
+
199
+ // Transaction Types
200
+ const SALE = 'sale';
201
+ const CREDIT = 'credit';
202
+
203
+ // Transaction Created Using
204
+ const FULL_INFORMATION = 'full_information';
205
+ const TOKEN = 'token';
206
+
207
+ // Transaction Sources
208
+ const API = 'api';
209
+ const CONTROL_PANEL = 'control_panel';
210
+ const RECURRING = 'recurring';
211
+
212
+ // Gateway Rejection Reason
213
+ const AVS = 'avs';
214
+ const AVS_AND_CVV = 'avs_and_cvv';
215
+ const CVV = 'cvv';
216
+ const DUPLICATE = 'duplicate';
217
+ const FRAUD = 'fraud';
218
+ const THREE_D_SECURE = 'three_d_secure';
219
+ const APPLICATION_INCOMPLETE = 'application_incomplete';
220
+
221
+ // Industry Types
222
+ const LODGING_INDUSTRY = 'lodging';
223
+ const TRAVEL_AND_CRUISE_INDUSTRY = 'travel_cruise';
224
+
225
+ /**
226
+ * sets instance properties from an array of values
227
+ *
228
+ * @ignore
229
+ * @access protected
230
+ * @param array $transactionAttribs array of transaction data
231
+ * @return void
232
+ */
233
+ protected function _initialize($transactionAttribs)
234
+ {
235
+ $this->_attributes = $transactionAttribs;
236
+
237
+ if (isset($transactionAttribs['applePay'])) {
238
+ $this->_set('applePayCardDetails',
239
+ new Transaction\ApplePayCardDetails(
240
+ $transactionAttribs['applePay']
241
+ )
242
+ );
243
+ }
244
+
245
+ if (isset($transactionAttribs['androidPayCard'])) {
246
+ $this->_set('androidPayCardDetails',
247
+ new Transaction\AndroidPayCardDetails(
248
+ $transactionAttribs['androidPayCard']
249
+ )
250
+ );
251
+ }
252
+
253
+ if (isset($transactionAttribs['amexExpressCheckoutCard'])) {
254
+ $this->_set('amexExpressCheckoutCardDetails',
255
+ new Transaction\AmexExpressCheckoutCardDetails(
256
+ $transactionAttribs['amexExpressCheckoutCard']
257
+ )
258
+ );
259
+ }
260
+
261
+ if (isset($transactionAttribs['venmoAccount'])) {
262
+ $this->_set('venmoAccountDetails',
263
+ new Transaction\VenmoAccountDetails(
264
+ $transactionAttribs['venmoAccount']
265
+ )
266
+ );
267
+ }
268
+
269
+ if (isset($transactionAttribs['creditCard'])) {
270
+ $this->_set('creditCardDetails',
271
+ new Transaction\CreditCardDetails(
272
+ $transactionAttribs['creditCard']
273
+ )
274
+ );
275
+ }
276
+
277
+ if (isset($transactionAttribs['coinbaseAccount'])) {
278
+ $this->_set('coinbaseDetails',
279
+ new Transaction\CoinbaseDetails(
280
+ $transactionAttribs['coinbaseAccount']
281
+ )
282
+ );
283
+ }
284
+
285
+ if (isset($transactionAttribs['europeBankAccount'])) {
286
+ $this->_set('europeBankAccount',
287
+ new Transaction\EuropeBankAccountDetails(
288
+ $transactionAttribs['europeBankAccount']
289
+ )
290
+ );
291
+ }
292
+
293
+ if (isset($transactionAttribs['usBankAccount'])) {
294
+ $this->_set('usBankAccount',
295
+ new Transaction\UsBankAccountDetails(
296
+ $transactionAttribs['usBankAccount']
297
+ )
298
+ );
299
+ }
300
+
301
+ if (isset($transactionAttribs['paypal'])) {
302
+ $this->_set('paypalDetails',
303
+ new Transaction\PayPalDetails(
304
+ $transactionAttribs['paypal']
305
+ )
306
+ );
307
+ }
308
+
309
+ if (isset($transactionAttribs['customer'])) {
310
+ $this->_set('customerDetails',
311
+ new Transaction\CustomerDetails(
312
+ $transactionAttribs['customer']
313
+ )
314
+ );
315
+ }
316
+
317
+ if (isset($transactionAttribs['billing'])) {
318
+ $this->_set('billingDetails',
319
+ new Transaction\AddressDetails(
320
+ $transactionAttribs['billing']
321
+ )
322
+ );
323
+ }
324
+
325
+ if (isset($transactionAttribs['shipping'])) {
326
+ $this->_set('shippingDetails',
327
+ new Transaction\AddressDetails(
328
+ $transactionAttribs['shipping']
329
+ )
330
+ );
331
+ }
332
+
333
+ if (isset($transactionAttribs['subscription'])) {
334
+ $this->_set('subscriptionDetails',
335
+ new Transaction\SubscriptionDetails(
336
+ $transactionAttribs['subscription']
337
+ )
338
+ );
339
+ }
340
+
341
+ if (isset($transactionAttribs['descriptor'])) {
342
+ $this->_set('descriptor',
343
+ new Descriptor(
344
+ $transactionAttribs['descriptor']
345
+ )
346
+ );
347
+ }
348
+
349
+ if (isset($transactionAttribs['disbursementDetails'])) {
350
+ $this->_set('disbursementDetails',
351
+ new DisbursementDetails($transactionAttribs['disbursementDetails'])
352
+ );
353
+ }
354
+
355
+ $disputes = [];
356
+ if (isset($transactionAttribs['disputes'])) {
357
+ foreach ($transactionAttribs['disputes'] AS $dispute) {
358
+ $disputes[] = Dispute::factory($dispute);
359
+ }
360
+ }
361
+
362
+ $this->_set('disputes', $disputes);
363
+
364
+ $statusHistory = [];
365
+ if (isset($transactionAttribs['statusHistory'])) {
366
+ foreach ($transactionAttribs['statusHistory'] AS $history) {
367
+ $statusHistory[] = new Transaction\StatusDetails($history);
368
+ }
369
+ }
370
+
371
+ $this->_set('statusHistory', $statusHistory);
372
+
373
+ $addOnArray = [];
374
+ if (isset($transactionAttribs['addOns'])) {
375
+ foreach ($transactionAttribs['addOns'] AS $addOn) {
376
+ $addOnArray[] = AddOn::factory($addOn);
377
+ }
378
+ }
379
+ $this->_set('addOns', $addOnArray);
380
+
381
+ $discountArray = [];
382
+ if (isset($transactionAttribs['discounts'])) {
383
+ foreach ($transactionAttribs['discounts'] AS $discount) {
384
+ $discountArray[] = Discount::factory($discount);
385
+ }
386
+ }
387
+ $this->_set('discounts', $discountArray);
388
+
389
+ if(isset($transactionAttribs['riskData'])) {
390
+ $this->_set('riskData', RiskData::factory($transactionAttribs['riskData']));
391
+ }
392
+ if(isset($transactionAttribs['threeDSecureInfo'])) {
393
+ $this->_set('threeDSecureInfo', ThreeDSecureInfo::factory($transactionAttribs['threeDSecureInfo']));
394
+ }
395
+ if(isset($transactionAttribs['facilitatorDetails'])) {
396
+ $this->_set('facilitatorDetails', FacilitatorDetails::factory($transactionAttribs['facilitatorDetails']));
397
+ }
398
+ }
399
+
400
+ /**
401
+ * returns a string representation of the transaction
402
+ * @return string
403
+ */
404
+ public function __toString()
405
+ {
406
+ // array of attributes to print
407
+ $display = [
408
+ 'id', 'type', 'amount', 'status',
409
+ 'createdAt', 'creditCardDetails', 'customerDetails'
410
+ ];
411
+
412
+ $displayAttributes = [];
413
+ foreach ($display AS $attrib) {
414
+ $displayAttributes[$attrib] = $this->$attrib;
415
+ }
416
+ return __CLASS__ . '[' .
417
+ Util::attributesToString($displayAttributes) .']';
418
+ }
419
+
420
+ public function isEqual($otherTx)
421
+ {
422
+ return $this->id === $otherTx->id;
423
+ }
424
+
425
+ public function vaultCreditCard()
426
+ {
427
+ $token = $this->creditCardDetails->token;
428
+ if (empty($token)) {
429
+ return null;
430
+ }
431
+ else {
432
+ return CreditCard::find($token);
433
+ }
434
+ }
435
+
436
+ /** @return void|Braintree\Customer */
437
+ public function vaultCustomer()
438
+ {
439
+ $customerId = $this->customerDetails->id;
440
+ if (empty($customerId)) {
441
+ return null;
442
+ }
443
+ else {
444
+ return Customer::find($customerId);
445
+ }
446
+ }
447
+
448
+ /** @return bool */
449
+ public function isDisbursed() {
450
+ return $this->disbursementDetails->isValid();
451
+ }
452
+
453
+ /**
454
+ * factory method: returns an instance of Transaction
455
+ * to the requesting method, with populated properties
456
+ *
457
+ * @ignore
458
+ * @return Transaction
459
+ */
460
+ public static function factory($attributes)
461
+ {
462
+ $instance = new self();
463
+ $instance->_initialize($attributes);
464
+ return $instance;
465
+ }
466
+
467
+
468
+ // static methods redirecting to gateway
469
+
470
+ public static function cloneTransaction($transactionId, $attribs)
471
+ {
472
+ return Configuration::gateway()->transaction()->cloneTransaction($transactionId, $attribs);
473
+ }
474
+
475
+ public static function createFromTransparentRedirect($queryString)
476
+ {
477
+ return Configuration::gateway()->transaction()->createFromTransparentRedirect($queryString);
478
+ }
479
+
480
+ public static function createTransactionUrl()
481
+ {
482
+ return Configuration::gateway()->transaction()->createTransactionUrl();
483
+ }
484
+
485
+ public static function credit($attribs)
486
+ {
487
+ return Configuration::gateway()->transaction()->credit($attribs);
488
+ }
489
+
490
+ public static function creditNoValidate($attribs)
491
+ {
492
+ return Configuration::gateway()->transaction()->creditNoValidate($attribs);
493
+ }
494
+
495
+ public static function find($id)
496
+ {
497
+ return Configuration::gateway()->transaction()->find($id);
498
+ }
499
+
500
+ public static function sale($attribs)
501
+ {
502
+ return Configuration::gateway()->transaction()->sale($attribs);
503
+ }
504
+
505
+ public static function saleNoValidate($attribs)
506
+ {
507
+ return Configuration::gateway()->transaction()->saleNoValidate($attribs);
508
+ }
509
+
510
+ public static function search($query)
511
+ {
512
+ return Configuration::gateway()->transaction()->search($query);
513
+ }
514
+
515
+ public static function fetch($query, $ids)
516
+ {
517
+ return Configuration::gateway()->transaction()->fetch($query, $ids);
518
+ }
519
+
520
+ public static function void($transactionId)
521
+ {
522
+ return Configuration::gateway()->transaction()->void($transactionId);
523
+ }
524
+
525
+ public static function voidNoValidate($transactionId)
526
+ {
527
+ return Configuration::gateway()->transaction()->voidNoValidate($transactionId);
528
+ }
529
+
530
+ public static function submitForSettlement($transactionId, $amount = null, $attribs = [])
531
+ {
532
+ return Configuration::gateway()->transaction()->submitForSettlement($transactionId, $amount, $attribs);
533
+ }
534
+
535
+ public static function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = [])
536
+ {
537
+ return Configuration::gateway()->transaction()->submitForSettlementNoValidate($transactionId, $amount, $attribs);
538
+ }
539
+
540
+ public static function updateDetails($transactionId, $attribs = [])
541
+ {
542
+ return Configuration::gateway()->transaction()->updateDetails($transactionId, $attribs);
543
+ }
544
+
545
+ public static function submitForPartialSettlement($transactionId, $amount, $attribs = [])
546
+ {
547
+ return Configuration::gateway()->transaction()->submitForPartialSettlement($transactionId, $amount, $attribs);
548
+ }
549
+
550
+ public static function holdInEscrow($transactionId)
551
+ {
552
+ return Configuration::gateway()->transaction()->holdInEscrow($transactionId);
553
+ }
554
+
555
+ public static function releaseFromEscrow($transactionId)
556
+ {
557
+ return Configuration::gateway()->transaction()->releaseFromEscrow($transactionId);
558
+ }
559
+
560
+ public static function cancelRelease($transactionId)
561
+ {
562
+ return Configuration::gateway()->transaction()->cancelRelease($transactionId);
563
+ }
564
+
565
+ public static function refund($transactionId, $amount = null)
566
+ {
567
+ return Configuration::gateway()->transaction()->refund($transactionId, $amount);
568
+ }
569
+ }
570
+ class_alias('Braintree\Transaction', 'Braintree_Transaction');
lib/braintree/lib/Braintree/Transaction/AddressDetails.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Creates an instance of AddressDetails as returned from a transaction
8
+ *
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ *
14
+ * @property-read string $firstName
15
+ * @property-read string $lastName
16
+ * @property-read string $company
17
+ * @property-read string $streetAddress
18
+ * @property-read string $extendedAddress
19
+ * @property-read string $locality
20
+ * @property-read string $region
21
+ * @property-read string $postalCode
22
+ * @property-read string $countryName
23
+ */
24
+ class AddressDetails extends Instance
25
+ {
26
+ protected $_attributes = [];
27
+ }
28
+ class_alias('Braintree\Transaction\AddressDetails', 'Braintree_Transaction_AddressDetails');
lib/braintree/lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+ /**
6
+ * Amex Express Checkout card details from a transaction
7
+ *
8
+ * @package Braintree
9
+ * @subpackage Transaction
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
+ */
12
+
13
+ /**
14
+ * creates an instance of AmexExpressCheckoutCardDetails
15
+ *
16
+ *
17
+ * @package Braintree
18
+ * @subpackage Transaction
19
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
20
+ *
21
+ * @property-read string $cardType
22
+ * @property-read string $bin
23
+ * @property-read string $cardMemberExpiryDate
24
+ * @property-read string $cardMemberNumber
25
+ * @property-read string $cardType
26
+ * @property-read string $sourceDescription
27
+ * @property-read string $token
28
+ * @property-read string $imageUrl
29
+ * @property-read string $expirationMonth
30
+ * @property-read string $expirationYear
31
+ * @uses Instance inherits methods
32
+ */
33
+ class AmexExpressCheckoutCardDetails extends Instance
34
+ {
35
+ protected $_attributes = [];
36
+
37
+ /**
38
+ * @ignore
39
+ */
40
+ public function __construct($attributes)
41
+ {
42
+ parent::__construct($attributes);
43
+ }
44
+ }
45
+ class_alias('Braintree\Transaction\AmexExpressCheckoutCardDetails', 'Braintree_Transaction_AmexExpressCheckoutCardDetails');
lib/braintree/lib/Braintree/Transaction/AndroidPayCardDetails.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Android Pay card details from a transaction
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Transaction
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ /**
15
+ * creates an instance of AndroidPayCardDetails
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @subpackage Transaction
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $bin
23
+ * @property-read string $default
24
+ * @property-read string $expirationMonth
25
+ * @property-read string $expirationYear
26
+ * @property-read string $googleTransactionId
27
+ * @property-read string $imageUrl
28
+ * @property-read string $sourceCardLast4
29
+ * @property-read string $sourceCardType
30
+ * @property-read string $sourceDescription
31
+ * @property-read string $token
32
+ * @property-read string $virtualCardLast4
33
+ * @property-read string $virtualCardType
34
+ */
35
+ class AndroidPayCardDetails extends Instance
36
+ {
37
+ protected $_attributes = [];
38
+
39
+ /**
40
+ * @ignore
41
+ */
42
+ public function __construct($attributes)
43
+ {
44
+ parent::__construct($attributes);
45
+ $this->_attributes['cardType'] = $this->virtualCardType;
46
+ $this->_attributes['last4'] = $this->virtualCardLast4;
47
+ }
48
+ }
49
+ class_alias('Braintree\Transaction\AndroidPayCardDetails', 'Braintree_Transaction_AndroidPayCardDetails');
lib/braintree/lib/Braintree/Transaction/ApplePayCardDetails.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Apple Pay card details from a transaction
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Transaction
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ /**
15
+ * creates an instance of ApplePayCardDetails
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @subpackage Transaction
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $cardType
23
+ * @property-read string $paymentInstrumentName
24
+ * @property-read string $expirationMonth
25
+ * @property-read string $expirationYear
26
+ * @property-read string $cardholderName
27
+ * @property-read string $sourceDescription
28
+ */
29
+ class ApplePayCardDetails extends Instance
30
+ {
31
+ protected $_attributes = [];
32
+
33
+ /**
34
+ * @ignore
35
+ */
36
+ public function __construct($attributes)
37
+ {
38
+ parent::__construct($attributes);
39
+ }
40
+ }
41
+ class_alias('Braintree\Transaction\ApplePayCardDetails', 'Braintree_Transaction_ApplePayCardDetails');
lib/braintree/lib/Braintree/Transaction/CoinbaseDetails.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Coinbase details from a transaction
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Transaction
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ /**
15
+ * creates an instance of Coinbase
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @subpackage Transaction
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $token
23
+ * @property-read string $userId
24
+ * @property-read string $userName
25
+ * @property-read string $userEmail
26
+ * @property-read string $imageUrl
27
+ */
28
+ class CoinbaseDetails extends Instance
29
+ {
30
+ protected $_attributes = [];
31
+
32
+ /**
33
+ * @ignore
34
+ */
35
+ public function __construct($attributes)
36
+ {
37
+ parent::__construct($attributes);
38
+ }
39
+ }
40
+ class_alias('Braintree\Transaction\CoinbaseDetails', 'Braintree_Transaction_CoinbaseDetails');
lib/braintree/lib/Braintree/Transaction/CreditCardDetails.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * CreditCard details from a transaction
8
+ * creates an instance of CreditCardDetails
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ *
14
+ * @property-read string $bin
15
+ * @property-read string $cardType
16
+ * @property-read string $expirationDate
17
+ * @property-read string $expirationMonth
18
+ * @property-read string $expirationYear
19
+ * @property-read string $issuerLocation
20
+ * @property-read string $last4
21
+ * @property-read string $maskedNumber
22
+ * @property-read string $token
23
+ */
24
+ class CreditCardDetails extends Instance
25
+ {
26
+ protected $_attributes = [];
27
+
28
+ /**
29
+ * @ignore
30
+ */
31
+ public function __construct($attributes)
32
+ {
33
+ parent::__construct($attributes);
34
+ $this->_attributes['expirationDate'] = $this->expirationMonth . '/' . $this->expirationYear;
35
+ $this->_attributes['maskedNumber'] = $this->bin . '******' . $this->last4;
36
+
37
+ }
38
+ }
39
+ class_alias('Braintree\Transaction\CreditCardDetails', 'Braintree_Transaction_CreditCardDetails');
lib/braintree/lib/Braintree/Transaction/CustomerDetails.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Customer details from a transaction
8
+ * Creates an instance of customer details as returned from a transaction
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ *
14
+ * @property-read string $company
15
+ * @property-read string $email
16
+ * @property-read string $fax
17
+ * @property-read string $firstName
18
+ * @property-read string $id
19
+ * @property-read string $lastName
20
+ * @property-read string $phone
21
+ * @property-read string $website
22
+ */
23
+ class CustomerDetails extends Instance
24
+ {
25
+ }
26
+ class_alias('Braintree\Transaction\CustomerDetails', 'Braintree_Transaction_CustomerDetails');
lib/braintree/lib/Braintree/Transaction/EuropeBankAccountDetails.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Europe bank account details from a transaction
8
+ * Creates an instance of europe bank account details as returned from a transaction
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ *
14
+ * @property-read string $accountHolderName
15
+ * @property-read string $bic
16
+ * @property-read string $imageUrl
17
+ * @property-read string $mandateAcceptedAt
18
+ * @property-read string $mandateReferenceNumber
19
+ * @property-read string $maskedIban
20
+ * @property-read string $token
21
+ */
22
+ class EuropeBankAccountDetails extends Instance
23
+ {
24
+ }
25
+ class_alias('Braintree\Transaction\EuropeBankAccountDetails', 'Braintree_Transaction_EuropeBankAccountDetails');
lib/braintree/lib/Braintree/Transaction/PayPalDetails.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * PayPal details from a transaction
8
+ *
9
+ * @package Braintree
10
+ * @subpackage Transaction
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ /**
15
+ * creates an instance of PayPalDetails
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @subpackage Transaction
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $payerEmail
23
+ * @property-read string $paymentId
24
+ * @property-read string $authorizationId
25
+ * @property-read string $token
26
+ * @property-read string $imageUrl
27
+ * @property-read string $transactionFeeAmount
28
+ * @property-read string $transactionFeeCurrencyIsoCode
29
+ * @property-read string $description
30
+ */
31
+ class PayPalDetails extends Instance
32
+ {
33
+ protected $_attributes = [];
34
+
35
+ /**
36
+ * @ignore
37
+ */
38
+ public function __construct($attributes)
39
+ {
40
+ parent::__construct($attributes);
41
+ }
42
+ }
43
+ class_alias('Braintree\Transaction\PayPalDetails', 'Braintree_Transaction_PayPalDetails');
lib/braintree/lib/Braintree/Transaction/StatusDetails.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Status details from a transaction
8
+ * Creates an instance of StatusDetails, as part of a transaction response
9
+ *
10
+ * @package Braintree
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ *
13
+ * @property-read string $amount
14
+ * @property-read string $status
15
+ * @property-read string $timestamp
16
+ * @property-read string $transactionSource
17
+ * @property-read string $user
18
+ */
19
+ class StatusDetails extends Instance
20
+ {
21
+ }
22
+ class_alias('Braintree\Transaction\StatusDetails', 'Braintree_Transaction_StatusDetails');
lib/braintree/lib/Braintree/Transaction/SubscriptionDetails.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * Customer details from a transaction
8
+ * Creates an instance of customer details as returned from a transaction
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ *
14
+ * @property-read string $billing_period_start_date
15
+ * @property-read string $billing_period_end_date
16
+ */
17
+ class SubscriptionDetails extends Instance
18
+ {
19
+ }
20
+ class_alias('Braintree\Transaction\SubscriptionDetails', 'Braintree_Transaction_SubscriptionDetails');
lib/braintree/lib/Braintree/Transaction/UsBankAccountDetails.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+
6
+ /**
7
+ * CreditCard details from a transaction
8
+ * creates an instance of UsbankAccountDetails
9
+ *
10
+ * @package Braintree
11
+ * @subpackage Transaction
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ *
14
+ * @property-read string $routingNumber
15
+ * @property-read string $last4
16
+ * @property-read string $accountType
17
+ * @property-read string $accountDescription
18
+ * @property-read string $accountHolderName
19
+ * @property-read string $token
20
+ * @property-read string $imageUrl
21
+ * @property-read string $bankName
22
+ */
23
+ class UsBankAccountDetails extends Instance
24
+ {
25
+ protected $_attributes = [];
26
+
27
+ /**
28
+ * @ignore
29
+ */
30
+ public function __construct($attributes)
31
+ {
32
+ parent::__construct($attributes);
33
+
34
+ }
35
+ }
36
+ class_alias('Braintree\Transaction\UsBankAccountDetails', 'Braintree_Transaction_UsBankAccountDetails');
lib/braintree/lib/Braintree/Transaction/VenmoAccountDetails.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Transaction;
3
+
4
+ use Braintree\Instance;
5
+ /**
6
+ * Venmo account details from a transaction
7
+ *
8
+ * @package Braintree
9
+ * @subpackage Transaction
10
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
11
+ */
12
+
13
+ /**
14
+ * creates an instance of VenmoAccountDetails
15
+ *
16
+ *
17
+ * @package Braintree
18
+ * @subpackage Transaction
19
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
20
+ *
21
+ * @property-read string $sourceDescription
22
+ * @property-read string $token
23
+ * @property-read string $imageUrl
24
+ * @property-read string $username
25
+ * @property-read string $venmo_user_id
26
+ * @uses Instance inherits methods
27
+ */
28
+ class VenmoAccountDetails extends Instance
29
+ {
30
+ protected $_attributes = array();
31
+
32
+ /**
33
+ * @ignore
34
+ */
35
+ public function __construct($attributes)
36
+ {
37
+ parent::__construct($attributes);
38
+ }
39
+ }
40
+ class_alias('Braintree\Transaction\VenmoAccountDetails', 'Braintree_Transaction_VenmoAccountDetails');
lib/braintree/lib/Braintree/TransactionGateway.php ADDED
@@ -0,0 +1,520 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree TransactionGateway processor
8
+ * Creates and manages transactions
9
+ *
10
+ *
11
+ * <b>== More information ==</b>
12
+ *
13
+ * For more detailed information on Transactions, see {@link http://www.braintreepayments.com/gateway/transaction-api http://www.braintreepaymentsolutions.com/gateway/transaction-api}
14
+ *
15
+ * @package Braintree
16
+ * @category Resources
17
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
18
+ */
19
+
20
+ class TransactionGateway
21
+ {
22
+ private $_gateway;
23
+ private $_config;
24
+ private $_http;
25
+
26
+ public function __construct($gateway)
27
+ {
28
+ $this->_gateway = $gateway;
29
+ $this->_config = $gateway->config;
30
+ $this->_config->assertHasAccessTokenOrKeys();
31
+ $this->_http = new Http($gateway->config);
32
+ }
33
+
34
+ public function cloneTransaction($transactionId, $attribs)
35
+ {
36
+ Util::verifyKeys(self::cloneSignature(), $attribs);
37
+ return $this->_doCreate('/transactions/' . $transactionId . '/clone', ['transactionClone' => $attribs]);
38
+ }
39
+
40
+ /**
41
+ * @ignore
42
+ * @access private
43
+ * @param array $attribs
44
+ * @return object
45
+ */
46
+ private function create($attribs)
47
+ {
48
+ Util::verifyKeys(self::createSignature(), $attribs);
49
+ return $this->_doCreate('/transactions', ['transaction' => $attribs]);
50
+ }
51
+
52
+ /**
53
+ * @ignore
54
+ * @access private
55
+ * @param array $attribs
56
+ * @return object
57
+ * @throws Exception\ValidationError
58
+ */
59
+ private function createNoValidate($attribs)
60
+ {
61
+ $result = $this->create($attribs);
62
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
63
+ }
64
+ /**
65
+ *
66
+ * @deprecated since version 2.3.0
67
+ * @access public
68
+ * @param array $attribs
69
+ * @return object
70
+ */
71
+ public function createFromTransparentRedirect($queryString)
72
+ {
73
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE);
74
+ $params = TransparentRedirect::parseAndValidateQueryString(
75
+ $queryString
76
+ );
77
+ return $this->_doCreate(
78
+ '/transactions/all/confirm_transparent_redirect_request',
79
+ ['id' => $params['id']]
80
+ );
81
+ }
82
+ /**
83
+ *
84
+ * @deprecated since version 2.3.0
85
+ * @access public
86
+ * @param none
87
+ * @return string
88
+ */
89
+ public function createTransactionUrl()
90
+ {
91
+ trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE);
92
+ return $this->_config->baseUrl() . $this->_config->merchantPath() .
93
+ '/transactions/all/create_via_transparent_redirect_request';
94
+ }
95
+
96
+ public static function cloneSignature()
97
+ {
98
+ return ['amount', 'channel', ['options' => ['submitForSettlement']]];
99
+ }
100
+
101
+ /**
102
+ * creates a full array signature of a valid gateway request
103
+ * @return array gateway request signature format
104
+ */
105
+ public static function createSignature()
106
+ {
107
+ return [
108
+ 'amount',
109
+ 'billingAddressId',
110
+ 'channel',
111
+ 'customerId',
112
+ 'deviceData',
113
+ 'deviceSessionId',
114
+ 'fraudMerchantId',
115
+ 'merchantAccountId',
116
+ 'orderId',
117
+ 'paymentMethodNonce',
118
+ 'paymentMethodToken',
119
+ 'purchaseOrderNumber',
120
+ 'recurring',
121
+ 'serviceFeeAmount',
122
+ 'sharedPaymentMethodToken',
123
+ 'sharedCustomerId',
124
+ 'sharedShippingAddressId',
125
+ 'sharedBillingAddressId',
126
+ 'shippingAddressId',
127
+ 'taxAmount',
128
+ 'taxExempt',
129
+ 'threeDSecureToken',
130
+ 'transactionSource',
131
+ 'type',
132
+ 'venmoSdkPaymentMethodCode',
133
+ ['riskData' =>
134
+ ['customerBrowser', 'customerIp', 'customer_browser', 'customer_ip']
135
+ ],
136
+ ['creditCard' =>
137
+ ['token', 'cardholderName', 'cvv', 'expirationDate', 'expirationMonth', 'expirationYear', 'number'],
138
+ ],
139
+ ['customer' =>
140
+ [
141
+ 'id', 'company', 'email', 'fax', 'firstName',
142
+ 'lastName', 'phone', 'website'],
143
+ ],
144
+ ['billing' =>
145
+ [
146
+ 'firstName', 'lastName', 'company', 'countryName',
147
+ 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
148
+ 'extendedAddress', 'locality', 'postalCode', 'region',
149
+ 'streetAddress'],
150
+ ],
151
+ ['shipping' =>
152
+ [
153
+ 'firstName', 'lastName', 'company', 'countryName',
154
+ 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
155
+ 'extendedAddress', 'locality', 'postalCode', 'region',
156
+ 'streetAddress'],
157
+ ],
158
+ ['threeDSecurePassThru' =>
159
+ [
160
+ 'eciFlag',
161
+ 'cavv',
162
+ 'xid'],
163
+ ],
164
+ ['options' =>
165
+ [
166
+ 'holdInEscrow',
167
+ 'storeInVault',
168
+ 'storeInVaultOnSuccess',
169
+ 'submitForSettlement',
170
+ 'addBillingAddressToPaymentMethod',
171
+ 'venmoSdkSession',
172
+ 'storeShippingAddressInVault',
173
+ 'payeeEmail',
174
+ ['threeDSecure' =>
175
+ ['required']
176
+ ],
177
+ ['paypal' =>
178
+ [
179
+ 'payeeEmail',
180
+ 'customField',
181
+ 'description',
182
+ ['supplementaryData' => ['_anyKey_']],
183
+ ]
184
+ ],
185
+ ['amexRewards' =>
186
+ [
187
+ 'requestId',
188
+ 'points',
189
+ 'currencyAmount',
190
+ 'currencyIsoCode'
191
+ ]
192
+ ]
193
+ ],
194
+ ],
195
+ ['customFields' => ['_anyKey_']],
196
+ ['descriptor' => ['name', 'phone', 'url']],
197
+ ['paypalAccount' => ['payeeEmail']],
198
+ ['apple_pay_card' => ['number', 'cardholder_name', 'cryptogram', 'expiration_month', 'expiration_year']],
199
+ ['industry' =>
200
+ ['industryType',
201
+ ['data' =>
202
+ [
203
+ 'folioNumber',
204
+ 'checkInDate',
205
+ 'checkOutDate',
206
+ 'travelPackage',
207
+ 'departureDate',
208
+ 'lodgingCheckInDate',
209
+ 'lodgingCheckOutDate',
210
+ 'lodgingName',
211
+ 'roomRate'
212
+ ]
213
+ ]
214
+ ]
215
+ ]
216
+ ];
217
+ }
218
+
219
+ public static function submitForSettlementSignature()
220
+ {
221
+ return ['orderId', ['descriptor' => ['name', 'phone', 'url']]];
222
+ }
223
+
224
+ public static function updateDetailsSignature()
225
+ {
226
+ return ['amount', 'orderId', ['descriptor' => ['name', 'phone', 'url']]];
227
+ }
228
+
229
+ public static function refundSignature()
230
+ {
231
+ return ['amount', 'orderId'];
232
+ }
233
+
234
+ /**
235
+ *
236
+ * @access public
237
+ * @param array $attribs
238
+ * @return Result\Successful|Result\Error
239
+ */
240
+ public function credit($attribs)
241
+ {
242
+ return $this->create(array_merge($attribs, ['type' => Transaction::CREDIT]));
243
+ }
244
+
245
+ /**
246
+ *
247
+ * @access public
248
+ * @param array $attribs
249
+ * @return Result\Successful|Result\Error
250
+ * @throws Exception\ValidationError
251
+ */
252
+ public function creditNoValidate($attribs)
253
+ {
254
+ $result = $this->credit($attribs);
255
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
256
+ }
257
+
258
+ /**
259
+ * @access public
260
+ * @param string id
261
+ * @return Transaction
262
+ */
263
+ public function find($id)
264
+ {
265
+ $this->_validateId($id);
266
+ try {
267
+ $path = $this->_config->merchantPath() . '/transactions/' . $id;
268
+ $response = $this->_http->get($path);
269
+ return Transaction::factory($response['transaction']);
270
+ } catch (Exception\NotFound $e) {
271
+ throw new Exception\NotFound(
272
+ 'transaction with id ' . $id . ' not found'
273
+ );
274
+ }
275
+ }
276
+ /**
277
+ * new sale
278
+ * @param array $attribs
279
+ * @return array
280
+ */
281
+ public function sale($attribs)
282
+ {
283
+ return $this->create(array_merge(['type' => Transaction::SALE], $attribs));
284
+ }
285
+
286
+ /**
287
+ * roughly equivalent to the ruby bang method
288
+ * @access public
289
+ * @param array $attribs
290
+ * @return array
291
+ * @throws Exception\ValidationsFailed
292
+ */
293
+ public function saleNoValidate($attribs)
294
+ {
295
+ $result = $this->sale($attribs);
296
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
297
+ }
298
+
299
+ /**
300
+ * Returns a ResourceCollection of transactions matching the search query.
301
+ *
302
+ * If <b>query</b> is a string, the search will be a basic search.
303
+ * If <b>query</b> is a hash, the search will be an advanced search.
304
+ * For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/transaction-api#searching http://www.braintreepaymentsolutions.com/gateway/transaction-api}
305
+ *
306
+ * @param mixed $query search query
307
+ * @param array $options options such as page number
308
+ * @return ResourceCollection
309
+ * @throws InvalidArgumentException
310
+ */
311
+ public function search($query)
312
+ {
313
+ $criteria = [];
314
+ foreach ($query as $term) {
315
+ $criteria[$term->name] = $term->toparam();
316
+ }
317
+
318
+ $path = $this->_config->merchantPath() . '/transactions/advanced_search_ids';
319
+ $response = $this->_http->post($path, ['search' => $criteria]);
320
+ if (array_key_exists('searchResults', $response)) {
321
+ $pager = [
322
+ 'object' => $this,
323
+ 'method' => 'fetch',
324
+ 'methodArgs' => [$query]
325
+ ];
326
+
327
+ return new ResourceCollection($response, $pager);
328
+ } else {
329
+ throw new Exception\DownForMaintenance();
330
+ }
331
+ }
332
+
333
+ public function fetch($query, $ids)
334
+ {
335
+ $criteria = [];
336
+ foreach ($query as $term) {
337
+ $criteria[$term->name] = $term->toparam();
338
+ }
339
+ $criteria["ids"] = TransactionSearch::ids()->in($ids)->toparam();
340
+ $path = $this->_config->merchantPath() . '/transactions/advanced_search';
341
+ $response = $this->_http->post($path, ['search' => $criteria]);
342
+
343
+ return Util::extractattributeasarray(
344
+ $response['creditCardTransactions'],
345
+ 'transaction'
346
+ );
347
+ }
348
+
349
+ /**
350
+ * void a transaction by id
351
+ *
352
+ * @param string $id transaction id
353
+ * @return Result\Successful|Result\Error
354
+ */
355
+ public function void($transactionId)
356
+ {
357
+ $this->_validateId($transactionId);
358
+
359
+ $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/void';
360
+ $response = $this->_http->put($path);
361
+ return $this->_verifyGatewayResponse($response);
362
+ }
363
+ /**
364
+ *
365
+ */
366
+ public function voidNoValidate($transactionId)
367
+ {
368
+ $result = $this->void($transactionId);
369
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
370
+ }
371
+
372
+ public function submitForSettlement($transactionId, $amount = null, $attribs = [])
373
+ {
374
+ $this->_validateId($transactionId);
375
+ Util::verifyKeys(self::submitForSettlementSignature(), $attribs);
376
+ $attribs['amount'] = $amount;
377
+
378
+ $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_settlement';
379
+ $response = $this->_http->put($path, ['transaction' => $attribs]);
380
+ return $this->_verifyGatewayResponse($response);
381
+ }
382
+
383
+ public function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = [])
384
+ {
385
+ $result = $this->submitForSettlement($transactionId, $amount, $attribs);
386
+ return Util::returnObjectOrThrowException(__CLASS__, $result);
387
+ }
388
+
389
+ public function updateDetails($transactionId, $attribs = [])
390
+ {
391
+ $this->_validateId($transactionId);
392
+ Util::verifyKeys(self::updateDetailsSignature(), $attribs);
393
+
394
+ $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/update_details';
395
+ $response = $this->_http->put($path, ['transaction' => $attribs]);
396
+ return $this->_verifyGatewayResponse($response);
397
+ }
398
+
399
+ public function submitForPartialSettlement($transactionId, $amount, $attribs = [])
400
+ {
401
+ $this->_validateId($transactionId);
402
+ Util::verifyKeys(self::submitForSettlementSignature(), $attribs);
403
+ $attribs['amount'] = $amount;
404
+
405
+ $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_partial_settlement';
406
+ $response = $this->_http->post($path, ['transaction' => $attribs]);
407
+ return $this->_verifyGatewayResponse($response);
408
+ }
409
+
410
+ public function holdInEscrow($transactionId)
411
+ {
412
+ $this->_validateId($transactionId);
413
+
414
+ $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/hold_in_escrow';
415
+ $response = $this->_http->put($path, []);
416
+ return $this->_verifyGatewayResponse($response);
417
+ }
418
+
419
+ public function releaseFromEscrow($transactionId)
420
+ {
421
+ $this->_validateId($transactionId);
422
+
423
+ $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/release_from_escrow';
424
+ $response = $this->_http->put($path, []);
425
+ return $this->_verifyGatewayResponse($response);
426
+ }
427
+
428
+ public function cancelRelease($transactionId)
429
+ {
430
+ $this->_validateId($transactionId);
431
+
432
+ $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/cancel_release';
433
+ $response = $this->_http->put($path, []);
434
+ return $this->_verifyGatewayResponse($response);
435
+ }
436
+
437
+ public function refund($transactionId, $amount_or_options = null)
438
+ {
439
+ self::_validateId($transactionId);
440
+
441
+ if(gettype($amount_or_options) == "array") {
442
+ $options = $amount_or_options;
443
+ } else {
444
+ $options = [
445
+ "amount" => $amount_or_options
446
+ ];
447
+ }
448
+ Util::verifyKeys(self::refundSignature(), $options);
449
+
450
+ $params = ['transaction' => $options];
451
+ $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/refund';
452
+ $response = $this->_http->post($path, $params);
453
+ return $this->_verifyGatewayResponse($response);
454
+ }
455
+
456
+ /**
457
+ * sends the create request to the gateway
458
+ *
459
+ * @ignore
460
+ * @param var $subPath
461
+ * @param array $params
462
+ * @return mixed
463
+ */
464
+ public function _doCreate($subPath, $params)
465
+ {
466
+ $fullPath = $this->_config->merchantPath() . $subPath;
467
+ $response = $this->_http->post($fullPath, $params);
468
+
469
+ return $this->_verifyGatewayResponse($response);
470
+ }
471
+
472
+ /**
473
+ * verifies that a valid transaction id is being used
474
+ * @ignore
475
+ * @param string transaction id
476
+ * @throws InvalidArgumentException
477
+ */
478
+ private function _validateId($id = null) {
479
+ if (empty($id)) {
480
+ throw new InvalidArgumentException(
481
+ 'expected transaction id to be set'
482
+ );
483
+ }
484
+ if (!preg_match('/^[0-9a-z]+$/', $id)) {
485
+ throw new InvalidArgumentException(
486
+ $id . ' is an invalid transaction id.'
487
+ );
488
+ }
489
+ }
490
+
491
+ /**
492
+ * generic method for validating incoming gateway responses
493
+ *
494
+ * creates a new Transaction object and encapsulates
495
+ * it inside a Result\Successful object, or
496
+ * encapsulates a Errors object inside a Result\Error
497
+ * alternatively, throws an Unexpected exception if the response is invalid.
498
+ *
499
+ * @ignore
500
+ * @param array $response gateway response values
501
+ * @return Result\Successful|Result\Error
502
+ * @throws Exception\Unexpected
503
+ */
504
+ private function _verifyGatewayResponse($response)
505
+ {
506
+ if (isset($response['transaction'])) {
507
+ // return a populated instance of Transaction
508
+ return new Result\Successful(
509
+ Transaction::factory($response['transaction'])
510
+ );
511
+ } else if (isset($response['apiErrorResponse'])) {
512
+ return new Result\Error($response['apiErrorResponse']);
513
+ } else {
514
+ throw new Exception\Unexpected(
515
+ "Expected transaction or apiErrorResponse"
516
+ );
517
+ }
518
+ }
519
+ }
520
+ class_alias('Braintree\TransactionGateway', 'Braintree_TransactionGateway');
lib/braintree/lib/Braintree/TransactionSearch.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class TransactionSearch
5
+ {
6
+ public static function amount() { return new RangeNode("amount"); }
7
+ public static function authorizationExpiredAt() { return new RangeNode("authorizationExpiredAt"); }
8
+ public static function authorizedAt() { return new RangeNode("authorizedAt"); }
9
+ public static function billingCompany() { return new TextNode('billing_company'); }
10
+ public static function billingCountryName() { return new TextNode('billing_country_name'); }
11
+ public static function billingExtendedAddress() { return new TextNode('billing_extended_address'); }
12
+ public static function billingFirstName() { return new TextNode('billing_first_name'); }
13
+ public static function billingLastName() { return new TextNode('billing_last_name'); }
14
+ public static function billingLocality() { return new TextNode('billing_locality'); }
15
+ public static function billingPostalCode() { return new TextNode('billing_postal_code'); }
16
+ public static function billingRegion() { return new TextNode('billing_region'); }
17
+ public static function billingStreetAddress() { return new TextNode('billing_street_address'); }
18
+ public static function createdAt() { return new RangeNode("createdAt"); }
19
+ public static function creditCardCardholderName() { return new TextNode('credit_card_cardholderName'); }
20
+ public static function creditCardExpirationDate() { return new EqualityNode('credit_card_expiration_date'); }
21
+ public static function creditCardNumber() { return new PartialMatchNode('credit_card_number'); }
22
+ public static function creditCardUniqueIdentifier() { return new TextNode('credit_card_unique_identifier'); }
23
+ public static function currency() { return new TextNode('currency'); }
24
+ public static function customerCompany() { return new TextNode('customer_company'); }
25
+ public static function customerEmail() { return new TextNode('customer_email'); }
26
+ public static function customerFax() { return new TextNode('customer_fax'); }
27
+ public static function customerFirstName() { return new TextNode('customer_first_name'); }
28
+ public static function customerId() { return new TextNode('customer_id'); }
29
+ public static function customerLastName() { return new TextNode('customer_last_name'); }
30
+ public static function customerPhone() { return new TextNode('customer_phone'); }
31
+ public static function customerWebsite() { return new TextNode('customer_website'); }
32
+ public static function disbursementDate() { return new RangeNode("disbursementDate"); }
33
+ public static function disputeDate() { return new RangeNode("disputeDate"); }
34
+ public static function europeBankAccountIban() { return new TextNode("europeBankAccountIban"); }
35
+ public static function failedAt() { return new RangeNode("failedAt"); }
36
+ public static function gatewayRejectedAt() { return new RangeNode("gatewayRejectedAt"); }
37
+ public static function id() { return new TextNode('id'); }
38
+ public static function ids() { return new MultipleValueNode('ids'); }
39
+ public static function merchantAccountId() { return new MultipleValueNode("merchant_account_id"); }
40
+ public static function orderId() { return new TextNode('order_id'); }
41
+ public static function paymentInstrumentType() { return new MultipleValueNode('paymentInstrumentType'); }
42
+ public static function paymentMethodToken() { return new TextNode('payment_method_token'); }
43
+ public static function paypalAuthorizationId() { return new TextNode('paypal_authorization_id'); }
44
+ public static function paypalPayerEmail() { return new TextNode('paypal_payer_email'); }
45
+ public static function paypalPaymentId() { return new TextNode('paypal_payment_id'); }
46
+ public static function processorAuthorizationCode() { return new TextNode('processor_authorization_code'); }
47
+ public static function processorDeclinedAt() { return new RangeNode("processorDeclinedAt"); }
48
+ public static function refund() { return new KeyValueNode("refund"); }
49
+ public static function settledAt() { return new RangeNode("settledAt"); }
50
+ public static function settlementBatchId() { return new TextNode('settlement_batch_id'); }
51
+ public static function shippingCompany() { return new TextNode('shipping_company'); }
52
+ public static function shippingCountryName() { return new TextNode('shipping_country_name'); }
53
+ public static function shippingExtendedAddress() { return new TextNode('shipping_extended_address'); }
54
+ public static function shippingFirstName() { return new TextNode('shipping_first_name'); }
55
+ public static function shippingLastName() { return new TextNode('shipping_last_name'); }
56
+ public static function shippingLocality() { return new TextNode('shipping_locality'); }
57
+ public static function shippingPostalCode() { return new TextNode('shipping_postal_code'); }
58
+ public static function shippingRegion() { return new TextNode('shipping_region'); }
59
+ public static function shippingStreetAddress() { return new TextNode('shipping_street_address'); }
60
+ public static function submittedForSettlementAt() { return new RangeNode("submittedForSettlementAt"); }
61
+ public static function user() { return new MultipleValueNode('user'); }
62
+ public static function voidedAt() { return new RangeNode("voidedAt"); }
63
+
64
+ public static function createdUsing()
65
+ {
66
+ return new MultipleValueNode('created_using', [
67
+ Transaction::FULL_INFORMATION,
68
+ Transaction::TOKEN
69
+ ]);
70
+ }
71
+
72
+ public static function creditCardCardType()
73
+ {
74
+ return new MultipleValueNode('credit_card_card_type', [
75
+ CreditCard::AMEX,
76
+ CreditCard::CARTE_BLANCHE,
77
+ CreditCard::CHINA_UNION_PAY,
78
+ CreditCard::DINERS_CLUB_INTERNATIONAL,
79
+ CreditCard::DISCOVER,
80
+ CreditCard::JCB,
81
+ CreditCard::LASER,
82
+ CreditCard::MAESTRO,
83
+ CreditCard::MASTER_CARD,
84
+ CreditCard::SOLO,
85
+ CreditCard::SWITCH_TYPE,
86
+ CreditCard::VISA,
87
+ CreditCard::UNKNOWN
88
+ ]);
89
+ }
90
+
91
+ public static function creditCardCustomerLocation()
92
+ {
93
+ return new MultipleValueNode('credit_card_customer_location', [
94
+ CreditCard::INTERNATIONAL,
95
+ CreditCard::US
96
+ ]);
97
+ }
98
+
99
+ public static function source()
100
+ {
101
+ return new MultipleValueNode('source', []);
102
+ }
103
+
104
+ public static function status()
105
+ {
106
+ return new MultipleValueNode('status', [
107
+ Transaction::AUTHORIZATION_EXPIRED,
108
+ Transaction::AUTHORIZING,
109
+ Transaction::AUTHORIZED,
110
+ Transaction::GATEWAY_REJECTED,
111
+ Transaction::FAILED,
112
+ Transaction::PROCESSOR_DECLINED,
113
+ Transaction::SETTLED,
114
+ Transaction::SETTLING,
115
+ Transaction::SUBMITTED_FOR_SETTLEMENT,
116
+ Transaction::VOIDED,
117
+ Transaction::SETTLEMENT_DECLINED,
118
+ Transaction::SETTLEMENT_PENDING
119
+ ]);
120
+ }
121
+
122
+ public static function type()
123
+ {
124
+ return new MultipleValueNode('type', [
125
+ Transaction::SALE,
126
+ Transaction::CREDIT
127
+ ]);
128
+ }
129
+ }
130
+ class_alias('Braintree\TransactionSearch', 'Braintree_TransactionSearch');
lib/braintree/lib/Braintree/TransparentRedirect.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Transparent Redirect module
6
+ * Static class providing methods to build Transparent Redirect urls.
7
+ *
8
+ * The TransparentRedirect module provides methods to build the tr_data param
9
+ * that must be submitted when using the transparent redirect API.
10
+ * For more information
11
+ * about transparent redirect, see (TODO).
12
+ *
13
+ * You must provide a redirectUrl to which the gateway will redirect the
14
+ * user the action is complete.
15
+ *
16
+ * <code>
17
+ * $trData = TransparentRedirect::createCustomerData(array(
18
+ * 'redirectUrl => 'http://example.com/redirect_back_to_merchant_site',
19
+ * ));
20
+ * </code>
21
+ *
22
+ * In addition to the redirectUrl, any data that needs to be protected
23
+ * from user tampering should be included in the trData.
24
+ * For example, to prevent the user from tampering with the transaction
25
+ * amount, include the amount in the trData.
26
+ *
27
+ * <code>
28
+ * $trData = TransparentRedirect::transactionData(array(
29
+ * 'redirectUrl' => 'http://example.com/complete_transaction',
30
+ * 'transaction' => array('amount' => '100.00'),
31
+ * ));
32
+ *
33
+ * </code>
34
+ *
35
+ * @package Braintree
36
+ * @category Resources
37
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
38
+ */
39
+ class TransparentRedirect
40
+ {
41
+ // Request Kinds
42
+ const CREATE_TRANSACTION = 'create_transaction';
43
+ const CREATE_PAYMENT_METHOD = 'create_payment_method';
44
+ const UPDATE_PAYMENT_METHOD = 'update_payment_method';
45
+ const CREATE_CUSTOMER = 'create_customer';
46
+ const UPDATE_CUSTOMER = 'update_customer';
47
+
48
+ /**
49
+ * @ignore
50
+ * don't permit an explicit call of the constructor!
51
+ * (like $t = new TransparentRedirect())
52
+ */
53
+ protected function __construct()
54
+ {
55
+
56
+ }
57
+
58
+
59
+ // static methods redirecting to gateway
60
+
61
+ public static function confirm($queryString)
62
+ {
63
+ return Configuration::gateway()->transparentRedirect()->confirm($queryString);
64
+ }
65
+
66
+ public static function createCreditCardData($params)
67
+ {
68
+ return Configuration::gateway()->transparentRedirect()->createCreditCardData($params);
69
+ }
70
+
71
+ public static function createCustomerData($params)
72
+ {
73
+ return Configuration::gateway()->transparentRedirect()->createCustomerData($params);
74
+ }
75
+
76
+ public static function url()
77
+ {
78
+ return Configuration::gateway()->transparentRedirect()->url();
79
+ }
80
+
81
+ public static function transactionData($params)
82
+ {
83
+ return Configuration::gateway()->transparentRedirect()->transactionData($params);
84
+ }
85
+
86
+ public static function updateCreditCardData($params)
87
+ {
88
+ return Configuration::gateway()->transparentRedirect()->updateCreditCardData($params);
89
+ }
90
+
91
+ public static function updateCustomerData($params)
92
+ {
93
+ return Configuration::gateway()->transparentRedirect()->updateCustomerData($params);
94
+ }
95
+
96
+ public static function parseAndValidateQueryString($queryString)
97
+ {
98
+ return Configuration::gateway()->transparentRedirect()->parseAndValidateQueryString($queryString);
99
+ }
100
+ }
101
+ class_alias('Braintree\TransparentRedirect', 'Braintree_TransparentRedirect');
lib/braintree/lib/Braintree/TransparentRedirectGateway.php ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+ use DateTime;
6
+ use DateTimeZone;
7
+
8
+ /**
9
+ * Braintree Transparent Redirect Gateway module
10
+ * Static class providing methods to build Transparent Redirect urls
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ */
16
+ class TransparentRedirectGateway
17
+ {
18
+ private $_gateway;
19
+ private $_config;
20
+
21
+ public function __construct($gateway)
22
+ {
23
+ $this->_gateway = $gateway;
24
+ $this->_config = $gateway->config;
25
+ $this->_config->assertHasAccessTokenOrKeys();
26
+ }
27
+
28
+ /**
29
+ *
30
+ * @ignore
31
+ */
32
+ private static $_transparentRedirectKeys = 'redirectUrl';
33
+ private static $_createCustomerSignature;
34
+ private static $_updateCustomerSignature;
35
+ private static $_transactionSignature;
36
+ private static $_createCreditCardSignature;
37
+ private static $_updateCreditCardSignature;
38
+
39
+ /**
40
+ * create signatures for different call types
41
+ * @ignore
42
+ */
43
+ public static function init()
44
+ {
45
+
46
+ self::$_createCustomerSignature = [
47
+ self::$_transparentRedirectKeys,
48
+ ['customer' => CustomerGateway::createSignature()],
49
+ ];
50
+ self::$_updateCustomerSignature = [
51
+ self::$_transparentRedirectKeys,
52
+ 'customerId',
53
+ ['customer' => CustomerGateway::updateSignature()],
54
+ ];
55
+ self::$_transactionSignature = [
56
+ self::$_transparentRedirectKeys,
57
+ ['transaction' => TransactionGateway::createSignature()],
58
+ ];
59
+ self::$_createCreditCardSignature = [
60
+ self::$_transparentRedirectKeys,
61
+ ['creditCard' => CreditCardGateway::createSignature()],
62
+ ];
63
+ self::$_updateCreditCardSignature = [
64
+ self::$_transparentRedirectKeys,
65
+ 'paymentMethodToken',
66
+ ['creditCard' => CreditCardGateway::updateSignature()],
67
+ ];
68
+ }
69
+
70
+ public function confirm($queryString)
71
+ {
72
+ $params = TransparentRedirect::parseAndValidateQueryString(
73
+ $queryString
74
+ );
75
+ $confirmationKlasses = [
76
+ TransparentRedirect::CREATE_TRANSACTION => 'Braintree\TransactionGateway',
77
+ TransparentRedirect::CREATE_CUSTOMER => 'Braintree\CustomerGateway',
78
+ TransparentRedirect::UPDATE_CUSTOMER => 'Braintree\CustomerGateway',
79
+ TransparentRedirect::CREATE_PAYMENT_METHOD => 'Braintree\CreditCardGateway',
80
+ TransparentRedirect::UPDATE_PAYMENT_METHOD => 'Braintree\CreditCardGateway',
81
+ ];
82
+ $confirmationGateway = new $confirmationKlasses[$params["kind"]]($this->_gateway);
83
+ return $confirmationGateway->_doCreate('/transparent_redirect_requests/' . $params['id'] . '/confirm', []);
84
+ }
85
+
86
+ /**
87
+ * returns the trData string for creating a credit card,
88
+ * @param array $params
89
+ * @return string
90
+ */
91
+ public function createCreditCardData($params)
92
+ {
93
+ Util::verifyKeys(
94
+ self::$_createCreditCardSignature,
95
+ $params
96
+ );
97
+ $params["kind"] = TransparentRedirect::CREATE_PAYMENT_METHOD;
98
+ return $this->_data($params);
99
+ }
100
+
101
+ /**
102
+ * returns the trData string for creating a customer.
103
+ * @param array $params
104
+ * @return string
105
+ */
106
+ public function createCustomerData($params)
107
+ {
108
+ Util::verifyKeys(
109
+ self::$_createCustomerSignature,
110
+ $params
111
+ );
112
+ $params["kind"] = TransparentRedirect::CREATE_CUSTOMER;
113
+ return $this->_data($params);
114
+
115
+ }
116
+
117
+ public function url()
118
+ {
119
+ return $this->_config->baseUrl() . $this->_config->merchantPath() . '/transparent_redirect_requests';
120
+ }
121
+
122
+ /**
123
+ * returns the trData string for creating a transaction
124
+ * @param array $params
125
+ * @return string
126
+ */
127
+ public function transactionData($params)
128
+ {
129
+ Util::verifyKeys(
130
+ self::$_transactionSignature,
131
+ $params
132
+ );
133
+ $params["kind"] = TransparentRedirect::CREATE_TRANSACTION;
134
+ $transactionType = isset($params['transaction']['type']) ?
135
+ $params['transaction']['type'] :
136
+ null;
137
+ if ($transactionType != Transaction::SALE && $transactionType != Transaction::CREDIT) {
138
+ throw new InvalidArgumentException(
139
+ 'expected transaction[type] of sale or credit, was: ' .
140
+ $transactionType
141
+ );
142
+ }
143
+
144
+ return $this->_data($params);
145
+ }
146
+
147
+ /**
148
+ * Returns the trData string for updating a credit card.
149
+ *
150
+ * The paymentMethodToken of the credit card to update is required.
151
+ *
152
+ * <code>
153
+ * $trData = TransparentRedirect::updateCreditCardData(array(
154
+ * 'redirectUrl' => 'http://example.com/redirect_here',
155
+ * 'paymentMethodToken' => 'token123',
156
+ * ));
157
+ * </code>
158
+ *
159
+ * @param array $params
160
+ * @return string
161
+ */
162
+ public function updateCreditCardData($params)
163
+ {
164
+ Util::verifyKeys(
165
+ self::$_updateCreditCardSignature,
166
+ $params
167
+ );
168
+ if (!isset($params['paymentMethodToken'])) {
169
+ throw new InvalidArgumentException(
170
+ 'expected params to contain paymentMethodToken.'
171
+ );
172
+ }
173
+ $params["kind"] = TransparentRedirect::UPDATE_PAYMENT_METHOD;
174
+ return $this->_data($params);
175
+ }
176
+
177
+ /**
178
+ * Returns the trData string for updating a customer.
179
+ *
180
+ * The customerId of the customer to update is required.
181
+ *
182
+ * <code>
183
+ * $trData = TransparentRedirect::updateCustomerData(array(
184
+ * 'redirectUrl' => 'http://example.com/redirect_here',
185
+ * 'customerId' => 'customer123',
186
+ * ));
187
+ * </code>
188
+ *
189
+ * @param array $params
190
+ * @return string
191
+ */
192
+ public function updateCustomerData($params)
193
+ {
194
+ Util::verifyKeys(
195
+ self::$_updateCustomerSignature,
196
+ $params
197
+ );
198
+ if (!isset($params['customerId'])) {
199
+ throw new InvalidArgumentException(
200
+ 'expected params to contain customerId of customer to update'
201
+ );
202
+ }
203
+ $params["kind"] = TransparentRedirect::UPDATE_CUSTOMER;
204
+ return $this->_data($params);
205
+ }
206
+
207
+ public function parseAndValidateQueryString($queryString)
208
+ {
209
+ // parse the params into an array
210
+ parse_str($queryString, $params);
211
+ // remove the hash
212
+ $queryStringWithoutHash = null;
213
+ if (preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) {
214
+ $queryStringWithoutHash = $match[1];
215
+ }
216
+
217
+ if($params['http_status'] != '200') {
218
+ $message = null;
219
+ if(array_key_exists('bt_message', $params)) {
220
+ $message = $params['bt_message'];
221
+ }
222
+ Util::throwStatusCodeException(isset($params['http_status']) ? $params['http_status'] : null, $message);
223
+ }
224
+
225
+ // recreate the hash and compare it
226
+ if ($this->_hash($queryStringWithoutHash) == $params['hash']) {
227
+ return $params;
228
+ } else {
229
+ throw new Exception\ForgedQueryString();
230
+ }
231
+ }
232
+
233
+
234
+ /**
235
+ *
236
+ * @ignore
237
+ */
238
+ private function _data($params)
239
+ {
240
+ if (!isset($params['redirectUrl'])) {
241
+ throw new InvalidArgumentException(
242
+ 'expected params to contain redirectUrl'
243
+ );
244
+ }
245
+ $params = $this->_underscoreKeys($params);
246
+ $now = new DateTime('now', new DateTimeZone('UTC'));
247
+ $trDataParams = array_merge($params,
248
+ [
249
+ 'api_version' => Configuration::API_VERSION,
250
+ 'public_key' => $this->_config->publicKey(),
251
+ 'time' => $now->format('YmdHis'),
252
+ ]
253
+ );
254
+ ksort($trDataParams);
255
+ $urlEncodedData = http_build_query($trDataParams, null, "&");
256
+ $signatureService = new SignatureService(
257
+ $this->_config->privateKey(),
258
+ "Braintree\Digest::hexDigestSha1"
259
+ );
260
+ return $signatureService->sign($urlEncodedData);
261
+ }
262
+
263
+ private function _underscoreKeys($array)
264
+ {
265
+ foreach($array as $key=>$value)
266
+ {
267
+ $newKey = Util::camelCaseToDelimiter($key, '_');
268
+ unset($array[$key]);
269
+ if (is_array($value))
270
+ {
271
+ $array[$newKey] = $this->_underscoreKeys($value);
272
+ }
273
+ else
274
+ {
275
+ $array[$newKey] = $value;
276
+ }
277
+ }
278
+ return $array;
279
+ }
280
+
281
+ /**
282
+ * @ignore
283
+ */
284
+ private function _hash($string)
285
+ {
286
+ return Digest::hexDigestSha1($this->_config->privateKey(), $string);
287
+ }
288
+ }
289
+ TransparentRedirectGateway::init();
290
+ class_alias('Braintree\TransparentRedirectGateway', 'Braintree_TransparentRedirectGateway');
lib/braintree/lib/Braintree/UnknownPaymentMethod.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree UnknownPaymentMethod module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Manages Braintree UnknownPaymentMethod
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $token
23
+ * @property-read string $imageUrl
24
+ */
25
+ class UnknownPaymentMethod extends Base
26
+ {
27
+
28
+
29
+ /**
30
+ * factory method: returns an instance of UnknownPaymentMethod
31
+ * to the requesting method, with populated properties
32
+ *
33
+ * @ignore
34
+ * @return UnknownPaymentMethod
35
+ */
36
+ public static function factory($attributes)
37
+ {
38
+ $instance = new self();
39
+ $values = array_values($attributes);
40
+ $instance->_initialize(array_shift($values));
41
+ return $instance;
42
+ }
43
+
44
+ /* instance methods */
45
+
46
+ /**
47
+ * returns false if default is null or false
48
+ *
49
+ * @return boolean
50
+ */
51
+ public function isDefault()
52
+ {
53
+ return $this->default;
54
+ }
55
+
56
+ /**
57
+ * sets instance properties from an array of values
58
+ *
59
+ * @access protected
60
+ * @param array $unknownPaymentMethodAttribs array of unknownPaymentMethod data
61
+ * @return void
62
+ */
63
+ protected function _initialize($unknownPaymentMethodAttribs)
64
+ {
65
+ // set the attributes
66
+ $this->imageUrl = 'https://assets.braintreegateway.com/payment_method_logo/unknown.png';
67
+ $this->_attributes = $unknownPaymentMethodAttribs;
68
+ }
69
+
70
+ }
71
+ class_alias('Braintree\UnknownPaymentMethod', 'Braintree_UnknownPaymentMethod');
lib/braintree/lib/Braintree/UsBankAccount.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree UsBankAccount module
6
+ *
7
+ * @package Braintree
8
+ * @category Resources
9
+ * @copyright 2016 Braintree, a division of PayPal, Inc.
10
+ */
11
+
12
+ /**
13
+ * Manages Braintree UsBankAccounts
14
+ *
15
+ * <b>== More information ==</b>
16
+ *
17
+ *
18
+ * @package Braintree
19
+ * @category Resources
20
+ * @copyright 2016 Braintree, a division of PayPal, Inc.
21
+ *
22
+ * @property-read string $customerId
23
+ * @property-read string $email
24
+ * @property-read string $token
25
+ * @property-read string $imageUrl
26
+ * @property-read string $bankName
27
+ */
28
+ class UsBankAccount extends Base
29
+ {
30
+ /**
31
+ * factory method: returns an instance of UsBankAccount
32
+ * to the requesting method, with populated properties
33
+ *
34
+ * @ignore
35
+ * @return UsBankAccount
36
+ */
37
+ public static function factory($attributes)
38
+ {
39
+ $instance = new self();
40
+ $instance->_initialize($attributes);
41
+ return $instance;
42
+ }
43
+
44
+ /* instance methods */
45
+
46
+ /**
47
+ * sets instance properties from an array of values
48
+ *
49
+ * @access protected
50
+ * @param array $usBankAccountAttribs array of usBankAccount data
51
+ * @return void
52
+ */
53
+ protected function _initialize($usBankAccountAttribs)
54
+ {
55
+ // set the attributes
56
+ $this->_attributes = $usBankAccountAttribs;
57
+ }
58
+
59
+ /**
60
+ * create a printable representation of the object as:
61
+ * ClassName[property=value, property=value]
62
+ * @return string
63
+ */
64
+ public function __toString()
65
+ {
66
+ return __CLASS__ . '[' .
67
+ Util::attributesToString($this->_attributes) . ']';
68
+ }
69
+
70
+
71
+ // static methods redirecting to gateway
72
+
73
+ public static function find($token)
74
+ {
75
+ return Configuration::gateway()->usBankAccount()->find($token);
76
+ }
77
+
78
+ public static function sale($token, $transactionAttribs)
79
+ {
80
+ $transactionAttribs['options'] = [
81
+ 'submitForSettlement' => true
82
+ ];
83
+ return Configuration::gateway()->usBankAccount()->sale($token, $transactionAttribs);
84
+ }
85
+ }
86
+ class_alias('Braintree\UsBankAccount', 'Braintree_UsBankAccount');
lib/braintree/lib/Braintree/UsBankAccountGateway.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use InvalidArgumentException;
5
+
6
+ /**
7
+ * Braintree UsBankAccountGateway module
8
+ *
9
+ * @package Braintree
10
+ * @category Resources
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ /**
15
+ * Manages Braintree UsBankAccounts
16
+ *
17
+ * <b>== More information ==</b>
18
+ *
19
+ *
20
+ * @package Braintree
21
+ * @category Resources
22
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
23
+ */
24
+ class UsBankAccountGateway
25
+ {
26
+ private $_gateway;
27
+ private $_config;
28
+ private $_http;
29
+
30
+ public function __construct($gateway)
31
+ {
32
+ $this->_gateway = $gateway;
33
+ $this->_config = $gateway->config;
34
+ $this->_config->assertHasAccessTokenOrKeys();
35
+ $this->_http = new Http($gateway->config);
36
+ }
37
+
38
+
39
+ /**
40
+ * find a usBankAccount by token
41
+ *
42
+ * @access public
43
+ * @param string $token paypal accountunique id
44
+ * @return UsBankAccount
45
+ * @throws Exception\NotFound
46
+ */
47
+ public function find($token)
48
+ {
49
+ try {
50
+ $path = $this->_config->merchantPath() . '/payment_methods/us_bank_account/' . $token;
51
+ $response = $this->_http->get($path);
52
+ return UsBankAccount::factory($response['usBankAccount']);
53
+ } catch (Exception\NotFound $e) {
54
+ throw new Exception\NotFound(
55
+ 'US bank account with token ' . $token . ' not found'
56
+ );
57
+ }
58
+
59
+ }
60
+
61
+ /**
62
+ * create a new sale for the current UsBank account
63
+ *
64
+ * @param string $token
65
+ * @param array $transactionAttribs
66
+ * @return Result\Successful|Result\Error
67
+ * @see Transaction::sale()
68
+ */
69
+ public function sale($token, $transactionAttribs)
70
+ {
71
+ return Transaction::sale(
72
+ array_merge(
73
+ $transactionAttribs,
74
+ ['paymentMethodToken' => $token]
75
+ )
76
+ );
77
+ }
78
+
79
+ /**
80
+ * generic method for validating incoming gateway responses
81
+ *
82
+ * creates a new UsBankAccount object and encapsulates
83
+ * it inside a Result\Successful object, or
84
+ * encapsulates a Errors object inside a Result\Error
85
+ * alternatively, throws an Unexpected exception if the response is invalid.
86
+ *
87
+ * @ignore
88
+ * @param array $response gateway response values
89
+ * @return Result\Successful|Result\Error
90
+ * @throws Exception\Unexpected
91
+ */
92
+ private function _verifyGatewayResponse($response)
93
+ {
94
+ if (isset($response['usBankAccount'])) {
95
+ // return a populated instance of UsBankAccount
96
+ return new Result\Successful(
97
+ UsBankAccount::factory($response['usBankAccount'])
98
+ );
99
+ } else if (isset($response['apiErrorResponse'])) {
100
+ return new Result\Error($response['apiErrorResponse']);
101
+ } else {
102
+ throw new Exception\Unexpected(
103
+ 'Expected US bank account or apiErrorResponse'
104
+ );
105
+ }
106
+ }
107
+ }
108
+ class_alias('Braintree\UsBankAccountGateway', 'Braintree_UsBankAccountGateway');
lib/braintree/lib/Braintree/Util.php ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ use DateTime;
5
+ use InvalidArgumentException;
6
+
7
+ /**
8
+ * Braintree Utility methods
9
+ * PHP version 5
10
+ *
11
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
12
+ */
13
+
14
+ class Util
15
+ {
16
+ /**
17
+ * extracts an attribute and returns an array of objects
18
+ *
19
+ * extracts the requested element from an array, and converts the contents
20
+ * of its child arrays to objects of type $attributeName, or returns
21
+ * an array with a single element containing the value of that array element
22
+ *
23
+ * @param array $attribArray attributes from a search response
24
+ * @param string $attributeName indicates which element of the passed array to extract
25
+ * @return array array of $attributeName objects, or a single element array
26
+ */
27
+ public static function extractAttributeAsArray(&$attribArray, $attributeName)
28
+ {
29
+ if(!isset($attribArray[$attributeName])):
30
+ return [];
31
+ endif;
32
+
33
+ // get what should be an array from the passed array
34
+ $data = $attribArray[$attributeName];
35
+ // set up the class that will be used to convert each array element
36
+ $classFactory = self::buildClassName($attributeName) . '::factory';
37
+ if(is_array($data)):
38
+ // create an object from the data in each element
39
+ $objectArray = array_map($classFactory, $data);
40
+ else:
41
+ return [$data];
42
+ endif;
43
+
44
+ unset($attribArray[$attributeName]);
45
+ return $objectArray;
46
+ }
47
+ /**
48
+ * throws an exception based on the type of error
49
+ * @param string $statusCode HTTP status code to throw exception from
50
+ * @param null|string $message
51
+ * @throws Exception multiple types depending on the error
52
+ * @return void
53
+ */
54
+ public static function throwStatusCodeException($statusCode, $message=null)
55
+ {
56
+ switch($statusCode) {
57
+ case 401:
58
+ throw new Exception\Authentication();
59
+ break;
60
+ case 403:
61
+ throw new Exception\Authorization($message);
62
+ break;
63
+ case 404:
64
+ throw new Exception\NotFound();
65
+ break;
66
+ case 426:
67
+ throw new Exception\UpgradeRequired();
68
+ break;
69
+ case 429:
70
+ throw new Exception\TooManyRequests();
71
+ break;
72
+ case 500:
73
+ throw new Exception\ServerError();
74
+ break;
75
+ case 503:
76
+ throw new Exception\DownForMaintenance();
77
+ break;
78
+ default:
79
+ throw new Exception\Unexpected('Unexpected HTTP_RESPONSE #' . $statusCode);
80
+ break;
81
+ }
82
+ }
83
+
84
+ /**
85
+ *
86
+ * @param string $className
87
+ * @param object $resultObj
88
+ * @return object returns the passed object if successful
89
+ * @throws Exception\ValidationsFailed
90
+ */
91
+ public static function returnObjectOrThrowException($className, $resultObj)
92
+ {
93
+ $resultObjName = self::cleanClassName($className);
94
+ if ($resultObj->success) {
95
+ return $resultObj->$resultObjName;
96
+ } else {
97
+ throw new Exception\ValidationsFailed();
98
+ }
99
+ }
100
+
101
+ /**
102
+ * removes the header from a classname
103
+ *
104
+ * @param string $name ClassName
105
+ * @return camelCased classname minus header
106
+ */
107
+ public static function cleanClassName($name)
108
+ {
109
+ $classNamesToResponseKeys = [
110
+ 'Braintree\CreditCard' => 'creditCard',
111
+ 'Braintree_CreditCard' => 'creditCard',
112
+ 'Braintree\CreditCardGateway' => 'creditCard',
113
+ 'Braintree_CreditCardGateway' => 'creditCard',
114
+ 'Braintree\Customer' => 'customer',
115
+ 'Braintree_Customer' => 'customer',
116
+ 'Braintree\CustomerGateway' => 'customer',
117
+ 'Braintree_CustomerGateway' => 'customer',
118
+ 'Braintree\Subscription' => 'subscription',
119
+ 'Braintree_Subscription' => 'subscription',
120
+ 'Braintree\SubscriptionGateway' => 'subscription',
121
+ 'Braintree_SubscriptionGateway' => 'subscription',
122
+ 'Braintree\Transaction' => 'transaction',
123
+ 'Braintree_Transaction' => 'transaction',
124
+ 'Braintree\TransactionGateway' => 'transaction',
125
+ 'Braintree_TransactionGateway' => 'transaction',
126
+ 'Braintree\CreditCardVerification' => 'verification',
127
+ 'Braintree_CreditCardVerification' => 'verification',
128
+ 'Braintree\CreditCardVerificationGateway' => 'verification',
129
+ 'Braintree_CreditCardVerificationGateway' => 'verification',
130
+ 'Braintree\AddOn' => 'addOn',
131
+ 'Braintree_AddOn' => 'addOn',
132
+ 'Braintree\AddOnGateway' => 'addOn',
133
+ 'Braintree_AddOnGateway' => 'addOn',
134
+ 'Braintree\Discount' => 'discount',
135
+ 'Braintree_Discount' => 'discount',
136
+ 'Braintree\DiscountGateway' => 'discount',
137
+ 'Braintree_DiscountGateway' => 'discount',
138
+ 'Braintree\Plan' => 'plan',
139
+ 'Braintree_Plan' => 'plan',
140
+ 'Braintree\PlanGateway' => 'plan',
141
+ 'Braintree_PlanGateway' => 'plan',
142
+ 'Braintree\Address' => 'address',
143
+ 'Braintree_Address' => 'address',
144
+ 'Braintree\AddressGateway' => 'address',
145
+ 'Braintree_AddressGateway' => 'address',
146
+ 'Braintree\SettlementBatchSummary' => 'settlementBatchSummary',
147
+ 'Braintree_SettlementBatchSummary' => 'settlementBatchSummary',
148
+ 'Braintree\SettlementBatchSummaryGateway' => 'settlementBatchSummary',
149
+ 'Braintree_SettlementBatchSummaryGateway' => 'settlementBatchSummary',
150
+ 'Braintree\Merchant' => 'merchant',
151
+ 'Braintree_Merchant' => 'merchant',
152
+ 'Braintree\MerchantGateway' => 'merchant',
153
+ 'Braintree_MerchantGateway' => 'merchant',
154
+ 'Braintree\MerchantAccount' => 'merchantAccount',
155
+ 'Braintree_MerchantAccount' => 'merchantAccount',
156
+ 'Braintree\MerchantAccountGateway' => 'merchantAccount',
157
+ 'Braintree_MerchantAccountGateway' => 'merchantAccount',
158
+ 'Braintree\OAuthCredentials' => 'credentials',
159
+ 'Braintree_OAuthCredentials' => 'credentials',
160
+ 'Braintree\OAuthResult' => 'result',
161
+ 'Braintree_OAuthResult' => 'result',
162
+ 'Braintree\PayPalAccount' => 'paypalAccount',
163
+ 'Braintree_PayPalAccount' => 'paypalAccount',
164
+ 'Braintree\PayPalAccountGateway' => 'paypalAccount',
165
+ 'Braintree_PayPalAccountGateway' => 'paypalAccount',
166
+ ];
167
+
168
+ return $classNamesToResponseKeys[$name];
169
+ }
170
+
171
+ /**
172
+ *
173
+ * @param string $name className
174
+ * @return string ClassName
175
+ */
176
+ public static function buildClassName($name)
177
+ {
178
+ $responseKeysToClassNames = [
179
+ 'creditCard' => 'Braintree\CreditCard',
180
+ 'customer' => 'Braintree\Customer',
181
+ 'subscription' => 'Braintree\Subscription',
182
+ 'transaction' => 'Braintree\Transaction',
183
+ 'verification' => 'Braintree\CreditCardVerification',
184
+ 'addOn' => 'Braintree\AddOn',
185
+ 'discount' => 'Braintree\Discount',
186
+ 'plan' => 'Braintree\Plan',
187
+ 'address' => 'Braintree\Address',
188
+ 'settlementBatchSummary' => 'Braintree\SettlementBatchSummary',
189
+ 'merchantAccount' => 'Braintree\MerchantAccount',
190
+ ];
191
+
192
+ return (string) $responseKeysToClassNames[$name];
193
+ }
194
+
195
+ /**
196
+ * convert alpha-beta-gamma to alphaBetaGamma
197
+ *
198
+ * @access public
199
+ * @param string $string
200
+ * @param null|string $delimiter
201
+ * @return string modified string
202
+ */
203
+ public static function delimiterToCamelCase($string, $delimiter = '[\-\_]')
204
+ {
205
+ // php doesn't garbage collect functions created by create_function()
206
+ // so use a static variable to avoid adding a new function to memory
207
+ // every time this function is called.
208
+ static $callback = null;
209
+ if ($callback === null) {
210
+ $callback = create_function('$matches', 'return strtoupper($matches[1]);');
211
+ }
212
+
213
+ return preg_replace_callback('/' . $delimiter . '(\w)/', $callback, $string);
214
+ }
215
+
216
+ /**
217
+ * convert alpha-beta-gamma to alpha_beta_gamma
218
+ *
219
+ * @access public
220
+ * @param string $string
221
+ * @return string modified string
222
+ */
223
+ public static function delimiterToUnderscore($string)
224
+ {
225
+ return preg_replace('/-/', '_', $string);
226
+ }
227
+
228
+
229
+ /**
230
+ * find capitals and convert to delimiter + lowercase
231
+ *
232
+ * @access public
233
+ * @param string $string
234
+ * @param null|string $delimiter
235
+ * @return string modified string
236
+ */
237
+ public static function camelCaseToDelimiter($string, $delimiter = '-')
238
+ {
239
+ return strtolower(preg_replace('/([A-Z])/', "$delimiter\\1", $string));
240
+ }
241
+
242
+ public static function delimiterToCamelCaseArray($array, $delimiter = '[\-\_]')
243
+ {
244
+ $converted = [];
245
+ foreach ($array as $key => $value) {
246
+ if (is_string($key)) {
247
+ $key = self::delimiterToCamelCase($key, $delimiter);
248
+ }
249
+
250
+ if (is_array($value)) {
251
+ // Make an exception for custom fields, which must be underscore (can't be
252
+ // camelCase).
253
+ if ($key === 'customFields') {
254
+ $value = self::delimiterToUnderscoreArray($value);
255
+ } else {
256
+ $value = self::delimiterToCamelCaseArray($value, $delimiter);
257
+ }
258
+ }
259
+ $converted[$key] = $value;
260
+ }
261
+ return $converted;
262
+ }
263
+
264
+ public static function camelCaseToDelimiterArray($array, $delimiter = '-')
265
+ {
266
+ $converted = [];
267
+ foreach ($array as $key => $value) {
268
+ if (is_string($key)) {
269
+ $key = self::camelCaseToDelimiter($key, $delimiter);
270
+ }
271
+ if (is_array($value)) {
272
+ $value = self::camelCaseToDelimiterArray($value, $delimiter);
273
+ }
274
+ $converted[$key] = $value;
275
+ }
276
+ return $converted;
277
+ }
278
+
279
+ public static function delimiterToUnderscoreArray($array)
280
+ {
281
+ $converted = [];
282
+ foreach ($array as $key => $value) {
283
+ $key = self::delimiterToUnderscore($key);
284
+ $converted[$key] = $value;
285
+ }
286
+ return $converted;
287
+ }
288
+
289
+ /**
290
+ *
291
+ * @param array $array associative array to implode
292
+ * @param string $separator (optional, defaults to =)
293
+ * @param string $glue (optional, defaults to ', ')
294
+ * @return bool
295
+ */
296
+ public static function implodeAssociativeArray($array, $separator = '=', $glue = ', ')
297
+ {
298
+ // build a new array with joined keys and values
299
+ $tmpArray = null;
300
+ foreach ($array AS $key => $value) {
301
+ if ($value instanceof DateTime) {
302
+ $value = $value->format('r');
303
+ }
304
+ $tmpArray[] = $key . $separator . $value;
305
+ }
306
+ // implode and return the new array
307
+ return (is_array($tmpArray)) ? implode($glue, $tmpArray) : false;
308
+ }
309
+
310
+ public static function attributesToString($attributes) {
311
+ $printableAttribs = [];
312
+ foreach ($attributes AS $key => $value) {
313
+ if (is_array($value)) {
314
+ $pAttrib = self::attributesToString($value);
315
+ } else if ($value instanceof DateTime) {
316
+ $pAttrib = $value->format(DateTime::RFC850);
317
+ } else {
318
+ $pAttrib = $value;
319
+ }
320
+ $printableAttribs[$key] = sprintf('%s', $pAttrib);
321
+ }
322
+ return self::implodeAssociativeArray($printableAttribs);
323
+ }
324
+
325
+ /**
326
+ * verify user request structure
327
+ *
328
+ * compares the expected signature of a gateway request
329
+ * against the actual structure sent by the user
330
+ *
331
+ * @param array $signature
332
+ * @param array $attributes
333
+ */
334
+ public static function verifyKeys($signature, $attributes)
335
+ {
336
+ $validKeys = self::_flattenArray($signature);
337
+ $userKeys = self::_flattenUserKeys($attributes);
338
+ $invalidKeys = array_diff($userKeys, $validKeys);
339
+ $invalidKeys = self::_removeWildcardKeys($validKeys, $invalidKeys);
340
+
341
+ if(!empty($invalidKeys)) {
342
+ asort($invalidKeys);
343
+ $sortedList = join(', ', $invalidKeys);
344
+ throw new InvalidArgumentException('invalid keys: ' . $sortedList);
345
+ }
346
+ }
347
+ /**
348
+ * flattens a numerically indexed nested array to a single level
349
+ * @param array $keys
350
+ * @param string $namespace
351
+ * @return array
352
+ */
353
+ private static function _flattenArray($keys, $namespace = null)
354
+ {
355
+ $flattenedArray = [];
356
+ foreach($keys AS $key) {
357
+ if(is_array($key)) {
358
+ $theKeys = array_keys($key);
359
+ $theValues = array_values($key);
360
+ $scope = $theKeys[0];
361
+ $fullKey = empty($namespace) ? $scope : $namespace . '[' . $scope . ']';
362
+ $flattenedArray = array_merge($flattenedArray, self::_flattenArray($theValues[0], $fullKey));
363
+ } else {
364
+ $fullKey = empty($namespace) ? $key : $namespace . '[' . $key . ']';
365
+ $flattenedArray[] = $fullKey;
366
+ }
367
+ }
368
+ sort($flattenedArray);
369
+ return $flattenedArray;
370
+ }
371
+
372
+ private static function _flattenUserKeys($keys, $namespace = null)
373
+ {
374
+ $flattenedArray = [];
375
+
376
+ foreach($keys AS $key => $value) {
377
+ $fullKey = empty($namespace) ? $key : $namespace;
378
+ if (!is_numeric($key) && $namespace != null) {
379
+ $fullKey .= '[' . $key . ']';
380
+ }
381
+ if (is_numeric($key) && is_string($value)) {
382
+ $fullKey .= '[' . $value . ']';
383
+ }
384
+ if(is_array($value)) {
385
+ $more = self::_flattenUserKeys($value, $fullKey);
386
+ $flattenedArray = array_merge($flattenedArray, $more);
387
+ } else {
388
+ $flattenedArray[] = $fullKey;
389
+ }
390
+ }
391
+ sort($flattenedArray);
392
+ return $flattenedArray;
393
+ }
394
+
395
+ /**
396
+ * removes wildcard entries from the invalid keys array
397
+ * @param array $validKeys
398
+ * @param <array $invalidKeys
399
+ * @return array
400
+ */
401
+ private static function _removeWildcardKeys($validKeys, $invalidKeys)
402
+ {
403
+ foreach($validKeys AS $key) {
404
+ if (stristr($key, '[_anyKey_]')) {
405
+ $wildcardKey = str_replace('[_anyKey_]', '', $key);
406
+ foreach ($invalidKeys AS $index => $invalidKey) {
407
+ if (stristr($invalidKey, $wildcardKey)) {
408
+ unset($invalidKeys[$index]);
409
+ }
410
+ }
411
+ }
412
+ }
413
+ return $invalidKeys;
414
+ }
415
+ }
416
+ class_alias('Braintree\Util', 'Braintree_Util');
lib/braintree/lib/Braintree/VenmoAccount.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree VenmoAccount module
6
+ * Creates and manages Braintree Venmo accounts
7
+ *
8
+ * <b>== More information ==</b>
9
+ *
10
+ * See {@link https://developers.braintreepayments.com/javascript+php}<br />
11
+ *
12
+ * @package Braintree
13
+ * @category Resources
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ *
16
+ * @property-read string $createdAt
17
+ * @property-read string $default
18
+ * @property-read string $updatedAt
19
+ * @property-read string $customerId
20
+ * @property-read string $sourceDescription
21
+ * @property-read string $token
22
+ * @property-read string $imageUrl
23
+ * @property-read string $username
24
+ * @property-read string $venmoUserId
25
+ */
26
+ class VenmoAccount extends Base
27
+ {
28
+ /* instance methods */
29
+ /**
30
+ * returns false if default is null or false
31
+ *
32
+ * @return boolean
33
+ */
34
+ public function isDefault()
35
+ {
36
+ return $this->default;
37
+ }
38
+
39
+ /**
40
+ * factory method: returns an instance of VenmoAccount
41
+ * to the requesting method, with populated properties
42
+ *
43
+ * @ignore
44
+ * @return VenmoAccount
45
+ */
46
+ public static function factory($attributes)
47
+ {
48
+
49
+ $instance = new self();
50
+ $instance->_initialize($attributes);
51
+ return $instance;
52
+ }
53
+
54
+ /**
55
+ * sets instance properties from an array of values
56
+ *
57
+ * @access protected
58
+ * @param array $venmoAccountAttribs array of Venmo account properties
59
+ * @return void
60
+ */
61
+ protected function _initialize($venmoAccountAttribs)
62
+ {
63
+ $this->_attributes = $venmoAccountAttribs;
64
+
65
+ $subscriptionArray = array();
66
+ if (isset($venmoAccountAttribs['subscriptions'])) {
67
+ foreach ($venmoAccountAttribs['subscriptions'] AS $subscription) {
68
+ $subscriptionArray[] = Subscription::factory($subscription);
69
+ }
70
+ }
71
+
72
+ $this->_set('subscriptions', $subscriptionArray);
73
+ }
74
+ }
75
+ class_alias('Braintree\VenmoAccount', 'Braintree_VenmoAccount');
lib/braintree/lib/Braintree/Version.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Library Version
6
+ * stores version information about the Braintree library
7
+ *
8
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
9
+ */
10
+ class Version
11
+ {
12
+ /**
13
+ * class constants
14
+ */
15
+ const MAJOR = 3;
16
+ const MINOR = 18;
17
+ const TINY = 0;
18
+
19
+ /**
20
+ * @ignore
21
+ * @access protected
22
+ */
23
+ protected function __construct()
24
+ {
25
+ }
26
+
27
+ /**
28
+ *
29
+ * @return string the current library version
30
+ */
31
+ public static function get()
32
+ {
33
+ return self::MAJOR . '.' . self::MINOR . '.' . self::TINY;
34
+ }
35
+ }
36
+ class_alias('Braintree\Version', 'Braintree_Version');
lib/braintree/lib/Braintree/WebhookNotification.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class WebhookNotification extends Base
5
+ {
6
+ const SUBSCRIPTION_CANCELED = 'subscription_canceled';
7
+ const SUBSCRIPTION_CHARGED_SUCCESSFULLY = 'subscription_charged_successfully';
8
+ const SUBSCRIPTION_CHARGED_UNSUCCESSFULLY = 'subscription_charged_unsuccessfully';
9
+ const SUBSCRIPTION_EXPIRED = 'subscription_expired';
10
+ const SUBSCRIPTION_TRIAL_ENDED = 'subscription_trial_ended';
11
+ const SUBSCRIPTION_WENT_ACTIVE = 'subscription_went_active';
12
+ const SUBSCRIPTION_WENT_PAST_DUE = 'subscription_went_past_due';
13
+ const SUB_MERCHANT_ACCOUNT_APPROVED = 'sub_merchant_account_approved';
14
+ const SUB_MERCHANT_ACCOUNT_DECLINED = 'sub_merchant_account_declined';
15
+ const TRANSACTION_DISBURSED = 'transaction_disbursed';
16
+ const TRANSACTION_SETTLED = 'transaction_settled';
17
+ const TRANSACTION_SETTLEMENT_DECLINED = 'transaction_settlement_declined';
18
+ const DISBURSEMENT_EXCEPTION = 'disbursement_exception';
19
+ const DISBURSEMENT = 'disbursement';
20
+ const DISPUTE_OPENED = 'dispute_opened';
21
+ const DISPUTE_LOST = 'dispute_lost';
22
+ const DISPUTE_WON = 'dispute_won';
23
+ const PARTNER_MERCHANT_CONNECTED = 'partner_merchant_connected';
24
+ const PARTNER_MERCHANT_DISCONNECTED = 'partner_merchant_disconnected';
25
+ const PARTNER_MERCHANT_DECLINED = 'partner_merchant_declined';
26
+ const CHECK = 'check';
27
+ const ACCOUNT_UPDATER_DAILY_REPORT = 'account_updater_daily_report';
28
+
29
+ public static function parse($signature, $payload)
30
+ {
31
+ if (preg_match("/[^A-Za-z0-9+=\/\n]/", $payload) === 1) {
32
+ throw new Exception\InvalidSignature("payload contains illegal characters");
33
+ }
34
+
35
+ Configuration::assertGlobalHasAccessTokenOrKeys();
36
+ self::_validateSignature($signature, $payload);
37
+
38
+ $xml = base64_decode($payload);
39
+ $attributes = Xml::buildArrayFromXml($xml);
40
+ return self::factory($attributes['notification']);
41
+ }
42
+
43
+ public static function verify($challenge)
44
+ {
45
+ if (!preg_match('/^[a-f0-9]{20,32}$/', $challenge)) {
46
+ throw new Exception\InvalidChallenge("challenge contains non-hex characters");
47
+ }
48
+ Configuration::assertGlobalHasAccessTokenOrKeys();
49
+ $publicKey = Configuration::publicKey();
50
+ $digest = Digest::hexDigestSha1(Configuration::privateKey(), $challenge);
51
+ return "{$publicKey}|{$digest}";
52
+ }
53
+
54
+ public static function factory($attributes)
55
+ {
56
+ $instance = new self();
57
+ $instance->_initialize($attributes);
58
+ return $instance;
59
+ }
60
+
61
+ private static function _matchingSignature($signaturePairs)
62
+ {
63
+ foreach ($signaturePairs as $pair)
64
+ {
65
+ $components = preg_split("/\|/", $pair);
66
+ if ($components[0] == Configuration::publicKey()) {
67
+ return $components[1];
68
+ }
69
+ }
70
+
71
+ return null;
72
+ }
73
+
74
+ private static function _payloadMatches($signature, $payload)
75
+ {
76
+ $payloadSignature = Digest::hexDigestSha1(Configuration::privateKey(), $payload);
77
+ return Digest::secureCompare($signature, $payloadSignature);
78
+ }
79
+
80
+ private static function _validateSignature($signatureString, $payload)
81
+ {
82
+ $signaturePairs = preg_split("/&/", $signatureString);
83
+ $signature = self::_matchingSignature($signaturePairs);
84
+ if (!$signature) {
85
+ throw new Exception\InvalidSignature("no matching public key");
86
+ }
87
+
88
+ if (!(self::_payloadMatches($signature, $payload) || self::_payloadMatches($signature, $payload . "\n"))) {
89
+ throw new Exception\InvalidSignature("signature does not match payload - one has been modified");
90
+ }
91
+ }
92
+
93
+ protected function _initialize($attributes)
94
+ {
95
+ $this->_attributes = $attributes;
96
+
97
+ if (isset($attributes['subject']['apiErrorResponse'])) {
98
+ $wrapperNode = $attributes['subject']['apiErrorResponse'];
99
+ } else {
100
+ $wrapperNode = $attributes['subject'];
101
+ }
102
+
103
+ if (isset($wrapperNode['subscription'])) {
104
+ $this->_set('subscription', Subscription::factory($attributes['subject']['subscription']));
105
+ }
106
+
107
+ if (isset($wrapperNode['merchantAccount'])) {
108
+ $this->_set('merchantAccount', MerchantAccount::factory($wrapperNode['merchantAccount']));
109
+ }
110
+
111
+ if (isset($wrapperNode['transaction'])) {
112
+ $this->_set('transaction', Transaction::factory($wrapperNode['transaction']));
113
+ }
114
+
115
+ if (isset($wrapperNode['disbursement'])) {
116
+ $this->_set('disbursement', Disbursement::factory($wrapperNode['disbursement']));
117
+ }
118
+
119
+ if (isset($wrapperNode['partnerMerchant'])) {
120
+ $this->_set('partnerMerchant', PartnerMerchant::factory($wrapperNode['partnerMerchant']));
121
+ }
122
+
123
+ if (isset($wrapperNode['dispute'])) {
124
+ $this->_set('dispute', Dispute::factory($wrapperNode['dispute']));
125
+ }
126
+
127
+ if (isset($wrapperNode['accountUpdaterDailyReport'])) {
128
+ $this->_set('accountUpdaterDailyReport', AccountUpdaterDailyReport::factory($wrapperNode['accountUpdaterDailyReport']));
129
+ }
130
+
131
+ if (isset($wrapperNode['errors'])) {
132
+ $this->_set('errors', new Error\ValidationErrorCollection($wrapperNode['errors']));
133
+ $this->_set('message', $wrapperNode['message']);
134
+ }
135
+ }
136
+ }
137
+ class_alias('Braintree\WebhookNotification', 'Braintree_WebhookNotification');
lib/braintree/lib/Braintree/WebhookTesting.php ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ class WebhookTesting
5
+ {
6
+ public static function sampleNotification($kind, $id)
7
+ {
8
+ $payload = base64_encode(self::_sampleXml($kind, $id)) . "\n";
9
+ $signature = Configuration::publicKey() . "|" . Digest::hexDigestSha1(Configuration::privateKey(), $payload);
10
+
11
+ return [
12
+ 'bt_signature' => $signature,
13
+ 'bt_payload' => $payload
14
+ ];
15
+ }
16
+
17
+ private static function _sampleXml($kind, $id)
18
+ {
19
+ switch ($kind) {
20
+ case WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED:
21
+ $subjectXml = self::_merchantAccountApprovedSampleXml($id);
22
+ break;
23
+ case WebhookNotification::SUB_MERCHANT_ACCOUNT_DECLINED:
24
+ $subjectXml = self::_merchantAccountDeclinedSampleXml($id);
25
+ break;
26
+ case WebhookNotification::TRANSACTION_DISBURSED:
27
+ $subjectXml = self::_transactionDisbursedSampleXml($id);
28
+ break;
29
+ case WebhookNotification::TRANSACTION_SETTLED:
30
+ $subjectXml = self::_transactionSettledSampleXml($id);
31
+ break;
32
+ case WebhookNotification::TRANSACTION_SETTLEMENT_DECLINED:
33
+ $subjectXml = self::_transactionSettlementDeclinedSampleXml($id);
34
+ break;
35
+ case WebhookNotification::DISBURSEMENT_EXCEPTION:
36
+ $subjectXml = self::_disbursementExceptionSampleXml($id);
37
+ break;
38
+ case WebhookNotification::DISBURSEMENT:
39
+ $subjectXml = self::_disbursementSampleXml($id);
40
+ break;
41
+ case WebhookNotification::PARTNER_MERCHANT_CONNECTED:
42
+ $subjectXml = self::_partnerMerchantConnectedSampleXml($id);
43
+ break;
44
+ case WebhookNotification::PARTNER_MERCHANT_DISCONNECTED:
45
+ $subjectXml = self::_partnerMerchantDisconnectedSampleXml($id);
46
+ break;
47
+ case WebhookNotification::PARTNER_MERCHANT_DECLINED:
48
+ $subjectXml = self::_partnerMerchantDeclinedSampleXml($id);
49
+ break;
50
+ case WebhookNotification::DISPUTE_OPENED:
51
+ $subjectXml = self::_disputeOpenedSampleXml($id);
52
+ break;
53
+ case WebhookNotification::DISPUTE_LOST:
54
+ $subjectXml = self::_disputeLostSampleXml($id);
55
+ break;
56
+ case WebhookNotification::DISPUTE_WON:
57
+ $subjectXml = self::_disputeWonSampleXml($id);
58
+ break;
59
+ case WebhookNotification::SUBSCRIPTION_CHARGED_SUCCESSFULLY:
60
+ $subjectXml = self::_subscriptionChargedSuccessfullySampleXml($id);
61
+ break;
62
+ case WebhookNotification::CHECK:
63
+ $subjectXml = self::_checkSampleXml();
64
+ break;
65
+ case WebhookNotification::ACCOUNT_UPDATER_DAILY_REPORT:
66
+ $subjectXml = self::_accountUpdaterDailyReportSampleXml($id);
67
+ break;
68
+ default:
69
+ $subjectXml = self::_subscriptionSampleXml($id);
70
+ break;
71
+ }
72
+ $timestamp = self::_timestamp();
73
+ return "
74
+ <notification>
75
+ <timestamp type=\"datetime\">{$timestamp}</timestamp>
76
+ <kind>{$kind}</kind>
77
+ <subject>{$subjectXml}</subject>
78
+ </notification>
79
+ ";
80
+ }
81
+
82
+ private static function _merchantAccountApprovedSampleXml($id)
83
+ {
84
+ return "
85
+ <merchant_account>
86
+ <id>{$id}</id>
87
+ <master_merchant_account>
88
+ <id>master_ma_for_{$id}</id>
89
+ <status>active</status>
90
+ </master_merchant_account>
91
+ <status>active</status>
92
+ </merchant_account>
93
+ ";
94
+ }
95
+
96
+ private static function _merchantAccountDeclinedSampleXml($id)
97
+ {
98
+ return "
99
+ <api-error-response>
100
+ <message>Credit score is too low</message>
101
+ <errors>
102
+ <errors type=\"array\"/>
103
+ <merchant-account>
104
+ <errors type=\"array\">
105
+ <error>
106
+ <code>82621</code>
107
+ <message>Credit score is too low</message>
108
+ <attribute type=\"symbol\">base</attribute>
109
+ </error>
110
+ </errors>
111
+ </merchant-account>
112
+ </errors>
113
+ <merchant-account>
114
+ <id>{$id}</id>
115
+ <status>suspended</status>
116
+ <master-merchant-account>
117
+ <id>master_ma_for_{$id}</id>
118
+ <status>suspended</status>
119
+ </master-merchant-account>
120
+ </merchant-account>
121
+ </api-error-response>
122
+ ";
123
+ }
124
+
125
+ private static function _transactionDisbursedSampleXml($id)
126
+ {
127
+ return "
128
+ <transaction>
129
+ <id>${id}</id>
130
+ <amount>100</amount>
131
+ <disbursement-details>
132
+ <disbursement-date type=\"date\">2013-07-09</disbursement-date>
133
+ </disbursement-details>
134
+ </transaction>
135
+ ";
136
+ }
137
+
138
+ private static function _transactionSettledSampleXml($id)
139
+ {
140
+ return "
141
+ <transaction>
142
+ <id>${id}</id>
143
+ <status>settled</status>
144
+ <type>sale</type>
145
+ <currency-iso-code>USD</currency-iso-code>
146
+ <amount>100.00</amount>
147
+ <merchant-account-id>ogaotkivejpfayqfeaimuktty</merchant-account-id>
148
+ <payment-instrument-type>us_bank_account</payment-instrument-type>
149
+ <us-bank-account>
150
+ <routing-number>123456789</routing-number>
151
+ <last-4>1234</last-4>
152
+ <account-type>checking</account-type>
153
+ <account-description>PayPal Checking - 1234</account-description>
154
+ <account-holder-name>Dan Schulman</account-holder-name>
155
+ </us-bank-account>
156
+ </transaction>
157
+ ";
158
+ }
159
+
160
+ private static function _transactionSettlementDeclinedSampleXml($id)
161
+ {
162
+ return "
163
+ <transaction>
164
+ <id>${id}</id>
165
+ <status>settlement_declined</status>
166
+ <type>sale</type>
167
+ <currency-iso-code>USD</currency-iso-code>
168
+ <amount>100.00</amount>
169
+ <merchant-account-id>ogaotkivejpfayqfeaimuktty</merchant-account-id>
170
+ <payment-instrument-type>us_bank_account</payment-instrument-type>
171
+ <us-bank-account>
172
+ <routing-number>123456789</routing-number>
173
+ <last-4>1234</last-4>
174
+ <account-type>checking</account-type>
175
+ <account-description>PayPal Checking - 1234</account-description>
176
+ <account-holder-name>Dan Schulman</account-holder-name>
177
+ </us-bank-account>
178
+ </transaction>
179
+ ";
180
+ }
181
+
182
+ private static function _disbursementExceptionSampleXml($id)
183
+ {
184
+ return "
185
+ <disbursement>
186
+ <id>${id}</id>
187
+ <transaction-ids type=\"array\">
188
+ <item>asdfg</item>
189
+ <item>qwert</item>
190
+ </transaction-ids>
191
+ <success type=\"boolean\">false</success>
192
+ <retry type=\"boolean\">false</retry>
193
+ <merchant-account>
194
+ <id>merchant_account_token</id>
195
+ <currency-iso-code>USD</currency-iso-code>
196
+ <sub-merchant-account type=\"boolean\">false</sub-merchant-account>
197
+ <status>active</status>
198
+ </merchant-account>
199
+ <amount>100.00</amount>
200
+ <disbursement-date type=\"date\">2014-02-10</disbursement-date>
201
+ <exception-message>bank_rejected</exception-message>
202
+ <follow-up-action>update_funding_information</follow-up-action>
203
+ </disbursement>
204
+ ";
205
+ }
206
+
207
+ private static function _disbursementSampleXml($id)
208
+ {
209
+ return "
210
+ <disbursement>
211
+ <id>${id}</id>
212
+ <transaction-ids type=\"array\">
213
+ <item>asdfg</item>
214
+ <item>qwert</item>
215
+ </transaction-ids>
216
+ <success type=\"boolean\">true</success>
217
+ <retry type=\"boolean\">false</retry>
218
+ <merchant-account>
219
+ <id>merchant_account_token</id>
220
+ <currency-iso-code>USD</currency-iso-code>
221
+ <sub-merchant-account type=\"boolean\">false</sub-merchant-account>
222
+ <status>active</status>
223
+ </merchant-account>
224
+ <amount>100.00</amount>
225
+ <disbursement-date type=\"date\">2014-02-10</disbursement-date>
226
+ <exception-message nil=\"true\"/>
227
+ <follow-up-action nil=\"true\"/>
228
+ </disbursement>
229
+ ";
230
+ }
231
+
232
+ private static function _disputeOpenedSampleXml($id)
233
+ {
234
+ return "
235
+ <dispute>
236
+ <amount>250.00</amount>
237
+ <currency-iso-code>USD</currency-iso-code>
238
+ <received-date type=\"date\">2014-03-01</received-date>
239
+ <reply-by-date type=\"date\">2014-03-21</reply-by-date>
240
+ <kind>chargeback</kind>
241
+ <status>open</status>
242
+ <reason>fraud</reason>
243
+ <id>${id}</id>
244
+ <transaction>
245
+ <id>${id}</id>
246
+ <amount>250.00</amount>
247
+ </transaction>
248
+ <date-opened type=\"date\">2014-03-21</date-opened>
249
+ </dispute>
250
+ ";
251
+ }
252
+
253
+ private static function _disputeLostSampleXml($id)
254
+ {
255
+ return "
256
+ <dispute>
257
+ <amount>250.00</amount>
258
+ <currency-iso-code>USD</currency-iso-code>
259
+ <received-date type=\"date\">2014-03-01</received-date>
260
+ <reply-by-date type=\"date\">2014-03-21</reply-by-date>
261
+ <kind>chargeback</kind>
262
+ <status>lost</status>
263
+ <reason>fraud</reason>
264
+ <id>${id}</id>
265
+ <transaction>
266
+ <id>${id}</id>
267
+ <amount>250.00</amount>
268
+ <next_billing-date type=\"date\">2020-02-10</next_billing-date>
269
+ </transaction>
270
+ <date-opened type=\"date\">2014-03-21</date-opened>
271
+ </dispute>
272
+ ";
273
+ }
274
+
275
+ private static function _disputeWonSampleXml($id)
276
+ {
277
+ return "
278
+ <dispute>
279
+ <amount>250.00</amount>
280
+ <currency-iso-code>USD</currency-iso-code>
281
+ <received-date type=\"date\">2014-03-01</received-date>
282
+ <reply-by-date type=\"date\">2014-03-21</reply-by-date>
283
+ <kind>chargeback</kind>
284
+ <status>won</status>
285
+ <reason>fraud</reason>
286
+ <id>${id}</id>
287
+ <transaction>
288
+ <id>${id}</id>
289
+ <amount>250.00</amount>
290
+ </transaction>
291
+ <date-opened type=\"date\">2014-03-21</date-opened>
292
+ <date-won type=\"date\">2014-03-22</date-won>
293
+ </dispute>
294
+ ";
295
+ }
296
+
297
+ private static function _subscriptionSampleXml($id)
298
+ {
299
+ return "
300
+ <subscription>
301
+ <id>{$id}</id>
302
+ <transactions type=\"array\">
303
+ </transactions>
304
+ <add_ons type=\"array\">
305
+ </add_ons>
306
+ <discounts type=\"array\">
307
+ </discounts>
308
+ </subscription>
309
+ ";
310
+ }
311
+
312
+ private static function _subscriptionChargedSuccessfullySampleXml($id)
313
+ {
314
+ return "
315
+ <subscription>
316
+ <id>{$id}</id>
317
+ <billing-period-start-date type=\"date\">2016-03-21</billing-period-start-date>
318
+ <billing-period-end-date type=\"date\">2017-03-31</billing-period-end-date>
319
+ <transactions type=\"array\">
320
+ <transaction>
321
+ <status>submitted_for_settlement</status>
322
+ <amount>49.99</amount>
323
+ </transaction>
324
+ </transactions>
325
+ <add_ons type=\"array\">
326
+ </add_ons>
327
+ <discounts type=\"array\">
328
+ </discounts>
329
+ </subscription>
330
+ ";
331
+ }
332
+
333
+ private static function _checkSampleXml()
334
+ {
335
+ return "
336
+ <check type=\"boolean\">true</check>
337
+ ";
338
+ }
339
+
340
+ private static function _partnerMerchantConnectedSampleXml($id)
341
+ {
342
+ return "
343
+ <partner-merchant>
344
+ <merchant-public-id>public_id</merchant-public-id>
345
+ <public-key>public_key</public-key>
346
+ <private-key>private_key</private-key>
347
+ <partner-merchant-id>abc123</partner-merchant-id>
348
+ <client-side-encryption-key>cse_key</client-side-encryption-key>
349
+ </partner-merchant>
350
+ ";
351
+ }
352
+
353
+ private static function _partnerMerchantDisconnectedSampleXml($id)
354
+ {
355
+ return "
356
+ <partner-merchant>
357
+ <partner-merchant-id>abc123</partner-merchant-id>
358
+ </partner-merchant>
359
+ ";
360
+ }
361
+
362
+ private static function _partnerMerchantDeclinedSampleXml($id)
363
+ {
364
+ return "
365
+ <partner-merchant>
366
+ <partner-merchant-id>abc123</partner-merchant-id>
367
+ </partner-merchant>
368
+ ";
369
+ }
370
+
371
+ private static function _accountUpdaterDailyReportSampleXml($id)
372
+ {
373
+ return "
374
+ <account-updater-daily-report>
375
+ <report-date type=\"date\">2016-01-14</report-date>
376
+ <report-url>link-to-csv-report</report-url>
377
+ </account-updater-daily-report>
378
+ ";
379
+ }
380
+
381
+ private static function _timestamp()
382
+ {
383
+ $originalZone = date_default_timezone_get();
384
+ date_default_timezone_set('UTC');
385
+ $timestamp = strftime('%Y-%m-%dT%TZ');
386
+ date_default_timezone_set($originalZone);
387
+
388
+ return $timestamp;
389
+ }
390
+ }
391
+ class_alias('Braintree\WebhookTesting', 'Braintree_WebhookTesting');
lib/braintree/lib/Braintree/Xml.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree;
3
+
4
+ /**
5
+ * Braintree Xml parser and generator
6
+ * PHP version 5
7
+ * superclass for Braintree XML parsing and generation
8
+ *
9
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
10
+ */
11
+ class Xml
12
+ {
13
+ /**
14
+ * @ignore
15
+ */
16
+ protected function __construct()
17
+ {
18
+
19
+ }
20
+
21
+ /**
22
+ *
23
+ * @param string $xml
24
+ * @return array
25
+ */
26
+ public static function buildArrayFromXml($xml)
27
+ {
28
+ return Xml\Parser::arrayFromXml($xml);
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @param array $array
34
+ * @return string
35
+ */
36
+ public static function buildXmlFromArray($array)
37
+ {
38
+ return Xml\Generator::arrayToXml($array);
39
+ }
40
+ }
41
+ class_alias('Braintree\Xml', 'Braintree_Xml');
lib/braintree/lib/Braintree/Xml/Generator.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Xml;
3
+
4
+ use DateTime;
5
+ use DateTimeZone;
6
+ use XMLWriter;
7
+ use Braintree\Util;
8
+
9
+ /**
10
+ * PHP version 5
11
+ *
12
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
13
+ */
14
+
15
+ /**
16
+ * Generates XML output from arrays using PHP's
17
+ * built-in XMLWriter
18
+ *
19
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
20
+ */
21
+ class Generator
22
+ {
23
+ /**
24
+ * arrays passed to this method should have a single root element
25
+ * with an array as its value
26
+ * @param array $aData the array of data
27
+ * @return string XML string
28
+ */
29
+ public static function arrayToXml($aData)
30
+ {
31
+ $aData = Util::camelCaseToDelimiterArray($aData, '-');
32
+ // set up the XMLWriter
33
+ $writer = new XMLWriter();
34
+ $writer->openMemory();
35
+
36
+ $writer->setIndent(true);
37
+ $writer->setIndentString(' ');
38
+ $writer->startDocument('1.0', 'UTF-8');
39
+
40
+ // get the root element name
41
+ $aKeys = array_keys($aData);
42
+ $rootElementName = $aKeys[0];
43
+ // open the root element
44
+ $writer->startElement($rootElementName);
45
+ // create the body
46
+ self::_createElementsFromArray($writer, $aData[$rootElementName], $rootElementName);
47
+
48
+ // close the root element and document
49
+ $writer->endElement();
50
+ $writer->endDocument();
51
+
52
+ // send the output as string
53
+ return $writer->outputMemory();
54
+ }
55
+
56
+ /**
57
+ * Construct XML elements with attributes from an associative array.
58
+ *
59
+ * @access protected
60
+ * @static
61
+ * @param object $writer XMLWriter object
62
+ * @param array $aData contains attributes and values
63
+ * @return void
64
+ */
65
+ private static function _createElementsFromArray(&$writer, $aData)
66
+ {
67
+ if (!is_array($aData)) {
68
+ if (is_bool($aData)) {
69
+ $writer->text($aData ? 'true' : 'false');
70
+ } else {
71
+ $writer->text($aData);
72
+ }
73
+ return;
74
+ }
75
+ foreach ($aData AS $elementName => $element) {
76
+ // handle child elements
77
+ $writer->startElement($elementName);
78
+ if (is_array($element)) {
79
+ if (array_key_exists(0, $element) || empty($element)) {
80
+ $writer->writeAttribute('type', 'array');
81
+ foreach ($element AS $ignored => $itemInArray) {
82
+ $writer->startElement('item');
83
+ self::_createElementsFromArray($writer, $itemInArray);
84
+ $writer->endElement();
85
+ }
86
+ }
87
+ else {
88
+ self::_createElementsFromArray($writer, $element);
89
+ }
90
+ } else {
91
+ // generate attributes as needed
92
+ $attribute = self::_generateXmlAttribute($element);
93
+ if (is_array($attribute)) {
94
+ $writer->writeAttribute($attribute[0], $attribute[1]);
95
+ $element = $attribute[2];
96
+ }
97
+ $writer->text($element);
98
+ }
99
+ $writer->endElement();
100
+ }
101
+ }
102
+
103
+ /**
104
+ * convert passed data into an array of attributeType, attributeName, and value
105
+ * dates sent as DateTime objects will be converted to strings
106
+ * @access protected
107
+ * @param mixed $value
108
+ * @return array attributes and element value
109
+ */
110
+ private static function _generateXmlAttribute($value)
111
+ {
112
+ if ($value instanceof DateTime) {
113
+ return ['type', 'datetime', self::_dateTimeToXmlTimestamp($value)];
114
+ }
115
+ if (is_int($value)) {
116
+ return ['type', 'integer', $value];
117
+ }
118
+ if (is_bool($value)) {
119
+ return ['type', 'boolean', ($value ? 'true' : 'false')];
120
+ }
121
+ if ($value === NULL) {
122
+ return ['nil', 'true', $value];
123
+ }
124
+ }
125
+ /**
126
+ * converts datetime back to xml schema format
127
+ * @access protected
128
+ * @param object $dateTime
129
+ * @return string XML schema formatted timestamp
130
+ */
131
+ private static function _dateTimeToXmlTimestamp($dateTime)
132
+ {
133
+ $dateTimeForUTC = clone $dateTime;
134
+
135
+ $dateTimeForUTC->setTimeZone(new DateTimeZone('UTC'));
136
+ return ($dateTimeForUTC->format('Y-m-d\TH:i:s') . 'Z');
137
+ }
138
+
139
+ private static function _castDateTime($string)
140
+ {
141
+ try {
142
+ if (empty($string)) {
143
+ return false;
144
+ }
145
+ $dateTime = new DateTime($string);
146
+ return self::_dateTimeToXmlTimestamp($dateTime);
147
+ } catch (Exception $e) {
148
+ // not a datetime
149
+ return false;
150
+ }
151
+ }
152
+ }
153
+ class_alias('Braintree\Xml\Generator', 'Braintree_Xml_Generator');
lib/braintree/lib/Braintree/Xml/Parser.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Braintree\Xml;
3
+
4
+ use DateTime;
5
+ use DateTimeZone;
6
+ use DOMDocument;
7
+ use DOMElement;
8
+ use DOMText;
9
+ use Braintree\Util;
10
+
11
+ /**
12
+ * Braintree XML Parser
13
+ *
14
+ * @copyright 2015 Braintree, a division of PayPal, Inc.
15
+ */
16
+ class Parser
17
+ {
18
+ /**
19
+ * Converts an XML string into a multidimensional array
20
+ *
21
+ * @param string $xml
22
+ * @return array
23
+ */
24
+ public static function arrayFromXml($xml)
25
+ {
26
+ $document = new DOMDocument('1.0', 'UTF-8');
27
+ $document->loadXML($xml);
28
+
29
+ $root = $document->documentElement->nodeName;
30
+
31
+ return Util::delimiterToCamelCaseArray([
32
+ $root => self::_nodeToValue($document->childNodes->item(0)),
33
+ ]);
34
+ }
35
+
36
+ /**
37
+ * Converts a node to an array of values or nodes
38
+ *
39
+ * @param DOMNode @node
40
+ * @return mixed
41
+ */
42
+ private static function _nodeToArray($node)
43
+ {
44
+ $type = null;
45
+ if ($node instanceof DOMElement) {
46
+ $type = $node->getAttribute('type');
47
+ }
48
+
49
+ switch($type) {
50
+ case 'array':
51
+ $array = [];
52
+ foreach ($node->childNodes as $child) {
53
+ $value = self::_nodeToValue($child);
54
+ if ($value !== null) {
55
+ $array[] = $value;
56
+ }
57
+ }
58
+ return $array;
59
+ case 'collection':
60
+ $collection = [];
61
+ foreach ($node->childNodes as $child) {
62
+ $value = self::_nodetoValue($child);
63
+ if ($value !== null) {
64
+ if (!isset($collection[$child->nodeName])) {
65
+ $collection[$child->nodeName] = [];
66
+ }
67
+ $collection[$child->nodeName][] = self::_nodeToValue($child);
68
+ }
69
+ }
70
+ return $collection;
71
+ default:
72
+ $values = [];
73
+ if ($node->childNodes->length === 1 && $node->childNodes->item(0) instanceof DOMText) {
74
+ return $node->childNodes->item(0)->nodeValue;
75
+ } else {
76
+ foreach ($node->childNodes as $child) {
77
+ if (!$child instanceof DOMText) {
78
+ $values[$child->nodeName] = self::_nodeToValue($child);
79
+ }
80
+ }
81
+ return $values;
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Converts a node to a PHP value
88
+ *
89
+ * @param DOMNode $node
90
+ * @return mixed
91
+ */
92
+ private static function _nodeToValue($node)
93
+ {
94
+ $type = null;
95
+ if ($node instanceof DOMElement) {
96
+ $type = $node->getAttribute('type');
97
+ }
98
+
99
+ switch($type) {
100
+ case 'datetime':
101
+ return self::_timestampToUTC((string) $node->nodeValue);
102
+ case 'date':
103
+ return new DateTime((string) $node->nodeValue);
104
+ case 'integer':
105
+ return (int) $node->nodeValue;
106
+ case 'boolean':
107
+ $value = (string) $node->nodeValue;
108
+ if(is_numeric($value)) {
109
+ return (bool) $value;
110
+ } else {
111
+ return ($value !== "true") ? false : true;
112
+ }
113
+ case 'array':
114
+ case 'collection':
115
+ return self::_nodeToArray($node);
116
+ default:
117
+ if ($node->hasChildNodes()) {
118
+ return self::_nodeToArray($node);
119
+ } elseif (trim($node->nodeValue) === '') {
120
+ return null;
121
+ } else {
122
+ return $node->nodeValue;
123
+ }
124
+ }
125
+ }
126
+
127
+
128
+ /**
129
+ * Converts XML timestamps into DateTime instances
130
+ *
131
+ * @param string $timestamp
132
+ * @return DateTime
133
+ */
134
+ private static function _timestampToUTC($timestamp)
135
+ {
136
+ $tz = new DateTimeZone('UTC');
137
+ $dateTime = new DateTime($timestamp, $tz);
138
+ $dateTime->setTimezone($tz);
139
+ return $dateTime;
140
+ }
141
+ }
142
+ class_alias('Braintree\Xml\Parser', 'Braintree_Xml_Parser');
lib/braintree/lib/Braintree/index.html ADDED
File without changes
lib/braintree/lib/autoload.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ spl_autoload_register(function ($className) {
4
+ if (strpos($className, 'Braintree') !== 0) {
5
+ return;
6
+ }
7
+
8
+ $fileName = dirname(__DIR__) . '/lib/';
9
+
10
+ if ($lastNsPos = strripos($className, '\\')) {
11
+ $namespace = substr($className, 0, $lastNsPos);
12
+ $className = substr($className, $lastNsPos + 1);
13
+ $fileName .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
14
+ }
15
+
16
+ $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
17
+
18
+ if (is_file($fileName)) {
19
+ require_once $fileName;
20
+ }
21
+ });
lib/braintree/lib/index.html ADDED
File without changes
lib/braintree/lib/ssl/api_braintreegateway_com.ca.crt ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB
3
+ yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
4
+ ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp
5
+ U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW
6
+ ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0
7
+ aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL
8
+ MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW
9
+ ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln
10
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp
11
+ U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y
12
+ aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1
13
+ nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex
14
+ t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz
15
+ SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG
16
+ BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+
17
+ rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/
18
+ NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E
19
+ BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH
20
+ BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
21
+ aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv
22
+ MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE
23
+ p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y
24
+ 5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK
25
+ WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ
26
+ 4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N
27
+ hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
28
+ -----END CERTIFICATE-----
29
+ -----BEGIN CERTIFICATE-----
30
+ MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI
31
+ MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x
32
+ FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz
33
+ MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv
34
+ cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN
35
+ AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz
36
+ Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO
37
+ 0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao
38
+ wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj
39
+ 7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS
40
+ 8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmHursCAwEAAaOBnTCBmjAT
41
+ BgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
42
+ /zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCeg
43
+ JYYjaHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGC
44
+ NxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt3
45
+ 6Z3q059c4EVlew3KW+JwULKUBRSuSceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/
46
+ 3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHfmbx8IVQr5Fiiu1cprp6poxkm
47
+ D5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZnMUFdAvnZyPS
48
+ CPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
49
+ 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
50
+ -----END CERTIFICATE-----
51
+ -----BEGIN CERTIFICATE-----
52
+ MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx
53
+ EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT
54
+ EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp
55
+ ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz
56
+ NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH
57
+ EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE
58
+ AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw
59
+ DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD
60
+ E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH
61
+ /PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy
62
+ DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh
63
+ GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR
64
+ tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA
65
+ AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
66
+ FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX
67
+ WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu
68
+ 9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr
69
+ gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo
70
+ 2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
71
+ LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI
72
+ 4uJEvlz36hz1
73
+ -----END CERTIFICATE-----
74
+ -----BEGIN CERTIFICATE-----
75
+ MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl
76
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
77
+ d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv
78
+ b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG
79
+ EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl
80
+ cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi
81
+ MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c
82
+ JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP
83
+ mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+
84
+ wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4
85
+ VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/
86
+ AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB
87
+ AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW
88
+ BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun
89
+ pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC
90
+ dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf
91
+ fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm
92
+ NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx
93
+ H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
94
+ +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
95
+ -----END CERTIFICATE-----
96
+ -----BEGIN CERTIFICATE-----
97
+ MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
98
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
99
+ d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
100
+ QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT
101
+ MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
102
+ b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG
103
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB
104
+ CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
105
+ nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
106
+ 43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
107
+ T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
108
+ gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
109
+ BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
110
+ TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
111
+ DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr
112
+ hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg
113
+ 06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF
114
+ PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
115
+ YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
116
+ CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
117
+ -----END CERTIFICATE-----
118
+ -----BEGIN CERTIFICATE-----
119
+ MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs
120
+ MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
121
+ d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
122
+ ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL
123
+ MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3
124
+ LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug
125
+ RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm
126
+ +9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW
127
+ PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM
128
+ xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB
129
+ Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3
130
+ hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg
131
+ EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF
132
+ MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA
133
+ FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec
134
+ nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z
135
+ eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF
136
+ hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2
137
+ Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
138
+ vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep
139
+ +OkuE6N36B9K
140
+ -----END CERTIFICATE-----
141
+ -----BEGIN CERTIFICATE-----
142
+ MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW
143
+ MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy
144
+ c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE
145
+ BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0
146
+ IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV
147
+ VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8
148
+ cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT
149
+ QjOgNB0eRXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFh
150
+ F7em6fgemdtzbvQKoiFs7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2v
151
+ c7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d8Lsrlh/eezJS/R27tQahsiFepdaVaH/w
152
+ mZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7VqnJNk22CDtucvc+081xd
153
+ VHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3CgaRr0BHdCX
154
+ teGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZ
155
+ f9hBZ3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfRe
156
+ Bi9Fi1jUIxaS5BZuKGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+
157
+ nhutxx9z3SxPGWX9f5NAEC7S8O08ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB
158
+ /wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0XG0D08DYj3rWMB8GA1UdIwQY
159
+ MBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG
160
+ 9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc
161
+ aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fX
162
+ IwjhmF7DWgh2qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzyn
163
+ ANXH/KttgCJwpQzgXQQpAvvLoJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0z
164
+ uzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsKxr2EoyNB3tZ3b4XUhRxQ4K5RirqN
165
+ Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja
166
+ QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW
167
+ koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9
168
+ ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt
169
+ DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm
170
+ bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw=
171
+ -----END CERTIFICATE-----
172
+ -----BEGIN CERTIFICATE-----
173
+ MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
174
+ MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
175
+ YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG
176
+ EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg
177
+ R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9
178
+ 9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq
179
+ fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv
180
+ iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU
181
+ 1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+
182
+ bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW
183
+ MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA
184
+ ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l
185
+ uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn
186
+ Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS
187
+ tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF
188
+ PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un
189
+ hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV
190
+ 5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==
191
+ -----END CERTIFICATE-----
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: smp7, wp.insider, amijanina
3
  Donate link: https://simple-membership-plugin.com/
4
  Tags: member, members, members only, membership, memberships, register, WordPress membership plugin, content, content protection, paypal, restrict, restrict access, Restrict content, admin, access control, subscription, teaser, protection, profile, login, login page, bbpress, stripe
5
  Requires at least: 4.0
6
- Tested up to: 4.6
7
- Stable tag: 3.3.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -129,6 +129,16 @@ https://simple-membership-plugin.com/
129
 
130
  == Changelog ==
131
 
 
 
 
 
 
 
 
 
 
 
132
  = 3.3.8 =
133
  - The account renewal payment will take into account any remaining time (when the user's level is using a duration type expiry).
134
  - The members can now user their email address (instead of username) and password to log into the site. The username field of the member login form will accept either the email address or the username.
3
  Donate link: https://simple-membership-plugin.com/
4
  Tags: member, members, members only, membership, memberships, register, WordPress membership plugin, content, content protection, paypal, restrict, restrict access, Restrict content, admin, access control, subscription, teaser, protection, profile, login, login page, bbpress, stripe
5
  Requires at least: 4.0
6
+ Tested up to: 4.7
7
+ Stable tag: 3.3.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
129
 
130
  == Changelog ==
131
 
132
+ = 3.3.9 =
133
+ - Deleted the Spanish language files from the plugin folder so it can pull the language from translate.wordpress.org
134
+ - WordPress 4.7 compatibility.
135
+ - Regenerated the POT file.
136
+ - The after login redirection now uses home_url() instead of site_url(). The URL also gets passed via a filter.
137
+ - Added a new filter for the after logout redirection URL.
138
+ - Renamed the swpm-ja_JP language filename to swpmp-ja
139
+ - Added the Braintree payment gateway so you can accept membership payments using Braintree. Details in the following documentation:
140
+ https://simple-membership-plugin.com/create-braintree-buy-now-button-for-membership-payment/
141
+
142
  = 3.3.8 =
143
  - The account renewal payment will take into account any remaining time (when the user's level is using a duration type expiry).
144
  - The members can now user their email address (instead of username) and password to log into the site. The username field of the member login form will accept either the email address or the username.
simple-wp-membership.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Simple WordPress Membership
4
- Version: 3.3.8
5
  Plugin URI: https://simple-membership-plugin.com/
6
  Author: smp7, wp.insider
7
  Author URI: https://simple-membership-plugin.com/
@@ -17,7 +17,7 @@ include_once('classes/class.simple-wp-membership.php');
17
  include_once('classes/class.swpm-cronjob.php');
18
  include_once('swpm-compat.php');
19
 
20
- define('SIMPLE_WP_MEMBERSHIP_VER', '3.3.8');
21
  define('SIMPLE_WP_MEMBERSHIP_DB_VER', '1.2');
22
  define('SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url());
23
  define('SIMPLE_WP_MEMBERSHIP_PATH', dirname(__FILE__) . '/');
1
  <?php
2
  /*
3
  Plugin Name: Simple WordPress Membership
4
+ Version: 3.3.9
5
  Plugin URI: https://simple-membership-plugin.com/
6
  Author: smp7, wp.insider
7
  Author URI: https://simple-membership-plugin.com/
17
  include_once('classes/class.swpm-cronjob.php');
18
  include_once('swpm-compat.php');
19
 
20
+ define('SIMPLE_WP_MEMBERSHIP_VER', '3.3.9');
21
  define('SIMPLE_WP_MEMBERSHIP_DB_VER', '1.2');
22
  define('SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL', home_url());
23
  define('SIMPLE_WP_MEMBERSHIP_PATH', dirname(__FILE__) . '/');
views/payments/admin_create_payment_buttons.php CHANGED
@@ -5,6 +5,7 @@
5
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_paypal_buy_now_button.php');
6
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_paypal_subscription_button.php');
7
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_stripe_buy_now_button.php');
 
8
 
9
  do_action('swpm_create_new_button_process_submission');//Addons can use this hook to save the data after the form submit then redirect to the "edit" interface of that newly created button.
10
 
@@ -28,6 +29,8 @@ if (!isset($_REQUEST['swpm_button_type_selected'])) {
28
  <br />
29
  <input type="radio" name="button_type" value="stripe_buy_now"><?php SwpmUtils::e('Stripe Buy Now'); ?>
30
  <br />
 
 
31
  <?php
32
  apply_filters('swpm_new_button_select_button_type', '');
33
  ?>
5
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_paypal_buy_now_button.php');
6
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_paypal_subscription_button.php');
7
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_stripe_buy_now_button.php');
8
+ include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_braintree_buy_now_button.php');
9
 
10
  do_action('swpm_create_new_button_process_submission');//Addons can use this hook to save the data after the form submit then redirect to the "edit" interface of that newly created button.
11
 
29
  <br />
30
  <input type="radio" name="button_type" value="stripe_buy_now"><?php SwpmUtils::e('Stripe Buy Now'); ?>
31
  <br />
32
+ <input type="radio" name="button_type" value="braintree_buy_now"><?php SwpmUtils::e('Braintree Buy Now'); ?>
33
+ <br />
34
  <?php
35
  apply_filters('swpm_new_button_select_button_type', '');
36
  ?>
views/payments/admin_edit_payment_buttons.php CHANGED
@@ -4,6 +4,7 @@
4
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_paypal_buy_now_button.php');
5
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_paypal_subscription_button.php');
6
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_stripe_buy_now_button.php');
 
7
 
8
  do_action('swpm_edit_payment_button_process_submission'); //Addons can use this hook to save the data after the form submit.
9
  ?>
4
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_paypal_buy_now_button.php');
5
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_paypal_subscription_button.php');
6
  include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_stripe_buy_now_button.php');
7
+ include_once(SIMPLE_WP_MEMBERSHIP_PATH . 'views/payments/payment-gateway/admin_braintree_buy_now_button.php');
8
 
9
  do_action('swpm_edit_payment_button_process_submission'); //Addons can use this hook to save the data after the form submit.
10
  ?>
views/payments/payment-gateway/admin_braintree_buy_now_button.php ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* * ***************************************************************
3
+ * Render the new Braintree payment button creation interface
4
+ * ************************************************************** */
5
+
6
+ /*
7
+ I've optimized render function in order to avoid code duplication.
8
+ This function is responsible for rendering either Save or Edit button interface depending on the parameters.
9
+ It's much easier to modify it as the changes (descriptions update etc) are reflected in both forms at once.
10
+ */
11
+
12
+ function render_save_edit_braintree_button_interface($bt_opts, $is_edit_mode = false) {
13
+
14
+ ?>
15
+
16
+ <div class="swpm-orange-box">
17
+ View the <a target="_blank" href="https://simple-membership-plugin.com/create-braintree-buy-now-button-for-membership-payment/">documentation</a>&nbsp;
18
+ to learn how to create and use a Braintree Buy Now payment button.
19
+ </div>
20
+
21
+ <div class="postbox">
22
+ <h3 class="hndle"><label for="title"><?php echo SwpmUtils::_('Braintree Buy Now Button Configuration'); ?></label></h3>
23
+ <div class="inside">
24
+
25
+ <form id="braintree_button_config_form" method="post">
26
+ <input type="hidden" name="button_type" value="<?php echo $bt_opts['button_type']; ?>">
27
+ <?php if (!$is_edit_mode) { ?>
28
+ <input type="hidden" name="swpm_button_type_selected" value="1">
29
+ <?php } ?>
30
+
31
+ <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
32
+ <?php if ($is_edit_mode) { ?>
33
+ <tr valign="top">
34
+ <th scope="row"><?php echo SwpmUtils::_('Button ID'); ?></th>
35
+ <td>
36
+ <input type="text" size="10" name="button_id" value="<?php echo $bt_opts['button_id']; ?>" readonly required />
37
+ <p class="description">This is the ID of this payment button. It is automatically generated for you and it cannot be changed.</p>
38
+ </td>
39
+ </tr>
40
+ <?php } ?>
41
+ <tr valign="top">
42
+ <th scope="row"><?php echo SwpmUtils::_('Button Title'); ?></th>
43
+ <td>
44
+ <input type="text" size="50" name="button_name" value="<?php echo ($is_edit_mode ? $bt_opts['button_name'] : ''); ?>" required />
45
+ <p class="description">Give this membership payment button a name. Example: Gold membership payment</p>
46
+ </td>
47
+ </tr>
48
+
49
+ <tr valign="top">
50
+ <th scope="row"><?php echo SwpmUtils::_('Membership Level'); ?></th>
51
+ <td>
52
+ <select id="membership_level_id" name="membership_level_id">
53
+ <?php echo ($is_edit_mode ? SwpmUtils::membership_level_dropdown($bt_opts['membership_level_id']) : SwpmUtils::membership_level_dropdown()); ?>
54
+ </select>
55
+ <p class="description">Select the membership level this payment button is for.</p>
56
+ </td>
57
+ </tr>
58
+
59
+ <tr valign="top">
60
+ <th scope="row"><?php echo SwpmUtils::_('Payment Amount'); ?></th>
61
+ <td>
62
+ <input type="text" size="6" name="payment_amount" value="<?php echo ($is_edit_mode ? $bt_opts['payment_amount'] : ''); ?>" required />
63
+ <p class="description">Enter payment amount. Example values: 10.00 or 19.50 or 299.95 etc (do not put currency symbol).</p>
64
+ </td>
65
+ </tr>
66
+
67
+ <tr valign="top">
68
+ <th colspan="2"><div class="swpm-grey-box"><?php echo SwpmUtils::_('Braintree API key and account details. You can get this from your Braintree account.'); ?></div></th>
69
+ </tr>
70
+
71
+ <tr valign="top">
72
+ <th scope="row"><?php echo SwpmUtils::_('Merchant ID'); ?></th>
73
+ <td>
74
+ <input type="text" size="50" name="braintree_merchant_acc_id" value="<?php echo ($is_edit_mode ? $bt_opts['braintree_merchant_acc_id'] : ''); ?>" required/>
75
+ <p class="description">Enter you Braintree Merchant ID.</p>
76
+ </td>
77
+ </tr>
78
+
79
+ <tr valign="top">
80
+ <th scope="row"><?php echo SwpmUtils::_('Public Key'); ?></th>
81
+ <td>
82
+ <input type="text" size="50" name="braintree_public_key" value="<?php echo ($is_edit_mode ? $bt_opts['braintree_public_key'] : ''); ?>" required />
83
+ <p class="description">Enter your Braintree public key.</p>
84
+ </td>
85
+ </tr>
86
+ <tr valign="top">
87
+ <th scope="row"><?php echo SwpmUtils::_('Private Key'); ?></th>
88
+ <td>
89
+ <input type="text" size="50" name="braintree_private_key" value="<?php echo ($is_edit_mode ? $bt_opts['braintree_private_key'] : ''); ?>" required />
90
+ <p class="description">Enter your Braintree private key.</p>
91
+ </td>
92
+ </tr>
93
+
94
+ <tr valign="top">
95
+ <th scope="row"><?php echo SwpmUtils::_('Merchant Account ID'); ?></th>
96
+ <td>
97
+ <input type="text" size="50" name="braintree_merchant_acc_name" value="<?php echo ($is_edit_mode ? $bt_opts['braintree_merchant_acc_name'] : ''); ?>" />
98
+ <p class="description">Enter your Braintree Merchant Account ID (This is different than the Merchant ID you specified above). Please note currency depends on the Merchant Account ID you specify. Leave empty to use the default one.
99
+ <?php
100
+ if ($is_edit_mode) {
101
+ if (isset($bt_opts['currency_code']) && $bt_opts['currency_code'] != '') {
102
+ ?>
103
+ <br />The currency for this button is set to: <strong><?php echo $bt_opts['currency_code']; ?></strong>
104
+ <?php
105
+ }
106
+ }
107
+ ?>
108
+ </p>
109
+ </td>
110
+ </tr>
111
+
112
+ <tr valign="top">
113
+ <th colspan="2"><div class="swpm-grey-box"><?php echo SwpmUtils::_('The following details are optional.'); ?></div></th>
114
+ </tr>
115
+
116
+ <tr valign="top">
117
+ <th scope="row"><?php echo SwpmUtils::_('Return URL'); ?></th>
118
+ <td>
119
+ <input type="text" size="100" name="return_url" value="<?php echo ($is_edit_mode ? $bt_opts['return_url'] : ''); ?>" />
120
+ <p class="description">This is the URL the user will be redirected to after a successful payment. Enter the URL of your Thank You page here.</p>
121
+ </td>
122
+ </tr>
123
+
124
+ </table>
125
+
126
+ <p class="submit">
127
+ <input type="submit" name="swpm_braintree_buy_now_<?php echo ($is_edit_mode ? 'edit' : 'save'); ?>_submit" class="button-primary" value="<?php echo SwpmUtils::_('Save Payment Data'); ?>" >
128
+ </p>
129
+
130
+ </form>
131
+
132
+ </div>
133
+ </div>
134
+ <?php
135
+ }
136
+
137
+ /* * ***************************************************************
138
+ * Render save Braintree Buy now payment button interface
139
+ * ************************************************************** */
140
+ add_action('swpm_create_new_button_for_braintree_buy_now', 'swpm_create_new_braintree_buy_now_button');
141
+
142
+ function swpm_create_new_braintree_buy_now_button() {
143
+
144
+ //Test for PHP v5.4.0 or show error and don't show the remaining interface.
145
+ if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
146
+ //The server is using at least PHP version 5.4.0
147
+ //Can use Braintree gateway library
148
+ } else {
149
+ //This server can't handle Braintree library
150
+ echo '<div class="swpm-red-box">';
151
+ echo '<p>The Braintree payment gateway library requires at least PHP 5.4.0. Your server is using a very old version of PHP that Braintree does not support.</p>';
152
+ echo '<p>Request your hosting provider to upgrade your PHP to a more recent version then you will be able to use the Braintree gateway.<p>';
153
+ echo '</div>';
154
+ return;
155
+ }
156
+
157
+ $bt_opts = array(
158
+ 'button_type' => sanitize_text_field($_REQUEST['button_type']),
159
+ );
160
+
161
+ render_save_edit_braintree_button_interface($bt_opts);
162
+ }
163
+
164
+ /* * ***************************************************************
165
+ * Render edit Braintree Buy now payment button interface
166
+ * ************************************************************** */
167
+ add_action('swpm_edit_payment_button_for_braintree_buy_now', 'swpm_edit_braintree_buy_now_button');
168
+
169
+ function swpm_edit_braintree_buy_now_button() {
170
+
171
+ //Retrieve the payment button data and present it for editing.
172
+
173
+ $button_id = sanitize_text_field($_REQUEST['button_id']);
174
+ $button_id = absint($button_id);
175
+
176
+ $button = get_post($button_id); //Retrieve the CPT for this button
177
+ //$button_image_url = get_post_meta($button_id, 'button_image_url', true);
178
+
179
+ $bt_opts = array(
180
+ 'button_id' => $button_id,
181
+ 'button_type' => sanitize_text_field($_REQUEST['button_type']),
182
+ 'button_name' => $button->post_title,
183
+ 'membership_level_id' => get_post_meta($button_id, 'membership_level_id', true),
184
+ 'payment_amount' => get_post_meta($button_id, 'payment_amount', true),
185
+ 'braintree_merchant_acc_id' => get_post_meta($button_id, 'braintree_merchant_acc_id', true),
186
+ 'braintree_merchant_acc_name' => get_post_meta($button_id, 'braintree_merchant_acc_name', true),
187
+ 'braintree_public_key' => get_post_meta($button_id, 'braintree_public_key', true),
188
+ 'braintree_private_key' => get_post_meta($button_id, 'braintree_private_key', true),
189
+ 'return_url' => get_post_meta($button_id, 'return_url', true),
190
+ 'currency_code' => get_post_meta($button_id, 'currency_code', true),
191
+ );
192
+
193
+ render_save_edit_braintree_button_interface($bt_opts, true);
194
+ }
195
+
196
+ /*
197
+ * Process submission and save the new or edit Braintree Buy now payment button data
198
+ */
199
+
200
+ // This function tries to get Merchant Account currency
201
+ function swpm_get_braintree_default_currency($params) {
202
+ $settings = SwpmSettings::get_instance();
203
+ $sandbox_enabled = $settings->get_value('enable-sandbox-testing');
204
+
205
+ if ($sandbox_enabled) {
206
+ $braintree_env = "sandbox";
207
+ } else {
208
+ $braintree_env = "production";
209
+ }
210
+
211
+ require_once(SIMPLE_WP_MEMBERSHIP_PATH . 'lib/braintree/lib/autoload.php');
212
+ try {
213
+ Braintree_Configuration::environment($braintree_env);
214
+ Braintree_Configuration::merchantId($params['merc_id']);
215
+ Braintree_Configuration::publicKey($params['public_key']);
216
+ Braintree_Configuration::privateKey($params['private_key']);
217
+ $merchantAccount = Braintree_MerchantAccount::find($params['merc_name']);
218
+ } catch (Exception $e) {
219
+ // Something went wrong. We actually don't care what exactly happened, so we just return ''
220
+ return '';
221
+ }
222
+ return $merchantAccount->currencyIsoCode;
223
+ }
224
+
225
+ add_action('swpm_create_new_button_process_submission', 'swpm_save_edit_braintree_buy_now_button_data');
226
+ add_action('swpm_edit_payment_button_process_submission', 'swpm_save_edit_braintree_buy_now_button_data');
227
+
228
+ //I've merged two (save and edit events) into one
229
+
230
+ function swpm_save_edit_braintree_buy_now_button_data() {
231
+ if (isset($_REQUEST['swpm_braintree_buy_now_save_submit'])) {
232
+ //This is a Braintree buy now button save event.
233
+
234
+ $button_id = wp_insert_post(
235
+ array(
236
+ 'post_title' => sanitize_text_field($_REQUEST['button_name']),
237
+ 'post_type' => 'swpm_payment_button',
238
+ 'post_content' => '',
239
+ 'post_status' => 'publish'
240
+ )
241
+ );
242
+
243
+ $button_type = sanitize_text_field($_REQUEST['button_type']);
244
+ add_post_meta($button_id, 'button_type', $button_type);
245
+ add_post_meta($button_id, 'membership_level_id', sanitize_text_field($_REQUEST['membership_level_id']));
246
+ add_post_meta($button_id, 'payment_amount', trim(sanitize_text_field($_REQUEST['payment_amount'])));
247
+ add_post_meta($button_id, 'braintree_merchant_acc_name', trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_name'])));
248
+
249
+ add_post_meta($button_id, 'braintree_merchant_acc_id', trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_id'])));
250
+ add_post_meta($button_id, 'braintree_public_key', trim(sanitize_text_field($_REQUEST['braintree_public_key'])));
251
+ add_post_meta($button_id, 'braintree_private_key', trim(sanitize_text_field($_REQUEST['braintree_private_key'])));
252
+
253
+ add_post_meta($button_id, 'return_url', trim(sanitize_text_field($_REQUEST['return_url'])));
254
+ //add_post_meta($button_id, 'button_image_url', trim(sanitize_text_field($_REQUEST['button_image_url'])));
255
+ //Let's try to get currency code for current Merchant Account
256
+
257
+ $params = array(
258
+ 'merc_name' => trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_name'])),
259
+ 'merc_id' => trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_id'])),
260
+ 'public_key' => trim(sanitize_text_field($_REQUEST['braintree_public_key'])),
261
+ 'private_key' => trim(sanitize_text_field($_REQUEST['braintree_private_key'])),
262
+ );
263
+
264
+ $currency_code = swpm_get_braintree_default_currency($params);
265
+
266
+ add_post_meta($button_id, 'currency_code', $currency_code);
267
+
268
+ //Redirect to the manage payment buttons interface
269
+ $url = admin_url() . 'admin.php?page=simple_wp_membership_payments&tab=payment_buttons';
270
+ SwpmMiscUtils::redirect_to_url($url);
271
+ }
272
+
273
+ if (isset($_REQUEST['swpm_braintree_buy_now_edit_submit'])) {
274
+ //This is a Braintree buy now button edit event.
275
+ $button_id = sanitize_text_field($_REQUEST['button_id']);
276
+ $button_id = absint($button_id);
277
+ $button_type = sanitize_text_field($_REQUEST['button_type']);
278
+ $button_name = sanitize_text_field($_REQUEST['button_name']);
279
+
280
+ $button_post = array(
281
+ 'ID' => $button_id,
282
+ 'post_title' => $button_name,
283
+ 'post_type' => 'swpm_payment_button',
284
+ );
285
+ wp_update_post($button_post);
286
+
287
+ $prev_merc_acc_name = get_post_meta($button_id, 'braintree_merchant_acc_name', true);
288
+ $new_merc_acc_name = trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_name']));
289
+
290
+ update_post_meta($button_id, 'button_type', $button_type);
291
+ update_post_meta($button_id, 'membership_level_id', sanitize_text_field($_REQUEST['membership_level_id']));
292
+ update_post_meta($button_id, 'payment_amount', trim(sanitize_text_field($_REQUEST['payment_amount'])));
293
+ update_post_meta($button_id, 'braintree_merchant_acc_name', trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_name'])));
294
+
295
+ update_post_meta($button_id, 'braintree_merchant_acc_id', trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_id'])));
296
+ update_post_meta($button_id, 'braintree_public_key', trim(sanitize_text_field($_REQUEST['braintree_public_key'])));
297
+ update_post_meta($button_id, 'braintree_private_key', trim(sanitize_text_field($_REQUEST['braintree_private_key'])));
298
+
299
+ update_post_meta($button_id, 'return_url', trim(sanitize_text_field($_REQUEST['return_url'])));
300
+ //update_post_meta($button_id, 'button_image_url', trim(sanitize_text_field($_REQUEST['button_image_url'])));
301
+
302
+ if ($prev_merc_acc_name != $new_merc_acc_name) { //Looks like Merchant Account Name was modified, so let's try to request new currency code
303
+ $params = array(
304
+ 'merc_name' => trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_name'])),
305
+ 'merc_id' => trim(sanitize_text_field($_REQUEST['braintree_merchant_acc_id'])),
306
+ 'public_key' => trim(sanitize_text_field($_REQUEST['braintree_public_key'])),
307
+ 'private_key' => trim(sanitize_text_field($_REQUEST['braintree_private_key'])),
308
+ );
309
+
310
+ $currency_code = swpm_get_braintree_default_currency($params);
311
+
312
+ update_post_meta($button_id, 'currency_code', $currency_code);
313
+ }
314
+
315
+ echo '<div id="message" class="updated fade"><p>Payment button data successfully updated!</p></div>';
316
+ }
317
+ }
views/payments/payment-gateway/braintree_button_shortcode_view.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* * ************************************************
4
+ * Braintree Buy Now button shortcode handler
5
+ * *********************************************** */
6
+ add_filter('swpm_payment_button_shortcode_for_braintree_buy_now', 'swpm_render_braintree_buy_now_button_sc_output', 10, 2);
7
+
8
+ function swpm_render_braintree_buy_now_button_sc_output($button_code, $args) {
9
+
10
+ $button_id = isset($args['id']) ? $args['id'] : '';
11
+ if (empty($button_id)) {
12
+ return '<p class="swpm-red-box">Error! swpm_render_braintree_buy_now_button_sc_output() function requires the button ID value to be passed to it.</p>';
13
+ }
14
+
15
+ //Check new_window parameter
16
+ $window_target = isset($args['new_window']) ? 'target="_blank"' : '';
17
+ $button_text = (isset($args['button_text'])) ? $args['button_text'] : SwpmUtils::_('Buy Now');
18
+ $billing_address = isset($args['billing_address']) ? '1' : '';
19
+ ; //By default don't show the billing address in the checkout form.
20
+ $item_logo = ''; //Can be used to show an item logo or thumbnail in the checkout form.
21
+
22
+ $settings = SwpmSettings::get_instance();
23
+ $button_cpt = get_post($button_id); //Retrieve the CPT for this button
24
+ $item_name = htmlspecialchars($button_cpt->post_title);
25
+
26
+ $membership_level_id = get_post_meta($button_id, 'membership_level_id', true);
27
+ //Verify that this membership level exists (to prevent user paying for a level that has been deleted)
28
+ if (!SwpmUtils::membership_level_id_exists($membership_level_id)) {
29
+ return '<p class="swpm-red-box">Error! The membership level specified in this button does not exist. You may have deleted this membership level. Edit the button and use the correct membership level.</p>';
30
+ }
31
+
32
+ //Payment amount and currency
33
+ $payment_amount = get_post_meta($button_id, 'payment_amount', true);
34
+ if (!is_numeric($payment_amount)) {
35
+ return '<p class="swpm-red-box">Error! The payment amount value of the button must be a numeric number. Example: 49.50 </p>';
36
+ }
37
+ $payment_amount = round($payment_amount, 2); //round the amount to 2 decimal place.
38
+ $payment_amount_formatted = number_format($payment_amount, 2, '.', '');
39
+ $payment_currency = get_post_meta($button_id, 'currency_code', true);
40
+
41
+ //Return, cancel, notifiy URLs
42
+ $return_url = get_post_meta($button_id, 'return_url', true);
43
+ if (empty($return_url)) {
44
+ $return_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL;
45
+ }
46
+ $notify_url = SIMPLE_WP_MEMBERSHIP_SITE_HOME_URL . '/?swpm_process_braintree_buy_now=1'; //We are going to use it to do post payment processing.
47
+ //$button_image_url = get_post_meta($button_id, 'button_image_url', true);//Stripe doesn't currenty support button image for their standard checkout.
48
+ //User's IP address
49
+ $user_ip = SwpmUtils::get_user_ip_address();
50
+ $_SESSION['swpm_payment_button_interaction'] = $user_ip;
51
+
52
+ //Custom field data
53
+ $custom_field_value = 'subsc_ref=' . $membership_level_id;
54
+ $custom_field_value .= '&user_ip=' . $user_ip;
55
+ if (SwpmMemberUtils::is_member_logged_in()) {
56
+ $member_id = SwpmMemberUtils::get_logged_in_members_id();
57
+ $custom_field_value .= '&swpm_id=' . $member_id;
58
+ $member_first_name = SwpmMemberUtils::get_member_field_by_id($member_id, 'first_name');
59
+ $member_last_name = SwpmMemberUtils::get_member_field_by_id($member_id, 'last_name');
60
+ $member_email = SwpmMemberUtils::get_member_field_by_id($member_id, 'email');
61
+ }
62
+ $custom_field_value = apply_filters('swpm_custom_field_value_filter', $custom_field_value);
63
+
64
+ //Sandbox settings
65
+ $sandbox_enabled = $settings->get_value('enable-sandbox-testing');
66
+
67
+ if ($sandbox_enabled) {
68
+ $braintree_env = "sandbox";
69
+ } else {
70
+ $braintree_env = "production";
71
+ }
72
+
73
+ require_once(SIMPLE_WP_MEMBERSHIP_PATH . 'lib/braintree/lib/autoload.php');
74
+
75
+ try {
76
+ Braintree_Configuration::environment($braintree_env);
77
+ Braintree_Configuration::merchantId(get_post_meta($button_id, 'braintree_merchant_acc_id', true));
78
+ Braintree_Configuration::publicKey(get_post_meta($button_id, 'braintree_public_key', true));
79
+ Braintree_Configuration::privateKey(get_post_meta($button_id, 'braintree_private_key', true));
80
+ $clientToken = Braintree_ClientToken::generate();
81
+ } catch (Exception $e) {
82
+ $e_class = get_class($e);
83
+ $ret = 'Braintree Pay Now button error: ' . $e_class;
84
+ if ($e_class == "Braintree\Exception\Authentication")
85
+ $ret.="<br />API keys are incorrect. Double-check that you haven't accidentally tried to use your sandbox keys in production or vice-versa.";
86
+ return $ret;
87
+ }
88
+
89
+ $uniqid = uniqid(); // Get unique ID to ensure several buttons can be added to one page without conflicts
90
+
91
+ /* === Braintree Buy Now Button Form === */
92
+ $output = '';
93
+ $output .= '<div class="swpm-button-wrapper swpm-braintree-buy-now-wrapper">';
94
+ $output .= "<form action='" . $notify_url . "' METHOD='POST'> ";
95
+ $output.='<div id="swpm-form-cont-' . $uniqid . '" class="swpm-braintree-form-container swpm-form-container-' . $button_id . '" style="display:none;"></div>';
96
+ $output.='<div id="swpm-braintree-additional-fields-container-' . $uniqid . '" class="swpm-braintree-additional-fields-container swpm-braintree-additional-fields-container-' . $button_id . '" style="display:none;">';
97
+ $output.='<p><input type="text" name="first_name" placeholder="First Name" value="' . (isset($member_first_name) ? $member_first_name : '') . '" required></p>';
98
+ $output.='<p><input type="text" name="last_name" placeholder="Last Name" value="' . (isset($member_last_name) ? $member_last_name : '') . '" required></p>';
99
+ $output.='<p><input type="text" name="member_email" placeholder="Email" value="' . (isset($member_email) ? $member_email : '') . '" required></p>';
100
+ $output.='<div id="swpm-braintree-amount-container-' . $uniqid . '" class="swpm-braintree-amount-container"><p>' . $payment_amount_formatted . ' ' . $payment_currency . '</p></div>';
101
+ $output.='</div>';
102
+ $output.='<button id="swpm-show-form-btn-' . $uniqid . '" class="swpm-braintree-pay-now-button swpm-braintree-show-form-button-' . $button_id . '" type="button" onclick="swpm_braintree_show_form_' . $uniqid . '();">' . $button_text . '</button>';
103
+ $output.='<button id="swpm-submit-form-btn-' . $uniqid . '" class="swpm-braintree-pay-now-button swpm-braintree-submit-form-button-' . $button_id . '" type="submit" style="display: none;">' . $button_text . '</button>';
104
+ $output.='<script src="https://js.braintreegateway.com/js/braintree-2.30.0.min.js"></script>';
105
+ $output.='<script>';
106
+ $output .= "function swpm_braintree_show_form_" . $uniqid . "() {";
107
+ $output .= 'document.getElementById(\'swpm-show-form-btn-' . $uniqid . '\').style.display = "none";';
108
+ $output .= 'document.getElementById(\'swpm-submit-form-btn-' . $uniqid . '\').style.display = "block";';
109
+ $output .= 'document.getElementById(\'swpm-form-cont-' . $uniqid . '\').style.display = "block";';
110
+ $output.="braintree.setup('" . $clientToken . "', 'dropin', {container: 'swpm-form-cont-" . $uniqid . "', ";
111
+ $output.="onReady: function(obj){document.getElementById('swpm-braintree-additional-fields-container-" . $uniqid . "').style.display = \"block\";}});";
112
+ $output .= '}';
113
+ $output.='</script>';
114
+
115
+ $output .= wp_nonce_field('stripe_payments', '_wpnonce', true, false);
116
+ $output .= '<input type="hidden" name="item_number" value="' . $button_id . '" />';
117
+ $output .= "<input type='hidden' value='{$item_name}' name='item_name' />";
118
+ $output .= "<input type='hidden' value='{$payment_amount}' name='item_price' />";
119
+ $output .= "<input type='hidden' value='{$payment_currency}' name='currency_code' />";
120
+ $output .= "<input type='hidden' value='{$custom_field_value}' name='custom' />";
121
+
122
+ //Filter to add additional payment input fields to the form.
123
+ $output .= apply_filters('swpm_braintree_payment_form_additional_fields', '');
124
+
125
+ $output .= "</form>";
126
+ $output .= '</div>'; //End .swpm_button_wrapper
127
+
128
+ return $output;
129
+ }