Version Description
- BUG: Fixed issue with cancelling 2Checkout recurring subscriptions. Now using the payment_transaction_id to find/cancel the sale's recurring subscription since no subscription_transaction_id is being saved.
- BUG: Fixed issue where old membership levels were not listed correctly in the cancellation email. (Thanks, Mike from Migrating Eye)
- BUG: Fixed issue where "custom trial" values were not saving for discount codes.
- BUG: Fixed issue where checkouts were still processing even if there were errors with the discount code used.
- BUG: Fixed bug where settings added via the pmpro_custom_advanced_settings were not being saved to DB unless they were prefixed with custom_.
- BUG: Fixed other formatting issues with settings added via pmpro_custom_advanced_settings.
- BUG: Fixed issue where the sendInvoiceEmail method of the email class was expecting $order->discount_code to be a string, but it was sometimes a discount code object. (Thanks, Bill Stoltz)
- FEATURE: Added the pmpro_member shortcode. See the Paid Memberships Pro website for documentation.
- ENHANCEMENT: Added pmpro_account_membership_expiration_text filter to filter the expiration text that shows ona user's membership account page.
- ENHANCEMENT: Updated our Stripe and Braintree libraries to use their latest versions. This update allows our gateway integrations to support PHP7 and also removes support for PHP 5.2 and 5.3.
- ENHANCEMENT: The Braintree level compatibility check now also looks for a properly named plan.
- ENHANCEMENT: Better error handling when trying to update plugins that update against the PMPro license server.
- ENHANCEMENT: Improved Italian translation. (Thanks, Francesco Pezzotti)
- ENHANCEMENT: Improved German tranlsation. (Thanks, Simon)
- ENHANCEMENT: Added a Sweedish tranlsation. (Thanks, Mathias Persson)
- ENHANCEMENT: Added a "Chinese/Cantonese (Hong Kong SAR China)" tranlsation. (Thanks, Kai Chan)
Download this release
Release Info
Developer | strangerstudios |
Plugin | Paid Memberships Pro |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8.13.6 to 1.9
- adminpages/addons.php +27 -27
- adminpages/admin_header.php +40 -28
- adminpages/advancedsettings.php +110 -119
- adminpages/discountcodes.php +55 -53
- adminpages/emailsettings.php +22 -22
- adminpages/functions.php +28 -35
- adminpages/membershiplevels.php +66 -66
- adminpages/memberslist-csv.php +2 -2
- adminpages/memberslist.php +23 -23
- adminpages/orders-csv.php +1 -1
- adminpages/orders-print.php +1 -1
- adminpages/orders.php +88 -88
- adminpages/pagesettings.php +56 -55
- adminpages/paymentsettings.php +31 -31
- adminpages/reports.php +3 -3
- adminpages/reports/login.php +27 -27
- adminpages/reports/memberships.php +20 -20
- adminpages/reports/sales.php +19 -19
- adminpages/templates/orders-email.php +10 -10
- adminpages/templates/orders-print.php +9 -9
- adminpages/updates.php +4 -4
- classes/class.memberorder.php +26 -11
- classes/class.pmproemail.php +136 -71
- classes/gateways/class.pmprogateway.php +5 -5
- classes/gateways/class.pmprogateway_authorizenet.php +14 -14
- classes/gateways/class.pmprogateway_braintree.php +142 -44
- classes/gateways/class.pmprogateway_check.php +9 -9
- classes/gateways/class.pmprogateway_cybersource.php +10 -10
- classes/gateways/class.pmprogateway_payflowpro.php +12 -12
- classes/gateways/class.pmprogateway_paypal.php +16 -16
- classes/gateways/class.pmprogateway_paypalexpress.php +15 -15
- classes/gateways/class.pmprogateway_paypalstandard.php +12 -12
- classes/gateways/class.pmprogateway_stripe.php +90 -55
- classes/gateways/class.pmprogateway_twocheckout.php +12 -12
- includes/addons.php +96 -2
- includes/adminpages.php +26 -26
- includes/currencies.php +36 -36
- includes/functions.php +47 -44
- includes/init.php +2 -2
- includes/lib/Braintree/ACKNOWLEDGEMENTS.md +6 -0
- includes/lib/Braintree/Braintree.php +0 -172
- includes/lib/Braintree/Braintree/AddOn.php +0 -15
- includes/lib/Braintree/Braintree/Address.php +0 -352
- includes/lib/Braintree/Braintree/Configuration.php +0 -346
- includes/lib/Braintree/Braintree/CreditCard.php +0 -591
- includes/lib/Braintree/Braintree/CreditCardVerification.php +0 -41
- includes/lib/Braintree/Braintree/CreditCardVerificationSearch.php +0 -34
- includes/lib/Braintree/Braintree/Customer.php +0 -562
- includes/lib/Braintree/Braintree/CustomerSearch.php +0 -31
- includes/lib/Braintree/Braintree/Descriptor.php +0 -4
- includes/lib/Braintree/Braintree/Discount.php +0 -15
- includes/lib/Braintree/Braintree/Error/Codes.php +0 -206
- includes/lib/Braintree/Braintree/Exception.php +0 -20
- includes/lib/Braintree/Braintree/Exception/Authentication.php +0 -21
- includes/lib/Braintree/Braintree/Exception/Configuration.php +0 -20
- includes/lib/Braintree/Braintree/Exception/DownForMaintenance.php +0 -20
- includes/lib/Braintree/Braintree/Exception/ForgedQueryString.php +0 -23
- includes/lib/Braintree/Braintree/Exception/InvalidSignature.php +0 -5
- includes/lib/Braintree/Braintree/Exception/NotFound.php +0 -20
- includes/lib/Braintree/Braintree/Exception/SSLCaFileNotFound.php +0 -20
- includes/lib/Braintree/Braintree/Exception/SSLCertificate.php +0 -20
- includes/lib/Braintree/Braintree/Exception/ServerError.php +0 -20
- includes/lib/Braintree/Braintree/Exception/Unexpected.php +0 -21
- includes/lib/Braintree/Braintree/Exception/UpgradeRequired.php +0 -12
- includes/lib/Braintree/Braintree/Exception/ValidationsFailed.php +0 -21
- includes/lib/Braintree/Braintree/Http.php +0 -99
- includes/lib/Braintree/Braintree/IsNode.php +0 -22
- includes/lib/Braintree/Braintree/Modification.php +0 -23
- includes/lib/Braintree/Braintree/PartialMatchNode.php +0 -16
- includes/lib/Braintree/Braintree/Result/Successful.php +0 -78
- includes/lib/Braintree/Braintree/SettlementBatchSummary.php +0 -74
- includes/lib/Braintree/Braintree/Subscription.php +0 -256
- includes/lib/Braintree/Braintree/SubscriptionSearch.php +0 -64
- includes/lib/Braintree/Braintree/SubscriptionStatus.php +0 -0
- includes/lib/Braintree/Braintree/TextNode.php +0 -10
- includes/lib/Braintree/Braintree/Transaction.php +0 -664
- includes/lib/Braintree/Braintree/TransactionSearch.php +0 -124
- includes/lib/Braintree/Braintree/TransparentRedirect.php +0 -327
- includes/lib/Braintree/Braintree/Util.php +0 -294
- includes/lib/Braintree/Braintree/WebhookNotification.php +0 -66
- includes/lib/Braintree/Braintree/WebhookTesting.php +0 -52
- includes/lib/Braintree/Braintree/Xml/Parser.php +0 -179
- includes/lib/Braintree/CHANGELOG.md +460 -0
- includes/lib/Braintree/LICENSE +22 -0
- includes/lib/Braintree/README.md +82 -0
- includes/lib/Braintree/Rakefile +81 -0
- includes/lib/Braintree/ci.sh +11 -0
- includes/lib/Braintree/composer.json +36 -0
- includes/lib/Braintree/lib/Braintree.php +25 -0
- includes/lib/Braintree/lib/Braintree/AccountUpdaterDailyReport.php +45 -0
- includes/lib/Braintree/lib/Braintree/AchMandate.php +58 -0
- includes/lib/Braintree/lib/Braintree/AddOn.php +29 -0
- includes/lib/Braintree/lib/Braintree/AddOnGateway.php +53 -0
- includes/lib/Braintree/lib/Braintree/Address.php +151 -0
- includes/lib/Braintree/lib/Braintree/AddressGateway.php +315 -0
- includes/lib/Braintree/lib/Braintree/AmexExpressCheckoutCard.php +81 -0
- includes/lib/Braintree/lib/Braintree/AndroidPayCard.php +90 -0
- includes/lib/Braintree/lib/Braintree/ApplePayCard.php +100 -0
- includes/lib/Braintree/lib/Braintree/Base.php +77 -0
- includes/lib/Braintree/lib/Braintree/ClientToken.php +49 -0
- includes/lib/Braintree/lib/Braintree/ClientTokenGateway.php +129 -0
- includes/lib/Braintree/lib/Braintree/CoinbaseAccount.php +112 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Collection.php +14 -11
- includes/lib/Braintree/lib/Braintree/Configuration.php +578 -0
- includes/lib/Braintree/lib/Braintree/CredentialsParser.php +148 -0
- includes/lib/Braintree/lib/Braintree/CreditCard.php +316 -0
- includes/lib/Braintree/lib/Braintree/CreditCardGateway.php +487 -0
- includes/lib/Braintree/lib/Braintree/CreditCardVerification.php +43 -0
- includes/lib/Braintree/lib/Braintree/CreditCardVerificationGateway.php +74 -0
- includes/lib/Braintree/lib/Braintree/CreditCardVerificationSearch.php +56 -0
- includes/lib/Braintree/lib/Braintree/Customer.php +405 -0
- includes/lib/Braintree/lib/Braintree/CustomerGateway.php +626 -0
- includes/lib/Braintree/lib/Braintree/CustomerSearch.php +34 -0
- includes/lib/Braintree/lib/Braintree/Descriptor.php +7 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Digest.php +16 -13
- includes/lib/Braintree/lib/Braintree/Disbursement.php +52 -0
- includes/lib/Braintree/lib/Braintree/DisbursementDetails.php +25 -0
- includes/lib/Braintree/lib/Braintree/Discount.php +21 -0
- includes/lib/Braintree/lib/Braintree/DiscountGateway.php +31 -0
- includes/lib/Braintree/lib/Braintree/Dispute.php +82 -0
- includes/lib/Braintree/lib/Braintree/Dispute/TransactionDetails.php +27 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/EqualityNode.php +3 -1
- includes/lib/Braintree/lib/Braintree/Error/Codes.php +529 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Error/ErrorCollection.php +22 -16
- includes/lib/Braintree/{Braintree → lib/Braintree}/Error/Validation.php +11 -14
- includes/lib/Braintree/{Braintree → lib/Braintree}/Error/ValidationErrorCollection.php +13 -16
- includes/lib/Braintree/lib/Braintree/EuropeBankAccount.php +68 -0
- includes/lib/Braintree/lib/Braintree/Exception.php +14 -0
- includes/lib/Braintree/lib/Braintree/Exception/Authentication.php +18 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Exception/Authorization.php +6 -9
- includes/lib/Braintree/lib/Braintree/Exception/Configuration.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/DownForMaintenance.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/ForgedQueryString.php +21 -0
- includes/lib/Braintree/lib/Braintree/Exception/InvalidChallenge.php +9 -0
- includes/lib/Braintree/lib/Braintree/Exception/InvalidSignature.php +9 -0
- includes/lib/Braintree/lib/Braintree/Exception/NotFound.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/SSLCaFileNotFound.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/SSLCertificate.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/ServerError.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/TestOperationPerformedInProduction.php +16 -0
- includes/lib/Braintree/lib/Braintree/Exception/Timeout.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/TooManyRequests.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/Unexpected.php +18 -0
- includes/lib/Braintree/lib/Braintree/Exception/UpgradeRequired.php +17 -0
- includes/lib/Braintree/lib/Braintree/Exception/ValidationsFailed.php +17 -0
- includes/lib/Braintree/lib/Braintree/FacilitatorDetails.php +30 -0
- includes/lib/Braintree/lib/Braintree/Gateway.php +208 -0
- includes/lib/Braintree/lib/Braintree/Http.php +197 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Instance.php +24 -19
- includes/lib/Braintree/lib/Braintree/IsNode.php +24 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/KeyValueNode.php +6 -5
- includes/lib/Braintree/lib/Braintree/Merchant.php +36 -0
- includes/lib/Braintree/lib/Braintree/MerchantAccount.php +64 -0
- includes/lib/Braintree/lib/Braintree/MerchantAccount/AddressDetails.php +10 -0
- includes/lib/Braintree/lib/Braintree/MerchantAccount/BusinessDetails.php +23 -0
- includes/lib/Braintree/lib/Braintree/MerchantAccount/FundingDetails.php +10 -0
- includes/lib/Braintree/lib/Braintree/MerchantAccount/IndividualDetails.php +23 -0
- includes/lib/Braintree/lib/Braintree/MerchantAccountGateway.php +182 -0
- includes/lib/Braintree/lib/Braintree/MerchantGateway.php +42 -0
- includes/lib/Braintree/lib/Braintree/Modification.php +22 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/MultipleValueNode.php +11 -7
- includes/lib/Braintree/{Braintree → lib/Braintree}/MultipleValueOrTextNode.php +11 -10
- includes/lib/Braintree/lib/Braintree/OAuthCredentials.php +36 -0
- includes/lib/Braintree/lib/Braintree/OAuthGateway.php +123 -0
- includes/lib/Braintree/lib/Braintree/OAuthResult.php +36 -0
- includes/lib/Braintree/lib/Braintree/PaginatedCollection.php +111 -0
- includes/lib/Braintree/lib/Braintree/PaginatedResult.php +32 -0
- includes/lib/Braintree/lib/Braintree/PartialMatchNode.php +18 -0
- includes/lib/Braintree/lib/Braintree/PartnerMerchant.php +42 -0
- includes/lib/Braintree/lib/Braintree/PayPalAccount.php +111 -0
- includes/lib/Braintree/lib/Braintree/PayPalAccountGateway.php +180 -0
- includes/lib/Braintree/lib/Braintree/PaymentInstrumentType.php +15 -0
- includes/lib/Braintree/lib/Braintree/PaymentMethod.php +47 -0
- includes/lib/Braintree/lib/Braintree/PaymentMethodGateway.php +332 -0
- includes/lib/Braintree/lib/Braintree/PaymentMethodNonce.php +55 -0
- includes/lib/Braintree/lib/Braintree/PaymentMethodNonceGateway.php +67 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Plan.php +18 -22
- includes/lib/Braintree/lib/Braintree/PlanGateway.php +34 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/RangeNode.php +10 -8
- includes/lib/Braintree/{Braintree → lib/Braintree}/ResourceCollection.php +30 -21
- includes/lib/Braintree/{Braintree → lib/Braintree}/Result/CreditCardVerification.php +26 -13
- includes/lib/Braintree/{Braintree → lib/Braintree}/Result/Error.php +42 -25
- includes/lib/Braintree/lib/Braintree/Result/Successful.php +93 -0
- includes/lib/Braintree/lib/Braintree/RiskData.php +30 -0
- includes/lib/Braintree/lib/Braintree/SettlementBatchSummary.php +45 -0
- includes/lib/Braintree/lib/Braintree/SettlementBatchSummaryGateway.php +106 -0
- includes/lib/Braintree/lib/Braintree/SignatureService.php +24 -0
- includes/lib/Braintree/lib/Braintree/Subscription.php +141 -0
- includes/lib/Braintree/lib/Braintree/Subscription/StatusDetails.php +25 -0
- includes/lib/Braintree/lib/Braintree/SubscriptionGateway.php +215 -0
- includes/lib/Braintree/lib/Braintree/SubscriptionSearch.php +72 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Test/CreditCardNumbers.php +26 -26
- includes/lib/Braintree/lib/Braintree/Test/MerchantAccount.php +22 -0
- includes/lib/Braintree/lib/Braintree/Test/Nonces.php +70 -0
- includes/lib/Braintree/lib/Braintree/Test/Transaction.php +64 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Test/TransactionAmounts.php +4 -9
- includes/lib/Braintree/lib/Braintree/Test/VenmoSdk.php +31 -0
- includes/lib/Braintree/lib/Braintree/TestingGateway.php +52 -0
- includes/lib/Braintree/lib/Braintree/TextNode.php +12 -0
- includes/lib/Braintree/lib/Braintree/ThreeDSecureInfo.php +30 -0
- includes/lib/Braintree/lib/Braintree/Transaction.php +570 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/AddressDetails.php +7 -11
- includes/lib/Braintree/lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php +45 -0
- includes/lib/Braintree/lib/Braintree/Transaction/AndroidPayCardDetails.php +49 -0
- includes/lib/Braintree/lib/Braintree/Transaction/ApplePayCardDetails.php +41 -0
- includes/lib/Braintree/lib/Braintree/Transaction/CoinbaseDetails.php +40 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/CreditCardDetails.php +8 -12
- includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/CustomerDetails.php +7 -10
- includes/lib/Braintree/lib/Braintree/Transaction/EuropeBankAccountDetails.php +25 -0
- includes/lib/Braintree/lib/Braintree/Transaction/PayPalDetails.php +43 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/StatusDetails.php +7 -10
- includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/SubscriptionDetails.php +7 -9
- includes/lib/Braintree/lib/Braintree/Transaction/UsBankAccountDetails.php +41 -0
- includes/lib/Braintree/lib/Braintree/Transaction/VenmoAccountDetails.php +40 -0
- includes/lib/Braintree/lib/Braintree/TransactionGateway.php +530 -0
- includes/lib/Braintree/lib/Braintree/TransactionSearch.php +130 -0
- includes/lib/Braintree/lib/Braintree/TransparentRedirect.php +101 -0
- includes/lib/Braintree/lib/Braintree/TransparentRedirectGateway.php +290 -0
- includes/lib/Braintree/lib/Braintree/UnknownPaymentMethod.php +71 -0
- includes/lib/Braintree/lib/Braintree/UsBankAccount.php +97 -0
- includes/lib/Braintree/lib/Braintree/UsBankAccountGateway.php +108 -0
- includes/lib/Braintree/lib/Braintree/Util.php +416 -0
- includes/lib/Braintree/lib/Braintree/VenmoAccount.php +75 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Version.php +9 -12
- includes/lib/Braintree/lib/Braintree/WebhookNotification.php +137 -0
- includes/lib/Braintree/lib/Braintree/WebhookTesting.php +391 -0
- includes/lib/Braintree/{Braintree → lib/Braintree}/Xml.php +7 -9
- includes/lib/Braintree/{Braintree → lib/Braintree}/Xml/Generator.php +25 -16
- includes/lib/Braintree/lib/Braintree/Xml/Parser.php +142 -0
- includes/lib/Braintree/lib/autoload.php +21 -0
- includes/lib/Braintree/lib/ssl/api_braintreegateway_com.ca.crt +166 -0
adminpages/addons.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_addons")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
global $wpdb, $msg, $msgt, $pmpro_addons;
|
@@ -64,23 +64,23 @@
|
|
64 |
$addons_uninstalled[] = $addon;
|
65 |
}
|
66 |
?>
|
67 |
-
<h2><?php _e('Add Ons', '
|
68 |
|
69 |
<?php
|
70 |
pmpro_showMessage();
|
71 |
?>
|
72 |
|
73 |
<p>
|
74 |
-
<?php printf(__('Last checked on %s at %s.', '
|
75 |
-
<a class="button" href="<?php echo admin_url("admin.php?page=pmpro-addons&force-check=1&plugin_status=" . $status);?>"><?php _e('Check Again', '
|
76 |
</p>
|
77 |
|
78 |
<ul class="subsubsub">
|
79 |
-
<li class="all"><a href="admin.php?page=pmpro-addons&plugin_status=all" <?php if(empty($status) || $status == "all") { ?>class="current"<?php } ?>><?php _e('All', '
|
80 |
-
<li class="active"><a href="admin.php?page=pmpro-addons&plugin_status=active" <?php if($status == "active") { ?>class="current"<?php } ?>><?php _e('Active', '
|
81 |
-
<li class="inactive"><a href="admin.php?page=pmpro-addons&plugin_status=inactive" <?php if($status == "inactive") { ?>class="current"<?php } ?>><?php _e('Inactive', '
|
82 |
-
<li class="update"><a href="admin.php?page=pmpro-addons&plugin_status=update" <?php if($status == "update") { ?>class="current"<?php } ?>><?php _e('Update Available', '
|
83 |
-
<li class="uninstalled"><a href="admin.php?page=pmpro-addons&plugin_status=uninstalled" <?php if($status == "uninstalled") { ?>class="current"<?php } ?>><?php _e('Not Installed', '
|
84 |
</ul>
|
85 |
|
86 |
<br /><br />
|
@@ -93,9 +93,9 @@
|
|
93 |
<label class="screen-reader-text" for="cb-select-all-1"><?php _e('Select All'); ?></label><input id="cb-select-all-1" type="checkbox">
|
94 |
*/ ?>
|
95 |
</th>
|
96 |
-
<th scope="col" id="name" class="manage-column column-name" style=""><?php _e('Add On Name','
|
97 |
-
<th scope="col" id="type" class="manage-column column-type" style=""><?php _e('Type', '
|
98 |
-
<th scope="col" id="description" class="manage-column column-description" style=""><?php _e('Description', '
|
99 |
</tr>
|
100 |
</thead>
|
101 |
<tbody id="the-list">
|
@@ -118,7 +118,7 @@
|
|
118 |
?>
|
119 |
<tr>
|
120 |
<td></td>
|
121 |
-
<td colspan="3"><p><?php _e('No Add Ons found.', '
|
122 |
</tr>
|
123 |
<?php
|
124 |
}
|
@@ -179,31 +179,31 @@
|
|
179 |
if($plugin_data['License'] == 'wordpress.org')
|
180 |
{
|
181 |
//wordpress.org
|
182 |
-
$actions['install'] = '<span class="install"><a href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_data['Slug']), 'install-plugin_' . $plugin_data['Slug']) . '">' . __('Install Now', '
|
183 |
}
|
184 |
elseif($plugin_data['License'] == 'free')
|
185 |
{
|
186 |
//free
|
187 |
-
$actions['install'] = '<span class="install"><a href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_data['Slug']), 'install-plugin_' . $plugin_data['Slug']) . '">' . __('Install Now', '
|
188 |
-
$actions['download'] = '<span class="download"><a target="_blank" href="' . $plugin_data['Download'] . '?key=' . $pmpro_license_key . '">' . __('Download', '
|
189 |
}
|
190 |
elseif(empty($pmpro_license_key))
|
191 |
{
|
192 |
//no key
|
193 |
-
$actions['settings'] = '<span class="settings"><a href="' . admin_url('options-general.php?page=pmpro_license_settings') . '">' . __('Update License', '
|
194 |
-
$actions['download'] = '<span class="download"><a target="_blank" href="' . $plugin_data['PluginURI'] . '">' . __('Download', '
|
195 |
}
|
196 |
elseif(pmpro_license_isValid($pmpro_license_key, $plugin_data['License']))
|
197 |
{
|
198 |
//valid key
|
199 |
-
$actions['install'] = '<span class="install"><a href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_data['Slug']), 'install-plugin_' . $plugin_data['Slug']) . '">' . __('Install Now', '
|
200 |
-
$actions['download'] = '<span class="download"><a target="_blank" href="' . $plugin_data['Download'] . '?key=' . $pmpro_license_key . '">' . __('Download', '
|
201 |
}
|
202 |
else
|
203 |
{
|
204 |
//invalid key
|
205 |
-
$actions['settings'] = '<span class="settings"><a href="' . admin_url('options-general.php?page=pmpro_license_settings') . '">' . __('Update License', '
|
206 |
-
$actions['download'] = '<span class="download"><a target="_blank" href="' . $plugin_data['PluginURI'] . '">' . __('Download', '
|
207 |
}
|
208 |
}
|
209 |
elseif($context === 'active' || $context === 'active update')
|
@@ -223,15 +223,15 @@
|
|
223 |
<td class="column-type">
|
224 |
<?php
|
225 |
if($addon['License'] == 'free')
|
226 |
-
_e("PMPro Free",
|
227 |
elseif($addon['License'] == 'core')
|
228 |
-
_e("PMPro Core",
|
229 |
elseif($addon['License'] == 'plus')
|
230 |
-
_e("PMPro Plus",
|
231 |
elseif($addon['License'] == 'wordpress.org')
|
232 |
-
_e("WordPress.org",
|
233 |
else
|
234 |
-
_e("N/A",
|
235 |
?>
|
236 |
</td>
|
237 |
<td class="column-description desc">
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_addons")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
global $wpdb, $msg, $msgt, $pmpro_addons;
|
64 |
$addons_uninstalled[] = $addon;
|
65 |
}
|
66 |
?>
|
67 |
+
<h2><?php _e('Add Ons', 'paid-memberships-pro' ); ?></h2>
|
68 |
|
69 |
<?php
|
70 |
pmpro_showMessage();
|
71 |
?>
|
72 |
|
73 |
<p>
|
74 |
+
<?php printf(__('Last checked on %s at %s.', 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $addons_timestamp), date_i18n(get_option('time_format'), $addons_timestamp));?>
|
75 |
+
<a class="button" href="<?php echo admin_url("admin.php?page=pmpro-addons&force-check=1&plugin_status=" . $status);?>"><?php _e('Check Again', 'paid-memberships-pro' ); ?></a>
|
76 |
</p>
|
77 |
|
78 |
<ul class="subsubsub">
|
79 |
+
<li class="all"><a href="admin.php?page=pmpro-addons&plugin_status=all" <?php if(empty($status) || $status == "all") { ?>class="current"<?php } ?>><?php _e('All', 'paid-memberships-pro' ); ?> <span class="count">(<?php echo count($addons);?>)</span></a> |</li>
|
80 |
+
<li class="active"><a href="admin.php?page=pmpro-addons&plugin_status=active" <?php if($status == "active") { ?>class="current"<?php } ?>><?php _e('Active', 'paid-memberships-pro' ); ?> <span class="count">(<?php echo count($addons_active);?>)</span></a> |</li>
|
81 |
+
<li class="inactive"><a href="admin.php?page=pmpro-addons&plugin_status=inactive" <?php if($status == "inactive") { ?>class="current"<?php } ?>><?php _e('Inactive', 'paid-memberships-pro' ); ?> <span class="count">(<?php echo count($addons_inactive);?>)</span></a> |</li>
|
82 |
+
<li class="update"><a href="admin.php?page=pmpro-addons&plugin_status=update" <?php if($status == "update") { ?>class="current"<?php } ?>><?php _e('Update Available', 'paid-memberships-pro' ); ?> <span class="count">(<?php echo count($addons_update);?>)</span></a> |</li>
|
83 |
+
<li class="uninstalled"><a href="admin.php?page=pmpro-addons&plugin_status=uninstalled" <?php if($status == "uninstalled") { ?>class="current"<?php } ?>><?php _e('Not Installed', 'paid-memberships-pro' ); ?> <span class="count">(<?php echo count($addons_uninstalled);?>)</span></a></li>
|
84 |
</ul>
|
85 |
|
86 |
<br /><br />
|
93 |
<label class="screen-reader-text" for="cb-select-all-1"><?php _e('Select All'); ?></label><input id="cb-select-all-1" type="checkbox">
|
94 |
*/ ?>
|
95 |
</th>
|
96 |
+
<th scope="col" id="name" class="manage-column column-name" style=""><?php _e('Add On Name', 'paid-memberships-pro' ); ?></th>
|
97 |
+
<th scope="col" id="type" class="manage-column column-type" style=""><?php _e('Type', 'paid-memberships-pro' ); ?></th>
|
98 |
+
<th scope="col" id="description" class="manage-column column-description" style=""><?php _e('Description', 'paid-memberships-pro' ); ?></th>
|
99 |
</tr>
|
100 |
</thead>
|
101 |
<tbody id="the-list">
|
118 |
?>
|
119 |
<tr>
|
120 |
<td></td>
|
121 |
+
<td colspan="3"><p><?php _e('No Add Ons found.', 'paid-memberships-pro' ); ?></p></td>
|
122 |
</tr>
|
123 |
<?php
|
124 |
}
|
179 |
if($plugin_data['License'] == 'wordpress.org')
|
180 |
{
|
181 |
//wordpress.org
|
182 |
+
$actions['install'] = '<span class="install"><a href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_data['Slug']), 'install-plugin_' . $plugin_data['Slug']) . '">' . __('Install Now', 'paid-memberships-pro' ) . '</a></span>';
|
183 |
}
|
184 |
elseif($plugin_data['License'] == 'free')
|
185 |
{
|
186 |
//free
|
187 |
+
$actions['install'] = '<span class="install"><a href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_data['Slug']), 'install-plugin_' . $plugin_data['Slug']) . '">' . __('Install Now', 'paid-memberships-pro' ) . '</a></span>';
|
188 |
+
$actions['download'] = '<span class="download"><a target="_blank" href="' . $plugin_data['Download'] . '?key=' . $pmpro_license_key . '">' . __('Download', 'paid-memberships-pro' ) . '</a></span>';
|
189 |
}
|
190 |
elseif(empty($pmpro_license_key))
|
191 |
{
|
192 |
//no key
|
193 |
+
$actions['settings'] = '<span class="settings"><a href="' . admin_url('options-general.php?page=pmpro_license_settings') . '">' . __('Update License', 'paid-memberships-pro' ) . '</a></span>';
|
194 |
+
$actions['download'] = '<span class="download"><a target="_blank" href="' . $plugin_data['PluginURI'] . '">' . __('Download', 'paid-memberships-pro' ) . '</a></span>';
|
195 |
}
|
196 |
elseif(pmpro_license_isValid($pmpro_license_key, $plugin_data['License']))
|
197 |
{
|
198 |
//valid key
|
199 |
+
$actions['install'] = '<span class="install"><a href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $plugin_data['Slug']), 'install-plugin_' . $plugin_data['Slug']) . '">' . __('Install Now', 'paid-memberships-pro' ) . '</a></span>';
|
200 |
+
$actions['download'] = '<span class="download"><a target="_blank" href="' . $plugin_data['Download'] . '?key=' . $pmpro_license_key . '">' . __('Download', 'paid-memberships-pro' ) . '</a></span>';
|
201 |
}
|
202 |
else
|
203 |
{
|
204 |
//invalid key
|
205 |
+
$actions['settings'] = '<span class="settings"><a href="' . admin_url('options-general.php?page=pmpro_license_settings') . '">' . __('Update License', 'paid-memberships-pro' ) . '</a></span>';
|
206 |
+
$actions['download'] = '<span class="download"><a target="_blank" href="' . $plugin_data['PluginURI'] . '">' . __('Download', 'paid-memberships-pro' ) . '</a></span>';
|
207 |
}
|
208 |
}
|
209 |
elseif($context === 'active' || $context === 'active update')
|
223 |
<td class="column-type">
|
224 |
<?php
|
225 |
if($addon['License'] == 'free')
|
226 |
+
_e("PMPro Free", 'paid-memberships-pro' );
|
227 |
elseif($addon['License'] == 'core')
|
228 |
+
_e("PMPro Core", 'paid-memberships-pro' );
|
229 |
elseif($addon['License'] == 'plus')
|
230 |
+
_e("PMPro Plus", 'paid-memberships-pro' );
|
231 |
elseif($addon['License'] == 'wordpress.org')
|
232 |
+
_e("WordPress.org", 'paid-memberships-pro' );
|
233 |
else
|
234 |
+
_e("N/A", 'paid-memberships-pro' );
|
235 |
?>
|
236 |
</td>
|
237 |
<td class="column-description desc">
|
adminpages/admin_header.php
CHANGED
@@ -22,11 +22,11 @@
|
|
22 |
if(empty($msg))
|
23 |
$msg = -1;
|
24 |
if(empty($pmpro_level_ready) && empty($edit))
|
25 |
-
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels&edit=-1') . "\">" . __("Add a membership level to get started.",
|
26 |
elseif($pmpro_level_ready && !$pmpro_pages_ready && $view != "pmpro-pagesettings")
|
27 |
-
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-pagesettings') . "\">" . __("Set up the membership pages",
|
28 |
elseif($pmpro_level_ready && $pmpro_pages_ready && !$pmpro_gateway_ready && $view != "pmpro-paymentsettings")
|
29 |
-
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-paymentsettings') . "\">" . __("Set up your SSL certificate and payment gateway",
|
30 |
|
31 |
if(empty($msgt))
|
32 |
$msg = false;
|
@@ -36,7 +36,7 @@
|
|
36 |
if(!pmpro_checkLevelForStripeCompatibility())
|
37 |
{
|
38 |
$msg = -1;
|
39 |
-
$msgt = __("The billing details for some of your membership levels is not supported by Stripe.",
|
40 |
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
41 |
{
|
42 |
if(!pmpro_checkLevelForStripeCompatibility($_REQUEST['edit']))
|
@@ -44,19 +44,19 @@
|
|
44 |
global $pmpro_stripe_error;
|
45 |
$pmpro_stripe_error = true;
|
46 |
$msg = -1;
|
47 |
-
$msgt = __("The billing details for this level are not supported by Stripe. Please review the notes in the Billing Details section below.",
|
48 |
}
|
49 |
}
|
50 |
elseif($view == "pmpro-membershiplevels")
|
51 |
-
$msgt .= " " . __("The levels with issues are highlighted below.",
|
52 |
else
|
53 |
-
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels') . "\">" . __("Please edit your levels",
|
54 |
}
|
55 |
|
56 |
if(!pmpro_checkLevelForPayflowCompatibility())
|
57 |
{
|
58 |
$msg = -1;
|
59 |
-
$msgt = __("The billing details for some of your membership levels is not supported by Payflow.",
|
60 |
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
61 |
{
|
62 |
if(!pmpro_checkLevelForPayflowCompatibility($_REQUEST['edit']))
|
@@ -64,19 +64,19 @@
|
|
64 |
global $pmpro_payflow_error;
|
65 |
$pmpro_payflow_error = true;
|
66 |
$msg = -1;
|
67 |
-
$msgt = __("The billing details for this level are not supported by Payflow. Please review the notes in the Billing Details section below.",
|
68 |
}
|
69 |
}
|
70 |
elseif($view == "pmpro-membershiplevels")
|
71 |
-
$msgt .= " " . __("The levels with issues are highlighted below.",
|
72 |
else
|
73 |
-
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels') . "\">" . __("Please edit your levels",
|
74 |
}
|
75 |
|
76 |
if(!pmpro_checkLevelForBraintreeCompatibility())
|
77 |
{
|
78 |
$msg = -1;
|
79 |
-
$msgt = __("The billing details for some of your membership levels is not supported by Braintree.",
|
80 |
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
81 |
{
|
82 |
if(!pmpro_checkLevelForBraintreeCompatibility($_REQUEST['edit']))
|
@@ -84,19 +84,19 @@
|
|
84 |
global $pmpro_braintree_error;
|
85 |
$pmpro_braintree_error = true;
|
86 |
$msg = -1;
|
87 |
-
$msgt = __("The billing details for this level are not supported by Braintree. Please review the notes in the Billing Details section below.",
|
88 |
}
|
89 |
}
|
90 |
elseif($view == "pmpro-membershiplevels")
|
91 |
-
$msgt .= " " . __("The levels with issues are highlighted below.",
|
92 |
else
|
93 |
-
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels') . "\">" . __("Please edit your levels",
|
94 |
}
|
95 |
|
96 |
if(!pmpro_checkLevelForTwoCheckoutCompatibility())
|
97 |
{
|
98 |
$msg = -1;
|
99 |
-
$msgt = __("The billing details for some of your membership levels is not supported by TwoCheckout.",
|
100 |
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
101 |
{
|
102 |
if(!pmpro_checkLevelForTwoCheckoutCompatibility($_REQUEST['edit']))
|
@@ -105,21 +105,33 @@
|
|
105 |
$pmpro_twocheckout_error = true;
|
106 |
|
107 |
$msg = -1;
|
108 |
-
$msgt = __("The billing details for this level are not supported by 2Checkout. Please review the notes in the Billing Details section below.",
|
109 |
}
|
110 |
}
|
111 |
elseif($view == "pmpro-membershiplevels")
|
112 |
-
$msgt .= " " . __("The levels with issues are highlighted below.",
|
113 |
else
|
114 |
-
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels') . "\">" . __("Please edit your levels",
|
115 |
}
|
116 |
|
117 |
//check gateway dependencies
|
118 |
$gateway = pmpro_getOption('gateway');
|
119 |
-
if($gateway == "stripe") {
|
120 |
PMProGateway_stripe::dependencies();
|
121 |
-
} elseif($gateway == "braintree") {
|
122 |
PMProGateway_braintree::dependencies();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
|
125 |
if(!empty($msg))
|
@@ -133,7 +145,7 @@
|
|
133 |
<div class="wrap pmpro_admin">
|
134 |
<div class="pmpro_banner">
|
135 |
<a class="pmpro_logo" title="Paid Memberships Pro - Membership Plugin for WordPress" target="_blank" href="<?php echo pmpro_https_filter("http://www.paidmembershipspro.com")?>"><img src="<?php echo PMPRO_URL?>/images/Paid-Memberships-Pro.png" width="350" height="75" border="0" alt="Paid Memberships Pro(c) - All Rights Reserved" /></a>
|
136 |
-
<div class="pmpro_meta"><span class="pmpro_tag-grey">v<?php echo PMPRO_VERSION?></span><a target="_blank" class="pmpro_tag-blue" href="<?php echo pmpro_https_filter("http://www.paidmembershipspro.com")?>"><?php _e('Plugin Support', '
|
137 |
|
138 |
<br style="clear:both;" />
|
139 |
</div>
|
@@ -156,27 +168,27 @@
|
|
156 |
?>
|
157 |
<h2 class="nav-tab-wrapper">
|
158 |
<?php if(current_user_can('pmpro_membershiplevels')) { ?>
|
159 |
-
<a href="<?php echo admin_url('admin.php?page=pmpro-membershiplevels');?>" class="nav-tab<?php if($view == 'pmpro-membershiplevels') { ?> nav-tab-active<?php } ?>"><?php _e('Membership Levels', '
|
160 |
<?php } ?>
|
161 |
|
162 |
<?php if(current_user_can('pmpro_pagesettings')) { ?>
|
163 |
-
<a href="<?php echo admin_url('admin.php?page=pmpro-pagesettings');?>" class="nav-tab<?php if($view == 'pmpro-pagesettings') { ?> nav-tab-active<?php } ?>"><?php _e('Pages', '
|
164 |
<?php } ?>
|
165 |
|
166 |
<?php if(current_user_can('pmpro_paymentsettings')) { ?>
|
167 |
-
<a href="<?php echo admin_url('admin.php?page=pmpro-paymentsettings');?>" class="nav-tab<?php if($view == 'pmpro-paymentsettings') { ?> nav-tab-active<?php } ?>"><?php _e('Payment Gateway & SSL', '
|
168 |
<?php } ?>
|
169 |
|
170 |
<?php if(current_user_can('pmpro_emailsettings')) { ?>
|
171 |
-
<a href="<?php echo admin_url('admin.php?page=pmpro-emailsettings');?>" class="nav-tab<?php if($view == 'pmpro-emailsettings') { ?> nav-tab-active<?php } ?>"><?php _e('Email', '
|
172 |
<?php } ?>
|
173 |
|
174 |
<?php if(current_user_can('pmpro_advancedsettings')) { ?>
|
175 |
-
<a href="<?php echo admin_url('admin.php?page=pmpro-advancedsettings');?>" class="nav-tab<?php if($view == 'pmpro-advancedsettings') { ?> nav-tab-active<?php } ?>"><?php _e('Advanced', '
|
176 |
<?php } ?>
|
177 |
|
178 |
<?php if(current_user_can('pmpro_addons')) { ?>
|
179 |
-
<a href="<?php echo admin_url('admin.php?page=pmpro-addons');?>" class="nav-tab<?php if($view == 'pmpro-addons') { ?> nav-tab-active<?php } ?>"><?php _e('Add Ons', '
|
180 |
<?php } ?>
|
181 |
</h2>
|
182 |
<?php } ?>
|
22 |
if(empty($msg))
|
23 |
$msg = -1;
|
24 |
if(empty($pmpro_level_ready) && empty($edit))
|
25 |
+
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels&edit=-1') . "\">" . __("Add a membership level to get started.", 'paid-memberships-pro' ) . "</a>";
|
26 |
elseif($pmpro_level_ready && !$pmpro_pages_ready && $view != "pmpro-pagesettings")
|
27 |
+
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-pagesettings') . "\">" . __("Set up the membership pages", 'paid-memberships-pro' ) . "</a>.";
|
28 |
elseif($pmpro_level_ready && $pmpro_pages_ready && !$pmpro_gateway_ready && $view != "pmpro-paymentsettings")
|
29 |
+
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-paymentsettings') . "\">" . __("Set up your SSL certificate and payment gateway", 'paid-memberships-pro' ) . "</a>.";
|
30 |
|
31 |
if(empty($msgt))
|
32 |
$msg = false;
|
36 |
if(!pmpro_checkLevelForStripeCompatibility())
|
37 |
{
|
38 |
$msg = -1;
|
39 |
+
$msgt = __("The billing details for some of your membership levels is not supported by Stripe.", 'paid-memberships-pro' );
|
40 |
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
41 |
{
|
42 |
if(!pmpro_checkLevelForStripeCompatibility($_REQUEST['edit']))
|
44 |
global $pmpro_stripe_error;
|
45 |
$pmpro_stripe_error = true;
|
46 |
$msg = -1;
|
47 |
+
$msgt = __("The billing details for this level are not supported by Stripe. Please review the notes in the Billing Details section below.", 'paid-memberships-pro' );
|
48 |
}
|
49 |
}
|
50 |
elseif($view == "pmpro-membershiplevels")
|
51 |
+
$msgt .= " " . __("The levels with issues are highlighted below.", 'paid-memberships-pro' );
|
52 |
else
|
53 |
+
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels') . "\">" . __("Please edit your levels", 'paid-memberships-pro' ) . "</a>.";
|
54 |
}
|
55 |
|
56 |
if(!pmpro_checkLevelForPayflowCompatibility())
|
57 |
{
|
58 |
$msg = -1;
|
59 |
+
$msgt = __("The billing details for some of your membership levels is not supported by Payflow.", 'paid-memberships-pro' );
|
60 |
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
61 |
{
|
62 |
if(!pmpro_checkLevelForPayflowCompatibility($_REQUEST['edit']))
|
64 |
global $pmpro_payflow_error;
|
65 |
$pmpro_payflow_error = true;
|
66 |
$msg = -1;
|
67 |
+
$msgt = __("The billing details for this level are not supported by Payflow. Please review the notes in the Billing Details section below.", 'paid-memberships-pro' );
|
68 |
}
|
69 |
}
|
70 |
elseif($view == "pmpro-membershiplevels")
|
71 |
+
$msgt .= " " . __("The levels with issues are highlighted below.", 'paid-memberships-pro' );
|
72 |
else
|
73 |
+
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels') . "\">" . __("Please edit your levels", 'paid-memberships-pro' ) . "</a>.";
|
74 |
}
|
75 |
|
76 |
if(!pmpro_checkLevelForBraintreeCompatibility())
|
77 |
{
|
78 |
$msg = -1;
|
79 |
+
$msgt = __("The billing details for some of your membership levels is not supported by Braintree.", 'paid-memberships-pro' );
|
80 |
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
81 |
{
|
82 |
if(!pmpro_checkLevelForBraintreeCompatibility($_REQUEST['edit']))
|
84 |
global $pmpro_braintree_error;
|
85 |
$pmpro_braintree_error = true;
|
86 |
$msg = -1;
|
87 |
+
$msgt = __("The billing details for this level are not supported by Braintree. Please review the notes in the Billing Details section below.", 'paid-memberships-pro' );
|
88 |
}
|
89 |
}
|
90 |
elseif($view == "pmpro-membershiplevels")
|
91 |
+
$msgt .= " " . __("The levels with issues are highlighted below.", 'paid-memberships-pro' );
|
92 |
else
|
93 |
+
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels') . "\">" . __("Please edit your levels", 'paid-memberships-pro' ) . "</a>.";
|
94 |
}
|
95 |
|
96 |
if(!pmpro_checkLevelForTwoCheckoutCompatibility())
|
97 |
{
|
98 |
$msg = -1;
|
99 |
+
$msgt = __("The billing details for some of your membership levels is not supported by TwoCheckout.", 'paid-memberships-pro' );
|
100 |
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
101 |
{
|
102 |
if(!pmpro_checkLevelForTwoCheckoutCompatibility($_REQUEST['edit']))
|
105 |
$pmpro_twocheckout_error = true;
|
106 |
|
107 |
$msg = -1;
|
108 |
+
$msgt = __("The billing details for this level are not supported by 2Checkout. Please review the notes in the Billing Details section below.", 'paid-memberships-pro' );
|
109 |
}
|
110 |
}
|
111 |
elseif($view == "pmpro-membershiplevels")
|
112 |
+
$msgt .= " " . __("The levels with issues are highlighted below.", 'paid-memberships-pro' );
|
113 |
else
|
114 |
+
$msgt .= " <a href=\"" . admin_url('admin.php?page=pmpro-membershiplevels') . "\">" . __("Please edit your levels", 'paid-memberships-pro' ) . "</a>.";
|
115 |
}
|
116 |
|
117 |
//check gateway dependencies
|
118 |
$gateway = pmpro_getOption('gateway');
|
119 |
+
if($gateway == "stripe" && version_compare( PHP_VERSION, '5.3.29', '>=' ) ) {
|
120 |
PMProGateway_stripe::dependencies();
|
121 |
+
} elseif($gateway == "braintree" && version_compare( PHP_VERSION, '5.4.45', '>=' ) ) {
|
122 |
PMProGateway_braintree::dependencies();
|
123 |
+
} elseif($gateway == "stripe" && version_compare( PHP_VERSION, '5.3.29', '<' ) ) {
|
124 |
+
$msg = -1;
|
125 |
+
$msgt = sprintf(__("The Stripe Gateway requires PHP 5.3.29 or greater. We recommend upgrading to PHP %s or greater. Ask your host to upgrade.", "paid-memberships-pro" ), PMPRO_MIN_PHP_VERSION );
|
126 |
+
} elseif($gateway == "braintree" && version_compare( PHP_VERSION, '5.4.45', '<' ) ) {
|
127 |
+
$msg = -1;
|
128 |
+
$msgt = sprintf(__("The Braintree Gateway requires PHP 5.4.45 or greater. We recommend upgrading to PHP %s or greater. Ask your host to upgrade.", "paid-memberships-pro" ), PMPRO_MIN_PHP_VERSION );
|
129 |
+
}
|
130 |
+
|
131 |
+
//if no errors yet, let's check and bug them if < our PMPRO_PHP_MIN_VERSION
|
132 |
+
if( empty($msgt) && version_compare( PHP_VERSION, PMPRO_MIN_PHP_VERSION, '<' ) ) {
|
133 |
+
$msg = 1;
|
134 |
+
$msgt = sprintf(__("We recommend upgrading to PHP %s or greater. Ask your host to upgrade.", "paid-memberships-pro" ), PMPRO_MIN_PHP_VERSION );
|
135 |
}
|
136 |
|
137 |
if(!empty($msg))
|
145 |
<div class="wrap pmpro_admin">
|
146 |
<div class="pmpro_banner">
|
147 |
<a class="pmpro_logo" title="Paid Memberships Pro - Membership Plugin for WordPress" target="_blank" href="<?php echo pmpro_https_filter("http://www.paidmembershipspro.com")?>"><img src="<?php echo PMPRO_URL?>/images/Paid-Memberships-Pro.png" width="350" height="75" border="0" alt="Paid Memberships Pro(c) - All Rights Reserved" /></a>
|
148 |
+
<div class="pmpro_meta"><span class="pmpro_tag-grey">v<?php echo PMPRO_VERSION?></span><a target="_blank" class="pmpro_tag-blue" href="<?php echo pmpro_https_filter("http://www.paidmembershipspro.com")?>"><?php _e('Plugin Support', 'paid-memberships-pro' );?></a><a target="_blank" class="pmpro_tag-blue" href="http://www.paidmembershipspro.com/forums/"><?php _e('User Forum', 'paid-memberships-pro' );?></a></div>
|
149 |
|
150 |
<br style="clear:both;" />
|
151 |
</div>
|
168 |
?>
|
169 |
<h2 class="nav-tab-wrapper">
|
170 |
<?php if(current_user_can('pmpro_membershiplevels')) { ?>
|
171 |
+
<a href="<?php echo admin_url('admin.php?page=pmpro-membershiplevels');?>" class="nav-tab<?php if($view == 'pmpro-membershiplevels') { ?> nav-tab-active<?php } ?>"><?php _e('Membership Levels', 'paid-memberships-pro' );?></a>
|
172 |
<?php } ?>
|
173 |
|
174 |
<?php if(current_user_can('pmpro_pagesettings')) { ?>
|
175 |
+
<a href="<?php echo admin_url('admin.php?page=pmpro-pagesettings');?>" class="nav-tab<?php if($view == 'pmpro-pagesettings') { ?> nav-tab-active<?php } ?>"><?php _e('Pages', 'paid-memberships-pro' );?></a>
|
176 |
<?php } ?>
|
177 |
|
178 |
<?php if(current_user_can('pmpro_paymentsettings')) { ?>
|
179 |
+
<a href="<?php echo admin_url('admin.php?page=pmpro-paymentsettings');?>" class="nav-tab<?php if($view == 'pmpro-paymentsettings') { ?> nav-tab-active<?php } ?>"><?php _e('Payment Gateway & SSL', 'paid-memberships-pro' );?></a>
|
180 |
<?php } ?>
|
181 |
|
182 |
<?php if(current_user_can('pmpro_emailsettings')) { ?>
|
183 |
+
<a href="<?php echo admin_url('admin.php?page=pmpro-emailsettings');?>" class="nav-tab<?php if($view == 'pmpro-emailsettings') { ?> nav-tab-active<?php } ?>"><?php _e('Email', 'paid-memberships-pro' );?></a>
|
184 |
<?php } ?>
|
185 |
|
186 |
<?php if(current_user_can('pmpro_advancedsettings')) { ?>
|
187 |
+
<a href="<?php echo admin_url('admin.php?page=pmpro-advancedsettings');?>" class="nav-tab<?php if($view == 'pmpro-advancedsettings') { ?> nav-tab-active<?php } ?>"><?php _e('Advanced', 'paid-memberships-pro' );?></a>
|
188 |
<?php } ?>
|
189 |
|
190 |
<?php if(current_user_can('pmpro_addons')) { ?>
|
191 |
+
<a href="<?php echo admin_url('admin.php?page=pmpro-addons');?>" class="nav-tab<?php if($view == 'pmpro-addons') { ?> nav-tab-active<?php } ?>"><?php _e('Add Ons', 'paid-memberships-pro' );?></a>
|
192 |
<?php } ?>
|
193 |
</h2>
|
194 |
<?php } ?>
|
adminpages/advancedsettings.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_advancedsettings")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
global $wpdb, $msg, $msgt;
|
@@ -31,16 +31,19 @@
|
|
31 |
//footer link
|
32 |
pmpro_setOption("hide_footer_link");
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
}
|
40 |
-
|
41 |
//assume success
|
42 |
$msg = true;
|
43 |
-
$msgt = __("Your advanced settings have been updated.",
|
44 |
}
|
45 |
|
46 |
$nonmembertext = pmpro_getOption("nonmembertext");
|
@@ -65,17 +68,17 @@
|
|
65 |
//default settings
|
66 |
if(!$nonmembertext)
|
67 |
{
|
68 |
-
$nonmembertext = sprintf( __( 'This content is for !!levels!! members only. <a href="%s">Register here</a>.', '
|
69 |
pmpro_setOption("nonmembertext", $nonmembertext);
|
70 |
}
|
71 |
if(!$notloggedintext)
|
72 |
{
|
73 |
-
$notloggedintext = sprintf( __( 'Please <a href="%s">login</a> to view this content. (<a href="%s">Register here</a>.)', '
|
74 |
pmpro_setOption("notloggedintext", $notloggedintext);
|
75 |
}
|
76 |
if(!$rsstext)
|
77 |
{
|
78 |
-
$rsstext = __( 'This content is for members only. Visit the site and log in/register to read.', '
|
79 |
pmpro_setOption("rsstext", $rsstext);
|
80 |
}
|
81 |
|
@@ -85,77 +88,77 @@
|
|
85 |
?>
|
86 |
|
87 |
<form action="" method="post" enctype="multipart/form-data">
|
88 |
-
<h2><?php _e('Advanced Settings', '
|
89 |
|
90 |
<table class="form-table">
|
91 |
<tbody>
|
92 |
<tr>
|
93 |
<th scope="row" valign="top">
|
94 |
-
<label for="nonmembertext"><?php _e('Message for Logged-in Non-members', '
|
95 |
</th>
|
96 |
<td>
|
97 |
<textarea name="nonmembertext" rows="3" cols="80"><?php echo stripslashes($nonmembertext)?></textarea><br />
|
98 |
-
<small class="litegray"><?php _e('This message replaces the post content for non-members. Available variables', '
|
99 |
</td>
|
100 |
</tr>
|
101 |
<tr>
|
102 |
<th scope="row" valign="top">
|
103 |
-
<label for="notloggedintext"><?php _e('Message for Logged-out Users', '
|
104 |
</th>
|
105 |
<td>
|
106 |
<textarea name="notloggedintext" rows="3" cols="80"><?php echo stripslashes($notloggedintext)?></textarea><br />
|
107 |
-
<small class="litegray"><?php _e('This message replaces the post content for logged-out visitors.', '
|
108 |
</td>
|
109 |
</tr>
|
110 |
<tr>
|
111 |
<th scope="row" valign="top">
|
112 |
-
<label for="rsstext"><?php _e('Message for RSS Feed', '
|
113 |
</th>
|
114 |
<td>
|
115 |
<textarea name="rsstext" rows="3" cols="80"><?php echo stripslashes($rsstext)?></textarea><br />
|
116 |
-
<small class="litegray"><?php _e('This message replaces the post content in RSS feeds.', '
|
117 |
</td>
|
118 |
</tr>
|
119 |
|
120 |
<tr>
|
121 |
<th scope="row" valign="top">
|
122 |
-
<label for="filterqueries"><?php _e("Filter searches and archives?", '
|
123 |
</th>
|
124 |
<td>
|
125 |
<select id="filterqueries" name="filterqueries">
|
126 |
-
<option value="0" <?php if(!$filterqueries) { ?>selected="selected"<?php } ?>><?php _e('No - Non-members will see restricted posts/pages in searches and archives.', '
|
127 |
-
<option value="1" <?php if($filterqueries == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes - Only members will see restricted posts/pages in searches and archives.', '
|
128 |
</select>
|
129 |
</td>
|
130 |
</tr>
|
131 |
<tr>
|
132 |
<th scope="row" valign="top">
|
133 |
-
<label for="showexcerpts"><?php _e('Show Excerpts to Non-Members?', '
|
134 |
</th>
|
135 |
<td>
|
136 |
<select id="showexcerpts" name="showexcerpts">
|
137 |
-
<option value="0" <?php if(!$showexcerpts) { ?>selected="selected"<?php } ?>><?php _e('No - Hide excerpts.', '
|
138 |
-
<option value="1" <?php if($showexcerpts == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes - Show excerpts.', '
|
139 |
</select>
|
140 |
</td>
|
141 |
</tr>
|
142 |
<tr>
|
143 |
<th scope="row" valign="top">
|
144 |
-
<label for="hideads"><?php _e("Hide Ads From Members?", '
|
145 |
</th>
|
146 |
<td>
|
147 |
<select id="hideads" name="hideads" onchange="pmpro_updateHideAdsTRs();">
|
148 |
-
<option value="0" <?php if(!$hideads) { ?>selected="selected"<?php } ?>><?php _e('No', '
|
149 |
-
<option value="1" <?php if($hideads == 1) { ?>selected="selected"<?php } ?>><?php _e('Hide Ads From All Members', '
|
150 |
-
<option value="2" <?php if($hideads == 2) { ?>selected="selected"<?php } ?>><?php _e('Hide Ads From Certain Members', '
|
151 |
</select>
|
152 |
</td>
|
153 |
</tr>
|
154 |
<tr id="hideads_explanation" <?php if($hideads < 2) { ?>style="display: none;"<?php } ?>>
|
155 |
<th scope="row" valign="top"> </th>
|
156 |
<td>
|
157 |
-
<p class="top0em"><?php _e('Ads from the following plugins will be automatically turned off', '
|
158 |
-
<p><?php _e('To hide ads in your template code, use code like the following', '
|
159 |
<pre lang="PHP">
|
160 |
if(pmpro_displayAds())
|
161 |
{
|
@@ -166,7 +169,7 @@ if(pmpro_displayAds())
|
|
166 |
</tr>
|
167 |
<tr id="hideadslevels_tr" <?php if($hideads != 2) { ?>style="display: none;"<?php } ?>>
|
168 |
<th scope="row" valign="top">
|
169 |
-
<label for="hideadslevels"><?php _e('Choose Levels to Hide Ads From', '
|
170 |
</th>
|
171 |
<td>
|
172 |
<div class="checkbox_box" <?php if(count($levels) > 5) { ?>style="height: 100px; overflow: auto;"<?php } ?>>
|
@@ -200,129 +203,117 @@ if(pmpro_displayAds())
|
|
200 |
<?php if(is_multisite()) { ?>
|
201 |
<tr>
|
202 |
<th scope="row" valign="top">
|
203 |
-
<label for="redirecttosubscription"><?php _e('Redirect all traffic from registration page to /susbcription/?', '
|
204 |
</th>
|
205 |
<td>
|
206 |
<select id="redirecttosubscription" name="redirecttosubscription">
|
207 |
-
<option value="0" <?php if(!$redirecttosubscription) { ?>selected="selected"<?php } ?>><?php _e('No', '
|
208 |
-
<option value="1" <?php if($redirecttosubscription == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes', '
|
209 |
</select>
|
210 |
</td>
|
211 |
</tr>
|
212 |
<?php } ?>
|
213 |
<tr>
|
214 |
<th scope="row" valign="top">
|
215 |
-
<label for="recaptcha"><?php _e('Use reCAPTCHA?', '
|
216 |
</th>
|
217 |
<td>
|
218 |
<select id="recaptcha" name="recaptcha" onchange="pmpro_updateRecaptchaTRs();">
|
219 |
-
<option value="0" <?php if(!$recaptcha) { ?>selected="selected"<?php } ?>><?php _e('No', '
|
220 |
-
<option value="1" <?php if($recaptcha == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes - Free memberships only.', '
|
221 |
-
<option value="2" <?php if($recaptcha == 2) { ?>selected="selected"<?php } ?>><?php _e('Yes - All memberships.', '
|
222 |
</select><br />
|
223 |
-
<small><?php _e('A free reCAPTCHA key is required.', '
|
224 |
</td>
|
225 |
</tr>
|
226 |
<tr id="recaptcha_tr" <?php if(!$recaptcha) { ?>style="display: none;"<?php } ?>>
|
227 |
<th scope="row" valign="top"> </th>
|
228 |
<td>
|
229 |
-
<label for="recaptcha_publickey"><?php _e('reCAPTCHA Public Key', '
|
230 |
<input type="text" name="recaptcha_publickey" size="60" value="<?php echo esc_attr($recaptcha_publickey);?>" />
|
231 |
<br /><br />
|
232 |
-
<label for="recaptcha_privatekey"><?php _e('reCAPTCHA Private Key', '
|
233 |
<input type="text" name="recaptcha_privatekey" size="60" value="<?php echo esc_attr($recaptcha_privatekey);?>" />
|
234 |
</td>
|
235 |
</tr>
|
236 |
<tr>
|
237 |
<th scope="row" valign="top">
|
238 |
-
<label for="tospage"><?php _e('Require Terms of Service on signups?', '
|
239 |
</th>
|
240 |
<td>
|
241 |
<?php
|
242 |
wp_dropdown_pages(array("name"=>"tospage", "show_option_none"=>"No", "selected"=>$tospage));
|
243 |
?>
|
244 |
<br />
|
245 |
-
<small><?php _e('If yes, create a WordPress page containing your TOS agreement and assign it using the dropdown above.', '
|
246 |
</td>
|
247 |
</tr>
|
248 |
|
249 |
-
<?php
|
250 |
-
<tr>
|
251 |
-
<th scope="row" valign="top">
|
252 |
-
<label for="hide_footer_link">Hide the PMPro Link in the Footer?</label>
|
253 |
-
</th>
|
254 |
-
<td>
|
255 |
-
<select id="hide_footer_link" name="hide_footer_link">
|
256 |
-
<option value="0" <?php if(!$hide_footer_link) { ?>selected="selected"<?php } ?>>No - Leave the link. (Thanks!)</option>
|
257 |
-
<option value="1" <?php if($hide_footer_link == 1) { ?>selected="selected"<?php } ?>>Yes - Hide the link.</option>
|
258 |
-
</select>
|
259 |
-
</td>
|
260 |
-
</tr>
|
261 |
-
*/
|
262 |
-
|
263 |
// Filter to Add More Advanced Settings for Misc Plugin Options, etc.
|
264 |
if (has_action('pmpro_custom_advanced_settings')) {
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
|
|
326 |
</tbody>
|
327 |
</table>
|
328 |
<script>
|
@@ -365,7 +356,7 @@ if(pmpro_displayAds())
|
|
365 |
</script>
|
366 |
|
367 |
<p class="submit">
|
368 |
-
<input name="savesettings" type="submit" class="button button-primary" value="<?php _e('Save Settings', '
|
369 |
</p>
|
370 |
</form>
|
371 |
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_advancedsettings")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
global $wpdb, $msg, $msgt;
|
31 |
//footer link
|
32 |
pmpro_setOption("hide_footer_link");
|
33 |
|
34 |
+
/**
|
35 |
+
* Filter to add custom settings to the advanced settings page.
|
36 |
+
* @param array $settings Array of settings, each setting an array with keys field_name, field_type, label, description.
|
37 |
+
*/
|
38 |
+
$custom_settings = apply_filters('pmpro_custom_advanced_settings', array());
|
39 |
+
foreach($custom_settings as $setting) {
|
40 |
+
if(!empty($setting['field_name']))
|
41 |
+
pmpro_setOption($setting['field_name']);
|
42 |
}
|
43 |
+
|
44 |
//assume success
|
45 |
$msg = true;
|
46 |
+
$msgt = __("Your advanced settings have been updated.", 'paid-memberships-pro' );
|
47 |
}
|
48 |
|
49 |
$nonmembertext = pmpro_getOption("nonmembertext");
|
68 |
//default settings
|
69 |
if(!$nonmembertext)
|
70 |
{
|
71 |
+
$nonmembertext = sprintf( __( 'This content is for !!levels!! members only. <a href="%s">Register here</a>.', 'paid-memberships-pro' ), wp_login_url() . "?action=register" );
|
72 |
pmpro_setOption("nonmembertext", $nonmembertext);
|
73 |
}
|
74 |
if(!$notloggedintext)
|
75 |
{
|
76 |
+
$notloggedintext = sprintf( __( 'Please <a href="%s">login</a> to view this content. (<a href="%s">Register here</a>.)', 'paid-memberships-pro' ), wp_login_url( get_permalink() ), wp_login_url() . "?action=register" );
|
77 |
pmpro_setOption("notloggedintext", $notloggedintext);
|
78 |
}
|
79 |
if(!$rsstext)
|
80 |
{
|
81 |
+
$rsstext = __( 'This content is for members only. Visit the site and log in/register to read.', 'paid-memberships-pro' );
|
82 |
pmpro_setOption("rsstext", $rsstext);
|
83 |
}
|
84 |
|
88 |
?>
|
89 |
|
90 |
<form action="" method="post" enctype="multipart/form-data">
|
91 |
+
<h2><?php _e('Advanced Settings', 'paid-memberships-pro' );?></h2>
|
92 |
|
93 |
<table class="form-table">
|
94 |
<tbody>
|
95 |
<tr>
|
96 |
<th scope="row" valign="top">
|
97 |
+
<label for="nonmembertext"><?php _e('Message for Logged-in Non-members', 'paid-memberships-pro' );?>:</label>
|
98 |
</th>
|
99 |
<td>
|
100 |
<textarea name="nonmembertext" rows="3" cols="80"><?php echo stripslashes($nonmembertext)?></textarea><br />
|
101 |
+
<small class="litegray"><?php _e('This message replaces the post content for non-members. Available variables', 'paid-memberships-pro' );?>: !!levels!!, !!referrer!!</small>
|
102 |
</td>
|
103 |
</tr>
|
104 |
<tr>
|
105 |
<th scope="row" valign="top">
|
106 |
+
<label for="notloggedintext"><?php _e('Message for Logged-out Users', 'paid-memberships-pro' );?>:</label>
|
107 |
</th>
|
108 |
<td>
|
109 |
<textarea name="notloggedintext" rows="3" cols="80"><?php echo stripslashes($notloggedintext)?></textarea><br />
|
110 |
+
<small class="litegray"><?php _e('This message replaces the post content for logged-out visitors.', 'paid-memberships-pro' );?></small>
|
111 |
</td>
|
112 |
</tr>
|
113 |
<tr>
|
114 |
<th scope="row" valign="top">
|
115 |
+
<label for="rsstext"><?php _e('Message for RSS Feed', 'paid-memberships-pro' );?>:</label>
|
116 |
</th>
|
117 |
<td>
|
118 |
<textarea name="rsstext" rows="3" cols="80"><?php echo stripslashes($rsstext)?></textarea><br />
|
119 |
+
<small class="litegray"><?php _e('This message replaces the post content in RSS feeds.', 'paid-memberships-pro' );?></small>
|
120 |
</td>
|
121 |
</tr>
|
122 |
|
123 |
<tr>
|
124 |
<th scope="row" valign="top">
|
125 |
+
<label for="filterqueries"><?php _e("Filter searches and archives?", 'paid-memberships-pro' );?></label>
|
126 |
</th>
|
127 |
<td>
|
128 |
<select id="filterqueries" name="filterqueries">
|
129 |
+
<option value="0" <?php if(!$filterqueries) { ?>selected="selected"<?php } ?>><?php _e('No - Non-members will see restricted posts/pages in searches and archives.', 'paid-memberships-pro' );?></option>
|
130 |
+
<option value="1" <?php if($filterqueries == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes - Only members will see restricted posts/pages in searches and archives.', 'paid-memberships-pro' );?></option>
|
131 |
</select>
|
132 |
</td>
|
133 |
</tr>
|
134 |
<tr>
|
135 |
<th scope="row" valign="top">
|
136 |
+
<label for="showexcerpts"><?php _e('Show Excerpts to Non-Members?', 'paid-memberships-pro' );?></label>
|
137 |
</th>
|
138 |
<td>
|
139 |
<select id="showexcerpts" name="showexcerpts">
|
140 |
+
<option value="0" <?php if(!$showexcerpts) { ?>selected="selected"<?php } ?>><?php _e('No - Hide excerpts.', 'paid-memberships-pro' );?></option>
|
141 |
+
<option value="1" <?php if($showexcerpts == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes - Show excerpts.', 'paid-memberships-pro' );?></option>
|
142 |
</select>
|
143 |
</td>
|
144 |
</tr>
|
145 |
<tr>
|
146 |
<th scope="row" valign="top">
|
147 |
+
<label for="hideads"><?php _e("Hide Ads From Members?", 'paid-memberships-pro' );?></label>
|
148 |
</th>
|
149 |
<td>
|
150 |
<select id="hideads" name="hideads" onchange="pmpro_updateHideAdsTRs();">
|
151 |
+
<option value="0" <?php if(!$hideads) { ?>selected="selected"<?php } ?>><?php _e('No', 'paid-memberships-pro' );?></option>
|
152 |
+
<option value="1" <?php if($hideads == 1) { ?>selected="selected"<?php } ?>><?php _e('Hide Ads From All Members', 'paid-memberships-pro' );?></option>
|
153 |
+
<option value="2" <?php if($hideads == 2) { ?>selected="selected"<?php } ?>><?php _e('Hide Ads From Certain Members', 'paid-memberships-pro' );?></option>
|
154 |
</select>
|
155 |
</td>
|
156 |
</tr>
|
157 |
<tr id="hideads_explanation" <?php if($hideads < 2) { ?>style="display: none;"<?php } ?>>
|
158 |
<th scope="row" valign="top"> </th>
|
159 |
<td>
|
160 |
+
<p class="top0em"><?php _e('Ads from the following plugins will be automatically turned off', 'paid-memberships-pro' );?>: <em>Easy Adsense</em>, ...</p>
|
161 |
+
<p><?php _e('To hide ads in your template code, use code like the following', 'paid-memberships-pro' );?>:</p>
|
162 |
<pre lang="PHP">
|
163 |
if(pmpro_displayAds())
|
164 |
{
|
169 |
</tr>
|
170 |
<tr id="hideadslevels_tr" <?php if($hideads != 2) { ?>style="display: none;"<?php } ?>>
|
171 |
<th scope="row" valign="top">
|
172 |
+
<label for="hideadslevels"><?php _e('Choose Levels to Hide Ads From', 'paid-memberships-pro' );?>:</label>
|
173 |
</th>
|
174 |
<td>
|
175 |
<div class="checkbox_box" <?php if(count($levels) > 5) { ?>style="height: 100px; overflow: auto;"<?php } ?>>
|
203 |
<?php if(is_multisite()) { ?>
|
204 |
<tr>
|
205 |
<th scope="row" valign="top">
|
206 |
+
<label for="redirecttosubscription"><?php _e('Redirect all traffic from registration page to /susbcription/?', 'paid-memberships-pro' );?>: <em>(<?php _e('multisite only', 'paid-memberships-pro' );?>)</em></label>
|
207 |
</th>
|
208 |
<td>
|
209 |
<select id="redirecttosubscription" name="redirecttosubscription">
|
210 |
+
<option value="0" <?php if(!$redirecttosubscription) { ?>selected="selected"<?php } ?>><?php _e('No', 'paid-memberships-pro' );?></option>
|
211 |
+
<option value="1" <?php if($redirecttosubscription == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes', 'paid-memberships-pro' );?></option>
|
212 |
</select>
|
213 |
</td>
|
214 |
</tr>
|
215 |
<?php } ?>
|
216 |
<tr>
|
217 |
<th scope="row" valign="top">
|
218 |
+
<label for="recaptcha"><?php _e('Use reCAPTCHA?', 'paid-memberships-pro' );?>:</label>
|
219 |
</th>
|
220 |
<td>
|
221 |
<select id="recaptcha" name="recaptcha" onchange="pmpro_updateRecaptchaTRs();">
|
222 |
+
<option value="0" <?php if(!$recaptcha) { ?>selected="selected"<?php } ?>><?php _e('No', 'paid-memberships-pro' );?></option>
|
223 |
+
<option value="1" <?php if($recaptcha == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes - Free memberships only.', 'paid-memberships-pro' );?></option>
|
224 |
+
<option value="2" <?php if($recaptcha == 2) { ?>selected="selected"<?php } ?>><?php _e('Yes - All memberships.', 'paid-memberships-pro' );?></option>
|
225 |
</select><br />
|
226 |
+
<small><?php _e('A free reCAPTCHA key is required.', 'paid-memberships-pro' );?> <a href="https://www.google.com/recaptcha/admin/create"><?php _e('Click here to signup for reCAPTCHA', 'paid-memberships-pro' );?></a>.</small>
|
227 |
</td>
|
228 |
</tr>
|
229 |
<tr id="recaptcha_tr" <?php if(!$recaptcha) { ?>style="display: none;"<?php } ?>>
|
230 |
<th scope="row" valign="top"> </th>
|
231 |
<td>
|
232 |
+
<label for="recaptcha_publickey"><?php _e('reCAPTCHA Public Key', 'paid-memberships-pro' );?>:</label>
|
233 |
<input type="text" name="recaptcha_publickey" size="60" value="<?php echo esc_attr($recaptcha_publickey);?>" />
|
234 |
<br /><br />
|
235 |
+
<label for="recaptcha_privatekey"><?php _e('reCAPTCHA Private Key', 'paid-memberships-pro' );?>:</label>
|
236 |
<input type="text" name="recaptcha_privatekey" size="60" value="<?php echo esc_attr($recaptcha_privatekey);?>" />
|
237 |
</td>
|
238 |
</tr>
|
239 |
<tr>
|
240 |
<th scope="row" valign="top">
|
241 |
+
<label for="tospage"><?php _e('Require Terms of Service on signups?', 'paid-memberships-pro' );?></label>
|
242 |
</th>
|
243 |
<td>
|
244 |
<?php
|
245 |
wp_dropdown_pages(array("name"=>"tospage", "show_option_none"=>"No", "selected"=>$tospage));
|
246 |
?>
|
247 |
<br />
|
248 |
+
<small><?php _e('If yes, create a WordPress page containing your TOS agreement and assign it using the dropdown above.', 'paid-memberships-pro' );?></small>
|
249 |
</td>
|
250 |
</tr>
|
251 |
|
252 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
// Filter to Add More Advanced Settings for Misc Plugin Options, etc.
|
254 |
if (has_action('pmpro_custom_advanced_settings')) {
|
255 |
+
$custom_fields = apply_filters('pmpro_custom_advanced_settings', array());
|
256 |
+
foreach ($custom_fields as $field) {
|
257 |
+
?>
|
258 |
+
<tr>
|
259 |
+
<th valign="top" scope="row">
|
260 |
+
<label
|
261 |
+
for="<?php echo esc_attr( $field['field_name'] ); ?>"><?php echo esc_textarea( $field['label'] ); ?></label>
|
262 |
+
</th>
|
263 |
+
<td>
|
264 |
+
<?php
|
265 |
+
switch ($field['field_type']) {
|
266 |
+
case 'select':
|
267 |
+
?>
|
268 |
+
<select id="<?php echo esc_attr( $field['field_name'] ); ?>"
|
269 |
+
name="<?php echo esc_attr( $field['field_name'] ); ?>">
|
270 |
+
<?php
|
271 |
+
//For associative arrays, we use the array keys as values. For numerically indexed arrays, we use the array values.
|
272 |
+
$is_associative = (bool)count(array_filter(array_keys($field['options']), 'is_string'));
|
273 |
+
foreach ($field['options'] as $key => $option) {
|
274 |
+
if(!$is_associative) $key = $option;
|
275 |
+
?>
|
276 |
+
<option value="<?php echo esc_attr($key); ?>" <?php selected($key, pmpro_getOption($field['field_name']));?>>
|
277 |
+
<?php echo esc_textarea($option); ?>
|
278 |
+
</option>
|
279 |
+
<?php
|
280 |
+
}
|
281 |
+
?>
|
282 |
+
</select>
|
283 |
+
<?php
|
284 |
+
break;
|
285 |
+
case 'text':
|
286 |
+
?>
|
287 |
+
<input id="<?php echo esc_attr( $field['field_name'] ); ?>"
|
288 |
+
name="<?php echo esc_attr( $field['field_name'] ); ?>"
|
289 |
+
type="<?php echo esc_attr( $field['field_type'] ); ?>"
|
290 |
+
value="<?php echo esc_attr(pmpro_getOption($field['field_name'])); ?> ">
|
291 |
+
<?php
|
292 |
+
break;
|
293 |
+
case 'textarea':
|
294 |
+
?>
|
295 |
+
<textarea id="<?php echo esc_attr( $field['field_name'] ); ?>"
|
296 |
+
name="<?php echo esc_attr( $field['field_name'] ); ?>">
|
297 |
+
<?php echo esc_textarea(pmpro_getOption($field['field_name'])); ?>
|
298 |
+
</textarea>
|
299 |
+
<?php
|
300 |
+
break;
|
301 |
+
default:
|
302 |
+
break;
|
303 |
+
}
|
304 |
+
if (!empty($field['description'])) {
|
305 |
+
?>
|
306 |
+
<br>
|
307 |
+
<small><?php echo esc_textarea( $field['description'] ); ?></small>
|
308 |
+
<?php
|
309 |
+
}
|
310 |
+
?>
|
311 |
+
</td>
|
312 |
+
</tr>
|
313 |
+
<?php
|
314 |
+
}
|
315 |
+
}
|
316 |
+
?>
|
317 |
</tbody>
|
318 |
</table>
|
319 |
<script>
|
356 |
</script>
|
357 |
|
358 |
<p class="submit">
|
359 |
+
<input name="savesettings" type="submit" class="button button-primary" value="<?php _e('Save Settings', 'paid-memberships-pro' );?>" />
|
360 |
</p>
|
361 |
</form>
|
362 |
|
adminpages/discountcodes.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_discountcodes")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
//vars
|
@@ -68,13 +68,13 @@
|
|
68 |
if(empty($wpdb->last_error)) {
|
69 |
if($saveid < 1) {
|
70 |
//insert
|
71 |
-
$pmpro_msg = __("Discount code added successfully.",
|
72 |
$pmpro_msgt = "success";
|
73 |
$saved = true;
|
74 |
$edit = $wpdb->insert_id;
|
75 |
} else {
|
76 |
//updated
|
77 |
-
$pmpro_msg = __("Discount code updated successfully.",
|
78 |
$pmpro_msgt = "success";
|
79 |
$saved = true;
|
80 |
$edit = $saveid;
|
@@ -82,11 +82,11 @@
|
|
82 |
} else {
|
83 |
if($saveid < 1) {
|
84 |
//error inserting
|
85 |
-
$pmpro_msg = __("Error adding discount code. That code may already be in use.",
|
86 |
$pmpro_msgt = "error";
|
87 |
} else {
|
88 |
//error updating
|
89 |
-
$pmpro_msg = __("Error updating discount code. That code may already be in use.",
|
90 |
$pmpro_msgt = "error";
|
91 |
}
|
92 |
}
|
@@ -217,6 +217,7 @@
|
|
217 |
'cycle_period' => $cycle_period,
|
218 |
'billing_limit' => $billing_limit,
|
219 |
'trial_amount' => $trial_amount,
|
|
|
220 |
'expiration_number' => $expiration_number,
|
221 |
'expiration_period' => $expiration_period
|
222 |
),
|
@@ -230,6 +231,7 @@
|
|
230 |
'%d',
|
231 |
'%f',
|
232 |
'%d',
|
|
|
233 |
'%s'
|
234 |
)
|
235 |
);
|
@@ -242,7 +244,7 @@
|
|
242 |
else
|
243 |
{
|
244 |
$level = pmpro_getLevel($level_id);
|
245 |
-
$level_errors[] = sprintf(__("Error saving values for the %s level.",
|
246 |
}
|
247 |
}
|
248 |
}
|
@@ -250,7 +252,7 @@
|
|
250 |
//errors?
|
251 |
if(!empty($level_errors))
|
252 |
{
|
253 |
-
$pmpro_msg = __("There were errors updating the level values: ",
|
254 |
$pmpro_msgt = "error";
|
255 |
}
|
256 |
else
|
@@ -283,24 +285,24 @@
|
|
283 |
|
284 |
if($r2 !== false)
|
285 |
{
|
286 |
-
$pmpro_msg = sprintf(__("Code %s deleted successfully.",
|
287 |
$pmpro_msgt = "success";
|
288 |
}
|
289 |
else
|
290 |
{
|
291 |
-
$pmpro_msg = __("Error deleting discount code. The code was only partially deleted. Please try again.",
|
292 |
$pmpro_msgt = "error";
|
293 |
}
|
294 |
}
|
295 |
else
|
296 |
{
|
297 |
-
$pmpro_msg = __("Error deleting code. Please try again.",
|
298 |
$pmpro_msgt = "error";
|
299 |
}
|
300 |
}
|
301 |
else
|
302 |
{
|
303 |
-
$pmpro_msg = __("Code not found.",
|
304 |
$pmpro_msgt = "error";
|
305 |
}
|
306 |
}
|
@@ -313,9 +315,9 @@
|
|
313 |
<h2>
|
314 |
<?php
|
315 |
if($edit > 0)
|
316 |
-
echo __("Edit Discount Code",
|
317 |
else
|
318 |
-
echo __("Add New Discount Code",
|
319 |
?>
|
320 |
</h2>
|
321 |
|
@@ -376,12 +378,12 @@
|
|
376 |
<table class="form-table">
|
377 |
<tbody>
|
378 |
<tr>
|
379 |
-
<th scope="row" valign="top"><label><?php _e('ID', '
|
380 |
-
<td class="pmpro_lite"><?php if(!empty($code->id)) echo $code->id; else echo __("This will be generated when you save.",
|
381 |
</tr>
|
382 |
|
383 |
<tr>
|
384 |
-
<th scope="row" valign="top"><label for="code"><?php _e('Code', '
|
385 |
<td><input name="code" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($code->code))?>" /></td>
|
386 |
</tr>
|
387 |
|
@@ -419,7 +421,7 @@
|
|
419 |
?>
|
420 |
|
421 |
<tr>
|
422 |
-
<th scope="row" valign="top"><label for="starts"><?php _e('Start Date', '
|
423 |
<td>
|
424 |
<select name="starts_month">
|
425 |
<?php
|
@@ -437,7 +439,7 @@
|
|
437 |
</tr>
|
438 |
|
439 |
<tr>
|
440 |
-
<th scope="row" valign="top"><label for="expires"><?php _e('Expiration Date', '
|
441 |
<td>
|
442 |
<select name="expires_month">
|
443 |
<?php
|
@@ -455,10 +457,10 @@
|
|
455 |
</tr>
|
456 |
|
457 |
<tr>
|
458 |
-
<th scope="row" valign="top"><label for="uses"><?php _e('Uses', '
|
459 |
<td>
|
460 |
<input name="uses" type="text" size="10" value="<?php if(!empty($code->uses)) echo str_replace("\"", """, stripslashes($code->uses));?>" />
|
461 |
-
<small class="pmpro_lite"><?php _e('Leave blank for unlimited uses.', '
|
462 |
</td>
|
463 |
</tr>
|
464 |
|
@@ -467,7 +469,7 @@
|
|
467 |
|
468 |
<?php do_action("pmpro_discount_code_after_settings", $edit); ?>
|
469 |
|
470 |
-
<h3><?php _e('Which Levels Will This Code Apply To?', '
|
471 |
|
472 |
<div class="pmpro_discount_levels">
|
473 |
<?php
|
@@ -505,7 +507,7 @@
|
|
505 |
<table class="form-table">
|
506 |
<tbody>
|
507 |
<tr>
|
508 |
-
<th scope="row" valign="top"><label for="initial_payment"><?php _e('Initial Payment', '
|
509 |
<td>
|
510 |
<?php
|
511 |
if(pmpro_getCurrencyPosition() == "left")
|
@@ -516,17 +518,17 @@
|
|
516 |
if(pmpro_getCurrencyPosition() == "right")
|
517 |
echo $pmpro_currency_symbol;
|
518 |
?>
|
519 |
-
<small><?php _e('The initial amount collected at registration.', '
|
520 |
</td>
|
521 |
</tr>
|
522 |
|
523 |
<tr>
|
524 |
-
<th scope="row" valign="top"><label><?php _e('Recurring Subscription', '
|
525 |
-
<td><input class="recurring_checkbox" id="recurring_<?php echo $level->id;?>" name="recurring[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelRecurring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).attr('checked')) { jQuery(this).parent().parent().siblings('.recurring_info').show(); if(!jQuery('#custom_trial_<?php echo $level->id?>').is(':checked')) jQuery(this).parent().parent().siblings('.trial_info').hide();} else jQuery(this).parent().parent().siblings('.recurring_info').hide();" /> <label for="recurring_<?php echo $level->id;?>"><?php _e('Check if this level has a recurring subscription payment.', '
|
526 |
</tr>
|
527 |
|
528 |
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
529 |
-
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Billing Amount', '
|
530 |
<td>
|
531 |
<?php
|
532 |
if(pmpro_getCurrencyPosition() == "left")
|
@@ -541,7 +543,7 @@
|
|
541 |
<input name="cycle_number[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->cycle_number))?>" />
|
542 |
<select name="cycle_period[]" onchange="updateCyclePeriod();">
|
543 |
<?php
|
544 |
-
$cycles = array( __('Day(s)', '
|
545 |
foreach ( $cycles as $name => $value ) {
|
546 |
echo "<option value='$value'";
|
547 |
if ( $level->cycle_period == $value ) echo " selected='selected'";
|
@@ -549,25 +551,25 @@
|
|
549 |
}
|
550 |
?>
|
551 |
</select>
|
552 |
-
<br /><small><?php _e('The amount to be billed one cycle after the initial payment.', '
|
553 |
</td>
|
554 |
</tr>
|
555 |
|
556 |
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
557 |
-
<th scope="row" valign="top"><label for="billing_limit"><?php _e('Billing Cycle Limit', '
|
558 |
<td>
|
559 |
<input name="billing_limit[]" type="text" size="20" value="<?php echo $level->billing_limit?>" />
|
560 |
-
<br /><small><?php _e('The <strong>total</strong> number of recurring billing cycles for this level, including the trial period (if applicable) but not including the initial payment. Set to zero if membership is indefinite.', '
|
561 |
</td>
|
562 |
</tr>
|
563 |
|
564 |
<tr class="recurring_info" <?php if (!pmpro_isLevelRecurring($level)) echo "style='display:none;'";?>>
|
565 |
-
<th scope="row" valign="top"><label><?php _e('Custom Trial', '
|
566 |
-
<td><input id="custom_trial_<?php echo $level->id?>" id="custom_trial_<?php echo $level->id;?>" name="custom_trial[]" type="checkbox" value="<?php echo $level->id?>" <?php if ( pmpro_isLevelTrial($level) ) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).attr('checked')) jQuery(this).parent().parent().siblings('.trial_info').show(); else jQuery(this).parent().parent().siblings('.trial_info').hide();" /> <label for="custom_trial_<?php echo $level->id;?>"><?php _e('Check to add a custom trial period.', '
|
567 |
</tr>
|
568 |
|
569 |
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>>
|
570 |
-
<th scope="row" valign="top"><label for="trial_amount"><?php _e('Trial Billing Amount', '
|
571 |
<td>
|
572 |
<?php
|
573 |
if(pmpro_getCurrencyPosition() == "left")
|
@@ -578,24 +580,24 @@
|
|
578 |
if(pmpro_getCurrencyPosition() == "right")
|
579 |
echo $pmpro_currency_symbol;
|
580 |
?>
|
581 |
-
<small><?php _e('for the first', '
|
582 |
<input name="trial_limit[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->trial_limit))?>" />
|
583 |
-
<small><?php _e('subscription payments', '
|
584 |
</td>
|
585 |
</tr>
|
586 |
|
587 |
<tr>
|
588 |
-
<th scope="row" valign="top"><label><?php _e('Membership Expiration', '
|
589 |
-
<td><input id="expiration_<?php echo $level->id;?>" name="expiration[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelExpiring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).is(':checked')) { jQuery(this).parent().parent().siblings('.expiration_info').show(); } else { jQuery(this).parent().parent().siblings('.expiration_info').hide();}" /> <label for="expiration_<?php echo $level->id;?>"><?php _e('Check this to set when membership access expires.', '
|
590 |
</tr>
|
591 |
|
592 |
<tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>>
|
593 |
-
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Expires In', '
|
594 |
<td>
|
595 |
<input id="expiration_number" name="expiration_number[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->expiration_number))?>" />
|
596 |
<select id="expiration_period" name="expiration_period[]">
|
597 |
<?php
|
598 |
-
$cycles = array( __('Day(s)', '
|
599 |
foreach ( $cycles as $name => $value ) {
|
600 |
echo "<option value='$value'";
|
601 |
if ( $level->expiration_period == $value ) echo " selected='selected'";
|
@@ -603,7 +605,7 @@
|
|
603 |
}
|
604 |
?>
|
605 |
</select>
|
606 |
-
<br /><small><?php _e('Set the duration of membership access. Note that the any future payments (recurring subscription, if any) will be cancelled when the membership expires.', '
|
607 |
</td>
|
608 |
</tr>
|
609 |
</tbody>
|
@@ -631,8 +633,8 @@
|
|
631 |
<?php } else { ?>
|
632 |
|
633 |
<h2>
|
634 |
-
<?php _e('Memberships Discount Codes', '
|
635 |
-
<a href="admin.php?page=pmpro-discountcodes&edit=-1" class="add-new-h2"><?php _e('Add New Discount Code', '
|
636 |
</h2>
|
637 |
|
638 |
<?php if(!empty($pmpro_msg)) { ?>
|
@@ -641,10 +643,10 @@
|
|
641 |
|
642 |
<form id="posts-filter" method="get" action="">
|
643 |
<p class="search-box">
|
644 |
-
<label class="screen-reader-text" for="post-search-input"><?php _e('Search Discount Codes', '
|
645 |
<input type="hidden" name="page" value="pmpro-discountcodes" />
|
646 |
<input id="post-search-input" type="text" value="<?php if(!empty($s)) echo $s;?>" name="s" size="30" />
|
647 |
-
<input class="button" type="submit" value="<?php _e('Search', '
|
648 |
</p>
|
649 |
</form>
|
650 |
|
@@ -660,12 +662,12 @@
|
|
660 |
<table class="widefat">
|
661 |
<thead>
|
662 |
<tr>
|
663 |
-
<th><?php _e('ID', '
|
664 |
-
<th><?php _e('Code', '
|
665 |
-
<th><?php _e('Starts', '
|
666 |
-
<th><?php _e('Expires', '
|
667 |
-
<th><?php _e('Uses', '
|
668 |
-
<th><?php _e('Levels', '
|
669 |
<?php do_action("pmpro_discountcodes_extra_cols_header", $codes);?>
|
670 |
<th></th>
|
671 |
<th></th>
|
@@ -677,7 +679,7 @@
|
|
677 |
{
|
678 |
?>
|
679 |
<tr><td colspan="7" class="pmpro_pad20">
|
680 |
-
<p><?php _e('Discount codes allow you to offer your memberships at discounted prices to select customers.', '
|
681 |
</td></tr>
|
682 |
<?php
|
683 |
}
|
@@ -730,10 +732,10 @@
|
|
730 |
</td>
|
731 |
<?php do_action("pmpro_discountcodes_extra_cols_body", $code);?>
|
732 |
<td>
|
733 |
-
<a href="?page=pmpro-discountcodes&edit=<?php echo $code->id?>"><?php _e('edit', '
|
734 |
</td>
|
735 |
<td>
|
736 |
-
<a href="javascript:askfirst('<?php echo str_replace("'", "\'", sprintf(__('Are you sure you want to delete the %s discount code? The subscriptions for existing users will not change, but new users will not be able to use this code anymore.', '
|
737 |
</td>
|
738 |
</tr>
|
739 |
<?php
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_discountcodes")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
//vars
|
68 |
if(empty($wpdb->last_error)) {
|
69 |
if($saveid < 1) {
|
70 |
//insert
|
71 |
+
$pmpro_msg = __("Discount code added successfully.", 'paid-memberships-pro' );
|
72 |
$pmpro_msgt = "success";
|
73 |
$saved = true;
|
74 |
$edit = $wpdb->insert_id;
|
75 |
} else {
|
76 |
//updated
|
77 |
+
$pmpro_msg = __("Discount code updated successfully.", 'paid-memberships-pro' );
|
78 |
$pmpro_msgt = "success";
|
79 |
$saved = true;
|
80 |
$edit = $saveid;
|
82 |
} else {
|
83 |
if($saveid < 1) {
|
84 |
//error inserting
|
85 |
+
$pmpro_msg = __("Error adding discount code. That code may already be in use.", 'paid-memberships-pro' ) . $wpdb->last_error;
|
86 |
$pmpro_msgt = "error";
|
87 |
} else {
|
88 |
//error updating
|
89 |
+
$pmpro_msg = __("Error updating discount code. That code may already be in use.", 'paid-memberships-pro' );
|
90 |
$pmpro_msgt = "error";
|
91 |
}
|
92 |
}
|
217 |
'cycle_period' => $cycle_period,
|
218 |
'billing_limit' => $billing_limit,
|
219 |
'trial_amount' => $trial_amount,
|
220 |
+
'trial_limit' => $trial_limit,
|
221 |
'expiration_number' => $expiration_number,
|
222 |
'expiration_period' => $expiration_period
|
223 |
),
|
231 |
'%d',
|
232 |
'%f',
|
233 |
'%d',
|
234 |
+
'%d',
|
235 |
'%s'
|
236 |
)
|
237 |
);
|
244 |
else
|
245 |
{
|
246 |
$level = pmpro_getLevel($level_id);
|
247 |
+
$level_errors[] = sprintf(__("Error saving values for the %s level.", 'paid-memberships-pro' ), $level->name);
|
248 |
}
|
249 |
}
|
250 |
}
|
252 |
//errors?
|
253 |
if(!empty($level_errors))
|
254 |
{
|
255 |
+
$pmpro_msg = __("There were errors updating the level values: ", 'paid-memberships-pro' ) . implode(" ", $level_errors);
|
256 |
$pmpro_msgt = "error";
|
257 |
}
|
258 |
else
|
285 |
|
286 |
if($r2 !== false)
|
287 |
{
|
288 |
+
$pmpro_msg = sprintf(__("Code %s deleted successfully.", 'paid-memberships-pro' ), $code);
|
289 |
$pmpro_msgt = "success";
|
290 |
}
|
291 |
else
|
292 |
{
|
293 |
+
$pmpro_msg = __("Error deleting discount code. The code was only partially deleted. Please try again.", 'paid-memberships-pro' );
|
294 |
$pmpro_msgt = "error";
|
295 |
}
|
296 |
}
|
297 |
else
|
298 |
{
|
299 |
+
$pmpro_msg = __("Error deleting code. Please try again.", 'paid-memberships-pro' );
|
300 |
$pmpro_msgt = "error";
|
301 |
}
|
302 |
}
|
303 |
else
|
304 |
{
|
305 |
+
$pmpro_msg = __("Code not found.", 'paid-memberships-pro' );
|
306 |
$pmpro_msgt = "error";
|
307 |
}
|
308 |
}
|
315 |
<h2>
|
316 |
<?php
|
317 |
if($edit > 0)
|
318 |
+
echo __("Edit Discount Code", 'paid-memberships-pro' );
|
319 |
else
|
320 |
+
echo __("Add New Discount Code", 'paid-memberships-pro' );
|
321 |
?>
|
322 |
</h2>
|
323 |
|
378 |
<table class="form-table">
|
379 |
<tbody>
|
380 |
<tr>
|
381 |
+
<th scope="row" valign="top"><label><?php _e('ID', 'paid-memberships-pro' );?>:</label></th>
|
382 |
+
<td class="pmpro_lite"><?php if(!empty($code->id)) echo $code->id; else echo __("This will be generated when you save.", 'paid-memberships-pro' );?></td>
|
383 |
</tr>
|
384 |
|
385 |
<tr>
|
386 |
+
<th scope="row" valign="top"><label for="code"><?php _e('Code', 'paid-memberships-pro' );?>:</label></th>
|
387 |
<td><input name="code" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($code->code))?>" /></td>
|
388 |
</tr>
|
389 |
|
421 |
?>
|
422 |
|
423 |
<tr>
|
424 |
+
<th scope="row" valign="top"><label for="starts"><?php _e('Start Date', 'paid-memberships-pro' );?>:</label></th>
|
425 |
<td>
|
426 |
<select name="starts_month">
|
427 |
<?php
|
439 |
</tr>
|
440 |
|
441 |
<tr>
|
442 |
+
<th scope="row" valign="top"><label for="expires"><?php _e('Expiration Date', 'paid-memberships-pro' );?>:</label></th>
|
443 |
<td>
|
444 |
<select name="expires_month">
|
445 |
<?php
|
457 |
</tr>
|
458 |
|
459 |
<tr>
|
460 |
+
<th scope="row" valign="top"><label for="uses"><?php _e('Uses', 'paid-memberships-pro' );?>:</label></th>
|
461 |
<td>
|
462 |
<input name="uses" type="text" size="10" value="<?php if(!empty($code->uses)) echo str_replace("\"", """, stripslashes($code->uses));?>" />
|
463 |
+
<small class="pmpro_lite"><?php _e('Leave blank for unlimited uses.', 'paid-memberships-pro' );?></small>
|
464 |
</td>
|
465 |
</tr>
|
466 |
|
469 |
|
470 |
<?php do_action("pmpro_discount_code_after_settings", $edit); ?>
|
471 |
|
472 |
+
<h3><?php _e('Which Levels Will This Code Apply To?', 'paid-memberships-pro' ); ?></h3>
|
473 |
|
474 |
<div class="pmpro_discount_levels">
|
475 |
<?php
|
507 |
<table class="form-table">
|
508 |
<tbody>
|
509 |
<tr>
|
510 |
+
<th scope="row" valign="top"><label for="initial_payment"><?php _e('Initial Payment', 'paid-memberships-pro' );?>:</label></th>
|
511 |
<td>
|
512 |
<?php
|
513 |
if(pmpro_getCurrencyPosition() == "left")
|
518 |
if(pmpro_getCurrencyPosition() == "right")
|
519 |
echo $pmpro_currency_symbol;
|
520 |
?>
|
521 |
+
<small><?php _e('The initial amount collected at registration.', 'paid-memberships-pro' );?></small>
|
522 |
</td>
|
523 |
</tr>
|
524 |
|
525 |
<tr>
|
526 |
+
<th scope="row" valign="top"><label><?php _e('Recurring Subscription', 'paid-memberships-pro' );?>:</label></th>
|
527 |
+
<td><input class="recurring_checkbox" id="recurring_<?php echo $level->id;?>" name="recurring[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelRecurring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).attr('checked')) { jQuery(this).parent().parent().siblings('.recurring_info').show(); if(!jQuery('#custom_trial_<?php echo $level->id?>').is(':checked')) jQuery(this).parent().parent().siblings('.trial_info').hide();} else jQuery(this).parent().parent().siblings('.recurring_info').hide();" /> <label for="recurring_<?php echo $level->id;?>"><?php _e('Check if this level has a recurring subscription payment.', 'paid-memberships-pro' );?></label></td>
|
528 |
</tr>
|
529 |
|
530 |
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
531 |
+
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Billing Amount', 'paid-memberships-pro' );?>:</label></th>
|
532 |
<td>
|
533 |
<?php
|
534 |
if(pmpro_getCurrencyPosition() == "left")
|
543 |
<input name="cycle_number[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->cycle_number))?>" />
|
544 |
<select name="cycle_period[]" onchange="updateCyclePeriod();">
|
545 |
<?php
|
546 |
+
$cycles = array( __('Day(s)', 'paid-memberships-pro' ) => 'Day', __('Week(s)', 'paid-memberships-pro' ) => 'Week', __('Month(s)', 'paid-memberships-pro' ) => 'Month', __('Year(s)', 'paid-memberships-pro' ) => 'Year' );
|
547 |
foreach ( $cycles as $name => $value ) {
|
548 |
echo "<option value='$value'";
|
549 |
if ( $level->cycle_period == $value ) echo " selected='selected'";
|
551 |
}
|
552 |
?>
|
553 |
</select>
|
554 |
+
<br /><small><?php _e('The amount to be billed one cycle after the initial payment.', 'paid-memberships-pro' );?></small>
|
555 |
</td>
|
556 |
</tr>
|
557 |
|
558 |
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
559 |
+
<th scope="row" valign="top"><label for="billing_limit"><?php _e('Billing Cycle Limit', 'paid-memberships-pro' );?>:</label></th>
|
560 |
<td>
|
561 |
<input name="billing_limit[]" type="text" size="20" value="<?php echo $level->billing_limit?>" />
|
562 |
+
<br /><small><?php _e('The <strong>total</strong> number of recurring billing cycles for this level, including the trial period (if applicable) but not including the initial payment. Set to zero if membership is indefinite.', 'paid-memberships-pro' );?></small>
|
563 |
</td>
|
564 |
</tr>
|
565 |
|
566 |
<tr class="recurring_info" <?php if (!pmpro_isLevelRecurring($level)) echo "style='display:none;'";?>>
|
567 |
+
<th scope="row" valign="top"><label><?php _e('Custom Trial', 'paid-memberships-pro' );?>:</label></th>
|
568 |
+
<td><input id="custom_trial_<?php echo $level->id?>" id="custom_trial_<?php echo $level->id;?>" name="custom_trial[]" type="checkbox" value="<?php echo $level->id?>" <?php if ( pmpro_isLevelTrial($level) ) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).attr('checked')) jQuery(this).parent().parent().siblings('.trial_info').show(); else jQuery(this).parent().parent().siblings('.trial_info').hide();" /> <label for="custom_trial_<?php echo $level->id;?>"><?php _e('Check to add a custom trial period.', 'paid-memberships-pro' );?></label></td>
|
569 |
</tr>
|
570 |
|
571 |
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>>
|
572 |
+
<th scope="row" valign="top"><label for="trial_amount"><?php _e('Trial Billing Amount', 'paid-memberships-pro' );?>:</label></th>
|
573 |
<td>
|
574 |
<?php
|
575 |
if(pmpro_getCurrencyPosition() == "left")
|
580 |
if(pmpro_getCurrencyPosition() == "right")
|
581 |
echo $pmpro_currency_symbol;
|
582 |
?>
|
583 |
+
<small><?php _e('for the first', 'paid-memberships-pro' );?></small>
|
584 |
<input name="trial_limit[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->trial_limit))?>" />
|
585 |
+
<small><?php _e('subscription payments', 'paid-memberships-pro' );?>.</small>
|
586 |
</td>
|
587 |
</tr>
|
588 |
|
589 |
<tr>
|
590 |
+
<th scope="row" valign="top"><label><?php _e('Membership Expiration', 'paid-memberships-pro' );?>:</label></th>
|
591 |
+
<td><input id="expiration_<?php echo $level->id;?>" name="expiration[]" type="checkbox" value="<?php echo $level->id?>" <?php if(pmpro_isLevelExpiring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery(this).is(':checked')) { jQuery(this).parent().parent().siblings('.expiration_info').show(); } else { jQuery(this).parent().parent().siblings('.expiration_info').hide();}" /> <label for="expiration_<?php echo $level->id;?>"><?php _e('Check this to set when membership access expires.', 'paid-memberships-pro' );?></label></td>
|
592 |
</tr>
|
593 |
|
594 |
<tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>>
|
595 |
+
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Expires In', 'paid-memberships-pro' );?>:</label></th>
|
596 |
<td>
|
597 |
<input id="expiration_number" name="expiration_number[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->expiration_number))?>" />
|
598 |
<select id="expiration_period" name="expiration_period[]">
|
599 |
<?php
|
600 |
+
$cycles = array( __('Day(s)', 'paid-memberships-pro' ) => 'Day', __('Week(s)', 'paid-memberships-pro' ) => 'Week', __('Month(s)', 'paid-memberships-pro' ) => 'Month', __('Year(s)', 'paid-memberships-pro' ) => 'Year' );
|
601 |
foreach ( $cycles as $name => $value ) {
|
602 |
echo "<option value='$value'";
|
603 |
if ( $level->expiration_period == $value ) echo " selected='selected'";
|
605 |
}
|
606 |
?>
|
607 |
</select>
|
608 |
+
<br /><small><?php _e('Set the duration of membership access. Note that the any future payments (recurring subscription, if any) will be cancelled when the membership expires.', 'paid-memberships-pro' );?></small>
|
609 |
</td>
|
610 |
</tr>
|
611 |
</tbody>
|
633 |
<?php } else { ?>
|
634 |
|
635 |
<h2>
|
636 |
+
<?php _e('Memberships Discount Codes', 'paid-memberships-pro' );?>
|
637 |
+
<a href="admin.php?page=pmpro-discountcodes&edit=-1" class="add-new-h2"><?php _e('Add New Discount Code', 'paid-memberships-pro' );?></a>
|
638 |
</h2>
|
639 |
|
640 |
<?php if(!empty($pmpro_msg)) { ?>
|
643 |
|
644 |
<form id="posts-filter" method="get" action="">
|
645 |
<p class="search-box">
|
646 |
+
<label class="screen-reader-text" for="post-search-input"><?php _e('Search Discount Codes', 'paid-memberships-pro' );?>:</label>
|
647 |
<input type="hidden" name="page" value="pmpro-discountcodes" />
|
648 |
<input id="post-search-input" type="text" value="<?php if(!empty($s)) echo $s;?>" name="s" size="30" />
|
649 |
+
<input class="button" type="submit" value="<?php _e('Search', 'paid-memberships-pro' );?>" id="search-submit "/>
|
650 |
</p>
|
651 |
</form>
|
652 |
|
662 |
<table class="widefat">
|
663 |
<thead>
|
664 |
<tr>
|
665 |
+
<th><?php _e('ID', 'paid-memberships-pro' );?></th>
|
666 |
+
<th><?php _e('Code', 'paid-memberships-pro' );?></th>
|
667 |
+
<th><?php _e('Starts', 'paid-memberships-pro' );?></th>
|
668 |
+
<th><?php _e('Expires', 'paid-memberships-pro' );?></th>
|
669 |
+
<th><?php _e('Uses', 'paid-memberships-pro' );?></th>
|
670 |
+
<th><?php _e('Levels', 'paid-memberships-pro' );?></th>
|
671 |
<?php do_action("pmpro_discountcodes_extra_cols_header", $codes);?>
|
672 |
<th></th>
|
673 |
<th></th>
|
679 |
{
|
680 |
?>
|
681 |
<tr><td colspan="7" class="pmpro_pad20">
|
682 |
+
<p><?php _e('Discount codes allow you to offer your memberships at discounted prices to select customers.', 'paid-memberships-pro' );?> <a href="admin.php?page=pmpro-discountcodes&edit=-1"><?php _e('Create your first discount code now', 'paid-memberships-pro' );?></a>.</p>
|
683 |
</td></tr>
|
684 |
<?php
|
685 |
}
|
732 |
</td>
|
733 |
<?php do_action("pmpro_discountcodes_extra_cols_body", $code);?>
|
734 |
<td>
|
735 |
+
<a href="?page=pmpro-discountcodes&edit=<?php echo $code->id?>"><?php _e('edit', 'paid-memberships-pro' );?></a>
|
736 |
</td>
|
737 |
<td>
|
738 |
+
<a href="javascript:askfirst('<?php echo str_replace("'", "\'", sprintf(__('Are you sure you want to delete the %s discount code? The subscriptions for existing users will not change, but new users will not be able to use this code anymore.', 'paid-memberships-pro' ), $code->code));?>', '?page=pmpro-discountcodes&delete=<?php echo $code->id?>'); void(0);"><?php _e('delete', 'paid-memberships-pro' );?></a>
|
739 |
</td>
|
740 |
</tr>
|
741 |
<?php
|
adminpages/emailsettings.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_emailsettings")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
global $wpdb, $msg, $msgt;
|
@@ -66,16 +66,16 @@
|
|
66 |
?>
|
67 |
|
68 |
<form action="" method="post" enctype="multipart/form-data">
|
69 |
-
<h2><?php _e('Email Settings', '
|
70 |
-
<p><?php _e('By default, system generated emails are sent from <em><strong>wordpress@yourdomain.com</strong></em>. You can update this from address using the fields below.', '
|
71 |
|
72 |
-
<p><?php _e('To modify the appearance of system generated emails, add the files <em>email_header.html</em> and <em>email_footer.html</em> to your theme\'s directory. This will modify both the WordPress default messages as well as messages generated by Paid Memberships Pro. <a title="Paid Memberships Pro - Member Communications" target="_blank" href="http://www.paidmembershipspro.com/documentation/member-communications/">Click here to learn more about Paid Memberships Pro emails</a>.', '
|
73 |
|
74 |
<table class="form-table">
|
75 |
<tbody>
|
76 |
<tr>
|
77 |
<th scope="row" valign="top">
|
78 |
-
<label for="from_email"><?php _e('From Email', '
|
79 |
</th>
|
80 |
<td>
|
81 |
<input type="text" name="from_email" size="60" value="<?php echo esc_attr($from_email);?>" />
|
@@ -83,7 +83,7 @@
|
|
83 |
</tr>
|
84 |
<tr>
|
85 |
<th scope="row" valign="top">
|
86 |
-
<label for="from_name"><?php _e('From Name', '
|
87 |
</th>
|
88 |
<td>
|
89 |
<input type="text" name="from_name" size="60" value="<?php echo esc_attr($from_name);?>" />
|
@@ -91,81 +91,81 @@
|
|
91 |
</tr>
|
92 |
<tr>
|
93 |
<th scope="row" valign="top">
|
94 |
-
<label for="only_filter_pmpro_emails"><?php _e('Only Filter PMPro Emails?', '
|
95 |
</th>
|
96 |
<td>
|
97 |
<input type="checkbox" id="only_filter_pmpro_emails" name="only_filter_pmpro_emails" value="1" <?php if(!empty($only_filter_pmpro_emails)) { ?>checked="checked"<?php } ?> />
|
98 |
-
<label for="only_filter_pmpro_emails"><?php printf( __('If unchecked, all emails from "WordPress <%s>" will be filtered to use the above settings.', '
|
99 |
</td>
|
100 |
</tr>
|
101 |
</tbody>
|
102 |
</table>
|
103 |
|
104 |
<?php /* going to put something like this here in next version
|
105 |
-
<h3><?php _e('Modify System-generated Email Templates', '
|
106 |
<?php
|
107 |
if (function_exists('pmproet_scripts'))
|
108 |
{
|
109 |
_e('You have installed the PMPro Email Templates add on. <a href="' . admin_url('admin.php?page=pmpro-email-templates') . '">Click here to modify email templates</a>');
|
110 |
}
|
111 |
?>
|
112 |
-
<p><?php _e('To modify the subject line and body content of system generated emails, <a title="Paid Memberships Pro - Email Templates Plugin" target="_blank" href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-email-templates-addon'), 'install-plugin_pmpro-email-templates-addon') . '">Install and Activate the PMPro Email Templates add on</a>.', '
|
113 |
*/ ?>
|
114 |
|
115 |
-
<h3><?php _e('Send the site admin emails', '
|
116 |
|
117 |
<table class="form-table">
|
118 |
<tbody>
|
119 |
<tr>
|
120 |
<th scope="row" valign="top">
|
121 |
-
<label for="email_admin_checkout"><?php _e('Checkout', '
|
122 |
</th>
|
123 |
<td>
|
124 |
<input type="checkbox" id="email_admin_checkout" name="email_admin_checkout" value="1" <?php if(!empty($email_admin_checkout)) { ?>checked="checked"<?php } ?> />
|
125 |
-
<label for="email_admin_checkout"><?php _e('when a member checks out.', '
|
126 |
</td>
|
127 |
</tr>
|
128 |
<tr>
|
129 |
<th scope="row" valign="top">
|
130 |
-
<label for="email_admin_changes"><?php _e('Admin Changes', '
|
131 |
</th>
|
132 |
<td>
|
133 |
<input type="checkbox" id="email_admin_changes" name="email_admin_changes" value="1" <?php if(!empty($email_admin_changes)) { ?>checked="checked"<?php } ?> />
|
134 |
-
<label for="email_admin_changes"><?php _e('when an admin changes a user\'s membership level through the dashboard.', '
|
135 |
</td>
|
136 |
</tr>
|
137 |
<tr>
|
138 |
<th scope="row" valign="top">
|
139 |
-
<label for="email_admin_cancels"><?php _e('Cancellation', '
|
140 |
</th>
|
141 |
<td>
|
142 |
<input type="checkbox" id="email_admin_cancels" name="email_admin_cancels" value="1" <?php if(!empty($email_admin_cancels)) { ?>checked="checked"<?php } ?> />
|
143 |
-
<label for="email_admin_cancels"><?php _e('when a user cancels his or her account.', '
|
144 |
</td>
|
145 |
</tr>
|
146 |
<tr>
|
147 |
<th scope="row" valign="top">
|
148 |
-
<label for="email_admin_billing"><?php _e('Bill Updates', '
|
149 |
</th>
|
150 |
<td>
|
151 |
<input type="checkbox" id="email_admin_billing" name="email_admin_billing" value="1" <?php if(!empty($email_admin_billing)) { ?>checked="checked"<?php } ?> />
|
152 |
-
<label for="email_admin_billing"><?php _e('when a user updates his or her billing information.', '
|
153 |
</td>
|
154 |
</tr>
|
155 |
</tbody>
|
156 |
</table>
|
157 |
|
158 |
-
<h3><?php _e('Send members emails', '
|
159 |
|
160 |
<table class="form-table">
|
161 |
<tbody>
|
162 |
<tr>
|
163 |
<th scope="row" valign="top">
|
164 |
-
<label for="email_member_notification"><?php _e('New Users', '
|
165 |
</th>
|
166 |
<td>
|
167 |
<input type="checkbox" id="email_member_notification" name="email_member_notification" value="1" <?php if(!empty($email_member_notification)) { ?>checked="checked"<?php } ?> />
|
168 |
-
<label for="email_member_notification"><?php _e('Default WP notification email. (Recommended: Leave unchecked. Members will still get an email confirmation from PMPro after checkout.)', '
|
169 |
</td>
|
170 |
</tr>
|
171 |
</tbody>
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_emailsettings")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
global $wpdb, $msg, $msgt;
|
66 |
?>
|
67 |
|
68 |
<form action="" method="post" enctype="multipart/form-data">
|
69 |
+
<h2><?php _e('Email Settings', 'paid-memberships-pro' );?></h2>
|
70 |
+
<p><?php _e('By default, system generated emails are sent from <em><strong>wordpress@yourdomain.com</strong></em>. You can update this from address using the fields below.', 'paid-memberships-pro' );?></p>
|
71 |
|
72 |
+
<p><?php _e('To modify the appearance of system generated emails, add the files <em>email_header.html</em> and <em>email_footer.html</em> to your theme\'s directory. This will modify both the WordPress default messages as well as messages generated by Paid Memberships Pro. <a title="Paid Memberships Pro - Member Communications" target="_blank" href="http://www.paidmembershipspro.com/documentation/member-communications/">Click here to learn more about Paid Memberships Pro emails</a>.', 'paid-memberships-pro' );?></p>
|
73 |
|
74 |
<table class="form-table">
|
75 |
<tbody>
|
76 |
<tr>
|
77 |
<th scope="row" valign="top">
|
78 |
+
<label for="from_email"><?php _e('From Email', 'paid-memberships-pro' );?>:</label>
|
79 |
</th>
|
80 |
<td>
|
81 |
<input type="text" name="from_email" size="60" value="<?php echo esc_attr($from_email);?>" />
|
83 |
</tr>
|
84 |
<tr>
|
85 |
<th scope="row" valign="top">
|
86 |
+
<label for="from_name"><?php _e('From Name', 'paid-memberships-pro' );?>:</label>
|
87 |
</th>
|
88 |
<td>
|
89 |
<input type="text" name="from_name" size="60" value="<?php echo esc_attr($from_name);?>" />
|
91 |
</tr>
|
92 |
<tr>
|
93 |
<th scope="row" valign="top">
|
94 |
+
<label for="only_filter_pmpro_emails"><?php _e('Only Filter PMPro Emails?', 'paid-memberships-pro' );?>:</label>
|
95 |
</th>
|
96 |
<td>
|
97 |
<input type="checkbox" id="only_filter_pmpro_emails" name="only_filter_pmpro_emails" value="1" <?php if(!empty($only_filter_pmpro_emails)) { ?>checked="checked"<?php } ?> />
|
98 |
+
<label for="only_filter_pmpro_emails"><?php printf( __('If unchecked, all emails from "WordPress <%s>" will be filtered to use the above settings.', 'paid-memberships-pro' ), $default_from_email );?></label>
|
99 |
</td>
|
100 |
</tr>
|
101 |
</tbody>
|
102 |
</table>
|
103 |
|
104 |
<?php /* going to put something like this here in next version
|
105 |
+
<h3><?php _e('Modify System-generated Email Templates', 'paid-memberships-pro' );?>:</h3>
|
106 |
<?php
|
107 |
if (function_exists('pmproet_scripts'))
|
108 |
{
|
109 |
_e('You have installed the PMPro Email Templates add on. <a href="' . admin_url('admin.php?page=pmpro-email-templates') . '">Click here to modify email templates</a>');
|
110 |
}
|
111 |
?>
|
112 |
+
<p><?php _e('To modify the subject line and body content of system generated emails, <a title="Paid Memberships Pro - Email Templates Plugin" target="_blank" href="' . wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-email-templates-addon'), 'install-plugin_pmpro-email-templates-addon') . '">Install and Activate the PMPro Email Templates add on</a>.', 'paid-memberships-pro' ); ?></p>
|
113 |
*/ ?>
|
114 |
|
115 |
+
<h3><?php _e('Send the site admin emails', 'paid-memberships-pro' );?>:</h3>
|
116 |
|
117 |
<table class="form-table">
|
118 |
<tbody>
|
119 |
<tr>
|
120 |
<th scope="row" valign="top">
|
121 |
+
<label for="email_admin_checkout"><?php _e('Checkout', 'paid-memberships-pro' );?>:</label>
|
122 |
</th>
|
123 |
<td>
|
124 |
<input type="checkbox" id="email_admin_checkout" name="email_admin_checkout" value="1" <?php if(!empty($email_admin_checkout)) { ?>checked="checked"<?php } ?> />
|
125 |
+
<label for="email_admin_checkout"><?php _e('when a member checks out.', 'paid-memberships-pro' );?></label>
|
126 |
</td>
|
127 |
</tr>
|
128 |
<tr>
|
129 |
<th scope="row" valign="top">
|
130 |
+
<label for="email_admin_changes"><?php _e('Admin Changes', 'paid-memberships-pro' );?>:</label>
|
131 |
</th>
|
132 |
<td>
|
133 |
<input type="checkbox" id="email_admin_changes" name="email_admin_changes" value="1" <?php if(!empty($email_admin_changes)) { ?>checked="checked"<?php } ?> />
|
134 |
+
<label for="email_admin_changes"><?php _e('when an admin changes a user\'s membership level through the dashboard.', 'paid-memberships-pro' );?></label>
|
135 |
</td>
|
136 |
</tr>
|
137 |
<tr>
|
138 |
<th scope="row" valign="top">
|
139 |
+
<label for="email_admin_cancels"><?php _e('Cancellation', 'paid-memberships-pro' );?>:</label>
|
140 |
</th>
|
141 |
<td>
|
142 |
<input type="checkbox" id="email_admin_cancels" name="email_admin_cancels" value="1" <?php if(!empty($email_admin_cancels)) { ?>checked="checked"<?php } ?> />
|
143 |
+
<label for="email_admin_cancels"><?php _e('when a user cancels his or her account.', 'paid-memberships-pro' );?></label>
|
144 |
</td>
|
145 |
</tr>
|
146 |
<tr>
|
147 |
<th scope="row" valign="top">
|
148 |
+
<label for="email_admin_billing"><?php _e('Bill Updates', 'paid-memberships-pro' );?>:</label>
|
149 |
</th>
|
150 |
<td>
|
151 |
<input type="checkbox" id="email_admin_billing" name="email_admin_billing" value="1" <?php if(!empty($email_admin_billing)) { ?>checked="checked"<?php } ?> />
|
152 |
+
<label for="email_admin_billing"><?php _e('when a user updates his or her billing information.', 'paid-memberships-pro' );?></label>
|
153 |
</td>
|
154 |
</tr>
|
155 |
</tbody>
|
156 |
</table>
|
157 |
|
158 |
+
<h3><?php _e('Send members emails', 'paid-memberships-pro' );?>:</h3>
|
159 |
|
160 |
<table class="form-table">
|
161 |
<tbody>
|
162 |
<tr>
|
163 |
<th scope="row" valign="top">
|
164 |
+
<label for="email_member_notification"><?php _e('New Users', 'paid-memberships-pro' );?>:</label>
|
165 |
</th>
|
166 |
<td>
|
167 |
<input type="checkbox" id="email_member_notification" name="email_member_notification" value="1" <?php if(!empty($email_member_notification)) { ?>checked="checked"<?php } ?> />
|
168 |
+
<label for="email_member_notification"><?php _e('Default WP notification email. (Recommended: Leave unchecked. Members will still get an email confirmation from PMPro after checkout.)', 'paid-memberships-pro' );?></label>
|
169 |
</td>
|
170 |
</tr>
|
171 |
</tbody>
|
adminpages/functions.php
CHANGED
@@ -11,15 +11,18 @@
|
|
11 |
If you were asked to insert code into "your functions.php file", it was meant that you edit the functions.php
|
12 |
in the root folder of your active theme. e.g. /wp-content/themes/twentytwelve/functions.php
|
13 |
You can also create a custom plugin to place customization code into. Instructions are here:
|
14 |
-
|
15 |
|
16 |
Further documentation for customizing Paid Memberships Pro can be found here:
|
17 |
-
|
18 |
|
19 |
****************************************************************/
|
20 |
|
21 |
/*
|
22 |
Checks if PMPro settings are complete or if there are any errors.
|
|
|
|
|
|
|
23 |
*/
|
24 |
function pmpro_checkLevelForStripeCompatibility($level = NULL)
|
25 |
{
|
@@ -37,14 +40,8 @@ function pmpro_checkLevelForStripeCompatibility($level = NULL)
|
|
37 |
{
|
38 |
foreach($levels as $level)
|
39 |
{
|
40 |
-
|
41 |
-
Stripe currently does not support:
|
42 |
-
* Billing Limits.
|
43 |
-
*/
|
44 |
-
if($level->billing_limit > 0)
|
45 |
-
{
|
46 |
return false;
|
47 |
-
}
|
48 |
}
|
49 |
}
|
50 |
}
|
@@ -67,6 +64,9 @@ function pmpro_checkLevelForStripeCompatibility($level = NULL)
|
|
67 |
|
68 |
/*
|
69 |
Checks if PMPro settings are complete or if there are any errors.
|
|
|
|
|
|
|
70 |
*/
|
71 |
function pmpro_checkLevelForPayflowCompatibility($level = NULL)
|
72 |
{
|
@@ -83,16 +83,9 @@ function pmpro_checkLevelForPayflowCompatibility($level = NULL)
|
|
83 |
if(!empty($levels))
|
84 |
{
|
85 |
foreach($levels as $level)
|
86 |
-
{
|
87 |
-
|
88 |
-
Payflow currently does not support:
|
89 |
-
* Trial Amounts > 0.
|
90 |
-
*/
|
91 |
-
|
92 |
-
if($level->trial_amount > 0)
|
93 |
-
{
|
94 |
return false;
|
95 |
-
}
|
96 |
}
|
97 |
}
|
98 |
}
|
@@ -115,6 +108,11 @@ function pmpro_checkLevelForPayflowCompatibility($level = NULL)
|
|
115 |
|
116 |
/*
|
117 |
Checks if PMPro settings are complete or if there are any errors.
|
|
|
|
|
|
|
|
|
|
|
118 |
*/
|
119 |
function pmpro_checkLevelForBraintreeCompatibility($level = NULL)
|
120 |
{
|
@@ -132,16 +130,8 @@ function pmpro_checkLevelForBraintreeCompatibility($level = NULL)
|
|
132 |
{
|
133 |
foreach($levels as $level)
|
134 |
{
|
135 |
-
|
136 |
-
Braintree currently does not support:
|
137 |
-
* Trial Amounts > 0.
|
138 |
-
* Daily or Weekly billing periods.
|
139 |
-
*/
|
140 |
-
if($level->trial_amount > 0 ||
|
141 |
-
($level->cycle_number > 0 && ($level->cycle_period == "Day" || $level->cycle_period == "Week")))
|
142 |
-
{
|
143 |
return false;
|
144 |
-
}
|
145 |
}
|
146 |
}
|
147 |
}
|
@@ -157,6 +147,12 @@ function pmpro_checkLevelForBraintreeCompatibility($level = NULL)
|
|
157 |
{
|
158 |
return false;
|
159 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
}
|
162 |
|
@@ -165,6 +161,9 @@ function pmpro_checkLevelForBraintreeCompatibility($level = NULL)
|
|
165 |
|
166 |
/*
|
167 |
Checks if PMPro settings are complete or if there are any errors.
|
|
|
|
|
|
|
168 |
*/
|
169 |
function pmpro_checkLevelForTwoCheckoutCompatibility($level = NULL)
|
170 |
{
|
@@ -181,15 +180,9 @@ function pmpro_checkLevelForTwoCheckoutCompatibility($level = NULL)
|
|
181 |
if(!empty($levels))
|
182 |
{
|
183 |
foreach($levels as $level)
|
184 |
-
{
|
185 |
-
|
186 |
-
2Checkout currently does not support:
|
187 |
-
* Trial amounts less than or greater than the absolute value of amonthly recurring amount.
|
188 |
-
*/
|
189 |
-
if(pmpro_isLevelTrial($level))
|
190 |
-
{
|
191 |
return false;
|
192 |
-
}
|
193 |
}
|
194 |
}
|
195 |
}
|
11 |
If you were asked to insert code into "your functions.php file", it was meant that you edit the functions.php
|
12 |
in the root folder of your active theme. e.g. /wp-content/themes/twentytwelve/functions.php
|
13 |
You can also create a custom plugin to place customization code into. Instructions are here:
|
14 |
+
https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
|
15 |
|
16 |
Further documentation for customizing Paid Memberships Pro can be found here:
|
17 |
+
https://www.paidmembershipspro.com/documentation/
|
18 |
|
19 |
****************************************************************/
|
20 |
|
21 |
/*
|
22 |
Checks if PMPro settings are complete or if there are any errors.
|
23 |
+
|
24 |
+
Stripe currently does not support:
|
25 |
+
* Billing Limits.
|
26 |
*/
|
27 |
function pmpro_checkLevelForStripeCompatibility($level = NULL)
|
28 |
{
|
40 |
{
|
41 |
foreach($levels as $level)
|
42 |
{
|
43 |
+
if(!pmpro_checkLevelForStripeCompatibility($level))
|
|
|
|
|
|
|
|
|
|
|
44 |
return false;
|
|
|
45 |
}
|
46 |
}
|
47 |
}
|
64 |
|
65 |
/*
|
66 |
Checks if PMPro settings are complete or if there are any errors.
|
67 |
+
|
68 |
+
Payflow currently does not support:
|
69 |
+
* Trial Amounts > 0.
|
70 |
*/
|
71 |
function pmpro_checkLevelForPayflowCompatibility($level = NULL)
|
72 |
{
|
83 |
if(!empty($levels))
|
84 |
{
|
85 |
foreach($levels as $level)
|
86 |
+
{
|
87 |
+
if(!pmpro_checkLevelForPayflowCompatibility($level))
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
return false;
|
|
|
89 |
}
|
90 |
}
|
91 |
}
|
108 |
|
109 |
/*
|
110 |
Checks if PMPro settings are complete or if there are any errors.
|
111 |
+
|
112 |
+
Braintree currently does not support:
|
113 |
+
* Trial Amounts > 0.
|
114 |
+
* Daily or Weekly billing periods.
|
115 |
+
* Also check that a plan has been created at Braintree
|
116 |
*/
|
117 |
function pmpro_checkLevelForBraintreeCompatibility($level = NULL)
|
118 |
{
|
130 |
{
|
131 |
foreach($levels as $level)
|
132 |
{
|
133 |
+
if(!pmpro_checkLevelForBraintreeCompatibility($level))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
return false;
|
|
|
135 |
}
|
136 |
}
|
137 |
}
|
147 |
{
|
148 |
return false;
|
149 |
}
|
150 |
+
|
151 |
+
//check for plan
|
152 |
+
if(pmpro_isLevelRecurring($level)) {
|
153 |
+
if(!PMProGateway_braintree::checkLevelForPlan($level->id))
|
154 |
+
return false;
|
155 |
+
}
|
156 |
}
|
157 |
}
|
158 |
|
161 |
|
162 |
/*
|
163 |
Checks if PMPro settings are complete or if there are any errors.
|
164 |
+
|
165 |
+
2Checkout currently does not support:
|
166 |
+
* Trial amounts less than or greater than the absolute value of amonthly recurring amount.
|
167 |
*/
|
168 |
function pmpro_checkLevelForTwoCheckoutCompatibility($level = NULL)
|
169 |
{
|
180 |
if(!empty($levels))
|
181 |
{
|
182 |
foreach($levels as $level)
|
183 |
+
{
|
184 |
+
if(!pmpro_checkLevelForTwoCheckoutCompatibility($level))
|
|
|
|
|
|
|
|
|
|
|
185 |
return false;
|
|
|
186 |
}
|
187 |
}
|
188 |
}
|
adminpages/membershiplevels.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_membershiplevels")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
global $wpdb, $msg, $msgt, $pmpro_currency_symbol;
|
@@ -134,10 +134,10 @@
|
|
134 |
|
135 |
$edit = false;
|
136 |
$msg = 1;
|
137 |
-
$msgt = __("Membership level added successfully.",
|
138 |
} else {
|
139 |
$msg = -1;
|
140 |
-
$msgt = __("Error adding membership level.",
|
141 |
}
|
142 |
} else {
|
143 |
pmpro_updateMembershipCategories( $saveid, $ml_categories );
|
@@ -145,11 +145,11 @@
|
|
145 |
if(empty($wpdb->last_error)) {
|
146 |
$edit = false;
|
147 |
$msg = 2;
|
148 |
-
$msgt = __("Membership level updated successfully.",
|
149 |
} else {
|
150 |
$msg = -2;
|
151 |
$msg = true;
|
152 |
-
$msgt = __("Error updating membership level.",
|
153 |
}
|
154 |
}
|
155 |
|
@@ -190,7 +190,7 @@
|
|
190 |
//couldn't delete the subscription
|
191 |
//we should probably notify the admin
|
192 |
$pmproemail = new PMProEmail();
|
193 |
-
$pmproemail->data = array("body"=>"<p>" . sprintf(__("There was an error canceling the subscription for user with ID=%d. You will want to check your payment gateway to see if their subscription is still active.",
|
194 |
$last_order = $wpdb->get_row( $wpdb->prepare( "
|
195 |
SELECT * FROM $wpdb->pmpro_membership_orders
|
196 |
WHERE user_id = %d
|
@@ -198,7 +198,7 @@
|
|
198 |
$user_id
|
199 |
) );
|
200 |
if($last_order)
|
201 |
-
$pmproemail->data["body"] .= "<p>" . __("Last Invoice",
|
202 |
$pmproemail->sendEmail(get_bloginfo("admin_email"));
|
203 |
|
204 |
$r2 = false;
|
@@ -215,15 +215,15 @@
|
|
215 |
|
216 |
if($r1 !== FALSE && $r2 !== FALSE && $r3 !== FALSE) {
|
217 |
$msg = 3;
|
218 |
-
$msgt = __("Membership level deleted successfully.",
|
219 |
} else {
|
220 |
$msg = -3;
|
221 |
-
$msgt = __("Error deleting membership level.",
|
222 |
}
|
223 |
}
|
224 |
else {
|
225 |
$msg = -3;
|
226 |
-
$msgt = __("Error deleting membership level.",
|
227 |
}
|
228 |
}
|
229 |
|
@@ -237,9 +237,9 @@
|
|
237 |
<h2>
|
238 |
<?php
|
239 |
if($edit > 0)
|
240 |
-
echo __("Edit Membership Level",
|
241 |
else
|
242 |
-
echo __("Add New Membership Level",
|
243 |
?>
|
244 |
</h2>
|
245 |
|
@@ -309,19 +309,19 @@
|
|
309 |
<table class="form-table">
|
310 |
<tbody>
|
311 |
<tr>
|
312 |
-
<th scope="row" valign="top"><label><?php _e('ID', '
|
313 |
<td>
|
314 |
<?php echo $level->id?>
|
315 |
</td>
|
316 |
</tr>
|
317 |
|
318 |
<tr>
|
319 |
-
<th scope="row" valign="top"><label for="name"><?php _e('Name', '
|
320 |
<td><input name="name" type="text" size="50" value="<?php echo esc_attr($level->name);?>" /></td>
|
321 |
</tr>
|
322 |
|
323 |
<tr>
|
324 |
-
<th scope="row" valign="top"><label for="description"><?php _e('Description', '
|
325 |
<td>
|
326 |
<div id="poststuff" class="pmpro_description">
|
327 |
<?php
|
@@ -339,7 +339,7 @@
|
|
339 |
</tr>
|
340 |
|
341 |
<tr>
|
342 |
-
<th scope="row" valign="top"><label for="confirmation"><?php _e('Confirmation Message', '
|
343 |
<td>
|
344 |
<div class="pmpro_confirmation">
|
345 |
<?php
|
@@ -358,11 +358,11 @@
|
|
358 |
</tbody>
|
359 |
</table>
|
360 |
|
361 |
-
<h3 class="topborder"><?php _e('Billing Details', '
|
362 |
<table class="form-table">
|
363 |
<tbody>
|
364 |
<tr>
|
365 |
-
<th scope="row" valign="top"><label for="initial_payment"><?php _e('Initial Payment', '
|
366 |
<td>
|
367 |
<?php
|
368 |
if(pmpro_getCurrencyPosition() == "left")
|
@@ -373,16 +373,16 @@
|
|
373 |
if(pmpro_getCurrencyPosition() == "right")
|
374 |
echo $pmpro_currency_symbol;
|
375 |
?>
|
376 |
-
<small><?php _e('The initial amount collected at registration.', '
|
377 |
</tr>
|
378 |
|
379 |
<tr>
|
380 |
-
<th scope="row" valign="top"><label><?php _e('Recurring Subscription', '
|
381 |
-
<td><input id="recurring" name="recurring" type="checkbox" value="yes" <?php if(pmpro_isLevelRecurring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery('#recurring').is(':checked')) { jQuery('.recurring_info').show(); if(jQuery('#custom_trial').is(':checked')) {jQuery('.trial_info').show();} else {jQuery('.trial_info').hide();} } else { jQuery('.recurring_info').hide();}" /> <label for="recurring"><?php _e('Check if this level has a recurring subscription payment.', '
|
382 |
</tr>
|
383 |
|
384 |
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
385 |
-
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Billing Amount', '
|
386 |
<td>
|
387 |
<?php
|
388 |
if(pmpro_getCurrencyPosition() == "left")
|
@@ -393,11 +393,11 @@
|
|
393 |
if(pmpro_getCurrencyPosition() == "right")
|
394 |
echo $pmpro_currency_symbol;
|
395 |
?>
|
396 |
-
<small><?php _e('per', '
|
397 |
<input id="cycle_number" name="cycle_number" type="text" size="10" value="<?php echo esc_attr($level->cycle_number);?>" />
|
398 |
<select id="cycle_period" name="cycle_period">
|
399 |
<?php
|
400 |
-
$cycles = array( __('Day(s)', '
|
401 |
foreach ( $cycles as $name => $value ) {
|
402 |
echo "<option value='$value'";
|
403 |
if ( $level->cycle_period == $value ) echo " selected='selected'";
|
@@ -406,47 +406,47 @@
|
|
406 |
?>
|
407 |
</select>
|
408 |
<br /><small>
|
409 |
-
<?php _e('The amount to be billed one cycle after the initial payment.', '
|
410 |
<?php if($gateway == "stripe") { ?>
|
411 |
-
<br /><strong <?php if(!empty($pmpro_stripe_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Stripe integration currently only supports billing periods of "Week", "Month" or "Year".', '
|
412 |
<?php } elseif($gateway == "braintree") { ?>
|
413 |
-
<br /><strong <?php if(!empty($pmpro_braintree_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Braintree integration currently only supports billing periods of "Month" or "Year".', '
|
414 |
<?php } ?>
|
415 |
</small>
|
416 |
<?php if($gateway == "braintree" && $edit < 0) { ?>
|
417 |
-
<p class="pmpro_message"><strong><?php _e('Note', '
|
418 |
<?php } elseif($gateway == "braintree") { ?>
|
419 |
-
<p class="pmpro_message"><strong><?php _e('Note', '
|
420 |
<?php } ?>
|
421 |
</td>
|
422 |
</tr>
|
423 |
|
424 |
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
425 |
-
<th scope="row" valign="top"><label for="billing_limit"><?php _e('Billing Cycle Limit', '
|
426 |
<td>
|
427 |
<input name="billing_limit" type="text" size="20" value="<?php echo $level->billing_limit?>" />
|
428 |
<br /><small>
|
429 |
-
<?php _e('The <strong>total</strong> number of recurring billing cycles for this level, including the trial period (if applicable) but not including the initial payment. Set to zero if membership is indefinite.', '
|
430 |
<?php if($gateway == "stripe") { ?>
|
431 |
-
<br /><strong <?php if(!empty($pmpro_stripe_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Stripe integration currently does not support billing limits. You can still set an expiration date below.', '
|
432 |
<?php } ?>
|
433 |
</small>
|
434 |
</td>
|
435 |
</tr>
|
436 |
|
437 |
<tr class="recurring_info" <?php if (!pmpro_isLevelRecurring($level)) echo "style='display:none;'";?>>
|
438 |
-
<th scope="row" valign="top"><label><?php _e('Custom Trial', '
|
439 |
<td>
|
440 |
-
<input id="custom_trial" name="custom_trial" type="checkbox" value="yes" <?php if ( pmpro_isLevelTrial($level) ) { echo "checked='checked'"; } ?> onclick="jQuery('.trial_info').toggle();" /> <label for="custom_trial"><?php _e('Check to add a custom trial period.', '
|
441 |
|
442 |
<?php if($gateway == "twocheckout") { ?>
|
443 |
-
<br /><small><strong <?php if(!empty($pmpro_twocheckout_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('2Checkout integration does not support custom trials. You can do one period trials by setting an initial payment different from the billing amount.', '
|
444 |
<?php } ?>
|
445 |
</td>
|
446 |
</tr>
|
447 |
|
448 |
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>>
|
449 |
-
<th scope="row" valign="top"><label for="trial_amount"><?php _e('Trial Billing Amount', '
|
450 |
<td>
|
451 |
<?php
|
452 |
if(pmpro_getCurrencyPosition() == "left")
|
@@ -457,20 +457,20 @@
|
|
457 |
if(pmpro_getCurrencyPosition() == "right")
|
458 |
echo $pmpro_currency_symbol;
|
459 |
?>
|
460 |
-
<small><?php _e('for the first', '
|
461 |
<input name="trial_limit" type="text" size="10" value="<?php echo esc_attr($level->trial_limit);?>" />
|
462 |
-
<small><?php _e('subscription payments', '
|
463 |
<?php if($gateway == "stripe") { ?>
|
464 |
<br /><small>
|
465 |
-
<strong <?php if(!empty($pmpro_stripe_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Stripe integration currently does not support trial amounts greater than $0.', '
|
466 |
</small>
|
467 |
<?php } elseif($gateway == "braintree") { ?>
|
468 |
<br /><small>
|
469 |
-
<strong <?php if(!empty($pmpro_braintree_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Braintree integration currently does not support trial amounts greater than $0.', '
|
470 |
</small>
|
471 |
<?php } elseif($gateway == "payflowpro") { ?>
|
472 |
<br /><small>
|
473 |
-
<strong <?php if(!empty($pmpro_payflow_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Payflow integration currently does not support trial amounts greater than $0.', '
|
474 |
</small>
|
475 |
<?php } ?>
|
476 |
</td>
|
@@ -479,26 +479,26 @@
|
|
479 |
</tbody>
|
480 |
</table>
|
481 |
|
482 |
-
<h3 class="topborder"><?php _e('Other Settings', '
|
483 |
<table class="form-table">
|
484 |
<tbody>
|
485 |
<tr>
|
486 |
-
<th scope="row" valign="top"><label><?php _e('Disable New Signups', '
|
487 |
-
<td><input id="disable_signups" name="disable_signups" type="checkbox" value="yes" <?php if($level->id && !$level->allow_signups) { ?>checked="checked"<?php } ?> /> <label for="disable_signups"><?php _e('Check to hide this level from the membership levels page and disable registration.', '
|
488 |
</tr>
|
489 |
|
490 |
<tr>
|
491 |
-
<th scope="row" valign="top"><label><?php _e('Membership Expiration', '
|
492 |
-
<td><input id="expiration" name="expiration" type="checkbox" value="yes" <?php if(pmpro_isLevelExpiring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery('#expiration').is(':checked')) { jQuery('.expiration_info').show(); } else { jQuery('.expiration_info').hide();}" /> <label for="expiration"><?php _e('Check this to set when membership access expires.', '
|
493 |
</tr>
|
494 |
|
495 |
<tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>>
|
496 |
-
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Expires In', '
|
497 |
<td>
|
498 |
<input id="expiration_number" name="expiration_number" type="text" size="10" value="<?php echo esc_attr($level->expiration_number);?>" />
|
499 |
<select id="expiration_period" name="expiration_period">
|
500 |
<?php
|
501 |
-
$cycles = array( __('Day(s)', '
|
502 |
foreach ( $cycles as $name => $value ) {
|
503 |
echo "<option value='$value'";
|
504 |
if ( $level->expiration_period == $value ) echo " selected='selected'";
|
@@ -506,7 +506,7 @@
|
|
506 |
}
|
507 |
?>
|
508 |
</select>
|
509 |
-
<br /><small><?php _e('Set the duration of membership access. Note that the any future payments (recurring subscription, if any) will be cancelled when the membership expires.', '
|
510 |
</td>
|
511 |
</tr>
|
512 |
</tbody>
|
@@ -514,11 +514,11 @@
|
|
514 |
|
515 |
<?php do_action("pmpro_membership_level_after_other_settings"); ?>
|
516 |
|
517 |
-
<h3 class="topborder"><?php _e('Content Settings', '
|
518 |
<table class="form-table">
|
519 |
<tbody>
|
520 |
<tr class="membership_categories">
|
521 |
-
<th scope="row" valign="top"><label><?php _e('Categories', '
|
522 |
<td>
|
523 |
<?php pmpro_listCategories(0, $level->categories); ?>
|
524 |
</td>
|
@@ -526,8 +526,8 @@
|
|
526 |
</tbody>
|
527 |
</table>
|
528 |
<p class="submit topborder">
|
529 |
-
<input name="save" type="submit" class="button-primary" value="<?php _e('Save Level', '
|
530 |
-
<input name="cancel" type="button" value="<?php _e('Cancel', '
|
531 |
</p>
|
532 |
</form>
|
533 |
</div>
|
@@ -628,19 +628,19 @@
|
|
628 |
}
|
629 |
?>
|
630 |
|
631 |
-
<h2 class="alignleft"><?php _e('Membership Levels', '
|
632 |
<form id="posts-filter" method="get" action="">
|
633 |
<p class="search-box">
|
634 |
-
<label class="screen-reader-text" for="post-search-input"><?php _e('Search Levels', '
|
635 |
<input type="hidden" name="page" value="pmpro-membershiplevels" />
|
636 |
<input id="post-search-input" type="text" value="<?php echo esc_attr($s); ?>" name="s" size="30" />
|
637 |
-
<input class="button" type="submit" value="<?php _e('Search Levels', '
|
638 |
</p>
|
639 |
</form>
|
640 |
|
641 |
<?php if(empty($_REQUEST['s']) && count($reordered_levels) > 1) { ?>
|
642 |
<br class="clear" />
|
643 |
-
<p><?php _e('Drag and drop membership levels to reorder them on the Levels page.', '
|
644 |
<?php } ?>
|
645 |
|
646 |
<?php
|
@@ -650,11 +650,11 @@
|
|
650 |
<table class="widefat membership-levels">
|
651 |
<thead>
|
652 |
<tr>
|
653 |
-
<th><?php _e('ID', '
|
654 |
-
<th><?php _e('Name', '
|
655 |
-
<th><?php _e('Billing Details', '
|
656 |
-
<th><?php _e('Expiration', '
|
657 |
-
<th><?php _e('Allow Signups', '
|
658 |
<th></th>
|
659 |
</tr>
|
660 |
</thead>
|
@@ -669,7 +669,7 @@
|
|
669 |
<td class="level_name"><a href="<?php echo add_query_arg( array( 'page' => 'pmpro-membershiplevels', 'edit' => $level->id ), admin_url( 'admin.php' ) ); ?>"><?php esc_attr_e( $level->name ); ?></a></td>
|
670 |
<td>
|
671 |
<?php if(pmpro_isLevelFree($level)) { ?>
|
672 |
-
<?php _e('FREE', '
|
673 |
<?php } else { ?>
|
674 |
<?php echo str_replace( 'The price for membership is', '', pmpro_getLevelCost($level)); ?>
|
675 |
<?php } ?>
|
@@ -678,12 +678,12 @@
|
|
678 |
<?php if(!pmpro_isLevelExpiring($level)) { ?>
|
679 |
--
|
680 |
<?php } else { ?>
|
681 |
-
<?php _e('After', '
|
682 |
<?php } ?>
|
683 |
</td>
|
684 |
-
<td><?php if($level->allow_signups) { ?><a href="<?php echo add_query_arg( 'level', $level->id, pmpro_url("checkout") );?>"><?php _e('Yes', '
|
685 |
|
686 |
-
<td><a title="<?php _e('edit','
|
687 |
</tr>
|
688 |
<?php
|
689 |
}
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_membershiplevels")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
global $wpdb, $msg, $msgt, $pmpro_currency_symbol;
|
134 |
|
135 |
$edit = false;
|
136 |
$msg = 1;
|
137 |
+
$msgt = __("Membership level added successfully.", 'paid-memberships-pro' );
|
138 |
} else {
|
139 |
$msg = -1;
|
140 |
+
$msgt = __("Error adding membership level.", 'paid-memberships-pro' );
|
141 |
}
|
142 |
} else {
|
143 |
pmpro_updateMembershipCategories( $saveid, $ml_categories );
|
145 |
if(empty($wpdb->last_error)) {
|
146 |
$edit = false;
|
147 |
$msg = 2;
|
148 |
+
$msgt = __("Membership level updated successfully.", 'paid-memberships-pro' );
|
149 |
} else {
|
150 |
$msg = -2;
|
151 |
$msg = true;
|
152 |
+
$msgt = __("Error updating membership level.", 'paid-memberships-pro' );
|
153 |
}
|
154 |
}
|
155 |
|
190 |
//couldn't delete the subscription
|
191 |
//we should probably notify the admin
|
192 |
$pmproemail = new PMProEmail();
|
193 |
+
$pmproemail->data = array("body"=>"<p>" . sprintf(__("There was an error canceling the subscription for user with ID=%d. You will want to check your payment gateway to see if their subscription is still active.", 'paid-memberships-pro' ), $user_id) . "</p>");
|
194 |
$last_order = $wpdb->get_row( $wpdb->prepare( "
|
195 |
SELECT * FROM $wpdb->pmpro_membership_orders
|
196 |
WHERE user_id = %d
|
198 |
$user_id
|
199 |
) );
|
200 |
if($last_order)
|
201 |
+
$pmproemail->data["body"] .= "<p>" . __("Last Invoice", 'paid-memberships-pro' ) . ":<br />" . nl2br(var_export($last_order, true)) . "</p>";
|
202 |
$pmproemail->sendEmail(get_bloginfo("admin_email"));
|
203 |
|
204 |
$r2 = false;
|
215 |
|
216 |
if($r1 !== FALSE && $r2 !== FALSE && $r3 !== FALSE) {
|
217 |
$msg = 3;
|
218 |
+
$msgt = __("Membership level deleted successfully.", 'paid-memberships-pro' );
|
219 |
} else {
|
220 |
$msg = -3;
|
221 |
+
$msgt = __("Error deleting membership level.", 'paid-memberships-pro' );
|
222 |
}
|
223 |
}
|
224 |
else {
|
225 |
$msg = -3;
|
226 |
+
$msgt = __("Error deleting membership level.", 'paid-memberships-pro' );
|
227 |
}
|
228 |
}
|
229 |
|
237 |
<h2>
|
238 |
<?php
|
239 |
if($edit > 0)
|
240 |
+
echo __("Edit Membership Level", 'paid-memberships-pro' );
|
241 |
else
|
242 |
+
echo __("Add New Membership Level", 'paid-memberships-pro' );
|
243 |
?>
|
244 |
</h2>
|
245 |
|
309 |
<table class="form-table">
|
310 |
<tbody>
|
311 |
<tr>
|
312 |
+
<th scope="row" valign="top"><label><?php _e('ID', 'paid-memberships-pro' );?>:</label></th>
|
313 |
<td>
|
314 |
<?php echo $level->id?>
|
315 |
</td>
|
316 |
</tr>
|
317 |
|
318 |
<tr>
|
319 |
+
<th scope="row" valign="top"><label for="name"><?php _e('Name', 'paid-memberships-pro' );?>:</label></th>
|
320 |
<td><input name="name" type="text" size="50" value="<?php echo esc_attr($level->name);?>" /></td>
|
321 |
</tr>
|
322 |
|
323 |
<tr>
|
324 |
+
<th scope="row" valign="top"><label for="description"><?php _e('Description', 'paid-memberships-pro' );?>:</label></th>
|
325 |
<td>
|
326 |
<div id="poststuff" class="pmpro_description">
|
327 |
<?php
|
339 |
</tr>
|
340 |
|
341 |
<tr>
|
342 |
+
<th scope="row" valign="top"><label for="confirmation"><?php _e('Confirmation Message', 'paid-memberships-pro' );?>:</label></th>
|
343 |
<td>
|
344 |
<div class="pmpro_confirmation">
|
345 |
<?php
|
358 |
</tbody>
|
359 |
</table>
|
360 |
|
361 |
+
<h3 class="topborder"><?php _e('Billing Details', 'paid-memberships-pro' );?></h3>
|
362 |
<table class="form-table">
|
363 |
<tbody>
|
364 |
<tr>
|
365 |
+
<th scope="row" valign="top"><label for="initial_payment"><?php _e('Initial Payment', 'paid-memberships-pro' );?>:</label></th>
|
366 |
<td>
|
367 |
<?php
|
368 |
if(pmpro_getCurrencyPosition() == "left")
|
373 |
if(pmpro_getCurrencyPosition() == "right")
|
374 |
echo $pmpro_currency_symbol;
|
375 |
?>
|
376 |
+
<small><?php _e('The initial amount collected at registration.', 'paid-memberships-pro' );?></small></td>
|
377 |
</tr>
|
378 |
|
379 |
<tr>
|
380 |
+
<th scope="row" valign="top"><label><?php _e('Recurring Subscription', 'paid-memberships-pro' );?>:</label></th>
|
381 |
+
<td><input id="recurring" name="recurring" type="checkbox" value="yes" <?php if(pmpro_isLevelRecurring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery('#recurring').is(':checked')) { jQuery('.recurring_info').show(); if(jQuery('#custom_trial').is(':checked')) {jQuery('.trial_info').show();} else {jQuery('.trial_info').hide();} } else { jQuery('.recurring_info').hide();}" /> <label for="recurring"><?php _e('Check if this level has a recurring subscription payment.', 'paid-memberships-pro' );?></label></td>
|
382 |
</tr>
|
383 |
|
384 |
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
385 |
+
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Billing Amount', 'paid-memberships-pro' );?>:</label></th>
|
386 |
<td>
|
387 |
<?php
|
388 |
if(pmpro_getCurrencyPosition() == "left")
|
393 |
if(pmpro_getCurrencyPosition() == "right")
|
394 |
echo $pmpro_currency_symbol;
|
395 |
?>
|
396 |
+
<small><?php _e('per', 'paid-memberships-pro' );?></small>
|
397 |
<input id="cycle_number" name="cycle_number" type="text" size="10" value="<?php echo esc_attr($level->cycle_number);?>" />
|
398 |
<select id="cycle_period" name="cycle_period">
|
399 |
<?php
|
400 |
+
$cycles = array( __('Day(s)', 'paid-memberships-pro' ) => 'Day', __('Week(s)', 'paid-memberships-pro' ) => 'Week', __('Month(s)', 'paid-memberships-pro' ) => 'Month', __('Year(s)', 'paid-memberships-pro' ) => 'Year' );
|
401 |
foreach ( $cycles as $name => $value ) {
|
402 |
echo "<option value='$value'";
|
403 |
if ( $level->cycle_period == $value ) echo " selected='selected'";
|
406 |
?>
|
407 |
</select>
|
408 |
<br /><small>
|
409 |
+
<?php _e('The amount to be billed one cycle after the initial payment.', 'paid-memberships-pro' );?>
|
410 |
<?php if($gateway == "stripe") { ?>
|
411 |
+
<br /><strong <?php if(!empty($pmpro_stripe_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Stripe integration currently only supports billing periods of "Week", "Month" or "Year".', 'paid-memberships-pro' );?>
|
412 |
<?php } elseif($gateway == "braintree") { ?>
|
413 |
+
<br /><strong <?php if(!empty($pmpro_braintree_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Braintree integration currently only supports billing periods of "Month" or "Year".', 'paid-memberships-pro' );?>
|
414 |
<?php } ?>
|
415 |
</small>
|
416 |
<?php if($gateway == "braintree" && $edit < 0) { ?>
|
417 |
+
<p class="pmpro_message"><strong><?php _e('Note', 'paid-memberships-pro' );?>:</strong> <?php _e('After saving this level, make note of the ID and create a "Plan" in your Braintree dashboard with the same settings and the "Plan ID" set to <em>pmpro_#</em>, where # is the level ID.', 'paid-memberships-pro' );?></p>
|
418 |
<?php } elseif($gateway == "braintree") { ?>
|
419 |
+
<p class="pmpro_message <?php if(!PMProGateway_braintree::checkLevelForPlan($level->id)) {?>pmpro_error<?php } ?>"><strong><?php _e('Note', 'paid-memberships-pro' );?>:</strong> <?php _e('You will need to create a "Plan" in your Braintree dashboard with the same settings and the "Plan ID" set to', 'paid-memberships-pro' );?> <em>pmpro_<?php echo $level->id;?></em>.</p>
|
420 |
<?php } ?>
|
421 |
</td>
|
422 |
</tr>
|
423 |
|
424 |
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
425 |
+
<th scope="row" valign="top"><label for="billing_limit"><?php _e('Billing Cycle Limit', 'paid-memberships-pro' );?>:</label></th>
|
426 |
<td>
|
427 |
<input name="billing_limit" type="text" size="20" value="<?php echo $level->billing_limit?>" />
|
428 |
<br /><small>
|
429 |
+
<?php _e('The <strong>total</strong> number of recurring billing cycles for this level, including the trial period (if applicable) but not including the initial payment. Set to zero if membership is indefinite.', 'paid-memberships-pro' );?>
|
430 |
<?php if($gateway == "stripe") { ?>
|
431 |
+
<br /><strong <?php if(!empty($pmpro_stripe_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Stripe integration currently does not support billing limits. You can still set an expiration date below.', 'paid-memberships-pro' );?></strong>
|
432 |
<?php } ?>
|
433 |
</small>
|
434 |
</td>
|
435 |
</tr>
|
436 |
|
437 |
<tr class="recurring_info" <?php if (!pmpro_isLevelRecurring($level)) echo "style='display:none;'";?>>
|
438 |
+
<th scope="row" valign="top"><label><?php _e('Custom Trial', 'paid-memberships-pro' );?>:</label></th>
|
439 |
<td>
|
440 |
+
<input id="custom_trial" name="custom_trial" type="checkbox" value="yes" <?php if ( pmpro_isLevelTrial($level) ) { echo "checked='checked'"; } ?> onclick="jQuery('.trial_info').toggle();" /> <label for="custom_trial"><?php _e('Check to add a custom trial period.', 'paid-memberships-pro' );?></label>
|
441 |
|
442 |
<?php if($gateway == "twocheckout") { ?>
|
443 |
+
<br /><small><strong <?php if(!empty($pmpro_twocheckout_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('2Checkout integration does not support custom trials. You can do one period trials by setting an initial payment different from the billing amount.', 'paid-memberships-pro' );?></strong></small>
|
444 |
<?php } ?>
|
445 |
</td>
|
446 |
</tr>
|
447 |
|
448 |
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>>
|
449 |
+
<th scope="row" valign="top"><label for="trial_amount"><?php _e('Trial Billing Amount', 'paid-memberships-pro' );?>:</label></th>
|
450 |
<td>
|
451 |
<?php
|
452 |
if(pmpro_getCurrencyPosition() == "left")
|
457 |
if(pmpro_getCurrencyPosition() == "right")
|
458 |
echo $pmpro_currency_symbol;
|
459 |
?>
|
460 |
+
<small><?php _e('for the first', 'paid-memberships-pro' );?></small>
|
461 |
<input name="trial_limit" type="text" size="10" value="<?php echo esc_attr($level->trial_limit);?>" />
|
462 |
+
<small><?php _e('subscription payments', 'paid-memberships-pro' );?>.</small>
|
463 |
<?php if($gateway == "stripe") { ?>
|
464 |
<br /><small>
|
465 |
+
<strong <?php if(!empty($pmpro_stripe_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Stripe integration currently does not support trial amounts greater than $0.', 'paid-memberships-pro' );?></strong>
|
466 |
</small>
|
467 |
<?php } elseif($gateway == "braintree") { ?>
|
468 |
<br /><small>
|
469 |
+
<strong <?php if(!empty($pmpro_braintree_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Braintree integration currently does not support trial amounts greater than $0.', 'paid-memberships-pro' );?></strong>
|
470 |
</small>
|
471 |
<?php } elseif($gateway == "payflowpro") { ?>
|
472 |
<br /><small>
|
473 |
+
<strong <?php if(!empty($pmpro_payflow_error)) { ?>class="pmpro_red"<?php } ?>><?php _e('Payflow integration currently does not support trial amounts greater than $0.', 'paid-memberships-pro' );?></strong>
|
474 |
</small>
|
475 |
<?php } ?>
|
476 |
</td>
|
479 |
</tbody>
|
480 |
</table>
|
481 |
|
482 |
+
<h3 class="topborder"><?php _e('Other Settings', 'paid-memberships-pro' );?></h3>
|
483 |
<table class="form-table">
|
484 |
<tbody>
|
485 |
<tr>
|
486 |
+
<th scope="row" valign="top"><label><?php _e('Disable New Signups', 'paid-memberships-pro' );?>:</label></th>
|
487 |
+
<td><input id="disable_signups" name="disable_signups" type="checkbox" value="yes" <?php if($level->id && !$level->allow_signups) { ?>checked="checked"<?php } ?> /> <label for="disable_signups"><?php _e('Check to hide this level from the membership levels page and disable registration.', 'paid-memberships-pro' );?></label></td>
|
488 |
</tr>
|
489 |
|
490 |
<tr>
|
491 |
+
<th scope="row" valign="top"><label><?php _e('Membership Expiration', 'paid-memberships-pro' );?>:</label></th>
|
492 |
+
<td><input id="expiration" name="expiration" type="checkbox" value="yes" <?php if(pmpro_isLevelExpiring($level)) { echo "checked='checked'"; } ?> onclick="if(jQuery('#expiration').is(':checked')) { jQuery('.expiration_info').show(); } else { jQuery('.expiration_info').hide();}" /> <label for="expiration"><?php _e('Check this to set when membership access expires.', 'paid-memberships-pro' );?></label></a></td>
|
493 |
</tr>
|
494 |
|
495 |
<tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>>
|
496 |
+
<th scope="row" valign="top"><label for="billing_amount"><?php _e('Expires In', 'paid-memberships-pro' );?>:</label></th>
|
497 |
<td>
|
498 |
<input id="expiration_number" name="expiration_number" type="text" size="10" value="<?php echo esc_attr($level->expiration_number);?>" />
|
499 |
<select id="expiration_period" name="expiration_period">
|
500 |
<?php
|
501 |
+
$cycles = array( __('Day(s)', 'paid-memberships-pro' ) => 'Day', __('Week(s)', 'paid-memberships-pro' ) => 'Week', __('Month(s)', 'paid-memberships-pro' ) => 'Month', __('Year(s)', 'paid-memberships-pro' ) => 'Year' );
|
502 |
foreach ( $cycles as $name => $value ) {
|
503 |
echo "<option value='$value'";
|
504 |
if ( $level->expiration_period == $value ) echo " selected='selected'";
|
506 |
}
|
507 |
?>
|
508 |
</select>
|
509 |
+
<br /><small><?php _e('Set the duration of membership access. Note that the any future payments (recurring subscription, if any) will be cancelled when the membership expires.', 'paid-memberships-pro' );?></small>
|
510 |
</td>
|
511 |
</tr>
|
512 |
</tbody>
|
514 |
|
515 |
<?php do_action("pmpro_membership_level_after_other_settings"); ?>
|
516 |
|
517 |
+
<h3 class="topborder"><?php _e('Content Settings', 'paid-memberships-pro' );?></h3>
|
518 |
<table class="form-table">
|
519 |
<tbody>
|
520 |
<tr class="membership_categories">
|
521 |
+
<th scope="row" valign="top"><label><?php _e('Categories', 'paid-memberships-pro' );?>:</label></th>
|
522 |
<td>
|
523 |
<?php pmpro_listCategories(0, $level->categories); ?>
|
524 |
</td>
|
526 |
</tbody>
|
527 |
</table>
|
528 |
<p class="submit topborder">
|
529 |
+
<input name="save" type="submit" class="button-primary" value="<?php _e('Save Level', 'paid-memberships-pro' ); ?>" />
|
530 |
+
<input name="cancel" type="button" value="<?php _e('Cancel', 'paid-memberships-pro' ); ?>" onclick="location.href='<?php echo add_query_arg( 'page', 'pmpro-membershiplevels' , get_admin_url(NULL, '/admin.php') ); ?>';" />
|
531 |
</p>
|
532 |
</form>
|
533 |
</div>
|
628 |
}
|
629 |
?>
|
630 |
|
631 |
+
<h2 class="alignleft"><?php _e('Membership Levels', 'paid-memberships-pro' );?> <a href="<?php echo add_query_arg( array( 'page' => 'pmpro-membershiplevels', 'edit' => -1 ), get_admin_url(null, 'admin.php' ) ); ?>" class="add-new-h2"><?php _e('Add New Level', 'paid-memberships-pro' );?></a></h2>
|
632 |
<form id="posts-filter" method="get" action="">
|
633 |
<p class="search-box">
|
634 |
+
<label class="screen-reader-text" for="post-search-input"><?php _e('Search Levels', 'paid-memberships-pro' );?>:</label>
|
635 |
<input type="hidden" name="page" value="pmpro-membershiplevels" />
|
636 |
<input id="post-search-input" type="text" value="<?php echo esc_attr($s); ?>" name="s" size="30" />
|
637 |
+
<input class="button" type="submit" value="<?php _e('Search Levels', 'paid-memberships-pro' );?>" id="search-submit" />
|
638 |
</p>
|
639 |
</form>
|
640 |
|
641 |
<?php if(empty($_REQUEST['s']) && count($reordered_levels) > 1) { ?>
|
642 |
<br class="clear" />
|
643 |
+
<p><?php _e('Drag and drop membership levels to reorder them on the Levels page.', 'paid-memberships-pro' ); ?></p>
|
644 |
<?php } ?>
|
645 |
|
646 |
<?php
|
650 |
<table class="widefat membership-levels">
|
651 |
<thead>
|
652 |
<tr>
|
653 |
+
<th><?php _e('ID', 'paid-memberships-pro' );?></th>
|
654 |
+
<th><?php _e('Name', 'paid-memberships-pro' );?></th>
|
655 |
+
<th><?php _e('Billing Details', 'paid-memberships-pro' );?></th>
|
656 |
+
<th><?php _e('Expiration', 'paid-memberships-pro' );?></th>
|
657 |
+
<th><?php _e('Allow Signups', 'paid-memberships-pro' );?></th>
|
658 |
<th></th>
|
659 |
</tr>
|
660 |
</thead>
|
669 |
<td class="level_name"><a href="<?php echo add_query_arg( array( 'page' => 'pmpro-membershiplevels', 'edit' => $level->id ), admin_url( 'admin.php' ) ); ?>"><?php esc_attr_e( $level->name ); ?></a></td>
|
670 |
<td>
|
671 |
<?php if(pmpro_isLevelFree($level)) { ?>
|
672 |
+
<?php _e('FREE', 'paid-memberships-pro' );?>
|
673 |
<?php } else { ?>
|
674 |
<?php echo str_replace( 'The price for membership is', '', pmpro_getLevelCost($level)); ?>
|
675 |
<?php } ?>
|
678 |
<?php if(!pmpro_isLevelExpiring($level)) { ?>
|
679 |
--
|
680 |
<?php } else { ?>
|
681 |
+
<?php _e('After', 'paid-memberships-pro' );?> <?php echo $level->expiration_number?> <?php echo sornot($level->expiration_period,$level->expiration_number)?>
|
682 |
<?php } ?>
|
683 |
</td>
|
684 |
+
<td><?php if($level->allow_signups) { ?><a href="<?php echo add_query_arg( 'level', $level->id, pmpro_url("checkout") );?>"><?php _e('Yes', 'paid-memberships-pro' );?></a><?php } else { ?><?php _e('No', 'paid-memberships-pro' );?><?php } ?></td>
|
685 |
|
686 |
+
<td><a title="<?php _e('edit', 'paid-memberships-pro' ); ?>" href="<?php echo add_query_arg( array( 'page' => 'pmpro-membershiplevels', 'edit' => $level->id ), admin_url('admin.php' ) ); ?>" class="button-primary"><?php _e('edit', 'paid-memberships-pro' ); ?></a> <a title="<?php _e('copy', 'paid-memberships-pro' ); ?>" href="<?php echo add_query_arg( array( 'page' => 'pmpro-membershiplevels', 'edit' => -1, 'copy' => $level->id ), admin_url( 'admin.php' ) ); ?>" class="button-secondary"><?php _e('copy', 'paid-memberships-pro' ); ?></a> <a title="<?php _e('delete', 'paid-memberships-pro' ); ?>" href="javascript:askfirst('<?php echo str_replace("'", "\'", sprintf(__("Are you sure you want to delete membership level %s? All subscriptions will be cancelled.", 'paid-memberships-pro' ), $level->name));?>', '<?php echo add_query_arg( array( 'page' => 'pmpro-membershiplevels', 'action' => 'delete_membership_level', 'deleteid' => $level->id ), admin_url( 'admin.php' ) ); ?>'); void(0);" class="button-secondary"><?php _e('delete', 'paid-memberships-pro' ); ?></a></td>
|
687 |
</tr>
|
688 |
<?php
|
689 |
}
|
adminpages/memberslist-csv.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_memberslistcsv")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
if (!defined('PMPRO_BENCHMARK'))
|
@@ -350,7 +350,7 @@
|
|
350 |
|
351 |
foreach( $um_values as $key => $value ) {
|
352 |
|
353 |
-
$metavalues->{$key} = $value[0];
|
354 |
}
|
355 |
|
356 |
$theuser->metavalues = $metavalues;
|
2 |
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_memberslistcsv")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
if (!defined('PMPRO_BENCHMARK'))
|
350 |
|
351 |
foreach( $um_values as $key => $value ) {
|
352 |
|
353 |
+
$metavalues->{$key} = isset( $value[0] ) ? $value[0] : null;
|
354 |
}
|
355 |
|
356 |
$theuser->metavalues = $metavalues;
|
adminpages/memberslist.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_memberslist")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
//vars
|
@@ -22,14 +22,14 @@
|
|
22 |
|
23 |
<form id="posts-filter" method="get" action="">
|
24 |
<h2>
|
25 |
-
<?php _e('Members List', '
|
26 |
-
<a target="_blank" href="<?php echo admin_url('admin-ajax.php');?>?action=memberslist_csv&s=<?php echo esc_attr($s);?>&l=<?php echo $l?>" class="add-new-h2"><?php _e('Export to CSV', '
|
27 |
</h2>
|
28 |
<ul class="subsubsub">
|
29 |
<li>
|
30 |
-
<?php _e('Show', '
|
31 |
<select name="l" onchange="jQuery('#posts-filter').submit();">
|
32 |
-
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', '
|
33 |
<?php
|
34 |
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
35 |
foreach($levels as $level)
|
@@ -39,17 +39,17 @@
|
|
39 |
<?php
|
40 |
}
|
41 |
?>
|
42 |
-
<option value="cancelled" <?php if($l == "cancelled") { ?>selected="selected"<?php } ?>><?php _e('Cancelled Members', '
|
43 |
-
<option value="expired" <?php if($l == "expired") { ?>selected="selected"<?php } ?>><?php _e('Expired Members', '
|
44 |
-
<option value="oldmembers" <?php if($l == "oldmembers") { ?>selected="selected"<?php } ?>><?php _e('Old Members', '
|
45 |
</select>
|
46 |
</li>
|
47 |
</ul>
|
48 |
<p class="search-box">
|
49 |
-
<label class="hidden" for="post-search-input"><?php _e('Search Members', '
|
50 |
<input type="hidden" name="page" value="pmpro-memberslist" />
|
51 |
<input id="post-search-input" type="text" value="<?php echo esc_attr($s);?>" name="s"/>
|
52 |
-
<input class="button" type="submit" value="<?php _e('Search Members', '
|
53 |
</p>
|
54 |
<?php
|
55 |
//some vars for the search
|
@@ -153,7 +153,7 @@
|
|
153 |
else
|
154 |
{
|
155 |
?>
|
156 |
-
<p class="clear"><?php printf(__("%d members found.",
|
157 |
<?php
|
158 |
}
|
159 |
}
|
@@ -161,22 +161,22 @@
|
|
161 |
<table class="widefat">
|
162 |
<thead>
|
163 |
<tr class="thead">
|
164 |
-
<th><?php _e('ID', '
|
165 |
-
<th><?php _e('Username', '
|
166 |
-
<th><?php _e('First Name', '
|
167 |
-
<th><?php _e('Last Name', '
|
168 |
-
<th><?php _e('Email', '
|
169 |
<?php do_action("pmpro_memberslist_extra_cols_header", $theusers);?>
|
170 |
-
<th><?php _e('Billing Address', '
|
171 |
-
<th><?php _e('Membership', '
|
172 |
-
<th><?php _e('Fee', '
|
173 |
-
<th><?php _e('Joined', '
|
174 |
<th>
|
175 |
<?php
|
176 |
if($l == "oldmembers")
|
177 |
-
_e('Ended', '
|
178 |
else
|
179 |
-
_e('Expires', '
|
180 |
?>
|
181 |
</th>
|
182 |
</tr>
|
@@ -259,7 +259,7 @@
|
|
259 |
{
|
260 |
?>
|
261 |
<tr>
|
262 |
-
<td colspan="9"><p><?php _e("No members found.",
|
263 |
</tr>
|
264 |
<?php
|
265 |
}
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_memberslist")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
//vars
|
22 |
|
23 |
<form id="posts-filter" method="get" action="">
|
24 |
<h2>
|
25 |
+
<?php _e('Members List', 'paid-memberships-pro' );?>
|
26 |
+
<a target="_blank" href="<?php echo admin_url('admin-ajax.php');?>?action=memberslist_csv&s=<?php echo esc_attr($s);?>&l=<?php echo $l?>" class="add-new-h2"><?php _e('Export to CSV', 'paid-memberships-pro' );?></a>
|
27 |
</h2>
|
28 |
<ul class="subsubsub">
|
29 |
<li>
|
30 |
+
<?php _e('Show', 'paid-memberships-pro' );?>
|
31 |
<select name="l" onchange="jQuery('#posts-filter').submit();">
|
32 |
+
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'paid-memberships-pro' );?></option>
|
33 |
<?php
|
34 |
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
35 |
foreach($levels as $level)
|
39 |
<?php
|
40 |
}
|
41 |
?>
|
42 |
+
<option value="cancelled" <?php if($l == "cancelled") { ?>selected="selected"<?php } ?>><?php _e('Cancelled Members', 'paid-memberships-pro' );?></option>
|
43 |
+
<option value="expired" <?php if($l == "expired") { ?>selected="selected"<?php } ?>><?php _e('Expired Members', 'paid-memberships-pro' );?></option>
|
44 |
+
<option value="oldmembers" <?php if($l == "oldmembers") { ?>selected="selected"<?php } ?>><?php _e('Old Members', 'paid-memberships-pro' );?></option>
|
45 |
</select>
|
46 |
</li>
|
47 |
</ul>
|
48 |
<p class="search-box">
|
49 |
+
<label class="hidden" for="post-search-input"><?php _e('Search Members', 'paid-memberships-pro' );?>:</label>
|
50 |
<input type="hidden" name="page" value="pmpro-memberslist" />
|
51 |
<input id="post-search-input" type="text" value="<?php echo esc_attr($s);?>" name="s"/>
|
52 |
+
<input class="button" type="submit" value="<?php _e('Search Members', 'paid-memberships-pro' );?>"/>
|
53 |
</p>
|
54 |
<?php
|
55 |
//some vars for the search
|
153 |
else
|
154 |
{
|
155 |
?>
|
156 |
+
<p class="clear"><?php printf(__("%d members found.", 'paid-memberships-pro' ), $totalrows);?></span></p>
|
157 |
<?php
|
158 |
}
|
159 |
}
|
161 |
<table class="widefat">
|
162 |
<thead>
|
163 |
<tr class="thead">
|
164 |
+
<th><?php _e('ID', 'paid-memberships-pro' );?></th>
|
165 |
+
<th><?php _e('Username', 'paid-memberships-pro' );?></th>
|
166 |
+
<th><?php _e('First Name', 'paid-memberships-pro' );?></th>
|
167 |
+
<th><?php _e('Last Name', 'paid-memberships-pro' );?></th>
|
168 |
+
<th><?php _e('Email', 'paid-memberships-pro' );?></th>
|
169 |
<?php do_action("pmpro_memberslist_extra_cols_header", $theusers);?>
|
170 |
+
<th><?php _e('Billing Address', 'paid-memberships-pro' );?></th>
|
171 |
+
<th><?php _e('Membership', 'paid-memberships-pro' );?></th>
|
172 |
+
<th><?php _e('Fee', 'paid-memberships-pro' );?></th>
|
173 |
+
<th><?php _e('Joined', 'paid-memberships-pro' );?></th>
|
174 |
<th>
|
175 |
<?php
|
176 |
if($l == "oldmembers")
|
177 |
+
_e('Ended', 'paid-memberships-pro' );
|
178 |
else
|
179 |
+
_e('Expires', 'paid-memberships-pro' );
|
180 |
?>
|
181 |
</th>
|
182 |
</tr>
|
259 |
{
|
260 |
?>
|
261 |
<tr>
|
262 |
+
<td colspan="9"><p><?php _e("No members found.", 'paid-memberships-pro' );?> <?php if($l) { ?><a href="?page=pmpro-memberslist&s=<?php echo esc_attr($s);?>"><?php _e("Search all levels", 'paid-memberships-pro' );?></a>.<?php } ?></p></td>
|
263 |
</tr>
|
264 |
<?php
|
265 |
}
|
adminpages/orders-csv.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
//only admins can get this
|
3 |
if ( ! function_exists( "current_user_can" ) || ( ! current_user_can( "manage_options" ) && ! current_user_can( "pmpro_orderscsv" ) ) ) {
|
4 |
-
die( __( "You do not have permissions to perform this action.",
|
5 |
}
|
6 |
|
7 |
define('PMPRO_BENCHMARK', true);
|
1 |
<?php
|
2 |
//only admins can get this
|
3 |
if ( ! function_exists( "current_user_can" ) || ( ! current_user_can( "manage_options" ) && ! current_user_can( "pmpro_orderscsv" ) ) ) {
|
4 |
+
die( __( "You do not have permissions to perform this action.", 'paid-memberships-pro' ) );
|
5 |
}
|
6 |
|
7 |
define('PMPRO_BENCHMARK', true);
|
adminpages/orders-print.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
|
10 |
//only admins can get this
|
11 |
if ( ! function_exists( "current_user_can" ) || ( ! current_user_can( "manage_options" ) && ! current_user_can( "pmpro_ordersprint" ) ) ) {
|
12 |
-
die( __( "You do not have permissions to perform this action.",
|
13 |
}
|
14 |
|
15 |
// Do we have an order ID?
|
9 |
|
10 |
//only admins can get this
|
11 |
if ( ! function_exists( "current_user_can" ) || ( ! current_user_can( "manage_options" ) && ! current_user_can( "pmpro_ordersprint" ) ) ) {
|
12 |
+
die( __( "You do not have permissions to perform this action.", 'paid-memberships-pro' ) );
|
13 |
}
|
14 |
|
15 |
// Do we have an order ID?
|
adminpages/orders.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
//only admins can get this
|
3 |
if ( ! function_exists( "current_user_can" ) || ( ! current_user_can( "manage_options" ) && ! current_user_can( "pmpro_orders" ) ) ) {
|
4 |
-
die( __( "You do not have permissions to perform this action.",
|
5 |
}
|
6 |
|
7 |
//vars
|
@@ -143,10 +143,10 @@ if ( ! empty( $_REQUEST['email'] ) && ! empty( $_REQUEST['order'] ) ) {
|
|
143 |
$user = get_user_by( 'email', $_REQUEST['email'] );
|
144 |
$order = new MemberOrder( $_REQUEST['order'] );
|
145 |
if ( $email->sendBillableInvoiceEmail( $user, $order ) ) {
|
146 |
-
$pmpro_msg = __( "Invoice emailed successfully.",
|
147 |
$pmpro_msgt = "success";
|
148 |
} else {
|
149 |
-
$pmpro_msg = __( "Error emailing invoice.",
|
150 |
$pmpro_msgt = "error";
|
151 |
}
|
152 |
|
@@ -159,10 +159,10 @@ if ( ! empty( $_REQUEST['email'] ) && ! empty( $_REQUEST['order'] ) ) {
|
|
159 |
if ( ! empty( $_REQUEST['delete'] ) ) {
|
160 |
$dorder = new MemberOrder( intval( $_REQUEST['delete'] ) );
|
161 |
if ( $dorder->deleteMe() ) {
|
162 |
-
$pmpro_msg = __( "Order deleted successfully.",
|
163 |
$pmpro_msgt = "success";
|
164 |
} else {
|
165 |
-
$pmpro_msg = __( "Error deleting order.",
|
166 |
$pmpro_msgt = "error";
|
167 |
}
|
168 |
}
|
@@ -282,14 +282,14 @@ if ( ! empty( $_REQUEST['save'] ) ) {
|
|
282 |
if ( $order->saveOrder() !== false ) {
|
283 |
//handle timestamp
|
284 |
if ( $order->updateTimestamp( $_POST['ts_year'], $_POST['ts_month'], $_POST['ts_day'] ) !== false ) {
|
285 |
-
$pmpro_msg = __( "Order saved successfully.",
|
286 |
$pmpro_msgt = "success";
|
287 |
} else {
|
288 |
-
$pmpro_msg = __( "Error updating order timestamp.",
|
289 |
$pmpro_msgt = "error";
|
290 |
}
|
291 |
} else {
|
292 |
-
$pmpro_msg = __( "Error saving order.",
|
293 |
$pmpro_msgt = "error";
|
294 |
}
|
295 |
} else {
|
@@ -349,9 +349,9 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
349 |
|
350 |
<h2>
|
351 |
<?php if ( ! empty( $order->id ) ) { ?>
|
352 |
-
<?php _e( 'Order', '
|
353 |
<?php } else { ?>
|
354 |
-
<?php _e( 'New Order', '
|
355 |
<?php } ?>
|
356 |
</h2>
|
357 |
|
@@ -372,12 +372,12 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
372 |
<td><?php if ( ! empty( $order->id ) ) {
|
373 |
echo $order->id;
|
374 |
} else {
|
375 |
-
echo __( "This will be generated when you save.",
|
376 |
} ?></td>
|
377 |
</tr>
|
378 |
|
379 |
<tr>
|
380 |
-
<th scope="row" valign="top"><label for="code"><?php _e( 'Code', '
|
381 |
<td>
|
382 |
<?php if ( in_array( "code", $read_only_fields ) ) {
|
383 |
echo $order->code;
|
@@ -387,12 +387,12 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
387 |
<?php } ?>
|
388 |
<?php if ( $order_id < 0 ) { ?>
|
389 |
<small
|
390 |
-
class="pmpro_lite"><?php _e( 'Randomly generated for you.', '
|
391 |
</td>
|
392 |
</tr>
|
393 |
|
394 |
<tr>
|
395 |
-
<th scope="row" valign="top"><label for="user_id"><?php _e( 'User ID', '
|
396 |
<td>
|
397 |
<?php if ( in_array( "user_id", $read_only_fields ) && $order_id > 0 ) {
|
398 |
echo $order->user_id;
|
@@ -404,7 +404,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
404 |
</tr>
|
405 |
|
406 |
<tr>
|
407 |
-
<th scope="row" valign="top"><label for="membership_id"><?php _e( 'Membership Level ID', '
|
408 |
:</label></th>
|
409 |
<td>
|
410 |
<?php if ( in_array( "membership_id", $read_only_fields ) && $order_id > 0 ) {
|
@@ -417,7 +417,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
417 |
</tr>
|
418 |
|
419 |
<tr>
|
420 |
-
<th scope="row" valign="top"><label for="billing_name"><?php _e( 'Billing Name', '
|
421 |
</th>
|
422 |
<td>
|
423 |
<?php if ( in_array( "billing_name", $read_only_fields ) && $order_id > 0 ) {
|
@@ -429,7 +429,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
429 |
</td>
|
430 |
</tr>
|
431 |
<tr>
|
432 |
-
<th scope="row" valign="top"><label for="billing_street"><?php _e( 'Billing Street', '
|
433 |
:</label></th>
|
434 |
<td>
|
435 |
<?php if ( in_array( "billing_street", $read_only_fields ) && $order_id > 0 ) {
|
@@ -440,7 +440,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
440 |
<?php } ?>
|
441 |
</tr>
|
442 |
<tr>
|
443 |
-
<th scope="row" valign="top"><label for="billing_city"><?php _e( 'Billing City', '
|
444 |
</th>
|
445 |
<td>
|
446 |
<?php if ( in_array( "billing_city", $read_only_fields ) && $order_id > 0 ) {
|
@@ -451,7 +451,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
451 |
<?php } ?>
|
452 |
</tr>
|
453 |
<tr>
|
454 |
-
<th scope="row" valign="top"><label for="billing_state"><?php _e( 'Billing State', '
|
455 |
:</label></th>
|
456 |
<td>
|
457 |
<?php if ( in_array( "billing_state", $read_only_fields ) && $order_id > 0 ) {
|
@@ -462,7 +462,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
462 |
<?php } ?>
|
463 |
</tr>
|
464 |
<tr>
|
465 |
-
<th scope="row" valign="top"><label for="billing_zip"><?php _e( 'Billing Postal Code', '
|
466 |
:</label></th>
|
467 |
<td>
|
468 |
<?php if ( in_array( "billing_zip", $read_only_fields ) && $order_id > 0 ) {
|
@@ -473,7 +473,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
473 |
<?php } ?>
|
474 |
</tr>
|
475 |
<tr>
|
476 |
-
<th scope="row" valign="top"><label for="billing_country"><?php _e( 'Billing Country', '
|
477 |
:</label></th>
|
478 |
<td>
|
479 |
<?php if ( in_array( "billing_country", $read_only_fields ) && $order_id > 0 ) {
|
@@ -485,7 +485,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
485 |
</td>
|
486 |
</tr>
|
487 |
<tr>
|
488 |
-
<th scope="row" valign="top"><label for="billing_phone"><?php _e( 'Billing Phone', '
|
489 |
:</label></th>
|
490 |
<td>
|
491 |
<?php if ( in_array( "billing_phone", $read_only_fields ) && $order_id > 0 ) {
|
@@ -498,7 +498,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
498 |
</tr>
|
499 |
|
500 |
<tr>
|
501 |
-
<th scope="row" valign="top"><label for="subtotal"><?php _e( 'Sub Total', '
|
502 |
<td>
|
503 |
<?php if ( in_array( "subtotal", $read_only_fields ) && $order_id > 0 ) {
|
504 |
echo $order->subtotal;
|
@@ -509,7 +509,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
509 |
</td>
|
510 |
</tr>
|
511 |
<tr>
|
512 |
-
<th scope="row" valign="top"><label for="tax"><?php _e( 'Tax', '
|
513 |
<td>
|
514 |
<?php if ( in_array( "tax", $read_only_fields ) && $order_id > 0 ) {
|
515 |
echo $order->tax;
|
@@ -520,7 +520,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
520 |
</td>
|
521 |
</tr>
|
522 |
<tr>
|
523 |
-
<th scope="row" valign="top"><label for="couponamount"><?php _e( 'Coupon Amount', '
|
524 |
</th>
|
525 |
<td>
|
526 |
<?php if ( in_array( "couponamount", $read_only_fields ) && $order_id > 0 ) {
|
@@ -532,7 +532,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
532 |
</td>
|
533 |
</tr>
|
534 |
<tr>
|
535 |
-
<th scope="row" valign="top"><label for="total"><?php _e( 'Total', '
|
536 |
<td>
|
537 |
<?php if ( in_array( "total", $read_only_fields ) && $order_id > 0 ) {
|
538 |
echo $order->total;
|
@@ -541,12 +541,12 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
541 |
value="<?php echo esc_attr( $order->total ); ?>"/>
|
542 |
<?php } ?>
|
543 |
<small
|
544 |
-
class="pmpro_lite"><?php _e( 'Should be subtotal + tax - couponamount.', '
|
545 |
</td>
|
546 |
</tr>
|
547 |
|
548 |
<tr>
|
549 |
-
<th scope="row" valign="top"><label for="payment_type"><?php _e( 'Payment Type', '
|
550 |
</th>
|
551 |
<td>
|
552 |
<?php if ( in_array( "payment_type", $read_only_fields ) && $order_id > 0 ) {
|
@@ -556,11 +556,11 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
556 |
value="<?php echo esc_attr( $order->payment_type ); ?>"/>
|
557 |
<?php } ?>
|
558 |
<small
|
559 |
-
class="pmpro_lite"><?php _e( 'e.g. PayPal Express, PayPal Standard, Credit Card.', '
|
560 |
</td>
|
561 |
</tr>
|
562 |
<tr>
|
563 |
-
<th scope="row" valign="top"><label for="cardtype"><?php _e( 'Card Type', '
|
564 |
<td>
|
565 |
<?php if ( in_array( "cardtype", $read_only_fields ) && $order_id > 0 ) {
|
566 |
echo $order->cardtype;
|
@@ -568,11 +568,11 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
568 |
<input id="cardtype" name="cardtype" type="text" size="50"
|
569 |
value="<?php echo esc_attr( $order->cardtype ); ?>"/>
|
570 |
<?php } ?>
|
571 |
-
<small class="pmpro_lite"><?php _e( 'e.g. Visa, MasterCard, AMEX, etc', '
|
572 |
</td>
|
573 |
</tr>
|
574 |
<tr>
|
575 |
-
<th scope="row" valign="top"><label for="accountnumber"><?php _e( 'Account Number', '
|
576 |
:</label></th>
|
577 |
<td>
|
578 |
<?php if ( in_array( "accountnumber", $read_only_fields ) && $order_id > 0 ) {
|
@@ -581,7 +581,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
581 |
<input id="accountnumber" name="accountnumber" type="text" size="50"
|
582 |
value="<?php echo esc_attr( $order->accountnumber ); ?>"/>
|
583 |
<?php } ?>
|
584 |
-
<small class="pmpro_lite"><?php _e( 'Obscure all but last 4 digits.', '
|
585 |
</td>
|
586 |
</tr>
|
587 |
<?php if ( in_array( "ExpirationDate", $read_only_fields ) && $order_id > 0 ) {
|
@@ -589,7 +589,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
589 |
} else { ?>
|
590 |
<tr>
|
591 |
<th scope="row" valign="top"><label
|
592 |
-
for="expirationmonth"><?php _e( 'Expiration Month', '
|
593 |
<td>
|
594 |
<input id="expirationmonth" name="expirationmonth" type="text" size="10"
|
595 |
value="<?php echo esc_attr( $order->expirationmonth ); ?>"/>
|
@@ -597,7 +597,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
597 |
</td>
|
598 |
</tr>
|
599 |
<tr>
|
600 |
-
<th scope="row" valign="top"><label for="expirationyear"><?php _e( 'Expiration Year', '
|
601 |
:</label></th>
|
602 |
<td>
|
603 |
<input id="expirationyear" name="expirationyear" type="text" size="10"
|
@@ -607,7 +607,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
607 |
</tr>
|
608 |
<?php } ?>
|
609 |
<tr>
|
610 |
-
<th scope="row" valign="top"><label for="status"><?php _e( 'Status', '
|
611 |
<td>
|
612 |
<?php if ( in_array( "status", $read_only_fields ) && $order_id > 0 ) {
|
613 |
echo $order->status;
|
@@ -640,7 +640,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
640 |
</tr>
|
641 |
|
642 |
<tr>
|
643 |
-
<th scope="row" valign="top"><label for="gateway"><?php _e( 'Gateway', '
|
644 |
<td>
|
645 |
<?php if ( in_array( "gateway", $read_only_fields ) && $order_id > 0 ) {
|
646 |
echo $order->gateway;
|
@@ -661,16 +661,16 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
661 |
</tr>
|
662 |
<tr>
|
663 |
<th scope="row" valign="top"><label
|
664 |
-
for="gateway_environment"><?php _e( 'Gateway Environment', '
|
665 |
<td>
|
666 |
<?php if ( in_array( "gateway_environment", $read_only_fields ) && $order_id > 0 ) {
|
667 |
echo $order->gateway_environment;
|
668 |
} else { ?>
|
669 |
<select name="gateway_environment">
|
670 |
<option value="sandbox"
|
671 |
-
<?php if ( $order->gateway_environment == "sandbox" ) { ?>selected="selected"<?php } ?>><?php _e( 'Sandbox/Testing', '
|
672 |
<option value="live"
|
673 |
-
<?php if ( $order->gateway_environment == "live" ) { ?>selected="selected"<?php } ?>><?php _e( 'Live/Production', '
|
674 |
</select>
|
675 |
<?php } ?>
|
676 |
</td>
|
@@ -678,7 +678,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
678 |
|
679 |
<tr>
|
680 |
<th scope="row" valign="top"><label
|
681 |
-
for="payment_transaction_id"><?php _e( 'Payment Transaction ID', '
|
682 |
<td>
|
683 |
<?php if ( in_array( "payment_transaction_id", $read_only_fields ) && $order_id > 0 ) {
|
684 |
echo $order->payment_transaction_id;
|
@@ -687,12 +687,12 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
687 |
value="<?php echo esc_attr( $order->payment_transaction_id ); ?>"/>
|
688 |
<?php } ?>
|
689 |
<small
|
690 |
-
class="pmpro_lite"><?php _e( 'Generated by the gateway. Useful to cross reference orders.', '
|
691 |
</td>
|
692 |
</tr>
|
693 |
<tr>
|
694 |
<th scope="row" valign="top"><label
|
695 |
-
for="subscription_transaction_id"><?php _e( 'Subscription Transaction ID', '
|
696 |
:</label></th>
|
697 |
<td>
|
698 |
<?php if ( in_array( "subscription_transaction_id", $read_only_fields ) && $order_id > 0 ) {
|
@@ -702,12 +702,12 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
702 |
value="<?php echo esc_attr( $order->subscription_transaction_id ); ?>"/>
|
703 |
<?php } ?>
|
704 |
<small
|
705 |
-
class="pmpro_lite"><?php _e( 'Generated by the gateway. Useful to cross reference subscriptions.', '
|
706 |
</td>
|
707 |
</tr>
|
708 |
|
709 |
<tr>
|
710 |
-
<th scope="row" valign="top"><label for="ts_month"><?php _e( 'Date', '
|
711 |
<td>
|
712 |
<?php if ( in_array( "timestamp", $read_only_fields ) && $order_id > 0 ) {
|
713 |
echo date_i18n( get_option( 'date_format' ) . " " . get_option( 'time_format' ), $order->timestamp );
|
@@ -744,7 +744,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
744 |
if ( ! empty( $affiliates ) ) {
|
745 |
?>
|
746 |
<tr>
|
747 |
-
<th scope="row" valign="top"><label for="affiliate_id"><?php _e( 'Affiliate ID', '
|
748 |
:</label></th>
|
749 |
<td>
|
750 |
<?php if ( in_array( "affiliate_id", $read_only_fields ) && $order_id > 0 ) {
|
@@ -756,7 +756,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
756 |
</td>
|
757 |
</tr>
|
758 |
<tr>
|
759 |
-
<th scope="row" valign="top"><label for="affiliate_subid"><?php _e( 'Affiliate SubID', '
|
760 |
:</label></th>
|
761 |
<td>
|
762 |
<?php if ( in_array( "affiliate_subid", $read_only_fields ) && $order_id > 0 ) {
|
@@ -770,7 +770,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
770 |
<?php } ?>
|
771 |
|
772 |
<tr>
|
773 |
-
<th scope="row" valign="top"><label for="notes"><?php _e( 'Notes', '
|
774 |
<td>
|
775 |
<?php if ( in_array( "notes", $read_only_fields ) && $order_id > 0 ) {
|
776 |
echo $order->notes;
|
@@ -792,8 +792,8 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
792 |
} else {
|
793 |
echo $order_id;
|
794 |
} ?>"/>
|
795 |
-
<input name="save" type="submit" class="button-primary" value="<?php _e( 'Save Order', '
|
796 |
-
<input name="cancel" type="button" class="cancel button-secondary" value="<?php _e( 'Cancel', '
|
797 |
onclick="location.href='<?php echo get_admin_url( null, '/admin.php?page=pmpro-orders' ) ?>';"/>
|
798 |
</p>
|
799 |
|
@@ -828,19 +828,19 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
828 |
</script>
|
829 |
<?php add_thickbox(); ?>
|
830 |
<div id="email_invoice" style="display:none;">
|
831 |
-
<h3><?php _e( 'Email Invoice', '
|
832 |
<form method="post" action="">
|
833 |
<input type="hidden" name="order" value=""/>
|
834 |
-
<?php _e( 'Send an invoice for this order to: ', '
|
835 |
<input type="text" value="" name="email"/>
|
836 |
-
<button class="button button-primary alignright"><?php _e( 'Send Email', '
|
837 |
</form>
|
838 |
</div>
|
839 |
<form id="posts-filter" method="get" action="">
|
840 |
<h2>
|
841 |
-
<?php _e( 'Orders', '
|
842 |
<a href="admin.php?page=pmpro-orders&order=-1"
|
843 |
-
class="add-new-h2">+ <?php _e( 'Add New Order', '
|
844 |
|
845 |
<?php
|
846 |
//build the export URL
|
@@ -861,7 +861,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
861 |
$export_url = add_query_arg( $url_params, $export_url );
|
862 |
?>
|
863 |
<a target="_blank" href="<?php echo $export_url; ?>"
|
864 |
-
class="add-new-h2"><?php _e( 'Export to CSV', '
|
865 |
</h2>
|
866 |
|
867 |
|
@@ -876,20 +876,20 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
876 |
|
877 |
<ul class="subsubsub">
|
878 |
<li>
|
879 |
-
<?php _e( 'Show', '
|
880 |
<select id="filter" name="filter">
|
881 |
-
<option value="all" <?php selected( $filter, "all" ); ?>><?php _e( 'All', '
|
882 |
<option
|
883 |
-
value="within-a-date-range" <?php selected( $filter, "within-a-date-range" ); ?>><?php _e( 'Within a Date Range', '
|
884 |
<option
|
885 |
-
value="predefined-date-range" <?php selected( $filter, "predefined-date-range" ); ?>><?php _e( 'Predefined Date Range', '
|
886 |
<option
|
887 |
-
value="within-a-level" <?php selected( $filter, "within-a-level" ); ?>><?php _e( 'Within a Level', '
|
888 |
<option
|
889 |
-
value="within-a-status" <?php selected( $filter, "within-a-status" ); ?>><?php _e( 'Within a Status', '
|
890 |
</select>
|
891 |
|
892 |
-
<span id="from"><?php _e( 'From', '
|
893 |
|
894 |
<select id="start-month" name="start-month">
|
895 |
<?php for ( $i = 1; $i < 13; $i ++ ) { ?>
|
@@ -904,7 +904,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
904 |
value="<?php echo esc_attr( $start_year ); ?>"/>
|
905 |
|
906 |
|
907 |
-
<span id="to"><?php _e( 'To', '
|
908 |
|
909 |
<select id="end-month" name="end-month">
|
910 |
<?php for ( $i = 1; $i < 13; $i ++ ) { ?>
|
@@ -917,7 +917,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
917 |
<input id='end-day' name="end-day" type="text" size="2" value="<?php echo esc_attr( $end_day ); ?>"/>
|
918 |
<input id='end-year' name="end-year" type="text" size="4" value="<?php echo esc_attr( $end_year ); ?>"/>
|
919 |
|
920 |
-
<span id="filterby"><?php _e( 'filter by ', '
|
921 |
|
922 |
<select id="predefined-date" name="predefined-date">
|
923 |
|
@@ -960,7 +960,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
960 |
</select>
|
961 |
|
962 |
|
963 |
-
<input id="submit" type="submit" value="<?php _e( 'Filter', '
|
964 |
</li>
|
965 |
</ul>
|
966 |
|
@@ -1057,10 +1057,10 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
1057 |
</script>
|
1058 |
|
1059 |
<p class="search-box">
|
1060 |
-
<label class="hidden" for="post-search-input"><?php _e( 'Search Orders', '
|
1061 |
<input type="hidden" name="page" value="pmpro-orders"/>
|
1062 |
<input id="post-search-input" type="text" value="<?php echo esc_attr( $s ); ?>" name="s"/>
|
1063 |
-
<input class="button" type="submit" value="<?php _e( 'Search Orders', '
|
1064 |
</p>
|
1065 |
|
1066 |
<?php
|
@@ -1124,24 +1124,24 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
1124 |
|
1125 |
if ( $order_ids ) {
|
1126 |
?>
|
1127 |
-
<p class="clear"><?php printf( __( "%d orders found.",
|
1128 |
<?php
|
1129 |
}
|
1130 |
?>
|
1131 |
<table class="widefat">
|
1132 |
<thead>
|
1133 |
<tr class="thead">
|
1134 |
-
<th><?php _e( 'ID', '
|
1135 |
-
<th><?php _e( 'Code', '
|
1136 |
-
<th><?php _e( 'User', '
|
1137 |
<?php do_action( "pmpro_orders_extra_cols_header", $order_ids ); ?>
|
1138 |
-
<th><?php _e( 'Membership Level', '
|
1139 |
-
<th><?php _e( 'Total', '
|
1140 |
-
<th><?php _e( 'Payment', '
|
1141 |
-
<th><?php _e( 'Gateway', '
|
1142 |
-
<th><?php _e( 'Transaction IDs', '
|
1143 |
-
<th><?php _e( 'Status', '
|
1144 |
-
<th><?php _e( 'Date', '
|
1145 |
<th></th>
|
1146 |
<th></th>
|
1147 |
<th></th>
|
@@ -1169,7 +1169,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
1169 |
<?php if ( ! empty( $order->user ) ) { ?>
|
1170 |
<a href="user-edit.php?user_id=<?php echo $order->user->ID ?>"><?php echo $order->user->user_login ?></a>
|
1171 |
<?php } else { ?>
|
1172 |
-
[<?php _e( 'deleted', '
|
1173 |
<?php } ?>
|
1174 |
<br/>
|
1175 |
<?php
|
@@ -1217,13 +1217,13 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
1217 |
echo "(test)";
|
1218 |
} ?></td>
|
1219 |
<td>
|
1220 |
-
<?php _e( 'Payment', '
|
1221 |
echo $order->payment_transaction_id;
|
1222 |
} else {
|
1223 |
echo "N/A";
|
1224 |
} ?>
|
1225 |
<br/>
|
1226 |
-
<?php _e( 'Subscription', '
|
1227 |
: <?php if ( ! empty( $order->subscription_transaction_id ) ) {
|
1228 |
echo $order->subscription_transaction_id;
|
1229 |
} else {
|
@@ -1236,21 +1236,21 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
1236 |
<?php echo date_i18n( get_option( 'time_format' ), $order->timestamp ); ?>
|
1237 |
</td>
|
1238 |
<td align="center">
|
1239 |
-
<a href="admin.php?page=pmpro-orders&order=<?php echo $order->id; ?>"><?php _e( 'edit', '
|
1240 |
</td>
|
1241 |
<td align="center">
|
1242 |
-
<a href="admin.php?page=pmpro-orders&order=-1©=<?php echo $order->id; ?>"><?php _e( 'copy', '
|
1243 |
</td>
|
1244 |
<td align="center">
|
1245 |
-
<a href="javascript:askfirst('<?php echo str_replace( "'", "\'", sprintf( __( "Deleting orders is permanent and can affect active users. Are you sure you want to delete order %s?",
|
1246 |
</td>
|
1247 |
<td align="center">
|
1248 |
<a href="admin-ajax.php?action=pmpro_orders_print_view&order=<?php echo $order->id; ?>"
|
1249 |
-
target="_blank"><?php _e( 'print', '
|
1250 |
</td>
|
1251 |
<td align="center">
|
1252 |
<a href="#TB_inline?width=600&height=200&inlineId=email_invoice" class="thickbox email_link"
|
1253 |
-
data-order="<?php echo $order->id; ?>"><?php _e( 'email', '
|
1254 |
</td>
|
1255 |
</tr>
|
1256 |
<?php
|
@@ -1259,7 +1259,7 @@ require_once( dirname( __FILE__ ) . "/admin_header.php" );
|
|
1259 |
if ( ! $order_ids ) {
|
1260 |
?>
|
1261 |
<tr>
|
1262 |
-
<td colspan="9"><p><?php _e( 'No orders found.', '
|
1263 |
</tr>
|
1264 |
<?php
|
1265 |
}
|
1 |
<?php
|
2 |
//only admins can get this
|
3 |
if ( ! function_exists( "current_user_can" ) || ( ! current_user_can( "manage_options" ) && ! current_user_can( "pmpro_orders" ) ) ) {
|
4 |
+
die( __( "You do not have permissions to perform this action.", 'paid-memberships-pro' ) );
|
5 |
}
|
6 |
|
7 |
//vars
|
143 |
$user = get_user_by( 'email', $_REQUEST['email'] );
|
144 |
$order = new MemberOrder( $_REQUEST['order'] );
|
145 |
if ( $email->sendBillableInvoiceEmail( $user, $order ) ) {
|
146 |
+
$pmpro_msg = __( "Invoice emailed successfully.", 'paid-memberships-pro' );
|
147 |
$pmpro_msgt = "success";
|
148 |
} else {
|
149 |
+
$pmpro_msg = __( "Error emailing invoice.", 'paid-memberships-pro' );
|
150 |
$pmpro_msgt = "error";
|
151 |
}
|
152 |
|
159 |
if ( ! empty( $_REQUEST['delete'] ) ) {
|
160 |
$dorder = new MemberOrder( intval( $_REQUEST['delete'] ) );
|
161 |
if ( $dorder->deleteMe() ) {
|
162 |
+
$pmpro_msg = __( "Order deleted successfully.", 'paid-memberships-pro' );
|
163 |
$pmpro_msgt = "success";
|
164 |
} else {
|
165 |
+
$pmpro_msg = __( "Error deleting order.", 'paid-memberships-pro' );
|
166 |
$pmpro_msgt = "error";
|
167 |
}
|
168 |
}
|
282 |
if ( $order->saveOrder() !== false ) {
|
283 |
//handle timestamp
|
284 |
if ( $order->updateTimestamp( $_POST['ts_year'], $_POST['ts_month'], $_POST['ts_day'] ) !== false ) {
|
285 |
+
$pmpro_msg = __( "Order saved successfully.", 'paid-memberships-pro' );
|
286 |
$pmpro_msgt = "success";
|
287 |
} else {
|
288 |
+
$pmpro_msg = __( "Error updating order timestamp.", 'paid-memberships-pro' );
|
289 |
$pmpro_msgt = "error";
|
290 |
}
|
291 |
} else {
|
292 |
+
$pmpro_msg = __( "Error saving order.", 'paid-memberships-pro' );
|
293 |
$pmpro_msgt = "error";
|
294 |
}
|
295 |
} else {
|
349 |
|
350 |
<h2>
|
351 |
<?php if ( ! empty( $order->id ) ) { ?>
|
352 |
+
<?php _e( 'Order', 'paid-memberships-pro' ); ?> #<?php echo $order->id ?>: <?php echo $order->code ?>
|
353 |
<?php } else { ?>
|
354 |
+
<?php _e( 'New Order', 'paid-memberships-pro' ); ?>
|
355 |
<?php } ?>
|
356 |
</h2>
|
357 |
|
372 |
<td><?php if ( ! empty( $order->id ) ) {
|
373 |
echo $order->id;
|
374 |
} else {
|
375 |
+
echo __( "This will be generated when you save.", 'paid-memberships-pro' );
|
376 |
} ?></td>
|
377 |
</tr>
|
378 |
|
379 |
<tr>
|
380 |
+
<th scope="row" valign="top"><label for="code"><?php _e( 'Code', 'paid-memberships-pro' ); ?>:</label></th>
|
381 |
<td>
|
382 |
<?php if ( in_array( "code", $read_only_fields ) ) {
|
383 |
echo $order->code;
|
387 |
<?php } ?>
|
388 |
<?php if ( $order_id < 0 ) { ?>
|
389 |
<small
|
390 |
+
class="pmpro_lite"><?php _e( 'Randomly generated for you.', 'paid-memberships-pro' ); ?></small><?php } ?>
|
391 |
</td>
|
392 |
</tr>
|
393 |
|
394 |
<tr>
|
395 |
+
<th scope="row" valign="top"><label for="user_id"><?php _e( 'User ID', 'paid-memberships-pro' ); ?>:</label></th>
|
396 |
<td>
|
397 |
<?php if ( in_array( "user_id", $read_only_fields ) && $order_id > 0 ) {
|
398 |
echo $order->user_id;
|
404 |
</tr>
|
405 |
|
406 |
<tr>
|
407 |
+
<th scope="row" valign="top"><label for="membership_id"><?php _e( 'Membership Level ID', 'paid-memberships-pro' ); ?>
|
408 |
:</label></th>
|
409 |
<td>
|
410 |
<?php if ( in_array( "membership_id", $read_only_fields ) && $order_id > 0 ) {
|
417 |
</tr>
|
418 |
|
419 |
<tr>
|
420 |
+
<th scope="row" valign="top"><label for="billing_name"><?php _e( 'Billing Name', 'paid-memberships-pro' ); ?>:</label>
|
421 |
</th>
|
422 |
<td>
|
423 |
<?php if ( in_array( "billing_name", $read_only_fields ) && $order_id > 0 ) {
|
429 |
</td>
|
430 |
</tr>
|
431 |
<tr>
|
432 |
+
<th scope="row" valign="top"><label for="billing_street"><?php _e( 'Billing Street', 'paid-memberships-pro' ); ?>
|
433 |
:</label></th>
|
434 |
<td>
|
435 |
<?php if ( in_array( "billing_street", $read_only_fields ) && $order_id > 0 ) {
|
440 |
<?php } ?>
|
441 |
</tr>
|
442 |
<tr>
|
443 |
+
<th scope="row" valign="top"><label for="billing_city"><?php _e( 'Billing City', 'paid-memberships-pro' ); ?>:</label>
|
444 |
</th>
|
445 |
<td>
|
446 |
<?php if ( in_array( "billing_city", $read_only_fields ) && $order_id > 0 ) {
|
451 |
<?php } ?>
|
452 |
</tr>
|
453 |
<tr>
|
454 |
+
<th scope="row" valign="top"><label for="billing_state"><?php _e( 'Billing State', 'paid-memberships-pro' ); ?>
|
455 |
:</label></th>
|
456 |
<td>
|
457 |
<?php if ( in_array( "billing_state", $read_only_fields ) && $order_id > 0 ) {
|
462 |
<?php } ?>
|
463 |
</tr>
|
464 |
<tr>
|
465 |
+
<th scope="row" valign="top"><label for="billing_zip"><?php _e( 'Billing Postal Code', 'paid-memberships-pro' ); ?>
|
466 |
:</label></th>
|
467 |
<td>
|
468 |
<?php if ( in_array( "billing_zip", $read_only_fields ) && $order_id > 0 ) {
|
473 |
<?php } ?>
|
474 |
</tr>
|
475 |
<tr>
|
476 |
+
<th scope="row" valign="top"><label for="billing_country"><?php _e( 'Billing Country', 'paid-memberships-pro' ); ?>
|
477 |
:</label></th>
|
478 |
<td>
|
479 |
<?php if ( in_array( "billing_country", $read_only_fields ) && $order_id > 0 ) {
|
485 |
</td>
|
486 |
</tr>
|
487 |
<tr>
|
488 |
+
<th scope="row" valign="top"><label for="billing_phone"><?php _e( 'Billing Phone', 'paid-memberships-pro' ); ?>
|
489 |
:</label></th>
|
490 |
<td>
|
491 |
<?php if ( in_array( "billing_phone", $read_only_fields ) && $order_id > 0 ) {
|
498 |
</tr>
|
499 |
|
500 |
<tr>
|
501 |
+
<th scope="row" valign="top"><label for="subtotal"><?php _e( 'Sub Total', 'paid-memberships-pro' ); ?>:</label></th>
|
502 |
<td>
|
503 |
<?php if ( in_array( "subtotal", $read_only_fields ) && $order_id > 0 ) {
|
504 |
echo $order->subtotal;
|
509 |
</td>
|
510 |
</tr>
|
511 |
<tr>
|
512 |
+
<th scope="row" valign="top"><label for="tax"><?php _e( 'Tax', 'paid-memberships-pro' ); ?>:</label></th>
|
513 |
<td>
|
514 |
<?php if ( in_array( "tax", $read_only_fields ) && $order_id > 0 ) {
|
515 |
echo $order->tax;
|
520 |
</td>
|
521 |
</tr>
|
522 |
<tr>
|
523 |
+
<th scope="row" valign="top"><label for="couponamount"><?php _e( 'Coupon Amount', 'paid-memberships-pro' ); ?>:</label>
|
524 |
</th>
|
525 |
<td>
|
526 |
<?php if ( in_array( "couponamount", $read_only_fields ) && $order_id > 0 ) {
|
532 |
</td>
|
533 |
</tr>
|
534 |
<tr>
|
535 |
+
<th scope="row" valign="top"><label for="total"><?php _e( 'Total', 'paid-memberships-pro' ); ?>:</label></th>
|
536 |
<td>
|
537 |
<?php if ( in_array( "total", $read_only_fields ) && $order_id > 0 ) {
|
538 |
echo $order->total;
|
541 |
value="<?php echo esc_attr( $order->total ); ?>"/>
|
542 |
<?php } ?>
|
543 |
<small
|
544 |
+
class="pmpro_lite"><?php _e( 'Should be subtotal + tax - couponamount.', 'paid-memberships-pro' ); ?></small>
|
545 |
</td>
|
546 |
</tr>
|
547 |
|
548 |
<tr>
|
549 |
+
<th scope="row" valign="top"><label for="payment_type"><?php _e( 'Payment Type', 'paid-memberships-pro' ); ?>:</label>
|
550 |
</th>
|
551 |
<td>
|
552 |
<?php if ( in_array( "payment_type", $read_only_fields ) && $order_id > 0 ) {
|
556 |
value="<?php echo esc_attr( $order->payment_type ); ?>"/>
|
557 |
<?php } ?>
|
558 |
<small
|
559 |
+
class="pmpro_lite"><?php _e( 'e.g. PayPal Express, PayPal Standard, Credit Card.', 'paid-memberships-pro' ); ?></small>
|
560 |
</td>
|
561 |
</tr>
|
562 |
<tr>
|
563 |
+
<th scope="row" valign="top"><label for="cardtype"><?php _e( 'Card Type', 'paid-memberships-pro' ); ?></label></th>
|
564 |
<td>
|
565 |
<?php if ( in_array( "cardtype", $read_only_fields ) && $order_id > 0 ) {
|
566 |
echo $order->cardtype;
|
568 |
<input id="cardtype" name="cardtype" type="text" size="50"
|
569 |
value="<?php echo esc_attr( $order->cardtype ); ?>"/>
|
570 |
<?php } ?>
|
571 |
+
<small class="pmpro_lite"><?php _e( 'e.g. Visa, MasterCard, AMEX, etc', 'paid-memberships-pro' ); ?></small>
|
572 |
</td>
|
573 |
</tr>
|
574 |
<tr>
|
575 |
+
<th scope="row" valign="top"><label for="accountnumber"><?php _e( 'Account Number', 'paid-memberships-pro' ); ?>
|
576 |
:</label></th>
|
577 |
<td>
|
578 |
<?php if ( in_array( "accountnumber", $read_only_fields ) && $order_id > 0 ) {
|
581 |
<input id="accountnumber" name="accountnumber" type="text" size="50"
|
582 |
value="<?php echo esc_attr( $order->accountnumber ); ?>"/>
|
583 |
<?php } ?>
|
584 |
+
<small class="pmpro_lite"><?php _e( 'Obscure all but last 4 digits.', 'paid-memberships-pro' ); ?></small>
|
585 |
</td>
|
586 |
</tr>
|
587 |
<?php if ( in_array( "ExpirationDate", $read_only_fields ) && $order_id > 0 ) {
|
589 |
} else { ?>
|
590 |
<tr>
|
591 |
<th scope="row" valign="top"><label
|
592 |
+
for="expirationmonth"><?php _e( 'Expiration Month', 'paid-memberships-pro' ); ?>:</label></th>
|
593 |
<td>
|
594 |
<input id="expirationmonth" name="expirationmonth" type="text" size="10"
|
595 |
value="<?php echo esc_attr( $order->expirationmonth ); ?>"/>
|
597 |
</td>
|
598 |
</tr>
|
599 |
<tr>
|
600 |
+
<th scope="row" valign="top"><label for="expirationyear"><?php _e( 'Expiration Year', 'paid-memberships-pro' ); ?>
|
601 |
:</label></th>
|
602 |
<td>
|
603 |
<input id="expirationyear" name="expirationyear" type="text" size="10"
|
607 |
</tr>
|
608 |
<?php } ?>
|
609 |
<tr>
|
610 |
+
<th scope="row" valign="top"><label for="status"><?php _e( 'Status', 'paid-memberships-pro' ); ?>:</label></th>
|
611 |
<td>
|
612 |
<?php if ( in_array( "status", $read_only_fields ) && $order_id > 0 ) {
|
613 |
echo $order->status;
|
640 |
</tr>
|
641 |
|
642 |
<tr>
|
643 |
+
<th scope="row" valign="top"><label for="gateway"><?php _e( 'Gateway', 'paid-memberships-pro' ); ?>:</label></th>
|
644 |
<td>
|
645 |
<?php if ( in_array( "gateway", $read_only_fields ) && $order_id > 0 ) {
|
646 |
echo $order->gateway;
|
661 |
</tr>
|
662 |
<tr>
|
663 |
<th scope="row" valign="top"><label
|
664 |
+
for="gateway_environment"><?php _e( 'Gateway Environment', 'paid-memberships-pro' ); ?>:</label></th>
|
665 |
<td>
|
666 |
<?php if ( in_array( "gateway_environment", $read_only_fields ) && $order_id > 0 ) {
|
667 |
echo $order->gateway_environment;
|
668 |
} else { ?>
|
669 |
<select name="gateway_environment">
|
670 |
<option value="sandbox"
|
671 |
+
<?php if ( $order->gateway_environment == "sandbox" ) { ?>selected="selected"<?php } ?>><?php _e( 'Sandbox/Testing', 'paid-memberships-pro' ); ?></option>
|
672 |
<option value="live"
|
673 |
+
<?php if ( $order->gateway_environment == "live" ) { ?>selected="selected"<?php } ?>><?php _e( 'Live/Production', 'paid-memberships-pro' ); ?></option>
|
674 |
</select>
|
675 |
<?php } ?>
|
676 |
</td>
|
678 |
|
679 |
<tr>
|
680 |
<th scope="row" valign="top"><label
|
681 |
+
for="payment_transaction_id"><?php _e( 'Payment Transaction ID', 'paid-memberships-pro' ); ?>:</label></th>
|
682 |
<td>
|
683 |
<?php if ( in_array( "payment_transaction_id", $read_only_fields ) && $order_id > 0 ) {
|
684 |
echo $order->payment_transaction_id;
|
687 |
value="<?php echo esc_attr( $order->payment_transaction_id ); ?>"/>
|
688 |
<?php } ?>
|
689 |
<small
|
690 |
+
class="pmpro_lite"><?php _e( 'Generated by the gateway. Useful to cross reference orders.', 'paid-memberships-pro' ); ?></small>
|
691 |
</td>
|
692 |
</tr>
|
693 |
<tr>
|
694 |
<th scope="row" valign="top"><label
|
695 |
+
for="subscription_transaction_id"><?php _e( 'Subscription Transaction ID', 'paid-memberships-pro' ); ?>
|
696 |
:</label></th>
|
697 |
<td>
|
698 |
<?php if ( in_array( "subscription_transaction_id", $read_only_fields ) && $order_id > 0 ) {
|
702 |
value="<?php echo esc_attr( $order->subscription_transaction_id ); ?>"/>
|
703 |
<?php } ?>
|
704 |
<small
|
705 |
+
class="pmpro_lite"><?php _e( 'Generated by the gateway. Useful to cross reference subscriptions.', 'paid-memberships-pro' ); ?></small>
|
706 |
</td>
|
707 |
</tr>
|
708 |
|
709 |
<tr>
|
710 |
+
<th scope="row" valign="top"><label for="ts_month"><?php _e( 'Date', 'paid-memberships-pro' ); ?>:</label></th>
|
711 |
<td>
|
712 |
<?php if ( in_array( "timestamp", $read_only_fields ) && $order_id > 0 ) {
|
713 |
echo date_i18n( get_option( 'date_format' ) . " " . get_option( 'time_format' ), $order->timestamp );
|
744 |
if ( ! empty( $affiliates ) ) {
|
745 |
?>
|
746 |
<tr>
|
747 |
+
<th scope="row" valign="top"><label for="affiliate_id"><?php _e( 'Affiliate ID', 'paid-memberships-pro' ); ?>
|
748 |
:</label></th>
|
749 |
<td>
|
750 |
<?php if ( in_array( "affiliate_id", $read_only_fields ) && $order_id > 0 ) {
|
756 |
</td>
|
757 |
</tr>
|
758 |
<tr>
|
759 |
+
<th scope="row" valign="top"><label for="affiliate_subid"><?php _e( 'Affiliate SubID', 'paid-memberships-pro' ); ?>
|
760 |
:</label></th>
|
761 |
<td>
|
762 |
<?php if ( in_array( "affiliate_subid", $read_only_fields ) && $order_id > 0 ) {
|
770 |
<?php } ?>
|
771 |
|
772 |
<tr>
|
773 |
+
<th scope="row" valign="top"><label for="notes"><?php _e( 'Notes', 'paid-memberships-pro' ); ?>:</label></th>
|
774 |
<td>
|
775 |
<?php if ( in_array( "notes", $read_only_fields ) && $order_id > 0 ) {
|
776 |
echo $order->notes;
|
792 |
} else {
|
793 |
echo $order_id;
|
794 |
} ?>"/>
|
795 |
+
<input name="save" type="submit" class="button-primary" value="<?php _e( 'Save Order', 'paid-memberships-pro' ); ?>"/>
|
796 |
+
<input name="cancel" type="button" class="cancel button-secondary" value="<?php _e( 'Cancel', 'paid-memberships-pro' ); ?>"
|
797 |
onclick="location.href='<?php echo get_admin_url( null, '/admin.php?page=pmpro-orders' ) ?>';"/>
|
798 |
</p>
|
799 |
|
828 |
</script>
|
829 |
<?php add_thickbox(); ?>
|
830 |
<div id="email_invoice" style="display:none;">
|
831 |
+
<h3><?php _e( 'Email Invoice', 'paid-memberships-pro' ); ?></h3>
|
832 |
<form method="post" action="">
|
833 |
<input type="hidden" name="order" value=""/>
|
834 |
+
<?php _e( 'Send an invoice for this order to: ', 'paid-memberships-pro' ); ?>
|
835 |
<input type="text" value="" name="email"/>
|
836 |
+
<button class="button button-primary alignright"><?php _e( 'Send Email', 'paid-memberships-pro' ); ?></button>
|
837 |
</form>
|
838 |
</div>
|
839 |
<form id="posts-filter" method="get" action="">
|
840 |
<h2>
|
841 |
+
<?php _e( 'Orders', 'paid-memberships-pro' ); ?>
|
842 |
<a href="admin.php?page=pmpro-orders&order=-1"
|
843 |
+
class="add-new-h2">+ <?php _e( 'Add New Order', 'paid-memberships-pro' ); ?></a>
|
844 |
|
845 |
<?php
|
846 |
//build the export URL
|
861 |
$export_url = add_query_arg( $url_params, $export_url );
|
862 |
?>
|
863 |
<a target="_blank" href="<?php echo $export_url; ?>"
|
864 |
+
class="add-new-h2"><?php _e( 'Export to CSV', 'paid-memberships-pro' ); ?></a>
|
865 |
</h2>
|
866 |
|
867 |
|
876 |
|
877 |
<ul class="subsubsub">
|
878 |
<li>
|
879 |
+
<?php _e( 'Show', 'paid-memberships-pro' ) ?>
|
880 |
<select id="filter" name="filter">
|
881 |
+
<option value="all" <?php selected( $filter, "all" ); ?>><?php _e( 'All', 'paid-memberships-pro' ); ?></option>
|
882 |
<option
|
883 |
+
value="within-a-date-range" <?php selected( $filter, "within-a-date-range" ); ?>><?php _e( 'Within a Date Range', 'paid-memberships-pro' ); ?></option>
|
884 |
<option
|
885 |
+
value="predefined-date-range" <?php selected( $filter, "predefined-date-range" ); ?>><?php _e( 'Predefined Date Range', 'paid-memberships-pro' ); ?></option>
|
886 |
<option
|
887 |
+
value="within-a-level" <?php selected( $filter, "within-a-level" ); ?>><?php _e( 'Within a Level', 'paid-memberships-pro' ); ?></option>
|
888 |
<option
|
889 |
+
value="within-a-status" <?php selected( $filter, "within-a-status" ); ?>><?php _e( 'Within a Status', 'paid-memberships-pro' ); ?></option>
|
890 |
</select>
|
891 |
|
892 |
+
<span id="from"><?php _e( 'From', 'paid-memberships-pro' ) ?></span>
|
893 |
|
894 |
<select id="start-month" name="start-month">
|
895 |
<?php for ( $i = 1; $i < 13; $i ++ ) { ?>
|
904 |
value="<?php echo esc_attr( $start_year ); ?>"/>
|
905 |
|
906 |
|
907 |
+
<span id="to"><?php _e( 'To', 'paid-memberships-pro' ) ?></span>
|
908 |
|
909 |
<select id="end-month" name="end-month">
|
910 |
<?php for ( $i = 1; $i < 13; $i ++ ) { ?>
|
917 |
<input id='end-day' name="end-day" type="text" size="2" value="<?php echo esc_attr( $end_day ); ?>"/>
|
918 |
<input id='end-year' name="end-year" type="text" size="4" value="<?php echo esc_attr( $end_year ); ?>"/>
|
919 |
|
920 |
+
<span id="filterby"><?php _e( 'filter by ', 'paid-memberships-pro' ) ?></span>
|
921 |
|
922 |
<select id="predefined-date" name="predefined-date">
|
923 |
|
960 |
</select>
|
961 |
|
962 |
|
963 |
+
<input id="submit" type="submit" value="<?php _e( 'Filter', 'paid-memberships-pro' ); ?>"/>
|
964 |
</li>
|
965 |
</ul>
|
966 |
|
1057 |
</script>
|
1058 |
|
1059 |
<p class="search-box">
|
1060 |
+
<label class="hidden" for="post-search-input"><?php _e( 'Search Orders', 'paid-memberships-pro' ); ?>:</label>
|
1061 |
<input type="hidden" name="page" value="pmpro-orders"/>
|
1062 |
<input id="post-search-input" type="text" value="<?php echo esc_attr( $s ); ?>" name="s"/>
|
1063 |
+
<input class="button" type="submit" value="<?php _e( 'Search Orders', 'paid-memberships-pro' ); ?>"/>
|
1064 |
</p>
|
1065 |
|
1066 |
<?php
|
1124 |
|
1125 |
if ( $order_ids ) {
|
1126 |
?>
|
1127 |
+
<p class="clear"><?php printf( __( "%d orders found.", 'paid-memberships-pro' ), $totalrows ); ?></span></p>
|
1128 |
<?php
|
1129 |
}
|
1130 |
?>
|
1131 |
<table class="widefat">
|
1132 |
<thead>
|
1133 |
<tr class="thead">
|
1134 |
+
<th><?php _e( 'ID', 'paid-memberships-pro' ); ?></th>
|
1135 |
+
<th><?php _e( 'Code', 'paid-memberships-pro' ); ?></th>
|
1136 |
+
<th><?php _e( 'User', 'paid-memberships-pro' ); ?></th>
|
1137 |
<?php do_action( "pmpro_orders_extra_cols_header", $order_ids ); ?>
|
1138 |
+
<th><?php _e( 'Membership Level', 'paid-memberships-pro' ); ?></th>
|
1139 |
+
<th><?php _e( 'Total', 'paid-memberships-pro' ); ?></th>
|
1140 |
+
<th><?php _e( 'Payment', 'paid-memberships-pro' ); ?></th>
|
1141 |
+
<th><?php _e( 'Gateway', 'paid-memberships-pro' ); ?></th>
|
1142 |
+
<th><?php _e( 'Transaction IDs', 'paid-memberships-pro' ); ?></th>
|
1143 |
+
<th><?php _e( 'Status', 'paid-memberships-pro' ); ?></th>
|
1144 |
+
<th><?php _e( 'Date', 'paid-memberships-pro' ); ?></th>
|
1145 |
<th></th>
|
1146 |
<th></th>
|
1147 |
<th></th>
|
1169 |
<?php if ( ! empty( $order->user ) ) { ?>
|
1170 |
<a href="user-edit.php?user_id=<?php echo $order->user->ID ?>"><?php echo $order->user->user_login ?></a>
|
1171 |
<?php } else { ?>
|
1172 |
+
[<?php _e( 'deleted', 'paid-memberships-pro' ); ?>]
|
1173 |
<?php } ?>
|
1174 |
<br/>
|
1175 |
<?php
|
1217 |
echo "(test)";
|
1218 |
} ?></td>
|
1219 |
<td>
|
1220 |
+
<?php _e( 'Payment', 'paid-memberships-pro' ); ?>: <?php if ( ! empty( $order->payment_transaction_id ) ) {
|
1221 |
echo $order->payment_transaction_id;
|
1222 |
} else {
|
1223 |
echo "N/A";
|
1224 |
} ?>
|
1225 |
<br/>
|
1226 |
+
<?php _e( 'Subscription', 'paid-memberships-pro' ); ?>
|
1227 |
: <?php if ( ! empty( $order->subscription_transaction_id ) ) {
|
1228 |
echo $order->subscription_transaction_id;
|
1229 |
} else {
|
1236 |
<?php echo date_i18n( get_option( 'time_format' ), $order->timestamp ); ?>
|
1237 |
</td>
|
1238 |
<td align="center">
|
1239 |
+
<a href="admin.php?page=pmpro-orders&order=<?php echo $order->id; ?>"><?php _e( 'edit', 'paid-memberships-pro' ); ?></a>
|
1240 |
</td>
|
1241 |
<td align="center">
|
1242 |
+
<a href="admin.php?page=pmpro-orders&order=-1©=<?php echo $order->id; ?>"><?php _e( 'copy', 'paid-memberships-pro' ); ?></a>
|
1243 |
</td>
|
1244 |
<td align="center">
|
1245 |
+
<a href="javascript:askfirst('<?php echo str_replace( "'", "\'", sprintf( __( "Deleting orders is permanent and can affect active users. Are you sure you want to delete order %s?", 'paid-memberships-pro' ), str_replace( "'", "", $order->code ) ) ); ?>', 'admin.php?page=pmpro-orders&delete=<?php echo $order->id; ?>'); void(0);"><?php _e( 'delete', 'paid-memberships-pro' ); ?></a>
|
1246 |
</td>
|
1247 |
<td align="center">
|
1248 |
<a href="admin-ajax.php?action=pmpro_orders_print_view&order=<?php echo $order->id; ?>"
|
1249 |
+
target="_blank"><?php _e( 'print', 'paid-memberships-pro' ); ?></a>
|
1250 |
</td>
|
1251 |
<td align="center">
|
1252 |
<a href="#TB_inline?width=600&height=200&inlineId=email_invoice" class="thickbox email_link"
|
1253 |
+
data-order="<?php echo $order->id; ?>"><?php _e( 'email', 'paid-memberships-pro' ); ?></a>
|
1254 |
</td>
|
1255 |
</tr>
|
1256 |
<?php
|
1259 |
if ( ! $order_ids ) {
|
1260 |
?>
|
1261 |
<tr>
|
1262 |
+
<td colspan="9"><p><?php _e( 'No orders found.', 'paid-memberships-pro' ); ?></p></td>
|
1263 |
</tr>
|
1264 |
<?php
|
1265 |
}
|
adminpages/pagesettings.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
//only admins can get this
|
3 |
if (!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_pagesettings"))) {
|
4 |
-
die(__("You do not have permissions to perform this action.",
|
5 |
}
|
6 |
|
7 |
global $wpdb, $msg, $msgt;
|
@@ -21,6 +21,7 @@ global $pmpro_pages;
|
|
21 |
* @since 1.8.5
|
22 |
*/
|
23 |
$extra_pages = apply_filters('pmpro_extra_page_settings', array());
|
|
|
24 |
|
25 |
if (!empty($_REQUEST['savesettings'])) {
|
26 |
//page ids
|
@@ -51,7 +52,7 @@ if (!empty($_REQUEST['savesettings'])) {
|
|
51 |
|
52 |
//assume success
|
53 |
$msg = true;
|
54 |
-
$msgt = __("Your page settings have been updated.",
|
55 |
}
|
56 |
|
57 |
//are we generating pages?
|
@@ -61,13 +62,13 @@ if (!empty($_REQUEST['createpages'])) {
|
|
61 |
|
62 |
if(empty($_REQUEST['page_name'])) {
|
63 |
//default pages
|
64 |
-
$pages['account'] = __('Membership Account', '
|
65 |
-
$pages['billing'] = __('Membership Billing', '
|
66 |
-
$pages['cancel'] = __('Membership Cancel', '
|
67 |
-
$pages['checkout'] = __('Membership Checkout', '
|
68 |
-
$pages['confirmation'] = __('Membership Confirmation', '
|
69 |
-
$pages['invoice'] = __('Membership Invoice', '
|
70 |
-
$pages['levels'] = __('Membership Levels', '
|
71 |
|
72 |
} else {
|
73 |
//generate extra pages one at a time
|
@@ -80,7 +81,7 @@ if (!empty($_REQUEST['createpages'])) {
|
|
80 |
|
81 |
if (!empty($pages_created)) {
|
82 |
$msg = true;
|
83 |
-
$msgt = __("The following pages have been created for you",
|
84 |
}
|
85 |
}
|
86 |
|
@@ -89,17 +90,17 @@ require_once(dirname(__FILE__) . "/admin_header.php");
|
|
89 |
|
90 |
|
91 |
<form action="" method="post" enctype="multipart/form-data">
|
92 |
-
<h2><?php _e('Pages', '
|
93 |
<?php
|
94 |
global $pmpro_pages_ready;
|
95 |
if ($pmpro_pages_ready) {
|
96 |
?>
|
97 |
-
<p><?php _e('Manage the WordPress pages assigned to each required Paid Memberships Pro page.', '
|
98 |
<?php
|
99 |
} else {
|
100 |
?>
|
101 |
-
<p><?php _e('Assign the WordPress pages for each required Paid Memberships Pro page or', '
|
102 |
-
href="?page=pmpro-pagesettings&createpages=1"><?php _e('click here to let us generate them for you', '
|
103 |
</p>
|
104 |
<?php
|
105 |
}
|
@@ -108,141 +109,141 @@ require_once(dirname(__FILE__) . "/admin_header.php");
|
|
108 |
<tbody>
|
109 |
<tr>
|
110 |
<th scope="row" valign="top">
|
111 |
-
<label for="account_page_id"><?php _e('Account Page', '
|
112 |
</th>
|
113 |
<td>
|
114 |
<?php
|
115 |
-
wp_dropdown_pages(array("name" => "account_page_id", "show_option_none" => "-- " . __('Choose One', '
|
116 |
?>
|
117 |
<?php if (!empty($pmpro_pages['account'])) { ?>
|
118 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['account']; ?>&action=edit"
|
119 |
-
class="button button-secondary pmpro_page_edit"><?php _e('edit page', '
|
120 |
|
121 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['account']); ?>"
|
122 |
-
class="button button-secondary pmpro_page_view"><?php _e('view page', '
|
123 |
<?php } ?>
|
124 |
<br/>
|
125 |
-
<small class="pmpro_lite"><?php _e('Include the shortcode', '
|
126 |
</td>
|
127 |
<tr>
|
128 |
<th scope="row" valign="top">
|
129 |
-
<label for="billing_page_id"><?php _e('Billing Information Page', '
|
130 |
</th>
|
131 |
<td>
|
132 |
<?php
|
133 |
-
wp_dropdown_pages(array("name" => "billing_page_id", "show_option_none" => "-- " . __('Choose One', '
|
134 |
?>
|
135 |
<?php if (!empty($pmpro_pages['billing'])) { ?>
|
136 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['billing'] ?>&action=edit"
|
137 |
-
class="button button-secondary pmpro_page_edit"><?php _e('edit page', '
|
138 |
|
139 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['billing']); ?>"
|
140 |
-
class="button button-secondary pmpro_page_view"><?php _e('view page', '
|
141 |
<?php } ?>
|
142 |
<br/>
|
143 |
-
<small class="pmpro_lite"><?php _e('Include the shortcode', '
|
144 |
</td>
|
145 |
<tr>
|
146 |
<th scope="row" valign="top">
|
147 |
-
<label for="cancel_page_id"><?php _e('Cancel Page', '
|
148 |
</th>
|
149 |
<td>
|
150 |
<?php
|
151 |
-
wp_dropdown_pages(array("name" => "cancel_page_id", "show_option_none" => "-- " . __('Choose One', '
|
152 |
?>
|
153 |
<?php if (!empty($pmpro_pages['cancel'])) { ?>
|
154 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['cancel'] ?>&action=edit"
|
155 |
-
class="button button-secondary pmpro_page_edit"><?php _e('edit page', '
|
156 |
|
157 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['cancel']); ?>"
|
158 |
-
class="button button-secondary pmpro_page_view"><?php _e('view page', '
|
159 |
<?php } ?>
|
160 |
<br/>
|
161 |
-
<small class="pmpro_lite"><?php _e('Include the shortcode', '
|
162 |
</td>
|
163 |
</tr>
|
164 |
<tr>
|
165 |
<th scope="row" valign="top">
|
166 |
-
<label for="checkout_page_id"><?php _e('Checkout Page', '
|
167 |
</th>
|
168 |
<td>
|
169 |
<?php
|
170 |
-
wp_dropdown_pages(array("name" => "checkout_page_id", "show_option_none" => "-- " . __('Choose One', '
|
171 |
?>
|
172 |
<?php if (!empty($pmpro_pages['checkout'])) { ?>
|
173 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['checkout'] ?>&action=edit"
|
174 |
-
class="button button-secondary pmpro_page_edit"><?php _e('edit page', '
|
175 |
|
176 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['checkout']); ?>"
|
177 |
-
class="button button-secondary pmpro_page_view"><?php _e('view page', '
|
178 |
<?php } ?>
|
179 |
<br/>
|
180 |
-
<small class="pmpro_lite"><?php _e('Include the shortcode', '
|
181 |
</td>
|
182 |
</tr>
|
183 |
<tr>
|
184 |
<th scope="row" valign="top">
|
185 |
-
<label for="confirmation_page_id"><?php _e('Confirmation Page', '
|
186 |
</th>
|
187 |
<td>
|
188 |
<?php
|
189 |
-
wp_dropdown_pages(array("name" => "confirmation_page_id", "show_option_none" => "-- " . __('Choose One', '
|
190 |
?>
|
191 |
<?php if (!empty($pmpro_pages['confirmation'])) { ?>
|
192 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['confirmation'] ?>&action=edit"
|
193 |
-
class="button button-secondary pmpro_page_edit"><?php _e('edit page', '
|
194 |
|
195 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['confirmation']); ?>"
|
196 |
-
class="button button-secondary pmpro_page_view"><?php _e('view page', '
|
197 |
<?php } ?>
|
198 |
<br/>
|
199 |
-
<small class="pmpro_lite"><?php _e('Include the shortcode', '
|
200 |
</small>
|
201 |
</td>
|
202 |
</tr>
|
203 |
<tr>
|
204 |
<th scope="row" valign="top">
|
205 |
-
<label for="invoice_page_id"><?php _e('Invoice Page', '
|
206 |
</th>
|
207 |
<td>
|
208 |
<?php
|
209 |
-
wp_dropdown_pages(array("name" => "invoice_page_id", "show_option_none" => "-- " . __('Choose One', '
|
210 |
?>
|
211 |
<?php if (!empty($pmpro_pages['invoice'])) { ?>
|
212 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['invoice'] ?>&action=edit"
|
213 |
-
class="button button-secondary pmpro_page_edit"><?php _e('edit page', '
|
214 |
|
215 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['invoice']); ?>"
|
216 |
-
class="button button-secondary pmpro_page_view"><?php _e('view page', '
|
217 |
<?php } ?>
|
218 |
<br/>
|
219 |
-
<small class="pmpro_lite"><?php _e('Include the shortcode', '
|
220 |
</td>
|
221 |
</tr>
|
222 |
<tr>
|
223 |
<th scope="row" valign="top">
|
224 |
-
<label for="levels_page_id"><?php _e('Levels Page', '
|
225 |
</th>
|
226 |
<td>
|
227 |
<?php
|
228 |
-
wp_dropdown_pages(array("name" => "levels_page_id", "show_option_none" => "-- " . __('Choose One', '
|
229 |
?>
|
230 |
<?php if (!empty($pmpro_pages['levels'])) { ?>
|
231 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['levels'] ?>&action=edit"
|
232 |
-
class="button button-secondary pmpro_page_edit"><?php _e('edit page', '
|
233 |
|
234 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['levels']); ?>"
|
235 |
-
class="button button-secondary pmpro_page_view"><?php _e('view page', '
|
236 |
<?php } ?>
|
237 |
<br/>
|
238 |
-
<small class="pmpro_lite"><?php _e('Include the shortcode', '
|
239 |
</td>
|
240 |
</tr>
|
241 |
</tbody>
|
242 |
</table>
|
243 |
<?php
|
244 |
if (!empty($extra_pages)) { ?>
|
245 |
-
<h2><?php _e('Additional Page Settings', '
|
246 |
<table class="form-table">
|
247 |
<tbody>
|
248 |
<?php foreach ($extra_pages as $name => $page) { ?>
|
@@ -265,19 +266,19 @@ require_once(dirname(__FILE__) . "/admin_header.php");
|
|
265 |
<td>
|
266 |
<?php wp_dropdown_pages(array(
|
267 |
"name" => $name . '_page_id',
|
268 |
-
"show_option_none" => "-- " . __('Choose One', '
|
269 |
"selected" => $pmpro_pages[$name],
|
270 |
));
|
271 |
if(!empty($pmpro_pages[$name])) {
|
272 |
?>
|
273 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[$name] ?>&action=edit"
|
274 |
-
class="button button-secondary pmpro_page_edit"><?php _e('edit page', '
|
275 |
|
276 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages[$name]); ?>"
|
277 |
-
class="button button-secondary pmpro_page_view"><?php _e('view page', '
|
278 |
<?php } else { ?>
|
279 |
|
280 |
-
<a href="?page=pmpro-pagesettings&createpages=1&page_name=<?php echo $name; ?>"><?php _e('Generate Page', '
|
281 |
<?php } ?>
|
282 |
<?php if(!empty($hint)) { ?>
|
283 |
<br/>
|
@@ -291,7 +292,7 @@ require_once(dirname(__FILE__) . "/admin_header.php");
|
|
291 |
<?php } ?>
|
292 |
<p class="submit">
|
293 |
<input name="savesettings" type="submit" class="button button-primary"
|
294 |
-
value="<?php _e('Save Settings', '
|
295 |
</p>
|
296 |
</form>
|
297 |
|
1 |
<?php
|
2 |
//only admins can get this
|
3 |
if (!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_pagesettings"))) {
|
4 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
5 |
}
|
6 |
|
7 |
global $wpdb, $msg, $msgt;
|
21 |
* @since 1.8.5
|
22 |
*/
|
23 |
$extra_pages = apply_filters('pmpro_extra_page_settings', array());
|
24 |
+
$post_types = apply_filters('pmpro_admin_pagesetting_post_type_array', array( 'page' ) );
|
25 |
|
26 |
if (!empty($_REQUEST['savesettings'])) {
|
27 |
//page ids
|
52 |
|
53 |
//assume success
|
54 |
$msg = true;
|
55 |
+
$msgt = __("Your page settings have been updated.", 'paid-memberships-pro' );
|
56 |
}
|
57 |
|
58 |
//are we generating pages?
|
62 |
|
63 |
if(empty($_REQUEST['page_name'])) {
|
64 |
//default pages
|
65 |
+
$pages['account'] = __('Membership Account', 'paid-memberships-pro' );
|
66 |
+
$pages['billing'] = __('Membership Billing', 'paid-memberships-pro' );
|
67 |
+
$pages['cancel'] = __('Membership Cancel', 'paid-memberships-pro' );
|
68 |
+
$pages['checkout'] = __('Membership Checkout', 'paid-memberships-pro' );
|
69 |
+
$pages['confirmation'] = __('Membership Confirmation', 'paid-memberships-pro' );
|
70 |
+
$pages['invoice'] = __('Membership Invoice', 'paid-memberships-pro' );
|
71 |
+
$pages['levels'] = __('Membership Levels', 'paid-memberships-pro' );
|
72 |
|
73 |
} else {
|
74 |
//generate extra pages one at a time
|
81 |
|
82 |
if (!empty($pages_created)) {
|
83 |
$msg = true;
|
84 |
+
$msgt = __("The following pages have been created for you", 'paid-memberships-pro' ) . ": " . implode(", ", $pages_created) . ".";
|
85 |
}
|
86 |
}
|
87 |
|
90 |
|
91 |
|
92 |
<form action="" method="post" enctype="multipart/form-data">
|
93 |
+
<h2><?php _e('Pages', 'paid-memberships-pro' ); ?></h2>
|
94 |
<?php
|
95 |
global $pmpro_pages_ready;
|
96 |
if ($pmpro_pages_ready) {
|
97 |
?>
|
98 |
+
<p><?php _e('Manage the WordPress pages assigned to each required Paid Memberships Pro page.', 'paid-memberships-pro' ); ?></p>
|
99 |
<?php
|
100 |
} else {
|
101 |
?>
|
102 |
+
<p><?php _e('Assign the WordPress pages for each required Paid Memberships Pro page or', 'paid-memberships-pro' ); ?> <a
|
103 |
+
href="?page=pmpro-pagesettings&createpages=1"><?php _e('click here to let us generate them for you', 'paid-memberships-pro' ); ?></a>.
|
104 |
</p>
|
105 |
<?php
|
106 |
}
|
109 |
<tbody>
|
110 |
<tr>
|
111 |
<th scope="row" valign="top">
|
112 |
+
<label for="account_page_id"><?php _e('Account Page', 'paid-memberships-pro' ); ?>:</label>
|
113 |
</th>
|
114 |
<td>
|
115 |
<?php
|
116 |
+
wp_dropdown_pages(array("name" => "account_page_id", "show_option_none" => "-- " . __('Choose One', 'paid-memberships-pro' ) . " --", "selected" => $pmpro_pages['account']));
|
117 |
?>
|
118 |
<?php if (!empty($pmpro_pages['account'])) { ?>
|
119 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['account']; ?>&action=edit"
|
120 |
+
class="button button-secondary pmpro_page_edit"><?php _e('edit page', 'paid-memberships-pro' ); ?></a>
|
121 |
|
122 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['account']); ?>"
|
123 |
+
class="button button-secondary pmpro_page_view"><?php _e('view page', 'paid-memberships-pro' ); ?></a>
|
124 |
<?php } ?>
|
125 |
<br/>
|
126 |
+
<small class="pmpro_lite"><?php _e('Include the shortcode', 'paid-memberships-pro' ); ?> [pmpro_account].</small>
|
127 |
</td>
|
128 |
<tr>
|
129 |
<th scope="row" valign="top">
|
130 |
+
<label for="billing_page_id"><?php _e('Billing Information Page', 'paid-memberships-pro' ); ?>:</label>
|
131 |
</th>
|
132 |
<td>
|
133 |
<?php
|
134 |
+
wp_dropdown_pages(array("name" => "billing_page_id", "show_option_none" => "-- " . __('Choose One', 'paid-memberships-pro' ) . " --", "selected" => $pmpro_pages['billing']));
|
135 |
?>
|
136 |
<?php if (!empty($pmpro_pages['billing'])) { ?>
|
137 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['billing'] ?>&action=edit"
|
138 |
+
class="button button-secondary pmpro_page_edit"><?php _e('edit page', 'paid-memberships-pro' ); ?></a>
|
139 |
|
140 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['billing']); ?>"
|
141 |
+
class="button button-secondary pmpro_page_view"><?php _e('view page', 'paid-memberships-pro' ); ?></a>
|
142 |
<?php } ?>
|
143 |
<br/>
|
144 |
+
<small class="pmpro_lite"><?php _e('Include the shortcode', 'paid-memberships-pro' ); ?> [pmpro_billing].</small>
|
145 |
</td>
|
146 |
<tr>
|
147 |
<th scope="row" valign="top">
|
148 |
+
<label for="cancel_page_id"><?php _e('Cancel Page', 'paid-memberships-pro' ); ?>:</label>
|
149 |
</th>
|
150 |
<td>
|
151 |
<?php
|
152 |
+
wp_dropdown_pages(array("name" => "cancel_page_id", "show_option_none" => "-- " . __('Choose One', 'paid-memberships-pro') . " --", "selected" => $pmpro_pages['cancel'], "post_types" => $post_types ) );
|
153 |
?>
|
154 |
<?php if (!empty($pmpro_pages['cancel'])) { ?>
|
155 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['cancel'] ?>&action=edit"
|
156 |
+
class="button button-secondary pmpro_page_edit"><?php _e('edit page', 'paid-memberships-pro' ); ?></a>
|
157 |
|
158 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['cancel']); ?>"
|
159 |
+
class="button button-secondary pmpro_page_view"><?php _e('view page', 'paid-memberships-pro' ); ?></a>
|
160 |
<?php } ?>
|
161 |
<br/>
|
162 |
+
<small class="pmpro_lite"><?php _e('Include the shortcode', 'paid-memberships-pro' ); ?> [pmpro_cancel].</small>
|
163 |
</td>
|
164 |
</tr>
|
165 |
<tr>
|
166 |
<th scope="row" valign="top">
|
167 |
+
<label for="checkout_page_id"><?php _e('Checkout Page', 'paid-memberships-pro' ); ?>:</label>
|
168 |
</th>
|
169 |
<td>
|
170 |
<?php
|
171 |
+
wp_dropdown_pages(array("name" => "checkout_page_id", "show_option_none" => "-- " . __('Choose One', 'paid-memberships-pro') . " --", "selected" => $pmpro_pages['checkout'], "post_types" => $post_types ));
|
172 |
?>
|
173 |
<?php if (!empty($pmpro_pages['checkout'])) { ?>
|
174 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['checkout'] ?>&action=edit"
|
175 |
+
class="button button-secondary pmpro_page_edit"><?php _e('edit page', 'paid-memberships-pro' ); ?></a>
|
176 |
|
177 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['checkout']); ?>"
|
178 |
+
class="button button-secondary pmpro_page_view"><?php _e('view page', 'paid-memberships-pro' ); ?></a>
|
179 |
<?php } ?>
|
180 |
<br/>
|
181 |
+
<small class="pmpro_lite"><?php _e('Include the shortcode', 'paid-memberships-pro' ); ?> [pmpro_checkout].</small>
|
182 |
</td>
|
183 |
</tr>
|
184 |
<tr>
|
185 |
<th scope="row" valign="top">
|
186 |
+
<label for="confirmation_page_id"><?php _e('Confirmation Page', 'paid-memberships-pro' ); ?>:</label>
|
187 |
</th>
|
188 |
<td>
|
189 |
<?php
|
190 |
+
wp_dropdown_pages(array("name" => "confirmation_page_id", "show_option_none" => "-- " . __('Choose One', 'paid-memberships-pro') . " --", "selected" => $pmpro_pages['confirmation'], "post_types" => $post_types));
|
191 |
?>
|
192 |
<?php if (!empty($pmpro_pages['confirmation'])) { ?>
|
193 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['confirmation'] ?>&action=edit"
|
194 |
+
class="button button-secondary pmpro_page_edit"><?php _e('edit page', 'paid-memberships-pro' ); ?></a>
|
195 |
|
196 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['confirmation']); ?>"
|
197 |
+
class="button button-secondary pmpro_page_view"><?php _e('view page', 'paid-memberships-pro' ); ?></a>
|
198 |
<?php } ?>
|
199 |
<br/>
|
200 |
+
<small class="pmpro_lite"><?php _e('Include the shortcode', 'paid-memberships-pro' ); ?> [pmpro_confirmation].
|
201 |
</small>
|
202 |
</td>
|
203 |
</tr>
|
204 |
<tr>
|
205 |
<th scope="row" valign="top">
|
206 |
+
<label for="invoice_page_id"><?php _e('Invoice Page', 'paid-memberships-pro' ); ?>:</label>
|
207 |
</th>
|
208 |
<td>
|
209 |
<?php
|
210 |
+
wp_dropdown_pages(array("name" => "invoice_page_id", "show_option_none" => "-- " . __('Choose One', 'paid-memberships-pro') . " --", "selected" => $pmpro_pages['invoice'], "post_types" => $post_types));
|
211 |
?>
|
212 |
<?php if (!empty($pmpro_pages['invoice'])) { ?>
|
213 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['invoice'] ?>&action=edit"
|
214 |
+
class="button button-secondary pmpro_page_edit"><?php _e('edit page', 'paid-memberships-pro' ); ?></a>
|
215 |
|
216 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['invoice']); ?>"
|
217 |
+
class="button button-secondary pmpro_page_view"><?php _e('view page', 'paid-memberships-pro' ); ?></a>
|
218 |
<?php } ?>
|
219 |
<br/>
|
220 |
+
<small class="pmpro_lite"><?php _e('Include the shortcode', 'paid-memberships-pro' ); ?> [pmpro_invoice].</small>
|
221 |
</td>
|
222 |
</tr>
|
223 |
<tr>
|
224 |
<th scope="row" valign="top">
|
225 |
+
<label for="levels_page_id"><?php _e('Levels Page', 'paid-memberships-pro' ); ?>:</label>
|
226 |
</th>
|
227 |
<td>
|
228 |
<?php
|
229 |
+
wp_dropdown_pages(array("name" => "levels_page_id", "show_option_none" => "-- " . __('Choose One', 'paid-memberships-pro') . " --", "selected" => $pmpro_pages['levels'], "post_types" => $post_types));
|
230 |
?>
|
231 |
<?php if (!empty($pmpro_pages['levels'])) { ?>
|
232 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages['levels'] ?>&action=edit"
|
233 |
+
class="button button-secondary pmpro_page_edit"><?php _e('edit page', 'paid-memberships-pro' ); ?></a>
|
234 |
|
235 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['levels']); ?>"
|
236 |
+
class="button button-secondary pmpro_page_view"><?php _e('view page', 'paid-memberships-pro' ); ?></a>
|
237 |
<?php } ?>
|
238 |
<br/>
|
239 |
+
<small class="pmpro_lite"><?php _e('Include the shortcode', 'paid-memberships-pro' ); ?> [pmpro_levels].</small>
|
240 |
</td>
|
241 |
</tr>
|
242 |
</tbody>
|
243 |
</table>
|
244 |
<?php
|
245 |
if (!empty($extra_pages)) { ?>
|
246 |
+
<h2><?php _e('Additional Page Settings', 'paid-memberships-pro' ); ?></h2>
|
247 |
<table class="form-table">
|
248 |
<tbody>
|
249 |
<?php foreach ($extra_pages as $name => $page) { ?>
|
266 |
<td>
|
267 |
<?php wp_dropdown_pages(array(
|
268 |
"name" => $name . '_page_id',
|
269 |
+
"show_option_none" => "-- " . __('Choose One', 'paid-memberships-pro' ) . " --",
|
270 |
"selected" => $pmpro_pages[$name],
|
271 |
));
|
272 |
if(!empty($pmpro_pages[$name])) {
|
273 |
?>
|
274 |
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[$name] ?>&action=edit"
|
275 |
+
class="button button-secondary pmpro_page_edit"><?php _e('edit page', 'paid-memberships-pro' ); ?></a>
|
276 |
|
277 |
<a target="_blank" href="<?php echo get_permalink($pmpro_pages[$name]); ?>"
|
278 |
+
class="button button-secondary pmpro_page_view"><?php _e('view page', 'paid-memberships-pro' ); ?></a>
|
279 |
<?php } else { ?>
|
280 |
|
281 |
+
<a href="?page=pmpro-pagesettings&createpages=1&page_name=<?php echo $name; ?>"><?php _e('Generate Page', 'paid-memberships-pro' ); ?></a>
|
282 |
<?php } ?>
|
283 |
<?php if(!empty($hint)) { ?>
|
284 |
<br/>
|
292 |
<?php } ?>
|
293 |
<p class="submit">
|
294 |
<input name="savesettings" type="submit" class="button button-primary"
|
295 |
+
value="<?php _e('Save Settings', 'paid-memberships-pro' ); ?>"/>
|
296 |
</p>
|
297 |
</form>
|
298 |
|
adminpages/paymentsettings.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_paymentsettings")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
global $wpdb, $pmpro_currency_symbol, $msg, $msgt;
|
@@ -46,7 +46,7 @@
|
|
46 |
|
47 |
//assume success
|
48 |
$msg = true;
|
49 |
-
$msgt = __("Your payment settings have been updated.",
|
50 |
}
|
51 |
|
52 |
/*
|
@@ -90,20 +90,20 @@
|
|
90 |
?>
|
91 |
|
92 |
<form action="" method="post" enctype="multipart/form-data">
|
93 |
-
<h2><?php _e('Payment Gateway', '
|
94 |
|
95 |
-
<p><?php _e('Learn more about <a title="Paid Memberships Pro - SSL Settings" target="_blank" href="http://www.paidmembershipspro.com/support/initial-plugin-setup/ssl/">SSL</a> or <a title="Paid Memberships Pro - Payment Gateway Settings" target="_blank" href="http://www.paidmembershipspro.com/support/initial-plugin-setup/payment-gateway/">Payment Gateway Settings</a>.', '
|
96 |
|
97 |
<table class="form-table">
|
98 |
<tbody>
|
99 |
<tr class="pmpro_settings_divider">
|
100 |
<td colspan="2">
|
101 |
-
<?php _e('Choose a Gateway', '
|
102 |
</td>
|
103 |
</tr>
|
104 |
<tr>
|
105 |
<th scope="row" valign="top">
|
106 |
-
<label for="gateway"><?php _e('Payment Gateway', '
|
107 |
</th>
|
108 |
<td>
|
109 |
<select id="gateway" name="gateway" onchange="pmpro_changeGateway(jQuery(this).val());">
|
@@ -121,12 +121,12 @@
|
|
121 |
</tr>
|
122 |
<tr>
|
123 |
<th scope="row" valign="top">
|
124 |
-
<label for="gateway_environment"><?php _e('Gateway Environment', '
|
125 |
</th>
|
126 |
<td>
|
127 |
<select name="gateway_environment">
|
128 |
-
<option value="sandbox" <?php selected( $gateway_environment, "sandbox" ); ?>><?php _e('Sandbox/Testing', '
|
129 |
-
<option value="live" <?php selected( $gateway_environment, "live" ); ?>><?php _e('Live/Production', '
|
130 |
</select>
|
131 |
<script>
|
132 |
function pmpro_changeGateway(gateway)
|
@@ -145,12 +145,12 @@
|
|
145 |
|
146 |
<tr class="pmpro_settings_divider">
|
147 |
<td colspan="2">
|
148 |
-
<?php _e('Currency and Tax Settings', '
|
149 |
</td>
|
150 |
</tr>
|
151 |
<tr class="gateway gateway_ <?php echo esc_attr(pmpro_getClassesForPaymentSettingsField("currency"));?>" <?php if(!empty($gateway) && $gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard" && $gateway != "braintree" && $gateway != "twocheckout" && $gateway != "cybersource" && $gateway != "payflowpro" && $gateway != "stripe" && $gateway != "authorizenet" && $gateway != "gourl") { ?>style="display: none;"<?php } ?>>
|
152 |
<th scope="row" valign="top">
|
153 |
-
<label for="currency"><?php _e('Currency', '
|
154 |
</th>
|
155 |
<td>
|
156 |
<select name="currency">
|
@@ -166,12 +166,12 @@
|
|
166 |
}
|
167 |
?>
|
168 |
</select>
|
169 |
-
<small><?php _e( 'Not all currencies will be supported by every gateway. Please check with your gateway.', '
|
170 |
</td>
|
171 |
</tr>
|
172 |
<tr class="gateway gateway_ <?php echo esc_attr(pmpro_getClassesForPaymentSettingsField("accepted_credit_cards"));?>" <?php if(!empty($gateway) && $gateway != "authorizenet" && $gateway != "paypal" && $gateway != "stripe" && $gateway != "payflowpro" && $gateway != "braintree" && $gateway != "twocheckout" && $gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
173 |
<th scope="row" valign="top">
|
174 |
-
<label for="creditcards"><?php _e('Accepted Credit Card Types', '
|
175 |
</th>
|
176 |
<td>
|
177 |
<input type="checkbox" id="creditcards_visa" name="creditcards_visa" value="1" <?php if(in_array("Visa", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> <label for="creditcards_visa">Visa</label><br />
|
@@ -185,42 +185,42 @@
|
|
185 |
</tr>
|
186 |
<tr class="gateway gateway_ <?php echo esc_attr(pmpro_getClassesForPaymentSettingsField("tax_rate"));?>" <?php if(!empty($gateway) && $gateway != "stripe" && $gateway != "authorizenet" && $gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "check" && $gateway != "paypalstandard" && $gateway != "payflowpro" && $gateway != "braintree" && $gateway != "twocheckout" && $gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
187 |
<th scope="row" valign="top">
|
188 |
-
<label for="tax"><?php _e('Sales Tax', '
|
189 |
</th>
|
190 |
<td>
|
191 |
-
<?php _e('Tax State', '
|
192 |
-
<input type="text" id="tax_state" name="tax_state" size="4" value="<?php echo esc_attr($tax_state)?>" /> <small>(<?php _e('abbreviation, e.g. "PA"', '
|
193 |
-
<?php _e('Tax Rate', '
|
194 |
-
<input type="text" id="tax_rate" name="tax_rate" size="10" value="<?php echo esc_attr($tax_rate)?>" /> <small>(<?php _e('decimal, e.g. "0.06"', '
|
195 |
-
<p><small><?php _e('US only. If values are given, tax will be applied for any members ordering from the selected state.<br />For non-US or more complex tax rules, use the <a target="_blank" href="http://www.paidmembershipspro.com/2013/10/non-us-taxes-paid-memberships-pro/">pmpro_tax filter</a>.', '
|
196 |
</td>
|
197 |
</tr>
|
198 |
|
199 |
<tr class="pmpro_settings_divider">
|
200 |
<td colspan="2">
|
201 |
-
<?php _e('SSL Settings', '
|
202 |
</td>
|
203 |
</tr>
|
204 |
<tr class="gateway gateway_ <?php echo esc_attr(pmpro_getClassesForPaymentSettingsField("use_ssl"));?>">
|
205 |
<th scope="row" valign="top">
|
206 |
-
<label for="use_ssl"><?php _e('Force SSL', '
|
207 |
</th>
|
208 |
<td>
|
209 |
<?php
|
210 |
if( pmpro_check_site_url_for_https() ) {
|
211 |
//entire site is over HTTPS
|
212 |
?>
|
213 |
-
<p><?php _e( 'Your Site URL starts with https:// and so PMPro will allow your entire site to be served over HTTPS.'
|
214 |
<?php
|
215 |
} else {
|
216 |
//site is not over HTTPS, show setting
|
217 |
?>
|
218 |
<select id="use_ssl" name="use_ssl">
|
219 |
-
<option value="0" <?php if(empty($use_ssl)) { ?>selected="selected"<?php } ?>><?php _e('No', '
|
220 |
-
<option value="1" <?php if(!empty($use_ssl) && $use_ssl == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes', '
|
221 |
-
<option value="2" <?php if(!empty($use_ssl) && $use_ssl == 2) { ?>selected="selected"<?php } ?>><?php _e('Yes (with JavaScript redirects)', '
|
222 |
</select>
|
223 |
-
<small><?php _e('Recommended: Yes. Try the JavaScript redirects setting if you are having issues with infinite redirect loops.', '
|
224 |
<?php
|
225 |
}
|
226 |
?>
|
@@ -228,26 +228,26 @@
|
|
228 |
</tr>
|
229 |
<tr>
|
230 |
<th scope="row" valign="top">
|
231 |
-
<label for="sslseal"><?php _e('SSL Seal Code', '
|
232 |
</th>
|
233 |
<td>
|
234 |
<textarea id="sslseal" name="sslseal" rows="3" cols="80"><?php echo stripslashes(esc_textarea($sslseal))?></textarea>
|
235 |
-
<br /><small><?php _e('Your <strong><a target="_blank" href="http://www.paidmembershipspro.com/documentation/initial-plugin-setup/ssl/">SSL Certificate</a></strong> must be installed by your web host. Your <strong>SSL Seal</strong> will be a short HTML or JavaScript snippet that can be pasted here.', '
|
236 |
</td>
|
237 |
</tr>
|
238 |
<tr>
|
239 |
<th scope="row" valign="top">
|
240 |
-
<label for="nuclear_HTTPS"><?php _e('Extra HTTPS URL Filter', '
|
241 |
</th>
|
242 |
<td>
|
243 |
-
<input type="checkbox" id="nuclear_HTTPS" name="nuclear_HTTPS" value="1" <?php if(!empty($nuclear_HTTPS)) { ?>checked="checked"<?php } ?> /> <label for="nuclear_HTTPS"><?php _e('Pass all generated HTML through a URL filter to add HTTPS to URLs used on secure pages. Check this if you are using SSL and have warnings on your checkout pages.', '
|
244 |
</td>
|
245 |
</tr>
|
246 |
|
247 |
</tbody>
|
248 |
</table>
|
249 |
<p class="submit">
|
250 |
-
<input name="savesettings" type="submit" class="button-primary" value="<?php _e('Save Settings', '
|
251 |
</p>
|
252 |
</form>
|
253 |
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_paymentsettings")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
global $wpdb, $pmpro_currency_symbol, $msg, $msgt;
|
46 |
|
47 |
//assume success
|
48 |
$msg = true;
|
49 |
+
$msgt = __("Your payment settings have been updated.", 'paid-memberships-pro' );
|
50 |
}
|
51 |
|
52 |
/*
|
90 |
?>
|
91 |
|
92 |
<form action="" method="post" enctype="multipart/form-data">
|
93 |
+
<h2><?php _e('Payment Gateway', 'paid-memberships-pro' );?> & <?php _e('SSL Settings', 'paid-memberships-pro' );?></h2>
|
94 |
|
95 |
+
<p><?php _e('Learn more about <a title="Paid Memberships Pro - SSL Settings" target="_blank" href="http://www.paidmembershipspro.com/support/initial-plugin-setup/ssl/">SSL</a> or <a title="Paid Memberships Pro - Payment Gateway Settings" target="_blank" href="http://www.paidmembershipspro.com/support/initial-plugin-setup/payment-gateway/">Payment Gateway Settings</a>.', 'paid-memberships-pro' ); ?></p>
|
96 |
|
97 |
<table class="form-table">
|
98 |
<tbody>
|
99 |
<tr class="pmpro_settings_divider">
|
100 |
<td colspan="2">
|
101 |
+
<?php _e('Choose a Gateway', 'paid-memberships-pro' ); ?>
|
102 |
</td>
|
103 |
</tr>
|
104 |
<tr>
|
105 |
<th scope="row" valign="top">
|
106 |
+
<label for="gateway"><?php _e('Payment Gateway', 'paid-memberships-pro' );?>:</label>
|
107 |
</th>
|
108 |
<td>
|
109 |
<select id="gateway" name="gateway" onchange="pmpro_changeGateway(jQuery(this).val());">
|
121 |
</tr>
|
122 |
<tr>
|
123 |
<th scope="row" valign="top">
|
124 |
+
<label for="gateway_environment"><?php _e('Gateway Environment', 'paid-memberships-pro' );?>:</label>
|
125 |
</th>
|
126 |
<td>
|
127 |
<select name="gateway_environment">
|
128 |
+
<option value="sandbox" <?php selected( $gateway_environment, "sandbox" ); ?>><?php _e('Sandbox/Testing', 'paid-memberships-pro' );?></option>
|
129 |
+
<option value="live" <?php selected( $gateway_environment, "live" ); ?>><?php _e('Live/Production', 'paid-memberships-pro' );?></option>
|
130 |
</select>
|
131 |
<script>
|
132 |
function pmpro_changeGateway(gateway)
|
145 |
|
146 |
<tr class="pmpro_settings_divider">
|
147 |
<td colspan="2">
|
148 |
+
<?php _e('Currency and Tax Settings', 'paid-memberships-pro' ); ?>
|
149 |
</td>
|
150 |
</tr>
|
151 |
<tr class="gateway gateway_ <?php echo esc_attr(pmpro_getClassesForPaymentSettingsField("currency"));?>" <?php if(!empty($gateway) && $gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard" && $gateway != "braintree" && $gateway != "twocheckout" && $gateway != "cybersource" && $gateway != "payflowpro" && $gateway != "stripe" && $gateway != "authorizenet" && $gateway != "gourl") { ?>style="display: none;"<?php } ?>>
|
152 |
<th scope="row" valign="top">
|
153 |
+
<label for="currency"><?php _e('Currency', 'paid-memberships-pro' );?>:</label>
|
154 |
</th>
|
155 |
<td>
|
156 |
<select name="currency">
|
166 |
}
|
167 |
?>
|
168 |
</select>
|
169 |
+
<small><?php _e( 'Not all currencies will be supported by every gateway. Please check with your gateway.', 'paid-memberships-pro' ); ?></small>
|
170 |
</td>
|
171 |
</tr>
|
172 |
<tr class="gateway gateway_ <?php echo esc_attr(pmpro_getClassesForPaymentSettingsField("accepted_credit_cards"));?>" <?php if(!empty($gateway) && $gateway != "authorizenet" && $gateway != "paypal" && $gateway != "stripe" && $gateway != "payflowpro" && $gateway != "braintree" && $gateway != "twocheckout" && $gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
173 |
<th scope="row" valign="top">
|
174 |
+
<label for="creditcards"><?php _e('Accepted Credit Card Types', 'paid-memberships-pro' );?></label>
|
175 |
</th>
|
176 |
<td>
|
177 |
<input type="checkbox" id="creditcards_visa" name="creditcards_visa" value="1" <?php if(in_array("Visa", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> <label for="creditcards_visa">Visa</label><br />
|
185 |
</tr>
|
186 |
<tr class="gateway gateway_ <?php echo esc_attr(pmpro_getClassesForPaymentSettingsField("tax_rate"));?>" <?php if(!empty($gateway) && $gateway != "stripe" && $gateway != "authorizenet" && $gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "check" && $gateway != "paypalstandard" && $gateway != "payflowpro" && $gateway != "braintree" && $gateway != "twocheckout" && $gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
187 |
<th scope="row" valign="top">
|
188 |
+
<label for="tax"><?php _e('Sales Tax', 'paid-memberships-pro' );?> <small>(<?php _e('optional', 'paid-memberships-pro' );?>)</small></label>
|
189 |
</th>
|
190 |
<td>
|
191 |
+
<?php _e('Tax State', 'paid-memberships-pro' );?>:
|
192 |
+
<input type="text" id="tax_state" name="tax_state" size="4" value="<?php echo esc_attr($tax_state)?>" /> <small>(<?php _e('abbreviation, e.g. "PA"', 'paid-memberships-pro' );?>)</small>
|
193 |
+
<?php _e('Tax Rate', 'paid-memberships-pro' ); ?>:
|
194 |
+
<input type="text" id="tax_rate" name="tax_rate" size="10" value="<?php echo esc_attr($tax_rate)?>" /> <small>(<?php _e('decimal, e.g. "0.06"', 'paid-memberships-pro' );?>)</small>
|
195 |
+
<p><small><?php _e('US only. If values are given, tax will be applied for any members ordering from the selected state.<br />For non-US or more complex tax rules, use the <a target="_blank" href="http://www.paidmembershipspro.com/2013/10/non-us-taxes-paid-memberships-pro/">pmpro_tax filter</a>.', 'paid-memberships-pro' );?></small></p>
|
196 |
</td>
|
197 |
</tr>
|
198 |
|
199 |
<tr class="pmpro_settings_divider">
|
200 |
<td colspan="2">
|
201 |
+
<?php _e('SSL Settings', 'paid-memberships-pro' ); ?>
|
202 |
</td>
|
203 |
</tr>
|
204 |
<tr class="gateway gateway_ <?php echo esc_attr(pmpro_getClassesForPaymentSettingsField("use_ssl"));?>">
|
205 |
<th scope="row" valign="top">
|
206 |
+
<label for="use_ssl"><?php _e('Force SSL', 'paid-memberships-pro' );?>:</label>
|
207 |
</th>
|
208 |
<td>
|
209 |
<?php
|
210 |
if( pmpro_check_site_url_for_https() ) {
|
211 |
//entire site is over HTTPS
|
212 |
?>
|
213 |
+
<p><?php _e( 'Your Site URL starts with https:// and so PMPro will allow your entire site to be served over HTTPS.', 'paid-memberships-pro' ); ?></p>
|
214 |
<?php
|
215 |
} else {
|
216 |
//site is not over HTTPS, show setting
|
217 |
?>
|
218 |
<select id="use_ssl" name="use_ssl">
|
219 |
+
<option value="0" <?php if(empty($use_ssl)) { ?>selected="selected"<?php } ?>><?php _e('No', 'paid-memberships-pro' );?></option>
|
220 |
+
<option value="1" <?php if(!empty($use_ssl) && $use_ssl == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes', 'paid-memberships-pro' );?></option>
|
221 |
+
<option value="2" <?php if(!empty($use_ssl) && $use_ssl == 2) { ?>selected="selected"<?php } ?>><?php _e('Yes (with JavaScript redirects)', 'paid-memberships-pro' );?></option>
|
222 |
</select>
|
223 |
+
<small><?php _e('Recommended: Yes. Try the JavaScript redirects setting if you are having issues with infinite redirect loops.', 'paid-memberships-pro' ); ?></small>
|
224 |
<?php
|
225 |
}
|
226 |
?>
|
228 |
</tr>
|
229 |
<tr>
|
230 |
<th scope="row" valign="top">
|
231 |
+
<label for="sslseal"><?php _e('SSL Seal Code', 'paid-memberships-pro' );?>:</label>
|
232 |
</th>
|
233 |
<td>
|
234 |
<textarea id="sslseal" name="sslseal" rows="3" cols="80"><?php echo stripslashes(esc_textarea($sslseal))?></textarea>
|
235 |
+
<br /><small><?php _e('Your <strong><a target="_blank" href="http://www.paidmembershipspro.com/documentation/initial-plugin-setup/ssl/">SSL Certificate</a></strong> must be installed by your web host. Your <strong>SSL Seal</strong> will be a short HTML or JavaScript snippet that can be pasted here.', 'paid-memberships-pro' ); ?></small>
|
236 |
</td>
|
237 |
</tr>
|
238 |
<tr>
|
239 |
<th scope="row" valign="top">
|
240 |
+
<label for="nuclear_HTTPS"><?php _e('Extra HTTPS URL Filter', 'paid-memberships-pro' );?>:</label>
|
241 |
</th>
|
242 |
<td>
|
243 |
+
<input type="checkbox" id="nuclear_HTTPS" name="nuclear_HTTPS" value="1" <?php if(!empty($nuclear_HTTPS)) { ?>checked="checked"<?php } ?> /> <label for="nuclear_HTTPS"><?php _e('Pass all generated HTML through a URL filter to add HTTPS to URLs used on secure pages. Check this if you are using SSL and have warnings on your checkout pages.', 'paid-memberships-pro' );?></label>
|
244 |
</td>
|
245 |
</tr>
|
246 |
|
247 |
</tbody>
|
248 |
</table>
|
249 |
<p class="submit">
|
250 |
+
<input name="savesettings" type="submit" class="button-primary" value="<?php _e('Save Settings', 'paid-memberships-pro' );?>" />
|
251 |
</p>
|
252 |
</form>
|
253 |
|
adminpages/reports.php
CHANGED
@@ -38,7 +38,7 @@
|
|
38 |
<?php call_user_func("pmpro_report_" . $report . "_widget"); ?>
|
39 |
<?php if(function_exists('pmpro_report_' . $report . '_page')) { ?>
|
40 |
<p style="text-align:center;">
|
41 |
-
<a class="button button-primary" href="<?php echo admin_url("admin.php?page=pmpro-reports&report=" . $report);?>"><?php _e('Details', '
|
42 |
</p>
|
43 |
<?php } ?>
|
44 |
</div>
|
@@ -60,9 +60,9 @@
|
|
60 |
call_user_func("pmpro_report_" . $report . "_page");
|
61 |
?>
|
62 |
<hr />
|
63 |
-
<a class="button button-primary" href="<?php echo admin_url("admin.php?page=pmpro-reports");?>"><?php _e('Back to Reports Dashboard', '
|
64 |
<?php
|
65 |
}
|
66 |
|
67 |
require_once(dirname(__FILE__) . "/admin_footer.php");
|
68 |
-
?>
|
38 |
<?php call_user_func("pmpro_report_" . $report . "_widget"); ?>
|
39 |
<?php if(function_exists('pmpro_report_' . $report . '_page')) { ?>
|
40 |
<p style="text-align:center;">
|
41 |
+
<a class="button button-primary" href="<?php echo admin_url("admin.php?page=pmpro-reports&report=" . $report);?>"><?php _e('Details', 'paid-memberships-pro' );?></a>
|
42 |
</p>
|
43 |
<?php } ?>
|
44 |
</div>
|
60 |
call_user_func("pmpro_report_" . $report . "_page");
|
61 |
?>
|
62 |
<hr />
|
63 |
+
<a class="button button-primary" href="<?php echo admin_url("admin.php?page=pmpro-reports");?>"><?php _e('Back to Reports Dashboard', 'paid-memberships-pro' );?></a>
|
64 |
<?php
|
65 |
}
|
66 |
|
67 |
require_once(dirname(__FILE__) . "/admin_footer.php");
|
68 |
+
?>
|
adminpages/reports/login.php
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
* pmpro_report_{slug}_page() to show up when users click on the report page widget.
|
14 |
*/
|
15 |
global $pmpro_reports;
|
16 |
-
$pmpro_reports['login'] = __('Visits, Views, and Logins', '
|
17 |
|
18 |
function pmpro_report_login_widget()
|
19 |
{
|
@@ -28,26 +28,26 @@ function pmpro_report_login_widget()
|
|
28 |
<thead>
|
29 |
<tr>
|
30 |
<th scope="col"> </th>
|
31 |
-
<th scope="col"><?php _e('Visits','
|
32 |
-
<th scope="col"><?php _e('Views','
|
33 |
-
<th scope="col"><?php _e('Logins','
|
34 |
</tr>
|
35 |
</thead>
|
36 |
<tbody>
|
37 |
<tr>
|
38 |
-
<th scope="row"><?php _e('Today','
|
39 |
<td><?php echo number_format_i18n($visits['today']); ?></td>
|
40 |
<td><?php echo number_format_i18n($views['today']); ?></td>
|
41 |
<td><?php echo number_format_i18n($logins['today']);?></td>
|
42 |
</tr>
|
43 |
<tr>
|
44 |
-
<th scope="row"><?php _e('This Month','
|
45 |
<td><?php echo number_format_i18n($visits['month']); ?></td>
|
46 |
<td><?php echo number_format_i18n($views['month']); ?></td>
|
47 |
<td><?php echo number_format_i18n($logins['month']); ?></td>
|
48 |
</tr>
|
49 |
<tr>
|
50 |
-
<th scope="row"><?php _e('All Time','
|
51 |
<td><?php echo number_format_i18n($visits['alltime']); ?></td>
|
52 |
<td><?php echo number_format_i18n($views['alltime']);?></td>
|
53 |
<td><?php echo number_format_i18n($logins['alltime']); ?></td>
|
@@ -76,13 +76,13 @@ function pmpro_report_login_page()
|
|
76 |
?>
|
77 |
<form id="posts-filter" method="get" action="">
|
78 |
<h1>
|
79 |
-
<?php _e('Visits, Views, and Logins Report', '
|
80 |
</h1>
|
81 |
<ul class="subsubsub">
|
82 |
<li>
|
83 |
-
<?php _e('Show', '
|
84 |
-
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Users', '
|
85 |
-
<option value="all" <?php if($l == "all") { ?>selected="selected"<?php } ?>><?php _e('All Levels', '
|
86 |
<?php
|
87 |
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
88 |
foreach($levels as $level)
|
@@ -96,7 +96,7 @@ function pmpro_report_login_page()
|
|
96 |
</li>
|
97 |
</ul>
|
98 |
<p class="search-box">
|
99 |
-
<label class="hidden" for="post-search-input"><?php _e('Search', '
|
100 |
<input type="hidden" name="page" value="pmpro-reports" />
|
101 |
<input type="hidden" name="report" value="login" />
|
102 |
<input id="post-search-input" type="text" value="<?php echo esc_attr($s)?>" name="s"/>
|
@@ -155,20 +155,20 @@ function pmpro_report_login_page()
|
|
155 |
<table class="widefat">
|
156 |
<thead>
|
157 |
<tr class="thead">
|
158 |
-
<th><?php _e('ID', '
|
159 |
-
<th><?php _e('User', '
|
160 |
-
<th><?php _e('Name', '
|
161 |
-
<th><?php _e('Membership', '
|
162 |
-
<th><?php _e('Joined', '
|
163 |
-
<th><?php _e('Expires', '
|
164 |
-
<th><?php _e('Last Visit', '
|
165 |
-
<th><?php _e('Visits This Month', '
|
166 |
-
<th><?php _e('Total Visits', '
|
167 |
-
<th><?php _e('Views This Month', '
|
168 |
-
<th><?php _e('Total Views', '
|
169 |
-
<th><?php _e('Last Login', '
|
170 |
-
<th><?php _e('Logins This Month', '
|
171 |
-
<th><?php _e('Total Logins', '
|
172 |
</tr>
|
173 |
</thead>
|
174 |
<tbody id="users" class="list:user user-list">
|
@@ -225,7 +225,7 @@ function pmpro_report_login_page()
|
|
225 |
{
|
226 |
?>
|
227 |
<tr>
|
228 |
-
<td colspan="9"><p><?php _e('No members found.', '
|
229 |
</tr>
|
230 |
<?php
|
231 |
}
|
13 |
* pmpro_report_{slug}_page() to show up when users click on the report page widget.
|
14 |
*/
|
15 |
global $pmpro_reports;
|
16 |
+
$pmpro_reports['login'] = __('Visits, Views, and Logins', 'paid-memberships-pro' );
|
17 |
|
18 |
function pmpro_report_login_widget()
|
19 |
{
|
28 |
<thead>
|
29 |
<tr>
|
30 |
<th scope="col"> </th>
|
31 |
+
<th scope="col"><?php _e('Visits', 'paid-memberships-pro' ); ?></th>
|
32 |
+
<th scope="col"><?php _e('Views', 'paid-memberships-pro' ); ?></th>
|
33 |
+
<th scope="col"><?php _e('Logins', 'paid-memberships-pro' ); ?></th>
|
34 |
</tr>
|
35 |
</thead>
|
36 |
<tbody>
|
37 |
<tr>
|
38 |
+
<th scope="row"><?php _e('Today', 'paid-memberships-pro' ); ?></th>
|
39 |
<td><?php echo number_format_i18n($visits['today']); ?></td>
|
40 |
<td><?php echo number_format_i18n($views['today']); ?></td>
|
41 |
<td><?php echo number_format_i18n($logins['today']);?></td>
|
42 |
</tr>
|
43 |
<tr>
|
44 |
+
<th scope="row"><?php _e('This Month', 'paid-memberships-pro' ); ?></th>
|
45 |
<td><?php echo number_format_i18n($visits['month']); ?></td>
|
46 |
<td><?php echo number_format_i18n($views['month']); ?></td>
|
47 |
<td><?php echo number_format_i18n($logins['month']); ?></td>
|
48 |
</tr>
|
49 |
<tr>
|
50 |
+
<th scope="row"><?php _e('All Time', 'paid-memberships-pro' ); ?></th>
|
51 |
<td><?php echo number_format_i18n($visits['alltime']); ?></td>
|
52 |
<td><?php echo number_format_i18n($views['alltime']);?></td>
|
53 |
<td><?php echo number_format_i18n($logins['alltime']); ?></td>
|
76 |
?>
|
77 |
<form id="posts-filter" method="get" action="">
|
78 |
<h1>
|
79 |
+
<?php _e('Visits, Views, and Logins Report', 'paid-memberships-pro' );?>
|
80 |
</h1>
|
81 |
<ul class="subsubsub">
|
82 |
<li>
|
83 |
+
<?php _e('Show', 'paid-memberships-pro' )?> <select name="l" onchange="jQuery('#posts-filter').submit();">
|
84 |
+
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Users', 'paid-memberships-pro' )?></option>
|
85 |
+
<option value="all" <?php if($l == "all") { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'paid-memberships-pro' )?></option>
|
86 |
<?php
|
87 |
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
88 |
foreach($levels as $level)
|
96 |
</li>
|
97 |
</ul>
|
98 |
<p class="search-box">
|
99 |
+
<label class="hidden" for="post-search-input"><?php _e('Search', 'paid-memberships-pro' )?> <?php if(empty($l)) echo "Users"; else echo "Members";?>:</label>
|
100 |
<input type="hidden" name="page" value="pmpro-reports" />
|
101 |
<input type="hidden" name="report" value="login" />
|
102 |
<input id="post-search-input" type="text" value="<?php echo esc_attr($s)?>" name="s"/>
|
155 |
<table class="widefat">
|
156 |
<thead>
|
157 |
<tr class="thead">
|
158 |
+
<th><?php _e('ID', 'paid-memberships-pro' )?></th>
|
159 |
+
<th><?php _e('User', 'paid-memberships-pro' )?></th>
|
160 |
+
<th><?php _e('Name', 'paid-memberships-pro' )?></th>
|
161 |
+
<th><?php _e('Membership', 'paid-memberships-pro' )?></th>
|
162 |
+
<th><?php _e('Joined', 'paid-memberships-pro' )?></th>
|
163 |
+
<th><?php _e('Expires', 'paid-memberships-pro' )?></th>
|
164 |
+
<th><?php _e('Last Visit', 'paid-memberships-pro' )?></th>
|
165 |
+
<th><?php _e('Visits This Month', 'paid-memberships-pro' )?></th>
|
166 |
+
<th><?php _e('Total Visits', 'paid-memberships-pro' )?></th>
|
167 |
+
<th><?php _e('Views This Month', 'paid-memberships-pro' )?></th>
|
168 |
+
<th><?php _e('Total Views', 'paid-memberships-pro' )?></th>
|
169 |
+
<th><?php _e('Last Login', 'paid-memberships-pro' )?></th>
|
170 |
+
<th><?php _e('Logins This Month', 'paid-memberships-pro' )?></th>
|
171 |
+
<th><?php _e('Total Logins', 'paid-memberships-pro' )?></th>
|
172 |
</tr>
|
173 |
</thead>
|
174 |
<tbody id="users" class="list:user user-list">
|
225 |
{
|
226 |
?>
|
227 |
<tr>
|
228 |
+
<td colspan="9"><p><?php _e('No members found.', 'paid-memberships-pro' )?> <?php if($l) { ?><a href="?page=pmpro-memberslist&s=<?php echo esc_attr($s)?>"><?php _e('Search all levels', 'paid-memberships-pro' )?></a>.<?php } ?></p></td>
|
229 |
</tr>
|
230 |
<?php
|
231 |
}
|
adminpages/reports/memberships.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
|
16 |
global $pmpro_reports;
|
17 |
|
18 |
-
$pmpro_reports['memberships'] = __('Membership Stats', '
|
19 |
|
20 |
//queue Google Visualization JS on report page
|
21 |
function pmpro_report_memberships_init() {
|
@@ -37,16 +37,16 @@ function pmpro_report_memberships_widget() {
|
|
37 |
<thead>
|
38 |
<tr>
|
39 |
<th scope="col"> </th>
|
40 |
-
<th scope="col"><?php _e('Signups','
|
41 |
-
<th scope="col"><?php _e('All Cancellations','
|
42 |
</tr>
|
43 |
</thead>
|
44 |
<?php
|
45 |
$reports = array(
|
46 |
-
'today'=> __('Today', '
|
47 |
-
'this month'=> __('This Month', '
|
48 |
-
'this year'=> __('This Year', '
|
49 |
-
'all time'=> __('All Time', '
|
50 |
);
|
51 |
|
52 |
foreach($reports as $report_type => $report_name) {
|
@@ -297,25 +297,25 @@ function pmpro_report_memberships_page()
|
|
297 |
?>
|
298 |
<form id="posts-filter" method="get" action="">
|
299 |
<h1>
|
300 |
-
<?php _e('Membership Stats', '
|
301 |
</h1>
|
302 |
<ul class="subsubsub">
|
303 |
<li>
|
304 |
-
<?php _e('Show', '
|
305 |
<select id="period" name="period">
|
306 |
-
<option value="daily" <?php selected($period, "daily");?>><?php _e('Daily', '
|
307 |
-
<option value="monthly" <?php selected($period, "monthly");?>><?php _e('Monthly', '
|
308 |
-
<option value="annual" <?php selected($period, "annual");?>><?php _e('Annual', '
|
309 |
</select>
|
310 |
<select id="type" name="type">
|
311 |
-
<option value="signup_v_all" <?php selected($type, "signup_v_all");?>><?php _e('Signups vs. All Cancellations', '
|
312 |
-
<option value="signup_v_cancel" <?php selected($type, "signup_v_cancel");?>><?php _e('Signups vs. Cancellations', '
|
313 |
-
<option value="signup_v_expiration" <?php selected($type, "signup_v_expiration");?>><?php _e('Signups vs. Expirations', '
|
314 |
<?php /*
|
315 |
-
<option value="mrr_ltv" <?php selected($type, "mrr_ltv");?>><?php _e('MRR & LTV', '
|
316 |
*/ ?>
|
317 |
</select>
|
318 |
-
<span id="for"><?php _e('for', '
|
319 |
<select id="month" name="month">
|
320 |
<?php for($i = 1; $i < 13; $i++) { ?>
|
321 |
<option value="<?php echo $i;?>" <?php selected($month, $i);?>><?php echo date_i18n("F", mktime(0, 0, 0, $i, 2));?></option>
|
@@ -326,9 +326,9 @@ function pmpro_report_memberships_page()
|
|
326 |
<option value="<?php echo $i;?>" <?php selected($year, $i);?>><?php echo $i;?></option>
|
327 |
<?php } ?>
|
328 |
</select>
|
329 |
-
<span id="for"><?php _e('for', '
|
330 |
<select name="level">
|
331 |
-
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', '
|
332 |
<?php
|
333 |
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
334 |
foreach($levels as $level)
|
@@ -342,7 +342,7 @@ function pmpro_report_memberships_page()
|
|
342 |
|
343 |
<input type="hidden" name="page" value="pmpro-reports" />
|
344 |
<input type="hidden" name="report" value="memberships" />
|
345 |
-
<input type="submit" class="button" value="<?php _e('Generate Report', '
|
346 |
</li>
|
347 |
</ul>
|
348 |
|
15 |
|
16 |
global $pmpro_reports;
|
17 |
|
18 |
+
$pmpro_reports['memberships'] = __('Membership Stats', 'paid-memberships-pro' );
|
19 |
|
20 |
//queue Google Visualization JS on report page
|
21 |
function pmpro_report_memberships_init() {
|
37 |
<thead>
|
38 |
<tr>
|
39 |
<th scope="col"> </th>
|
40 |
+
<th scope="col"><?php _e('Signups', 'paid-memberships-pro' ); ?></th>
|
41 |
+
<th scope="col"><?php _e('All Cancellations', 'paid-memberships-pro' ); ?></th>
|
42 |
</tr>
|
43 |
</thead>
|
44 |
<?php
|
45 |
$reports = array(
|
46 |
+
'today'=> __('Today', 'paid-memberships-pro' ),
|
47 |
+
'this month'=> __('This Month', 'paid-memberships-pro' ),
|
48 |
+
'this year'=> __('This Year', 'paid-memberships-pro' ),
|
49 |
+
'all time'=> __('All Time', 'paid-memberships-pro' ),
|
50 |
);
|
51 |
|
52 |
foreach($reports as $report_type => $report_name) {
|
297 |
?>
|
298 |
<form id="posts-filter" method="get" action="">
|
299 |
<h1>
|
300 |
+
<?php _e('Membership Stats', 'paid-memberships-pro' );?>
|
301 |
</h1>
|
302 |
<ul class="subsubsub">
|
303 |
<li>
|
304 |
+
<?php _e('Show', 'paid-memberships-pro' )?>
|
305 |
<select id="period" name="period">
|
306 |
+
<option value="daily" <?php selected($period, "daily");?>><?php _e('Daily', 'paid-memberships-pro' );?></option>
|
307 |
+
<option value="monthly" <?php selected($period, "monthly");?>><?php _e('Monthly', 'paid-memberships-pro' );?></option>
|
308 |
+
<option value="annual" <?php selected($period, "annual");?>><?php _e('Annual', 'paid-memberships-pro' );?></option>
|
309 |
</select>
|
310 |
<select id="type" name="type">
|
311 |
+
<option value="signup_v_all" <?php selected($type, "signup_v_all");?>><?php _e('Signups vs. All Cancellations', 'paid-memberships-pro' );?></option>
|
312 |
+
<option value="signup_v_cancel" <?php selected($type, "signup_v_cancel");?>><?php _e('Signups vs. Cancellations', 'paid-memberships-pro' );?></option>
|
313 |
+
<option value="signup_v_expiration" <?php selected($type, "signup_v_expiration");?>><?php _e('Signups vs. Expirations', 'paid-memberships-pro' );?></option>
|
314 |
<?php /*
|
315 |
+
<option value="mrr_ltv" <?php selected($type, "mrr_ltv");?>><?php _e('MRR & LTV', 'paid-memberships-pro' );?></option>
|
316 |
*/ ?>
|
317 |
</select>
|
318 |
+
<span id="for"><?php _e('for', 'paid-memberships-pro' )?></span>
|
319 |
<select id="month" name="month">
|
320 |
<?php for($i = 1; $i < 13; $i++) { ?>
|
321 |
<option value="<?php echo $i;?>" <?php selected($month, $i);?>><?php echo date_i18n("F", mktime(0, 0, 0, $i, 2));?></option>
|
326 |
<option value="<?php echo $i;?>" <?php selected($year, $i);?>><?php echo $i;?></option>
|
327 |
<?php } ?>
|
328 |
</select>
|
329 |
+
<span id="for"><?php _e('for', 'paid-memberships-pro' )?></span>
|
330 |
<select name="level">
|
331 |
+
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'paid-memberships-pro' );?></option>
|
332 |
<?php
|
333 |
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
334 |
foreach($levels as $level)
|
342 |
|
343 |
<input type="hidden" name="page" value="pmpro-reports" />
|
344 |
<input type="hidden" name="report" value="memberships" />
|
345 |
+
<input type="submit" class="button" value="<?php _e('Generate Report', 'paid-memberships-pro' );?>" />
|
346 |
</li>
|
347 |
</ul>
|
348 |
|
adminpages/reports/sales.php
CHANGED
@@ -15,9 +15,9 @@
|
|
15 |
global $pmpro_reports;
|
16 |
$gateway_environment = pmpro_getOption("gateway_environment");
|
17 |
if($gateway_environment == "sandbox")
|
18 |
-
$pmpro_reports['sales'] = __('Sales and Revenue (Testing/Sandbox)', '
|
19 |
else
|
20 |
-
$pmpro_reports['sales'] = __('Sales and Revenue', '
|
21 |
|
22 |
//queue Google Visualization JS on report page
|
23 |
function pmpro_report_sales_init()
|
@@ -42,28 +42,28 @@ function pmpro_report_sales_widget()
|
|
42 |
<thead>
|
43 |
<tr>
|
44 |
<th scope="col"> </th>
|
45 |
-
<th scope="col"><?php _e('Sales','
|
46 |
-
<th scope="col"><?php _e('Revenue','
|
47 |
</tr>
|
48 |
</thead>
|
49 |
<tbody>
|
50 |
<tr>
|
51 |
-
<th scope="row"><?php _e('Today','
|
52 |
<td><?php echo number_format_i18n(pmpro_getSales("today")); ?></td>
|
53 |
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("today"));?></td>
|
54 |
</tr>
|
55 |
<tr>
|
56 |
-
<th scope="row"><?php _e('This Month','
|
57 |
<td><?php echo number_format_i18n(pmpro_getSales("this month")); ?></td>
|
58 |
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("this month"));?></td>
|
59 |
</tr>
|
60 |
<tr>
|
61 |
-
<th scope="row"><?php _e('This Year','
|
62 |
<td><?php echo number_format_i18n(pmpro_getSales("this year")); ?></td>
|
63 |
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("this year"));?></td>
|
64 |
</tr>
|
65 |
<tr>
|
66 |
-
<th scope="row"><?php _e('All Time','
|
67 |
<td><?php echo number_format_i18n(pmpro_getSales("all time")); ?></td>
|
68 |
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("all time"));?></td>
|
69 |
</tr>
|
@@ -195,21 +195,21 @@ function pmpro_report_sales_page()
|
|
195 |
?>
|
196 |
<form id="posts-filter" method="get" action="">
|
197 |
<h1>
|
198 |
-
<?php _e('Sales and Revenue', '
|
199 |
</h1>
|
200 |
|
201 |
<div class="tablenav top">
|
202 |
-
<?php _e('Show', '
|
203 |
<select id="period" name="period">
|
204 |
-
<option value="daily" <?php selected($period, "daily");?>><?php _e('Daily', '
|
205 |
-
<option value="monthly" <?php selected($period, "monthly");?>><?php _e('Monthly', '
|
206 |
-
<option value="annual" <?php selected($period, "annual");?>><?php _e('Annual', '
|
207 |
</select>
|
208 |
<select name="type">
|
209 |
-
<option value="revenue" <?php selected($type, "revenue");?>><?php _e('Revenue', '
|
210 |
-
<option value="sales" <?php selected($type, "sales");?>><?php _e('Sales', '
|
211 |
</select>
|
212 |
-
<span id="for"><?php _e('for', '
|
213 |
<select id="month" name="month">
|
214 |
<?php for($i = 1; $i < 13; $i++) { ?>
|
215 |
<option value="<?php echo $i;?>" <?php selected($month, $i);?>><?php echo date_i18n("F", mktime(0, 0, 0, $i, 2));?></option>
|
@@ -220,9 +220,9 @@ function pmpro_report_sales_page()
|
|
220 |
<option value="<?php echo $i;?>" <?php selected($year, $i);?>><?php echo $i;?></option>
|
221 |
<?php } ?>
|
222 |
</select>
|
223 |
-
<span id="for"><?php _e('for', '
|
224 |
<select name="level">
|
225 |
-
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', '
|
226 |
<?php
|
227 |
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
228 |
foreach($levels as $level)
|
@@ -236,7 +236,7 @@ function pmpro_report_sales_page()
|
|
236 |
|
237 |
<input type="hidden" name="page" value="pmpro-reports" />
|
238 |
<input type="hidden" name="report" value="sales" />
|
239 |
-
<input type="submit" class="button action" value="<?php _e('Generate Report', '
|
240 |
</div>
|
241 |
|
242 |
<div id="chart_div" style="clear: both; width: 100%; height: 500px;"></div>
|
15 |
global $pmpro_reports;
|
16 |
$gateway_environment = pmpro_getOption("gateway_environment");
|
17 |
if($gateway_environment == "sandbox")
|
18 |
+
$pmpro_reports['sales'] = __('Sales and Revenue (Testing/Sandbox)', 'paid-memberships-pro' );
|
19 |
else
|
20 |
+
$pmpro_reports['sales'] = __('Sales and Revenue', 'paid-memberships-pro' );
|
21 |
|
22 |
//queue Google Visualization JS on report page
|
23 |
function pmpro_report_sales_init()
|
42 |
<thead>
|
43 |
<tr>
|
44 |
<th scope="col"> </th>
|
45 |
+
<th scope="col"><?php _e('Sales', 'paid-memberships-pro' ); ?></th>
|
46 |
+
<th scope="col"><?php _e('Revenue', 'paid-memberships-pro' ); ?></th>
|
47 |
</tr>
|
48 |
</thead>
|
49 |
<tbody>
|
50 |
<tr>
|
51 |
+
<th scope="row"><?php _e('Today', 'paid-memberships-pro' ); ?></th>
|
52 |
<td><?php echo number_format_i18n(pmpro_getSales("today")); ?></td>
|
53 |
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("today"));?></td>
|
54 |
</tr>
|
55 |
<tr>
|
56 |
+
<th scope="row"><?php _e('This Month', 'paid-memberships-pro' ); ?></th>
|
57 |
<td><?php echo number_format_i18n(pmpro_getSales("this month")); ?></td>
|
58 |
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("this month"));?></td>
|
59 |
</tr>
|
60 |
<tr>
|
61 |
+
<th scope="row"><?php _e('This Year', 'paid-memberships-pro' ); ?></th>
|
62 |
<td><?php echo number_format_i18n(pmpro_getSales("this year")); ?></td>
|
63 |
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("this year"));?></td>
|
64 |
</tr>
|
65 |
<tr>
|
66 |
+
<th scope="row"><?php _e('All Time', 'paid-memberships-pro' ); ?></th>
|
67 |
<td><?php echo number_format_i18n(pmpro_getSales("all time")); ?></td>
|
68 |
<td><?php echo pmpro_formatPrice(pmpro_getRevenue("all time"));?></td>
|
69 |
</tr>
|
195 |
?>
|
196 |
<form id="posts-filter" method="get" action="">
|
197 |
<h1>
|
198 |
+
<?php _e('Sales and Revenue', 'paid-memberships-pro' );?>
|
199 |
</h1>
|
200 |
|
201 |
<div class="tablenav top">
|
202 |
+
<?php _e('Show', 'paid-memberships-pro' )?>
|
203 |
<select id="period" name="period">
|
204 |
+
<option value="daily" <?php selected($period, "daily");?>><?php _e('Daily', 'paid-memberships-pro' );?></option>
|
205 |
+
<option value="monthly" <?php selected($period, "monthly");?>><?php _e('Monthly', 'paid-memberships-pro' );?></option>
|
206 |
+
<option value="annual" <?php selected($period, "annual");?>><?php _e('Annual', 'paid-memberships-pro' );?></option>
|
207 |
</select>
|
208 |
<select name="type">
|
209 |
+
<option value="revenue" <?php selected($type, "revenue");?>><?php _e('Revenue', 'paid-memberships-pro' );?></option>
|
210 |
+
<option value="sales" <?php selected($type, "sales");?>><?php _e('Sales', 'paid-memberships-pro' );?></option>
|
211 |
</select>
|
212 |
+
<span id="for"><?php _e('for', 'paid-memberships-pro' )?></span>
|
213 |
<select id="month" name="month">
|
214 |
<?php for($i = 1; $i < 13; $i++) { ?>
|
215 |
<option value="<?php echo $i;?>" <?php selected($month, $i);?>><?php echo date_i18n("F", mktime(0, 0, 0, $i, 2));?></option>
|
220 |
<option value="<?php echo $i;?>" <?php selected($year, $i);?>><?php echo $i;?></option>
|
221 |
<?php } ?>
|
222 |
</select>
|
223 |
+
<span id="for"><?php _e('for', 'paid-memberships-pro' )?></span>
|
224 |
<select name="level">
|
225 |
+
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'paid-memberships-pro' );?></option>
|
226 |
<?php
|
227 |
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
228 |
foreach($levels as $level)
|
236 |
|
237 |
<input type="hidden" name="page" value="pmpro-reports" />
|
238 |
<input type="hidden" name="report" value="sales" />
|
239 |
+
<input type="submit" class="button action" value="<?php _e('Generate Report', 'paid-memberships-pro' );?>" />
|
240 |
</div>
|
241 |
|
242 |
<div id="chart_div" style="clear: both; width: 100%; height: 500px;"></div>
|
adminpages/templates/orders-email.php
CHANGED
@@ -11,17 +11,17 @@
|
|
11 |
<td rowspan="2" style="width:80%;">
|
12 |
<h2><?php bloginfo( 'sitename' ); ?></h2>
|
13 |
</td>
|
14 |
-
<td><?php echo __('Invoice #: ', '
|
15 |
</tr>
|
16 |
<tr>
|
17 |
<td>
|
18 |
-
<?php echo __( 'Date:', '
|
19 |
</td>
|
20 |
</tr>
|
21 |
<?php if(!empty($order->billing->name)): ?>
|
22 |
<tr>
|
23 |
<td>
|
24 |
-
<strong><?php _e( 'Bill to:', '
|
25 |
<?php
|
26 |
echo pmpro_formatAddress(
|
27 |
$order->billing->name,
|
@@ -43,9 +43,9 @@
|
|
43 |
<td colspan="2">
|
44 |
<table style="width:100%;border-width:1px;border-style:solid;border-collapse:collapse;">
|
45 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
46 |
-
<th style="text-align:center;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('ID', '
|
47 |
-
<th style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Item', '
|
48 |
-
<th style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Price', '
|
49 |
</tr>
|
50 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
51 |
<td style="text-align:center;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $level->id; ?></td>
|
@@ -53,19 +53,19 @@
|
|
53 |
<td style="text-align:right;"><?php echo $order->subtotal; ?></td>
|
54 |
</tr>
|
55 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
56 |
-
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Subtotal', '
|
57 |
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $order->subtotal; ?></td>
|
58 |
</tr>
|
59 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
60 |
-
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Tax', '
|
61 |
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $order->tax; ?></td>
|
62 |
</tr>
|
63 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
64 |
-
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Total', '
|
65 |
<th style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo pmpro_formatPrice($order->total); ?></th>
|
66 |
</tr>
|
67 |
</table>
|
68 |
</td>
|
69 |
</tr>
|
70 |
</tbody>
|
71 |
-
</table>
|
11 |
<td rowspan="2" style="width:80%;">
|
12 |
<h2><?php bloginfo( 'sitename' ); ?></h2>
|
13 |
</td>
|
14 |
+
<td><?php echo __('Invoice #: ', 'paid-memberships-pro' ) . ' ' . $order->code; ?></td>
|
15 |
</tr>
|
16 |
<tr>
|
17 |
<td>
|
18 |
+
<?php echo __( 'Date:', 'paid-memberships-pro' ) . ' ' . date_i18n( 'Y-m-d', $order->timestamp ) ?>
|
19 |
</td>
|
20 |
</tr>
|
21 |
<?php if(!empty($order->billing->name)): ?>
|
22 |
<tr>
|
23 |
<td>
|
24 |
+
<strong><?php _e( 'Bill to:', 'paid-memberships-pro' ); ?></strong><br>
|
25 |
<?php
|
26 |
echo pmpro_formatAddress(
|
27 |
$order->billing->name,
|
43 |
<td colspan="2">
|
44 |
<table style="width:100%;border-width:1px;border-style:solid;border-collapse:collapse;">
|
45 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
46 |
+
<th style="text-align:center;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('ID', 'paid-memberships-pro' ); ?></th>
|
47 |
+
<th style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Item', 'paid-memberships-pro' ); ?></th>
|
48 |
+
<th style="border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Price', 'paid-memberships-pro' ); ?></th>
|
49 |
</tr>
|
50 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
51 |
<td style="text-align:center;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $level->id; ?></td>
|
53 |
<td style="text-align:right;"><?php echo $order->subtotal; ?></td>
|
54 |
</tr>
|
55 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
56 |
+
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Subtotal', 'paid-memberships-pro' ); ?></th>
|
57 |
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $order->subtotal; ?></td>
|
58 |
</tr>
|
59 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
60 |
+
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Tax', 'paid-memberships-pro' ); ?></th>
|
61 |
<td style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo $order->tax; ?></td>
|
62 |
</tr>
|
63 |
<tr style="border-width:1px;border-style:solid;border-collapse:collapse;">
|
64 |
+
<th colspan="2" style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php _e('Total', 'paid-memberships-pro' ); ?></th>
|
65 |
<th style="text-align:right;border-width:1px;border-style:solid;border-collapse:collapse;"><?php echo pmpro_formatPrice($order->total); ?></th>
|
66 |
</tr>
|
67 |
</table>
|
68 |
</td>
|
69 |
</tr>
|
70 |
</tbody>
|
71 |
+
</table>
|
adminpages/templates/orders-print.php
CHANGED
@@ -47,11 +47,11 @@
|
|
47 |
<div class="right">
|
48 |
<table>
|
49 |
<tr>
|
50 |
-
<td><?php echo __('Invoice #: ', '
|
51 |
</tr>
|
52 |
<tr>
|
53 |
<td>
|
54 |
-
<?php echo __( 'Date:', '
|
55 |
</td>
|
56 |
</tr>
|
57 |
</table>
|
@@ -72,9 +72,9 @@
|
|
72 |
</p>
|
73 |
<table class="invoice">
|
74 |
<tr>
|
75 |
-
<th><?php _e('ID', '
|
76 |
-
<th><?php _e('Item', '
|
77 |
-
<th><?php _e('Price', '
|
78 |
</tr>
|
79 |
<tr>
|
80 |
<td class="aligncenter"><?php echo $level->id; ?></td>
|
@@ -82,18 +82,18 @@
|
|
82 |
<td class="alignright"><?php echo $order->subtotal; ?></td>
|
83 |
</tr>
|
84 |
<tr>
|
85 |
-
<th colspan="2" class="alignright"><?php _e('Subtotal', '
|
86 |
<td class="alignright"><?php echo $order->subtotal; ?></td>
|
87 |
</tr>
|
88 |
<tr>
|
89 |
-
<th colspan="2" class="alignright"><?php _e('Tax', '
|
90 |
<td class="alignright"><?php echo $order->tax; ?></td>
|
91 |
</tr>
|
92 |
<tr>
|
93 |
-
<th colspan="2" class="alignright"><?php _e('Total', '
|
94 |
<th class="alignright"><?php echo pmpro_formatPrice( $order->total ); ?></th>
|
95 |
</tr>
|
96 |
</table>
|
97 |
</main>
|
98 |
</body>
|
99 |
-
</html>
|
47 |
<div class="right">
|
48 |
<table>
|
49 |
<tr>
|
50 |
+
<td><?php echo __('Invoice #: ', 'paid-memberships-pro' ) . ' ' . $order->code; ?></td>
|
51 |
</tr>
|
52 |
<tr>
|
53 |
<td>
|
54 |
+
<?php echo __( 'Date:', 'paid-memberships-pro' ) . ' ' . date_i18n( 'Y-m-d', $order->timestamp ) ?>
|
55 |
</td>
|
56 |
</tr>
|
57 |
</table>
|
72 |
</p>
|
73 |
<table class="invoice">
|
74 |
<tr>
|
75 |
+
<th><?php _e('ID', 'paid-memberships-pro' ); ?></th>
|
76 |
+
<th><?php _e('Item', 'paid-memberships-pro' ); ?></th>
|
77 |
+
<th><?php _e('Price', 'paid-memberships-pro' ); ?></th>
|
78 |
</tr>
|
79 |
<tr>
|
80 |
<td class="aligncenter"><?php echo $level->id; ?></td>
|
82 |
<td class="alignright"><?php echo $order->subtotal; ?></td>
|
83 |
</tr>
|
84 |
<tr>
|
85 |
+
<th colspan="2" class="alignright"><?php _e('Subtotal', 'paid-memberships-pro' ); ?></th>
|
86 |
<td class="alignright"><?php echo $order->subtotal; ?></td>
|
87 |
</tr>
|
88 |
<tr>
|
89 |
+
<th colspan="2" class="alignright"><?php _e('Tax', 'paid-memberships-pro' ); ?></th>
|
90 |
<td class="alignright"><?php echo $order->tax; ?></td>
|
91 |
</tr>
|
92 |
<tr>
|
93 |
+
<th colspan="2" class="alignright"><?php _e('Total', 'paid-memberships-pro' ); ?></th>
|
94 |
<th class="alignright"><?php echo pmpro_formatPrice( $order->total ); ?></th>
|
95 |
</tr>
|
96 |
</table>
|
97 |
</main>
|
98 |
</body>
|
99 |
+
</html>
|
adminpages/updates.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_updates")))
|
4 |
{
|
5 |
-
die(__("You do not have permissions to perform this action.",
|
6 |
}
|
7 |
|
8 |
//reset this transient so we know the page was just loaded
|
@@ -11,14 +11,14 @@
|
|
11 |
require_once(dirname(__FILE__) . "/admin_header.php");
|
12 |
?>
|
13 |
|
14 |
-
<h2><?php _e('Updating Paid Memberships Pro', '
|
15 |
|
16 |
<?php
|
17 |
$updates = get_option('pmpro_updates', array());
|
18 |
if(!empty($updates)) {
|
19 |
//let's process the first one
|
20 |
?>
|
21 |
-
<p id="pmpro_updates_intro"><?php _e('Updates are processing. This may take a few minutes to complete.', '
|
22 |
<p id="pmpro_updates_progress">[...]</p>
|
23 |
<textarea id="pmpro_updates_status" rows="10" cols="60">Loading...</textarea>
|
24 |
|
@@ -30,4 +30,4 @@
|
|
30 |
|
31 |
<?php
|
32 |
require_once(dirname(__FILE__) . "/admin_footer.php");
|
33 |
-
?>
|
2 |
//only admins can get this
|
3 |
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_updates")))
|
4 |
{
|
5 |
+
die(__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
|
6 |
}
|
7 |
|
8 |
//reset this transient so we know the page was just loaded
|
11 |
require_once(dirname(__FILE__) . "/admin_header.php");
|
12 |
?>
|
13 |
|
14 |
+
<h2><?php _e('Updating Paid Memberships Pro', 'paid-memberships-pro' );?></h2>
|
15 |
|
16 |
<?php
|
17 |
$updates = get_option('pmpro_updates', array());
|
18 |
if(!empty($updates)) {
|
19 |
//let's process the first one
|
20 |
?>
|
21 |
+
<p id="pmpro_updates_intro"><?php _e('Updates are processing. This may take a few minutes to complete.', 'paid-memberships-pro' );?></p>
|
22 |
<p id="pmpro_updates_progress">[...]</p>
|
23 |
<textarea id="pmpro_updates_status" rows="10" cols="60">Loading...</textarea>
|
24 |
|
30 |
|
31 |
<?php
|
32 |
require_once(dirname(__FILE__) . "/admin_footer.php");
|
33 |
+
?>
|
classes/class.memberorder.php
CHANGED
@@ -212,7 +212,7 @@
|
|
212 |
|
213 |
if(!empty($membership_id))
|
214 |
$this->sqlQuery .= "AND membership_id = '" . $membership_id . "' ";
|
215 |
-
|
216 |
if(!empty($gateway))
|
217 |
$this->sqlQuery .= "AND gateway = '" . esc_sql($gateway) . "' ";
|
218 |
|
@@ -527,7 +527,7 @@
|
|
527 |
|
528 |
if(empty($this->notes))
|
529 |
$this->notes = "";
|
530 |
-
|
531 |
if(empty($this->checkout_id) || intval($this->checkout_id)<1) {
|
532 |
$highestval = $wpdb->get_var("SELECT MAX(checkout_id) FROM $wpdb->pmpro_membership_orders");
|
533 |
$this->checkout_id = intval($highestval)+1;
|
@@ -680,7 +680,9 @@
|
|
680 |
*/
|
681 |
function process()
|
682 |
{
|
683 |
-
|
|
|
|
|
684 |
}
|
685 |
|
686 |
/**
|
@@ -690,7 +692,9 @@
|
|
690 |
*/
|
691 |
function confirm()
|
692 |
{
|
693 |
-
|
|
|
|
|
694 |
}
|
695 |
|
696 |
/**
|
@@ -708,7 +712,12 @@
|
|
708 |
else
|
709 |
{
|
710 |
//cancel the gateway subscription first
|
711 |
-
|
|
|
|
|
|
|
|
|
|
|
712 |
if($result == false)
|
713 |
{
|
714 |
//there was an error, but cancel the order no matter what
|
@@ -717,7 +726,7 @@
|
|
717 |
//we should probably notify the admin
|
718 |
$pmproemail = new PMProEmail();
|
719 |
$pmproemail->template = "subscription_cancel_error";
|
720 |
-
$pmproemail->data = array("body"=>"<p>" . sprintf(__("There was an error canceling the subscription for user with ID=%s. You will want to check your payment gateway to see if their subscription is still active.",
|
721 |
$pmproemail->data["body"] .= "<p>Associated Order:<br />" . nl2br(var_export($this, true)) . "</p>";
|
722 |
$pmproemail->sendEmail(get_bloginfo("admin_email"));
|
723 |
|
@@ -726,12 +735,12 @@
|
|
726 |
else
|
727 |
{
|
728 |
//Note: status would have been set to cancelled by the gateway class. So we don't have to update it here.
|
729 |
-
|
730 |
//remove billing numbers in pmpro_memberships_users if the membership is still active
|
731 |
global $wpdb;
|
732 |
$sqlQuery = "UPDATE $wpdb->pmpro_memberships_users SET initial_payment = 0, billing_amount = 0, cycle_number = 0 WHERE user_id = '" . $this->user_id . "' AND membership_id = '" . $this->membership_id . "' AND status = 'active'";
|
733 |
$wpdb->query($sqlQuery);
|
734 |
-
|
735 |
return $result;
|
736 |
}
|
737 |
}
|
@@ -742,7 +751,9 @@
|
|
742 |
*/
|
743 |
function updateBilling()
|
744 |
{
|
745 |
-
|
|
|
|
|
746 |
}
|
747 |
|
748 |
/**
|
@@ -750,7 +761,9 @@
|
|
750 |
*/
|
751 |
function getGatewaySubscriptionStatus()
|
752 |
{
|
753 |
-
|
|
|
|
|
754 |
}
|
755 |
|
756 |
/**
|
@@ -758,7 +771,9 @@
|
|
758 |
*/
|
759 |
function getGatewayTransactionStatus()
|
760 |
{
|
761 |
-
|
|
|
|
|
762 |
}
|
763 |
|
764 |
/**
|
212 |
|
213 |
if(!empty($membership_id))
|
214 |
$this->sqlQuery .= "AND membership_id = '" . $membership_id . "' ";
|
215 |
+
|
216 |
if(!empty($gateway))
|
217 |
$this->sqlQuery .= "AND gateway = '" . esc_sql($gateway) . "' ";
|
218 |
|
527 |
|
528 |
if(empty($this->notes))
|
529 |
$this->notes = "";
|
530 |
+
|
531 |
if(empty($this->checkout_id) || intval($this->checkout_id)<1) {
|
532 |
$highestval = $wpdb->get_var("SELECT MAX(checkout_id) FROM $wpdb->pmpro_membership_orders");
|
533 |
$this->checkout_id = intval($highestval)+1;
|
680 |
*/
|
681 |
function process()
|
682 |
{
|
683 |
+
if (is_object($this->Gateway)) {
|
684 |
+
return $this->Gateway->process($this);
|
685 |
+
}
|
686 |
}
|
687 |
|
688 |
/**
|
692 |
*/
|
693 |
function confirm()
|
694 |
{
|
695 |
+
if (is_object($this->Gateway)) {
|
696 |
+
return $this->Gateway->confirm($this);
|
697 |
+
}
|
698 |
}
|
699 |
|
700 |
/**
|
712 |
else
|
713 |
{
|
714 |
//cancel the gateway subscription first
|
715 |
+
if (is_object($this->Gateway)) {
|
716 |
+
$result = $this->Gateway->cancel( $this );
|
717 |
+
} else {
|
718 |
+
$result = false;
|
719 |
+
}
|
720 |
+
|
721 |
if($result == false)
|
722 |
{
|
723 |
//there was an error, but cancel the order no matter what
|
726 |
//we should probably notify the admin
|
727 |
$pmproemail = new PMProEmail();
|
728 |
$pmproemail->template = "subscription_cancel_error";
|
729 |
+
$pmproemail->data = array("body"=>"<p>" . sprintf(__("There was an error canceling the subscription for user with ID=%s. You will want to check your payment gateway to see if their subscription is still active.", 'paid-memberships-pro' ), strval($this->user_id)) . "</p><p>Error: " . $this->error . "</p>");
|
730 |
$pmproemail->data["body"] .= "<p>Associated Order:<br />" . nl2br(var_export($this, true)) . "</p>";
|
731 |
$pmproemail->sendEmail(get_bloginfo("admin_email"));
|
732 |
|
735 |
else
|
736 |
{
|
737 |
//Note: status would have been set to cancelled by the gateway class. So we don't have to update it here.
|
738 |
+
|
739 |
//remove billing numbers in pmpro_memberships_users if the membership is still active
|
740 |
global $wpdb;
|
741 |
$sqlQuery = "UPDATE $wpdb->pmpro_memberships_users SET initial_payment = 0, billing_amount = 0, cycle_number = 0 WHERE user_id = '" . $this->user_id . "' AND membership_id = '" . $this->membership_id . "' AND status = 'active'";
|
742 |
$wpdb->query($sqlQuery);
|
743 |
+
|
744 |
return $result;
|
745 |
}
|
746 |
}
|
751 |
*/
|
752 |
function updateBilling()
|
753 |
{
|
754 |
+
if (is_object($this->Gateway)) {
|
755 |
+
return $this->Gateway->update( $this );
|
756 |
+
}
|
757 |
}
|
758 |
|
759 |
/**
|
761 |
*/
|
762 |
function getGatewaySubscriptionStatus()
|
763 |
{
|
764 |
+
if (is_object($this->Gateway)) {
|
765 |
+
return $this->Gateway->getSubscriptionStatus( $this );
|
766 |
+
}
|
767 |
}
|
768 |
|
769 |
/**
|
771 |
*/
|
772 |
function getGatewayTransactionStatus()
|
773 |
{
|
774 |
+
if (is_object($this->Gateway)) {
|
775 |
+
return $this->Gateway->getTransactionStatus( $this );
|
776 |
+
}
|
777 |
}
|
778 |
|
779 |
/**
|
classes/class.pmproemail.php
CHANGED
@@ -34,7 +34,7 @@
|
|
34 |
$this->fromname = pmpro_getOption("from_name");
|
35 |
|
36 |
if(!$this->subject)
|
37 |
-
$this->subject = sprintf(__("An Email From %s",
|
38 |
|
39 |
//decode the subject line in case there are apostrophes/etc in it
|
40 |
$this->subject = html_entity_decode($this->subject, ENT_QUOTES, 'UTF-8');
|
@@ -47,7 +47,7 @@
|
|
47 |
$this->attachments = NULL;
|
48 |
|
49 |
//load the template
|
50 |
-
$locale = apply_filters("plugin_locale", get_locale(), "
|
51 |
|
52 |
if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/email/" . $locale . "/" . $this->template . ".html"))
|
53 |
$this->body = file_get_contents(get_stylesheet_directory() . "/paid-memberships-pro/email/" . $locale . "/" . $this->template . ".html"); //localized email folder in child theme
|
@@ -60,13 +60,15 @@
|
|
60 |
elseif(file_exists(get_template_directory() . "/paid-memberships-pro/email/" . $this->template . ".html"))
|
61 |
$this->body = file_get_contents(get_template_directory() . "/paid-memberships-pro/email/" . $this->template . ".html"); //email folder in parent theme
|
62 |
elseif(file_exists(get_template_directory() . "/membership-email-" . $this->template . ".html"))
|
63 |
-
$this->body = file_get_contents(get_template_directory() . "/membership-email-" . $this->template . ".html"); //membership-email- file in parent theme
|
64 |
elseif(file_exists(WP_LANG_DIR . '/pmpro/email/' . $locale . "/" . $this->template . ".html"))
|
65 |
$this->body = file_get_contents(WP_LANG_DIR . '/pmpro/email/' . $locale . "/" . $this->template . ".html"); //localized email folder in WP language folder
|
66 |
elseif(file_exists(WP_LANG_DIR . '/pmpro/email/' . $this->template . ".html"))
|
67 |
$this->body = file_get_contents(WP_LANG_DIR . '/pmpro/email/' . $this->template . ".html"); //email folder in WP language folder
|
68 |
elseif(file_exists(PMPRO_DIR . "/languages/email/" . $locale . "/" . $this->template . ".html"))
|
69 |
$this->body = file_get_contents(PMPRO_DIR . "/languages/email/" . $locale . "/" . $this->template . ".html"); //email folder in PMPro language folder
|
|
|
|
|
70 |
elseif(file_exists(PMPRO_DIR . "/email/" . $this->template . ".html"))
|
71 |
$this->body = file_get_contents(PMPRO_DIR . "/email/" . $this->template . ".html"); //default template in plugin
|
72 |
elseif(!empty($this->data) && !empty($this->data['body']))
|
@@ -131,8 +133,8 @@
|
|
131 |
return false;
|
132 |
|
133 |
$this->email = $user->user_email;
|
134 |
-
$this->subject = sprintf(__(
|
135 |
-
|
136 |
$this->data = array("name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"));
|
137 |
|
138 |
if(!empty($old_level_id)) {
|
@@ -142,9 +144,10 @@
|
|
142 |
$this->data['membership_level_name'] = pmpro_implodeToEnglish($wpdb->get_col("SELECT name FROM $wpdb->pmpro_membership_levels WHERE id IN('" . implode("','", $old_level_id) . "')"));
|
143 |
} else {
|
144 |
$this->data['membership_id'] = '';
|
145 |
-
$this->data['membership_level_name'] = __('All Levels', '
|
146 |
}
|
147 |
-
|
|
|
148 |
return $this->sendEmail();
|
149 |
}
|
150 |
|
@@ -163,8 +166,8 @@
|
|
163 |
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
164 |
|
165 |
$this->email = get_bloginfo("admin_email");
|
166 |
-
$this->subject = sprintf(__("Membership for %s at %s has been CANCELLED",
|
167 |
-
|
168 |
$this->data = array("user_login" => $user->user_login, "user_email" => $user->user_email, "display_name" => $user->display_name, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url());
|
169 |
|
170 |
if(!empty($old_level_id)) {
|
@@ -186,11 +189,13 @@
|
|
186 |
$this->data['enddate'] = "";
|
187 |
} else {
|
188 |
$this->data['membership_id'] = '';
|
189 |
-
$this->data['membership_level_name'] = __('All Levels', '
|
190 |
$this->data['startdate'] = '';
|
191 |
$this->data['enddate'] = '';
|
192 |
}
|
193 |
-
|
|
|
|
|
194 |
return $this->sendEmail();
|
195 |
}
|
196 |
|
@@ -204,7 +209,7 @@
|
|
204 |
return false;
|
205 |
|
206 |
$this->email = $user->user_email;
|
207 |
-
$this->subject = sprintf(__("Your membership confirmation for %s",
|
208 |
|
209 |
$this->data = array(
|
210 |
"subject" => $this->subject,
|
@@ -233,6 +238,10 @@
|
|
233 |
$this->template = "checkout_trial";
|
234 |
else
|
235 |
$this->template = "checkout_paid";
|
|
|
|
|
|
|
|
|
236 |
$this->data["invoice_id"] = $invoice->code;
|
237 |
$this->data["invoice_total"] = pmpro_formatPrice($invoice->total);
|
238 |
$this->data["invoice_date"] = date_i18n(get_option('date_format'), $invoice->timestamp);
|
@@ -257,7 +266,7 @@
|
|
257 |
$invoice->billing->phone);
|
258 |
|
259 |
if($invoice->getDiscountCode())
|
260 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code",
|
261 |
else
|
262 |
$this->data["discount_code"] = "";
|
263 |
}
|
@@ -266,7 +275,7 @@
|
|
266 |
$this->template = "checkout_free";
|
267 |
global $discount_code;
|
268 |
if(!empty($discount_code))
|
269 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code",
|
270 |
else
|
271 |
$this->data["discount_code"] = "";
|
272 |
}
|
@@ -275,14 +284,14 @@
|
|
275 |
$this->template = "checkout_freetrial";
|
276 |
global $discount_code;
|
277 |
if(!empty($discount_code))
|
278 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code",
|
279 |
else
|
280 |
$this->data["discount_code"] = "";
|
281 |
}
|
282 |
|
283 |
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
|
284 |
if($enddate)
|
285 |
-
$this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.",
|
286 |
else
|
287 |
$this->data["membership_expiration"] = "";
|
288 |
|
@@ -304,7 +313,7 @@
|
|
304 |
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
305 |
|
306 |
$this->email = get_bloginfo("admin_email");
|
307 |
-
$this->subject = sprintf(__("Member Checkout for %s at %s",
|
308 |
|
309 |
$this->data = array(
|
310 |
"subject" => $this->subject,
|
@@ -330,6 +339,9 @@
|
|
330 |
$this->template = "checkout_trial_admin";
|
331 |
else
|
332 |
$this->template = "checkout_paid_admin";
|
|
|
|
|
|
|
333 |
$this->data["invoice_id"] = $invoice->code;
|
334 |
$this->data["invoice_total"] = pmpro_formatPrice($invoice->total);
|
335 |
$this->data["invoice_date"] = date_i18n(get_option('date_format'), $invoice->timestamp);
|
@@ -354,7 +366,7 @@
|
|
354 |
$invoice->billing->phone);
|
355 |
|
356 |
if($invoice->getDiscountCode())
|
357 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code",
|
358 |
else
|
359 |
$this->data["discount_code"] = "";
|
360 |
}
|
@@ -363,7 +375,7 @@
|
|
363 |
$this->template = "checkout_free_admin";
|
364 |
global $discount_code;
|
365 |
if(!empty($discount_code))
|
366 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code",
|
367 |
else
|
368 |
$this->data["discount_code"] = "";
|
369 |
}
|
@@ -375,7 +387,7 @@
|
|
375 |
|
376 |
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
|
377 |
if($enddate)
|
378 |
-
$this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.",
|
379 |
else
|
380 |
$this->data["membership_expiration"] = "";
|
381 |
|
@@ -392,9 +404,8 @@
|
|
392 |
return false;
|
393 |
|
394 |
$this->email = $user->user_email;
|
395 |
-
$this->subject = sprintf(__("Your billing information has been updated at %s", "
|
396 |
-
|
397 |
-
|
398 |
$this->data = array(
|
399 |
"subject" => $this->subject,
|
400 |
"name" => $user->display_name,
|
@@ -426,7 +437,9 @@
|
|
426 |
$invoice->billing->zip,
|
427 |
$invoice->billing->country,
|
428 |
$invoice->billing->phone);
|
429 |
-
|
|
|
|
|
430 |
return $this->sendEmail();
|
431 |
}
|
432 |
|
@@ -445,8 +458,7 @@
|
|
445 |
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
446 |
|
447 |
$this->email = get_bloginfo("admin_email");
|
448 |
-
$this->subject = sprintf(__("Billing information has been updated for %s at %s", "
|
449 |
-
$this->template = "billing_admin";
|
450 |
|
451 |
$this->data = array(
|
452 |
"subject" => $this->subject,
|
@@ -479,7 +491,9 @@
|
|
479 |
$invoice->billing->zip,
|
480 |
$invoice->billing->country,
|
481 |
$invoice->billing->phone);
|
482 |
-
|
|
|
|
|
483 |
return $this->sendEmail();
|
484 |
}
|
485 |
|
@@ -493,8 +507,7 @@
|
|
493 |
return false;
|
494 |
|
495 |
$this->email = $user->user_email;
|
496 |
-
$this->subject = sprintf(__("Membership Payment Failed at %s", "
|
497 |
-
$this->template = "billing_failure";
|
498 |
|
499 |
$this->data = array(
|
500 |
"subject" => $this->subject,
|
@@ -527,7 +540,9 @@
|
|
527 |
$invoice->billing->zip,
|
528 |
$invoice->billing->country,
|
529 |
$invoice->billing->phone);
|
530 |
-
|
|
|
|
|
531 |
return $this->sendEmail();
|
532 |
}
|
533 |
|
@@ -539,8 +554,7 @@
|
|
539 |
$user = get_userdata($invoice->user_id);
|
540 |
|
541 |
$this->email = $email;
|
542 |
-
$this->subject = sprintf(__("Membership Payment Failed For %s at %s", "
|
543 |
-
$this->template = "billing_failure_admin";
|
544 |
|
545 |
$this->data = array(
|
546 |
"subject" => $this->subject,
|
@@ -572,7 +586,9 @@
|
|
572 |
$invoice->billing->state,
|
573 |
$invoice->billing->zip,
|
574 |
$invoice->billing->country,
|
575 |
-
$invoice->billing->phone);
|
|
|
|
|
576 |
return $this->sendEmail();
|
577 |
}
|
578 |
|
@@ -586,8 +602,7 @@
|
|
586 |
return false;
|
587 |
|
588 |
$this->email = $user->user_email;
|
589 |
-
$this->subject = sprintf(__("Credit Card on File Expiring Soon at %s", "
|
590 |
-
$this->template = "credit_card_expiring";
|
591 |
|
592 |
$this->data = array(
|
593 |
"subject" => $this->subject,
|
@@ -620,7 +635,9 @@
|
|
620 |
$invoice->billing->zip,
|
621 |
$invoice->billing->country,
|
622 |
$invoice->billing->phone);
|
623 |
-
|
|
|
|
|
624 |
return $this->sendEmail();
|
625 |
}
|
626 |
|
@@ -636,9 +653,8 @@
|
|
636 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
637 |
|
638 |
$this->email = $user->user_email;
|
639 |
-
$this->subject = sprintf(__("INVOICE for %s membership", "
|
640 |
-
|
641 |
-
|
642 |
$this->data = array(
|
643 |
"subject" => $this->subject,
|
644 |
"name" => $user->display_name,
|
@@ -675,17 +691,24 @@
|
|
675 |
$invoice->billing->country,
|
676 |
$invoice->billing->phone);
|
677 |
|
678 |
-
if($invoice->getDiscountCode())
|
679 |
-
|
680 |
-
|
|
|
|
|
|
|
681 |
$this->data["discount_code"] = "";
|
|
|
682 |
|
683 |
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
|
684 |
if($enddate)
|
685 |
-
$this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.",
|
686 |
else
|
687 |
$this->data["membership_expiration"] = "";
|
688 |
-
|
|
|
|
|
|
|
689 |
return $this->sendEmail();
|
690 |
}
|
691 |
|
@@ -707,8 +730,8 @@
|
|
707 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
708 |
|
709 |
$this->email = $user->user_email;
|
710 |
-
$this->subject = sprintf(__("Your trial at %s is ending soon", "
|
711 |
-
|
712 |
$this->data = array(
|
713 |
"subject" => $this->subject,
|
714 |
"name" => $user->display_name,
|
@@ -726,8 +749,10 @@
|
|
726 |
"trial_amount" => pmpro_formatPrice($user->membership_level->trial_amount),
|
727 |
"trial_limit" => $user->membership_level->trial_limit,
|
728 |
"trial_end" => date_i18n(get_option('date_format'), strtotime(date_i18n("m/d/Y", $user->membership_level->startdate) . " + " . $user->membership_level->trial_limit . " " . $user->membership_level->cycle_period), current_time("timestamp"))
|
729 |
-
);
|
730 |
-
|
|
|
|
|
731 |
return $this->sendEmail();
|
732 |
}
|
733 |
|
@@ -741,10 +766,12 @@
|
|
741 |
return false;
|
742 |
|
743 |
$this->email = $user->user_email;
|
744 |
-
$this->subject = sprintf(__("Your membership at %s has ended", "
|
745 |
-
|
746 |
-
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url(), "display_name" => $user->display_name, "user_email" => $user->user_email, "levels_link" => pmpro_url("levels"));
|
747 |
-
|
|
|
|
|
748 |
return $this->sendEmail();
|
749 |
}
|
750 |
|
@@ -766,10 +793,12 @@
|
|
766 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
767 |
|
768 |
$this->email = $user->user_email;
|
769 |
-
$this->subject = sprintf(__("Your membership at %s will end soon", "
|
770 |
-
|
771 |
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "membership_id" => $user->membership_level->id, "membership_level_name" => $user->membership_level->name, "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url(), "enddate" => date_i18n(get_option('date_format'), $user->membership_level->enddate), "display_name" => $user->display_name, "user_email" => $user->user_email);
|
772 |
-
|
|
|
|
|
773 |
return $this->sendEmail();
|
774 |
}
|
775 |
|
@@ -786,22 +815,26 @@
|
|
786 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID, true);
|
787 |
|
788 |
$this->email = $user->user_email;
|
789 |
-
$this->subject = sprintf(__("Your membership at %s has been changed", "
|
790 |
-
|
791 |
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "membership_id" => $user->membership_level->id, "membership_level_name" => $user->membership_level->name, "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url());
|
|
|
792 |
if($user->membership_level->ID)
|
793 |
-
$this->data["membership_change"] = sprintf(__("The new level is %s",
|
794 |
else
|
795 |
-
$this->data["membership_change"] = __("Your membership has been cancelled", "
|
|
|
796 |
if(!empty($user->membership_level->enddate))
|
797 |
{
|
798 |
-
$this->data["membership_change"] .= ". " . sprintf(__("This membership will expire on %s",
|
799 |
}
|
800 |
elseif(!empty($this->expiration_changed))
|
801 |
{
|
802 |
-
$this->data["membership_change"] .= ". " . __("This membership does not expire",
|
803 |
}
|
804 |
-
|
|
|
|
|
805 |
return $this->sendEmail();
|
806 |
}
|
807 |
|
@@ -823,23 +856,25 @@
|
|
823 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID, true);
|
824 |
|
825 |
$this->email = get_bloginfo("admin_email");
|
826 |
-
$this->subject = sprintf(__("Membership for %s at %s has been changed", "
|
827 |
-
|
828 |
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "membership_level_name" => $user->membership_level->name, "siteemail" => get_bloginfo("admin_email"), "login_link" => wp_login_url());
|
829 |
if($user->membership_level->ID)
|
830 |
-
$this->data["membership_change"] = sprintf(__("The new level is %s",
|
831 |
else
|
832 |
-
$this->data["membership_change"] = __("Membership has been cancelled",
|
833 |
|
834 |
if(!empty($user->membership_level->enddate))
|
835 |
{
|
836 |
-
$this->data["membership_change"] .= ". " . sprintf(__("This membership will expire on %s",
|
837 |
}
|
838 |
elseif(!empty($this->expiration_changed))
|
839 |
{
|
840 |
-
$this->data["membership_change"] .= ". " . __("This membership does not expire",
|
841 |
}
|
842 |
-
|
|
|
|
|
843 |
return $this->sendEmail();
|
844 |
}
|
845 |
|
@@ -866,8 +901,7 @@
|
|
866 |
$level = pmpro_getLevel($order->membership_id);
|
867 |
|
868 |
$this->email = $user->user_email;
|
869 |
-
$this->subject = __('Invoice for Order #: ', '
|
870 |
-
$this->template = "billable_invoice";
|
871 |
|
872 |
// Load invoice template
|
873 |
if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/pages/orders-email.php' ) ) {
|
@@ -891,6 +925,37 @@
|
|
891 |
'invoice' => $invoice
|
892 |
);
|
893 |
|
|
|
|
|
894 |
return $this->sendEmail();
|
895 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
896 |
}
|
34 |
$this->fromname = pmpro_getOption("from_name");
|
35 |
|
36 |
if(!$this->subject)
|
37 |
+
$this->subject = sprintf(__("An Email From %s", 'paid-memberships-pro' ), get_option("blogname"));
|
38 |
|
39 |
//decode the subject line in case there are apostrophes/etc in it
|
40 |
$this->subject = html_entity_decode($this->subject, ENT_QUOTES, 'UTF-8');
|
47 |
$this->attachments = NULL;
|
48 |
|
49 |
//load the template
|
50 |
+
$locale = apply_filters("plugin_locale", get_locale(), "paid-memberships-pro");
|
51 |
|
52 |
if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/email/" . $locale . "/" . $this->template . ".html"))
|
53 |
$this->body = file_get_contents(get_stylesheet_directory() . "/paid-memberships-pro/email/" . $locale . "/" . $this->template . ".html"); //localized email folder in child theme
|
60 |
elseif(file_exists(get_template_directory() . "/paid-memberships-pro/email/" . $this->template . ".html"))
|
61 |
$this->body = file_get_contents(get_template_directory() . "/paid-memberships-pro/email/" . $this->template . ".html"); //email folder in parent theme
|
62 |
elseif(file_exists(get_template_directory() . "/membership-email-" . $this->template . ".html"))
|
63 |
+
$this->body = file_get_contents(get_template_directory() . "/membership-email-" . $this->template . ".html"); //membership-email- file in parent theme
|
64 |
elseif(file_exists(WP_LANG_DIR . '/pmpro/email/' . $locale . "/" . $this->template . ".html"))
|
65 |
$this->body = file_get_contents(WP_LANG_DIR . '/pmpro/email/' . $locale . "/" . $this->template . ".html"); //localized email folder in WP language folder
|
66 |
elseif(file_exists(WP_LANG_DIR . '/pmpro/email/' . $this->template . ".html"))
|
67 |
$this->body = file_get_contents(WP_LANG_DIR . '/pmpro/email/' . $this->template . ".html"); //email folder in WP language folder
|
68 |
elseif(file_exists(PMPRO_DIR . "/languages/email/" . $locale . "/" . $this->template . ".html"))
|
69 |
$this->body = file_get_contents(PMPRO_DIR . "/languages/email/" . $locale . "/" . $this->template . ".html"); //email folder in PMPro language folder
|
70 |
+
elseif($this->getDefaultEmailTemplate($this->template))
|
71 |
+
$this->body = $this->getDefaultEmailTemplate($this->template);
|
72 |
elseif(file_exists(PMPRO_DIR . "/email/" . $this->template . ".html"))
|
73 |
$this->body = file_get_contents(PMPRO_DIR . "/email/" . $this->template . ".html"); //default template in plugin
|
74 |
elseif(!empty($this->data) && !empty($this->data['body']))
|
133 |
return false;
|
134 |
|
135 |
$this->email = $user->user_email;
|
136 |
+
$this->subject = sprintf(__('Your membership at %s has been CANCELLED', 'paid-memberships-pro'), get_option("blogname"));
|
137 |
+
|
138 |
$this->data = array("name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"));
|
139 |
|
140 |
if(!empty($old_level_id)) {
|
144 |
$this->data['membership_level_name'] = pmpro_implodeToEnglish($wpdb->get_col("SELECT name FROM $wpdb->pmpro_membership_levels WHERE id IN('" . implode("','", $old_level_id) . "')"));
|
145 |
} else {
|
146 |
$this->data['membership_id'] = '';
|
147 |
+
$this->data['membership_level_name'] = __('All Levels', 'paid-memberships-pro' );
|
148 |
}
|
149 |
+
|
150 |
+
$this->template = apply_filters("pmpro_email_template", "cancel", $this);
|
151 |
return $this->sendEmail();
|
152 |
}
|
153 |
|
166 |
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
167 |
|
168 |
$this->email = get_bloginfo("admin_email");
|
169 |
+
$this->subject = sprintf(__("Membership for %s at %s has been CANCELLED", 'paid-memberships-pro'), $user->user_login, get_option("blogname"));
|
170 |
+
|
171 |
$this->data = array("user_login" => $user->user_login, "user_email" => $user->user_email, "display_name" => $user->display_name, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url());
|
172 |
|
173 |
if(!empty($old_level_id)) {
|
189 |
$this->data['enddate'] = "";
|
190 |
} else {
|
191 |
$this->data['membership_id'] = '';
|
192 |
+
$this->data['membership_level_name'] = __('All Levels', 'paid-memberships-pro' );
|
193 |
$this->data['startdate'] = '';
|
194 |
$this->data['enddate'] = '';
|
195 |
}
|
196 |
+
|
197 |
+
$this->template = apply_filters("pmpro_email_template", "cancel_admin", $this);
|
198 |
+
|
199 |
return $this->sendEmail();
|
200 |
}
|
201 |
|
209 |
return false;
|
210 |
|
211 |
$this->email = $user->user_email;
|
212 |
+
$this->subject = sprintf(__("Your membership confirmation for %s", 'paid-memberships-pro' ), get_option("blogname"));
|
213 |
|
214 |
$this->data = array(
|
215 |
"subject" => $this->subject,
|
238 |
$this->template = "checkout_trial";
|
239 |
else
|
240 |
$this->template = "checkout_paid";
|
241 |
+
|
242 |
+
//BUG: Didn't apply template filter before it was being used in sendEmail()
|
243 |
+
$this->template = apply_filters("pmpro_email_template", $this->template, $this);
|
244 |
+
|
245 |
$this->data["invoice_id"] = $invoice->code;
|
246 |
$this->data["invoice_total"] = pmpro_formatPrice($invoice->total);
|
247 |
$this->data["invoice_date"] = date_i18n(get_option('date_format'), $invoice->timestamp);
|
266 |
$invoice->billing->phone);
|
267 |
|
268 |
if($invoice->getDiscountCode())
|
269 |
+
$this->data["discount_code"] = "<p>" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $invoice->discount_code->code . "</p>\n";
|
270 |
else
|
271 |
$this->data["discount_code"] = "";
|
272 |
}
|
275 |
$this->template = "checkout_free";
|
276 |
global $discount_code;
|
277 |
if(!empty($discount_code))
|
278 |
+
$this->data["discount_code"] = "<p>" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $discount_code . "</p>\n";
|
279 |
else
|
280 |
$this->data["discount_code"] = "";
|
281 |
}
|
284 |
$this->template = "checkout_freetrial";
|
285 |
global $discount_code;
|
286 |
if(!empty($discount_code))
|
287 |
+
$this->data["discount_code"] = "<p>" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $discount_code . "</p>\n";
|
288 |
else
|
289 |
$this->data["discount_code"] = "";
|
290 |
}
|
291 |
|
292 |
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
|
293 |
if($enddate)
|
294 |
+
$this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "</p>\n";
|
295 |
else
|
296 |
$this->data["membership_expiration"] = "";
|
297 |
|
313 |
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
314 |
|
315 |
$this->email = get_bloginfo("admin_email");
|
316 |
+
$this->subject = sprintf(__("Member Checkout for %s at %s", 'paid-memberships-pro' ), $user->membership_level->name, get_option("blogname"));
|
317 |
|
318 |
$this->data = array(
|
319 |
"subject" => $this->subject,
|
339 |
$this->template = "checkout_trial_admin";
|
340 |
else
|
341 |
$this->template = "checkout_paid_admin";
|
342 |
+
|
343 |
+
$this->template = apply_filters( "pmpro_email_template", $this->template, $this );
|
344 |
+
|
345 |
$this->data["invoice_id"] = $invoice->code;
|
346 |
$this->data["invoice_total"] = pmpro_formatPrice($invoice->total);
|
347 |
$this->data["invoice_date"] = date_i18n(get_option('date_format'), $invoice->timestamp);
|
366 |
$invoice->billing->phone);
|
367 |
|
368 |
if($invoice->getDiscountCode())
|
369 |
+
$this->data["discount_code"] = "<p>" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $invoice->discount_code->code . "</p>\n";
|
370 |
else
|
371 |
$this->data["discount_code"] = "";
|
372 |
}
|
375 |
$this->template = "checkout_free_admin";
|
376 |
global $discount_code;
|
377 |
if(!empty($discount_code))
|
378 |
+
$this->data["discount_code"] = "<p>" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $discount_code . "</p>\n";
|
379 |
else
|
380 |
$this->data["discount_code"] = "";
|
381 |
}
|
387 |
|
388 |
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
|
389 |
if($enddate)
|
390 |
+
$this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "</p>\n";
|
391 |
else
|
392 |
$this->data["membership_expiration"] = "";
|
393 |
|
404 |
return false;
|
405 |
|
406 |
$this->email = $user->user_email;
|
407 |
+
$this->subject = sprintf(__("Your billing information has been updated at %s", "paid-memberships-pro"), get_option("blogname"));
|
408 |
+
|
|
|
409 |
$this->data = array(
|
410 |
"subject" => $this->subject,
|
411 |
"name" => $user->display_name,
|
437 |
$invoice->billing->zip,
|
438 |
$invoice->billing->country,
|
439 |
$invoice->billing->phone);
|
440 |
+
|
441 |
+
$this->template = apply_filters( "pmpro_email_template", "billing", $this );
|
442 |
+
|
443 |
return $this->sendEmail();
|
444 |
}
|
445 |
|
458 |
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
459 |
|
460 |
$this->email = get_bloginfo("admin_email");
|
461 |
+
$this->subject = sprintf(__("Billing information has been updated for %s at %s", "paid-memberships-pro"), $user->user_login, get_option("blogname"));
|
|
|
462 |
|
463 |
$this->data = array(
|
464 |
"subject" => $this->subject,
|
491 |
$invoice->billing->zip,
|
492 |
$invoice->billing->country,
|
493 |
$invoice->billing->phone);
|
494 |
+
|
495 |
+
$this->template = apply_filters( "pmpro_email_template", "billing_admin", $this );
|
496 |
+
|
497 |
return $this->sendEmail();
|
498 |
}
|
499 |
|
507 |
return false;
|
508 |
|
509 |
$this->email = $user->user_email;
|
510 |
+
$this->subject = sprintf(__("Membership Payment Failed at %s", "paid-memberships-pro"), get_option("blogname"));
|
|
|
511 |
|
512 |
$this->data = array(
|
513 |
"subject" => $this->subject,
|
540 |
$invoice->billing->zip,
|
541 |
$invoice->billing->country,
|
542 |
$invoice->billing->phone);
|
543 |
+
|
544 |
+
$this->template = apply_filters("pmpro_email_template", "billing_failure", $this);
|
545 |
+
|
546 |
return $this->sendEmail();
|
547 |
}
|
548 |
|
554 |
$user = get_userdata($invoice->user_id);
|
555 |
|
556 |
$this->email = $email;
|
557 |
+
$this->subject = sprintf(__("Membership Payment Failed For %s at %s", "paid-memberships-pro"), $user->display_name, get_option("blogname"));
|
|
|
558 |
|
559 |
$this->data = array(
|
560 |
"subject" => $this->subject,
|
586 |
$invoice->billing->state,
|
587 |
$invoice->billing->zip,
|
588 |
$invoice->billing->country,
|
589 |
+
$invoice->billing->phone);
|
590 |
+
$this->template = apply_filters("pmpro_email_template", "billing_failure_admin", $this);
|
591 |
+
|
592 |
return $this->sendEmail();
|
593 |
}
|
594 |
|
602 |
return false;
|
603 |
|
604 |
$this->email = $user->user_email;
|
605 |
+
$this->subject = sprintf(__("Credit Card on File Expiring Soon at %s", "paid-memberships-pro"), get_option("blogname"));
|
|
|
606 |
|
607 |
$this->data = array(
|
608 |
"subject" => $this->subject,
|
635 |
$invoice->billing->zip,
|
636 |
$invoice->billing->country,
|
637 |
$invoice->billing->phone);
|
638 |
+
|
639 |
+
$this->template = apply_filters("pmpro_email_template", "credit_card_expiring", $this);
|
640 |
+
|
641 |
return $this->sendEmail();
|
642 |
}
|
643 |
|
653 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
654 |
|
655 |
$this->email = $user->user_email;
|
656 |
+
$this->subject = sprintf(__("INVOICE for %s membership", "paid-memberships-pro"), get_option("blogname"));
|
657 |
+
|
|
|
658 |
$this->data = array(
|
659 |
"subject" => $this->subject,
|
660 |
"name" => $user->display_name,
|
691 |
$invoice->billing->country,
|
692 |
$invoice->billing->phone);
|
693 |
|
694 |
+
if($invoice->getDiscountCode()) {
|
695 |
+
if(!empty($invoice->discount_code->code))
|
696 |
+
$this->data["discount_code"] = "<p>" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $invoice->discount_code->code . "</p>\n";
|
697 |
+
else
|
698 |
+
$this->data["discount_code"] = "<p>" . __("Discount Code", 'paid-memberships-pro' ) . ": " . $invoice->discount_code . "</p>\n";
|
699 |
+
} else {
|
700 |
$this->data["discount_code"] = "";
|
701 |
+
}
|
702 |
|
703 |
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
|
704 |
if($enddate)
|
705 |
+
$this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $enddate)) . "</p>\n";
|
706 |
else
|
707 |
$this->data["membership_expiration"] = "";
|
708 |
+
|
709 |
+
|
710 |
+
$this->template = apply_filters("pmpro_email_template", "invoice", $this);
|
711 |
+
|
712 |
return $this->sendEmail();
|
713 |
}
|
714 |
|
730 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
731 |
|
732 |
$this->email = $user->user_email;
|
733 |
+
$this->subject = sprintf(__("Your trial at %s is ending soon", "paid-memberships-pro"), get_option("blogname"));
|
734 |
+
|
735 |
$this->data = array(
|
736 |
"subject" => $this->subject,
|
737 |
"name" => $user->display_name,
|
749 |
"trial_amount" => pmpro_formatPrice($user->membership_level->trial_amount),
|
750 |
"trial_limit" => $user->membership_level->trial_limit,
|
751 |
"trial_end" => date_i18n(get_option('date_format'), strtotime(date_i18n("m/d/Y", $user->membership_level->startdate) . " + " . $user->membership_level->trial_limit . " " . $user->membership_level->cycle_period), current_time("timestamp"))
|
752 |
+
);
|
753 |
+
|
754 |
+
$this->template = apply_filters("pmpro_email_template", "trial_ending", $this);
|
755 |
+
|
756 |
return $this->sendEmail();
|
757 |
}
|
758 |
|
766 |
return false;
|
767 |
|
768 |
$this->email = $user->user_email;
|
769 |
+
$this->subject = sprintf(__("Your membership at %s has ended", "paid-memberships-pro"), get_option("blogname"));
|
770 |
+
|
771 |
+
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url(), "display_name" => $user->display_name, "user_email" => $user->user_email, "levels_link" => pmpro_url("levels"));
|
772 |
+
|
773 |
+
$this->template = apply_filters("pmpro_email_template", "membership_expired", $this);
|
774 |
+
|
775 |
return $this->sendEmail();
|
776 |
}
|
777 |
|
793 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
794 |
|
795 |
$this->email = $user->user_email;
|
796 |
+
$this->subject = sprintf(__("Your membership at %s will end soon", "paid-memberships-pro"), get_option("blogname"));
|
797 |
+
|
798 |
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "membership_id" => $user->membership_level->id, "membership_level_name" => $user->membership_level->name, "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url(), "enddate" => date_i18n(get_option('date_format'), $user->membership_level->enddate), "display_name" => $user->display_name, "user_email" => $user->user_email);
|
799 |
+
|
800 |
+
$this->template = apply_filters("pmpro_email_template", "membership_expiring", $this);
|
801 |
+
|
802 |
return $this->sendEmail();
|
803 |
}
|
804 |
|
815 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID, true);
|
816 |
|
817 |
$this->email = $user->user_email;
|
818 |
+
$this->subject = sprintf(__("Your membership at %s has been changed", "paid-memberships-pro"), get_option("blogname"));
|
819 |
+
|
820 |
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "membership_id" => $user->membership_level->id, "membership_level_name" => $user->membership_level->name, "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url());
|
821 |
+
|
822 |
if($user->membership_level->ID)
|
823 |
+
$this->data["membership_change"] = sprintf(__("The new level is %s", 'paid-memberships-pro' ), $user->membership_level->name);
|
824 |
else
|
825 |
+
$this->data["membership_change"] = __("Your membership has been cancelled", "paid-memberships-pro");
|
826 |
+
|
827 |
if(!empty($user->membership_level->enddate))
|
828 |
{
|
829 |
+
$this->data["membership_change"] .= ". " . sprintf(__("This membership will expire on %s", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $user->membership_level->enddate));
|
830 |
}
|
831 |
elseif(!empty($this->expiration_changed))
|
832 |
{
|
833 |
+
$this->data["membership_change"] .= ". " . __("This membership does not expire", 'paid-memberships-pro' );
|
834 |
}
|
835 |
+
|
836 |
+
$this->template = apply_filters("pmpro_email_template", "admin_change", $this);
|
837 |
+
|
838 |
return $this->sendEmail();
|
839 |
}
|
840 |
|
856 |
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID, true);
|
857 |
|
858 |
$this->email = get_bloginfo("admin_email");
|
859 |
+
$this->subject = sprintf(__("Membership for %s at %s has been changed", "paid-memberships-pro"), $user->user_login, get_option("blogname"));
|
860 |
+
|
861 |
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "user_login" => $user->user_login, "sitename" => get_option("blogname"), "membership_level_name" => $user->membership_level->name, "siteemail" => get_bloginfo("admin_email"), "login_link" => wp_login_url());
|
862 |
if($user->membership_level->ID)
|
863 |
+
$this->data["membership_change"] = sprintf(__("The new level is %s", 'paid-memberships-pro' ), $user->membership_level->name);
|
864 |
else
|
865 |
+
$this->data["membership_change"] = __("Membership has been cancelled", 'paid-memberships-pro' );
|
866 |
|
867 |
if(!empty($user->membership_level->enddate))
|
868 |
{
|
869 |
+
$this->data["membership_change"] .= ". " . sprintf(__("This membership will expire on %s", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $user->membership_level->enddate));
|
870 |
}
|
871 |
elseif(!empty($this->expiration_changed))
|
872 |
{
|
873 |
+
$this->data["membership_change"] .= ". " . __("This membership does not expire", 'paid-memberships-pro' );
|
874 |
}
|
875 |
+
|
876 |
+
$this->template = apply_filters("pmpro_email_template", "admin_change_admin", $this);
|
877 |
+
|
878 |
return $this->sendEmail();
|
879 |
}
|
880 |
|
901 |
$level = pmpro_getLevel($order->membership_id);
|
902 |
|
903 |
$this->email = $user->user_email;
|
904 |
+
$this->subject = __('Invoice for Order #: ', 'paid-memberships-pro') . $order->code;
|
|
|
905 |
|
906 |
// Load invoice template
|
907 |
if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/pages/orders-email.php' ) ) {
|
925 |
'invoice' => $invoice
|
926 |
);
|
927 |
|
928 |
+
$this->template = apply_filters("pmpro_email_template", "billable_invoice", $this);
|
929 |
+
|
930 |
return $this->sendEmail();
|
931 |
}
|
932 |
+
|
933 |
+
/**
|
934 |
+
* Load the text for each default email template.
|
935 |
+
* This overrides the old /email/*.html templates.
|
936 |
+
*/
|
937 |
+
function getDefaultEmailTemplate( $template = null ) {
|
938 |
+
if( empty( $template ) && !empty( $this->template ) )
|
939 |
+
$template = $this->template;
|
940 |
+
|
941 |
+
if( empty( $template ) )
|
942 |
+
return false;
|
943 |
+
|
944 |
+
$r = '';
|
945 |
+
|
946 |
+
switch($template) {
|
947 |
+
case "admin_change":
|
948 |
+
$r = __( "<p>An administrator at !!sitename!! has changed your membership level.</p>
|
949 |
+
|
950 |
+
<p>!!membership_change!!.</p>
|
951 |
+
|
952 |
+
<p>If you did not request this membership change and would like more information please contact us at !!siteemail!!</p>
|
953 |
+
|
954 |
+
<p>Log in to your membership account here: !!login_link!!</p>", 'paid-memberships-pro' );
|
955 |
+
break;
|
956 |
+
//repeat above for each template
|
957 |
+
}
|
958 |
+
|
959 |
+
return $r;
|
960 |
+
}
|
961 |
}
|
classes/gateways/class.pmprogateway.php
CHANGED
@@ -52,7 +52,7 @@
|
|
52 |
else
|
53 |
{
|
54 |
if(empty($order->error))
|
55 |
-
$order->error = __("Unknown error: Authorization failed.",
|
56 |
return false;
|
57 |
}
|
58 |
}
|
@@ -103,14 +103,14 @@
|
|
103 |
if($this->void($order))
|
104 |
{
|
105 |
if(!$order->error)
|
106 |
-
$order->error = __("Unknown error: Payment failed.",
|
107 |
}
|
108 |
else
|
109 |
{
|
110 |
if(!$order->error)
|
111 |
-
$order->error = __("Unknown error: Payment failed.",
|
112 |
|
113 |
-
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.",
|
114 |
}
|
115 |
|
116 |
return false;
|
@@ -126,7 +126,7 @@
|
|
126 |
else
|
127 |
{
|
128 |
if(empty($order->error))
|
129 |
-
$order->error = __("Unknown error: Payment failed.",
|
130 |
|
131 |
return false;
|
132 |
}
|
52 |
else
|
53 |
{
|
54 |
if(empty($order->error))
|
55 |
+
$order->error = __("Unknown error: Authorization failed.", 'paid-memberships-pro' );
|
56 |
return false;
|
57 |
}
|
58 |
}
|
103 |
if($this->void($order))
|
104 |
{
|
105 |
if(!$order->error)
|
106 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
107 |
}
|
108 |
else
|
109 |
{
|
110 |
if(!$order->error)
|
111 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
112 |
|
113 |
+
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", 'paid-memberships-pro' );
|
114 |
}
|
115 |
|
116 |
return false;
|
126 |
else
|
127 |
{
|
128 |
if(empty($order->error))
|
129 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
130 |
|
131 |
return false;
|
132 |
}
|
classes/gateways/class.pmprogateway_authorizenet.php
CHANGED
@@ -36,7 +36,7 @@
|
|
36 |
static function pmpro_gateways($gateways)
|
37 |
{
|
38 |
if(empty($gateways['authorizenet']))
|
39 |
-
$gateways['authorizenet'] = __('Authorize.net', '
|
40 |
|
41 |
return $gateways;
|
42 |
}
|
@@ -90,12 +90,12 @@
|
|
90 |
?>
|
91 |
<tr class="pmpro_settings_divider gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
92 |
<td colspan="2">
|
93 |
-
<?php _e('Authorize.net Settings', '
|
94 |
</td>
|
95 |
</tr>
|
96 |
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
97 |
<th scope="row" valign="top">
|
98 |
-
<label for="loginname"><?php _e('Login Name', '
|
99 |
</th>
|
100 |
<td>
|
101 |
<input type="text" id="loginname" name="loginname" size="60" value="<?php echo esc_attr($values['loginname'])?>" />
|
@@ -103,7 +103,7 @@
|
|
103 |
</tr>
|
104 |
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
105 |
<th scope="row" valign="top">
|
106 |
-
<label for="transactionkey"><?php _e('Transaction Key', '
|
107 |
</th>
|
108 |
<td>
|
109 |
<input type="text" id="transactionkey" name="transactionkey" size="60" value="<?php echo esc_attr($values['transactionkey'])?>" />
|
@@ -111,10 +111,10 @@
|
|
111 |
</tr>
|
112 |
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
113 |
<th scope="row" valign="top">
|
114 |
-
<label><?php _e('Silent Post URL', '
|
115 |
</th>
|
116 |
<td>
|
117 |
-
<p><?php _e('To fully integrate with Authorize.net, be sure to set your Silent Post URL to', '
|
118 |
</td>
|
119 |
</tr>
|
120 |
<?php
|
@@ -168,7 +168,7 @@
|
|
168 |
else
|
169 |
{
|
170 |
if(empty($order->error))
|
171 |
-
$order->error = __("Unknown error: Authorization failed.",
|
172 |
return false;
|
173 |
}
|
174 |
}
|
@@ -219,13 +219,13 @@
|
|
219 |
if($this->void($order))
|
220 |
{
|
221 |
if(!$order->error)
|
222 |
-
$order->error = __("Unknown error: Payment failed.",
|
223 |
}
|
224 |
else
|
225 |
{
|
226 |
if(!$order->error)
|
227 |
-
$order->error = __("Unknown error: Payment failed.",
|
228 |
-
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.",
|
229 |
}
|
230 |
|
231 |
return false;
|
@@ -241,7 +241,7 @@
|
|
241 |
else
|
242 |
{
|
243 |
if(empty($order->error))
|
244 |
-
$order->error = __("Unknown error: Payment failed.",
|
245 |
|
246 |
return false;
|
247 |
}
|
@@ -300,7 +300,7 @@
|
|
300 |
"x_exp_date" => $order->ExpirationDate,
|
301 |
|
302 |
"x_amount" => $amount,
|
303 |
-
"x_description" => $order->membership_level->name . " " . __("Membership",
|
304 |
|
305 |
"x_first_name" => $order->FirstName,
|
306 |
"x_last_name" => $order->LastName,
|
@@ -906,8 +906,8 @@
|
|
906 |
else
|
907 |
{
|
908 |
$order->status = "error";
|
909 |
-
$order->error = __("Could not connect to Authorize.net",
|
910 |
-
$order->shorterror = __("Could not connect to Authorize.net",
|
911 |
return false;
|
912 |
}
|
913 |
}
|
36 |
static function pmpro_gateways($gateways)
|
37 |
{
|
38 |
if(empty($gateways['authorizenet']))
|
39 |
+
$gateways['authorizenet'] = __('Authorize.net', 'paid-memberships-pro' );
|
40 |
|
41 |
return $gateways;
|
42 |
}
|
90 |
?>
|
91 |
<tr class="pmpro_settings_divider gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
92 |
<td colspan="2">
|
93 |
+
<?php _e('Authorize.net Settings', 'paid-memberships-pro' ); ?>
|
94 |
</td>
|
95 |
</tr>
|
96 |
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
97 |
<th scope="row" valign="top">
|
98 |
+
<label for="loginname"><?php _e('Login Name', 'paid-memberships-pro' );?>:</label>
|
99 |
</th>
|
100 |
<td>
|
101 |
<input type="text" id="loginname" name="loginname" size="60" value="<?php echo esc_attr($values['loginname'])?>" />
|
103 |
</tr>
|
104 |
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
105 |
<th scope="row" valign="top">
|
106 |
+
<label for="transactionkey"><?php _e('Transaction Key', 'paid-memberships-pro' );?>:</label>
|
107 |
</th>
|
108 |
<td>
|
109 |
<input type="text" id="transactionkey" name="transactionkey" size="60" value="<?php echo esc_attr($values['transactionkey'])?>" />
|
111 |
</tr>
|
112 |
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
113 |
<th scope="row" valign="top">
|
114 |
+
<label><?php _e('Silent Post URL', 'paid-memberships-pro' );?>:</label>
|
115 |
</th>
|
116 |
<td>
|
117 |
+
<p><?php _e('To fully integrate with Authorize.net, be sure to set your Silent Post URL to', 'paid-memberships-pro' );?> <pre><?php echo admin_url("admin-ajax.php") . "?action=authnet_silent_post";?></pre></p>
|
118 |
</td>
|
119 |
</tr>
|
120 |
<?php
|
168 |
else
|
169 |
{
|
170 |
if(empty($order->error))
|
171 |
+
$order->error = __("Unknown error: Authorization failed.", 'paid-memberships-pro' );
|
172 |
return false;
|
173 |
}
|
174 |
}
|
219 |
if($this->void($order))
|
220 |
{
|
221 |
if(!$order->error)
|
222 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
223 |
}
|
224 |
else
|
225 |
{
|
226 |
if(!$order->error)
|
227 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
228 |
+
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", 'paid-memberships-pro' );
|
229 |
}
|
230 |
|
231 |
return false;
|
241 |
else
|
242 |
{
|
243 |
if(empty($order->error))
|
244 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
245 |
|
246 |
return false;
|
247 |
}
|
300 |
"x_exp_date" => $order->ExpirationDate,
|
301 |
|
302 |
"x_amount" => $amount,
|
303 |
+
"x_description" => $order->membership_level->name . " " . __("Membership", 'paid-memberships-pro' ),
|
304 |
|
305 |
"x_first_name" => $order->FirstName,
|
306 |
"x_last_name" => $order->LastName,
|
906 |
else
|
907 |
{
|
908 |
$order->status = "error";
|
909 |
+
$order->error = __("Could not connect to Authorize.net", 'paid-memberships-pro' );
|
910 |
+
$order->shorterror = __("Could not connect to Authorize.net", 'paid-memberships-pro' );
|
911 |
return false;
|
912 |
}
|
913 |
}
|
classes/gateways/class.pmprogateway_braintree.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
//include pmprogateway
|
3 |
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
4 |
|
@@ -7,12 +7,17 @@
|
|
7 |
|
8 |
class PMProGateway_braintree extends PMProGateway
|
9 |
{
|
|
|
|
|
|
|
|
|
|
|
10 |
function __construct($gateway = NULL)
|
11 |
-
{
|
12 |
$this->gateway = $gateway;
|
13 |
$this->gateway_environment = pmpro_getOption("gateway_environment");
|
14 |
|
15 |
-
if($this->dependencies()) {
|
16 |
$this->loadBraintreeLibrary();
|
17 |
|
18 |
//convert to braintree nomenclature
|
@@ -24,8 +29,7 @@
|
|
24 |
Braintree_Configuration::merchantId(pmpro_getOption("braintree_merchantid"));
|
25 |
Braintree_Configuration::publicKey(pmpro_getOption("braintree_publickey"));
|
26 |
Braintree_Configuration::privateKey(pmpro_getOption("braintree_privatekey"));
|
27 |
-
|
28 |
-
return false;
|
29 |
}
|
30 |
|
31 |
return $this->gateway;
|
@@ -40,13 +44,22 @@
|
|
40 |
{
|
41 |
global $msg, $msgt, $pmpro_braintree_error;
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
$modules = array('xmlwriter', 'SimpleXML', 'openssl', 'dom', 'hash', 'curl');
|
44 |
|
45 |
foreach($modules as $module){
|
46 |
if(!extension_loaded($module)){
|
47 |
$pmpro_braintree_error = true;
|
48 |
$msg = -1;
|
49 |
-
$msgt = sprintf(__("The %s gateway depends on the %s PHP extension. Please enable it, or ask your hosting provider to enable it.",
|
50 |
|
51 |
//throw error on checkout page
|
52 |
if(!is_admin())
|
@@ -55,7 +68,8 @@
|
|
55 |
return false;
|
56 |
}
|
57 |
}
|
58 |
-
|
|
|
59 |
return true;
|
60 |
}
|
61 |
|
@@ -68,10 +82,57 @@
|
|
68 |
function loadBraintreeLibrary()
|
69 |
{
|
70 |
//load Braintree library if it hasn't been loaded already (usually by another plugin using Braintree)
|
71 |
-
if(!class_exists("Braintree"))
|
72 |
-
require_once(
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/**
|
76 |
* Run on WP init
|
77 |
*
|
@@ -89,7 +150,7 @@
|
|
89 |
//code to add at checkout if Braintree is the current gateway
|
90 |
$default_gateway = pmpro_getOption('gateway');
|
91 |
$current_gateway = pmpro_getGateway();
|
92 |
-
if($default_gateway == "braintree" || $current_gateway == "braintree" && empty($_REQUEST['review'])) //$_REQUEST['review'] means the PayPal Express review page
|
93 |
{
|
94 |
add_action('pmpro_checkout_before_submit_button', array('PMProGateway_braintree', 'pmpro_checkout_before_submit_button'));
|
95 |
add_action('pmpro_billing_before_submit_button', array('PMProGateway_braintree', 'pmpro_checkout_before_submit_button'));
|
@@ -97,7 +158,7 @@
|
|
97 |
add_filter('pmpro_billing_order', array('PMProGateway_braintree', 'pmpro_checkout_order'));
|
98 |
add_filter('pmpro_required_billing_fields', array('PMProGateway_braintree', 'pmpro_required_billing_fields'));
|
99 |
add_filter('pmpro_include_payment_information_fields', array('PMProGateway_braintree', 'pmpro_include_payment_information_fields'));
|
100 |
-
}
|
101 |
}
|
102 |
|
103 |
/**
|
@@ -108,7 +169,7 @@
|
|
108 |
static function pmpro_gateways($gateways)
|
109 |
{
|
110 |
if(empty($gateways['braintree']))
|
111 |
-
$gateways['braintree'] = __('Braintree Payments', '
|
112 |
|
113 |
return $gateways;
|
114 |
}
|
@@ -146,7 +207,7 @@
|
|
146 |
static function pmpro_payment_options($options)
|
147 |
{
|
148 |
//get Braintree options
|
149 |
-
$braintree_options =
|
150 |
|
151 |
//merge with others.
|
152 |
$options = array_merge($braintree_options, $options);
|
@@ -161,15 +222,15 @@
|
|
161 |
*/
|
162 |
static function pmpro_payment_option_fields($values, $gateway)
|
163 |
{
|
164 |
-
|
165 |
<tr class="pmpro_settings_divider gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
166 |
<td colspan="2">
|
167 |
-
<?php _e('Braintree Settings', '
|
168 |
</td>
|
169 |
</tr>
|
170 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
171 |
<th scope="row" valign="top">
|
172 |
-
<label for="braintree_merchantid"><?php _e('Merchant ID', '
|
173 |
</th>
|
174 |
<td>
|
175 |
<input type="text" id="braintree_merchantid" name="braintree_merchantid" size="60" value="<?php echo esc_attr($values['braintree_merchantid'])?>" />
|
@@ -177,7 +238,7 @@
|
|
177 |
</tr>
|
178 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
179 |
<th scope="row" valign="top">
|
180 |
-
<label for="braintree_publickey"><?php _e('Public Key', '
|
181 |
</th>
|
182 |
<td>
|
183 |
<input type="text" id="braintree_publickey" name="braintree_publickey" size="60" value="<?php echo esc_attr($values['braintree_publickey'])?>" />
|
@@ -185,7 +246,7 @@
|
|
185 |
</tr>
|
186 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
187 |
<th scope="row" valign="top">
|
188 |
-
<label for="braintree_privatekey"><?php _e('Private Key', '
|
189 |
</th>
|
190 |
<td>
|
191 |
<input type="text" id="braintree_privatekey" name="braintree_privatekey" size="60" value="<?php echo esc_attr($values['braintree_privatekey'])?>" />
|
@@ -193,7 +254,7 @@
|
|
193 |
</tr>
|
194 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
195 |
<th scope="row" valign="top">
|
196 |
-
<label for="braintree_encryptionkey"><?php _e('Client-Side Encryption Key', '
|
197 |
</th>
|
198 |
<td>
|
199 |
<textarea id="braintree_encryptionkey" name="braintree_encryptionkey" rows="3" cols="80"><?php echo esc_textarea($values['braintree_encryptionkey'])?></textarea>
|
@@ -201,11 +262,11 @@
|
|
201 |
</tr>
|
202 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
203 |
<th scope="row" valign="top">
|
204 |
-
<label><?php _e('Web Hook URL', '
|
205 |
</th>
|
206 |
<td>
|
207 |
<p>
|
208 |
-
<?php _e('To fully integrate with Braintree, be sure to set your Web Hook URL to', '
|
209 |
<pre><?php
|
210 |
//echo admin_url("admin-ajax.php") . "?action=braintree_webhook";
|
211 |
echo PMPRO_URL . "/services/braintree-webhook.php";
|
@@ -303,7 +364,8 @@
|
|
303 |
* @since 1.8
|
304 |
*/
|
305 |
static function pmpro_include_payment_information_fields($include)
|
306 |
-
{
|
|
|
307 |
//global vars
|
308 |
global $pmpro_requirebilling, $pmpro_show_discount_code, $discount_code, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
|
309 |
|
@@ -318,8 +380,8 @@
|
|
318 |
<thead>
|
319 |
<tr>
|
320 |
<th>
|
321 |
-
<span class="pmpro_thead-name"><?php _e('Payment Information', '
|
322 |
-
<span class="pmpro_thead-msg"><?php printf(__('We Accept %s', '
|
323 |
</th>
|
324 |
</tr>
|
325 |
</thead>
|
@@ -341,7 +403,7 @@
|
|
341 |
{
|
342 |
?>
|
343 |
<div class="pmpro_payment-card-type">
|
344 |
-
<label for="CardType"><?php _e('Card Type', '
|
345 |
<select id="CardType" name="CardType" class=" <?php echo pmpro_getClassForField("CardType");?>">
|
346 |
<?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
|
347 |
<option value="<?php echo $cc?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc?></option>
|
@@ -353,12 +415,12 @@
|
|
353 |
?>
|
354 |
|
355 |
<div class="pmpro_payment-account-number">
|
356 |
-
<label for="AccountNumber"><?php _e('Card Number', '
|
357 |
<input id="AccountNumber" name="AccountNumber" class="input <?php echo pmpro_getClassForField("AccountNumber");?>" type="text" size="25" value="<?php echo esc_attr($AccountNumber)?>" data-encrypted-name="number" autocomplete="off" />
|
358 |
</div>
|
359 |
|
360 |
<div class="pmpro_payment-expiration">
|
361 |
-
<label for="ExpirationMonth"><?php _e('Expiration Date', '
|
362 |
<select id="ExpirationMonth" name="ExpirationMonth" class=" <?php echo pmpro_getClassForField("ExpirationMonth");?>">
|
363 |
<option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
|
364 |
<option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
|
@@ -390,8 +452,8 @@
|
|
390 |
{
|
391 |
?>
|
392 |
<div class="pmpro_payment-cvv">
|
393 |
-
<label for="CVV"><?php _e('CVV', '
|
394 |
-
<input class="input" id="CVV" name="cvv" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr($_REQUEST['CVV']); }?>" class=" <?php echo pmpro_getClassForField("CVV");?>" data-encrypted-name="cvv" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter(PMPRO_URL)?>/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", '
|
395 |
</div>
|
396 |
<?php
|
397 |
}
|
@@ -399,9 +461,9 @@
|
|
399 |
|
400 |
<?php if($pmpro_show_discount_code) { ?>
|
401 |
<div class="pmpro_payment-discount-code">
|
402 |
-
<label for="discount_code"><?php _e('Discount Code', '
|
403 |
<input class="input <?php echo pmpro_getClassForField("discount_code");?>" id="discount_code" name="discount_code" type="text" size="20" value="<?php echo esc_attr($discount_code)?>" />
|
404 |
-
<input type="button" id="discount_code_button" name="discount_code_button" value="<?php _e('Apply', '
|
405 |
<p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
|
406 |
</div>
|
407 |
<?php } ?>
|
@@ -455,8 +517,18 @@
|
|
455 |
}
|
456 |
else
|
457 |
{
|
458 |
-
if(empty($order->error))
|
459 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
return false;
|
461 |
}
|
462 |
}
|
@@ -464,6 +536,12 @@
|
|
464 |
|
465 |
function charge(&$order)
|
466 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
467 |
//create a code for the order
|
468 |
if(empty($order->code))
|
469 |
$order->code = $order->getRandomCode();
|
@@ -515,7 +593,7 @@
|
|
515 |
else
|
516 |
{
|
517 |
$order->errorcode = true;
|
518 |
-
$order->error = __("Error during settlement:",
|
519 |
$order->shorterror = $response->message;
|
520 |
return false;
|
521 |
}
|
@@ -524,7 +602,7 @@
|
|
524 |
{
|
525 |
//$order->status = "error";
|
526 |
$order->errorcode = true;
|
527 |
-
$order->error = __("Error during charge:",
|
528 |
$order->shorterror = $response->message;
|
529 |
return false;
|
530 |
}
|
@@ -541,6 +619,11 @@
|
|
541 |
*/
|
542 |
function getCustomer(&$order, $force = false)
|
543 |
{
|
|
|
|
|
|
|
|
|
|
|
544 |
global $current_user;
|
545 |
|
546 |
//already have it?
|
@@ -616,7 +699,7 @@
|
|
616 |
}
|
617 |
else
|
618 |
{
|
619 |
-
$order->error = __("Failed to update customer.",
|
620 |
$order->shorterror = $order->error;
|
621 |
return false;
|
622 |
}
|
@@ -664,14 +747,14 @@
|
|
664 |
}
|
665 |
else
|
666 |
{
|
667 |
-
$order->error = __("Failed to create customer.",
|
668 |
$order->shorterror = $order->error;
|
669 |
return false;
|
670 |
}
|
671 |
}
|
672 |
catch (Exception $e)
|
673 |
{
|
674 |
-
$order->error = __("Error creating customer record with Braintree:",
|
675 |
$order->shorterror = $order->error;
|
676 |
return false;
|
677 |
}
|
@@ -694,6 +777,11 @@
|
|
694 |
|
695 |
function subscribe(&$order)
|
696 |
{
|
|
|
|
|
|
|
|
|
|
|
697 |
//create a code for the order
|
698 |
if(empty($order->code))
|
699 |
$order->code = $order->getRandomCode();
|
@@ -771,7 +859,7 @@
|
|
771 |
}
|
772 |
catch (Exception $e)
|
773 |
{
|
774 |
-
$order->error = __("Error subscribing customer to plan with Braintree:",
|
775 |
//return error
|
776 |
$order->shorterror = $order->error;
|
777 |
return false;
|
@@ -786,14 +874,19 @@
|
|
786 |
}
|
787 |
else
|
788 |
{
|
789 |
-
$order->error = __("Failed to subscribe with Braintree:",
|
790 |
$order->shorterror = $result->message;
|
791 |
return false;
|
792 |
}
|
793 |
}
|
794 |
|
795 |
function update(&$order)
|
796 |
-
{
|
|
|
|
|
|
|
|
|
|
|
797 |
//we just have to run getCustomer which will look for the customer and update it with the new token
|
798 |
$this->getCustomer($order, true);
|
799 |
|
@@ -809,6 +902,11 @@
|
|
809 |
|
810 |
function cancel(&$order)
|
811 |
{
|
|
|
|
|
|
|
|
|
|
|
812 |
//require a subscription id
|
813 |
if(empty($order->subscription_transaction_id))
|
814 |
return false;
|
@@ -824,7 +922,7 @@
|
|
824 |
catch(Exception $e)
|
825 |
{
|
826 |
$order->updateStatus("cancelled"); //assume it's been cancelled already
|
827 |
-
$order->error = __("Could not find the subscription.",
|
828 |
$order->shorterror = $order->error;
|
829 |
return false; //no subscription found
|
830 |
}
|
@@ -837,14 +935,14 @@
|
|
837 |
else
|
838 |
{
|
839 |
$order->updateStatus("cancelled"); //assume it's been cancelled already
|
840 |
-
$order->error = __("Could not find the subscription.",
|
841 |
$order->shorterror = $order->error;
|
842 |
return false; //no subscription found
|
843 |
}
|
844 |
}
|
845 |
else
|
846 |
{
|
847 |
-
$order->error = __("Could not find the subscription.",
|
848 |
$order->shorterror = $order->error;
|
849 |
return false; //no customer found
|
850 |
}
|
1 |
+
<?php
|
2 |
//include pmprogateway
|
3 |
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
4 |
|
7 |
|
8 |
class PMProGateway_braintree extends PMProGateway
|
9 |
{
|
10 |
+
/**
|
11 |
+
* @var bool Is the Braintree/PHP Library loaded
|
12 |
+
*/
|
13 |
+
private static $is_loaded = false;
|
14 |
+
|
15 |
function __construct($gateway = NULL)
|
16 |
+
{
|
17 |
$this->gateway = $gateway;
|
18 |
$this->gateway_environment = pmpro_getOption("gateway_environment");
|
19 |
|
20 |
+
if( true === $this->dependencies() ) {
|
21 |
$this->loadBraintreeLibrary();
|
22 |
|
23 |
//convert to braintree nomenclature
|
29 |
Braintree_Configuration::merchantId(pmpro_getOption("braintree_merchantid"));
|
30 |
Braintree_Configuration::publicKey(pmpro_getOption("braintree_publickey"));
|
31 |
Braintree_Configuration::privateKey(pmpro_getOption("braintree_privatekey"));
|
32 |
+
self::$is_loaded = true;
|
|
|
33 |
}
|
34 |
|
35 |
return $this->gateway;
|
44 |
{
|
45 |
global $msg, $msgt, $pmpro_braintree_error;
|
46 |
|
47 |
+
if ( version_compare( PHP_VERSION, '5.4.45', '<' )) {
|
48 |
+
|
49 |
+
$msg = -1;
|
50 |
+
$msgt = sprintf(__("The Braintree Gateway requires PHP 5.4.45 or greater. We recommend upgrading to PHP %s or greater. Ask your host to upgrade.", "paid-memberships-pro" ), PMPRO_PHP_MIN_VERSION );
|
51 |
+
|
52 |
+
pmpro_setMessage( $msgt, "pmpro_error" );
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
|
56 |
$modules = array('xmlwriter', 'SimpleXML', 'openssl', 'dom', 'hash', 'curl');
|
57 |
|
58 |
foreach($modules as $module){
|
59 |
if(!extension_loaded($module)){
|
60 |
$pmpro_braintree_error = true;
|
61 |
$msg = -1;
|
62 |
+
$msgt = sprintf(__("The %s gateway depends on the %s PHP extension. Please enable it, or ask your hosting provider to enable it.", 'paid-memberships-pro' ), 'Braintree', $module);
|
63 |
|
64 |
//throw error on checkout page
|
65 |
if(!is_admin())
|
68 |
return false;
|
69 |
}
|
70 |
}
|
71 |
+
|
72 |
+
self::$is_loaded = true;
|
73 |
return true;
|
74 |
}
|
75 |
|
82 |
function loadBraintreeLibrary()
|
83 |
{
|
84 |
//load Braintree library if it hasn't been loaded already (usually by another plugin using Braintree)
|
85 |
+
if(!class_exists("\\Braintree"))
|
86 |
+
require_once( PMPRO_DIR . "/includes/lib/Braintree/lib/Braintree.php");
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
+
* Get a collection of plans available for this Braintree account.
|
91 |
+
*/
|
92 |
+
function getPlans($force = false) {
|
93 |
+
//check for cache
|
94 |
+
$cache_key = 'pmpro_braintree_plans_' . md5($this->gateway_environment . pmpro_getOption("braintree_merchantid") . pmpro_getOption("braintree_publickey") . pmpro_getOption("braintree_privatekey"));
|
95 |
+
|
96 |
+
$plans = get_transient($cache_key);
|
97 |
+
|
98 |
+
//check Braintree if no transient found
|
99 |
+
if($plans === false) {
|
100 |
+
$plans = Braintree_Plan::all();
|
101 |
+
|
102 |
+
set_transient($cache_key, $plans);
|
103 |
+
}
|
104 |
+
|
105 |
+
return $plans;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Search for a plan by id
|
110 |
+
*/
|
111 |
+
function getPlanByID($id) {
|
112 |
+
$plans = $this->getPlans();
|
113 |
+
|
114 |
+
if(!empty($plans)) {
|
115 |
+
foreach($plans as $plan) {
|
116 |
+
if($plan->id == $id)
|
117 |
+
return $plan;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Checks if a level has an associated plan.
|
126 |
+
*/
|
127 |
+
static function checkLevelForPlan($level_id) {
|
128 |
+
$Gateway = new PMProGateway_braintree();
|
129 |
+
$plan = $Gateway->getPlanByID('pmpro_' . $level_id);
|
130 |
+
if(!empty($plan))
|
131 |
+
return true;
|
132 |
+
else
|
133 |
+
return false;
|
134 |
+
}
|
135 |
+
|
136 |
/**
|
137 |
* Run on WP init
|
138 |
*
|
150 |
//code to add at checkout if Braintree is the current gateway
|
151 |
$default_gateway = pmpro_getOption('gateway');
|
152 |
$current_gateway = pmpro_getGateway();
|
153 |
+
if( ( $default_gateway == "braintree" || $current_gateway == "braintree" && empty($_REQUEST['review']))) //$_REQUEST['review'] means the PayPal Express review page
|
154 |
{
|
155 |
add_action('pmpro_checkout_before_submit_button', array('PMProGateway_braintree', 'pmpro_checkout_before_submit_button'));
|
156 |
add_action('pmpro_billing_before_submit_button', array('PMProGateway_braintree', 'pmpro_checkout_before_submit_button'));
|
158 |
add_filter('pmpro_billing_order', array('PMProGateway_braintree', 'pmpro_checkout_order'));
|
159 |
add_filter('pmpro_required_billing_fields', array('PMProGateway_braintree', 'pmpro_required_billing_fields'));
|
160 |
add_filter('pmpro_include_payment_information_fields', array('PMProGateway_braintree', 'pmpro_include_payment_information_fields'));
|
161 |
+
}
|
162 |
}
|
163 |
|
164 |
/**
|
169 |
static function pmpro_gateways($gateways)
|
170 |
{
|
171 |
if(empty($gateways['braintree']))
|
172 |
+
$gateways['braintree'] = __('Braintree Payments', 'paid-memberships-pro' );
|
173 |
|
174 |
return $gateways;
|
175 |
}
|
207 |
static function pmpro_payment_options($options)
|
208 |
{
|
209 |
//get Braintree options
|
210 |
+
$braintree_options = self::getGatewayOptions();
|
211 |
|
212 |
//merge with others.
|
213 |
$options = array_merge($braintree_options, $options);
|
222 |
*/
|
223 |
static function pmpro_payment_option_fields($values, $gateway)
|
224 |
{
|
225 |
+
?>
|
226 |
<tr class="pmpro_settings_divider gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
227 |
<td colspan="2">
|
228 |
+
<?php _e('Braintree Settings', 'paid-memberships-pro' ); ?>
|
229 |
</td>
|
230 |
</tr>
|
231 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
232 |
<th scope="row" valign="top">
|
233 |
+
<label for="braintree_merchantid"><?php _e('Merchant ID', 'paid-memberships-pro' );?>:</label>
|
234 |
</th>
|
235 |
<td>
|
236 |
<input type="text" id="braintree_merchantid" name="braintree_merchantid" size="60" value="<?php echo esc_attr($values['braintree_merchantid'])?>" />
|
238 |
</tr>
|
239 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
240 |
<th scope="row" valign="top">
|
241 |
+
<label for="braintree_publickey"><?php _e('Public Key', 'paid-memberships-pro' );?>:</label>
|
242 |
</th>
|
243 |
<td>
|
244 |
<input type="text" id="braintree_publickey" name="braintree_publickey" size="60" value="<?php echo esc_attr($values['braintree_publickey'])?>" />
|
246 |
</tr>
|
247 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
248 |
<th scope="row" valign="top">
|
249 |
+
<label for="braintree_privatekey"><?php _e('Private Key', 'paid-memberships-pro' );?>:</label>
|
250 |
</th>
|
251 |
<td>
|
252 |
<input type="text" id="braintree_privatekey" name="braintree_privatekey" size="60" value="<?php echo esc_attr($values['braintree_privatekey'])?>" />
|
254 |
</tr>
|
255 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
256 |
<th scope="row" valign="top">
|
257 |
+
<label for="braintree_encryptionkey"><?php _e('Client-Side Encryption Key', 'paid-memberships-pro' );?>:</label>
|
258 |
</th>
|
259 |
<td>
|
260 |
<textarea id="braintree_encryptionkey" name="braintree_encryptionkey" rows="3" cols="80"><?php echo esc_textarea($values['braintree_encryptionkey'])?></textarea>
|
262 |
</tr>
|
263 |
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
264 |
<th scope="row" valign="top">
|
265 |
+
<label><?php _e('Web Hook URL', 'paid-memberships-pro' );?>:</label>
|
266 |
</th>
|
267 |
<td>
|
268 |
<p>
|
269 |
+
<?php _e('To fully integrate with Braintree, be sure to set your Web Hook URL to', 'paid-memberships-pro' );?>
|
270 |
<pre><?php
|
271 |
//echo admin_url("admin-ajax.php") . "?action=braintree_webhook";
|
272 |
echo PMPRO_URL . "/services/braintree-webhook.php";
|
364 |
* @since 1.8
|
365 |
*/
|
366 |
static function pmpro_include_payment_information_fields($include)
|
367 |
+
{
|
368 |
+
|
369 |
//global vars
|
370 |
global $pmpro_requirebilling, $pmpro_show_discount_code, $discount_code, $CardType, $AccountNumber, $ExpirationMonth, $ExpirationYear;
|
371 |
|
380 |
<thead>
|
381 |
<tr>
|
382 |
<th>
|
383 |
+
<span class="pmpro_thead-name"><?php _e('Payment Information', 'paid-memberships-pro' );?></span>
|
384 |
+
<span class="pmpro_thead-msg"><?php printf(__('We Accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string);?></span>
|
385 |
</th>
|
386 |
</tr>
|
387 |
</thead>
|
403 |
{
|
404 |
?>
|
405 |
<div class="pmpro_payment-card-type">
|
406 |
+
<label for="CardType"><?php _e('Card Type', 'paid-memberships-pro' );?></label>
|
407 |
<select id="CardType" name="CardType" class=" <?php echo pmpro_getClassForField("CardType");?>">
|
408 |
<?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
|
409 |
<option value="<?php echo $cc?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc?></option>
|
415 |
?>
|
416 |
|
417 |
<div class="pmpro_payment-account-number">
|
418 |
+
<label for="AccountNumber"><?php _e('Card Number', 'paid-memberships-pro' );?></label>
|
419 |
<input id="AccountNumber" name="AccountNumber" class="input <?php echo pmpro_getClassForField("AccountNumber");?>" type="text" size="25" value="<?php echo esc_attr($AccountNumber)?>" data-encrypted-name="number" autocomplete="off" />
|
420 |
</div>
|
421 |
|
422 |
<div class="pmpro_payment-expiration">
|
423 |
+
<label for="ExpirationMonth"><?php _e('Expiration Date', 'paid-memberships-pro' );?></label>
|
424 |
<select id="ExpirationMonth" name="ExpirationMonth" class=" <?php echo pmpro_getClassForField("ExpirationMonth");?>">
|
425 |
<option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
|
426 |
<option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
|
452 |
{
|
453 |
?>
|
454 |
<div class="pmpro_payment-cvv">
|
455 |
+
<label for="CVV"><?php _e('CVV', 'paid-memberships-pro' );?></label>
|
456 |
+
<input class="input" id="CVV" name="cvv" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr($_REQUEST['CVV']); }?>" class=" <?php echo pmpro_getClassForField("CVV");?>" data-encrypted-name="cvv" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter(PMPRO_URL)?>/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", 'paid-memberships-pro' );?></a>)</small>
|
457 |
</div>
|
458 |
<?php
|
459 |
}
|
461 |
|
462 |
<?php if($pmpro_show_discount_code) { ?>
|
463 |
<div class="pmpro_payment-discount-code">
|
464 |
+
<label for="discount_code"><?php _e('Discount Code', 'paid-memberships-pro' );?></label>
|
465 |
<input class="input <?php echo pmpro_getClassForField("discount_code");?>" id="discount_code" name="discount_code" type="text" size="20" value="<?php echo esc_attr($discount_code)?>" />
|
466 |
+
<input type="button" id="discount_code_button" name="discount_code_button" value="<?php _e('Apply', 'paid-memberships-pro' );?>" />
|
467 |
<p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
|
468 |
</div>
|
469 |
<?php } ?>
|
517 |
}
|
518 |
else
|
519 |
{
|
520 |
+
if(empty($order->error)) {
|
521 |
+
|
522 |
+
if ( !self::$is_loaded ) {
|
523 |
+
|
524 |
+
$order->error = __("Payment error: Please contact the webmaster (braintree-load-error)", "paid-memberships-pro");
|
525 |
+
|
526 |
+
} else {
|
527 |
+
|
528 |
+
$order->error = __( "Unknown error: Initial payment failed.", "paid-memberships-pro" );
|
529 |
+
}
|
530 |
+
}
|
531 |
+
|
532 |
return false;
|
533 |
}
|
534 |
}
|
536 |
|
537 |
function charge(&$order)
|
538 |
{
|
539 |
+
if ( ! self::$is_loaded ) {
|
540 |
+
|
541 |
+
$order->error = __("Payment error: Please contact the webmaster (braintree-load-error)", "paid-memberships-pro");
|
542 |
+
return false;
|
543 |
+
}
|
544 |
+
|
545 |
//create a code for the order
|
546 |
if(empty($order->code))
|
547 |
$order->code = $order->getRandomCode();
|
593 |
else
|
594 |
{
|
595 |
$order->errorcode = true;
|
596 |
+
$order->error = __("Error during settlement:", 'paid-memberships-pro' ) . " " . $response->message;
|
597 |
$order->shorterror = $response->message;
|
598 |
return false;
|
599 |
}
|
602 |
{
|
603 |
//$order->status = "error";
|
604 |
$order->errorcode = true;
|
605 |
+
$order->error = __("Error during charge:", 'paid-memberships-pro' ) . " " . $response->message;
|
606 |
$order->shorterror = $response->message;
|
607 |
return false;
|
608 |
}
|
619 |
*/
|
620 |
function getCustomer(&$order, $force = false)
|
621 |
{
|
622 |
+
if ( ! self::$is_loaded ) {
|
623 |
+
$order->error = __("Payment error: Please contact the webmaster (braintree-load-error)", 'paid-memberships-pro');
|
624 |
+
return false;
|
625 |
+
}
|
626 |
+
|
627 |
global $current_user;
|
628 |
|
629 |
//already have it?
|
699 |
}
|
700 |
else
|
701 |
{
|
702 |
+
$order->error = __("Failed to update customer.", 'paid-memberships-pro' ) . " " . $response->message;
|
703 |
$order->shorterror = $order->error;
|
704 |
return false;
|
705 |
}
|
747 |
}
|
748 |
else
|
749 |
{
|
750 |
+
$order->error = __("Failed to create customer.", 'paid-memberships-pro' ) . " " . $result->message;
|
751 |
$order->shorterror = $order->error;
|
752 |
return false;
|
753 |
}
|
754 |
}
|
755 |
catch (Exception $e)
|
756 |
{
|
757 |
+
$order->error = __("Error creating customer record with Braintree:", 'paid-memberships-pro' ) . $e->getMessage() . " (" . get_class($e) . ")";
|
758 |
$order->shorterror = $order->error;
|
759 |
return false;
|
760 |
}
|
777 |
|
778 |
function subscribe(&$order)
|
779 |
{
|
780 |
+
if ( ! self::$is_loaded ) {
|
781 |
+
$order->error = __("Payment error: Please contact the webmaster (braintree-load-error)", 'paid-memberships-pro');
|
782 |
+
return false;
|
783 |
+
}
|
784 |
+
|
785 |
//create a code for the order
|
786 |
if(empty($order->code))
|
787 |
$order->code = $order->getRandomCode();
|
859 |
}
|
860 |
catch (Exception $e)
|
861 |
{
|
862 |
+
$order->error = __("Error subscribing customer to plan with Braintree:", 'paid-memberships-pro' ) . " " . $e->getMessage() . " (" . get_class($e) . ")";
|
863 |
//return error
|
864 |
$order->shorterror = $order->error;
|
865 |
return false;
|
874 |
}
|
875 |
else
|
876 |
{
|
877 |
+
$order->error = __("Failed to subscribe with Braintree:", 'paid-memberships-pro' ) . " " . $result->message;
|
878 |
$order->shorterror = $result->message;
|
879 |
return false;
|
880 |
}
|
881 |
}
|
882 |
|
883 |
function update(&$order)
|
884 |
+
{
|
885 |
+
if ( ! self::$is_loaded ) {
|
886 |
+
$order->error = __("Payment error: Please contact the webmaster (braintree-load-error)", 'paid-memberships-pro');
|
887 |
+
return false;
|
888 |
+
}
|
889 |
+
|
890 |
//we just have to run getCustomer which will look for the customer and update it with the new token
|
891 |
$this->getCustomer($order, true);
|
892 |
|
902 |
|
903 |
function cancel(&$order)
|
904 |
{
|
905 |
+
if ( ! self::$is_loaded ) {
|
906 |
+
$order->error = __("Payment error: Please contact the webmaster (braintree-load-error)", 'paid-memberships-pro');
|
907 |
+
return false;
|
908 |
+
}
|
909 |
+
|
910 |
//require a subscription id
|
911 |
if(empty($order->subscription_transaction_id))
|
912 |
return false;
|
922 |
catch(Exception $e)
|
923 |
{
|
924 |
$order->updateStatus("cancelled"); //assume it's been cancelled already
|
925 |
+
$order->error = __("Could not find the subscription.", 'paid-memberships-pro' ) . " " . $e->getMessage();
|
926 |
$order->shorterror = $order->error;
|
927 |
return false; //no subscription found
|
928 |
}
|
935 |
else
|
936 |
{
|
937 |
$order->updateStatus("cancelled"); //assume it's been cancelled already
|
938 |
+
$order->error = __("Could not find the subscription.", 'paid-memberships-pro' ) . " " . $result->message;
|
939 |
$order->shorterror = $order->error;
|
940 |
return false; //no subscription found
|
941 |
}
|
942 |
}
|
943 |
else
|
944 |
{
|
945 |
+
$order->error = __("Could not find the subscription.", 'paid-memberships-pro' );
|
946 |
$order->shorterror = $order->error;
|
947 |
return false; //no customer found
|
948 |
}
|
classes/gateways/class.pmprogateway_check.php
CHANGED
@@ -46,7 +46,7 @@
|
|
46 |
static function pmpro_gateways($gateways)
|
47 |
{
|
48 |
if(empty($gateways['check']))
|
49 |
-
$gateways['check'] = __('Pay by Check', '
|
50 |
|
51 |
return $gateways;
|
52 |
}
|
@@ -98,16 +98,16 @@
|
|
98 |
?>
|
99 |
<tr class="pmpro_settings_divider gateway gateway_check" <?php if($gateway != "check") { ?>style="display: none;"<?php } ?>>
|
100 |
<td colspan="2">
|
101 |
-
<?php _e('Pay by Check Settings', '
|
102 |
</td>
|
103 |
</tr>
|
104 |
<tr class="gateway gateway_check" <?php if($gateway != "check") { ?>style="display: none;"<?php } ?>>
|
105 |
<th scope="row" valign="top">
|
106 |
-
<label for="instructions"><?php _e('Instructions', '
|
107 |
</th>
|
108 |
<td>
|
109 |
<textarea id="instructions" name="instructions" rows="3" cols="80"><?php echo esc_textarea($values['instructions'])?></textarea>
|
110 |
-
<p><small><?php _e('Who to write the check out to. Where to mail it. Shown on checkout, confirmation, and invoice pages.', '
|
111 |
</td>
|
112 |
</tr>
|
113 |
<?php
|
@@ -207,7 +207,7 @@
|
|
207 |
else
|
208 |
{
|
209 |
if(empty($order->error))
|
210 |
-
$order->error = __("Unknown error: Authorization failed.",
|
211 |
return false;
|
212 |
}
|
213 |
}
|
@@ -259,14 +259,14 @@
|
|
259 |
if($this->void($order))
|
260 |
{
|
261 |
if(!$order->error)
|
262 |
-
$order->error = __("Unknown error: Payment failed.",
|
263 |
}
|
264 |
else
|
265 |
{
|
266 |
if(!$order->error)
|
267 |
-
$order->error = __("Unknown error: Payment failed.",
|
268 |
|
269 |
-
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.",
|
270 |
}
|
271 |
|
272 |
return false;
|
@@ -282,7 +282,7 @@
|
|
282 |
else
|
283 |
{
|
284 |
if(empty($order->error))
|
285 |
-
$order->error = __("Unknown error: Payment failed.",
|
286 |
|
287 |
return false;
|
288 |
}
|
46 |
static function pmpro_gateways($gateways)
|
47 |
{
|
48 |
if(empty($gateways['check']))
|
49 |
+
$gateways['check'] = __('Pay by Check', 'paid-memberships-pro' );
|
50 |
|
51 |
return $gateways;
|
52 |
}
|
98 |
?>
|
99 |
<tr class="pmpro_settings_divider gateway gateway_check" <?php if($gateway != "check") { ?>style="display: none;"<?php } ?>>
|
100 |
<td colspan="2">
|
101 |
+
<?php _e('Pay by Check Settings', 'paid-memberships-pro' ); ?>
|
102 |
</td>
|
103 |
</tr>
|
104 |
<tr class="gateway gateway_check" <?php if($gateway != "check") { ?>style="display: none;"<?php } ?>>
|
105 |
<th scope="row" valign="top">
|
106 |
+
<label for="instructions"><?php _e('Instructions', 'paid-memberships-pro' );?></label>
|
107 |
</th>
|
108 |
<td>
|
109 |
<textarea id="instructions" name="instructions" rows="3" cols="80"><?php echo esc_textarea($values['instructions'])?></textarea>
|
110 |
+
<p><small><?php _e('Who to write the check out to. Where to mail it. Shown on checkout, confirmation, and invoice pages.', 'paid-memberships-pro' );?></small></p>
|
111 |
</td>
|
112 |
</tr>
|
113 |
<?php
|
207 |
else
|
208 |
{
|
209 |
if(empty($order->error))
|
210 |
+
$order->error = __("Unknown error: Authorization failed.", 'paid-memberships-pro' );
|
211 |
return false;
|
212 |
}
|
213 |
}
|
259 |
if($this->void($order))
|
260 |
{
|
261 |
if(!$order->error)
|
262 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
263 |
}
|
264 |
else
|
265 |
{
|
266 |
if(!$order->error)
|
267 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
268 |
|
269 |
+
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", 'paid-memberships-pro' );
|
270 |
}
|
271 |
|
272 |
return false;
|
282 |
else
|
283 |
{
|
284 |
if(empty($order->error))
|
285 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
286 |
|
287 |
return false;
|
288 |
}
|
classes/gateways/class.pmprogateway_cybersource.php
CHANGED
@@ -39,7 +39,7 @@
|
|
39 |
static function pmpro_gateways($gateways)
|
40 |
{
|
41 |
if(empty($gateways['cybersource']))
|
42 |
-
$gateways['cybersource'] = __('CyberSource', '
|
43 |
|
44 |
return $gateways;
|
45 |
}
|
@@ -93,17 +93,17 @@
|
|
93 |
?>
|
94 |
<tr class="pmpro_settings_divider gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
95 |
<td colspan="2">
|
96 |
-
<?php _e('CyberSource Settings', '
|
97 |
</td>
|
98 |
</tr>
|
99 |
<tr class="gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
100 |
<td colspan="2">
|
101 |
-
<strong><?php _e('Note', '
|
102 |
</td>
|
103 |
</tr>
|
104 |
<tr class="gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
105 |
<th scope="row" valign="top">
|
106 |
-
<label for="cybersource_merchantid"><?php _e('Merchant ID', '
|
107 |
</th>
|
108 |
<td>
|
109 |
<input type="text" id="cybersource_merchantid" name="cybersource_merchantid" size="60" value="<?php echo esc_attr($values['cybersource_merchantid'])?>" />
|
@@ -111,7 +111,7 @@
|
|
111 |
</tr>
|
112 |
<tr class="gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
113 |
<th scope="row" valign="top">
|
114 |
-
<label for="cybersource_securitykey"><?php _e('Transaction Security Key', '
|
115 |
</th>
|
116 |
<td>
|
117 |
<textarea id="cybersource_securitykey" name="cybersource_securitykey" rows="3" cols="80"><?php echo esc_textarea($values['cybersource_securitykey']);?></textarea>
|
@@ -168,7 +168,7 @@
|
|
168 |
else
|
169 |
{
|
170 |
if(empty($order->error))
|
171 |
-
$order->error = __("Unknown error: Authorization failed.",
|
172 |
return false;
|
173 |
}
|
174 |
}
|
@@ -219,14 +219,14 @@
|
|
219 |
if($this->void($order))
|
220 |
{
|
221 |
if(!$order->error)
|
222 |
-
$order->error = __("Unknown error: Payment failed.",
|
223 |
}
|
224 |
else
|
225 |
{
|
226 |
if(!$order->error)
|
227 |
-
$order->error = __("Unknown error: Payment failed.",
|
228 |
|
229 |
-
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.",
|
230 |
}
|
231 |
|
232 |
return false;
|
@@ -242,7 +242,7 @@
|
|
242 |
else
|
243 |
{
|
244 |
if(empty($order->error))
|
245 |
-
$order->error = __("Unknown error: Payment failed.",
|
246 |
|
247 |
return false;
|
248 |
}
|
39 |
static function pmpro_gateways($gateways)
|
40 |
{
|
41 |
if(empty($gateways['cybersource']))
|
42 |
+
$gateways['cybersource'] = __('CyberSource', 'paid-memberships-pro' );
|
43 |
|
44 |
return $gateways;
|
45 |
}
|
93 |
?>
|
94 |
<tr class="pmpro_settings_divider gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
95 |
<td colspan="2">
|
96 |
+
<?php _e('CyberSource Settings', 'paid-memberships-pro' ); ?>
|
97 |
</td>
|
98 |
</tr>
|
99 |
<tr class="gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
100 |
<td colspan="2">
|
101 |
+
<strong><?php _e('Note', 'paid-memberships-pro' );?>:</strong> <?php _e('This gateway option is in beta. Some functionality may not be available. Please contact Paid Memberships Pro with any issues you run into. <strong>Please be sure to upgrade Paid Memberships Pro to the latest versions when available.</strong>', 'paid-memberships-pro' );?>
|
102 |
</td>
|
103 |
</tr>
|
104 |
<tr class="gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
105 |
<th scope="row" valign="top">
|
106 |
+
<label for="cybersource_merchantid"><?php _e('Merchant ID', 'paid-memberships-pro' );?>:</label>
|
107 |
</th>
|
108 |
<td>
|
109 |
<input type="text" id="cybersource_merchantid" name="cybersource_merchantid" size="60" value="<?php echo esc_attr($values['cybersource_merchantid'])?>" />
|
111 |
</tr>
|
112 |
<tr class="gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
113 |
<th scope="row" valign="top">
|
114 |
+
<label for="cybersource_securitykey"><?php _e('Transaction Security Key', 'paid-memberships-pro' );?>:</label>
|
115 |
</th>
|
116 |
<td>
|
117 |
<textarea id="cybersource_securitykey" name="cybersource_securitykey" rows="3" cols="80"><?php echo esc_textarea($values['cybersource_securitykey']);?></textarea>
|
168 |
else
|
169 |
{
|
170 |
if(empty($order->error))
|
171 |
+
$order->error = __("Unknown error: Authorization failed.", 'paid-memberships-pro' );
|
172 |
return false;
|
173 |
}
|
174 |
}
|
219 |
if($this->void($order))
|
220 |
{
|
221 |
if(!$order->error)
|
222 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
223 |
}
|
224 |
else
|
225 |
{
|
226 |
if(!$order->error)
|
227 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
228 |
|
229 |
+
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", 'paid-memberships-pro' );
|
230 |
}
|
231 |
|
232 |
return false;
|
242 |
else
|
243 |
{
|
244 |
if(empty($order->error))
|
245 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
246 |
|
247 |
return false;
|
248 |
}
|
classes/gateways/class.pmprogateway_payflowpro.php
CHANGED
@@ -36,7 +36,7 @@
|
|
36 |
static function pmpro_gateways($gateways)
|
37 |
{
|
38 |
if(empty($gateways['payflowpro']))
|
39 |
-
$gateways['payflowpro'] = __('Payflow Pro/PayPal Pro', '
|
40 |
|
41 |
return $gateways;
|
42 |
}
|
@@ -92,12 +92,12 @@
|
|
92 |
?>
|
93 |
<tr class="pmpro_settings_divider gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
94 |
<td colspan="2">
|
95 |
-
<?php _e('Payflow Pro Settings', '
|
96 |
</td>
|
97 |
</tr>
|
98 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
99 |
<th scope="row" valign="top">
|
100 |
-
<label for="payflow_partner"><?php _e('Partner', '
|
101 |
</th>
|
102 |
<td>
|
103 |
<input type="text" id="payflow_partner" name="payflow_partner" size="60" value="<?php echo esc_attr($values['payflow_partner'])?>" />
|
@@ -105,7 +105,7 @@
|
|
105 |
</tr>
|
106 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
107 |
<th scope="row" valign="top">
|
108 |
-
<label for="payflow_vendor"><?php _e('Vendor', '
|
109 |
</th>
|
110 |
<td>
|
111 |
<input type="text" id="payflow_vendor" name="payflow_vendor" size="60" value="<?php echo esc_attr($values['payflow_vendor'])?>" />
|
@@ -113,7 +113,7 @@
|
|
113 |
</tr>
|
114 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
115 |
<th scope="row" valign="top">
|
116 |
-
<label for="payflow_user"><?php _e('User', '
|
117 |
</th>
|
118 |
<td>
|
119 |
<input type="text" id="payflow_user" name="payflow_user" size="60" value="<?php echo esc_attr($values['payflow_user'])?>" />
|
@@ -121,7 +121,7 @@
|
|
121 |
</tr>
|
122 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
123 |
<th scope="row" valign="top">
|
124 |
-
<label for="payflow_pwd"><?php _e('Password', '
|
125 |
</th>
|
126 |
<td>
|
127 |
<input type="password" id="payflow_pwd" name="payflow_pwd" size="60" value="<?php echo esc_attr($values['payflow_pwd'])?>" />
|
@@ -129,12 +129,12 @@
|
|
129 |
</tr>
|
130 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
131 |
<th scope="row" valign="top">
|
132 |
-
<label><?php _e('IPN Handler', '
|
133 |
</th>
|
134 |
<td>
|
135 |
<p><?php
|
136 |
$addon_url = "http://www.paidmembershipspro.com/add-ons/plugins-on-github/payflow-recurring-orders-addon/";
|
137 |
-
printf(__('Payflow does not use IPN. To sync recurring subscriptions, please see <a target="_blank" href="%s">this addon</a>.', '
|
138 |
</p>
|
139 |
</td>
|
140 |
</tr>
|
@@ -161,7 +161,7 @@
|
|
161 |
else
|
162 |
{
|
163 |
if(empty($order->error))
|
164 |
-
$order->error = __("Unknown error: Authorization failed.",
|
165 |
return false;
|
166 |
}
|
167 |
}
|
@@ -184,14 +184,14 @@
|
|
184 |
if($this->void($order, $order->payment_transaction_id))
|
185 |
{
|
186 |
if(empty($order->error))
|
187 |
-
$order->error = __("Unknown error: Payment failed.",
|
188 |
}
|
189 |
else
|
190 |
{
|
191 |
if(empty($order->error))
|
192 |
-
$order->error = __("Unknown error: Payment failed.",
|
193 |
|
194 |
-
$order->error .= " " . __("A partial payment was made that we could not refund. Please contact the site owner immediately to correct this.",
|
195 |
}
|
196 |
|
197 |
return false;
|
36 |
static function pmpro_gateways($gateways)
|
37 |
{
|
38 |
if(empty($gateways['payflowpro']))
|
39 |
+
$gateways['payflowpro'] = __('Payflow Pro/PayPal Pro', 'paid-memberships-pro' );
|
40 |
|
41 |
return $gateways;
|
42 |
}
|
92 |
?>
|
93 |
<tr class="pmpro_settings_divider gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
94 |
<td colspan="2">
|
95 |
+
<?php _e('Payflow Pro Settings', 'paid-memberships-pro' ); ?>
|
96 |
</td>
|
97 |
</tr>
|
98 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
99 |
<th scope="row" valign="top">
|
100 |
+
<label for="payflow_partner"><?php _e('Partner', 'paid-memberships-pro' );?>:</label>
|
101 |
</th>
|
102 |
<td>
|
103 |
<input type="text" id="payflow_partner" name="payflow_partner" size="60" value="<?php echo esc_attr($values['payflow_partner'])?>" />
|
105 |
</tr>
|
106 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
107 |
<th scope="row" valign="top">
|
108 |
+
<label for="payflow_vendor"><?php _e('Vendor', 'paid-memberships-pro' );?>:</label>
|
109 |
</th>
|
110 |
<td>
|
111 |
<input type="text" id="payflow_vendor" name="payflow_vendor" size="60" value="<?php echo esc_attr($values['payflow_vendor'])?>" />
|
113 |
</tr>
|
114 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
115 |
<th scope="row" valign="top">
|
116 |
+
<label for="payflow_user"><?php _e('User', 'paid-memberships-pro' );?>:</label>
|
117 |
</th>
|
118 |
<td>
|
119 |
<input type="text" id="payflow_user" name="payflow_user" size="60" value="<?php echo esc_attr($values['payflow_user'])?>" />
|
121 |
</tr>
|
122 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
123 |
<th scope="row" valign="top">
|
124 |
+
<label for="payflow_pwd"><?php _e('Password', 'paid-memberships-pro' );?>:</label>
|
125 |
</th>
|
126 |
<td>
|
127 |
<input type="password" id="payflow_pwd" name="payflow_pwd" size="60" value="<?php echo esc_attr($values['payflow_pwd'])?>" />
|
129 |
</tr>
|
130 |
<tr class="gateway gateway_payflowpro" <?php if($gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
131 |
<th scope="row" valign="top">
|
132 |
+
<label><?php _e('IPN Handler', 'paid-memberships-pro' );?>:</label>
|
133 |
</th>
|
134 |
<td>
|
135 |
<p><?php
|
136 |
$addon_url = "http://www.paidmembershipspro.com/add-ons/plugins-on-github/payflow-recurring-orders-addon/";
|
137 |
+
printf(__('Payflow does not use IPN. To sync recurring subscriptions, please see <a target="_blank" href="%s">this addon</a>.', 'paid-memberships-pro' ), $addon_url);?>
|
138 |
</p>
|
139 |
</td>
|
140 |
</tr>
|
161 |
else
|
162 |
{
|
163 |
if(empty($order->error))
|
164 |
+
$order->error = __("Unknown error: Authorization failed.", 'paid-memberships-pro' );
|
165 |
return false;
|
166 |
}
|
167 |
}
|
184 |
if($this->void($order, $order->payment_transaction_id))
|
185 |
{
|
186 |
if(empty($order->error))
|
187 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
188 |
}
|
189 |
else
|
190 |
{
|
191 |
if(empty($order->error))
|
192 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
193 |
|
194 |
+
$order->error .= " " . __("A partial payment was made that we could not refund. Please contact the site owner immediately to correct this.", 'paid-memberships-pro' );
|
195 |
}
|
196 |
|
197 |
return false;
|
classes/gateways/class.pmprogateway_paypal.php
CHANGED
@@ -65,7 +65,7 @@
|
|
65 |
static function pmpro_gateways($gateways)
|
66 |
{
|
67 |
if(empty($gateways['paypal']))
|
68 |
-
$gateways['paypal'] = __('PayPal Website Payments Pro', '
|
69 |
|
70 |
return $gateways;
|
71 |
}
|
@@ -122,17 +122,17 @@
|
|
122 |
?>
|
123 |
<tr class="pmpro_settings_divider gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
124 |
<td colspan="2">
|
125 |
-
<?php _e('PayPal Settings', '
|
126 |
</td>
|
127 |
</tr>
|
128 |
<tr class="gateway gateway_paypalstandard" <?php if($gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
129 |
<td colspan="2">
|
130 |
-
<strong><?php _e('Note', '
|
131 |
</td>
|
132 |
</tr>
|
133 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
134 |
<th scope="row" valign="top">
|
135 |
-
<label for="gateway_email"><?php _e('Gateway Account Email', '
|
136 |
</th>
|
137 |
<td>
|
138 |
<input type="text" id="gateway_email" name="gateway_email" size="60" value="<?php echo esc_attr($values['gateway_email'])?>" />
|
@@ -140,7 +140,7 @@
|
|
140 |
</tr>
|
141 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
142 |
<th scope="row" valign="top">
|
143 |
-
<label for="apiusername"><?php _e('API Username', '
|
144 |
</th>
|
145 |
<td>
|
146 |
<input type="text" id="apiusername" name="apiusername" size="60" value="<?php echo esc_attr($values['apiusername'])?>" />
|
@@ -148,7 +148,7 @@
|
|
148 |
</tr>
|
149 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
150 |
<th scope="row" valign="top">
|
151 |
-
<label for="apipassword"><?php _e('API Password', '
|
152 |
</th>
|
153 |
<td>
|
154 |
<input type="text" id="apipassword" name="apipassword" size="60" value="<?php echo esc_attr($values['apipassword'])?>" />
|
@@ -156,7 +156,7 @@
|
|
156 |
</tr>
|
157 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
158 |
<th scope="row" valign="top">
|
159 |
-
<label for="apisignature"><?php _e('API Signature', '
|
160 |
</th>
|
161 |
<td>
|
162 |
<input type="text" id="apisignature" name="apisignature" size="60" value="<?php echo esc_attr($values['apisignature'])?>" />
|
@@ -164,7 +164,7 @@
|
|
164 |
</tr>
|
165 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
166 |
<th scope="row" valign="top">
|
167 |
-
<label for="paypalexpress_skip_confirmation"><?php _e('Confirmation Step', '
|
168 |
</th>
|
169 |
<td>
|
170 |
<select id="paypalexpress_skip_confirmation" name="paypalexpress_skip_confirmation">
|
@@ -175,10 +175,10 @@
|
|
175 |
</tr>
|
176 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
177 |
<th scope="row" valign="top">
|
178 |
-
<label><?php _e('IPN Handler URL', '
|
179 |
</th>
|
180 |
<td>
|
181 |
-
<p><?php _e('This URL is passed to PayPal for all new charges and subscriptions. You SHOULD NOT set this in your PayPal account settings.', '
|
182 |
</td>
|
183 |
</tr>
|
184 |
<?php
|
@@ -198,13 +198,13 @@
|
|
198 |
<?php if($gateway == "paypal" || $gateway == "paypalexpress" || $gateway == "paypalstandard") { ?>
|
199 |
<span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
200 |
<input type="hidden" name="submit-checkout" value="1" />
|
201 |
-
<input type="image" class="pmpro_btn-submit-checkout" value="<?php _e('Check Out with PayPal', '
|
202 |
</span>
|
203 |
<?php } ?>
|
204 |
|
205 |
<span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
206 |
<input type="hidden" name="submit-checkout" value="1" />
|
207 |
-
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', '
|
208 |
</span>
|
209 |
<?php
|
210 |
|
@@ -269,7 +269,7 @@
|
|
269 |
else
|
270 |
{
|
271 |
if(empty($order->error))
|
272 |
-
$order->error = __("Unknown error: Authorization failed.",
|
273 |
return false;
|
274 |
}
|
275 |
}
|
@@ -292,14 +292,14 @@
|
|
292 |
if($this->refund($order, $order->payment_transaction_id))
|
293 |
{
|
294 |
if(empty($order->error))
|
295 |
-
$order->error = __("Unknown error: Payment failed.",
|
296 |
}
|
297 |
else
|
298 |
{
|
299 |
if(empty($order->error))
|
300 |
$order->error = "Unknown error: Payment failed.";
|
301 |
|
302 |
-
$order->error .= " " . __("A partial payment was made that we could not refund. Please contact the site owner immediately to correct this.",
|
303 |
}
|
304 |
|
305 |
return false;
|
@@ -628,7 +628,7 @@
|
|
628 |
{
|
629 |
$order->status = "error";
|
630 |
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
631 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']) . ". " . __("Please contact the site owner or cancel your subscription from within PayPal to make sure you are not charged going forward.",
|
632 |
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
633 |
|
634 |
return false;
|
65 |
static function pmpro_gateways($gateways)
|
66 |
{
|
67 |
if(empty($gateways['paypal']))
|
68 |
+
$gateways['paypal'] = __('PayPal Website Payments Pro', 'paid-memberships-pro' );
|
69 |
|
70 |
return $gateways;
|
71 |
}
|
122 |
?>
|
123 |
<tr class="pmpro_settings_divider gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
124 |
<td colspan="2">
|
125 |
+
<?php _e('PayPal Settings', 'paid-memberships-pro' ); ?>
|
126 |
</td>
|
127 |
</tr>
|
128 |
<tr class="gateway gateway_paypalstandard" <?php if($gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
129 |
<td colspan="2">
|
130 |
+
<strong><?php _e('Note', 'paid-memberships-pro' );?>:</strong> <?php _e('We do not recommend using PayPal Standard. We suggest using PayPal Express, Website Payments Pro (Legacy), or PayPal Pro (Payflow Pro). <a target="_blank" href="http://www.paidmembershipspro.com/2013/09/read-using-paypal-standard-paid-memberships-pro/">More information on why can be found here.</a>', 'paid-memberships-pro' );?>
|
131 |
</td>
|
132 |
</tr>
|
133 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
134 |
<th scope="row" valign="top">
|
135 |
+
<label for="gateway_email"><?php _e('Gateway Account Email', 'paid-memberships-pro' );?>:</label>
|
136 |
</th>
|
137 |
<td>
|
138 |
<input type="text" id="gateway_email" name="gateway_email" size="60" value="<?php echo esc_attr($values['gateway_email'])?>" />
|
140 |
</tr>
|
141 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
142 |
<th scope="row" valign="top">
|
143 |
+
<label for="apiusername"><?php _e('API Username', 'paid-memberships-pro' );?>:</label>
|
144 |
</th>
|
145 |
<td>
|
146 |
<input type="text" id="apiusername" name="apiusername" size="60" value="<?php echo esc_attr($values['apiusername'])?>" />
|
148 |
</tr>
|
149 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
150 |
<th scope="row" valign="top">
|
151 |
+
<label for="apipassword"><?php _e('API Password', 'paid-memberships-pro' );?>:</label>
|
152 |
</th>
|
153 |
<td>
|
154 |
<input type="text" id="apipassword" name="apipassword" size="60" value="<?php echo esc_attr($values['apipassword'])?>" />
|
156 |
</tr>
|
157 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
158 |
<th scope="row" valign="top">
|
159 |
+
<label for="apisignature"><?php _e('API Signature', 'paid-memberships-pro' );?>:</label>
|
160 |
</th>
|
161 |
<td>
|
162 |
<input type="text" id="apisignature" name="apisignature" size="60" value="<?php echo esc_attr($values['apisignature'])?>" />
|
164 |
</tr>
|
165 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
166 |
<th scope="row" valign="top">
|
167 |
+
<label for="paypalexpress_skip_confirmation"><?php _e('Confirmation Step', 'paid-memberships-pro' );?>:</label>
|
168 |
</th>
|
169 |
<td>
|
170 |
<select id="paypalexpress_skip_confirmation" name="paypalexpress_skip_confirmation">
|
175 |
</tr>
|
176 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
177 |
<th scope="row" valign="top">
|
178 |
+
<label><?php _e('IPN Handler URL', 'paid-memberships-pro' );?>:</label>
|
179 |
</th>
|
180 |
<td>
|
181 |
+
<p><?php _e('This URL is passed to PayPal for all new charges and subscriptions. You SHOULD NOT set this in your PayPal account settings.', 'paid-memberships-pro' );?><pre><?php echo admin_url("admin-ajax.php") . "?action=ipnhandler";?></pre></p>
|
182 |
</td>
|
183 |
</tr>
|
184 |
<?php
|
198 |
<?php if($gateway == "paypal" || $gateway == "paypalexpress" || $gateway == "paypalstandard") { ?>
|
199 |
<span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
200 |
<input type="hidden" name="submit-checkout" value="1" />
|
201 |
+
<input type="image" class="pmpro_btn-submit-checkout" value="<?php _e('Check Out with PayPal', 'paid-memberships-pro' );?> »" src="<?php echo apply_filters("pmpro_paypal_button_image", "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif");?>" />
|
202 |
</span>
|
203 |
<?php } ?>
|
204 |
|
205 |
<span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
206 |
<input type="hidden" name="submit-checkout" value="1" />
|
207 |
+
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> »" />
|
208 |
</span>
|
209 |
<?php
|
210 |
|
269 |
else
|
270 |
{
|
271 |
if(empty($order->error))
|
272 |
+
$order->error = __("Unknown error: Authorization failed.", 'paid-memberships-pro' );
|
273 |
return false;
|
274 |
}
|
275 |
}
|
292 |
if($this->refund($order, $order->payment_transaction_id))
|
293 |
{
|
294 |
if(empty($order->error))
|
295 |
+
$order->error = __("Unknown error: Payment failed.", 'paid-memberships-pro' );
|
296 |
}
|
297 |
else
|
298 |
{
|
299 |
if(empty($order->error))
|
300 |
$order->error = "Unknown error: Payment failed.";
|
301 |
|
302 |
+
$order->error .= " " . __("A partial payment was made that we could not refund. Please contact the site owner immediately to correct this.", 'paid-memberships-pro' );
|
303 |
}
|
304 |
|
305 |
return false;
|
628 |
{
|
629 |
$order->status = "error";
|
630 |
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
631 |
+
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']) . ". " . __("Please contact the site owner or cancel your subscription from within PayPal to make sure you are not charged going forward.", 'paid-memberships-pro' );
|
632 |
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
633 |
|
634 |
return false;
|
classes/gateways/class.pmprogateway_paypalexpress.php
CHANGED
@@ -81,7 +81,7 @@
|
|
81 |
static function pmpro_gateways($gateways)
|
82 |
{
|
83 |
if(empty($gateways['paypalexpress']))
|
84 |
-
$gateways['paypalexpress'] = __('PayPal Express', '
|
85 |
|
86 |
return $gateways;
|
87 |
}
|
@@ -137,17 +137,17 @@
|
|
137 |
?>
|
138 |
<tr class="pmpro_settings_divider gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
139 |
<td colspan="2">
|
140 |
-
<?php _e('PayPal Settings', '
|
141 |
</td>
|
142 |
</tr>
|
143 |
<tr class="gateway gateway_paypalstandard" <?php if($gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
144 |
<td colspan="2">
|
145 |
-
<strong><?php _e('Note', '
|
146 |
</td>
|
147 |
</tr>
|
148 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
149 |
<th scope="row" valign="top">
|
150 |
-
<label for="gateway_email"><?php _e('Gateway Account Email', '
|
151 |
</th>
|
152 |
<td>
|
153 |
<input type="text" id="gateway_email" name="gateway_email" size="60" value="<?php echo esc_attr($values['gateway_email'])?>" />
|
@@ -155,7 +155,7 @@
|
|
155 |
</tr>
|
156 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
157 |
<th scope="row" valign="top">
|
158 |
-
<label for="apiusername"><?php _e('API Username', '
|
159 |
</th>
|
160 |
<td>
|
161 |
<input type="text" id="apiusername" name="apiusername" size="60" value="<?php echo esc_attr($values['apiusername'])?>" />
|
@@ -163,7 +163,7 @@
|
|
163 |
</tr>
|
164 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
165 |
<th scope="row" valign="top">
|
166 |
-
<label for="apipassword"><?php _e('API Password', '
|
167 |
</th>
|
168 |
<td>
|
169 |
<input type="text" id="apipassword" name="apipassword" size="60" value="<?php echo esc_attr($values['apipassword'])?>" />
|
@@ -171,7 +171,7 @@
|
|
171 |
</tr>
|
172 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
173 |
<th scope="row" valign="top">
|
174 |
-
<label for="apisignature"><?php _e('API Signature', '
|
175 |
</th>
|
176 |
<td>
|
177 |
<input type="text" id="apisignature" name="apisignature" size="60" value="<?php echo esc_attr($values['apisignature'])?>" />
|
@@ -179,7 +179,7 @@
|
|
179 |
</tr>
|
180 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
181 |
<th scope="row" valign="top">
|
182 |
-
<label for="paypalexpress_skip_confirmation"><?php _e('Confirmation Step', '
|
183 |
</th>
|
184 |
<td>
|
185 |
<select id="paypalexpress_skip_confirmation" name="paypalexpress_skip_confirmation">
|
@@ -190,10 +190,10 @@
|
|
190 |
</tr>
|
191 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
192 |
<th scope="row" valign="top">
|
193 |
-
<label><?php _e('IPN Handler URL', '
|
194 |
</th>
|
195 |
<td>
|
196 |
-
<p><?php _e('To fully integrate with PayPal, be sure to set your IPN Handler URL to ', '
|
197 |
</td>
|
198 |
</tr>
|
199 |
<?php
|
@@ -298,7 +298,7 @@
|
|
298 |
}
|
299 |
else
|
300 |
{
|
301 |
-
$pmpro_msg = __("The PayPal Token was lost.",
|
302 |
$pmpro_msgt = "pmpro_error";
|
303 |
}
|
304 |
}
|
@@ -354,7 +354,7 @@
|
|
354 |
}
|
355 |
else
|
356 |
{
|
357 |
-
$pmpro_msg = __("The PayPal Token was lost.",
|
358 |
$pmpro_msgt = "pmpro_error";
|
359 |
}
|
360 |
}
|
@@ -435,12 +435,12 @@
|
|
435 |
?>
|
436 |
<span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
437 |
<input type="hidden" name="submit-checkout" value="1" />
|
438 |
-
<input type="image" class="pmpro_btn-submit-checkout" value="<?php _e('Check Out with PayPal', '
|
439 |
</span>
|
440 |
|
441 |
<span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
442 |
<input type="hidden" name="submit-checkout" value="1" />
|
443 |
-
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', '
|
444 |
</span>
|
445 |
<?php
|
446 |
|
@@ -774,7 +774,7 @@
|
|
774 |
{
|
775 |
$order->status = "error";
|
776 |
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
777 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']) . ". " . __("Please contact the site owner or cancel your subscription from within PayPal to make sure you are not charged going forward.",
|
778 |
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
779 |
|
780 |
return false;
|
81 |
static function pmpro_gateways($gateways)
|
82 |
{
|
83 |
if(empty($gateways['paypalexpress']))
|
84 |
+
$gateways['paypalexpress'] = __('PayPal Express', 'paid-memberships-pro' );
|
85 |
|
86 |
return $gateways;
|
87 |
}
|
137 |
?>
|
138 |
<tr class="pmpro_settings_divider gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
139 |
<td colspan="2">
|
140 |
+
<?php _e('PayPal Settings', 'paid-memberships-pro' ); ?>
|
141 |
</td>
|
142 |
</tr>
|
143 |
<tr class="gateway gateway_paypalstandard" <?php if($gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
144 |
<td colspan="2">
|
145 |
+
<strong><?php _e('Note', 'paid-memberships-pro' );?>:</strong> <?php _e('We do not recommend using PayPal Standard. We suggest using PayPal Express, Website Payments Pro (Legacy), or PayPal Pro (Payflow Pro). <a target="_blank" href="http://www.paidmembershipspro.com/2013/09/read-using-paypal-standard-paid-memberships-pro/">More information on why can be found here.</a>', 'paid-memberships-pro' );?>
|
146 |
</td>
|
147 |
</tr>
|
148 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
149 |
<th scope="row" valign="top">
|
150 |
+
<label for="gateway_email"><?php _e('Gateway Account Email', 'paid-memberships-pro' );?>:</label>
|
151 |
</th>
|
152 |
<td>
|
153 |
<input type="text" id="gateway_email" name="gateway_email" size="60" value="<?php echo esc_attr($values['gateway_email'])?>" />
|
155 |
</tr>
|
156 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
157 |
<th scope="row" valign="top">
|
158 |
+
<label for="apiusername"><?php _e('API Username', 'paid-memberships-pro' );?>:</label>
|
159 |
</th>
|
160 |
<td>
|
161 |
<input type="text" id="apiusername" name="apiusername" size="60" value="<?php echo esc_attr($values['apiusername'])?>" />
|
163 |
</tr>
|
164 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
165 |
<th scope="row" valign="top">
|
166 |
+
<label for="apipassword"><?php _e('API Password', 'paid-memberships-pro' );?>:</label>
|
167 |
</th>
|
168 |
<td>
|
169 |
<input type="text" id="apipassword" name="apipassword" size="60" value="<?php echo esc_attr($values['apipassword'])?>" />
|
171 |
</tr>
|
172 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
173 |
<th scope="row" valign="top">
|
174 |
+
<label for="apisignature"><?php _e('API Signature', 'paid-memberships-pro' );?>:</label>
|
175 |
</th>
|
176 |
<td>
|
177 |
<input type="text" id="apisignature" name="apisignature" size="60" value="<?php echo esc_attr($values['apisignature'])?>" />
|
179 |
</tr>
|
180 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
181 |
<th scope="row" valign="top">
|
182 |
+
<label for="paypalexpress_skip_confirmation"><?php _e('Confirmation Step', 'paid-memberships-pro' );?>:</label>
|
183 |
</th>
|
184 |
<td>
|
185 |
<select id="paypalexpress_skip_confirmation" name="paypalexpress_skip_confirmation">
|
190 |
</tr>
|
191 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
192 |
<th scope="row" valign="top">
|
193 |
+
<label><?php _e('IPN Handler URL', 'paid-memberships-pro' );?>:</label>
|
194 |
</th>
|
195 |
<td>
|
196 |
+
<p><?php _e('To fully integrate with PayPal, be sure to set your IPN Handler URL to ', 'paid-memberships-pro' );?> <pre><?php echo admin_url("admin-ajax.php") . "?action=ipnhandler";?></pre></p>
|
197 |
</td>
|
198 |
</tr>
|
199 |
<?php
|
298 |
}
|
299 |
else
|
300 |
{
|
301 |
+
$pmpro_msg = __("The PayPal Token was lost.", 'paid-memberships-pro' );
|
302 |
$pmpro_msgt = "pmpro_error";
|
303 |
}
|
304 |
}
|
354 |
}
|
355 |
else
|
356 |
{
|
357 |
+
$pmpro_msg = __("The PayPal Token was lost.", 'paid-memberships-pro' );
|
358 |
$pmpro_msgt = "pmpro_error";
|
359 |
}
|
360 |
}
|
435 |
?>
|
436 |
<span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
437 |
<input type="hidden" name="submit-checkout" value="1" />
|
438 |
+
<input type="image" class="pmpro_btn-submit-checkout" value="<?php _e('Check Out with PayPal', 'paid-memberships-pro' );?> »" src="<?php echo apply_filters("pmpro_paypal_button_image", "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif");?>" />
|
439 |
</span>
|
440 |
|
441 |
<span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
442 |
<input type="hidden" name="submit-checkout" value="1" />
|
443 |
+
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> »" />
|
444 |
</span>
|
445 |
<?php
|
446 |
|
774 |
{
|
775 |
$order->status = "error";
|
776 |
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
777 |
+
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']) . ". " . __("Please contact the site owner or cancel your subscription from within PayPal to make sure you are not charged going forward.", 'paid-memberships-pro' );
|
778 |
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
779 |
|
780 |
return false;
|
classes/gateways/class.pmprogateway_paypalstandard.php
CHANGED
@@ -57,7 +57,7 @@
|
|
57 |
static function pmpro_gateways($gateways)
|
58 |
{
|
59 |
if(empty($gateways['paypalstandard']))
|
60 |
-
$gateways['paypalstandard'] = __('PayPal Standard', '
|
61 |
|
62 |
return $gateways;
|
63 |
}
|
@@ -109,17 +109,17 @@
|
|
109 |
?>
|
110 |
<tr class="pmpro_settings_divider gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
111 |
<td colspan="2">
|
112 |
-
<?php _e('PayPal Settings', '
|
113 |
</td>
|
114 |
</tr>
|
115 |
<tr class="gateway gateway_paypalstandard" <?php if($gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
116 |
<td colspan="2">
|
117 |
-
<strong><?php _e('Note', '
|
118 |
</td>
|
119 |
</tr>
|
120 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
121 |
<th scope="row" valign="top">
|
122 |
-
<label for="gateway_email"><?php _e('Gateway Account Email', '
|
123 |
</th>
|
124 |
<td>
|
125 |
<input type="text" id="gateway_email" name="gateway_email" size="60" value="<?php echo esc_attr($values['gateway_email'])?>" />
|
@@ -127,7 +127,7 @@
|
|
127 |
</tr>
|
128 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
129 |
<th scope="row" valign="top">
|
130 |
-
<label for="apiusername"><?php _e('API Username', '
|
131 |
</th>
|
132 |
<td>
|
133 |
<input type="text" id="apiusername" name="apiusername" size="60" value="<?php echo esc_attr($values['apiusername'])?>" />
|
@@ -135,7 +135,7 @@
|
|
135 |
</tr>
|
136 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
137 |
<th scope="row" valign="top">
|
138 |
-
<label for="apipassword"><?php _e('API Password', '
|
139 |
</th>
|
140 |
<td>
|
141 |
<input type="text" id="apipassword" name="apipassword" size="60" value="<?php echo esc_attr($values['apipassword'])?>" />
|
@@ -143,7 +143,7 @@
|
|
143 |
</tr>
|
144 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
145 |
<th scope="row" valign="top">
|
146 |
-
<label for="apisignature"><?php _e('API Signature', '
|
147 |
</th>
|
148 |
<td>
|
149 |
<input type="text" id="apisignature" name="apisignature" size="60" value="<?php echo esc_attr($values['apisignature'])?>" />
|
@@ -151,10 +151,10 @@
|
|
151 |
</tr>
|
152 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
153 |
<th scope="row" valign="top">
|
154 |
-
<label><?php _e('IPN Handler URL', '
|
155 |
</th>
|
156 |
<td>
|
157 |
-
<p><?php _e('Here is your IPN URL for reference. You SHOULD NOT set this in your PayPal settings.', '
|
158 |
</td>
|
159 |
</tr>
|
160 |
<?php
|
@@ -198,12 +198,12 @@
|
|
198 |
?>
|
199 |
<span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
200 |
<input type="hidden" name="submit-checkout" value="1" />
|
201 |
-
<input type="image" value="<?php _e('Check Out with PayPal', '
|
202 |
</span>
|
203 |
|
204 |
<span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
205 |
<input type="hidden" name="submit-checkout" value="1" />
|
206 |
-
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', '
|
207 |
</span>
|
208 |
<?php
|
209 |
|
@@ -461,7 +461,7 @@
|
|
461 |
{
|
462 |
$order->status = "error";
|
463 |
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
464 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']) . ". " . __("Please contact the site owner or cancel your subscription from within PayPal to make sure you are not charged going forward.",
|
465 |
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
466 |
|
467 |
return false;
|
57 |
static function pmpro_gateways($gateways)
|
58 |
{
|
59 |
if(empty($gateways['paypalstandard']))
|
60 |
+
$gateways['paypalstandard'] = __('PayPal Standard', 'paid-memberships-pro' );
|
61 |
|
62 |
return $gateways;
|
63 |
}
|
109 |
?>
|
110 |
<tr class="pmpro_settings_divider gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
111 |
<td colspan="2">
|
112 |
+
<?php _e('PayPal Settings', 'paid-memberships-pro' ); ?>
|
113 |
</td>
|
114 |
</tr>
|
115 |
<tr class="gateway gateway_paypalstandard" <?php if($gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
116 |
<td colspan="2">
|
117 |
+
<strong><?php _e('Note', 'paid-memberships-pro' );?>:</strong> <?php _e('We do not recommend using PayPal Standard. We suggest using PayPal Express, Website Payments Pro (Legacy), or PayPal Pro (Payflow Pro). <a target="_blank" href="http://www.paidmembershipspro.com/2013/09/read-using-paypal-standard-paid-memberships-pro/">More information on why can be found here.</a>', 'paid-memberships-pro' );?>
|
118 |
</td>
|
119 |
</tr>
|
120 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
121 |
<th scope="row" valign="top">
|
122 |
+
<label for="gateway_email"><?php _e('Gateway Account Email', 'paid-memberships-pro' );?>:</label>
|
123 |
</th>
|
124 |
<td>
|
125 |
<input type="text" id="gateway_email" name="gateway_email" size="60" value="<?php echo esc_attr($values['gateway_email'])?>" />
|
127 |
</tr>
|
128 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
129 |
<th scope="row" valign="top">
|
130 |
+
<label for="apiusername"><?php _e('API Username', 'paid-memberships-pro' );?>:</label>
|
131 |
</th>
|
132 |
<td>
|
133 |
<input type="text" id="apiusername" name="apiusername" size="60" value="<?php echo esc_attr($values['apiusername'])?>" />
|
135 |
</tr>
|
136 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
137 |
<th scope="row" valign="top">
|
138 |
+
<label for="apipassword"><?php _e('API Password', 'paid-memberships-pro' );?>:</label>
|
139 |
</th>
|
140 |
<td>
|
141 |
<input type="text" id="apipassword" name="apipassword" size="60" value="<?php echo esc_attr($values['apipassword'])?>" />
|
143 |
</tr>
|
144 |
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
145 |
<th scope="row" valign="top">
|
146 |
+
<label for="apisignature"><?php _e('API Signature', 'paid-memberships-pro' );?>:</label>
|
147 |
</th>
|
148 |
<td>
|
149 |
<input type="text" id="apisignature" name="apisignature" size="60" value="<?php echo esc_attr($values['apisignature'])?>" />
|
151 |
</tr>
|
152 |
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard") { ?>style="display: none;"<?php } ?>>
|
153 |
<th scope="row" valign="top">
|
154 |
+
<label><?php _e('IPN Handler URL', 'paid-memberships-pro' );?>:</label>
|
155 |
</th>
|
156 |
<td>
|
157 |
+
<p><?php _e('Here is your IPN URL for reference. You SHOULD NOT set this in your PayPal settings.', 'paid-memberships-pro' );?> <pre><?php echo admin_url("admin-ajax.php") . "?action=ipnhandler";?></pre></p>
|
158 |
</td>
|
159 |
</tr>
|
160 |
<?php
|
198 |
?>
|
199 |
<span id="pmpro_paypalexpress_checkout" <?php if(($gateway != "paypalexpress" && $gateway != "paypalstandard") || !$pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
200 |
<input type="hidden" name="submit-checkout" value="1" />
|
201 |
+
<input type="image" value="<?php _e('Check Out with PayPal', 'paid-memberships-pro' );?> »" src="<?php echo apply_filters("pmpro_paypal_button_image", "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif");?>" />
|
202 |
</span>
|
203 |
|
204 |
<span id="pmpro_submit_span" <?php if(($gateway == "paypalexpress" || $gateway == "paypalstandard") && $pmpro_requirebilling) { ?>style="display: none;"<?php } ?>>
|
205 |
<input type="hidden" name="submit-checkout" value="1" />
|
206 |
+
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Submit and Check Out', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> »" />
|
207 |
</span>
|
208 |
<?php
|
209 |
|
461 |
{
|
462 |
$order->status = "error";
|
463 |
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
464 |
+
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']) . ". " . __("Please contact the site owner or cancel your subscription from within PayPal to make sure you are not charged going forward.", 'paid-memberships-pro' );
|
465 |
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
466 |
|
467 |
return false;
|
classes/gateways/class.pmprogateway_stripe.php
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
//include pmprogateway
|
3 |
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
4 |
|
@@ -18,6 +24,10 @@
|
|
18 |
*/
|
19 |
class PMProGateway_stripe extends PMProGateway
|
20 |
{
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* Stripe Class Constructor
|
23 |
*
|
@@ -28,12 +38,11 @@
|
|
28 |
$this->gateway = $gateway;
|
29 |
$this->gateway_environment = pmpro_getOption("gateway_environment");
|
30 |
|
31 |
-
if($this->dependencies()) {
|
32 |
$this->loadStripeLibrary();
|
33 |
-
Stripe::setApiKey(pmpro_getOption("stripe_secretkey"));
|
34 |
-
Stripe::setAPIVersion("2015-07-13");
|
35 |
-
|
36 |
-
return false;
|
37 |
}
|
38 |
|
39 |
return $this->gateway;
|
@@ -44,18 +53,32 @@
|
|
44 |
*
|
45 |
* @return bool
|
46 |
* @since 1.8.6.8.1
|
|
|
47 |
*/
|
48 |
public static function dependencies()
|
49 |
{
|
50 |
global $msg, $msgt, $pmpro_stripe_error;
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
foreach($modules as $module){
|
55 |
if(!extension_loaded($module)){
|
56 |
$pmpro_stripe_error = true;
|
57 |
$msg = -1;
|
58 |
-
$msgt = sprintf(__("The %s gateway depends on the %s PHP extension. Please enable it, or ask your hosting provider to enable it.",
|
59 |
|
60 |
//throw error on checkout page
|
61 |
if(!is_admin())
|
@@ -64,7 +87,8 @@
|
|
64 |
return false;
|
65 |
}
|
66 |
}
|
67 |
-
|
|
|
68 |
return true;
|
69 |
}
|
70 |
|
@@ -77,8 +101,9 @@
|
|
77 |
function loadStripeLibrary()
|
78 |
{
|
79 |
//load Stripe library if it hasn't been loaded already (usually by another plugin using Stripe)
|
80 |
-
if(!class_exists("Stripe"))
|
81 |
-
|
|
|
82 |
}
|
83 |
|
84 |
/**
|
@@ -119,8 +144,9 @@
|
|
119 |
|
120 |
//code to add at checkout if Stripe is the current gateway
|
121 |
$default_gateway = pmpro_getOption('gateway');
|
122 |
-
$current_gateway = pmpro_getGateway();
|
123 |
-
|
|
|
124 |
{
|
125 |
add_action('pmpro_checkout_preheader', array('PMProGateway_stripe', 'pmpro_checkout_preheader'));
|
126 |
add_action('pmpro_billing_preheader', array('PMProGateway_stripe', 'pmpro_checkout_preheader'));
|
@@ -140,7 +166,7 @@
|
|
140 |
static function pmpro_gateways($gateways)
|
141 |
{
|
142 |
if(empty($gateways['stripe']))
|
143 |
-
$gateways['stripe'] = __('Stripe', '
|
144 |
|
145 |
return $gateways;
|
146 |
}
|
@@ -177,7 +203,7 @@
|
|
177 |
static function pmpro_payment_options($options)
|
178 |
{
|
179 |
//get stripe options
|
180 |
-
$stripe_options =
|
181 |
|
182 |
//merge with others.
|
183 |
$options = array_merge($stripe_options, $options);
|
@@ -195,12 +221,12 @@
|
|
195 |
?>
|
196 |
<tr class="pmpro_settings_divider gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
197 |
<td colspan="2">
|
198 |
-
<?php _e('Stripe Settings', '
|
199 |
</td>
|
200 |
</tr>
|
201 |
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
202 |
<th scope="row" valign="top">
|
203 |
-
<label for="stripe_secretkey"><?php _e('Secret Key', '
|
204 |
</th>
|
205 |
<td>
|
206 |
<input type="text" id="stripe_secretkey" name="stripe_secretkey" size="60" value="<?php echo esc_attr($values['stripe_secretkey'])?>" />
|
@@ -208,7 +234,7 @@
|
|
208 |
</tr>
|
209 |
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
210 |
<th scope="row" valign="top">
|
211 |
-
<label for="stripe_publishablekey"><?php _e('Publishable Key', '
|
212 |
</th>
|
213 |
<td>
|
214 |
<input type="text" id="stripe_publishablekey" name="stripe_publishablekey" size="60" value="<?php echo esc_attr($values['stripe_publishablekey'])?>" />
|
@@ -216,22 +242,22 @@
|
|
216 |
</tr>
|
217 |
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
218 |
<th scope="row" valign="top">
|
219 |
-
<label for="stripe_billingaddress"><?php _e('Show Billing Address Fields', '
|
220 |
</th>
|
221 |
<td>
|
222 |
<select id="stripe_billingaddress" name="stripe_billingaddress">
|
223 |
-
<option value="0" <?php if(empty($values['stripe_billingaddress'])) { ?>selected="selected"<?php } ?>><?php _e('No', '
|
224 |
-
<option value="1" <?php if(!empty($values['stripe_billingaddress'])) { ?>selected="selected"<?php } ?>><?php _e('Yes', '
|
225 |
</select>
|
226 |
-
<small><?php _e("Stripe doesn't require billing address fields. Choose 'No' to hide them on the checkout page.<br /><strong>If No, make sure you disable address verification in the Stripe dashboard settings.</strong>", '
|
227 |
</td>
|
228 |
</tr>
|
229 |
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
230 |
<th scope="row" valign="top">
|
231 |
-
<label><?php _e('Web Hook URL', '
|
232 |
</th>
|
233 |
<td>
|
234 |
-
<p><?php _e('To fully integrate with Stripe, be sure to set your Web Hook URL to', '
|
235 |
</td>
|
236 |
</tr>
|
237 |
<?php
|
@@ -457,7 +483,7 @@
|
|
457 |
|
458 |
if($gateway == "stripe")
|
459 |
{
|
460 |
-
if(!empty($morder) && !empty($morder->Gateway) && !empty($morder->Gateway->customer) && !empty($morder->Gateway->customer->id))
|
461 |
{
|
462 |
update_user_meta($user_id, "pmpro_stripe_customerid", $morder->Gateway->customer->id);
|
463 |
}
|
@@ -497,8 +523,8 @@
|
|
497 |
<thead>
|
498 |
<tr>
|
499 |
<th>
|
500 |
-
<span class="pmpro_thead-name"><?php _e('Payment Information', '
|
501 |
-
<span class="pmpro_thead-msg"><?php printf(__('We Accept %s', '
|
502 |
</th>
|
503 |
</tr>
|
504 |
</thead>
|
@@ -520,7 +546,7 @@
|
|
520 |
{
|
521 |
?>
|
522 |
<div class="pmpro_payment-card-type">
|
523 |
-
<label for="CardType"><?php _e('Card Type', '
|
524 |
<select id="CardType" class=" <?php echo pmpro_getClassForField("CardType");?>">
|
525 |
<?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
|
526 |
<option value="<?php echo $cc?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc?></option>
|
@@ -563,12 +589,12 @@
|
|
563 |
?>
|
564 |
|
565 |
<div class="pmpro_payment-account-number">
|
566 |
-
<label for="AccountNumber"><?php _e('Card Number', '
|
567 |
<input id="AccountNumber" class="input <?php echo pmpro_getClassForField("AccountNumber");?>" type="text" size="25" value="<?php echo esc_attr($AccountNumber)?>" autocomplete="off" />
|
568 |
</div>
|
569 |
|
570 |
<div class="pmpro_payment-expiration">
|
571 |
-
<label for="ExpirationMonth"><?php _e('Expiration Date', '
|
572 |
<select id="ExpirationMonth" class=" <?php echo pmpro_getClassForField("ExpirationMonth");?>">
|
573 |
<option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
|
574 |
<option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
|
@@ -600,8 +626,8 @@
|
|
600 |
{
|
601 |
?>
|
602 |
<div class="pmpro_payment-cvv">
|
603 |
-
<label for="CVV"><?php _e('CVV', '
|
604 |
-
<input id="CVV" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr($_REQUEST['CVV']); }?>" class="input <?php echo pmpro_getClassForField("CVV");?>" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter(PMPRO_URL)?>/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", '
|
605 |
</div>
|
606 |
<?php
|
607 |
}
|
@@ -609,9 +635,9 @@
|
|
609 |
|
610 |
<?php if($pmpro_show_discount_code) { ?>
|
611 |
<div class="pmpro_payment-discount-code">
|
612 |
-
<label for="discount_code"><?php _e('Discount Code', '
|
613 |
<input class="input <?php echo pmpro_getClassForField("discount_code");?>" id="discount_code" name="discount_code" type="text" size="20" value="<?php echo esc_attr($discount_code)?>" />
|
614 |
-
<input type="button" id="discount_code_button" name="discount_code_button" value="<?php _e('Apply', '
|
615 |
<p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
|
616 |
</div>
|
617 |
<?php } ?>
|
@@ -635,7 +661,7 @@
|
|
635 |
{
|
636 |
global $wpdb, $current_user, $pmpro_currency_symbol;
|
637 |
|
638 |
-
$cycles = array( __('Day(s)', '
|
639 |
$current_year = date_i18n("Y");
|
640 |
$current_month = date_i18n("m");
|
641 |
|
@@ -657,7 +683,7 @@
|
|
657 |
$sub = false;
|
658 |
|
659 |
//check that gateway is Stripe
|
660 |
-
if($last_order->gateway == "stripe")
|
661 |
{
|
662 |
//is there a customer?
|
663 |
$sub = $last_order->Gateway->getSubscription($last_order);
|
@@ -674,25 +700,25 @@
|
|
674 |
if(!empty($last_order) && $last_order->gateway == "stripe" && !empty($last_order->subscription_transaction_id) && strpos($last_order->subscription_transaction_id, "sub_") !== false)
|
675 |
{
|
676 |
?>
|
677 |
-
<p
|
678 |
<?php
|
679 |
}
|
680 |
}
|
681 |
-
|
682 |
{
|
683 |
?>
|
684 |
-
<h3><?php _e("Subscription Updates",
|
685 |
<p>
|
686 |
<?php
|
687 |
if(empty($_REQUEST['user_id']))
|
688 |
-
_e("Subscription updates, allow you to change the member's subscription values at predefined times. Be sure to click Update Profile after making changes.", '
|
689 |
else
|
690 |
-
_e("Subscription updates, allow you to change the member's subscription values at predefined times. Be sure to click Update User after making changes.", '
|
691 |
?>
|
692 |
</p>
|
693 |
<table class="form-table">
|
694 |
<tr>
|
695 |
-
<th><label for="membership_level"><?php _e("Update",
|
696 |
<td id="updates_td">
|
697 |
<?php
|
698 |
$old_updates = $user->pmpro_stripe_updates;
|
@@ -733,7 +759,7 @@
|
|
733 |
</span>
|
734 |
<span class="updates_billing" <?php if($update['when'] == "now") { ?>style="display: none;"<?php } ?>>
|
735 |
<?php echo $pmpro_currency_symbol?><input name="updates_billing_amount[]" type="text" size="10" value="<?php echo esc_attr($update['billing_amount']);?>" />
|
736 |
-
<small><?php _e('per', '
|
737 |
<input name="updates_cycle_number[]" type="text" size="5" value="<?php echo esc_attr($update['cycle_number']);?>" />
|
738 |
<select name="updates_cycle_period[]">
|
739 |
<?php
|
@@ -885,7 +911,7 @@
|
|
885 |
//throw error and halt save
|
886 |
function pmpro_stripe_user_profile_fields_save_error($errors, $update, $user)
|
887 |
{
|
888 |
-
$errors->add('pmpro_stripe_updates',__('Could not cancel the old subscription. Updates have not been processed.', '
|
889 |
}
|
890 |
add_filter('user_profile_update_errors', 'pmpro_stripe_user_profile_fields_save_error', 10, 3);
|
891 |
|
@@ -1140,9 +1166,18 @@
|
|
1140 |
}
|
1141 |
else
|
1142 |
{
|
1143 |
-
if(empty($order->error))
|
1144 |
-
|
1145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1146 |
}
|
1147 |
}
|
1148 |
}
|
@@ -1372,7 +1407,7 @@
|
|
1372 |
}
|
1373 |
catch (Exception $e)
|
1374 |
{
|
1375 |
-
$order->error = __("Error creating customer record with Stripe:",
|
1376 |
$order->shorterror = $order->error;
|
1377 |
return false;
|
1378 |
}
|
@@ -1431,7 +1466,7 @@
|
|
1431 |
}
|
1432 |
catch (Exception $e)
|
1433 |
{
|
1434 |
-
$order->error = __("Error getting subscription with Stripe:",
|
1435 |
$order->shorterror = $order->error;
|
1436 |
return false;
|
1437 |
}
|
@@ -1587,7 +1622,7 @@
|
|
1587 |
}
|
1588 |
catch (Exception $e)
|
1589 |
{
|
1590 |
-
$order->error = __("Error creating plan with Stripe:",
|
1591 |
$order->shorterror = $order->error;
|
1592 |
return false;
|
1593 |
}
|
@@ -1618,7 +1653,7 @@
|
|
1618 |
update_user_meta($user_id, "pmpro_stripe_updates", $old_user_updates);
|
1619 |
|
1620 |
//return error
|
1621 |
-
$order->error = __("Error subscribing customer to plan with Stripe:",
|
1622 |
$order->shorterror = $order->error;
|
1623 |
return false;
|
1624 |
}
|
@@ -1714,7 +1749,7 @@
|
|
1714 |
}
|
1715 |
else
|
1716 |
{
|
1717 |
-
$order->error = __("Could not cancel old subscription.",
|
1718 |
$order->shorterror = $order->error;
|
1719 |
|
1720 |
return false;
|
@@ -1731,7 +1766,7 @@
|
|
1731 |
}
|
1732 |
else
|
1733 |
{
|
1734 |
-
$order->error = __("Could not find the customer.",
|
1735 |
$order->shorterror = $order->error;
|
1736 |
return false; //no customer found
|
1737 |
}
|
@@ -1809,7 +1844,7 @@
|
|
1809 |
$order = new MemberOrder();
|
1810 |
$order->getLastMemberOrder($user_id, $order_status);
|
1811 |
|
1812 |
-
//check if this is a
|
1813 |
if(!empty($order->id) && !empty($order->subscription_transaction_id) && $order->gateway == "stripe")
|
1814 |
{
|
1815 |
//get the subscription and return the current_period end or false
|
@@ -1883,7 +1918,7 @@
|
|
1883 |
{
|
1884 |
//$order->status = "error";
|
1885 |
$order->errorcode = true;
|
1886 |
-
$order->error = __("Error: ",
|
1887 |
$order->shorterror = $order->error;
|
1888 |
return false;
|
1889 |
}
|
@@ -1896,7 +1931,7 @@
|
|
1896 |
} else {
|
1897 |
$order->status = "error";
|
1898 |
$order->errorcode = true;
|
1899 |
-
$order->error = sprintf(__("Error: Unkown error while refunding charge #%s",
|
1900 |
$order->shorterror = $order->error;
|
1901 |
|
1902 |
return false;
|
1 |
<?php
|
2 |
+
// For compatibility with old library (Namespace Alias)
|
3 |
+
use Stripe\Customer as Stripe_Customer;
|
4 |
+
use Stripe\Invoice as Stripe_Invoice;
|
5 |
+
use Stripe\Plan as Stripe_Plan;
|
6 |
+
use Stripe\Charge as Stripe_Charge;
|
7 |
+
|
8 |
//include pmprogateway
|
9 |
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
10 |
|
24 |
*/
|
25 |
class PMProGateway_stripe extends PMProGateway
|
26 |
{
|
27 |
+
/**
|
28 |
+
* @var bool Is the Stripe/PHP Library loaded
|
29 |
+
*/
|
30 |
+
private static $is_loaded = false;
|
31 |
/**
|
32 |
* Stripe Class Constructor
|
33 |
*
|
38 |
$this->gateway = $gateway;
|
39 |
$this->gateway_environment = pmpro_getOption("gateway_environment");
|
40 |
|
41 |
+
if( true === $this->dependencies() ) {
|
42 |
$this->loadStripeLibrary();
|
43 |
+
Stripe\Stripe::setApiKey(pmpro_getOption("stripe_secretkey"));
|
44 |
+
Stripe\Stripe::setAPIVersion("2015-07-13");
|
45 |
+
self::$is_loaded = true;
|
|
|
46 |
}
|
47 |
|
48 |
return $this->gateway;
|
53 |
*
|
54 |
* @return bool
|
55 |
* @since 1.8.6.8.1
|
56 |
+
* @since 1.8.13.6 - Add json dependency
|
57 |
*/
|
58 |
public static function dependencies()
|
59 |
{
|
60 |
global $msg, $msgt, $pmpro_stripe_error;
|
61 |
|
62 |
+
if ( version_compare( PHP_VERSION, '5.3.29', '<' )) {
|
63 |
+
|
64 |
+
$pmpro_stripe_error = true;
|
65 |
+
$msg = -1;
|
66 |
+
$msgt = sprintf(__("The Stripe Gateway requires PHP 5.3.29 or greater. We recommend upgrading to PHP %s or greater. Ask your host to upgrade.", "paid-memberships-pro" ), PMPRO_PHP_MIN_VERSION );
|
67 |
+
|
68 |
+
if ( !is_admin() ) {
|
69 |
+
pmpro_setMessage( $msgt, "pmpro_error" );
|
70 |
+
}
|
71 |
+
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
$modules = array( 'curl', 'mbstring', 'json' );
|
76 |
|
77 |
foreach($modules as $module){
|
78 |
if(!extension_loaded($module)){
|
79 |
$pmpro_stripe_error = true;
|
80 |
$msg = -1;
|
81 |
+
$msgt = sprintf(__("The %s gateway depends on the %s PHP extension. Please enable it, or ask your hosting provider to enable it.", 'paid-memberships-pro' ), 'Stripe', $module);
|
82 |
|
83 |
//throw error on checkout page
|
84 |
if(!is_admin())
|
87 |
return false;
|
88 |
}
|
89 |
}
|
90 |
+
|
91 |
+
self::$is_loaded = true;
|
92 |
return true;
|
93 |
}
|
94 |
|
101 |
function loadStripeLibrary()
|
102 |
{
|
103 |
//load Stripe library if it hasn't been loaded already (usually by another plugin using Stripe)
|
104 |
+
if(!class_exists("\\Stripe")) {
|
105 |
+
require_once( PMPRO_DIR . "/includes/lib/Stripe/init.php" );
|
106 |
+
}
|
107 |
}
|
108 |
|
109 |
/**
|
144 |
|
145 |
//code to add at checkout if Stripe is the current gateway
|
146 |
$default_gateway = pmpro_getOption('gateway');
|
147 |
+
$current_gateway = pmpro_getGateway();
|
148 |
+
|
149 |
+
if( ($default_gateway == "stripe" || $current_gateway == "stripe") && empty($_REQUEST['review'] ) ) //$_REQUEST['review'] means the PayPal Express review page
|
150 |
{
|
151 |
add_action('pmpro_checkout_preheader', array('PMProGateway_stripe', 'pmpro_checkout_preheader'));
|
152 |
add_action('pmpro_billing_preheader', array('PMProGateway_stripe', 'pmpro_checkout_preheader'));
|
166 |
static function pmpro_gateways($gateways)
|
167 |
{
|
168 |
if(empty($gateways['stripe']))
|
169 |
+
$gateways['stripe'] = __('Stripe', 'paid-memberships-pro' );
|
170 |
|
171 |
return $gateways;
|
172 |
}
|
203 |
static function pmpro_payment_options($options)
|
204 |
{
|
205 |
//get stripe options
|
206 |
+
$stripe_options = self::getGatewayOptions();
|
207 |
|
208 |
//merge with others.
|
209 |
$options = array_merge($stripe_options, $options);
|
221 |
?>
|
222 |
<tr class="pmpro_settings_divider gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
223 |
<td colspan="2">
|
224 |
+
<?php _e('Stripe Settings', 'paid-memberships-pro' ); ?>
|
225 |
</td>
|
226 |
</tr>
|
227 |
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
228 |
<th scope="row" valign="top">
|
229 |
+
<label for="stripe_secretkey"><?php _e('Secret Key', 'paid-memberships-pro' );?>:</label>
|
230 |
</th>
|
231 |
<td>
|
232 |
<input type="text" id="stripe_secretkey" name="stripe_secretkey" size="60" value="<?php echo esc_attr($values['stripe_secretkey'])?>" />
|
234 |
</tr>
|
235 |
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
236 |
<th scope="row" valign="top">
|
237 |
+
<label for="stripe_publishablekey"><?php _e('Publishable Key', 'paid-memberships-pro' );?>:</label>
|
238 |
</th>
|
239 |
<td>
|
240 |
<input type="text" id="stripe_publishablekey" name="stripe_publishablekey" size="60" value="<?php echo esc_attr($values['stripe_publishablekey'])?>" />
|
242 |
</tr>
|
243 |
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
244 |
<th scope="row" valign="top">
|
245 |
+
<label for="stripe_billingaddress"><?php _e('Show Billing Address Fields', 'paid-memberships-pro' );?>:</label>
|
246 |
</th>
|
247 |
<td>
|
248 |
<select id="stripe_billingaddress" name="stripe_billingaddress">
|
249 |
+
<option value="0" <?php if(empty($values['stripe_billingaddress'])) { ?>selected="selected"<?php } ?>><?php _e('No', 'paid-memberships-pro' );?></option>
|
250 |
+
<option value="1" <?php if(!empty($values['stripe_billingaddress'])) { ?>selected="selected"<?php } ?>><?php _e('Yes', 'paid-memberships-pro' );?></option>
|
251 |
</select>
|
252 |
+
<small><?php _e("Stripe doesn't require billing address fields. Choose 'No' to hide them on the checkout page.<br /><strong>If No, make sure you disable address verification in the Stripe dashboard settings.</strong>", 'paid-memberships-pro' );?></small>
|
253 |
</td>
|
254 |
</tr>
|
255 |
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
256 |
<th scope="row" valign="top">
|
257 |
+
<label><?php _e('Web Hook URL', 'paid-memberships-pro' );?>:</label>
|
258 |
</th>
|
259 |
<td>
|
260 |
+
<p><?php _e('To fully integrate with Stripe, be sure to set your Web Hook URL to', 'paid-memberships-pro' );?> <pre><?php echo admin_url("admin-ajax.php") . "?action=stripe_webhook";?></pre></p>
|
261 |
</td>
|
262 |
</tr>
|
263 |
<?php
|
483 |
|
484 |
if($gateway == "stripe")
|
485 |
{
|
486 |
+
if(static::$is_loaded && !empty($morder) && !empty($morder->Gateway) && !empty($morder->Gateway->customer) && !empty($morder->Gateway->customer->id))
|
487 |
{
|
488 |
update_user_meta($user_id, "pmpro_stripe_customerid", $morder->Gateway->customer->id);
|
489 |
}
|
523 |
<thead>
|
524 |
<tr>
|
525 |
<th>
|
526 |
+
<span class="pmpro_thead-name"><?php _e('Payment Information', 'paid-memberships-pro' );?></span>
|
527 |
+
<span class="pmpro_thead-msg"><?php printf(__('We Accept %s', 'paid-memberships-pro' ), $pmpro_accepted_credit_cards_string);?></span>
|
528 |
</th>
|
529 |
</tr>
|
530 |
</thead>
|
546 |
{
|
547 |
?>
|
548 |
<div class="pmpro_payment-card-type">
|
549 |
+
<label for="CardType"><?php _e('Card Type', 'paid-memberships-pro' );?></label>
|
550 |
<select id="CardType" class=" <?php echo pmpro_getClassForField("CardType");?>">
|
551 |
<?php foreach($pmpro_accepted_credit_cards as $cc) { ?>
|
552 |
<option value="<?php echo $cc?>" <?php if($CardType == $cc) { ?>selected="selected"<?php } ?>><?php echo $cc?></option>
|
589 |
?>
|
590 |
|
591 |
<div class="pmpro_payment-account-number">
|
592 |
+
<label for="AccountNumber"><?php _e('Card Number', 'paid-memberships-pro' );?></label>
|
593 |
<input id="AccountNumber" class="input <?php echo pmpro_getClassForField("AccountNumber");?>" type="text" size="25" value="<?php echo esc_attr($AccountNumber)?>" autocomplete="off" />
|
594 |
</div>
|
595 |
|
596 |
<div class="pmpro_payment-expiration">
|
597 |
+
<label for="ExpirationMonth"><?php _e('Expiration Date', 'paid-memberships-pro' );?></label>
|
598 |
<select id="ExpirationMonth" class=" <?php echo pmpro_getClassForField("ExpirationMonth");?>">
|
599 |
<option value="01" <?php if($ExpirationMonth == "01") { ?>selected="selected"<?php } ?>>01</option>
|
600 |
<option value="02" <?php if($ExpirationMonth == "02") { ?>selected="selected"<?php } ?>>02</option>
|
626 |
{
|
627 |
?>
|
628 |
<div class="pmpro_payment-cvv">
|
629 |
+
<label for="CVV"><?php _e('CVV', 'paid-memberships-pro' );?></label>
|
630 |
+
<input id="CVV" type="text" size="4" value="<?php if(!empty($_REQUEST['CVV'])) { echo esc_attr($_REQUEST['CVV']); }?>" class="input <?php echo pmpro_getClassForField("CVV");?>" /> <small>(<a href="javascript:void(0);" onclick="javascript:window.open('<?php echo pmpro_https_filter(PMPRO_URL)?>/pages/popup-cvv.html','cvv','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=475');"><?php _e("what's this?", 'paid-memberships-pro' );?></a>)</small>
|
631 |
</div>
|
632 |
<?php
|
633 |
}
|
635 |
|
636 |
<?php if($pmpro_show_discount_code) { ?>
|
637 |
<div class="pmpro_payment-discount-code">
|
638 |
+
<label for="discount_code"><?php _e('Discount Code', 'paid-memberships-pro' );?></label>
|
639 |
<input class="input <?php echo pmpro_getClassForField("discount_code");?>" id="discount_code" name="discount_code" type="text" size="20" value="<?php echo esc_attr($discount_code)?>" />
|
640 |
+
<input type="button" id="discount_code_button" name="discount_code_button" value="<?php _e('Apply', 'paid-memberships-pro' );?>" />
|
641 |
<p id="discount_code_message" class="pmpro_message" style="display: none;"></p>
|
642 |
</div>
|
643 |
<?php } ?>
|
661 |
{
|
662 |
global $wpdb, $current_user, $pmpro_currency_symbol;
|
663 |
|
664 |
+
$cycles = array( __('Day(s)', 'paid-memberships-pro' ) => 'Day', __('Week(s)', 'paid-memberships-pro' ) => 'Week', __('Month(s)', 'paid-memberships-pro' ) => 'Month', __('Year(s)', 'paid-memberships-pro' ) => 'Year' );
|
665 |
$current_year = date_i18n("Y");
|
666 |
$current_month = date_i18n("m");
|
667 |
|
683 |
$sub = false;
|
684 |
|
685 |
//check that gateway is Stripe
|
686 |
+
if($last_order->gateway == "stripe" && self::$is_loaded )
|
687 |
{
|
688 |
//is there a customer?
|
689 |
$sub = $last_order->Gateway->getSubscription($last_order);
|
700 |
if(!empty($last_order) && $last_order->gateway == "stripe" && !empty($last_order->subscription_transaction_id) && strpos($last_order->subscription_transaction_id, "sub_") !== false)
|
701 |
{
|
702 |
?>
|
703 |
+
<p><?php printf( __('%1$sNote:%2$s Subscription %3$s%4$s%5$s could not be found at Stripe. It may have been deleted.', 'paid-memberships-pro'), '<strong>', '</strong>', '<strong>', esc_attr($last_order->subscription_transaction_id), '</strong>' ); ?></p>
|
704 |
<?php
|
705 |
}
|
706 |
}
|
707 |
+
elseif ( true === self::$is_loaded )
|
708 |
{
|
709 |
?>
|
710 |
+
<h3><?php _e("Subscription Updates", 'paid-memberships-pro' ); ?></h3>
|
711 |
<p>
|
712 |
<?php
|
713 |
if(empty($_REQUEST['user_id']))
|
714 |
+
_e("Subscription updates, allow you to change the member's subscription values at predefined times. Be sure to click Update Profile after making changes.", 'paid-memberships-pro' );
|
715 |
else
|
716 |
+
_e("Subscription updates, allow you to change the member's subscription values at predefined times. Be sure to click Update User after making changes.", 'paid-memberships-pro' );
|
717 |
?>
|
718 |
</p>
|
719 |
<table class="form-table">
|
720 |
<tr>
|
721 |
+
<th><label for="membership_level"><?php _e("Update", 'paid-memberships-pro' ); ?></label></th>
|
722 |
<td id="updates_td">
|
723 |
<?php
|
724 |
$old_updates = $user->pmpro_stripe_updates;
|
759 |
</span>
|
760 |
<span class="updates_billing" <?php if($update['when'] == "now") { ?>style="display: none;"<?php } ?>>
|
761 |
<?php echo $pmpro_currency_symbol?><input name="updates_billing_amount[]" type="text" size="10" value="<?php echo esc_attr($update['billing_amount']);?>" />
|
762 |
+
<small><?php _e('per', 'paid-memberships-pro' );?></small>
|
763 |
<input name="updates_cycle_number[]" type="text" size="5" value="<?php echo esc_attr($update['cycle_number']);?>" />
|
764 |
<select name="updates_cycle_period[]">
|
765 |
<?php
|
911 |
//throw error and halt save
|
912 |
function pmpro_stripe_user_profile_fields_save_error($errors, $update, $user)
|
913 |
{
|
914 |
+
$errors->add('pmpro_stripe_updates',__('Could not cancel the old subscription. Updates have not been processed.', 'paid-memberships-pro' ));
|
915 |
}
|
916 |
add_filter('user_profile_update_errors', 'pmpro_stripe_user_profile_fields_save_error', 10, 3);
|
917 |
|
1166 |
}
|
1167 |
else
|
1168 |
{
|
1169 |
+
if(empty($order->error)) {
|
1170 |
+
if ( ! self::$is_loaded ) {
|
1171 |
+
|
1172 |
+
$order->error = __( "Payment error: Please contact the webmaster (stripe-load-error)", 'paid-memberships-pro' );
|
1173 |
+
|
1174 |
+
} else {
|
1175 |
+
|
1176 |
+
$order->error = __( "Unknown error: Initial payment failed.", 'paid-memberships-pro' );
|
1177 |
+
}
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
return false;
|
1181 |
}
|
1182 |
}
|
1183 |
}
|
1407 |
}
|
1408 |
catch (Exception $e)
|
1409 |
{
|
1410 |
+
$order->error = __("Error creating customer record with Stripe:", 'paid-memberships-pro' ) . " " . $e->getMessage();
|
1411 |
$order->shorterror = $order->error;
|
1412 |
return false;
|
1413 |
}
|
1466 |
}
|
1467 |
catch (Exception $e)
|
1468 |
{
|
1469 |
+
$order->error = __("Error getting subscription with Stripe:", 'paid-memberships-pro' ) . $e->getMessage();
|
1470 |
$order->shorterror = $order->error;
|
1471 |
return false;
|
1472 |
}
|
1622 |
}
|
1623 |
catch (Exception $e)
|
1624 |
{
|
1625 |
+
$order->error = __("Error creating plan with Stripe:", 'paid-memberships-pro' ) . $e->getMessage();
|
1626 |
$order->shorterror = $order->error;
|
1627 |
return false;
|
1628 |
}
|
1653 |
update_user_meta($user_id, "pmpro_stripe_updates", $old_user_updates);
|
1654 |
|
1655 |
//return error
|
1656 |
+
$order->error = __("Error subscribing customer to plan with Stripe:", 'paid-memberships-pro' ) . $e->getMessage();
|
1657 |
$order->shorterror = $order->error;
|
1658 |
return false;
|
1659 |
}
|
1749 |
}
|
1750 |
else
|
1751 |
{
|
1752 |
+
$order->error = __("Could not cancel old subscription.", 'paid-memberships-pro' );
|
1753 |
$order->shorterror = $order->error;
|
1754 |
|
1755 |
return false;
|
1766 |
}
|
1767 |
else
|
1768 |
{
|
1769 |
+
$order->error = __("Could not find the customer.", 'paid-memberships-pro' );
|
1770 |
$order->shorterror = $order->error;
|
1771 |
return false; //no customer found
|
1772 |
}
|
1844 |
$order = new MemberOrder();
|
1845 |
$order->getLastMemberOrder($user_id, $order_status);
|
1846 |
|
1847 |
+
//check if this is a Stripe order with a subscription transaction id
|
1848 |
if(!empty($order->id) && !empty($order->subscription_transaction_id) && $order->gateway == "stripe")
|
1849 |
{
|
1850 |
//get the subscription and return the current_period end or false
|
1918 |
{
|
1919 |
//$order->status = "error";
|
1920 |
$order->errorcode = true;
|
1921 |
+
$order->error = __("Error: ", 'paid-memberships-pro' ) . $e->getMessage();
|
1922 |
$order->shorterror = $order->error;
|
1923 |
return false;
|
1924 |
}
|
1931 |
} else {
|
1932 |
$order->status = "error";
|
1933 |
$order->errorcode = true;
|
1934 |
+
$order->error = sprintf(__("Error: Unkown error while refunding charge #%s", 'paid-memberships-pro' ), $transaction_id);
|
1935 |
$order->shorterror = $order->error;
|
1936 |
|
1937 |
return false;
|
classes/gateways/class.pmprogateway_twocheckout.php
CHANGED
@@ -56,7 +56,7 @@
|
|
56 |
static function pmpro_gateways($gateways)
|
57 |
{
|
58 |
if(empty($gateways['twocheckout']))
|
59 |
-
$gateways['twocheckout'] = __('2Checkout', '
|
60 |
|
61 |
return $gateways;
|
62 |
}
|
@@ -111,12 +111,12 @@
|
|
111 |
?>
|
112 |
<tr class="pmpro_settings_divider gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
113 |
<td colspan="2">
|
114 |
-
<?php _e('2Checkout Settings', '
|
115 |
</td>
|
116 |
</tr>
|
117 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
118 |
<th scope="row" valign="top">
|
119 |
-
<label for="twocheckout_apiusername"><?php _e('API Username', '
|
120 |
</th>
|
121 |
<td>
|
122 |
<input type="text" id="twocheckout_apiusername" name="twocheckout_apiusername" size="60" value="<?php echo esc_attr($values['twocheckout_apiusername'])?>" />
|
@@ -125,7 +125,7 @@
|
|
125 |
</tr>
|
126 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
127 |
<th scope="row" valign="top">
|
128 |
-
<label for="twocheckout_apipassword"><?php _e('API Password', '
|
129 |
</th>
|
130 |
<td>
|
131 |
<input type="text" id="twocheckout_apipassword" name="twocheckout_apipassword" size="60" value="<?php echo esc_attr($values['twocheckout_apipassword'])?>" />
|
@@ -134,7 +134,7 @@
|
|
134 |
</tr>
|
135 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
136 |
<th scope="row" valign="top">
|
137 |
-
<label for="twocheckout_accountnumber"><?php _e('Account Number', '
|
138 |
</th>
|
139 |
<td>
|
140 |
<input type="text" name="twocheckout_accountnumber" size="60" value="<?php echo $values['twocheckout_accountnumber']?>" />
|
@@ -143,7 +143,7 @@
|
|
143 |
</tr>
|
144 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
145 |
<th scope="row" valign="top">
|
146 |
-
<label for="twocheckout_secretword"><?php _e('Secret Word', '
|
147 |
</th>
|
148 |
<td>
|
149 |
<input type="text" name="twocheckout_secretword" size="60" value="<?php echo $values['twocheckout_secretword']?>" />
|
@@ -152,10 +152,10 @@
|
|
152 |
</tr>
|
153 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
154 |
<th scope="row" valign="top">
|
155 |
-
<label><?php _e('TwoCheckout INS URL', '
|
156 |
</th>
|
157 |
<td>
|
158 |
-
<p><?php _e('To fully integrate with 2Checkout, be sure to use the following for your INS URL and Approved URL', '
|
159 |
|
160 |
</td>
|
161 |
</tr>
|
@@ -200,7 +200,7 @@
|
|
200 |
?>
|
201 |
<span id="pmpro_submit_span">
|
202 |
<input type="hidden" name="submit-checkout" value="1" />
|
203 |
-
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Check Out with 2Checkout', '
|
204 |
</span>
|
205 |
<?php
|
206 |
|
@@ -359,13 +359,13 @@
|
|
359 |
//no matter what happens below, we're going to cancel the order in our system
|
360 |
$order->updateStatus("cancelled");
|
361 |
|
362 |
-
//require a
|
363 |
-
if(empty($order->
|
364 |
return false;
|
365 |
|
366 |
//build api params
|
367 |
$params = array();
|
368 |
-
$params['sale_id'] = $order->
|
369 |
|
370 |
// Demo mode?
|
371 |
if(empty($order->gateway_environment))
|
56 |
static function pmpro_gateways($gateways)
|
57 |
{
|
58 |
if(empty($gateways['twocheckout']))
|
59 |
+
$gateways['twocheckout'] = __('2Checkout', 'paid-memberships-pro' );
|
60 |
|
61 |
return $gateways;
|
62 |
}
|
111 |
?>
|
112 |
<tr class="pmpro_settings_divider gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
113 |
<td colspan="2">
|
114 |
+
<?php _e('2Checkout Settings', 'paid-memberships-pro' ); ?>
|
115 |
</td>
|
116 |
</tr>
|
117 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
118 |
<th scope="row" valign="top">
|
119 |
+
<label for="twocheckout_apiusername"><?php _e('API Username', 'paid-memberships-pro' );?>:</label>
|
120 |
</th>
|
121 |
<td>
|
122 |
<input type="text" id="twocheckout_apiusername" name="twocheckout_apiusername" size="60" value="<?php echo esc_attr($values['twocheckout_apiusername'])?>" />
|
125 |
</tr>
|
126 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
127 |
<th scope="row" valign="top">
|
128 |
+
<label for="twocheckout_apipassword"><?php _e('API Password', 'paid-memberships-pro' );?>:</label>
|
129 |
</th>
|
130 |
<td>
|
131 |
<input type="text" id="twocheckout_apipassword" name="twocheckout_apipassword" size="60" value="<?php echo esc_attr($values['twocheckout_apipassword'])?>" />
|
134 |
</tr>
|
135 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
136 |
<th scope="row" valign="top">
|
137 |
+
<label for="twocheckout_accountnumber"><?php _e('Account Number', 'paid-memberships-pro' );?>:</label>
|
138 |
</th>
|
139 |
<td>
|
140 |
<input type="text" name="twocheckout_accountnumber" size="60" value="<?php echo $values['twocheckout_accountnumber']?>" />
|
143 |
</tr>
|
144 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
145 |
<th scope="row" valign="top">
|
146 |
+
<label for="twocheckout_secretword"><?php _e('Secret Word', 'paid-memberships-pro' );?>:</label>
|
147 |
</th>
|
148 |
<td>
|
149 |
<input type="text" name="twocheckout_secretword" size="60" value="<?php echo $values['twocheckout_secretword']?>" />
|
152 |
</tr>
|
153 |
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
154 |
<th scope="row" valign="top">
|
155 |
+
<label><?php _e('TwoCheckout INS URL', 'paid-memberships-pro' );?>:</label>
|
156 |
</th>
|
157 |
<td>
|
158 |
+
<p><?php _e('To fully integrate with 2Checkout, be sure to use the following for your INS URL and Approved URL', 'paid-memberships-pro' );?> <pre><?php echo admin_url("admin-ajax.php") . "?action=twocheckout-ins";?></pre></p>
|
159 |
|
160 |
</td>
|
161 |
</tr>
|
200 |
?>
|
201 |
<span id="pmpro_submit_span">
|
202 |
<input type="hidden" name="submit-checkout" value="1" />
|
203 |
+
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Check Out with 2Checkout', 'paid-memberships-pro' ); } else { _e('Submit and Confirm', 'paid-memberships-pro' );}?> »" />
|
204 |
</span>
|
205 |
<?php
|
206 |
|
359 |
//no matter what happens below, we're going to cancel the order in our system
|
360 |
$order->updateStatus("cancelled");
|
361 |
|
362 |
+
//require a payment transaction id
|
363 |
+
if(empty($order->payment_transaction_id))
|
364 |
return false;
|
365 |
|
366 |
//build api params
|
367 |
$params = array();
|
368 |
+
$params['sale_id'] = $order->payment_transaction_id;
|
369 |
|
370 |
// Demo mode?
|
371 |
if(empty($order->gateway_environment))
|
includes/addons.php
CHANGED
@@ -218,14 +218,16 @@ function pmpro_getPluginAPIObjectFromAddon($addon)
|
|
218 |
$api->download_link = add_query_arg("key", $key, $api->download_link);
|
219 |
if(!empty($key) && !empty($api->package))
|
220 |
$api->package = add_query_arg("key", $key, $api->package);
|
221 |
-
|
|
|
|
|
222 |
return $api;
|
223 |
}
|
224 |
|
225 |
/**
|
226 |
* Force update of plugin update data when the PMPro License key is updated
|
227 |
*
|
228 |
-
* @since
|
229 |
*
|
230 |
* @param array $args Array of request args.
|
231 |
* @param string $url The URL to be pinged.
|
@@ -236,3 +238,95 @@ function pmpro_reset_update_plugins_cache($old_value, $value)
|
|
236 |
delete_option('pmpro_addons_timestamp');
|
237 |
delete_site_transient('update_themes');
|
238 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
$api->download_link = add_query_arg("key", $key, $api->download_link);
|
219 |
if(!empty($key) && !empty($api->package))
|
220 |
$api->package = add_query_arg("key", $key, $api->package);
|
221 |
+
if(empty($api->upgrade_notice) && !pmpro_license_isValid())
|
222 |
+
$api->upgrade_notice = __('Important: This plugin requires a valid PMPro Plus license key to update.', 'paid-memberships-pro');
|
223 |
+
|
224 |
return $api;
|
225 |
}
|
226 |
|
227 |
/**
|
228 |
* Force update of plugin update data when the PMPro License key is updated
|
229 |
*
|
230 |
+
* @since 1.8
|
231 |
*
|
232 |
* @param array $args Array of request args.
|
233 |
* @param string $url The URL to be pinged.
|
238 |
delete_option('pmpro_addons_timestamp');
|
239 |
delete_site_transient('update_themes');
|
240 |
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Detect when trying to update a PMPro Plus plugin without a valid license key.
|
244 |
+
*
|
245 |
+
* @since 1.9
|
246 |
+
*/
|
247 |
+
function pmpro_admin_init_updating_plugins() {
|
248 |
+
//if user can't edit plugins, then WP will catch this later
|
249 |
+
if ( ! current_user_can('update_plugins') )
|
250 |
+
return;
|
251 |
+
|
252 |
+
//updating one or more plugins via Dashboard -> Upgrade
|
253 |
+
if(basename($_SERVER['SCRIPT_NAME']) == 'update.php' && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'update-selected' && !empty($_REQUEST['plugins'])) {
|
254 |
+
//figure out which plugin we are updating
|
255 |
+
$plugins = explode( ',', stripslashes($_GET['plugins']) );
|
256 |
+
$plugins = array_map('urldecode', $plugins);
|
257 |
+
|
258 |
+
//look for addons
|
259 |
+
$plus_addons = array();
|
260 |
+
$plus_plugins = array();
|
261 |
+
foreach($plugins as $plugin) {
|
262 |
+
$slug = str_replace('.php', '', basename($plugin));
|
263 |
+
$addon = pmpro_getAddonBySlug($slug);
|
264 |
+
if(!empty($addon) && $addon['License'] == 'plus') {
|
265 |
+
$plus_addons[] = $addon['Name'];
|
266 |
+
$plus_plugins[] = $plugin;
|
267 |
+
}
|
268 |
+
}
|
269 |
+
unset($plugin);
|
270 |
+
|
271 |
+
//if Plus addons found, check license key
|
272 |
+
if(!empty($plus_plugins) && !pmpro_license_isValid()) {
|
273 |
+
//show error
|
274 |
+
$msg = __('You must have a <a href="https://www.paidmembershipspro.com/pricing/?utm_source=wp-admin&utm_pluginlink=bulkupdate">valid PMPro Plus License Key</a> to update PMPro Plus add ons. The following plugins will not be updated:', 'paid-memberships-pro');
|
275 |
+
echo '<div class="error"><p>' . $msg . ' <strong>' . implode(', ', $plus_addons) . '</strong></p></div>';
|
276 |
+
}
|
277 |
+
|
278 |
+
//can exit out of this function now
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
|
282 |
+
//upgrading just one or plugin via an update.php link
|
283 |
+
if(basename($_SERVER['SCRIPT_NAME']) == 'update.php' && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'upgrade-plugin' && !empty($_REQUEST['plugin'])) {
|
284 |
+
//figure out which plugin we are updating
|
285 |
+
$plugin = urldecode(trim($_REQUEST['plugin']));
|
286 |
+
|
287 |
+
$slug = str_replace('.php', '', basename($plugin));
|
288 |
+
$addon = pmpro_getAddonBySlug($slug);
|
289 |
+
if(!empty($addon) && !pmpro_license_isValid()) {
|
290 |
+
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
291 |
+
|
292 |
+
echo '<div class="wrap"><h2>' . __('Update Plugin') . '</h2>';
|
293 |
+
|
294 |
+
$msg = __('You must have a <a href="https://www.paidmembershipspro.com/pricing/?utm_source=wp-admin&utm_pluginlink=addon_update">valid PMPro Plus License Key</a> to update PMPro Plus add ons.', 'paid-memberships-pro');
|
295 |
+
echo '<div class="error"><p>' . $msg . '</p></div>';
|
296 |
+
|
297 |
+
echo '<p><a href="' . admin_url('admin.php?page=pmpro-addons') . '" target="_parent">' . __('Return to the PMPro Add Ons page', 'paid-memberships-pro') . '</a></p>';
|
298 |
+
|
299 |
+
echo '</div>';
|
300 |
+
|
301 |
+
include(ABSPATH . 'wp-admin/admin-footer.php');
|
302 |
+
|
303 |
+
//can exit WP now
|
304 |
+
exit;
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
//updating via AJAX on the plugins page
|
309 |
+
if(basename($_SERVER['SCRIPT_NAME']) == 'admin-ajax.php' && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'update-plugin' && !empty($_REQUEST['plugin'])) {
|
310 |
+
//figure out which plugin we are updating
|
311 |
+
$plugin = urldecode(trim($_REQUEST['plugin']));
|
312 |
+
|
313 |
+
$slug = str_replace('.php', '', basename($plugin));
|
314 |
+
$addon = pmpro_getAddonBySlug($slug);
|
315 |
+
if(!empty($addon) && !pmpro_license_isValid()) {
|
316 |
+
$msg = __('You must enter a valid PMPro Plus License Key under Settings > PMPro License to update this add on.', 'paid-memberships-pro');
|
317 |
+
echo '<div class="error"><p>' . $msg . '</p></div>';
|
318 |
+
|
319 |
+
//can exit WP now
|
320 |
+
exit;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
/*
|
325 |
+
TODO:
|
326 |
+
* Check for PMPro Plug plugins
|
327 |
+
* If a plus plugin is found, check the PMPro license key
|
328 |
+
* If the key is missing or invalid, throw an error
|
329 |
+
* Show appropriate footer and exit... maybe do something else to keep plugin update from happening
|
330 |
+
*/
|
331 |
+
}
|
332 |
+
add_action('admin_init', 'pmpro_admin_init_updating_plugins');
|
includes/adminpages.php
CHANGED
@@ -45,20 +45,20 @@ function pmpro_add_pages()
|
|
45 |
if(empty($top_menu_cap))
|
46 |
return;
|
47 |
|
48 |
-
add_menu_page(__('Memberships', '
|
49 |
-
add_submenu_page('pmpro-membershiplevels', __('Page Settings', '
|
50 |
-
add_submenu_page('pmpro-membershiplevels', __('Payment Settings', '
|
51 |
-
add_submenu_page('pmpro-membershiplevels', __('Email Settings', '
|
52 |
-
add_submenu_page('pmpro-membershiplevels', __('Advanced Settings', '
|
53 |
-
add_submenu_page('pmpro-membershiplevels', __('Add Ons', '
|
54 |
-
add_submenu_page('pmpro-membershiplevels', __('Members List', '
|
55 |
-
add_submenu_page('pmpro-membershiplevels', __('Reports', '
|
56 |
-
add_submenu_page('pmpro-membershiplevels', __('Orders', '
|
57 |
-
add_submenu_page('pmpro-membershiplevels', __('Discount Codes', '
|
58 |
|
59 |
//updates page only if needed
|
60 |
if(pmpro_isUpdateRequired())
|
61 |
-
add_submenu_page('pmpro-membershiplevels', __('Updates Required', '
|
62 |
|
63 |
//rename the automatically added Memberships submenu item
|
64 |
global $submenu;
|
@@ -66,8 +66,8 @@ function pmpro_add_pages()
|
|
66 |
{
|
67 |
if(current_user_can("pmpro_membershiplevels"))
|
68 |
{
|
69 |
-
$submenu['pmpro-membershiplevels'][0][0] = __( 'Membership Levels', '
|
70 |
-
$submenu['pmpro-membershiplevels'][0][3] = __( 'Membership Levels', '
|
71 |
}
|
72 |
elseif(current_user_can($top_menu_cap))
|
73 |
{
|
@@ -106,77 +106,77 @@ function pmpro_admin_bar_menu() {
|
|
106 |
|
107 |
$wp_admin_bar->add_menu( array(
|
108 |
'id' => 'paid-memberships-pro',
|
109 |
-
'title' => __( '<span class="ab-icon"></span>Memberships', '
|
110 |
'href' => get_admin_url(NULL, '/admin.php?page=' . $top_menu_page) ) );
|
111 |
|
112 |
if(current_user_can('pmpro_membershiplevels'))
|
113 |
$wp_admin_bar->add_menu( array(
|
114 |
'id' => 'pmpro-membership-levels',
|
115 |
'parent' => 'paid-memberships-pro',
|
116 |
-
'title' => __( 'Membership Levels', '
|
117 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-membershiplevels') ) );
|
118 |
|
119 |
if(current_user_can('pmpro_pagesettings'))
|
120 |
$wp_admin_bar->add_menu( array(
|
121 |
'id' => 'pmpro-page-settings',
|
122 |
'parent' => 'paid-memberships-pro',
|
123 |
-
'title' => __( 'Page Settings', '
|
124 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-pagesettings') ) );
|
125 |
|
126 |
if(current_user_can('pmpro_paymentsettings'))
|
127 |
$wp_admin_bar->add_menu( array(
|
128 |
'id' => 'pmpro-payment-settings',
|
129 |
'parent' => 'paid-memberships-pro',
|
130 |
-
'title' => __( 'Payment Settings', '
|
131 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-paymentsettings') ) );
|
132 |
|
133 |
if(current_user_can('pmpro_emailsettings'))
|
134 |
$wp_admin_bar->add_menu( array(
|
135 |
'id' => 'pmpro-email-settings',
|
136 |
'parent' => 'paid-memberships-pro',
|
137 |
-
'title' => __( 'Email Settings', '
|
138 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-emailsettings') ) );
|
139 |
|
140 |
if(current_user_can('pmpro_advancedsettings'))
|
141 |
$wp_admin_bar->add_menu( array(
|
142 |
'id' => 'pmpro-advanced-settings',
|
143 |
'parent' => 'paid-memberships-pro',
|
144 |
-
'title' => __( 'Advanced Settings', '
|
145 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-advancedsettings') ) );
|
146 |
|
147 |
if(current_user_can('pmpro_addons'))
|
148 |
$wp_admin_bar->add_menu( array(
|
149 |
'id' => 'pmpro-addons',
|
150 |
'parent' => 'paid-memberships-pro',
|
151 |
-
'title' => __( 'Add Ons', '
|
152 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-addons') ) );
|
153 |
|
154 |
if(current_user_can('pmpro_memberslist'))
|
155 |
$wp_admin_bar->add_menu( array(
|
156 |
'id' => 'pmpro-members-list',
|
157 |
'parent' => 'paid-memberships-pro',
|
158 |
-
'title' => __( 'Members List', '
|
159 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-memberslist') ) );
|
160 |
|
161 |
if(current_user_can('pmpro_reports'))
|
162 |
$wp_admin_bar->add_menu( array(
|
163 |
'id' => 'pmpro-reports',
|
164 |
'parent' => 'paid-memberships-pro',
|
165 |
-
'title' => __( 'Reports', '
|
166 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-reports') ) );
|
167 |
|
168 |
if(current_user_can('pmpro_orders'))
|
169 |
$wp_admin_bar->add_menu( array(
|
170 |
'id' => 'pmpro-orders',
|
171 |
'parent' => 'paid-memberships-pro',
|
172 |
-
'title' => __( 'Orders', '
|
173 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-orders') ) );
|
174 |
|
175 |
if(current_user_can('pmpro_discountcodes'))
|
176 |
$wp_admin_bar->add_menu( array(
|
177 |
'id' => 'pmpro-discount-codes',
|
178 |
'parent' => 'paid-memberships-pro',
|
179 |
-
'title' => __( 'Discount Codes', '
|
180 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-discountcodes') ) );
|
181 |
}
|
182 |
add_action('admin_bar_menu', 'pmpro_admin_bar_menu', 1000);
|
@@ -271,8 +271,8 @@ function pmpro_plugin_row_meta($links, $file) {
|
|
271 |
if(strpos($file, 'paid-memberships-pro.php') !== false)
|
272 |
{
|
273 |
$new_links = array(
|
274 |
-
'<a href="' . esc_url( apply_filters( 'pmpro_docs_url', 'http://paidmembershipspro.com/documentation/' ) ) . '" title="' . esc_attr( __( 'View PMPro Documentation', '
|
275 |
-
'<a href="' . esc_url( apply_filters( 'pmpro_support_url', 'http://paidmembershipspro.com/support/' ) ) . '" title="' . esc_attr( __( 'Visit Customer Support Forum', '
|
276 |
);
|
277 |
$links = array_merge($links, $new_links);
|
278 |
}
|
45 |
if(empty($top_menu_cap))
|
46 |
return;
|
47 |
|
48 |
+
add_menu_page(__('Memberships', 'paid-memberships-pro' ), __('Memberships', 'paid-memberships-pro' ), 'pmpro_memberships_menu', 'pmpro-membershiplevels', $top_menu_cap, 'dashicons-groups');
|
49 |
+
add_submenu_page('pmpro-membershiplevels', __('Page Settings', 'paid-memberships-pro' ), __('Page Settings', 'paid-memberships-pro' ), 'pmpro_pagesettings', 'pmpro-pagesettings', 'pmpro_pagesettings');
|
50 |
+
add_submenu_page('pmpro-membershiplevels', __('Payment Settings', 'paid-memberships-pro' ), __('Payment Settings', 'paid-memberships-pro' ), 'pmpro_paymentsettings', 'pmpro-paymentsettings', 'pmpro_paymentsettings');
|
51 |
+
add_submenu_page('pmpro-membershiplevels', __('Email Settings', 'paid-memberships-pro' ), __('Email Settings', 'paid-memberships-pro' ), 'pmpro_emailsettings', 'pmpro-emailsettings', 'pmpro_emailsettings');
|
52 |
+
add_submenu_page('pmpro-membershiplevels', __('Advanced Settings', 'paid-memberships-pro' ), __('Advanced Settings', 'paid-memberships-pro' ), 'pmpro_advancedsettings', 'pmpro-advancedsettings', 'pmpro_advancedsettings');
|
53 |
+
add_submenu_page('pmpro-membershiplevels', __('Add Ons', 'paid-memberships-pro' ), __('Add Ons', 'paid-memberships-pro' ), 'pmpro_addons', 'pmpro-addons', 'pmpro_addons');
|
54 |
+
add_submenu_page('pmpro-membershiplevels', __('Members List', 'paid-memberships-pro' ), __('Members List', 'paid-memberships-pro' ), 'pmpro_memberslist', 'pmpro-memberslist', 'pmpro_memberslist');
|
55 |
+
add_submenu_page('pmpro-membershiplevels', __('Reports', 'paid-memberships-pro' ), __('Reports', 'paid-memberships-pro' ), 'pmpro_reports', 'pmpro-reports', 'pmpro_reports');
|
56 |
+
add_submenu_page('pmpro-membershiplevels', __('Orders', 'paid-memberships-pro' ), __('Orders', 'paid-memberships-pro' ), 'pmpro_orders', 'pmpro-orders', 'pmpro_orders');
|
57 |
+
add_submenu_page('pmpro-membershiplevels', __('Discount Codes', 'paid-memberships-pro' ), __('Discount Codes', 'paid-memberships-pro' ), 'pmpro_discountcodes', 'pmpro-discountcodes', 'pmpro_discountcodes');
|
58 |
|
59 |
//updates page only if needed
|
60 |
if(pmpro_isUpdateRequired())
|
61 |
+
add_submenu_page('pmpro-membershiplevels', __('Updates Required', 'paid-memberships-pro' ), __('Updates Required', 'paid-memberships-pro' ), 'pmpro_updates', 'pmpro-updates', 'pmpro_updates');
|
62 |
|
63 |
//rename the automatically added Memberships submenu item
|
64 |
global $submenu;
|
66 |
{
|
67 |
if(current_user_can("pmpro_membershiplevels"))
|
68 |
{
|
69 |
+
$submenu['pmpro-membershiplevels'][0][0] = __( 'Membership Levels', 'paid-memberships-pro' );
|
70 |
+
$submenu['pmpro-membershiplevels'][0][3] = __( 'Membership Levels', 'paid-memberships-pro' );
|
71 |
}
|
72 |
elseif(current_user_can($top_menu_cap))
|
73 |
{
|
106 |
|
107 |
$wp_admin_bar->add_menu( array(
|
108 |
'id' => 'paid-memberships-pro',
|
109 |
+
'title' => __( '<span class="ab-icon"></span>Memberships', 'paid-memberships-pro' ),
|
110 |
'href' => get_admin_url(NULL, '/admin.php?page=' . $top_menu_page) ) );
|
111 |
|
112 |
if(current_user_can('pmpro_membershiplevels'))
|
113 |
$wp_admin_bar->add_menu( array(
|
114 |
'id' => 'pmpro-membership-levels',
|
115 |
'parent' => 'paid-memberships-pro',
|
116 |
+
'title' => __( 'Membership Levels', 'paid-memberships-pro' ),
|
117 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-membershiplevels') ) );
|
118 |
|
119 |
if(current_user_can('pmpro_pagesettings'))
|
120 |
$wp_admin_bar->add_menu( array(
|
121 |
'id' => 'pmpro-page-settings',
|
122 |
'parent' => 'paid-memberships-pro',
|
123 |
+
'title' => __( 'Page Settings', 'paid-memberships-pro' ),
|
124 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-pagesettings') ) );
|
125 |
|
126 |
if(current_user_can('pmpro_paymentsettings'))
|
127 |
$wp_admin_bar->add_menu( array(
|
128 |
'id' => 'pmpro-payment-settings',
|
129 |
'parent' => 'paid-memberships-pro',
|
130 |
+
'title' => __( 'Payment Settings', 'paid-memberships-pro' ),
|
131 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-paymentsettings') ) );
|
132 |
|
133 |
if(current_user_can('pmpro_emailsettings'))
|
134 |
$wp_admin_bar->add_menu( array(
|
135 |
'id' => 'pmpro-email-settings',
|
136 |
'parent' => 'paid-memberships-pro',
|
137 |
+
'title' => __( 'Email Settings', 'paid-memberships-pro' ),
|
138 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-emailsettings') ) );
|
139 |
|
140 |
if(current_user_can('pmpro_advancedsettings'))
|
141 |
$wp_admin_bar->add_menu( array(
|
142 |
'id' => 'pmpro-advanced-settings',
|
143 |
'parent' => 'paid-memberships-pro',
|
144 |
+
'title' => __( 'Advanced Settings', 'paid-memberships-pro' ),
|
145 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-advancedsettings') ) );
|
146 |
|
147 |
if(current_user_can('pmpro_addons'))
|
148 |
$wp_admin_bar->add_menu( array(
|
149 |
'id' => 'pmpro-addons',
|
150 |
'parent' => 'paid-memberships-pro',
|
151 |
+
'title' => __( 'Add Ons', 'paid-memberships-pro' ),
|
152 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-addons') ) );
|
153 |
|
154 |
if(current_user_can('pmpro_memberslist'))
|
155 |
$wp_admin_bar->add_menu( array(
|
156 |
'id' => 'pmpro-members-list',
|
157 |
'parent' => 'paid-memberships-pro',
|
158 |
+
'title' => __( 'Members List', 'paid-memberships-pro' ),
|
159 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-memberslist') ) );
|
160 |
|
161 |
if(current_user_can('pmpro_reports'))
|
162 |
$wp_admin_bar->add_menu( array(
|
163 |
'id' => 'pmpro-reports',
|
164 |
'parent' => 'paid-memberships-pro',
|
165 |
+
'title' => __( 'Reports', 'paid-memberships-pro' ),
|
166 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-reports') ) );
|
167 |
|
168 |
if(current_user_can('pmpro_orders'))
|
169 |
$wp_admin_bar->add_menu( array(
|
170 |
'id' => 'pmpro-orders',
|
171 |
'parent' => 'paid-memberships-pro',
|
172 |
+
'title' => __( 'Orders', 'paid-memberships-pro' ),
|
173 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-orders') ) );
|
174 |
|
175 |
if(current_user_can('pmpro_discountcodes'))
|
176 |
$wp_admin_bar->add_menu( array(
|
177 |
'id' => 'pmpro-discount-codes',
|
178 |
'parent' => 'paid-memberships-pro',
|
179 |
+
'title' => __( 'Discount Codes', 'paid-memberships-pro' ),
|
180 |
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-discountcodes') ) );
|
181 |
}
|
182 |
add_action('admin_bar_menu', 'pmpro_admin_bar_menu', 1000);
|
271 |
if(strpos($file, 'paid-memberships-pro.php') !== false)
|
272 |
{
|
273 |
$new_links = array(
|
274 |
+
'<a href="' . esc_url( apply_filters( 'pmpro_docs_url', 'http://paidmembershipspro.com/documentation/' ) ) . '" title="' . esc_attr( __( 'View PMPro Documentation', 'paid-memberships-pro' ) ) . '">' . __( 'Docs', 'paid-memberships-pro' ) . '</a>',
|
275 |
+
'<a href="' . esc_url( apply_filters( 'pmpro_support_url', 'http://paidmembershipspro.com/support/' ) ) . '" title="' . esc_attr( __( 'Visit Customer Support Forum', 'paid-memberships-pro' ) ) . '">' . __( 'Support', 'paid-memberships-pro' ) . '</a>',
|
276 |
);
|
277 |
$links = array_merge($links, $new_links);
|
278 |
}
|
includes/currencies.php
CHANGED
@@ -14,74 +14,74 @@
|
|
14 |
}
|
15 |
|
16 |
$pmpro_currencies = array(
|
17 |
-
'USD' => __('US Dollars ($)', '
|
18 |
'EUR' => array(
|
19 |
-
'name' => __('Euros (€)', '
|
20 |
'symbol' => '€',
|
21 |
'position' => apply_filters("pmpro_euro_position", pmpro_euro_position_from_locale())
|
22 |
),
|
23 |
'GBP' => array(
|
24 |
-
'name' => __('Pounds Sterling (£)', '
|
25 |
'symbol' => '£',
|
26 |
'position' => 'left'
|
27 |
),
|
28 |
-
'ARS' => __('Argentine Peso ($)', '
|
29 |
-
'AUD' => __('Australian Dollars ($)', '
|
30 |
'BRL' => array(
|
31 |
-
'name' => __('Brazilian Real (R$)', '
|
32 |
'symbol' => 'R$',
|
33 |
'position' => 'left'
|
34 |
),
|
35 |
-
'CAD' => __('Canadian Dollars ($)', '
|
36 |
-
'CNY' => __('Chinese Yuan', '
|
37 |
'CZK' => array(
|
38 |
-
'name' => __('Czech Koruna', '
|
39 |
'decimals' => '0',
|
40 |
'thousands_separator' => ' ',
|
41 |
'decimal_separator' => ',',
|
42 |
'symbol' => ' Kč',
|
43 |
'position' => 'right',
|
44 |
),
|
45 |
-
'DKK' => __('Danish Krone', '
|
46 |
-
'HKD' => __('Hong Kong Dollar ($)', '
|
47 |
-
'HUF' => __('Hungarian Forint', '
|
48 |
-
'INR' => __('Indian Rupee', '
|
49 |
-
'IDR' => __('Indonesia Rupiah', '
|
50 |
-
'ILS' => __('Israeli Shekel', '
|
51 |
'JPY' => array(
|
52 |
-
'name' => __('Japanese Yen (¥)', '
|
53 |
'symbol' => '¥',
|
54 |
'position' => 'right',
|
55 |
'decimals' => 0,
|
56 |
),
|
57 |
-
'MYR' => __('Malaysian Ringgits', '
|
58 |
-
'MXN' => __('Mexican Peso ($)', '
|
59 |
-
'NGN' => __('Nigerian Naira (₦)', '
|
60 |
-
'NZD' => __('New Zealand Dollar ($)', '
|
61 |
-
'NOK' => __('Norwegian Krone', '
|
62 |
-
'PHP' => __('Philippine Pesos', '
|
63 |
-
'PLN' => __('Polish Zloty', '
|
64 |
'SGD' => array(
|
65 |
-
'name' => __('Singapore Dollar ($)', '
|
66 |
'symbol' => '$',
|
67 |
'position' => 'right'
|
68 |
),
|
69 |
'ZAR' => array(
|
70 |
-
'name' => __('South African Rand (R)', '
|
71 |
'symbol' => 'R ',
|
72 |
'position' => 'left'
|
73 |
),
|
74 |
'KRW' => array(
|
75 |
-
'name' => __('South Korean Won', '
|
76 |
'decimals' => 0,
|
77 |
),
|
78 |
-
'SEK' => __('Swedish Krona', '
|
79 |
-
'CHF' => __('Swiss Franc', '
|
80 |
-
'TWD' => __('Taiwan New Dollars', '
|
81 |
-
'THB' => __('Thai Baht', '
|
82 |
-
'TRY' => __('Turkish Lira', '
|
83 |
'VND' => array(
|
84 |
-
'name' => __('Vietnamese Dong', '
|
85 |
'decimals' => 0,
|
86 |
),
|
87 |
);
|
@@ -91,9 +91,9 @@
|
|
91 |
//stripe only supports a few (not using this anymore since 1.7.4)
|
92 |
global $pmpro_stripe_currencies;
|
93 |
$pmpro_stripe_currencies = array(
|
94 |
-
'USD' => __('US Dollars ($)', '
|
95 |
-
'CAD' => __('Canadian Dollars ($)', '
|
96 |
-
'GBP' => __('Pounds Sterling (£)', '
|
97 |
-
'EUR' => __('Euros (€)', '
|
98 |
);
|
99 |
?>
|
14 |
}
|
15 |
|
16 |
$pmpro_currencies = array(
|
17 |
+
'USD' => __('US Dollars ($)', 'paid-memberships-pro' ),
|
18 |
'EUR' => array(
|
19 |
+
'name' => __('Euros (€)', 'paid-memberships-pro' ),
|
20 |
'symbol' => '€',
|
21 |
'position' => apply_filters("pmpro_euro_position", pmpro_euro_position_from_locale())
|
22 |
),
|
23 |
'GBP' => array(
|
24 |
+
'name' => __('Pounds Sterling (£)', 'paid-memberships-pro' ),
|
25 |
'symbol' => '£',
|
26 |
'position' => 'left'
|
27 |
),
|
28 |
+
'ARS' => __('Argentine Peso ($)', 'paid-memberships-pro' ),
|
29 |
+
'AUD' => __('Australian Dollars ($)', 'paid-memberships-pro' ),
|
30 |
'BRL' => array(
|
31 |
+
'name' => __('Brazilian Real (R$)', 'paid-memberships-pro' ),
|
32 |
'symbol' => 'R$',
|
33 |
'position' => 'left'
|
34 |
),
|
35 |
+
'CAD' => __('Canadian Dollars ($)', 'paid-memberships-pro' ),
|
36 |
+
'CNY' => __('Chinese Yuan', 'paid-memberships-pro' ),
|
37 |
'CZK' => array(
|
38 |
+
'name' => __('Czech Koruna', 'paid-memberships-pro' ),
|
39 |
'decimals' => '0',
|
40 |
'thousands_separator' => ' ',
|
41 |
'decimal_separator' => ',',
|
42 |
'symbol' => ' Kč',
|
43 |
'position' => 'right',
|
44 |
),
|
45 |
+
'DKK' => __('Danish Krone', 'paid-memberships-pro' ),
|
46 |
+
'HKD' => __('Hong Kong Dollar ($)', 'paid-memberships-pro' ),
|
47 |
+
'HUF' => __('Hungarian Forint', 'paid-memberships-pro' ),
|
48 |
+
'INR' => __('Indian Rupee', 'paid-memberships-pro' ),
|
49 |
+
'IDR' => __('Indonesia Rupiah', 'paid-memberships-pro' ),
|
50 |
+
'ILS' => __('Israeli Shekel', 'paid-memberships-pro' ),
|
51 |
'JPY' => array(
|
52 |
+
'name' => __('Japanese Yen (¥)', 'paid-memberships-pro' ),
|
53 |
'symbol' => '¥',
|
54 |
'position' => 'right',
|
55 |
'decimals' => 0,
|
56 |
),
|
57 |
+
'MYR' => __('Malaysian Ringgits', 'paid-memberships-pro' ),
|
58 |
+
'MXN' => __('Mexican Peso ($)', 'paid-memberships-pro' ),
|
59 |
+
'NGN' => __('Nigerian Naira (₦)', 'paid-memberships-pro' ),
|
60 |
+
'NZD' => __('New Zealand Dollar ($)', 'paid-memberships-pro' ),
|
61 |
+
'NOK' => __('Norwegian Krone', 'paid-memberships-pro' ),
|
62 |
+
'PHP' => __('Philippine Pesos', 'paid-memberships-pro' ),
|
63 |
+
'PLN' => __('Polish Zloty', 'paid-memberships-pro' ),
|
64 |
'SGD' => array(
|
65 |
+
'name' => __('Singapore Dollar ($)', 'paid-memberships-pro' ),
|
66 |
'symbol' => '$',
|
67 |
'position' => 'right'
|
68 |
),
|
69 |
'ZAR' => array(
|
70 |
+
'name' => __('South African Rand (R)', 'paid-memberships-pro' ),
|
71 |
'symbol' => 'R ',
|
72 |
'position' => 'left'
|
73 |
),
|
74 |
'KRW' => array(
|
75 |
+
'name' => __('South Korean Won', 'paid-memberships-pro' ),
|
76 |
'decimals' => 0,
|
77 |
),
|
78 |
+
'SEK' => __('Swedish Krona', 'paid-memberships-pro' ),
|
79 |
+
'CHF' => __('Swiss Franc', 'paid-memberships-pro' ),
|
80 |
+
'TWD' => __('Taiwan New Dollars', 'paid-memberships-pro' ),
|
81 |
+
'THB' => __('Thai Baht', 'paid-memberships-pro' ),
|
82 |
+
'TRY' => __('Turkish Lira', 'paid-memberships-pro' ),
|
83 |
'VND' => array(
|
84 |
+
'name' => __('Vietnamese Dong', 'paid-memberships-pro' ),
|
85 |
'decimals' => 0,
|
86 |
),
|
87 |
);
|
91 |
//stripe only supports a few (not using this anymore since 1.7.4)
|
92 |
global $pmpro_stripe_currencies;
|
93 |
$pmpro_stripe_currencies = array(
|
94 |
+
'USD' => __('US Dollars ($)', 'paid-memberships-pro' ),
|
95 |
+
'CAD' => __('Canadian Dollars ($)', 'paid-memberships-pro' ),
|
96 |
+
'GBP' => __('Pounds Sterling (£)', 'paid-memberships-pro' ),
|
97 |
+
'EUR' => __('Euros (€)', 'paid-memberships-pro' )
|
98 |
);
|
99 |
?>
|
includes/functions.php
CHANGED
@@ -317,9 +317,9 @@ function pmpro_getLevelCost(&$level, $tags = true, $short = false)
|
|
317 |
{
|
318 |
//initial payment
|
319 |
if(!$short)
|
320 |
-
$r = sprintf(__('The price for membership is <strong>%s</strong> now', '
|
321 |
else
|
322 |
-
$r = sprintf(__('<strong>%s</strong> now', '
|
323 |
|
324 |
//recurring part
|
325 |
if($level->billing_amount != '0.00')
|
@@ -328,16 +328,16 @@ function pmpro_getLevelCost(&$level, $tags = true, $short = false)
|
|
328 |
{
|
329 |
if($level->cycle_number == '1')
|
330 |
{
|
331 |
-
$r .= sprintf(__(' and then <strong>%s per %s for %d more %s</strong>.', '
|
332 |
}
|
333 |
else
|
334 |
{
|
335 |
-
$r .= sprintf(__(' and then <strong>%s every %d %s for %d more payments</strong>.', '
|
336 |
}
|
337 |
}
|
338 |
elseif($level->billing_limit == 1)
|
339 |
{
|
340 |
-
$r .= sprintf(__(' and then <strong>%s after %d %s</strong>.', '
|
341 |
}
|
342 |
else
|
343 |
{
|
@@ -345,25 +345,25 @@ function pmpro_getLevelCost(&$level, $tags = true, $short = false)
|
|
345 |
if($level->cycle_number == '1')
|
346 |
{
|
347 |
if(!$short)
|
348 |
-
$r = sprintf(__('The price for membership is <strong>%s per %s</strong>.', '
|
349 |
else
|
350 |
-
$r = sprintf(__('<strong>%s per %s</strong>.', '
|
351 |
}
|
352 |
else
|
353 |
{
|
354 |
if(!$short)
|
355 |
-
$r = sprintf(__('The price for membership is <strong>%s every %d %s</strong>.', '
|
356 |
else
|
357 |
-
$r = sprintf(__('<strong>%s every %d %s</strong>.', '
|
358 |
}
|
359 |
} else {
|
360 |
if($level->cycle_number == '1')
|
361 |
{
|
362 |
-
$r .= sprintf(__(' and then <strong>%s per %s</strong>.', '
|
363 |
}
|
364 |
else
|
365 |
{
|
366 |
-
$r .= sprintf(__(' and then <strong>%s every %d %s</strong>.', '
|
367 |
}
|
368 |
}
|
369 |
}
|
@@ -381,22 +381,22 @@ function pmpro_getLevelCost(&$level, $tags = true, $short = false)
|
|
381 |
{
|
382 |
if($level->trial_limit == '1')
|
383 |
{
|
384 |
-
$r .= ' ' . __('After your initial payment, your first payment is Free.', '
|
385 |
}
|
386 |
else
|
387 |
{
|
388 |
-
$r .= ' ' . sprintf(__('After your initial payment, your first %d payments are Free.', '
|
389 |
}
|
390 |
}
|
391 |
else
|
392 |
{
|
393 |
if($level->trial_limit == '1')
|
394 |
{
|
395 |
-
$r .= ' ' . sprintf(__('After your initial payment, your first payment will cost %s.', '
|
396 |
}
|
397 |
else
|
398 |
{
|
399 |
-
$r .= ' ' . sprintf(__('After your initial payment, your first %d payments will cost %s.', '
|
400 |
}
|
401 |
}
|
402 |
}
|
@@ -407,7 +407,7 @@ function pmpro_getLevelCost(&$level, $tags = true, $short = false)
|
|
407 |
|
408 |
if($tax_state && $tax_rate && !pmpro_isLevelFree($level))
|
409 |
{
|
410 |
-
$r .= sprintf(__('Customers in %s will be charged %s%% tax.', '
|
411 |
}
|
412 |
|
413 |
if(!$tags)
|
@@ -452,9 +452,9 @@ function pmpro_getLevelsCost(&$levels, $tags = true, $short = false)
|
|
452 |
|
453 |
// initial payment
|
454 |
if(!$short)
|
455 |
-
$r = sprintf(__('The price for membership is <strong>%s</strong> now', '
|
456 |
else
|
457 |
-
$r = sprintf(__('<strong>%s</strong> now', '
|
458 |
|
459 |
//recurring part
|
460 |
$billtextparts = array();
|
@@ -466,26 +466,26 @@ function pmpro_getLevelsCost(&$levels, $tags = true, $short = false)
|
|
466 |
{
|
467 |
if($curcyclenum == '1')
|
468 |
{
|
469 |
-
$billtextparts[] = sprintf(__('<strong>%s per %s for %d more %s</strong>', '
|
470 |
}
|
471 |
else
|
472 |
{
|
473 |
-
$billtextparts[] = sprintf(__('<strong>%s every %d %s for %d more payments</strong>', '
|
474 |
}
|
475 |
}
|
476 |
elseif($curbilllimit == 1)
|
477 |
{
|
478 |
-
$billtextparts[] = sprintf(__('<strong>%s after %d %s</strong>', '
|
479 |
}
|
480 |
else
|
481 |
{
|
482 |
if($curcyclenum == '1')
|
483 |
{
|
484 |
-
$billtextparts[] = sprintf(__('<strong>%s every %s</strong>', '
|
485 |
}
|
486 |
else
|
487 |
{
|
488 |
-
$billtextparts[] = sprintf(__('<strong>%s every %d %s</strong>', '
|
489 |
}
|
490 |
}
|
491 |
}
|
@@ -520,7 +520,7 @@ function pmpro_getLevelsCost(&$levels, $tags = true, $short = false)
|
|
520 |
|
521 |
if($tax_state && $tax_rate && !pmpro_areLevelsFree($levels))
|
522 |
{
|
523 |
-
$r .= sprintf(__('Customers in %s will be charged %s%% tax.', '
|
524 |
}
|
525 |
|
526 |
if(!$tags)
|
@@ -537,7 +537,7 @@ function pmpro_getLevelExpiration(&$level)
|
|
537 |
{
|
538 |
if($level->expiration_number)
|
539 |
{
|
540 |
-
$expiration_text = sprintf(__("Membership expires after %d %s.",
|
541 |
}
|
542 |
else
|
543 |
$expiration_text = "";
|
@@ -554,7 +554,7 @@ function pmpro_getLevelsExpiration(&$levels)
|
|
554 |
if(!empty($levels) && !is_array($levels)) { $levels = array($levels); } elseif(empty($levels)) { $levels = array(); }
|
555 |
foreach($levels as $curlevel) {
|
556 |
if($curlevel->expiration_number) {
|
557 |
-
$expirystrings[] = sprintf(__("%s membership expires after %d %s",
|
558 |
} else {
|
559 |
$ongoinglevelnum++;
|
560 |
}
|
@@ -944,7 +944,7 @@ function pmpro_changeMembershipLevel($level, $user_id = NULL, $old_level_status
|
|
944 |
|
945 |
if(empty($user_id))
|
946 |
{
|
947 |
-
$pmpro_error = __("User ID not found.",
|
948 |
return false;
|
949 |
}
|
950 |
|
@@ -964,7 +964,7 @@ function pmpro_changeMembershipLevel($level, $user_id = NULL, $old_level_status
|
|
964 |
$level_obj = pmpro_getLevel($level);
|
965 |
if(empty($level_obj))
|
966 |
{
|
967 |
-
$pmpro_error = __("Invalid level.",
|
968 |
return false;
|
969 |
}
|
970 |
$level = $level_obj->id;
|
@@ -975,7 +975,7 @@ function pmpro_changeMembershipLevel($level, $user_id = NULL, $old_level_status
|
|
975 |
{
|
976 |
//are they even changing?
|
977 |
if(pmpro_hasMembershipLevel($level, $user_id)) {
|
978 |
-
$pmpro_error = __("not changing?",
|
979 |
return false; //not changing
|
980 |
}
|
981 |
}
|
@@ -1034,7 +1034,7 @@ function pmpro_changeMembershipLevel($level, $user_id = NULL, $old_level_status
|
|
1034 |
|
1035 |
if(!$wpdb->query($sql))
|
1036 |
{
|
1037 |
-
$pmpro_error = __("Error interacting with database",
|
1038 |
|
1039 |
return false;
|
1040 |
}
|
@@ -1124,7 +1124,7 @@ function pmpro_changeMembershipLevel($level, $user_id = NULL, $old_level_status
|
|
1124 |
|
1125 |
if( false === $wpdb->query($sql) )
|
1126 |
{
|
1127 |
-
$pmpro_error = sprintf( __("Error interacting with database: %s",
|
1128 |
return false;
|
1129 |
}
|
1130 |
}
|
@@ -1199,7 +1199,7 @@ function pmpro_toggleMembershipCategory( $level, $category, $value )
|
|
1199 |
$safe = addslashes($level);
|
1200 |
if ( ($level = intval($wpdb->get_var("SELECT id FROM {$wpdb->pmpro_membership_levels} WHERE name = '$safe' LIMIT 1"))) <= 0 )
|
1201 |
{
|
1202 |
-
return __("Membership level not found.",
|
1203 |
}
|
1204 |
}
|
1205 |
|
@@ -1238,7 +1238,7 @@ function pmpro_updateMembershipCategories($level, $categories)
|
|
1238 |
$level = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels WHERE name = '" . esc_sql($level) . "' LIMIT 1");
|
1239 |
if(empty($level))
|
1240 |
{
|
1241 |
-
return __("Membership level not found.",
|
1242 |
}
|
1243 |
}
|
1244 |
|
@@ -1606,7 +1606,7 @@ function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false
|
|
1606 |
|
1607 |
//no code, no code
|
1608 |
if(empty($code))
|
1609 |
-
$error = __("No code was given to check.",
|
1610 |
|
1611 |
//get code from db
|
1612 |
if(!$error)
|
@@ -1615,7 +1615,7 @@ function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false
|
|
1615 |
|
1616 |
//did we find it?
|
1617 |
if(empty($dbcode->id))
|
1618 |
-
$error = __("The discount code could not be found.",
|
1619 |
}
|
1620 |
|
1621 |
//check if the code has started
|
@@ -1630,14 +1630,14 @@ function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false
|
|
1630 |
|
1631 |
//has this code started yet?
|
1632 |
if(!empty($dbcode->starts) && $dbcode->starts > $today)
|
1633 |
-
$error = sprintf(__("This discount code goes into effect on %s.",
|
1634 |
}
|
1635 |
|
1636 |
//check if the code is expired
|
1637 |
if(!$error)
|
1638 |
{
|
1639 |
if(!empty($dbcode->expires) && $dbcode->expires < $today)
|
1640 |
-
$error = sprintf(__("This discount code expired on %s.",
|
1641 |
}
|
1642 |
|
1643 |
//have we run out of uses?
|
@@ -1647,7 +1647,7 @@ function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false
|
|
1647 |
{
|
1648 |
$used = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $dbcode->id . "'");
|
1649 |
if($used >= $dbcode->uses)
|
1650 |
-
$error = __("This discount code is no longer valid.",
|
1651 |
}
|
1652 |
}
|
1653 |
|
@@ -1667,7 +1667,7 @@ function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false
|
|
1667 |
$code_level = $wpdb->get_row("SELECT l.id, cl.*, l.name, l.description, l.allow_signups FROM $wpdb->pmpro_discount_codes_levels cl LEFT JOIN $wpdb->pmpro_membership_levels l ON cl.level_id = l.id WHERE cl.code_id = '" . $dbcode->id . "' AND cl.level_id IN (" . $level_id . ") LIMIT 1");
|
1668 |
|
1669 |
if(empty($code_level))
|
1670 |
-
$error = __("This discount code does not apply to this membership level.",
|
1671 |
}
|
1672 |
}
|
1673 |
|
@@ -1704,7 +1704,7 @@ function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false
|
|
1704 |
{
|
1705 |
//guess we're all good
|
1706 |
if(!empty($return_errors))
|
1707 |
-
return array(true, __("This discount code is okay.",
|
1708 |
else
|
1709 |
return true;
|
1710 |
}
|
@@ -1731,7 +1731,7 @@ function pmpro_implodeToEnglish($array, $conjunction = 'and')
|
|
1731 |
|
1732 |
//possibly translate the conjunction
|
1733 |
if($conjunction == 'and')
|
1734 |
-
$conjunction = __('and', '
|
1735 |
|
1736 |
return implode (', ', $array).' ' . $conjunction . ' '.$last;
|
1737 |
}
|
@@ -1993,13 +1993,16 @@ function pmpro_getLevelAtCheckout($level_id = NULL, $discount_code = NULL) {
|
|
1993 |
//filter adjustments to the level
|
1994 |
$pmpro_level->code_id = $discount_code_id;
|
1995 |
$pmpro_level = apply_filters( "pmpro_discount_code_level", $pmpro_level, $discount_code_id );
|
|
|
|
|
|
|
1996 |
}
|
1997 |
}
|
1998 |
|
1999 |
//what level are they purchasing? (no discount code)
|
2000 |
if ( empty( $pmpro_level ) && ! empty( $level_id ) ) {
|
2001 |
$pmpro_level = $wpdb->get_row( "SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql( $level_id ) . "' AND allow_signups = 1 LIMIT 1" );
|
2002 |
-
} elseif ( empty( $pmpro_level ) ) {
|
2003 |
//check if a level is defined in custom fields
|
2004 |
$default_level = get_post_meta( $post->ID, "pmpro_default_level", true );
|
2005 |
if ( ! empty( $default_level ) ) {
|
@@ -2016,13 +2019,13 @@ function pmpro_getLevelAtCheckout($level_id = NULL, $discount_code = NULL) {
|
|
2016 |
function pmpro_getCheckoutButton($level_id, $button_text = NULL, $classes = NULL)
|
2017 |
{
|
2018 |
if(empty($button_text))
|
2019 |
-
$button_text = __("Sign Up for !!name!! Now",
|
2020 |
|
2021 |
if(empty($classes))
|
2022 |
$classes = "pmpro_btn";
|
2023 |
|
2024 |
if(empty($level_id))
|
2025 |
-
$r = __("Please specify a level id.",
|
2026 |
else
|
2027 |
{
|
2028 |
//get level
|
317 |
{
|
318 |
//initial payment
|
319 |
if(!$short)
|
320 |
+
$r = sprintf(__('The price for membership is <strong>%s</strong> now', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment));
|
321 |
else
|
322 |
+
$r = sprintf(__('<strong>%s</strong> now', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment));
|
323 |
|
324 |
//recurring part
|
325 |
if($level->billing_amount != '0.00')
|
328 |
{
|
329 |
if($level->cycle_number == '1')
|
330 |
{
|
331 |
+
$r .= sprintf(__(' and then <strong>%s per %s for %d more %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit));
|
332 |
}
|
333 |
else
|
334 |
{
|
335 |
+
$r .= sprintf(__(' and then <strong>%s every %d %s for %d more payments</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number), $level->billing_limit);
|
336 |
}
|
337 |
}
|
338 |
elseif($level->billing_limit == 1)
|
339 |
{
|
340 |
+
$r .= sprintf(__(' and then <strong>%s after %d %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
|
341 |
}
|
342 |
else
|
343 |
{
|
345 |
if($level->cycle_number == '1')
|
346 |
{
|
347 |
if(!$short)
|
348 |
+
$r = sprintf(__('The price for membership is <strong>%s per %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period) );
|
349 |
else
|
350 |
+
$r = sprintf(__('<strong>%s per %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period) );
|
351 |
}
|
352 |
else
|
353 |
{
|
354 |
if(!$short)
|
355 |
+
$r = sprintf(__('The price for membership is <strong>%s every %d %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number) );
|
356 |
else
|
357 |
+
$r = sprintf(__('<strong>%s every %d %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number) );
|
358 |
}
|
359 |
} else {
|
360 |
if($level->cycle_number == '1')
|
361 |
{
|
362 |
+
$r .= sprintf(__(' and then <strong>%s per %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period));
|
363 |
}
|
364 |
else
|
365 |
{
|
366 |
+
$r .= sprintf(__(' and then <strong>%s every %d %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
|
367 |
}
|
368 |
}
|
369 |
}
|
381 |
{
|
382 |
if($level->trial_limit == '1')
|
383 |
{
|
384 |
+
$r .= ' ' . __('After your initial payment, your first payment is Free.', 'paid-memberships-pro' );
|
385 |
}
|
386 |
else
|
387 |
{
|
388 |
+
$r .= ' ' . sprintf(__('After your initial payment, your first %d payments are Free.', 'paid-memberships-pro' ), $level->trial_limit);
|
389 |
}
|
390 |
}
|
391 |
else
|
392 |
{
|
393 |
if($level->trial_limit == '1')
|
394 |
{
|
395 |
+
$r .= ' ' . sprintf(__('After your initial payment, your first payment will cost %s.', 'paid-memberships-pro' ), pmpro_formatPrice($level->trial_amount));
|
396 |
}
|
397 |
else
|
398 |
{
|
399 |
+
$r .= ' ' . sprintf(__('After your initial payment, your first %d payments will cost %s.', 'paid-memberships-pro' ), $level->trial_limit, pmpro_formatPrice($level->trial_amount));
|
400 |
}
|
401 |
}
|
402 |
}
|
407 |
|
408 |
if($tax_state && $tax_rate && !pmpro_isLevelFree($level))
|
409 |
{
|
410 |
+
$r .= sprintf(__('Customers in %s will be charged %s%% tax.', 'paid-memberships-pro' ), $tax_state, round($tax_rate * 100, 2));
|
411 |
}
|
412 |
|
413 |
if(!$tags)
|
452 |
|
453 |
// initial payment
|
454 |
if(!$short)
|
455 |
+
$r = sprintf(__('The price for membership is <strong>%s</strong> now', 'paid-memberships-pro' ), pmpro_formatPrice($initpmt));
|
456 |
else
|
457 |
+
$r = sprintf(__('<strong>%s</strong> now', 'paid-memberships-pro' ), pmpro_formatPrice($initpmt));
|
458 |
|
459 |
//recurring part
|
460 |
$billtextparts = array();
|
466 |
{
|
467 |
if($curcyclenum == '1')
|
468 |
{
|
469 |
+
$billtextparts[] = sprintf(__('<strong>%s per %s for %d more %s</strong>', 'paid-memberships-pro' ), pmpro_formatPrice($curtotal), pmpro_translate_billing_period($curperiod), $curbilllimit, pmpro_translate_billing_period($curperiod, $curbilllimit));
|
470 |
}
|
471 |
else
|
472 |
{
|
473 |
+
$billtextparts[] = sprintf(__('<strong>%s every %d %s for %d more payments</strong>', 'paid-memberships-pro' ), pmpro_formatPrice($curtotal), $curcyclenum, pmpro_translate_billing_period($curperiod, $curcyclenum), $curbilllimit);
|
474 |
}
|
475 |
}
|
476 |
elseif($curbilllimit == 1)
|
477 |
{
|
478 |
+
$billtextparts[] = sprintf(__('<strong>%s after %d %s</strong>', 'paid-memberships-pro' ), pmpro_formatPrice($curtotal), $curcyclenum, pmpro_translate_billing_period($curperiod, $curcyclenum));
|
479 |
}
|
480 |
else
|
481 |
{
|
482 |
if($curcyclenum == '1')
|
483 |
{
|
484 |
+
$billtextparts[] = sprintf(__('<strong>%s every %s</strong>', 'paid-memberships-pro' ), pmpro_formatPrice($curtotal), pmpro_translate_billing_period($curperiod));
|
485 |
}
|
486 |
else
|
487 |
{
|
488 |
+
$billtextparts[] = sprintf(__('<strong>%s every %d %s</strong>', 'paid-memberships-pro' ), pmpro_formatPrice($curtotal), $curcyclenum, pmpro_translate_billing_period($curperiod, $curcyclenum));
|
489 |
}
|
490 |
}
|
491 |
}
|
520 |
|
521 |
if($tax_state && $tax_rate && !pmpro_areLevelsFree($levels))
|
522 |
{
|
523 |
+
$r .= sprintf(__('Customers in %s will be charged %s%% tax.', 'paid-memberships-pro' ), $tax_state, round($tax_rate * 100, 2));
|
524 |
}
|
525 |
|
526 |
if(!$tags)
|
537 |
{
|
538 |
if($level->expiration_number)
|
539 |
{
|
540 |
+
$expiration_text = sprintf(__("Membership expires after %d %s.", 'paid-memberships-pro' ), $level->expiration_number, pmpro_translate_billing_period($level->expiration_period, $level->expiration_number));
|
541 |
}
|
542 |
else
|
543 |
$expiration_text = "";
|
554 |
if(!empty($levels) && !is_array($levels)) { $levels = array($levels); } elseif(empty($levels)) { $levels = array(); }
|
555 |
foreach($levels as $curlevel) {
|
556 |
if($curlevel->expiration_number) {
|
557 |
+
$expirystrings[] = sprintf(__("%s membership expires after %d %s", 'paid-memberships-pro' ), $curlevel->name, $curlevel->expiration_number, pmpro_translate_billing_period($curlevel->expiration_period, $curlevel->expiration_number));
|
558 |
} else {
|
559 |
$ongoinglevelnum++;
|
560 |
}
|
944 |
|
945 |
if(empty($user_id))
|
946 |
{
|
947 |
+
$pmpro_error = __("User ID not found.", 'paid-memberships-pro' );
|
948 |
return false;
|
949 |
}
|
950 |
|
964 |
$level_obj = pmpro_getLevel($level);
|
965 |
if(empty($level_obj))
|
966 |
{
|
967 |
+
$pmpro_error = __("Invalid level.", 'paid-memberships-pro' );
|
968 |
return false;
|
969 |
}
|
970 |
$level = $level_obj->id;
|
975 |
{
|
976 |
//are they even changing?
|
977 |
if(pmpro_hasMembershipLevel($level, $user_id)) {
|
978 |
+
$pmpro_error = __("not changing?", 'paid-memberships-pro' );
|
979 |
return false; //not changing
|
980 |
}
|
981 |
}
|
1034 |
|
1035 |
if(!$wpdb->query($sql))
|
1036 |
{
|
1037 |
+
$pmpro_error = __("Error interacting with database", 'paid-memberships-pro' ) . ": ".($wpdb->last_error?$wpdb->last_error:'unavailable');
|
1038 |
|
1039 |
return false;
|
1040 |
}
|
1124 |
|
1125 |
if( false === $wpdb->query($sql) )
|
1126 |
{
|
1127 |
+
$pmpro_error = sprintf( __("Error interacting with database: %s", 'paid-memberships-pro' ), (!empty($wpdb->last_error) ? $wpdb->last_error : 'unavailable' ));
|
1128 |
return false;
|
1129 |
}
|
1130 |
}
|
1199 |
$safe = addslashes($level);
|
1200 |
if ( ($level = intval($wpdb->get_var("SELECT id FROM {$wpdb->pmpro_membership_levels} WHERE name = '$safe' LIMIT 1"))) <= 0 )
|
1201 |
{
|
1202 |
+
return __("Membership level not found.", 'paid-memberships-pro' );
|
1203 |
}
|
1204 |
}
|
1205 |
|
1238 |
$level = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels WHERE name = '" . esc_sql($level) . "' LIMIT 1");
|
1239 |
if(empty($level))
|
1240 |
{
|
1241 |
+
return __("Membership level not found.", 'paid-memberships-pro' );
|
1242 |
}
|
1243 |
}
|
1244 |
|
1606 |
|
1607 |
//no code, no code
|
1608 |
if(empty($code))
|
1609 |
+
$error = __("No code was given to check.", 'paid-memberships-pro' );
|
1610 |
|
1611 |
//get code from db
|
1612 |
if(!$error)
|
1615 |
|
1616 |
//did we find it?
|
1617 |
if(empty($dbcode->id))
|
1618 |
+
$error = __("The discount code could not be found.", 'paid-memberships-pro' );
|
1619 |
}
|
1620 |
|
1621 |
//check if the code has started
|
1630 |
|
1631 |
//has this code started yet?
|
1632 |
if(!empty($dbcode->starts) && $dbcode->starts > $today)
|
1633 |
+
$error = sprintf(__("This discount code goes into effect on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $dbcode->starts));
|
1634 |
}
|
1635 |
|
1636 |
//check if the code is expired
|
1637 |
if(!$error)
|
1638 |
{
|
1639 |
if(!empty($dbcode->expires) && $dbcode->expires < $today)
|
1640 |
+
$error = sprintf(__("This discount code expired on %s.", 'paid-memberships-pro' ), date_i18n(get_option('date_format'), $dbcode->expires));
|
1641 |
}
|
1642 |
|
1643 |
//have we run out of uses?
|
1647 |
{
|
1648 |
$used = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $dbcode->id . "'");
|
1649 |
if($used >= $dbcode->uses)
|
1650 |
+
$error = __("This discount code is no longer valid.", 'paid-memberships-pro' );
|
1651 |
}
|
1652 |
}
|
1653 |
|
1667 |
$code_level = $wpdb->get_row("SELECT l.id, cl.*, l.name, l.description, l.allow_signups FROM $wpdb->pmpro_discount_codes_levels cl LEFT JOIN $wpdb->pmpro_membership_levels l ON cl.level_id = l.id WHERE cl.code_id = '" . $dbcode->id . "' AND cl.level_id IN (" . $level_id . ") LIMIT 1");
|
1668 |
|
1669 |
if(empty($code_level))
|
1670 |
+
$error = __("This discount code does not apply to this membership level.", 'paid-memberships-pro' );
|
1671 |
}
|
1672 |
}
|
1673 |
|
1704 |
{
|
1705 |
//guess we're all good
|
1706 |
if(!empty($return_errors))
|
1707 |
+
return array(true, __("This discount code is okay.", 'paid-memberships-pro' ));
|
1708 |
else
|
1709 |
return true;
|
1710 |
}
|
1731 |
|
1732 |
//possibly translate the conjunction
|
1733 |
if($conjunction == 'and')
|
1734 |
+
$conjunction = __('and', 'paid-memberships-pro' );
|
1735 |
|
1736 |
return implode (', ', $array).' ' . $conjunction . ' '.$last;
|
1737 |
}
|
1993 |
//filter adjustments to the level
|
1994 |
$pmpro_level->code_id = $discount_code_id;
|
1995 |
$pmpro_level = apply_filters( "pmpro_discount_code_level", $pmpro_level, $discount_code_id );
|
1996 |
+
} else {
|
1997 |
+
//error with discount code, we want to halt checkout
|
1998 |
+
pmpro_setMessage($code_check[1], 'pmpro_error');
|
1999 |
}
|
2000 |
}
|
2001 |
|
2002 |
//what level are they purchasing? (no discount code)
|
2003 |
if ( empty( $pmpro_level ) && ! empty( $level_id ) ) {
|
2004 |
$pmpro_level = $wpdb->get_row( "SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql( $level_id ) . "' AND allow_signups = 1 LIMIT 1" );
|
2005 |
+
} elseif ( empty( $pmpro_level ) && !empty( $post ) ) {
|
2006 |
//check if a level is defined in custom fields
|
2007 |
$default_level = get_post_meta( $post->ID, "pmpro_default_level", true );
|
2008 |
if ( ! empty( $default_level ) ) {
|
2019 |
function pmpro_getCheckoutButton($level_id, $button_text = NULL, $classes = NULL)
|
2020 |
{
|
2021 |
if(empty($button_text))
|
2022 |
+
$button_text = __("Sign Up for !!name!! Now", 'paid-memberships-pro' );
|
2023 |
|
2024 |
if(empty($classes))
|
2025 |
$classes = "pmpro_btn";
|
2026 |
|
2027 |
if(empty($level_id))
|
2028 |
+
$r = __("Please specify a level id.", 'paid-memberships-pro' );
|
2029 |
else
|
2030 |
{
|
2031 |
//get level
|
includes/init.php
CHANGED
@@ -241,7 +241,7 @@ add_action('init', 'pmpro_set_current_user');
|
|
241 |
* Add Membership Level to Users page in WordPress dashboard.
|
242 |
*/
|
243 |
function pmpro_manage_users_columns($columns) {
|
244 |
-
$columns['pmpro_membership_level'] = __('Membership Level', '
|
245 |
return $columns;
|
246 |
}
|
247 |
|
@@ -256,7 +256,7 @@ function pmpro_manage_users_custom_column($column_data, $column_name, $user_id)
|
|
256 |
$column_data = implode(',', $level_names);
|
257 |
}
|
258 |
else
|
259 |
-
$column_data = __('None', '
|
260 |
}
|
261 |
return $column_data;
|
262 |
}
|
241 |
* Add Membership Level to Users page in WordPress dashboard.
|
242 |
*/
|
243 |
function pmpro_manage_users_columns($columns) {
|
244 |
+
$columns['pmpro_membership_level'] = __('Membership Level', 'paid-memberships-pro' );
|
245 |
return $columns;
|
246 |
}
|
247 |
|
256 |
$column_data = implode(',', $level_names);
|
257 |
}
|
258 |
else
|
259 |
+
$column_data = __('None', 'paid-memberships-pro' );
|
260 |
}
|
261 |
return $column_data;
|
262 |
}
|
includes/lib/Braintree/ACKNOWLEDGEMENTS.md
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Acknowledgements
|
2 |
+
----------------
|
3 |
+
|
4 |
+
The Braintree SDK uses code from the following libraries:
|
5 |
+
|
6 |
+
* [phpunit](https://github.com/sebastianbergmann/phpunit), BSD-3-Clause License
|
includes/lib/Braintree/Braintree.php
DELETED
@@ -1,172 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree base class and initialization
|
4 |
-
*
|
5 |
-
* PHP version 5
|
6 |
-
*
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
|
11 |
-
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__)));
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Braintree PHP Library
|
15 |
-
*
|
16 |
-
* Provides methods to child classes. This class cannot be instantiated.
|
17 |
-
*
|
18 |
-
* @copyright 2010 Braintree Payment Solutions
|
19 |
-
*/
|
20 |
-
abstract class Braintree
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* @ignore
|
24 |
-
* don't permit an explicit call of the constructor!
|
25 |
-
* (like $t = new Braintree_Transaction())
|
26 |
-
*/
|
27 |
-
protected function __construct()
|
28 |
-
{
|
29 |
-
}
|
30 |
-
/**
|
31 |
-
* @ignore
|
32 |
-
* don't permit cloning the instances (like $x = clone $v)
|
33 |
-
*/
|
34 |
-
protected function __clone()
|
35 |
-
{
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* returns private/nonexistent instance properties
|
40 |
-
* @ignore
|
41 |
-
* @access public
|
42 |
-
* @param string $name property name
|
43 |
-
* @return mixed contents of instance properties
|
44 |
-
*/
|
45 |
-
public function __get($name)
|
46 |
-
{
|
47 |
-
if (array_key_exists($name, $this->_attributes)) {
|
48 |
-
return $this->_attributes[$name];
|
49 |
-
}
|
50 |
-
else {
|
51 |
-
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
|
52 |
-
return null;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* used by isset() and empty()
|
58 |
-
* @access public
|
59 |
-
* @param string $name property name
|
60 |
-
* @return boolean
|
61 |
-
*/
|
62 |
-
public function __isset($name)
|
63 |
-
{
|
64 |
-
return array_key_exists($name, $this->_attributes);
|
65 |
-
}
|
66 |
-
|
67 |
-
public function _set($key, $value)
|
68 |
-
{
|
69 |
-
$this->_attributes[$key] = $value;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
*
|
74 |
-
* @param string $className
|
75 |
-
* @param object $resultObj
|
76 |
-
* @return object returns the passed object if successful
|
77 |
-
* @throws Braintree_Exception_ValidationsFailed
|
78 |
-
*/
|
79 |
-
public static function returnObjectOrThrowException($className, $resultObj)
|
80 |
-
{
|
81 |
-
$resultObjName = Braintree_Util::cleanClassName($className);
|
82 |
-
if ($resultObj->success) {
|
83 |
-
return $resultObj->$resultObjName;
|
84 |
-
} else {
|
85 |
-
throw new Braintree_Exception_ValidationsFailed();
|
86 |
-
}
|
87 |
-
}
|
88 |
-
}
|
89 |
-
require_once('Braintree/Modification.php');
|
90 |
-
require_once('Braintree/Instance.php');
|
91 |
-
|
92 |
-
require_once('Braintree/Address.php');
|
93 |
-
require_once('Braintree/AddOn.php');
|
94 |
-
require_once('Braintree/Collection.php');
|
95 |
-
require_once('Braintree/Configuration.php');
|
96 |
-
require_once('Braintree/CreditCard.php');
|
97 |
-
require_once('Braintree/Customer.php');
|
98 |
-
require_once('Braintree/CustomerSearch.php');
|
99 |
-
require_once('Braintree/Descriptor.php');
|
100 |
-
require_once('Braintree/Digest.php');
|
101 |
-
require_once('Braintree/Discount.php');
|
102 |
-
require_once('Braintree/IsNode.php');
|
103 |
-
require_once('Braintree/EqualityNode.php');
|
104 |
-
require_once('Braintree/Exception.php');
|
105 |
-
require_once('Braintree/Http.php');
|
106 |
-
require_once('Braintree/KeyValueNode.php');
|
107 |
-
require_once('Braintree/MultipleValueNode.php');
|
108 |
-
require_once('Braintree/MultipleValueOrTextNode.php');
|
109 |
-
require_once('Braintree/PartialMatchNode.php');
|
110 |
-
require_once('Braintree/Plan.php');
|
111 |
-
require_once('Braintree/RangeNode.php');
|
112 |
-
require_once('Braintree/ResourceCollection.php');
|
113 |
-
require_once('Braintree/SettlementBatchSummary.php');
|
114 |
-
require_once('Braintree/Subscription.php');
|
115 |
-
require_once('Braintree/SubscriptionSearch.php');
|
116 |
-
require_once('Braintree/SubscriptionStatus.php');
|
117 |
-
require_once('Braintree/TextNode.php');
|
118 |
-
require_once('Braintree/Transaction.php');
|
119 |
-
require_once('Braintree/TransactionSearch.php');
|
120 |
-
require_once('Braintree/TransparentRedirect.php');
|
121 |
-
require_once('Braintree/Util.php');
|
122 |
-
require_once('Braintree/Version.php');
|
123 |
-
require_once('Braintree/Xml.php');
|
124 |
-
require_once('Braintree/Error/Codes.php');
|
125 |
-
require_once('Braintree/Error/ErrorCollection.php');
|
126 |
-
require_once('Braintree/Error/Validation.php');
|
127 |
-
require_once('Braintree/Error/ValidationErrorCollection.php');
|
128 |
-
require_once('Braintree/Exception/Authentication.php');
|
129 |
-
require_once('Braintree/Exception/Authorization.php');
|
130 |
-
require_once('Braintree/Exception/Configuration.php');
|
131 |
-
require_once('Braintree/Exception/DownForMaintenance.php');
|
132 |
-
require_once('Braintree/Exception/ForgedQueryString.php');
|
133 |
-
require_once('Braintree/Exception/InvalidSignature.php');
|
134 |
-
require_once('Braintree/Exception/NotFound.php');
|
135 |
-
require_once('Braintree/Exception/ServerError.php');
|
136 |
-
require_once('Braintree/Exception/SSLCertificate.php');
|
137 |
-
require_once('Braintree/Exception/SSLCaFileNotFound.php');
|
138 |
-
require_once('Braintree/Exception/Unexpected.php');
|
139 |
-
require_once('Braintree/Exception/UpgradeRequired.php');
|
140 |
-
require_once('Braintree/Exception/ValidationsFailed.php');
|
141 |
-
require_once('Braintree/Result/CreditCardVerification.php');
|
142 |
-
require_once('Braintree/Result/Error.php');
|
143 |
-
require_once('Braintree/Result/Successful.php');
|
144 |
-
require_once('Braintree/Test/CreditCardNumbers.php');
|
145 |
-
require_once('Braintree/Test/TransactionAmounts.php');
|
146 |
-
require_once('Braintree/Transaction/AddressDetails.php');
|
147 |
-
require_once('Braintree/Transaction/CreditCardDetails.php');
|
148 |
-
require_once('Braintree/Transaction/CustomerDetails.php');
|
149 |
-
require_once('Braintree/Transaction/StatusDetails.php');
|
150 |
-
require_once('Braintree/Transaction/SubscriptionDetails.php');
|
151 |
-
require_once('Braintree/WebhookNotification.php');
|
152 |
-
require_once('Braintree/WebhookTesting.php');
|
153 |
-
require_once('Braintree/Xml/Generator.php');
|
154 |
-
require_once('Braintree/Xml/Parser.php');
|
155 |
-
require_once('Braintree/CreditCardVerification.php');
|
156 |
-
require_once('Braintree/CreditCardVerificationSearch.php');
|
157 |
-
|
158 |
-
if (version_compare(PHP_VERSION, '5.2.1', '<')) {
|
159 |
-
throw new Braintree_Exception('PHP version >= 5.2.1 required');
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
function requireDependencies() {
|
164 |
-
$requiredExtensions = array('xmlwriter', 'SimpleXML', 'openssl', 'dom', 'hash', 'curl');
|
165 |
-
foreach ($requiredExtensions AS $ext) {
|
166 |
-
if (!extension_loaded($ext)) {
|
167 |
-
throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.');
|
168 |
-
}
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
requireDependencies();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/AddOn.php
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_AddOn extends Braintree_Modification
|
3 |
-
{
|
4 |
-
public static function all()
|
5 |
-
{
|
6 |
-
$response = Braintree_Http::get('/add_ons');
|
7 |
-
|
8 |
-
$addOns = array("addOn" => $response['addOns']);
|
9 |
-
|
10 |
-
return Braintree_Util::extractAttributeAsArray(
|
11 |
-
$addOns,
|
12 |
-
'addOn'
|
13 |
-
);
|
14 |
-
}
|
15 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Address.php
DELETED
@@ -1,352 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree Address module
|
4 |
-
*
|
5 |
-
* PHP Version 5
|
6 |
-
*
|
7 |
-
* @package Braintree
|
8 |
-
* @copyright 2010 Braintree Payment Solutions
|
9 |
-
*/
|
10 |
-
/**
|
11 |
-
* Creates and manages Braintree Addresses
|
12 |
-
*
|
13 |
-
* An Address belongs to a Customer. It can be associated to a
|
14 |
-
* CreditCard as the billing address. It can also be used
|
15 |
-
* as the shipping address when creating a Transaction.
|
16 |
-
*
|
17 |
-
* @package Braintree
|
18 |
-
* @copyright 2010 Braintree Payment Solutions
|
19 |
-
*
|
20 |
-
* @property-read string $company
|
21 |
-
* @property-read string $countryName
|
22 |
-
* @property-read string $createdAt
|
23 |
-
* @property-read string $customerId
|
24 |
-
* @property-read string $extendedAddress
|
25 |
-
* @property-read string $firstName
|
26 |
-
* @property-read string $id
|
27 |
-
* @property-read string $lastName
|
28 |
-
* @property-read string $locality
|
29 |
-
* @property-read string $postalCode
|
30 |
-
* @property-read string $region
|
31 |
-
* @property-read string $streetAddress
|
32 |
-
* @property-read string $updatedAt
|
33 |
-
*/
|
34 |
-
class Braintree_Address extends Braintree
|
35 |
-
{
|
36 |
-
|
37 |
-
/* public class methods */
|
38 |
-
/**
|
39 |
-
*
|
40 |
-
* @access public
|
41 |
-
* @param array $attribs
|
42 |
-
* @return object Result, either Successful or Error
|
43 |
-
*/
|
44 |
-
public static function create($attribs)
|
45 |
-
{
|
46 |
-
Braintree_Util::verifyKeys(self::createSignature(), $attribs);
|
47 |
-
$customerId = isset($attribs['customerId']) ?
|
48 |
-
$attribs['customerId'] :
|
49 |
-
null;
|
50 |
-
|
51 |
-
self::_validateCustomerId($customerId);
|
52 |
-
unset($attribs['customerId']);
|
53 |
-
return self::_doCreate(
|
54 |
-
'/customers/' . $customerId . '/addresses',
|
55 |
-
array('address' => $attribs)
|
56 |
-
);
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* attempts the create operation assuming all data will validate
|
61 |
-
* returns a Braintree_Address object instead of a Result
|
62 |
-
*
|
63 |
-
* @access public
|
64 |
-
* @param array $attribs
|
65 |
-
* @return object
|
66 |
-
* @throws Braintree_Exception_ValidationError
|
67 |
-
*/
|
68 |
-
public static function createNoValidate($attribs)
|
69 |
-
{
|
70 |
-
$result = self::create($attribs);
|
71 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
72 |
-
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* delete an address by id
|
77 |
-
*
|
78 |
-
* @param mixed $customerOrId
|
79 |
-
* @param string $addressId
|
80 |
-
*/
|
81 |
-
public static function delete($customerOrId = null, $addressId = null)
|
82 |
-
{
|
83 |
-
self::_validateId($addressId);
|
84 |
-
$customerId = self::_determineCustomerId($customerOrId);
|
85 |
-
Braintree_Http::delete(
|
86 |
-
'/customers/' . $customerId . '/addresses/' . $addressId
|
87 |
-
);
|
88 |
-
return new Braintree_Result_Successful();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* find an address by id
|
93 |
-
*
|
94 |
-
* Finds the address with the given <b>addressId</b> that is associated
|
95 |
-
* to the given <b>customerOrId</b>.
|
96 |
-
* If the address cannot be found, a NotFound exception will be thrown.
|
97 |
-
*
|
98 |
-
*
|
99 |
-
* @access public
|
100 |
-
* @param mixed $customerOrId
|
101 |
-
* @param string $addressId
|
102 |
-
* @return object Braintree_Address
|
103 |
-
* @throws Braintree_Exception_NotFound
|
104 |
-
*/
|
105 |
-
public static function find($customerOrId, $addressId)
|
106 |
-
{
|
107 |
-
|
108 |
-
$customerId = self::_determineCustomerId($customerOrId);
|
109 |
-
self::_validateId($addressId);
|
110 |
-
|
111 |
-
try {
|
112 |
-
$response = Braintree_Http::get(
|
113 |
-
'/customers/' . $customerId . '/addresses/' . $addressId
|
114 |
-
);
|
115 |
-
return self::factory($response['address']);
|
116 |
-
} catch (Braintree_Exception_NotFound $e) {
|
117 |
-
throw new Braintree_Exception_NotFound(
|
118 |
-
'address for customer ' . $customerId .
|
119 |
-
' with id ' . $addressId . ' not found.'
|
120 |
-
);
|
121 |
-
}
|
122 |
-
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* returns false if comparing object is not a Braintree_Address,
|
127 |
-
* or is a Braintree_Address with a different id
|
128 |
-
*
|
129 |
-
* @param object $other address to compare against
|
130 |
-
* @return boolean
|
131 |
-
*/
|
132 |
-
public function isEqual($other)
|
133 |
-
{
|
134 |
-
return !($other instanceof Braintree_Address) ?
|
135 |
-
false :
|
136 |
-
($this->id === $other->id && $this->customerId === $other->customerId);
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* updates the address record
|
141 |
-
*
|
142 |
-
* if calling this method in static context,
|
143 |
-
* customerOrId is the 2nd attribute, addressId 3rd.
|
144 |
-
* customerOrId & addressId are not sent in object context.
|
145 |
-
*
|
146 |
-
*
|
147 |
-
* @access public
|
148 |
-
* @param array $attributes
|
149 |
-
* @param mixed $customerOrId (only used in static call)
|
150 |
-
* @param string $addressId (only used in static call)
|
151 |
-
* @return object Braintree_Result_Successful or Braintree_Result_Error
|
152 |
-
*/
|
153 |
-
public static function update($customerOrId, $addressId, $attributes)
|
154 |
-
{
|
155 |
-
self::_validateId($addressId);
|
156 |
-
$customerId = self::_determineCustomerId($customerOrId);
|
157 |
-
Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
|
158 |
-
|
159 |
-
$response = Braintree_Http::put(
|
160 |
-
'/customers/' . $customerId . '/addresses/' . $addressId,
|
161 |
-
array('address' => $attributes)
|
162 |
-
);
|
163 |
-
|
164 |
-
return self::_verifyGatewayResponse($response);
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* update an address record, assuming validations will pass
|
170 |
-
*
|
171 |
-
* if calling this method in static context,
|
172 |
-
* customerOrId is the 2nd attribute, addressId 3rd.
|
173 |
-
* customerOrId & addressId are not sent in object context.
|
174 |
-
*
|
175 |
-
* @access public
|
176 |
-
* @param array $transactionAttribs
|
177 |
-
* @param string $customerId
|
178 |
-
* @return object Braintree_Transaction
|
179 |
-
* @throws Braintree_Exception_ValidationsFailed
|
180 |
-
* @see Braintree_Address::update()
|
181 |
-
*/
|
182 |
-
public static function updateNoValidate($customerOrId, $addressId, $attributes)
|
183 |
-
{
|
184 |
-
$result = self::update($customerOrId, $addressId, $attributes);
|
185 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* creates a full array signature of a valid create request
|
190 |
-
* @return array gateway create request format
|
191 |
-
*/
|
192 |
-
public static function createSignature()
|
193 |
-
{
|
194 |
-
return array(
|
195 |
-
'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
|
196 |
-
'countryName', 'customerId', 'extendedAddress', 'firstName',
|
197 |
-
'lastName', 'locality', 'postalCode', 'region', 'streetAddress'
|
198 |
-
);
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* creates a full array signature of a valid update request
|
203 |
-
* @return array gateway update request format
|
204 |
-
*/
|
205 |
-
public static function updateSignature()
|
206 |
-
{
|
207 |
-
// TODO: remove customerId from update signature
|
208 |
-
return self::createSignature();
|
209 |
-
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* create a printable representation of the object as:
|
214 |
-
* ClassName[property=value, property=value]
|
215 |
-
* @ignore
|
216 |
-
* @return var
|
217 |
-
*/
|
218 |
-
public function __toString()
|
219 |
-
{
|
220 |
-
return __CLASS__ . '[' .
|
221 |
-
Braintree_Util::attributesToString($this->_attributes) .']';
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* sets instance properties from an array of values
|
226 |
-
*
|
227 |
-
* @ignore
|
228 |
-
* @access protected
|
229 |
-
* @param array $addressAttribs array of address data
|
230 |
-
* @return none
|
231 |
-
*/
|
232 |
-
protected function _initialize($addressAttribs)
|
233 |
-
{
|
234 |
-
// set the attributes
|
235 |
-
$this->_attributes = $addressAttribs;
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* verifies that a valid address id is being used
|
240 |
-
* @ignore
|
241 |
-
* @param string $id address id
|
242 |
-
* @throws InvalidArgumentException
|
243 |
-
*/
|
244 |
-
private static function _validateId($id = null)
|
245 |
-
{
|
246 |
-
if (empty($id) || trim($id) == "") {
|
247 |
-
throw new InvalidArgumentException(
|
248 |
-
'expected address id to be set'
|
249 |
-
);
|
250 |
-
}
|
251 |
-
if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
|
252 |
-
throw new InvalidArgumentException(
|
253 |
-
$id . ' is an invalid address id.'
|
254 |
-
);
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* verifies that a valid customer id is being used
|
260 |
-
* @ignore
|
261 |
-
* @param string $id customer id
|
262 |
-
* @throws InvalidArgumentException
|
263 |
-
*/
|
264 |
-
private static function _validateCustomerId($id = null)
|
265 |
-
{
|
266 |
-
if (empty($id) || trim($id) == "") {
|
267 |
-
throw new InvalidArgumentException(
|
268 |
-
'expected customer id to be set'
|
269 |
-
);
|
270 |
-
}
|
271 |
-
if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
|
272 |
-
throw new InvalidArgumentException(
|
273 |
-
$id . ' is an invalid customer id.'
|
274 |
-
);
|
275 |
-
}
|
276 |
-
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* determines if a string id or Customer object was passed
|
281 |
-
* @ignore
|
282 |
-
* @param mixed $customerOrId
|
283 |
-
* @return string customerId
|
284 |
-
*/
|
285 |
-
private static function _determineCustomerId($customerOrId)
|
286 |
-
{
|
287 |
-
$customerId = ($customerOrId instanceof Braintree_Customer) ? $customerOrId->id : $customerOrId;
|
288 |
-
self::_validateCustomerId($customerId);
|
289 |
-
return $customerId;
|
290 |
-
|
291 |
-
}
|
292 |
-
|
293 |
-
/* private class methods */
|
294 |
-
/**
|
295 |
-
* sends the create request to the gateway
|
296 |
-
* @ignore
|
297 |
-
* @param string $url
|
298 |
-
* @param array $params
|
299 |
-
* @return mixed
|
300 |
-
*/
|
301 |
-
private static function _doCreate($url, $params)
|
302 |
-
{
|
303 |
-
$response = Braintree_Http::post($url, $params);
|
304 |
-
|
305 |
-
return self::_verifyGatewayResponse($response);
|
306 |
-
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* generic method for validating incoming gateway responses
|
311 |
-
*
|
312 |
-
* creates a new Braintree_Address object and encapsulates
|
313 |
-
* it inside a Braintree_Result_Successful object, or
|
314 |
-
* encapsulates a Braintree_Errors object inside a Result_Error
|
315 |
-
* alternatively, throws an Unexpected exception if the response is invalid.
|
316 |
-
*
|
317 |
-
* @ignore
|
318 |
-
* @param array $response gateway response values
|
319 |
-
* @return object Result_Successful or Result_Error
|
320 |
-
* @throws Braintree_Exception_Unexpected
|
321 |
-
*/
|
322 |
-
private static function _verifyGatewayResponse($response)
|
323 |
-
{
|
324 |
-
if (isset($response['address'])) {
|
325 |
-
// return a populated instance of Braintree_Address
|
326 |
-
return new Braintree_Result_Successful(
|
327 |
-
self::factory($response['address'])
|
328 |
-
);
|
329 |
-
} else if (isset($response['apiErrorResponse'])) {
|
330 |
-
return new Braintree_Result_Error($response['apiErrorResponse']);
|
331 |
-
} else {
|
332 |
-
throw new Braintree_Exception_Unexpected(
|
333 |
-
"Expected address or apiErrorResponse"
|
334 |
-
);
|
335 |
-
}
|
336 |
-
|
337 |
-
}
|
338 |
-
|
339 |
-
/**
|
340 |
-
* factory method: returns an instance of Braintree_Address
|
341 |
-
* to the requesting method, with populated properties
|
342 |
-
* @ignore
|
343 |
-
* @return object instance of Braintree_Address
|
344 |
-
*/
|
345 |
-
public static function factory($attributes)
|
346 |
-
{
|
347 |
-
$instance = new self();
|
348 |
-
$instance->_initialize($attributes);
|
349 |
-
return $instance;
|
350 |
-
|
351 |
-
}
|
352 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Configuration.php
DELETED
@@ -1,346 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* Configuration registry
|
5 |
-
*
|
6 |
-
* @package Braintree
|
7 |
-
* @subpackage Utility
|
8 |
-
* @copyright 2010 Braintree Payment Solutions
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
* acts as a registry for config data.
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @package Braintree
|
16 |
-
* @subpackage Utility
|
17 |
-
*
|
18 |
-
* */
|
19 |
-
|
20 |
-
class Braintree_Configuration extends Braintree
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Braintree API version to use
|
24 |
-
* @access public
|
25 |
-
*/
|
26 |
-
const API_VERSION = 3;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @var array array of config properties
|
30 |
-
* @access protected
|
31 |
-
* @static
|
32 |
-
*/
|
33 |
-
private static $_cache = array(
|
34 |
-
'environment' => '',
|
35 |
-
'merchantId' => '',
|
36 |
-
'publicKey' => '',
|
37 |
-
'privateKey' => '',
|
38 |
-
);
|
39 |
-
/**
|
40 |
-
*
|
41 |
-
* @access protected
|
42 |
-
* @static
|
43 |
-
* @var array valid environments, used for validation
|
44 |
-
*/
|
45 |
-
private static $_validEnvironments = array(
|
46 |
-
'development',
|
47 |
-
'sandbox',
|
48 |
-
'production',
|
49 |
-
'qa',
|
50 |
-
);
|
51 |
-
|
52 |
-
/**
|
53 |
-
* resets configuration to default
|
54 |
-
* @access public
|
55 |
-
* @static
|
56 |
-
*/
|
57 |
-
public static function reset()
|
58 |
-
{
|
59 |
-
self::$_cache = array (
|
60 |
-
'environment' => '',
|
61 |
-
'merchantId' => '',
|
62 |
-
'publicKey' => '',
|
63 |
-
'privateKey' => '',
|
64 |
-
);
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* performs sanity checks when config settings are being set
|
69 |
-
*
|
70 |
-
* @ignore
|
71 |
-
* @access protected
|
72 |
-
* @param string $key name of config setting
|
73 |
-
* @param string $value value to set
|
74 |
-
* @throws InvalidArgumentException
|
75 |
-
* @throws Braintree_Exception_Configuration
|
76 |
-
* @static
|
77 |
-
* @return boolean
|
78 |
-
*/
|
79 |
-
private static function validate($key=null, $value=null)
|
80 |
-
{
|
81 |
-
if (empty($key) && empty($value)) {
|
82 |
-
throw new InvalidArgumentException('nothing to validate');
|
83 |
-
}
|
84 |
-
|
85 |
-
if ($key === 'environment' &&
|
86 |
-
!in_array($value, self::$_validEnvironments) ) {
|
87 |
-
throw new Braintree_Exception_Configuration('"' .
|
88 |
-
$value . '" is not a valid environment.');
|
89 |
-
}
|
90 |
-
|
91 |
-
if (!isset(self::$_cache[$key])) {
|
92 |
-
throw new Braintree_Exception_Configuration($key .
|
93 |
-
' is not a valid configuration setting.');
|
94 |
-
}
|
95 |
-
|
96 |
-
if (empty($value)) {
|
97 |
-
throw new InvalidArgumentException($key . ' cannot be empty.');
|
98 |
-
}
|
99 |
-
|
100 |
-
return true;
|
101 |
-
}
|
102 |
-
|
103 |
-
private static function set($key, $value)
|
104 |
-
{
|
105 |
-
// this method will raise an exception on invalid data
|
106 |
-
self::validate($key, $value);
|
107 |
-
// set the value in the cache
|
108 |
-
self::$_cache[$key] = $value;
|
109 |
-
|
110 |
-
}
|
111 |
-
|
112 |
-
private static function get($key)
|
113 |
-
{
|
114 |
-
// throw an exception if the value hasn't been set
|
115 |
-
if (isset(self::$_cache[$key]) &&
|
116 |
-
(empty(self::$_cache[$key]))) {
|
117 |
-
throw new Braintree_Exception_Configuration(
|
118 |
-
$key.' needs to be set'
|
119 |
-
);
|
120 |
-
}
|
121 |
-
|
122 |
-
if (array_key_exists($key, self::$_cache)) {
|
123 |
-
return self::$_cache[$key];
|
124 |
-
}
|
125 |
-
|
126 |
-
// return null by default to prevent __set from overloading
|
127 |
-
return null;
|
128 |
-
}
|
129 |
-
|
130 |
-
|
131 |
-
private static function setOrGet($name, $value = null)
|
132 |
-
{
|
133 |
-
if (!empty($value) && is_array($value)) {
|
134 |
-
$value = $value[0];
|
135 |
-
}
|
136 |
-
if (!empty($value)) {
|
137 |
-
self::set($name, $value);
|
138 |
-
} else {
|
139 |
-
return self::get($name);
|
140 |
-
}
|
141 |
-
return true;
|
142 |
-
}
|
143 |
-
/**#@+
|
144 |
-
* sets or returns the property after validation
|
145 |
-
* @access public
|
146 |
-
* @static
|
147 |
-
* @param string $value pass a string to set, empty to get
|
148 |
-
* @return mixed returns true on set
|
149 |
-
*/
|
150 |
-
public static function environment($value = null)
|
151 |
-
{
|
152 |
-
return self::setOrGet(__FUNCTION__, $value);
|
153 |
-
}
|
154 |
-
|
155 |
-
public static function merchantId($value = null)
|
156 |
-
{
|
157 |
-
return self::setOrGet(__FUNCTION__, $value);
|
158 |
-
}
|
159 |
-
|
160 |
-
public static function publicKey($value = null)
|
161 |
-
{
|
162 |
-
return self::setOrGet(__FUNCTION__, $value);
|
163 |
-
}
|
164 |
-
|
165 |
-
public static function privateKey($value = null)
|
166 |
-
{
|
167 |
-
return self::setOrGet(__FUNCTION__, $value);
|
168 |
-
}
|
169 |
-
/**#@-*/
|
170 |
-
|
171 |
-
/**
|
172 |
-
* returns the full merchant URL based on config values
|
173 |
-
*
|
174 |
-
* @access public
|
175 |
-
* @static
|
176 |
-
* @param none
|
177 |
-
* @return string merchant URL
|
178 |
-
*/
|
179 |
-
public static function merchantUrl()
|
180 |
-
{
|
181 |
-
return self::baseUrl() .
|
182 |
-
self::merchantPath();
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* returns the base braintree gateway URL based on config values
|
187 |
-
*
|
188 |
-
* @access public
|
189 |
-
* @static
|
190 |
-
* @param none
|
191 |
-
* @return string braintree gateway URL
|
192 |
-
*/
|
193 |
-
public static function baseUrl()
|
194 |
-
{
|
195 |
-
return self::protocol() . '://' .
|
196 |
-
self::serverName() . ':' .
|
197 |
-
self::portNumber();
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* sets the merchant path based on merchant ID
|
202 |
-
*
|
203 |
-
* @access protected
|
204 |
-
* @static
|
205 |
-
* @param none
|
206 |
-
* @return string merchant path uri
|
207 |
-
*/
|
208 |
-
public static function merchantPath()
|
209 |
-
{
|
210 |
-
return '/merchants/'.self::merchantId();
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* sets the physical path for the location of the CA certs
|
215 |
-
*
|
216 |
-
* @access public
|
217 |
-
* @static
|
218 |
-
* @param none
|
219 |
-
* @return string filepath
|
220 |
-
*/
|
221 |
-
public static function caFile($sslPath = NULL)
|
222 |
-
{
|
223 |
-
$sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
|
224 |
-
'ssl' . DIRECTORY_SEPARATOR;
|
225 |
-
|
226 |
-
switch(self::environment()) {
|
227 |
-
case 'production':
|
228 |
-
$caPath = realpath(
|
229 |
-
dirname(__FILE__) .
|
230 |
-
$sslPath . 'www_braintreegateway_com.ca.crt'
|
231 |
-
);
|
232 |
-
break;
|
233 |
-
case 'qa':
|
234 |
-
case 'sandbox':
|
235 |
-
default:
|
236 |
-
$caPath = realpath(
|
237 |
-
dirname(__FILE__) .
|
238 |
-
$sslPath . 'sandbox_braintreegateway_com.ca.crt'
|
239 |
-
);
|
240 |
-
break;
|
241 |
-
}
|
242 |
-
|
243 |
-
if (!file_exists($caPath))
|
244 |
-
{
|
245 |
-
throw new Braintree_Exception_SSLCaFileNotFound();
|
246 |
-
}
|
247 |
-
|
248 |
-
return $caPath;
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* returns the port number depending on environment
|
253 |
-
*
|
254 |
-
* @access public
|
255 |
-
* @static
|
256 |
-
* @param none
|
257 |
-
* @return int portnumber
|
258 |
-
*/
|
259 |
-
public static function portNumber()
|
260 |
-
{
|
261 |
-
if (self::sslOn()) {
|
262 |
-
return 443;
|
263 |
-
}
|
264 |
-
return getenv("GATEWAY_PORT") ? getenv("GATEWAY_PORT") : 3000;
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* returns http protocol depending on environment
|
269 |
-
*
|
270 |
-
* @access public
|
271 |
-
* @static
|
272 |
-
* @param none
|
273 |
-
* @return string http || https
|
274 |
-
*/
|
275 |
-
public static function protocol()
|
276 |
-
{
|
277 |
-
return self::sslOn() ? 'https' : 'http';
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* returns gateway server name depending on environment
|
282 |
-
*
|
283 |
-
* @access public
|
284 |
-
* @static
|
285 |
-
* @param none
|
286 |
-
* @return string server domain name
|
287 |
-
*/
|
288 |
-
public static function serverName()
|
289 |
-
{
|
290 |
-
switch(self::environment()) {
|
291 |
-
case 'production':
|
292 |
-
$serverName = 'www.braintreegateway.com';
|
293 |
-
break;
|
294 |
-
case 'qa':
|
295 |
-
$serverName = 'qa.braintreegateway.com';
|
296 |
-
break;
|
297 |
-
case 'sandbox':
|
298 |
-
$serverName = 'sandbox.braintreegateway.com';
|
299 |
-
break;
|
300 |
-
case 'development':
|
301 |
-
default:
|
302 |
-
$serverName = 'localhost';
|
303 |
-
break;
|
304 |
-
}
|
305 |
-
|
306 |
-
return $serverName;
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* returns boolean indicating SSL is on or off for this session,
|
311 |
-
* depending on environment
|
312 |
-
*
|
313 |
-
* @access public
|
314 |
-
* @static
|
315 |
-
* @param none
|
316 |
-
* @return boolean
|
317 |
-
*/
|
318 |
-
public static function sslOn()
|
319 |
-
{
|
320 |
-
switch(self::environment()) {
|
321 |
-
case 'development':
|
322 |
-
$ssl = false;
|
323 |
-
break;
|
324 |
-
case 'production':
|
325 |
-
case 'qa':
|
326 |
-
case 'sandbox':
|
327 |
-
default:
|
328 |
-
$ssl = true;
|
329 |
-
break;
|
330 |
-
}
|
331 |
-
|
332 |
-
return $ssl;
|
333 |
-
}
|
334 |
-
|
335 |
-
/**
|
336 |
-
* log message to default logger
|
337 |
-
*
|
338 |
-
* @param string $message
|
339 |
-
*
|
340 |
-
*/
|
341 |
-
public static function logMessage($message)
|
342 |
-
{
|
343 |
-
error_log('[Braintree] ' . $message);
|
344 |
-
}
|
345 |
-
|
346 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/CreditCard.php
DELETED
@@ -1,591 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree CreditCard module
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @category Resources
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Creates and manages Braintree CreditCards
|
12 |
-
*
|
13 |
-
* <b>== More information ==</b>
|
14 |
-
*
|
15 |
-
* 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 />
|
16 |
-
* 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}
|
17 |
-
*
|
18 |
-
* @package Braintree
|
19 |
-
* @category Resources
|
20 |
-
* @copyright 2010 Braintree Payment Solutions
|
21 |
-
*
|
22 |
-
* @property-read string $billingAddress
|
23 |
-
* @property-read string $bin
|
24 |
-
* @property-read string $cardType
|
25 |
-
* @property-read string $cardholderName
|
26 |
-
* @property-read string $createdAt
|
27 |
-
* @property-read string $customerId
|
28 |
-
* @property-read string $expirationDate
|
29 |
-
* @property-read string $expirationMonth
|
30 |
-
* @property-read string $expirationYear
|
31 |
-
* @property-read string $last4
|
32 |
-
* @property-read string $maskedNumber
|
33 |
-
* @property-read string $token
|
34 |
-
* @property-read string $updatedAt
|
35 |
-
*/
|
36 |
-
class Braintree_CreditCard extends Braintree
|
37 |
-
{
|
38 |
-
// Card Type
|
39 |
-
const AMEX = 'American Express';
|
40 |
-
const CARTE_BLANCHE = 'Carte Blanche';
|
41 |
-
const CHINA_UNION_PAY = 'China UnionPay';
|
42 |
-
const DINERS_CLUB_INTERNATIONAL = 'Diners Club';
|
43 |
-
const DISCOVER = 'Discover';
|
44 |
-
const JCB = 'JCB';
|
45 |
-
const LASER = 'Laser';
|
46 |
-
const MAESTRO = 'Maestro';
|
47 |
-
const MASTER_CARD = 'MasterCard';
|
48 |
-
const SOLO = 'Solo';
|
49 |
-
const SWITCH_TYPE = 'Switch';
|
50 |
-
const VISA = 'Visa';
|
51 |
-
const UNKNOWN = 'Unknown';
|
52 |
-
|
53 |
-
// Credit card origination location
|
54 |
-
const INTERNATIONAL = "international";
|
55 |
-
const US = "us";
|
56 |
-
|
57 |
-
const PREPAID_YES = 'Yes';
|
58 |
-
const PREPAID_NO = 'No';
|
59 |
-
const PREPAID_UNKNOWN = 'Unknown';
|
60 |
-
|
61 |
-
const PAYROLL_YES = 'Yes';
|
62 |
-
const PAYROLL_NO = 'No';
|
63 |
-
const PAYROLL_UNKNOWN = 'Unknown';
|
64 |
-
|
65 |
-
const HEALTHCARE_YES = 'Yes';
|
66 |
-
const HEALTHCARE_NO = 'No';
|
67 |
-
const HEALTHCARE_UNKNOWN = 'Unknown';
|
68 |
-
|
69 |
-
const DURBIN_REGULATED_YES = 'Yes';
|
70 |
-
const DURBIN_REGULATED_NO = 'No';
|
71 |
-
const DURBIN_REGULATED_UNKNOWN = 'Unknown';
|
72 |
-
|
73 |
-
const DEBIT_YES = 'Yes';
|
74 |
-
const DEBIT_NO = 'No';
|
75 |
-
const DEBIT_UNKNOWN = 'Unknown';
|
76 |
-
|
77 |
-
const COMMERCIAL_YES = 'Yes';
|
78 |
-
const COMMERCIAL_NO = 'No';
|
79 |
-
const COMMERCIAL_UNKNOWN = 'Unknown';
|
80 |
-
|
81 |
-
const COUNTRY_OF_ISSUANCE_UNKNOWN = "Unknown";
|
82 |
-
const ISSUING_BANK_UNKNOWN = "Unknown";
|
83 |
-
|
84 |
-
public static function create($attribs)
|
85 |
-
{
|
86 |
-
Braintree_Util::verifyKeys(self::createSignature(), $attribs);
|
87 |
-
return self::_doCreate('/payment_methods', array('credit_card' => $attribs));
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* attempts the create operation assuming all data will validate
|
92 |
-
* returns a Braintree_CreditCard object instead of a Result
|
93 |
-
*
|
94 |
-
* @access public
|
95 |
-
* @param array $attribs
|
96 |
-
* @return object
|
97 |
-
* @throws Braintree_Exception_ValidationError
|
98 |
-
*/
|
99 |
-
public static function createNoValidate($attribs)
|
100 |
-
{
|
101 |
-
$result = self::create($attribs);
|
102 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
103 |
-
}
|
104 |
-
/**
|
105 |
-
* create a customer from a TransparentRedirect operation
|
106 |
-
*
|
107 |
-
* @access public
|
108 |
-
* @param array $attribs
|
109 |
-
* @return object
|
110 |
-
*/
|
111 |
-
public static function createFromTransparentRedirect($queryString)
|
112 |
-
{
|
113 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
114 |
-
$params = Braintree_TransparentRedirect::parseAndValidateQueryString(
|
115 |
-
$queryString
|
116 |
-
);
|
117 |
-
return self::_doCreate(
|
118 |
-
'/payment_methods/all/confirm_transparent_redirect_request',
|
119 |
-
array('id' => $params['id'])
|
120 |
-
);
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
*
|
125 |
-
* @access public
|
126 |
-
* @param none
|
127 |
-
* @return string
|
128 |
-
*/
|
129 |
-
public static function createCreditCardUrl()
|
130 |
-
{
|
131 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
|
132 |
-
return Braintree_Configuration::merchantUrl() .
|
133 |
-
'/payment_methods/all/create_via_transparent_redirect_request';
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* returns a ResourceCollection of expired credit cards
|
138 |
-
* @return object ResourceCollection
|
139 |
-
*/
|
140 |
-
public static function expired()
|
141 |
-
{
|
142 |
-
$response = Braintree_Http::post("/payment_methods/all/expired_ids");
|
143 |
-
$pager = array(
|
144 |
-
'className' => __CLASS__,
|
145 |
-
'classMethod' => 'fetchExpired',
|
146 |
-
'methodArgs' => array()
|
147 |
-
);
|
148 |
-
|
149 |
-
return new Braintree_ResourceCollection($response, $pager);
|
150 |
-
}
|
151 |
-
|
152 |
-
public static function fetchExpired($ids)
|
153 |
-
{
|
154 |
-
$response = Braintree_Http::post("/payment_methods/all/expired", array('search' => array('ids' => $ids)));
|
155 |
-
|
156 |
-
return braintree_util::extractattributeasarray(
|
157 |
-
$response['paymentMethods'],
|
158 |
-
'creditCard'
|
159 |
-
);
|
160 |
-
}
|
161 |
-
/**
|
162 |
-
* returns a ResourceCollection of credit cards expiring between start/end
|
163 |
-
*
|
164 |
-
* @return object ResourceCollection
|
165 |
-
*/
|
166 |
-
public static function expiringBetween($startDate, $endDate)
|
167 |
-
{
|
168 |
-
$queryPath = '/payment_methods/all/expiring_ids?start=' . date_i18n('mY', $startDate) . '&end=' . date_i18n('mY', $endDate);
|
169 |
-
$response = Braintree_Http::post($queryPath);
|
170 |
-
$pager = array(
|
171 |
-
'className' => __CLASS__,
|
172 |
-
'classMethod' => 'fetchExpiring',
|
173 |
-
'methodArgs' => array($startDate, $endDate)
|
174 |
-
);
|
175 |
-
|
176 |
-
return new Braintree_ResourceCollection($response, $pager);
|
177 |
-
}
|
178 |
-
|
179 |
-
public static function fetchExpiring($startDate, $endDate, $ids)
|
180 |
-
{
|
181 |
-
$queryPath = '/payment_methods/all/expiring?start=' . date_i18n('mY', $startDate) . '&end=' . date_i18n('mY', $endDate);
|
182 |
-
$response = Braintree_Http::post($queryPath, array('search' => array('ids' => $ids)));
|
183 |
-
|
184 |
-
return Braintree_Util::extractAttributeAsArray(
|
185 |
-
$response['paymentMethods'],
|
186 |
-
'creditCard'
|
187 |
-
);
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* find a creditcard by token
|
192 |
-
*
|
193 |
-
* @access public
|
194 |
-
* @param string $token credit card unique id
|
195 |
-
* @return object Braintree_CreditCard
|
196 |
-
* @throws Braintree_Exception_NotFound
|
197 |
-
*/
|
198 |
-
public static function find($token)
|
199 |
-
{
|
200 |
-
self::_validateId($token);
|
201 |
-
try {
|
202 |
-
$response = Braintree_Http::get('/payment_methods/'.$token);
|
203 |
-
return self::factory($response['creditCard']);
|
204 |
-
} catch (Braintree_Exception_NotFound $e) {
|
205 |
-
throw new Braintree_Exception_NotFound(
|
206 |
-
'credit card with token ' . $token . ' not found'
|
207 |
-
);
|
208 |
-
}
|
209 |
-
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* create a credit on the card for the passed transaction
|
214 |
-
*
|
215 |
-
* @access public
|
216 |
-
* @param array $attribs
|
217 |
-
* @return object Braintree_Result_Successful or Braintree_Result_Error
|
218 |
-
*/
|
219 |
-
public static function credit($token, $transactionAttribs)
|
220 |
-
{
|
221 |
-
self::_validateId($token);
|
222 |
-
return Braintree_Transaction::credit(
|
223 |
-
array_merge(
|
224 |
-
$transactionAttribs,
|
225 |
-
array('paymentMethodToken' => $token)
|
226 |
-
)
|
227 |
-
);
|
228 |
-
}
|
229 |
-
|
230 |
-
/**
|
231 |
-
* create a credit on this card, assuming validations will pass
|
232 |
-
*
|
233 |
-
* returns a Braintree_Transaction object on success
|
234 |
-
*
|
235 |
-
* @access public
|
236 |
-
* @param array $attribs
|
237 |
-
* @return object Braintree_Transaction
|
238 |
-
* @throws Braintree_Exception_ValidationError
|
239 |
-
*/
|
240 |
-
public static function creditNoValidate($token, $transactionAttribs)
|
241 |
-
{
|
242 |
-
$result = self::credit($token, $transactionAttribs);
|
243 |
-
return self::returnObjectOrThrowException('Transaction', $result);
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* create a new sale for the current card
|
248 |
-
*
|
249 |
-
* @param string $token
|
250 |
-
* @param array $transactionAttribs
|
251 |
-
* @return object Braintree_Result_Successful or Braintree_Result_Error
|
252 |
-
* @see Braintree_Transaction::sale()
|
253 |
-
*/
|
254 |
-
public static function sale($token, $transactionAttribs)
|
255 |
-
{
|
256 |
-
self::_validateId($token);
|
257 |
-
return Braintree_Transaction::sale(
|
258 |
-
array_merge(
|
259 |
-
$transactionAttribs,
|
260 |
-
array('paymentMethodToken' => $token)
|
261 |
-
)
|
262 |
-
);
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* create a new sale using this card, assuming validations will pass
|
267 |
-
*
|
268 |
-
* returns a Braintree_Transaction object on success
|
269 |
-
*
|
270 |
-
* @access public
|
271 |
-
* @param array $transactionAttribs
|
272 |
-
* @param string $token
|
273 |
-
* @return object Braintree_Transaction
|
274 |
-
* @throws Braintree_Exception_ValidationsFailed
|
275 |
-
* @see Braintree_Transaction::sale()
|
276 |
-
*/
|
277 |
-
public static function saleNoValidate($token, $transactionAttribs)
|
278 |
-
{
|
279 |
-
$result = self::sale($token, $transactionAttribs);
|
280 |
-
return self::returnObjectOrThrowException('Transaction', $result);
|
281 |
-
}
|
282 |
-
|
283 |
-
/**
|
284 |
-
* updates the creditcard record
|
285 |
-
*
|
286 |
-
* if calling this method in static context, $token
|
287 |
-
* is the 2nd attribute. $token is not sent in object context.
|
288 |
-
*
|
289 |
-
* @access public
|
290 |
-
* @param array $attributes
|
291 |
-
* @param string $token (optional)
|
292 |
-
* @return object Braintree_Result_Successful or Braintree_Result_Error
|
293 |
-
*/
|
294 |
-
public static function update($token, $attributes)
|
295 |
-
{
|
296 |
-
Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
|
297 |
-
self::_validateId($token);
|
298 |
-
return self::_doUpdate('put', '/payment_methods/' . $token, array('creditCard' => $attributes));
|
299 |
-
}
|
300 |
-
|
301 |
-
/**
|
302 |
-
* update a creditcard record, assuming validations will pass
|
303 |
-
*
|
304 |
-
* if calling this method in static context, $token
|
305 |
-
* is the 2nd attribute. $token is not sent in object context.
|
306 |
-
* returns a Braintree_CreditCard object on success
|
307 |
-
*
|
308 |
-
* @access public
|
309 |
-
* @param array $attributes
|
310 |
-
* @param string $token
|
311 |
-
* @return object Braintree_CreditCard
|
312 |
-
* @throws Braintree_Exception_ValidationsFailed
|
313 |
-
*/
|
314 |
-
public static function updateNoValidate($token, $attributes)
|
315 |
-
{
|
316 |
-
$result = self::update($token, $attributes);
|
317 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
318 |
-
}
|
319 |
-
/**
|
320 |
-
*
|
321 |
-
* @access public
|
322 |
-
* @param none
|
323 |
-
* @return string
|
324 |
-
*/
|
325 |
-
public static function updateCreditCardUrl()
|
326 |
-
{
|
327 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
|
328 |
-
return Braintree_Configuration::merchantUrl() .
|
329 |
-
'/payment_methods/all/update_via_transparent_redirect_request';
|
330 |
-
}
|
331 |
-
|
332 |
-
/**
|
333 |
-
* update a customer from a TransparentRedirect operation
|
334 |
-
*
|
335 |
-
* @access public
|
336 |
-
* @param array $attribs
|
337 |
-
* @return object
|
338 |
-
*/
|
339 |
-
public static function updateFromTransparentRedirect($queryString)
|
340 |
-
{
|
341 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
342 |
-
$params = Braintree_TransparentRedirect::parseAndValidateQueryString(
|
343 |
-
$queryString
|
344 |
-
);
|
345 |
-
return self::_doUpdate(
|
346 |
-
'post',
|
347 |
-
'/payment_methods/all/confirm_transparent_redirect_request',
|
348 |
-
array('id' => $params['id'])
|
349 |
-
);
|
350 |
-
}
|
351 |
-
|
352 |
-
/* instance methods */
|
353 |
-
/**
|
354 |
-
* returns false if default is null or false
|
355 |
-
*
|
356 |
-
* @return boolean
|
357 |
-
*/
|
358 |
-
public function isDefault()
|
359 |
-
{
|
360 |
-
return $this->default;
|
361 |
-
}
|
362 |
-
|
363 |
-
/**
|
364 |
-
* checks whether the card is expired based on the current date
|
365 |
-
*
|
366 |
-
* @return boolean
|
367 |
-
*/
|
368 |
-
public function isExpired()
|
369 |
-
{
|
370 |
-
return $this->expired;
|
371 |
-
}
|
372 |
-
|
373 |
-
public static function delete($token)
|
374 |
-
{
|
375 |
-
self::_validateId($token);
|
376 |
-
Braintree_Http::delete('/payment_methods/' . $token);
|
377 |
-
return new Braintree_Result_Successful();
|
378 |
-
}
|
379 |
-
|
380 |
-
/**
|
381 |
-
* sets instance properties from an array of values
|
382 |
-
*
|
383 |
-
* @access protected
|
384 |
-
* @param array $creditCardAttribs array of creditcard data
|
385 |
-
* @return none
|
386 |
-
*/
|
387 |
-
protected function _initialize($creditCardAttribs)
|
388 |
-
{
|
389 |
-
// set the attributes
|
390 |
-
$this->_attributes = $creditCardAttribs;
|
391 |
-
|
392 |
-
// map each address into its own object
|
393 |
-
$billingAddress = isset($creditCardAttribs['billingAddress']) ?
|
394 |
-
Braintree_Address::factory($creditCardAttribs['billingAddress']) :
|
395 |
-
null;
|
396 |
-
|
397 |
-
$subscriptionArray = array();
|
398 |
-
if (isset($creditCardAttribs['subscriptions'])) {
|
399 |
-
foreach ($creditCardAttribs['subscriptions'] AS $subscription) {
|
400 |
-
$subscriptionArray[] = Braintree_Subscription::factory($subscription);
|
401 |
-
}
|
402 |
-
}
|
403 |
-
|
404 |
-
$this->_set('subscriptions', $subscriptionArray);
|
405 |
-
$this->_set('billingAddress', $billingAddress);
|
406 |
-
$this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
|
407 |
-
$this->_set('maskedNumber', $this->bin . '******' . $this->last4);
|
408 |
-
}
|
409 |
-
|
410 |
-
/**
|
411 |
-
* returns false if comparing object is not a Braintree_CreditCard,
|
412 |
-
* or is a Braintree_CreditCard with a different id
|
413 |
-
*
|
414 |
-
* @param object $otherCreditCard customer to compare against
|
415 |
-
* @return boolean
|
416 |
-
*/
|
417 |
-
public function isEqual($otherCreditCard)
|
418 |
-
{
|
419 |
-
return !($otherCreditCard instanceof Braintree_CreditCard) ? false : $this->token === $otherCreditCard->token;
|
420 |
-
}
|
421 |
-
|
422 |
-
private static function baseOptions()
|
423 |
-
{
|
424 |
-
return array('makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'venmoSdkSession');
|
425 |
-
}
|
426 |
-
|
427 |
-
private static function baseSignature($options)
|
428 |
-
{
|
429 |
-
return array(
|
430 |
-
'billingAddressId', 'cardholderName', 'cvv', 'number',
|
431 |
-
'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode',
|
432 |
-
array('options' => $options),
|
433 |
-
array(
|
434 |
-
'billingAddress' => array(
|
435 |
-
'firstName',
|
436 |
-
'lastName',
|
437 |
-
'company',
|
438 |
-
'countryCodeAlpha2',
|
439 |
-
'countryCodeAlpha3',
|
440 |
-
'countryCodeNumeric',
|
441 |
-
'countryName',
|
442 |
-
'extendedAddress',
|
443 |
-
'locality',
|
444 |
-
'region',
|
445 |
-
'postalCode',
|
446 |
-
'streetAddress'
|
447 |
-
),
|
448 |
-
),
|
449 |
-
);
|
450 |
-
}
|
451 |
-
|
452 |
-
public static function createSignature()
|
453 |
-
{
|
454 |
-
$options = self::baseOptions();
|
455 |
-
$options[] = "failOnDuplicatePaymentMethod";
|
456 |
-
$signature = self::baseSignature($options);
|
457 |
-
$signature[] = 'customerId';
|
458 |
-
return $signature;
|
459 |
-
}
|
460 |
-
|
461 |
-
public static function updateSignature()
|
462 |
-
{
|
463 |
-
$signature = self::baseSignature(self::baseOptions());
|
464 |
-
|
465 |
-
$updateExistingBillingSignature = array(
|
466 |
-
array(
|
467 |
-
'options' => array(
|
468 |
-
'updateExisting'
|
469 |
-
)
|
470 |
-
)
|
471 |
-
);
|
472 |
-
|
473 |
-
foreach($signature AS $key => $value) {
|
474 |
-
if(is_array($value) and array_key_exists('billingAddress', $value)) {
|
475 |
-
$signature[$key]['billingAddress'] = array_merge_recursive($value['billingAddress'], $updateExistingBillingSignature);
|
476 |
-
}
|
477 |
-
}
|
478 |
-
|
479 |
-
return $signature;
|
480 |
-
}
|
481 |
-
|
482 |
-
/**
|
483 |
-
* sends the create request to the gateway
|
484 |
-
*
|
485 |
-
* @ignore
|
486 |
-
* @param string $url
|
487 |
-
* @param array $params
|
488 |
-
* @return mixed
|
489 |
-
*/
|
490 |
-
public static function _doCreate($url, $params)
|
491 |
-
{
|
492 |
-
$response = Braintree_Http::post($url, $params);
|
493 |
-
|
494 |
-
return self::_verifyGatewayResponse($response);
|
495 |
-
}
|
496 |
-
|
497 |
-
/**
|
498 |
-
* create a printable representation of the object as:
|
499 |
-
* ClassName[property=value, property=value]
|
500 |
-
* @return string
|
501 |
-
*/
|
502 |
-
public function __toString()
|
503 |
-
{
|
504 |
-
return __CLASS__ . '[' .
|
505 |
-
Braintree_Util::attributesToString($this->_attributes) .']';
|
506 |
-
}
|
507 |
-
|
508 |
-
/**
|
509 |
-
* verifies that a valid credit card token is being used
|
510 |
-
* @ignore
|
511 |
-
* @param string $token
|
512 |
-
* @throws InvalidArgumentException
|
513 |
-
*/
|
514 |
-
private static function _validateId($token = null)
|
515 |
-
{
|
516 |
-
if (empty($token)) {
|
517 |
-
throw new InvalidArgumentException(
|
518 |
-
'expected credit card id to be set'
|
519 |
-
);
|
520 |
-
}
|
521 |
-
if (!preg_match('/^[0-9A-Za-z_-]+$/', $token)) {
|
522 |
-
throw new InvalidArgumentException(
|
523 |
-
$token . ' is an invalid credit card id.'
|
524 |
-
);
|
525 |
-
}
|
526 |
-
}
|
527 |
-
|
528 |
-
/**
|
529 |
-
* sends the update request to the gateway
|
530 |
-
*
|
531 |
-
* @ignore
|
532 |
-
* @param string $url
|
533 |
-
* @param array $params
|
534 |
-
* @return mixed
|
535 |
-
*/
|
536 |
-
private static function _doUpdate($httpVerb, $url, $params)
|
537 |
-
{
|
538 |
-
$response = Braintree_Http::$httpVerb($url, $params);
|
539 |
-
return self::_verifyGatewayResponse($response);
|
540 |
-
}
|
541 |
-
|
542 |
-
/**
|
543 |
-
* generic method for validating incoming gateway responses
|
544 |
-
*
|
545 |
-
* creates a new Braintree_CreditCard object and encapsulates
|
546 |
-
* it inside a Braintree_Result_Successful object, or
|
547 |
-
* encapsulates a Braintree_Errors object inside a Result_Error
|
548 |
-
* alternatively, throws an Unexpected exception if the response is invalid.
|
549 |
-
*
|
550 |
-
* @ignore
|
551 |
-
* @param array $response gateway response values
|
552 |
-
* @return object Result_Successful or Result_Error
|
553 |
-
* @throws Braintree_Exception_Unexpected
|
554 |
-
*/
|
555 |
-
private static function _verifyGatewayResponse($response)
|
556 |
-
{
|
557 |
-
if (isset($response['creditCard'])) {
|
558 |
-
// return a populated instance of Braintree_Address
|
559 |
-
return new Braintree_Result_Successful(
|
560 |
-
self::factory($response['creditCard'])
|
561 |
-
);
|
562 |
-
} else if (isset($response['apiErrorResponse'])) {
|
563 |
-
return new Braintree_Result_Error($response['apiErrorResponse']);
|
564 |
-
} else {
|
565 |
-
throw new Braintree_Exception_Unexpected(
|
566 |
-
"Expected address or apiErrorResponse"
|
567 |
-
);
|
568 |
-
}
|
569 |
-
}
|
570 |
-
|
571 |
-
/**
|
572 |
-
* factory method: returns an instance of Braintree_CreditCard
|
573 |
-
* to the requesting method, with populated properties
|
574 |
-
*
|
575 |
-
* @ignore
|
576 |
-
* @return object instance of Braintree_CreditCard
|
577 |
-
*/
|
578 |
-
public static function factory($attributes)
|
579 |
-
{
|
580 |
-
$defaultAttributes = array(
|
581 |
-
'bin' => '',
|
582 |
-
'expirationMonth' => '',
|
583 |
-
'expirationYear' => '',
|
584 |
-
'last4' => '',
|
585 |
-
);
|
586 |
-
|
587 |
-
$instance = new self();
|
588 |
-
$instance->_initialize(array_merge($defaultAttributes, $attributes));
|
589 |
-
return $instance;
|
590 |
-
}
|
591 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/CreditCardVerification.php
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_CreditCardVerification extends Braintree_Result_CreditCardVerification
|
3 |
-
{
|
4 |
-
public static function factory($attributes)
|
5 |
-
{
|
6 |
-
$instance = new self($attributes);
|
7 |
-
return $instance;
|
8 |
-
}
|
9 |
-
|
10 |
-
public static function fetch($query, $ids)
|
11 |
-
{
|
12 |
-
$criteria = array();
|
13 |
-
foreach ($query as $term) {
|
14 |
-
$criteria[$term->name] = $term->toparam();
|
15 |
-
}
|
16 |
-
$criteria["ids"] = Braintree_CreditCardVerificationSearch::ids()->in($ids)->toparam();
|
17 |
-
$response = braintree_http::post('/verifications/advanced_search', array('search' => $criteria));
|
18 |
-
|
19 |
-
return braintree_util::extractattributeasarray(
|
20 |
-
$response['creditCardVerifications'],
|
21 |
-
'verification'
|
22 |
-
);
|
23 |
-
}
|
24 |
-
|
25 |
-
public static function search($query)
|
26 |
-
{
|
27 |
-
$criteria = array();
|
28 |
-
foreach ($query as $term) {
|
29 |
-
$criteria[$term->name] = $term->toparam();
|
30 |
-
}
|
31 |
-
|
32 |
-
$response = braintree_http::post('/verifications/advanced_search_ids', array('search' => $criteria));
|
33 |
-
$pager = array(
|
34 |
-
'className' => __CLASS__,
|
35 |
-
'classMethod' => 'fetch',
|
36 |
-
'methodArgs' => array($query)
|
37 |
-
);
|
38 |
-
|
39 |
-
return new Braintree_ResourceCollection($response, $pager);
|
40 |
-
}
|
41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/CreditCardVerificationSearch.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_CreditCardVerificationSearch
|
3 |
-
{
|
4 |
-
static function id() { return new Braintree_TextNode('id'); }
|
5 |
-
static function creditCardCardholderName() { return new Braintree_TextNode('credit_card_cardholder_name'); }
|
6 |
-
|
7 |
-
static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); }
|
8 |
-
static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); }
|
9 |
-
|
10 |
-
static function ids() { return new Braintree_MultipleValueNode('ids'); }
|
11 |
-
|
12 |
-
static function creditCardCardType()
|
13 |
-
{
|
14 |
-
return new Braintree_MultipleValueNode("credit_card_card_type", array(
|
15 |
-
Braintree_CreditCard::AMEX,
|
16 |
-
Braintree_CreditCard::CARTE_BLANCHE,
|
17 |
-
Braintree_CreditCard::CHINA_UNION_PAY,
|
18 |
-
Braintree_CreditCard::DINERS_CLUB_INTERNATIONAL,
|
19 |
-
Braintree_CreditCard::DISCOVER,
|
20 |
-
Braintree_CreditCard::JCB,
|
21 |
-
Braintree_CreditCard::LASER,
|
22 |
-
Braintree_CreditCard::MAESTRO,
|
23 |
-
Braintree_CreditCard::MASTER_CARD,
|
24 |
-
Braintree_CreditCard::SOLO,
|
25 |
-
Braintree_CreditCard::SWITCH_TYPE,
|
26 |
-
Braintree_CreditCard::VISA,
|
27 |
-
Braintree_CreditCard::UNKNOWN
|
28 |
-
));
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
static function createdAt() { return new Braintree_RangeNode("created_at"); }
|
33 |
-
}
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Customer.php
DELETED
@@ -1,562 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree Customer module
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @category Resources
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Creates and manages Customers
|
12 |
-
*
|
13 |
-
* <b>== More information ==</b>
|
14 |
-
*
|
15 |
-
* For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api}
|
16 |
-
*
|
17 |
-
* @package Braintree
|
18 |
-
* @category Resources
|
19 |
-
* @copyright 2010 Braintree Payment Solutions
|
20 |
-
*
|
21 |
-
* @property-read array $addresses
|
22 |
-
* @property-read string $company
|
23 |
-
* @property-read string $createdAt
|
24 |
-
* @property-read array $creditCards
|
25 |
-
* @property-read array $customFields custom fields passed with the request
|
26 |
-
* @property-read string $email
|
27 |
-
* @property-read string $fax
|
28 |
-
* @property-read string $firstName
|
29 |
-
* @property-read string $id
|
30 |
-
* @property-read string $lastName
|
31 |
-
* @property-read string $phone
|
32 |
-
* @property-read string $updatedAt
|
33 |
-
* @property-read string $website
|
34 |
-
*/
|
35 |
-
class Braintree_Customer extends Braintree
|
36 |
-
{
|
37 |
-
public static function all()
|
38 |
-
{
|
39 |
-
$response = braintree_http::post('/customers/advanced_search_ids');
|
40 |
-
$pager = array(
|
41 |
-
'className' => __CLASS__,
|
42 |
-
'classMethod' => 'fetch',
|
43 |
-
'methodArgs' => array(array())
|
44 |
-
);
|
45 |
-
|
46 |
-
return new Braintree_ResourceCollection($response, $pager);
|
47 |
-
}
|
48 |
-
|
49 |
-
public static function fetch($query, $ids)
|
50 |
-
{
|
51 |
-
$criteria = array();
|
52 |
-
foreach ($query as $term) {
|
53 |
-
$criteria[$term->name] = $term->toparam();
|
54 |
-
}
|
55 |
-
$criteria["ids"] = Braintree_CustomerSearch::ids()->in($ids)->toparam();
|
56 |
-
$response = braintree_http::post('/customers/advanced_search', array('search' => $criteria));
|
57 |
-
|
58 |
-
return braintree_util::extractattributeasarray(
|
59 |
-
$response['customers'],
|
60 |
-
'customer'
|
61 |
-
);
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Creates a customer using the given +attributes+. If <tt>:id</tt> is not passed,
|
66 |
-
* the gateway will generate it.
|
67 |
-
*
|
68 |
-
* <code>
|
69 |
-
* $result = Braintree_Customer::create(array(
|
70 |
-
* 'first_name' => 'John',
|
71 |
-
* 'last_name' => 'Smith',
|
72 |
-
* 'company' => 'Smith Co.',
|
73 |
-
* 'email' => 'john@smith.com',
|
74 |
-
* 'website' => 'www.smithco.com',
|
75 |
-
* 'fax' => '419-555-1234',
|
76 |
-
* 'phone' => '614-555-1234'
|
77 |
-
* ));
|
78 |
-
* if($result->success) {
|
79 |
-
* echo 'Created customer ' . $result->customer->id;
|
80 |
-
* } else {
|
81 |
-
* echo 'Could not create customer, see result->errors';
|
82 |
-
* }
|
83 |
-
* </code>
|
84 |
-
*
|
85 |
-
* @access public
|
86 |
-
* @param array $attribs
|
87 |
-
* @return object Result, either Successful or Error
|
88 |
-
*/
|
89 |
-
public static function create($attribs = array())
|
90 |
-
{
|
91 |
-
Braintree_Util::verifyKeys(self::createSignature(), $attribs);
|
92 |
-
return self::_doCreate('/customers', array('customer' => $attribs));
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* attempts the create operation assuming all data will validate
|
97 |
-
* returns a Braintree_Customer object instead of a Result
|
98 |
-
*
|
99 |
-
* @access public
|
100 |
-
* @param array $attribs
|
101 |
-
* @return object
|
102 |
-
* @throws Braintree_Exception_ValidationError
|
103 |
-
*/
|
104 |
-
public static function createNoValidate($attribs = array())
|
105 |
-
{
|
106 |
-
$result = self::create($attribs);
|
107 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
108 |
-
}
|
109 |
-
/**
|
110 |
-
* create a customer from a TransparentRedirect operation
|
111 |
-
*
|
112 |
-
* @access public
|
113 |
-
* @param array $attribs
|
114 |
-
* @return object
|
115 |
-
*/
|
116 |
-
public static function createFromTransparentRedirect($queryString)
|
117 |
-
{
|
118 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
119 |
-
$params = Braintree_TransparentRedirect::parseAndValidateQueryString(
|
120 |
-
$queryString
|
121 |
-
);
|
122 |
-
return self::_doCreate(
|
123 |
-
'/customers/all/confirm_transparent_redirect_request',
|
124 |
-
array('id' => $params['id'])
|
125 |
-
);
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
*
|
130 |
-
* @access public
|
131 |
-
* @param none
|
132 |
-
* @return string
|
133 |
-
*/
|
134 |
-
public static function createCustomerUrl()
|
135 |
-
{
|
136 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
|
137 |
-
return Braintree_Configuration::merchantUrl() .
|
138 |
-
'/customers/all/create_via_transparent_redirect_request';
|
139 |
-
}
|
140 |
-
|
141 |
-
|
142 |
-
/**
|
143 |
-
* creates a full array signature of a valid create request
|
144 |
-
* @return array gateway create request format
|
145 |
-
*/
|
146 |
-
public static function createSignature()
|
147 |
-
{
|
148 |
-
|
149 |
-
$creditCardSignature = Braintree_CreditCard::createSignature();
|
150 |
-
unset($creditCardSignature['customerId']);
|
151 |
-
$signature = array(
|
152 |
-
'id', 'company', 'email', 'fax', 'firstName',
|
153 |
-
'lastName', 'phone', 'website',
|
154 |
-
array('creditCard' => $creditCardSignature),
|
155 |
-
array('customFields' => array('_anyKey_')),
|
156 |
-
);
|
157 |
-
return $signature;
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* creates a full array signature of a valid update request
|
162 |
-
* @return array update request format
|
163 |
-
*/
|
164 |
-
public static function updateSignature()
|
165 |
-
{
|
166 |
-
$creditCardSignature = Braintree_CreditCard::updateSignature();
|
167 |
-
|
168 |
-
foreach($creditCardSignature AS $key => $value) {
|
169 |
-
if(is_array($value) and array_key_exists('options', $value)) {
|
170 |
-
array_push($creditCardSignature[$key]['options'], 'updateExistingToken');
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
$signature = array(
|
175 |
-
'id', 'company', 'email', 'fax', 'firstName',
|
176 |
-
'lastName', 'phone', 'website',
|
177 |
-
array('creditCard' => $creditCardSignature),
|
178 |
-
array('customFields' => array('_anyKey_')),
|
179 |
-
);
|
180 |
-
return $signature;
|
181 |
-
}
|
182 |
-
|
183 |
-
|
184 |
-
/**
|
185 |
-
* find a customer by id
|
186 |
-
*
|
187 |
-
* @access public
|
188 |
-
* @param string id customer Id
|
189 |
-
* @return object Braintree_Customer
|
190 |
-
* @throws Braintree_Exception_NotFound
|
191 |
-
*/
|
192 |
-
public static function find($id)
|
193 |
-
{
|
194 |
-
self::_validateId($id);
|
195 |
-
try {
|
196 |
-
$response = Braintree_Http::get('/customers/'.$id);
|
197 |
-
return self::factory($response['customer']);
|
198 |
-
} catch (Braintree_Exception_NotFound $e) {
|
199 |
-
throw new Braintree_Exception_NotFound(
|
200 |
-
'customer with id ' . $id . ' not found'
|
201 |
-
);
|
202 |
-
}
|
203 |
-
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* credit a customer for the passed transaction
|
208 |
-
*
|
209 |
-
* @access public
|
210 |
-
* @param array $attribs
|
211 |
-
* @return object Braintree_Result_Successful or Braintree_Result_Error
|
212 |
-
*/
|
213 |
-
public static function credit($customerId, $transactionAttribs)
|
214 |
-
{
|
215 |
-
self::_validateId($customerId);
|
216 |
-
return Braintree_Transaction::credit(
|
217 |
-
array_merge($transactionAttribs,
|
218 |
-
array('customerId' => $customerId)
|
219 |
-
)
|
220 |
-
);
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* credit a customer, assuming validations will pass
|
225 |
-
*
|
226 |
-
* returns a Braintree_Transaction object on success
|
227 |
-
*
|
228 |
-
* @access public
|
229 |
-
* @param array $attribs
|
230 |
-
* @return object Braintree_Transaction
|
231 |
-
* @throws Braintree_Exception_ValidationError
|
232 |
-
*/
|
233 |
-
public static function creditNoValidate($customerId, $transactionAttribs)
|
234 |
-
{
|
235 |
-
$result = self::credit($customerId, $transactionAttribs);
|
236 |
-
return self::returnObjectOrThrowException('Braintree_Transaction', $result);
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* delete a customer by id
|
241 |
-
*
|
242 |
-
* @param string $customerId
|
243 |
-
*/
|
244 |
-
public static function delete($customerId)
|
245 |
-
{
|
246 |
-
self::_validateId($customerId);
|
247 |
-
Braintree_Http::delete('/customers/' . $customerId);
|
248 |
-
return new Braintree_Result_Successful();
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* create a new sale for a customer
|
253 |
-
*
|
254 |
-
* @param string $customerId
|
255 |
-
* @param array $transactionAttribs
|
256 |
-
* @return object Braintree_Result_Successful or Braintree_Result_Error
|
257 |
-
* @see Braintree_Transaction::sale()
|
258 |
-
*/
|
259 |
-
public static function sale($customerId, $transactionAttribs)
|
260 |
-
{
|
261 |
-
self::_validateId($customerId);
|
262 |
-
return Braintree_Transaction::sale(
|
263 |
-
array_merge($transactionAttribs,
|
264 |
-
array('customerId' => $customerId)
|
265 |
-
)
|
266 |
-
);
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* create a new sale for a customer, assuming validations will pass
|
271 |
-
*
|
272 |
-
* returns a Braintree_Transaction object on success
|
273 |
-
* @access public
|
274 |
-
* @param string $customerId
|
275 |
-
* @param array $transactionAttribs
|
276 |
-
* @return object Braintree_Transaction
|
277 |
-
* @throws Braintree_Exception_ValidationsFailed
|
278 |
-
* @see Braintree_Transaction::sale()
|
279 |
-
*/
|
280 |
-
public static function saleNoValidate($customerId, $transactionAttribs)
|
281 |
-
{
|
282 |
-
$result = self::sale($customerId, $transactionAttribs);
|
283 |
-
return self::returnObjectOrThrowException('Braintree_Transaction', $result);
|
284 |
-
}
|
285 |
-
|
286 |
-
/**
|
287 |
-
* Returns a ResourceCollection of customers matching the search query.
|
288 |
-
*
|
289 |
-
* If <b>query</b> is a string, the search will be a basic search.
|
290 |
-
* If <b>query</b> is a hash, the search will be an advanced search.
|
291 |
-
* For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/customer-api#searching http://www.braintreepaymentsolutions.com/gateway/customer-api}
|
292 |
-
*
|
293 |
-
* @param mixed $query search query
|
294 |
-
* @param array $options options such as page number
|
295 |
-
* @return object Braintree_ResourceCollection
|
296 |
-
* @throws InvalidArgumentException
|
297 |
-
*/
|
298 |
-
public static function search($query)
|
299 |
-
{
|
300 |
-
$criteria = array();
|
301 |
-
foreach ($query as $term) {
|
302 |
-
$criteria[$term->name] = $term->toparam();
|
303 |
-
}
|
304 |
-
|
305 |
-
$response = braintree_http::post('/customers/advanced_search_ids', array('search' => $criteria));
|
306 |
-
$pager = array(
|
307 |
-
'className' => __CLASS__,
|
308 |
-
'classMethod' => 'fetch',
|
309 |
-
'methodArgs' => array($query)
|
310 |
-
);
|
311 |
-
|
312 |
-
return new Braintree_ResourceCollection($response, $pager);
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
* updates the customer record
|
317 |
-
*
|
318 |
-
* if calling this method in static context, customerId
|
319 |
-
* is the 2nd attribute. customerId is not sent in object context.
|
320 |
-
*
|
321 |
-
* @access public
|
322 |
-
* @param array $attributes
|
323 |
-
* @param string $customerId (optional)
|
324 |
-
* @return object Braintree_Result_Successful or Braintree_Result_Error
|
325 |
-
*/
|
326 |
-
public static function update($customerId, $attributes)
|
327 |
-
{
|
328 |
-
Braintree_Util::verifyKeys(self::updateSignature(), $attributes);
|
329 |
-
self::_validateId($customerId);
|
330 |
-
return self::_doUpdate(
|
331 |
-
'put',
|
332 |
-
'/customers/' . $customerId,
|
333 |
-
array('customer' => $attributes)
|
334 |
-
);
|
335 |
-
}
|
336 |
-
|
337 |
-
/**
|
338 |
-
* update a customer record, assuming validations will pass
|
339 |
-
*
|
340 |
-
* if calling this method in static context, customerId
|
341 |
-
* is the 2nd attribute. customerId is not sent in object context.
|
342 |
-
* returns a Braintree_Customer object on success
|
343 |
-
*
|
344 |
-
* @access public
|
345 |
-
* @param array $attributes
|
346 |
-
* @param string $customerId
|
347 |
-
* @return object Braintree_Customer
|
348 |
-
* @throws Braintree_Exception_ValidationsFailed
|
349 |
-
*/
|
350 |
-
public static function updateNoValidate($customerId, $attributes)
|
351 |
-
{
|
352 |
-
$result = self::update($customerId, $attributes);
|
353 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
354 |
-
}
|
355 |
-
/**
|
356 |
-
*
|
357 |
-
* @access public
|
358 |
-
* @param none
|
359 |
-
* @return string
|
360 |
-
*/
|
361 |
-
public static function updateCustomerUrl()
|
362 |
-
{
|
363 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
|
364 |
-
return Braintree_Configuration::merchantUrl() .
|
365 |
-
'/customers/all/update_via_transparent_redirect_request';
|
366 |
-
}
|
367 |
-
|
368 |
-
/**
|
369 |
-
* update a customer from a TransparentRedirect operation
|
370 |
-
*
|
371 |
-
* @access public
|
372 |
-
* @param array $attribs
|
373 |
-
* @return object
|
374 |
-
*/
|
375 |
-
public static function updateFromTransparentRedirect($queryString)
|
376 |
-
{
|
377 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
378 |
-
$params = Braintree_TransparentRedirect::parseAndValidateQueryString(
|
379 |
-
$queryString
|
380 |
-
);
|
381 |
-
return self::_doUpdate(
|
382 |
-
'post',
|
383 |
-
'/customers/all/confirm_transparent_redirect_request',
|
384 |
-
array('id' => $params['id'])
|
385 |
-
);
|
386 |
-
}
|
387 |
-
|
388 |
-
/* instance methods */
|
389 |
-
|
390 |
-
/**
|
391 |
-
* sets instance properties from an array of values
|
392 |
-
*
|
393 |
-
* @ignore
|
394 |
-
* @access protected
|
395 |
-
* @param array $customerAttribs array of customer data
|
396 |
-
* @return none
|
397 |
-
*/
|
398 |
-
protected function _initialize($customerAttribs)
|
399 |
-
{
|
400 |
-
// set the attributes
|
401 |
-
$this->_attributes = $customerAttribs;
|
402 |
-
|
403 |
-
// map each address into its own object
|
404 |
-
$addressArray = array();
|
405 |
-
if (isset($customerAttribs['addresses'])) {
|
406 |
-
|
407 |
-
foreach ($customerAttribs['addresses'] AS $address) {
|
408 |
-
$addressArray[] = Braintree_Address::factory($address);
|
409 |
-
}
|
410 |
-
}
|
411 |
-
$this->_set('addresses', $addressArray);
|
412 |
-
|
413 |
-
// map each creditcard into its own object
|
414 |
-
$ccArray = array();
|
415 |
-
if (isset($customerAttribs['creditCards'])) {
|
416 |
-
foreach ($customerAttribs['creditCards'] AS $creditCard) {
|
417 |
-
$ccArray[] = Braintree_CreditCard::factory($creditCard);
|
418 |
-
}
|
419 |
-
}
|
420 |
-
$this->_set('creditCards', $ccArray);
|
421 |
-
|
422 |
-
}
|
423 |
-
|
424 |
-
/**
|
425 |
-
* returns a string representation of the customer
|
426 |
-
* @return string
|
427 |
-
*/
|
428 |
-
public function __toString()
|
429 |
-
{
|
430 |
-
return __CLASS__ . '[' .
|
431 |
-
Braintree_Util::attributesToString($this->_attributes) .']';
|
432 |
-
}
|
433 |
-
|
434 |
-
/**
|
435 |
-
* returns false if comparing object is not a Braintree_Customer,
|
436 |
-
* or is a Braintree_Customer with a different id
|
437 |
-
*
|
438 |
-
* @param object $otherCust customer to compare against
|
439 |
-
* @return boolean
|
440 |
-
*/
|
441 |
-
public function isEqual($otherCust)
|
442 |
-
{
|
443 |
-
return !($otherCust instanceof Braintree_Customer) ? false : $this->id === $otherCust->id;
|
444 |
-
}
|
445 |
-
|
446 |
-
/* private class properties */
|
447 |
-
|
448 |
-
/**
|
449 |
-
* @access protected
|
450 |
-
* @var array registry of customer data
|
451 |
-
*/
|
452 |
-
protected $_attributes = array(
|
453 |
-
'addresses' => '',
|
454 |
-
'company' => '',
|
455 |
-
'creditCards' => '',
|
456 |
-
'email' => '',
|
457 |
-
'fax' => '',
|
458 |
-
'firstName' => '',
|
459 |
-
'id' => '',
|
460 |
-
'lastName' => '',
|
461 |
-
'phone' => '',
|
462 |
-
'createdAt' => '',
|
463 |
-
'updatedAt' => '',
|
464 |
-
'website' => '',
|
465 |
-
);
|
466 |
-
|
467 |
-
/**
|
468 |
-
* sends the create request to the gateway
|
469 |
-
*
|
470 |
-
* @ignore
|
471 |
-
* @param string $url
|
472 |
-
* @param array $params
|
473 |
-
* @return mixed
|
474 |
-
*/
|
475 |
-
public static function _doCreate($url, $params)
|
476 |
-
{
|
477 |
-
$response = Braintree_Http::post($url, $params);
|
478 |
-
|
479 |
-
return self::_verifyGatewayResponse($response);
|
480 |
-
}
|
481 |
-
|
482 |
-
/**
|
483 |
-
* verifies that a valid customer id is being used
|
484 |
-
* @ignore
|
485 |
-
* @param string customer id
|
486 |
-
* @throws InvalidArgumentException
|
487 |
-
*/
|
488 |
-
private static function _validateId($id = null) {
|
489 |
-
if (empty($id)) {
|
490 |
-
throw new InvalidArgumentException(
|
491 |
-
'expected customer id to be set'
|
492 |
-
);
|
493 |
-
}
|
494 |
-
if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
|
495 |
-
throw new InvalidArgumentException(
|
496 |
-
$id . ' is an invalid customer id.'
|
497 |
-
);
|
498 |
-
}
|
499 |
-
}
|
500 |
-
|
501 |
-
|
502 |
-
/* private class methods */
|
503 |
-
|
504 |
-
/**
|
505 |
-
* sends the update request to the gateway
|
506 |
-
*
|
507 |
-
* @ignore
|
508 |
-
* @param string $url
|
509 |
-
* @param array $params
|
510 |
-
* @return mixed
|
511 |
-
*/
|
512 |
-
private static function _doUpdate($httpVerb, $url, $params)
|
513 |
-
{
|
514 |
-
$response = Braintree_Http::$httpVerb($url, $params);
|
515 |
-
|
516 |
-
return self::_verifyGatewayResponse($response);
|
517 |
-
}
|
518 |
-
|
519 |
-
/**
|
520 |
-
* generic method for validating incoming gateway responses
|
521 |
-
*
|
522 |
-
* creates a new Braintree_Customer object and encapsulates
|
523 |
-
* it inside a Braintree_Result_Successful object, or
|
524 |
-
* encapsulates a Braintree_Errors object inside a Result_Error
|
525 |
-
* alternatively, throws an Unexpected exception if the response is invalid.
|
526 |
-
*
|
527 |
-
* @ignore
|
528 |
-
* @param array $response gateway response values
|
529 |
-
* @return object Result_Successful or Result_Error
|
530 |
-
* @throws Braintree_Exception_Unexpected
|
531 |
-
*/
|
532 |
-
private static function _verifyGatewayResponse($response)
|
533 |
-
{
|
534 |
-
if (isset($response['customer'])) {
|
535 |
-
// return a populated instance of Braintree_Customer
|
536 |
-
return new Braintree_Result_Successful(
|
537 |
-
self::factory($response['customer'])
|
538 |
-
);
|
539 |
-
} else if (isset($response['apiErrorResponse'])) {
|
540 |
-
return new Braintree_Result_Error($response['apiErrorResponse']);
|
541 |
-
} else {
|
542 |
-
throw new Braintree_Exception_Unexpected(
|
543 |
-
"Expected customer or apiErrorResponse"
|
544 |
-
);
|
545 |
-
}
|
546 |
-
}
|
547 |
-
|
548 |
-
/**
|
549 |
-
* factory method: returns an instance of Braintree_Customer
|
550 |
-
* to the requesting method, with populated properties
|
551 |
-
*
|
552 |
-
* @ignore
|
553 |
-
* @return object instance of Braintree_Customer
|
554 |
-
*/
|
555 |
-
public static function factory($attributes)
|
556 |
-
{
|
557 |
-
$instance = new self();
|
558 |
-
$instance->_initialize($attributes);
|
559 |
-
return $instance;
|
560 |
-
}
|
561 |
-
|
562 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/CustomerSearch.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_CustomerSearch
|
3 |
-
{
|
4 |
-
static function addressCountryName() { return new Braintree_TextNode('address_country_name'); }
|
5 |
-
static function addressExtendedAddress() { return new Braintree_TextNode('address_extended_address'); }
|
6 |
-
static function addressFirstName() { return new Braintree_TextNode('address_first_name'); }
|
7 |
-
static function addressLastName() { return new Braintree_TextNode('address_last_name'); }
|
8 |
-
static function addressLocality() { return new Braintree_TextNode('address_locality'); }
|
9 |
-
static function addressPostalCode() { return new Braintree_TextNode('address_postal_code'); }
|
10 |
-
static function addressRegion() { return new Braintree_TextNode('address_region'); }
|
11 |
-
static function addressStreetAddress() { return new Braintree_TextNode('address_street_address'); }
|
12 |
-
static function cardholderName() { return new Braintree_TextNode('cardholder_name'); }
|
13 |
-
static function company() { return new Braintree_TextNode('company'); }
|
14 |
-
static function email() { return new Braintree_TextNode('email'); }
|
15 |
-
static function fax() { return new Braintree_TextNode('fax'); }
|
16 |
-
static function firstName() { return new Braintree_TextNode('first_name'); }
|
17 |
-
static function id() { return new Braintree_TextNode('id'); }
|
18 |
-
static function lastName() { return new Braintree_TextNode('last_name'); }
|
19 |
-
static function paymentMethodToken() { return new Braintree_TextNode('payment_method_token'); }
|
20 |
-
static function paymentMethodTokenWithDuplicates() { return new Braintree_IsNode('payment_method_token_with_duplicates'); }
|
21 |
-
static function phone() { return new Braintree_TextNode('phone'); }
|
22 |
-
static function website() { return new Braintree_TextNode('website'); }
|
23 |
-
|
24 |
-
static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); }
|
25 |
-
static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); }
|
26 |
-
|
27 |
-
static function ids() { return new Braintree_MultipleValueNode('ids'); }
|
28 |
-
|
29 |
-
static function createdAt() { return new Braintree_RangeNode("created_at"); }
|
30 |
-
}
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Descriptor.php
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_Descriptor extends Braintree_Instance
|
3 |
-
{
|
4 |
-
}
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Discount.php
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_Discount extends Braintree_Modification
|
3 |
-
{
|
4 |
-
public static function all()
|
5 |
-
{
|
6 |
-
$response = Braintree_Http::get('/discounts');
|
7 |
-
|
8 |
-
$discounts = array("discount" => $response['discounts']);
|
9 |
-
|
10 |
-
return Braintree_Util::extractAttributeAsArray(
|
11 |
-
$discounts,
|
12 |
-
'discount'
|
13 |
-
);
|
14 |
-
}
|
15 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Error/Codes.php
DELETED
@@ -1,206 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* validation Error codes and messages
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Errors
|
7 |
-
* @category Validation
|
8 |
-
* @copyright 2010 Braintree Payment Solutions
|
9 |
-
*/
|
10 |
-
|
11 |
-
/**
|
12 |
-
*
|
13 |
-
* Validation Error codes and messages
|
14 |
-
*
|
15 |
-
* ErrorCodes class provides constants for validation errors.
|
16 |
-
* The constants should be used to check for a specific validation
|
17 |
-
* error in a ValidationErrorCollection.
|
18 |
-
* The error messages returned from the server may change,
|
19 |
-
* but the codes will remain the same.
|
20 |
-
*
|
21 |
-
* @package Braintree
|
22 |
-
* @subpackage Errors
|
23 |
-
* @category Validation
|
24 |
-
* @copyright 2010 Braintree Payment Solutions
|
25 |
-
*/
|
26 |
-
class Braintree_Error_Codes
|
27 |
-
{
|
28 |
-
const ADDRESS_CANNOT_BE_BLANK = '81801';
|
29 |
-
const ADDRESS_COMPANY_IS_TOO_LONG = '81802';
|
30 |
-
const ADDRESS_COUNTRY_CODE_ALPHA2_IS_NOT_ACCEPTED = '91814';
|
31 |
-
const ADDRESS_COUNTRY_CODE_ALPHA3_IS_NOT_ACCEPTED = '91816';
|
32 |
-
const ADDRESS_COUNTRY_CODE_NUMERIC_IS_NOT_ACCEPTED = '91817';
|
33 |
-
const ADDRESS_COUNTRY_NAME_IS_NOT_ACCEPTED = '91803';
|
34 |
-
const ADDRESS_EXTENDED_ADDRESS_IS_TOO_LONG = '81804';
|
35 |
-
const ADDRESS_FIRST_NAME_IS_TOO_LONG = '81805';
|
36 |
-
const ADDRESS_INCONSISTENT_COUNTRY = '91815';
|
37 |
-
const ADDRESS_LAST_NAME_IS_TOO_LONG = '81806';
|
38 |
-
const ADDRESS_LOCALITY_IS_TOO_LONG = '81807';
|
39 |
-
const ADDRESS_POSTAL_CODE_INVALID_CHARACTERS = '81813';
|
40 |
-
const ADDRESS_POSTAL_CODE_IS_REQUIRED = '81808';
|
41 |
-
const ADDRESS_POSTAL_CODE_IS_TOO_LONG = '81809';
|
42 |
-
const ADDRESS_REGION_IS_TOO_LONG = '81810';
|
43 |
-
const ADDRESS_STREET_ADDRESS_IS_REQUIRED = '81811';
|
44 |
-
const ADDRESS_STREET_ADDRESS_IS_TOO_LONG = '81812';
|
45 |
-
const ADDRESS_TOO_MANY_ADDRESSES_PER_CUSTOMER = '91818';
|
46 |
-
|
47 |
-
const CREDIT_CARD_BILLING_ADDRESS_CONFLICT = '91701';
|
48 |
-
const CREDIT_CARD_BILLING_ADDRESS_ID_IS_INVALID = '91702';
|
49 |
-
const CREDIT_CARD_CARDHOLDER_NAME_IS_TOO_LONG = '81723';
|
50 |
-
const CREDIT_CARD_CREDIT_CARD_TYPE_IS_NOT_ACCEPTED = '81703';
|
51 |
-
const CREDIT_CARD_CREDIT_CARD_TYPE_IS_NOT_ACCEPTED_BY_SUBSCRIPTION_MERCHANT_ACCOUNT = '81718';
|
52 |
-
const CREDIT_CARD_CUSTOMER_ID_IS_INVALID = '91705';
|
53 |
-
const CREDIT_CARD_CUSTOMER_ID_IS_REQUIRED = '91704';
|
54 |
-
const CREDIT_CARD_CVV_IS_INVALID = '81707';
|
55 |
-
const CREDIT_CARD_CVV_IS_REQUIRED = '81706';
|
56 |
-
const CREDIT_CARD_DUPLICATE_CARD_EXISTS = '81724';
|
57 |
-
const CREDIT_CARD_EXPIRATION_DATE_CONFLICT = '91708';
|
58 |
-
const CREDIT_CARD_EXPIRATION_DATE_IS_INVALID = '81710';
|
59 |
-
const CREDIT_CARD_EXPIRATION_DATE_IS_REQUIRED = '81709';
|
60 |
-
const CREDIT_CARD_EXPIRATION_DATE_YEAR_IS_INVALID = '81711';
|
61 |
-
const CREDIT_CARD_EXPIRATION_MONTH_IS_INVALID = '81712';
|
62 |
-
const CREDIT_CARD_EXPIRATION_YEAR_IS_INVALID = '81713';
|
63 |
-
const CREDIT_CARD_NUMBER_INVALID_LENGTH = '81716';
|
64 |
-
const CREDIT_CARD_NUMBER_IS_INVALID = '81715';
|
65 |
-
const CREDIT_CARD_NUMBER_IS_REQUIRED = '81714';
|
66 |
-
const CREDIT_CARD_NUMBER_MUST_BE_TEST_NUMBER = '81717';
|
67 |
-
const CREDIT_CARD_OPTIONS_UPDATE_EXISTING_TOKEN_IS_INVALID = '91723';
|
68 |
-
const CREDIT_CARD_TOKEN_INVALID = '91718';
|
69 |
-
const CREDIT_CARD_TOKEN_IS_IN_USE = '91719';
|
70 |
-
const CREDIT_CARD_TOKEN_IS_NOT_ALLOWED = '91721';
|
71 |
-
const CREDIT_CARD_TOKEN_IS_REQUIRED = '91722';
|
72 |
-
const CREDIT_CARD_TOKEN_IS_TOO_LONG = '91720';
|
73 |
-
|
74 |
-
const CUSTOMER_COMPANY_IS_TOO_LONG = '81601';
|
75 |
-
const CUSTOMER_CUSTOM_FIELD_IS_INVALID = '91602';
|
76 |
-
const CUSTOMER_CUSTOM_FIELD_IS_TOO_LONG = '81603';
|
77 |
-
const CUSTOMER_EMAIL_IS_INVALID = '81604';
|
78 |
-
const CUSTOMER_EMAIL_IS_REQUIRED = '81606';
|
79 |
-
const CUSTOMER_EMAIL_IS_TOO_LONG = '81605';
|
80 |
-
const CUSTOMER_FAX_IS_TOO_LONG = '81607';
|
81 |
-
const CUSTOMER_FIRST_NAME_IS_TOO_LONG = '81608';
|
82 |
-
const CUSTOMER_ID_IS_INVAILD = '91610'; //Deprecated
|
83 |
-
const CUSTOMER_ID_IS_INVALID = '91610';
|
84 |
-
const CUSTOMER_ID_IS_IN_USE = '91609';
|
85 |
-
const CUSTOMER_ID_IS_NOT_ALLOWED = '91611';
|
86 |
-
const CUSTOMER_ID_IS_REQUIRED = '91613';
|
87 |
-
const CUSTOMER_ID_IS_TOO_LONG = '91612';
|
88 |
-
const CUSTOMER_LAST_NAME_IS_TOO_LONG = '81613';
|
89 |
-
const CUSTOMER_PHONE_IS_TOO_LONG = '81614';
|
90 |
-
const CUSTOMER_WEBSITE_IS_INVALID = '81616';
|
91 |
-
const CUSTOMER_WEBSITE_IS_TOO_LONG = '81615';
|
92 |
-
|
93 |
-
const DESCRIPTOR_NAME_FORMAT_IS_INVALID = '92201';
|
94 |
-
const DESCRIPTOR_PHONE_FORMAT_IS_INVALID = '92202';
|
95 |
-
|
96 |
-
const SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_INVALID = '82302';
|
97 |
-
const SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_REQUIRED = '82301';
|
98 |
-
const SETTLEMENT_BATCH_SUMMARY_CUSTOM_FIELD_IS_INVALID = '82303';
|
99 |
-
|
100 |
-
const SUBSCRIPTION_BILLING_DAY_OF_MONTH_CANNOT_BE_UPDATED = '91918';
|
101 |
-
const SUBSCRIPTION_BILLING_DAY_OF_MONTH_IS_INVALID = '91914';
|
102 |
-
const SUBSCRIPTION_BILLING_DAY_OF_MONTH_MUST_BE_NUMERIC = '91913';
|
103 |
-
const SUBSCRIPTION_CANNOT_ADD_DUPLICATE_ADDON_OR_DISCOUNT = '91911';
|
104 |
-
const SUBSCRIPTION_CANNOT_EDIT_CANCELED_SUBSCRIPTION = '81901';
|
105 |
-
const SUBSCRIPTION_CANNOT_EDIT_EXPIRED_SUBSCRIPTION = '81910';
|
106 |
-
const SUBSCRIPTION_CANNOT_EDIT_PRICE_CHANGING_FIELDS_ON_PAST_DUE_SUBSCRIPTION = '91920';
|
107 |
-
const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_IN_THE_PAST = '91916';
|
108 |
-
const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_UPDATED = '91919';
|
109 |
-
const SUBSCRIPTION_FIRST_BILLING_DATE_IS_INVALID = '91915';
|
110 |
-
const SUBSCRIPTION_ID_IS_IN_USE = '81902';
|
111 |
-
const SUBSCRIPTION_INCONSISTENT_NUMBER_OF_BILLING_CYCLES = '91908';
|
112 |
-
const SUBSCRIPTION_INCONSISTENT_START_DATE = '91917';
|
113 |
-
const SUBSCRIPTION_INVALID_REQUEST_FORMAT = '91921';
|
114 |
-
const SUBSCRIPTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91901';
|
115 |
-
const SUBSCRIPTION_MISMATCH_CURRENCY_ISO_CODE = '91923';
|
116 |
-
const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_CANNOT_BE_BLANK = '91912';
|
117 |
-
const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_IS_TOO_SMALL = '91909';
|
118 |
-
const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_GREATER_THAN_ZERO = '91907';
|
119 |
-
const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_NUMERIC = '91906';
|
120 |
-
const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91902';
|
121 |
-
const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91903';
|
122 |
-
const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_NOT_ASSOCIATED_WITH_CUSTOMER = '91905';
|
123 |
-
const SUBSCRIPTION_PLAN_BILLING_FREQUENCY_CANNOT_BE_UPDATED = '91922';
|
124 |
-
const SUBSCRIPTION_PLAN_ID_IS_INVALID = '91904';
|
125 |
-
const SUBSCRIPTION_PRICE_CANNOT_BE_BLANK = '81903';
|
126 |
-
const SUBSCRIPTION_PRICE_FORMAT_IS_INVALID = '81904';
|
127 |
-
const SUBSCRIPTION_PRICE_IS_TOO_LARGE = '81923';
|
128 |
-
const SUBSCRIPTION_STATUS_IS_CANCELED = '81905';
|
129 |
-
const SUBSCRIPTION_TOKEN_FORMAT_IS_INVALID = '81906';
|
130 |
-
const SUBSCRIPTION_TRIAL_DURATION_FORMAT_IS_INVALID = '81907';
|
131 |
-
const SUBSCRIPTION_TRIAL_DURATION_IS_REQUIRED = '81908';
|
132 |
-
const SUBSCRIPTION_TRIAL_DURATION_UNIT_IS_INVALID = '81909';
|
133 |
-
|
134 |
-
const SUBSCRIPTION_MODIFICATION_AMOUNT_CANNOT_BE_BLANK = '92003';
|
135 |
-
const SUBSCRIPTION_MODIFICATION_AMOUNT_IS_INVALID = '92002';
|
136 |
-
const SUBSCRIPTION_MODIFICATION_AMOUNT_IS_TOO_LARGE = '92023';
|
137 |
-
const SUBSCRIPTION_MODIFICATION_CANNOT_EDIT_MODIFICATIONS_ON_PAST_DUE_SUBSCRIPTION = '92022';
|
138 |
-
const SUBSCRIPTION_MODIFICATION_CANNOT_UPDATE_AND_REMOVE = '92015';
|
139 |
-
const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_INCORRECT_KIND = '92020';
|
140 |
-
const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_INVALID = '92011';
|
141 |
-
const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_REQUIRED = '92012';
|
142 |
-
const SUBSCRIPTION_MODIFICATION_ID_TO_REMOVE_IS_INCORRECT_KIND = '92021';
|
143 |
-
const SUBSCRIPTION_MODIFICATION_ID_TO_REMOVE_IS_NOT_PRESENT = '92016';
|
144 |
-
const SUBSCRIPTION_MODIFICATION_INCONSISTENT_NUMBER_OF_BILLING_CYCLES = '92018';
|
145 |
-
const SUBSCRIPTION_MODIFICATION_INHERITED_FROM_ID_IS_INVALID = '92013';
|
146 |
-
const SUBSCRIPTION_MODIFICATION_INHERITED_FROM_ID_IS_REQUIRED = '92014';
|
147 |
-
const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_CANNOT_BE_BLANK = '92017';
|
148 |
-
const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_IS_INVALID = '92005';
|
149 |
-
const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_MUST_BE_GREATER_THAN_ZERO = '92019';
|
150 |
-
const SUBSCRIPTION_MODIFICATION_QUANTITY_CANNOT_BE_BLANK = '92004';
|
151 |
-
const SUBSCRIPTION_MODIFICATION_QUANTITY_IS_INVALID = '92001';
|
152 |
-
const SUBSCRIPTION_MODIFICATION_QUANTITY_MUST_BE_GREATER_THAN_ZERO = '92010';
|
153 |
-
|
154 |
-
const TRANSACTION_AMOUNT_CANNOT_BE_NEGATIVE = '81501';
|
155 |
-
const TRANSACTION_AMOUNT_IS_INVALID = '81503';
|
156 |
-
const TRANSACTION_AMOUNT_IS_REQUIRED = '81502';
|
157 |
-
const TRANSACTION_AMOUNT_IS_TOO_LARGE = '81528';
|
158 |
-
const TRANSACTION_AMOUNT_MUST_BE_GREATER_THAN_ZERO = '81531';
|
159 |
-
const TRANSACTION_BILLING_ADDRESS_CONFLICT = '91530';
|
160 |
-
const TRANSACTION_CANNOT_BE_VOIDED = '91504';
|
161 |
-
const TRANSACTION_CANNOT_CLONE_CREDIT = '91543';
|
162 |
-
const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_VAULT_CREDIT_CARD = '91540';
|
163 |
-
const TRANSACTION_CANNOT_CLONE_UNSUCCESSFUL_TRANSACTION = '91542';
|
164 |
-
const TRANSACTION_CANNOT_CLONE_VOICE_AUTHORIZATIONS = '91541';
|
165 |
-
const TRANSACTION_CANNOT_REFUND_CREDIT = '91505';
|
166 |
-
const TRANSACTION_CANNOT_REFUND_UNLESS_SETTLED = '91506';
|
167 |
-
const TRANSACTION_CANNOT_REFUND_WITH_SUSPENDED_MERCHANT_ACCOUNT = '91538';
|
168 |
-
const TRANSACTION_CANNOT_SUBMIT_FOR_SETTLEMENT = '91507';
|
169 |
-
const TRANSACTION_CHANNEL_IS_TOO_LONG = '91550';
|
170 |
-
const TRANSACTION_CREDIT_CARD_IS_REQUIRED = '91508';
|
171 |
-
const TRANSACTION_CUSTOMER_DEFAULT_PAYMENT_METHOD_CARD_TYPE_IS_NOT_ACCEPTED = '81509';
|
172 |
-
const TRANSACTION_CUSTOMER_DOES_NOT_HAVE_CREDIT_CARD = '91511';
|
173 |
-
const TRANSACTION_CUSTOMER_ID_IS_INVALID = '91510';
|
174 |
-
const TRANSACTION_CUSTOM_FIELD_IS_INVALID = '91526';
|
175 |
-
const TRANSACTION_CUSTOM_FIELD_IS_TOO_LONG = '81527';
|
176 |
-
const TRANSACTION_HAS_ALREADY_BEEN_REFUNDED = '91512';
|
177 |
-
const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_REFUNDS = '91547';
|
178 |
-
const TRANSACTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91513';
|
179 |
-
const TRANSACTION_MERCHANT_ACCOUNT_IS_SUSPENDED = '91514';
|
180 |
-
const TRANSACTION_MERCHANT_ACCOUNT_NAME_IS_INVALID = '91513'; //Deprecated
|
181 |
-
const TRANSACTION_OPTIONS_SUBMIT_FOR_SETTLEMENT_IS_REQUIRED_FOR_CLONING = '91544';
|
182 |
-
const TRANSACTION_OPTIONS_VAULT_IS_DISABLED = '91525';
|
183 |
-
const TRANSACTION_ORDER_ID_IS_TOO_LONG = '91501';
|
184 |
-
const TRANSACTION_PAYMENT_METHOD_CONFLICT = '91515';
|
185 |
-
const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_CUSTOMER = '91516';
|
186 |
-
const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_SUBSCRIPTION = '91527';
|
187 |
-
const TRANSACTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91517';
|
188 |
-
const TRANSACTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91518';
|
189 |
-
const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_CANNOT_BE_SET = '91519';
|
190 |
-
const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_IS_INVALID = '81520';
|
191 |
-
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_CREDITS = '91546';
|
192 |
-
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_VOICE_AUTHORIZATIONS = '91545';
|
193 |
-
const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_TOO_LONG = '91537';
|
194 |
-
const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_INVALID = '91548';
|
195 |
-
const TRANSACTION_REFUND_AMOUNT_IS_TOO_LARGE = '91521';
|
196 |
-
const TRANSACTION_SETTLEMENT_AMOUNT_IS_TOO_LARGE = '91522';
|
197 |
-
const TRANSACTION_SUBSCRIPTION_DOES_NOT_BELONG_TO_CUSTOMER = '91529';
|
198 |
-
const TRANSACTION_SUBSCRIPTION_ID_IS_INVALID = '91528';
|
199 |
-
const TRANSACTION_SUBSCRIPTION_STATUS_MUST_BE_PAST_DUE = '91531';
|
200 |
-
const TRANSACTION_TAX_AMOUNT_CANNOT_BE_NEGATIVE = '81534';
|
201 |
-
const TRANSACTION_TAX_AMOUNT_FORMAT_IS_INVALID = '81535';
|
202 |
-
const TRANSACTION_TAX_AMOUNT_IS_TOO_LARGE = '81536';
|
203 |
-
const TRANSACTION_TYPE_IS_INVALID = '91523';
|
204 |
-
const TRANSACTION_TYPE_IS_REQUIRED = '91524';
|
205 |
-
const TRANSACTION_UNSUPPORTED_VOICE_AUTHORIZATION = '91539';
|
206 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* super class for all Braintree exceptions
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
|
11 |
-
/**
|
12 |
-
* super class for all Braintree exceptions
|
13 |
-
*
|
14 |
-
* @package Braintree
|
15 |
-
* @subpackage Exception
|
16 |
-
* @copyright 2010 Braintree Payment Solutions
|
17 |
-
*/
|
18 |
-
class Braintree_Exception extends Exception
|
19 |
-
{
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/Authentication.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when authentication fails
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised when authentication fails.
|
12 |
-
* This may be caused by an incorrect Braintree_Configuration
|
13 |
-
*
|
14 |
-
* @package Braintree
|
15 |
-
* @subpackage Exception
|
16 |
-
* @copyright 2010 Braintree Payment Solutions
|
17 |
-
*/
|
18 |
-
class Braintree_Exception_Authentication extends Braintree_Exception
|
19 |
-
{
|
20 |
-
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/Configuration.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* raised when the Braintree library is not completely configured
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised when the Braintree library is not completely configured.
|
12 |
-
*
|
13 |
-
* @package Braintree
|
14 |
-
* @subpackage Exception
|
15 |
-
* @see Braintree_Configuration
|
16 |
-
*/
|
17 |
-
class Braintree_Exception_Configuration extends Braintree_Exception
|
18 |
-
{
|
19 |
-
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/DownForMaintenance.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when the gateway is down for maintenance
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised when the gateway is down for maintenance.
|
12 |
-
*
|
13 |
-
* @package Braintree
|
14 |
-
* @subpackage Exception
|
15 |
-
* @copyright 2010 Braintree Payment Solutions
|
16 |
-
*/
|
17 |
-
class Braintree_Exception_DownForMaintenance extends Braintree_Exception
|
18 |
-
{
|
19 |
-
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/ForgedQueryString.php
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when a suspected forged query string is present
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised from methods that confirm transparent request requests
|
12 |
-
* when the given query string cannot be verified. This may indicate
|
13 |
-
* an attempted hack on the merchant's transparent redirect
|
14 |
-
* confirmation URL.
|
15 |
-
*
|
16 |
-
* @package Braintree
|
17 |
-
* @subpackage Exception
|
18 |
-
* @copyright 2010 Braintree Payment Solutions
|
19 |
-
*/
|
20 |
-
class Braintree_Exception_ForgedQueryString extends Braintree_Exception
|
21 |
-
{
|
22 |
-
|
23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/InvalidSignature.php
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_Exception_InvalidSignature extends Braintree_Exception
|
3 |
-
{
|
4 |
-
|
5 |
-
}
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/NotFound.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when a record coult not be found
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised when a record could not be found.
|
12 |
-
*
|
13 |
-
* @package Braintree
|
14 |
-
* @subpackage Exception
|
15 |
-
* @copyright 2010 Braintree Payment Solutions
|
16 |
-
*/
|
17 |
-
class Braintree_Exception_NotFound extends Braintree_Exception
|
18 |
-
{
|
19 |
-
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/SSLCaFileNotFound.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when the SSL CaFile is not found.
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2011 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised when the SSL CaFile is not found.
|
12 |
-
*
|
13 |
-
* @package Braintree
|
14 |
-
* @subpackage Exception
|
15 |
-
* @copyright 2011 Braintree Payment Solutions
|
16 |
-
*/
|
17 |
-
class Braintree_Exception_SSLCaFileNotFound extends Braintree_Exception
|
18 |
-
{
|
19 |
-
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/SSLCertificate.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when the SSL certificate fails verification.
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised when the SSL certificate fails verification.
|
12 |
-
*
|
13 |
-
* @package Braintree
|
14 |
-
* @subpackage Exception
|
15 |
-
* @copyright 2010 Braintree Payment Solutions
|
16 |
-
*/
|
17 |
-
class Braintree_Exception_SSLCertificate extends Braintree_Exception
|
18 |
-
{
|
19 |
-
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/ServerError.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when an unexpected server error occurs.
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised when an unexpected server error occurs.
|
12 |
-
*
|
13 |
-
* @package Braintree
|
14 |
-
* @subpackage Exception
|
15 |
-
* @copyright 2010 Braintree Payment Solutions
|
16 |
-
*/
|
17 |
-
class Braintree_Exception_ServerError extends Braintree_Exception
|
18 |
-
{
|
19 |
-
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/Unexpected.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when an unexpected error occurs
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised when an error occurs that the client library is not built to handle.
|
12 |
-
* This shouldn't happen.
|
13 |
-
*
|
14 |
-
* @package Braintree
|
15 |
-
* @subpackage Exception
|
16 |
-
* @copyright 2010 Braintree Payment Solutions
|
17 |
-
*/
|
18 |
-
class Braintree_Exception_Unexpected extends Braintree_Exception
|
19 |
-
{
|
20 |
-
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/UpgradeRequired.php
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised when a client library must be upgraded.
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
class Braintree_Exception_UpgradeRequired extends Braintree_Exception
|
10 |
-
{
|
11 |
-
|
12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Exception/ValidationsFailed.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Raised from non-validating exceptions when validations fail
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Raised from non-validating methods when gateway validations fail.
|
12 |
-
*
|
13 |
-
* @package Braintree
|
14 |
-
* @subpackage Exception
|
15 |
-
* @copyright 2010 Braintree Payment Solutions
|
16 |
-
*/
|
17 |
-
class Braintree_Exception_ValidationsFailed extends Braintree_Exception
|
18 |
-
{
|
19 |
-
|
20 |
-
}
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Http.php
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree HTTP Client
|
4 |
-
*
|
5 |
-
* @copyright 2010 Braintree Payment Solutions
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* processes Http requests using curl
|
10 |
-
*
|
11 |
-
* @copyright 2010 Braintree Payment Solutions
|
12 |
-
*/
|
13 |
-
class Braintree_Http
|
14 |
-
{
|
15 |
-
public static function delete($path)
|
16 |
-
{
|
17 |
-
$response = self::_doRequest('DELETE', $path);
|
18 |
-
if($response['status'] === 200) {
|
19 |
-
return true;
|
20 |
-
} else {
|
21 |
-
Braintree_Util::throwStatusCodeException($response['status']);
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
25 |
-
public static function get($path)
|
26 |
-
{
|
27 |
-
$response = self::_doRequest('GET', $path);
|
28 |
-
if($response['status'] === 200) {
|
29 |
-
return Braintree_Xml::buildArrayFromXml($response['body']);
|
30 |
-
} else {
|
31 |
-
Braintree_Util::throwStatusCodeException($response['status']);
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
public static function post($path, $params = null)
|
36 |
-
{
|
37 |
-
$response = self::_doRequest('POST', $path, self::_buildXml($params));
|
38 |
-
$responseCode = $response['status'];
|
39 |
-
if($responseCode === 200 || $responseCode === 201 || $responseCode === 422) {
|
40 |
-
return Braintree_Xml::buildArrayFromXml($response['body']);
|
41 |
-
} else {
|
42 |
-
Braintree_Util::throwStatusCodeException($responseCode);
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
public static function put($path, $params = null)
|
47 |
-
{
|
48 |
-
$response = self::_doRequest('PUT', $path, self::_buildXml($params));
|
49 |
-
$responseCode = $response['status'];
|
50 |
-
if($responseCode === 200 || $responseCode === 201 || $responseCode === 422) {
|
51 |
-
return Braintree_Xml::buildArrayFromXml($response['body']);
|
52 |
-
} else {
|
53 |
-
Braintree_Util::throwStatusCodeException($responseCode);
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
private static function _buildXml($params)
|
58 |
-
{
|
59 |
-
return empty($params) ? null : Braintree_Xml::buildXmlFromArray($params);
|
60 |
-
}
|
61 |
-
|
62 |
-
private static function _doRequest($httpVerb, $path, $requestBody = null)
|
63 |
-
{
|
64 |
-
$curl = curl_init();
|
65 |
-
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
|
66 |
-
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb);
|
67 |
-
curl_setopt($curl, CURLOPT_URL, Braintree_Configuration::merchantUrl() . $path);
|
68 |
-
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
|
69 |
-
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
70 |
-
'Accept: application/xml',
|
71 |
-
'Content-Type: application/xml',
|
72 |
-
'User-Agent: Braintree PHP Library ' . Braintree_Version::get(),
|
73 |
-
'X-ApiVersion: ' . Braintree_Configuration::API_VERSION
|
74 |
-
));
|
75 |
-
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
76 |
-
curl_setopt($curl, CURLOPT_USERPWD, Braintree_Configuration::publicKey() . ':' . Braintree_Configuration::privateKey());
|
77 |
-
// curl_setopt($curl, CURLOPT_VERBOSE, true);
|
78 |
-
if (Braintree_Configuration::sslOn()) {
|
79 |
-
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
|
80 |
-
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
|
81 |
-
curl_setopt($curl, CURLOPT_CAINFO, Braintree_Configuration::caFile());
|
82 |
-
}
|
83 |
-
|
84 |
-
if(!empty($requestBody)) {
|
85 |
-
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
|
86 |
-
}
|
87 |
-
|
88 |
-
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
89 |
-
$response = curl_exec($curl);
|
90 |
-
$httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
91 |
-
curl_close($curl);
|
92 |
-
if (Braintree_Configuration::sslOn()) {
|
93 |
-
if ($httpStatus == 0) {
|
94 |
-
throw new Braintree_Exception_SSLCertificate();
|
95 |
-
}
|
96 |
-
}
|
97 |
-
return array('status' => $httpStatus, 'body' => $response);
|
98 |
-
}
|
99 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/IsNode.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Braintree_IsNode
|
4 |
-
{
|
5 |
-
function __construct($name)
|
6 |
-
{
|
7 |
-
$this->name = $name;
|
8 |
-
$this->searchTerms = array();
|
9 |
-
}
|
10 |
-
|
11 |
-
function is($value)
|
12 |
-
{
|
13 |
-
$this->searchTerms['is'] = strval($value);
|
14 |
-
return $this;
|
15 |
-
}
|
16 |
-
|
17 |
-
function toParam()
|
18 |
-
{
|
19 |
-
return $this->searchTerms;
|
20 |
-
}
|
21 |
-
}
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Modification.php
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_Modification extends Braintree
|
3 |
-
{
|
4 |
-
protected function _initialize($attributes)
|
5 |
-
{
|
6 |
-
$this->_attributes = $attributes;
|
7 |
-
|
8 |
-
$addOnArray = array();
|
9 |
-
if (isset($attributes['addOns'])) {
|
10 |
-
foreach ($attributes['addOns'] AS $addOn) {
|
11 |
-
$addOnArray[] = Braintree_addOn::factory($addOn);
|
12 |
-
}
|
13 |
-
}
|
14 |
-
$this->_attributes['addOns'] = $addOnArray;
|
15 |
-
}
|
16 |
-
|
17 |
-
public static function factory($attributes)
|
18 |
-
{
|
19 |
-
$instance = new self();
|
20 |
-
$instance->_initialize($attributes);
|
21 |
-
return $instance;
|
22 |
-
}
|
23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/PartialMatchNode.php
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Braintree_PartialMatchNode extends Braintree_EqualityNode
|
4 |
-
{
|
5 |
-
function startsWith($value)
|
6 |
-
{
|
7 |
-
$this->searchTerms["starts_with"] = strval($value);
|
8 |
-
return $this;
|
9 |
-
}
|
10 |
-
|
11 |
-
function endsWith($value)
|
12 |
-
{
|
13 |
-
$this->searchTerms["ends_with"] = strval($value);
|
14 |
-
return $this;
|
15 |
-
}
|
16 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Result/Successful.php
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree Successful Result
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Result
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Braintree Successful Result
|
12 |
-
*
|
13 |
-
* A Successful Result will be returned from gateway methods when
|
14 |
-
* validations pass. It will provide access to the created resource.
|
15 |
-
*
|
16 |
-
* For example, when creating a customer, Braintree_Result_Successful will
|
17 |
-
* respond to <b>customer</b> like so:
|
18 |
-
*
|
19 |
-
* <code>
|
20 |
-
* $result = Braintree_Customer::create(array('first_name' => "John"));
|
21 |
-
* if ($result->success) {
|
22 |
-
* // Braintree_Result_Successful
|
23 |
-
* echo "Created customer {$result->customer->id}";
|
24 |
-
* } else {
|
25 |
-
* // Braintree_Result_Error
|
26 |
-
* }
|
27 |
-
* </code>
|
28 |
-
*
|
29 |
-
*
|
30 |
-
* @package Braintree
|
31 |
-
* @subpackage Result
|
32 |
-
* @copyright 2010 Braintree Payment Solutions
|
33 |
-
*/
|
34 |
-
class Braintree_Result_Successful extends Braintree_Instance
|
35 |
-
{
|
36 |
-
/**
|
37 |
-
*
|
38 |
-
* @var boolean always true
|
39 |
-
*/
|
40 |
-
public $success = true;
|
41 |
-
/**
|
42 |
-
*
|
43 |
-
* @var string stores the internal name of the object providing access to
|
44 |
-
*/
|
45 |
-
private $_returnObjectName;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @ignore
|
49 |
-
* @param string $classToReturn name of class to instantiate
|
50 |
-
*/
|
51 |
-
public function __construct($objToReturn = null)
|
52 |
-
{
|
53 |
-
if(!empty($objToReturn)) {
|
54 |
-
// get a lowercase direct name for the property
|
55 |
-
$property = Braintree_Util::cleanClassName(
|
56 |
-
get_class($objToReturn)
|
57 |
-
);
|
58 |
-
// save the name for indirect access
|
59 |
-
$this->_returnObjectName = $property;
|
60 |
-
|
61 |
-
// create the property!
|
62 |
-
$this->$property = $objToReturn;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
|
67 |
-
/**
|
68 |
-
*
|
69 |
-
* @ignore
|
70 |
-
* @return string string representation of the object's structure
|
71 |
-
*/
|
72 |
-
public function __toString()
|
73 |
-
{
|
74 |
-
$returnObject = $this->_returnObjectName;
|
75 |
-
return __CLASS__ . '['.$this->$returnObject->__toString().']';
|
76 |
-
}
|
77 |
-
|
78 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/SettlementBatchSummary.php
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_SettlementBatchSummary extends Braintree
|
3 |
-
{
|
4 |
-
public static function generate($settlement_date, $groupByCustomField = NULL)
|
5 |
-
{
|
6 |
-
$criteria = array('settlement_date' => $settlement_date);
|
7 |
-
if (isset($groupByCustomField))
|
8 |
-
{
|
9 |
-
$criteria['group_by_custom_field'] = $groupByCustomField;
|
10 |
-
}
|
11 |
-
$params = array('settlement_batch_summary' => $criteria);
|
12 |
-
$response = Braintree_Http::post('/settlement_batch_summary', $params);
|
13 |
-
|
14 |
-
if (isset($groupByCustomField))
|
15 |
-
{
|
16 |
-
$response['settlementBatchSummary']['records'] = self::_underscoreCustomField(
|
17 |
-
$groupByCustomField,
|
18 |
-
$response['settlementBatchSummary']['records']
|
19 |
-
);
|
20 |
-
}
|
21 |
-
|
22 |
-
return self::_verifyGatewayResponse($response);
|
23 |
-
}
|
24 |
-
|
25 |
-
private static function _underscoreCustomField($groupByCustomField, $records)
|
26 |
-
{
|
27 |
-
$updatedRecords = array();
|
28 |
-
|
29 |
-
foreach ($records as $record)
|
30 |
-
{
|
31 |
-
$camelized = Braintree_Util::delimiterToCamelCase($groupByCustomField);
|
32 |
-
$record[$groupByCustomField] = $record[$camelized];
|
33 |
-
unset($record[$camelized]);
|
34 |
-
$updatedRecords[] = $record;
|
35 |
-
}
|
36 |
-
|
37 |
-
return $updatedRecords;
|
38 |
-
}
|
39 |
-
|
40 |
-
private static function _verifyGatewayResponse($response)
|
41 |
-
{
|
42 |
-
if (isset($response['settlementBatchSummary'])) {
|
43 |
-
return new Braintree_Result_Successful(
|
44 |
-
self::factory($response['settlementBatchSummary'])
|
45 |
-
);
|
46 |
-
} else if (isset($response['apiErrorResponse'])) {
|
47 |
-
return new Braintree_Result_Error($response['apiErrorResponse']);
|
48 |
-
} else {
|
49 |
-
throw new Braintree_Exception_Unexpected(
|
50 |
-
"Expected settlementBatchSummary or apiErrorResponse"
|
51 |
-
);
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
public static function factory($attributes)
|
56 |
-
{
|
57 |
-
$instance = new self();
|
58 |
-
$instance->_initialize($attributes);
|
59 |
-
return $instance;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* @ignore
|
64 |
-
*/
|
65 |
-
protected function _initialize($attributes)
|
66 |
-
{
|
67 |
-
$this->_attributes = $attributes;
|
68 |
-
}
|
69 |
-
|
70 |
-
public function records()
|
71 |
-
{
|
72 |
-
return $this->_attributes['records'];
|
73 |
-
}
|
74 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Subscription.php
DELETED
@@ -1,256 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree Subscription module
|
4 |
-
*
|
5 |
-
* <b>== More information ==</b>
|
6 |
-
*
|
7 |
-
* For more detailed information on Subscriptions, see {@link http://www.braintreepayments.com/gateway/subscription-api http://www.braintreepaymentsolutions.com/gateway/subscription-api}
|
8 |
-
*
|
9 |
-
* PHP Version 5
|
10 |
-
*
|
11 |
-
* @package Braintree
|
12 |
-
* @copyright 2010 Braintree Payment Solutions
|
13 |
-
*/
|
14 |
-
class Braintree_Subscription extends Braintree
|
15 |
-
{
|
16 |
-
const ACTIVE = 'Active';
|
17 |
-
const CANCELED = 'Canceled';
|
18 |
-
const EXPIRED = 'Expired';
|
19 |
-
const PAST_DUE = 'Past Due';
|
20 |
-
const PENDING = 'Pending';
|
21 |
-
|
22 |
-
public static function create($attributes)
|
23 |
-
{
|
24 |
-
Braintree_Util::verifyKeys(self::_createSignature(), $attributes);
|
25 |
-
$response = Braintree_Http::post('/subscriptions', array('subscription' => $attributes));
|
26 |
-
return self::_verifyGatewayResponse($response);
|
27 |
-
}
|
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 |
-
public static function find($id)
|
41 |
-
{
|
42 |
-
self::_validateId($id);
|
43 |
-
|
44 |
-
try {
|
45 |
-
$response = Braintree_Http::get('/subscriptions/' . $id);
|
46 |
-
return self::factory($response['subscription']);
|
47 |
-
} catch (Braintree_Exception_NotFound $e) {
|
48 |
-
throw new Braintree_Exception_NotFound('subscription with id ' . $id . ' not found');
|
49 |
-
}
|
50 |
-
|
51 |
-
}
|
52 |
-
|
53 |
-
public static function search($query)
|
54 |
-
{
|
55 |
-
$criteria = array();
|
56 |
-
foreach ($query as $term) {
|
57 |
-
$criteria[$term->name] = $term->toparam();
|
58 |
-
}
|
59 |
-
|
60 |
-
|
61 |
-
$response = braintree_http::post('/subscriptions/advanced_search_ids', array('search' => $criteria));
|
62 |
-
$pager = array(
|
63 |
-
'className' => __CLASS__,
|
64 |
-
'classMethod' => 'fetch',
|
65 |
-
'methodArgs' => array($query)
|
66 |
-
);
|
67 |
-
|
68 |
-
return new Braintree_ResourceCollection($response, $pager);
|
69 |
-
}
|
70 |
-
|
71 |
-
public static function fetch($query, $ids)
|
72 |
-
{
|
73 |
-
$criteria = array();
|
74 |
-
foreach ($query as $term) {
|
75 |
-
$criteria[$term->name] = $term->toparam();
|
76 |
-
}
|
77 |
-
$criteria["ids"] = Braintree_SubscriptionSearch::ids()->in($ids)->toparam();
|
78 |
-
$response = Braintree_Http::post('/subscriptions/advanced_search', array('search' => $criteria));
|
79 |
-
|
80 |
-
return Braintree_Util::extractAttributeAsArray(
|
81 |
-
$response['subscriptions'],
|
82 |
-
'subscription'
|
83 |
-
);
|
84 |
-
}
|
85 |
-
|
86 |
-
public static function update($subscriptionId, $attributes)
|
87 |
-
{
|
88 |
-
Braintree_Util::verifyKeys(self::_updateSignature(), $attributes);
|
89 |
-
$response = Braintree_Http::put(
|
90 |
-
'/subscriptions/' . $subscriptionId,
|
91 |
-
array('subscription' => $attributes)
|
92 |
-
);
|
93 |
-
return self::_verifyGatewayResponse($response);
|
94 |
-
}
|
95 |
-
|
96 |
-
public static function retryCharge($subscriptionId, $amount = null)
|
97 |
-
{
|
98 |
-
$transaction_params = array('type' => Braintree_Transaction::SALE,
|
99 |
-
'subscriptionId' => $subscriptionId);
|
100 |
-
if (isset($amount)) {
|
101 |
-
$transaction_params['amount'] = $amount;
|
102 |
-
}
|
103 |
-
|
104 |
-
$response = Braintree_Http::post(
|
105 |
-
'/transactions',
|
106 |
-
array('transaction' => $transaction_params));
|
107 |
-
return self::_verifyGatewayResponse($response);
|
108 |
-
}
|
109 |
-
|
110 |
-
public static function cancel($subscriptionId)
|
111 |
-
{
|
112 |
-
$response = Braintree_Http::put('/subscriptions/' . $subscriptionId . '/cancel');
|
113 |
-
return self::_verifyGatewayResponse($response);
|
114 |
-
}
|
115 |
-
|
116 |
-
private static function _createSignature()
|
117 |
-
{
|
118 |
-
return array_merge(
|
119 |
-
array(
|
120 |
-
'billingDayOfMonth',
|
121 |
-
'firstBillingDate',
|
122 |
-
'id',
|
123 |
-
'merchantAccountId',
|
124 |
-
'neverExpires',
|
125 |
-
'numberOfBillingCycles',
|
126 |
-
'paymentMethodToken',
|
127 |
-
'planId',
|
128 |
-
'price',
|
129 |
-
'trialDuration',
|
130 |
-
'trialDurationUnit',
|
131 |
-
'trialPeriod',
|
132 |
-
array('descriptor' => array('name', 'phone')),
|
133 |
-
array('options' => array('doNotInheritAddOnsOrDiscounts', 'startImmediately')),
|
134 |
-
),
|
135 |
-
self::_addOnDiscountSignature()
|
136 |
-
);
|
137 |
-
}
|
138 |
-
|
139 |
-
private static function _updateSignature()
|
140 |
-
{
|
141 |
-
return array_merge(
|
142 |
-
array(
|
143 |
-
'merchantAccountId', 'numberOfBillingCycles', 'paymentMethodToken', 'planId',
|
144 |
-
'id', 'neverExpires', 'price',
|
145 |
-
array('descriptor' => array('name', 'phone')),
|
146 |
-
array('options' => array('prorateCharges', 'replaceAllAddOnsAndDiscounts', 'revertSubscriptionOnProrationFailure')),
|
147 |
-
),
|
148 |
-
self::_addOnDiscountSignature()
|
149 |
-
);
|
150 |
-
}
|
151 |
-
|
152 |
-
private static function _addOnDiscountSignature()
|
153 |
-
{
|
154 |
-
return array(
|
155 |
-
array(
|
156 |
-
'addOns' => array(
|
157 |
-
array('add' => array('amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity')),
|
158 |
-
array('update' => array('amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity')),
|
159 |
-
array('remove' => array('_anyKey_')),
|
160 |
-
)
|
161 |
-
),
|
162 |
-
array(
|
163 |
-
'discounts' => array(
|
164 |
-
array('add' => array('amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity')),
|
165 |
-
array('update' => array('amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity')),
|
166 |
-
array('remove' => array('_anyKey_')),
|
167 |
-
)
|
168 |
-
)
|
169 |
-
);
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* @ignore
|
174 |
-
*/
|
175 |
-
protected function _initialize($attributes)
|
176 |
-
{
|
177 |
-
$this->_attributes = $attributes;
|
178 |
-
|
179 |
-
$addOnArray = array();
|
180 |
-
if (isset($attributes['addOns'])) {
|
181 |
-
foreach ($attributes['addOns'] AS $addOn) {
|
182 |
-
$addOnArray[] = Braintree_AddOn::factory($addOn);
|
183 |
-
}
|
184 |
-
}
|
185 |
-
$this->_attributes['addOns'] = $addOnArray;
|
186 |
-
|
187 |
-
$discountArray = array();
|
188 |
-
if (isset($attributes['discounts'])) {
|
189 |
-
foreach ($attributes['discounts'] AS $discount) {
|
190 |
-
$discountArray[] = Braintree_Discount::factory($discount);
|
191 |
-
}
|
192 |
-
}
|
193 |
-
$this->_attributes['discounts'] = $discountArray;
|
194 |
-
|
195 |
-
if (isset($attributes['descriptor'])) {
|
196 |
-
$this->_set('descriptor', new Braintree_Descriptor($attributes['descriptor']));
|
197 |
-
}
|
198 |
-
|
199 |
-
$transactionArray = array();
|
200 |
-
if (isset($attributes['transactions'])) {
|
201 |
-
foreach ($attributes['transactions'] AS $transaction) {
|
202 |
-
$transactionArray[] = Braintree_Transaction::factory($transaction);
|
203 |
-
}
|
204 |
-
}
|
205 |
-
$this->_attributes['transactions'] = $transactionArray;
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* @ignore
|
210 |
-
*/
|
211 |
-
private static function _validateId($id = null) {
|
212 |
-
if (empty($id)) {
|
213 |
-
throw new InvalidArgumentException(
|
214 |
-
'expected subscription id to be set'
|
215 |
-
);
|
216 |
-
}
|
217 |
-
if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) {
|
218 |
-
throw new InvalidArgumentException(
|
219 |
-
$id . ' is an invalid subscription id.'
|
220 |
-
);
|
221 |
-
}
|
222 |
-
}
|
223 |
-
/**
|
224 |
-
* @ignore
|
225 |
-
*/
|
226 |
-
private static function _verifyGatewayResponse($response)
|
227 |
-
{
|
228 |
-
if (isset($response['subscription'])) {
|
229 |
-
return new Braintree_Result_Successful(
|
230 |
-
self::factory($response['subscription'])
|
231 |
-
);
|
232 |
-
} else if (isset($response['transaction'])) {
|
233 |
-
// return a populated instance of Braintree_Transaction, for subscription retryCharge
|
234 |
-
return new Braintree_Result_Successful(
|
235 |
-
Braintree_Transaction::factory($response['transaction'])
|
236 |
-
);
|
237 |
-
} else if (isset($response['apiErrorResponse'])) {
|
238 |
-
return new Braintree_Result_Error($response['apiErrorResponse']);
|
239 |
-
} else {
|
240 |
-
throw new Braintree_Exception_Unexpected(
|
241 |
-
"Expected subscription, transaction, or apiErrorResponse"
|
242 |
-
);
|
243 |
-
}
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* returns a string representation of the customer
|
248 |
-
* @return string
|
249 |
-
*/
|
250 |
-
public function __toString()
|
251 |
-
{
|
252 |
-
return __CLASS__ . '[' .
|
253 |
-
Braintree_Util::attributesToString($this->_attributes) .']';
|
254 |
-
}
|
255 |
-
|
256 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/SubscriptionSearch.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_SubscriptionSearch
|
3 |
-
{
|
4 |
-
static function billingCyclesRemaining()
|
5 |
-
{
|
6 |
-
return new Braintree_RangeNode('billing_cycles_remaining');
|
7 |
-
}
|
8 |
-
|
9 |
-
static function daysPastDue()
|
10 |
-
{
|
11 |
-
return new Braintree_RangeNode('days_past_due');
|
12 |
-
}
|
13 |
-
|
14 |
-
static function id()
|
15 |
-
{
|
16 |
-
return new Braintree_TextNode('id');
|
17 |
-
}
|
18 |
-
|
19 |
-
static function inTrialPeriod()
|
20 |
-
{
|
21 |
-
return new Braintree_MultipleValueNode('in_trial_period', array(true, false));
|
22 |
-
}
|
23 |
-
|
24 |
-
static function merchantAccountId()
|
25 |
-
{
|
26 |
-
return new Braintree_MultipleValueNode('merchant_account_id');
|
27 |
-
}
|
28 |
-
|
29 |
-
static function nextBillingDate()
|
30 |
-
{
|
31 |
-
return new Braintree_RangeNode('next_billing_date');
|
32 |
-
}
|
33 |
-
|
34 |
-
static function planId()
|
35 |
-
{
|
36 |
-
return new Braintree_MultipleValueOrTextNode('plan_id');
|
37 |
-
}
|
38 |
-
|
39 |
-
static function price()
|
40 |
-
{
|
41 |
-
return new Braintree_RangeNode('price');
|
42 |
-
}
|
43 |
-
|
44 |
-
static function status()
|
45 |
-
{
|
46 |
-
return new Braintree_MultipleValueNode("status", array(
|
47 |
-
Braintree_Subscription::ACTIVE,
|
48 |
-
Braintree_Subscription::CANCELED,
|
49 |
-
Braintree_Subscription::EXPIRED,
|
50 |
-
Braintree_Subscription::PAST_DUE,
|
51 |
-
Braintree_Subscription::PENDING
|
52 |
-
));
|
53 |
-
}
|
54 |
-
|
55 |
-
static function transactionId()
|
56 |
-
{
|
57 |
-
return new Braintree_TextNode('transaction_id');
|
58 |
-
}
|
59 |
-
|
60 |
-
static function ids()
|
61 |
-
{
|
62 |
-
return new Braintree_MultipleValueNode('ids');
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/SubscriptionStatus.php
DELETED
File without changes
|
includes/lib/Braintree/Braintree/TextNode.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Braintree_TextNode extends Braintree_PartialMatchNode
|
4 |
-
{
|
5 |
-
function contains($value)
|
6 |
-
{
|
7 |
-
$this->searchTerms["contains"] = strval($value);
|
8 |
-
return $this;
|
9 |
-
}
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Transaction.php
DELETED
@@ -1,664 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree Transaction processor
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @category Resources
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Creates and manages transactions
|
12 |
-
*
|
13 |
-
* At minimum, an amount, credit card number, and
|
14 |
-
* credit card expiration date are required.
|
15 |
-
*
|
16 |
-
* <b>Minimalistic example:</b>
|
17 |
-
* <code>
|
18 |
-
* Braintree_Transaction::saleNoValidate(array(
|
19 |
-
* 'amount' => '100.00',
|
20 |
-
* 'creditCard' => array(
|
21 |
-
* 'number' => '5105105105105100',
|
22 |
-
* 'expirationDate' => '05/12',
|
23 |
-
* ),
|
24 |
-
* ));
|
25 |
-
* </code>
|
26 |
-
*
|
27 |
-
* <b>Full example:</b>
|
28 |
-
* <code>
|
29 |
-
* Braintree_Transaction::saleNoValidate(array(
|
30 |
-
* 'amount' => '100.00',
|
31 |
-
* 'orderId' => '123',
|
32 |
-
* 'channel' => 'MyShoppingCardProvider',
|
33 |
-
* 'creditCard' => array(
|
34 |
-
* // if token is omitted, the gateway will generate a token
|
35 |
-
* 'token' => 'credit_card_123',
|
36 |
-
* 'number' => '5105105105105100',
|
37 |
-
* 'expirationDate' => '05/2011',
|
38 |
-
* 'cvv' => '123',
|
39 |
-
* ),
|
40 |
-
* 'customer' => array(
|
41 |
-
* // if id is omitted, the gateway will generate an id
|
42 |
-
* 'id' => 'customer_123',
|
43 |
-
* 'firstName' => 'Dan',
|
44 |
-
* 'lastName' => 'Smith',
|
45 |
-
* 'company' => 'Braintree Payment Solutions',
|
46 |
-
* 'email' => 'dan@example.com',
|
47 |
-
* 'phone' => '419-555-1234',
|
48 |
-
* 'fax' => '419-555-1235',
|
49 |
-
* 'website' => 'http://braintreepayments.com'
|
50 |
-
* ),
|
51 |
-
* 'billing' => array(
|
52 |
-
* 'firstName' => 'Carl',
|
53 |
-
* 'lastName' => 'Jones',
|
54 |
-
* 'company' => 'Braintree',
|
55 |
-
* 'streetAddress' => '123 E Main St',
|
56 |
-
* 'extendedAddress' => 'Suite 403',
|
57 |
-
* 'locality' => 'Chicago',
|
58 |
-
* 'region' => 'IL',
|
59 |
-
* 'postalCode' => '60622',
|
60 |
-
* 'countryName' => 'United States of America'
|
61 |
-
* ),
|
62 |
-
* 'shipping' => array(
|
63 |
-
* 'firstName' => 'Andrew',
|
64 |
-
* 'lastName' => 'Mason',
|
65 |
-
* 'company' => 'Braintree',
|
66 |
-
* 'streetAddress' => '456 W Main St',
|
67 |
-
* 'extendedAddress' => 'Apt 2F',
|
68 |
-
* 'locality' => 'Bartlett',
|
69 |
-
* 'region' => 'IL',
|
70 |
-
* 'postalCode' => '60103',
|
71 |
-
* 'countryName' => 'United States of America'
|
72 |
-
* ),
|
73 |
-
* 'customFields' => array(
|
74 |
-
* 'birthdate' => '11/13/1954'
|
75 |
-
* )
|
76 |
-
* )
|
77 |
-
* </code>
|
78 |
-
*
|
79 |
-
* <b>== Storing in the Vault ==</b>
|
80 |
-
*
|
81 |
-
* The customer and credit card information used for
|
82 |
-
* a transaction can be stored in the vault by setting
|
83 |
-
* <i>transaction[options][storeInVault]</i> to true.
|
84 |
-
* <code>
|
85 |
-
* $transaction = Braintree_Transaction::saleNoValidate(array(
|
86 |
-
* 'customer' => array(
|
87 |
-
* 'firstName' => 'Adam',
|
88 |
-
* 'lastName' => 'Williams'
|
89 |
-
* ),
|
90 |
-
* 'creditCard' => array(
|
91 |
-
* 'number' => '5105105105105100',
|
92 |
-
* 'expirationDate' => '05/2012'
|
93 |
-
* ),
|
94 |
-
* 'options' => array(
|
95 |
-
* 'storeInVault' => true
|
96 |
-
* )
|
97 |
-
* ));
|
98 |
-
*
|
99 |
-
* echo $transaction->customerDetails->id
|
100 |
-
* // '865534'
|
101 |
-
* echo $transaction->creditCardDetails->token
|
102 |
-
* // '6b6m'
|
103 |
-
* </code>
|
104 |
-
*
|
105 |
-
* To also store the billing address in the vault, pass the
|
106 |
-
* <b>addBillingAddressToPaymentMethod</b> option.
|
107 |
-
* <code>
|
108 |
-
* Braintree_Transaction.saleNoValidate(array(
|
109 |
-
* ...
|
110 |
-
* 'options' => array(
|
111 |
-
* 'storeInVault' => true
|
112 |
-
* 'addBillingAddressToPaymentMethod' => true
|
113 |
-
* )
|
114 |
-
* ));
|
115 |
-
* </code>
|
116 |
-
*
|
117 |
-
* <b>== Submitting for Settlement==</b>
|
118 |
-
*
|
119 |
-
* This can only be done when the transction's
|
120 |
-
* status is <b>authorized</b>. If <b>amount</b> is not specified,
|
121 |
-
* the full authorized amount will be settled. If you would like to settle
|
122 |
-
* less than the full authorized amount, pass the desired amount.
|
123 |
-
* You cannot settle more than the authorized amount.
|
124 |
-
*
|
125 |
-
* A transaction can be submitted for settlement when created by setting
|
126 |
-
* $transaction[options][submitForSettlement] to true.
|
127 |
-
*
|
128 |
-
* <code>
|
129 |
-
* $transaction = Braintree_Transaction::saleNoValidate(array(
|
130 |
-
* 'amount' => '100.00',
|
131 |
-
* 'creditCard' => array(
|
132 |
-
* 'number' => '5105105105105100',
|
133 |
-
* 'expirationDate' => '05/2012'
|
134 |
-
* ),
|
135 |
-
* 'options' => array(
|
136 |
-
* 'submitForSettlement' => true
|
137 |
-
* )
|
138 |
-
* ));
|
139 |
-
* </code>
|
140 |
-
*
|
141 |
-
* <b>== More information ==</b>
|
142 |
-
*
|
143 |
-
* For more detailed information on Transactions, see {@link http://www.braintreepayments.com/gateway/transaction-api http://www.braintreepaymentsolutions.com/gateway/transaction-api}
|
144 |
-
*
|
145 |
-
* @package Braintree
|
146 |
-
* @category Resources
|
147 |
-
* @copyright 2010 Braintree Payment Solutions
|
148 |
-
*
|
149 |
-
*
|
150 |
-
* @property-read string $avsErrorResponseCode
|
151 |
-
* @property-read string $avsPostalCodeResponseCode
|
152 |
-
* @property-read string $avsStreetAddressResponseCode
|
153 |
-
* @property-read string $cvvResponseCode
|
154 |
-
* @property-read string $id transaction id
|
155 |
-
* @property-read string $amount transaction amount
|
156 |
-
* @property-read object $billingDetails transaction billing address
|
157 |
-
* @property-read string $createdAt transaction created timestamp
|
158 |
-
* @property-read object $creditCardDetails transaction credit card info
|
159 |
-
* @property-read object $customerDetails transaction customer info
|
160 |
-
* @property-read array $customFields custom fields passed with the request
|
161 |
-
* @property-read string $processorResponseCode gateway response code
|
162 |
-
* @property-read object $shippingDetails transaction shipping address
|
163 |
-
* @property-read string $status transaction status
|
164 |
-
* @property-read array $statusHistory array of StatusDetails objects
|
165 |
-
* @property-read string $type transaction type
|
166 |
-
* @property-read string $updatedAt transaction updated timestamp
|
167 |
-
*
|
168 |
-
*/
|
169 |
-
|
170 |
-
final class Braintree_Transaction extends Braintree
|
171 |
-
{
|
172 |
-
// Transaction Status
|
173 |
-
const AUTHORIZATION_EXPIRED = 'authorization_expired';
|
174 |
-
const AUTHORIZING = 'authorizing';
|
175 |
-
const AUTHORIZED = 'authorized';
|
176 |
-
const GATEWAY_REJECTED = 'gateway_rejected';
|
177 |
-
const FAILED = 'failed';
|
178 |
-
const PROCESSOR_DECLINED = 'processor_declined';
|
179 |
-
const SETTLED = 'settled';
|
180 |
-
const SETTLING = 'settling';
|
181 |
-
const SUBMITTED_FOR_SETTLEMENT = 'submitted_for_settlement';
|
182 |
-
const VOIDED = 'voided';
|
183 |
-
|
184 |
-
// Transaction Types
|
185 |
-
const SALE = 'sale';
|
186 |
-
const CREDIT = 'credit';
|
187 |
-
|
188 |
-
// Transaction Created Using
|
189 |
-
const FULL_INFORMATION = 'full_information';
|
190 |
-
const TOKEN = 'token';
|
191 |
-
|
192 |
-
// Transaction Sources
|
193 |
-
const API = 'api';
|
194 |
-
const CONTROL_PANEL = 'control_panel';
|
195 |
-
const RECURRING = 'recurring';
|
196 |
-
|
197 |
-
// Gateway Rejection Reason
|
198 |
-
const AVS = 'avs';
|
199 |
-
const AVS_AND_CVV = 'avs_and_cvv';
|
200 |
-
const CVV = 'cvv';
|
201 |
-
const DUPLICATE = 'duplicate';
|
202 |
-
|
203 |
-
public static function cloneTransaction($transactionId, $attribs)
|
204 |
-
{
|
205 |
-
Braintree_Util::verifyKeys(self::cloneSignature(), $attribs);
|
206 |
-
return self::_doCreate('/transactions/' . $transactionId . '/clone', array('transactionClone' => $attribs));
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* @ignore
|
211 |
-
* @access public
|
212 |
-
* @param array $attribs
|
213 |
-
* @return object
|
214 |
-
*/
|
215 |
-
private static function create($attribs)
|
216 |
-
{
|
217 |
-
Braintree_Util::verifyKeys(self::createSignature(), $attribs);
|
218 |
-
return self::_doCreate('/transactions', array('transaction' => $attribs));
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
*
|
223 |
-
* @ignore
|
224 |
-
* @access public
|
225 |
-
* @param array $attribs
|
226 |
-
* @return object
|
227 |
-
* @throws Braintree_Exception_ValidationError
|
228 |
-
*/
|
229 |
-
private static function createNoValidate($attribs)
|
230 |
-
{
|
231 |
-
$result = self::create($attribs);
|
232 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
233 |
-
}
|
234 |
-
/**
|
235 |
-
*
|
236 |
-
* @access public
|
237 |
-
* @param array $attribs
|
238 |
-
* @return object
|
239 |
-
*/
|
240 |
-
public static function createFromTransparentRedirect($queryString)
|
241 |
-
{
|
242 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::confirm", E_USER_NOTICE);
|
243 |
-
$params = Braintree_TransparentRedirect::parseAndValidateQueryString(
|
244 |
-
$queryString
|
245 |
-
);
|
246 |
-
return self::_doCreate(
|
247 |
-
'/transactions/all/confirm_transparent_redirect_request',
|
248 |
-
array('id' => $params['id'])
|
249 |
-
);
|
250 |
-
}
|
251 |
-
/**
|
252 |
-
*
|
253 |
-
* @access public
|
254 |
-
* @param none
|
255 |
-
* @return string
|
256 |
-
*/
|
257 |
-
public static function createTransactionUrl()
|
258 |
-
{
|
259 |
-
trigger_error("DEPRECATED: Please use Braintree_TransparentRedirectRequest::url", E_USER_NOTICE);
|
260 |
-
return Braintree_Configuration::merchantUrl() .
|
261 |
-
'/transactions/all/create_via_transparent_redirect_request';
|
262 |
-
}
|
263 |
-
|
264 |
-
public static function cloneSignature()
|
265 |
-
{
|
266 |
-
return array('amount', 'channel', array('options' => array('submitForSettlement')));
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* creates a full array signature of a valid gateway request
|
271 |
-
* @return array gateway request signature format
|
272 |
-
*/
|
273 |
-
public static function createSignature()
|
274 |
-
{
|
275 |
-
return array(
|
276 |
-
'amount', 'customerId', 'merchantAccountId', 'orderId', 'channel', 'paymentMethodToken',
|
277 |
-
'purchaseOrderNumber', 'recurring', 'shippingAddressId', 'taxAmount', 'taxExempt', 'type', 'venmoSdkPaymentMethodCode',
|
278 |
-
array('creditCard' =>
|
279 |
-
array('token', 'cardholderName', 'cvv', 'expirationDate', 'expirationMonth', 'expirationYear', 'number'),
|
280 |
-
),
|
281 |
-
array('customer' =>
|
282 |
-
array(
|
283 |
-
'id', 'company', 'email', 'fax', 'firstName',
|
284 |
-
'lastName', 'phone', 'website'),
|
285 |
-
),
|
286 |
-
array('billing' =>
|
287 |
-
array(
|
288 |
-
'firstName', 'lastName', 'company', 'countryName',
|
289 |
-
'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
|
290 |
-
'extendedAddress', 'locality', 'postalCode', 'region',
|
291 |
-
'streetAddress'),
|
292 |
-
),
|
293 |
-
array('shipping' =>
|
294 |
-
array(
|
295 |
-
'firstName', 'lastName', 'company', 'countryName',
|
296 |
-
'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
|
297 |
-
'extendedAddress', 'locality', 'postalCode', 'region',
|
298 |
-
'streetAddress'),
|
299 |
-
),
|
300 |
-
array('options' =>
|
301 |
-
array(
|
302 |
-
'storeInVault',
|
303 |
-
'storeInVaultOnSuccess',
|
304 |
-
'submitForSettlement',
|
305 |
-
'addBillingAddressToPaymentMethod',
|
306 |
-
'venmoSdkSession',
|
307 |
-
'storeShippingAddressInVault'),
|
308 |
-
),
|
309 |
-
array('customFields' => array('_anyKey_')
|
310 |
-
),
|
311 |
-
array('descriptor' => array('name', 'phone')),
|
312 |
-
);
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
*
|
317 |
-
* @access public
|
318 |
-
* @param array $attribs
|
319 |
-
* @return object
|
320 |
-
*/
|
321 |
-
public static function credit($attribs)
|
322 |
-
{
|
323 |
-
return self::create(array_merge($attribs, array('type' => Braintree_Transaction::CREDIT)));
|
324 |
-
}
|
325 |
-
|
326 |
-
/**
|
327 |
-
*
|
328 |
-
* @access public
|
329 |
-
* @param array $attribs
|
330 |
-
* @return object
|
331 |
-
* @throws Braintree_Exception_ValidationError
|
332 |
-
*/
|
333 |
-
public static function creditNoValidate($attribs)
|
334 |
-
{
|
335 |
-
$result = self::credit($attribs);
|
336 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
337 |
-
}
|
338 |
-
|
339 |
-
|
340 |
-
/**
|
341 |
-
* @access public
|
342 |
-
*
|
343 |
-
*/
|
344 |
-
public static function find($id)
|
345 |
-
{
|
346 |
-
self::_validateId($id);
|
347 |
-
try {
|
348 |
-
$response = Braintree_Http::get('/transactions/'.$id);
|
349 |
-
return self::factory($response['transaction']);
|
350 |
-
} catch (Braintree_Exception_NotFound $e) {
|
351 |
-
throw new Braintree_Exception_NotFound(
|
352 |
-
'transaction with id ' . $id . ' not found'
|
353 |
-
);
|
354 |
-
}
|
355 |
-
|
356 |
-
}
|
357 |
-
/**
|
358 |
-
* new sale
|
359 |
-
* @param array $attribs
|
360 |
-
* @return array
|
361 |
-
*/
|
362 |
-
public static function sale($attribs)
|
363 |
-
{
|
364 |
-
return self::create(array_merge(array('type' => Braintree_Transaction::SALE), $attribs));
|
365 |
-
}
|
366 |
-
|
367 |
-
/**
|
368 |
-
* roughly equivalent to the ruby bang method
|
369 |
-
* @access public
|
370 |
-
* @param array $attribs
|
371 |
-
* @return array
|
372 |
-
* @throws Braintree_Exception_ValidationsFailed
|
373 |
-
*/
|
374 |
-
public static function saleNoValidate($attribs)
|
375 |
-
{
|
376 |
-
$result = self::sale($attribs);
|
377 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
378 |
-
}
|
379 |
-
|
380 |
-
/**
|
381 |
-
* Returns a ResourceCollection of transactions matching the search query.
|
382 |
-
*
|
383 |
-
* If <b>query</b> is a string, the search will be a basic search.
|
384 |
-
* If <b>query</b> is a hash, the search will be an advanced search.
|
385 |
-
* For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/transaction-api#searching http://www.braintreepaymentsolutions.com/gateway/transaction-api}
|
386 |
-
*
|
387 |
-
* @param mixed $query search query
|
388 |
-
* @param array $options options such as page number
|
389 |
-
* @return object Braintree_ResourceCollection
|
390 |
-
* @throws InvalidArgumentException
|
391 |
-
*/
|
392 |
-
public static function search($query)
|
393 |
-
{
|
394 |
-
$criteria = array();
|
395 |
-
foreach ($query as $term) {
|
396 |
-
$criteria[$term->name] = $term->toparam();
|
397 |
-
}
|
398 |
-
|
399 |
-
$response = braintree_http::post('/transactions/advanced_search_ids', array('search' => $criteria));
|
400 |
-
$pager = array(
|
401 |
-
'className' => __CLASS__,
|
402 |
-
'classMethod' => 'fetch',
|
403 |
-
'methodArgs' => array($query)
|
404 |
-
);
|
405 |
-
|
406 |
-
return new Braintree_ResourceCollection($response, $pager);
|
407 |
-
}
|
408 |
-
|
409 |
-
public static function fetch($query, $ids)
|
410 |
-
{
|
411 |
-
$criteria = array();
|
412 |
-
foreach ($query as $term) {
|
413 |
-
$criteria[$term->name] = $term->toparam();
|
414 |
-
}
|
415 |
-
$criteria["ids"] = Braintree_TransactionSearch::ids()->in($ids)->toparam();
|
416 |
-
$response = braintree_http::post('/transactions/advanced_search', array('search' => $criteria));
|
417 |
-
|
418 |
-
return braintree_util::extractattributeasarray(
|
419 |
-
$response['creditCardTransactions'],
|
420 |
-
'transaction'
|
421 |
-
);
|
422 |
-
}
|
423 |
-
|
424 |
-
/**
|
425 |
-
* void a transaction by id
|
426 |
-
*
|
427 |
-
* @param string $id transaction id
|
428 |
-
* @return object Braintree_Result_Successful|Braintree_Result_Error
|
429 |
-
*/
|
430 |
-
public static function void($transactionId)
|
431 |
-
{
|
432 |
-
self::_validateId($transactionId);
|
433 |
-
|
434 |
-
$response = Braintree_Http::put('/transactions/'. $transactionId . '/void');
|
435 |
-
return self::_verifyGatewayResponse($response);
|
436 |
-
}
|
437 |
-
/**
|
438 |
-
*
|
439 |
-
*/
|
440 |
-
public static function voidNoValidate($transactionId)
|
441 |
-
{
|
442 |
-
$result = self::void($transactionId);
|
443 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
444 |
-
}
|
445 |
-
|
446 |
-
public static function submitForSettlement($transactionId, $amount = null)
|
447 |
-
{
|
448 |
-
self::_validateId($transactionId);
|
449 |
-
|
450 |
-
$response = Braintree_Http::put(
|
451 |
-
'/transactions/'. $transactionId . '/submit_for_settlement',
|
452 |
-
array( 'transaction' => array( 'amount' => $amount))
|
453 |
-
);
|
454 |
-
return self::_verifyGatewayResponse($response);
|
455 |
-
}
|
456 |
-
|
457 |
-
public static function submitForSettlementNoValidate($transactionId, $amount = null)
|
458 |
-
{
|
459 |
-
$result = self::submitForSettlement($transactionId, $amount);
|
460 |
-
return self::returnObjectOrThrowException(__CLASS__, $result);
|
461 |
-
}
|
462 |
-
|
463 |
-
|
464 |
-
/**
|
465 |
-
* sets instance properties from an array of values
|
466 |
-
*
|
467 |
-
* @ignore
|
468 |
-
* @access protected
|
469 |
-
* @param array $transactionAttribs array of transaction data
|
470 |
-
* @return none
|
471 |
-
*/
|
472 |
-
protected function _initialize($transactionAttribs)
|
473 |
-
{
|
474 |
-
$this->_attributes = $transactionAttribs;
|
475 |
-
|
476 |
-
$this->_set('creditCardDetails',
|
477 |
-
new Braintree_Transaction_CreditCardDetails(
|
478 |
-
$transactionAttribs['creditCard']
|
479 |
-
)
|
480 |
-
);
|
481 |
-
$this->_set('customerDetails',
|
482 |
-
new Braintree_Transaction_CustomerDetails(
|
483 |
-
$transactionAttribs['customer']
|
484 |
-
)
|
485 |
-
);
|
486 |
-
$this->_set('billingDetails',
|
487 |
-
new Braintree_Transaction_AddressDetails(
|
488 |
-
$transactionAttribs['billing']
|
489 |
-
)
|
490 |
-
);
|
491 |
-
$this->_set('shippingDetails',
|
492 |
-
new Braintree_Transaction_AddressDetails(
|
493 |
-
$transactionAttribs['shipping']
|
494 |
-
)
|
495 |
-
);
|
496 |
-
$this->_set('subscriptionDetails',
|
497 |
-
new Braintree_Transaction_SubscriptionDetails(
|
498 |
-
$transactionAttribs['subscription']
|
499 |
-
)
|
500 |
-
);
|
501 |
-
$this->_set('descriptor',
|
502 |
-
new Braintree_Descriptor(
|
503 |
-
$transactionAttribs['descriptor']
|
504 |
-
)
|
505 |
-
);
|
506 |
-
|
507 |
-
$statusHistory = array();
|
508 |
-
foreach ($transactionAttribs['statusHistory'] AS $history) {
|
509 |
-
$statusHistory[] = new Braintree_Transaction_StatusDetails($history);
|
510 |
-
}
|
511 |
-
$this->_set('statusHistory', $statusHistory);
|
512 |
-
|
513 |
-
|
514 |
-
$addOnArray = array();
|
515 |
-
if (isset($transactionAttribs['addOns'])) {
|
516 |
-
foreach ($transactionAttribs['addOns'] AS $addOn) {
|
517 |
-
$addOnArray[] = Braintree_AddOn::factory($addOn);
|
518 |
-
}
|
519 |
-
}
|
520 |
-
$this->_set('addOns', $addOnArray);
|
521 |
-
|
522 |
-
$discountArray = array();
|
523 |
-
if (isset($transactionAttribs['discounts'])) {
|
524 |
-
foreach ($transactionAttribs['discounts'] AS $discount) {
|
525 |
-
$discountArray[] = Braintree_Discount::factory($discount);
|
526 |
-
}
|
527 |
-
}
|
528 |
-
$this->_set('discounts', $discountArray);
|
529 |
-
}
|
530 |
-
|
531 |
-
/**
|
532 |
-
* returns a string representation of the transaction
|
533 |
-
* @return string
|
534 |
-
*/
|
535 |
-
public function __toString()
|
536 |
-
{
|
537 |
-
// array of attributes to print
|
538 |
-
$display = array(
|
539 |
-
'id', 'type', 'amount', 'status',
|
540 |
-
'createdAt', 'creditCardDetails', 'customerDetails'
|
541 |
-
);
|
542 |
-
|
543 |
-
$displayAttributes = array();
|
544 |
-
foreach ($display AS $attrib) {
|
545 |
-
$displayAttributes[$attrib] = $this->$attrib;
|
546 |
-
}
|
547 |
-
return __CLASS__ . '[' .
|
548 |
-
Braintree_Util::attributesToString($displayAttributes) .']';
|
549 |
-
}
|
550 |
-
|
551 |
-
public static function refund($transactionId, $amount = null)
|
552 |
-
{
|
553 |
-
$params = array('transaction' => array('amount' => $amount));
|
554 |
-
$response = Braintree_Http::post('/transactions/' . $transactionId . '/refund', $params);
|
555 |
-
return self::_verifyGatewayResponse($response);
|
556 |
-
}
|
557 |
-
|
558 |
-
public function isEqual($otherTx)
|
559 |
-
{
|
560 |
-
return $this->id === $otherTx->id;
|
561 |
-
}
|
562 |
-
|
563 |
-
public function vaultCreditCard()
|
564 |
-
{
|
565 |
-
$token = $this->creditCardDetails->token;
|
566 |
-
if (empty($token)) {
|
567 |
-
return null;
|
568 |
-
}
|
569 |
-
else {
|
570 |
-
return Braintree_CreditCard::find($token);
|
571 |
-
}
|
572 |
-
}
|
573 |
-
|
574 |
-
public function vaultCustomer()
|
575 |
-
{
|
576 |
-
$customerId = $this->customerDetails->id;
|
577 |
-
if (empty($customerId)) {
|
578 |
-
return null;
|
579 |
-
}
|
580 |
-
else {
|
581 |
-
return Braintree_Customer::find($customerId);
|
582 |
-
}
|
583 |
-
}
|
584 |
-
|
585 |
-
/**
|
586 |
-
* sends the create request to the gateway
|
587 |
-
*
|
588 |
-
* @ignore
|
589 |
-
* @param var $url
|
590 |
-
* @param array $params
|
591 |
-
* @return mixed
|
592 |
-
*/
|
593 |
-
public static function _doCreate($url, $params)
|
594 |
-
{
|
595 |
-
$response = Braintree_Http::post($url, $params);
|
596 |
-
|
597 |
-
return self::_verifyGatewayResponse($response);
|
598 |
-
}
|
599 |
-
|
600 |
-
/**
|
601 |
-
* verifies that a valid transaction id is being used
|
602 |
-
* @ignore
|
603 |
-
* @param string transaction id
|
604 |
-
* @throws InvalidArgumentException
|
605 |
-
*/
|
606 |
-
private static function _validateId($id = null) {
|
607 |
-
if (empty($id)) {
|
608 |
-
throw new InvalidArgumentException(
|
609 |
-
'expected transaction id to be set'
|
610 |
-
);
|
611 |
-
}
|
612 |
-
if (!preg_match('/^[0-9a-z]+$/', $id)) {
|
613 |
-
throw new InvalidArgumentException(
|
614 |
-
$id . ' is an invalid transaction id.'
|
615 |
-
);
|
616 |
-
}
|
617 |
-
}
|
618 |
-
|
619 |
-
|
620 |
-
/* private class methods */
|
621 |
-
|
622 |
-
/**
|
623 |
-
* generic method for validating incoming gateway responses
|
624 |
-
*
|
625 |
-
* creates a new Braintree_Transaction object and encapsulates
|
626 |
-
* it inside a Braintree_Result_Successful object, or
|
627 |
-
* encapsulates a Braintree_Errors object inside a Result_Error
|
628 |
-
* alternatively, throws an Unexpected exception if the response is invalid.
|
629 |
-
*
|
630 |
-
* @ignore
|
631 |
-
* @param array $response gateway response values
|
632 |
-
* @return object Result_Successful or Result_Error
|
633 |
-
* @throws Braintree_Exception_Unexpected
|
634 |
-
*/
|
635 |
-
private static function _verifyGatewayResponse($response)
|
636 |
-
{
|
637 |
-
if (isset($response['transaction'])) {
|
638 |
-
// return a populated instance of Braintree_Transaction
|
639 |
-
return new Braintree_Result_Successful(
|
640 |
-
self::factory($response['transaction'])
|
641 |
-
);
|
642 |
-
} else if (isset($response['apiErrorResponse'])) {
|
643 |
-
return new Braintree_Result_Error($response['apiErrorResponse']);
|
644 |
-
} else {
|
645 |
-
throw new Braintree_Exception_Unexpected(
|
646 |
-
"Expected transaction or apiErrorResponse"
|
647 |
-
);
|
648 |
-
}
|
649 |
-
}
|
650 |
-
|
651 |
-
/**
|
652 |
-
* factory method: returns an instance of Braintree_Transaction
|
653 |
-
* to the requesting method, with populated properties
|
654 |
-
*
|
655 |
-
* @ignore
|
656 |
-
* @return object instance of Braintree_Transaction
|
657 |
-
*/
|
658 |
-
public static function factory($attributes)
|
659 |
-
{
|
660 |
-
$instance = new self();
|
661 |
-
$instance->_initialize($attributes);
|
662 |
-
return $instance;
|
663 |
-
}
|
664 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/TransactionSearch.php
DELETED
@@ -1,124 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_TransactionSearch
|
3 |
-
{
|
4 |
-
static function billingCompany() { return new Braintree_TextNode('billing_company'); }
|
5 |
-
static function billingCountryName() { return new Braintree_TextNode('billing_country_name'); }
|
6 |
-
static function billingExtendedAddress() { return new Braintree_TextNode('billing_extended_address'); }
|
7 |
-
static function billingFirstName() { return new Braintree_TextNode('billing_first_name'); }
|
8 |
-
static function billingLastName() { return new Braintree_TextNode('billing_last_name'); }
|
9 |
-
static function billingLocality() { return new Braintree_TextNode('billing_locality'); }
|
10 |
-
static function billingPostalCode() { return new Braintree_TextNode('billing_postal_code'); }
|
11 |
-
static function billingRegion() { return new Braintree_TextNode('billing_region'); }
|
12 |
-
static function billingStreetAddress() { return new Braintree_TextNode('billing_street_address'); }
|
13 |
-
static function creditCardCardholderName() { return new Braintree_TextNode('credit_card_cardholderName'); }
|
14 |
-
static function customerCompany() { return new Braintree_TextNode('customer_company'); }
|
15 |
-
static function customerEmail() { return new Braintree_TextNode('customer_email'); }
|
16 |
-
static function customerFax() { return new Braintree_TextNode('customer_fax'); }
|
17 |
-
static function customerFirstName() { return new Braintree_TextNode('customer_first_name'); }
|
18 |
-
static function customerId() { return new Braintree_TextNode('customer_id'); }
|
19 |
-
static function customerLastName() { return new Braintree_TextNode('customer_last_name'); }
|
20 |
-
static function customerPhone() { return new Braintree_TextNode('customer_phone'); }
|
21 |
-
static function customerWebsite() { return new Braintree_TextNode('customer_website'); }
|
22 |
-
static function id() { return new Braintree_TextNode('id'); }
|
23 |
-
static function ids() { return new Braintree_MultipleValueNode('ids'); }
|
24 |
-
static function orderId() { return new Braintree_TextNode('order_id'); }
|
25 |
-
static function paymentMethodToken() { return new Braintree_TextNode('payment_method_token'); }
|
26 |
-
static function processorAuthorizationCode() { return new Braintree_TextNode('processor_authorization_code'); }
|
27 |
-
static function settlementBatchId() { return new Braintree_TextNode('settlement_batch_id'); }
|
28 |
-
static function shippingCompany() { return new Braintree_TextNode('shipping_company'); }
|
29 |
-
static function shippingCountryName() { return new Braintree_TextNode('shipping_country_name'); }
|
30 |
-
static function shippingExtendedAddress() { return new Braintree_TextNode('shipping_extended_address'); }
|
31 |
-
static function shippingFirstName() { return new Braintree_TextNode('shipping_first_name'); }
|
32 |
-
static function shippingLastName() { return new Braintree_TextNode('shipping_last_name'); }
|
33 |
-
static function shippingLocality() { return new Braintree_TextNode('shipping_locality'); }
|
34 |
-
static function shippingPostalCode() { return new Braintree_TextNode('shipping_postal_code'); }
|
35 |
-
static function shippingRegion() { return new Braintree_TextNode('shipping_region'); }
|
36 |
-
static function shippingStreetAddress() { return new Braintree_TextNode('shipping_street_address'); }
|
37 |
-
|
38 |
-
static function creditCardExpirationDate() { return new Braintree_EqualityNode('credit_card_expiration_date'); }
|
39 |
-
|
40 |
-
static function creditCardNumber() { return new Braintree_PartialMatchNode('credit_card_number'); }
|
41 |
-
|
42 |
-
static function refund() { return new Braintree_KeyValueNode("refund"); }
|
43 |
-
|
44 |
-
static function amount() { return new Braintree_RangeNode("amount"); }
|
45 |
-
static function authorizedAt() { return new Braintree_RangeNode("authorizedAt"); }
|
46 |
-
static function authorizationExpiredAt() { return new Braintree_RangeNode("authorizationExpiredAt"); }
|
47 |
-
static function createdAt() { return new Braintree_RangeNode("createdAt"); }
|
48 |
-
static function failedAt() { return new Braintree_RangeNode("failedAt"); }
|
49 |
-
static function gatewayRejectedAt() { return new Braintree_RangeNode("gatewayRejectedAt"); }
|
50 |
-
static function processorDeclinedAt() { return new Braintree_RangeNode("processorDeclinedAt"); }
|
51 |
-
static function settledAt() { return new Braintree_RangeNode("settledAt"); }
|
52 |
-
static function submittedForSettlementAt() { return new Braintree_RangeNode("submittedForSettlementAt"); }
|
53 |
-
static function voidedAt() { return new Braintree_RangeNode("voidedAt"); }
|
54 |
-
|
55 |
-
static function merchantAccountId() { return new Braintree_MultipleValueNode("merchant_account_id"); }
|
56 |
-
|
57 |
-
static function createdUsing()
|
58 |
-
{
|
59 |
-
return new Braintree_MultipleValueNode("created_using", array(
|
60 |
-
Braintree_Transaction::FULL_INFORMATION,
|
61 |
-
Braintree_Transaction::TOKEN
|
62 |
-
));
|
63 |
-
}
|
64 |
-
|
65 |
-
static function creditCardCardType()
|
66 |
-
{
|
67 |
-
return new Braintree_MultipleValueNode("credit_card_card_type", array(
|
68 |
-
Braintree_CreditCard::AMEX,
|
69 |
-
Braintree_CreditCard::CARTE_BLANCHE,
|
70 |
-
Braintree_CreditCard::CHINA_UNION_PAY,
|
71 |
-
Braintree_CreditCard::DINERS_CLUB_INTERNATIONAL,
|
72 |
-
Braintree_CreditCard::DISCOVER,
|
73 |
-
Braintree_CreditCard::JCB,
|
74 |
-
Braintree_CreditCard::LASER,
|
75 |
-
Braintree_CreditCard::MAESTRO,
|
76 |
-
Braintree_CreditCard::MASTER_CARD,
|
77 |
-
Braintree_CreditCard::SOLO,
|
78 |
-
Braintree_CreditCard::SWITCH_TYPE,
|
79 |
-
Braintree_CreditCard::VISA,
|
80 |
-
Braintree_CreditCard::UNKNOWN
|
81 |
-
));
|
82 |
-
}
|
83 |
-
|
84 |
-
static function creditCardCustomerLocation()
|
85 |
-
{
|
86 |
-
return new Braintree_MultipleValueNode("credit_card_customer_location", array(
|
87 |
-
Braintree_CreditCard::INTERNATIONAL,
|
88 |
-
Braintree_CreditCard::US
|
89 |
-
));
|
90 |
-
}
|
91 |
-
|
92 |
-
static function source()
|
93 |
-
{
|
94 |
-
return new Braintree_MultipleValueNode("source", array(
|
95 |
-
Braintree_Transaction::API,
|
96 |
-
Braintree_Transaction::CONTROL_PANEL,
|
97 |
-
Braintree_Transaction::RECURRING,
|
98 |
-
));
|
99 |
-
}
|
100 |
-
|
101 |
-
static function status()
|
102 |
-
{
|
103 |
-
return new Braintree_MultipleValueNode("status", array(
|
104 |
-
Braintree_Transaction::AUTHORIZATION_EXPIRED,
|
105 |
-
Braintree_Transaction::AUTHORIZING,
|
106 |
-
Braintree_Transaction::AUTHORIZED,
|
107 |
-
Braintree_Transaction::GATEWAY_REJECTED,
|
108 |
-
Braintree_Transaction::FAILED,
|
109 |
-
Braintree_Transaction::PROCESSOR_DECLINED,
|
110 |
-
Braintree_Transaction::SETTLED,
|
111 |
-
Braintree_Transaction::SETTLING,
|
112 |
-
Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT,
|
113 |
-
Braintree_Transaction::VOIDED
|
114 |
-
));
|
115 |
-
}
|
116 |
-
|
117 |
-
static function type()
|
118 |
-
{
|
119 |
-
return new Braintree_MultipleValueNode("type", array(
|
120 |
-
Braintree_Transaction::SALE,
|
121 |
-
Braintree_Transaction::CREDIT
|
122 |
-
));
|
123 |
-
}
|
124 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/TransparentRedirect.php
DELETED
@@ -1,327 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Braintree Transparent Redirect module
|
6 |
-
*
|
7 |
-
* @package Braintree
|
8 |
-
* @category Resources
|
9 |
-
* @copyright 2010 Braintree Payment Solutions
|
10 |
-
*/
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Static class providing methods to build Transparent Redirect urls
|
14 |
-
*
|
15 |
-
* The TransparentRedirect module provides methods to build the tr_data param
|
16 |
-
* that must be submitted when using the transparent redirect API.
|
17 |
-
* For more information
|
18 |
-
* about transparent redirect, see (TODO).
|
19 |
-
*
|
20 |
-
* You must provide a redirectUrl to which the gateway will redirect the
|
21 |
-
* user the action is complete.
|
22 |
-
*
|
23 |
-
* <code>
|
24 |
-
* $trData = Braintree_TransparentRedirect::createCustomerData(array(
|
25 |
-
* 'redirectUrl => 'http://example.com/redirect_back_to_merchant_site',
|
26 |
-
* ));
|
27 |
-
* </code>
|
28 |
-
*
|
29 |
-
* In addition to the redirectUrl, any data that needs to be protected
|
30 |
-
* from user tampering should be included in the trData.
|
31 |
-
* For example, to prevent the user from tampering with the transaction
|
32 |
-
* amount, include the amount in the trData.
|
33 |
-
*
|
34 |
-
* <code>
|
35 |
-
* $trData = Braintree_TransparentRedirect::transactionData(array(
|
36 |
-
* 'redirectUrl' => 'http://example.com/complete_transaction',
|
37 |
-
* 'transaction' => array('amount' => '100.00'),
|
38 |
-
* ));
|
39 |
-
*
|
40 |
-
* </code>
|
41 |
-
*
|
42 |
-
* @package Braintree
|
43 |
-
* @category Resources
|
44 |
-
* @copyright 2010 Braintree Payment Solutions
|
45 |
-
*/
|
46 |
-
class Braintree_TransparentRedirect
|
47 |
-
{
|
48 |
-
// Request Kinds
|
49 |
-
const CREATE_TRANSACTION = 'create_transaction';
|
50 |
-
const CREATE_PAYMENT_METHOD = 'create_payment_method';
|
51 |
-
const UPDATE_PAYMENT_METHOD = 'update_payment_method';
|
52 |
-
const CREATE_CUSTOMER = 'create_customer';
|
53 |
-
const UPDATE_CUSTOMER = 'update_customer';
|
54 |
-
|
55 |
-
/**
|
56 |
-
*
|
57 |
-
* @ignore
|
58 |
-
*/
|
59 |
-
private static $_transparentRedirectKeys = 'redirectUrl';
|
60 |
-
private static $_createCustomerSignature;
|
61 |
-
private static $_updateCustomerSignature;
|
62 |
-
private static $_transactionSignature;
|
63 |
-
private static $_createCreditCardSignature;
|
64 |
-
private static $_updateCreditCardSignature;
|
65 |
-
|
66 |
-
|
67 |
-
/**
|
68 |
-
* @ignore
|
69 |
-
* don't permit an explicit call of the constructor!
|
70 |
-
* (like $t = new Braintree_TransparentRedirect())
|
71 |
-
*/
|
72 |
-
protected function __construct()
|
73 |
-
{
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* create signatures for different call types
|
79 |
-
* @ignore
|
80 |
-
*/
|
81 |
-
public static function init()
|
82 |
-
{
|
83 |
-
|
84 |
-
self::$_createCustomerSignature = array(
|
85 |
-
self::$_transparentRedirectKeys,
|
86 |
-
array('customer' => Braintree_Customer::createSignature()),
|
87 |
-
);
|
88 |
-
self::$_updateCustomerSignature = array(
|
89 |
-
self::$_transparentRedirectKeys,
|
90 |
-
'customerId',
|
91 |
-
array('customer' => Braintree_Customer::updateSignature()),
|
92 |
-
);
|
93 |
-
self::$_transactionSignature = array(
|
94 |
-
self::$_transparentRedirectKeys,
|
95 |
-
array('transaction' => Braintree_Transaction::createSignature()),
|
96 |
-
);
|
97 |
-
self::$_createCreditCardSignature = array(
|
98 |
-
self::$_transparentRedirectKeys,
|
99 |
-
array('creditCard' => Braintree_CreditCard::createSignature()),
|
100 |
-
);
|
101 |
-
self::$_updateCreditCardSignature = array(
|
102 |
-
self::$_transparentRedirectKeys,
|
103 |
-
'paymentMethodToken',
|
104 |
-
array('creditCard' => Braintree_CreditCard::updateSignature()),
|
105 |
-
);
|
106 |
-
}
|
107 |
-
|
108 |
-
public static function confirm($queryString)
|
109 |
-
{
|
110 |
-
$params = Braintree_TransparentRedirect::parseAndValidateQueryString(
|
111 |
-
$queryString
|
112 |
-
);
|
113 |
-
$confirmationKlasses = array(
|
114 |
-
Braintree_TransparentRedirect::CREATE_TRANSACTION => 'Braintree_Transaction',
|
115 |
-
Braintree_TransparentRedirect::CREATE_CUSTOMER => 'Braintree_Customer',
|
116 |
-
Braintree_TransparentRedirect::UPDATE_CUSTOMER => 'Braintree_Customer',
|
117 |
-
Braintree_TransparentRedirect::CREATE_PAYMENT_METHOD => 'Braintree_CreditCard',
|
118 |
-
Braintree_TransparentRedirect::UPDATE_PAYMENT_METHOD => 'Braintree_CreditCard'
|
119 |
-
);
|
120 |
-
return call_user_func(array($confirmationKlasses[$params["kind"]], '_doCreate'),
|
121 |
-
'/transparent_redirect_requests/' . $params['id'] . '/confirm',
|
122 |
-
array()
|
123 |
-
);
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* returns the trData string for creating a credit card,
|
128 |
-
* @param array $params
|
129 |
-
* @return string
|
130 |
-
*/
|
131 |
-
public static function createCreditCardData($params)
|
132 |
-
{
|
133 |
-
Braintree_Util::verifyKeys(
|
134 |
-
self::$_createCreditCardSignature,
|
135 |
-
$params
|
136 |
-
);
|
137 |
-
$params["kind"] = Braintree_TransparentRedirect::CREATE_PAYMENT_METHOD;
|
138 |
-
return self::_data($params);
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* returns the trData string for creating a customer.
|
143 |
-
* @param array $params
|
144 |
-
* @return string
|
145 |
-
*/
|
146 |
-
public static function createCustomerData($params)
|
147 |
-
{
|
148 |
-
Braintree_Util::verifyKeys(
|
149 |
-
self::$_createCustomerSignature,
|
150 |
-
$params
|
151 |
-
);
|
152 |
-
$params["kind"] = Braintree_TransparentRedirect::CREATE_CUSTOMER;
|
153 |
-
return self::_data($params);
|
154 |
-
|
155 |
-
}
|
156 |
-
|
157 |
-
public static function url()
|
158 |
-
{
|
159 |
-
return Braintree_Configuration::merchantUrl() . "/transparent_redirect_requests";
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* returns the trData string for creating a transaction
|
164 |
-
* @param array $params
|
165 |
-
* @return string
|
166 |
-
*/
|
167 |
-
public static function transactionData($params)
|
168 |
-
{
|
169 |
-
Braintree_Util::verifyKeys(
|
170 |
-
self::$_transactionSignature,
|
171 |
-
$params
|
172 |
-
);
|
173 |
-
$params["kind"] = Braintree_TransparentRedirect::CREATE_TRANSACTION;
|
174 |
-
$transactionType = isset($params['transaction']['type']) ?
|
175 |
-
$params['transaction']['type'] :
|
176 |
-
null;
|
177 |
-
if ($transactionType != Braintree_Transaction::SALE && $transactionType != Braintree_Transaction::CREDIT) {
|
178 |
-
throw new InvalidArgumentException(
|
179 |
-
'expected transaction[type] of sale or credit, was: ' .
|
180 |
-
$transactionType
|
181 |
-
);
|
182 |
-
}
|
183 |
-
|
184 |
-
return self::_data($params);
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Returns the trData string for updating a credit card.
|
189 |
-
*
|
190 |
-
* The paymentMethodToken of the credit card to update is required.
|
191 |
-
*
|
192 |
-
* <code>
|
193 |
-
* $trData = Braintree_TransparentRedirect::updateCreditCardData(array(
|
194 |
-
* 'redirectUrl' => 'http://example.com/redirect_here',
|
195 |
-
* 'paymentMethodToken' => 'token123',
|
196 |
-
* ));
|
197 |
-
* </code>
|
198 |
-
*
|
199 |
-
* @param array $params
|
200 |
-
* @return string
|
201 |
-
*/
|
202 |
-
public static function updateCreditCardData($params)
|
203 |
-
{
|
204 |
-
Braintree_Util::verifyKeys(
|
205 |
-
self::$_updateCreditCardSignature,
|
206 |
-
$params
|
207 |
-
);
|
208 |
-
if (!isset($params['paymentMethodToken'])) {
|
209 |
-
throw new InvalidArgumentException(
|
210 |
-
'expected params to contain paymentMethodToken.'
|
211 |
-
);
|
212 |
-
}
|
213 |
-
$params["kind"] = Braintree_TransparentRedirect::UPDATE_PAYMENT_METHOD;
|
214 |
-
return self::_data($params);
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Returns the trData string for updating a customer.
|
219 |
-
*
|
220 |
-
* The customerId of the customer to update is required.
|
221 |
-
*
|
222 |
-
* <code>
|
223 |
-
* $trData = Braintree_TransparentRedirect::updateCustomerData(array(
|
224 |
-
* 'redirectUrl' => 'http://example.com/redirect_here',
|
225 |
-
* 'customerId' => 'customer123',
|
226 |
-
* ));
|
227 |
-
* </code>
|
228 |
-
*
|
229 |
-
* @param array $params
|
230 |
-
* @return string
|
231 |
-
*/
|
232 |
-
public static function updateCustomerData($params)
|
233 |
-
{
|
234 |
-
Braintree_Util::verifyKeys(
|
235 |
-
self::$_updateCustomerSignature,
|
236 |
-
$params
|
237 |
-
);
|
238 |
-
if (!isset($params['customerId'])) {
|
239 |
-
throw new InvalidArgumentException(
|
240 |
-
'expected params to contain customerId of customer to update'
|
241 |
-
);
|
242 |
-
}
|
243 |
-
$params["kind"] = Braintree_TransparentRedirect::UPDATE_CUSTOMER;
|
244 |
-
return self::_data($params);
|
245 |
-
}
|
246 |
-
|
247 |
-
public static function parseAndValidateQueryString($queryString)
|
248 |
-
{
|
249 |
-
// parse the params into an array
|
250 |
-
parse_str($queryString, $params);
|
251 |
-
// remove the hash
|
252 |
-
$queryStringWithoutHash = null;
|
253 |
-
if(preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) {
|
254 |
-
$queryStringWithoutHash = $match[1];
|
255 |
-
}
|
256 |
-
|
257 |
-
if($params['http_status'] != '200') {
|
258 |
-
$message = null;
|
259 |
-
if(array_key_exists('bt_message', $params)) {
|
260 |
-
$message = $params['bt_message'];
|
261 |
-
}
|
262 |
-
Braintree_Util::throwStatusCodeException($params['http_status'], $message);
|
263 |
-
}
|
264 |
-
|
265 |
-
// recreate the hash and compare it
|
266 |
-
if(self::_hash($queryStringWithoutHash) == $params['hash']) {
|
267 |
-
return $params;
|
268 |
-
} else {
|
269 |
-
throw new Braintree_Exception_ForgedQueryString();
|
270 |
-
}
|
271 |
-
}
|
272 |
-
|
273 |
-
|
274 |
-
/**
|
275 |
-
*
|
276 |
-
* @ignore
|
277 |
-
*/
|
278 |
-
private static function _data($params)
|
279 |
-
{
|
280 |
-
if (!isset($params['redirectUrl'])) {
|
281 |
-
throw new InvalidArgumentException(
|
282 |
-
'expected params to contain redirectUrl'
|
283 |
-
);
|
284 |
-
}
|
285 |
-
$params = self::_underscoreKeys($params);
|
286 |
-
$now = new DateTime('now', new DateTimeZone('UTC'));
|
287 |
-
$trDataParams = array_merge($params,
|
288 |
-
array(
|
289 |
-
'api_version' => Braintree_Configuration::API_VERSION,
|
290 |
-
'public_key' => Braintree_Configuration::publicKey(),
|
291 |
-
'time' => $now->format('YmdHis'),
|
292 |
-
)
|
293 |
-
);
|
294 |
-
ksort($trDataParams);
|
295 |
-
$trDataSegment = http_build_query($trDataParams, null, '&');
|
296 |
-
$trDataHash = self::_hash($trDataSegment);
|
297 |
-
return "$trDataHash|$trDataSegment";
|
298 |
-
}
|
299 |
-
|
300 |
-
private static function _underscoreKeys($array)
|
301 |
-
{
|
302 |
-
foreach($array as $key=>$value)
|
303 |
-
{
|
304 |
-
$newKey = Braintree_Util::camelCaseToDelimiter($key, '_');
|
305 |
-
unset($array[$key]);
|
306 |
-
if (is_array($value))
|
307 |
-
{
|
308 |
-
$array[$newKey] = self::_underscoreKeys($value);
|
309 |
-
}
|
310 |
-
else
|
311 |
-
{
|
312 |
-
$array[$newKey] = $value;
|
313 |
-
}
|
314 |
-
}
|
315 |
-
return $array;
|
316 |
-
}
|
317 |
-
|
318 |
-
/**
|
319 |
-
* @ignore
|
320 |
-
*/
|
321 |
-
private static function _hash($string)
|
322 |
-
{
|
323 |
-
return Braintree_Digest::hexDigest($string);
|
324 |
-
}
|
325 |
-
|
326 |
-
}
|
327 |
-
Braintree_TransparentRedirect::init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Util.php
DELETED
@@ -1,294 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree Utility methods
|
4 |
-
* PHP version 5
|
5 |
-
*
|
6 |
-
* @copyright 2010 Braintree Payment Solutions
|
7 |
-
*/
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Braintree Utility methods
|
11 |
-
*
|
12 |
-
*
|
13 |
-
* @copyright 2010 Braintree Payment Solutions
|
14 |
-
*/
|
15 |
-
class Braintree_Util
|
16 |
-
{
|
17 |
-
/**
|
18 |
-
* extracts an attribute and returns an array of objects
|
19 |
-
*
|
20 |
-
* extracts the requested element from an array, and converts the contents
|
21 |
-
* of its child arrays to objects of type Braintree_$attributeName, or returns
|
22 |
-
* an array with a single element containing the value of that array element
|
23 |
-
*
|
24 |
-
* @param array $attribArray attributes from a search response
|
25 |
-
* @param string $attributeName indicates which element of the passed array to extract
|
26 |
-
*
|
27 |
-
* @return array array of Braintree_$attributeName objects, or a single element array
|
28 |
-
*/
|
29 |
-
public static function extractAttributeAsArray(& $attribArray, $attributeName)
|
30 |
-
{
|
31 |
-
if(!isset($attribArray[$attributeName])):
|
32 |
-
return array();
|
33 |
-
endif;
|
34 |
-
|
35 |
-
// get what should be an array from the passed array
|
36 |
-
$data = $attribArray[$attributeName];
|
37 |
-
// set up the class that will be used to convert each array element
|
38 |
-
$classFactory = self::buildClassName($attributeName) . '::factory';
|
39 |
-
if(is_array($data)):
|
40 |
-
// create an object from the data in each element
|
41 |
-
$objectArray = array_map($classFactory, $data);
|
42 |
-
else:
|
43 |
-
return array($data);
|
44 |
-
endif;
|
45 |
-
|
46 |
-
unset($attribArray[$attributeName]);
|
47 |
-
return $objectArray;
|
48 |
-
}
|
49 |
-
/**
|
50 |
-
* throws an exception based on the type of error
|
51 |
-
* @param string $statusCode HTTP status code to throw exception from
|
52 |
-
* @throws Braintree_Exception multiple types depending on the error
|
53 |
-
*
|
54 |
-
*/
|
55 |
-
public static function throwStatusCodeException($statusCode, $message=null)
|
56 |
-
{
|
57 |
-
switch($statusCode) {
|
58 |
-
case 401:
|
59 |
-
throw new Braintree_Exception_Authentication();
|
60 |
-
break;
|
61 |
-
case 403:
|
62 |
-
throw new Braintree_Exception_Authorization($message);
|
63 |
-
break;
|
64 |
-
case 404:
|
65 |
-
throw new Braintree_Exception_NotFound();
|
66 |
-
break;
|
67 |
-
case 426:
|
68 |
-
throw new Braintree_Exception_UpgradeRequired();
|
69 |
-
break;
|
70 |
-
case 500:
|
71 |
-
throw new Braintree_Exception_ServerError();
|
72 |
-
break;
|
73 |
-
case 503:
|
74 |
-
throw new Braintree_Exception_DownForMaintenance();
|
75 |
-
break;
|
76 |
-
default:
|
77 |
-
throw new Braintree_Exception_Unexpected('Unexpected HTTP_RESPONSE #'.$statusCode);
|
78 |
-
break;
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* removes the Braintree_ header from a classname
|
84 |
-
*
|
85 |
-
* @param string $name Braintree_ClassName
|
86 |
-
* @return camelCased classname minus Braintree_ header
|
87 |
-
*/
|
88 |
-
public static function cleanClassName($name)
|
89 |
-
{
|
90 |
-
$classNamesToResponseKeys = array(
|
91 |
-
'CreditCard' => 'creditCard',
|
92 |
-
'Customer' => 'customer',
|
93 |
-
'Subscription' => 'subscription',
|
94 |
-
'Transaction' => 'transaction',
|
95 |
-
'CreditCardVerification' => 'verification',
|
96 |
-
'AddOn' => 'addOn',
|
97 |
-
'Discount' => 'discount',
|
98 |
-
'Plan' => 'plan',
|
99 |
-
'Address' => 'address',
|
100 |
-
'SettlementBatchSummary' => 'settlementBatchSummary'
|
101 |
-
);
|
102 |
-
|
103 |
-
$name = str_replace('Braintree_', '', $name);
|
104 |
-
return $classNamesToResponseKeys[$name];
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
*
|
109 |
-
* @param string $name className
|
110 |
-
* @return string Braintree_ClassName
|
111 |
-
*/
|
112 |
-
public static function buildClassName($name)
|
113 |
-
{
|
114 |
-
$responseKeysToClassNames = array(
|
115 |
-
'creditCard' => 'CreditCard',
|
116 |
-
'customer' => 'Customer',
|
117 |
-
'subscription' => 'Subscription',
|
118 |
-
'transaction' => 'Transaction',
|
119 |
-
'verification' => 'CreditCardVerification',
|
120 |
-
'addOn' => 'AddOn',
|
121 |
-
'discount' => 'Discount',
|
122 |
-
'plan' => 'Plan',
|
123 |
-
'address' => 'Address',
|
124 |
-
'settlementBatchSummary' => 'SettlementBatchSummary'
|
125 |
-
);
|
126 |
-
|
127 |
-
return 'Braintree_' . $responseKeysToClassNames[$name];
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* convert alpha-beta-gamma to alphaBetaGamma
|
132 |
-
*
|
133 |
-
* @access public
|
134 |
-
* @param string $string
|
135 |
-
* @return string modified string
|
136 |
-
*/
|
137 |
-
public static function delimiterToCamelCase($string, $delimiter = '[\-\_]')
|
138 |
-
{
|
139 |
-
return preg_replace_callback('/' . $delimiter . '(\w)/',function($matches) {
|
140 |
-
return strtoupper($matches[1]);
|
141 |
-
}, $string);
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* convert alpha-beta-gamma to alpha_beta_gamma
|
146 |
-
*
|
147 |
-
* @access public
|
148 |
-
* @param string $string
|
149 |
-
* @return string modified string
|
150 |
-
*/
|
151 |
-
public static function delimiterToUnderscore($string)
|
152 |
-
{
|
153 |
-
return preg_replace('/-/', '_', $string);
|
154 |
-
}
|
155 |
-
|
156 |
-
|
157 |
-
/**
|
158 |
-
* find capitals and convert to delimiter + lowercase
|
159 |
-
*
|
160 |
-
* @access public
|
161 |
-
* @param var $string
|
162 |
-
* @return var modified string
|
163 |
-
*/
|
164 |
-
public static function camelCaseToDelimiter($string, $delimiter = '-')
|
165 |
-
{
|
166 |
-
return preg_replace_callback('/([A-Z])/',function($matches) use ($delimiter) {
|
167 |
-
return $delimiter.strtolower($matches[1]);
|
168 |
-
}, $string);
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
*
|
173 |
-
* @param array $array associative array to implode
|
174 |
-
* @param string $separator (optional, defaults to =)
|
175 |
-
* @param string $glue (optional, defaults to ', ')
|
176 |
-
*/
|
177 |
-
public static function implodeAssociativeArray($array, $separator = '=', $glue = ', ')
|
178 |
-
{
|
179 |
-
// build a new array with joined keys and values
|
180 |
-
$tmpArray = null;
|
181 |
-
foreach ($array AS $key => $value) {
|
182 |
-
$tmpArray[] = $key . $separator . $value;
|
183 |
-
|
184 |
-
}
|
185 |
-
// implode and return the new array
|
186 |
-
return (is_array($tmpArray)) ? implode($glue, $tmpArray) : false;
|
187 |
-
}
|
188 |
-
|
189 |
-
public static function attributesToString($attributes) {
|
190 |
-
$printableAttribs = array();
|
191 |
-
foreach ($attributes AS $key => $value) {
|
192 |
-
if (is_array($value)) {
|
193 |
-
$pAttrib = Braintree_Util::attributesToString($value);
|
194 |
-
} else if ($value instanceof DateTime) {
|
195 |
-
$pAttrib = $value->format(DateTime::RFC850);
|
196 |
-
} else {
|
197 |
-
$pAttrib = $value;
|
198 |
-
}
|
199 |
-
$printableAttribs[$key] = sprintf('%s', $pAttrib);
|
200 |
-
}
|
201 |
-
return Braintree_Util::implodeAssociativeArray($printableAttribs);
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* verify user request structure
|
206 |
-
*
|
207 |
-
* compares the expected signature of a gateway request
|
208 |
-
* against the actual structure sent by the user
|
209 |
-
*
|
210 |
-
* @param array $signature
|
211 |
-
* @param array $attributes
|
212 |
-
*/
|
213 |
-
public static function verifyKeys($signature, $attributes)
|
214 |
-
{
|
215 |
-
$validKeys = self::_flattenArray($signature);
|
216 |
-
$userKeys = self::_flattenUserKeys($attributes);
|
217 |
-
$invalidKeys = array_diff($userKeys, $validKeys);
|
218 |
-
$invalidKeys = self::_removeWildcardKeys($validKeys, $invalidKeys);
|
219 |
-
|
220 |
-
if(!empty($invalidKeys)) {
|
221 |
-
asort($invalidKeys);
|
222 |
-
$sortedList = join(', ', $invalidKeys);
|
223 |
-
throw new InvalidArgumentException('invalid keys: '. $sortedList);
|
224 |
-
}
|
225 |
-
}
|
226 |
-
/**
|
227 |
-
* flattens a numerically indexed nested array to a single level
|
228 |
-
* @param array $keys
|
229 |
-
* @param string $namespace
|
230 |
-
* @return array
|
231 |
-
*/
|
232 |
-
private static function _flattenArray($keys, $namespace = null)
|
233 |
-
{
|
234 |
-
$flattenedArray = array();
|
235 |
-
foreach($keys AS $key) {
|
236 |
-
if(is_array($key)) {
|
237 |
-
$theKeys = array_keys($key);
|
238 |
-
$theValues = array_values($key);
|
239 |
-
$scope = $theKeys[0];
|
240 |
-
$fullKey = empty($namespace) ? $scope : $namespace . '[' . $scope . ']';
|
241 |
-
$flattenedArray = array_merge($flattenedArray, self::_flattenArray($theValues[0], $fullKey));
|
242 |
-
} else {
|
243 |
-
$fullKey = empty($namespace) ? $key : $namespace . '[' . $key . ']';
|
244 |
-
$flattenedArray[] = $fullKey;
|
245 |
-
}
|
246 |
-
}
|
247 |
-
sort($flattenedArray);
|
248 |
-
return $flattenedArray;
|
249 |
-
}
|
250 |
-
|
251 |
-
private static function _flattenUserKeys($keys, $namespace = null)
|
252 |
-
{
|
253 |
-
$flattenedArray = array();
|
254 |
-
|
255 |
-
foreach($keys AS $key => $value) {
|
256 |
-
$fullKey = empty($namespace) ? $key : $namespace;
|
257 |
-
if (!is_numeric($key) && $namespace != null) {
|
258 |
-
$fullKey .= '[' . $key . ']';
|
259 |
-
}
|
260 |
-
if (is_numeric($key) && is_string($value)) {
|
261 |
-
$fullKey .= '[' . $value . ']';
|
262 |
-
}
|
263 |
-
if(is_array($value)) {
|
264 |
-
$more = self::_flattenUserKeys($value, $fullKey);
|
265 |
-
$flattenedArray = array_merge($flattenedArray, $more);
|
266 |
-
} else {
|
267 |
-
$flattenedArray[] = $fullKey;
|
268 |
-
}
|
269 |
-
}
|
270 |
-
sort($flattenedArray);
|
271 |
-
return $flattenedArray;
|
272 |
-
}
|
273 |
-
|
274 |
-
/**
|
275 |
-
* removes wildcard entries from the invalid keys array
|
276 |
-
* @param array $validKeys
|
277 |
-
* @param <array $invalidKeys
|
278 |
-
* @return array
|
279 |
-
*/
|
280 |
-
private static function _removeWildcardKeys($validKeys, $invalidKeys)
|
281 |
-
{
|
282 |
-
foreach($validKeys AS $key) {
|
283 |
-
if (stristr($key, '[_anyKey_]')) {
|
284 |
-
$wildcardKey = str_replace('[_anyKey_]', '', $key);
|
285 |
-
foreach ($invalidKeys AS $index => $invalidKey) {
|
286 |
-
if (stristr($invalidKey, $wildcardKey)) {
|
287 |
-
unset($invalidKeys[$index]);
|
288 |
-
}
|
289 |
-
}
|
290 |
-
}
|
291 |
-
}
|
292 |
-
return $invalidKeys;
|
293 |
-
}
|
294 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/WebhookNotification.php
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_WebhookNotification extends Braintree
|
3 |
-
{
|
4 |
-
const SUBSCRIPTION_CANCELED = 'subscription_canceled';
|
5 |
-
const SUBSCRIPTION_CHARGED_SUCCESSFULLY = 'subscription_charged_successfully';
|
6 |
-
const SUBSCRIPTION_CHARGED_UNSUCCESSFULLY = 'subscription_charged_unsuccessfully';
|
7 |
-
const SUBSCRIPTION_EXPIRED = 'subscription_expired';
|
8 |
-
const SUBSCRIPTION_TRIAL_ENDED = 'subscription_trial_ended';
|
9 |
-
const SUBSCRIPTION_WENT_ACTIVE = 'subscription_went_active';
|
10 |
-
const SUBSCRIPTION_WENT_PAST_DUE = 'subscription_went_past_due';
|
11 |
-
|
12 |
-
public static function parse($signature, $payload)
|
13 |
-
{
|
14 |
-
self::_validateSignature($signature, $payload);
|
15 |
-
|
16 |
-
$xml = base64_decode($payload);
|
17 |
-
$attributes = Braintree_Xml::buildArrayFromXml($xml);
|
18 |
-
return self::factory($attributes['notification']);
|
19 |
-
}
|
20 |
-
|
21 |
-
public static function verify($challenge)
|
22 |
-
{
|
23 |
-
$publicKey = Braintree_Configuration::publicKey();
|
24 |
-
$digest = Braintree_Digest::hexDigest($challenge);
|
25 |
-
return "{$publicKey}|{$digest}";
|
26 |
-
}
|
27 |
-
|
28 |
-
public static function factory($attributes)
|
29 |
-
{
|
30 |
-
$instance = new self();
|
31 |
-
$instance->_initialize($attributes);
|
32 |
-
return $instance;
|
33 |
-
}
|
34 |
-
|
35 |
-
private static function _matchingSignature($signaturePairs)
|
36 |
-
{
|
37 |
-
foreach ($signaturePairs as $pair)
|
38 |
-
{
|
39 |
-
$components = preg_split("/\|/", $pair);
|
40 |
-
if ($components[0] == Braintree_Configuration::publicKey()) {
|
41 |
-
return $components[1];
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
return null;
|
46 |
-
}
|
47 |
-
|
48 |
-
private static function _validateSignature($signature, $payload)
|
49 |
-
{
|
50 |
-
$signaturePairs = preg_split("/&/", $signature);
|
51 |
-
$matchingSignature = self::_matchingSignature($signaturePairs);
|
52 |
-
|
53 |
-
$payloadSignature = Braintree_Digest::hexDigest($payload);
|
54 |
-
if (!Braintree_Digest::secureCompare($matchingSignature, $payloadSignature)) {
|
55 |
-
throw new Braintree_Exception_InvalidSignature("webhook notification signature invalid");
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
protected function _initialize($attributes)
|
60 |
-
{
|
61 |
-
$this->_attributes = $attributes;
|
62 |
-
if (isset($attributes['subject']) && isset($attributes['subject']['subscription'])) {
|
63 |
-
$this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
|
64 |
-
}
|
65 |
-
}
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/WebhookTesting.php
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_WebhookTesting
|
3 |
-
{
|
4 |
-
public static function sampleNotification($kind, $id)
|
5 |
-
{
|
6 |
-
$payload = base64_encode(self::_sampleXml($kind, $id));
|
7 |
-
$signature = Braintree_Configuration::publicKey() . "|" . Braintree_Digest::hexDigest($payload);
|
8 |
-
|
9 |
-
return array(
|
10 |
-
'signature' => $signature,
|
11 |
-
'payload' => $payload
|
12 |
-
);
|
13 |
-
}
|
14 |
-
|
15 |
-
private static function _sampleXml($kind, $id)
|
16 |
-
{
|
17 |
-
$subjectXml = self::_subscriptionSampleXml($id);
|
18 |
-
$timestamp = self::_timestamp();
|
19 |
-
return "
|
20 |
-
<notification>
|
21 |
-
<timestamp type=\"datetime\">{$timestamp}</timestamp>
|
22 |
-
<kind>{$kind}</kind>
|
23 |
-
<subject>{$subjectXml}</subject>
|
24 |
-
</notification>
|
25 |
-
";
|
26 |
-
}
|
27 |
-
|
28 |
-
private static function _subscriptionSampleXml($id)
|
29 |
-
{
|
30 |
-
return "
|
31 |
-
<subscription>
|
32 |
-
<id>{$id}</id>
|
33 |
-
<transactions type=\"array\">
|
34 |
-
</transactions>
|
35 |
-
<add_ons type=\"array\">
|
36 |
-
</add_ons>
|
37 |
-
<discounts type=\"array\">
|
38 |
-
</discounts>
|
39 |
-
</subscription>
|
40 |
-
";
|
41 |
-
}
|
42 |
-
|
43 |
-
private static function _timestamp()
|
44 |
-
{
|
45 |
-
$originalZone = date_default_timezone_get();
|
46 |
-
date_default_timezone_set('UTC');
|
47 |
-
$timestamp = strftime('%Y-%m-%dT%TZ');
|
48 |
-
date_default_timezone_set($originalZone);
|
49 |
-
|
50 |
-
return $timestamp;
|
51 |
-
}
|
52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Xml/Parser.php
DELETED
@@ -1,179 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Braintree XML Parser
|
5 |
-
*
|
6 |
-
* @copyright 2010 Braintree Payment Solutions
|
7 |
-
*/
|
8 |
-
/**
|
9 |
-
* Parses incoming Xml into arrays using PHP's
|
10 |
-
* built-in SimpleXML, and its extension via
|
11 |
-
* Iterator, SimpleXMLIterator
|
12 |
-
*
|
13 |
-
* @copyright 2010 Braintree Payment Solutions
|
14 |
-
*/
|
15 |
-
class Braintree_Xml_Parser
|
16 |
-
{
|
17 |
-
|
18 |
-
private static $_xmlRoot;
|
19 |
-
private static $_responseType;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* sets up the SimpleXMLIterator and starts the parsing
|
23 |
-
* @access public
|
24 |
-
* @param string $xml
|
25 |
-
* @return array array mapped to the passed xml
|
26 |
-
*/
|
27 |
-
public static function arrayFromXml($xml)
|
28 |
-
{
|
29 |
-
// SimpleXML provides the root information on construct
|
30 |
-
$iterator = new SimpleXMLIterator($xml);
|
31 |
-
$xmlRoot = Braintree_Util::delimiterToCamelCase($iterator->getName());
|
32 |
-
$type = $iterator->attributes()->type;
|
33 |
-
|
34 |
-
self::$_xmlRoot = $iterator->getName();
|
35 |
-
self::$_responseType = $type;
|
36 |
-
|
37 |
-
// return the mapped array with the root element as the header
|
38 |
-
return array($xmlRoot => self::_iteratorToArray($iterator));
|
39 |
-
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* processes SimpleXMLIterator objects recursively
|
44 |
-
*
|
45 |
-
* @access protected
|
46 |
-
* @param object $iterator
|
47 |
-
* @return array xml converted to array
|
48 |
-
*/
|
49 |
-
private static function _iteratorToArray($iterator)
|
50 |
-
{
|
51 |
-
$xmlArray = array();
|
52 |
-
$value = null;
|
53 |
-
|
54 |
-
// rewind the iterator and check if the position is valid
|
55 |
-
// if not, return the string it contains
|
56 |
-
$iterator->rewind();
|
57 |
-
if (!$iterator->valid()) {
|
58 |
-
return self::_typecastXmlValue($iterator);
|
59 |
-
}
|
60 |
-
for ($iterator->rewind(); $iterator->valid(); $iterator->next()) {
|
61 |
-
|
62 |
-
$tmpArray = null;
|
63 |
-
$value = null;
|
64 |
-
|
65 |
-
// get the attribute type string for use in conditions below
|
66 |
-
$attributeType = $iterator->attributes()->type;
|
67 |
-
|
68 |
-
// extract the parent element via xpath query
|
69 |
-
$parentElement = $iterator->xpath($iterator->key() . '/..');
|
70 |
-
if ($parentElement[0] instanceof SimpleXMLIterator) {
|
71 |
-
$parentElement = $parentElement[0];
|
72 |
-
$parentKey = Braintree_Util::delimiterToCamelCase($parentElement->getName());
|
73 |
-
} else {
|
74 |
-
$parentElement = null;
|
75 |
-
}
|
76 |
-
|
77 |
-
|
78 |
-
if ($parentKey == "customFields") {
|
79 |
-
$key = Braintree_Util::delimiterToUnderscore($iterator->key());
|
80 |
-
} else {
|
81 |
-
$key = Braintree_Util::delimiterToCamelCase($iterator->key());
|
82 |
-
}
|
83 |
-
|
84 |
-
// process children recursively
|
85 |
-
if ($iterator->hasChildren()) {
|
86 |
-
// return the child elements
|
87 |
-
$value = self::_iteratorToArray($iterator->current());
|
88 |
-
|
89 |
-
// if the element is an array type,
|
90 |
-
// use numeric keys to allow multiple values
|
91 |
-
if ($attributeType != 'array') {
|
92 |
-
$tmpArray[$key] = $value;
|
93 |
-
}
|
94 |
-
} else {
|
95 |
-
// cast values according to attributes
|
96 |
-
$tmpArray[$key] = self::_typecastXmlValue($iterator->current());
|
97 |
-
}
|
98 |
-
|
99 |
-
// set the output string
|
100 |
-
$output = isset($value) ? $value : $tmpArray[$key];
|
101 |
-
|
102 |
-
// determine if there are multiple tags of this name at the same level
|
103 |
-
if (isset($parentElement) &&
|
104 |
-
($parentElement->attributes()->type == 'collection') &&
|
105 |
-
$iterator->hasChildren()) {
|
106 |
-
$xmlArray[$key][] = $output;
|
107 |
-
continue;
|
108 |
-
}
|
109 |
-
|
110 |
-
// if the element was an array type, output to a numbered key
|
111 |
-
// otherwise, use the element name
|
112 |
-
if ($attributeType == 'array') {
|
113 |
-
$xmlArray[] = $output;
|
114 |
-
} else {
|
115 |
-
$xmlArray[$key] = $output;
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
return $xmlArray;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* typecast xml value based on attributes
|
124 |
-
* @param object $valueObj SimpleXMLElement
|
125 |
-
* @return mixed value for placing into array
|
126 |
-
*/
|
127 |
-
private static function _typecastXmlValue($valueObj)
|
128 |
-
{
|
129 |
-
// get the element attributes
|
130 |
-
$attribs = $valueObj->attributes();
|
131 |
-
// the element is null, so jump out here
|
132 |
-
if (isset($attribs->nil) && $attribs->nil) {
|
133 |
-
return null;
|
134 |
-
}
|
135 |
-
// switch on the type attribute
|
136 |
-
// switch works even if $attribs->type isn't set
|
137 |
-
switch ($attribs->type) {
|
138 |
-
case 'datetime':
|
139 |
-
return self::_timestampToUTC((string) $valueObj);
|
140 |
-
break;
|
141 |
-
case 'date':
|
142 |
-
return new DateTime((string)$valueObj);
|
143 |
-
break;
|
144 |
-
case 'integer':
|
145 |
-
return (int) $valueObj;
|
146 |
-
break;
|
147 |
-
case 'boolean':
|
148 |
-
$value = (string) $valueObj;
|
149 |
-
// look for a number inside the string
|
150 |
-
if(is_numeric($value)) {
|
151 |
-
return (bool) $value;
|
152 |
-
} else {
|
153 |
-
// look for the string "true", return false in all other cases
|
154 |
-
return ($value != "true") ? FALSE : TRUE;
|
155 |
-
}
|
156 |
-
break;
|
157 |
-
case 'array':
|
158 |
-
return array();
|
159 |
-
default:
|
160 |
-
return (string) $valueObj;
|
161 |
-
}
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* convert xml timestamps into DateTime
|
167 |
-
* @param string $timestamp
|
168 |
-
* @return string UTC formatted datetime string
|
169 |
-
*/
|
170 |
-
private static function _timestampToUTC($timestamp)
|
171 |
-
{
|
172 |
-
$tz = new DateTimeZone('UTC');
|
173 |
-
// strangely DateTime requires an explicit set below
|
174 |
-
// to show the proper time zone
|
175 |
-
$dateTime = new DateTime($timestamp, $tz);
|
176 |
-
$dateTime->setTimezone($tz);
|
177 |
-
return $dateTime;
|
178 |
-
}
|
179 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/CHANGELOG.md
ADDED
@@ -0,0 +1,460 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## 3.21.1
|
2 |
+
* Add back in `options->three_d_secure` to transaction params that was accidentally removed in v3.14.0
|
3 |
+
|
4 |
+
## 3.21.0
|
5 |
+
* Allow optional configuration of SSL version
|
6 |
+
* Replace `var_dump` with `print_r`. Thanks, @mnlg
|
7 |
+
* Add functionality to list all merchant accounts for a merchant with `merchantAccount->all`
|
8 |
+
* Stop sending account_description field from us bank accounts
|
9 |
+
|
10 |
+
## 3.20.0
|
11 |
+
* Add option `skip_advanced_fraud_check` for transaction flows
|
12 |
+
|
13 |
+
## 3.19.0
|
14 |
+
* Add multi-currency updates to merchants onboarded through Braintree Auth
|
15 |
+
* Raise an exception if fetching pages of results times out during a transaction search
|
16 |
+
|
17 |
+
## 3.18.0
|
18 |
+
* Fix `UsBankAccount` support for `Customer`s
|
19 |
+
* Update `Grant` api to support options hash
|
20 |
+
|
21 |
+
## 3.17.0
|
22 |
+
* Add 'UsBankAccount' payment method
|
23 |
+
|
24 |
+
## 3.16.0
|
25 |
+
* Add authenticated proxy functionality
|
26 |
+
* Add constant for Venmo Account payment instrument type
|
27 |
+
* Add validation error for verifications with submerchants
|
28 |
+
|
29 |
+
## 3.15.0
|
30 |
+
* Add 'default_payment_method' option for Customer
|
31 |
+
|
32 |
+
## 3.14.0
|
33 |
+
**Note: This version introduced an unintentional breaking change where the `options->three_d_secure` transaction parameter was changed to `options->threeDSecure`. Starting in v3.21.1, both case conventions are supported for backwards compatibility.**
|
34 |
+
|
35 |
+
* Add OrderId to refund
|
36 |
+
* Add 3DS Pass thru support
|
37 |
+
* Expose IDs in resource collections
|
38 |
+
* Add leading slash to the namespace. Thanks, @bocharsky-bw
|
39 |
+
* Stop modifying DateTime parameters during XML generation. Thanks, @jodarove
|
40 |
+
|
41 |
+
## 3.13.0
|
42 |
+
* Add method of revoking OAuth access tokens.
|
43 |
+
|
44 |
+
## 3.12.0
|
45 |
+
* Add Transaction `update_details`
|
46 |
+
* Support for Too Many Requests response codes
|
47 |
+
* Add ability to count errors in ErrorCollection object. Thanks, @bocharsky-bw
|
48 |
+
* Improve Type Hinting
|
49 |
+
|
50 |
+
## 3.11.0
|
51 |
+
* Remove final from classes. Thanks, @ibrahimlawal!
|
52 |
+
* Add currency to Transaction search
|
53 |
+
|
54 |
+
## 3.10.0
|
55 |
+
* Add timeout attribute
|
56 |
+
* Add start-date and end-date to SUBSCRIPTION_CHARGED_SUCCESSFULLY test webhook response
|
57 |
+
|
58 |
+
## 3.9.0
|
59 |
+
* Add AccountUpdaterDailyReport webhook parsing
|
60 |
+
|
61 |
+
## 3.8.0
|
62 |
+
* Add payment method revoke
|
63 |
+
* Add support for options in `submit_for_settlement` transaction flows
|
64 |
+
* Add verification create API
|
65 |
+
* Update https certificate bundle
|
66 |
+
|
67 |
+
## 3.7.0
|
68 |
+
* Add VenmoAccount
|
69 |
+
* Allow order_id and descriptor to be passed in for Transaction submit_for_settlement
|
70 |
+
* Add facilitator details onto transactions
|
71 |
+
* Add check webhook constant
|
72 |
+
|
73 |
+
## 3.6.1
|
74 |
+
* Fix PSR-0 style namespacing when using Symfony
|
75 |
+
|
76 |
+
## 3.6.0
|
77 |
+
* Add support for proxy servers
|
78 |
+
* Add PSR-4 namespacing support
|
79 |
+
* Add support for AMEX Express Checkout
|
80 |
+
* Add support for new fields in dispute webhooks (`dateWon`, `dateOpened`, `kind`)
|
81 |
+
* Add transaction data to sucessful subscription webhook
|
82 |
+
|
83 |
+
## 3.5.0
|
84 |
+
* Add support for raw ApplePay params on Transaction create
|
85 |
+
|
86 |
+
## 3.4.0
|
87 |
+
* Add sourceDescription method to Android Pay and Apple Pay payment methods
|
88 |
+
* Add new Android Pay test nonces
|
89 |
+
* Add billing agreement ID to PayPal Account
|
90 |
+
* Support amex rewards transactions
|
91 |
+
|
92 |
+
## 3.3.0
|
93 |
+
* Add new test payment method nonces
|
94 |
+
* Allow passing description on PayPal transactions
|
95 |
+
* Add methods to change transaction settlement status in sandbox
|
96 |
+
* Fix issue where customer with an id of 0 could not be found
|
97 |
+
* Add Europe Bank Account functionality
|
98 |
+
|
99 |
+
## 3.2.0
|
100 |
+
* Add additional search criteria
|
101 |
+
|
102 |
+
## 3.1.0
|
103 |
+
* Add support for HHVM
|
104 |
+
* Validate that configuration is valid before verifying webhooks
|
105 |
+
* Make OAuth methods conform more to existing API
|
106 |
+
* Expose customer paymentMethods as an attribute
|
107 |
+
|
108 |
+
## 3.0.1
|
109 |
+
* Add support for Android Pay
|
110 |
+
|
111 |
+
## 3.0.0
|
112 |
+
* Deprecate PHP 5.2 and 5.3
|
113 |
+
* Validate webhook challenge payload
|
114 |
+
* Bugfix for calling `__toString()` on objects that contain a `\DateTime`
|
115 |
+
|
116 |
+
## 2.40.0
|
117 |
+
* Add missing criteria to credit card verification search
|
118 |
+
* Bugfix for autoloading files with Composer
|
119 |
+
|
120 |
+
## 2.39.0
|
121 |
+
* Add oauth functionality
|
122 |
+
* Add 3DS info to the server side
|
123 |
+
|
124 |
+
## 2.38.0
|
125 |
+
* Update payment instrument types and test nonces
|
126 |
+
* Add missing valid params to PaymentMethodGateway
|
127 |
+
|
128 |
+
## 2.37.0
|
129 |
+
* Add 3D Secure transaction fields
|
130 |
+
* Add ability to create nonce from vaulted payment methods
|
131 |
+
|
132 |
+
## 2.36.0
|
133 |
+
* Surface Apple Pay payment instrument name in responses
|
134 |
+
* Support Coinbase payment instruments
|
135 |
+
|
136 |
+
## 2.35.2
|
137 |
+
* Fix E_STRICT errors
|
138 |
+
* Expose subscription status details
|
139 |
+
|
140 |
+
## 2.35.1
|
141 |
+
* Bugfix for auto loading files
|
142 |
+
|
143 |
+
## 2.35.0
|
144 |
+
* Allow PayPal fields in transaction.options.paypal
|
145 |
+
* Add error code constants
|
146 |
+
* Internal refactoring
|
147 |
+
|
148 |
+
## 2.34.0
|
149 |
+
* Add risk_data to Transaction and Verification with Kount decision and id
|
150 |
+
* Add verification_amount an option when creating a credit card
|
151 |
+
* Add TravelCruise industry type to Transaction
|
152 |
+
* Add room_rate to Lodging industry type
|
153 |
+
* Add CreditCard#verification as the latest verification on that credit card
|
154 |
+
* Add ApplePay support to all endpoints that may return ApplePayCard objects
|
155 |
+
* Add prefix to sample Webhook to simulate webhook query params
|
156 |
+
|
157 |
+
## 2.33.0
|
158 |
+
* Allow descriptor to be passed in Funding Details options params for Merchant Account create and update.
|
159 |
+
|
160 |
+
## 2.32.0
|
161 |
+
* Add additionalProcessorResponse to Transaction
|
162 |
+
|
163 |
+
## 2.31.1
|
164 |
+
* Allow payee_email to be passed in options params for Transaction create
|
165 |
+
|
166 |
+
## 2.31.0
|
167 |
+
* Added paypal specific fields to transaction calls
|
168 |
+
* Added SettlementPending, SettlementDeclined transaction statuses
|
169 |
+
|
170 |
+
## 2.30.0
|
171 |
+
* Add descriptor url support
|
172 |
+
|
173 |
+
## 2.29.0
|
174 |
+
* Allow credit card verification options to be passed outside of the nonce for PaymentMethod.create
|
175 |
+
* Allow billing_address parameters and billing_address_id to be passed outside of the nonce for PaymentMethod.create
|
176 |
+
* Add Subscriptions to paypal accounts
|
177 |
+
* Add PaymentMethod.update
|
178 |
+
* Add fail_on_duplicate_payment_method option to PaymentMethod.create
|
179 |
+
|
180 |
+
## 2.28.0
|
181 |
+
* Adds support for v.zero SDKs.
|
182 |
+
|
183 |
+
## 2.27.2
|
184 |
+
|
185 |
+
* Make webhook parsing more robust with newlines
|
186 |
+
* Add messages to InvalidSignature exceptions
|
187 |
+
|
188 |
+
## 2.27.1
|
189 |
+
|
190 |
+
* Updated secureCompare to correctly compare strings in consistent time
|
191 |
+
* Add better error messages around webhook verification
|
192 |
+
|
193 |
+
## 2.27.0
|
194 |
+
|
195 |
+
* Include Dispute information on Transaction
|
196 |
+
* Search for Transactions disputed on a certain date
|
197 |
+
|
198 |
+
## 2.26.0
|
199 |
+
|
200 |
+
* Disbursement Webhooks
|
201 |
+
|
202 |
+
## 2.25.1
|
203 |
+
|
204 |
+
* Fix factories on AddOn and Discount (thanks [stewe](https://github.com/stewe))
|
205 |
+
* Allow billingAddressId on transaction create
|
206 |
+
|
207 |
+
## 2.25.0
|
208 |
+
|
209 |
+
* Merchant account find API
|
210 |
+
|
211 |
+
## 2.24.0
|
212 |
+
|
213 |
+
* Merchant account update API
|
214 |
+
* Merchant account create API v2
|
215 |
+
|
216 |
+
## 2.23.1
|
217 |
+
|
218 |
+
* Update configuration URLs
|
219 |
+
|
220 |
+
## 2.23.0
|
221 |
+
|
222 |
+
* Official Partnership support
|
223 |
+
|
224 |
+
## 2.22.2
|
225 |
+
|
226 |
+
* Add Partner Merchant Declined webhook
|
227 |
+
* use preg_callback_replace instead of preg_replace (thanks [jonthornton](https://github.com/jonthornton)!)
|
228 |
+
|
229 |
+
## 2.22.1
|
230 |
+
|
231 |
+
* Adds missing test contstant to library namespace
|
232 |
+
|
233 |
+
## 2.22.0
|
234 |
+
|
235 |
+
* Adds holdInEscrow method
|
236 |
+
* Add error codes for verification not supported error
|
237 |
+
* Add companyName and taxId to merchant account create
|
238 |
+
* Adds cancelRelease method
|
239 |
+
* Adds releaseFromEscrow functionality
|
240 |
+
* Adds phone to merchant account signature.
|
241 |
+
* Adds merchant account phone error code.
|
242 |
+
* Fix casing issues with Braintree\_Http and Braintree\_Util references (thanks [steven-hadfield](https://github.com/steven-hadfield)!)
|
243 |
+
* Fixed transaction initialization arguments to be optional (thanks [karolsojko](https://github.com/karolsojko)!)
|
244 |
+
|
245 |
+
## 2.21.0
|
246 |
+
|
247 |
+
* Enable device data.
|
248 |
+
|
249 |
+
## 2.20.0
|
250 |
+
|
251 |
+
* Fixed getting custom fields with valueForHtmlField. [Thanks to Miguel Manso for the fix.](https://github.com/mumia)
|
252 |
+
* Adds disbursement details to transactions.
|
253 |
+
* Adds image url to transactions.
|
254 |
+
|
255 |
+
## 2.19.0
|
256 |
+
|
257 |
+
* Adds channel field to transactions.
|
258 |
+
|
259 |
+
## 2.18.0
|
260 |
+
|
261 |
+
* Adds country of issuance and issuing bank bin database fields
|
262 |
+
|
263 |
+
## 2.17.0
|
264 |
+
|
265 |
+
* Adds verification search
|
266 |
+
|
267 |
+
## 2.16.0
|
268 |
+
|
269 |
+
* Additional card information, such as prepaid, debit, commercial, Durbin regulated, healthcare, and payroll, are returned on credit card responses
|
270 |
+
* Allows transactions to be specified as recurring
|
271 |
+
|
272 |
+
## 2.15.0
|
273 |
+
|
274 |
+
* Adds prepaid field to credit cards (possible values include Yes, No, Unknown)
|
275 |
+
|
276 |
+
## 2.14.1
|
277 |
+
|
278 |
+
* Adds composer support (thanks [till](https://github.com/till))
|
279 |
+
* Fixes erroneous version number
|
280 |
+
* Braintree_Plan::all() returns empty array if no plans exist
|
281 |
+
|
282 |
+
## 2.14.0
|
283 |
+
|
284 |
+
* Adds webhook gateways for parsing, verifying, and testing notifications
|
285 |
+
|
286 |
+
## 2.13.0
|
287 |
+
|
288 |
+
* Adds search for duplicate credit cards given a payment method token
|
289 |
+
* Adds flag to fail saving credit card to vault if card is duplicate
|
290 |
+
|
291 |
+
## 2.12.5
|
292 |
+
|
293 |
+
* Exposes plan_id on transactions
|
294 |
+
|
295 |
+
## 2.12.4
|
296 |
+
|
297 |
+
* Added error code for invalid purchase order number
|
298 |
+
|
299 |
+
## 2.12.3
|
300 |
+
|
301 |
+
* Fixed problematic case in ResourceCollection when no results are returned from a search.
|
302 |
+
|
303 |
+
## 2.12.2
|
304 |
+
|
305 |
+
* Fixed customer search, which returned customers when no customers matched search criteria
|
306 |
+
|
307 |
+
## 2.12.1
|
308 |
+
|
309 |
+
* Added new error message for merchant accounts that do not support refunds
|
310 |
+
|
311 |
+
## 2.12.0
|
312 |
+
|
313 |
+
* Added ability to retrieve all Plans, AddOns, and Discounts
|
314 |
+
* Added Transaction cloning
|
315 |
+
|
316 |
+
## 2.11.0
|
317 |
+
|
318 |
+
* Added Braintree_SettlementBatchSummary
|
319 |
+
|
320 |
+
## 2.10.1
|
321 |
+
|
322 |
+
* Wrap dependency requirement in a function, to prevent pollution of the global namespace
|
323 |
+
|
324 |
+
## 2.10.0
|
325 |
+
|
326 |
+
* Added subscriptionDetails to Transaction
|
327 |
+
* Added flag to store in vault only when a transaction is successful
|
328 |
+
* Added new error code
|
329 |
+
|
330 |
+
## 2.9.0
|
331 |
+
|
332 |
+
* Added a new transaction state, AUTHORIZATION_EXPIRED.
|
333 |
+
* Enabled searching by authorizationExpiredAt.
|
334 |
+
|
335 |
+
## 2.8.0
|
336 |
+
|
337 |
+
* Added next_billing_date and transaction_id to subscription search
|
338 |
+
* Added address_country_name to customer search
|
339 |
+
* Added new error codes
|
340 |
+
|
341 |
+
## 2.7.0
|
342 |
+
|
343 |
+
* Added Customer search
|
344 |
+
* Added dynamic descriptors to Subscriptions and Transactions
|
345 |
+
* Added level 2 fields to Transactions:
|
346 |
+
* tax_amount
|
347 |
+
* tax_exempt
|
348 |
+
* purchase_order_number
|
349 |
+
|
350 |
+
## 2.6.1
|
351 |
+
|
352 |
+
* Added billingAddressId to allowed parameters for credit cards create and update
|
353 |
+
* Allow searching on subscriptions that are currently in a trial period using inTrialPeriod
|
354 |
+
|
355 |
+
## 2.6.0
|
356 |
+
|
357 |
+
* Added ability to perform multiple partial refunds on Braintree_Transactions
|
358 |
+
* Allow passing expirationMonth and expirationYear separately when creating Braintree_Transactions
|
359 |
+
* Added revertSubscriptionOnProrationFailure flag to Braintree_Subscription update that specifies how a Subscription should react to a failed proration charge
|
360 |
+
* Deprecated Braintree_Subscription nextBillAmount in favor of nextBillingPeriodAmount
|
361 |
+
* Deprecated Braintree_Transaction refundId in favor of refundIds
|
362 |
+
* Added new fields to Braintree_Subscription:
|
363 |
+
* balance
|
364 |
+
* paidThroughDate
|
365 |
+
* nextBillingPeriodAmount
|
366 |
+
|
367 |
+
## 2.5.0
|
368 |
+
|
369 |
+
* Added Braintree_AddOns/Braintree_Discounts
|
370 |
+
* Enhanced Braintree_Subscription search
|
371 |
+
* Enhanced Braintree_Transaction search
|
372 |
+
* Added constants for Braintree_Result_CreditCardVerification statuses
|
373 |
+
* Added EXPIRED and PENDING statuses to Braintree_Subscription
|
374 |
+
* Allowed prorateCharges to be specified on Braintree_Subscription update
|
375 |
+
* Added Braintree_AddOn/Braintree_Discount details to Braintree_Transactions that were created from a Braintree_Subscription
|
376 |
+
* Removed 13 digit Visa Sandbox Credit Card number and replaced it with a 16 digit Visa
|
377 |
+
* Added new fields to Braintree_Subscription:
|
378 |
+
* billingDayOfMonth
|
379 |
+
* daysPastDue
|
380 |
+
* firstBillingDate
|
381 |
+
* neverExpires
|
382 |
+
* numberOfBillingCycles
|
383 |
+
|
384 |
+
## 2.4.0
|
385 |
+
|
386 |
+
* Added ability to specify country using countryName, countryCodeAlpha2, countryCodeAlpha3, or countryCodeNumeric (see [ISO_3166-1](http://en.wikipedia.org/wiki/ISO_3166-1))
|
387 |
+
* Added gatewayRejectionReason to Braintree_Transaction and Braintree_Verification
|
388 |
+
* Added unified message to result objects
|
389 |
+
|
390 |
+
## 2.3.0
|
391 |
+
|
392 |
+
* Added unified Braintree_TransparentRedirect url and confirm methods and deprecated old methods
|
393 |
+
* Added functions to Braintree_CreditCard to allow searching on expiring and expired credit cards
|
394 |
+
* Allow card verification against a specified merchant account
|
395 |
+
* Added ability to update a customer, credit card, and billing address in one request
|
396 |
+
* Allow updating the paymentMethodToken on a subscription
|
397 |
+
|
398 |
+
## 2.2.0
|
399 |
+
|
400 |
+
* Prevent race condition when pulling back collection results -- search results represent the state of the data at the time the query was run
|
401 |
+
* Rename ResourceCollection's approximate_size to maximum_size because items that no longer match the query will not be returned in the result set
|
402 |
+
* Correctly handle HTTP error 426 (Upgrade Required) -- the error code is returned when your client library version is no long compatible with the gateway
|
403 |
+
* Add the ability to specify merchant_account_id when verifying credit cards
|
404 |
+
* Add subscription_id to transactions created from subscriptions
|
405 |
+
|
406 |
+
## 2.1.0
|
407 |
+
|
408 |
+
* Added transaction advanced search
|
409 |
+
* Added ability to partially refund transactions
|
410 |
+
* Added ability to manually retry past-due subscriptions
|
411 |
+
* Added new transaction error codes
|
412 |
+
* Allow merchant account to be specified when creating transactions
|
413 |
+
* Allow creating a transaction with a vault customer and new payment method
|
414 |
+
* Allow existing billing address to be updated when updating credit card
|
415 |
+
* Correctly handle xml with nil=true
|
416 |
+
|
417 |
+
## 2.0.0
|
418 |
+
|
419 |
+
* Updated success? on transaction responses to return false on declined transactions
|
420 |
+
* Search results now include Enumerable and will automatically paginate data
|
421 |
+
* Added credit_card[cardholder_name] to allowed transaction params and CreditCardDetails (thanks [chrismcc](http://github.com/chrismcc))
|
422 |
+
* Fixed a bug with Customer::all
|
423 |
+
* Added constants for error codes
|
424 |
+
|
425 |
+
## 1.2.1
|
426 |
+
|
427 |
+
* Added methods to get both shallow and deep errors from a Braintree_ValidationErrorCollection
|
428 |
+
* Added the ability to make a credit card the default card for a customer
|
429 |
+
* Added constants for transaction statuses
|
430 |
+
* Updated Quick Start in README.md to show a workflow with error checking
|
431 |
+
|
432 |
+
## 1.2.0
|
433 |
+
|
434 |
+
* Added subscription search
|
435 |
+
* Provide access to associated subscriptions from CreditCard
|
436 |
+
* Switched from using Zend framework for HTTP requests to using curl extension
|
437 |
+
* Fixed a bug in Transparent Redirect when arg_separator.output is configured as & instead of &
|
438 |
+
* Increased http request timeout
|
439 |
+
* Fixed a bug where ForgedQueryString exception was being raised instead of DownForMaintenance
|
440 |
+
* Updated SSL CA files
|
441 |
+
|
442 |
+
## 1.1.1
|
443 |
+
|
444 |
+
* Added Braintree_Transaction::refund
|
445 |
+
* Added Braintree_Transaction::submitForSettlementNoValidate
|
446 |
+
* Fixed a bug in errors->onHtmlField when checking for errors on custom fields when there are none
|
447 |
+
* Added support for passing merchantAccountId for Transaction and Subscription
|
448 |
+
|
449 |
+
## 1.1.0
|
450 |
+
|
451 |
+
* Added recurring billing support
|
452 |
+
|
453 |
+
## 1.0.1
|
454 |
+
|
455 |
+
* Fixed bug with Braintree_Error_ErrorCollection.deepSize
|
456 |
+
* Added methods for accessing validation errors and params by html field name
|
457 |
+
|
458 |
+
## 1.0.0
|
459 |
+
|
460 |
+
* Initial release
|
includes/lib/Braintree/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright (c) 2014 Braintree, a division of PayPal, Inc.
|
2 |
+
|
3 |
+
Permission is hereby granted, free of charge, to any person
|
4 |
+
obtaining a copy of this software and associated documentation
|
5 |
+
files (the "Software"), to deal in the Software without
|
6 |
+
restriction, including without limitation the rights to use,
|
7 |
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8 |
+
copies of the Software, and to permit persons to whom the
|
9 |
+
Software is furnished to do so, subject to the following
|
10 |
+
conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be
|
13 |
+
included in all copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17 |
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19 |
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20 |
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21 |
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22 |
+
OTHER DEALINGS IN THE SOFTWARE.
|
includes/lib/Braintree/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Braintree PHP Server Library
|
2 |
+
|
3 |
+
The Braintree PHP library provides integration access to the Braintree Gateway.
|
4 |
+
|
5 |
+
## Please Note
|
6 |
+
> **The Payment Card Industry (PCI) Council has [mandated](http://blog.pcisecuritystandards.org/migrating-from-ssl-and-early-tls) that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, Braintree is updating its services to require TLS 1.2 for all HTTPS connections. Braintree will also require HTTP/1.1 for all connections. Please see our [technical documentation](https://github.com/paypal/tls-update) for more information.**
|
7 |
+
|
8 |
+
## Dependencies
|
9 |
+
|
10 |
+
PHP version >= 5.4.0 is required.
|
11 |
+
|
12 |
+
The following PHP extensions are required:
|
13 |
+
|
14 |
+
* curl
|
15 |
+
* dom
|
16 |
+
* hash
|
17 |
+
* openssl
|
18 |
+
* xmlwriter
|
19 |
+
|
20 |
+
## Quick Start Example
|
21 |
+
|
22 |
+
```php
|
23 |
+
<?php
|
24 |
+
|
25 |
+
require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';
|
26 |
+
|
27 |
+
Braintree_Configuration::environment('sandbox');
|
28 |
+
Braintree_Configuration::merchantId('your_merchant_id');
|
29 |
+
Braintree_Configuration::publicKey('your_public_key');
|
30 |
+
Braintree_Configuration::privateKey('your_private_key');
|
31 |
+
|
32 |
+
$result = Braintree_Transaction::sale([
|
33 |
+
'amount' => '1000.00',
|
34 |
+
'paymentMethodNonce' => 'nonceFromTheClient',
|
35 |
+
'options' => [ 'submitForSettlement' => true ]
|
36 |
+
]);
|
37 |
+
|
38 |
+
if ($result->success) {
|
39 |
+
print_r("success!: " . $result->transaction->id);
|
40 |
+
} else if ($result->transaction) {
|
41 |
+
print_r("Error processing transaction:");
|
42 |
+
print_r("\n code: " . $result->transaction->processorResponseCode);
|
43 |
+
print_r("\n text: " . $result->transaction->processorResponseText);
|
44 |
+
} else {
|
45 |
+
print_r("Validation errors: \n");
|
46 |
+
print_r($result->errors->deepAll());
|
47 |
+
}
|
48 |
+
```
|
49 |
+
|
50 |
+
Both PSR-0 and PSR-4 namespacing are supported. If you are using composer with `--classmap-authoritative` or
|
51 |
+
`--optimize-autoloader` enabled, you'll have to reference classes using PSR-4 namespacing:
|
52 |
+
```php
|
53 |
+
Braintree\Configuration::environment('sandbox');
|
54 |
+
Braintree\Configuration::merchantId('your_merchant_id');
|
55 |
+
Braintree\Configuration::publicKey('your_public_key');
|
56 |
+
Braintree\Configuration::privateKey('your_private_key');
|
57 |
+
```
|
58 |
+
|
59 |
+
## HHVM Support
|
60 |
+
|
61 |
+
The Braintree PHP library will run on HHVM >= 3.4.2.
|
62 |
+
|
63 |
+
## Legacy PHP Support
|
64 |
+
|
65 |
+
Version [2.40.0](https://github.com/braintree/braintree_php/releases/tag/2.40.0) is compatible with PHP 5.2 and 5.3. You can find it on our releases page.
|
66 |
+
|
67 |
+
## Documentation
|
68 |
+
|
69 |
+
* [Official documentation](https://developers.braintreepayments.com/php/sdk/server/overview)
|
70 |
+
|
71 |
+
## Testing
|
72 |
+
|
73 |
+
The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on your system. To run unit tests use rake: `rake test:unit`.
|
74 |
+
|
75 |
+
The benefit of the `rake` tasks is that testing covers default `hhvm` and `php` interpreters. However, if you want to run tests manually simply use the following command:
|
76 |
+
```
|
77 |
+
phpunit tests/unit/
|
78 |
+
```
|
79 |
+
|
80 |
+
## License
|
81 |
+
|
82 |
+
See the LICENSE file.
|
includes/lib/Braintree/Rakefile
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
task :default => :test
|
2 |
+
task :test => %w[test:unit test:integration]
|
3 |
+
|
4 |
+
namespace :test do
|
5 |
+
task :unit => %w[test:php:unit test:hhvm:unit]
|
6 |
+
task :integration => %w[test:php:integration test:hhvm:integration]
|
7 |
+
|
8 |
+
namespace :php do
|
9 |
+
desc "print PHP version"
|
10 |
+
task :version do
|
11 |
+
print_php_version("php")
|
12 |
+
end
|
13 |
+
|
14 |
+
desc "run unit tests under PHP"
|
15 |
+
task :unit => :version do
|
16 |
+
run_php_test_suite("php", "unit")
|
17 |
+
end
|
18 |
+
|
19 |
+
desc "run integration tests under PHP"
|
20 |
+
task :integration do
|
21 |
+
run_php_test_suite("php", "integration")
|
22 |
+
end
|
23 |
+
end
|
24 |
+
|
25 |
+
namespace :hhvm do
|
26 |
+
desc "print HHVM version"
|
27 |
+
task :version do
|
28 |
+
print_php_version("hhvm")
|
29 |
+
end
|
30 |
+
|
31 |
+
desc "run tests under HHVM"
|
32 |
+
task :test => [:unit, :integration]
|
33 |
+
|
34 |
+
desc "run unit tests under HHVM"
|
35 |
+
task :unit => :version do
|
36 |
+
run_php_test_suite("hhvm", "unit")
|
37 |
+
end
|
38 |
+
|
39 |
+
desc "run integration tests under HHVM"
|
40 |
+
task :integration do
|
41 |
+
run_php_test_suite("hhvm", "integration")
|
42 |
+
end
|
43 |
+
end
|
44 |
+
|
45 |
+
desc "run tests under PHP"
|
46 |
+
task :php => %w[php:unit php:integration]
|
47 |
+
|
48 |
+
desc "run tests under HHVM"
|
49 |
+
task :hhvm => %w[hhvm:unit hhvm:integration]
|
50 |
+
|
51 |
+
desc "run a single test file"
|
52 |
+
task :file, :file_path do |t, args|
|
53 |
+
run_php_test_file(args[:file_path])
|
54 |
+
end
|
55 |
+
|
56 |
+
desc "run a single test"
|
57 |
+
task :single, :test_name do |t, args|
|
58 |
+
run_php_test(args[:test_name])
|
59 |
+
end
|
60 |
+
end
|
61 |
+
|
62 |
+
desc "update the copyright year"
|
63 |
+
task :copyright, :from_year, :to_year do |t, args|
|
64 |
+
sh "find tests lib -type f -name '*.php' -exec sed -i 's/#{args[:from_year]} Braintree/#{args[:to_year]} Braintree/g' {} +"
|
65 |
+
end
|
66 |
+
|
67 |
+
def print_php_version(interpreter)
|
68 |
+
sh "#{interpreter} --version"
|
69 |
+
end
|
70 |
+
|
71 |
+
def run_php_test_suite(interpreter, test_suite)
|
72 |
+
sh "#{interpreter} ./vendor/bin/phpunit --testsuite #{test_suite}"
|
73 |
+
end
|
74 |
+
|
75 |
+
def run_php_test_file(test_file)
|
76 |
+
sh "./vendor/bin/phpunit #{test_file}"
|
77 |
+
end
|
78 |
+
|
79 |
+
def run_php_test(test_name)
|
80 |
+
sh "./vendor/bin/phpunit --filter #{test_name}"
|
81 |
+
end
|
includes/lib/Braintree/ci.sh
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
curl -sS https://getcomposer.org/installer | php -d suhosin.executor.include.whitelist=phar
|
4 |
+
|
5 |
+
php -d suhosin.executor.include.whitelist=phar ./composer.phar install
|
6 |
+
|
7 |
+
if [ "$1" == "hhvm" ]; then
|
8 |
+
rake test:hhvm --trace
|
9 |
+
else
|
10 |
+
rake test:php --trace
|
11 |
+
fi
|
includes/lib/Braintree/composer.json
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "braintree/braintree_php",
|
3 |
+
"type": "library",
|
4 |
+
"description": "Braintree PHP Client Library",
|
5 |
+
"license": "MIT",
|
6 |
+
"authors": [
|
7 |
+
{
|
8 |
+
"name": "Braintree",
|
9 |
+
"homepage": "http://www.braintreepayments.com"
|
10 |
+
}
|
11 |
+
],
|
12 |
+
"require": {
|
13 |
+
"php": ">=5.4.0",
|
14 |
+
"ext-curl": "*",
|
15 |
+
"ext-dom": "*",
|
16 |
+
"ext-hash": "*",
|
17 |
+
"ext-openssl": "*",
|
18 |
+
"ext-xmlwriter": "*"
|
19 |
+
},
|
20 |
+
"require-dev": {
|
21 |
+
"phpunit/phpunit": "3.7.*"
|
22 |
+
},
|
23 |
+
"autoload": {
|
24 |
+
"psr-0": {
|
25 |
+
"Braintree": "lib/"
|
26 |
+
},
|
27 |
+
"psr-4": {
|
28 |
+
"Braintree\\": "lib/Braintree"
|
29 |
+
}
|
30 |
+
},
|
31 |
+
"autoload-dev": {
|
32 |
+
"psr-4": {
|
33 |
+
"Test\\": "tests"
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
includes/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();
|
includes/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');
|
includes/lib/Braintree/lib/Braintree/AchMandate.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Braintree;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Braintree AchMandate module
|
6 |
+
* PHP Version 5
|
7 |
+
*
|
8 |
+
* @package Braintree
|
9 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
10 |
+
*
|
11 |
+
* @property-read string $text
|
12 |
+
* @property-read string $acceptedAt
|
13 |
+
*/
|
14 |
+
class AchMandate extends Base
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* create a printable representation of the object as:
|
18 |
+
* ClassName[property=value, property=value]
|
19 |
+
* @ignore
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function __toString()
|
23 |
+
{
|
24 |
+
return __CLASS__ . '[' .
|
25 |
+
Util::attributesToString($this->_attributes) . ']';
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* sets instance properties from an array of values
|
30 |
+
*
|
31 |
+
* @ignore
|
32 |
+
* @access protected
|
33 |
+
* @param array $achAttribs array of achMandate data
|
34 |
+
* @return void
|
35 |
+
*/
|
36 |
+
protected function _initialize($achAttribs)
|
37 |
+
{
|
38 |
+
// set the attributes
|
39 |
+
$this->_attributes = $achAttribs;
|
40 |
+
$date = new \DateTime($this->acceptedAt);
|
41 |
+
$this->_set('acceptedAt', $date);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* factory method: returns an instance of AchMandate
|
46 |
+
* to the requesting method, with populated properties
|
47 |
+
* @ignore
|
48 |
+
* @return AchMandate
|
49 |
+
*/
|
50 |
+
public static function factory($attributes)
|
51 |
+
{
|
52 |
+
$instance = new self();
|
53 |
+
$instance->_initialize($attributes);
|
54 |
+
return $instance;
|
55 |
+
|
56 |
+
}
|
57 |
+
}
|
58 |
+
class_alias('Braintree\AchMandate', 'Braintree_Mandate');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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 |
+
}
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Collection.php
RENAMED
@@ -1,30 +1,32 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* Braintree Generic collection
|
4 |
*
|
5 |
* PHP Version 5
|
6 |
*
|
7 |
-
* @package Braintree
|
8 |
-
* @subpackage Utility
|
9 |
-
* @copyright 2010 Braintree Payment Solutions
|
10 |
-
*/
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Generic Collection class
|
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 |
*/
|
21 |
-
|
|
|
22 |
{
|
23 |
/**
|
24 |
*
|
25 |
-
* @var array
|
26 |
*/
|
27 |
-
protected $_collection =
|
28 |
|
29 |
/**
|
30 |
* Add a value into the collection
|
@@ -157,3 +159,4 @@ class Braintree_Collection implements Countable, IteratorAggregate, ArrayAccess
|
|
157 |
}
|
158 |
|
159 |
}
|
|
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
|
159 |
}
|
160 |
|
161 |
}
|
162 |
+
class_alias('Braintree\Collection', 'Braintree_Collection');
|
includes/lib/Braintree/lib/Braintree/Configuration.php
ADDED
@@ -0,0 +1,578 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
private $_sslVersion = null;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Braintree API version to use
|
34 |
+
* @access public
|
35 |
+
*/
|
36 |
+
const API_VERSION = 4;
|
37 |
+
|
38 |
+
public function __construct($attribs = [])
|
39 |
+
{
|
40 |
+
foreach ($attribs as $kind => $value) {
|
41 |
+
if ($kind == 'environment') {
|
42 |
+
CredentialsParser::assertValidEnvironment($value);
|
43 |
+
$this->_environment = $value;
|
44 |
+
}
|
45 |
+
if ($kind == 'merchantId') {
|
46 |
+
$this->_merchantId = $value;
|
47 |
+
}
|
48 |
+
if ($kind == 'publicKey') {
|
49 |
+
$this->_publicKey = $value;
|
50 |
+
}
|
51 |
+
if ($kind == 'privateKey') {
|
52 |
+
$this->_privateKey = $value;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
if (isset($attribs['clientId']) || isset($attribs['accessToken'])) {
|
57 |
+
if (isset($attribs['environment']) || isset($attribs['merchantId']) || isset($attribs['publicKey']) || isset($attribs['privateKey'])) {
|
58 |
+
throw new Exception\Configuration('Cannot mix OAuth credentials (clientId, clientSecret, accessToken) with key credentials (publicKey, privateKey, environment, merchantId).');
|
59 |
+
}
|
60 |
+
$parsedCredentials = new CredentialsParser($attribs);
|
61 |
+
|
62 |
+
$this->_environment = $parsedCredentials->getEnvironment();
|
63 |
+
$this->_merchantId = $parsedCredentials->getMerchantId();
|
64 |
+
$this->_clientId = $parsedCredentials->getClientId();
|
65 |
+
$this->_clientSecret = $parsedCredentials->getClientSecret();
|
66 |
+
$this->_accessToken = $parsedCredentials->getAccessToken();
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* resets configuration to default
|
72 |
+
* @access public
|
73 |
+
*/
|
74 |
+
public static function reset()
|
75 |
+
{
|
76 |
+
self::$global = new Configuration();
|
77 |
+
}
|
78 |
+
|
79 |
+
public static function gateway()
|
80 |
+
{
|
81 |
+
return new Gateway(self::$global);
|
82 |
+
}
|
83 |
+
|
84 |
+
public static function environment($value=null)
|
85 |
+
{
|
86 |
+
if (empty($value)) {
|
87 |
+
return self::$global->getEnvironment();
|
88 |
+
}
|
89 |
+
CredentialsParser::assertValidEnvironment($value);
|
90 |
+
self::$global->setEnvironment($value);
|
91 |
+
}
|
92 |
+
|
93 |
+
public static function merchantId($value=null)
|
94 |
+
{
|
95 |
+
if (empty($value)) {
|
96 |
+
return self::$global->getMerchantId();
|
97 |
+
}
|
98 |
+
self::$global->setMerchantId($value);
|
99 |
+
}
|
100 |
+
|
101 |
+
public static function publicKey($value=null)
|
102 |
+
{
|
103 |
+
if (empty($value)) {
|
104 |
+
return self::$global->getPublicKey();
|
105 |
+
}
|
106 |
+
self::$global->setPublicKey($value);
|
107 |
+
}
|
108 |
+
|
109 |
+
public static function privateKey($value=null)
|
110 |
+
{
|
111 |
+
if (empty($value)) {
|
112 |
+
return self::$global->getPrivateKey();
|
113 |
+
}
|
114 |
+
self::$global->setPrivateKey($value);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Sets or gets the read timeout to use for making requests.
|
119 |
+
*
|
120 |
+
* @param integer $value If provided, sets the read timeout
|
121 |
+
* @return integer The read timeout used for connecting to Braintree
|
122 |
+
*/
|
123 |
+
public static function timeout($value=null)
|
124 |
+
{
|
125 |
+
if (empty($value)) {
|
126 |
+
return self::$global->getTimeout();
|
127 |
+
}
|
128 |
+
self::$global->setTimeout($value);
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Sets or gets the SSL version to use for making requests. See
|
133 |
+
* http://php.net/manual/en/function.curl-setopt.php for possible
|
134 |
+
* CURLOPT_SSLVERSION values.
|
135 |
+
*
|
136 |
+
* @param integer $value If provided, sets the SSL version
|
137 |
+
* @return integer The SSL version used for connecting to Braintree
|
138 |
+
*/
|
139 |
+
public static function sslVersion($value=null)
|
140 |
+
{
|
141 |
+
if (empty($value)) {
|
142 |
+
return self::$global->getSslVersion();
|
143 |
+
}
|
144 |
+
self::$global->setSslVersion($value);
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Sets or gets the proxy host to use for connecting to Braintree
|
149 |
+
*
|
150 |
+
* @param string $value If provided, sets the proxy host
|
151 |
+
* @return string The proxy host used for connecting to Braintree
|
152 |
+
*/
|
153 |
+
public static function proxyHost($value = null)
|
154 |
+
{
|
155 |
+
if (empty($value)) {
|
156 |
+
return self::$global->getProxyHost();
|
157 |
+
}
|
158 |
+
self::$global->setProxyHost($value);
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Sets or gets the port of the proxy to use for connecting to Braintree
|
163 |
+
*
|
164 |
+
* @param string $value If provided, sets the port of the proxy
|
165 |
+
* @return string The port of the proxy used for connecting to Braintree
|
166 |
+
*/
|
167 |
+
public static function proxyPort($value = null)
|
168 |
+
{
|
169 |
+
if (empty($value)) {
|
170 |
+
return self::$global->getProxyPort();
|
171 |
+
}
|
172 |
+
self::$global->setProxyPort($value);
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Sets or gets the proxy type to use for connecting to Braintree. This value
|
177 |
+
* can be any of the CURLOPT_PROXYTYPE options in PHP cURL.
|
178 |
+
*
|
179 |
+
* @param string $value If provided, sets the proxy type
|
180 |
+
* @return string The proxy type used for connecting to Braintree
|
181 |
+
*/
|
182 |
+
public static function proxyType($value = null)
|
183 |
+
{
|
184 |
+
if (empty($value)) {
|
185 |
+
return self::$global->getProxyType();
|
186 |
+
}
|
187 |
+
self::$global->setProxyType($value);
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Specifies whether or not a proxy is properly configured
|
192 |
+
*
|
193 |
+
* @return bool true if a proxy is configured properly, false if not
|
194 |
+
*/
|
195 |
+
public static function isUsingProxy()
|
196 |
+
{
|
197 |
+
$proxyHost = self::$global->getProxyHost();
|
198 |
+
$proxyPort = self::$global->getProxyPort();
|
199 |
+
return !empty($proxyHost) && !empty($proxyPort);
|
200 |
+
}
|
201 |
+
|
202 |
+
public static function proxyUser($value = null)
|
203 |
+
{
|
204 |
+
if (empty($value)) {
|
205 |
+
return self::$global->getProxyUser();
|
206 |
+
}
|
207 |
+
self::$global->setProxyUser($value);
|
208 |
+
}
|
209 |
+
|
210 |
+
public static function proxyPassword($value = null)
|
211 |
+
{
|
212 |
+
if (empty($value)) {
|
213 |
+
return self::$global->getProxyPassword();
|
214 |
+
}
|
215 |
+
self::$global->setProxyPassword($value);
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Specified whether or not a username and password have been provided for
|
220 |
+
* use with an authenticated proxy
|
221 |
+
*
|
222 |
+
* @return bool true if both proxyUser and proxyPassword are present
|
223 |
+
*/
|
224 |
+
public static function isAuthenticatedProxy()
|
225 |
+
{
|
226 |
+
$proxyUser = self::$global->getProxyUser();
|
227 |
+
$proxyPwd = self::$global->getProxyPassword();
|
228 |
+
return !empty($proxyUser) && !empty($proxyPwd);
|
229 |
+
}
|
230 |
+
|
231 |
+
public static function assertGlobalHasAccessTokenOrKeys()
|
232 |
+
{
|
233 |
+
self::$global->assertHasAccessTokenOrKeys();
|
234 |
+
}
|
235 |
+
|
236 |
+
public function assertHasAccessTokenOrKeys()
|
237 |
+
{
|
238 |
+
if (empty($this->_accessToken)) {
|
239 |
+
if (empty($this->_merchantId)) {
|
240 |
+
throw new Exception\Configuration('Braintree\\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\\Gateway).');
|
241 |
+
} else if (empty($this->_environment)) {
|
242 |
+
throw new Exception\Configuration('Braintree\\Configuration::environment needs to be set.');
|
243 |
+
} else if (empty($this->_publicKey)) {
|
244 |
+
throw new Exception\Configuration('Braintree\\Configuration::publicKey needs to be set.');
|
245 |
+
} else if (empty($this->_privateKey)) {
|
246 |
+
throw new Exception\Configuration('Braintree\\Configuration::privateKey needs to be set.');
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
public function assertHasClientCredentials()
|
252 |
+
{
|
253 |
+
$this->assertHasClientId();
|
254 |
+
$this->assertHasClientSecret();
|
255 |
+
}
|
256 |
+
|
257 |
+
public function assertHasClientId()
|
258 |
+
{
|
259 |
+
if (empty($this->_clientId)) {
|
260 |
+
throw new Exception\Configuration('clientId needs to be passed to Braintree\\Gateway.');
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
public function assertHasClientSecret()
|
265 |
+
{
|
266 |
+
if (empty($this->_clientSecret)) {
|
267 |
+
throw new Exception\Configuration('clientSecret needs to be passed to Braintree\\Gateway.');
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
public function getEnvironment()
|
272 |
+
{
|
273 |
+
return $this->_environment;
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Do not use this method directly. Pass in the environment to the constructor.
|
278 |
+
*/
|
279 |
+
public function setEnvironment($value)
|
280 |
+
{
|
281 |
+
$this->_environment = $value;
|
282 |
+
}
|
283 |
+
|
284 |
+
public function getMerchantId()
|
285 |
+
{
|
286 |
+
return $this->_merchantId;
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Do not use this method directly. Pass in the merchantId to the constructor.
|
291 |
+
*/
|
292 |
+
public function setMerchantId($value)
|
293 |
+
{
|
294 |
+
$this->_merchantId = $value;
|
295 |
+
}
|
296 |
+
|
297 |
+
public function getPublicKey()
|
298 |
+
{
|
299 |
+
return $this->_publicKey;
|
300 |
+
}
|
301 |
+
|
302 |
+
public function getClientId()
|
303 |
+
{
|
304 |
+
return $this->_clientId;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Do not use this method directly. Pass in the publicKey to the constructor.
|
309 |
+
*/
|
310 |
+
public function setPublicKey($value)
|
311 |
+
{
|
312 |
+
$this->_publicKey = $value;
|
313 |
+
}
|
314 |
+
|
315 |
+
public function getPrivateKey()
|
316 |
+
{
|
317 |
+
return $this->_privateKey;
|
318 |
+
}
|
319 |
+
|
320 |
+
public function getClientSecret()
|
321 |
+
{
|
322 |
+
return $this->_clientSecret;
|
323 |
+
}
|
324 |
+
|
325 |
+
/**
|
326 |
+
* Do not use this method directly. Pass in the privateKey to the constructor.
|
327 |
+
*/
|
328 |
+
public function setPrivateKey($value)
|
329 |
+
{
|
330 |
+
$this->_privateKey = $value;
|
331 |
+
}
|
332 |
+
|
333 |
+
private function setProxyHost($value)
|
334 |
+
{
|
335 |
+
$this->_proxyHost = $value;
|
336 |
+
}
|
337 |
+
|
338 |
+
public function getProxyHost()
|
339 |
+
{
|
340 |
+
return $this->_proxyHost;
|
341 |
+
}
|
342 |
+
|
343 |
+
private function setProxyPort($value)
|
344 |
+
{
|
345 |
+
$this->_proxyPort = $value;
|
346 |
+
}
|
347 |
+
|
348 |
+
public function getProxyPort()
|
349 |
+
{
|
350 |
+
return $this->_proxyPort;
|
351 |
+
}
|
352 |
+
|
353 |
+
private function setProxyType($value)
|
354 |
+
{
|
355 |
+
$this->_proxyType = $value;
|
356 |
+
}
|
357 |
+
|
358 |
+
public function getProxyType()
|
359 |
+
{
|
360 |
+
return $this->_proxyType;
|
361 |
+
}
|
362 |
+
|
363 |
+
private function setProxyUser($value)
|
364 |
+
{
|
365 |
+
$this->_proxyUser = $value;
|
366 |
+
}
|
367 |
+
|
368 |
+
public function getProxyUser()
|
369 |
+
{
|
370 |
+
return $this->_proxyUser;
|
371 |
+
}
|
372 |
+
|
373 |
+
private function setProxyPassword($value)
|
374 |
+
{
|
375 |
+
$this->_proxyPassword = $value;
|
376 |
+
}
|
377 |
+
|
378 |
+
public function getProxyPassword()
|
379 |
+
{
|
380 |
+
return $this->_proxyPassword;
|
381 |
+
}
|
382 |
+
|
383 |
+
private function setTimeout($value)
|
384 |
+
{
|
385 |
+
$this->_timeout = $value;
|
386 |
+
}
|
387 |
+
|
388 |
+
public function getTimeout()
|
389 |
+
{
|
390 |
+
return $this->_timeout;
|
391 |
+
}
|
392 |
+
|
393 |
+
private function setSslVersion($value)
|
394 |
+
{
|
395 |
+
$this->_sslVersion = $value;
|
396 |
+
}
|
397 |
+
|
398 |
+
private function getSslVersion()
|
399 |
+
{
|
400 |
+
return $this->_sslVersion;
|
401 |
+
}
|
402 |
+
|
403 |
+
public function getAccessToken()
|
404 |
+
{
|
405 |
+
return $this->_accessToken;
|
406 |
+
}
|
407 |
+
|
408 |
+
public function isAccessToken()
|
409 |
+
{
|
410 |
+
return !empty($this->_accessToken);
|
411 |
+
}
|
412 |
+
|
413 |
+
public function isClientCredentials()
|
414 |
+
{
|
415 |
+
return !empty($this->_clientId);
|
416 |
+
}
|
417 |
+
/**
|
418 |
+
* returns the base braintree gateway URL based on config values
|
419 |
+
*
|
420 |
+
* @access public
|
421 |
+
* @param none
|
422 |
+
* @return string braintree gateway URL
|
423 |
+
*/
|
424 |
+
public function baseUrl()
|
425 |
+
{
|
426 |
+
return sprintf('%s://%s:%d', $this->protocol(), $this->serverName(), $this->portNumber());
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* sets the merchant path based on merchant ID
|
431 |
+
*
|
432 |
+
* @access protected
|
433 |
+
* @param none
|
434 |
+
* @return string merchant path uri
|
435 |
+
*/
|
436 |
+
public function merchantPath()
|
437 |
+
{
|
438 |
+
return '/merchants/' . $this->_merchantId;
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
+
* sets the physical path for the location of the CA certs
|
443 |
+
*
|
444 |
+
* @access public
|
445 |
+
* @param none
|
446 |
+
* @return string filepath
|
447 |
+
*/
|
448 |
+
public function caFile($sslPath = NULL)
|
449 |
+
{
|
450 |
+
$sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .
|
451 |
+
'ssl' . DIRECTORY_SEPARATOR;
|
452 |
+
$caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt';
|
453 |
+
|
454 |
+
if (!file_exists($caPath))
|
455 |
+
{
|
456 |
+
throw new Exception\SSLCaFileNotFound();
|
457 |
+
}
|
458 |
+
|
459 |
+
return $caPath;
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* returns the port number depending on environment
|
464 |
+
*
|
465 |
+
* @access public
|
466 |
+
* @param none
|
467 |
+
* @return int portnumber
|
468 |
+
*/
|
469 |
+
public function portNumber()
|
470 |
+
{
|
471 |
+
if ($this->sslOn()) {
|
472 |
+
return 443;
|
473 |
+
}
|
474 |
+
return getenv("GATEWAY_PORT") ? getenv("GATEWAY_PORT") : 3000;
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* returns http protocol depending on environment
|
479 |
+
*
|
480 |
+
* @access public
|
481 |
+
* @param none
|
482 |
+
* @return string http || https
|
483 |
+
*/
|
484 |
+
public function protocol()
|
485 |
+
{
|
486 |
+
return $this->sslOn() ? 'https' : 'http';
|
487 |
+
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
* returns gateway server name depending on environment
|
491 |
+
*
|
492 |
+
* @access public
|
493 |
+
* @param none
|
494 |
+
* @return string server domain name
|
495 |
+
*/
|
496 |
+
public function serverName()
|
497 |
+
{
|
498 |
+
switch($this->_environment) {
|
499 |
+
case 'production':
|
500 |
+
$serverName = 'api.braintreegateway.com';
|
501 |
+
break;
|
502 |
+
case 'qa':
|
503 |
+
$serverName = 'gateway.qa.braintreepayments.com';
|
504 |
+
break;
|
505 |
+
case 'sandbox':
|
506 |
+
$serverName = 'api.sandbox.braintreegateway.com';
|
507 |
+
break;
|
508 |
+
case 'development':
|
509 |
+
case 'integration':
|
510 |
+
default:
|
511 |
+
$serverName = 'localhost';
|
512 |
+
break;
|
513 |
+
}
|
514 |
+
|
515 |
+
return $serverName;
|
516 |
+
}
|
517 |
+
|
518 |
+
public function authUrl()
|
519 |
+
{
|
520 |
+
switch($this->_environment) {
|
521 |
+
case 'production':
|
522 |
+
$serverName = 'https://auth.venmo.com';
|
523 |
+
break;
|
524 |
+
case 'qa':
|
525 |
+
$serverName = 'https://auth.qa.venmo.com';
|
526 |
+
break;
|
527 |
+
case 'sandbox':
|
528 |
+
$serverName = 'https://auth.sandbox.venmo.com';
|
529 |
+
break;
|
530 |
+
case 'development':
|
531 |
+
case 'integration':
|
532 |
+
default:
|
533 |
+
$serverName = 'http://auth.venmo.dev:9292';
|
534 |
+
break;
|
535 |
+
}
|
536 |
+
|
537 |
+
return $serverName;
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* returns boolean indicating SSL is on or off for this session,
|
542 |
+
* depending on environment
|
543 |
+
*
|
544 |
+
* @access public
|
545 |
+
* @param none
|
546 |
+
* @return boolean
|
547 |
+
*/
|
548 |
+
public function sslOn()
|
549 |
+
{
|
550 |
+
switch($this->_environment) {
|
551 |
+
case 'integration':
|
552 |
+
case 'development':
|
553 |
+
$ssl = false;
|
554 |
+
break;
|
555 |
+
case 'production':
|
556 |
+
case 'qa':
|
557 |
+
case 'sandbox':
|
558 |
+
default:
|
559 |
+
$ssl = true;
|
560 |
+
break;
|
561 |
+
}
|
562 |
+
|
563 |
+
return $ssl;
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* log message to default logger
|
568 |
+
*
|
569 |
+
* @param string $message
|
570 |
+
*
|
571 |
+
*/
|
572 |
+
public function logMessage($message)
|
573 |
+
{
|
574 |
+
error_log('[Braintree] ' . $message);
|
575 |
+
}
|
576 |
+
}
|
577 |
+
Configuration::reset();
|
578 |
+
class_alias('Braintree\Configuration', 'Braintree_Configuration');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Digest.php
RENAMED
@@ -1,26 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
* Digest encryption module
|
4 |
-
*
|
5 |
-
* @copyright 2010 Braintree Payment Solutions
|
6 |
-
*/
|
7 |
|
8 |
/**
|
|
|
9 |
* Digest creates an HMAC-SHA1 hash for encrypting messages
|
10 |
*
|
11 |
-
* @copyright
|
12 |
*/
|
13 |
-
class
|
14 |
{
|
15 |
-
public static function
|
16 |
{
|
17 |
if(function_exists('hash_hmac')) {
|
18 |
-
return self::_builtInHmacSha1($string,
|
19 |
} else {
|
20 |
-
return self::_hmacSha1($string,
|
21 |
}
|
22 |
}
|
23 |
|
|
|
|
|
|
|
|
|
|
|
24 |
public static function secureCompare($left, $right)
|
25 |
{
|
26 |
if (strlen($left) != strlen($right)) {
|
@@ -31,15 +33,15 @@ class Braintree_Digest
|
|
31 |
$rightBytes = unpack("C*", $right);
|
32 |
|
33 |
$result = 0;
|
34 |
-
for ($i =
|
35 |
-
$result = $result | ($
|
36 |
}
|
37 |
return $result == 0;
|
38 |
}
|
39 |
|
40 |
public static function _builtInHmacSha1($message, $key)
|
41 |
{
|
42 |
-
return hash_hmac('sha1', $message, sha1(
|
43 |
}
|
44 |
|
45 |
public static function _hmacSha1($message, $key)
|
@@ -57,3 +59,4 @@ class Braintree_Digest
|
|
57 |
return sha1($outerPad.pack($pack, sha1($innerPad.$message)));
|
58 |
}
|
59 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree;
|
|
|
|
|
|
|
|
|
3 |
|
4 |
/**
|
5 |
+
* Digest encryption module
|
6 |
* Digest creates an HMAC-SHA1 hash for encrypting messages
|
7 |
*
|
8 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
9 |
*/
|
10 |
+
class Digest
|
11 |
{
|
12 |
+
public static function hexDigestSha1($key, $string)
|
13 |
{
|
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)) {
|
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)
|
59 |
return sha1($outerPad.pack($pack, sha1($innerPad.$message)));
|
60 |
}
|
61 |
}
|
62 |
+
class_alias('Braintree\Digest', 'Braintree_Digest');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/EqualityNode.php
RENAMED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
function isNot($value)
|
6 |
{
|
@@ -8,3 +9,4 @@ class Braintree_EqualityNode extends Braintree_IsNode
|
|
8 |
return $this;
|
9 |
}
|
10 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree;
|
3 |
|
4 |
+
class EqualityNode extends IsNode
|
5 |
{
|
6 |
function isNot($value)
|
7 |
{
|
9 |
return $this;
|
10 |
}
|
11 |
}
|
12 |
+
class_alias('Braintree\EqualityNode', 'Braintree_EqualityNode');
|
includes/lib/Braintree/lib/Braintree/Error/Codes.php
ADDED
@@ -0,0 +1,529 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
const MERCHANT_MERCHANT_ACCOUNT_EXISTS_FOR_CURRENCY = '93616';
|
200 |
+
const MERCHANT_CURRENCY_IS_REQUIRED = '93617';
|
201 |
+
const MERCHANT_CURRENCY_IS_INVALID = '93618';
|
202 |
+
const MERCHANT_NO_MERCHANT_ACCOUNTS = '93619';
|
203 |
+
const MERCHANT_MERCHANT_ACCOUNT_EXISTS_FOR_ID = '93620';
|
204 |
+
const MERCHANT_MERCHANT_ACCOUNT_NOT_AUTH_ONBOARDED = '93621';
|
205 |
+
|
206 |
+
const MERCHANT_ACCOUNT_ID_FORMAT_IS_INVALID = '82603';
|
207 |
+
const MERCHANT_ACCOUNT_ID_IS_IN_USE = '82604';
|
208 |
+
const MERCHANT_ACCOUNT_ID_IS_NOT_ALLOWED = '82605';
|
209 |
+
const MERCHANT_ACCOUNT_ID_IS_TOO_LONG = '82602';
|
210 |
+
const MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_IS_INVALID = '82607';
|
211 |
+
const MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_IS_REQUIRED = '82606';
|
212 |
+
const MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_MUST_BE_ACTIVE = '82608';
|
213 |
+
const MERCHANT_ACCOUNT_TOS_ACCEPTED_IS_REQUIRED = '82610';
|
214 |
+
const MERCHANT_ACCOUNT_CANNOT_BE_UPDATED = '82674';
|
215 |
+
const MERCHANT_ACCOUNT_DECLINED = '82626';
|
216 |
+
const MERCHANT_ACCOUNT_DECLINED_MASTER_CARD_MATCH = '82622';
|
217 |
+
const MERCHANT_ACCOUNT_DECLINED_OFAC = '82621';
|
218 |
+
const MERCHANT_ACCOUNT_DECLINED_FAILED_KYC = '82623';
|
219 |
+
const MERCHANT_ACCOUNT_DECLINED_SSN_INVALID = '82624';
|
220 |
+
const MERCHANT_ACCOUNT_DECLINED_SSN_MATCHES_DECEASED = '82625';
|
221 |
+
const MERCHANT_ACCOUNT_ID_CANNOT_BE_UPDATED = '82675';
|
222 |
+
const MERCHANT_ACCOUNT_MASTER_MERCHANT_ACCOUNT_ID_CANNOT_BE_UPDATED = '82676';
|
223 |
+
|
224 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ACCOUNT_NUMBER_IS_REQUIRED = '82614';
|
225 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_COMPANY_NAME_IS_INVALID = '82631';
|
226 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_COMPANY_NAME_IS_REQUIRED_WITH_TAX_ID = '82633';
|
227 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DATE_OF_BIRTH_IS_REQUIRED = '82612';
|
228 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED = '82626'; // Keep for backwards compatibility
|
229 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_MASTER_CARD_MATCH = '82622'; // Keep for backwards compatibility
|
230 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_OFAC = '82621'; // Keep for backwards compatibility
|
231 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_FAILED_KYC = '82623'; // Keep for backwards compatibility
|
232 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_SSN_INVALID = '82624'; // Keep for backwards compatibility
|
233 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DECLINED_SSN_MATCHES_DECEASED = '82625'; // Keep for backwards compatibility
|
234 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_EMAIL_ADDRESS_IS_INVALID = '82616';
|
235 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_FIRST_NAME_IS_INVALID = '82627';
|
236 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_FIRST_NAME_IS_REQUIRED = '82609';
|
237 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_LAST_NAME_IS_INVALID = '82628';
|
238 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_LAST_NAME_IS_REQUIRED = '82611';
|
239 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_PHONE_IS_INVALID = '82636';
|
240 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ROUTING_NUMBER_IS_INVALID = '82635';
|
241 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ROUTING_NUMBER_IS_REQUIRED = '82613';
|
242 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_SSN_IS_INVALID = '82615';
|
243 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_TAX_ID_IS_INVALID = '82632';
|
244 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_TAX_ID_IS_REQUIRED_WITH_COMPANY_NAME = '82634';
|
245 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_DATE_OF_BIRTH_IS_INVALID = '82663';
|
246 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_REGION_IS_INVALID = '82664';
|
247 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_EMAIL_ADDRESS_IS_REQUIRED = '82665';
|
248 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ACCOUNT_NUMBER_IS_INVALID = '82670';
|
249 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_TAX_ID_MUST_BE_BLANK = '82673';
|
250 |
+
|
251 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_LOCALITY_IS_REQUIRED = '82618';
|
252 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_POSTAL_CODE_IS_INVALID = '82630';
|
253 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_POSTAL_CODE_IS_REQUIRED = '82619';
|
254 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_REGION_IS_REQUIRED = '82620';
|
255 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_STREET_ADDRESS_IS_INVALID = '82629';
|
256 |
+
const MERCHANT_ACCOUNT_APPLICANT_DETAILS_ADDRESS_STREET_ADDRESS_IS_REQUIRED = '82617';
|
257 |
+
|
258 |
+
const MERCHANT_ACCOUNT_BUSINESS_DBA_NAME_IS_INVALID = '82646';
|
259 |
+
const MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_INVALID = '82647';
|
260 |
+
const MERCHANT_ACCOUNT_BUSINESS_TAX_ID_IS_REQUIRED_WITH_LEGAL_NAME = '82648';
|
261 |
+
const MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_REQUIRED_WITH_TAX_ID = '82669';
|
262 |
+
const MERCHANT_ACCOUNT_BUSINESS_TAX_ID_MUST_BE_BLANK = '82672';
|
263 |
+
const MERCHANT_ACCOUNT_BUSINESS_LEGAL_NAME_IS_INVALID = '82677';
|
264 |
+
const MERCHANT_ACCOUNT_BUSINESS_ADDRESS_REGION_IS_INVALID = '82684';
|
265 |
+
const MERCHANT_ACCOUNT_BUSINESS_ADDRESS_STREET_ADDRESS_IS_INVALID = '82685';
|
266 |
+
const MERCHANT_ACCOUNT_BUSINESS_ADDRESS_POSTAL_CODE_IS_INVALID = '82686';
|
267 |
+
|
268 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_REQUIRED = '82637';
|
269 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_REQUIRED = '82638';
|
270 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_DATE_OF_BIRTH_IS_REQUIRED = '82639';
|
271 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_SSN_IS_INVALID = '82642';
|
272 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_INVALID = '82643';
|
273 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_FIRST_NAME_IS_INVALID = '82644';
|
274 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_LAST_NAME_IS_INVALID = '82645';
|
275 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_PHONE_IS_INVALID = '82656';
|
276 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_DATE_OF_BIRTH_IS_INVALID = '82666';
|
277 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_EMAIL_IS_REQUIRED = '82667';
|
278 |
+
|
279 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_REQUIRED = '82657';
|
280 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_LOCALITY_IS_REQUIRED = '82658';
|
281 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_REQUIRED = '82659';
|
282 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_REQUIRED = '82660';
|
283 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_STREET_ADDRESS_IS_INVALID = '82661';
|
284 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_POSTAL_CODE_IS_INVALID = '82662';
|
285 |
+
const MERCHANT_ACCOUNT_INDIVIDUAL_ADDRESS_REGION_IS_INVALID = '82668';
|
286 |
+
|
287 |
+
const MERCHANT_ACCOUNT_FUNDING_ROUTING_NUMBER_IS_REQUIRED = '82640';
|
288 |
+
const MERCHANT_ACCOUNT_FUNDING_ACCOUNT_NUMBER_IS_REQUIRED = '82641';
|
289 |
+
const MERCHANT_ACCOUNT_FUNDING_ROUTING_NUMBER_IS_INVALID = '82649';
|
290 |
+
const MERCHANT_ACCOUNT_FUNDING_ACCOUNT_NUMBER_IS_INVALID = '82671';
|
291 |
+
const MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_REQUIRED = '82678';
|
292 |
+
const MERCHANT_ACCOUNT_FUNDING_DESTINATION_IS_INVALID = '82679';
|
293 |
+
const MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_REQUIRED = '82680';
|
294 |
+
const MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_INVALID = '82681';
|
295 |
+
const MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_REQUIRED = '82682';
|
296 |
+
const MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_INVALID = '82683';
|
297 |
+
|
298 |
+
const OAUTH_INVALID_GRANT = '93801';
|
299 |
+
const OAUTH_INVALID_CREDENTIALS = '93802';
|
300 |
+
const OAUTH_INVALID_SCOPE = '93803';
|
301 |
+
const OAUTH_INVALID_REQUEST = '93804';
|
302 |
+
const OAUTH_UNSUPPORTED_GRANT_TYPE = '93805';
|
303 |
+
|
304 |
+
const PAYMENT_METHOD_CANNOT_FORWARD_PAYMENT_METHOD_TYPE = '93106';
|
305 |
+
const PAYMENT_METHOD_CUSTOMER_ID_IS_INVALID = '93105';
|
306 |
+
const PAYMENT_METHOD_CUSTOMER_ID_IS_REQUIRED = '93104';
|
307 |
+
const PAYMENT_METHOD_NONCE_IS_INVALID = '93102';
|
308 |
+
const PAYMENT_METHOD_NONCE_IS_REQUIRED = '93103';
|
309 |
+
const PAYMENT_METHOD_PAYMENT_METHOD_NONCE_CONSUMED = '93107';
|
310 |
+
const PAYMENT_METHOD_PAYMENT_METHOD_NONCE_UNKNOWN = '93108';
|
311 |
+
const PAYMENT_METHOD_PAYMENT_METHOD_NONCE_LOCKED = '93109';
|
312 |
+
const PAYMENT_METHOD_PAYMENT_METHOD_PARAMS_ARE_REQUIRED = '93101';
|
313 |
+
|
314 |
+
const PAYPAL_ACCOUNT_AUTH_EXPIRED = '92911';
|
315 |
+
const PAYPAL_ACCOUNT_CANNOT_HAVE_BOTH_ACCESS_TOKEN_AND_CONSENT_CODE = '82903';
|
316 |
+
const PAYPAL_ACCOUNT_CANNOT_HAVE_FUNDING_SOURCE_WITHOUT_ACCESS_TOKEN = '92912';
|
317 |
+
const PAYPAL_ACCOUNT_CANNOT_UPDATE_PAYPAL_ACCOUNT_USING_PAYMENT_METHOD_NONCE = '92914';
|
318 |
+
const PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT = '82902';
|
319 |
+
const PAYPAL_ACCOUNT_CONSENT_CODE_OR_ACCESS_TOKEN_IS_REQUIRED = '82901';
|
320 |
+
const PAYPAL_ACCOUNT_CUSTOMER_ID_IS_REQUIRED_FOR_VAULTING = '82905';
|
321 |
+
const PAYPAL_ACCOUNT_INVALID_FUNDING_SOURCE_SELECTION = '92913';
|
322 |
+
const PAYPAL_ACCOUNT_INVALID_PARAMS_FOR_PAYPAL_ACCOUNT_UPDATE = '92915';
|
323 |
+
const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_CONSUMED = '92907';
|
324 |
+
const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_LOCKED = '92909';
|
325 |
+
const PAYPAL_ACCOUNT_PAYMENT_METHOD_NONCE_UNKNOWN = '92908';
|
326 |
+
const PAYPAL_ACCOUNT_PAYPAL_ACCOUNTS_ARE_NOT_ACCEPTED = '82904';
|
327 |
+
const PAYPAL_ACCOUNT_PAYPAL_COMMUNICATION_ERROR = '92910';
|
328 |
+
const PAYPAL_ACCOUNT_TOKEN_IS_IN_USE = '92906';
|
329 |
+
|
330 |
+
const SEPA_BANK_ACCOUNT_ACCOUNT_HOLDER_NAME_IS_REQUIRED = '93003';
|
331 |
+
const SEPA_BANK_ACCOUNT_BIC_IS_REQUIRED = '93002';
|
332 |
+
const SEPA_BANK_ACCOUNT_IBAN_IS_REQUIRED = '93001';
|
333 |
+
|
334 |
+
const SEPA_MANDATE_ACCOUNT_HOLDER_NAME_IS_REQUIRED = '83301';
|
335 |
+
const SEPA_MANDATE_BIC_INVALID_CHARACTER = '83306';
|
336 |
+
const SEPA_MANDATE_BIC_IS_REQUIRED = '83302';
|
337 |
+
const SEPA_MANDATE_BIC_LENGTH_IS_INVALID = '83307';
|
338 |
+
const SEPA_MANDATE_BIC_UNSUPPORTED_COUNTRY = '83308';
|
339 |
+
const SEPA_MANDATE_BILLING_ADDRESS_CONFLICT = '93311';
|
340 |
+
const SEPA_MANDATE_BILLING_ADDRESS_ID_IS_INVALID = '93312';
|
341 |
+
const SEPA_MANDATE_IBAN_INVALID_CHARACTER = '83305';
|
342 |
+
const SEPA_MANDATE_IBAN_INVALID_FORMAT = '83310';
|
343 |
+
const SEPA_MANDATE_IBAN_IS_REQUIRED = '83303';
|
344 |
+
const SEPA_MANDATE_IBAN_UNSUPPORTED_COUNTRY = '83309';
|
345 |
+
const SEPA_MANDATE_TYPE_IS_REQUIRED = '93304';
|
346 |
+
const SEPA_MANDATE_TYPE_IS_INVALID = '93313';
|
347 |
+
|
348 |
+
const SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_INVALID = '82302';
|
349 |
+
const SETTLEMENT_BATCH_SUMMARY_SETTLEMENT_DATE_IS_REQUIRED = '82301';
|
350 |
+
const SETTLEMENT_BATCH_SUMMARY_CUSTOM_FIELD_IS_INVALID = '82303';
|
351 |
+
|
352 |
+
const SUBSCRIPTION_BILLING_DAY_OF_MONTH_CANNOT_BE_UPDATED = '91918';
|
353 |
+
const SUBSCRIPTION_BILLING_DAY_OF_MONTH_IS_INVALID = '91914';
|
354 |
+
const SUBSCRIPTION_BILLING_DAY_OF_MONTH_MUST_BE_NUMERIC = '91913';
|
355 |
+
const SUBSCRIPTION_CANNOT_ADD_DUPLICATE_ADDON_OR_DISCOUNT = '91911';
|
356 |
+
const SUBSCRIPTION_CANNOT_EDIT_CANCELED_SUBSCRIPTION = '81901';
|
357 |
+
const SUBSCRIPTION_CANNOT_EDIT_EXPIRED_SUBSCRIPTION = '81910';
|
358 |
+
const SUBSCRIPTION_CANNOT_EDIT_PRICE_CHANGING_FIELDS_ON_PAST_DUE_SUBSCRIPTION = '91920';
|
359 |
+
const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_IN_THE_PAST = '91916';
|
360 |
+
const SUBSCRIPTION_FIRST_BILLING_DATE_CANNOT_BE_UPDATED = '91919';
|
361 |
+
const SUBSCRIPTION_FIRST_BILLING_DATE_IS_INVALID = '91915';
|
362 |
+
const SUBSCRIPTION_ID_IS_IN_USE = '81902';
|
363 |
+
const SUBSCRIPTION_INCONSISTENT_NUMBER_OF_BILLING_CYCLES = '91908';
|
364 |
+
const SUBSCRIPTION_INCONSISTENT_START_DATE = '91917';
|
365 |
+
const SUBSCRIPTION_INVALID_REQUEST_FORMAT = '91921';
|
366 |
+
const SUBSCRIPTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91901';
|
367 |
+
const SUBSCRIPTION_MISMATCH_CURRENCY_ISO_CODE = '91923';
|
368 |
+
const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_CANNOT_BE_BLANK = '91912';
|
369 |
+
const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_IS_TOO_SMALL = '91909';
|
370 |
+
const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_GREATER_THAN_ZERO = '91907';
|
371 |
+
const SUBSCRIPTION_NUMBER_OF_BILLING_CYCLES_MUST_BE_NUMERIC = '91906';
|
372 |
+
const SUBSCRIPTION_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91924';
|
373 |
+
const SUBSCRIPTION_PAYMENT_METHOD_NONCE_IS_INVALID = '91925';
|
374 |
+
const SUBSCRIPTION_PAYMENT_METHOD_NONCE_NOT_ASSOCIATED_WITH_CUSTOMER = '91926';
|
375 |
+
const SUBSCRIPTION_PAYMENT_METHOD_NONCE_UNVAULTED_CARD_IS_NOT_ACCEPTED = '91927';
|
376 |
+
const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91902';
|
377 |
+
const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91903';
|
378 |
+
const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_NOT_ASSOCIATED_WITH_CUSTOMER = '91905';
|
379 |
+
const SUBSCRIPTION_PLAN_BILLING_FREQUENCY_CANNOT_BE_UPDATED = '91922';
|
380 |
+
const SUBSCRIPTION_PLAN_ID_IS_INVALID = '91904';
|
381 |
+
const SUBSCRIPTION_PRICE_CANNOT_BE_BLANK = '81903';
|
382 |
+
const SUBSCRIPTION_PRICE_FORMAT_IS_INVALID = '81904';
|
383 |
+
const SUBSCRIPTION_PRICE_IS_TOO_LARGE = '81923';
|
384 |
+
const SUBSCRIPTION_STATUS_IS_CANCELED = '81905';
|
385 |
+
const SUBSCRIPTION_TOKEN_FORMAT_IS_INVALID = '81906';
|
386 |
+
const SUBSCRIPTION_TRIAL_DURATION_FORMAT_IS_INVALID = '81907';
|
387 |
+
const SUBSCRIPTION_TRIAL_DURATION_IS_REQUIRED = '81908';
|
388 |
+
const SUBSCRIPTION_TRIAL_DURATION_UNIT_IS_INVALID = '81909';
|
389 |
+
const SUBSCRIPTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_INSTRUMENT_TYPE = '91930';
|
390 |
+
const SUBSCRIPTION_PAYMENT_METHOD_NONCE_INSTRUMENT_TYPE_DOES_NOT_SUPPORT_SUBSCRIPTIONS = '91929';
|
391 |
+
const SUBSCRIPTION_PAYMENT_METHOD_TOKEN_INSTRUMENT_TYPE_DOES_NOT_SUPPORT_SUBSCRIPTIONS = '91928';
|
392 |
+
|
393 |
+
const SUBSCRIPTION_MODIFICATION_AMOUNT_CANNOT_BE_BLANK = '92003';
|
394 |
+
const SUBSCRIPTION_MODIFICATION_AMOUNT_IS_INVALID = '92002';
|
395 |
+
const SUBSCRIPTION_MODIFICATION_AMOUNT_IS_TOO_LARGE = '92023';
|
396 |
+
const SUBSCRIPTION_MODIFICATION_CANNOT_EDIT_MODIFICATIONS_ON_PAST_DUE_SUBSCRIPTION = '92022';
|
397 |
+
const SUBSCRIPTION_MODIFICATION_CANNOT_UPDATE_AND_REMOVE = '92015';
|
398 |
+
const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_INCORRECT_KIND = '92020';
|
399 |
+
const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_INVALID = '92011';
|
400 |
+
const SUBSCRIPTION_MODIFICATION_EXISTING_ID_IS_REQUIRED = '92012';
|
401 |
+
const SUBSCRIPTION_MODIFICATION_ID_TO_REMOVE_IS_INCORRECT_KIND = '92021';
|
402 |
+
const SUBSCRIPTION_MODIFICATION_ID_TO_REMOVE_IS_INVALID = '92025';
|
403 |
+
const SUBSCRIPTION_MODIFICATION_ID_TO_REMOVE_IS_NOT_PRESENT = '92016';
|
404 |
+
const SUBSCRIPTION_MODIFICATION_INCONSISTENT_NUMBER_OF_BILLING_CYCLES = '92018';
|
405 |
+
const SUBSCRIPTION_MODIFICATION_INHERITED_FROM_ID_IS_INVALID = '92013';
|
406 |
+
const SUBSCRIPTION_MODIFICATION_INHERITED_FROM_ID_IS_REQUIRED = '92014';
|
407 |
+
const SUBSCRIPTION_MODIFICATION_MISSING = '92024';
|
408 |
+
const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_CANNOT_BE_BLANK = '92017';
|
409 |
+
const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_IS_INVALID = '92005';
|
410 |
+
const SUBSCRIPTION_MODIFICATION_NUMBER_OF_BILLING_CYCLES_MUST_BE_GREATER_THAN_ZERO = '92019';
|
411 |
+
const SUBSCRIPTION_MODIFICATION_QUANTITY_CANNOT_BE_BLANK = '92004';
|
412 |
+
const SUBSCRIPTION_MODIFICATION_QUANTITY_IS_INVALID = '92001';
|
413 |
+
const SUBSCRIPTION_MODIFICATION_QUANTITY_MUST_BE_GREATER_THAN_ZERO = '92010';
|
414 |
+
|
415 |
+
const TRANSACTION_AMOUNT_CANNOT_BE_NEGATIVE = '81501';
|
416 |
+
const TRANSACTION_AMOUNT_DOES_NOT_MATCH3_D_SECURE_AMOUNT = '91585';
|
417 |
+
const TRANSACTION_AMOUNT_FORMAT_IS_INVALID = '81503';
|
418 |
+
const TRANSACTION_AMOUNT_IS_INVALID = '81503';
|
419 |
+
const TRANSACTION_AMOUNT_IS_REQUIRED = '81502';
|
420 |
+
const TRANSACTION_AMOUNT_IS_TOO_LARGE = '81528';
|
421 |
+
const TRANSACTION_AMOUNT_MUST_BE_GREATER_THAN_ZERO = '81531';
|
422 |
+
const TRANSACTION_BILLING_ADDRESS_CONFLICT = '91530';
|
423 |
+
const TRANSACTION_CANNOT_BE_VOIDED = '91504';
|
424 |
+
const TRANSACTION_CANNOT_CANCEL_RELEASE = '91562';
|
425 |
+
const TRANSACTION_CANNOT_CLONE_CREDIT = '91543';
|
426 |
+
const TRANSACTION_CANNOT_CLONE_MARKETPLACE_TRANSACTION = '915137';
|
427 |
+
const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_PAYPAL_ACCOUNT = '91573';
|
428 |
+
const TRANSACTION_CANNOT_CLONE_TRANSACTION_WITH_VAULT_CREDIT_CARD = '91540';
|
429 |
+
const TRANSACTION_CANNOT_CLONE_UNSUCCESSFUL_TRANSACTION = '91542';
|
430 |
+
const TRANSACTION_CANNOT_CLONE_VOICE_AUTHORIZATIONS = '91541';
|
431 |
+
const TRANSACTION_CANNOT_HOLD_IN_ESCROW = '91560';
|
432 |
+
const TRANSACTION_CANNOT_PARTIALLY_REFUND_ESCROWED_TRANSACTION = '91563';
|
433 |
+
const TRANSACTION_CANNOT_REFUND_CREDIT = '91505';
|
434 |
+
const TRANSACTION_CANNOT_REFUND_SETTLING_TRANSACTION = '91574';
|
435 |
+
const TRANSACTION_CANNOT_REFUND_UNLESS_SETTLED = '91506';
|
436 |
+
const TRANSACTION_CANNOT_REFUND_WITH_PENDING_MERCHANT_ACCOUNT = '91559';
|
437 |
+
const TRANSACTION_CANNOT_REFUND_WITH_SUSPENDED_MERCHANT_ACCOUNT = '91538';
|
438 |
+
const TRANSACTION_CANNOT_RELEASE_FROM_ESCROW = '91561';
|
439 |
+
const TRANSACTION_CANNOT_SIMULATE_SETTLEMENT = '91575';
|
440 |
+
const TRANSACTION_CANNOT_SUBMIT_FOR_PARTIAL_SETTLEMENT = '915103';
|
441 |
+
const TRANSACTION_CANNOT_SUBMIT_FOR_SETTLEMENT = '91507';
|
442 |
+
const TRANSACTION_CANNOT_UPDATE_DETAILS_NOT_SUBMITTED_FOR_SETTLEMENT = '915129';
|
443 |
+
const TRANSACTION_CHANNEL_IS_TOO_LONG = '91550';
|
444 |
+
const TRANSACTION_CREDIT_CARD_IS_REQUIRED = '91508';
|
445 |
+
const TRANSACTION_CUSTOMER_DEFAULT_PAYMENT_METHOD_CARD_TYPE_IS_NOT_ACCEPTED = '81509';
|
446 |
+
const TRANSACTION_CUSTOMER_DOES_NOT_HAVE_CREDIT_CARD = '91511';
|
447 |
+
const TRANSACTION_CUSTOMER_ID_IS_INVALID = '91510';
|
448 |
+
const TRANSACTION_CUSTOM_FIELD_IS_INVALID = '91526';
|
449 |
+
const TRANSACTION_CUSTOM_FIELD_IS_TOO_LONG = '81527';
|
450 |
+
const TRANSACTION_HAS_ALREADY_BEEN_REFUNDED = '91512';
|
451 |
+
const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_MATCH3_D_SECURE_MERCHANT_ACCOUNT = '91584';
|
452 |
+
const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_MOTO = '91558';
|
453 |
+
const TRANSACTION_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_REFUNDS = '91547';
|
454 |
+
const TRANSACTION_MERCHANT_ACCOUNT_ID_IS_INVALID = '91513';
|
455 |
+
const TRANSACTION_MERCHANT_ACCOUNT_IS_SUSPENDED = '91514';
|
456 |
+
const TRANSACTION_MERCHANT_ACCOUNT_NAME_IS_INVALID = '91513'; //Deprecated
|
457 |
+
const TRANSACTION_OPTIONS_PAY_PAL_CUSTOM_FIELD_TOO_LONG = '91580';
|
458 |
+
const TRANSACTION_OPTIONS_SUBMIT_FOR_SETTLEMENT_IS_REQUIRED_FOR_CLONING = '91544';
|
459 |
+
const TRANSACTION_OPTIONS_SUBMIT_FOR_SETTLEMENT_IS_REQUIRED_FOR_PAYPAL_UNILATERAL = '91582';
|
460 |
+
const TRANSACTION_OPTIONS_USE_BILLING_FOR_SHIPPING_DISABLED = '91572';
|
461 |
+
const TRANSACTION_OPTIONS_VAULT_IS_DISABLED = '91525';
|
462 |
+
const TRANSACTION_ORDER_ID_IS_TOO_LONG = '91501';
|
463 |
+
const TRANSACTION_PAYMENT_INSTRUMENT_NOT_SUPPORTED_BY_MERCHANT_ACCOUNT = '91577';
|
464 |
+
const TRANSACTION_PAYMENT_INSTRUMENT_TYPE_IS_NOT_ACCEPTED = '915101';
|
465 |
+
const TRANSACTION_PAYMENT_METHOD_CONFLICT = '91515';
|
466 |
+
const TRANSACTION_PAYMENT_METHOD_CONFLICT_WITH_VENMO_SDK = '91549';
|
467 |
+
const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_CUSTOMER = '91516';
|
468 |
+
const TRANSACTION_PAYMENT_METHOD_DOES_NOT_BELONG_TO_SUBSCRIPTION = '91527';
|
469 |
+
const TRANSACTION_PAYMENT_METHOD_NONCE_CARD_TYPE_IS_NOT_ACCEPTED = '91567';
|
470 |
+
const TRANSACTION_PAYMENT_METHOD_NONCE_CONSUMED = '91564';
|
471 |
+
const TRANSACTION_PAYMENT_METHOD_NONCE_HAS_NO_VALID_PAYMENT_INSTRUMENT_TYPE = '91569';
|
472 |
+
const TRANSACTION_PAYMENT_METHOD_NONCE_LOCKED = '91566';
|
473 |
+
const TRANSACTION_PAYMENT_METHOD_NONCE_UNKNOWN = '91565';
|
474 |
+
const TRANSACTION_PAYMENT_METHOD_TOKEN_CARD_TYPE_IS_NOT_ACCEPTED = '91517';
|
475 |
+
const TRANSACTION_PAYMENT_METHOD_TOKEN_IS_INVALID = '91518';
|
476 |
+
const TRANSACTION_PAYPAL_NOT_ENABLED = '91576';
|
477 |
+
const TRANSACTION_PAY_PAL_AUTH_EXPIRED = '91579';
|
478 |
+
const TRANSACTION_PAY_PAL_VAULT_RECORD_MISSING_DATA = '91583';
|
479 |
+
const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_CANNOT_BE_SET = '91519';
|
480 |
+
const TRANSACTION_PROCESSOR_AUTHORIZATION_CODE_IS_INVALID = '81520';
|
481 |
+
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_AUTHS = '915104';
|
482 |
+
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_CREDITS = '91546';
|
483 |
+
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_PARTIAL_SETTLEMENT = '915102';
|
484 |
+
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_ORDER_ID = '915107';
|
485 |
+
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_DESCRIPTOR = '915108';
|
486 |
+
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_UPDATING_DETAILS = '915130';
|
487 |
+
const TRANSACTION_PROCESSOR_DOES_NOT_SUPPORT_VOICE_AUTHORIZATIONS = '91545';
|
488 |
+
const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_INVALID = '91548';
|
489 |
+
const TRANSACTION_PURCHASE_ORDER_NUMBER_IS_TOO_LONG = '91537';
|
490 |
+
const TRANSACTION_REFUND_AMOUNT_IS_TOO_LARGE = '91521';
|
491 |
+
const TRANSACTION_SERVICE_FEE_AMOUNT_CANNOT_BE_NEGATIVE = '91554';
|
492 |
+
const TRANSACTION_SERVICE_FEE_AMOUNT_FORMAT_IS_INVALID = '91555';
|
493 |
+
const TRANSACTION_SERVICE_FEE_AMOUNT_IS_TOO_LARGE = '91556';
|
494 |
+
const TRANSACTION_SERVICE_FEE_AMOUNT_NOT_ALLOWED_ON_MASTER_MERCHANT_ACCOUNT = '91557';
|
495 |
+
const TRANSACTION_SERVICE_FEE_IS_NOT_ALLOWED_ON_CREDITS = '91552';
|
496 |
+
const TRANSACTION_SERVICE_FEE_NOT_ACCEPTED_FOR_PAYPAL = '91578';
|
497 |
+
const TRANSACTION_SETTLEMENT_AMOUNT_IS_LESS_THAN_SERVICE_FEE_AMOUNT = '91551';
|
498 |
+
const TRANSACTION_SETTLEMENT_AMOUNT_IS_TOO_LARGE = '91522';
|
499 |
+
const TRANSACTION_SHIPPING_ADDRESS_DOESNT_MATCH_CUSTOMER = '91581';
|
500 |
+
const TRANSACTION_SUBSCRIPTION_DOES_NOT_BELONG_TO_CUSTOMER = '91529';
|
501 |
+
const TRANSACTION_SUBSCRIPTION_ID_IS_INVALID = '91528';
|
502 |
+
const TRANSACTION_SUBSCRIPTION_STATUS_MUST_BE_PAST_DUE = '91531';
|
503 |
+
const TRANSACTION_SUB_MERCHANT_ACCOUNT_REQUIRES_SERVICE_FEE_AMOUNT = '91553';
|
504 |
+
const TRANSACTION_TAX_AMOUNT_CANNOT_BE_NEGATIVE = '81534';
|
505 |
+
const TRANSACTION_TAX_AMOUNT_FORMAT_IS_INVALID = '81535';
|
506 |
+
const TRANSACTION_TAX_AMOUNT_IS_TOO_LARGE = '81536';
|
507 |
+
|
508 |
+
const TRANSACTION_THREE_D_SECURE_AUTHENTICATION_FAILED = '81571';
|
509 |
+
const TRANSACTION_THREE_D_SECURE_TOKEN_IS_INVALID = '91568';
|
510 |
+
const TRANSACTION_THREE_D_SECURE_TRANSACTION_DATA_DOESNT_MATCH_VERIFY = '91570';
|
511 |
+
const TRANSACTION_THREE_D_SECURE_ECI_FLAG_IS_REQUIRED = '915113';
|
512 |
+
const TRANSACTION_THREE_D_SECURE_CAVV_IS_REQUIRED = '915116';
|
513 |
+
const TRANSACTION_THREE_D_SECURE_XID_IS_REQUIRED = '915115';
|
514 |
+
const TRANSACTION_THREE_D_SECURE_ECI_FLAG_IS_INVALID = '915114';
|
515 |
+
const TRANSACTION_THREE_D_SECURE_MERCHANT_ACCOUNT_DOES_NOT_SUPPORT_CARD_TYPE = '915131';
|
516 |
+
const TRANSACTION_TYPE_IS_INVALID = '91523';
|
517 |
+
const TRANSACTION_TYPE_IS_REQUIRED = '91524';
|
518 |
+
const TRANSACTION_UNSUPPORTED_VOICE_AUTHORIZATION = '91539';
|
519 |
+
|
520 |
+
const VERIFICATION_OPTIONS_AMOUNT_CANNOT_BE_NEGATIVE = '94201';
|
521 |
+
const VERIFICATION_OPTIONS_AMOUNT_FORMAT_IS_INVALID = '94202';
|
522 |
+
const VERIFICATION_OPTIONS_AMOUNT_IS_TOO_LARGE = '94207';
|
523 |
+
const VERIFICATION_OPTIONS_AMOUNT_NOT_SUPPORTED_BY_PROCESSOR = '94203';
|
524 |
+
const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_ID_IS_INVALID = '94204';
|
525 |
+
const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_IS_SUSPENDED = '94205';
|
526 |
+
const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_IS_FORBIDDEN = '94206';
|
527 |
+
const VERIFICATION_OPTIONS_MERCHANT_ACCOUNT_CANNOT_BE_SUB_MERCHANT_ACCOUNT = '94208';
|
528 |
+
}
|
529 |
+
class_alias('Braintree\Error\Codes', 'Braintree_Error_Codes');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Error/ErrorCollection.php
RENAMED
@@ -1,16 +1,11 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
*
|
4 |
-
* Error handler
|
5 |
-
*
|
6 |
-
* @package Braintree
|
7 |
-
* @subpackage Errors
|
8 |
-
* @category Errors
|
9 |
-
* @copyright 2010 Braintree Payment Solutions
|
10 |
-
*/
|
11 |
|
|
|
12 |
|
13 |
/**
|
|
|
|
|
14 |
* Handles validation errors
|
15 |
*
|
16 |
* Contains a read-only property $error which is a ValidationErrorCollection
|
@@ -18,20 +13,30 @@
|
|
18 |
* @package Braintree
|
19 |
* @subpackage Errors
|
20 |
* @category Errors
|
21 |
-
* @copyright
|
22 |
*
|
23 |
* @property-read object $errors
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
private $_errors;
|
28 |
|
29 |
public function __construct($errorData)
|
30 |
{
|
31 |
$this->_errors =
|
32 |
-
new
|
33 |
}
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
/**
|
37 |
* Returns all of the validation errors at all levels of nesting in a single, flat array.
|
@@ -77,10 +82,10 @@ class Braintree_Error_ErrorCollection
|
|
77 |
$pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
|
78 |
$errors = $this;
|
79 |
foreach(array_slice($pieces, 0, -1) as $key) {
|
80 |
-
$errors = $errors->forKey(
|
81 |
-
if (!isset($errors)) { return
|
82 |
}
|
83 |
-
$finalKey =
|
84 |
return $errors->onAttribute($finalKey);
|
85 |
}
|
86 |
|
@@ -88,7 +93,7 @@ class Braintree_Error_ErrorCollection
|
|
88 |
* Returns the errors at the given nesting level (see forKey) in a single, flat array:
|
89 |
*
|
90 |
* <code>
|
91 |
-
* $result =
|
92 |
* $customerErrors = $result->errors->forKey('customer')->shallowAll();
|
93 |
* </code>
|
94 |
*/
|
@@ -116,3 +121,4 @@ class Braintree_Error_ErrorCollection
|
|
116 |
return sprintf('%s', $this->_errors);
|
117 |
}
|
118 |
}
|
|
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
|
13 |
* @package Braintree
|
14 |
* @subpackage Errors
|
15 |
* @category Errors
|
16 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
17 |
*
|
18 |
* @property-read object $errors
|
19 |
*/
|
20 |
+
class ErrorCollection implements \Countable
|
21 |
{
|
22 |
private $_errors;
|
23 |
|
24 |
public function __construct($errorData)
|
25 |
{
|
26 |
$this->_errors =
|
27 |
+
new ValidationErrorCollection($errorData);
|
28 |
}
|
29 |
|
30 |
+
/**
|
31 |
+
* Return count of items in collection
|
32 |
+
* Implements countable
|
33 |
+
*
|
34 |
+
* @return integer
|
35 |
+
*/
|
36 |
+
public function count()
|
37 |
+
{
|
38 |
+
return $this->deepSize();
|
39 |
+
}
|
40 |
|
41 |
/**
|
42 |
* Returns all of the validation errors at all levels of nesting in a single, flat array.
|
82 |
$pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
|
83 |
$errors = $this;
|
84 |
foreach(array_slice($pieces, 0, -1) as $key) {
|
85 |
+
$errors = $errors->forKey(Util::delimiterToCamelCase($key));
|
86 |
+
if (!isset($errors)) { return []; }
|
87 |
}
|
88 |
+
$finalKey = Util::delimiterToCamelCase(end($pieces));
|
89 |
return $errors->onAttribute($finalKey);
|
90 |
}
|
91 |
|
93 |
* Returns the errors at the given nesting level (see forKey) in a single, flat array:
|
94 |
*
|
95 |
* <code>
|
96 |
+
* $result = Customer::create(...);
|
97 |
* $customerErrors = $result->errors->forKey('customer')->shallowAll();
|
98 |
* </code>
|
99 |
*/
|
121 |
return sprintf('%s', $this->_errors);
|
122 |
}
|
123 |
}
|
124 |
+
class_alias('Braintree\Error\ErrorCollection', 'Braintree_Error_ErrorCollection');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Error/Validation.php
RENAMED
@@ -1,11 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Error
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
11 |
* error object returned as part of a validation error collection
|
@@ -17,17 +13,17 @@
|
|
17 |
*
|
18 |
* @package Braintree
|
19 |
* @subpackage Error
|
20 |
-
* @copyright
|
21 |
*
|
22 |
* @property-read string $attribute
|
23 |
* @property-read string $code
|
24 |
* @property-read string $message
|
25 |
*/
|
26 |
-
class
|
27 |
{
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
/**
|
33 |
* @ignore
|
@@ -42,13 +38,13 @@ class Braintree_Error_Validation
|
|
42 |
* @ignore
|
43 |
* @access protected
|
44 |
* @param array $attributes array of properties to set - single level
|
45 |
-
* @return
|
46 |
*/
|
47 |
private function _initializeFromArray($attributes)
|
48 |
{
|
49 |
foreach($attributes AS $name => $value) {
|
50 |
$varName = "_$name";
|
51 |
-
$this->$varName =
|
52 |
}
|
53 |
}
|
54 |
|
@@ -62,3 +58,4 @@ class Braintree_Error_Validation
|
|
62 |
return isset($this->$varName) ? $this->$varName : null;
|
63 |
}
|
64 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree\Error;
|
3 |
+
|
4 |
+
use Braintree\Util;
|
|
|
|
|
|
|
|
|
5 |
|
6 |
/**
|
7 |
* error object returned as part of a validation error collection
|
13 |
*
|
14 |
* @package Braintree
|
15 |
* @subpackage Error
|
16 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
17 |
*
|
18 |
* @property-read string $attribute
|
19 |
* @property-read string $code
|
20 |
* @property-read string $message
|
21 |
*/
|
22 |
+
class Validation
|
23 |
{
|
24 |
+
private $_attribute;
|
25 |
+
private $_code;
|
26 |
+
private $_message;
|
27 |
|
28 |
/**
|
29 |
* @ignore
|
38 |
* @ignore
|
39 |
* @access protected
|
40 |
* @param array $attributes array of properties to set - single level
|
41 |
+
* @return void
|
42 |
*/
|
43 |
private function _initializeFromArray($attributes)
|
44 |
{
|
45 |
foreach($attributes AS $name => $value) {
|
46 |
$varName = "_$name";
|
47 |
+
$this->$varName = Util::delimiterToCamelCase($value, '_');
|
48 |
}
|
49 |
}
|
50 |
|
58 |
return isset($this->$varName) ? $this->$varName : null;
|
59 |
}
|
60 |
}
|
61 |
+
class_alias('Braintree\Error\Validation', 'Braintree_Error_Validation');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Error/ValidationErrorCollection.php
RENAMED
@@ -1,11 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Error
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
11 |
* collection of errors enumerating all validation errors for a given request
|
@@ -16,15 +12,15 @@
|
|
16 |
*
|
17 |
* @package Braintree
|
18 |
* @subpackage Error
|
19 |
-
* @copyright
|
20 |
*
|
21 |
* @property-read array $errors
|
22 |
* @property-read array $nested
|
23 |
*/
|
24 |
-
class
|
25 |
{
|
26 |
-
private $_errors =
|
27 |
-
private $_nested =
|
28 |
|
29 |
/**
|
30 |
* @ignore
|
@@ -35,17 +31,17 @@ class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
|
|
35 |
// map errors to new collections recursively
|
36 |
if ($key == 'errors') {
|
37 |
foreach ($errorData AS $error) {
|
38 |
-
$this->_errors[] = new
|
39 |
}
|
40 |
} else {
|
41 |
-
$this->_nested[$key] = new
|
42 |
}
|
43 |
|
44 |
}
|
45 |
|
46 |
public function deepAll()
|
47 |
{
|
48 |
-
$validationErrors = array_merge(
|
49 |
foreach($this->_nested as $nestedErrors)
|
50 |
{
|
51 |
$validationErrors = array_merge($validationErrors, $nestedErrors->deepAll());
|
@@ -75,7 +71,7 @@ class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
|
|
75 |
|
76 |
public function onAttribute($attribute)
|
77 |
{
|
78 |
-
$matches =
|
79 |
foreach ($this->_errors AS $key => $error) {
|
80 |
if($error->attribute == $attribute) {
|
81 |
$matches[] = $error;
|
@@ -105,7 +101,7 @@ class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
|
|
105 |
*/
|
106 |
public function __toString()
|
107 |
{
|
108 |
-
$output =
|
109 |
|
110 |
// TODO: implement scope
|
111 |
if (!empty($this->_errors)) {
|
@@ -133,3 +129,4 @@ class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
|
|
133 |
return $eOutput;
|
134 |
}
|
135 |
}
|
|
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
|
12 |
*
|
13 |
* @package Braintree
|
14 |
* @subpackage Error
|
15 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
16 |
*
|
17 |
* @property-read array $errors
|
18 |
* @property-read array $nested
|
19 |
*/
|
20 |
+
class ValidationErrorCollection extends Collection
|
21 |
{
|
22 |
+
private $_errors = [];
|
23 |
+
private $_nested = [];
|
24 |
|
25 |
/**
|
26 |
* @ignore
|
31 |
// map errors to new collections recursively
|
32 |
if ($key == 'errors') {
|
33 |
foreach ($errorData AS $error) {
|
34 |
+
$this->_errors[] = new Validation($error);
|
35 |
}
|
36 |
} else {
|
37 |
+
$this->_nested[$key] = new ValidationErrorCollection($errorData);
|
38 |
}
|
39 |
|
40 |
}
|
41 |
|
42 |
public function deepAll()
|
43 |
{
|
44 |
+
$validationErrors = array_merge([], $this->_errors);
|
45 |
foreach($this->_nested as $nestedErrors)
|
46 |
{
|
47 |
$validationErrors = array_merge($validationErrors, $nestedErrors->deepAll());
|
71 |
|
72 |
public function onAttribute($attribute)
|
73 |
{
|
74 |
+
$matches = [];
|
75 |
foreach ($this->_errors AS $key => $error) {
|
76 |
if($error->attribute == $attribute) {
|
77 |
$matches[] = $error;
|
101 |
*/
|
102 |
public function __toString()
|
103 |
{
|
104 |
+
$output = [];
|
105 |
|
106 |
// TODO: implement scope
|
107 |
if (!empty($this->_errors)) {
|
129 |
return $eOutput;
|
130 |
}
|
131 |
}
|
132 |
+
class_alias('Braintree\Error\ValidationErrorCollection', 'Braintree_Error_ValidationErrorCollection');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Exception/Authorization.php
RENAMED
@@ -1,23 +1,20 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
* Raised when authorization fails
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Exception
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
|
|
10 |
|
11 |
/**
|
|
|
12 |
* Raised when the API key being used is not authorized to perform
|
13 |
* the attempted action according to the roles assigned to the user
|
14 |
* who owns the API key.
|
15 |
*
|
16 |
* @package Braintree
|
17 |
* @subpackage Exception
|
18 |
-
* @copyright
|
19 |
*/
|
20 |
-
class
|
21 |
{
|
22 |
|
23 |
}
|
|
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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/lib/Braintree/Http.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
if ($this->_config->sslVersion()) {
|
113 |
+
curl_setopt($curl, CURLOPT_SSLVERSION, $this->_config->sslVersion());
|
114 |
+
}
|
115 |
+
|
116 |
+
$headers = $this->_getHeaders($curl);
|
117 |
+
$headers[] = 'User-Agent: Braintree PHP Library ' . Version::get();
|
118 |
+
$headers[] = 'X-ApiVersion: ' . Configuration::API_VERSION;
|
119 |
+
|
120 |
+
$authorization = $this->_getAuthorization();
|
121 |
+
if (isset($authorization['user'])) {
|
122 |
+
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
123 |
+
curl_setopt($curl, CURLOPT_USERPWD, $authorization['user'] . ':' . $authorization['password']);
|
124 |
+
} else if (isset($authorization['token'])) {
|
125 |
+
$headers[] = 'Authorization: Bearer ' . $authorization['token'];
|
126 |
+
}
|
127 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
128 |
+
|
129 |
+
// curl_setopt($curl, CURLOPT_VERBOSE, true);
|
130 |
+
if ($this->_config->sslOn()) {
|
131 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
|
132 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
|
133 |
+
curl_setopt($curl, CURLOPT_CAINFO, $this->getCaFile());
|
134 |
+
}
|
135 |
+
|
136 |
+
if(!empty($requestBody)) {
|
137 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
|
138 |
+
}
|
139 |
+
|
140 |
+
if($this->_config->isUsingProxy()) {
|
141 |
+
$proxyHost = $this->_config->getProxyHost();
|
142 |
+
$proxyPort = $this->_config->getProxyPort();
|
143 |
+
$proxyType = $this->_config->getProxyType();
|
144 |
+
$proxyUser = $this->_config->getProxyUser();
|
145 |
+
$proxyPwd= $this->_config->getProxyPassword();
|
146 |
+
curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort);
|
147 |
+
if(!empty($proxyType)) {
|
148 |
+
curl_setopt($curl, CURLOPT_PROXYTYPE, $proxyType);
|
149 |
+
}
|
150 |
+
if($this->_config->isAuthenticatedProxy()) {
|
151 |
+
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUser . ':' . $proxyPwd);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
156 |
+
$response = curl_exec($curl);
|
157 |
+
$httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
158 |
+
$error_code = curl_errno($curl);
|
159 |
+
|
160 |
+
if ($error_code == 28 && $httpStatus == 0) {
|
161 |
+
throw new Exception\Timeout();
|
162 |
+
}
|
163 |
+
|
164 |
+
curl_close($curl);
|
165 |
+
if ($this->_config->sslOn()) {
|
166 |
+
if ($httpStatus == 0) {
|
167 |
+
throw new Exception\SSLCertificate();
|
168 |
+
}
|
169 |
+
}
|
170 |
+
return ['status' => $httpStatus, 'body' => $response];
|
171 |
+
}
|
172 |
+
|
173 |
+
private function getCaFile()
|
174 |
+
{
|
175 |
+
static $memo;
|
176 |
+
|
177 |
+
if ($memo === null) {
|
178 |
+
$caFile = $this->_config->caFile();
|
179 |
+
|
180 |
+
if (substr($caFile, 0, 7) !== 'phar://') {
|
181 |
+
return $caFile;
|
182 |
+
}
|
183 |
+
|
184 |
+
$extractedCaFile = sys_get_temp_dir() . '/api_braintreegateway_com.ca.crt';
|
185 |
+
|
186 |
+
if (!file_exists($extractedCaFile) || sha1_file($extractedCaFile) != sha1_file($caFile)) {
|
187 |
+
if (!copy($caFile, $extractedCaFile)) {
|
188 |
+
throw new Exception\SSLCaFileNotFound();
|
189 |
+
}
|
190 |
+
}
|
191 |
+
$memo = $extractedCaFile;
|
192 |
+
}
|
193 |
+
|
194 |
+
return $memo;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
class_alias('Braintree\Http', 'Braintree_Http');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Instance.php
RENAMED
@@ -1,25 +1,19 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
* Braintree Class Instance template
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Utility
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
11 |
-
*
|
12 |
*
|
13 |
-
* @
|
14 |
-
* @subpackage Utility
|
15 |
-
* @copyright 2010 Braintree Payment Solutions
|
16 |
* @abstract
|
17 |
*/
|
18 |
-
abstract class
|
19 |
{
|
|
|
|
|
20 |
/**
|
21 |
*
|
22 |
-
* @param array $
|
23 |
*/
|
24 |
public function __construct($attributes)
|
25 |
{
|
@@ -28,11 +22,10 @@ abstract class Braintree_Instance
|
|
28 |
}
|
29 |
}
|
30 |
|
31 |
-
|
32 |
/**
|
33 |
* returns private/nonexistent instance properties
|
34 |
* @access public
|
35 |
-
* @param
|
36 |
* @return mixed contents of instance properties
|
37 |
*/
|
38 |
public function __get($name)
|
@@ -45,22 +38,33 @@ abstract class Braintree_Instance
|
|
45 |
}
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* create a printable representation of the object as:
|
50 |
* ClassName[property=value, property=value]
|
51 |
-
* @return
|
52 |
*/
|
53 |
public function __toString()
|
54 |
{
|
55 |
-
$objOutput =
|
56 |
-
return get_class($this) .'['
|
57 |
}
|
58 |
/**
|
59 |
* initializes instance properties from the keys/values of an array
|
60 |
* @ignore
|
61 |
* @access protected
|
62 |
* @param <type> $aAttribs array of properties to set - single level
|
63 |
-
* @return
|
64 |
*/
|
65 |
private function _initializeFromArray($attributes)
|
66 |
{
|
@@ -68,3 +72,4 @@ abstract class Braintree_Instance
|
|
68 |
}
|
69 |
|
70 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree;
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
/**
|
5 |
+
* Braintree Class Instance template
|
6 |
*
|
7 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
|
|
|
|
8 |
* @abstract
|
9 |
*/
|
10 |
+
abstract class Instance
|
11 |
{
|
12 |
+
protected $_attributes = [];
|
13 |
+
|
14 |
/**
|
15 |
*
|
16 |
+
* @param array $attributes
|
17 |
*/
|
18 |
public function __construct($attributes)
|
19 |
{
|
22 |
}
|
23 |
}
|
24 |
|
|
|
25 |
/**
|
26 |
* returns private/nonexistent instance properties
|
27 |
* @access public
|
28 |
+
* @param string $name property name
|
29 |
* @return mixed contents of instance properties
|
30 |
*/
|
31 |
public function __get($name)
|
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 |
{
|
72 |
}
|
73 |
|
74 |
}
|
75 |
+
class_alias('Braintree\Instance', 'Braintree_Instance');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/KeyValueNode.php
RENAMED
@@ -1,22 +1,23 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
-
function __construct($name)
|
6 |
{
|
7 |
$this->name = $name;
|
8 |
$this->searchTerm = True;
|
9 |
-
|
10 |
}
|
11 |
|
12 |
-
function is($value)
|
13 |
{
|
14 |
$this->searchTerm = $value;
|
15 |
return $this;
|
16 |
}
|
17 |
|
18 |
-
function toParam()
|
19 |
{
|
20 |
return $this->searchTerm;
|
21 |
}
|
22 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree;
|
3 |
|
4 |
+
class KeyValueNode
|
5 |
{
|
6 |
+
public function __construct($name)
|
7 |
{
|
8 |
$this->name = $name;
|
9 |
$this->searchTerm = True;
|
|
|
10 |
}
|
11 |
|
12 |
+
public function is($value)
|
13 |
{
|
14 |
$this->searchTerm = $value;
|
15 |
return $this;
|
16 |
}
|
17 |
|
18 |
+
public function toParam()
|
19 |
{
|
20 |
return $this->searchTerm;
|
21 |
}
|
22 |
}
|
23 |
+
class_alias('Braintree\KeyValueNode', 'Braintree_KeyValueNode');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/lib/Braintree/MerchantAccountGateway.php
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 function createForCurrency($attribs)
|
59 |
+
{
|
60 |
+
$response = $this->_http->post($this->_config->merchantPath() . '/merchant_accounts/create_for_currency', ['merchant_account' => $attribs]);
|
61 |
+
return $this->_verifyGatewayResponse($response);
|
62 |
+
}
|
63 |
+
|
64 |
+
public function all()
|
65 |
+
{
|
66 |
+
$pager = [
|
67 |
+
'object' => $this,
|
68 |
+
'method' => 'fetchMerchantAccounts',
|
69 |
+
];
|
70 |
+
return new PaginatedCollection($pager);
|
71 |
+
}
|
72 |
+
|
73 |
+
public function fetchMerchantAccounts($page)
|
74 |
+
{
|
75 |
+
$response = $this->_http->get($this->_config->merchantPath() . '/merchant_accounts?page=' . $page);
|
76 |
+
$body = $response['merchantAccounts'];
|
77 |
+
$merchantAccounts = Util::extractattributeasarray($body, 'merchantAccount');
|
78 |
+
$totalItems = $body['totalItems'][0];
|
79 |
+
$pageSize = $body['pageSize'][0];
|
80 |
+
return new PaginatedResult($totalItems, $pageSize, $merchantAccounts);
|
81 |
+
}
|
82 |
+
|
83 |
+
public static function createSignature()
|
84 |
+
{
|
85 |
+
$addressSignature = ['streetAddress', 'postalCode', 'locality', 'region'];
|
86 |
+
$individualSignature = [
|
87 |
+
'firstName',
|
88 |
+
'lastName',
|
89 |
+
'email',
|
90 |
+
'phone',
|
91 |
+
'dateOfBirth',
|
92 |
+
'ssn',
|
93 |
+
['address' => $addressSignature]
|
94 |
+
];
|
95 |
+
|
96 |
+
$businessSignature = [
|
97 |
+
'dbaName',
|
98 |
+
'legalName',
|
99 |
+
'taxId',
|
100 |
+
['address' => $addressSignature]
|
101 |
+
];
|
102 |
+
|
103 |
+
$fundingSignature = [
|
104 |
+
'routingNumber',
|
105 |
+
'accountNumber',
|
106 |
+
'destination',
|
107 |
+
'email',
|
108 |
+
'mobilePhone',
|
109 |
+
'descriptor',
|
110 |
+
];
|
111 |
+
|
112 |
+
return [
|
113 |
+
'id',
|
114 |
+
'tosAccepted',
|
115 |
+
'masterMerchantAccountId',
|
116 |
+
['individual' => $individualSignature],
|
117 |
+
['funding' => $fundingSignature],
|
118 |
+
['business' => $businessSignature]
|
119 |
+
];
|
120 |
+
}
|
121 |
+
|
122 |
+
public static function createDeprecatedSignature()
|
123 |
+
{
|
124 |
+
$applicantDetailsAddressSignature = ['streetAddress', 'postalCode', 'locality', 'region'];
|
125 |
+
$applicantDetailsSignature = [
|
126 |
+
'companyName',
|
127 |
+
'firstName',
|
128 |
+
'lastName',
|
129 |
+
'email',
|
130 |
+
'phone',
|
131 |
+
'dateOfBirth',
|
132 |
+
'ssn',
|
133 |
+
'taxId',
|
134 |
+
'routingNumber',
|
135 |
+
'accountNumber',
|
136 |
+
['address' => $applicantDetailsAddressSignature]
|
137 |
+
];
|
138 |
+
|
139 |
+
return [
|
140 |
+
['applicantDetails' => $applicantDetailsSignature],
|
141 |
+
'id',
|
142 |
+
'tosAccepted',
|
143 |
+
'masterMerchantAccountId'
|
144 |
+
];
|
145 |
+
}
|
146 |
+
|
147 |
+
public function _doCreate($subPath, $params)
|
148 |
+
{
|
149 |
+
$fullPath = $this->_config->merchantPath() . $subPath;
|
150 |
+
$response = $this->_http->post($fullPath, $params);
|
151 |
+
|
152 |
+
return $this->_verifyGatewayResponse($response);
|
153 |
+
}
|
154 |
+
|
155 |
+
private function _doUpdate($subPath, $params)
|
156 |
+
{
|
157 |
+
$fullPath = $this->_config->merchantPath() . $subPath;
|
158 |
+
$response = $this->_http->put($fullPath, $params);
|
159 |
+
|
160 |
+
return $this->_verifyGatewayResponse($response);
|
161 |
+
}
|
162 |
+
|
163 |
+
private function _verifyGatewayResponse($response)
|
164 |
+
{
|
165 |
+
if (isset($response['response'])) {
|
166 |
+
$response = $response['response'];
|
167 |
+
}
|
168 |
+
if (isset($response['merchantAccount'])) {
|
169 |
+
// return a populated instance of merchantAccount
|
170 |
+
return new Result\Successful(
|
171 |
+
MerchantAccount::factory($response['merchantAccount'])
|
172 |
+
);
|
173 |
+
} else if (isset($response['apiErrorResponse'])) {
|
174 |
+
return new Result\Error($response['apiErrorResponse']);
|
175 |
+
} else {
|
176 |
+
throw new Exception\Unexpected(
|
177 |
+
"Expected merchant account or apiErrorResponse"
|
178 |
+
);
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
class_alias('Braintree\MerchantAccountGateway', 'Braintree_MerchantAccountGateway');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/MultipleValueNode.php
RENAMED
@@ -1,15 +1,18 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
|
|
|
|
|
4 |
{
|
5 |
-
function __construct($name, $allowedValues =
|
6 |
{
|
7 |
$this->name = $name;
|
8 |
-
$this->items =
|
9 |
$this->allowedValues = $allowedValues;
|
10 |
}
|
11 |
|
12 |
-
function in($values)
|
13 |
{
|
14 |
$bad_values = array_diff($values, $this->allowedValues);
|
15 |
if (count($this->allowedValues) > 0 && count($bad_values) > 0) {
|
@@ -25,13 +28,14 @@ class Braintree_MultipleValueNode
|
|
25 |
return $this;
|
26 |
}
|
27 |
|
28 |
-
function is($value)
|
29 |
{
|
30 |
-
return $this->in(
|
31 |
}
|
32 |
|
33 |
-
function toParam()
|
34 |
{
|
35 |
return $this->items;
|
36 |
}
|
37 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree;
|
3 |
|
4 |
+
use InvalidArgumentException;
|
5 |
+
|
6 |
+
class MultipleValueNode
|
7 |
{
|
8 |
+
public function __construct($name, $allowedValues = [])
|
9 |
{
|
10 |
$this->name = $name;
|
11 |
+
$this->items = [];
|
12 |
$this->allowedValues = $allowedValues;
|
13 |
}
|
14 |
|
15 |
+
public function in($values)
|
16 |
{
|
17 |
$bad_values = array_diff($values, $this->allowedValues);
|
18 |
if (count($this->allowedValues) > 0 && count($bad_values) > 0) {
|
28 |
return $this;
|
29 |
}
|
30 |
|
31 |
+
public function is($value)
|
32 |
{
|
33 |
+
return $this->in([$value]);
|
34 |
}
|
35 |
|
36 |
+
public function toParam()
|
37 |
{
|
38 |
return $this->items;
|
39 |
}
|
40 |
}
|
41 |
+
class_alias('Braintree\MultipleValueNode', 'Braintree_MultipleValueNode');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/MultipleValueOrTextNode.php
RENAMED
@@ -1,46 +1,47 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
-
function __construct($name)
|
6 |
{
|
7 |
parent::__construct($name);
|
8 |
-
$this->textNode = new
|
9 |
}
|
10 |
|
11 |
-
function contains($value)
|
12 |
{
|
13 |
$this->textNode->contains($value);
|
14 |
return $this;
|
15 |
}
|
16 |
|
17 |
-
function endsWith($value)
|
18 |
{
|
19 |
$this->textNode->endsWith($value);
|
20 |
return $this;
|
21 |
}
|
22 |
|
23 |
-
function is($value)
|
24 |
{
|
25 |
$this->textNode->is($value);
|
26 |
return $this;
|
27 |
}
|
28 |
|
29 |
-
function isNot($value)
|
30 |
{
|
31 |
$this->textNode->isNot($value);
|
32 |
return $this;
|
33 |
}
|
34 |
|
35 |
-
function startsWith($value)
|
36 |
{
|
37 |
$this->textNode->startsWith($value);
|
38 |
return $this;
|
39 |
}
|
40 |
|
41 |
-
function toParam()
|
42 |
{
|
43 |
return array_merge(parent::toParam(), $this->textNode->toParam());
|
44 |
}
|
45 |
}
|
46 |
-
|
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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/lib/Braintree/PaginatedCollection.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Braintree;
|
3 |
+
|
4 |
+
use Iterator;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Braintree PaginatedCollection
|
8 |
+
* PaginatedCollection is a container object for paginated data
|
9 |
+
*
|
10 |
+
* retrieves and pages through large collections of results
|
11 |
+
*
|
12 |
+
* example:
|
13 |
+
* <code>
|
14 |
+
* $result = MerchantAccount::all();
|
15 |
+
*
|
16 |
+
* foreach($result as $merchantAccount) {
|
17 |
+
* print_r($merchantAccount->status);
|
18 |
+
* }
|
19 |
+
* </code>
|
20 |
+
*
|
21 |
+
* @package Braintree
|
22 |
+
* @subpackage Utility
|
23 |
+
* @copyright 2016 Braintree, a division of PayPal, Inc.
|
24 |
+
*/
|
25 |
+
class PaginatedCollection implements Iterator
|
26 |
+
{
|
27 |
+
private $_pager;
|
28 |
+
private $_pageSize;
|
29 |
+
private $_currentPage;
|
30 |
+
private $_index;
|
31 |
+
private $_totalItems;
|
32 |
+
private $_items;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* set up the paginated collection
|
36 |
+
*
|
37 |
+
* expects an array of an object and method to call on it
|
38 |
+
*
|
39 |
+
* @param array $pager
|
40 |
+
*/
|
41 |
+
public function __construct($pager)
|
42 |
+
{
|
43 |
+
$this->_pager = $pager;
|
44 |
+
$this->_pageSize = 0;
|
45 |
+
$this->_currentPage = 0;
|
46 |
+
$this->_totalItems = 0;
|
47 |
+
$this->_index = 0;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* returns the current item when iterating with foreach
|
52 |
+
*/
|
53 |
+
public function current()
|
54 |
+
{
|
55 |
+
return $this->_items[($this->_index % $this->_pageSize)];
|
56 |
+
}
|
57 |
+
|
58 |
+
public function key()
|
59 |
+
{
|
60 |
+
return null;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* advances to the next item in the collection when iterating with foreach
|
65 |
+
*/
|
66 |
+
public function next()
|
67 |
+
{
|
68 |
+
++$this->_index;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* rewinds the collection to the first item when iterating with foreach
|
73 |
+
*/
|
74 |
+
public function rewind()
|
75 |
+
{
|
76 |
+
$this->_index = 0;
|
77 |
+
$this->_currentPage = 0;
|
78 |
+
$this->_pageSize = 0;
|
79 |
+
$this->_totalItems = 0;
|
80 |
+
$this->_items = [];
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* returns whether the current item is valid when iterating with foreach
|
85 |
+
*/
|
86 |
+
public function valid()
|
87 |
+
{
|
88 |
+
if ($this->_currentPage == 0 || $this->_index % $this->_pageSize == 0)
|
89 |
+
{
|
90 |
+
$this->_getNextPage();
|
91 |
+
}
|
92 |
+
|
93 |
+
return $this->_index < $this->_totalItems;
|
94 |
+
}
|
95 |
+
|
96 |
+
private function _getNextPage()
|
97 |
+
{
|
98 |
+
$this->_currentPage++;
|
99 |
+
$object = $this->_pager['object'];
|
100 |
+
$method = $this->_pager['method'];
|
101 |
+
$result = call_user_func(
|
102 |
+
[$object, $method],
|
103 |
+
$this->_currentPage
|
104 |
+
);
|
105 |
+
|
106 |
+
$this->_totalItems= $result->getTotalItems();
|
107 |
+
$this->_pageSize = $result->getPageSize();
|
108 |
+
$this->_items = $result->getCurrentPage();
|
109 |
+
}
|
110 |
+
}
|
111 |
+
class_alias('Braintree\PaginatedCollection', 'Braintree_PaginatedCollection');
|
includes/lib/Braintree/lib/Braintree/PaginatedResult.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Braintree;
|
3 |
+
|
4 |
+
class PaginatedResult
|
5 |
+
{
|
6 |
+
private $_totalItems;
|
7 |
+
private $_pageSize;
|
8 |
+
private $_currentPage;
|
9 |
+
|
10 |
+
public function __construct($totalItems, $pageSize, $currentPage)
|
11 |
+
{
|
12 |
+
$this->_totalItems = $totalItems;
|
13 |
+
$this->_pageSize = $pageSize;
|
14 |
+
$this->_currentPage = $currentPage;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getTotalItems()
|
18 |
+
{
|
19 |
+
return $this->_totalItems;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getPageSize()
|
23 |
+
{
|
24 |
+
return $this->_pageSize;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getCurrentPage()
|
28 |
+
{
|
29 |
+
return $this->_currentPage;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
class_alias('Braintree\PaginatedResult', 'Braintree_PaginatedResult');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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, $options=[])
|
43 |
+
{
|
44 |
+
return Configuration::gateway()->paymentMethod()->delete($token, $options);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
class_alias('Braintree\PaymentMethod', 'Braintree_PaymentMethod');
|
includes/lib/Braintree/lib/Braintree/PaymentMethodGateway.php
ADDED
@@ -0,0 +1,332 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, $options=[])
|
94 |
+
{
|
95 |
+
Util::verifyKeys(self::deleteSignature(), $options);
|
96 |
+
$this->_validateId($token);
|
97 |
+
$queryString = "";
|
98 |
+
if (!empty($options)) {
|
99 |
+
$queryString = "?" . http_build_query(Util::camelCaseToDelimiterArray($options, '_'));
|
100 |
+
}
|
101 |
+
return $this->_doDelete('/payment_methods/any/' . $token . $queryString);
|
102 |
+
}
|
103 |
+
|
104 |
+
public function grant($sharedPaymentMethodToken, $attribs=[])
|
105 |
+
{
|
106 |
+
if (is_bool($attribs) === true) {
|
107 |
+
$attribs = ['allow_vaulting' => $attribs];
|
108 |
+
}
|
109 |
+
$options = [ 'shared_payment_method_token' => $sharedPaymentMethodToken ];
|
110 |
+
|
111 |
+
return $this->_doCreate(
|
112 |
+
'/payment_methods/grant',
|
113 |
+
[
|
114 |
+
'payment_method' => array_merge($attribs, $options)
|
115 |
+
]
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
public function revoke($sharedPaymentMethodToken)
|
120 |
+
{
|
121 |
+
return $this->_doCreate(
|
122 |
+
'/payment_methods/revoke',
|
123 |
+
[
|
124 |
+
'payment_method' => [
|
125 |
+
'shared_payment_method_token' => $sharedPaymentMethodToken
|
126 |
+
]
|
127 |
+
]
|
128 |
+
);
|
129 |
+
}
|
130 |
+
|
131 |
+
private static function baseSignature()
|
132 |
+
{
|
133 |
+
$billingAddressSignature = AddressGateway::createSignature();
|
134 |
+
$optionsSignature = [
|
135 |
+
'failOnDuplicatePaymentMethod',
|
136 |
+
'makeDefault',
|
137 |
+
'verificationMerchantAccountId',
|
138 |
+
'verifyCard',
|
139 |
+
'verificationAmount'
|
140 |
+
];
|
141 |
+
return [
|
142 |
+
'billingAddressId',
|
143 |
+
'cardholderName',
|
144 |
+
'cvv',
|
145 |
+
'deviceData',
|
146 |
+
'expirationDate',
|
147 |
+
'expirationMonth',
|
148 |
+
'expirationYear',
|
149 |
+
'number',
|
150 |
+
'paymentMethodNonce',
|
151 |
+
'token',
|
152 |
+
['options' => $optionsSignature],
|
153 |
+
['billingAddress' => $billingAddressSignature]
|
154 |
+
];
|
155 |
+
}
|
156 |
+
|
157 |
+
public static function createSignature()
|
158 |
+
{
|
159 |
+
$signature = array_merge(self::baseSignature(), ['customerId']);
|
160 |
+
return $signature;
|
161 |
+
}
|
162 |
+
|
163 |
+
public static function updateSignature()
|
164 |
+
{
|
165 |
+
$billingAddressSignature = AddressGateway::updateSignature();
|
166 |
+
array_push($billingAddressSignature, [
|
167 |
+
'options' => [
|
168 |
+
'updateExisting'
|
169 |
+
]
|
170 |
+
]);
|
171 |
+
$signature = array_merge(self::baseSignature(), [
|
172 |
+
'deviceSessionId',
|
173 |
+
'venmoSdkPaymentMethodCode',
|
174 |
+
'fraudMerchantId',
|
175 |
+
['billingAddress' => $billingAddressSignature]
|
176 |
+
]);
|
177 |
+
return $signature;
|
178 |
+
}
|
179 |
+
|
180 |
+
private static function deleteSignature()
|
181 |
+
{
|
182 |
+
return ['revokeAllGrants'];
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* sends the create request to the gateway
|
187 |
+
*
|
188 |
+
* @ignore
|
189 |
+
* @param string $subPath
|
190 |
+
* @param array $params
|
191 |
+
* @return mixed
|
192 |
+
*/
|
193 |
+
public function _doCreate($subPath, $params)
|
194 |
+
{
|
195 |
+
$fullPath = $this->_config->merchantPath() . $subPath;
|
196 |
+
$response = $this->_http->post($fullPath, $params);
|
197 |
+
|
198 |
+
return $this->_verifyGatewayResponse($response);
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* sends the update request to the gateway
|
203 |
+
*
|
204 |
+
* @ignore
|
205 |
+
* @param string $subPath
|
206 |
+
* @param array $params
|
207 |
+
* @return mixed
|
208 |
+
*/
|
209 |
+
public function _doUpdate($subPath, $params)
|
210 |
+
{
|
211 |
+
$fullPath = $this->_config->merchantPath() . $subPath;
|
212 |
+
$response = $this->_http->put($fullPath, $params);
|
213 |
+
|
214 |
+
return $this->_verifyGatewayResponse($response);
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
/**
|
219 |
+
* sends the delete request to the gateway
|
220 |
+
*
|
221 |
+
* @ignore
|
222 |
+
* @param string $subPath
|
223 |
+
* @return mixed
|
224 |
+
*/
|
225 |
+
public function _doDelete($subPath)
|
226 |
+
{
|
227 |
+
$fullPath = $this->_config->merchantPath() . $subPath;
|
228 |
+
$this->_http->delete($fullPath);
|
229 |
+
return new Result\Successful();
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* generic method for validating incoming gateway responses
|
234 |
+
*
|
235 |
+
* creates a new CreditCard or PayPalAccount object
|
236 |
+
* and encapsulates it inside a Result\Successful object, or
|
237 |
+
* encapsulates a Errors object inside a Result\Error
|
238 |
+
* alternatively, throws an Unexpected exception if the response is invalid.
|
239 |
+
*
|
240 |
+
* @ignore
|
241 |
+
* @param array $response gateway response values
|
242 |
+
* @return Result\Successful|Result\Error
|
243 |
+
* @throws Exception\Unexpected
|
244 |
+
*/
|
245 |
+
private function _verifyGatewayResponse($response)
|
246 |
+
{
|
247 |
+
if (isset($response['creditCard'])) {
|
248 |
+
return new Result\Successful(
|
249 |
+
CreditCard::factory($response['creditCard']),
|
250 |
+
'paymentMethod'
|
251 |
+
);
|
252 |
+
} else if (isset($response['paypalAccount'])) {
|
253 |
+
return new Result\Successful(
|
254 |
+
PayPalAccount::factory($response['paypalAccount']),
|
255 |
+
"paymentMethod"
|
256 |
+
);
|
257 |
+
} else if (isset($response['coinbaseAccount'])) {
|
258 |
+
return new Result\Successful(
|
259 |
+
CoinbaseAccount::factory($response['coinbaseAccount']),
|
260 |
+
"paymentMethod"
|
261 |
+
);
|
262 |
+
} else if (isset($response['applePayCard'])) {
|
263 |
+
return new Result\Successful(
|
264 |
+
ApplePayCard::factory($response['applePayCard']),
|
265 |
+
"paymentMethod"
|
266 |
+
);
|
267 |
+
} else if (isset($response['androidPayCard'])) {
|
268 |
+
return new Result\Successful(
|
269 |
+
AndroidPayCard::factory($response['androidPayCard']),
|
270 |
+
"paymentMethod"
|
271 |
+
);
|
272 |
+
} else if (isset($response['amexExpressCheckoutCard'])) {
|
273 |
+
return new Result\Successful(
|
274 |
+
AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']),
|
275 |
+
"paymentMethod"
|
276 |
+
);
|
277 |
+
} else if (isset($response['europeBankAccount'])) {
|
278 |
+
return new Result\Successful(
|
279 |
+
EuropeBankAccount::factory($response['europeBankAccount']),
|
280 |
+
"paymentMethod"
|
281 |
+
);
|
282 |
+
} else if (isset($response['usBankAccount'])) {
|
283 |
+
return new Result\Successful(
|
284 |
+
UsBankAccount::factory($response['usBankAccount']),
|
285 |
+
"paymentMethod"
|
286 |
+
);
|
287 |
+
} else if (isset($response['venmoAccount'])) {
|
288 |
+
return new Result\Successful(
|
289 |
+
VenmoAccount::factory($response['venmoAccount']),
|
290 |
+
"paymentMethod"
|
291 |
+
);
|
292 |
+
} else if (isset($response['paymentMethodNonce'])) {
|
293 |
+
return new Result\Successful(
|
294 |
+
PaymentMethodNonce::factory($response['paymentMethodNonce']),
|
295 |
+
"paymentMethodNonce"
|
296 |
+
);
|
297 |
+
} else if (isset($response['apiErrorResponse'])) {
|
298 |
+
return new Result\Error($response['apiErrorResponse']);
|
299 |
+
} else if (is_array($response)) {
|
300 |
+
return new Result\Successful(
|
301 |
+
UnknownPaymentMethod::factory($response),
|
302 |
+
"paymentMethod"
|
303 |
+
);
|
304 |
+
} else {
|
305 |
+
throw new Exception\Unexpected(
|
306 |
+
'Expected payment method or apiErrorResponse'
|
307 |
+
);
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* verifies that a valid payment method identifier is being used
|
313 |
+
* @ignore
|
314 |
+
* @param string $identifier
|
315 |
+
* @param Optional $string $identifierType type of identifier supplied, default 'token'
|
316 |
+
* @throws InvalidArgumentException
|
317 |
+
*/
|
318 |
+
private function _validateId($identifier = null, $identifierType = 'token')
|
319 |
+
{
|
320 |
+
if (empty($identifier)) {
|
321 |
+
throw new InvalidArgumentException(
|
322 |
+
'expected payment method id to be set'
|
323 |
+
);
|
324 |
+
}
|
325 |
+
if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) {
|
326 |
+
throw new InvalidArgumentException(
|
327 |
+
$identifier . ' is an invalid payment method ' . $identifierType . '.'
|
328 |
+
);
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
class_alias('Braintree\PaymentMethodGateway', 'Braintree_PaymentMethodGateway');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Plan.php
RENAMED
@@ -1,21 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
{
|
4 |
-
public static function all()
|
5 |
-
{
|
6 |
-
$response = Braintree_Http::get('/plans');
|
7 |
-
if (key_exists('plans', $response)){
|
8 |
-
$plans = array("plan" => $response['plans']);
|
9 |
-
} else {
|
10 |
-
$plans = array("plan" => array());
|
11 |
-
}
|
12 |
-
|
13 |
-
return Braintree_Util::extractAttributeAsArray(
|
14 |
-
$plans,
|
15 |
-
'plan'
|
16 |
-
);
|
17 |
-
}
|
18 |
|
|
|
|
|
19 |
public static function factory($attributes)
|
20 |
{
|
21 |
$instance = new self();
|
@@ -28,28 +15,37 @@ class Braintree_Plan extends Braintree
|
|
28 |
{
|
29 |
$this->_attributes = $attributes;
|
30 |
|
31 |
-
$addOnArray =
|
32 |
if (isset($attributes['addOns'])) {
|
33 |
foreach ($attributes['addOns'] AS $addOn) {
|
34 |
-
$addOnArray[] =
|
35 |
}
|
36 |
}
|
37 |
$this->_attributes['addOns'] = $addOnArray;
|
38 |
|
39 |
-
$discountArray =
|
40 |
if (isset($attributes['discounts'])) {
|
41 |
foreach ($attributes['discounts'] AS $discount) {
|
42 |
-
$discountArray[] =
|
43 |
}
|
44 |
}
|
45 |
$this->_attributes['discounts'] = $discountArray;
|
46 |
|
47 |
-
$planArray =
|
48 |
if (isset($attributes['plans'])) {
|
49 |
foreach ($attributes['plans'] AS $plan) {
|
50 |
-
$planArray[] =
|
51 |
}
|
52 |
}
|
53 |
$this->_attributes['plans'] = $planArray;
|
54 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
class Plan extends Base
|
5 |
+
{
|
6 |
public static function factory($attributes)
|
7 |
{
|
8 |
$instance = new self();
|
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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/RangeNode.php
RENAMED
@@ -1,38 +1,40 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
-
function __construct($name)
|
6 |
{
|
7 |
$this->name = $name;
|
8 |
-
$this->searchTerms =
|
9 |
}
|
10 |
|
11 |
-
function greaterThanOrEqualTo($value)
|
12 |
{
|
13 |
$this->searchTerms['min'] = $value;
|
14 |
return $this;
|
15 |
}
|
16 |
|
17 |
-
function lessThanOrEqualTo($value)
|
18 |
{
|
19 |
$this->searchTerms['max'] = $value;
|
20 |
return $this;
|
21 |
}
|
22 |
|
23 |
-
function is($value)
|
24 |
{
|
25 |
$this->searchTerms['is'] = $value;
|
26 |
return $this;
|
27 |
}
|
28 |
|
29 |
-
function between($min, $max)
|
30 |
{
|
31 |
return $this->greaterThanOrEqualTo($min)->lessThanOrEqualTo($max);
|
32 |
}
|
33 |
|
34 |
-
function toParam()
|
35 |
{
|
36 |
return $this->searchTerms;
|
37 |
}
|
38 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree;
|
3 |
|
4 |
+
class RangeNode
|
5 |
{
|
6 |
+
public function __construct($name)
|
7 |
{
|
8 |
$this->name = $name;
|
9 |
+
$this->searchTerms = [];
|
10 |
}
|
11 |
|
12 |
+
public function greaterThanOrEqualTo($value)
|
13 |
{
|
14 |
$this->searchTerms['min'] = $value;
|
15 |
return $this;
|
16 |
}
|
17 |
|
18 |
+
public function lessThanOrEqualTo($value)
|
19 |
{
|
20 |
$this->searchTerms['max'] = $value;
|
21 |
return $this;
|
22 |
}
|
23 |
|
24 |
+
public function is($value)
|
25 |
{
|
26 |
$this->searchTerms['is'] = $value;
|
27 |
return $this;
|
28 |
}
|
29 |
|
30 |
+
public function between($min, $max)
|
31 |
{
|
32 |
return $this->greaterThanOrEqualTo($min)->lessThanOrEqualTo($max);
|
33 |
}
|
34 |
|
35 |
+
public function toParam()
|
36 |
{
|
37 |
return $this->searchTerms;
|
38 |
}
|
39 |
}
|
40 |
+
class_alias('Braintree\RangeNode', 'Braintree_RangeNode');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/ResourceCollection.php
RENAMED
@@ -1,20 +1,17 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Utility
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
|
|
11 |
* ResourceCollection is a container object for result data
|
12 |
*
|
13 |
* stores and retrieves search results and aggregate data
|
14 |
*
|
15 |
* example:
|
16 |
* <code>
|
17 |
-
* $result =
|
18 |
*
|
19 |
* foreach($result as $transaction) {
|
20 |
* print_r($transaction->id);
|
@@ -23,12 +20,13 @@
|
|
23 |
*
|
24 |
* @package Braintree
|
25 |
* @subpackage Utility
|
26 |
-
* @copyright
|
27 |
*/
|
28 |
-
class
|
29 |
{
|
30 |
-
private $_index;
|
31 |
private $_batchIndex;
|
|
|
|
|
32 |
private $_items;
|
33 |
private $_pageSize;
|
34 |
private $_pager;
|
@@ -38,8 +36,8 @@ class Braintree_ResourceCollection implements Iterator
|
|
38 |
*
|
39 |
* expects an array of attributes with literal keys
|
40 |
*
|
41 |
-
* @param array $
|
42 |
-
* @param array $
|
43 |
*/
|
44 |
public function __construct($response, $pager)
|
45 |
{
|
@@ -64,7 +62,7 @@ class Braintree_ResourceCollection implements Iterator
|
|
64 |
public function firstItem()
|
65 |
{
|
66 |
$ids = $this->_ids;
|
67 |
-
$page = $this->_getPage(
|
68 |
return $page[0];
|
69 |
}
|
70 |
|
@@ -82,7 +80,7 @@ class Braintree_ResourceCollection implements Iterator
|
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
-
* rewinds
|
86 |
*/
|
87 |
public function rewind()
|
88 |
{
|
@@ -115,7 +113,7 @@ class Braintree_ResourceCollection implements Iterator
|
|
115 |
{
|
116 |
if (empty($this->_ids))
|
117 |
{
|
118 |
-
$this->_items =
|
119 |
}
|
120 |
else
|
121 |
{
|
@@ -128,21 +126,32 @@ class Braintree_ResourceCollection implements Iterator
|
|
128 |
/**
|
129 |
* requests the next page of results for the collection
|
130 |
*
|
131 |
-
* @return
|
132 |
*/
|
133 |
private function _getPage($ids)
|
134 |
{
|
135 |
-
$
|
136 |
-
$
|
137 |
-
$methodArgs =
|
138 |
foreach ($this->_pager['methodArgs'] as $arg) {
|
139 |
array_push($methodArgs, $arg);
|
140 |
}
|
141 |
array_push($methodArgs, $ids);
|
142 |
|
143 |
return call_user_func_array(
|
144 |
-
|
145 |
$methodArgs
|
146 |
);
|
147 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
|
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);
|
20 |
*
|
21 |
* @package Braintree
|
22 |
* @subpackage Utility
|
23 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
24 |
*/
|
25 |
+
class ResourceCollection implements Iterator
|
26 |
{
|
|
|
27 |
private $_batchIndex;
|
28 |
+
private $_ids;
|
29 |
+
private $_index;
|
30 |
private $_items;
|
31 |
private $_pageSize;
|
32 |
private $_pager;
|
36 |
*
|
37 |
* expects an array of attributes with literal keys
|
38 |
*
|
39 |
+
* @param array $response
|
40 |
+
* @param array $pager
|
41 |
*/
|
42 |
public function __construct($response, $pager)
|
43 |
{
|
62 |
public function firstItem()
|
63 |
{
|
64 |
$ids = $this->_ids;
|
65 |
+
$page = $this->_getPage([$ids[0]]);
|
66 |
return $page[0];
|
67 |
}
|
68 |
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* rewinds the testIterateOverResults collection to the first item when iterating with foreach
|
84 |
*/
|
85 |
public function rewind()
|
86 |
{
|
113 |
{
|
114 |
if (empty($this->_ids))
|
115 |
{
|
116 |
+
$this->_items = [];
|
117 |
}
|
118 |
else
|
119 |
{
|
126 |
/**
|
127 |
* requests the next page of results for the collection
|
128 |
*
|
129 |
+
* @return void
|
130 |
*/
|
131 |
private function _getPage($ids)
|
132 |
{
|
133 |
+
$object = $this->_pager['object'];
|
134 |
+
$method = $this->_pager['method'];
|
135 |
+
$methodArgs = [];
|
136 |
foreach ($this->_pager['methodArgs'] as $arg) {
|
137 |
array_push($methodArgs, $arg);
|
138 |
}
|
139 |
array_push($methodArgs, $ids);
|
140 |
|
141 |
return call_user_func_array(
|
142 |
+
[$object, $method],
|
143 |
$methodArgs
|
144 |
);
|
145 |
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* returns all IDs in the collection
|
149 |
+
*
|
150 |
+
* @return array
|
151 |
+
*/
|
152 |
+
public function getIds()
|
153 |
+
{
|
154 |
+
return $this->_ids;
|
155 |
+
}
|
156 |
}
|
157 |
+
class_alias('Braintree\ResourceCollection', 'Braintree_ResourceCollection');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Result/CreditCardVerification.php
RENAMED
@@ -1,11 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
* @subpackage Result
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
11 |
* Braintree Credit Card Verification Result
|
@@ -16,7 +13,7 @@
|
|
16 |
*
|
17 |
* @package Braintree
|
18 |
* @subpackage Result
|
19 |
-
* @copyright
|
20 |
*
|
21 |
* @property-read string $avsErrorResponseCode
|
22 |
* @property-read string $avsPostalCodeResponseCode
|
@@ -25,7 +22,7 @@
|
|
25 |
* @property-read string $status
|
26 |
*
|
27 |
*/
|
28 |
-
class
|
29 |
{
|
30 |
// Status
|
31 |
const FAILED = 'failed';
|
@@ -48,24 +45,29 @@ class Braintree_Result_CreditCardVerification
|
|
48 |
{
|
49 |
$this->_initializeFromArray($attributes);
|
50 |
}
|
|
|
51 |
/**
|
52 |
* initializes instance properties from the keys/values of an array
|
53 |
* @ignore
|
54 |
* @access protected
|
55 |
* @param <type> $aAttribs array of properties to set - single level
|
56 |
-
* @return
|
57 |
*/
|
58 |
private function _initializeFromArray($attributes)
|
59 |
{
|
|
|
|
|
|
|
|
|
|
|
60 |
$this->_attributes = $attributes;
|
61 |
foreach($attributes AS $name => $value) {
|
62 |
$varName = "_$name";
|
63 |
$this->$varName = $value;
|
64 |
-
// $this->$varName = Braintree_Util::delimiterToCamelCase($value, '_');
|
65 |
}
|
66 |
}
|
|
|
67 |
/**
|
68 |
-
*
|
69 |
* @ignore
|
70 |
*/
|
71 |
public function __get($name)
|
@@ -81,6 +83,17 @@ class Braintree_Result_CreditCardVerification
|
|
81 |
public function __toString()
|
82 |
{
|
83 |
return __CLASS__ . '[' .
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree\Result;
|
3 |
+
|
4 |
+
use Braintree\RiskData;
|
5 |
+
use Braintree\Util;
|
|
|
|
|
|
|
6 |
|
7 |
/**
|
8 |
* Braintree Credit Card Verification Result
|
13 |
*
|
14 |
* @package Braintree
|
15 |
* @subpackage Result
|
16 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
17 |
*
|
18 |
* @property-read string $avsErrorResponseCode
|
19 |
* @property-read string $avsPostalCodeResponseCode
|
22 |
* @property-read string $status
|
23 |
*
|
24 |
*/
|
25 |
+
class CreditCardVerification
|
26 |
{
|
27 |
// Status
|
28 |
const FAILED = 'failed';
|
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)
|
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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Result/Error.php
RENAMED
@@ -1,11 +1,12 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
9 |
|
10 |
/**
|
11 |
* Braintree Error Result
|
@@ -17,27 +18,26 @@
|
|
17 |
* respond to the void request if it failed:
|
18 |
*
|
19 |
* <code>
|
20 |
-
* $result =
|
21 |
* if ($result->success) {
|
22 |
* // Successful Result
|
23 |
* } else {
|
24 |
-
* //
|
25 |
* }
|
26 |
* </code>
|
27 |
*
|
28 |
* @package Braintree
|
29 |
* @subpackage Result
|
30 |
-
* @copyright
|
31 |
*
|
32 |
* @property-read array $params original passed params
|
33 |
-
* @property-read
|
34 |
-
* @property-read
|
35 |
*/
|
36 |
-
class
|
37 |
{
|
38 |
-
|
39 |
-
*
|
40 |
-
* @var boolean always false
|
41 |
*/
|
42 |
public $success = false;
|
43 |
|
@@ -54,9 +54,13 @@ class Braintree_Result_Error extends Braintree
|
|
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[
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
-
$finalKey = Braintree_Util::delimiterToCamelCase(end($pieces));
|
60 |
$fieldValue = isset($params[$finalKey]) ? $params[$finalKey] : null;
|
61 |
return $fieldValue;
|
62 |
}
|
@@ -69,39 +73,52 @@ class Braintree_Result_Error extends Braintree
|
|
69 |
public function __construct($response)
|
70 |
{
|
71 |
$this->_attributes = $response;
|
72 |
-
$this->_set('errors', new
|
73 |
|
74 |
if(isset($response['verification'])) {
|
75 |
-
$this->_set('creditCardVerification', new
|
76 |
} else {
|
77 |
$this->_set('creditCardVerification', null);
|
78 |
}
|
79 |
|
80 |
if(isset($response['transaction'])) {
|
81 |
-
$this->_set('transaction',
|
82 |
} else {
|
83 |
$this->_set('transaction', null);
|
84 |
}
|
85 |
|
86 |
if(isset($response['subscription'])) {
|
87 |
-
$this->_set('subscription',
|
88 |
} else {
|
89 |
$this->_set('subscription', null);
|
90 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
* create a printable representation of the object as:
|
95 |
* ClassName[property=value, property=value]
|
96 |
* @ignore
|
97 |
-
* @return
|
98 |
*/
|
99 |
public function __toString()
|
100 |
{
|
101 |
-
$output =
|
102 |
if (isset($this->_creditCardVerification)) {
|
103 |
$output .= sprintf('%s', $this->_creditCardVerification);
|
104 |
}
|
105 |
-
return __CLASS__ .'['
|
106 |
}
|
107 |
}
|
|
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
|
18 |
* respond to the void request if it failed:
|
19 |
*
|
20 |
* <code>
|
21 |
+
* $result = Transaction::void('abc123');
|
22 |
* if ($result->success) {
|
23 |
* // Successful Result
|
24 |
* } else {
|
25 |
+
* // Result\Error
|
26 |
* }
|
27 |
* </code>
|
28 |
*
|
29 |
* @package Braintree
|
30 |
* @subpackage Result
|
31 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
32 |
*
|
33 |
* @property-read array $params original passed params
|
34 |
+
* @property-read \Braintree\Error\ErrorCollection $errors
|
35 |
+
* @property-read \Braintree\Result\CreditCardVerification $creditCardVerification credit card verification data
|
36 |
*/
|
37 |
+
class Error extends Base
|
38 |
{
|
39 |
+
/**
|
40 |
+
* @var bool always false
|
|
|
41 |
*/
|
42 |
public $success = false;
|
43 |
|
54 |
$pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
|
55 |
$params = $this->params;
|
56 |
foreach(array_slice($pieces, 0, -1) as $key) {
|
57 |
+
$params = $params[Util::delimiterToCamelCase($key)];
|
58 |
+
}
|
59 |
+
if ($key != 'custom_fields') {
|
60 |
+
$finalKey = Util::delimiterToCamelCase(end($pieces));
|
61 |
+
} else {
|
62 |
+
$finalKey = end($pieces);
|
63 |
}
|
|
|
64 |
$fieldValue = isset($params[$finalKey]) ? $params[$finalKey] : null;
|
65 |
return $fieldValue;
|
66 |
}
|
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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Test/CreditCardNumbers.php
RENAMED
@@ -1,68 +1,67 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
* Credit card information used for testing purposes
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Test
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
11 |
* Credit card information used for testing purposes
|
12 |
*
|
13 |
-
* The constants contained in the
|
14 |
* credit card numbers that should be used when working in the sandbox environment.
|
15 |
* The sandbox will not accept any credit card numbers other than the ones listed below.
|
16 |
*
|
17 |
* @package Braintree
|
18 |
* @subpackage Test
|
19 |
-
* @copyright
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
-
public static $amExes =
|
24 |
'378282246310005',
|
25 |
'371449635398431',
|
26 |
'378734493671000',
|
27 |
-
|
28 |
-
public static $carteBlanches =
|
29 |
-
public static $dinersClubs =
|
30 |
-
public static $discoverCards =
|
31 |
'6011111111111117',
|
32 |
'6011000990139424',
|
33 |
-
|
34 |
-
public static $JCBs =
|
35 |
'3530111333300000',
|
36 |
'3566002020360505',
|
37 |
-
|
38 |
|
39 |
public static $masterCard = '5555555555554444';
|
40 |
public static $masterCardInternational = '5105105105105100';
|
41 |
-
public static $masterCards =
|
42 |
'5105105105105100',
|
43 |
'5555555555554444',
|
44 |
-
|
45 |
|
46 |
public static $visa = '4012888888881881';
|
47 |
public static $visaInternational = '4009348888881881';
|
48 |
-
public static $visas =
|
49 |
'4009348888881881',
|
50 |
'4012888888881881',
|
51 |
'4111111111111111',
|
52 |
'4000111111111115',
|
53 |
-
|
54 |
|
55 |
-
public static $unknowns =
|
56 |
'1000000000000008',
|
57 |
-
|
58 |
|
59 |
-
public static $failsSandboxVerification =
|
60 |
'AmEx' => '378734493671000',
|
61 |
'Discover' => '6011000990139424',
|
62 |
'MasterCard' => '5105105105105100',
|
63 |
'Visa' => '4000111111111115',
|
64 |
-
|
65 |
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
public static function getAll()
|
68 |
{
|
@@ -74,3 +73,4 @@ class Braintree_Test_CreditCardNumbers
|
|
74 |
);
|
75 |
}
|
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 |
{
|
73 |
);
|
74 |
}
|
75 |
}
|
76 |
+
class_alias('Braintree\Test\CreditCardNumbers', 'Braintree_Test_CreditCardNumbers');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Test/TransactionAmounts.php
RENAMED
@@ -1,11 +1,5 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
* Transaction amounts used for testing purposes
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Test
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
11 |
* Transaction amounts used for testing purposes
|
@@ -15,10 +9,11 @@
|
|
15 |
*
|
16 |
* @package Braintree
|
17 |
* @subpackage Test
|
18 |
-
* @copyright
|
19 |
*/
|
20 |
-
class
|
21 |
{
|
22 |
public static $authorize = '1000.00';
|
23 |
public static $decline = '2000.00';
|
24 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree\Test;
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
/**
|
5 |
* Transaction amounts used for testing purposes
|
9 |
*
|
10 |
* @package Braintree
|
11 |
* @subpackage Test
|
12 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
13 |
*/
|
14 |
+
class TransactionAmounts
|
15 |
{
|
16 |
public static $authorize = '1000.00';
|
17 |
public static $decline = '2000.00';
|
18 |
}
|
19 |
+
class_alias('Braintree\Test\TransactionAmounts', 'Braintree_Test_TransactionAmounts');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/AddressDetails.php
RENAMED
@@ -1,11 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Transaction
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
11 |
* Creates an instance of AddressDetails as returned from a transaction
|
@@ -13,7 +9,7 @@
|
|
13 |
*
|
14 |
* @package Braintree
|
15 |
* @subpackage Transaction
|
16 |
-
* @copyright
|
17 |
*
|
18 |
* @property-read string $firstName
|
19 |
* @property-read string $lastName
|
@@ -24,9 +20,9 @@
|
|
24 |
* @property-read string $region
|
25 |
* @property-read string $postalCode
|
26 |
* @property-read string $countryName
|
27 |
-
* @uses Braintree_Instance inherits methods
|
28 |
*/
|
29 |
-
class
|
30 |
{
|
31 |
-
protected $_attributes =
|
32 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree\Transaction;
|
3 |
+
|
4 |
+
use Braintree\Instance;
|
|
|
|
|
|
|
|
|
5 |
|
6 |
/**
|
7 |
* Creates an instance of AddressDetails 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 $firstName
|
15 |
* @property-read string $lastName
|
20 |
* @property-read string $region
|
21 |
* @property-read string $postalCode
|
22 |
* @property-read string $countryName
|
|
|
23 |
*/
|
24 |
+
class AddressDetails extends Instance
|
25 |
{
|
26 |
+
protected $_attributes = [];
|
27 |
}
|
28 |
+
class_alias('Braintree\Transaction\AddressDetails', 'Braintree_Transaction_AddressDetails');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/CreditCardDetails.php
RENAMED
@@ -1,19 +1,15 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Transaction
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
|
|
11 |
* creates an instance of CreditCardDetails
|
12 |
*
|
13 |
-
*
|
14 |
* @package Braintree
|
15 |
* @subpackage Transaction
|
16 |
-
* @copyright
|
17 |
*
|
18 |
* @property-read string $bin
|
19 |
* @property-read string $cardType
|
@@ -24,11 +20,10 @@
|
|
24 |
* @property-read string $last4
|
25 |
* @property-read string $maskedNumber
|
26 |
* @property-read string $token
|
27 |
-
* @uses Braintree_Instance inherits methods
|
28 |
*/
|
29 |
-
class
|
30 |
{
|
31 |
-
protected $_attributes =
|
32 |
|
33 |
/**
|
34 |
* @ignore
|
@@ -41,3 +36,4 @@ class Braintree_Transaction_CreditCardDetails extends Braintree_Instance
|
|
41 |
|
42 |
}
|
43 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree\Transaction;
|
3 |
+
|
4 |
+
use Braintree\Instance;
|
|
|
|
|
|
|
|
|
5 |
|
6 |
/**
|
7 |
+
* CreditCard details from a transaction
|
8 |
* creates an instance of CreditCardDetails
|
9 |
*
|
|
|
10 |
* @package Braintree
|
11 |
* @subpackage Transaction
|
12 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
13 |
*
|
14 |
* @property-read string $bin
|
15 |
* @property-read string $cardType
|
20 |
* @property-read string $last4
|
21 |
* @property-read string $maskedNumber
|
22 |
* @property-read string $token
|
|
|
23 |
*/
|
24 |
+
class CreditCardDetails extends Instance
|
25 |
{
|
26 |
+
protected $_attributes = [];
|
27 |
|
28 |
/**
|
29 |
* @ignore
|
36 |
|
37 |
}
|
38 |
}
|
39 |
+
class_alias('Braintree\Transaction\CreditCardDetails', 'Braintree_Transaction_CreditCardDetails');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/CustomerDetails.php
RENAMED
@@ -1,18 +1,15 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Transaction
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
|
|
11 |
* Creates an instance of customer details as returned from a transaction
|
12 |
*
|
13 |
* @package Braintree
|
14 |
* @subpackage Transaction
|
15 |
-
* @copyright
|
16 |
*
|
17 |
* @property-read string $company
|
18 |
* @property-read string $email
|
@@ -22,8 +19,8 @@
|
|
22 |
* @property-read string $lastName
|
23 |
* @property-read string $phone
|
24 |
* @property-read string $website
|
25 |
-
* @uses Braintree_Instance inherits methods
|
26 |
*/
|
27 |
-
class
|
28 |
{
|
29 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree\Transaction;
|
3 |
+
|
4 |
+
use Braintree\Instance;
|
|
|
|
|
|
|
|
|
5 |
|
6 |
/**
|
7 |
+
* Customer details from a transaction
|
8 |
* Creates an instance of customer details as returned from a transaction
|
9 |
*
|
10 |
* @package Braintree
|
11 |
* @subpackage Transaction
|
12 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
13 |
*
|
14 |
* @property-read string $company
|
15 |
* @property-read string $email
|
19 |
* @property-read string $lastName
|
20 |
* @property-read string $phone
|
21 |
* @property-read string $website
|
|
|
22 |
*/
|
23 |
+
class CustomerDetails extends Instance
|
24 |
{
|
25 |
}
|
26 |
+
class_alias('Braintree\Transaction\CustomerDetails', 'Braintree_Transaction_CustomerDetails');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/StatusDetails.php
RENAMED
@@ -1,25 +1,22 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Transaction
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
|
|
11 |
* Creates an instance of StatusDetails, as part of a transaction response
|
12 |
*
|
13 |
* @package Braintree
|
14 |
-
* @copyright
|
15 |
*
|
16 |
* @property-read string $amount
|
17 |
* @property-read string $status
|
18 |
* @property-read string $timestamp
|
19 |
* @property-read string $transactionSource
|
20 |
* @property-read string $user
|
21 |
-
* @uses Braintree_Instance inherits methods
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
}
|
|
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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Transaction/SubscriptionDetails.php
RENAMED
@@ -1,22 +1,20 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Transaction
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
|
10 |
/**
|
|
|
11 |
* Creates an instance of customer details as returned from a transaction
|
12 |
*
|
13 |
* @package Braintree
|
14 |
* @subpackage Transaction
|
15 |
-
* @copyright
|
16 |
*
|
17 |
* @property-read string $billing_period_start_date
|
18 |
* @property-read string $billing_period_end_date
|
19 |
*/
|
20 |
-
class
|
21 |
{
|
22 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree\Transaction;
|
3 |
+
|
4 |
+
use Braintree\Instance;
|
|
|
|
|
|
|
|
|
5 |
|
6 |
/**
|
7 |
+
* Customer details from a transaction
|
8 |
* Creates an instance of customer details as returned from a transaction
|
9 |
*
|
10 |
* @package Braintree
|
11 |
* @subpackage Transaction
|
12 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
13 |
*
|
14 |
* @property-read string $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');
|
includes/lib/Braintree/lib/Braintree/Transaction/UsBankAccountDetails.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Braintree\Transaction;
|
3 |
+
|
4 |
+
use Braintree\Instance;
|
5 |
+
use Braintree\AchMandate;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* CreditCard details from a transaction
|
9 |
+
* creates an instance of UsbankAccountDetails
|
10 |
+
*
|
11 |
+
* @package Braintree
|
12 |
+
* @subpackage Transaction
|
13 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
14 |
+
*
|
15 |
+
* @property-read string $token
|
16 |
+
* @property-read string $imageUrl
|
17 |
+
* @property-read string $routingNumber
|
18 |
+
* @property-read string $accountType
|
19 |
+
* @property-read string $accountHolderName
|
20 |
+
* @property-read string $last4
|
21 |
+
* @property-read string $bankName
|
22 |
+
* @property-read string $achMandate
|
23 |
+
*/
|
24 |
+
class UsBankAccountDetails extends Instance
|
25 |
+
{
|
26 |
+
protected $_attributes = [];
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @ignore
|
30 |
+
*/
|
31 |
+
public function __construct($attributes)
|
32 |
+
{
|
33 |
+
parent::__construct($attributes);
|
34 |
+
|
35 |
+
$achMandate = isset($attributes['achMandate']) ?
|
36 |
+
AchMandate::factory($attributes['achMandate']) :
|
37 |
+
null;
|
38 |
+
$this->achMandate = $achMandate;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
class_alias('Braintree\Transaction\UsBankAccountDetails', 'Braintree_Transaction_UsBankAccountDetails');
|
includes/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');
|
includes/lib/Braintree/lib/Braintree/TransactionGateway.php
ADDED
@@ -0,0 +1,530 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
'skipAdvancedFraudChecking',
|
175 |
+
['threeDSecure' =>
|
176 |
+
['required']
|
177 |
+
],
|
178 |
+
# Included for backwards compatiblity. Remove in the next major version
|
179 |
+
['three_d_secure' =>
|
180 |
+
['required']
|
181 |
+
],
|
182 |
+
['paypal' =>
|
183 |
+
[
|
184 |
+
'payeeEmail',
|
185 |
+
'customField',
|
186 |
+
'description',
|
187 |
+
['supplementaryData' => ['_anyKey_']],
|
188 |
+
]
|
189 |
+
],
|
190 |
+
['amexRewards' =>
|
191 |
+
[
|
192 |
+
'requestId',
|
193 |
+
'points',
|
194 |
+
'currencyAmount',
|
195 |
+
'currencyIsoCode'
|
196 |
+
]
|
197 |
+
]
|
198 |
+
],
|
199 |
+
],
|
200 |
+
['customFields' => ['_anyKey_']],
|
201 |
+
['descriptor' => ['name', 'phone', 'url']],
|
202 |
+
['paypalAccount' => ['payeeEmail']],
|
203 |
+
['apple_pay_card' => ['number', 'cardholder_name', 'cryptogram', 'expiration_month', 'expiration_year']], #backwards compatibility
|
204 |
+
['applePayCard' => ['number', 'cardholderName', 'cryptogram', 'expirationMonth', 'expirationYear']],
|
205 |
+
['industry' =>
|
206 |
+
['industryType',
|
207 |
+
['data' =>
|
208 |
+
[
|
209 |
+
'folioNumber',
|
210 |
+
'checkInDate',
|
211 |
+
'checkOutDate',
|
212 |
+
'travelPackage',
|
213 |
+
'departureDate',
|
214 |
+
'lodgingCheckInDate',
|
215 |
+
'lodgingCheckOutDate',
|
216 |
+
'lodgingName',
|
217 |
+
'roomRate'
|
218 |
+
]
|
219 |
+
]
|
220 |
+
]
|
221 |
+
]
|
222 |
+
];
|
223 |
+
}
|
224 |
+
|
225 |
+
public static function submitForSettlementSignature()
|
226 |
+
{
|
227 |
+
return ['orderId', ['descriptor' => ['name', 'phone', 'url']]];
|
228 |
+
}
|
229 |
+
|
230 |
+
public static function updateDetailsSignature()
|
231 |
+
{
|
232 |
+
return ['amount', 'orderId', ['descriptor' => ['name', 'phone', 'url']]];
|
233 |
+
}
|
234 |
+
|
235 |
+
public static function refundSignature()
|
236 |
+
{
|
237 |
+
return ['amount', 'orderId'];
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
*
|
242 |
+
* @access public
|
243 |
+
* @param array $attribs
|
244 |
+
* @return Result\Successful|Result\Error
|
245 |
+
*/
|
246 |
+
public function credit($attribs)
|
247 |
+
{
|
248 |
+
return $this->create(array_merge($attribs, ['type' => Transaction::CREDIT]));
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
*
|
253 |
+
* @access public
|
254 |
+
* @param array $attribs
|
255 |
+
* @return Result\Successful|Result\Error
|
256 |
+
* @throws Exception\ValidationError
|
257 |
+
*/
|
258 |
+
public function creditNoValidate($attribs)
|
259 |
+
{
|
260 |
+
$result = $this->credit($attribs);
|
261 |
+
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @access public
|
266 |
+
* @param string id
|
267 |
+
* @return Transaction
|
268 |
+
*/
|
269 |
+
public function find($id)
|
270 |
+
{
|
271 |
+
$this->_validateId($id);
|
272 |
+
try {
|
273 |
+
$path = $this->_config->merchantPath() . '/transactions/' . $id;
|
274 |
+
$response = $this->_http->get($path);
|
275 |
+
return Transaction::factory($response['transaction']);
|
276 |
+
} catch (Exception\NotFound $e) {
|
277 |
+
throw new Exception\NotFound(
|
278 |
+
'transaction with id ' . $id . ' not found'
|
279 |
+
);
|
280 |
+
}
|
281 |
+
}
|
282 |
+
/**
|
283 |
+
* new sale
|
284 |
+
* @param array $attribs
|
285 |
+
* @return array
|
286 |
+
*/
|
287 |
+
public function sale($attribs)
|
288 |
+
{
|
289 |
+
return $this->create(array_merge(['type' => Transaction::SALE], $attribs));
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* roughly equivalent to the ruby bang method
|
294 |
+
* @access public
|
295 |
+
* @param array $attribs
|
296 |
+
* @return array
|
297 |
+
* @throws Exception\ValidationsFailed
|
298 |
+
*/
|
299 |
+
public function saleNoValidate($attribs)
|
300 |
+
{
|
301 |
+
$result = $this->sale($attribs);
|
302 |
+
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Returns a ResourceCollection of transactions matching the search query.
|
307 |
+
*
|
308 |
+
* If <b>query</b> is a string, the search will be a basic search.
|
309 |
+
* If <b>query</b> is a hash, the search will be an advanced search.
|
310 |
+
* For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/transaction-api#searching http://www.braintreepaymentsolutions.com/gateway/transaction-api}
|
311 |
+
*
|
312 |
+
* @param mixed $query search query
|
313 |
+
* @param array $options options such as page number
|
314 |
+
* @return ResourceCollection
|
315 |
+
* @throws InvalidArgumentException
|
316 |
+
*/
|
317 |
+
public function search($query)
|
318 |
+
{
|
319 |
+
$criteria = [];
|
320 |
+
foreach ($query as $term) {
|
321 |
+
$criteria[$term->name] = $term->toparam();
|
322 |
+
}
|
323 |
+
|
324 |
+
$path = $this->_config->merchantPath() . '/transactions/advanced_search_ids';
|
325 |
+
$response = $this->_http->post($path, ['search' => $criteria]);
|
326 |
+
if (array_key_exists('searchResults', $response)) {
|
327 |
+
$pager = [
|
328 |
+
'object' => $this,
|
329 |
+
'method' => 'fetch',
|
330 |
+
'methodArgs' => [$query]
|
331 |
+
];
|
332 |
+
|
333 |
+
return new ResourceCollection($response, $pager);
|
334 |
+
} else {
|
335 |
+
throw new Exception\DownForMaintenance();
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
public function fetch($query, $ids)
|
340 |
+
{
|
341 |
+
$criteria = [];
|
342 |
+
foreach ($query as $term) {
|
343 |
+
$criteria[$term->name] = $term->toparam();
|
344 |
+
}
|
345 |
+
$criteria["ids"] = TransactionSearch::ids()->in($ids)->toparam();
|
346 |
+
$path = $this->_config->merchantPath() . '/transactions/advanced_search';
|
347 |
+
$response = $this->_http->post($path, ['search' => $criteria]);
|
348 |
+
|
349 |
+
if (array_key_exists('creditCardTransactions', $response)) {
|
350 |
+
return Util::extractattributeasarray(
|
351 |
+
$response['creditCardTransactions'],
|
352 |
+
'transaction'
|
353 |
+
);
|
354 |
+
} else {
|
355 |
+
throw new Exception\DownForMaintenance();
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* void a transaction by id
|
361 |
+
*
|
362 |
+
* @param string $id transaction id
|
363 |
+
* @return Result\Successful|Result\Error
|
364 |
+
*/
|
365 |
+
public function void($transactionId)
|
366 |
+
{
|
367 |
+
$this->_validateId($transactionId);
|
368 |
+
|
369 |
+
$path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/void';
|
370 |
+
$response = $this->_http->put($path);
|
371 |
+
return $this->_verifyGatewayResponse($response);
|
372 |
+
}
|
373 |
+
/**
|
374 |
+
*
|
375 |
+
*/
|
376 |
+
public function voidNoValidate($transactionId)
|
377 |
+
{
|
378 |
+
$result = $this->void($transactionId);
|
379 |
+
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
380 |
+
}
|
381 |
+
|
382 |
+
public function submitForSettlement($transactionId, $amount = null, $attribs = [])
|
383 |
+
{
|
384 |
+
$this->_validateId($transactionId);
|
385 |
+
Util::verifyKeys(self::submitForSettlementSignature(), $attribs);
|
386 |
+
$attribs['amount'] = $amount;
|
387 |
+
|
388 |
+
$path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_settlement';
|
389 |
+
$response = $this->_http->put($path, ['transaction' => $attribs]);
|
390 |
+
return $this->_verifyGatewayResponse($response);
|
391 |
+
}
|
392 |
+
|
393 |
+
public function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = [])
|
394 |
+
{
|
395 |
+
$result = $this->submitForSettlement($transactionId, $amount, $attribs);
|
396 |
+
return Util::returnObjectOrThrowException(__CLASS__, $result);
|
397 |
+
}
|
398 |
+
|
399 |
+
public function updateDetails($transactionId, $attribs = [])
|
400 |
+
{
|
401 |
+
$this->_validateId($transactionId);
|
402 |
+
Util::verifyKeys(self::updateDetailsSignature(), $attribs);
|
403 |
+
|
404 |
+
$path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/update_details';
|
405 |
+
$response = $this->_http->put($path, ['transaction' => $attribs]);
|
406 |
+
return $this->_verifyGatewayResponse($response);
|
407 |
+
}
|
408 |
+
|
409 |
+
public function submitForPartialSettlement($transactionId, $amount, $attribs = [])
|
410 |
+
{
|
411 |
+
$this->_validateId($transactionId);
|
412 |
+
Util::verifyKeys(self::submitForSettlementSignature(), $attribs);
|
413 |
+
$attribs['amount'] = $amount;
|
414 |
+
|
415 |
+
$path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_partial_settlement';
|
416 |
+
$response = $this->_http->post($path, ['transaction' => $attribs]);
|
417 |
+
return $this->_verifyGatewayResponse($response);
|
418 |
+
}
|
419 |
+
|
420 |
+
public function holdInEscrow($transactionId)
|
421 |
+
{
|
422 |
+
$this->_validateId($transactionId);
|
423 |
+
|
424 |
+
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/hold_in_escrow';
|
425 |
+
$response = $this->_http->put($path, []);
|
426 |
+
return $this->_verifyGatewayResponse($response);
|
427 |
+
}
|
428 |
+
|
429 |
+
public function releaseFromEscrow($transactionId)
|
430 |
+
{
|
431 |
+
$this->_validateId($transactionId);
|
432 |
+
|
433 |
+
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/release_from_escrow';
|
434 |
+
$response = $this->_http->put($path, []);
|
435 |
+
return $this->_verifyGatewayResponse($response);
|
436 |
+
}
|
437 |
+
|
438 |
+
public function cancelRelease($transactionId)
|
439 |
+
{
|
440 |
+
$this->_validateId($transactionId);
|
441 |
+
|
442 |
+
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/cancel_release';
|
443 |
+
$response = $this->_http->put($path, []);
|
444 |
+
return $this->_verifyGatewayResponse($response);
|
445 |
+
}
|
446 |
+
|
447 |
+
public function refund($transactionId, $amount_or_options = null)
|
448 |
+
{
|
449 |
+
self::_validateId($transactionId);
|
450 |
+
|
451 |
+
if(gettype($amount_or_options) == "array") {
|
452 |
+
$options = $amount_or_options;
|
453 |
+
} else {
|
454 |
+
$options = [
|
455 |
+
"amount" => $amount_or_options
|
456 |
+
];
|
457 |
+
}
|
458 |
+
Util::verifyKeys(self::refundSignature(), $options);
|
459 |
+
|
460 |
+
$params = ['transaction' => $options];
|
461 |
+
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/refund';
|
462 |
+
$response = $this->_http->post($path, $params);
|
463 |
+
return $this->_verifyGatewayResponse($response);
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* sends the create request to the gateway
|
468 |
+
*
|
469 |
+
* @ignore
|
470 |
+
* @param var $subPath
|
471 |
+
* @param array $params
|
472 |
+
* @return mixed
|
473 |
+
*/
|
474 |
+
public function _doCreate($subPath, $params)
|
475 |
+
{
|
476 |
+
$fullPath = $this->_config->merchantPath() . $subPath;
|
477 |
+
$response = $this->_http->post($fullPath, $params);
|
478 |
+
|
479 |
+
return $this->_verifyGatewayResponse($response);
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* verifies that a valid transaction id is being used
|
484 |
+
* @ignore
|
485 |
+
* @param string transaction id
|
486 |
+
* @throws InvalidArgumentException
|
487 |
+
*/
|
488 |
+
private function _validateId($id = null) {
|
489 |
+
if (empty($id)) {
|
490 |
+
throw new InvalidArgumentException(
|
491 |
+
'expected transaction id to be set'
|
492 |
+
);
|
493 |
+
}
|
494 |
+
if (!preg_match('/^[0-9a-z]+$/', $id)) {
|
495 |
+
throw new InvalidArgumentException(
|
496 |
+
$id . ' is an invalid transaction id.'
|
497 |
+
);
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
/**
|
502 |
+
* generic method for validating incoming gateway responses
|
503 |
+
*
|
504 |
+
* creates a new Transaction object and encapsulates
|
505 |
+
* it inside a Result\Successful object, or
|
506 |
+
* encapsulates a Errors object inside a Result\Error
|
507 |
+
* alternatively, throws an Unexpected exception if the response is invalid.
|
508 |
+
*
|
509 |
+
* @ignore
|
510 |
+
* @param array $response gateway response values
|
511 |
+
* @return Result\Successful|Result\Error
|
512 |
+
* @throws Exception\Unexpected
|
513 |
+
*/
|
514 |
+
private function _verifyGatewayResponse($response)
|
515 |
+
{
|
516 |
+
if (isset($response['transaction'])) {
|
517 |
+
// return a populated instance of Transaction
|
518 |
+
return new Result\Successful(
|
519 |
+
Transaction::factory($response['transaction'])
|
520 |
+
);
|
521 |
+
} else if (isset($response['apiErrorResponse'])) {
|
522 |
+
return new Result\Error($response['apiErrorResponse']);
|
523 |
+
} else {
|
524 |
+
throw new Exception\Unexpected(
|
525 |
+
"Expected transaction or apiErrorResponse"
|
526 |
+
);
|
527 |
+
}
|
528 |
+
}
|
529 |
+
}
|
530 |
+
class_alias('Braintree\TransactionGateway', 'Braintree_TransactionGateway');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/lib/Braintree/UsBankAccount.php
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 $routingNumber
|
27 |
+
* @property-read string $accountType
|
28 |
+
* @property-read string $accountHolderName
|
29 |
+
* @property-read string $last4
|
30 |
+
* @property-read string $bankName
|
31 |
+
* @property-read string $achMandate
|
32 |
+
* @property-read string $default
|
33 |
+
*/
|
34 |
+
class UsBankAccount extends Base
|
35 |
+
{
|
36 |
+
/**
|
37 |
+
* factory method: returns an instance of UsBankAccount
|
38 |
+
* to the requesting method, with populated properties
|
39 |
+
*
|
40 |
+
* @ignore
|
41 |
+
* @return UsBankAccount
|
42 |
+
*/
|
43 |
+
public static function factory($attributes)
|
44 |
+
{
|
45 |
+
$instance = new self();
|
46 |
+
$instance->_initialize($attributes);
|
47 |
+
return $instance;
|
48 |
+
}
|
49 |
+
|
50 |
+
/* instance methods */
|
51 |
+
|
52 |
+
/**
|
53 |
+
* sets instance properties from an array of values
|
54 |
+
*
|
55 |
+
* @access protected
|
56 |
+
* @param array $usBankAccountAttribs array of usBankAccount data
|
57 |
+
* @return void
|
58 |
+
*/
|
59 |
+
protected function _initialize($usBankAccountAttribs)
|
60 |
+
{
|
61 |
+
// set the attributes
|
62 |
+
$this->_attributes = $usBankAccountAttribs;
|
63 |
+
|
64 |
+
$achMandate = isset($usBankAccountAttribs['achMandate']) ?
|
65 |
+
AchMandate::factory($usBankAccountAttribs['achMandate']) :
|
66 |
+
null;
|
67 |
+
$this->_set('achMandate', $achMandate);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* create a printable representation of the object as:
|
72 |
+
* ClassName[property=value, property=value]
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function __toString()
|
76 |
+
{
|
77 |
+
return __CLASS__ . '[' .
|
78 |
+
Util::attributesToString($this->_attributes) . ']';
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
// static methods redirecting to gateway
|
83 |
+
|
84 |
+
public static function find($token)
|
85 |
+
{
|
86 |
+
return Configuration::gateway()->usBankAccount()->find($token);
|
87 |
+
}
|
88 |
+
|
89 |
+
public static function sale($token, $transactionAttribs)
|
90 |
+
{
|
91 |
+
$transactionAttribs['options'] = [
|
92 |
+
'submitForSettlement' => true
|
93 |
+
];
|
94 |
+
return Configuration::gateway()->usBankAccount()->sale($token, $transactionAttribs);
|
95 |
+
}
|
96 |
+
}
|
97 |
+
class_alias('Braintree\UsBankAccount', 'Braintree_UsBankAccount');
|
includes/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');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Version.php
RENAMED
@@ -1,24 +1,20 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
* Braintree Library Version
|
4 |
-
*
|
5 |
-
* @copyright 2010 Braintree Payment Solutions
|
6 |
-
*/
|
7 |
|
8 |
/**
|
|
|
9 |
* stores version information about the Braintree library
|
10 |
*
|
11 |
-
*
|
12 |
-
* @copyright 2010 Braintree Payment Solutions
|
13 |
*/
|
14 |
-
|
15 |
{
|
16 |
/**
|
17 |
* class constants
|
18 |
*/
|
19 |
-
const MAJOR =
|
20 |
-
const MINOR =
|
21 |
-
const TINY =
|
22 |
|
23 |
/**
|
24 |
* @ignore
|
@@ -34,6 +30,7 @@ final class Braintree_Version
|
|
34 |
*/
|
35 |
public static function get()
|
36 |
{
|
37 |
-
return self::MAJOR.'.'.self::MINOR.'.'.self::TINY;
|
38 |
}
|
39 |
}
|
|
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 = 21;
|
17 |
+
const TINY = 1;
|
18 |
|
19 |
/**
|
20 |
* @ignore
|
30 |
*/
|
31 |
public static function get()
|
32 |
{
|
33 |
+
return self::MAJOR . '.' . self::MINOR . '.' . self::TINY;
|
34 |
}
|
35 |
}
|
36 |
+
class_alias('Braintree\Version', 'Braintree_Version');
|
includes/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');
|
includes/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');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Xml.php
RENAMED
@@ -1,17 +1,14 @@
|
|
1 |
<?php
|
|
|
|
|
2 |
/**
|
3 |
* Braintree Xml parser and generator
|
4 |
* PHP version 5
|
5 |
-
*
|
6 |
-
* @copyright 2010 Braintree Payment Solutions
|
7 |
-
*/
|
8 |
-
|
9 |
-
/**
|
10 |
* superclass for Braintree XML parsing and generation
|
11 |
*
|
12 |
-
* @copyright
|
13 |
*/
|
14 |
-
|
15 |
{
|
16 |
/**
|
17 |
* @ignore
|
@@ -28,7 +25,7 @@ final class Braintree_Xml
|
|
28 |
*/
|
29 |
public static function buildArrayFromXml($xml)
|
30 |
{
|
31 |
-
return
|
32 |
}
|
33 |
|
34 |
/**
|
@@ -38,6 +35,7 @@ final class Braintree_Xml
|
|
38 |
*/
|
39 |
public static function buildXmlFromArray($array)
|
40 |
{
|
41 |
-
return
|
42 |
}
|
43 |
}
|
|
1 |
<?php
|
2 |
+
namespace Braintree;
|
3 |
+
|
4 |
/**
|
5 |
* Braintree Xml parser and generator
|
6 |
* PHP version 5
|
|
|
|
|
|
|
|
|
|
|
7 |
* superclass for Braintree XML parsing and generation
|
8 |
*
|
9 |
+
* @copyright 2015 Braintree, a division of PayPal, Inc.
|
10 |
*/
|
11 |
+
class Xml
|
12 |
{
|
13 |
/**
|
14 |
* @ignore
|
25 |
*/
|
26 |
public static function buildArrayFromXml($xml)
|
27 |
{
|
28 |
+
return Xml\Parser::arrayFromXml($xml);
|
29 |
}
|
30 |
|
31 |
/**
|
35 |
*/
|
36 |
public static function buildXmlFromArray($array)
|
37 |
{
|
38 |
+
return Xml\Generator::arrayToXml($array);
|
39 |
}
|
40 |
}
|
41 |
+
class_alias('Braintree\Xml', 'Braintree_Xml');
|
includes/lib/Braintree/{Braintree → lib/Braintree}/Xml/Generator.php
RENAMED
@@ -1,26 +1,34 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* PHP version 5
|
4 |
*
|
5 |
-
* @copyright
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* Generates XML output from arrays using PHP's
|
10 |
* built-in XMLWriter
|
11 |
*
|
12 |
-
* @copyright
|
13 |
*/
|
14 |
-
class
|
15 |
{
|
16 |
/**
|
17 |
* arrays passed to this method should have a single root element
|
18 |
* with an array as its value
|
19 |
* @param array $aData the array of data
|
20 |
-
* @return
|
21 |
*/
|
22 |
public static function arrayToXml($aData)
|
23 |
{
|
|
|
24 |
// set up the XMLWriter
|
25 |
$writer = new XMLWriter();
|
26 |
$writer->openMemory();
|
@@ -33,7 +41,7 @@ class Braintree_Xml_Generator
|
|
33 |
$aKeys = array_keys($aData);
|
34 |
$rootElementName = $aKeys[0];
|
35 |
// open the root element
|
36 |
-
$writer->startElement(
|
37 |
// create the body
|
38 |
self::_createElementsFromArray($writer, $aData[$rootElementName], $rootElementName);
|
39 |
|
@@ -52,7 +60,7 @@ class Braintree_Xml_Generator
|
|
52 |
* @static
|
53 |
* @param object $writer XMLWriter object
|
54 |
* @param array $aData contains attributes and values
|
55 |
-
* @return
|
56 |
*/
|
57 |
private static function _createElementsFromArray(&$writer, $aData)
|
58 |
{
|
@@ -64,9 +72,7 @@ class Braintree_Xml_Generator
|
|
64 |
}
|
65 |
return;
|
66 |
}
|
67 |
-
foreach ($aData AS $
|
68 |
-
// convert the style back to gateway format
|
69 |
-
$elementName = Braintree_Util::camelCaseToDelimiter($index, '-');
|
70 |
// handle child elements
|
71 |
$writer->startElement($elementName);
|
72 |
if (is_array($element)) {
|
@@ -104,28 +110,30 @@ class Braintree_Xml_Generator
|
|
104 |
private static function _generateXmlAttribute($value)
|
105 |
{
|
106 |
if ($value instanceof DateTime) {
|
107 |
-
return
|
108 |
}
|
109 |
if (is_int($value)) {
|
110 |
-
return
|
111 |
}
|
112 |
if (is_bool($value)) {
|
113 |
-
return
|
114 |
}
|
115 |
if ($value === NULL) {
|
116 |
-
return
|
117 |
}
|
118 |
}
|
119 |
/**
|
120 |
* converts datetime back to xml schema format
|
121 |
* @access protected
|
122 |
* @param object $dateTime
|
123 |
-
* @return
|
124 |
*/
|
125 |
private static function _dateTimeToXmlTimestamp($dateTime)
|
126 |
{
|
127 |
-
$dateTime
|
128 |
-
|
|
|
|
|
129 |
}
|
130 |
|
131 |
private static function _castDateTime($string)
|
@@ -142,3 +150,4 @@ class Braintree_Xml_Generator
|
|
142 |
}
|
143 |
}
|
144 |
}
|
|
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();
|
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 |
|
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 |
{
|
72 |
}
|
73 |
return;
|
74 |
}
|
75 |
+
foreach ($aData AS $elementName => $element) {
|
|
|
|
|
76 |
// handle child elements
|
77 |
$writer->startElement($elementName);
|
78 |
if (is_array($element)) {
|
110 |
private static function _generateXmlAttribute($value)
|
111 |
{
|
112 |
if ($value instanceof DateTime) {
|
113 |
+
return ['type', 'datetime', self::_dateTimeToXmlTimestamp($value)];
|
114 |
}
|
115 |
if (is_int($value)) {
|
116 |
+
return ['type', 'integer', $value];
|
117 |
}
|
118 |
if (is_bool($value)) {
|
119 |
+
return ['type', 'boolean', ($value ? 'true' : 'false')];
|
120 |
}
|
121 |
if ($value === NULL) {
|
122 |
+
return ['nil', 'true', $value];
|
123 |
}
|
124 |
}
|
125 |
/**
|
126 |
* converts datetime back to xml schema format
|
127 |
* @access protected
|
128 |
* @param object $dateTime
|
129 |
+
* @return string XML schema formatted timestamp
|
130 |
*/
|
131 |
private static function _dateTimeToXmlTimestamp($dateTime)
|
132 |
{
|
133 |
+
$dateTimeForUTC = clone $dateTime;
|
134 |
+
|
135 |
+
$dateTimeForUTC->setTimeZone(new DateTimeZone('UTC'));
|
136 |
+
return ($dateTimeForUTC->format('Y-m-d\TH:i:s') . 'Z');
|
137 |
}
|
138 |
|
139 |
private static function _castDateTime($string)
|
150 |
}
|
151 |
}
|
152 |
}
|
153 |
+
class_alias('Braintree\Xml\Generator', 'Braintree_Xml_Generator');
|
includes/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');
|
includes/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 |
+
});
|
includes/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 |
+
QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm
|