Version Description
- Fixed automatic page creation, which broke in the last update.
- Added hook pmpro_checkout_level which allows you to tweak the $level object before checkout, e.g. to change pricing for upgrades.
- Added hook pmpro_checkout_start_date which allows you to change the start date of a membership before checkout. (preheaders/checkout.php)
- Added hook pmpro_profile_start_date which allows you to change the start date of a membership that is sent to the gateway. (classes/class.memberorder.php)
- Cleaned up some notices and warnings. Will hopefully finish the remaining ones next update.
- Removed some old tinyMCE code that wasn't in use anymore. FYI, WP 3.3 will have a way to include visual editors on other pages, so we may add it to the description field of the membership levels.
- Updated order class to send phone and email to Authorize.net when creating subscriptions. The charge/authorize API support international phone numbers, but the ARB API does not. So if a customer enters an international phone number (or other phone number over 10 characters), the number will be sent for any initial payment/charge, but not for the subscription setup.
- Fixed where !!discount_code!! was not being parsed out in emails.
Download this release
Release Info
Developer | strangerstudios |
Plugin | Paid Memberships Pro |
Version | 1.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.7.14 to 1.3.1
- adminpages/addons.php +0 -142
- adminpages/addons/hide-admin-bar-from-non-admins.php +0 -32
- adminpages/addons/images/pmpro-aweber.gif +0 -0
- adminpages/addons/images/pmpro-bbpress.jpg +0 -0
- adminpages/addons/images/pmpro-constant-contact.gif +0 -0
- adminpages/addons/images/pmpro-email-templates.gif +0 -0
- adminpages/addons/images/pmpro-infusionsoft.jpg +0 -0
- adminpages/addons/images/pmpro-mailchimp.jpg +0 -0
- adminpages/addons/images/pmpro-network.gif +0 -0
- adminpages/addons/images/pmpro-post-affiliate-pro.jpg +0 -0
- adminpages/addons/images/pmpro-register-helper.gif +0 -0
- adminpages/addons/images/pmpro-series.gif +0 -0
- adminpages/addons/images/pmpro-woocommerce.gif +0 -0
- adminpages/addons/images/pmpro-wp-affiliate-platform.jpg +0 -0
- adminpages/addons/images/wp-bouncer.gif +0 -0
- adminpages/addons/pmpro-addon-packages.php +0 -30
- adminpages/addons/pmpro-affiliates.php +0 -30
- adminpages/addons/pmpro-aweber.php +0 -31
- adminpages/addons/pmpro-bbpress.php +0 -31
- adminpages/addons/pmpro-constant-contact.php +0 -31
- adminpages/addons/pmpro-disable-emails.php +0 -28
- adminpages/addons/pmpro-email-templates.php +0 -31
- adminpages/addons/pmpro-expiration.php +0 -30
- adminpages/addons/pmpro-freeaddress.php +0 -30
- adminpages/addons/pmpro-infusionsoft.php +0 -31
- adminpages/addons/pmpro-international-addresses.php +0 -31
- adminpages/addons/pmpro-level-cost-text.php +0 -30
- adminpages/addons/pmpro-mailchimp.php +0 -31
- adminpages/addons/pmpro-network-subsite.php +0 -31
- adminpages/addons/pmpro-network.php +0 -31
- adminpages/addons/pmpro-post-affiliate-pro.php +0 -31
- adminpages/addons/pmpro-register-helper.php +0 -31
- adminpages/addons/pmpro-require-code-to-register.php +0 -28
- adminpages/addons/pmpro-series.php +0 -31
- adminpages/addons/pmpro-shipping.php +0 -31
- adminpages/addons/pmpro-user-pages.php +0 -30
- adminpages/addons/pmpro-woocommerce.php +0 -31
- adminpages/addons/pmpro-wp-affiliate.php +0 -31
- adminpages/addons/tml.php +0 -32
- adminpages/addons/wp-bouncer.php +0 -31
- adminpages/admin_footer.php +0 -1
- adminpages/admin_header.php +27 -126
- adminpages/advancedsettings.php +39 -131
- adminpages/dashboard.php +4 -4
- adminpages/discountcodes.php +614 -636
- adminpages/emailsettings.php +72 -181
- adminpages/functions.php +0 -222
- adminpages/membershiplevels.php +460 -588
- adminpages/memberslist-csv.php +59 -207
- adminpages/memberslist.php +164 -238
- adminpages/orders-csv.php +0 -297
- adminpages/orders.php +0 -996
- adminpages/pagesettings.php +54 -109
- adminpages/paymentsettings.php +240 -538
- adminpages/reports.php +0 -62
- adminpages/reports/login.php +0 -412
- adminpages/reports/memberships.php +0 -651
- adminpages/reports/sales.php +0 -397
- classes/class.memberorder.php +1419 -329
- classes/class.pmproemail.php +82 -448
- classes/gateways/class.pmprogateway.php +0 -220
- classes/gateways/class.pmprogateway_authorizenet.php +0 -872
- classes/gateways/class.pmprogateway_braintree.php +0 -422
- classes/gateways/class.pmprogateway_check.php +0 -208
- classes/gateways/class.pmprogateway_cybersource.php +0 -765
- classes/gateways/class.pmprogateway_payflowpro.php +0 -448
- classes/gateways/class.pmprogateway_paypal.php +0 -456
- classes/gateways/class.pmprogateway_paypalexpress.php +0 -402
- classes/gateways/class.pmprogateway_paypalstandard.php +0 -302
- classes/gateways/class.pmprogateway_stripe.php +0 -407
- classes/gateways/class.pmprogateway_twocheckout.php +0 -145
- css/admin-rtl.css +0 -63
- css/admin.css +53 -97
- css/frontend-rtl.css +0 -111
- css/frontend.css +97 -173
- email/admin_change.html +1 -1
- email/admin_change_admin.html +0 -5
- email/billing.html +4 -1
- email/billing_admin.html +0 -17
- email/billing_failure.html +5 -1
- email/billing_failure_admin.html +5 -1
- email/cancel.html +1 -1
- email/cancel_admin.html +0 -8
- email/checkout_check.html +0 -17
- email/checkout_check_admin.html +0 -17
- email/checkout_express.html +2 -2
- email/checkout_express_admin.html +0 -14
- email/checkout_free_admin.html +0 -8
- email/checkout_freetrial.html +4 -1
- email/checkout_freetrial_admin.html +0 -19
- email/checkout_paid.html +4 -1
- email/checkout_paid_admin.html +0 -23
- email/checkout_trial.html +4 -1
- email/checkout_trial_admin.html +0 -23
- email/credit_card_expiring.html +0 -13
- email/invoice.html +5 -2
- email/membership_expired.html +1 -1
- images/Paid-Memberships-Pro.png +0 -0
- images/Paid-Memberships-Pro_watermark.png +0 -0
- images/bg_grad-chrome.gif +0 -0
- images/bg_grad-grey.gif +0 -0
- images/icon-pmproadmin16-sprite.png +0 -0
- images/icon-pmproadmin16-sprite_2x.png +0 -0
- images/icon-pmproadmin32.png +0 -0
- images/icon-pmproadmin32_2x.png +0 -0
- includes/adminpages.php +0 -226
- includes/cleanup.php +0 -40
- includes/content.php +0 -405
- includes/countries.php +2 -3
- includes/currencies.php +1 -17
- includes/email.php +0 -111
- includes/filters.php +0 -150
- includes/functions.php +1045 -1742
- includes/https.php +0 -185
- includes/init.php +0 -240
- 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/Collection.php +0 -159
- 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/Digest.php +0 -59
- includes/lib/Braintree/Braintree/Discount.php +0 -15
- includes/lib/Braintree/Braintree/EqualityNode.php +0 -10
- includes/lib/Braintree/Braintree/Error/Codes.php +0 -206
- includes/lib/Braintree/Braintree/Error/ErrorCollection.php +0 -118
- includes/lib/Braintree/Braintree/Error/Validation.php +0 -64
- includes/lib/Braintree/Braintree/Error/ValidationErrorCollection.php +0 -135
- includes/lib/Braintree/Braintree/Exception.php +0 -20
- includes/lib/Braintree/Braintree/Exception/Authentication.php +0 -21
- includes/lib/Braintree/Braintree/Exception/Authorization.php +0 -23
- 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/Instance.php +0 -70
- includes/lib/Braintree/Braintree/IsNode.php +0 -22
- includes/lib/Braintree/Braintree/KeyValueNode.php +0 -22
- includes/lib/Braintree/Braintree/Modification.php +0 -23
- includes/lib/Braintree/Braintree/MultipleValueNode.php +0 -37
- includes/lib/Braintree/Braintree/MultipleValueOrTextNode.php +0 -46
- includes/lib/Braintree/Braintree/PartialMatchNode.php +0 -16
- includes/lib/Braintree/Braintree/Plan.php +0 -55
- includes/lib/Braintree/Braintree/RangeNode.php +0 -38
- includes/lib/Braintree/Braintree/ResourceCollection.php +0 -148
- includes/lib/Braintree/Braintree/Result/CreditCardVerification.php +0 -86
- includes/lib/Braintree/Braintree/Result/Error.php +0 -107
- 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/Test/CreditCardNumbers.php +0 -76
- includes/lib/Braintree/Braintree/Test/TransactionAmounts.php +0 -24
- includes/lib/Braintree/Braintree/TextNode.php +0 -10
- includes/lib/Braintree/Braintree/Transaction.php +0 -664
- includes/lib/Braintree/Braintree/Transaction/AddressDetails.php +0 -32
- includes/lib/Braintree/Braintree/Transaction/CreditCardDetails.php +0 -43
- includes/lib/Braintree/Braintree/Transaction/CustomerDetails.php +0 -29
- includes/lib/Braintree/Braintree/Transaction/StatusDetails.php +0 -25
- includes/lib/Braintree/Braintree/Transaction/SubscriptionDetails.php +0 -22
- includes/lib/Braintree/Braintree/TransactionSearch.php +0 -124
- includes/lib/Braintree/Braintree/TransparentRedirect.php +0 -327
- includes/lib/Braintree/Braintree/Util.php +0 -290
adminpages/addons.php
DELETED
@@ -1,142 +0,0 @@
|
|
1 |
-
<?php
|
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.", "pmpro"));
|
6 |
-
}
|
7 |
-
|
8 |
-
global $wpdb, $msg, $msgt, $pmpro_addons;
|
9 |
-
|
10 |
-
/*
|
11 |
-
Addon lists
|
12 |
-
*/
|
13 |
-
$pmpro_addon_lists = array(
|
14 |
-
'repo' => array('Plugins in the WordPress Repository', 'These official PMPro plugins are available in the WordPress repository and can be installed through Plugins --> Add New.'),
|
15 |
-
'thirdparty' => array('Third-party Integration', 'These official PMPro plugins integrate with specific third-party tools and software.'),
|
16 |
-
'recommended' => array('Recommended Plugins', 'These plugins are not developed by the PMPro team, but are recommended for sites running PMPro.'),
|
17 |
-
'github' => array('Plugins on GitHub', 'These official PMPro plugins must be downloaded from GitHub and installed through Plugins --> Add New --> Upload, then activated. These plugins cannot be automatically updated and may require more developer input.'),
|
18 |
-
'gists' => array('Code Gists', 'These are bits of code that generally must be added to your active theme\'s functions.php file or included in a custom plugin. Most gists require customization and are recommended for developers only.')
|
19 |
-
);
|
20 |
-
|
21 |
-
/*
|
22 |
-
Function to add an addon
|
23 |
-
*/
|
24 |
-
function pmpro_add_addon($list, $addon)
|
25 |
-
{
|
26 |
-
global $pmpro_addons;
|
27 |
-
|
28 |
-
//make sure we have the base array
|
29 |
-
if(empty($pmpro_addons))
|
30 |
-
$pmpro_addons = array();
|
31 |
-
|
32 |
-
//make sure we have an array for the list
|
33 |
-
if(empty($pmpro_addons[$list]))
|
34 |
-
$pmpro_addons[$list] = array();
|
35 |
-
|
36 |
-
//add addon to list
|
37 |
-
$pmpro_addons[$list][] = $addon;
|
38 |
-
}
|
39 |
-
|
40 |
-
/*
|
41 |
-
Load All Addons
|
42 |
-
*/
|
43 |
-
$pmpro_addons_dir = dirname(__FILE__) . "/../adminpages/addons/";
|
44 |
-
$cwd = getcwd();
|
45 |
-
chdir($pmpro_addons_dir);
|
46 |
-
$count = 0;
|
47 |
-
foreach (glob("*.php") as $filename)
|
48 |
-
{
|
49 |
-
$count++;
|
50 |
-
require_once($filename);
|
51 |
-
}
|
52 |
-
chdir($cwd);
|
53 |
-
|
54 |
-
require_once(dirname(__FILE__) . "/admin_header.php");
|
55 |
-
?>
|
56 |
-
|
57 |
-
<h2>Add Ons</h2>
|
58 |
-
<ul id="addon-filters" class="subsubsub">
|
59 |
-
<li id="addon-filters-all"><a href="javascript:void(0);" class="current all tab">All</a> <span>(<?php echo $count;?>)</span></li>
|
60 |
-
<?php foreach($pmpro_addon_lists as $list => $list_info) { ?>
|
61 |
-
<li id="addon-filters-<?php echo $list;?>"> | <a href="javascript:void(0);>" class="tab"><?php echo $list_info[0];?></a> <span>(<?php echo count($pmpro_addons[$list]);?>)</span></li>
|
62 |
-
<?php } ?>
|
63 |
-
</ul>
|
64 |
-
|
65 |
-
<?php foreach($pmpro_addon_lists as $list => $list_info) { ?>
|
66 |
-
<div id="pmpro-<?php echo $list;?>" class="pmpro-addon-list widgets-holder-wrap">
|
67 |
-
|
68 |
-
<h3 class="section-title"><?php echo $list_info[0];?></h3>
|
69 |
-
<p class="description"><?php echo $list_info[1];?></p>
|
70 |
-
<br class="clear" />
|
71 |
-
|
72 |
-
<div id="addons-list-<?php echo $list;?>" class="addon-list">
|
73 |
-
|
74 |
-
<?php foreach($pmpro_addons[$list] as $slug => $addon) { ?>
|
75 |
-
<div id="addon-<?php echo $slug;?>" class="widget <?php if($addon['enabled']) echo "enabled"; else echo "disabled";?>">
|
76 |
-
<div class="widget-top">
|
77 |
-
<div class="widget-title">
|
78 |
-
<h4>
|
79 |
-
<span class="status-label"><?php if($addon['enabled']) echo __("Enabled", "pmpro"); else echo __("Disabled", "pmpro");?></span>
|
80 |
-
<span class="title"><?php echo $addon['title'];?></span>
|
81 |
-
<span class="version pmpro_tag-grey"><?php echo $addon['version'];?></span>
|
82 |
-
<span class="in-widget-title"></span>
|
83 |
-
</h4>
|
84 |
-
</div> <!-- end widget-title -->
|
85 |
-
</div> <!-- end widget-top -->
|
86 |
-
<div class="widget-inside">
|
87 |
-
<?php call_user_func($addon['widget'], $addon);?>
|
88 |
-
</div> <!-- end addon-inside -->
|
89 |
-
</div> <!-- end widget -->
|
90 |
-
<?php } ?>
|
91 |
-
|
92 |
-
<br class="clear" />
|
93 |
-
</div> <!-- end addon-list -->
|
94 |
-
|
95 |
-
</div> <!-- end pmpro-<?php echo $list;?> -->
|
96 |
-
<?php } ?>
|
97 |
-
|
98 |
-
<script>
|
99 |
-
//tabs
|
100 |
-
jQuery(document).ready(function() {
|
101 |
-
jQuery('#addon-filters a.tab').click(function() {
|
102 |
-
//which tab?
|
103 |
-
var tab = jQuery(this).parent().attr('id').replace('addon-filters-', '');
|
104 |
-
|
105 |
-
//un select tabs
|
106 |
-
jQuery('#addon-filters a.tab').removeClass('current');
|
107 |
-
|
108 |
-
//select this tab
|
109 |
-
jQuery('#addon-filters-'+tab+' a').addClass('current');
|
110 |
-
|
111 |
-
//show all?
|
112 |
-
if(tab == 'all')
|
113 |
-
jQuery('div.pmpro-addon-list').show();
|
114 |
-
else
|
115 |
-
{
|
116 |
-
//hide all
|
117 |
-
jQuery('div.pmpro-addon-list').hide();
|
118 |
-
|
119 |
-
//show this one
|
120 |
-
jQuery('#pmpro-'+tab).show();
|
121 |
-
}
|
122 |
-
});
|
123 |
-
});
|
124 |
-
|
125 |
-
//resize addon boxes
|
126 |
-
jQuery(document).ready(function() {
|
127 |
-
jQuery('.addon-list').each(function() {
|
128 |
-
//what's the tallest p in the list?
|
129 |
-
var tallest = 32;
|
130 |
-
jQuery(this).find('div.info p').each(function() {
|
131 |
-
tallest = Math.max(tallest, jQuery(this).height());
|
132 |
-
});
|
133 |
-
|
134 |
-
//set all p's to match
|
135 |
-
jQuery(this).find('div.info p').css('height', tallest);
|
136 |
-
});
|
137 |
-
});
|
138 |
-
</script>
|
139 |
-
|
140 |
-
<?php
|
141 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
142 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/hide-admin-bar-from-non-admins.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: Hide Admin Bar From Non-Admins
|
4 |
-
Slug: hide-admin-bar-from-non-admins
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('repo', array(
|
7 |
-
'title' => 'Hide Admin Bar From Non-Admins',
|
8 |
-
'version' => '1.0',
|
9 |
-
'widget' => 'pmpro_addon_hide_admin_bar_from_non_admins_widget',
|
10 |
-
'enabled' => function_exists('habfna_disable_admin_bar')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_hide_admin_bar_from_non_admins_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Perfect for sites where there is only one admin who needs access to the dashboard and the admin bar. When activated only administrators will see the admin bar.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<form method="post" name="component-actions" action="">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("plugins.php");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../hide-admin-bar-from-non-admins/hide-admin-bar-from-non-admins.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=hide-admin-bar-from-non-admins/hide-admin-bar-from-non-admins.php'), 'activate-plugin_hide-admin-bar-from-non-admins/hide-admin-bar-from-non-admins.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=hide-admin-bar-from-non-admins'), 'install-plugin_hide-admin-bar-from-non-admins'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</form>
|
29 |
-
</div>
|
30 |
-
</div> <!-- end info -->
|
31 |
-
<?php
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/images/pmpro-aweber.gif
DELETED
Binary file
|
adminpages/addons/images/pmpro-bbpress.jpg
DELETED
Binary file
|
adminpages/addons/images/pmpro-constant-contact.gif
DELETED
Binary file
|
adminpages/addons/images/pmpro-email-templates.gif
DELETED
Binary file
|
adminpages/addons/images/pmpro-infusionsoft.jpg
DELETED
Binary file
|
adminpages/addons/images/pmpro-mailchimp.jpg
DELETED
Binary file
|
adminpages/addons/images/pmpro-network.gif
DELETED
Binary file
|
adminpages/addons/images/pmpro-post-affiliate-pro.jpg
DELETED
Binary file
|
adminpages/addons/images/pmpro-register-helper.gif
DELETED
Binary file
|
adminpages/addons/images/pmpro-series.gif
DELETED
Binary file
|
adminpages/addons/images/pmpro-woocommerce.gif
DELETED
Binary file
|
adminpages/addons/images/pmpro-wp-affiliate-platform.jpg
DELETED
Binary file
|
adminpages/addons/images/wp-bouncer.gif
DELETED
Binary file
|
adminpages/addons/pmpro-addon-packages.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Addon Packages
|
4 |
-
Slug: pmpro-addon-packages
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Addon Packages',
|
8 |
-
'version' => '.4.3',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_addon_packages_widget',
|
10 |
-
'enabled' => function_exists('pmproap_post_meta')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_addon_packages_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Sell access to individual pages or posts for a flat fee. This is a workaround if you would like to allow multiple membership levels per user.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<?php if($addon['enabled']) { ?>
|
21 |
-
<a href="https://github.com/strangerstudios/pmpro-addon-packages/blob/master/readme.txt" class="button">Enabled</a>
|
22 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-addon-packages/pmpro-addon-packages.php")) { ?>
|
23 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-addon-packages/pmpro-addon-packages.php'), 'activate-plugin_pmpro-addon-packages/pmpro-addon-packages.php')?>" class="button button-primary">Activate</a>
|
24 |
-
<?php } else { ?>
|
25 |
-
<a href="https://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-addon-packages.zip" class="button button-primary">Download</a>
|
26 |
-
<?php } ?>
|
27 |
-
</div>
|
28 |
-
</div> <!-- end info -->
|
29 |
-
<?php
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-affiliates.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Affiliates
|
4 |
-
Slug: pmpro-affiliates
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Affiliates',
|
8 |
-
'version' => '.2.4',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_affiliates_widget',
|
10 |
-
'enabled' => function_exists('pmpro_affiliates_dependencies')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_affiliates_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Lightweight Affiliate system. Create affiliate accounts and codes; tracks checkouts by affiliate account.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<?php if($addon['enabled']) { ?>
|
21 |
-
<a href="https://github.com/strangerstudios/pmpro-affiliates/blob/master/readme.txt" class="button">Enabled</a>
|
22 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-affiliates/pmpro-affiliates.php")) { ?>
|
23 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-affiliates/pmpro-affiliates.php'), 'activate-plugin_pmpro-affiliates/pmpro-affiliates.php')?>" class="button button-primary">Activate</a>
|
24 |
-
<?php } else { ?>
|
25 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-affiliates.zip" class="button button-primary">Download</a>
|
26 |
-
<?php } ?>
|
27 |
-
</div>
|
28 |
-
</div> <!-- end info -->
|
29 |
-
<?php
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-aweber.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro AWeber Integration
|
4 |
-
Slug: pmpro-aweber
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('thirdparty', array(
|
7 |
-
'title' => 'PMPro AWeber Integration',
|
8 |
-
'version' => '1.0',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_aweber_widget',
|
10 |
-
'enabled' => function_exists('pmproaw_init')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_aweber_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-aweber.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Integrate User Registrations with AWeber. Adds members to lists based on their membership level. (Note: works without PMPro as well.)</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("plugins.php");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-aweber/pmpro-aweber.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-aweber/pmpro-aweber.php'), 'activate-plugin_pmpro-aweber/pmpro-aweber.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-aweber'), 'install-plugin_pmpro-aweber'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-bbpress.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro bbPress
|
4 |
-
Slug: pmpro-bbpress
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('repo', array(
|
7 |
-
'title' => 'PMPro bbPress',
|
8 |
-
'version' => '1.0.1',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_bbpress_widget',
|
10 |
-
'enabled' => function_exists('pmprobbp_add_meta_box')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_bbpress_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-bbpress.jpg" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Locking down bbPress Forums by Membership Level and Forum ID.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("plugins.php");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-bbpress/pmpro-bbpress.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-bbpress/pmpro-bbpress.php'), 'activate-plugin_pmpro-bbpress/pmpro-bbpress.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-bbpress'), 'install-plugin_pmpro-bbpress'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-constant-contact.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Constant Contact Integration
|
4 |
-
Slug: pmpro-constant-contact
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('thirdparty', array(
|
7 |
-
'title' => 'PMPro Constant Contact Integration',
|
8 |
-
'version' => '1.0',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_constant_contact_widget',
|
10 |
-
'enabled' => function_exists('pmprocc_init')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_constant_contact_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-constant-contact.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Integrate User Registrations with Constant Contact . Adds members to lists based on their membership level. (Note: works without PMPro as well.)</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("plugins.php");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-constant-contact/pmpro-constant-contact.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-constant-contact/pmpro-constant-contact.php'), 'activate-plugin_pmpro-constant-contact/pmpro-constant-contact.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-constant-contact'), 'install-plugin_pmpro-constant-contact'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-disable-emails.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Disable PMPro Emails
|
4 |
-
Slug: pmpro-disable-emails
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('gists', array(
|
7 |
-
'title' => 'PMPro Disable Emails',
|
8 |
-
'version' => '.1',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_disable_emails_widget',
|
10 |
-
'enabled' => function_exists('dae_pmpro_email_recipient')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_disable_emails_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Disable all or specific emails sent by the PMPro plugin.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<?php if($addon['enabled']) { ?>
|
21 |
-
<a target="_blank" href="https://gist.github.com/strangerstudios/3667545" class="button">Enabled</a>
|
22 |
-
<?php } else { ?>
|
23 |
-
<a target="_blank" href="https://gist.github.com/strangerstudios/3667545" class="button button-primary">View Gist</a>
|
24 |
-
<?php } ?>
|
25 |
-
</div>
|
26 |
-
</div> <!-- end info -->
|
27 |
-
<?php
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-email-templates.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Email Templates Editor
|
4 |
-
Slug: pmpro-email-templates-addon
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('repo', array(
|
7 |
-
'title' => 'PMPro Email Templates',
|
8 |
-
'version' => '.5.2',
|
9 |
-
'widget' => 'pmpro_addon_email_templates_widget',
|
10 |
-
'enabled' => function_exists('pmproet_scripts')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_email_templates_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-email-templates.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Easily edit system-generated Email Templates from the WordPress admin.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="http://wordpress.org/plugins/pmpro-email-templates-addon/" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-email-templates-addon/pmpro-email-templates.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-email-templates-addon/pmpro-email-templates.php'), 'activate-plugin_pmpro-email-templates-addon/pmpro-email-templates.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-email-templates-addon'), 'install-plugin_pmpro-email-templates-addon'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-expiration.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Expiration Date
|
4 |
-
Slug: pmpro-expiration
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Set Expiration Dates',
|
8 |
-
'version' => '.1.1',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_expiration_widget',
|
10 |
-
'enabled' => function_exists('pmprosed_pmpro_checkout_level')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_expiration_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Set a specific expiration date (e.g. 2013-12-31) for a PMPro membership level or discount code.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<?php if($addon['enabled']) { ?>
|
21 |
-
<a href="https://github.com/strangerstudios/pmpro-set-expiration-dates/blob/master/readme.txt" class="button">Enabled</a>
|
22 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-set-expiration-dates/pmpro-set-expiration-dates.php")) { ?>
|
23 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-set-expiration-dates/pmpro-set-expiration-dates.php'), 'activate-plugin_pmpro-set-expiration-dates/pmpro-set-expiration-dates.php')?>" class="button button-primary">Activate</a>
|
24 |
-
<?php } else { ?>
|
25 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-set-expiration-dates.zip" class="button button-primary">Download</a>
|
26 |
-
<?php } ?>
|
27 |
-
</div>
|
28 |
-
</div> <!-- end info -->
|
29 |
-
<?php
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-freeaddress.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Require Name and Address for Free Level
|
4 |
-
Slug: pmpro-freerequire
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Require Name/Address for Free Level',
|
8 |
-
'version' => '.2',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_freerequire_widget',
|
10 |
-
'enabled' => function_exists('my_pmpro_checkout_boxes_require_address')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_freerequire_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Require name/address for free Membership Level checkout.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<?php if($addon['enabled']) { ?>
|
21 |
-
<a href="https://github.com/strangerstudios/pmpro-address-for-free-levels" class="button">Enabled</a>
|
22 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-address-for-free-levels/pmpro-address-for-free-levels.php")) { ?>
|
23 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-address-for-free-levels/pmpro-address-for-free-levels.php'), 'activate-plugin_pmpro-address-for-free-levels/pmpro-address-for-free-levels.php')?>" class="button button-primary">Activate</a>
|
24 |
-
<?php } else { ?>
|
25 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-address-for-free-levels.zip" class="button button-primary">Download</a>
|
26 |
-
<?php } ?>
|
27 |
-
</div>
|
28 |
-
</div> <!-- end info -->
|
29 |
-
<?php
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-infusionsoft.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Infusionsoft Integration
|
4 |
-
Slug: pmpro-infusionsoft
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('thirdparty', array(
|
7 |
-
'title' => 'PMPro Infusionsoft Integration',
|
8 |
-
'version' => '1.2',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_infusionsoft_widget',
|
10 |
-
'enabled' => function_exists('pmprois_init')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_infusionsoft_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-infusionsoft.jpg" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Integrate with Infusionsoft. Add members to email lists (groups, tags) based on their membership level. (Note: works without PMPro as well.)</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("plugins.php");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-infusionsoft/pmpro-infusionsoft.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-infusionsoft/pmpro-infusionsoft.php'), 'activate-plugin_pmpro-infusionsoft/pmpro-infusionsoft.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-infusionsoft'), 'install-plugin_pmpro-infusionsoft'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-international-addresses.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro International Addresses
|
4 |
-
Slug: pmpro-international-addresses
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro International Addresses',
|
8 |
-
'version' => '.2.2',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_international_addresses_widget',
|
10 |
-
'enabled' => function_exists('pmproia_pmpro_international_addresses')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_international_addresses_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<?php /* <img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-international-addresses.jpg" /> */ ?>
|
18 |
-
<div class="info">
|
19 |
-
<p>Adds long form addresses to the PMPro checkout.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="https://github.com/strangerstudios/pmpro-international-addresses/" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-international-addresses/pmpro-international-addresses.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-international-addresses/pmpro-international-addresses.php'), 'activate-plugin_pmpro-international-addresses/pmpro-international-addresses.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-international-addresses.zip" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-level-cost-text.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Custom Level Cost Text
|
4 |
-
Slug: pmpro-level-cost-text
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Level Cost Text',
|
8 |
-
'version' => '.2',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_level_cost_text_widget',
|
10 |
-
'enabled' => function_exists('pclct_pmpro_discount_code_after_level_settings')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_level_cost_text_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Adds a "level cost text" field to PMPro Membership Levels and Discount Codes to allow you to override the automatically generated level cost text PMPro provides.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<?php if($addon['enabled']) { ?>
|
21 |
-
<a href="https://github.com/strangerstudios/pmpro-level-cost-text/blob/master/readme.txt" class="button">Enabled</a>
|
22 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-level-cost-text/pmpro-level-cost-text.php")) { ?>
|
23 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-level-cost-text/pmpro-level-cost-text.php'), 'activate-plugin_pmpro-level-cost-text/pmpro-level-cost-text.php')?>" class="button button-primary">Activate</a>
|
24 |
-
<?php } else { ?>
|
25 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-level-cost-text.zip" class="button button-primary">Download</a>
|
26 |
-
<?php } ?>
|
27 |
-
</div>
|
28 |
-
</div> <!-- end info -->
|
29 |
-
<?php
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-mailchimp.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro MailChimp Integration
|
4 |
-
Slug: pmpro-mailchimp
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('thirdparty', array(
|
7 |
-
'title' => 'PMPro MailChimp Integration',
|
8 |
-
'version' => '1.0',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_mailchimp_widget',
|
10 |
-
'enabled' => function_exists('pmpromc_init')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_mailchimp_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-mailchimp.jpg" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Integrate User Registrations with Mailchimp. Adds members to lists based on their membership level. (Note: works without PMPro as well.)</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("plugins.php");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-mailchimp/pmpro-mailchimp.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-mailchimp/pmpro-mailchimp.php'), 'activate-plugin_pmpro-mailchimp/pmpro-mailchimp.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-mailchimp'), 'install-plugin_pmpro-mailchimp'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-network-subsite.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Network
|
4 |
-
Slug: pmpro-network-subsite
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Network Subsite Helper',
|
8 |
-
'version' => '.2',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_network_subsite_widget',
|
10 |
-
'enabled' => function_exists('pmpron_subsite_activated_plugin')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_network_subsite_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-network.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Have network subsites use membership data from a "main" site to handle access restrictions.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="https://github.com/strangerstudios/pmpro-network-subsite" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-network-subsite/pmpro-network-subsite.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-network-subsite/pmpro-network-subsite.php'), 'activate-plugin_pmpro-network-subsite/pmpro-network-subsite.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-network-subsite.zip" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-network.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Network
|
4 |
-
Slug: pmpro-network
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Network',
|
8 |
-
'version' => '.3.1',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_network_widget',
|
10 |
-
'enabled' => function_exists('pmpron_new_blogs_settings')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_network_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-network.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Allow users to checkout for a membership to create a site on your WordPress multisite network.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="https://github.com/strangerstudios/pmpro-network/blob/master/readme.txt" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-network/pmpro-network.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-network/pmpro-network.php'), 'activate-plugin_pmpro-network/pmpro-network.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-network.zip" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-post-affiliate-pro.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Post Affiliate Pro Integration
|
4 |
-
Slug: pmpro-post-affiliate-pro
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('thirdparty', array(
|
7 |
-
'title' => 'PMPro Post Affiliate Pro Integration',
|
8 |
-
'version' => '.2.1.1',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_post_affiliate_pro_widget',
|
10 |
-
'enabled' => function_exists('pap_pmpro_track_sale')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_post_affiliate_pro_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-post-affiliate-pro.jpg" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Integrate Paid Memberships Pro with the Post Affiliate Pro platform.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="https://github.com/strangerstudios/pmpro-post-affiliate-pro/blob/master/readme.txt" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-post-affiliate-pro/pmpro-post-affiliate-pro.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-post-affiliate-pro/pmpro-post-affiliate-pro.php'), 'activate-plugin_pmpro-post-affiliate-pro/pmpro-post-affiliate-pro.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-post-affiliate-pro.zip" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-register-helper.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Register Helper
|
4 |
-
Slug: pmpro-register-helper
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Register Helper',
|
8 |
-
'version' => '.5.16.1',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_register_helper_widget',
|
10 |
-
'enabled' => class_exists('PMProRH_Field')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_register_helper_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-register-helper.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Add additional meta fields to your PMPro checkout page and/or "Your Profile" pages. Support for text, select, multi-select, textarea, hidden, and custom HTML. Loop into existing checkout/profile field sections or add new ones.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="https://github.com/strangerstudios/pmpro-register-helper/blob/master/readme.txt" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-register-helper/pmpro-register-helper.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-register-helper/pmpro-register-helper.php'), 'activate-plugin_pmpro-register-helper/pmpro-register-helper.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-register-helper.zip" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-require-code-to-register.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Require Code to Register
|
4 |
-
Slug: pmpro-require-code-to-register
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('gists', array(
|
7 |
-
'title' => 'PMPro Require a Code to Register',
|
8 |
-
'version' => '.1',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_require_code_to_register_widget',
|
10 |
-
'enabled' => function_exists('my_pmpro_registration_checks_require_code_to_register')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_require_code_to_register_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Require a discount code to checkout for a specific level.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<?php if($addon['enabled']) { ?>
|
21 |
-
<a target="_blank" href="https://gist.github.com/strangerstudios/5573829" class="button">Enabled</a>
|
22 |
-
<?php } else { ?>
|
23 |
-
<a target="_blank" href="https://gist.github.com/strangerstudios/5573829" class="button button-primary">View Gist</a>
|
24 |
-
<?php } ?>
|
25 |
-
</div>
|
26 |
-
</div> <!-- end info -->
|
27 |
-
<?php
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-series.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Series
|
4 |
-
Slug: pmpro-series
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Series',
|
8 |
-
'version' => '.3',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_series_widget',
|
10 |
-
'enabled' => class_exists("PMProSeries")
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_series_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-series.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>"Drip feed" content to your members over the course of their membership. Serializes content by # of days post-registration.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("edit.php?post_type=pmpro_series");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-series/pmpro-series.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-series/pmpro-series.php'), 'activate-plugin_pmpro-series/pmpro-series.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-series.zip" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-shipping.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro Shipping Add On
|
4 |
-
Slug: pmpro-shipping
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro Shipping Add On',
|
8 |
-
'version' => '.2.6',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_shipping_widget',
|
10 |
-
'enabled' => function_exists('pmproship_pmpro_checkout_boxes')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_shipping_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<?php /* <img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-shipping.jpg" /> */ ?>
|
18 |
-
<div class="info">
|
19 |
-
<p>Adds shipping fields to the checkout page, confirmation page, confirmation emails, member's list and edit user profile pages.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="https://github.com/strangerstudios/pmpro-shipping/" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-shipping/pmpro-shipping.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-shipping/pmpro-shipping.php'), 'activate-plugin_pmpro-shipping/pmpro-shipping.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-shipping.zip" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-user-pages.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro User Pages
|
4 |
-
Slug: pmpro-user-pages
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('github', array(
|
7 |
-
'title' => 'PMPro User Pages',
|
8 |
-
'version' => '.3',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_user_pages_widget',
|
10 |
-
'enabled' => function_exists('pmproup_pmpro_after_checkout')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_user_pages_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>Creates a unique page for each Member after checkout, giving the Admin access to write customized content for each specific member.</p>
|
19 |
-
<div class="actions">
|
20 |
-
<?php if($addon['enabled']) { ?>
|
21 |
-
<a href="https://github.com/strangerstudios/pmpro-user-pages/blob/master/readme.txt" class="button">Enabled</a>
|
22 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-user-pages/pmpro-user-pages.php")) { ?>
|
23 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-user-pages/pmpro-user-pages.php'), 'activate-plugin_pmpro-user-pages/pmpro-user-pages.php')?>" class="button button-primary">Activate</a>
|
24 |
-
<?php } else { ?>
|
25 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-user-pages.zip" class="button button-primary">Download</a>
|
26 |
-
<?php } ?>
|
27 |
-
</div>
|
28 |
-
</div> <!-- end info -->
|
29 |
-
<?php
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-woocommerce.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro WooCommerce
|
4 |
-
Slug: pmpro-woocommerce
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('thirdparty', array(
|
7 |
-
'title' => 'PMPro WooCommerce',
|
8 |
-
'version' => '1.2.2',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_woocommerce_widget',
|
10 |
-
'enabled' => function_exists('pmprowoo_add_membership_from_order')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_woocommerce_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-woocommerce.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Use WooCommerce to purchase membership or set members-only product pricing.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("plugins.php");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-woocommerce/pmpro-woocommerce.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-woocommerce/pmpro-woocommerce.php'), 'activate-plugin_pmpro-woocommerce/pmpro-woocommerce.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=pmpro-woocommerce'), 'install-plugin_pmpro-woocommerce'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/pmpro-wp-affiliate.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: PMPro WP Affiliate Platform Integration
|
4 |
-
Slug: pmpro-wp-affiliate
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('thirdparty', array(
|
7 |
-
'title' => 'PMPro WP Affiliate Platform Integration',
|
8 |
-
'version' => '.3',
|
9 |
-
'widget' => 'pmpro_addon_pmpro_wp_affiliate_widget',
|
10 |
-
'enabled' => function_exists('wpa_pmpro_after_checkout')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_pmpro_wp_affiliate_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/pmpro-wp-affiliate-platform.jpg" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Process an affiliate via WP Affiliate Platform after a PMPro checkout.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="https://github.com/strangerstudios/pmpro-wp-affiliate-platform/" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../pmpro-wp-affiliate-platform/pmpro-wp-affiliate-platform.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=pmpro-wp-affiliate-platform/pmpro-wp-affiliate-platform.php'), 'activate-plugin_pmpro-wp-affiliate-platform/pmpro-wp-affiliate-platform.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="http://www.paidmembershipspro.com/wp-content/uploads/plugins/pmpro-wp-affiliate-platform.zip" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/tml.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: Theme My Login
|
4 |
-
Slug: pmpro-tml
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('recommended', array(
|
7 |
-
'title' => 'Theme My Login',
|
8 |
-
'widget' => 'pmpro_addon_tml_widget',
|
9 |
-
'enabled' => class_exists('Theme_My_Login'),
|
10 |
-
'version' => '6.3.10'
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_tml_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<div class="info">
|
18 |
-
<p>This plugin themes the WordPress login, registration and forgot password pages according to your current theme. By <a href="http://www.jfarthing.com/" target="_blank">Jeff Farthing</a></p>
|
19 |
-
<div class="actions">
|
20 |
-
<form method="post" name="component-actions" action="">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="<?php echo admin_url("plugins.php");?>" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../theme-my-login/theme-my-login.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=theme-my-login/theme-my-login.php'), 'activate-plugin_theme-my-login/theme-my-login.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=theme-my-login'), 'install-plugin_theme-my-login'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</form>
|
29 |
-
</div>
|
30 |
-
</div> <!-- end info -->
|
31 |
-
<?php
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/addons/wp-bouncer.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Addon: WP Bouncer
|
4 |
-
Slug: wp-bouncer
|
5 |
-
*/
|
6 |
-
pmpro_add_addon('repo', array(
|
7 |
-
'title' => 'WP Bouncer',
|
8 |
-
'version' => '1.1',
|
9 |
-
'widget' => 'pmpro_addon_wp_bouncer_widget',
|
10 |
-
'enabled' => class_exists('WP_Bouncer')
|
11 |
-
)
|
12 |
-
);
|
13 |
-
|
14 |
-
function pmpro_addon_wp_bouncer_widget($addon)
|
15 |
-
{
|
16 |
-
?>
|
17 |
-
<img class="addon-thumb" src="<?php echo PMPRO_URL?>/adminpages/addons/images/wp-bouncer.gif" />
|
18 |
-
<div class="info">
|
19 |
-
<p>Make sure users are only logged in from one computer or device at a time.</p>
|
20 |
-
<div class="actions">
|
21 |
-
<?php if($addon['enabled']) { ?>
|
22 |
-
<a href="http://wordpress.org/plugins/wp-bouncer/" class="button">Enabled</a>
|
23 |
-
<?php } elseif(file_exists(dirname(__FILE__) . "/../../../wp-bouncer/wp-bouncer.php")) { ?>
|
24 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin=wp-bouncer/wp-bouncer.php'), 'activate-plugin_wp-bouncer/wp-bouncer.php')?>" class="button button-primary">Activate</a>
|
25 |
-
<?php } else { ?>
|
26 |
-
<a href="<?php echo wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=wp-bouncer'), 'install-plugin_wp-bouncer'); ?>" class="button button-primary">Download</a>
|
27 |
-
<?php } ?>
|
28 |
-
</div>
|
29 |
-
</div> <!-- end info -->
|
30 |
-
<?php
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/admin_footer.php
CHANGED
@@ -1,2 +1 @@
|
|
1 |
-
<div class="clear"></div>
|
2 |
</div>
|
|
|
1 |
</div>
|
adminpages/admin_header.php
CHANGED
@@ -1,119 +1,26 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
if(isset($_REQUEST['page']))
|
5 |
-
$view = $_REQUEST['page'];
|
6 |
-
else
|
7 |
-
$view = "";
|
8 |
|
9 |
global $pmpro_ready, $msg, $msgt;
|
10 |
$pmpro_ready = pmpro_is_ready();
|
11 |
if(!$pmpro_ready)
|
12 |
{
|
13 |
global $pmpro_level_ready, $pmpro_gateway_ready, $pmpro_pages_ready;
|
14 |
-
|
15 |
-
|
16 |
-
if(isset($_REQUEST['edit']))
|
17 |
-
$edit = $_REQUEST['edit'];
|
18 |
-
else
|
19 |
-
$edit = false;
|
20 |
-
}
|
21 |
-
|
22 |
-
if(empty($msg))
|
23 |
$msg = -1;
|
24 |
-
if(
|
25 |
-
$msgt .= " <a href=\"?page=pmpro-membershiplevels&edit=-1\">
|
26 |
elseif($pmpro_level_ready && !$pmpro_pages_ready && $view != "pmpro-pagesettings")
|
27 |
-
$msgt .= " <a href=\"?page=pmpro-pagesettings\">
|
28 |
elseif($pmpro_level_ready && $pmpro_pages_ready && !$pmpro_gateway_ready && $view != "pmpro-paymentsettings")
|
29 |
-
$msgt .= " <a href=\"?page=pmpro-paymentsettings\">
|
30 |
|
31 |
-
if(
|
32 |
$msg = false;
|
33 |
}
|
34 |
|
35 |
-
if(
|
36 |
-
{
|
37 |
-
$msg = -1;
|
38 |
-
$msgt = __("The billing details for some of your membership levels is not supported by Stripe.", "pmpro");
|
39 |
-
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
40 |
-
{
|
41 |
-
if(!pmpro_checkLevelForStripeCompatibility($_REQUEST['edit']))
|
42 |
-
{
|
43 |
-
global $pmpro_stripe_error;
|
44 |
-
$pmpro_stripe_error = true;
|
45 |
-
$msg = -1;
|
46 |
-
$msgt = __("The billing details for this level are not supported by Stripe. Please review the notes in the Billing Details section below.", "pmpro");
|
47 |
-
}
|
48 |
-
}
|
49 |
-
elseif($view == "pmpro-membershiplevels")
|
50 |
-
$msgt .= " " . __("The levels with issues are highlighted below.", "pmpro");
|
51 |
-
else
|
52 |
-
$msgt .= " <a href=\"?page=pmpro-membershiplevels\">" . __("Please edit your levels", "pmpro") . "</a>.";
|
53 |
-
}
|
54 |
-
|
55 |
-
if(!pmpro_checkLevelForPayflowCompatibility())
|
56 |
-
{
|
57 |
-
$msg = -1;
|
58 |
-
$msgt = __("The billing details for some of your membership levels is not supported by Payflow.", "pmpro");
|
59 |
-
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
60 |
-
{
|
61 |
-
if(!pmpro_checkLevelForPayflowCompatibility($_REQUEST['edit']))
|
62 |
-
{
|
63 |
-
global $pmpro_payflow_error;
|
64 |
-
$pmpro_payflow_error = true;
|
65 |
-
$msg = -1;
|
66 |
-
$msgt = __("The billing details for this level are not supported by Payflow. Please review the notes in the Billing Details section below.", "pmpro");
|
67 |
-
}
|
68 |
-
}
|
69 |
-
elseif($view == "pmpro-membershiplevels")
|
70 |
-
$msgt .= " " . __("The levels with issues are highlighted below.", "pmpro");
|
71 |
-
else
|
72 |
-
$msgt .= " <a href=\"?page=pmpro-membershiplevels\">" . __("Please edit your levels", "pmpro") . "</a>.";
|
73 |
-
}
|
74 |
-
|
75 |
-
if(!pmpro_checkLevelForBraintreeCompatibility())
|
76 |
-
{
|
77 |
-
$msg = -1;
|
78 |
-
$msgt = __("The billing details for some of your membership levels is not supported by Braintree.", "pmpro");
|
79 |
-
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
80 |
-
{
|
81 |
-
if(!pmpro_checkLevelForBraintreeCompatibility($_REQUEST['edit']))
|
82 |
-
{
|
83 |
-
global $pmpro_braintree_error;
|
84 |
-
$pmpro_braintree_error = true;
|
85 |
-
$msg = -1;
|
86 |
-
$msgt = __("The billing details for this level are not supported by Braintree. Please review the notes in the Billing Details section below.", "pmpro");
|
87 |
-
}
|
88 |
-
}
|
89 |
-
elseif($view == "pmpro-membershiplevels")
|
90 |
-
$msgt .= " " . __("The levels with issues are highlighted below.", "pmpro");
|
91 |
-
else
|
92 |
-
$msgt .= " <a href=\"?page=pmpro-membershiplevels\">" . __("Please edit your levels", "pmpro") . "</a>.";
|
93 |
-
}
|
94 |
-
|
95 |
-
if(!pmpro_checkLevelForTwoCheckoutCompatibility())
|
96 |
-
{
|
97 |
-
$msg = -1;
|
98 |
-
$msgt = __("The billing details for some of your membership levels is not supported by TwoCheckout.", "pmpro");
|
99 |
-
if($view == "pmpro-membershiplevels" && !empty($_REQUEST['edit']) && $_REQUEST['edit'] > 0)
|
100 |
-
{
|
101 |
-
if(!pmpro_checkLevelForTwoCheckoutCompatibility($_REQUEST['edit']))
|
102 |
-
{
|
103 |
-
global $pmpro_twocheckout_error;
|
104 |
-
$pmpro_twocheckout_error = true;
|
105 |
-
|
106 |
-
$msg = -1;
|
107 |
-
$msgt = __("The billing details for this level are not supported by 2Checkout. Please review the notes in the Billing Details section below.", "pmpro");
|
108 |
-
}
|
109 |
-
}
|
110 |
-
elseif($view == "pmpro-membershiplevels")
|
111 |
-
$msgt .= " " . __("The levels with issues are highlighted below.", "pmpro");
|
112 |
-
else
|
113 |
-
$msgt .= " <a href=\"?page=pmpro-membershiplevels\">" . __("Please edit your levels", "pmpro") . "</a>.";
|
114 |
-
}
|
115 |
-
|
116 |
-
if(!empty($msg))
|
117 |
{
|
118 |
?>
|
119 |
<div id="message" class="<?php if($msg > 0) echo "updated fade"; else echo "error"; ?>"><p><?php echo $msgt?></p></div>
|
@@ -122,35 +29,29 @@
|
|
122 |
|
123 |
?>
|
124 |
<div class="wrap pmpro_admin">
|
125 |
-
<div class="pmpro_banner">
|
126 |
-
<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/
|
127 |
-
<div class="
|
128 |
-
|
129 |
-
<br style="clear:both;" />
|
130 |
-
</div>
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
<div id="pmpro_notifications">
|
133 |
</div>
|
134 |
<script>
|
135 |
-
jQuery(
|
136 |
-
|
137 |
-
if(data && data != 'NULL')
|
138 |
-
jQuery('#pmpro_notifications').html(data);
|
139 |
-
});
|
140 |
});
|
141 |
</script>
|
142 |
|
143 |
-
<?php
|
144 |
-
$settings_tabs = array("pmpro-membershiplevels", "pmpro-pagesettings", "pmpro-paymentsettings", "pmpro-emailsettings", "pmpro-advancedsettings", "pmpro-addons");
|
145 |
-
if(in_array($view, $settings_tabs))
|
146 |
-
{
|
147 |
-
?>
|
148 |
<h3 class="nav-tab-wrapper">
|
149 |
-
<a href="admin.php?page=pmpro-membershiplevels" class="nav-tab<?php if($view == 'pmpro-membershiplevels') { ?> nav-tab-active<?php } ?>"
|
150 |
-
<a href="admin.php?page=pmpro-pagesettings" class="nav-tab<?php if($view == 'pmpro-pagesettings') { ?> nav-tab-active<?php } ?>"
|
151 |
-
<a href="admin.php?page=pmpro-paymentsettings" class="nav-tab<?php if($view == 'pmpro-paymentsettings') { ?> nav-tab-active<?php } ?>"
|
152 |
-
<a href="admin.php?page=pmpro-emailsettings" class="nav-tab<?php if($view == 'pmpro-emailsettings') { ?> nav-tab-active<?php } ?>"
|
153 |
-
<a href="admin.php?page=pmpro-advancedsettings" class="nav-tab<?php if($view == 'pmpro-advancedsettings') { ?> nav-tab-active<?php } ?>"
|
154 |
-
|
155 |
-
</h3>
|
156 |
-
<?php } ?>
|
1 |
<?php
|
2 |
+
$view = $_REQUEST['page'];
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
global $pmpro_ready, $msg, $msgt;
|
5 |
$pmpro_ready = pmpro_is_ready();
|
6 |
if(!$pmpro_ready)
|
7 |
{
|
8 |
global $pmpro_level_ready, $pmpro_gateway_ready, $pmpro_pages_ready;
|
9 |
+
$edit = $_REQUEST['edit'];
|
10 |
+
if(!$msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
$msg = -1;
|
12 |
+
if(!$pmpro_level_ready && !$edit)
|
13 |
+
$msgt .= " <a href=\"?page=pmpro-membershiplevels&edit=-1\">Add a membership level</a> to get started.";
|
14 |
elseif($pmpro_level_ready && !$pmpro_pages_ready && $view != "pmpro-pagesettings")
|
15 |
+
$msgt .= " <a href=\"?page=pmpro-pagesettings\">Setup the membership pages</a>.";
|
16 |
elseif($pmpro_level_ready && $pmpro_pages_ready && !$pmpro_gateway_ready && $view != "pmpro-paymentsettings")
|
17 |
+
$msgt .= " <a href=\"?page=pmpro-paymentsettings\">Setup your SSL certificate and payment gateway</a>.";
|
18 |
|
19 |
+
if(!$msgt)
|
20 |
$msg = false;
|
21 |
}
|
22 |
|
23 |
+
if($msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
{
|
25 |
?>
|
26 |
<div id="message" class="<?php if($msg > 0) echo "updated fade"; else echo "error"; ?>"><p><?php echo $msgt?></p></div>
|
29 |
|
30 |
?>
|
31 |
<div class="wrap pmpro_admin">
|
32 |
+
<div class="pmpro_banner">
|
33 |
+
<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/PaidMembershipsPro.gif" width="350" height="45" border="0" alt="Paid Memberships Pro(c) - All Rights Reserved" /></a>
|
34 |
+
<div class="pmpro_tagline">Membership Plugin for WordPress</div>
|
|
|
|
|
|
|
35 |
|
36 |
+
<div class="pmpro_meta"><a href="<?php echo pmpro_https_filter("http://www.paidmembershipspro.com")?>">Plugin Support</a> | <a href="http://www.paidmembershipspro.com/forums/">User Forum</a> | <strong>Version <?php echo PMPRO_VERSION?></strong></div>
|
37 |
+
</div>
|
38 |
+
<br style="clear:both;" />
|
39 |
+
|
40 |
+
<?php
|
41 |
+
//include(pmpro_https_filter("http://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION));
|
42 |
+
?>
|
43 |
<div id="pmpro_notifications">
|
44 |
</div>
|
45 |
<script>
|
46 |
+
jQuery.get('<?php echo pmpro_https_filter("http://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION)?>', function(data) {
|
47 |
+
jQuery('#pmpro_notifications').html(data);
|
|
|
|
|
|
|
48 |
});
|
49 |
</script>
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
<h3 class="nav-tab-wrapper">
|
52 |
+
<a href="admin.php?page=pmpro-membershiplevels" class="nav-tab<?php if($view == 'pmpro-membershiplevels') { ?> nav-tab-active<?php } ?>">Membership Levels</a>
|
53 |
+
<a href="admin.php?page=pmpro-pagesettings" class="nav-tab<?php if($view == 'pmpro-pagesettings') { ?> nav-tab-active<?php } ?>">Pages</a>
|
54 |
+
<a href="admin.php?page=pmpro-paymentsettings" class="nav-tab<?php if($view == 'pmpro-paymentsettings') { ?> nav-tab-active<?php } ?>">SSL & Payment Gateway</a>
|
55 |
+
<a href="admin.php?page=pmpro-emailsettings" class="nav-tab<?php if($view == 'pmpro-emailsettings') { ?> nav-tab-active<?php } ?>">Email</a>
|
56 |
+
<a href="admin.php?page=pmpro-advancedsettings" class="nav-tab<?php if($view == 'pmpro-advancedsettings') { ?> nav-tab-active<?php } ?>">Advanced</a>
|
57 |
+
</h3>
|
|
|
|
adminpages/advancedsettings.php
CHANGED
@@ -1,20 +1,13 @@
|
|
1 |
<?php
|
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.", "pmpro"));
|
6 |
-
}
|
7 |
-
|
8 |
global $wpdb, $msg, $msgt;
|
9 |
|
10 |
//get/set settings
|
11 |
-
if(
|
12 |
{
|
13 |
//other settings
|
14 |
pmpro_setOption("nonmembertext");
|
15 |
pmpro_setOption("notloggedintext");
|
16 |
pmpro_setOption("rsstext");
|
17 |
-
pmpro_setOption("filterqueries");
|
18 |
pmpro_setOption("showexcerpts");
|
19 |
pmpro_setOption("hideads");
|
20 |
pmpro_setOption("hideadslevels");
|
@@ -30,24 +23,16 @@
|
|
30 |
|
31 |
//footer link
|
32 |
pmpro_setOption("hide_footer_link");
|
33 |
-
|
34 |
-
// custom settings (added with pmpro_custom_advanced_settings hook)
|
35 |
-
foreach($_REQUEST as $key => $value ) {
|
36 |
-
if (strpos($key, 'custom_') === 0) {
|
37 |
-
pmpro_setOption($key);
|
38 |
-
}
|
39 |
-
}
|
40 |
|
41 |
//assume success
|
42 |
$msg = true;
|
43 |
-
$msgt =
|
44 |
}
|
45 |
|
46 |
$nonmembertext = pmpro_getOption("nonmembertext");
|
47 |
$notloggedintext = pmpro_getOption("notloggedintext");
|
48 |
$rsstext = pmpro_getOption("rsstext");
|
49 |
$hideads = pmpro_getOption("hideads");
|
50 |
-
$filterqueries = pmpro_getOption('filterqueries');
|
51 |
$showexcerpts = pmpro_getOption("showexcerpts");
|
52 |
$hideadslevels = pmpro_getOption("hideadslevels");
|
53 |
|
@@ -65,97 +50,84 @@
|
|
65 |
//default settings
|
66 |
if(!$nonmembertext)
|
67 |
{
|
68 |
-
$nonmembertext =
|
69 |
pmpro_setOption("nonmembertext", $nonmembertext);
|
70 |
}
|
71 |
if(!$notloggedintext)
|
72 |
{
|
73 |
-
$notloggedintext =
|
74 |
pmpro_setOption("notloggedintext", $notloggedintext);
|
75 |
}
|
76 |
if(!$rsstext)
|
77 |
{
|
78 |
-
$rsstext =
|
79 |
pmpro_setOption("rsstext", $rsstext);
|
80 |
}
|
81 |
-
|
82 |
-
$levels = $wpdb->get_results( "SELECT * FROM {$wpdb->pmpro_membership_levels}", OBJECT );
|
83 |
|
84 |
require_once(dirname(__FILE__) . "/admin_header.php");
|
85 |
?>
|
86 |
|
87 |
<form action="" method="post" enctype="multipart/form-data">
|
88 |
-
<h2
|
89 |
|
90 |
<table class="form-table">
|
91 |
<tbody>
|
92 |
<tr>
|
93 |
<th scope="row" valign="top">
|
94 |
-
<label for="nonmembertext"
|
95 |
</th>
|
96 |
<td>
|
97 |
<textarea name="nonmembertext" rows="3" cols="80"><?php echo stripslashes($nonmembertext)?></textarea><br />
|
98 |
-
<small class="litegray"
|
99 |
</td>
|
100 |
</tr>
|
101 |
<tr>
|
102 |
<th scope="row" valign="top">
|
103 |
-
<label for="notloggedintext"
|
104 |
</th>
|
105 |
<td>
|
106 |
<textarea name="notloggedintext" rows="3" cols="80"><?php echo stripslashes($notloggedintext)?></textarea><br />
|
107 |
-
<small class="litegray"
|
108 |
</td>
|
109 |
</tr>
|
110 |
<tr>
|
111 |
<th scope="row" valign="top">
|
112 |
-
<label for="rsstext"
|
113 |
</th>
|
114 |
<td>
|
115 |
<textarea name="rsstext" rows="3" cols="80"><?php echo stripslashes($rsstext)?></textarea><br />
|
116 |
-
<small class="litegray"
|
117 |
</td>
|
118 |
</tr>
|
119 |
|
120 |
<tr>
|
121 |
<th scope="row" valign="top">
|
122 |
-
<label for="
|
123 |
</th>
|
124 |
<td>
|
125 |
-
<select id="
|
126 |
-
<option value="0" <?php if(!$
|
127 |
-
<option value="1" <?php if($
|
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?', 'pmpro');?></label>
|
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.', 'pmpro');?></option>
|
138 |
-
<option value="1" <?php if($showexcerpts == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes - Show excerpts.', 'pmpro');?></option>
|
139 |
-
</select>
|
140 |
-
</td>
|
141 |
-
</tr>
|
142 |
-
<tr>
|
143 |
<th scope="row" valign="top">
|
144 |
<label for="hideads">Hide Ads From Members?</label>
|
145 |
</th>
|
146 |
<td>
|
147 |
<select id="hideads" name="hideads" onchange="pmpro_updateHideAdsTRs();">
|
148 |
-
<option value="0" <?php if(!$hideads) { ?>selected="selected"<?php }
|
149 |
-
<option value="1" <?php if($hideads == 1) { ?>selected="selected"<?php }
|
150 |
-
<option value="2" <?php if($hideads == 2) { ?>selected="selected"<?php }
|
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"
|
158 |
-
<p
|
159 |
<pre lang="PHP">
|
160 |
if(pmpro_displayAds())
|
161 |
{
|
@@ -166,14 +138,14 @@ 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"
|
170 |
</th>
|
171 |
<td>
|
172 |
<div class="checkbox_box" <?php if(count($levels) > 5) { ?>style="height: 100px; overflow: auto;"<?php } ?>>
|
173 |
<?php
|
174 |
$hideadslevels = pmpro_getOption("hideadslevels");
|
175 |
if(!is_array($hideadslevels))
|
176 |
-
$hideadslevels =
|
177 |
|
178 |
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ";
|
179 |
$levels = $wpdb->get_results($sqlQuery, OBJECT);
|
@@ -200,49 +172,49 @@ if(pmpro_displayAds())
|
|
200 |
<?php if(is_multisite()) { ?>
|
201 |
<tr>
|
202 |
<th scope="row" valign="top">
|
203 |
-
<label for="redirecttosubscription"
|
204 |
</th>
|
205 |
<td>
|
206 |
<select id="redirecttosubscription" name="redirecttosubscription">
|
207 |
-
<option value="0" <?php if(!$redirecttosubscription) { ?>selected="selected"<?php }
|
208 |
-
<option value="1" <?php if($redirecttosubscription == 1) { ?>selected="selected"<?php }
|
209 |
</select>
|
210 |
</td>
|
211 |
</tr>
|
212 |
<?php } ?>
|
213 |
<tr>
|
214 |
<th scope="row" valign="top">
|
215 |
-
<label for="recaptcha"
|
216 |
</th>
|
217 |
<td>
|
218 |
<select id="recaptcha" name="recaptcha" onchange="pmpro_updateRecaptchaTRs();">
|
219 |
-
<option value="0" <?php if(!$recaptcha) { ?>selected="selected"<?php }
|
220 |
-
<option value="1" <?php if($recaptcha == 1) { ?>selected="selected"<?php }
|
221 |
-
<option value="2" <?php if($recaptcha == 2) { ?>selected="selected"<?php }
|
222 |
</select><br />
|
223 |
-
<small
|
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"
|
230 |
<input type="text" name="recaptcha_publickey" size="60" value="<?php echo $recaptcha_publickey?>" />
|
231 |
<br /><br />
|
232 |
-
<label for="recaptcha_privatekey"
|
233 |
<input type="text" name="recaptcha_privatekey" size="60" value="<?php echo $recaptcha_privatekey?>" />
|
234 |
</td>
|
235 |
</tr>
|
236 |
<tr>
|
237 |
<th scope="row" valign="top">
|
238 |
-
<label for="tospage"
|
239 |
</th>
|
240 |
<td>
|
241 |
<?php
|
242 |
wp_dropdown_pages(array("name"=>"tospage", "show_option_none"=>"No", "selected"=>$tospage));
|
243 |
?>
|
244 |
<br />
|
245 |
-
<small
|
246 |
</td>
|
247 |
</tr>
|
248 |
|
@@ -257,73 +229,9 @@ if(pmpro_displayAds())
|
|
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 |
-
$custom_fields = apply_filters('pmpro_custom_advanced_settings', $custom_fields);
|
266 |
-
foreach ($custom_fields as $field) {
|
267 |
-
?>
|
268 |
-
<tr>
|
269 |
-
<th valign="top" scope="row">
|
270 |
-
<label
|
271 |
-
for="<?php _e($field['field_name'], 'pmpro'); ?>"><?php _e($field['label'], 'pmpro'); ?></label>
|
272 |
-
</th>
|
273 |
-
<td>
|
274 |
-
<?php
|
275 |
-
switch ($field['field_type']) {
|
276 |
-
case 'select':
|
277 |
-
?>
|
278 |
-
<select id="<?php _e($field['field_name'], 'pmpro'); ?>"
|
279 |
-
name="<?php _e($field['field_name'], 'pmpro'); ?>">
|
280 |
-
<?php foreach ($field['options'] as $option) {
|
281 |
-
?>
|
282 |
-
<option value="<?php _e($option, 'pmpro'); ?>"
|
283 |
-
<?php
|
284 |
-
if ($option == pmpro_getOption($field['field_name'])) {
|
285 |
-
_e('selected', 'pmpro');
|
286 |
-
}
|
287 |
-
?>
|
288 |
-
><?php _e($option, 'pmpro'); ?></option>
|
289 |
-
<?php
|
290 |
-
} ?>
|
291 |
-
</select>
|
292 |
-
<?php
|
293 |
-
break;
|
294 |
-
case 'text':
|
295 |
-
?>
|
296 |
-
<input id="<?php _e($field['field_name'], 'pmpro'); ?>"
|
297 |
-
name="<?php _e($field['field_name'], 'pmpro'); ?>"
|
298 |
-
type="<?php _e($field['field_type'], 'pmpro'); ?>"
|
299 |
-
value="<?php echo pmpro_getOption($field['field_name']); ?> ">
|
300 |
-
<?php
|
301 |
-
break;
|
302 |
-
case 'textarea':
|
303 |
-
?>
|
304 |
-
<textarea id="<?php _e($field['field_name'], 'pmpro'); ?>"
|
305 |
-
name="<?php _e($field['field_name'], 'pmpro'); ?>">
|
306 |
-
<?php echo pmpro_getOption($field['field_name']); ?>
|
307 |
-
</textarea>
|
308 |
-
<?php
|
309 |
-
break;
|
310 |
-
default:
|
311 |
-
break;
|
312 |
-
}
|
313 |
-
if (!empty($field['description'])) {
|
314 |
-
?>
|
315 |
-
<br>
|
316 |
-
<small><?php _e($field['description'], 'pmpro'); ?></small>
|
317 |
-
<?php
|
318 |
-
}
|
319 |
-
?>
|
320 |
-
</td>
|
321 |
-
<?php
|
322 |
-
}
|
323 |
-
}
|
324 |
-
?>
|
325 |
-
</tr>
|
326 |
-
</tbody>
|
327 |
</table>
|
328 |
<script>
|
329 |
function pmpro_updateHideAdsTRs()
|
@@ -365,7 +273,7 @@ if(pmpro_displayAds())
|
|
365 |
</script>
|
366 |
|
367 |
<p class="submit">
|
368 |
-
<input name="savesettings" type="submit" class="button
|
369 |
</p>
|
370 |
</form>
|
371 |
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
global $wpdb, $msg, $msgt;
|
3 |
|
4 |
//get/set settings
|
5 |
+
if($_REQUEST['savesettings'])
|
6 |
{
|
7 |
//other settings
|
8 |
pmpro_setOption("nonmembertext");
|
9 |
pmpro_setOption("notloggedintext");
|
10 |
pmpro_setOption("rsstext");
|
|
|
11 |
pmpro_setOption("showexcerpts");
|
12 |
pmpro_setOption("hideads");
|
13 |
pmpro_setOption("hideadslevels");
|
23 |
|
24 |
//footer link
|
25 |
pmpro_setOption("hide_footer_link");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
//assume success
|
28 |
$msg = true;
|
29 |
+
$msgt = "Your advanced settings have been updated.";
|
30 |
}
|
31 |
|
32 |
$nonmembertext = pmpro_getOption("nonmembertext");
|
33 |
$notloggedintext = pmpro_getOption("notloggedintext");
|
34 |
$rsstext = pmpro_getOption("rsstext");
|
35 |
$hideads = pmpro_getOption("hideads");
|
|
|
36 |
$showexcerpts = pmpro_getOption("showexcerpts");
|
37 |
$hideadslevels = pmpro_getOption("hideadslevels");
|
38 |
|
50 |
//default settings
|
51 |
if(!$nonmembertext)
|
52 |
{
|
53 |
+
$nonmembertext = "This content is for !!levels!! members only. <a href=\"" . wp_login_url() . "?action=register\">Register here</a>.";
|
54 |
pmpro_setOption("nonmembertext", $nonmembertext);
|
55 |
}
|
56 |
if(!$notloggedintext)
|
57 |
{
|
58 |
+
$notloggedintext = "Please <a href=\"" . wp_login_url( get_permalink() ) . "\">login</a> to view this content. (<a href=\"" . wp_login_url() . "?action=register\">Register here</a>.)";
|
59 |
pmpro_setOption("notloggedintext", $notloggedintext);
|
60 |
}
|
61 |
if(!$rsstext)
|
62 |
{
|
63 |
+
$rsstext = "This content is for members only. Visit the site and log in/register to read.";
|
64 |
pmpro_setOption("rsstext", $rsstext);
|
65 |
}
|
|
|
|
|
66 |
|
67 |
require_once(dirname(__FILE__) . "/admin_header.php");
|
68 |
?>
|
69 |
|
70 |
<form action="" method="post" enctype="multipart/form-data">
|
71 |
+
<h2>Advanced Settings</h2>
|
72 |
|
73 |
<table class="form-table">
|
74 |
<tbody>
|
75 |
<tr>
|
76 |
<th scope="row" valign="top">
|
77 |
+
<label for="nonmembertext">Message for Logged-in Non-members:</label>
|
78 |
</th>
|
79 |
<td>
|
80 |
<textarea name="nonmembertext" rows="3" cols="80"><?php echo stripslashes($nonmembertext)?></textarea><br />
|
81 |
+
<small class="litegray">This message replaces the post content for non-members. Available variables: !!levels!!, !!referrer!!</small>
|
82 |
</td>
|
83 |
</tr>
|
84 |
<tr>
|
85 |
<th scope="row" valign="top">
|
86 |
+
<label for="notloggedintext">Message for Logged-out Users:</label>
|
87 |
</th>
|
88 |
<td>
|
89 |
<textarea name="notloggedintext" rows="3" cols="80"><?php echo stripslashes($notloggedintext)?></textarea><br />
|
90 |
+
<small class="litegray">This message replaces the post content for logged-out visitors.</small>
|
91 |
</td>
|
92 |
</tr>
|
93 |
<tr>
|
94 |
<th scope="row" valign="top">
|
95 |
+
<label for="rsstext">Message for RSS Feed:</label>
|
96 |
</th>
|
97 |
<td>
|
98 |
<textarea name="rsstext" rows="3" cols="80"><?php echo stripslashes($rsstext)?></textarea><br />
|
99 |
+
<small class="litegray">This message replaces the post content in RSS feeds.</small>
|
100 |
</td>
|
101 |
</tr>
|
102 |
|
103 |
<tr>
|
104 |
<th scope="row" valign="top">
|
105 |
+
<label for="showexcerpts">Show Excerpts to Non-Members?</label>
|
106 |
</th>
|
107 |
<td>
|
108 |
+
<select id="showexcerpts" name="showexcerpts">
|
109 |
+
<option value="0" <?php if(!$showexcerpts) { ?>selected="selected"<?php } ?>>No - Hide excerpts.</option>
|
110 |
+
<option value="1" <?php if($showexcerpts == 1) { ?>selected="selected"<?php } ?>>Yes - Show excerpts.</option>
|
111 |
</select>
|
112 |
</td>
|
113 |
</tr>
|
114 |
<tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
<th scope="row" valign="top">
|
116 |
<label for="hideads">Hide Ads From Members?</label>
|
117 |
</th>
|
118 |
<td>
|
119 |
<select id="hideads" name="hideads" onchange="pmpro_updateHideAdsTRs();">
|
120 |
+
<option value="0" <?php if(!$hideads) { ?>selected="selected"<?php } ?>>No</option>
|
121 |
+
<option value="1" <?php if($hideads == 1) { ?>selected="selected"<?php } ?>>Hide Ads From All Members</option>
|
122 |
+
<option value="2" <?php if($hideads == 2) { ?>selected="selected"<?php } ?>>Hide Ads From Certain Members</option>
|
123 |
</select>
|
124 |
</td>
|
125 |
</tr>
|
126 |
<tr id="hideads_explanation" <?php if($hideads < 2) { ?>style="display: none;"<?php } ?>>
|
127 |
<th scope="row" valign="top"> </th>
|
128 |
<td>
|
129 |
+
<p class="top0em">Ads from the following plugins will be automatically turned off: <em>Easy Adsense</em>, ...</p>
|
130 |
+
<p>To hide ads in your template code, use code like the following:</p>
|
131 |
<pre lang="PHP">
|
132 |
if(pmpro_displayAds())
|
133 |
{
|
138 |
</tr>
|
139 |
<tr id="hideadslevels_tr" <?php if($hideads != 2) { ?>style="display: none;"<?php } ?>>
|
140 |
<th scope="row" valign="top">
|
141 |
+
<label for="hideadslevels">Choose Levels to Hide Ads From:</label>
|
142 |
</th>
|
143 |
<td>
|
144 |
<div class="checkbox_box" <?php if(count($levels) > 5) { ?>style="height: 100px; overflow: auto;"<?php } ?>>
|
145 |
<?php
|
146 |
$hideadslevels = pmpro_getOption("hideadslevels");
|
147 |
if(!is_array($hideadslevels))
|
148 |
+
$hideadslevels = split(",", $hideadslevels);
|
149 |
|
150 |
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ";
|
151 |
$levels = $wpdb->get_results($sqlQuery, OBJECT);
|
172 |
<?php if(is_multisite()) { ?>
|
173 |
<tr>
|
174 |
<th scope="row" valign="top">
|
175 |
+
<label for="redirecttosubscription">Redirect all traffic from registration page to /susbcription/?: <em>(multisite only)</em></label>
|
176 |
</th>
|
177 |
<td>
|
178 |
<select id="redirecttosubscription" name="redirecttosubscription">
|
179 |
+
<option value="0" <?php if(!$redirecttosubscription) { ?>selected="selected"<?php } ?>>No</option>
|
180 |
+
<option value="1" <?php if($redirecttosubscription == 1) { ?>selected="selected"<?php } ?>>Yes</option>
|
181 |
</select>
|
182 |
</td>
|
183 |
</tr>
|
184 |
<?php } ?>
|
185 |
<tr>
|
186 |
<th scope="row" valign="top">
|
187 |
+
<label for="recaptcha">Use reCAPTCHA?:</label>
|
188 |
</th>
|
189 |
<td>
|
190 |
<select id="recaptcha" name="recaptcha" onchange="pmpro_updateRecaptchaTRs();">
|
191 |
+
<option value="0" <?php if(!$recaptcha) { ?>selected="selected"<?php } ?>>No</option>
|
192 |
+
<option value="1" <?php if($recaptcha == 1) { ?>selected="selected"<?php } ?>>Yes - Free memberships only.</option>
|
193 |
+
<option value="2" <?php if($recaptcha == 2) { ?>selected="selected"<?php } ?>>Yes - All memberships.</option>
|
194 |
</select><br />
|
195 |
+
<small>A free reCAPTCHA key is required. <a href="https://www.google.com/recaptcha/admin/create">Click here to signup for reCAPTCHA</a>.</small>
|
196 |
</td>
|
197 |
</tr>
|
198 |
<tr id="recaptcha_tr" <?php if(!$recaptcha) { ?>style="display: none;"<?php } ?>>
|
199 |
<th scope="row" valign="top"> </th>
|
200 |
<td>
|
201 |
+
<label for="recaptcha_publickey">reCAPTCHA Public Key:</label>
|
202 |
<input type="text" name="recaptcha_publickey" size="60" value="<?php echo $recaptcha_publickey?>" />
|
203 |
<br /><br />
|
204 |
+
<label for="recaptcha_privatekey">reCAPTCHA Private Key:</label>
|
205 |
<input type="text" name="recaptcha_privatekey" size="60" value="<?php echo $recaptcha_privatekey?>" />
|
206 |
</td>
|
207 |
</tr>
|
208 |
<tr>
|
209 |
<th scope="row" valign="top">
|
210 |
+
<label for="tospage">Require Terms of Service on signups?</label>
|
211 |
</th>
|
212 |
<td>
|
213 |
<?php
|
214 |
wp_dropdown_pages(array("name"=>"tospage", "show_option_none"=>"No", "selected"=>$tospage));
|
215 |
?>
|
216 |
<br />
|
217 |
+
<small>If yes, create a WordPress page containing your TOS agreement and assign it using the dropdown above.</small>
|
218 |
</td>
|
219 |
</tr>
|
220 |
|
229 |
<option value="1" <?php if($hide_footer_link == 1) { ?>selected="selected"<?php } ?>>Yes - Hide the link.</option>
|
230 |
</select>
|
231 |
</td>
|
232 |
+
</tr>
|
233 |
+
*/ ?>
|
234 |
+
</tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
</table>
|
236 |
<script>
|
237 |
function pmpro_updateHideAdsTRs()
|
273 |
</script>
|
274 |
|
275 |
<p class="submit">
|
276 |
+
<input name="savesettings" type="submit" class="button-primary" value="Save Settings" />
|
277 |
</p>
|
278 |
</form>
|
279 |
|
adminpages/dashboard.php
CHANGED
@@ -97,7 +97,7 @@
|
|
97 |
foreach ( $rss_items as $item ) {
|
98 |
echo '<li class="pmpro_news">';
|
99 |
echo '<a class="rsswidget" href="'.esc_url( $item->get_permalink(), $protocolls=null, 'display' ).'">'. esc_html( $item->get_title() ) .'</a>';
|
100 |
-
echo ' <span class="rss-date">'. $item->get_date(
|
101 |
echo '<div class="rssSummary">'. esc_html( pmpro_text_limit( strip_tags( $item->get_description() ), 150 ) ).'</div>';
|
102 |
echo '</li>';
|
103 |
}
|
@@ -105,9 +105,9 @@
|
|
105 |
|
106 |
echo '</ul>';
|
107 |
echo '<br class="clear"/><div style="margin-top:10px;border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">';
|
108 |
-
echo '<a
|
109 |
echo ' ';
|
110 |
-
echo '<a
|
111 |
echo '<form class="alignright" method="post"><input type="hidden" name="pmpro_removedbwidget" value="true"/><input title="Remove this widget from all users dashboards" class="button" type="submit" value="X"/></form>';
|
112 |
echo '</div>';
|
113 |
}
|
@@ -124,4 +124,4 @@
|
|
124 |
}
|
125 |
|
126 |
add_action( 'wp_dashboard_setup', 'pmpro_widget_setup');
|
127 |
-
?>
|
97 |
foreach ( $rss_items as $item ) {
|
98 |
echo '<li class="pmpro_news">';
|
99 |
echo '<a class="rsswidget" href="'.esc_url( $item->get_permalink(), $protocolls=null, 'display' ).'">'. esc_html( $item->get_title() ) .'</a>';
|
100 |
+
echo ' <span class="rss-date">'. $item->get_date('F j, Y') .'</span>';
|
101 |
echo '<div class="rssSummary">'. esc_html( pmpro_text_limit( strip_tags( $item->get_description() ), 150 ) ).'</div>';
|
102 |
echo '</li>';
|
103 |
}
|
105 |
|
106 |
echo '</ul>';
|
107 |
echo '<br class="clear"/><div style="margin-top:10px;border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">';
|
108 |
+
echo '<a href="'.$pmpro_feed.'"><img src="'.get_bloginfo('wpurl').'/wp-includes/images/rss.png" alt=""/> Subscribe with RSS</a>';
|
109 |
echo ' ';
|
110 |
+
echo '<a href="http://www.paidmembershipspro.com/"><img src="'.get_bloginfo('wpurl').'/wp-includes/images/wpmini-blue.png" alt=""/> View Online</a>';
|
111 |
echo '<form class="alignright" method="post"><input type="hidden" name="pmpro_removedbwidget" value="true"/><input title="Remove this widget from all users dashboards" class="button" type="submit" value="X"/></form>';
|
112 |
echo '</div>';
|
113 |
}
|
124 |
}
|
125 |
|
126 |
add_action( 'wp_dashboard_setup', 'pmpro_widget_setup');
|
127 |
+
?>
|
adminpages/discountcodes.php
CHANGED
@@ -1,636 +1,614 @@
|
|
1 |
-
<?php
|
2 |
-
//
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
$
|
13 |
-
|
14 |
-
$
|
15 |
-
|
16 |
-
|
17 |
-
$
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
$
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$
|
49 |
-
$
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
{
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
}
|
122 |
-
else
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
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 |
-
if(
|
326 |
-
$
|
327 |
-
else
|
328 |
-
$
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
$
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
}
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
if(
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
}
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
<
|
442 |
-
|
443 |
-
<input name="
|
444 |
-
<
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
</tr>
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
<input
|
520 |
-
<input
|
521 |
-
|
522 |
-
</
|
523 |
-
</
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
<
|
528 |
-
|
529 |
-
<
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
?>
|
616 |
-
</td>
|
617 |
-
<?php do_action("pmpro_discountcodes_extra_cols_body", $code);?>
|
618 |
-
<td>
|
619 |
-
<a href="?page=pmpro-discountcodes&edit=<?php echo $code->id?>"><?php _e('edit', 'pmpro');?></a>
|
620 |
-
</td>
|
621 |
-
<td>
|
622 |
-
<a href="javascript:askfirst('<?php printf(__('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.', 'pmpro'), $code->code);?>', '?page=pmpro-discountcodes&delete=<?php echo $code->id?>'); void(0);"><?php _e('delete', 'pmpro');?></a>
|
623 |
-
</td>
|
624 |
-
</tr>
|
625 |
-
<?php
|
626 |
-
}
|
627 |
-
}
|
628 |
-
?>
|
629 |
-
</tbody>
|
630 |
-
</table>
|
631 |
-
|
632 |
-
<?php } ?>
|
633 |
-
|
634 |
-
<?php
|
635 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
636 |
-
?>
|
1 |
+
<?php
|
2 |
+
//vars
|
3 |
+
global $wpdb, $pmpro_currency_symbol;
|
4 |
+
$edit = $_REQUEST['edit'];
|
5 |
+
$delete = $_REQUEST['delete'];
|
6 |
+
$saveid = $_POST['saveid'];
|
7 |
+
|
8 |
+
if($saveid)
|
9 |
+
{
|
10 |
+
//get vars
|
11 |
+
$code = $_POST['code'];
|
12 |
+
$starts_month = $_POST['starts_month'];
|
13 |
+
$starts_day = $_POST['starts_day'];
|
14 |
+
$starts_year = $_POST['starts_year'];
|
15 |
+
$expires_month = $_POST['expires_month'];
|
16 |
+
$expires_day = $_POST['expires_day'];
|
17 |
+
$expires_year = $_POST['expires_year'];
|
18 |
+
$uses = $_POST['uses'];
|
19 |
+
|
20 |
+
//fix up dates
|
21 |
+
$starts = date("Y-m-d", strtotime($starts_month . "/" . $starts_day . "/" . $starts_year));
|
22 |
+
$expires = date("Y-m-d", strtotime($expires_month . "/" . $expires_day . "/" . $expires_year));
|
23 |
+
|
24 |
+
//updating or new?
|
25 |
+
if($saveid > 0)
|
26 |
+
{
|
27 |
+
$sqlQuery = "UPDATE $wpdb->pmpro_discount_codes SET code = '" . $wpdb->escape($code) . "', starts = '" . $starts . "', expires = '" . $expires . "', uses = '" . $uses . "' WHERE id = '" . $saveid . "' LIMIT 1";
|
28 |
+
if($wpdb->query($sqlQuery) !== false)
|
29 |
+
{
|
30 |
+
$pmpro_msg = "Discount code updated successfully.";
|
31 |
+
$pmpro_msgt = "success";
|
32 |
+
$saved = true;
|
33 |
+
$edit = $saveid;
|
34 |
+
}
|
35 |
+
else
|
36 |
+
{
|
37 |
+
$pmpro_msg = "Error updating discount code. That code may already be in use.";
|
38 |
+
$pmpro_msgt = "error";
|
39 |
+
}
|
40 |
+
}
|
41 |
+
else
|
42 |
+
{
|
43 |
+
$sqlQuery = "INSERT INTO $wpdb->pmpro_discount_codes (id, code, starts, expires, uses) VALUES('', '" . $wpdb->escape($code) . "', '" . $starts . "', '" . $expires . "', '" . $uses . "')";
|
44 |
+
if($wpdb->query($sqlQuery) !== false)
|
45 |
+
{
|
46 |
+
$pmpro_msg = "Discount code added successfully.";
|
47 |
+
$pmpro_msgt = "success";
|
48 |
+
$saved = true;
|
49 |
+
$edit = $wpdb->insert_id;
|
50 |
+
}
|
51 |
+
else
|
52 |
+
{
|
53 |
+
$pmpro_msg = "Error adding discount code. That code may already be in use.";
|
54 |
+
$pmpro_msgt = "error";
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
//now add the membership level rows
|
59 |
+
if($saved && $edit > 0)
|
60 |
+
{
|
61 |
+
//get the submitted values
|
62 |
+
$all_levels_a = $_REQUEST['all_levels'];
|
63 |
+
$levels_a = $_REQUEST['levels'];
|
64 |
+
$initial_payment_a = $_REQUEST['initial_payment'];
|
65 |
+
$recurring_a = $_REQUEST['recurring'];
|
66 |
+
$billing_amount_a = $_REQUEST['billing_amount'];
|
67 |
+
$cycle_number_a = $_REQUEST['cycle_number'];
|
68 |
+
$cycle_period_a = $_REQUEST['cycle_period'];
|
69 |
+
$billing_limit_a = $_REQUEST['billing_limit'];
|
70 |
+
$custom_trial_a = $_REQUEST['custom_trial'];
|
71 |
+
$trial_amount_a = $_REQUEST['trial_amount'];
|
72 |
+
$trial_limit_a = $_REQUEST['trial_limit'];
|
73 |
+
$expiration_a = $_REQUEST['expiration'];
|
74 |
+
$expiration_number_a = $_REQUEST['expiration_number'];
|
75 |
+
$expiration_period_a = $_REQUEST['expiration_period'];
|
76 |
+
|
77 |
+
//clear the old rows
|
78 |
+
$sqlQuery = "DELETE FROM $wpdb->pmpro_discount_codes_levels WHERE code_id = '" . $edit . "'";
|
79 |
+
$wpdb->query($sqlQuery);
|
80 |
+
|
81 |
+
//add a row for each checked level
|
82 |
+
foreach($levels_a as $level_id)
|
83 |
+
{
|
84 |
+
//get the values ready
|
85 |
+
$n = array_search($level_id, $all_levels_a); //this is the key location of this level's values
|
86 |
+
$initial_payment = $initial_payment_a[$n];
|
87 |
+
|
88 |
+
//is this recurring?
|
89 |
+
if($recurring_a)
|
90 |
+
{
|
91 |
+
if(in_array($level_id, $recurring_a))
|
92 |
+
$recurring = 1;
|
93 |
+
else
|
94 |
+
$recurring = 0;
|
95 |
+
}
|
96 |
+
else
|
97 |
+
$recurring = 0;
|
98 |
+
|
99 |
+
if($recurring)
|
100 |
+
{
|
101 |
+
$billing_amount = $billing_amount_a[$n];
|
102 |
+
$cycle_number = $cycle_number_a[$n];
|
103 |
+
$cycle_period = $cycle_period_a[$n];
|
104 |
+
$billing_limit = $billing_limit_a[$n];
|
105 |
+
|
106 |
+
//custom trial
|
107 |
+
if($custom_trial_a)
|
108 |
+
{
|
109 |
+
if(in_array($level_id, $custom_trial_a))
|
110 |
+
$custom_trial = 1;
|
111 |
+
else
|
112 |
+
$custom_trial = 0;
|
113 |
+
}
|
114 |
+
else
|
115 |
+
$custom_trial = 0;
|
116 |
+
|
117 |
+
if($custom_trial)
|
118 |
+
{
|
119 |
+
$trial_amount = $trial_amount_a[$n];
|
120 |
+
$trial_limit = $trial_limit_a[$n];
|
121 |
+
}
|
122 |
+
else
|
123 |
+
{
|
124 |
+
$trial_amount = '';
|
125 |
+
$trial_limit = '';
|
126 |
+
}
|
127 |
+
}
|
128 |
+
else
|
129 |
+
{
|
130 |
+
$billing_amount = '';
|
131 |
+
$cycle_number = '';
|
132 |
+
$cycle_period = '';
|
133 |
+
$billing_limit = '';
|
134 |
+
$custom_trial = 0;
|
135 |
+
$trial_amount = '';
|
136 |
+
$trial_limit = '';
|
137 |
+
}
|
138 |
+
|
139 |
+
if($expiration_a)
|
140 |
+
{
|
141 |
+
if(in_array($level_id, $expiration_a))
|
142 |
+
$expiration = 1;
|
143 |
+
else
|
144 |
+
$expiration = 0;
|
145 |
+
}
|
146 |
+
else
|
147 |
+
$expiration = 0;
|
148 |
+
|
149 |
+
if($expiration)
|
150 |
+
{
|
151 |
+
$expiration_number = $expiration_number_a[$n];
|
152 |
+
$expiration_period = $expiration_period_a[$n];
|
153 |
+
}
|
154 |
+
else
|
155 |
+
{
|
156 |
+
$expiration_number = '';
|
157 |
+
$expiration_period = '';
|
158 |
+
}
|
159 |
+
|
160 |
+
//okay, do the insert
|
161 |
+
$sqlQuery = "INSERT INTO $wpdb->pmpro_discount_codes_levels (code_id, level_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, trial_amount, trial_limit, expiration_number, expiration_period) VALUES('" . $wpdb->escape($edit) . "', '" . $wpdb->escape($level_id) . "', '" . $wpdb->escape($initial_payment) . "', '" . $wpdb->escape($billing_amount) . "', '" . $wpdb->escape($cycle_number) . "', '" . $wpdb->escape($cycle_period) . "', '" . $wpdb->escape($billing_limit) . "', '" . $wpdb->escape($trial_amount) . "', '" . $wpdb->escape($trial_limit) . "', '" . $wpdb->escape($expiration_number) . "', '" . $wpdb->escape($expiration_period) . "')";
|
162 |
+
|
163 |
+
if($wpdb->query($sqlQuery) !== false)
|
164 |
+
{
|
165 |
+
//okay
|
166 |
+
}
|
167 |
+
else
|
168 |
+
{
|
169 |
+
$level_errors[] = "Error saving values for the " . $wpdb->get_var("SELECT name FROM $wpdb->pmpro_membership_levels WHERE id = '" . $level_id . "' LIMIT 1") . " level.";
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
//errors?
|
174 |
+
if($level_errors)
|
175 |
+
{
|
176 |
+
$pmpro_msg = "There were errors updating the level values: " . explode(" ", $level_errors);
|
177 |
+
$pmpro_msgt = "error";
|
178 |
+
}
|
179 |
+
else
|
180 |
+
{
|
181 |
+
//all good. set edit = NULL so we go back to the overview page
|
182 |
+
$edit = NULL;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
//are we deleting?
|
188 |
+
if($delete)
|
189 |
+
{
|
190 |
+
//is this a code?
|
191 |
+
$code = $wpdb->get_var("SELECT code FROM $wpdb->pmpro_discount_codes WHERE id = '" . $delete . "' LIMIT 1");
|
192 |
+
if($code)
|
193 |
+
{
|
194 |
+
//delete the code levels
|
195 |
+
$r1 = $wpdb->query("DELETE FROM $wpdb->pmpro_discount_codes_levels WHERE code_id = '" . $delete . "'");
|
196 |
+
|
197 |
+
if($r1 !== false)
|
198 |
+
{
|
199 |
+
//delete the code
|
200 |
+
$r2 = $wpdb->query("DELETE FROM $wpdb->pmpro_discount_codes WHERE id = '" . $delete . "' LIMIT 1");
|
201 |
+
|
202 |
+
if($r2 !== false)
|
203 |
+
{
|
204 |
+
$pmpro_msg = "Code $code deleted successfully.";
|
205 |
+
$pmpro_msgt = "success";
|
206 |
+
}
|
207 |
+
else
|
208 |
+
{
|
209 |
+
$pmpro_msg = "Error deleting discount code. The code was only partially deleted. Please try again.";
|
210 |
+
$pmpro_msgt = "error";
|
211 |
+
}
|
212 |
+
}
|
213 |
+
else
|
214 |
+
{
|
215 |
+
$pmpro_msg = "Error deleting code. Please try again.";
|
216 |
+
$pmpro_msgt = "error";
|
217 |
+
}
|
218 |
+
}
|
219 |
+
else
|
220 |
+
{
|
221 |
+
$pmpro_msg = "Code not found.";
|
222 |
+
$pmpro_msgt = "error";
|
223 |
+
}
|
224 |
+
}
|
225 |
+
?>
|
226 |
+
<div class="wrap pmpro_admin">
|
227 |
+
<div class="pmpro_banner">
|
228 |
+
<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/PaidMembershipsPro.gif" width="350" height="45" border="0" alt="Paid Memberships Pro(c) - All Rights Reserved" /></a>
|
229 |
+
<div class="pmpro_tagline">Membership Plugin for WordPress</div>
|
230 |
+
|
231 |
+
<div class="pmpro_meta"><a href="<?php echo pmpro_https_filter("http://www.paidmembershipspro.com")?>">Plugin Support</a> | <a href="http://www.paidmembershipspro.com/forums/">User Forum</a> | <strong>Version <?php echo PMPRO_VERSION?></strong></div>
|
232 |
+
</div>
|
233 |
+
<br style="clear:both;" />
|
234 |
+
|
235 |
+
<?php
|
236 |
+
//include(pmpro_https_filter("http://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION));
|
237 |
+
?>
|
238 |
+
<div id="pmpro_notifications">
|
239 |
+
</div>
|
240 |
+
<script>
|
241 |
+
jQuery.get('<?php echo pmpro_https_filter("http://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION)?>', function(data) {
|
242 |
+
jQuery('#pmpro_notifications').html(data);
|
243 |
+
});
|
244 |
+
</script>
|
245 |
+
|
246 |
+
<?php if($edit) { ?>
|
247 |
+
|
248 |
+
<h2>
|
249 |
+
<?php
|
250 |
+
if($edit > 0)
|
251 |
+
echo "Edit Discount Code";
|
252 |
+
else
|
253 |
+
echo "Add New Discount Code";
|
254 |
+
?>
|
255 |
+
</h2>
|
256 |
+
|
257 |
+
<?php if($pmpro_msg){?>
|
258 |
+
<div id="message" class="<?php if($pmpro_msgt == "success") echo "updated fade"; else echo "error"; ?>"><p><?php echo $pmpro_msg?></p></div>
|
259 |
+
<?php } ?>
|
260 |
+
|
261 |
+
<div>
|
262 |
+
<?php
|
263 |
+
// get the code...
|
264 |
+
if($edit > 0)
|
265 |
+
{
|
266 |
+
$code = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes WHERE id = '" . $edit . "' LIMIT 1", OBJECT);
|
267 |
+
$uses = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $code->ID . "'");
|
268 |
+
$levels = $wpdb->get_results("SELECT l.id, l.name, cl.initial_payment, cl.billing_amount, cl.cycle_number, cl.period, cl.billing_limit, cl.trial_amount, cl.trial_limit FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_discount_codes_levels cl ON l.id = cl.level_id WHERE cl.code_id = '" . $code->code . "'");
|
269 |
+
$temp_id = $code->id;
|
270 |
+
}
|
271 |
+
elseif($copy > 0)
|
272 |
+
{
|
273 |
+
$code = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes WHERE id = '" . $copy . "' LIMIT 1", OBJECT);
|
274 |
+
$temp_id = $level->id;
|
275 |
+
$level->id = NULL;
|
276 |
+
}
|
277 |
+
|
278 |
+
// didn't find a discount code, let's add a new one...
|
279 |
+
if(!$code->id) $edit = -1;
|
280 |
+
|
281 |
+
//defaults for new codes
|
282 |
+
if($edit == -1)
|
283 |
+
{
|
284 |
+
$code = NULL;
|
285 |
+
$code->code = pmpro_getDiscountCode();
|
286 |
+
}
|
287 |
+
?>
|
288 |
+
<form action="" method="post">
|
289 |
+
<input name="saveid" type="hidden" value="<?php echo $edit?>" />
|
290 |
+
<table class="form-table">
|
291 |
+
<tbody>
|
292 |
+
<tr>
|
293 |
+
<th scope="row" valign="top"><label>ID:</label></th>
|
294 |
+
<td class="pmpro_lite"><?php if($code->id) echo $code->id; else echo "This will be generated when you save.";?></td>
|
295 |
+
</tr>
|
296 |
+
|
297 |
+
<tr>
|
298 |
+
<th scope="row" valign="top"><label for="code">Code:</label></th>
|
299 |
+
<td><input name="code" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($code->code))?>" /></td>
|
300 |
+
</tr>
|
301 |
+
|
302 |
+
<?php
|
303 |
+
//some vars for the dates
|
304 |
+
$current_day = date("j");
|
305 |
+
if($code->starts)
|
306 |
+
$selected_starts_day = date("j", $code->starts);
|
307 |
+
else
|
308 |
+
$selected_starts_day = $current_day;
|
309 |
+
if($code->expires)
|
310 |
+
$selected_expires_day = date("j", $code->expires);
|
311 |
+
else
|
312 |
+
$selected_expires_day = $current_day;
|
313 |
+
|
314 |
+
$current_month = date("M");
|
315 |
+
if($code->starts)
|
316 |
+
$selected_starts_month = date("m", $code->starts);
|
317 |
+
else
|
318 |
+
$selected_starts_month = date("m");
|
319 |
+
if($code->expires)
|
320 |
+
$selected_expires_month = date("m", $code->expires);
|
321 |
+
else
|
322 |
+
$selected_expires_month = date("m");
|
323 |
+
|
324 |
+
$current_year = date("Y");
|
325 |
+
if($code->starts)
|
326 |
+
$selected_starts_year = date("Y", $code->starts);
|
327 |
+
else
|
328 |
+
$selected_starts_year = $current_year;
|
329 |
+
if($code->expires)
|
330 |
+
$selected_expires_year = date("Y", $code->expires);
|
331 |
+
else
|
332 |
+
$selected_expires_year = (int)$current_year + 1;
|
333 |
+
?>
|
334 |
+
|
335 |
+
<tr>
|
336 |
+
<th scope="row" valign="top"><label for="starts">Start Date:</label></th>
|
337 |
+
<td>
|
338 |
+
<select name="starts_month">
|
339 |
+
<?php
|
340 |
+
for($i = 1; $i < 13; $i++)
|
341 |
+
{
|
342 |
+
?>
|
343 |
+
<option value="<?php echo $i?>" <?php if($i == $selected_starts_month) { ?>selected="selected"<?php } ?>><?php echo date("M", strtotime($i . "/1/" . $current_year))?></option>
|
344 |
+
<?php
|
345 |
+
}
|
346 |
+
?>
|
347 |
+
</select>
|
348 |
+
<input name="starts_day" type="text" size="2" value="<?php echo $selected_starts_day?>" />
|
349 |
+
<input name="starts_year" type="text" size="4" value="<?php echo $selected_starts_year?>" />
|
350 |
+
</td>
|
351 |
+
</tr>
|
352 |
+
|
353 |
+
<tr>
|
354 |
+
<th scope="row" valign="top"><label for="expires">Expiration Date:</label></th>
|
355 |
+
<td>
|
356 |
+
<select name="expires_month">
|
357 |
+
<?php
|
358 |
+
for($i = 1; $i < 13; $i++)
|
359 |
+
{
|
360 |
+
?>
|
361 |
+
<option value="<?php echo $i?>" <?php if($i == $selected_expires_month) { ?>selected="selected"<?php } ?>><?php echo date("M", strtotime($i . "/1/" . $current_year))?></option>
|
362 |
+
<?php
|
363 |
+
}
|
364 |
+
?>
|
365 |
+
</select>
|
366 |
+
<input name="expires_day" type="text" size="2" value="<?php echo $selected_expires_day?>" />
|
367 |
+
<input name="expires_year" type="text" size="4" value="<?php echo $selected_expires_year?>" />
|
368 |
+
</td>
|
369 |
+
</tr>
|
370 |
+
|
371 |
+
<tr>
|
372 |
+
<th scope="row" valign="top"><label for="uses">Uses:</label></th>
|
373 |
+
<td>
|
374 |
+
<input name="uses" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($code->uses))?>" />
|
375 |
+
<small class="pmpro_lite">Leave blank for unlimited uses.</small>
|
376 |
+
</td>
|
377 |
+
</tr>
|
378 |
+
|
379 |
+
</tbody>
|
380 |
+
</table>
|
381 |
+
|
382 |
+
<h3>Which Levels Will This Code Apply To?</h3>
|
383 |
+
|
384 |
+
<div class="pmpro_discount_levels">
|
385 |
+
<?php
|
386 |
+
$levels = $wpdb->get_results("SELECT * FROM $wpdb->pmpro_membership_levels");
|
387 |
+
foreach($levels as $level)
|
388 |
+
{
|
389 |
+
//if this level is already managed for this discount code, use the code values
|
390 |
+
if($edit > 0)
|
391 |
+
{
|
392 |
+
$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 = '" . $edit . "' AND cl.level_id = '" . $level->id . "' LIMIT 1");
|
393 |
+
if($code_level)
|
394 |
+
{
|
395 |
+
$level = $code_level;
|
396 |
+
$level->checked = true;
|
397 |
+
}
|
398 |
+
else
|
399 |
+
$level_checked = false;
|
400 |
+
}
|
401 |
+
else
|
402 |
+
$level_checked = false;
|
403 |
+
?>
|
404 |
+
<div>
|
405 |
+
<input type="hidden" name="all_levels[]" value="<?php echo $level->id?>" />
|
406 |
+
<input type="checkbox" name="levels[]" value="<?php echo $level->id?>" <?php if($level->checked) { ?>checked="checked"<?php } ?> onclick="if(jQuery(this).is(':checked')) jQuery(this).next().show(); else jQuery(this).next().hide();" />
|
407 |
+
<?php echo $level->name?>
|
408 |
+
<div class="pmpro_discount_levels_pricing level_<?php echo $level->id?>" <?php if(!$level->checked) { ?>style="display: none;"<?php } ?>>
|
409 |
+
<table class="form-table">
|
410 |
+
<tbody>
|
411 |
+
<tr>
|
412 |
+
<th scope="row" valign="top"><label for="initial_payment">Initial Payment:</label></th>
|
413 |
+
<td><?php echo $pmpro_currency_symbol?><input name="initial_payment[]" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($level->initial_payment))?>" /> <small>The initial amount collected at registration.</small></td>
|
414 |
+
</tr>
|
415 |
+
|
416 |
+
<tr>
|
417 |
+
<th scope="row" valign="top"><label>Recurring Subscription:</label></th>
|
418 |
+
<td><input class="recurring_checkbox" 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();" /> <small>Check if this level has a recurring subscription payment.</small></td>
|
419 |
+
</tr>
|
420 |
+
|
421 |
+
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
422 |
+
<th scope="row" valign="top"><label for="billing_amount">Billing Amount:</label></th>
|
423 |
+
<td>
|
424 |
+
<?php echo $pmpro_currency_symbol?><input name="billing_amount[]" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($level->billing_amount))?>" /> <small>per</small>
|
425 |
+
<input name="cycle_number[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->cycle_number))?>" />
|
426 |
+
<select name="cycle_period[]" onchange="updateCyclePeriod();">
|
427 |
+
<?php
|
428 |
+
$cycles = array( 'Day(s)' => 'Day', 'Week(s)' => 'Week', 'Month(s)' => 'Month', 'Year(s)' => 'Year' );
|
429 |
+
foreach ( $cycles as $name => $value ) {
|
430 |
+
echo "<option value='$value'";
|
431 |
+
if ( $level->cycle_period == $value ) echo " selected='selected'";
|
432 |
+
echo ">$name</option>";
|
433 |
+
}
|
434 |
+
?>
|
435 |
+
</select>
|
436 |
+
<br /><small>The amount to be billed one cycle after the initial payment.</small>
|
437 |
+
</td>
|
438 |
+
</tr>
|
439 |
+
|
440 |
+
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
441 |
+
<th scope="row" valign="top"><label for="billing_limit">Billing Cycle Limit:</label></th>
|
442 |
+
<td>
|
443 |
+
<input name="billing_limit[]" type="text" size="20" value="<?php echo $level->billing_limit?>" />
|
444 |
+
<br /><small>The <strong>total</strong> number of billing cycles for this level, including the trial period (if applicable). Set to zero if membership is indefinite.</small>
|
445 |
+
</td>
|
446 |
+
</tr>
|
447 |
+
|
448 |
+
<tr class="recurring_info" <?php if (!pmpro_isLevelRecurring($level)) echo "style='display:none;'";?>>
|
449 |
+
<th scope="row" valign="top"><label>Custom Trial:</label></th>
|
450 |
+
<td><input 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();" /> Check to add a custom trial period.</td>
|
451 |
+
</tr>
|
452 |
+
|
453 |
+
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>>
|
454 |
+
<th scope="row" valign="top"><label for="trial_amount">Trial Billing Amount:</label></th>
|
455 |
+
<td>
|
456 |
+
<?php echo $pmpro_currency_symbol?><input name="trial_amount[]" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($level->trial_amount))?>" />
|
457 |
+
<small>for the first</small>
|
458 |
+
<input name="trial_limit[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->trial_limit))?>" />
|
459 |
+
<small>subscription payments.</small>
|
460 |
+
</td>
|
461 |
+
</tr>
|
462 |
+
|
463 |
+
<tr>
|
464 |
+
<th scope="row" valign="top"><label>Membership Expiration:</label></th>
|
465 |
+
<td><input id="expiration" 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();}" /> <small>Check this to set an expiration date for new sign ups.</small></td>
|
466 |
+
</tr>
|
467 |
+
|
468 |
+
<tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>>
|
469 |
+
<th scope="row" valign="top"><label for="billing_amount">Expire In:</label></th>
|
470 |
+
<td>
|
471 |
+
<input id="expiration_number" name="expiration_number[]" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->expiration_number))?>" />
|
472 |
+
<select id="expiration_period" name="expiration_period[]">
|
473 |
+
<?php
|
474 |
+
$cycles = array( 'Day(s)' => 'Day', 'Week(s)' => 'Week', 'Month(s)' => 'Month', 'Year(s)' => 'Year' );
|
475 |
+
foreach ( $cycles as $name => $value ) {
|
476 |
+
echo "<option value='$value'";
|
477 |
+
if ( $level->expiration_period == $value ) echo " selected='selected'";
|
478 |
+
echo ">$name</option>";
|
479 |
+
}
|
480 |
+
?>
|
481 |
+
</select>
|
482 |
+
<br /><small>How long before the expiration expires. Not that any future payments will be canceled when the membership expires.</small>
|
483 |
+
</td>
|
484 |
+
</tr>
|
485 |
+
</tbody>
|
486 |
+
</table>
|
487 |
+
|
488 |
+
</div>
|
489 |
+
</div>
|
490 |
+
<script>
|
491 |
+
|
492 |
+
</script>
|
493 |
+
<?php
|
494 |
+
}
|
495 |
+
?>
|
496 |
+
</div>
|
497 |
+
|
498 |
+
<p class="submit topborder">
|
499 |
+
<input name="save" type="submit" class="button-primary" value="Save Code" />
|
500 |
+
<input name="cancel" type="button" value="Cancel" onclick="location.href='<?php echo home_url('/wp-admin/admin.php?page=pmpro-discountcodes')?>';" />
|
501 |
+
</p>
|
502 |
+
</form>
|
503 |
+
</div>
|
504 |
+
|
505 |
+
<?php } else { ?>
|
506 |
+
|
507 |
+
<h2>
|
508 |
+
Memberships Discount Codes
|
509 |
+
<a href="admin.php?page=pmpro-discountcodes&edit=-1" class="button add-new-h2">Add New Discount Code</a>
|
510 |
+
</h2>
|
511 |
+
|
512 |
+
<?php if($pmpro_msg){?>
|
513 |
+
<div id="message" class="<?php if($pmpro_msgt == "success") echo "updated fade"; else echo "error"; ?>"><p><?php echo $pmpro_msg?></p></div>
|
514 |
+
<?php } ?>
|
515 |
+
|
516 |
+
<form id="posts-filter" method="get" action="">
|
517 |
+
<p class="search-box">
|
518 |
+
<label class="screen-reader-text" for="post-search-input">Search Discount Codes:</label>
|
519 |
+
<input type="hidden" name="page" value="pmpro-discountcodes" />
|
520 |
+
<input id="post-search-input" type="text" value="<?php echo $s?>" name="s" size="30" />
|
521 |
+
<input class="button" type="submit" value="Search" id="search-submit "/>
|
522 |
+
</p>
|
523 |
+
</form>
|
524 |
+
|
525 |
+
<br class="clear" />
|
526 |
+
|
527 |
+
<table class="widefat">
|
528 |
+
<thead>
|
529 |
+
<tr>
|
530 |
+
<th>ID</th>
|
531 |
+
<th>Code</th>
|
532 |
+
<th>Starts</th>
|
533 |
+
<th>Expires</th>
|
534 |
+
<th>Uses</th>
|
535 |
+
<th>Levels</th>
|
536 |
+
<th></th>
|
537 |
+
<th></th>
|
538 |
+
</tr>
|
539 |
+
</thead>
|
540 |
+
<tbody>
|
541 |
+
<?php
|
542 |
+
$sqlQuery = "SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes ";
|
543 |
+
if($s)
|
544 |
+
$sqlQuery .= "WHERE code LIKE '%$s%' ";
|
545 |
+
$sqlQuery .= "ORDER BY id ASC";
|
546 |
+
|
547 |
+
$codes = $wpdb->get_results($sqlQuery, OBJECT);
|
548 |
+
|
549 |
+
if(!$codes)
|
550 |
+
{
|
551 |
+
?>
|
552 |
+
<tr><td colspan="7" class="pmpro_pad20">
|
553 |
+
<p>Discount codes allow you to offer your memberships at discounted prices to select customers. <a href="admin.php?page=pmpro-discountcodes&edit=-1">Create your first discount code now</a>.</p>
|
554 |
+
</td></tr>
|
555 |
+
<?php
|
556 |
+
}
|
557 |
+
else
|
558 |
+
{
|
559 |
+
foreach($codes as $code)
|
560 |
+
{
|
561 |
+
?>
|
562 |
+
<tr>
|
563 |
+
<td><?php echo $code->id?></td>
|
564 |
+
<td>
|
565 |
+
<a href="?page=pmpro-discountcodes&edit=<?php echo $code->id?>"><?php echo $code->code?></a>
|
566 |
+
</td>
|
567 |
+
<td>
|
568 |
+
<?php echo date("m/d/Y", $code->starts)?>
|
569 |
+
</td>
|
570 |
+
<td>
|
571 |
+
<?php echo date("m/d/Y", $code->expires)?>
|
572 |
+
</td>
|
573 |
+
<td>
|
574 |
+
<?php
|
575 |
+
$uses = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $code->id . "'");
|
576 |
+
if($code->uses > 0)
|
577 |
+
echo "<strong>" . (int)$uses . "</strong>/" . $code->uses;
|
578 |
+
else
|
579 |
+
echo "<strong>" . (int)$uses . "</strong>/unlimited";
|
580 |
+
?>
|
581 |
+
</td>
|
582 |
+
<td>
|
583 |
+
<?php
|
584 |
+
$sqlQuery = "SELECT l.id, l.name FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_discount_codes_levels cl ON l.id = cl.level_id WHERE cl.code_id = '" . $code->id . "'";
|
585 |
+
$levels = $wpdb->get_results($sqlQuery);
|
586 |
+
|
587 |
+
$level_names = array();
|
588 |
+
foreach($levels as $level)
|
589 |
+
$level_names[] = "<a target=\"_blank\" href=\"" . pmpro_url("checkout", "?level=" . $level->id . "&discountcode=" . $code->code) . "\">" . $level->name . "</a>";
|
590 |
+
if($level_names)
|
591 |
+
echo implode(", ", $level_names);
|
592 |
+
else
|
593 |
+
echo "None";
|
594 |
+
?>
|
595 |
+
</td>
|
596 |
+
<td>
|
597 |
+
<a href="?page=pmpro-discountcodes&edit=<?php echo $code->id?>">edit</a>
|
598 |
+
</td>
|
599 |
+
<td>
|
600 |
+
<a href="javascript:askfirst('Are you sure you want to delete the <?php echo $code->code?> discount code? The subscriptions for existing users will not change, but new users will not be able to use this code anymore.', '?page=pmpro-discountcodes&delete=<?php echo $code->id?>'); void(0);">delete</a>
|
601 |
+
</td>
|
602 |
+
</tr>
|
603 |
+
<?php
|
604 |
+
}
|
605 |
+
}
|
606 |
+
?>
|
607 |
+
</tbody>
|
608 |
+
</table>
|
609 |
+
|
610 |
+
<?php } ?>
|
611 |
+
|
612 |
+
</div>
|
613 |
+
<?php
|
614 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/emailsettings.php
CHANGED
@@ -1,181 +1,72 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
$
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
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', 'pmpro');?>:</label>
|
79 |
-
</th>
|
80 |
-
<td>
|
81 |
-
<input type="text" name="from_email" size="60" value="<?php echo $from_email?>" />
|
82 |
-
</td>
|
83 |
-
</tr>
|
84 |
-
<tr>
|
85 |
-
<th scope="row" valign="top">
|
86 |
-
<label for="from_name"><?php _e('From Name', 'pmpro');?>:</label>
|
87 |
-
</th>
|
88 |
-
<td>
|
89 |
-
<input type="text" name="from_name" size="60" value="<?php echo $from_name?>" />
|
90 |
-
</td>
|
91 |
-
</tr>
|
92 |
-
<tr>
|
93 |
-
<th scope="row" valign="top">
|
94 |
-
<label for="only_filter_pmpro_emails"><?php _e('Only Filter PMPro Emails?', 'pmpro');?>:</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 |
-
<?php _e('If unchecked, all emails from "WordPress <' . $default_from_email . '>" will be filtered to use the above settings.', 'pmpro');?>
|
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', 'pmpro');?>:</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>.', 'pmpro'); ?></p>
|
113 |
-
*/ ?>
|
114 |
-
|
115 |
-
<h3><?php _e('Send the site admin emails', 'pmpro');?>:</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', 'pmpro');?>:</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 |
-
<?php _e('when a member checks out.', 'pmpro');?>
|
126 |
-
</td>
|
127 |
-
</tr>
|
128 |
-
<tr>
|
129 |
-
<th scope="row" valign="top">
|
130 |
-
<label for="email_admin_changes"><?php _e('Admin Changes', 'pmpro');?>:</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 |
-
<?php _e('when an admin changes a user\'s membership level through the dashboard.', 'pmpro');?>
|
135 |
-
</td>
|
136 |
-
</tr>
|
137 |
-
<tr>
|
138 |
-
<th scope="row" valign="top">
|
139 |
-
<label for="email_admin_cancels"><?php _e('Cancellation', 'pmpro');?>:</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 |
-
<?php _e('when a user cancels his or her account.', 'pmpro');?>
|
144 |
-
</td>
|
145 |
-
</tr>
|
146 |
-
<tr>
|
147 |
-
<th scope="row" valign="top">
|
148 |
-
<label for="email_admin_billing"><?php _e('Bill Updates', 'pmpro');?>:</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 |
-
<?php _e('when a user updates his or her billing information.', 'pmpro');?>
|
153 |
-
</td>
|
154 |
-
</tr>
|
155 |
-
</tbody>
|
156 |
-
</table>
|
157 |
-
|
158 |
-
<h3><?php _e('Send members emails', 'pmpro');?>:</h3>
|
159 |
-
|
160 |
-
<table class="form-table">
|
161 |
-
<tbody>
|
162 |
-
<tr>
|
163 |
-
<th scope="row" valign="top">
|
164 |
-
<label for="email_admin_checkout"><?php _e('New Users', 'pmpro');?>:</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 |
-
<?php _e('Default WP notification email. (Recommended: Leave unchecked. Members will still get an email confirmation from PMPro after checkout.)', 'pmpro');?>
|
169 |
-
</td>
|
170 |
-
</tr>
|
171 |
-
</tbody>
|
172 |
-
</table>
|
173 |
-
|
174 |
-
<p class="submit">
|
175 |
-
<input name="savesettings" type="submit" class="button-primary" value="Save Settings" />
|
176 |
-
</p>
|
177 |
-
</form>
|
178 |
-
|
179 |
-
<?php
|
180 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
181 |
-
?>
|
1 |
+
<?php
|
2 |
+
global $wpdb, $msg, $msgt;
|
3 |
+
|
4 |
+
//get/set settings
|
5 |
+
global $pmpro_pages;
|
6 |
+
if($_REQUEST['savesettings'])
|
7 |
+
{
|
8 |
+
//email options
|
9 |
+
pmpro_setOption("from_email");
|
10 |
+
pmpro_setOption("from_name");
|
11 |
+
|
12 |
+
//assume success
|
13 |
+
$msg = true;
|
14 |
+
$msgt = "Your email settings have been updated.";
|
15 |
+
}
|
16 |
+
|
17 |
+
$from_email = pmpro_getOption("from_email");
|
18 |
+
$from_name = pmpro_getOption("from_name");
|
19 |
+
|
20 |
+
if(!$from_email)
|
21 |
+
{
|
22 |
+
$parsed = parse_url(home_url());
|
23 |
+
$hostname = $parsed[host];
|
24 |
+
$hostparts = split("\.", $hostname);
|
25 |
+
$email_domain = $hostparts[count($hostparts) - 2] . "." . $hostparts[count($hostparts) - 1];
|
26 |
+
$from_email = "wordpress@" . $email_domain;
|
27 |
+
pmpro_setOption("from_email", $from_email);
|
28 |
+
}
|
29 |
+
|
30 |
+
if(!$from_name)
|
31 |
+
{
|
32 |
+
$from_name = "WordPress";
|
33 |
+
pmpro_setOption("from_name", $from_name);
|
34 |
+
}
|
35 |
+
|
36 |
+
require_once(dirname(__FILE__) . "/admin_header.php");
|
37 |
+
?>
|
38 |
+
|
39 |
+
<form action="" method="post" enctype="multipart/form-data">
|
40 |
+
<h2>Email Settings</h2>
|
41 |
+
<p>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.</p>
|
42 |
+
|
43 |
+
<p>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/support/member-communications/">Click here to learn more about Paid Memberships Pro emails</a>.</p>
|
44 |
+
|
45 |
+
<table class="form-table">
|
46 |
+
<tbody>
|
47 |
+
<tr>
|
48 |
+
<th scope="row" valign="top">
|
49 |
+
<label for="from_email">From Email:</label>
|
50 |
+
</th>
|
51 |
+
<td>
|
52 |
+
<input type="text" name="from_email" size="60" value="<?php echo $from_email?>" />
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
<tr>
|
56 |
+
<th scope="row" valign="top">
|
57 |
+
<label for="from_name">From Name:</label>
|
58 |
+
</th>
|
59 |
+
<td>
|
60 |
+
<input type="text" name="from_name" size="60" value="<?php echo $from_name?>" />
|
61 |
+
</td>
|
62 |
+
</tr>
|
63 |
+
</tbody>
|
64 |
+
</table>
|
65 |
+
<p class="submit">
|
66 |
+
<input name="savesettings" type="submit" class="button-primary" value="Save Settings" />
|
67 |
+
</p>
|
68 |
+
</form>
|
69 |
+
|
70 |
+
<?php
|
71 |
+
require_once(dirname(__FILE__) . "/admin_footer.php");
|
72 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/functions.php
DELETED
@@ -1,222 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/****************************************************************
|
3 |
-
|
4 |
-
IMPORTANT. PLEASE READ.
|
5 |
-
|
6 |
-
DO NOT EDIT THIS FILE or any other file in the /wp-content/plugins/paid-memberships-pro/ directory.
|
7 |
-
Doing so could break the PMPro plugin and/or keep you from upgrading this plugin in the future.
|
8 |
-
We regularly release updates to the plugin, including important security fixes and new features.
|
9 |
-
You want to be able to upgrade.
|
10 |
-
|
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 |
-
http://www.paidmembershipspro.com/2012/08/create-a-plugin-for-pmpro-customizations/
|
15 |
-
|
16 |
-
Further documentation for customizing Paid Memberships Pro can be found here:
|
17 |
-
http://www.paidmembershipspro.com/documentation/
|
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 |
-
{
|
26 |
-
$gateway = pmpro_getOption("gateway");
|
27 |
-
if($gateway == "stripe")
|
28 |
-
{
|
29 |
-
global $wpdb;
|
30 |
-
|
31 |
-
//check ALL the levels
|
32 |
-
if(empty($level))
|
33 |
-
{
|
34 |
-
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ORDER BY id ASC";
|
35 |
-
$levels = $wpdb->get_results($sqlQuery, OBJECT);
|
36 |
-
if(!empty($levels))
|
37 |
-
{
|
38 |
-
foreach($levels as $level)
|
39 |
-
{
|
40 |
-
/*
|
41 |
-
Stripe currently does not support:
|
42 |
-
* Trial Amounts > 0.
|
43 |
-
* Daily billing periods.
|
44 |
-
* Billing Limits.
|
45 |
-
*/
|
46 |
-
if($level->trial_amount > 0 ||
|
47 |
-
($level->cycle_number > 0 && $level->cycle_period == "Day") ||
|
48 |
-
$level->billing_limit > 0)
|
49 |
-
{
|
50 |
-
return false;
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
54 |
-
}
|
55 |
-
else
|
56 |
-
{
|
57 |
-
//need to look it up?
|
58 |
-
if(is_numeric($level))
|
59 |
-
$level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($level) . "' LIMIT 1");
|
60 |
-
|
61 |
-
//check this level
|
62 |
-
if($level->trial_amount > 0 ||
|
63 |
-
($level->cycle_number > 0 && $level->cycle_period == "Day") ||
|
64 |
-
$level->billing_limit > 0)
|
65 |
-
{
|
66 |
-
return false;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
return true;
|
72 |
-
}
|
73 |
-
|
74 |
-
/*
|
75 |
-
Checks if PMPro settings are complete or if there are any errors.
|
76 |
-
*/
|
77 |
-
function pmpro_checkLevelForPayflowCompatibility($level = NULL)
|
78 |
-
{
|
79 |
-
$gateway = pmpro_getOption("gateway");
|
80 |
-
if($gateway == "payflowpro")
|
81 |
-
{
|
82 |
-
global $wpdb;
|
83 |
-
|
84 |
-
//check ALL the levels
|
85 |
-
if(empty($level))
|
86 |
-
{
|
87 |
-
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ORDER BY id ASC";
|
88 |
-
$levels = $wpdb->get_results($sqlQuery, OBJECT);
|
89 |
-
if(!empty($levels))
|
90 |
-
{
|
91 |
-
foreach($levels as $level)
|
92 |
-
{
|
93 |
-
/*
|
94 |
-
Payflow currently does not support:
|
95 |
-
* Trial Amounts > 0.
|
96 |
-
* Daily billing periods.
|
97 |
-
*/
|
98 |
-
|
99 |
-
if($level->trial_amount > 0 ||
|
100 |
-
$level->cycle_number > 1 ||
|
101 |
-
($level->cycle_number == 1 && $level->cycle_period == "Day"))
|
102 |
-
{
|
103 |
-
return false;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
}
|
107 |
-
}
|
108 |
-
else
|
109 |
-
{
|
110 |
-
//need to look it up?
|
111 |
-
if(is_numeric($level))
|
112 |
-
$level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($level) . "' LIMIT 1");
|
113 |
-
|
114 |
-
//check this level
|
115 |
-
if($level->trial_amount > 0 ||
|
116 |
-
$level->cycle_number > 1 ||
|
117 |
-
($level->cycle_number == 1 && $level->cycle_period == "Day"))
|
118 |
-
{
|
119 |
-
return false;
|
120 |
-
}
|
121 |
-
}
|
122 |
-
}
|
123 |
-
|
124 |
-
return true;
|
125 |
-
}
|
126 |
-
|
127 |
-
/*
|
128 |
-
Checks if PMPro settings are complete or if there are any errors.
|
129 |
-
*/
|
130 |
-
function pmpro_checkLevelForBraintreeCompatibility($level = NULL)
|
131 |
-
{
|
132 |
-
$gateway = pmpro_getOption("gateway");
|
133 |
-
if($gateway == "braintree")
|
134 |
-
{
|
135 |
-
global $wpdb;
|
136 |
-
|
137 |
-
//check ALL the levels
|
138 |
-
if(empty($level))
|
139 |
-
{
|
140 |
-
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ORDER BY id ASC";
|
141 |
-
$levels = $wpdb->get_results($sqlQuery, OBJECT);
|
142 |
-
if(!empty($levels))
|
143 |
-
{
|
144 |
-
foreach($levels as $level)
|
145 |
-
{
|
146 |
-
/*
|
147 |
-
Braintree currently does not support:
|
148 |
-
* Trial Amounts > 0.
|
149 |
-
* Daily or Weekly billing periods.
|
150 |
-
*/
|
151 |
-
if($level->trial_amount > 0 ||
|
152 |
-
($level->cycle_number > 0 && ($level->cycle_period == "Day" || $level->cycle_period == "Week")))
|
153 |
-
{
|
154 |
-
return false;
|
155 |
-
}
|
156 |
-
}
|
157 |
-
}
|
158 |
-
}
|
159 |
-
else
|
160 |
-
{
|
161 |
-
//need to look it up?
|
162 |
-
if(is_numeric($level))
|
163 |
-
$level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($level) . "' LIMIT 1");
|
164 |
-
|
165 |
-
//check this level
|
166 |
-
if($level->trial_amount > 0 ||
|
167 |
-
($level->cycle_number > 0 && ($level->cycle_period == "Day" || $level->cycle_period == "Week")))
|
168 |
-
{
|
169 |
-
return false;
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
return true;
|
175 |
-
}
|
176 |
-
|
177 |
-
/*
|
178 |
-
Checks if PMPro settings are complete or if there are any errors.
|
179 |
-
*/
|
180 |
-
function pmpro_checkLevelForTwoCheckoutCompatibility($level = NULL)
|
181 |
-
{
|
182 |
-
$gateway = pmpro_getOption("gateway");
|
183 |
-
if($gateway == "twocheckout")
|
184 |
-
{
|
185 |
-
global $wpdb;
|
186 |
-
|
187 |
-
//check ALL the levels
|
188 |
-
if(empty($level))
|
189 |
-
{
|
190 |
-
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ORDER BY id ASC";
|
191 |
-
$levels = $wpdb->get_results($sqlQuery, OBJECT);
|
192 |
-
if(!empty($levels))
|
193 |
-
{
|
194 |
-
foreach($levels as $level)
|
195 |
-
{
|
196 |
-
/*
|
197 |
-
2Checkout currently does not support:
|
198 |
-
* Trial amounts less than or greater than the absolute value of amonthly recurring amount.
|
199 |
-
*/
|
200 |
-
if(pmpro_isLevelTrial($level))
|
201 |
-
{
|
202 |
-
return false;
|
203 |
-
}
|
204 |
-
}
|
205 |
-
}
|
206 |
-
}
|
207 |
-
else
|
208 |
-
{
|
209 |
-
//need to look it up?
|
210 |
-
if(is_numeric($level))
|
211 |
-
$level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . esc_sql($level) . "' LIMIT 1");
|
212 |
-
|
213 |
-
//check this level
|
214 |
-
if(pmpro_isLevelTrial($level))
|
215 |
-
{
|
216 |
-
return false;
|
217 |
-
}
|
218 |
-
}
|
219 |
-
}
|
220 |
-
|
221 |
-
return true;
|
222 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/membershiplevels.php
CHANGED
@@ -1,588 +1,460 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
$
|
18 |
-
|
19 |
-
$
|
20 |
-
|
21 |
-
$
|
22 |
-
|
23 |
-
$
|
24 |
-
|
25 |
-
|
26 |
-
$
|
27 |
-
|
28 |
-
$
|
29 |
-
|
30 |
-
|
31 |
-
$
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
$
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
$
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
$
|
262 |
-
|
263 |
-
|
264 |
-
|
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 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
</
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
</table>
|
462 |
-
|
463 |
-
<?php do_action("pmpro_membership_level_after_other_settings"); ?>
|
464 |
-
|
465 |
-
<h3 class="topborder"><?php _e('Content Settings', 'pmpro');?></h3>
|
466 |
-
<table class="form-table">
|
467 |
-
<tbody>
|
468 |
-
<tr>
|
469 |
-
<th scope="row" valign="top"><label><?php _e('Categories', 'pmpro');?>:</label></th>
|
470 |
-
<td>
|
471 |
-
<?php
|
472 |
-
$categories = get_categories( array( 'hide_empty' => 0 ) );
|
473 |
-
echo "<ul>";
|
474 |
-
foreach ( $categories as $cat )
|
475 |
-
{
|
476 |
-
$checked = in_array( $cat->term_id, $level->categories ) ? "checked='checked'" : '';
|
477 |
-
echo "<li><input name='membershipcategory_{$cat->term_id}' type='checkbox' value='yes' $checked /> {$cat->name}</li>\n";
|
478 |
-
}
|
479 |
-
echo "</ul>";
|
480 |
-
?>
|
481 |
-
</td>
|
482 |
-
</tr>
|
483 |
-
</tbody>
|
484 |
-
</table>
|
485 |
-
<p class="submit topborder">
|
486 |
-
<input name="save" type="submit" class="button-primary" value="Save Level" />
|
487 |
-
<input name="cancel" type="button" value="Cancel" onclick="location.href='<?php echo get_admin_url(NULL, '/admin.php?page=pmpro-membershiplevels')?>';" />
|
488 |
-
</p>
|
489 |
-
</form>
|
490 |
-
</div>
|
491 |
-
|
492 |
-
<?php
|
493 |
-
}
|
494 |
-
else
|
495 |
-
{
|
496 |
-
?>
|
497 |
-
|
498 |
-
<h2><?php _e('Membership Levels', 'pmpro');?> <a href="admin.php?page=pmpro-membershiplevels&edit=-1" class="add-new-h2"><?php _e('Add New Level', 'pmpro');?></a></h2>
|
499 |
-
<form id="posts-filter" method="get" action="">
|
500 |
-
<p class="search-box">
|
501 |
-
<label class="screen-reader-text" for="post-search-input"><?php _e('Search Levels', 'pmpro');?>:</label>
|
502 |
-
<input type="hidden" name="page" value="pmpro-membershiplevels" />
|
503 |
-
<input id="post-search-input" type="text" value="<?php echo $s?>" name="s" size="30" />
|
504 |
-
<input class="button" type="submit" value="<?php _e('Search Levels', 'pmpro');?>" id="search-submit" />
|
505 |
-
</p>
|
506 |
-
</form>
|
507 |
-
|
508 |
-
<br class="clear" />
|
509 |
-
|
510 |
-
<table class="widefat">
|
511 |
-
<thead>
|
512 |
-
<tr>
|
513 |
-
<th><?php _e('ID', 'pmpro');?></th>
|
514 |
-
<th><?php _e('Name', 'pmpro');?></th>
|
515 |
-
<th><?php _e('Initial Payment', 'pmpro');?></th>
|
516 |
-
<th><?php _e('Billing Cycle', 'pmpro');?></th>
|
517 |
-
<th><?php _e('Trial Cycle', 'pmpro');?></th>
|
518 |
-
<th><?php _e('Expiration', 'pmpro');?></th>
|
519 |
-
<th><?php _e('Allow Signups', 'pmpro');?></th>
|
520 |
-
<th></th>
|
521 |
-
<th></th>
|
522 |
-
<th></th>
|
523 |
-
</tr>
|
524 |
-
</thead>
|
525 |
-
<tbody>
|
526 |
-
<?php
|
527 |
-
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ";
|
528 |
-
if($s)
|
529 |
-
$sqlQuery .= "WHERE name LIKE '%$s%' ";
|
530 |
-
$sqlQuery .= "ORDER BY id ASC";
|
531 |
-
|
532 |
-
$levels = $wpdb->get_results($sqlQuery, OBJECT);
|
533 |
-
|
534 |
-
foreach($levels as $level)
|
535 |
-
{
|
536 |
-
?>
|
537 |
-
<tr class="<?php if(!$level->allow_signups) { ?>pmpro_gray<?php } ?> <?php if(!pmpro_checkLevelForStripeCompatibility($level) || !pmpro_checkLevelForBraintreeCompatibility($level) || !pmpro_checkLevelForPayflowCompatibility($level) || !pmpro_checkLevelForTwoCheckoutCompatibility($level)) { ?>pmpro_error<?php } ?>">
|
538 |
-
<td><?php echo $level->id?></td>
|
539 |
-
<td><?php echo $level->name?></td>
|
540 |
-
<td>
|
541 |
-
<?php if(pmpro_isLevelFree($level)) { ?>
|
542 |
-
<?php _e('FREE', 'pmpro');?>
|
543 |
-
<?php } else { ?>
|
544 |
-
<?php echo $pmpro_currency_symbol?><?php echo $level->initial_payment?>
|
545 |
-
<?php } ?>
|
546 |
-
</td>
|
547 |
-
<td>
|
548 |
-
<?php if(!pmpro_isLevelRecurring($level)) { ?>
|
549 |
-
--
|
550 |
-
<?php } else { ?>
|
551 |
-
<?php echo $pmpro_currency_symbol?><?php echo $level->billing_amount?> <?php _e('every', 'pmpro');?> <?php echo $level->cycle_number.' '.pmpro_translate_billing_period($level->cycle_period,$level->cycle_number)?>
|
552 |
-
|
553 |
-
<?php if($level->billing_limit) { ?>(<?php _e('for', 'pmpro');?> <?php echo $level->billing_limit?> <?php echo sornot($level->cycle_period,$level->billing_limit)?>)<?php } ?>
|
554 |
-
|
555 |
-
<?php } ?>
|
556 |
-
</td>
|
557 |
-
<td>
|
558 |
-
<?php if(!pmpro_isLevelTrial($level)) { ?>
|
559 |
-
--
|
560 |
-
<?php } else { ?>
|
561 |
-
<?php echo $pmpro_currency_symbol?><?php echo $level->trial_amount?> <?php _e('for', 'pmpro');?> <?php echo $level->trial_limit?> <?php echo sornot("payment",$level->trial_limit)?>
|
562 |
-
<?php } ?>
|
563 |
-
</td>
|
564 |
-
<td>
|
565 |
-
<?php if(!pmpro_isLevelExpiring($level)) { ?>
|
566 |
-
--
|
567 |
-
<?php } else { ?>
|
568 |
-
<?php _e('After', 'pmpro');?> <?php echo $level->expiration_number?> <?php echo sornot($level->expiration_period,$level->expiration_number)?>
|
569 |
-
<?php } ?>
|
570 |
-
</td>
|
571 |
-
<td><?php if($level->allow_signups) { ?><?php _e('Yes', 'pmpro');?><?php } else { ?><?php _e('No', 'pmpro');?><?php } ?></td>
|
572 |
-
<td align="center"><a href="admin.php?page=pmpro-membershiplevels&edit=<?php echo $level->id?>" class="edit"><?php _e('edit', 'pmpro');?></a></td>
|
573 |
-
<td align="center"><a href="admin.php?page=pmpro-membershiplevels&copy=<?php echo $level->id?>&edit=-1" class="edit"><?php _e('copy', 'pmpro');?></a></td>
|
574 |
-
<td align="center"><a href="javascript: askfirst('<?php printf(__("Are you sure you want to delete membership level %s? All subscriptions will be cancelled.", "pmpro"), $level->name);?>','admin.php?page=pmpro-membershiplevels&action=delete_membership_level&deleteid=<?php echo $level->id?>'); void(0);" class="delete"><?php _e('delete', 'pmpro');?></a></td>
|
575 |
-
</tr>
|
576 |
-
<?php
|
577 |
-
}
|
578 |
-
?>
|
579 |
-
</tbody>
|
580 |
-
</table>
|
581 |
-
<?php
|
582 |
-
}
|
583 |
-
?>
|
584 |
-
|
585 |
-
<?php
|
586 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
587 |
-
?>
|
588 |
-
|
1 |
+
<?php
|
2 |
+
global $wpdb, $msg, $msgt;
|
3 |
+
|
4 |
+
//some vars
|
5 |
+
$edit = $_REQUEST['edit'];
|
6 |
+
$copy = $_REQUEST['copy'];
|
7 |
+
$s = $_REQUEST['s'];
|
8 |
+
|
9 |
+
$action = $_REQUEST['action'];
|
10 |
+
$saveandnext = $_REQUEST['saveandnext'];
|
11 |
+
|
12 |
+
$saveid = $_REQUEST['saveid'];
|
13 |
+
$deleteid = $_REQUEST['deleteid'];
|
14 |
+
|
15 |
+
if($action == "save_membershiplevel")
|
16 |
+
{
|
17 |
+
$ml_name = addslashes($_REQUEST['name']);
|
18 |
+
$ml_description = addslashes($_REQUEST['description']);
|
19 |
+
$ml_initial_payment = addslashes($_REQUEST['initial_payment']);
|
20 |
+
$ml_recurring = $_REQUEST['recurring'];
|
21 |
+
$ml_billing_amount = addslashes($_REQUEST['billing_amount']);
|
22 |
+
$ml_cycle_number = addslashes($_REQUEST['cycle_number']);
|
23 |
+
$ml_cycle_period = addslashes($_REQUEST['cycle_period']);
|
24 |
+
$ml_billing_limit = addslashes($_REQUEST['billing_limit']);
|
25 |
+
$ml_custom_trial = $_REQUEST['custom_trial'];
|
26 |
+
$ml_trial_amount = addslashes($_REQUEST['trial_amount']);
|
27 |
+
$ml_trial_limit = addslashes($_REQUEST['trial_limit']);
|
28 |
+
$ml_expiration = $_REQUEST['expiration'];
|
29 |
+
$ml_expiration_number = addslashes($_REQUEST['expiration_number']);
|
30 |
+
$ml_expiration_period = addslashes($_REQUEST['expiration_period']);
|
31 |
+
$ml_categories = array();
|
32 |
+
$ml_disable_signups = $_REQUEST['disable_signups'];
|
33 |
+
if($ml_disable_signups)
|
34 |
+
$ml_allow_signups = 0;
|
35 |
+
else
|
36 |
+
$ml_allow_signups = 1;
|
37 |
+
|
38 |
+
foreach ( $_REQUEST as $key => $value )
|
39 |
+
{
|
40 |
+
if ( $value == 'yes' && preg_match( '/^membershipcategory_(\d+)$/i', $key, $matches ) )
|
41 |
+
{
|
42 |
+
$ml_categories[] = $matches[1];
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
if ( $ml_recurring != "yes" )
|
47 |
+
{
|
48 |
+
$ml_billing_amount = $ml_cycle_number = $ml_cycle_period = $ml_billing_limit = $ml_trial_amount = $ml_trial_limit = 0;
|
49 |
+
}
|
50 |
+
elseif ( $ml_custom_trial != "yes" )
|
51 |
+
{
|
52 |
+
$ml_trial_amount = $ml_trial_limit = 0;
|
53 |
+
}
|
54 |
+
|
55 |
+
if($ml_expiration != "yes")
|
56 |
+
{
|
57 |
+
$ml_expiration_number = $ml_expiration_period = 0;
|
58 |
+
}
|
59 |
+
|
60 |
+
if($saveid > 0)
|
61 |
+
{
|
62 |
+
$sqlQuery = " UPDATE {$wpdb->pmpro_membership_levels}
|
63 |
+
SET name = '$ml_name',
|
64 |
+
description = '$ml_description',
|
65 |
+
initial_payment = '$ml_initial_payment',
|
66 |
+
billing_amount = '$ml_billing_amount',
|
67 |
+
cycle_number = '$ml_cycle_number',
|
68 |
+
cycle_period = '$ml_cycle_period',
|
69 |
+
billing_limit = '$ml_billing_limit',
|
70 |
+
trial_amount = '$ml_trial_amount',
|
71 |
+
trial_limit = '$ml_trial_limit',
|
72 |
+
expiration_number = '$ml_expiration_number',
|
73 |
+
expiration_period = '$ml_expiration_period',
|
74 |
+
allow_signups = '$ml_allow_signups'
|
75 |
+
WHERE id = '$saveid' LIMIT 1;";
|
76 |
+
$wpdb->query($sqlQuery);
|
77 |
+
|
78 |
+
pmpro_updateMembershipCategories( $saveid, $ml_categories );
|
79 |
+
if(!mysql_errno())
|
80 |
+
{
|
81 |
+
$edit = false;
|
82 |
+
$msg = 2;
|
83 |
+
$msgt = "Membership level updated successfully.";
|
84 |
+
}
|
85 |
+
else
|
86 |
+
{
|
87 |
+
$msg = -2;
|
88 |
+
$msg = true;
|
89 |
+
$msgt = "Error updating membership level.";
|
90 |
+
}
|
91 |
+
}
|
92 |
+
else
|
93 |
+
{
|
94 |
+
$sqlQuery = " INSERT INTO {$wpdb->pmpro_membership_levels}
|
95 |
+
( name, description, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, trial_amount, trial_limit, expiration_number, expiration_period, allow_signups)
|
96 |
+
VALUES
|
97 |
+
( '$ml_name', '$ml_description', '$ml_initial_payment', '$ml_billing_amount', '$ml_cycle_number', '$ml_cycle_period', '$ml_billing_limit', '$ml_trial_amount', '$ml_trial_limit', '$ml_expiration_number', '$ml_expiration_period', '$ml_allow_signups' )";
|
98 |
+
$wpdb->query($sqlQuery);
|
99 |
+
if(!mysql_errno())
|
100 |
+
{
|
101 |
+
$edit = false;
|
102 |
+
$msg = 1;
|
103 |
+
$msgt = "Membership level added successfully.";
|
104 |
+
}
|
105 |
+
else
|
106 |
+
{
|
107 |
+
$msg = -1;
|
108 |
+
$msgt = "Error adding membership level.";
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
elseif($action == "delete_membership_level")
|
113 |
+
{
|
114 |
+
global $wpdb;
|
115 |
+
|
116 |
+
$ml_id = $_REQUEST['deleteid'];
|
117 |
+
|
118 |
+
if($ml_id > 0)
|
119 |
+
{
|
120 |
+
//remove any categories from the ml
|
121 |
+
$sqlQuery = "DELETE FROM $wpdb->pmpro_memberships_categories WHERE membership_id = '$ml_id'";
|
122 |
+
$r1 = $wpdb->query($sqlQuery);
|
123 |
+
|
124 |
+
//cancel any subscriptions to the ml
|
125 |
+
$r2 = true;
|
126 |
+
$user_ids = $wpdb->get_col("SELECT user_id FROM $wpdb->pmpro_memberships_users WHERE membership_id = '$ml_id'");
|
127 |
+
foreach($user_ids as $user_id)
|
128 |
+
{
|
129 |
+
//change there membership level to none. that will handle the cancel
|
130 |
+
if(pmpro_changeMembershipLevel(0, $user_id))
|
131 |
+
{
|
132 |
+
//okay
|
133 |
+
}
|
134 |
+
else
|
135 |
+
{
|
136 |
+
//couldn't delete the subscription
|
137 |
+
//we should probably notify the admin
|
138 |
+
$pmproemail = new PMProEmail();
|
139 |
+
$pmproemail->data = array("body"=>"<p>There was an error canceling the subscription for user with ID=" . $user_id . ". You will want to check your payment gateway to see if their subscription is still active.</p>");
|
140 |
+
$last_order = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_orders WHERE user_id = '" . $user_id . "' ORDER BY timestamp DESC LIMIT 1");
|
141 |
+
if($last_order)
|
142 |
+
$pmproemail->data["body"] .= "<p>Last Invoice:<br />" . nl2br(var_export($last_order, true)) . "</p>";
|
143 |
+
$pmproemail->sendEmail(get_bloginfo("admin_email"));
|
144 |
+
|
145 |
+
$r2 = false;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
//delete the ml
|
150 |
+
$sqlQuery = "DELETE FROM $wpdb->pmpro_membership_levels WHERE id = '$ml_id' LIMIT 1";
|
151 |
+
$r3 = $wpdb->query($sqlQuery);
|
152 |
+
|
153 |
+
if($r1 !== FALSE && $r2 !== FALSE && $r3 !== FALSE)
|
154 |
+
{
|
155 |
+
$msg = 3;
|
156 |
+
$msgt = "Membership level deleted successfully.";
|
157 |
+
}
|
158 |
+
else
|
159 |
+
{
|
160 |
+
$msg = -3;
|
161 |
+
$msgt = "Error deleting membership level.";
|
162 |
+
}
|
163 |
+
}
|
164 |
+
else
|
165 |
+
{
|
166 |
+
$msg = -3;
|
167 |
+
$msgt = "Error deleting membership level.";
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
require_once(dirname(__FILE__) . "/admin_header.php");
|
172 |
+
?>
|
173 |
+
|
174 |
+
<?php
|
175 |
+
if($edit)
|
176 |
+
{
|
177 |
+
?>
|
178 |
+
|
179 |
+
<h2>
|
180 |
+
<?php
|
181 |
+
if($edit > 0)
|
182 |
+
echo "Edit Membership Level";
|
183 |
+
else
|
184 |
+
echo "Add New Membership Level";
|
185 |
+
?>
|
186 |
+
</h2>
|
187 |
+
|
188 |
+
<div>
|
189 |
+
<?php
|
190 |
+
// get the level...
|
191 |
+
if($edit > 0)
|
192 |
+
{
|
193 |
+
$level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '$edit' LIMIT 1", OBJECT);
|
194 |
+
$temp_id = $level->id;
|
195 |
+
}
|
196 |
+
elseif($copy > 0)
|
197 |
+
{
|
198 |
+
$level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '$copy' LIMIT 1", OBJECT);
|
199 |
+
$temp_id = $level->id;
|
200 |
+
$level->id = NULL;
|
201 |
+
}
|
202 |
+
|
203 |
+
// didn't find a membership level, let's add a new one...
|
204 |
+
if(!$level) $edit = -1;
|
205 |
+
|
206 |
+
//defaults for new levels
|
207 |
+
if($edit == -1)
|
208 |
+
{
|
209 |
+
$level->cycle_number = 1;
|
210 |
+
$level->cycle_period = "Month";
|
211 |
+
}
|
212 |
+
|
213 |
+
// grab the categories for the given level...
|
214 |
+
$level->categories = $wpdb->get_col("SELECT c.category_id
|
215 |
+
FROM $wpdb->pmpro_memberships_categories c
|
216 |
+
WHERE c.membership_id = '" . $temp_id . "'");
|
217 |
+
if(!$level->categories)
|
218 |
+
$level->categories = array();
|
219 |
+
|
220 |
+
global $pmpro_currency_symbol;
|
221 |
+
?>
|
222 |
+
<form action="" method="post" enctype="multipart/form-data">
|
223 |
+
<input name="saveid" type="hidden" value="<?php echo $edit?>" />
|
224 |
+
<input type="hidden" name="action" value="save_membershiplevel" />
|
225 |
+
<table class="form-table">
|
226 |
+
<tbody>
|
227 |
+
<tr>
|
228 |
+
<th scope="row" valign="top"><label>ID:</label></th>
|
229 |
+
<td><?php echo $level->id?></td>
|
230 |
+
</tr>
|
231 |
+
|
232 |
+
<tr>
|
233 |
+
<th scope="row" valign="top"><label for="name">Name:</label></th>
|
234 |
+
<td><input name="name" type="text" size="50" value="<?php echo str_replace("\"", """, stripslashes($level->name))?>" /></td>
|
235 |
+
</tr>
|
236 |
+
|
237 |
+
<tr>
|
238 |
+
<th scope="row" valign="top"><label for="description">Description:</label></th>
|
239 |
+
<td>
|
240 |
+
<div id="poststuff" class="pmpro_description">
|
241 |
+
<textarea rows="10" cols="80" name="description" id="description"><?php echo str_replace("\"", """, stripslashes($level->description))?></textarea>
|
242 |
+
</div>
|
243 |
+
</td>
|
244 |
+
</tr>
|
245 |
+
</tbody>
|
246 |
+
</table>
|
247 |
+
|
248 |
+
<h3 class="topborder">Billing Details</h3>
|
249 |
+
<table class="form-table">
|
250 |
+
<tbody>
|
251 |
+
<tr>
|
252 |
+
<th scope="row" valign="top"><label for="initial_payment">Initial Payment:</label></th>
|
253 |
+
<td><?php echo $pmpro_currency_symbol?><input name="initial_payment" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($level->initial_payment))?>" /> <small>The initial amount collected at registration.</small></td>
|
254 |
+
</tr>
|
255 |
+
|
256 |
+
<tr>
|
257 |
+
<th scope="row" valign="top"><label>Recurring Subscription:</label></th>
|
258 |
+
<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();}" /> <small>Check if this level has a recurring subscription payment.</small></td>
|
259 |
+
</tr>
|
260 |
+
|
261 |
+
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
262 |
+
<th scope="row" valign="top"><label for="billing_amount">Billing Amount:</label></th>
|
263 |
+
<td>
|
264 |
+
<?php echo $pmpro_currency_symbol?><input name="billing_amount" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($level->billing_amount))?>" /> <small>per</small>
|
265 |
+
<input id="cycle_number" name="cycle_number" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->cycle_number))?>" />
|
266 |
+
<select id="cycle_period" name="cycle_period">
|
267 |
+
<?php
|
268 |
+
$cycles = array( 'Day(s)' => 'Day', 'Week(s)' => 'Week', 'Month(s)' => 'Month', 'Year(s)' => 'Year' );
|
269 |
+
foreach ( $cycles as $name => $value ) {
|
270 |
+
echo "<option value='$value'";
|
271 |
+
if ( $level->cycle_period == $value ) echo " selected='selected'";
|
272 |
+
echo ">$name</option>";
|
273 |
+
}
|
274 |
+
?>
|
275 |
+
</select>
|
276 |
+
<br /><small>The amount to be billed one cycle after the initial payment.</small>
|
277 |
+
</td>
|
278 |
+
</tr>
|
279 |
+
|
280 |
+
<tr class="recurring_info" <?php if(!pmpro_isLevelRecurring($level)) {?>style="display: none;"<?php } ?>>
|
281 |
+
<th scope="row" valign="top"><label for="billing_limit">Billing Cycle Limit:</label></th>
|
282 |
+
<td>
|
283 |
+
<input name="billing_limit" type="text" size="20" value="<?php echo $level->billing_limit?>" />
|
284 |
+
<br /><small>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.</small>
|
285 |
+
</td>
|
286 |
+
</tr>
|
287 |
+
|
288 |
+
<tr class="recurring_info" <?php if (!pmpro_isLevelRecurring($level)) echo "style='display:none;'";?>>
|
289 |
+
<th scope="row" valign="top"><label>Custom Trial:</label></th>
|
290 |
+
<td><input id="custom_trial" name="custom_trial" type="checkbox" value="yes" <?php if ( pmpro_isLevelTrial($level) ) { echo "checked='checked'"; } ?> onclick="jQuery('.trial_info').toggle();" /> Check to add a custom trial period.</td>
|
291 |
+
</tr>
|
292 |
+
|
293 |
+
<tr class="trial_info recurring_info" <?php if (!pmpro_isLevelTrial($level)) echo "style='display:none;'";?>>
|
294 |
+
<th scope="row" valign="top"><label for="trial_amount">Trial Billing Amount:</label></th>
|
295 |
+
<td>
|
296 |
+
<?php echo $pmpro_currency_symbol?><input name="trial_amount" type="text" size="20" value="<?php echo str_replace("\"", """, stripslashes($level->trial_amount))?>" />
|
297 |
+
<small>for the first</small>
|
298 |
+
<input name="trial_limit" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->trial_limit))?>" />
|
299 |
+
<small>subscription payments.</small>
|
300 |
+
</td>
|
301 |
+
</tr>
|
302 |
+
|
303 |
+
</tbody>
|
304 |
+
</table>
|
305 |
+
<h3 class="topborder">Other Settings</h3>
|
306 |
+
<table class="form-table">
|
307 |
+
<tbody>
|
308 |
+
<tr>
|
309 |
+
<th scope="row" valign="top"><label>Disable New Signups:</label></th>
|
310 |
+
<td><input name="disable_signups" type="checkbox" value="yes" <?php if($level->id && !$level->allow_signups) { ?>checked="checked"<?php } ?> /> Check to hide this level from the membership levels page and disable registration.</td>
|
311 |
+
</tr>
|
312 |
+
|
313 |
+
<tr>
|
314 |
+
<th scope="row" valign="top"><label>Membership Expiration:</label></th>
|
315 |
+
<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();}" /> Check this to set an expiration date for new sign ups.</td>
|
316 |
+
</tr>
|
317 |
+
|
318 |
+
<tr class="expiration_info" <?php if(!pmpro_isLevelExpiring($level)) {?>style="display: none;"<?php } ?>>
|
319 |
+
<th scope="row" valign="top"><label for="billing_amount">Expire In:</label></th>
|
320 |
+
<td>
|
321 |
+
<input id="expiration_number" name="expiration_number" type="text" size="10" value="<?php echo str_replace("\"", """, stripslashes($level->expiration_number))?>" />
|
322 |
+
<select id="expiration_period" name="expiration_period">
|
323 |
+
<?php
|
324 |
+
$cycles = array( 'Day(s)' => 'Day', 'Week(s)' => 'Week', 'Month(s)' => 'Month', 'Year(s)' => 'Year' );
|
325 |
+
foreach ( $cycles as $name => $value ) {
|
326 |
+
echo "<option value='$value'";
|
327 |
+
if ( $level->expiration_period == $value ) echo " selected='selected'";
|
328 |
+
echo ">$name</option>";
|
329 |
+
}
|
330 |
+
?>
|
331 |
+
</select>
|
332 |
+
<br /><small>How long before the expiration expires. Not that any future payments will be canceled when the membership expires.</small>
|
333 |
+
</td>
|
334 |
+
</tr>
|
335 |
+
</tbody>
|
336 |
+
</table>
|
337 |
+
<h3 class="topborder">Content Settings</h3>
|
338 |
+
<table class="form-table">
|
339 |
+
<tbody>
|
340 |
+
<tr>
|
341 |
+
<th scope="row" valign="top"><label>Categories:</label></th>
|
342 |
+
<td>
|
343 |
+
<?php
|
344 |
+
$categories = get_categories( array( 'hide_empty' => 0 ) );
|
345 |
+
echo "<ul>";
|
346 |
+
foreach ( $categories as $cat )
|
347 |
+
{
|
348 |
+
$checked = in_array( $cat->term_id, $level->categories ) ? "checked='checked'" : '';
|
349 |
+
echo "<li><input name='membershipcategory_{$cat->term_id}' type='checkbox' value='yes' $checked /> {$cat->name}</li>\n";
|
350 |
+
}
|
351 |
+
echo "</ul>";
|
352 |
+
?>
|
353 |
+
</td>
|
354 |
+
</tr>
|
355 |
+
</tbody>
|
356 |
+
</table>
|
357 |
+
<p class="submit topborder">
|
358 |
+
<input name="save" type="submit" class="button-primary" value="Save Level" />
|
359 |
+
<input name="cancel" type="button" value="Cancel" onclick="location.href='<?php echo home_url('/wp-admin/admin.php?page=pmpro-membershiplevels')?>';" />
|
360 |
+
</p>
|
361 |
+
</form>
|
362 |
+
</div>
|
363 |
+
|
364 |
+
<?php
|
365 |
+
}
|
366 |
+
else
|
367 |
+
{
|
368 |
+
?>
|
369 |
+
|
370 |
+
<h2>Membership Levels <a href="admin.php?page=pmpro-membershiplevels&edit=-1" class="button add-new-h2">Add New Level</a></h2>
|
371 |
+
<form id="posts-filter" method="get" action="">
|
372 |
+
<p class="search-box">
|
373 |
+
<label class="screen-reader-text" for="post-search-input">Search Levels:</label>
|
374 |
+
<input type="hidden" name="page" value="pmpro-membershiplevels" />
|
375 |
+
<input id="post-search-input" type="text" value="<?php echo $s?>" name="s" size="30" />
|
376 |
+
<input class="button" type="submit" value="Search Levels" id="search-submit "/>
|
377 |
+
</p>
|
378 |
+
</form>
|
379 |
+
|
380 |
+
<br class="clear" />
|
381 |
+
|
382 |
+
<table class="widefat">
|
383 |
+
<thead>
|
384 |
+
<tr>
|
385 |
+
<th>ID</th>
|
386 |
+
<th>Name</th>
|
387 |
+
<th>Initial Payment</th>
|
388 |
+
<th>Billing Cycle</th>
|
389 |
+
<th>Trial Cycle</th>
|
390 |
+
<th>Expiration</th>
|
391 |
+
<th>Allow Signups</th>
|
392 |
+
<th></th>
|
393 |
+
<th></th>
|
394 |
+
<th></th>
|
395 |
+
</tr>
|
396 |
+
</thead>
|
397 |
+
<tbody>
|
398 |
+
<?php
|
399 |
+
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ";
|
400 |
+
if($s)
|
401 |
+
$sqlQuery .= "WHERE name LIKE '%$s%' ";
|
402 |
+
$sqlQuery .= "ORDER BY id ASC";
|
403 |
+
|
404 |
+
$levels = $wpdb->get_results($sqlQuery, OBJECT);
|
405 |
+
|
406 |
+
foreach($levels as $level)
|
407 |
+
{
|
408 |
+
?>
|
409 |
+
<tr <?php if(!$level->allow_signups) { ?>class="pmpro_gray"<?php } ?>>
|
410 |
+
<td><?php echo $level->id?></td>
|
411 |
+
<td><?php echo $level->name?></td>
|
412 |
+
<td>
|
413 |
+
<?php if(pmpro_isLevelFree($level)) { ?>
|
414 |
+
FREE
|
415 |
+
<?php } else { ?>
|
416 |
+
<?php echo $pmpro_currency_symbol?><?php echo $level->initial_payment?>
|
417 |
+
<?php } ?>
|
418 |
+
</td>
|
419 |
+
<td>
|
420 |
+
<?php if(!pmpro_isLevelRecurring($level)) { ?>
|
421 |
+
--
|
422 |
+
<?php } else { ?>
|
423 |
+
<?php echo $pmpro_currency_symbol?><?php echo $level->billing_amount?> every <?php echo $level->cycle_number.' '.sornot($level->cycle_period,$level->cycle_number)?>
|
424 |
+
|
425 |
+
<?php if($level->billing_limit) { ?>(for <?php echo $level->billing_limit?> <?php echo sornot($level->cycle_period,$level->billing_limit)?>)<?php } ?>
|
426 |
+
|
427 |
+
<?php } ?>
|
428 |
+
</td>
|
429 |
+
<td>
|
430 |
+
<?php if(!pmpro_isLevelTrial($level)) { ?>
|
431 |
+
--
|
432 |
+
<?php } else { ?>
|
433 |
+
<?php echo $pmpro_currency_symbol?><?php echo $level->trial_amount?> for <?php echo $level->trial_limit?> <?php echo sornot("payment",$level->trial_limit)?>
|
434 |
+
<?php } ?>
|
435 |
+
</td>
|
436 |
+
<td>
|
437 |
+
<?php if(!pmpro_isLevelExpiring($level)) { ?>
|
438 |
+
--
|
439 |
+
<?php } else { ?>
|
440 |
+
After <?php echo $level->expiration_number?> <?php echo sornot($level->expiration_period,$level->expiration_number)?>
|
441 |
+
<?php } ?>
|
442 |
+
</td>
|
443 |
+
<td><?php if($level->allow_signups) { ?>Yes<?php } else { ?>No<?php } ?></td>
|
444 |
+
<td align="center"><a href="admin.php?page=pmpro-membershiplevels&edit=<?php echo $level->id?>" class="edit">edit</a></td>
|
445 |
+
<td align="center"><a href="admin.php?page=pmpro-membershiplevels©=<?php echo $level->id?>&edit=-1" class="edit">copy</a></td>
|
446 |
+
<td align="center"><a href="javascript: askfirst('Are you sure you want to delete membership level <?php echo $level->name?>? All subscriptions will be canceled.','admin.php?page=pmpro-membershiplevels&action=delete_membership_level&deleteid=<?php echo $level->id?>'); void(0);" class="delete">delete</a></td>
|
447 |
+
</tr>
|
448 |
+
<?php
|
449 |
+
}
|
450 |
+
?>
|
451 |
+
</tbody>
|
452 |
+
</table>
|
453 |
+
<?php
|
454 |
+
}
|
455 |
+
?>
|
456 |
+
|
457 |
+
<?php
|
458 |
+
require_once(dirname(__FILE__) . "/admin_footer.php");
|
459 |
+
?>
|
460 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/memberslist-csv.php
CHANGED
@@ -1,243 +1,95 @@
|
|
1 |
-
<?php
|
2 |
-
//
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
{
|
5 |
-
die(
|
6 |
}
|
7 |
|
8 |
-
global $wpdb;
|
9 |
-
|
10 |
//get users
|
11 |
-
|
12 |
-
|
13 |
-
else
|
14 |
-
$s = "";
|
15 |
-
|
16 |
-
if(isset($_REQUEST['l']))
|
17 |
-
$l = $_REQUEST['l'];
|
18 |
-
else
|
19 |
-
$l = false;
|
20 |
|
21 |
//some vars for the search
|
22 |
-
|
23 |
-
$pn =
|
24 |
-
|
25 |
-
$pn = 1;
|
26 |
-
|
27 |
-
if(!empty($_REQUEST['limit']))
|
28 |
-
$limit = $_REQUEST['limit'];
|
29 |
-
else
|
30 |
-
$limit = false;
|
31 |
-
|
32 |
if($limit)
|
33 |
{
|
34 |
$end = $pn * $limit;
|
35 |
$start = $end - $limit;
|
36 |
}
|
37 |
-
|
38 |
-
{
|
39 |
-
$end = NULL;
|
40 |
-
$start = NULL;
|
41 |
-
}
|
42 |
-
|
43 |
if($s)
|
44 |
{
|
45 |
-
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate,
|
46 |
-
|
47 |
-
if($l == "oldmembers")
|
48 |
-
$sqlQuery .= " LEFT JOIN $wpdb->pmpro_memberships_users mu2 ON u.ID = mu2.user_id AND mu2.status = 'active' ";
|
49 |
-
|
50 |
-
$sqlQuery .= " WHERE mu.membership_id > 0 AND (u.user_login LIKE '%" . esc_sql($s) . "%' OR u.user_email LIKE '%" . esc_sql($s) . "%' OR um.meta_value LIKE '%" . esc_sql($s) . "%') ";
|
51 |
|
52 |
-
if($l
|
53 |
-
$sqlQuery .= " AND mu.
|
54 |
-
elseif($l)
|
55 |
-
$sqlQuery .= " AND mu.status = 'active' AND mu.membership_id = '" . esc_sql($l) . "' ";
|
56 |
-
else
|
57 |
-
$sqlQuery .= " AND mu.status = 'active' ";
|
58 |
|
59 |
-
$sqlQuery .= "GROUP BY u.ID ";
|
60 |
-
|
61 |
-
if($l == "oldmembers")
|
62 |
-
$sqlQuery .= "ORDER BY enddate DESC ";
|
63 |
-
else
|
64 |
-
$sqlQuery .= "ORDER BY u.user_registered DESC ";
|
65 |
-
|
66 |
-
if($limit)
|
67 |
-
$sqlQuery .= "LIMIT $start, $limit";
|
68 |
}
|
69 |
else
|
70 |
{
|
71 |
-
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS u.ID, UNIX_TIMESTAMP(mu.enddate) as enddate FROM $wpdb->users u LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id ";
|
72 |
-
|
73 |
-
if($l
|
74 |
-
|
75 |
-
|
76 |
-
$sqlQuery .= " WHERE mu.membership_id > 0 ";
|
77 |
-
|
78 |
-
if($l == "oldmembers")
|
79 |
-
$sqlQuery .= " AND mu.status = 'inactive' AND mu2.status IS NULL ";
|
80 |
-
elseif($l)
|
81 |
-
$sqlQuery .= " AND mu.status = 'active' AND mu.membership_id = '" . $l . "' ";
|
82 |
-
else
|
83 |
-
$sqlQuery .= " AND mu.status = 'active' ";
|
84 |
-
|
85 |
-
$sqlQuery .= "GROUP BY u.ID ";
|
86 |
-
|
87 |
-
if($l == "oldmembers")
|
88 |
-
$sqlQuery .= "ORDER BY enddate DESC ";
|
89 |
-
else
|
90 |
-
$sqlQuery .= "ORDER BY u.user_registered DESC ";
|
91 |
-
|
92 |
if($limit)
|
93 |
$sqlQuery .= "LIMIT $start, $limit";
|
94 |
}
|
95 |
-
|
96 |
-
//filter
|
97 |
-
$sqlQuery = apply_filters("pmpro_members_list_sql", $sqlQuery);
|
98 |
|
99 |
-
|
100 |
-
$
|
101 |
-
|
102 |
-
//begin output
|
103 |
-
header("Content-type: text/csv");
|
104 |
-
if($s && $l == "oldmembers")
|
105 |
-
header("Content-Disposition: attachment; filename=members_list_expired_" . sanitize_file_name($s) . ".csv");
|
106 |
-
elseif($s && $l)
|
107 |
-
header("Content-Disposition: attachment; filename=members_list_" . intval($l) . "_level_" . sanitize_file_name($s) . ".csv");
|
108 |
-
elseif($s)
|
109 |
-
header("Content-Disposition: attachment; filename=members_list_" . sanitize_file_name($s) . ".csv");
|
110 |
-
elseif($l == "oldmembers")
|
111 |
-
header("Content-Disposition: attachment; filename=members_list_expired.csv");
|
112 |
-
else
|
113 |
-
header("Content-Disposition: attachment; filename=members_list.csv");
|
114 |
-
|
115 |
-
$heading = "id,username,firstname,lastname,email,billing firstname,billing lastname,address1,address2,city,state,zipcode,country,phone,membership,initial payment,fee,term,discount_code_id,discount_code,joined";
|
116 |
-
|
117 |
-
if($l == "oldmembers")
|
118 |
-
$heading .= ",ended";
|
119 |
-
else
|
120 |
-
$heading .= ",expires";
|
121 |
-
|
122 |
-
$heading = apply_filters("pmpro_members_list_csv_heading", $heading);
|
123 |
-
$csvoutput = $heading;
|
124 |
-
|
125 |
-
//these are the meta_keys for the fields (arrays are object, property. so e.g. $theuser->ID)
|
126 |
-
$default_columns = array(
|
127 |
-
array("theuser", "ID"),
|
128 |
-
array("theuser", "user_login"),
|
129 |
-
array("metavalues", "first_name"),
|
130 |
-
array("metavalues", "last_name"),
|
131 |
-
array("theuser", "user_email"),
|
132 |
-
array("metavalues", "pmpro_bfirstname"),
|
133 |
-
array("metavalues", "pmpro_blastname"),
|
134 |
-
array("metavalues", "pmpro_baddress1"),
|
135 |
-
array("metavalues", "pmpro_baddress2"),
|
136 |
-
array("metavalues", "pmpro_bcity"),
|
137 |
-
array("metavalues", "pmpro_bstate"),
|
138 |
-
array("metavalues", "pmpro_bzipcode"),
|
139 |
-
array("metavalues", "pmpro_bcountry"),
|
140 |
-
array("metavalues", "pmpro_bphone"),
|
141 |
-
array("theuser", "membership"),
|
142 |
-
array("theuser", "initial_payment"),
|
143 |
-
array("theuser", "billing_amount"),
|
144 |
-
array("theuser", "cycle_period"),
|
145 |
-
array("discount_code", "id"),
|
146 |
-
array("discount_code", "code")
|
147 |
-
//joindate and enddate are handled specifically below
|
148 |
-
);
|
149 |
-
|
150 |
-
//filter
|
151 |
-
$default_columns = apply_filters("pmpro_members_list_csv_default_columns", $default_columns);
|
152 |
-
|
153 |
-
//any extra columns
|
154 |
-
$extra_columns = apply_filters("pmpro_members_list_csv_extra_columns", array());
|
155 |
-
if(!empty($extra_columns))
|
156 |
-
{
|
157 |
-
foreach($extra_columns as $heading => $callback)
|
158 |
-
{
|
159 |
-
$csvoutput .= "," . $heading;
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
$csvoutput .= "\n";
|
164 |
-
|
165 |
-
//output
|
166 |
-
echo $csvoutput;
|
167 |
-
$csvoutput = "";
|
168 |
|
169 |
if($theusers)
|
170 |
{
|
171 |
-
foreach($theusers as $
|
172 |
{
|
173 |
-
//MULTI: This query will need to be updated to support multiple levels per user. Should probably just dump multiple rows for each membership.
|
174 |
//get meta
|
175 |
-
|
176 |
-
if($l == "oldmembers")
|
177 |
-
$theuser = $wpdb->get_row("SELECT u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate, u.user_login, u.user_nicename, u.user_url, u.user_registered, u.user_status, u.display_name, mu.membership_id, mu.initial_payment, mu.billing_amount, mu.cycle_period, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id WHERE u.ID = '" . $user_id . "' ORDER BY mu.id DESC LIMIT 1");
|
178 |
-
else
|
179 |
-
$theuser = $wpdb->get_row("SELECT u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate, u.user_login, u.user_nicename, u.user_url, u.user_registered, u.user_status, u.display_name, mu.membership_id, mu.initial_payment, mu.billing_amount, mu.cycle_period, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id AND mu.status = 'active' LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id WHERE u.ID = '" . $user_id . "' LIMIT 1");
|
180 |
-
|
181 |
-
$sqlQuery = "SELECT meta_key as `key`, meta_value as `value` FROM $wpdb->usermeta WHERE $wpdb->usermeta.user_id = '" . $user_id . "'";
|
182 |
$metavalues = pmpro_getMetavalues($sqlQuery);
|
183 |
-
|
184 |
-
$
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
if($count > 1)
|
196 |
-
$csvoutput .= ",";
|
197 |
-
|
198 |
-
//checking $object->property. note the double $$
|
199 |
-
if(!empty($$col[0]->$col[1]))
|
200 |
-
$csvoutput .= pmpro_enclose($$col[0]->$col[1]); //output the value
|
201 |
-
}
|
202 |
-
}
|
203 |
-
|
204 |
-
//joindate and enddate
|
205 |
-
$csvoutput .= "," . pmpro_enclose(date("Y-m-d", $theuser->joindate)) . ",";
|
206 |
-
|
207 |
-
if($theuser->membership_id)
|
208 |
-
{
|
209 |
-
if($theuser->enddate)
|
210 |
-
$csvoutput .= pmpro_enclose(apply_filters("pmpro_memberslist_expires_column", date("Y-m-d", $theuser->enddate), $theuser));
|
211 |
-
else
|
212 |
-
$csvoutput .= pmpro_enclose(apply_filters("pmpro_memberslist_expires_column", "Never", $theuser));
|
213 |
-
}
|
214 |
-
elseif($l == "oldmembers" && $theuser->enddate)
|
215 |
-
{
|
216 |
-
$csvoutput .= pmpro_enclose(date("Y-m-d", $theuser->enddate));
|
217 |
-
}
|
218 |
else
|
219 |
-
$csvoutput .= "
|
220 |
-
|
221 |
-
//any extra columns
|
222 |
-
if(!empty($extra_columns))
|
223 |
-
{
|
224 |
-
foreach($extra_columns as $heading => $callback)
|
225 |
-
{
|
226 |
-
$csvoutput .= "," . pmpro_enclose(call_user_func($callback, $theuser, $heading));
|
227 |
-
}
|
228 |
-
}
|
229 |
-
|
230 |
$csvoutput .= "\n";
|
231 |
-
|
232 |
-
//output
|
233 |
-
echo $csvoutput;
|
234 |
-
$csvoutput = "";
|
235 |
}
|
236 |
}
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
print $csvoutput;
|
239 |
|
240 |
-
function
|
241 |
{
|
242 |
return "\"" . str_replace("\"", "\\\"", $s) . "\"";
|
243 |
-
}
|
|
1 |
+
<?php
|
2 |
+
//this file is launched via AJAX to get various data from the DB for the stranger_products plugin
|
3 |
+
|
4 |
+
//wp includes
|
5 |
+
define('WP_USE_THEMES', false);
|
6 |
+
require('../../../../wp-load.php');
|
7 |
+
|
8 |
+
//only admins can get this (PATCH!)
|
9 |
+
if(!function_exists("current_user_can") || !current_user_can("manage_options"))
|
10 |
{
|
11 |
+
die("You do not have permissions to perform this action.");
|
12 |
}
|
13 |
|
|
|
|
|
14 |
//get users
|
15 |
+
$s = $_REQUEST['s'];
|
16 |
+
$l = $_REQUEST['l'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
//some vars for the search
|
19 |
+
$pn = $_REQUEST['pn'];
|
20 |
+
if(!$pn) $pn = 1;
|
21 |
+
$limit = $_REQUEST['limit'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
if($limit)
|
23 |
{
|
24 |
$end = $pn * $limit;
|
25 |
$start = $end - $limit;
|
26 |
}
|
27 |
+
|
|
|
|
|
|
|
|
|
|
|
28 |
if($s)
|
29 |
{
|
30 |
+
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate, mu.membership_id, mu.billing_amount, mu.cycle_period, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id WHERE mu.membership_id > 0 AND (u.user_login LIKE '%$s%' OR u.user_email LIKE '%$s%' OR um.meta_value LIKE '%$s%') ";
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
if($l)
|
33 |
+
$sqlQuery .= " AND mu.membership_id = '" . $l . "' ";
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
$sqlQuery .= "GROUP BY u.ID ORDER BY user_registered DESC LIMIT $start, $limit";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
else
|
38 |
{
|
39 |
+
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate, mu.membership_id, mu.billing_amount, mu.cycle_period, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership FROM $wpdb->users u LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id ";
|
40 |
+
$sqlQuery .= "WHERE mu.membership_id > 0 ";
|
41 |
+
if($l)
|
42 |
+
$sqlQuery .= " AND mu.membership_id = '" . $l . "' ";
|
43 |
+
$sqlQuery .= "ORDER BY user_registered DESC ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
if($limit)
|
45 |
$sqlQuery .= "LIMIT $start, $limit";
|
46 |
}
|
|
|
|
|
|
|
47 |
|
48 |
+
$theusers = $wpdb->get_results($sqlQuery);
|
49 |
+
$csvoutput = "id,username,firstname,lastname,email,membership,fee,term,joined,expires\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
if($theusers)
|
52 |
{
|
53 |
+
foreach($theusers as $theuser)
|
54 |
{
|
|
|
55 |
//get meta
|
56 |
+
$sqlQuery = "SELECT meta_key as `key`, meta_value as `value` FROM $wpdb->usermeta WHERE $wpdb->usermeta.user_id = '" . $theuser->ID . "'";
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
$metavalues = pmpro_getMetavalues($sqlQuery);
|
58 |
+
|
59 |
+
$csvoutput .= enclose($theuser->ID) . "," .
|
60 |
+
enclose($theuser->user_login) . "," .
|
61 |
+
enclose($metavalues->first_name) . "," .
|
62 |
+
enclose($metavalues->last_name) . "," .
|
63 |
+
enclose($theuser->user_email) . "," .
|
64 |
+
enclose($theuser->membership) . "," .
|
65 |
+
enclose($theuser->billing_amount) . "," .
|
66 |
+
enclose($theuser->cycle_period) . "," .
|
67 |
+
enclose(date("m/d/Y", $theuser->joindate)) . ",";
|
68 |
+
if($theuser->enddate)
|
69 |
+
$csvoutput .= enclose(date("m/d/Y", $theuser->enddate));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
else
|
71 |
+
$csvoutput .= enclose("Never");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
$csvoutput .= "\n";
|
73 |
+
|
|
|
|
|
|
|
74 |
}
|
75 |
}
|
76 |
+
|
77 |
+
$size_in_bytes = strlen($csvoutput);
|
78 |
+
header("Content-type: text/csv");
|
79 |
+
//header("Content-type: application/vnd.ms-excel");
|
80 |
+
if($s && $l)
|
81 |
+
header("Content-Disposition: attachment; filename=members_list_" . $l . "_level" . $s . ".csv; size=$size_in_bytes");
|
82 |
+
elseif($s)
|
83 |
+
header("Content-Disposition: attachment; filename=members_list_" . $s . ".csv; size=$size_in_bytes");
|
84 |
+
elseif($l)
|
85 |
+
header("Content-Disposition: attachment; filename=members_list_level" . $l . ".csv; size=$size_in_bytes");
|
86 |
+
else
|
87 |
+
header("Content-Disposition: attachment; filename=members_list.csv; size=$size_in_bytes");
|
88 |
+
|
89 |
print $csvoutput;
|
90 |
|
91 |
+
function enclose($s)
|
92 |
{
|
93 |
return "\"" . str_replace("\"", "\\\"", $s) . "\"";
|
94 |
+
}
|
95 |
+
?>
|
adminpages/memberslist.php
CHANGED
@@ -1,238 +1,164 @@
|
|
1 |
-
<?php
|
2 |
-
//
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
<
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
<
|
50 |
-
<input
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
$pn = 1;
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
$sqlQuery
|
75 |
-
|
76 |
-
if($l
|
77 |
-
$sqlQuery .= " AND mu.
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
<
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
<?php
|
166 |
-
$count = 0;
|
167 |
-
foreach($theusers as $auser)
|
168 |
-
{
|
169 |
-
//get meta
|
170 |
-
$theuser = get_userdata($auser->ID);
|
171 |
-
?>
|
172 |
-
<tr <?php if($count++ % 2 == 0) { ?>class="alternate"<?php } ?>>
|
173 |
-
<td><?php echo $theuser->ID?></td>
|
174 |
-
<td>
|
175 |
-
<?php echo get_avatar($theuser->ID, 32)?>
|
176 |
-
<strong>
|
177 |
-
<?php
|
178 |
-
$userlink = '<a href="user-edit.php?user_id=' . $theuser->ID . '">' . $theuser->user_login . '</a>';
|
179 |
-
$userlink = apply_filters("pmpro_members_list_user_link", $userlink, $theuser);
|
180 |
-
echo $userlink;
|
181 |
-
?>
|
182 |
-
</strong>
|
183 |
-
</td>
|
184 |
-
<td><?php echo $theuser->first_name?></td>
|
185 |
-
<td><?php echo $theuser->last_name?></td>
|
186 |
-
<td><a href="mailto:<?php echo $theuser->user_email?>"><?php echo $theuser->user_email?></a></td>
|
187 |
-
<?php do_action("pmpro_memberslist_extra_cols_body", $theuser);?>
|
188 |
-
<td>
|
189 |
-
<?php
|
190 |
-
echo pmpro_formatAddress(trim($theuser->pmpro_bfirstname . " " . $theuser->pmpro_blastname), $theuser->pmpro_baddress1, $theuser->pmpro_baddress2, $theuser->pmpro_bcity, $theuser->pmpro_bstate, $theuser->pmpro_bzipcode, $theuser->pmpro_bcountry, $theuser->pmpro_bphone);
|
191 |
-
?>
|
192 |
-
</td>
|
193 |
-
<td><?php echo $auser->membership?></td>
|
194 |
-
<td>
|
195 |
-
<?php if((float)$auser->initial_payment > 0) { ?>
|
196 |
-
<?php echo $pmpro_currency_symbol; ?><?php echo $auser->initial_payment?>
|
197 |
-
<?php } ?>
|
198 |
-
<?php if((float)$auser->initial_payment > 0 && (float)$auser->billing_amount > 0) { ?>+<br /><?php } ?>
|
199 |
-
<?php if((float)$auser->billing_amount > 0) { ?>
|
200 |
-
<?php echo $pmpro_currency_symbol; ?><?php echo $auser->billing_amount?>/<?php echo $auser->cycle_period?>
|
201 |
-
<?php } ?>
|
202 |
-
<?php if((float)$auser->initial_payment <= 0 && (float)$auser->billing_amount <= 0) { ?>
|
203 |
-
-
|
204 |
-
<?php } ?>
|
205 |
-
</td>
|
206 |
-
<td><?php echo date(get_option("date_format"), strtotime($theuser->user_registered, current_time("timestamp")))?></td>
|
207 |
-
<td>
|
208 |
-
<?php
|
209 |
-
if($auser->enddate)
|
210 |
-
echo apply_filters("pmpro_memberslist_expires_column", date(get_option('date_format'), $auser->enddate), $auser);
|
211 |
-
else
|
212 |
-
echo __(apply_filters("pmpro_memberslist_expires_column", "Never", $auser), "pmpro");
|
213 |
-
?>
|
214 |
-
</td>
|
215 |
-
</tr>
|
216 |
-
<?php
|
217 |
-
}
|
218 |
-
|
219 |
-
if(!$theusers)
|
220 |
-
{
|
221 |
-
?>
|
222 |
-
<tr>
|
223 |
-
<td colspan="9"><p><?php _e("No members found.", "pmpro");?> <?php if($l) { ?><a href="?page=pmpro-memberslist&s=<?php echo $s?>"><?php _e("Search all levels", "pmpro");?></a>.<?php } ?></p></td>
|
224 |
-
</tr>
|
225 |
-
<?php
|
226 |
-
}
|
227 |
-
?>
|
228 |
-
</tbody>
|
229 |
-
</table>
|
230 |
-
</form>
|
231 |
-
|
232 |
-
<?php
|
233 |
-
echo pmpro_getPaginationString($pn, $totalrows, $limit, 1, get_admin_url(NULL, "/admin.php?page=pmpro-memberslist&s=" . urlencode($s)), "&l=$l&limit=$limit&pn=");
|
234 |
-
?>
|
235 |
-
|
236 |
-
<?php
|
237 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
238 |
-
?>
|
1 |
+
<?php
|
2 |
+
//vars
|
3 |
+
global $wpdb;
|
4 |
+
$s = $_REQUEST['s'];
|
5 |
+
$l = $_REQUEST['l'];
|
6 |
+
?>
|
7 |
+
<div class="wrap pmpro_admin">
|
8 |
+
<div class="pmpro_banner">
|
9 |
+
<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/PaidMembershipsPro.gif" width="350" height="45" border="0" alt="Paid Memberships Pro(c) - All Rights Reserved" /></a>
|
10 |
+
<div class="pmpro_tagline">Membership Plugin for WordPress</div>
|
11 |
+
|
12 |
+
<div class="pmpro_meta"><a href="<?php echo pmpro_https_filter("http://www.paidmembershipspro.com")?>">Plugin Support</a> | <a href="http://www.paidmembershipspro.com/forums/">User Forum</a> | <strong>Version <?php echo PMPRO_VERSION?></strong></div>
|
13 |
+
</div>
|
14 |
+
<br style="clear:both;" />
|
15 |
+
|
16 |
+
<?php
|
17 |
+
//include(pmpro_https_filter("http://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION));
|
18 |
+
?>
|
19 |
+
<div id="pmpro_notifications">
|
20 |
+
</div>
|
21 |
+
<script>
|
22 |
+
jQuery.get('<?php echo pmpro_https_filter("http://www.paidmembershipspro.com/notifications/?v=" . PMPRO_VERSION)?>', function(data) {
|
23 |
+
jQuery('#pmpro_notifications').html(data);
|
24 |
+
});
|
25 |
+
</script>
|
26 |
+
|
27 |
+
<form id="posts-filter" method="get" action="">
|
28 |
+
<h2>
|
29 |
+
Members Report
|
30 |
+
<small>(<a target="_blank" href="<?php echo PMPRO_URL?>/adminpages/memberslist-csv.php?s=<?php echo $s?>&l=<?php echo $l?>">Export to CSV</a>)</small>
|
31 |
+
</h2>
|
32 |
+
<ul class="subsubsub">
|
33 |
+
<li>
|
34 |
+
Show <select name="l" onchange="jQuery('#posts-filter').submit();">
|
35 |
+
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>>All Levels</option>
|
36 |
+
<?php
|
37 |
+
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
38 |
+
foreach($levels as $level)
|
39 |
+
{
|
40 |
+
?>
|
41 |
+
<option value="<?php echo $level->id?>" <?php if($l == $level->id) { ?>selected="selected"<?php } ?>><?php echo $level->name?></option>
|
42 |
+
<?php
|
43 |
+
}
|
44 |
+
?>
|
45 |
+
</select>
|
46 |
+
</li>
|
47 |
+
</ul>
|
48 |
+
<p class="search-box">
|
49 |
+
<label class="hidden" for="post-search-input">Search Members:</label>
|
50 |
+
<input type="hidden" name="page" value="pmpro-memberslist" />
|
51 |
+
<input id="post-search-input" type="text" value="<?php echo $s?>" name="s"/>
|
52 |
+
<input class="button" type="submit" value="Search Members"/>
|
53 |
+
</p>
|
54 |
+
<?php
|
55 |
+
//some vars for the search
|
56 |
+
$pn = $_REQUEST['pn'];
|
57 |
+
if(!$pn) $pn = 1;
|
58 |
+
$limit = $_REQUEST['limit'];
|
59 |
+
if(!$limit) $limit = 15;
|
60 |
+
$end = $pn * $limit;
|
61 |
+
$start = $end - $limit;
|
62 |
+
|
63 |
+
if($s)
|
64 |
+
{
|
65 |
+
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate, mu.membership_id, mu.initial_payment, mu.billing_amount, mu.cycle_period, mu.cycle_number, mu.billing_limit, mu.trial_amount, mu.trial_limit, UNIX_TIMESTAMP(mu.startdate) as startdate, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id WHERE mu.membership_id > 0 AND (u.user_login LIKE '%$s%' OR u.user_email LIKE '%$s%' OR um.meta_value LIKE '%$s%') ";
|
66 |
+
|
67 |
+
if($l)
|
68 |
+
$sqlQuery .= " AND mu.membership_id = '" . $l . "' ";
|
69 |
+
|
70 |
+
$sqlQuery .= "GROUP BY u.ID ORDER BY user_registered DESC LIMIT $start, $limit";
|
71 |
+
}
|
72 |
+
else
|
73 |
+
{
|
74 |
+
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate, mu.membership_id, mu.initial_payment, mu.billing_amount, mu.cycle_period, mu.cycle_number, mu.billing_limit, mu.trial_amount, mu.trial_limit, UNIX_TIMESTAMP(mu.startdate) as startdate, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership FROM $wpdb->users u LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id ";
|
75 |
+
$sqlQuery .= "WHERE mu.membership_id > 0 ";
|
76 |
+
if($l)
|
77 |
+
$sqlQuery .= " AND mu.membership_id = '" . $l . "' ";
|
78 |
+
$sqlQuery .= "ORDER BY user_registered DESC LIMIT $start, $limit";
|
79 |
+
}
|
80 |
+
|
81 |
+
$theusers = $wpdb->get_results($sqlQuery);
|
82 |
+
$totalrows = $wpdb->get_var("SELECT FOUND_ROWS() as found_rows");
|
83 |
+
|
84 |
+
if($theusers)
|
85 |
+
{
|
86 |
+
$initial_payments = pmpro_calculateInitialPaymentRevenue($s, $l);
|
87 |
+
$recurring_payments = pmpro_calculateRecurringRevenue($s, $l);
|
88 |
+
?>
|
89 |
+
<p class="clear"><?php echo strval($totalrows)?> members found. These members have paid <strong>$<?php echo number_format($initial_payments)?> in initial payments</strong> and will generate an estimated <strong>$<?php echo number_format($recurring_payments)?> in revenue over the next year</strong>, or <strong>$<?php echo number_format($recurring_payments/12)?>/month</strong>. <span class="pmpro_lite">(This estimate does not take into account trial periods or billing limits.)</span></p>
|
90 |
+
<?php
|
91 |
+
}
|
92 |
+
?>
|
93 |
+
<table class="widefat">
|
94 |
+
<thead>
|
95 |
+
<tr class="thead">
|
96 |
+
<th>ID</th>
|
97 |
+
<th>Username</th>
|
98 |
+
<th>First Name</th>
|
99 |
+
<th>Last Name</th>
|
100 |
+
<th>Email</th>
|
101 |
+
<th>Membership</th>
|
102 |
+
<th>Fee</th>
|
103 |
+
<th>Joined</th>
|
104 |
+
<th>Expires</th>
|
105 |
+
</tr>
|
106 |
+
</thead>
|
107 |
+
<tbody id="users" class="list:user user-list">
|
108 |
+
<?php
|
109 |
+
foreach($theusers as $theuser)
|
110 |
+
{
|
111 |
+
//get meta
|
112 |
+
$sqlQuery = "SELECT meta_key as `key`, meta_value as `value` FROM $wpdb->usermeta WHERE $wpdb->usermeta.user_id = '" . $theuser->ID . "'";
|
113 |
+
$metavalues = pmpro_getMetavalues($sqlQuery);
|
114 |
+
?>
|
115 |
+
<tr <?php if($count++ % 2 == 0) { ?>class="alternate"<?php } ?>>
|
116 |
+
<td><?php echo $theuser->ID?></td>
|
117 |
+
<td>
|
118 |
+
<?php echo get_avatar($theuser->ID, 32)?>
|
119 |
+
<strong><a href="user-edit.php?user_id=<?php echo $theuser->ID?>"><?php echo $theuser->user_login?></a></strong>
|
120 |
+
</td>
|
121 |
+
<td><?php echo $metavalues->first_name?></td>
|
122 |
+
<td><?php echo $metavalues->last_name?></td>
|
123 |
+
<td><a href="mailto:<?php echo $theuser->user_email?>"><?php echo $theuser->user_email?></a></td>
|
124 |
+
<td><?php echo $theuser->membership?></td>
|
125 |
+
<td>
|
126 |
+
<?php if($theuser->billing_amount > 0) { ?>
|
127 |
+
$<?php echo $theuser->billing_amount?>/<?php echo $theuser->cycle_period?>
|
128 |
+
<?php } else { ?>
|
129 |
+
-
|
130 |
+
<?php } ?>
|
131 |
+
</td>
|
132 |
+
<td><?php echo date("m/d/Y", $theuser->joindate)?></td>
|
133 |
+
<td>
|
134 |
+
<?php
|
135 |
+
if($theuser->enddate)
|
136 |
+
echo date("m/d/Y", $theuser->enddate);
|
137 |
+
else
|
138 |
+
echo "Never";
|
139 |
+
?>
|
140 |
+
</td>
|
141 |
+
</tr>
|
142 |
+
<?php
|
143 |
+
}
|
144 |
+
|
145 |
+
if(!$theusers)
|
146 |
+
{
|
147 |
+
?>
|
148 |
+
<tr>
|
149 |
+
<td colspan="9"><p>No members found. <?php if($l) { ?><a href="?page=pmpro-memberslist&s=<?php echo $s?>">Search all levels</a>.<?php } ?></p></td>
|
150 |
+
</tr>
|
151 |
+
<?php
|
152 |
+
}
|
153 |
+
?>
|
154 |
+
</tbody>
|
155 |
+
</table>
|
156 |
+
</form>
|
157 |
+
|
158 |
+
<?php
|
159 |
+
echo pmpro_getPaginationString($pn, $totalrows, $limit, 1, "/wp-admin/admin.php?page=pmpro-memberslist&s=" . urlencode($s), "&l=$l&limit=$limit&pn=");
|
160 |
+
?>
|
161 |
+
|
162 |
+
</div>
|
163 |
+
<?php
|
164 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/orders-csv.php
DELETED
@@ -1,297 +0,0 @@
|
|
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_csv")))
|
4 |
-
{
|
5 |
-
die(__("You do not have permissions to perform this action.", "pmpro"));
|
6 |
-
}
|
7 |
-
|
8 |
-
global $wpdb;
|
9 |
-
|
10 |
-
//get users
|
11 |
-
if(isset($_REQUEST['s']))
|
12 |
-
$s = $_REQUEST['s'];
|
13 |
-
else
|
14 |
-
$s = "";
|
15 |
-
|
16 |
-
if(isset($_REQUEST['l']))
|
17 |
-
$l = $_REQUEST['l'];
|
18 |
-
else
|
19 |
-
$l = false;
|
20 |
-
|
21 |
-
if(isset($_REQUEST['start-month']))
|
22 |
-
$start_month = $_REQUEST['start-month'];
|
23 |
-
else
|
24 |
-
$start_month = "1";
|
25 |
-
|
26 |
-
if(isset($_REQUEST['start-day']))
|
27 |
-
$start_day = $_REQUEST['start-day'];
|
28 |
-
else
|
29 |
-
$start_day = "1";
|
30 |
-
|
31 |
-
if(isset($_REQUEST['start-year']))
|
32 |
-
$start_year = $_REQUEST['start-year'];
|
33 |
-
else
|
34 |
-
$start_year = date("Y");
|
35 |
-
|
36 |
-
if(isset($_REQUEST['end-month']))
|
37 |
-
$end_month = $_REQUEST['end-month'];
|
38 |
-
else
|
39 |
-
$end_month = date("n");
|
40 |
-
|
41 |
-
if(isset($_REQUEST['end-day']))
|
42 |
-
$end_day = $_REQUEST['end-day'];
|
43 |
-
else
|
44 |
-
$end_day = date("j");
|
45 |
-
|
46 |
-
if(isset($_REQUEST['end-year']))
|
47 |
-
$end_year = $_REQUEST['end-year'];
|
48 |
-
else
|
49 |
-
$end_year = date("Y");
|
50 |
-
|
51 |
-
if(isset($_REQUEST['predefined-date']))
|
52 |
-
$predefined_date = $_REQUEST['predefined-date'];
|
53 |
-
else
|
54 |
-
$predefined_date = "This Month";
|
55 |
-
|
56 |
-
if(isset($_REQUEST['status']))
|
57 |
-
$status = $_REQUEST['status'];
|
58 |
-
else
|
59 |
-
$status = "";
|
60 |
-
|
61 |
-
if(isset($_REQUEST['filter']))
|
62 |
-
$filter = sanitize_text_field($_REQUEST['filter']);
|
63 |
-
else
|
64 |
-
$filter = "all";
|
65 |
-
|
66 |
-
//some vars for the search
|
67 |
-
if(!empty($_REQUEST['pn']))
|
68 |
-
$pn = $_REQUEST['pn'];
|
69 |
-
else
|
70 |
-
$pn = 1;
|
71 |
-
|
72 |
-
if(!empty($_REQUEST['limit']))
|
73 |
-
$limit = $_REQUEST['limit'];
|
74 |
-
else
|
75 |
-
$limit = false;
|
76 |
-
|
77 |
-
if($limit)
|
78 |
-
{
|
79 |
-
$end = $pn * $limit;
|
80 |
-
$start = $end - $limit;
|
81 |
-
}
|
82 |
-
else
|
83 |
-
{
|
84 |
-
$end = NULL;
|
85 |
-
$start = NULL;
|
86 |
-
}
|
87 |
-
|
88 |
-
//filters
|
89 |
-
if($filter == "all" || !$filter)
|
90 |
-
$condition = "1=1";
|
91 |
-
elseif($filter == "within-a-date-range")
|
92 |
-
{
|
93 |
-
$start_date = $start_year."-".$start_month."-".$start_day;
|
94 |
-
$end_date = $end_year."-".$end_month."-".$end_day;
|
95 |
-
|
96 |
-
//add times to dates
|
97 |
-
$start_date = $start_date . " 00:00:00";
|
98 |
-
$end_date = $end_date . " 23:59:59";
|
99 |
-
|
100 |
-
$condition = "timestamp BETWEEN '".$start_date."' AND '".$end_date."'";
|
101 |
-
}
|
102 |
-
elseif($filter == "predefined-date-range")
|
103 |
-
{
|
104 |
-
if($predefined_date == "Last Month")
|
105 |
-
{
|
106 |
-
$start_date = date("Y-m-d", strtotime("first day of last month", current_time("timestamp")));
|
107 |
-
$end_date = date("Y-m-d", strtotime("last day of last month", current_time("timestamp")));
|
108 |
-
}
|
109 |
-
elseif($predefined_date == "This Month")
|
110 |
-
{
|
111 |
-
$start_date = date("Y-m-d", strtotime("first day of this month", current_time("timestamp")));
|
112 |
-
$end_date = date("Y-m-d", strtotime("last day of this month", current_time("timestamp")));
|
113 |
-
}
|
114 |
-
elseif($predefined_date == "This Year")
|
115 |
-
{
|
116 |
-
$year = date('Y');
|
117 |
-
$start_date = date("Y-m-d", strtotime("first day of January $year", current_time("timestamp")));
|
118 |
-
$end_date = date("Y-m-d", strtotime("last day of December $year", current_time("timestamp")));
|
119 |
-
}
|
120 |
-
|
121 |
-
elseif($predefined_date == "Last Year")
|
122 |
-
{
|
123 |
-
$year = date('Y') - 1;
|
124 |
-
$start_date = date("Y-m-d", strtotime("first day of January $year", current_time("timestamp")));
|
125 |
-
$end_date = date("Y-m-d", strtotime("last day of December $year", current_time("timestamp")));
|
126 |
-
}
|
127 |
-
|
128 |
-
//add times to dates
|
129 |
-
$start_date = $start_date . " 00:00:00";
|
130 |
-
$end_date = $end_date . " 23:59:59";
|
131 |
-
|
132 |
-
$condition = "timestamp BETWEEN '".$start_date."' AND '".$end_date."'";
|
133 |
-
}
|
134 |
-
elseif($filter == "within-a-level")
|
135 |
-
{
|
136 |
-
$condition = "membership_id = $l";
|
137 |
-
}
|
138 |
-
elseif($filter == "within-a-status")
|
139 |
-
{
|
140 |
-
$condition = "status = '$status' ";
|
141 |
-
}
|
142 |
-
|
143 |
-
//string search
|
144 |
-
if($s)
|
145 |
-
{
|
146 |
-
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS o.id FROM $wpdb->pmpro_membership_orders o LEFT JOIN $wpdb->users u ON o.user_id = u.ID LEFT JOIN $wpdb->pmpro_membership_levels l ON o.membership_id = l.id ";
|
147 |
-
|
148 |
-
$join_with_usermeta = apply_filters("pmpro_orders_search_usermeta", false);
|
149 |
-
if($join_with_usermeta)
|
150 |
-
$sqlQuery .= "LEFT JOIN $wpdb->usermeta um ON o.user_id = um.user_id ";
|
151 |
-
|
152 |
-
$sqlQuery .= "WHERE (1=2 ";
|
153 |
-
|
154 |
-
$fields = array("o.id", "o.code", "o.billing_name", "o.billing_street", "o.billing_city", "o.billing_state", "o.billing_zip", "o.billing_phone", "o.payment_type", "o.cardtype", "o.accountnumber", "o.status", "o.gateway", "o.gateway_environment", "o.payment_transaction_id", "o.subscription_transaction_id", "u.user_login", "u.user_email", "u.display_name", "l.name");
|
155 |
-
|
156 |
-
if($join_with_usermeta)
|
157 |
-
$fields[] = "um.meta_value";
|
158 |
-
|
159 |
-
$fields = apply_filters("pmpro_orders_search_fields", $fields);
|
160 |
-
|
161 |
-
foreach($fields as $field)
|
162 |
-
$sqlQuery .= " OR " . $field . " LIKE '%" . esc_sql($s) . "%' ";
|
163 |
-
$sqlQuery .= ") ";
|
164 |
-
|
165 |
-
$sqlQuery .= "AND " . $condition . " ";
|
166 |
-
|
167 |
-
$sqlQuery .= "GROUP BY o.id ORDER BY o.id DESC, o.timestamp DESC ";
|
168 |
-
}
|
169 |
-
else
|
170 |
-
{
|
171 |
-
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS id FROM $wpdb->pmpro_membership_orders WHERE ".$condition." ORDER BY id DESC, timestamp DESC ";
|
172 |
-
}
|
173 |
-
|
174 |
-
if(!empty($start) && !empty($limit))
|
175 |
-
$sqlQuery .= "LIMIT $start, $limit";
|
176 |
-
|
177 |
-
$order_ids = $wpdb->get_col($sqlQuery);
|
178 |
-
|
179 |
-
//begin output
|
180 |
-
header("Content-type: text/csv");
|
181 |
-
|
182 |
-
$filename = "orders.csv";
|
183 |
-
/*
|
184 |
-
Insert logic here for building filename from $filter and other values.
|
185 |
-
*/
|
186 |
-
header("Content-Disposition: attachment; filename=$filename;");
|
187 |
-
|
188 |
-
$csvoutput = "id,user_id,user_login,first_name,last_name,user_email,billing_name,billing_street,billing_city,billing_state,billing_zip,billing_country,billing_phone,membership_id,level_name,subtotal,tax,couponamount,total,payment_type,cardtype,accountnumber,expirationmonth,expirationyear,status,gateway,gateway_environment,payment_transaction_id,subscription_transaction_id,discount_code_id,discount_code,timestamp";
|
189 |
-
|
190 |
-
//these are the meta_keys for the fields (arrays are object, property. so e.g. $theuser->ID)
|
191 |
-
$default_columns = array(
|
192 |
-
array("order", "id"),
|
193 |
-
array("user", "ID"),
|
194 |
-
array("user", "user_login"),
|
195 |
-
array("user", "first_name"),
|
196 |
-
array("user", "last_name"),
|
197 |
-
array("user", "user_email"),
|
198 |
-
array("order", "billing", "name"),
|
199 |
-
array("order", "billing", "street"),
|
200 |
-
array("order", "billing", "city"),
|
201 |
-
array("order", "billing", "state"),
|
202 |
-
array("order", "billing", "zip"),
|
203 |
-
array("order", "billing", "country"),
|
204 |
-
array("order", "billing", "phone"),
|
205 |
-
array("order", "membership_id"),
|
206 |
-
array("level", "name"),
|
207 |
-
array("order", "subtotal"),
|
208 |
-
array("order", "tax"),
|
209 |
-
array("order", "couponamount"),
|
210 |
-
array("order", "total"),
|
211 |
-
array("order", "payment_type"),
|
212 |
-
array("order", "cardtype"),
|
213 |
-
array("order", "accountnumber"),
|
214 |
-
array("order", "expirationmonth"),
|
215 |
-
array("order", "expirationyear"),
|
216 |
-
array("order", "status"),
|
217 |
-
array("order", "gateway"),
|
218 |
-
array("order", "gateway_environment"),
|
219 |
-
array("order", "payment_transaction_id"),
|
220 |
-
array("order", "subscription_transactiond_id"),
|
221 |
-
array("discount_code", "id"),
|
222 |
-
array("discount_code", "code")
|
223 |
-
);
|
224 |
-
|
225 |
-
//any extra columns
|
226 |
-
$extra_columns = apply_filters("pmpro_orders_csv_extra_columns", array());
|
227 |
-
if(!empty($extra_columns))
|
228 |
-
{
|
229 |
-
foreach($extra_columns as $heading => $callback)
|
230 |
-
{
|
231 |
-
$csvoutput .= "," . $heading;
|
232 |
-
}
|
233 |
-
}
|
234 |
-
|
235 |
-
$csvoutput .= "\n";
|
236 |
-
|
237 |
-
//output
|
238 |
-
echo $csvoutput;
|
239 |
-
$csvoutput = "";
|
240 |
-
|
241 |
-
if($order_ids)
|
242 |
-
{
|
243 |
-
foreach($order_ids as $order_id)
|
244 |
-
{
|
245 |
-
$order = new MemberOrder();
|
246 |
-
$order->nogateway = true;
|
247 |
-
$order->getMemberOrderByID($order_id);
|
248 |
-
$user = get_userdata($order->user_id);
|
249 |
-
$level = $order->getMembershipLevel();
|
250 |
-
$sqlQuery = "SELECT c.id, c.code FROM $wpdb->pmpro_discount_codes_uses cu LEFT JOIN $wpdb->pmpro_discount_codes c ON cu.code_id = c.id WHERE cu.order_id = '" . $order_id . "' LIMIT 1";
|
251 |
-
$discount_code = $wpdb->get_row($sqlQuery);
|
252 |
-
|
253 |
-
//default columns
|
254 |
-
if(!empty($default_columns))
|
255 |
-
{
|
256 |
-
$count = 0;
|
257 |
-
foreach($default_columns as $col)
|
258 |
-
{
|
259 |
-
//add comma after the first item
|
260 |
-
$count++;
|
261 |
-
if($count > 1)
|
262 |
-
$csvoutput .= ",";
|
263 |
-
|
264 |
-
//checking $object->property. note the double $$
|
265 |
-
if(!empty($col[2]) && isset($$col[0]->$col[1]->$col[2]))
|
266 |
-
$csvoutput .= pmpro_enclose($$col[0]->$col[1]->$col[2]); //output the value
|
267 |
-
elseif(!empty($$col[0]->$col[1]))
|
268 |
-
$csvoutput .= pmpro_enclose($$col[0]->$col[1]); //output the value
|
269 |
-
}
|
270 |
-
}
|
271 |
-
|
272 |
-
//timestamp
|
273 |
-
$csvoutput .= "," . pmpro_enclose(date(get_option("date_format"), $order->timestamp));
|
274 |
-
|
275 |
-
//any extra columns
|
276 |
-
if(!empty($extra_columns))
|
277 |
-
{
|
278 |
-
foreach($extra_columns as $heading => $callback)
|
279 |
-
{
|
280 |
-
$csvoutput .= "," . pmpro_enclose(call_user_func($callback, $order));
|
281 |
-
}
|
282 |
-
}
|
283 |
-
|
284 |
-
$csvoutput .= "\n";
|
285 |
-
|
286 |
-
//output
|
287 |
-
echo $csvoutput;
|
288 |
-
$csvoutput = "";
|
289 |
-
}
|
290 |
-
}
|
291 |
-
|
292 |
-
print $csvoutput;
|
293 |
-
|
294 |
-
function pmpro_enclose($s)
|
295 |
-
{
|
296 |
-
return "\"" . str_replace("\"", "\\\"", $s) . "\"";
|
297 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/orders.php
DELETED
@@ -1,996 +0,0 @@
|
|
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 |
-
{
|
5 |
-
die(__("You do not have permissions to perform this action.", "pmpro"));
|
6 |
-
}
|
7 |
-
|
8 |
-
//vars
|
9 |
-
global $wpdb, $pmpro_currency_symbol;
|
10 |
-
if(isset($_REQUEST['s']))
|
11 |
-
$s = $_REQUEST['s'];
|
12 |
-
else
|
13 |
-
$s = "";
|
14 |
-
|
15 |
-
if(isset($_REQUEST['l']))
|
16 |
-
$l = $_REQUEST['l'];
|
17 |
-
else
|
18 |
-
$l = false;
|
19 |
-
|
20 |
-
if(isset($_REQUEST['start-month']))
|
21 |
-
$start_month = $_REQUEST['start-month'];
|
22 |
-
else
|
23 |
-
$start_month = "1";
|
24 |
-
|
25 |
-
if(isset($_REQUEST['start-day']))
|
26 |
-
$start_day = $_REQUEST['start-day'];
|
27 |
-
else
|
28 |
-
$start_day = "1";
|
29 |
-
|
30 |
-
if(isset($_REQUEST['start-year']))
|
31 |
-
$start_year = $_REQUEST['start-year'];
|
32 |
-
else
|
33 |
-
$start_year = date("Y");
|
34 |
-
|
35 |
-
if(isset($_REQUEST['end-month']))
|
36 |
-
$end_month = $_REQUEST['end-month'];
|
37 |
-
else
|
38 |
-
$end_month = date("n");
|
39 |
-
|
40 |
-
if(isset($_REQUEST['end-day']))
|
41 |
-
$end_day = $_REQUEST['end-day'];
|
42 |
-
else
|
43 |
-
$end_day = date("j");
|
44 |
-
|
45 |
-
if(isset($_REQUEST['end-year']))
|
46 |
-
$end_year = $_REQUEST['end-year'];
|
47 |
-
else
|
48 |
-
$end_year = date("Y");
|
49 |
-
|
50 |
-
if(isset($_REQUEST['predefined-date']))
|
51 |
-
$predefined_date = $_REQUEST['predefined-date'];
|
52 |
-
else
|
53 |
-
$predefined_date = "This Month";
|
54 |
-
|
55 |
-
if(isset($_REQUEST['status']))
|
56 |
-
$status = $_REQUEST['status'];
|
57 |
-
else
|
58 |
-
$status = "";
|
59 |
-
|
60 |
-
|
61 |
-
//deleting?
|
62 |
-
if(!empty($_REQUEST['delete']))
|
63 |
-
{
|
64 |
-
$dorder = new MemberOrder(intval($_REQUEST['delete']));
|
65 |
-
if($dorder->deleteMe())
|
66 |
-
{
|
67 |
-
$pmpro_msg = __("Order deleted successfully.", "pmpro");
|
68 |
-
$pmpro_msgt = "success";
|
69 |
-
}
|
70 |
-
else
|
71 |
-
{
|
72 |
-
$pmpro_msg = __("Error deleting order.", "pmpro");
|
73 |
-
$pmpro_msgt = "error";
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
if(isset($_REQUEST['filter']))
|
78 |
-
$filter = sanitize_text_field($_REQUEST['filter']);
|
79 |
-
else
|
80 |
-
$filter = "all";
|
81 |
-
|
82 |
-
$thisyear = date("Y");
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
//this array stores fields that should be read only
|
87 |
-
$read_only_fields = apply_filters("pmpro_orders_read_only_fields", array("code", "payment_transaction_id", "subscription_transaction_id"));
|
88 |
-
|
89 |
-
//saving?
|
90 |
-
if(!empty($_REQUEST['save']))
|
91 |
-
{
|
92 |
-
//start with old order if applicable
|
93 |
-
$order_id = intval($_REQUEST['order']);
|
94 |
-
if($order_id > 0)
|
95 |
-
$order = new MemberOrder($order_id);
|
96 |
-
else
|
97 |
-
$order = new MemberOrder();
|
98 |
-
|
99 |
-
//update values
|
100 |
-
if(!in_array("code", $read_only_fields))
|
101 |
-
$order->code = $_POST['code'];
|
102 |
-
if(!in_array("user_id", $read_only_fields))
|
103 |
-
$order->user_id = intval($_POST['user_id']);
|
104 |
-
if(!in_array("membership_id", $read_only_fields))
|
105 |
-
$order->membership_id = intval($_POST['membership_id']);
|
106 |
-
if(!in_array("billing_name", $read_only_fields))
|
107 |
-
$order->billing->name = stripslashes($_POST['billing_name']);
|
108 |
-
if(!in_array("billing_street", $read_only_fields))
|
109 |
-
$order->billing->street = stripslashes($_POST['billing_street']);
|
110 |
-
if(!in_array("billing_city", $read_only_fields))
|
111 |
-
$order->billing->city = stripslashes($_POST['billing_city']);
|
112 |
-
if(!in_array("billing_state", $read_only_fields))
|
113 |
-
$order->billing->state = stripslashes($_POST['billing_state']);
|
114 |
-
if(!in_array("billing_zip", $read_only_fields))
|
115 |
-
$order->billing->zip = $_POST['billing_zip'];
|
116 |
-
if(!in_array("billing_country", $read_only_fields))
|
117 |
-
$order->billing->country = stripslashes($_POST['billing_country']);
|
118 |
-
if(!in_array("billing_phone", $read_only_fields))
|
119 |
-
$order->billing->phone = $_POST['billing_phone'];
|
120 |
-
if(!in_array("subtotal", $read_only_fields))
|
121 |
-
$order->subtotal = $_POST['subtotal'];
|
122 |
-
if(!in_array("tax", $read_only_fields))
|
123 |
-
$order->tax = $_POST['tax'];
|
124 |
-
if(!in_array("couponamount", $read_only_fields))
|
125 |
-
$order->couponamount = $_POST['couponamount'];
|
126 |
-
if(!in_array("total", $read_only_fields))
|
127 |
-
$order->total = $_POST['total'];
|
128 |
-
if(!in_array("payment_type", $read_only_fields))
|
129 |
-
$order->payment_type = $_POST['payment_type'];
|
130 |
-
if(!in_array("cardtype", $read_only_fields))
|
131 |
-
$order->cardtype = $_POST['cardtype'];
|
132 |
-
if(!in_array("accountnumber", $read_only_fields))
|
133 |
-
$order->accountnumber = $_POST['accountnumber'];
|
134 |
-
if(!in_array("expirationmonth", $read_only_fields))
|
135 |
-
$order->expirationmonth = $_POST['expirationmonth'];
|
136 |
-
if(!in_array("expirationyear", $read_only_fields))
|
137 |
-
$order->expirationyear = $_POST['expirationyear'];
|
138 |
-
if(!in_array("ExpirationDate", $read_only_fields))
|
139 |
-
$order->ExpirationDate = $order->expirationmonth . $order->expirationyear;
|
140 |
-
if(!in_array("status", $read_only_fields))
|
141 |
-
$order->status = stripslashes($_POST['status']);
|
142 |
-
if(!in_array("gateway", $read_only_fields))
|
143 |
-
$order->gateway = $_POST['gateway'];
|
144 |
-
if(!in_array("gateway_environment", $read_only_fields))
|
145 |
-
$order->gateway_environment = $_POST['gateway_environment'];
|
146 |
-
if(!in_array("payment_transaction_id", $read_only_fields))
|
147 |
-
$order->payment_transaction_id = $_POST['payment_transaction_id'];
|
148 |
-
if(!in_array("subscription_transaction_id", $read_only_fields))
|
149 |
-
$order->subscription_transaction_id = $_POST['subscription_transaction_id'];
|
150 |
-
if(!in_array("notes", $read_only_fields))
|
151 |
-
$order->notes = stripslashes($_POST['notes']);
|
152 |
-
|
153 |
-
//affiliate stuff
|
154 |
-
$affiliates = apply_filters("pmpro_orders_show_affiliate_ids", false);
|
155 |
-
if(!empty($affiliates))
|
156 |
-
{
|
157 |
-
if(!in_array("affiliate_id", $read_only_fields))
|
158 |
-
$order->affiliate_id = $_POST['affiliate_id'];
|
159 |
-
if(!in_array("affiliate_subid", $read_only_fields))
|
160 |
-
$order->affiliate_subid = $_POST['affiliate_subid'];
|
161 |
-
}
|
162 |
-
|
163 |
-
//save
|
164 |
-
if($order->saveOrder() !== false)
|
165 |
-
{
|
166 |
-
//handle timestamp
|
167 |
-
if($order->updateTimestamp($_POST['ts_year'], $_POST['ts_month'], $_POST['ts_day']) !== false)
|
168 |
-
{
|
169 |
-
$pmpro_msg = __("Order saved successfully.", "pmpro");
|
170 |
-
$pmpro_msgt = "success";
|
171 |
-
}
|
172 |
-
else
|
173 |
-
{
|
174 |
-
$pmpro_msg = __("Error updating order timestamp.", "pmpro");
|
175 |
-
$pmpro_msgt = "error";
|
176 |
-
}
|
177 |
-
}
|
178 |
-
else
|
179 |
-
{
|
180 |
-
$pmpro_msg = __("Error saving order.", "pmpro");
|
181 |
-
$pmpro_msgt = "error";
|
182 |
-
}
|
183 |
-
}
|
184 |
-
else
|
185 |
-
{
|
186 |
-
//order passed?
|
187 |
-
if(!empty($_REQUEST['order']))
|
188 |
-
{
|
189 |
-
$order_id = intval($_REQUEST['order']);
|
190 |
-
if($order_id > 0)
|
191 |
-
$order = new MemberOrder($order_id);
|
192 |
-
elseif(!empty($_REQUEST['copy']))
|
193 |
-
{
|
194 |
-
$order = new MemberOrder(intval($_REQUEST['copy']));
|
195 |
-
|
196 |
-
//new id
|
197 |
-
$order->id = NULL;
|
198 |
-
|
199 |
-
//new code
|
200 |
-
$order->code = $order->getRandomCode();
|
201 |
-
}
|
202 |
-
else
|
203 |
-
{
|
204 |
-
$order = new MemberOrder(); //new order
|
205 |
-
|
206 |
-
//defaults
|
207 |
-
$order->code = $order->getRandomCode();
|
208 |
-
$order->user_id = "";
|
209 |
-
$order->membership_id = "";
|
210 |
-
$order->billing->name = "";
|
211 |
-
$order->billing->street = "";
|
212 |
-
$order->billing->city = "";
|
213 |
-
$order->billing->state = "";
|
214 |
-
$order->billing->zip = "";
|
215 |
-
$order->billing->country = "";
|
216 |
-
$order->billing->phone = "";
|
217 |
-
$order->subtotal = "";
|
218 |
-
$order->tax = "";
|
219 |
-
$order->couponamount = "";
|
220 |
-
$order->total = "";
|
221 |
-
$order->payment_type = "";
|
222 |
-
$order->cardtype = "";
|
223 |
-
$order->accountnumber = "";
|
224 |
-
$order->expirationmonth = "";
|
225 |
-
$order->expirationyear = "";
|
226 |
-
$order->status = "success";
|
227 |
-
$order->gateway = pmpro_getOption("gateway");
|
228 |
-
$order->gateway_environment = pmpro_getOption("gateway_environment");
|
229 |
-
$order->payment_transaction_id = "";
|
230 |
-
$order->subscription_transaction_id = "";
|
231 |
-
$order->affiliate_id = "";
|
232 |
-
$order->affiliate_subid = "";
|
233 |
-
$order->notes = "";
|
234 |
-
}
|
235 |
-
}
|
236 |
-
}
|
237 |
-
|
238 |
-
require_once(dirname(__FILE__) . "/admin_header.php");
|
239 |
-
?>
|
240 |
-
|
241 |
-
<?php if(!empty($order)) { ?>
|
242 |
-
|
243 |
-
<h2>
|
244 |
-
<?php if(!empty($order->id)) { ?>
|
245 |
-
<?php _e('Order', 'pmpro');?> #<?php echo $order->id?>: <?php echo $order->code?>
|
246 |
-
<?php } else { ?>
|
247 |
-
<?php _e('New Order', 'pmpro');?>
|
248 |
-
<?php } ?>
|
249 |
-
</h2>
|
250 |
-
|
251 |
-
<?php if(!empty($pmpro_msg)) { ?>
|
252 |
-
<div id="message" class="<?php if($pmpro_msgt == "success") echo "updated fade"; else echo "error"; ?>"><p><?php echo $pmpro_msg?></p></div>
|
253 |
-
<?php } ?>
|
254 |
-
|
255 |
-
<form method="post" action="">
|
256 |
-
|
257 |
-
<table class="form-table">
|
258 |
-
<tbody>
|
259 |
-
<tr>
|
260 |
-
<th scope="row" valign="top"><label>ID:</label></th>
|
261 |
-
<td><?php if(!empty($order->id)) echo $order->id; else echo __("This will be generated when you save.", "pmpro");?></td>
|
262 |
-
</tr>
|
263 |
-
|
264 |
-
<tr>
|
265 |
-
<th scope="row" valign="top"><label for="code"><?php _e('Code', 'pmpro');?>:</label></th>
|
266 |
-
<td>
|
267 |
-
<?php if(in_array("code", $read_only_fields)) { echo $order->code; } else { ?>
|
268 |
-
<input id="code" name="code" type="text" size="50" value="<?php echo esc_attr($order->code);?>" />
|
269 |
-
<?php } ?>
|
270 |
-
<?php if($order_id < 0) { ?><small class="pmpro_lite"><?php _e('Randomly generated for you.', 'pmpro');?></small><?php } ?>
|
271 |
-
</td>
|
272 |
-
</tr>
|
273 |
-
|
274 |
-
<tr>
|
275 |
-
<th scope="row" valign="top"><label for="user_id"><?php _e('User ID', 'pmpro');?>:</label></th>
|
276 |
-
<td>
|
277 |
-
<?php if(in_array("user_id", $read_only_fields) && $order_id > 0) { echo $order->user_id; } else { ?>
|
278 |
-
<input id="user_id" name="user_id" type="text" size="50" value="<?php echo esc_attr($order->user_id);?>" />
|
279 |
-
<?php } ?>
|
280 |
-
</td>
|
281 |
-
</tr>
|
282 |
-
|
283 |
-
<tr>
|
284 |
-
<th scope="row" valign="top"><label for="membership_id"><?php _e('Membership Level ID', 'pmpro');?>:</label></th>
|
285 |
-
<td>
|
286 |
-
<?php if(in_array("membership_id", $read_only_fields) && $order_id > 0) { echo $order->membership_id; } else { ?>
|
287 |
-
<input id="membership_id" name="membership_id" type="text" size="50" value="<?php echo esc_attr($order->membership_id);?>" />
|
288 |
-
<?php } ?>
|
289 |
-
</td>
|
290 |
-
</tr>
|
291 |
-
|
292 |
-
<tr>
|
293 |
-
<th scope="row" valign="top"><label for="billing_name"><?php _e('Billing Name', 'pmpro');?>:</label></th>
|
294 |
-
<td>
|
295 |
-
<?php if(in_array("billing_name", $read_only_fields) && $order_id > 0) { echo $order->billing_name; } else { ?>
|
296 |
-
<input id="billing_name" name="billing_name" type="text" size="50" value="<?php echo esc_attr($order->billing->name);?>" />
|
297 |
-
<?php } ?>
|
298 |
-
</td>
|
299 |
-
</tr>
|
300 |
-
<tr>
|
301 |
-
<th scope="row" valign="top"><label for="billing_street"><?php _e('Billing Street', 'pmpro');?>:</label></th>
|
302 |
-
<td>
|
303 |
-
<?php if(in_array("billing_street", $read_only_fields) && $order_id > 0) { echo $order->billing_street; } else { ?>
|
304 |
-
<input id="billing_street" name="billing_street" type="text" size="50" value="<?php echo esc_attr($order->billing->street);?>" /></td>
|
305 |
-
<?php } ?>
|
306 |
-
</tr>
|
307 |
-
<tr>
|
308 |
-
<th scope="row" valign="top"><label for="billing_city"><?php _e('Billing City', 'pmpro');?>:</label></th>
|
309 |
-
<td>
|
310 |
-
<?php if(in_array("billing_city", $read_only_fields) && $order_id > 0) { echo $order->billing_city; } else { ?>
|
311 |
-
<input id="billing_city" name="billing_city" type="text" size="50" value="<?php echo esc_attr($order->billing->city);?>" /></td>
|
312 |
-
<?php } ?>
|
313 |
-
</tr>
|
314 |
-
<tr>
|
315 |
-
<th scope="row" valign="top"><label for="billing_state"><?php _e('Billing State', 'pmpro');?>:</label></th>
|
316 |
-
<td>
|
317 |
-
<?php if(in_array("billing_state", $read_only_fields) && $order_id > 0) { echo $order->billing_state; } else { ?>
|
318 |
-
<input id="billing_state" name="billing_state" type="text" size="50" value="<?php echo esc_attr($order->billing->state);?>" /></td>
|
319 |
-
<?php } ?>
|
320 |
-
</tr>
|
321 |
-
<tr>
|
322 |
-
<th scope="row" valign="top"><label for="billing_zip"><?php _e('Billing Postal Code', 'pmpro');?>:</label></th>
|
323 |
-
<td>
|
324 |
-
<?php if(in_array("billing_zip", $read_only_fields) && $order_id > 0) { echo $order->billing_zip; } else { ?>
|
325 |
-
<input id="billing_zip" name="billing_zip" type="text" size="50" value="<?php echo esc_attr($order->billing->zip);?>" /></td>
|
326 |
-
<?php } ?>
|
327 |
-
</tr>
|
328 |
-
<tr>
|
329 |
-
<th scope="row" valign="top"><label for="billing_country"><?php _e('Billing Country', 'pmpro');?>:</label></th>
|
330 |
-
<td>
|
331 |
-
<?php if(in_array("billing_country", $read_only_fields) && $order_id > 0) { echo $order->billing_country; } else { ?>
|
332 |
-
<input id="billing_country" name="billing_country" type="text" size="50" value="<?php echo esc_attr($order->billing->country);?>" />
|
333 |
-
<?php } ?>
|
334 |
-
</td>
|
335 |
-
</tr>
|
336 |
-
<tr>
|
337 |
-
<th scope="row" valign="top"><label for="billing_phone"><?php _e('Billing Phone', 'pmpro');?>:</label></th>
|
338 |
-
<td>
|
339 |
-
<?php if(in_array("billing_phone", $read_only_fields) && $order_id > 0) { echo $order->billing_phone; } else { ?>
|
340 |
-
<input id="billing_phone" name="billing_phone" type="text" size="50" value="<?php echo esc_attr($order->billing->phone);?>" />
|
341 |
-
<?php } ?>
|
342 |
-
</td>
|
343 |
-
</tr>
|
344 |
-
|
345 |
-
<tr>
|
346 |
-
<th scope="row" valign="top"><label for="subtotal"><?php _e('Sub Total', 'pmpro');?>:</label></th>
|
347 |
-
<td>
|
348 |
-
<?php if(in_array("subtotal", $read_only_fields) && $order_id > 0) { echo $order->subtotal; } else { ?>
|
349 |
-
<input id="subtotal" name="subtotal" type="text" size="10" value="<?php echo esc_attr($order->subtotal);?>" />
|
350 |
-
<?php } ?>
|
351 |
-
</td>
|
352 |
-
</tr>
|
353 |
-
<tr>
|
354 |
-
<th scope="row" valign="top"><label for="tax"><?php _e('Tax', 'pmpro');?>:</label></th>
|
355 |
-
<td>
|
356 |
-
<?php if(in_array("tax", $read_only_fields) && $order_id > 0) { echo $order->tax; } else { ?>
|
357 |
-
<input id="tax" name="tax" type="text" size="10" value="<?php echo esc_attr($order->tax);?>" />
|
358 |
-
<?php } ?>
|
359 |
-
</td>
|
360 |
-
</tr>
|
361 |
-
<tr>
|
362 |
-
<th scope="row" valign="top"><label for="couponamount"><?php _e('Coupon Amount', 'pmpro');?>:</label></th>
|
363 |
-
<td>
|
364 |
-
<?php if(in_array("couponamount", $read_only_fields) && $order_id > 0) { echo $order->couponamount; } else { ?>
|
365 |
-
<input id="couponamount" name="couponamount" type="text" size="10" value="<?php echo esc_attr($order->couponamount);?>" />
|
366 |
-
<?php } ?>
|
367 |
-
</td>
|
368 |
-
</tr>
|
369 |
-
<tr>
|
370 |
-
<th scope="row" valign="top"><label for="total"><?php _e('Total', 'pmpro');?>:</label></th>
|
371 |
-
<td>
|
372 |
-
<?php if(in_array("total", $read_only_fields) && $order_id > 0) { echo $order->total; } else { ?>
|
373 |
-
<input id="total" name="total" type="text" size="10" value="<?php echo esc_attr($order->total);?>" />
|
374 |
-
<?php } ?>
|
375 |
-
<small class="pmpro_lite"><?php _e('Should be subtotal + tax - couponamount.', 'pmpro');?></small>
|
376 |
-
</td>
|
377 |
-
</tr>
|
378 |
-
|
379 |
-
<tr>
|
380 |
-
<th scope="row" valign="top"><label for="payment_type"><?php _e('Payment Type', 'pmpro');?>:</label></th>
|
381 |
-
<td>
|
382 |
-
<?php if(in_array("payment_type", $read_only_fields) && $order_id > 0) { echo $order->payment_type; } else { ?>
|
383 |
-
<input id="payment_type" name="payment_type" type="text" size="50" value="<?php echo esc_attr($order->payment_type);?>" />
|
384 |
-
<?php } ?>
|
385 |
-
<small class="pmpro_lite"><?php _e('e.g. PayPal Express, PayPal Standard, Credit Card.', 'pmpro');?></small>
|
386 |
-
</td>
|
387 |
-
</tr>
|
388 |
-
<tr>
|
389 |
-
<th scope="row" valign="top"><label for="cardtype"><?php _e('Card Type', 'pmpro');?></label></th>
|
390 |
-
<td>
|
391 |
-
<?php if(in_array("cardtype", $read_only_fields) && $order_id > 0) { echo $order->cardtype; } else { ?>
|
392 |
-
<input id="cardtype" name="cardtype" type="text" size="50" value="<?php echo esc_attr($order->cardtype);?>" />
|
393 |
-
<?php } ?>
|
394 |
-
<small class="pmpro_lite"><?php _e('e.g. Visa, MasterCard, AMEX, etc', 'pmpro');?></small>
|
395 |
-
</td>
|
396 |
-
</tr>
|
397 |
-
<tr>
|
398 |
-
<th scope="row" valign="top"><label for="accountnumber"><?php _e('Account Number', 'pmpro');?>:</label></th>
|
399 |
-
<td>
|
400 |
-
<?php if(in_array("accountnumber", $read_only_fields) && $order_id > 0) { echo $order->accountnumber; } else { ?>
|
401 |
-
<input id="accountnumber" name="accountnumber" type="text" size="50" value="<?php echo esc_attr($order->accountnumber);?>" />
|
402 |
-
<?php } ?>
|
403 |
-
<small class="pmpro_lite"><?php _e('Obscure all but last 4 digits.', 'pmpro');?></small>
|
404 |
-
</td>
|
405 |
-
</tr>
|
406 |
-
<?php if(in_array("ExpirationDate", $read_only_fields) && $order_id > 0) { echo $order->ExpirationDate; } else { ?>
|
407 |
-
<tr>
|
408 |
-
<th scope="row" valign="top"><label for="expirationmonth"><?php _e('Expiration Month', 'pmpro');?>:</label></th>
|
409 |
-
<td>
|
410 |
-
<input id="expirationmonth" name="expirationmonth" type="text" size="10" value="<?php echo esc_attr($order->expirationmonth);?>" />
|
411 |
-
<small class="pmpro_lite">MM</small>
|
412 |
-
</td>
|
413 |
-
</tr>
|
414 |
-
<tr>
|
415 |
-
<th scope="row" valign="top"><label for="expirationyear"><?php _e('Expiration Year', 'pmpro');?>:</label></th>
|
416 |
-
<td>
|
417 |
-
<input id="expirationyear" name="expirationyear" type="text" size="10" value="<?php echo esc_attr($order->expirationyear);?>" />
|
418 |
-
<small class="pmpro_lite">YYYY</small>
|
419 |
-
</td>
|
420 |
-
</tr>
|
421 |
-
<?php } ?>
|
422 |
-
<tr>
|
423 |
-
<th scope="row" valign="top"><label for="status"><?php _e('Status', 'pmpro');?>:</label></th>
|
424 |
-
<td>
|
425 |
-
<?php if(in_array("status", $read_only_fields) && $order_id > 0) { echo $order->status; } else { ?>
|
426 |
-
<?php
|
427 |
-
$statuses = array();
|
428 |
-
$default_statuses = array("", "success", "cancelled", "review", "token", "refunded");
|
429 |
-
$used_statuses = $wpdb->get_col("SELECT DISTINCT(status) FROM $wpdb->pmpro_membership_orders");
|
430 |
-
$statuses = array_unique(array_merge($default_statuses, $used_statuses));
|
431 |
-
asort($statuses);
|
432 |
-
$statuses = apply_filters("pmpro_order_statuses", $statuses);
|
433 |
-
?>
|
434 |
-
<select id="status" name="status">
|
435 |
-
<?php foreach($statuses as $status) { ?>
|
436 |
-
<option value="<?php echo esc_attr($status);?>" <?php selected($order->status, $status);?>><?php echo $status;?></option>
|
437 |
-
<?php } ?>
|
438 |
-
</select>
|
439 |
-
<?php } ?>
|
440 |
-
</td>
|
441 |
-
</tr>
|
442 |
-
|
443 |
-
<tr>
|
444 |
-
<th scope="row" valign="top"><label for="gateway"><?php _e('Gateway', 'pmpro');?>:</label></th>
|
445 |
-
<td>
|
446 |
-
<?php if(in_array("gateway", $read_only_fields) && $order_id > 0) { echo $order->gateway; } else { ?>
|
447 |
-
<select id="gateway" name="gateway" onchange="pmpro_changeGateway(jQuery(this).val());">
|
448 |
-
<option value="" <?php if(empty($order->gateway)) { ?>selected="selected"<?php } ?>><?php _e('Testing Only', 'pmpro');?></option>
|
449 |
-
<option value="check" <?php if($order->gateway == "check") { ?>selected="selected"<?php } ?>><?php _e('Pay by Check', 'pmpro');?></option>
|
450 |
-
<option value="stripe" <?php if($order->gateway == "stripe") { ?>selected="selected"<?php } ?>>Stripe</option>
|
451 |
-
<option value="paypalstandard" <?php if($order->gateway == "paypalstandard") { ?>selected="selected"<?php } ?>>PayPal Standard</option>
|
452 |
-
<option value="paypalexpress" <?php if($order->gateway == "paypalexpress") { ?>selected="selected"<?php } ?>>PayPal Express</option>
|
453 |
-
<option value="paypal" <?php if($order->gateway == "paypal") { ?>selected="selected"<?php } ?>>PayPal Website Payments Pro</option>
|
454 |
-
<option value="payflowpro" <?php if($order->gateway == "payflowpro") { ?>selected="selected"<?php } ?>>PayPal Payflow Pro</option>
|
455 |
-
<option value="authorizenet" <?php if($order->gateway == "authorizenet") { ?>selected="selected"<?php } ?>>Authorize.net</option>
|
456 |
-
</select>
|
457 |
-
<?php } ?>
|
458 |
-
</td>
|
459 |
-
</tr>
|
460 |
-
<tr>
|
461 |
-
<th scope="row" valign="top"><label for="gateway_environment"><?php _e('Gateway Environment', 'pmpro');?>:</label></th>
|
462 |
-
<td>
|
463 |
-
<?php if(in_array("gateway_environment", $read_only_fields) && $order_id > 0) { echo $order->gateway_environment; } else { ?>
|
464 |
-
<select name="gateway_environment">
|
465 |
-
<option value="sandbox" <?php if($order->gateway_environment == "sandbox") { ?>selected="selected"<?php } ?>><?php _e('Sandbox/Testing', 'pmpro');?></option>
|
466 |
-
<option value="live" <?php if($order->gateway_environment == "live") { ?>selected="selected"<?php } ?>><?php _e('Live/Production', 'pmpro');?></option>
|
467 |
-
</select>
|
468 |
-
<?php } ?>
|
469 |
-
</td>
|
470 |
-
</tr>
|
471 |
-
|
472 |
-
<tr>
|
473 |
-
<th scope="row" valign="top"><label for="payment_transaction_id"><?php _e('Payment Transaction ID', 'pmpro');?>:</label></th>
|
474 |
-
<td>
|
475 |
-
<?php if(in_array("payment_transaction_id", $read_only_fields) && $order_id > 0) { echo $order->payment_transaction_id; } else { ?>
|
476 |
-
<input id="payment_transaction_id" name="payment_transaction_id" type="text" size="50" value="<?php echo esc_attr($order->payment_transaction_id);?>" />
|
477 |
-
<?php } ?>
|
478 |
-
<small class="pmpro_lite"><?php _e('Generated by the gateway. Useful to cross reference orders.', 'pmpro');?></small>
|
479 |
-
</td>
|
480 |
-
</tr>
|
481 |
-
<tr>
|
482 |
-
<th scope="row" valign="top"><label for="subscription_transaction_id"><?php _e('Subscription Transaction ID', 'pmpro');?>:</label></th>
|
483 |
-
<td>
|
484 |
-
<?php if(in_array("subscription_transaction_id", $read_only_fields) && $order_id > 0) { echo $order->subscription_transaction_id; } else { ?>
|
485 |
-
<input id="subscription_transaction_id" name="subscription_transaction_id" type="text" size="50" value="<?php echo esc_attr($order->subscription_transaction_id);?>" />
|
486 |
-
<?php } ?>
|
487 |
-
<small class="pmpro_lite"><?php _e('Generated by the gateway. Useful to cross reference subscriptions.', 'pmpro');?></small>
|
488 |
-
</td>
|
489 |
-
</tr>
|
490 |
-
|
491 |
-
<tr>
|
492 |
-
<th scope="row" valign="top"><label for="ts_month"><?php _e('Date', 'pmpro');?>:</label></th>
|
493 |
-
<td>
|
494 |
-
<?php if(in_array("timestamp", $read_only_fields) && $order_id > 0) { echo date(option("date_format"), $order->timestamp); } else { ?>
|
495 |
-
<?php
|
496 |
-
//setup date vars
|
497 |
-
if(!empty($order->timestamp))
|
498 |
-
$timestamp = $order->timestamp;
|
499 |
-
else
|
500 |
-
$timestamp = current_time('timestamp');
|
501 |
-
|
502 |
-
$year = date("Y", $timestamp);
|
503 |
-
$month = date("n", $timestamp);
|
504 |
-
$day = date("j", $timestamp);
|
505 |
-
?>
|
506 |
-
<select id="ts_month" name="ts_month">
|
507 |
-
<?php
|
508 |
-
for($i = 1; $i < 13; $i++)
|
509 |
-
{
|
510 |
-
?>
|
511 |
-
<option value="<?php echo $i?>" <?php if($i == $month) { ?>selected="selected"<?php } ?>><?php echo date("M", strtotime($i . "/1/" . $year, current_time("timestamp")))?></option>
|
512 |
-
<?php
|
513 |
-
}
|
514 |
-
?>
|
515 |
-
</select>
|
516 |
-
<input name="ts_day" type="text" size="2" value="<?php echo $day?>" />
|
517 |
-
<input name="ts_year" type="text" size="4" value="<?php echo $year?>" />
|
518 |
-
<?php } ?>
|
519 |
-
</td>
|
520 |
-
</tr>
|
521 |
-
|
522 |
-
<?php
|
523 |
-
$affiliates = apply_filters("pmpro_orders_show_affiliate_ids", false);
|
524 |
-
if(!empty($affiliates)) {
|
525 |
-
?>
|
526 |
-
<tr>
|
527 |
-
<th scope="row" valign="top"><label for="affiliate_id"><?php _e('Affiliate ID', 'pmpro');?>Affiliate ID:</label></th>
|
528 |
-
<td>
|
529 |
-
<?php if(in_array("affiliate_id", $read_only_fields) && $order_id > 0) { echo $order->affiliate_id; } else { ?>
|
530 |
-
<input id="affiliate_id" name="affiliate_id" type="text" size="50" value="<?php echo esc_attr($order->affiliate_id);?>" />
|
531 |
-
<?php } ?>
|
532 |
-
</td>
|
533 |
-
</tr>
|
534 |
-
<tr>
|
535 |
-
<th scope="row" valign="top"><label for="affiliate_subid"><?php _e('Affiliate SubID', 'pmpro');?>Affiliate SubID:</label></th>
|
536 |
-
<td>
|
537 |
-
<?php if(in_array("affiliate_subid", $read_only_fields) && $order_id > 0) { echo $order->affiliate_subid; } else { ?>
|
538 |
-
<input id="affiliate_subid" name="affiliate_subid" type="text" size="50" value="<?php echo esc_attr($order->affiliate_subid);?>" />
|
539 |
-
<?php } ?>
|
540 |
-
</td>
|
541 |
-
</tr>
|
542 |
-
<?php } ?>
|
543 |
-
|
544 |
-
<tr>
|
545 |
-
<th scope="row" valign="top"><label for="notes"><?php _e('Notes', 'pmpro');?>:</label></th>
|
546 |
-
<td>
|
547 |
-
<?php if(in_array("notes", $read_only_fields) && $order_id > 0) { echo $order->notes; } else { ?>
|
548 |
-
<textarea id="notes" name="notes" rows="5" cols="80"><?php echo esc_textarea($order->notes);?></textarea>
|
549 |
-
<?php } ?>
|
550 |
-
</td>
|
551 |
-
</tr>
|
552 |
-
|
553 |
-
<?php do_action("pmpro_after_order_settings", $order); ?>
|
554 |
-
|
555 |
-
</tbody>
|
556 |
-
</table>
|
557 |
-
|
558 |
-
<p class="submit topborder">
|
559 |
-
<input name="order" type="hidden" value="<?php if(!empty($order->id)) echo $order->id; else echo $order_id;?>" />
|
560 |
-
<input name="save" type="submit" class="button-primary" value="<?php _e('Save Order', 'pmpro');?>" />
|
561 |
-
<input name="cancel" type="button" class="cancel button-secondary" value="<?php _e('Cancel', 'pmpro');?>" onclick="location.href='<?php echo get_admin_url(NULL, '/admin.php?page=pmpro-orders')?>';" />
|
562 |
-
</p>
|
563 |
-
|
564 |
-
</form>
|
565 |
-
|
566 |
-
<?php } else { ?>
|
567 |
-
|
568 |
-
<form id="posts-filter" method="get" action="">
|
569 |
-
<h2>
|
570 |
-
<?php _e('Orders', 'pmpro');?>
|
571 |
-
<a href="admin.php?page=pmpro-orders&order=-1" class="add-new-h2">+ <?php _e('Add New Order', 'pmpro');?></a>
|
572 |
-
|
573 |
-
<?php
|
574 |
-
//build the export URL
|
575 |
-
$export_url = admin_url('admin-ajax.php') . "?action=orders_csv";
|
576 |
-
$url_params = array(
|
577 |
-
"filter"=>$filter,
|
578 |
-
"s"=>$s,
|
579 |
-
"l"=>$l,
|
580 |
-
"start-month"=>$start_month,
|
581 |
-
"start-day"=>$start_day,
|
582 |
-
"start-year"=>$start_year,
|
583 |
-
"end-month"=>$end_month,
|
584 |
-
"end-day"=>$end_day,
|
585 |
-
"end-year"=>$end_year,
|
586 |
-
"predefined-date"=>$predefined_date,
|
587 |
-
"status"=>$status
|
588 |
-
);
|
589 |
-
$export_url = add_query_arg($url_params, $export_url);
|
590 |
-
?>
|
591 |
-
<a target="_blank" href="<?php echo $export_url;?>" class="add-new-h2"><?php _e('Export to CSV', 'pmpro');?></a>
|
592 |
-
</h2>
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
<?php if(!empty($pmpro_msg)) { ?>
|
597 |
-
<div id="message" class="<?php if($pmpro_msgt == "success") echo "updated fade"; else echo "error"; ?>"><p><?php echo $pmpro_msg?></p></div>
|
598 |
-
<?php } ?>
|
599 |
-
|
600 |
-
|
601 |
-
<ul class="subsubsub">
|
602 |
-
<li>
|
603 |
-
<?php _ex('Show', 'Dropdown label, e.g. Show Daily Orders for January', 'pmpro')?>
|
604 |
-
<select id="filter" name="filter">
|
605 |
-
<option value="all" <?php selected($filter, "all");?>><?php _e('All', 'pmpro');?></option>
|
606 |
-
<option value="within-a-date-range" <?php selected($filter, "within-a-date-range");?>><?php _e('Within a Date Range', 'pmpro');?></option>
|
607 |
-
<option value="predefined-date-range" <?php selected($filter, "predefined-date-range");?>><?php _e('Predefined Date Range', 'pmpro');?></option>
|
608 |
-
<option value="within-a-level" <?php selected($filter, "within-a-level");?>><?php _e('Within a Level', 'pmpro');?></option>
|
609 |
-
<option value="within-a-status" <?php selected($filter, "within-a-status");?>><?php _e('Within a Status', 'pmpro');?></option>
|
610 |
-
</select>
|
611 |
-
|
612 |
-
<span id="from"><?php _ex('From', 'Dropdown label', 'pmpro')?></span>
|
613 |
-
|
614 |
-
<select id="start-month" name="start-month">
|
615 |
-
<?php for($i = 1; $i < 13; $i++) { ?>
|
616 |
-
<option value="<?php echo $i;?>" <?php selected($start_month, $i);?>><?php echo date("F", mktime(0, 0, 0, $i));?></option>
|
617 |
-
<?php } ?>
|
618 |
-
</select>
|
619 |
-
|
620 |
-
<input id='start-day' name="start-day" type="text" size="2" value="<?php echo $start_day?>" />
|
621 |
-
<input id='start-year' name="start-year" type="text" size="4" value="<?php echo $start_year?>" />
|
622 |
-
|
623 |
-
|
624 |
-
<span id="to"><?php _ex('To', 'Dropdown label', 'pmpro')?></span>
|
625 |
-
|
626 |
-
<select id="end-month" name="end-month">
|
627 |
-
<?php for($i = 1; $i < 13; $i++) { ?>
|
628 |
-
<option value="<?php echo $i;?>" <?php selected($end_month, $i);?>><?php echo date("F", mktime(0, 0, 0, $i));?></option>
|
629 |
-
<?php } ?>
|
630 |
-
</select>
|
631 |
-
|
632 |
-
|
633 |
-
<input id='end-day' name="end-day" type="text" size="2" value="<?php echo $end_day?>" />
|
634 |
-
<input id='end-year' name="end-year" type="text" size="4" value="<?php echo $end_year?>" />
|
635 |
-
|
636 |
-
<span id="filterby"><?php _ex('filter by ', 'Dropdown label', 'pmpro')?></span>
|
637 |
-
|
638 |
-
<select id="predefined-date" name="predefined-date">
|
639 |
-
|
640 |
-
<option value="<?php echo "This Month";?>" <?php selected($predefined_date, "This Month");?>><?php echo "This Month";?></option>
|
641 |
-
<option value="<?php echo "Last Month";?>" <?php selected($predefined_date, "Last Month");?>><?php echo "Last Month";?></option>
|
642 |
-
<option value="<?php echo "This Year";?>" <?php selected($predefined_date, "This Year");?>><?php echo "This Year";?></option>
|
643 |
-
<option value="<?php echo "Last Year";?>" <?php selected($predefined_date, "Last Year");?>><?php echo "Last Year";?></option>
|
644 |
-
|
645 |
-
</select>
|
646 |
-
|
647 |
-
<?php
|
648 |
-
//Note: only orders belonging to current levels can be filtered. There is no option for orders belonging to deleted levels
|
649 |
-
$levels = pmpro_getAllLevels();
|
650 |
-
|
651 |
-
?>
|
652 |
-
<select id="l" name="l">
|
653 |
-
<?php foreach($levels as $level) { ?>
|
654 |
-
<option value="<?php echo $level->id;?>" <?php selected($l, $level->id);?>><?php echo $level->name;?></option>
|
655 |
-
<?php } ?>
|
656 |
-
|
657 |
-
</select>
|
658 |
-
|
659 |
-
<?php
|
660 |
-
$statuses = array();
|
661 |
-
$default_statuses = array("", "success", "cancelled", "review", "token", "refunded");
|
662 |
-
$used_statuses = $wpdb->get_col("SELECT DISTINCT(status) FROM $wpdb->pmpro_membership_orders");
|
663 |
-
$statuses = array_unique(array_merge($default_statuses, $used_statuses));
|
664 |
-
asort($statuses);
|
665 |
-
$statuses = apply_filters("pmpro_order_statuses", $statuses);
|
666 |
-
?>
|
667 |
-
<select id="status" name="status">
|
668 |
-
<?php foreach($statuses as $the_status) { ?>
|
669 |
-
<option value="<?php echo esc_attr($the_status);?>" <?php selected($the_status, $status);?>><?php echo $the_status;?></option>
|
670 |
-
<?php } ?>
|
671 |
-
</select>
|
672 |
-
|
673 |
-
|
674 |
-
<input id="submit" type="submit" value="<?php _ex('Filter', 'Submit button value.', 'pmpro');?>" />
|
675 |
-
</li>
|
676 |
-
</ul>
|
677 |
-
|
678 |
-
<script>
|
679 |
-
//update month/year when period dropdown is changed
|
680 |
-
jQuery(document).ready(function() {
|
681 |
-
jQuery('#filter').change(function() {
|
682 |
-
pmpro_ShowMonthOrYear();
|
683 |
-
});
|
684 |
-
});
|
685 |
-
|
686 |
-
function pmpro_ShowMonthOrYear()
|
687 |
-
{
|
688 |
-
var filter = jQuery('#filter').val();
|
689 |
-
if(filter == 'all')
|
690 |
-
{
|
691 |
-
jQuery('#start-month').hide();
|
692 |
-
jQuery('#start-day').hide();
|
693 |
-
jQuery('#start-year').hide();
|
694 |
-
jQuery('#end-month').hide();
|
695 |
-
jQuery('#end-day').hide();
|
696 |
-
jQuery('#end-year').hide();
|
697 |
-
jQuery('#predefined-date').hide();
|
698 |
-
jQuery('#status').hide();
|
699 |
-
jQuery('#l').hide();
|
700 |
-
jQuery('#from').hide();
|
701 |
-
jQuery('#to').hide();
|
702 |
-
jQuery('#submit').show();
|
703 |
-
jQuery('#filterby').hide();
|
704 |
-
}
|
705 |
-
else if(filter == 'within-a-date-range')
|
706 |
-
{
|
707 |
-
jQuery('#start-month').show();
|
708 |
-
jQuery('#start-day').show();
|
709 |
-
jQuery('#start-year').show();
|
710 |
-
jQuery('#end-month').show();
|
711 |
-
jQuery('#end-day').show();
|
712 |
-
jQuery('#end-year').show();
|
713 |
-
jQuery('#predefined-date').hide();
|
714 |
-
jQuery('#status').hide();
|
715 |
-
jQuery('#l').hide();
|
716 |
-
jQuery('#submit').show();
|
717 |
-
jQuery('#from').show();
|
718 |
-
jQuery('#to').show();
|
719 |
-
jQuery('#filterby').hide();
|
720 |
-
}
|
721 |
-
else if(filter == 'predefined-date-range')
|
722 |
-
{
|
723 |
-
jQuery('#start-month').hide();
|
724 |
-
jQuery('#start-day').hide();
|
725 |
-
jQuery('#start-year').hide();
|
726 |
-
jQuery('#end-month').hide();
|
727 |
-
jQuery('#end-day').hide();
|
728 |
-
jQuery('#end-year').hide();
|
729 |
-
jQuery('#predefined-date').show();
|
730 |
-
jQuery('#status').hide();
|
731 |
-
jQuery('#l').hide();
|
732 |
-
jQuery('#submit').show();
|
733 |
-
jQuery('#from').hide();
|
734 |
-
jQuery('#to').hide();
|
735 |
-
jQuery('#filterby').show();
|
736 |
-
}
|
737 |
-
else if(filter == 'within-a-level')
|
738 |
-
{
|
739 |
-
jQuery('#start-month').hide();
|
740 |
-
jQuery('#start-day').hide();
|
741 |
-
jQuery('#start-year').hide();
|
742 |
-
jQuery('#end-month').hide();
|
743 |
-
jQuery('#end-day').hide();
|
744 |
-
jQuery('#end-year').hide();
|
745 |
-
jQuery('#predefined-date').hide();
|
746 |
-
jQuery('#status').hide();
|
747 |
-
jQuery('#l').show();
|
748 |
-
jQuery('#submit').show();
|
749 |
-
jQuery('#from').hide();
|
750 |
-
jQuery('#to').hide();
|
751 |
-
jQuery('#filterby').show();
|
752 |
-
}
|
753 |
-
else if(filter == 'within-a-status')
|
754 |
-
{
|
755 |
-
jQuery('#start-month').hide();
|
756 |
-
jQuery('#start-day').hide();
|
757 |
-
jQuery('#start-year').hide();
|
758 |
-
jQuery('#end-month').hide();
|
759 |
-
jQuery('#end-day').hide();
|
760 |
-
jQuery('#end-year').hide();
|
761 |
-
jQuery('#predefined-date').hide();
|
762 |
-
jQuery('#status').show();
|
763 |
-
jQuery('#l').hide();
|
764 |
-
jQuery('#submit').show();
|
765 |
-
jQuery('#from').hide();
|
766 |
-
jQuery('#to').hide();
|
767 |
-
jQuery('#filterby').show();
|
768 |
-
}
|
769 |
-
}
|
770 |
-
|
771 |
-
pmpro_ShowMonthOrYear();
|
772 |
-
|
773 |
-
|
774 |
-
</script>
|
775 |
-
|
776 |
-
<p class="search-box">
|
777 |
-
<label class="hidden" for="post-search-input"><?php _e('Search Orders', 'pmpro');?>:</label>
|
778 |
-
<input type="hidden" name="page" value="pmpro-orders" />
|
779 |
-
<input id="post-search-input" type="text" value="<?php echo $s?>" name="s"/>
|
780 |
-
<input class="button" type="submit" value="<?php _e('Search Orders', 'pmpro');?>"/>
|
781 |
-
</p>
|
782 |
-
|
783 |
-
<?php
|
784 |
-
//some vars for the search
|
785 |
-
if(isset($_REQUEST['pn']))
|
786 |
-
$pn = $_REQUEST['pn'];
|
787 |
-
else
|
788 |
-
$pn = 1;
|
789 |
-
|
790 |
-
if(isset($_REQUEST['limit']))
|
791 |
-
$limit = $_REQUEST['limit'];
|
792 |
-
else
|
793 |
-
$limit = 15;
|
794 |
-
|
795 |
-
$end = $pn * $limit;
|
796 |
-
$start = $end - $limit;
|
797 |
-
|
798 |
-
//filters
|
799 |
-
if($filter == "all" || !$filter)
|
800 |
-
$condition = "1=1";
|
801 |
-
elseif($filter == "within-a-date-range")
|
802 |
-
{
|
803 |
-
$start_date = $start_year."-".$start_month."-".$start_day;
|
804 |
-
$end_date = $end_year."-".$end_month."-".$end_day;
|
805 |
-
|
806 |
-
//add times to dates
|
807 |
-
$start_date = $start_date . " 00:00:00";
|
808 |
-
$end_date = $end_date . " 23:59:59";
|
809 |
-
|
810 |
-
$condition = "timestamp BETWEEN '".$start_date."' AND '".$end_date."'";
|
811 |
-
}
|
812 |
-
elseif($filter == "predefined-date-range")
|
813 |
-
{
|
814 |
-
if($predefined_date == "Last Month")
|
815 |
-
{
|
816 |
-
$start_date = date("Y-m-d", strtotime("first day of last month", current_time("timestamp")));
|
817 |
-
$end_date = date("Y-m-d", strtotime("last day of last month", current_time("timestamp")));
|
818 |
-
}
|
819 |
-
elseif($predefined_date == "This Month")
|
820 |
-
{
|
821 |
-
$start_date = date("Y-m-d", strtotime("first day of this month", current_time("timestamp")));
|
822 |
-
$end_date = date("Y-m-d", strtotime("last day of this month", current_time("timestamp")));
|
823 |
-
}
|
824 |
-
elseif($predefined_date == "This Year")
|
825 |
-
{
|
826 |
-
$year = date('Y');
|
827 |
-
$start_date = date("Y-m-d", strtotime("first day of January $year", current_time("timestamp")));
|
828 |
-
$end_date = date("Y-m-d", strtotime("last day of December $year", current_time("timestamp")));
|
829 |
-
}
|
830 |
-
|
831 |
-
elseif($predefined_date == "Last Year")
|
832 |
-
{
|
833 |
-
$year = date('Y') - 1;
|
834 |
-
$start_date = date("Y-m-d", strtotime("first day of January $year", current_time("timestamp")));
|
835 |
-
$end_date = date("Y-m-d", strtotime("last day of December $year", current_time("timestamp")));
|
836 |
-
}
|
837 |
-
|
838 |
-
//add times to dates
|
839 |
-
$start_date = $start_date . " 00:00:00";
|
840 |
-
$end_date = $end_date . " 23:59:59";
|
841 |
-
|
842 |
-
$condition = "timestamp BETWEEN '".$start_date."' AND '".$end_date."'";
|
843 |
-
}
|
844 |
-
elseif($filter == "within-a-level")
|
845 |
-
{
|
846 |
-
$condition = "membership_id = $l";
|
847 |
-
}
|
848 |
-
elseif($filter == "within-a-status")
|
849 |
-
{
|
850 |
-
$condition = "status = '$status' ";
|
851 |
-
}
|
852 |
-
|
853 |
-
//string search
|
854 |
-
if($s)
|
855 |
-
{
|
856 |
-
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS o.id FROM $wpdb->pmpro_membership_orders o LEFT JOIN $wpdb->users u ON o.user_id = u.ID LEFT JOIN $wpdb->pmpro_membership_levels l ON o.membership_id = l.id ";
|
857 |
-
|
858 |
-
$join_with_usermeta = apply_filters("pmpro_orders_search_usermeta", false);
|
859 |
-
if($join_with_usermeta)
|
860 |
-
$sqlQuery .= "LEFT JOIN $wpdb->usermeta um ON o.user_id = um.user_id ";
|
861 |
-
|
862 |
-
$sqlQuery .= "WHERE (1=2 ";
|
863 |
-
|
864 |
-
$fields = array("o.id", "o.code", "o.billing_name", "o.billing_street", "o.billing_city", "o.billing_state", "o.billing_zip", "o.billing_phone", "o.payment_type", "o.cardtype", "o.accountnumber", "o.status", "o.gateway", "o.gateway_environment", "o.payment_transaction_id", "o.subscription_transaction_id", "u.user_login", "u.user_email", "u.display_name", "l.name");
|
865 |
-
|
866 |
-
if($join_with_usermeta)
|
867 |
-
$fields[] = "um.meta_value";
|
868 |
-
|
869 |
-
$fields = apply_filters("pmpro_orders_search_fields", $fields);
|
870 |
-
|
871 |
-
foreach($fields as $field)
|
872 |
-
$sqlQuery .= " OR " . $field . " LIKE '%" . esc_sql($s) . "%' ";
|
873 |
-
$sqlQuery .= ") ";
|
874 |
-
|
875 |
-
$sqlQuery .= "AND " . $condition . " ";
|
876 |
-
|
877 |
-
$sqlQuery .= "GROUP BY o.id ORDER BY o.id DESC, o.timestamp DESC ";
|
878 |
-
}
|
879 |
-
else
|
880 |
-
{
|
881 |
-
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS id FROM $wpdb->pmpro_membership_orders WHERE ".$condition." ORDER BY id DESC, timestamp DESC ";
|
882 |
-
}
|
883 |
-
|
884 |
-
$sqlQuery .= "LIMIT $start, $limit";
|
885 |
-
|
886 |
-
$order_ids = $wpdb->get_col($sqlQuery);
|
887 |
-
|
888 |
-
$totalrows = $wpdb->get_var("SELECT FOUND_ROWS() as found_rows");
|
889 |
-
|
890 |
-
if($order_ids)
|
891 |
-
{
|
892 |
-
?>
|
893 |
-
<p class="clear"><?php printf(__("%d orders found.", "pmpro"), $totalrows);?></span></p>
|
894 |
-
<?php
|
895 |
-
}
|
896 |
-
?>
|
897 |
-
<table class="widefat">
|
898 |
-
<thead>
|
899 |
-
<tr class="thead">
|
900 |
-
<th><?php _e('ID', 'pmpro');?></th>
|
901 |
-
<th><?php _e('Code', 'pmpro');?></th>
|
902 |
-
<th><?php _e('User', 'pmpro');?></th>
|
903 |
-
<?php do_action("pmpro_orders_extra_cols_header", $order_ids);?>
|
904 |
-
<th><?php _e('Membership Level', 'pmpro');?></th>
|
905 |
-
<th><?php _e('Total', 'pmpro');?></th>
|
906 |
-
<th><?php _e('Payment', 'pmpro');?></th>
|
907 |
-
<th><?php _e('Gateway', 'pmpro');?></th>
|
908 |
-
<th><?php _e('Transaction IDs', 'pmpro');?></th>
|
909 |
-
<th><?php _e('Status', 'pmpro');?></th>
|
910 |
-
<th><?php _e('Date', 'pmpro');?></th>
|
911 |
-
<th></th>
|
912 |
-
<th></th>
|
913 |
-
<th></th>
|
914 |
-
</tr>
|
915 |
-
</thead>
|
916 |
-
<tbody id="orders" class="list:order orders-list">
|
917 |
-
<?php
|
918 |
-
$count = 0;
|
919 |
-
foreach($order_ids as $order_id)
|
920 |
-
{
|
921 |
-
$order = new MemberOrder();
|
922 |
-
$order->nogateway = true;
|
923 |
-
$order->getMemberOrderByID($order_id);
|
924 |
-
?>
|
925 |
-
<tr <?php if($count++ % 2 == 0) { ?>class="alternate"<?php } ?>>
|
926 |
-
<td><a href="admin.php?page=pmpro-orders&order=<?php echo $order->id?>"><?php echo $order->id;?></a></td>
|
927 |
-
<td><a href="admin.php?page=pmpro-orders&order=<?php echo $order->id?>"><?php echo $order->code;?></a></td>
|
928 |
-
<td>
|
929 |
-
<?php $order->getUser(); ?>
|
930 |
-
<?php if(!empty($order->user)) { ?>
|
931 |
-
<a href="user-edit.php?user_id=<?php echo $order->user->ID?>"><?php echo $order->user->user_login?></a>
|
932 |
-
<?php } else { ?>
|
933 |
-
[<?php _e('deleted', 'pmpro');?>]
|
934 |
-
<?php } ?>
|
935 |
-
</td>
|
936 |
-
<?php do_action("pmpro_orders_extra_cols_body", $order);?>
|
937 |
-
<td><?php echo $order->membership_id;?></td>
|
938 |
-
<td><?php echo $pmpro_currency_symbol . $order->total;?></td>
|
939 |
-
<td>
|
940 |
-
<?php if(!empty($order->payment_type)) echo $order->payment_type . "<br />";?>
|
941 |
-
<?php if(!empty($order->accountnumber)) { ?>
|
942 |
-
<?php echo $order->cardtype;?>: x<?php echo last4($order->accountnumber);?><br />
|
943 |
-
<?php } ?>
|
944 |
-
<?php if(!empty($order->billing->street)) { ?>
|
945 |
-
<?php echo $order->billing->street; ?><br />
|
946 |
-
<?php if( $order->billing->city && $order->billing->state) { ?>
|
947 |
-
<?php echo $order->billing->city?>, <?php echo $order->billing->state?> <?php echo $order->billing->zip?> <?php if(!empty( $order->billing->country)) echo $order->billing->country?><br />
|
948 |
-
<?php } ?>
|
949 |
-
<?php } ?>
|
950 |
-
<?php if(!empty($order->billing->phone)) echo formatPhone($order->billing->phone);?>
|
951 |
-
</td>
|
952 |
-
<td><?php echo $order->gateway;?><?php if($order->gateway_environment == "test") echo "(test)";?></td>
|
953 |
-
<td>
|
954 |
-
<?php _e('Payment', 'pmpro');?>: <?php if(!empty($order->payment_transaction_id)) echo $order->payment_transaction_id; else echo "N/A";?>
|
955 |
-
<br />
|
956 |
-
<?php _e('Subscription', 'pmpro');?>: <?php if(!empty($order->subscription_transaction_id)) echo $order->subscription_transaction_id; else echo "N/A";?>
|
957 |
-
</td>
|
958 |
-
<td><?php echo $order->status;?></td>
|
959 |
-
<td><?php echo date(get_option('date_format'), $order->timestamp);?></td>
|
960 |
-
<td align="center">
|
961 |
-
<a href="admin.php?page=pmpro-orders&order=<?php echo $order->id;?>"><?php _e('edit', 'pmpro');?></a>
|
962 |
-
</td>
|
963 |
-
<td align="center">
|
964 |
-
<a href="admin.php?page=pmpro-orders&order=-1©=<?php echo $order->id;?>"><?php _e('copy', 'pmpro');?></a>
|
965 |
-
</td>
|
966 |
-
<td align="center">
|
967 |
-
<a href="javascript:askfirst('<?php printf(__("Deleting orders is permanent and can affect active users. Are you sure you want to delete order %s?", "pmpro"), str_replace("'", "", $order->code));?>', 'admin.php?page=pmpro-orders&delete=<?php echo $order->id;?>'); void(0);"><?php _e('delete', 'pmpro');?></a>
|
968 |
-
</td>
|
969 |
-
</tr>
|
970 |
-
<?php
|
971 |
-
}
|
972 |
-
|
973 |
-
if(!$order_ids)
|
974 |
-
{
|
975 |
-
?>
|
976 |
-
<tr>
|
977 |
-
<td colspan="9"><p><?php _e('No orders found.', 'pmpro');?></p></td>
|
978 |
-
</tr>
|
979 |
-
<?php
|
980 |
-
}
|
981 |
-
?>
|
982 |
-
</tbody>
|
983 |
-
</table>
|
984 |
-
</form>
|
985 |
-
|
986 |
-
<?php
|
987 |
-
//add normal args
|
988 |
-
$pagination_url = add_query_arg($url_params, get_admin_url(NULL, "/admin.php?page=pmpro-orders"));
|
989 |
-
echo pmpro_getPaginationString($pn, $totalrows, $limit, 1, $pagination_url, "&limit=$limit&pn=");
|
990 |
-
?>
|
991 |
-
|
992 |
-
<?php } ?>
|
993 |
-
|
994 |
-
<?php
|
995 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
996 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/pagesettings.php
CHANGED
@@ -1,15 +1,9 @@
|
|
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 |
-
{
|
5 |
-
die(__("You do not have permissions to perform this action.", "pmpro"));
|
6 |
-
}
|
7 |
-
|
8 |
global $wpdb, $msg, $msgt;
|
9 |
-
|
10 |
//get/set settings
|
11 |
global $pmpro_pages;
|
12 |
-
if(
|
13 |
{
|
14 |
//page ids
|
15 |
pmpro_setOption("account_page_id");
|
@@ -27,15 +21,15 @@
|
|
27 |
$pmpro_pages["checkout"] = pmpro_getOption("checkout_page_id");
|
28 |
$pmpro_pages["confirmation"] = pmpro_getOption("confirmation_page_id");
|
29 |
$pmpro_pages["invoice"] = pmpro_getOption("invoice_page_id");
|
30 |
-
$pmpro_pages["levels"] = pmpro_getOption("levels_page_id");
|
31 |
-
|
32 |
-
//assume success
|
33 |
-
$msg = true;
|
34 |
$msgt = "Your page settings have been updated.";
|
35 |
}
|
36 |
|
37 |
//are we generating pages?
|
38 |
-
if(
|
39 |
{
|
40 |
global $pmpro_pages;
|
41 |
|
@@ -46,50 +40,15 @@
|
|
46 |
{
|
47 |
if(!$pmpro_page_id)
|
48 |
{
|
49 |
-
switch ($pmpro_page_name) {
|
50 |
-
case 'account':
|
51 |
-
$pmpro_page_title = __( 'Membership Account', 'pmpro' );
|
52 |
-
break;
|
53 |
-
case 'billing':
|
54 |
-
$pmpro_page_title = __( 'Membership Billing', 'pmpro' );
|
55 |
-
break;
|
56 |
-
case 'cancel':
|
57 |
-
$pmpro_page_title = __( 'Membership Cancel', 'pmpro' );
|
58 |
-
break;
|
59 |
-
case 'checkout':
|
60 |
-
$pmpro_page_title = __( 'Membership Checkout', 'pmpro' );
|
61 |
-
break;
|
62 |
-
case 'confirmation':
|
63 |
-
$pmpro_page_title = __( 'Membership Confirmation', 'pmpro' );
|
64 |
-
break;
|
65 |
-
case 'invoice':
|
66 |
-
$pmpro_page_title = __( 'Membership Invoice', 'pmpro' );
|
67 |
-
break;
|
68 |
-
case 'levels':
|
69 |
-
$pmpro_page_title = __( 'Membership Levels', 'pmpro' );
|
70 |
-
break;
|
71 |
-
|
72 |
-
default:
|
73 |
-
$pmpro_page_title = sprintf( __( 'Membership %s', 'Page title template', 'pmpro' ), ucwords($pmpro_page_name) );
|
74 |
-
break;
|
75 |
-
}
|
76 |
-
|
77 |
//no id set. create an array to store the page info
|
78 |
$insert = array(
|
79 |
-
'post_title' => $
|
80 |
'post_status' => 'publish',
|
81 |
'post_type' => 'page',
|
82 |
'post_content' => '[pmpro_' . $pmpro_page_name . ']',
|
83 |
'comment_status' => 'closed',
|
84 |
'ping_status' => 'closed'
|
85 |
);
|
86 |
-
|
87 |
-
//make non-account pages a subpage of account
|
88 |
-
if($pmpro_page_name != "account")
|
89 |
-
{
|
90 |
-
$insert['post_parent'] = $pmpro_pages['account'];
|
91 |
-
}
|
92 |
-
|
93 |
//create the page
|
94 |
$pmpro_pages[$pmpro_page_name] = wp_insert_post( $insert );
|
95 |
|
@@ -101,35 +60,35 @@
|
|
101 |
|
102 |
//update the option too
|
103 |
pmpro_setOption($pmpro_page_name . "_page_id", $pmpro_pages[$pmpro_page_name]);
|
104 |
-
$pages_created[] = $pmpro_pages[$pmpro_page_name];
|
105 |
}
|
106 |
}
|
107 |
|
108 |
-
if(
|
109 |
{
|
110 |
$msg = true;
|
111 |
-
$msgt =
|
112 |
}
|
113 |
-
}
|
114 |
-
|
115 |
require_once(dirname(__FILE__) . "/admin_header.php");
|
116 |
?>
|
117 |
|
118 |
|
119 |
<form action="" method="post" enctype="multipart/form-data">
|
120 |
-
<h2
|
121 |
<?php
|
122 |
global $pmpro_pages_ready;
|
123 |
if($pmpro_pages_ready)
|
124 |
{
|
125 |
?>
|
126 |
-
<p
|
127 |
<?php
|
128 |
}
|
129 |
else
|
130 |
{
|
131 |
?>
|
132 |
-
<p
|
133 |
<?php
|
134 |
}
|
135 |
?>
|
@@ -137,121 +96,107 @@
|
|
137 |
<tbody>
|
138 |
<tr>
|
139 |
<th scope="row" valign="top">
|
140 |
-
<label for="account_page_id"
|
141 |
</th>
|
142 |
<td>
|
143 |
<?php
|
144 |
-
wp_dropdown_pages(array("name"=>"account_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[
|
145 |
?>
|
146 |
-
<?php if(
|
147 |
-
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[
|
148 |
-
|
149 |
-
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['account']);?>" class="button button-secondary pmpro_page_view"><?php _e('view page', 'pmpro');?></a>
|
150 |
<?php } ?>
|
151 |
-
<br /><small class="pmpro_lite"
|
152 |
</td>
|
153 |
<tr>
|
154 |
<th scope="row" valign="top">
|
155 |
-
<label for="billing_page_id"
|
156 |
</th>
|
157 |
<td>
|
158 |
<?php
|
159 |
-
wp_dropdown_pages(array("name"=>"billing_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[
|
160 |
?>
|
161 |
-
<?php if(
|
162 |
-
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[
|
163 |
-
|
164 |
-
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['billing']);?>" class="button button-secondary pmpro_page_view"><?php _e('view page', 'pmpro');?></a>
|
165 |
<?php } ?>
|
166 |
-
<br /><small class="pmpro_lite"
|
167 |
</td>
|
168 |
<tr>
|
169 |
<th scope="row" valign="top">
|
170 |
-
<label for="cancel_page_id"
|
171 |
</th>
|
172 |
<td>
|
173 |
<?php
|
174 |
-
wp_dropdown_pages(array("name"=>"cancel_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[
|
175 |
?>
|
176 |
-
<?php if(
|
177 |
-
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[
|
178 |
-
|
179 |
-
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['cancel']);?>" class="button button-secondary pmpro_page_view"><?php _e('view page', 'pmpro');?></a>
|
180 |
<?php } ?>
|
181 |
-
<br /><small class="pmpro_lite"
|
182 |
</td>
|
183 |
</tr>
|
184 |
<tr>
|
185 |
<th scope="row" valign="top">
|
186 |
-
<label for="checkout_page_id"
|
187 |
</th>
|
188 |
<td>
|
189 |
<?php
|
190 |
-
wp_dropdown_pages(array("name"=>"checkout_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[
|
191 |
?>
|
192 |
-
<?php if(
|
193 |
-
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[
|
194 |
-
|
195 |
-
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['checkout']);?>" class="button button-secondary pmpro_page_view"><?php _e('view page', 'pmpro');?></a>
|
196 |
<?php } ?>
|
197 |
-
<br /><small class="pmpro_lite"
|
198 |
</td>
|
199 |
</tr>
|
200 |
<tr>
|
201 |
<th scope="row" valign="top">
|
202 |
-
<label for="confirmation_page_id"
|
203 |
</th>
|
204 |
<td>
|
205 |
<?php
|
206 |
-
wp_dropdown_pages(array("name"=>"confirmation_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[
|
207 |
?>
|
208 |
-
<?php if(
|
209 |
-
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[
|
210 |
-
|
211 |
-
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['confirmation']);?>" class="button button-secondary pmpro_page_view"><?php _e('view page', 'pmpro');?></a>
|
212 |
<?php } ?>
|
213 |
-
<br /><small class="pmpro_lite"
|
214 |
</td>
|
215 |
</tr>
|
216 |
<tr>
|
217 |
<th scope="row" valign="top">
|
218 |
-
<label for="invoice_page_id"
|
219 |
</th>
|
220 |
<td>
|
221 |
<?php
|
222 |
-
wp_dropdown_pages(array("name"=>"invoice_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[
|
223 |
?>
|
224 |
-
<?php if(
|
225 |
-
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[
|
226 |
-
|
227 |
-
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['invoice']);?>" class="button button-secondary pmpro_page_view"><?php _e('view page', 'pmpro');?></a>
|
228 |
<?php } ?>
|
229 |
-
<br /><small class="pmpro_lite"
|
230 |
</td>
|
231 |
</tr>
|
232 |
<tr>
|
233 |
<th scope="row" valign="top">
|
234 |
-
<label for="levels_page_id"
|
235 |
</th>
|
236 |
<td>
|
237 |
<?php
|
238 |
-
wp_dropdown_pages(array("name"=>"levels_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[
|
239 |
?>
|
240 |
-
<?php if(
|
241 |
-
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[
|
242 |
-
|
243 |
-
<a target="_blank" href="<?php echo get_permalink($pmpro_pages['levels']);?>" class="button button-secondary pmpro_page_view"><?php _e('view page', 'pmpro');?></a>
|
244 |
<?php } ?>
|
245 |
-
<br /><small class="pmpro_lite"
|
246 |
</td>
|
247 |
</tr>
|
248 |
</tbody>
|
249 |
</table>
|
250 |
<p class="submit">
|
251 |
-
<input name="savesettings" type="submit" class="button
|
252 |
</p>
|
253 |
</form>
|
254 |
|
255 |
-
<?php
|
256 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
257 |
?>
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
global $wpdb, $msg, $msgt;
|
3 |
+
|
4 |
//get/set settings
|
5 |
global $pmpro_pages;
|
6 |
+
if($_REQUEST['savesettings'])
|
7 |
{
|
8 |
//page ids
|
9 |
pmpro_setOption("account_page_id");
|
21 |
$pmpro_pages["checkout"] = pmpro_getOption("checkout_page_id");
|
22 |
$pmpro_pages["confirmation"] = pmpro_getOption("confirmation_page_id");
|
23 |
$pmpro_pages["invoice"] = pmpro_getOption("invoice_page_id");
|
24 |
+
$pmpro_pages["levels"] = pmpro_getOption("levels_page_id");
|
25 |
+
|
26 |
+
//assume success
|
27 |
+
$msg = true;
|
28 |
$msgt = "Your page settings have been updated.";
|
29 |
}
|
30 |
|
31 |
//are we generating pages?
|
32 |
+
if($_REQUEST['createpages'])
|
33 |
{
|
34 |
global $pmpro_pages;
|
35 |
|
40 |
{
|
41 |
if(!$pmpro_page_id)
|
42 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
//no id set. create an array to store the page info
|
44 |
$insert = array(
|
45 |
+
'post_title' => 'Membership ' . ucwords($pmpro_page_name),
|
46 |
'post_status' => 'publish',
|
47 |
'post_type' => 'page',
|
48 |
'post_content' => '[pmpro_' . $pmpro_page_name . ']',
|
49 |
'comment_status' => 'closed',
|
50 |
'ping_status' => 'closed'
|
51 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
//create the page
|
53 |
$pmpro_pages[$pmpro_page_name] = wp_insert_post( $insert );
|
54 |
|
60 |
|
61 |
//update the option too
|
62 |
pmpro_setOption($pmpro_page_name . "_page_id", $pmpro_pages[$pmpro_page_name]);
|
63 |
+
$pages_created[] = $pmpro_pages[$pmpro_page_name];
|
64 |
}
|
65 |
}
|
66 |
|
67 |
+
if($pages_created)
|
68 |
{
|
69 |
$msg = true;
|
70 |
+
$msgt = "The following pages have been created for you: " . implode(", ", $pages_created) . ".";
|
71 |
}
|
72 |
+
}
|
73 |
+
|
74 |
require_once(dirname(__FILE__) . "/admin_header.php");
|
75 |
?>
|
76 |
|
77 |
|
78 |
<form action="" method="post" enctype="multipart/form-data">
|
79 |
+
<h2>Pages</h2>
|
80 |
<?php
|
81 |
global $pmpro_pages_ready;
|
82 |
if($pmpro_pages_ready)
|
83 |
{
|
84 |
?>
|
85 |
+
<p>Manage the WordPress pages assigned to each required Paid Memberships Pro page.</p>
|
86 |
<?php
|
87 |
}
|
88 |
else
|
89 |
{
|
90 |
?>
|
91 |
+
<p>Assign the WordPress pages for each required Paid Memberships Pro page or <a href="?page=pmpro-pagesettings&createpages=1">click here to let us generate them for you</a>.</p>
|
92 |
<?php
|
93 |
}
|
94 |
?>
|
96 |
<tbody>
|
97 |
<tr>
|
98 |
<th scope="row" valign="top">
|
99 |
+
<label for="account_page_id">Account Page:</label>
|
100 |
</th>
|
101 |
<td>
|
102 |
<?php
|
103 |
+
wp_dropdown_pages(array("name"=>"account_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[account]));
|
104 |
?>
|
105 |
+
<?php if($pmpro_pages[account]) { ?>
|
106 |
+
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[account]?>&action=edit" class="pmpro_page_edit">edit page</a>
|
|
|
|
|
107 |
<?php } ?>
|
108 |
+
<br /><small class="pmpro_lite">Include the shortcode [pmpro_account].</small>
|
109 |
</td>
|
110 |
<tr>
|
111 |
<th scope="row" valign="top">
|
112 |
+
<label for="billing_page_id">Billing Information Page:</label>
|
113 |
</th>
|
114 |
<td>
|
115 |
<?php
|
116 |
+
wp_dropdown_pages(array("name"=>"billing_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[billing]));
|
117 |
?>
|
118 |
+
<?php if($pmpro_pages[billing]) { ?>
|
119 |
+
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[billing]?>&action=edit" class="pmpro_page_edit">edit page</a>
|
|
|
|
|
120 |
<?php } ?>
|
121 |
+
<br /><small class="pmpro_lite">Include the shortcode [pmpro_billing].</small>
|
122 |
</td>
|
123 |
<tr>
|
124 |
<th scope="row" valign="top">
|
125 |
+
<label for="cancel_page_id">Cancel Page:</label>
|
126 |
</th>
|
127 |
<td>
|
128 |
<?php
|
129 |
+
wp_dropdown_pages(array("name"=>"cancel_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[cancel]));
|
130 |
?>
|
131 |
+
<?php if($pmpro_pages[cancel]) { ?>
|
132 |
+
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[cancel]?>&action=edit" class="pmpro_page_edit">edit page</a>
|
|
|
|
|
133 |
<?php } ?>
|
134 |
+
<br /><small class="pmpro_lite">Include the shortcode [pmpro_cancel].</small>
|
135 |
</td>
|
136 |
</tr>
|
137 |
<tr>
|
138 |
<th scope="row" valign="top">
|
139 |
+
<label for="checkout_page_id">Checkout Page:</label>
|
140 |
</th>
|
141 |
<td>
|
142 |
<?php
|
143 |
+
wp_dropdown_pages(array("name"=>"checkout_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[checkout]));
|
144 |
?>
|
145 |
+
<?php if($pmpro_pages[checkout]) { ?>
|
146 |
+
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[checkout]?>&action=edit" class="pmpro_page_edit">edit page</a>
|
|
|
|
|
147 |
<?php } ?>
|
148 |
+
<br /><small class="pmpro_lite">Include the shortcode [pmpro_checkout].</small>
|
149 |
</td>
|
150 |
</tr>
|
151 |
<tr>
|
152 |
<th scope="row" valign="top">
|
153 |
+
<label for="confirmation_page_id">Confirmation Page:</label>
|
154 |
</th>
|
155 |
<td>
|
156 |
<?php
|
157 |
+
wp_dropdown_pages(array("name"=>"confirmation_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[confirmation]));
|
158 |
?>
|
159 |
+
<?php if($pmpro_pages[confirmation]) { ?>
|
160 |
+
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[confirmation]?>&action=edit" class="pmpro_page_edit">edit page</a>
|
|
|
|
|
161 |
<?php } ?>
|
162 |
+
<br /><small class="pmpro_lite">Include the shortcode [pmpro_confirmation].</small>
|
163 |
</td>
|
164 |
</tr>
|
165 |
<tr>
|
166 |
<th scope="row" valign="top">
|
167 |
+
<label for="invoice_page_id">Invoice Page:</label>
|
168 |
</th>
|
169 |
<td>
|
170 |
<?php
|
171 |
+
wp_dropdown_pages(array("name"=>"invoice_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[invoice]));
|
172 |
?>
|
173 |
+
<?php if($pmpro_pages[invoice]) { ?>
|
174 |
+
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[invoice]?>&action=edit" class="pmpro_page_edit">edit page</a>
|
|
|
|
|
175 |
<?php } ?>
|
176 |
+
<br /><small class="pmpro_lite">Include the shortcode [pmpro_invoice].</small>
|
177 |
</td>
|
178 |
</tr>
|
179 |
<tr>
|
180 |
<th scope="row" valign="top">
|
181 |
+
<label for="levels_page_id">Levels Page:</label>
|
182 |
</th>
|
183 |
<td>
|
184 |
<?php
|
185 |
+
wp_dropdown_pages(array("name"=>"levels_page_id", "show_option_none"=>"-- Choose One --", "selected"=>$pmpro_pages[levels]));
|
186 |
?>
|
187 |
+
<?php if($pmpro_pages[levels]) { ?>
|
188 |
+
<a target="_blank" href="post.php?post=<?php echo $pmpro_pages[levels]?>&action=edit" class="pmpro_page_edit">edit page</a>
|
|
|
|
|
189 |
<?php } ?>
|
190 |
+
<br /><small class="pmpro_lite">Include the shortcode [pmpro_levels].</small>
|
191 |
</td>
|
192 |
</tr>
|
193 |
</tbody>
|
194 |
</table>
|
195 |
<p class="submit">
|
196 |
+
<input name="savesettings" type="submit" class="button-primary" value="Save Settings" />
|
197 |
</p>
|
198 |
</form>
|
199 |
|
200 |
+
<?php
|
201 |
+
require_once(dirname(__FILE__) . "/admin_footer.php");
|
202 |
?>
|
adminpages/paymentsettings.php
CHANGED
@@ -1,538 +1,240 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
pmpro_setOption("
|
14 |
-
pmpro_setOption("
|
15 |
-
|
16 |
-
|
17 |
-
pmpro_setOption("
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
pmpro_setOption("
|
40 |
-
pmpro_setOption("
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
pmpro_setOption("
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
$
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
</td>
|
171 |
-
</tr>
|
172 |
-
<tr class="gateway
|
173 |
-
<
|
174 |
-
<
|
175 |
-
</
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
<
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
</
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
<input type="
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
<
|
229 |
-
</
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
</tr>
|
242 |
-
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
243 |
-
<th scope="row" valign="top">
|
244 |
-
<label for="apiusername"><?php _e('API Username', 'pmpro');?>:</label>
|
245 |
-
</th>
|
246 |
-
<td>
|
247 |
-
<input type="text" id="apiusername" name="apiusername" size="60" value="<?php echo esc_attr($apiusername)?>" />
|
248 |
-
</td>
|
249 |
-
</tr>
|
250 |
-
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
251 |
-
<th scope="row" valign="top">
|
252 |
-
<label for="apipassword"><?php _e('API Password', 'pmpro');?>:</label>
|
253 |
-
</th>
|
254 |
-
<td>
|
255 |
-
<input type="text" id="apipassword" name="apipassword" size="60" value="<?php echo esc_attr($apipassword)?>" />
|
256 |
-
</td>
|
257 |
-
</tr>
|
258 |
-
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
259 |
-
<th scope="row" valign="top">
|
260 |
-
<label for="apisignature"><?php _e('API Signature', 'pmpro');?>:</label>
|
261 |
-
</th>
|
262 |
-
<td>
|
263 |
-
<input type="text" id="apisignature" name="apisignature" size="60" value="<?php echo esc_attr($apisignature)?>" />
|
264 |
-
</td>
|
265 |
-
</tr>
|
266 |
-
|
267 |
-
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
268 |
-
<th scope="row" valign="top">
|
269 |
-
<label for="loginname"><?php _e('Login Name', 'pmpro');?>:</label>
|
270 |
-
</th>
|
271 |
-
<td>
|
272 |
-
<input type="text" id="loginname" name="loginname" size="60" value="<?php echo esc_attr($loginname)?>" />
|
273 |
-
</td>
|
274 |
-
</tr>
|
275 |
-
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
276 |
-
<th scope="row" valign="top">
|
277 |
-
<label for="transactionkey"><?php _e('Transaction Key', 'pmpro');?>:</label>
|
278 |
-
</th>
|
279 |
-
<td>
|
280 |
-
<input type="text" id="transactionkey" name="transactionkey" size="60" value="<?php echo esc_attr($transactionkey)?>" />
|
281 |
-
</td>
|
282 |
-
</tr>
|
283 |
-
|
284 |
-
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
285 |
-
<th scope="row" valign="top">
|
286 |
-
<label for="stripe_secretkey"><?php _e('Secret Key', 'pmpro');?>:</label>
|
287 |
-
</th>
|
288 |
-
<td>
|
289 |
-
<input type="text" id="stripe_secretkey" name="stripe_secretkey" size="60" value="<?php echo esc_attr($stripe_secretkey)?>" />
|
290 |
-
</td>
|
291 |
-
</tr>
|
292 |
-
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
293 |
-
<th scope="row" valign="top">
|
294 |
-
<label for="stripe_publishablekey"><?php _e('Publishable Key', 'pmpro');?>:</label>
|
295 |
-
</th>
|
296 |
-
<td>
|
297 |
-
<input type="text" id="stripe_publishablekey" name="stripe_publishablekey" size="60" value="<?php echo esc_attr($stripe_publishablekey)?>" />
|
298 |
-
</td>
|
299 |
-
</tr>
|
300 |
-
|
301 |
-
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
302 |
-
<th scope="row" valign="top">
|
303 |
-
<label for="braintree_merchantid"><?php _e('Merchant ID', 'pmpro');?>:</label>
|
304 |
-
</th>
|
305 |
-
<td>
|
306 |
-
<input type="text" id="braintree_merchantid" name="braintree_merchantid" size="60" value="<?php echo esc_attr($braintree_merchantid)?>" />
|
307 |
-
</td>
|
308 |
-
</tr>
|
309 |
-
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
310 |
-
<th scope="row" valign="top">
|
311 |
-
<label for="braintree_publickey"><?php _e('Public Key', 'pmpro');?>:</label>
|
312 |
-
</th>
|
313 |
-
<td>
|
314 |
-
<input type="text" id="braintree_publickey" name="braintree_publickey" size="60" value="<?php echo esc_attr($braintree_publickey)?>" />
|
315 |
-
</td>
|
316 |
-
</tr>
|
317 |
-
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
318 |
-
<th scope="row" valign="top">
|
319 |
-
<label for="braintree_privatekey"><?php _e('Private Key', 'pmpro');?>:</label>
|
320 |
-
</th>
|
321 |
-
<td>
|
322 |
-
<input type="text" id="braintree_privatekey" name="braintree_privatekey" size="60" value="<?php echo esc_attr($braintree_privatekey)?>" />
|
323 |
-
</td>
|
324 |
-
</tr>
|
325 |
-
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
326 |
-
<th scope="row" valign="top">
|
327 |
-
<label for="braintree_encryptionkey"><?php _e('Client-Side Encryption Key', 'pmpro');?>:</label>
|
328 |
-
</th>
|
329 |
-
<td>
|
330 |
-
<textarea id="braintree_encryptionkey" name="braintree_encryptionkey" rows="3" cols="80"><?php echo esc_textarea($braintree_encryptionkey)?></textarea>
|
331 |
-
</td>
|
332 |
-
</tr>
|
333 |
-
|
334 |
-
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
335 |
-
<th scope="row" valign="top">
|
336 |
-
<label for="twocheckout_apiusername"><?php _e('API Username', 'pmpro');?>:</label>
|
337 |
-
</th>
|
338 |
-
<td>
|
339 |
-
<input type="text" id="twocheckout_apiusername" name="twocheckout_apiusername" size="60" value="<?php echo esc_attr($twocheckout_apiusername)?>" />
|
340 |
-
</td>
|
341 |
-
</tr>
|
342 |
-
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
343 |
-
<th scope="row" valign="top">
|
344 |
-
<label for="twocheckout_apipassword"><?php _e('API Password', 'pmpro');?>:</label>
|
345 |
-
</th>
|
346 |
-
<td>
|
347 |
-
<input type="text" id="twocheckout_apipassword" name="twocheckout_apipassword" size="60" value="<?php echo esc_attr($twocheckout_apipassword)?>" />
|
348 |
-
</td>
|
349 |
-
</tr>
|
350 |
-
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
351 |
-
<th scope="row" valign="top">
|
352 |
-
<label for="twocheckout_accountnumber"><?php _e('Account Number', 'pmpro');?>:</label>
|
353 |
-
</th>
|
354 |
-
<td>
|
355 |
-
<input type="text" name="twocheckout_accountnumber" size="60" value="<?php echo $twocheckout_accountnumber?>" />
|
356 |
-
</td>
|
357 |
-
</tr>
|
358 |
-
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
359 |
-
<th scope="row" valign="top">
|
360 |
-
<label for="twocheckout_secretword"><?php _e('Secret Word', 'pmpro');?>:</label>
|
361 |
-
</th>
|
362 |
-
<td>
|
363 |
-
<input type="text" name="twocheckout_secretword" size="60" value="<?php echo $twocheckout_secretword?>" />
|
364 |
-
</td>
|
365 |
-
</tr>
|
366 |
-
|
367 |
-
<tr class="gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
368 |
-
<th scope="row" valign="top">
|
369 |
-
<label for="cybersource_merchantid"><?php _e('Merchant ID', 'pmpro');?>:</label>
|
370 |
-
</th>
|
371 |
-
<td>
|
372 |
-
<input type="text" id="cybersource_merchantid" name="cybersource_merchantid" size="60" value="<?php echo esc_attr($cybersource_merchantid)?>" />
|
373 |
-
</td>
|
374 |
-
</tr>
|
375 |
-
<tr class="gateway gateway_cybersource" <?php if($gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
376 |
-
<th scope="row" valign="top">
|
377 |
-
<label for="cybersource_securitykey"><?php _e('Transaction Security Key', 'pmpro');?>:</label>
|
378 |
-
</th>
|
379 |
-
<td>
|
380 |
-
<textarea id="cybersource_securitykey" name="cybersource_securitykey" rows="3" cols="80"><?php echo esc_textarea($cybersource_securitykey);?></textarea>
|
381 |
-
</td>
|
382 |
-
</tr>
|
383 |
-
|
384 |
-
<tr class="gateway gateway_ gateway_paypal gateway_paypalexpress gateway_paypalstandard gateway_braintree gateway_twocheckout gateway_cybersource gateway_stripe gateway_authorizenet gateway_payflowpro gateway_check" <?php if(!empty($gateway) && $gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard" && $gateway != "braintree" && $gateway != "twocheckout" && $gateway != "cybersource" && $gateway != "payflowpro" && $gateway != "stripe" && $gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
385 |
-
<th scope="row" valign="top">
|
386 |
-
<label for="currency"><?php _e('Currency', 'pmpro');?>:</label>
|
387 |
-
</th>
|
388 |
-
<td>
|
389 |
-
<select name="currency">
|
390 |
-
<?php
|
391 |
-
global $pmpro_currencies;
|
392 |
-
foreach($pmpro_currencies as $ccode => $cdescription)
|
393 |
-
{
|
394 |
-
?>
|
395 |
-
<option value="<?php echo $ccode?>" <?php if($currency == $ccode) { ?>selected="selected"<?php } ?>><?php echo $cdescription?></option>
|
396 |
-
<?php
|
397 |
-
}
|
398 |
-
?>
|
399 |
-
</select>
|
400 |
-
<small><?php _e( 'Not all currencies will be supported by every gateway. Please check with your gateway.', 'pmpro' ); ?></small>
|
401 |
-
</td>
|
402 |
-
</tr>
|
403 |
-
|
404 |
-
<tr class="gateway gateway_ gateway_stripe gateway_authorizenet gateway_paypal gateway_payflowpro gateway_braintree gateway_twocheckout gateway_cybersource" <?php if(!empty($gateway) && $gateway != "authorizenet" && $gateway != "paypal" && $gateway != "stripe" && $gateway != "payflowpro" && $gateway != "braintree" && $gateway != "twocheckout" && $gateway != "cybersource") { ?>style="display: none;"<?php } ?>>
|
405 |
-
<th scope="row" valign="top">
|
406 |
-
<label for="creditcards"><?php _e('Accepted Credit Card Types', 'pmpro');?></label>
|
407 |
-
</th>
|
408 |
-
<td>
|
409 |
-
<input type="checkbox" name="creditcards_visa" value="1" <?php if(in_array("Visa", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> Visa<br />
|
410 |
-
<input type="checkbox" name="creditcards_mastercard" value="1" <?php if(in_array("Mastercard", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> Mastercard<br />
|
411 |
-
<input type="checkbox" name="creditcards_amex" value="1" <?php if(in_array("American Express", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> American Express<br />
|
412 |
-
<input type="checkbox" name="creditcards_discover" value="1" <?php if(in_array("Discover", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> Discover<br />
|
413 |
-
<input type="checkbox" name="creditcards_dinersclub" value="1" <?php if(in_array("Diners Club", $pmpro_accepted_credit_cards)) {?>checked="checked"<?php } ?> /> Diner's Club<br />
|
414 |
-
<input type="checkbox" name="creditcards_enroute" value="1" <?php if(in_array("EnRoute", $pmpro_accepted_credit_cards)) {?>checked="checked"<?php } ?> /> EnRoute<br />
|
415 |
-
<input type="checkbox" name="creditcards_jcb" value="1" <?php if(in_array("JCB", $pmpro_accepted_credit_cards)) {?>checked="checked"<?php } ?> /> JCB<br />
|
416 |
-
</td>
|
417 |
-
</tr>
|
418 |
-
<tr class="gateway gateway_check" <?php if($gateway != "check") { ?>style="display: none;"<?php } ?>>
|
419 |
-
<th scope="row" valign="top">
|
420 |
-
<label for="instructions"><?php _e('Instructions', 'pmpro');?></label>
|
421 |
-
</th>
|
422 |
-
<td>
|
423 |
-
<textarea id="instructions" name="instructions" rows="3" cols="80"><?php echo esc_textarea($instructions)?></textarea>
|
424 |
-
<p><small><?php _e('Who to write the check out to. Where to mail it. Shown on checkout, confirmation, and invoice pages.', 'pmpro');?></small></p>
|
425 |
-
</td>
|
426 |
-
</tr>
|
427 |
-
|
428 |
-
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
429 |
-
<th scope="row" valign="top">
|
430 |
-
<label for="stripe_billingaddress"><?php _e('Show Billing Address Fields', 'pmpro');?>:</label>
|
431 |
-
</th>
|
432 |
-
<td>
|
433 |
-
<select id="stripe_billingaddress" name="stripe_billingaddress">
|
434 |
-
<option value="0" <?php if(empty($stripe_billingaddress)) { ?>selected="selected"<?php } ?>><?php _e('No', 'pmpro');?></option>
|
435 |
-
<option value="1" <?php if(!empty($stripe_billingaddress)) { ?>selected="selected"<?php } ?>><?php _e('Yes', 'pmpro');?></option>
|
436 |
-
</select>
|
437 |
-
<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>", 'pmpro');?></small>
|
438 |
-
</td>
|
439 |
-
</tr>
|
440 |
-
|
441 |
-
<tr class="gateway gateway_ gateway_stripe gateway_authorizenet gateway_paypal gateway_paypalexpress gateway_check gateway_paypalstandard gateway_payflowpro gateway_braintree gateway_twocheckout gateway_cybersource" <?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 } ?>>
|
442 |
-
<th scope="row" valign="top">
|
443 |
-
<label for="tax"><?php _e('Sales Tax', 'pmpro');?> <small>(<?php _e('optional', 'pmpro');?>)</small></label>
|
444 |
-
</th>
|
445 |
-
<td>
|
446 |
-
<?php _e('Tax State', 'pmpro');?>:
|
447 |
-
<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"', 'pmpro');?>)</small>
|
448 |
-
Tax Rate:
|
449 |
-
<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"', 'pmpro');?>)</small>
|
450 |
-
<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>.', 'pmpro');?></small></p>
|
451 |
-
</td>
|
452 |
-
</tr>
|
453 |
-
<tr class="gateway gateway_ gateway_stripe gateway_paypalexpress gateway_check gateway_paypalstandard gateway_braintree gateway_twocheckout gateway_cybersource gateway_payflowpro gateway_authorizenet gateway_paypal">
|
454 |
-
<th scope="row" valign="top">
|
455 |
-
<label for="use_ssl"><?php _e('Force SSL', 'pmpro');?>:</label>
|
456 |
-
</th>
|
457 |
-
<td>
|
458 |
-
<select id="use_ssl" name="use_ssl">
|
459 |
-
<option value="0" <?php if(empty($use_ssl)) { ?>selected="selected"<?php } ?>><?php _e('No', 'pmpro');?></option>
|
460 |
-
<option value="1" <?php if(!empty($use_ssl) && $use_ssl == 1) { ?>selected="selected"<?php } ?>><?php _e('Yes', 'pmpro');?></option>
|
461 |
-
<option value="2" <?php if(!empty($use_ssl) && $use_ssl == 2) { ?>selected="selected"<?php } ?>><?php _e('Yes (with JavaScript redirects)', 'pmpro');?></option>
|
462 |
-
</select>
|
463 |
-
<small>Recommended: Yes. Try the JavaScript redirects setting if you are having issues with infinite redirect loops.</small>
|
464 |
-
</td>
|
465 |
-
</tr>
|
466 |
-
<tr>
|
467 |
-
<th scope="row" valign="top">
|
468 |
-
<label for="sslseal"><?php _e('SSL Seal Code', 'pmpro');?>:</label>
|
469 |
-
</th>
|
470 |
-
<td>
|
471 |
-
<textarea id="sslseal" name="sslseal" rows="3" cols="80"><?php echo stripslashes(esc_textarea($sslseal))?></textarea>
|
472 |
-
<br /><small>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.</small>
|
473 |
-
</td>
|
474 |
-
</tr>
|
475 |
-
<tr>
|
476 |
-
<th scope="row" valign="top">
|
477 |
-
<label for="nuclear_HTTPS"><?php _e('HTTPS Nuclear Option', 'pmpro');?>:</label>
|
478 |
-
</th>
|
479 |
-
<td>
|
480 |
-
<input type="checkbox" id="nuclear_HTTPS" name="nuclear_HTTPS" value="1" <?php if(!empty($nuclear_HTTPS)) { ?>checked="checked"<?php } ?> /> <?php _e('Use the "Nuclear Option" to use secure (HTTPS) URLs on your secure pages. Check this if you are using SSL and have warnings on your checkout pages.', 'pmpro');?>
|
481 |
-
</td>
|
482 |
-
</tr>
|
483 |
-
<tr class="gateway gateway_paypal gateway_paypalexpress gateway_paypalstandard gateway_payflowpro" <?php if($gateway != "paypal" && $gateway != "paypalexpress" && $gateway != "paypalstandard" && $gateway != "payflowpro") { ?>style="display: none;"<?php } ?>>
|
484 |
-
<th scope="row" valign="top">
|
485 |
-
<label><?php _e('IPN Handler URL', 'pmpro');?>:</label>
|
486 |
-
</th>
|
487 |
-
<td>
|
488 |
-
<p><?php _e('To fully integrate with PayPal, be sure to set your IPN Handler URL to ', 'pmpro');?> <pre><?php echo admin_url("admin-ajax.php") . "?action=ipnhandler";?></pre></p>
|
489 |
-
</td>
|
490 |
-
</tr>
|
491 |
-
<tr class="gateway gateway_twocheckout" <?php if($gateway != "twocheckout") { ?>style="display: none;"<?php } ?>>
|
492 |
-
<th scope="row" valign="top">
|
493 |
-
<label><?php _e('TwoCheckout INS URL', 'pmpro');?>:</label>
|
494 |
-
</th>
|
495 |
-
<td>
|
496 |
-
<p><?php _e('To fully integrate with 2Checkout, be sure to set your 2Checkout INS URL ', 'pmpro');?> <pre><?php echo admin_url("admin-ajax.php") . "?action=twocheckout-ins";?></pre></p>
|
497 |
-
</td>
|
498 |
-
</tr>
|
499 |
-
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
500 |
-
<th scope="row" valign="top">
|
501 |
-
<label><?php _e('Silent Post URL', 'pmpro');?>:</label>
|
502 |
-
</th>
|
503 |
-
<td>
|
504 |
-
<p><?php _e('To fully integrate with Authorize.net, be sure to set your Silent Post URL to', 'pmpro');?> <pre><?php echo admin_url("admin-ajax.php") . "?action=authnet_silent_post";?></pre></p>
|
505 |
-
</td>
|
506 |
-
</tr>
|
507 |
-
<tr class="gateway gateway_stripe" <?php if($gateway != "stripe") { ?>style="display: none;"<?php } ?>>
|
508 |
-
<th scope="row" valign="top">
|
509 |
-
<label><?php _e('Web Hook URL', 'pmpro');?>:</label>
|
510 |
-
</th>
|
511 |
-
<td>
|
512 |
-
<p><?php _e('To fully integrate with Stripe, be sure to set your Web Hook URL to', 'pmpro');?> <pre><?php echo admin_url("admin-ajax.php") . "?action=stripe_webhook";?></pre></p>
|
513 |
-
</td>
|
514 |
-
</tr>
|
515 |
-
<tr class="gateway gateway_braintree" <?php if($gateway != "braintree") { ?>style="display: none;"<?php } ?>>
|
516 |
-
<th scope="row" valign="top">
|
517 |
-
<label><?php _e('Web Hook URL', 'pmpro');?>:</label>
|
518 |
-
</th>
|
519 |
-
<td>
|
520 |
-
<p>
|
521 |
-
<?php _e('To fully integrate with Braintree, be sure to set your Web Hook URL to', 'pmpro');?>
|
522 |
-
<pre><?php
|
523 |
-
//echo admin_url("admin-ajax.php") . "?action=braintree_webhook";
|
524 |
-
echo PMPRO_URL . "/services/braintree-webhook.php";
|
525 |
-
?></pre>.
|
526 |
-
</p>
|
527 |
-
</td>
|
528 |
-
</tr>
|
529 |
-
</tbody>
|
530 |
-
</table>
|
531 |
-
<p class="submit">
|
532 |
-
<input name="savesettings" type="submit" class="button-primary" value="<?php _e('Save Settings', 'pmpro');?>" />
|
533 |
-
</p>
|
534 |
-
</form>
|
535 |
-
|
536 |
-
<?php
|
537 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
538 |
-
?>
|
1 |
+
<?php
|
2 |
+
global $wpdb, $pmpro_currency_symbol, $msg, $msgt;
|
3 |
+
|
4 |
+
//get/set settings
|
5 |
+
if($_REQUEST['savesettings'])
|
6 |
+
{
|
7 |
+
pmpro_setOption("sslseal");
|
8 |
+
|
9 |
+
//gateway options
|
10 |
+
pmpro_setOption("gateway");
|
11 |
+
pmpro_setOption("gateway_environment");
|
12 |
+
pmpro_setOption("gateway_email");
|
13 |
+
pmpro_setOption("apiusername");
|
14 |
+
pmpro_setOption("apipassword");
|
15 |
+
pmpro_setOption("apisignature");
|
16 |
+
pmpro_setOption("loginname");
|
17 |
+
pmpro_setOption("transactionkey");
|
18 |
+
|
19 |
+
//currency
|
20 |
+
$currency_paypal = $_POST['currency_paypal'];
|
21 |
+
$currency_authorizenet = $_POST['currency_authorizenet'];
|
22 |
+
if($_POST['gateway'] == "authorizenet")
|
23 |
+
pmpro_setOption("currency", $currency_authorizenet);
|
24 |
+
else
|
25 |
+
pmpro_setOption("currency", $currency_paypal);
|
26 |
+
|
27 |
+
//credit cards
|
28 |
+
$pmpro_accepted_credit_cards = array();
|
29 |
+
if($_REQUEST['creditcards_visa'])
|
30 |
+
$pmpro_accepted_credit_cards[] = "Visa";
|
31 |
+
if($_REQUEST['creditcards_mastercard'])
|
32 |
+
$pmpro_accepted_credit_cards[] = "Mastercard";
|
33 |
+
if($_REQUEST['creditcards_amex'])
|
34 |
+
$pmpro_accepted_credit_cards[] = "American Express";
|
35 |
+
if($_REQUEST['creditcards_discover'])
|
36 |
+
$pmpro_accepted_credit_cards[] = "Discover";
|
37 |
+
|
38 |
+
//tax
|
39 |
+
pmpro_setOption("tax_state");
|
40 |
+
pmpro_setOption("tax_rate");
|
41 |
+
|
42 |
+
pmpro_setOption("accepted_credit_cards", implode(",", $pmpro_accepted_credit_cards));
|
43 |
+
|
44 |
+
//assume success
|
45 |
+
$msg = true;
|
46 |
+
$msgt = "Your payment settings have been updated.";
|
47 |
+
}
|
48 |
+
|
49 |
+
$sslseal = pmpro_getOption("sslseal");
|
50 |
+
|
51 |
+
$gateway = pmpro_getOption("gateway");
|
52 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
53 |
+
$gateway_email = pmpro_getOption("gateway_email");
|
54 |
+
$apiusername = pmpro_getOption("apiusername");
|
55 |
+
$apipassword = pmpro_getOption("apipassword");
|
56 |
+
$apisignature = pmpro_getOption("apisignature");
|
57 |
+
$loginname = pmpro_getOption("loginname");
|
58 |
+
$transactionkey = pmpro_getOption("transactionkey");
|
59 |
+
|
60 |
+
$currency = pmpro_getOption("currency");
|
61 |
+
|
62 |
+
$pmpro_accepted_credit_cards = pmpro_getOption("accepted_credit_cards");
|
63 |
+
|
64 |
+
$tax_state = pmpro_getOption("tax_state");
|
65 |
+
$tax_rate = pmpro_getOption("tax_rate");
|
66 |
+
|
67 |
+
//default settings
|
68 |
+
if(!$gateway_environment)
|
69 |
+
{
|
70 |
+
$gateway_environment = "sandbox";
|
71 |
+
pmpro_setOption("gateway_environment", $gateway_environment);
|
72 |
+
}
|
73 |
+
if(!$pmpro_accepted_credit_cards)
|
74 |
+
{
|
75 |
+
$pmpro_accepted_credit_cards = "Visa,Mastercard,American Express,Discover";
|
76 |
+
pmpro_setOption("accepted_credit_cards", $pmpro_accepted_credit_cards);
|
77 |
+
}
|
78 |
+
|
79 |
+
$pmpro_accepted_credit_cards = split(",", $pmpro_accepted_credit_cards);
|
80 |
+
|
81 |
+
require_once(dirname(__FILE__) . "/admin_header.php");
|
82 |
+
?>
|
83 |
+
|
84 |
+
<form action="" method="post" enctype="multipart/form-data">
|
85 |
+
<h2>SSL & Payment Gateway Settings</h2>
|
86 |
+
|
87 |
+
<p>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>.</p>
|
88 |
+
|
89 |
+
<table class="form-table">
|
90 |
+
<tbody>
|
91 |
+
<tr>
|
92 |
+
<th scope="row" valign="top">
|
93 |
+
<label for="sslseal">SSL Seal Code:</label>
|
94 |
+
</th>
|
95 |
+
<td>
|
96 |
+
<textarea name="sslseal" rows="3" cols="80"><?php echo stripslashes($sslseal)?></textarea>
|
97 |
+
</td>
|
98 |
+
</tr>
|
99 |
+
<tr>
|
100 |
+
<th scope="row" valign="top">
|
101 |
+
<label for="gateway">Payment Gateway:</label>
|
102 |
+
</th>
|
103 |
+
<td>
|
104 |
+
<select id="gateway" name="gateway" onchange="pmpro_changeGateway(jQuery(this).val());">
|
105 |
+
<option value="">-- choose one --</option>
|
106 |
+
<option value="paypalexpress" <?php if($gateway == "paypalexpress") { ?>selected="selected"<?php } ?>>PayPal Express</option>
|
107 |
+
<option value="paypal" <?php if($gateway == "paypal") { ?>selected="selected"<?php } ?>>PayPal Website Payments Pro</option>
|
108 |
+
<option value="authorizenet" <?php if($gateway == "authorizenet") { ?>selected="selected"<?php } ?>>Authorize.net</option>
|
109 |
+
</select>
|
110 |
+
</td>
|
111 |
+
</tr>
|
112 |
+
<tr>
|
113 |
+
<th scope="row" valign="top">
|
114 |
+
<label for="gateway_environment">Gateway Environment:</label>
|
115 |
+
</th>
|
116 |
+
<td>
|
117 |
+
<select name="gateway_environment">
|
118 |
+
<option value="sandbox" <?php if($gateway_environment == "sandbox") { ?>selected="selected"<?php } ?>>Sandbox/Testing</option>
|
119 |
+
<option value="live" <?php if($gateway_environment == "live") { ?>selected="selected"<?php } ?>>Live/Production</option>
|
120 |
+
</select>
|
121 |
+
<script>
|
122 |
+
function pmpro_changeGateway(gateway)
|
123 |
+
{
|
124 |
+
//hide all gateway options
|
125 |
+
jQuery('tr.gateway').hide();
|
126 |
+
jQuery('tr.gateway_'+gateway).show();
|
127 |
+
}
|
128 |
+
pmpro_changeGateway(jQuery().val('#gateway'));
|
129 |
+
</script>
|
130 |
+
</td>
|
131 |
+
</tr>
|
132 |
+
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
133 |
+
<th scope="row" valign="top">
|
134 |
+
<label for="gateway_email">Gateway Account Email:</label>
|
135 |
+
</th>
|
136 |
+
<td>
|
137 |
+
<input type="text" name="gateway_email" size="60" value="<?php echo $gateway_email?>" />
|
138 |
+
</td>
|
139 |
+
</tr>
|
140 |
+
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
141 |
+
<th scope="row" valign="top">
|
142 |
+
<label for="apiusername">API Username:</label>
|
143 |
+
</th>
|
144 |
+
<td>
|
145 |
+
<input type="text" name="apiusername" size="60" value="<?php echo $apiusername?>" />
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
+
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
149 |
+
<th scope="row" valign="top">
|
150 |
+
<label for="apipassword">API Password:</label>
|
151 |
+
</th>
|
152 |
+
<td>
|
153 |
+
<input type="text" name="apipassword" size="60" value="<?php echo $apipassword?>" />
|
154 |
+
</td>
|
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="apisignature">API Signature:</label>
|
159 |
+
</th>
|
160 |
+
<td>
|
161 |
+
<input type="text" name="apisignature" size="60" value="<?php echo $apisignature?>" />
|
162 |
+
</td>
|
163 |
+
</tr>
|
164 |
+
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
165 |
+
<th scope="row" valign="top">
|
166 |
+
<label for="loginname">Login Name:</label>
|
167 |
+
</th>
|
168 |
+
<td>
|
169 |
+
<input type="text" name="loginname" size="60" value="<?php echo $loginname?>" />
|
170 |
+
</td>
|
171 |
+
</tr>
|
172 |
+
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
173 |
+
<th scope="row" valign="top">
|
174 |
+
<label for="transactionkey">Transaction Key:</label>
|
175 |
+
</th>
|
176 |
+
<td>
|
177 |
+
<input type="text" name="transactionkey" size="60" value="<?php echo $transactionkey?>" />
|
178 |
+
</td>
|
179 |
+
</tr>
|
180 |
+
<tr class="gateway gateway_authorizenet" <?php if($gateway != "authorizenet") { ?>style="display: none;"<?php } ?>>
|
181 |
+
<th scope="row" valign="top">
|
182 |
+
<label for="transactionkey">Currency:</label>
|
183 |
+
</th>
|
184 |
+
<td>
|
185 |
+
<input type="hidden" name="currency_authorizenet" size="60" value="USD" />
|
186 |
+
USD
|
187 |
+
</td>
|
188 |
+
</tr>
|
189 |
+
<tr class="gateway gateway_paypal gateway_paypalexpress" <?php if($gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
190 |
+
<th scope="row" valign="top">
|
191 |
+
<label for="transactionkey">Currency:</label>
|
192 |
+
</th>
|
193 |
+
<td>
|
194 |
+
<select name="currency_paypal">
|
195 |
+
<?php
|
196 |
+
global $pmpro_currencies;
|
197 |
+
foreach($pmpro_currencies as $ccode => $cdescription)
|
198 |
+
{
|
199 |
+
?>
|
200 |
+
<option value="<?php echo $ccode?>" <?php if($currency == $ccode) { ?>selected="selected"<?php } ?>><?php echo $cdescription?></option>
|
201 |
+
<?php
|
202 |
+
}
|
203 |
+
?>
|
204 |
+
</select>
|
205 |
+
</td>
|
206 |
+
</tr>
|
207 |
+
|
208 |
+
<tr class="gateway gateway_authorizenet gateway_paypal" <?php if($gateway != "authorizenet" && $gateway != "paypal") { ?>style="display: none;"<?php } ?>>
|
209 |
+
<th scope="row" valign="top">
|
210 |
+
<label for="creditcards">Accepted Credit Card Types</label>
|
211 |
+
</th>
|
212 |
+
<td>
|
213 |
+
<input type="checkbox" name="creditcards_visa" value="1" <?php if(in_array("Visa", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> Visa<br />
|
214 |
+
<input type="checkbox" name="creditcards_mastercard" value="1" <?php if(in_array("Mastercard", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> Mastercard<br />
|
215 |
+
<input type="checkbox" name="creditcards_amex" value="1" <?php if(in_array("American Express", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> American Express<br />
|
216 |
+
<input type="checkbox" name="creditcards_discover" value="1" <?php if(in_array("Discover", $pmpro_accepted_credit_cards)) { ?>checked="checked"<?php } ?> /> Discover<br />
|
217 |
+
</td>
|
218 |
+
</tr>
|
219 |
+
<tr class="gateway gateway_authorizenet gateway_paypal gateway_paypalexpress" <?php if($gateway != "authorizenet" && $gateway != "paypal" && $gateway != "paypalexpress") { ?>style="display: none;"<?php } ?>>
|
220 |
+
<th scope="row" valign="top">
|
221 |
+
<label for="tax">Sales Tax <small>(optional)</small></label>
|
222 |
+
</th>
|
223 |
+
<td>
|
224 |
+
Tax State:
|
225 |
+
<input type="text" name="tax_state" size="4" value="<?php echo $tax_state?>" /> <small>(abbreviation, e.g. "PA")</small>
|
226 |
+
Tax Rate:
|
227 |
+
<input type="text" name="tax_rate" size="10" value="<?php echo $tax_rate?>" /> <small>(decimal, e.g. "0.06")</small>
|
228 |
+
<p><small>If values are given, tax will be applied for any members ordering from the selected state. For more complex tax rules, use the "pmpro_tax" filter.</small></p>
|
229 |
+
</td>
|
230 |
+
</tr>
|
231 |
+
</tbody>
|
232 |
+
</table>
|
233 |
+
<p class="submit">
|
234 |
+
<input name="savesettings" type="submit" class="button-primary" value="Save Settings" />
|
235 |
+
</p>
|
236 |
+
</form>
|
237 |
+
|
238 |
+
<?php
|
239 |
+
require_once(dirname(__FILE__) . "/admin_footer.php");
|
240 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/reports.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
global $pmpro_reports;
|
3 |
-
|
4 |
-
require_once(dirname(__FILE__) . "/admin_header.php");
|
5 |
-
|
6 |
-
//default view, report widgets
|
7 |
-
if(empty($_REQUEST['report']))
|
8 |
-
{
|
9 |
-
//wrapper
|
10 |
-
?>
|
11 |
-
<div id="dashboard-widgets-wrap">
|
12 |
-
<div id="dashboard-widgets" class="metabox-holder pmpro_reports-holder columns-2">
|
13 |
-
<div id="postbox-container-1" class="postbox-container">
|
14 |
-
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
15 |
-
<?php
|
16 |
-
|
17 |
-
//report widgets
|
18 |
-
$count = 0;
|
19 |
-
$nreports = count($pmpro_reports);
|
20 |
-
$split = false;
|
21 |
-
foreach($pmpro_reports as $report => $title)
|
22 |
-
{
|
23 |
-
//make sure title is translated (since these are set before translations happen)
|
24 |
-
$title = __($title, "pmpro");
|
25 |
-
|
26 |
-
//put half of the report widgets in postbox-container-2
|
27 |
-
if(!$split && $count++ > $nreports/2)
|
28 |
-
{
|
29 |
-
$split = true;
|
30 |
-
?>
|
31 |
-
</div></div><div id="postbox-container-2" class="postbox-container"><div id="side-sortables" class="meta-box-sortables ui-sortable">
|
32 |
-
<?php
|
33 |
-
}
|
34 |
-
?>
|
35 |
-
<div id="pmpro_report_<?php echo $report; ?>" class="postbox pmpro_clickable" onclick="location.href='<?php echo admin_url("admin.php?page=pmpro-reports&report=" . $report);?>';">
|
36 |
-
<h3 class="hndle"><span><?php echo $title; ?></span></h3>
|
37 |
-
<div class="inside">
|
38 |
-
<?php call_user_func("pmpro_report_" . $report . "_widget"); ?>
|
39 |
-
<div style="margin-top:10px;border-top: 1px solid #ddd; padding-top: 10px; text-align:center;">
|
40 |
-
<a class="button button-primary" href="<?php echo admin_url("admin.php?page=pmpro-reports&report=" . $report);?>"><?php _e('Details', 'pmpro');?></a>
|
41 |
-
</div>
|
42 |
-
</div>
|
43 |
-
</div>
|
44 |
-
<?php
|
45 |
-
}
|
46 |
-
|
47 |
-
//end wrapper
|
48 |
-
?>
|
49 |
-
</div>
|
50 |
-
</div>
|
51 |
-
</div>
|
52 |
-
<?php
|
53 |
-
}
|
54 |
-
else
|
55 |
-
{
|
56 |
-
//view a single report
|
57 |
-
$report = $_REQUEST['report'];
|
58 |
-
call_user_func("pmpro_report_" . $report . "_page");
|
59 |
-
}
|
60 |
-
|
61 |
-
require_once(dirname(__FILE__) . "/admin_footer.php");
|
62 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/reports/login.php
DELETED
@@ -1,412 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
PMPro Report
|
4 |
-
Title: Logins
|
5 |
-
Slug: login
|
6 |
-
|
7 |
-
For each report, add a line like:
|
8 |
-
global $pmpro_reports;
|
9 |
-
$pmpro_reports['slug'] = 'Title';
|
10 |
-
|
11 |
-
For each report, also write two functions:
|
12 |
-
* pmpro_report_{slug}_widget() to show up on the report homepage.
|
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', 'pmpro');
|
17 |
-
|
18 |
-
function pmpro_report_login_widget()
|
19 |
-
{
|
20 |
-
global $wpdb;
|
21 |
-
$visits = get_option("pmpro_visits", array("today"=>0, "thisday"=>date("Y-m-d"), "alltime"=>0, "month"=>0, "thismonth"=>date("n")));
|
22 |
-
$views = get_option("pmpro_views", array("today"=>0, "thisday"=>date("Y-m-d"), "alltime"=>0, "month"=>0, "thismonth"=>date("n")));
|
23 |
-
$logins = get_option("pmpro_logins", array("today"=>0, "thisday"=>date("Y-m-d"), "alltime"=>0, "month"=>0, "thismonth"=>date("n")));
|
24 |
-
?>
|
25 |
-
<div style="width: 33%; float: left;">
|
26 |
-
<p><?php _e('Visits Today', 'pmpro')?>: <?php echo $visits['today'];?></p>
|
27 |
-
<p><?php _e('Visits This Month', 'pmpro')?>: <?php echo $visits['month'];?></p>
|
28 |
-
<p><?php _e('Visits All Time', 'pmpro')?>: <?php echo $visits['alltime'];?></p>
|
29 |
-
</div>
|
30 |
-
<div style="width: 33%; float: left;">
|
31 |
-
<p><?php _e('Views Today', 'pmpro')?>: <?php echo $views['today'];?></p>
|
32 |
-
<p><?php _e('Views This Month', 'pmpro')?>: <?php echo $views['month'];?></p>
|
33 |
-
<p><?php _e('Views All Time', 'pmpro')?>: <?php echo $views['alltime'];?></p>
|
34 |
-
</div>
|
35 |
-
<div style="width: 33%; float: left;">
|
36 |
-
<p><?php _e('Logins Today', 'pmpro')?>: <?php echo $logins['today'];?></p>
|
37 |
-
<p><?php _e('Logins This Month', 'pmpro')?>: <?php echo $logins['month'];?></p>
|
38 |
-
<p><?php _e('Logins All Time', 'pmpro')?>: <?php echo $logins['alltime'];?></p>
|
39 |
-
</div>
|
40 |
-
<div class="clear"></div>
|
41 |
-
<?php
|
42 |
-
}
|
43 |
-
|
44 |
-
function pmpro_report_login_page()
|
45 |
-
{
|
46 |
-
global $wpdb;
|
47 |
-
|
48 |
-
//vars
|
49 |
-
if(!empty($_REQUEST['s']))
|
50 |
-
$s = $_REQUEST['s'];
|
51 |
-
else
|
52 |
-
$s = "";
|
53 |
-
|
54 |
-
if(!empty($_REQUEST['l']))
|
55 |
-
$l = $_REQUEST['l'];
|
56 |
-
else
|
57 |
-
$l = "";
|
58 |
-
?>
|
59 |
-
<form id="posts-filter" method="get" action="">
|
60 |
-
<h2>
|
61 |
-
<?php _e('Visits, Views, and Logins Report', 'pmpro');?>
|
62 |
-
</h2>
|
63 |
-
<ul class="subsubsub">
|
64 |
-
<li>
|
65 |
-
<?php _ex('Show', 'Dropdown label, e.g. Show All Users', 'pmpro')?> <select name="l" onchange="jQuery('#posts-filter').submit();">
|
66 |
-
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Users', 'pmpro')?></option>
|
67 |
-
<option value="all" <?php if($l == "all") { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'pmpro')?></option>
|
68 |
-
<?php
|
69 |
-
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
70 |
-
foreach($levels as $level)
|
71 |
-
{
|
72 |
-
?>
|
73 |
-
<option value="<?php echo $level->id?>" <?php if($l == $level->id) { ?>selected="selected"<?php } ?>><?php echo $level->name?></option>
|
74 |
-
<?php
|
75 |
-
}
|
76 |
-
?>
|
77 |
-
</select>
|
78 |
-
</li>
|
79 |
-
</ul>
|
80 |
-
<p class="search-box">
|
81 |
-
<label class="hidden" for="post-search-input"><?php _ex('Search', 'Search form label', 'pmpro')?> <?php if(empty($l)) echo "Users"; else echo "Members";?>:</label>
|
82 |
-
<input type="hidden" name="page" value="pmpro-reports" />
|
83 |
-
<input type="hidden" name="report" value="login" />
|
84 |
-
<input id="post-search-input" type="text" value="<?php echo $s?>" name="s"/>
|
85 |
-
<input class="button" type="submit" value="Search Members"/>
|
86 |
-
</p>
|
87 |
-
<?php
|
88 |
-
//some vars for the search
|
89 |
-
if(isset($_REQUEST['pn']))
|
90 |
-
$pn = $_REQUEST['pn'];
|
91 |
-
else
|
92 |
-
$pn = 1;
|
93 |
-
|
94 |
-
if(isset($_REQUEST['limit']))
|
95 |
-
$limit = $_REQUEST['limit'];
|
96 |
-
else
|
97 |
-
$limit = 15;
|
98 |
-
|
99 |
-
$end = $pn * $limit;
|
100 |
-
$start = $end - $limit;
|
101 |
-
|
102 |
-
if($s)
|
103 |
-
{
|
104 |
-
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate, mu.membership_id, mu.initial_payment, mu.billing_amount, mu.cycle_period, mu.cycle_number, mu.billing_limit, mu.trial_amount, mu.trial_limit, UNIX_TIMESTAMP(mu.startdate) as startdate, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id AND mu.status = 'active' LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id WHERE (u.user_login LIKE '%$s%' OR u.user_email LIKE '%$s%' OR um.meta_value LIKE '%$s%') ";
|
105 |
-
|
106 |
-
if($l == "all")
|
107 |
-
$sqlQuery .= " AND mu.status = 'active' AND mu.membership_id > 0 ";
|
108 |
-
elseif($l)
|
109 |
-
$sqlQuery .= " AND mu.membership_id = '" . $l . "' ";
|
110 |
-
|
111 |
-
$sqlQuery .= "GROUP BY u.ID ORDER BY user_registered DESC LIMIT $start, $limit";
|
112 |
-
}
|
113 |
-
else
|
114 |
-
{
|
115 |
-
$sqlQuery = "SELECT SQL_CALC_FOUND_ROWS u.ID, u.user_login, u.user_email, UNIX_TIMESTAMP(u.user_registered) as joindate, mu.membership_id, mu.initial_payment, mu.billing_amount, mu.cycle_period, mu.cycle_number, mu.billing_limit, mu.trial_amount, mu.trial_limit, UNIX_TIMESTAMP(mu.startdate) as startdate, UNIX_TIMESTAMP(mu.enddate) as enddate, m.name as membership FROM $wpdb->users u LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id AND mu.status = 'active' LEFT JOIN $wpdb->pmpro_membership_levels m ON mu.membership_id = m.id";
|
116 |
-
$sqlQuery .= " WHERE 1=1 ";
|
117 |
-
|
118 |
-
if($l == "all")
|
119 |
-
$sqlQuery .= " AND mu.membership_id > 0 AND mu.status = 'active' ";
|
120 |
-
elseif($l)
|
121 |
-
$sqlQuery .= " AND mu.membership_id = '" . $l . "' ";
|
122 |
-
$sqlQuery .= "GROUP BY u.ID ORDER BY user_registered DESC LIMIT $start, $limit";
|
123 |
-
}
|
124 |
-
|
125 |
-
$sqlQuery = apply_filters("pmpro_members_list_sql", $sqlQuery);
|
126 |
-
|
127 |
-
$theusers = $wpdb->get_results($sqlQuery);
|
128 |
-
$totalrows = $wpdb->get_var("SELECT FOUND_ROWS() as found_rows");
|
129 |
-
|
130 |
-
if($theusers)
|
131 |
-
{
|
132 |
-
?>
|
133 |
-
<p class="clear"><?php echo strval($totalrows)?> <?php if(empty($l)) echo "users"; else echo "members";?> found.
|
134 |
-
<?php
|
135 |
-
}
|
136 |
-
?>
|
137 |
-
<table class="widefat">
|
138 |
-
<thead>
|
139 |
-
<tr class="thead">
|
140 |
-
<th><?php _e('ID', 'pmpro')?></th>
|
141 |
-
<th><?php _e('User', 'pmpro')?></th>
|
142 |
-
<th><?php _e('Name', 'pmpro')?></th>
|
143 |
-
<th><?php _e('Membership', 'pmpro')?></th>
|
144 |
-
<th><?php _e('Joined', 'pmpro')?></th>
|
145 |
-
<th><?php _e('Expires', 'pmpro')?></th>
|
146 |
-
<th><?php _e('Last Visit', 'pmpro')?></th>
|
147 |
-
<th><?php _e('Visits This Month', 'pmpro')?></th>
|
148 |
-
<th><?php _e('Total Visits', 'pmpro')?></th>
|
149 |
-
<th><?php _e('Views This Month', 'pmpro')?></th>
|
150 |
-
<th><?php _e('Total Views', 'pmpro')?></th>
|
151 |
-
<th><?php _e('Last Login', 'pmpro')?></th>
|
152 |
-
<th><?php _e('Logins This Month', 'pmpro')?></th>
|
153 |
-
<th><?php _e('Total Logins', 'pmpro')?></th>
|
154 |
-
</tr>
|
155 |
-
</thead>
|
156 |
-
<tbody id="users" class="list:user user-list">
|
157 |
-
<?php
|
158 |
-
$count = 0;
|
159 |
-
foreach($theusers as $auser)
|
160 |
-
{
|
161 |
-
//get meta
|
162 |
-
$theuser = get_userdata($auser->ID);
|
163 |
-
$visits = get_user_meta($auser->ID, "pmpro_visits", true);
|
164 |
-
$views = get_user_meta($auser->ID, "pmpro_views", true);
|
165 |
-
$logins = get_user_meta($auser->ID, "pmpro_logins", true);
|
166 |
-
if(empty($logins))
|
167 |
-
$logins = array("last"=>"N/A", "month"=>"N/A", "alltime"=>"N/A");
|
168 |
-
?>
|
169 |
-
<tr <?php if($count++ % 2 == 0) { ?>class="alternate"<?php } ?>>
|
170 |
-
<td><?php echo $theuser->ID?></td>
|
171 |
-
<td>
|
172 |
-
<?php echo get_avatar($theuser->ID, 32)?>
|
173 |
-
<strong>
|
174 |
-
<?php
|
175 |
-
$userlink = '<a href="user-edit.php?user_id=' . $theuser->ID . '">' . $theuser->user_login . '</a>';
|
176 |
-
$userlink = apply_filters("pmpro_members_list_user_link", $userlink, $theuser);
|
177 |
-
echo $userlink;
|
178 |
-
?>
|
179 |
-
</strong>
|
180 |
-
</td>
|
181 |
-
<td>
|
182 |
-
<?php echo $theuser->display_name;?>
|
183 |
-
</td>
|
184 |
-
<td><?php echo $auser->membership?></td>
|
185 |
-
<td><?php echo date("m/d/Y", strtotime($theuser->user_registered, current_time("timestamp")))?></td>
|
186 |
-
<td>
|
187 |
-
<?php
|
188 |
-
if($auser->enddate)
|
189 |
-
echo date(get_option('date_format'), $auser->enddate);
|
190 |
-
else
|
191 |
-
echo "Never";
|
192 |
-
?>
|
193 |
-
</td>
|
194 |
-
<td><?php if(!empty($visits['last'])) echo $visits['last'];?></td>
|
195 |
-
<td><?php if(!empty($visits['month'])) echo $visits['month'];?></td>
|
196 |
-
<td><?php if(!empty($visits['alltime'])) echo $visits['alltime'];?></td>
|
197 |
-
<td><?php if(!empty($visits['month'])) echo $views['month'];?></td>
|
198 |
-
<td><?php if(!empty($visits['alltime'])) echo $views['alltime'];?></td>
|
199 |
-
<td><?php if(!empty($visits['last'])) echo $logins['last'];?></td>
|
200 |
-
<td><?php if(!empty($visits['month'])) echo $logins['month'];?></td>
|
201 |
-
<td><?php if(!empty($visits['alltime'])) echo $logins['alltime'];?></td>
|
202 |
-
</tr>
|
203 |
-
<?php
|
204 |
-
}
|
205 |
-
|
206 |
-
if(!$theusers)
|
207 |
-
{
|
208 |
-
?>
|
209 |
-
<tr>
|
210 |
-
<td colspan="9"><p><?php _e('No members found.', 'pmpro')?> <?php if($l) { ?><a href="?page=pmpro-memberslist&s=<?php echo $s?>"><?php _e('Search all levels', 'pmpro')?></a>.<?php } ?></p></td>
|
211 |
-
</tr>
|
212 |
-
<?php
|
213 |
-
}
|
214 |
-
?>
|
215 |
-
</tbody>
|
216 |
-
</table>
|
217 |
-
</form>
|
218 |
-
|
219 |
-
<?php
|
220 |
-
echo pmpro_getPaginationString($pn, $totalrows, $limit, 1, get_admin_url(NULL, "/admin.php?page=pmpro-reports&report=login&s=" . urlencode($s)), "&l=$l&limit=$limit&pn=");
|
221 |
-
?>
|
222 |
-
<?php
|
223 |
-
}
|
224 |
-
|
225 |
-
/*
|
226 |
-
Other code required for your reports. This file is loaded every time WP loads with PMPro enabled.
|
227 |
-
*/
|
228 |
-
|
229 |
-
//track visits
|
230 |
-
function pmpro_report_login_wp_visits()
|
231 |
-
{
|
232 |
-
//don't track admin
|
233 |
-
if(is_admin())
|
234 |
-
return;
|
235 |
-
|
236 |
-
//only track logged in users
|
237 |
-
if(!is_user_logged_in())
|
238 |
-
return;
|
239 |
-
|
240 |
-
//check for cookie
|
241 |
-
if(!empty($_COOKIE['pmpro_visit']))
|
242 |
-
return;
|
243 |
-
|
244 |
-
//set cookie, then track
|
245 |
-
setcookie("pmpro_visit", "1", NULL, COOKIEPATH, COOKIE_DOMAIN, false);
|
246 |
-
|
247 |
-
global $current_user;
|
248 |
-
//track for user
|
249 |
-
if(!empty($current_user->ID))
|
250 |
-
{
|
251 |
-
$visits = $current_user->pmpro_visits;
|
252 |
-
if(empty($visits))
|
253 |
-
$visits = array("last"=>"N/A", "thisdate"=>NULL, "month"=>0, "thismonth"=>NULL, "alltime"=>0);
|
254 |
-
|
255 |
-
//track logins for user
|
256 |
-
$visits['last'] = date(get_option("date_format"));
|
257 |
-
$visits['alltime']++;
|
258 |
-
$thismonth = date("n");
|
259 |
-
if($thismonth == $visits['thismonth'])
|
260 |
-
$visits['month']++;
|
261 |
-
else
|
262 |
-
{
|
263 |
-
$visits['month'] = 1;
|
264 |
-
$visits['thismonth'] = $thismonth;
|
265 |
-
}
|
266 |
-
|
267 |
-
//update user data
|
268 |
-
update_user_meta($current_user->ID, "pmpro_visits", $visits);
|
269 |
-
}
|
270 |
-
|
271 |
-
//track for all
|
272 |
-
$visits = get_option("pmpro_visits");
|
273 |
-
if(empty($visits))
|
274 |
-
$visits = array("today"=>0, "thisdate"=>NULL, "month"=>0, "thismonth"=> NULL, "alltime"=>0);
|
275 |
-
|
276 |
-
$visits['alltime']++;
|
277 |
-
$thisdate = date("Y-d-m");
|
278 |
-
if($thisdate == $visits['thisdate'])
|
279 |
-
$visits['today']++;
|
280 |
-
else
|
281 |
-
{
|
282 |
-
$visits['today'] = 1;
|
283 |
-
$visits['thisdate'] = $thisdate;
|
284 |
-
}
|
285 |
-
if($thismonth == $visits['thismonth'])
|
286 |
-
$visits['month']++;
|
287 |
-
else
|
288 |
-
{
|
289 |
-
$visits['month'] = 1;
|
290 |
-
$visits['thismonth'] = $thismonth;
|
291 |
-
}
|
292 |
-
|
293 |
-
update_option("pmpro_visits", $visits);
|
294 |
-
}
|
295 |
-
add_action("wp", "pmpro_report_login_wp_visits");
|
296 |
-
|
297 |
-
//we want to clear the pmpro_visit cookie on login/logout
|
298 |
-
function pmpro_report_login_clear_visit_cookie()
|
299 |
-
{
|
300 |
-
if(isset($_COOKIE['pmpro_visit']))
|
301 |
-
unset($_COOKIE['pmpro_visit']);
|
302 |
-
}
|
303 |
-
add_action("wp_login", "pmpro_report_login_clear_visit_cookie");
|
304 |
-
add_action("wp_logout", "pmpro_report_login_clear_visit_cookie");
|
305 |
-
|
306 |
-
//track views
|
307 |
-
function pmpro_report_login_wp_views()
|
308 |
-
{
|
309 |
-
//don't track admin
|
310 |
-
if(is_admin())
|
311 |
-
return;
|
312 |
-
|
313 |
-
global $current_user;
|
314 |
-
//track for user
|
315 |
-
if(!empty($current_user->ID))
|
316 |
-
{
|
317 |
-
$views = $current_user->pmpro_views;
|
318 |
-
if(empty($views))
|
319 |
-
$views = array("last"=>"N/A", "month"=>0, "alltime"=>0);
|
320 |
-
|
321 |
-
//track logins for user
|
322 |
-
$views['last'] = date(get_option("date_format"));
|
323 |
-
$views['alltime']++;
|
324 |
-
$thismonth = date("n");
|
325 |
-
if(isset($views['thismonth']) && $thismonth == $views['thismonth'])
|
326 |
-
$views['month']++;
|
327 |
-
else
|
328 |
-
{
|
329 |
-
$views['month'] = 1;
|
330 |
-
$views['thismonth'] = $thismonth;
|
331 |
-
}
|
332 |
-
|
333 |
-
//update user data
|
334 |
-
update_user_meta($current_user->ID, "pmpro_views", $views);
|
335 |
-
}
|
336 |
-
|
337 |
-
//track for all
|
338 |
-
$views = get_option("pmpro_views");
|
339 |
-
if(empty($views))
|
340 |
-
$views = array("today"=>0, "thisdate"=> NULL, "month"=>0, "thismonth"=> NULL, "alltime"=>0);
|
341 |
-
|
342 |
-
$views['alltime']++;
|
343 |
-
$thisdate = date("Y-d-m");
|
344 |
-
if($thisdate == $views['thisdate'])
|
345 |
-
$views['today']++;
|
346 |
-
else
|
347 |
-
{
|
348 |
-
$views['today'] = 1;
|
349 |
-
$views['thisdate'] = $thisdate;
|
350 |
-
}
|
351 |
-
$thismonth = date("n");
|
352 |
-
if(isset($views['thismonth']) && $thismonth == $views['thismonth'])
|
353 |
-
$views['month']++;
|
354 |
-
else
|
355 |
-
{
|
356 |
-
$views['month'] = 1;
|
357 |
-
$views['thismonth'] = $thismonth;
|
358 |
-
}
|
359 |
-
|
360 |
-
update_option("pmpro_views", $views);
|
361 |
-
}
|
362 |
-
add_action("wp", "pmpro_report_login_wp_views");
|
363 |
-
|
364 |
-
//track logins
|
365 |
-
function pmpro_report_login_wp_login($user_login)
|
366 |
-
{
|
367 |
-
//get user data
|
368 |
-
$user = get_user_by("login", $user_login);
|
369 |
-
$logins = $user->pmpro_logins;
|
370 |
-
if(empty($logins))
|
371 |
-
$logins = array("last"=>"N/A", "thisdate"=>NULL, "month"=>0, "thismonth"=> NULL, "alltime"=>0);
|
372 |
-
|
373 |
-
//track logins for user
|
374 |
-
$logins['last'] = date(get_option("date_format"));
|
375 |
-
$logins['alltime']++;
|
376 |
-
$thismonth = date("n");
|
377 |
-
if($thismonth == $logins['thismonth'])
|
378 |
-
$logins['month']++;
|
379 |
-
else
|
380 |
-
{
|
381 |
-
$logins['month'] = 1;
|
382 |
-
$logins['thismonth'] = $thismonth;
|
383 |
-
}
|
384 |
-
|
385 |
-
//update user data
|
386 |
-
update_user_meta($user->ID, "pmpro_logins", $logins);
|
387 |
-
|
388 |
-
//track logins overall
|
389 |
-
$logins = get_option("pmpro_logins");
|
390 |
-
if(empty($logins))
|
391 |
-
$logins = array("today"=>0, "thisdate"=>NULL, "month"=>0, "thismonth"=>NULL, "alltime"=>0);
|
392 |
-
|
393 |
-
$logins['alltime']++;
|
394 |
-
$thisdate = date("Y-d-m");
|
395 |
-
if($thisdate == $logins['thisdate'])
|
396 |
-
$logins['today']++;
|
397 |
-
else
|
398 |
-
{
|
399 |
-
$logins['today'] = 1;
|
400 |
-
$logins['thisdate'] = $thisdate;
|
401 |
-
}
|
402 |
-
if($thismonth == $logins['thismonth'])
|
403 |
-
$logins['month']++;
|
404 |
-
else
|
405 |
-
{
|
406 |
-
$logins['month'] = 1;
|
407 |
-
$logins['thismonth'] = $thismonth;
|
408 |
-
}
|
409 |
-
|
410 |
-
update_option("pmpro_logins", $logins);
|
411 |
-
}
|
412 |
-
add_action("wp_login", "pmpro_report_login_wp_login");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/reports/memberships.php
DELETED
@@ -1,651 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
PMPro Report
|
4 |
-
Title: Membership Stats
|
5 |
-
Slug: memberships
|
6 |
-
|
7 |
-
For each report, add a line like:
|
8 |
-
global $pmpro_reports;
|
9 |
-
$pmpro_reports['slug'] = 'Title';
|
10 |
-
|
11 |
-
For each report, also write two functions:
|
12 |
-
* pmpro_report_{slug}_widget() to show up on the report homepage.
|
13 |
-
* pmpro_report_{slug}_page() to show up when users click on the report page widget.
|
14 |
-
*/
|
15 |
-
|
16 |
-
global $pmpro_reports;
|
17 |
-
|
18 |
-
$pmpro_reports['memberships'] = __('Membership Stats', 'pmpro');
|
19 |
-
|
20 |
-
//queue Google Visualization JS on report page
|
21 |
-
function pmpro_report_memberships_init() {
|
22 |
-
if(is_admin() && isset($_REQUEST['report']) && $_REQUEST['report'] == "memberships" && isset($_REQUEST['page']) && $_REQUEST['page'] == "pmpro-reports")
|
23 |
-
wp_enqueue_script("jsapi", "https://www.google.com/jsapi");
|
24 |
-
}
|
25 |
-
add_action( 'init', 'pmpro_report_memberships_init' );
|
26 |
-
|
27 |
-
|
28 |
-
//widget
|
29 |
-
function pmpro_report_memberships_widget() {
|
30 |
-
global $wpdb, $pmpro_currency_symbol;
|
31 |
-
?>
|
32 |
-
<style type="text/css">
|
33 |
-
#pmpro_report_memberships .section-label {
|
34 |
-
margin: 15px 0;
|
35 |
-
font-size: 18px;
|
36 |
-
text-align: left;
|
37 |
-
display: block;
|
38 |
-
}
|
39 |
-
|
40 |
-
#pmpro_report_memberships .section-label:first-child {
|
41 |
-
margin-top: 0;
|
42 |
-
}
|
43 |
-
|
44 |
-
#pmpro_report_memberships div {text-align: center;}
|
45 |
-
#pmpro_report_memberships em {display: block; font-style: normal; font-size: 2em; margin: 5px; line-height: 26px;}
|
46 |
-
</style>
|
47 |
-
<span id="pmpro_report_memberships">
|
48 |
-
<label class="section-label"><?php _e('Signups', 'pmpro');?>:</label>
|
49 |
-
<div style="width: 25%; float: left;">
|
50 |
-
<label><?php _e('All Time', 'pmpro');?></label>
|
51 |
-
<em><?php echo pmpro_getSignups( 'all time' ); ?></em>
|
52 |
-
</div>
|
53 |
-
<div style="width: 25%; float: left;">
|
54 |
-
<label><?php _e('This Year', 'pmpro');?></label>
|
55 |
-
<em><?php echo pmpro_getSignups( 'this year' ); ?></em>
|
56 |
-
</div>
|
57 |
-
<div style="width: 25%; float: left;">
|
58 |
-
<label><?php _e('This Month', 'pmpro');?></label>
|
59 |
-
<em><?php echo pmpro_getSignups( 'this month' ); ?></em>
|
60 |
-
</div>
|
61 |
-
<div style="width: 25%; float: left;">
|
62 |
-
<label><?php _e('Today', 'pmpro');?></label>
|
63 |
-
<em><?php echo pmpro_getSignups( 'today' ); ?></em>
|
64 |
-
</div>
|
65 |
-
<div class="clear"></div>
|
66 |
-
|
67 |
-
<label class="section-label"><?php _e('Cancellations', 'pmpro');?>:</label>
|
68 |
-
<div style="width: 25%; float: left;">
|
69 |
-
<label><?php _e('All Time', 'pmpro');?></label>
|
70 |
-
<em><?php echo pmpro_getCancellations( 'all time' ); ?></em>
|
71 |
-
</div>
|
72 |
-
<div style="width: 25%; float: left;">
|
73 |
-
<label><?php _e('This Year', 'pmpro');?></label>
|
74 |
-
<em><?php echo pmpro_getCancellations( 'this year' ); ?></em>
|
75 |
-
</div>
|
76 |
-
<div style="width: 25%; float: left;">
|
77 |
-
<label><?php _e('This Month', 'pmpro');?></label>
|
78 |
-
<em><?php echo pmpro_getCancellations( 'this month' ); ?></em>
|
79 |
-
</div>
|
80 |
-
<div style="width: 25%; float: left;">
|
81 |
-
<label><?php _e('Today', 'pmpro');?></label>
|
82 |
-
<em><?php echo pmpro_getCancellations( 'today' ); ?></em>
|
83 |
-
</div>
|
84 |
-
<div class="clear"></div>
|
85 |
-
|
86 |
-
<label class="section-label"><?php _e('Other Stats', 'pmpro');?>:</label>
|
87 |
-
<div style="width: 33%; float: left;">
|
88 |
-
<label><?php _e('Monthly Recurring Revenue (MRR)', 'pmpro');?></label>
|
89 |
-
<em><?php echo $pmpro_currency_symbol . $pmpro_mrr = number_format(pmpro_getMRR( 'all time' ), 2); ?></em>
|
90 |
-
</div>
|
91 |
-
<div style="width: 33%; float: left;">
|
92 |
-
<label><?php _e('Cancellation Rate', 'pmpro');?></label>
|
93 |
-
<em><?php echo pmpro_getCancellationRate('all time' ); ?>%</em>
|
94 |
-
</div>
|
95 |
-
<div style="width: 33%; float: left;">
|
96 |
-
<label><?php _e('Lifetime Value (LTV)', 'pmpro');?></label>
|
97 |
-
<em><?php echo $pmpro_currency_symbol . number_format(pmpro_getLTV('all time' ), 2); ?></em>
|
98 |
-
</div>
|
99 |
-
<div class="clear"></div>
|
100 |
-
</span>
|
101 |
-
<?php
|
102 |
-
}
|
103 |
-
|
104 |
-
function pmpro_report_memberships_page()
|
105 |
-
{
|
106 |
-
global $wpdb, $pmpro_currency_symbol;
|
107 |
-
|
108 |
-
//get values from form
|
109 |
-
if(isset($_REQUEST['type']))
|
110 |
-
$type = sanitize_text_field($_REQUEST['type']);
|
111 |
-
else
|
112 |
-
$type = "signup_v_cancel";
|
113 |
-
|
114 |
-
if(isset($_REQUEST['period']))
|
115 |
-
$period = sanitize_text_field($_REQUEST['period']);
|
116 |
-
else
|
117 |
-
$period = "monthly";
|
118 |
-
|
119 |
-
if(isset($_REQUEST['month']))
|
120 |
-
$month = intval($_REQUEST['month']);
|
121 |
-
else
|
122 |
-
$month = date("n");
|
123 |
-
|
124 |
-
$thisyear = date("Y");
|
125 |
-
if(isset($_REQUEST['year']))
|
126 |
-
$year = intval($_REQUEST['year']);
|
127 |
-
else
|
128 |
-
$year = date("Y");
|
129 |
-
|
130 |
-
if(isset($_REQUEST['level']))
|
131 |
-
$l = intval($_REQUEST['level']);
|
132 |
-
else
|
133 |
-
$l = "";
|
134 |
-
|
135 |
-
//calculate start date and how to group dates returned from DB
|
136 |
-
if($period == "daily")
|
137 |
-
{
|
138 |
-
$startdate = $year . '-' . substr("0" . $month, strlen($month) - 1, 2) . '-01';
|
139 |
-
$enddate = $year . '-' . substr("0" . $month, strlen($month) - 1, 2) . '-31';
|
140 |
-
$date_function = 'DAY';
|
141 |
-
}
|
142 |
-
elseif($period == "monthly")
|
143 |
-
{
|
144 |
-
$startdate = $year . '-01-01';
|
145 |
-
$enddate = strval(intval($year)+1) . '-01-01';
|
146 |
-
$date_function = 'MONTH';
|
147 |
-
}
|
148 |
-
elseif($period == "annual")
|
149 |
-
{
|
150 |
-
$startdate = '1960-01-01'; //all time
|
151 |
-
$date_function = 'YEAR';
|
152 |
-
}
|
153 |
-
|
154 |
-
//testing or live data
|
155 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
156 |
-
|
157 |
-
//get data
|
158 |
-
if ( $type === "signup_v_cancel" ) {
|
159 |
-
$sqlQuery = "SELECT $date_function(startdate) as date, COUNT(DISTINCT user_id) as signups
|
160 |
-
FROM $wpdb->pmpro_memberships_users WHERE startdate >= '" . $startdate . "' ";
|
161 |
-
|
162 |
-
if(!empty($enddate))
|
163 |
-
$sqlQuery .= "AND startdate < '" . $enddate . "' ";
|
164 |
-
}
|
165 |
-
if ( $type === "mrr_ltv" ) {
|
166 |
-
// Get total revenue, number of months in system, and date
|
167 |
-
if ( $period == 'annual' )
|
168 |
-
$sqlQuery = "SELECT SUM(total) as total, COUNT(DISTINCT MONTH(timestamp)) as months, $date_function(timestamp) as date
|
169 |
-
FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token')
|
170 |
-
AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
171 |
-
|
172 |
-
if ( $period == 'monthly' )
|
173 |
-
$sqlQuery = "SELECT SUM(total) as total, $date_function(timestamp) as date
|
174 |
-
FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token')
|
175 |
-
AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
176 |
-
|
177 |
-
if(!empty($enddate))
|
178 |
-
$sqlQuery .= "AND timestamp < '" . $enddate . "' ";
|
179 |
-
}
|
180 |
-
|
181 |
-
if(!empty($l))
|
182 |
-
$sqlQuery .= "AND membership_id IN(" . $l . ") ";
|
183 |
-
|
184 |
-
$sqlQuery .= " GROUP BY date ORDER BY date ";
|
185 |
-
|
186 |
-
$dates = $wpdb->get_results($sqlQuery);
|
187 |
-
|
188 |
-
//fill in blanks in dates
|
189 |
-
$cols = array();
|
190 |
-
if($period == "daily")
|
191 |
-
{
|
192 |
-
$lastday = date("t", $startdate);
|
193 |
-
|
194 |
-
for($i = 1; $i <= $lastday; $i++)
|
195 |
-
{
|
196 |
-
// Signups vs. Cancellations
|
197 |
-
if ( $type === "signup_v_cancel" ) {
|
198 |
-
$cols[$i] = new stdClass();
|
199 |
-
$cols[$i]->signups = 0;
|
200 |
-
foreach($dates as $date)
|
201 |
-
{
|
202 |
-
if( $date->date == $i ) {
|
203 |
-
$cols[$i]->signups = $date->signups;
|
204 |
-
}
|
205 |
-
}
|
206 |
-
}
|
207 |
-
}
|
208 |
-
}
|
209 |
-
elseif($period == "monthly")
|
210 |
-
{
|
211 |
-
for($i = 1; $i < 13; $i++)
|
212 |
-
{
|
213 |
-
// Signups vs. Cancellations
|
214 |
-
if ( $type === "signup_v_cancel" ) {
|
215 |
-
$cols[$i] = new stdClass();
|
216 |
-
$cols[$i]->date = $i;
|
217 |
-
$cols[$i]->signups = 0;
|
218 |
-
foreach($dates as $date)
|
219 |
-
{
|
220 |
-
if( $date->date == $i ) {
|
221 |
-
$cols[$i]->date = $date->date;
|
222 |
-
$cols[$i]->signups = $date->signups;
|
223 |
-
}
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
227 |
-
// MRR & LTV
|
228 |
-
if ( $type === "mrr_ltv" ) {
|
229 |
-
$cols[$i] = new stdClass();
|
230 |
-
$cols[$i]->date = $i;
|
231 |
-
$cols[$i]->months = 1;
|
232 |
-
foreach($dates as $date)
|
233 |
-
{
|
234 |
-
if( $date->date == $i ) {
|
235 |
-
$cols[$i]->total = $date->total;
|
236 |
-
}
|
237 |
-
}
|
238 |
-
}
|
239 |
-
}
|
240 |
-
}
|
241 |
-
elseif($period == "annual") //annual
|
242 |
-
{
|
243 |
-
}
|
244 |
-
|
245 |
-
$dates = ( ! empty( $cols ) ) ? $cols : $dates;
|
246 |
-
|
247 |
-
// Signups vs. cancellations
|
248 |
-
if ( $type === "signup_v_cancel" )
|
249 |
-
{
|
250 |
-
$sqlQuery = "SELECT $date_function(mu1.modified) as date, COUNT(DISTINCT mu1.user_id) as cancellations
|
251 |
-
FROM $wpdb->pmpro_memberships_users mu1
|
252 |
-
LEFT JOIN $wpdb->pmpro_memberships_users mu2 ON mu1.user_id = mu2.user_id AND
|
253 |
-
mu2.modified > mu1.enddate AND
|
254 |
-
DATE_ADD(mu1.modified, INTERVAL 1 DAY) > mu2.startdate
|
255 |
-
WHERE mu1.status = 'inactive'
|
256 |
-
AND mu2.id IS NULL
|
257 |
-
AND mu1.startdate >= '" . $startdate . "'
|
258 |
-
AND mu1.startdate < '" . $enddate . "' ";
|
259 |
-
|
260 |
-
//restrict by level
|
261 |
-
if(!empty($l))
|
262 |
-
$sqlQuery .= "AND membership_id IN(" . $l . ") ";
|
263 |
-
|
264 |
-
$sqlQuery .= " GROUP BY date ORDER BY date ";
|
265 |
-
|
266 |
-
$cdates = $wpdb->get_results($sqlQuery, OBJECT_K);
|
267 |
-
|
268 |
-
foreach( $dates as &$date )
|
269 |
-
{
|
270 |
-
if(!empty($cdates[$date->date]))
|
271 |
-
$date->cancellations = $cdates[$date->date]->cancellations;
|
272 |
-
else
|
273 |
-
$date->cancellations = 0;
|
274 |
-
}
|
275 |
-
}
|
276 |
-
|
277 |
-
// MRR & LTV
|
278 |
-
if ( $type === "mrr_ltv" && count( $dates ) === 1 ) {
|
279 |
-
$dummy_date = new stdClass();
|
280 |
-
$dummy_date->total = 0;
|
281 |
-
$dummy_date->months = 0;
|
282 |
-
$dummy_date->date = $dates[0]->date - 1;
|
283 |
-
array_unshift( $dates, $dummy_date ); // Add to beginning
|
284 |
-
}
|
285 |
-
?>
|
286 |
-
<form id="posts-filter" method="get" action="">
|
287 |
-
<h2>
|
288 |
-
<?php _e('Membership Stats', 'pmpro');?>
|
289 |
-
</h2>
|
290 |
-
<ul class="subsubsub">
|
291 |
-
<li>
|
292 |
-
<?php _ex('Show', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?>
|
293 |
-
<select id="period" name="period">
|
294 |
-
<option value="daily" <?php selected($period, "daily");?>><?php _e('Daily', 'pmpro');?></option>
|
295 |
-
<option value="monthly" <?php selected($period, "monthly");?>><?php _e('Monthly', 'pmpro');?></option>
|
296 |
-
<option value="annual" <?php selected($period, "annual");?>><?php _e('Annual', 'pmpro');?></option>
|
297 |
-
</select>
|
298 |
-
<select id="type" name="type">
|
299 |
-
<option value="signup_v_cancel" <?php selected($type, "signup_v_cancel");?>><?php _e('Signups vs. Cancellations', 'pmpro');?></option>
|
300 |
-
<?php /*
|
301 |
-
<option value="mrr_ltv" <?php selected($type, "mrr_ltv");?>><?php _e('MRR & LTV', 'pmpro');?></option>
|
302 |
-
*/ ?>
|
303 |
-
</select>
|
304 |
-
<span id="for"><?php _ex('for', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?></span>
|
305 |
-
<select id="month" name="month">
|
306 |
-
<?php for($i = 1; $i < 13; $i++) { ?>
|
307 |
-
<option value="<?php echo $i;?>" <?php selected($month, $i);?>><?php echo date("F", mktime(0, 0, 0, $i));?></option>
|
308 |
-
<?php } ?>
|
309 |
-
</select>
|
310 |
-
<select id="year" name="year">
|
311 |
-
<?php for($i = $thisyear; $i > 2007; $i--) { ?>
|
312 |
-
<option value="<?php echo $i;?>" <?php selected($year, $i);?>><?php echo $i;?></option>
|
313 |
-
<?php } ?>
|
314 |
-
</select>
|
315 |
-
<span id="for"><?php _ex('for', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?></span>
|
316 |
-
<select name="level">
|
317 |
-
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'pmpro');?></option>
|
318 |
-
<?php
|
319 |
-
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
320 |
-
foreach($levels as $level)
|
321 |
-
{
|
322 |
-
?>
|
323 |
-
<option value="<?php echo $level->id?>" <?php if($l == $level->id) { ?>selected="selected"<?php } ?>><?php echo $level->name?></option>
|
324 |
-
<?php
|
325 |
-
}
|
326 |
-
?>
|
327 |
-
</select>
|
328 |
-
|
329 |
-
<input type="hidden" name="page" value="pmpro-reports" />
|
330 |
-
<input type="hidden" name="report" value="memberships" />
|
331 |
-
<input type="submit" value="<?php _ex('Generate Report', 'Submit button value.', 'pmpro');?>" />
|
332 |
-
</li>
|
333 |
-
</ul>
|
334 |
-
|
335 |
-
<div id="chart_div" style="clear: both; width: 100%; height: 500px;"></div>
|
336 |
-
|
337 |
-
<script>
|
338 |
-
//update month/year when period dropdown is changed
|
339 |
-
jQuery(document).ready(function() {
|
340 |
-
jQuery('#period').change(function() {
|
341 |
-
pmpro_ShowMonthOrYear();
|
342 |
-
});
|
343 |
-
});
|
344 |
-
|
345 |
-
function pmpro_ShowMonthOrYear()
|
346 |
-
{
|
347 |
-
var period = jQuery('#period').val();
|
348 |
-
if(period == 'daily')
|
349 |
-
{
|
350 |
-
jQuery('#for').show();
|
351 |
-
jQuery('#month').show();
|
352 |
-
jQuery('#year').show();
|
353 |
-
}
|
354 |
-
else if(period == 'monthly')
|
355 |
-
{
|
356 |
-
jQuery('#for').show();
|
357 |
-
jQuery('#month').hide();
|
358 |
-
jQuery('#year').show();
|
359 |
-
}
|
360 |
-
else
|
361 |
-
{
|
362 |
-
jQuery('#for').hide();
|
363 |
-
jQuery('#month').hide();
|
364 |
-
jQuery('#year').hide();
|
365 |
-
}
|
366 |
-
}
|
367 |
-
|
368 |
-
pmpro_ShowMonthOrYear();
|
369 |
-
|
370 |
-
//draw the chart
|
371 |
-
google.load("visualization", "1", {packages:["corechart"]});
|
372 |
-
google.setOnLoadCallback(drawChart);
|
373 |
-
function drawChart() {
|
374 |
-
|
375 |
-
var data = google.visualization.arrayToDataTable([
|
376 |
-
<?php if ( $type === "signup_v_cancel" ) : // Signups vs. cancellations ?>
|
377 |
-
['<?php echo $date_function;?>', 'Signups', 'Cancellations'],
|
378 |
-
<?php foreach($dates as $key => $value) { ?>
|
379 |
-
['<?php if($period == "monthly") echo date("M", mktime(0,0,0,$value->date)); else if($period == "daily") echo $key; else echo $value->date;?>', <?php echo $value->signups; ?>, <?php echo $value->cancellations; ?>],
|
380 |
-
<?php } ?>
|
381 |
-
<?php endif; ?>
|
382 |
-
|
383 |
-
<?php if ( $type === "mrr_ltv" ) : // Signups vs. cancellations ?>
|
384 |
-
['<?php echo $date_function;?>', 'MRR', 'LTV'],
|
385 |
-
<?php foreach($dates as $key => $value) { ?>
|
386 |
-
['<?php if($period == "monthly") echo date("M", mktime(0,0,0,$value->date)); else if($period == "daily") echo $key; else echo $value->date;?>', <?php echo (($mrr = $value->total / $value->months) && $mrr != 0) ? $mrr : 0; ?>, <?php echo pmpro_getLTV($period, NULL, $mrr ); ?>],
|
387 |
-
<?php } ?>
|
388 |
-
<?php endif; ?>
|
389 |
-
]);
|
390 |
-
|
391 |
-
var options = {
|
392 |
-
colors: ['#0099c6', '#dc3912'],
|
393 |
-
hAxis: {title: '<?php echo $date_function;?>', titleTextStyle: {color: 'black'}, maxAlternation: 1},
|
394 |
-
vAxis: {color: 'green', titleTextStyle: {color: '#51a351'}},
|
395 |
-
};
|
396 |
-
|
397 |
-
<?php if ( $type === "signup_v_cancel" ) : // Signups vs. cancellations ?>
|
398 |
-
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
|
399 |
-
<?php elseif ( $type === "mrr_ltv" ) : // MRR & LTV ?>
|
400 |
-
var formatter = new google.visualization.NumberFormat({prefix: '<?php echo html_entity_decode($pmpro_currency_symbol);?>'});
|
401 |
-
formatter.format(data, 2);
|
402 |
-
var formatter = new google.visualization.NumberFormat({prefix: '<?php echo html_entity_decode($pmpro_currency_symbol);?>'});
|
403 |
-
formatter.format(data, 1);
|
404 |
-
|
405 |
-
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
|
406 |
-
<?php endif; ?>
|
407 |
-
chart.draw(data, options);
|
408 |
-
}
|
409 |
-
</script>
|
410 |
-
|
411 |
-
</form>
|
412 |
-
<?php
|
413 |
-
}
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
/*
|
418 |
-
Other code required for your reports. This file is loaded every time WP loads with PMPro enabled.
|
419 |
-
*/
|
420 |
-
|
421 |
-
//get signups
|
422 |
-
function pmpro_getSignups($period = false, $levels = 'all')
|
423 |
-
{
|
424 |
-
//check for a transient
|
425 |
-
$cache = get_transient( 'pmpro_report_memberships_signups' );
|
426 |
-
if( ! empty( $cache ) && ! empty( $cache[$period] ) && ! empty( $cache[$period][$levels] ) )
|
427 |
-
return $cache[$period][$levels];
|
428 |
-
|
429 |
-
//a sale is an order with status = success
|
430 |
-
if( $period == 'today' )
|
431 |
-
$startdate = date(' Y-m-d' );
|
432 |
-
elseif( $period == 'this month')
|
433 |
-
$startdate = date( 'Y-m' ) . '-01';
|
434 |
-
elseif( $period == 'this year')
|
435 |
-
$startdate = date( 'Y' ) . '-01-01';
|
436 |
-
else
|
437 |
-
$startdate = '';
|
438 |
-
|
439 |
-
|
440 |
-
//build query
|
441 |
-
global $wpdb;
|
442 |
-
|
443 |
-
$sqlQuery = "SELECT COUNT(DISTINCT user_id) FROM $wpdb->pmpro_memberships_users WHERE startdate >= '" . $startdate . "' ";
|
444 |
-
|
445 |
-
//restrict by level
|
446 |
-
if(!empty($levels) && $levels != 'all')
|
447 |
-
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
448 |
-
|
449 |
-
$signups = $wpdb->get_var($sqlQuery);
|
450 |
-
|
451 |
-
//save in cache
|
452 |
-
if(!empty($cache) && !empty($cache[$period]))
|
453 |
-
$cache[$period][$levels] = $signups;
|
454 |
-
elseif(!empty($cache))
|
455 |
-
$cache[$period] = array($levels => $signups);
|
456 |
-
else
|
457 |
-
$cache = array($period => array($levels => $signups));
|
458 |
-
|
459 |
-
set_transient("pmpro_report_memberships_signups", $cache, 3600*24);
|
460 |
-
|
461 |
-
return $signups;
|
462 |
-
}
|
463 |
-
|
464 |
-
//get cancellations
|
465 |
-
function pmpro_getCancellations($period = false, $levels = 'all')
|
466 |
-
{
|
467 |
-
//check for a transient
|
468 |
-
$cache = get_transient( 'pmpro_report_memberships_cancellations' );
|
469 |
-
if( ! empty( $cache ) && ! empty( $cache[$period] ) && ! empty( $cache[$period][$levels] ) )
|
470 |
-
return $cache[$period][$levels];
|
471 |
-
|
472 |
-
//figure out start date
|
473 |
-
if( $period == 'today' )
|
474 |
-
$startdate = date(' Y-m-d' );
|
475 |
-
elseif( $period == 'this month')
|
476 |
-
$startdate = date( 'Y-m' ) . '-01';
|
477 |
-
elseif( $period == 'this year')
|
478 |
-
$startdate = date( 'Y' ) . '-01-01';
|
479 |
-
else
|
480 |
-
$startdate = '';
|
481 |
-
|
482 |
-
$startdate_plus_one = strtotime( $startdate . + ' + 1 day', current_time("timestamp") );
|
483 |
-
|
484 |
-
/*
|
485 |
-
build query.
|
486 |
-
cancellations are marked in the memberships users table with status = 'inactive'
|
487 |
-
we try to ignore cancellations when the user gets a new level with 24 hours (probably an upgrade or downgrade)
|
488 |
-
*/
|
489 |
-
global $wpdb;
|
490 |
-
|
491 |
-
//$sqlQuery = "SELECT mu1.user_id, mu2.user_id FROM $wpdb->pmpro_memberships_users mu1 LEFT JOIN $wpdb->pmpro_memberships_users mu2 ON mu1.user_id = mu2.user_id AND mu2.status = 'inactive' AND mu2.startdate > mu1.startdate";
|
492 |
-
$sqlQuery = "SELECT COUNT(mu1.id)
|
493 |
-
FROM $wpdb->pmpro_memberships_users mu1
|
494 |
-
LEFT JOIN $wpdb->pmpro_memberships_users mu2 ON mu1.user_id = mu2.user_id AND
|
495 |
-
mu2.modified > mu1.enddate AND
|
496 |
-
DATE_ADD(mu1.modified, INTERVAL 1 DAY) > mu2.startdate
|
497 |
-
WHERE mu1.status = 'inactive'
|
498 |
-
AND mu2.id IS NULL
|
499 |
-
AND mu1.startdate >= '" . $startdate . "' ";
|
500 |
-
|
501 |
-
//restrict by level
|
502 |
-
if(!empty($levels) && $levels != 'all')
|
503 |
-
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
504 |
-
|
505 |
-
$cancellations = $wpdb->get_var($sqlQuery);
|
506 |
-
|
507 |
-
//save in cache
|
508 |
-
if(!empty($cache) && !empty($cache[$period]) && is_array($cache[$period]))
|
509 |
-
$cache[$period][$levels] = $cancellations;
|
510 |
-
elseif(!empty($cache))
|
511 |
-
$cache[$period] = array($levels => $cancellations);
|
512 |
-
else
|
513 |
-
$cache = array($period => array($levels => $cancellations));
|
514 |
-
|
515 |
-
set_transient("pmpro_report_memberships_cancellations", $cache, 3600*24);
|
516 |
-
|
517 |
-
return $cancellations;
|
518 |
-
}
|
519 |
-
|
520 |
-
//get MRR
|
521 |
-
function pmpro_getMRR($period, $levels = 'all')
|
522 |
-
{
|
523 |
-
//check for a transient
|
524 |
-
//$cache = get_transient("pmpro_report_mrr");
|
525 |
-
if(!empty($cache) && !empty($cache[$period]) && !empty($cache[$period][$levels]))
|
526 |
-
return $cache[$period][$levels];
|
527 |
-
|
528 |
-
//a sale is an order with status NOT IN refunded, review, token, error
|
529 |
-
if($period == "this month")
|
530 |
-
$startdate = date("Y-m") . "-01";
|
531 |
-
elseif($period == "this year")
|
532 |
-
$startdate = date("Y") . "-01-01";
|
533 |
-
else
|
534 |
-
$startdate = "";
|
535 |
-
|
536 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
537 |
-
|
538 |
-
//build query
|
539 |
-
global $wpdb;
|
540 |
-
// Get total revenue
|
541 |
-
$sqlQuery = "SELECT SUM(total) FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token', 'error') AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
542 |
-
|
543 |
-
//restrict by level
|
544 |
-
if(!empty($levels) && $levels != 'all') {
|
545 |
-
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
546 |
-
}
|
547 |
-
|
548 |
-
$revenue = $wpdb->get_var($sqlQuery);
|
549 |
-
|
550 |
-
//when was the first order
|
551 |
-
$first_order_timestamp = $wpdb->get_var("SELECT UNIX_TIMESTAMP(`timestamp`) FROM $wpdb->pmpro_membership_orders WHERE `timestamp` IS NOT NULL AND `timestamp` > '0000-00-00 00:00:00' ORDER BY `timestamp` LIMIT 1");
|
552 |
-
|
553 |
-
//if we don't have a timestamp, we can't do this
|
554 |
-
if(empty($first_order_timestamp))
|
555 |
-
return false;
|
556 |
-
|
557 |
-
//how many months ago was the first order
|
558 |
-
$months = $wpdb->get_var("SELECT PERIOD_DIFF('" . date("Ym") . "', '" . date("Ym", $first_order_timestamp) . "')");
|
559 |
-
|
560 |
-
/* this works in PHP 5.3+ without using MySQL to get the diff
|
561 |
-
$date1 = new DateTime(date("Y-m-d", $first_order_timestamp));
|
562 |
-
$date2 = new DateTime(date("Y-m-d"));
|
563 |
-
$interval = $date1->diff($date2);
|
564 |
-
$years = intval($interval->format('%y'));
|
565 |
-
$months = $years*12 + intval($interval->format('%m'));
|
566 |
-
*/
|
567 |
-
|
568 |
-
if($months > 0)
|
569 |
-
$mrr = $revenue / $months;
|
570 |
-
else
|
571 |
-
$mrr = 0;
|
572 |
-
|
573 |
-
//save in cache
|
574 |
-
if(!empty($cache) && !empty($cache[$period]))
|
575 |
-
$cache[$period][$levels] = $mrr;
|
576 |
-
elseif(!empty($cache))
|
577 |
-
$cache[$period] = array($levels => $mrr);
|
578 |
-
else
|
579 |
-
$cache = array($period => array($levels => $mrr));
|
580 |
-
|
581 |
-
set_transient("pmpro_report_mrr", $cache, 3600*24);
|
582 |
-
|
583 |
-
return $mrr;
|
584 |
-
}
|
585 |
-
|
586 |
-
//get Cancellation Rate
|
587 |
-
function pmpro_getCancellationRate($period, $levels = 'all')
|
588 |
-
{
|
589 |
-
//check for a transient
|
590 |
-
$cache = get_transient("pmpro_report_cancellation_rate");
|
591 |
-
if(!empty($cache) && !empty($cache[$period]) && !empty($cache[$period][$levels]))
|
592 |
-
return $cache[$period][$levels];
|
593 |
-
|
594 |
-
$signups = pmpro_getSignups($period, $levels);
|
595 |
-
$cancellations = pmpro_getCancellations($period, $levels);
|
596 |
-
|
597 |
-
if(empty($signups))
|
598 |
-
return false;
|
599 |
-
|
600 |
-
$rate = number_format(($cancellations / $signups)*100, 2);
|
601 |
-
|
602 |
-
//save in cache
|
603 |
-
if(!empty($cache) && !empty($cache[$period]))
|
604 |
-
$cache[$period][$levels] = $rate;
|
605 |
-
elseif(!empty($cache))
|
606 |
-
$cache[$period] = array($levels => $rate);
|
607 |
-
else
|
608 |
-
$cache = array($period => array($levels => $rate));
|
609 |
-
|
610 |
-
set_transient("pmpro_report_cancellation_rate", $cache, 3600*24);
|
611 |
-
|
612 |
-
return $rate;
|
613 |
-
}
|
614 |
-
|
615 |
-
//get LTV
|
616 |
-
function pmpro_getLTV($period, $levels = 'all', $mrr = NULL, $signups = NULL, $cancellation_rate = NULL)
|
617 |
-
{
|
618 |
-
if(empty($mrr))
|
619 |
-
$mrr = pmpro_getMRR($period, $levels);
|
620 |
-
if(empty($signups))
|
621 |
-
$signups = pmpro_getSignups($period, $levels);
|
622 |
-
if(empty($cancellation_rate))
|
623 |
-
$cancellation_rate = pmpro_getCancellationRate($period, $levels);
|
624 |
-
|
625 |
-
//average monthly spend
|
626 |
-
if(empty($signups))
|
627 |
-
return false;
|
628 |
-
|
629 |
-
if($signups > 0)
|
630 |
-
$ams = $mrr / $signups;
|
631 |
-
else
|
632 |
-
$ams = 0;
|
633 |
-
|
634 |
-
if($cancellation_rate > 0)
|
635 |
-
$ltv = $ams * (1/$cancellation_rate);
|
636 |
-
else
|
637 |
-
$ltv = $ams;
|
638 |
-
|
639 |
-
return $ltv;
|
640 |
-
}
|
641 |
-
|
642 |
-
//delete transients when an order goes through
|
643 |
-
function pmpro_report_memberships_delete_transients()
|
644 |
-
{
|
645 |
-
delete_transient("pmpro_report_mrr");
|
646 |
-
delete_transient("pmpro_report_cancellation_rate");
|
647 |
-
delete_transient("pmpro_report_memberships_cancellations");
|
648 |
-
delete_transient("pmpro_report_memberships_signups");
|
649 |
-
}
|
650 |
-
add_action("pmpro_after_checkout", "pmpro_report_memberships_delete_transients");
|
651 |
-
add_action("pmpro_updated_order", "pmpro_report_memberships_delete_transients");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adminpages/reports/sales.php
DELETED
@@ -1,397 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
PMPro Report
|
4 |
-
Title: Sales
|
5 |
-
Slug: sales
|
6 |
-
|
7 |
-
For each report, add a line like:
|
8 |
-
global $pmpro_reports;
|
9 |
-
$pmpro_reports['slug'] = 'Title';
|
10 |
-
|
11 |
-
For each report, also write two functions:
|
12 |
-
* pmpro_report_{slug}_widget() to show up on the report homepage.
|
13 |
-
* pmpro_report_{slug}_page() to show up when users click on the report page widget.
|
14 |
-
*/
|
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)', 'pmpro');
|
19 |
-
else
|
20 |
-
$pmpro_reports['sales'] = __('Sales and Revenue', 'pmpro');
|
21 |
-
|
22 |
-
//queue Google Visualization JS on report page
|
23 |
-
function pmpro_report_sales_init()
|
24 |
-
{
|
25 |
-
if(is_admin() && isset($_REQUEST['report']) && $_REQUEST['report'] == "sales" && isset($_REQUEST['page']) && $_REQUEST['page'] == "pmpro-reports")
|
26 |
-
{
|
27 |
-
wp_enqueue_script("jsapi", "https://www.google.com/jsapi");
|
28 |
-
}
|
29 |
-
}
|
30 |
-
add_action("init", "pmpro_report_sales_init");
|
31 |
-
|
32 |
-
//widget
|
33 |
-
function pmpro_report_sales_widget()
|
34 |
-
{
|
35 |
-
global $wpdb, $pmpro_currency_symbol;
|
36 |
-
?>
|
37 |
-
<style>
|
38 |
-
#pmpro_report_sales div {text-align: center;}
|
39 |
-
#pmpro_report_sales em {display: block; font-style: normal; font-size: 2em; margin: 5px;}
|
40 |
-
</style>
|
41 |
-
<span id="#pmpro_report_sales">
|
42 |
-
<div style="width: 25%; float: left;">
|
43 |
-
<em><?php echo pmpro_getSales("all time");?></em>
|
44 |
-
<label>All Time</label>
|
45 |
-
<em><?php echo $pmpro_currency_symbol . number_format(pmpro_getRevenue("all time"), 2);?></em>
|
46 |
-
</div>
|
47 |
-
<div style="width: 25%; float: left;">
|
48 |
-
<em><?php echo pmpro_getSales("this year");?></em>
|
49 |
-
<label>This Year</label>
|
50 |
-
<em><?php echo $pmpro_currency_symbol . number_format(pmpro_getRevenue("this year"), 2);?></em>
|
51 |
-
</div>
|
52 |
-
<div style="width: 25%; float: left;">
|
53 |
-
<em><?php echo pmpro_getSales("this month");?></em>
|
54 |
-
<label>This Month</label>
|
55 |
-
<em><?php echo $pmpro_currency_symbol . number_format(pmpro_getRevenue("this month"), 2);?></em>
|
56 |
-
</div>
|
57 |
-
<div style="width: 25%; float: left;">
|
58 |
-
<em><?php echo pmpro_getSales("today");?></em>
|
59 |
-
<label>Today</label>
|
60 |
-
<em><?php echo $pmpro_currency_symbol . number_format(pmpro_getRevenue("today"), 2);?></em>
|
61 |
-
</div>
|
62 |
-
<div class="clear"></div>
|
63 |
-
</span>
|
64 |
-
<?php
|
65 |
-
}
|
66 |
-
|
67 |
-
function pmpro_report_sales_page()
|
68 |
-
{
|
69 |
-
global $wpdb, $pmpro_currency_symbol;
|
70 |
-
|
71 |
-
//get values from form
|
72 |
-
if(isset($_REQUEST['type']))
|
73 |
-
$type = sanitize_text_field($_REQUEST['type']);
|
74 |
-
else
|
75 |
-
$type = "revenue";
|
76 |
-
|
77 |
-
if($type == "sales")
|
78 |
-
$type_function = "COUNT";
|
79 |
-
else
|
80 |
-
$type_function = "SUM";
|
81 |
-
|
82 |
-
if(isset($_REQUEST['period']))
|
83 |
-
$period = sanitize_text_field($_REQUEST['period']);
|
84 |
-
else
|
85 |
-
$period = "daily";
|
86 |
-
|
87 |
-
if(isset($_REQUEST['month']))
|
88 |
-
$month = intval($_REQUEST['month']);
|
89 |
-
else
|
90 |
-
$month = date("n");
|
91 |
-
|
92 |
-
$thisyear = date("Y");
|
93 |
-
if(isset($_REQUEST['year']))
|
94 |
-
$year = intval($_REQUEST['year']);
|
95 |
-
else
|
96 |
-
$year = $thisyear;
|
97 |
-
|
98 |
-
if(isset($_REQUEST['level']))
|
99 |
-
$l = intval($_REQUEST['level']);
|
100 |
-
else
|
101 |
-
$l = "";
|
102 |
-
|
103 |
-
//calculate start date and how to group dates returned from DB
|
104 |
-
if($period == "daily")
|
105 |
-
{
|
106 |
-
$startdate = $year . '-' . substr("0" . $month, strlen($month) - 1, 2) . '-01';
|
107 |
-
$enddate = $year . '-' . substr("0" . $month, strlen($month) - 1, 2) . '-31';
|
108 |
-
$date_function = 'DAY';
|
109 |
-
}
|
110 |
-
elseif($period == "monthly")
|
111 |
-
{
|
112 |
-
$startdate = $year . '-01-01';
|
113 |
-
$enddate = strval(intval($year)+1) . '-01-01';
|
114 |
-
$date_function = 'MONTH';
|
115 |
-
}
|
116 |
-
else
|
117 |
-
{
|
118 |
-
$startdate = '1960-01-01'; //all time
|
119 |
-
$date_function = 'YEAR';
|
120 |
-
}
|
121 |
-
|
122 |
-
//testing or live data
|
123 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
124 |
-
|
125 |
-
//get data
|
126 |
-
$sqlQuery = "SELECT $date_function(timestamp) as date, $type_function(total) as value FROM $wpdb->pmpro_membership_orders WHERE timestamp >= '" . $startdate . "' AND status NOT IN('refunded', 'review', 'token', 'error') AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
127 |
-
|
128 |
-
if(!empty($enddate))
|
129 |
-
$sqlQuery .= "AND timestamp < '" . $enddate . "' ";
|
130 |
-
|
131 |
-
if(!empty($l))
|
132 |
-
$sqlQuery .= "AND membership_id IN(" . $l . ") ";
|
133 |
-
|
134 |
-
$sqlQuery .= " GROUP BY date ORDER BY date ";
|
135 |
-
|
136 |
-
$dates = $wpdb->get_results($sqlQuery);
|
137 |
-
|
138 |
-
//fill in blanks in dates
|
139 |
-
$cols = array();
|
140 |
-
if($period == "daily")
|
141 |
-
{
|
142 |
-
$lastday = date("t", $startdate);
|
143 |
-
|
144 |
-
for($i = 1; $i <= $lastday; $i++)
|
145 |
-
{
|
146 |
-
$cols[$i] = 0;
|
147 |
-
foreach($dates as $date)
|
148 |
-
{
|
149 |
-
if($date->date == $i)
|
150 |
-
$cols[$i] = $date->value;
|
151 |
-
}
|
152 |
-
}
|
153 |
-
}
|
154 |
-
elseif($period == "monthly")
|
155 |
-
{
|
156 |
-
for($i = 1; $i < 13; $i++)
|
157 |
-
{
|
158 |
-
$cols[$i] = 0;
|
159 |
-
foreach($dates as $date)
|
160 |
-
{
|
161 |
-
if($date->date == $i)
|
162 |
-
$cols[$i] = $date->value;
|
163 |
-
}
|
164 |
-
}
|
165 |
-
}
|
166 |
-
else //annual
|
167 |
-
{
|
168 |
-
//get min and max years
|
169 |
-
$min = 9999;
|
170 |
-
$max = 0;
|
171 |
-
foreach($dates as $date)
|
172 |
-
{
|
173 |
-
$min = min($min, $date->date);
|
174 |
-
$max = max($max, $date->date);
|
175 |
-
}
|
176 |
-
|
177 |
-
for($i = $min; $i <= $max; $i++)
|
178 |
-
{
|
179 |
-
foreach($dates as $date)
|
180 |
-
{
|
181 |
-
if($date->date == $i)
|
182 |
-
$cols[$i] = $date->value;
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
?>
|
187 |
-
<form id="posts-filter" method="get" action="">
|
188 |
-
<h2>
|
189 |
-
<?php _e('Sales and Revenue', 'pmpro');?>
|
190 |
-
</h2>
|
191 |
-
|
192 |
-
<div class="tablenav top">
|
193 |
-
<?php _ex('Show', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?>
|
194 |
-
<select id="period" name="period">
|
195 |
-
<option value="daily" <?php selected($period, "daily");?>><?php _e('Daily', 'pmpro');?></option>
|
196 |
-
<option value="monthly" <?php selected($period, "monthly");?>><?php _e('Monthly', 'pmpro');?></option>
|
197 |
-
<option value="annual" <?php selected($period, "annual");?>><?php _e('Annual', 'pmpro');?></option>
|
198 |
-
</select>
|
199 |
-
<select name="type">
|
200 |
-
<option value="revenue" <?php selected($type, "revenue");?>><?php _e('Revenue', 'pmpro');?></option>
|
201 |
-
<option value="sales" <?php selected($type, "sales");?>><?php _e('Sales', 'pmpro');?></option>
|
202 |
-
</select>
|
203 |
-
<span id="for"><?php _ex('for', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?></span>
|
204 |
-
<select id="month" name="month">
|
205 |
-
<?php for($i = 1; $i < 13; $i++) { ?>
|
206 |
-
<option value="<?php echo $i;?>" <?php selected($month, $i);?>><?php echo date("F", mktime(0, 0, 0, $i));?></option>
|
207 |
-
<?php } ?>
|
208 |
-
</select>
|
209 |
-
<select id="year" name="year">
|
210 |
-
<?php for($i = $thisyear; $i > 2007; $i--) { ?>
|
211 |
-
<option value="<?php echo $i;?>" <?php selected($year, $i);?>><?php echo $i;?></option>
|
212 |
-
<?php } ?>
|
213 |
-
</select>
|
214 |
-
<span id="for"><?php _ex('for', 'Dropdown label, e.g. Show Daily Revenue for January', 'pmpro')?></span>
|
215 |
-
<select name="level">
|
216 |
-
<option value="" <?php if(!$l) { ?>selected="selected"<?php } ?>><?php _e('All Levels', 'pmpro');?></option>
|
217 |
-
<?php
|
218 |
-
$levels = $wpdb->get_results("SELECT id, name FROM $wpdb->pmpro_membership_levels ORDER BY name");
|
219 |
-
foreach($levels as $level)
|
220 |
-
{
|
221 |
-
?>
|
222 |
-
<option value="<?php echo $level->id?>" <?php if($l == $level->id) { ?>selected="selected"<?php } ?>><?php echo $level->name?></option>
|
223 |
-
<?php
|
224 |
-
}
|
225 |
-
?>
|
226 |
-
</select>
|
227 |
-
|
228 |
-
<input type="hidden" name="page" value="pmpro-reports" />
|
229 |
-
<input type="hidden" name="report" value="sales" />
|
230 |
-
<input type="submit" class="button action" value="<?php _ex('Generate Report', 'Submit button value.', 'pmpro');?>" />
|
231 |
-
</div>
|
232 |
-
|
233 |
-
<div id="chart_div" style="clear: both; width: 100%; height: 500px;"></div>
|
234 |
-
|
235 |
-
<script>
|
236 |
-
//update month/year when period dropdown is changed
|
237 |
-
jQuery(document).ready(function() {
|
238 |
-
jQuery('#period').change(function() {
|
239 |
-
pmpro_ShowMonthOrYear();
|
240 |
-
});
|
241 |
-
});
|
242 |
-
|
243 |
-
function pmpro_ShowMonthOrYear()
|
244 |
-
{
|
245 |
-
var period = jQuery('#period').val();
|
246 |
-
if(period == 'daily')
|
247 |
-
{
|
248 |
-
jQuery('#for').show();
|
249 |
-
jQuery('#month').show();
|
250 |
-
jQuery('#year').show();
|
251 |
-
}
|
252 |
-
else if(period == 'monthly')
|
253 |
-
{
|
254 |
-
jQuery('#for').show();
|
255 |
-
jQuery('#month').hide();
|
256 |
-
jQuery('#year').show();
|
257 |
-
}
|
258 |
-
else
|
259 |
-
{
|
260 |
-
jQuery('#for').hide();
|
261 |
-
jQuery('#month').hide();
|
262 |
-
jQuery('#year').hide();
|
263 |
-
}
|
264 |
-
}
|
265 |
-
|
266 |
-
pmpro_ShowMonthOrYear();
|
267 |
-
|
268 |
-
//draw the chart
|
269 |
-
google.load("visualization", "1", {packages:["corechart"]});
|
270 |
-
google.setOnLoadCallback(drawChart);
|
271 |
-
function drawChart() {
|
272 |
-
|
273 |
-
var data = google.visualization.arrayToDataTable([
|
274 |
-
['<?php echo $date_function;?>', '<?php echo ucwords($type);?>'],
|
275 |
-
<?php foreach($cols as $date => $value) { ?>
|
276 |
-
['<?php if($period == "monthly") echo date("M", mktime(0,0,0,$date)); else echo $date;?>', <?php echo $value;?>],
|
277 |
-
<?php } ?>
|
278 |
-
]);
|
279 |
-
|
280 |
-
var options = {
|
281 |
-
colors: ['#51a351', '#387038'],
|
282 |
-
hAxis: {title: '<?php echo $date_function;?>', titleTextStyle: {color: 'black'}, maxAlternation: 1},
|
283 |
-
vAxis: {color: 'green', titleTextStyle: {color: '#51a351'}},
|
284 |
-
};
|
285 |
-
|
286 |
-
<?php if($type != "sales") { ?>
|
287 |
-
var formatter = new google.visualization.NumberFormat({prefix: '<?php echo html_entity_decode($pmpro_currency_symbol);?>'});
|
288 |
-
formatter.format(data, 1);
|
289 |
-
<?php } ?>
|
290 |
-
|
291 |
-
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
|
292 |
-
chart.draw(data, options);
|
293 |
-
}
|
294 |
-
</script>
|
295 |
-
|
296 |
-
</form>
|
297 |
-
<?php
|
298 |
-
}
|
299 |
-
|
300 |
-
/*
|
301 |
-
Other code required for your reports. This file is loaded every time WP loads with PMPro enabled.
|
302 |
-
*/
|
303 |
-
|
304 |
-
//get sales
|
305 |
-
function pmpro_getSales($period, $levels = NULL)
|
306 |
-
{
|
307 |
-
//check for a transient
|
308 |
-
$cache = get_transient("pmpro_report_sales");
|
309 |
-
if(!empty($cache) && !empty($cache[$period]) && !empty($cache[$period][$levels]))
|
310 |
-
return $cache[$period][$levels];
|
311 |
-
|
312 |
-
//a sale is an order with status NOT IN('refunded', 'review', 'token', 'error')
|
313 |
-
if($period == "today")
|
314 |
-
$startdate = date("Y-m-d");
|
315 |
-
elseif($period == "this month")
|
316 |
-
$startdate = date("Y-m") . "-01";
|
317 |
-
elseif($period == "this year")
|
318 |
-
$startdate = date("Y") . "-01-01";
|
319 |
-
else
|
320 |
-
$startdate = "";
|
321 |
-
|
322 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
323 |
-
|
324 |
-
//build query
|
325 |
-
global $wpdb;
|
326 |
-
$sqlQuery = "SELECT COUNT(*) FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token', 'error') AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
327 |
-
|
328 |
-
//restrict by level
|
329 |
-
if(!empty($levels))
|
330 |
-
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
331 |
-
|
332 |
-
$sales = $wpdb->get_var($sqlQuery);
|
333 |
-
|
334 |
-
//save in cache
|
335 |
-
if(!empty($cache) && !empty($cache[$period]))
|
336 |
-
$cache[$period][$levels] = $sales;
|
337 |
-
elseif(!empty($cache))
|
338 |
-
$cache[$period] = array($levels => $sales);
|
339 |
-
else
|
340 |
-
$cache = array($period => array($levels => $sales));
|
341 |
-
|
342 |
-
set_transient("pmpro_report_sales", $cache, 3600*24);
|
343 |
-
|
344 |
-
return $sales;
|
345 |
-
}
|
346 |
-
|
347 |
-
//get revenue
|
348 |
-
function pmpro_getRevenue($period, $levels = NULL)
|
349 |
-
{
|
350 |
-
//check for a transient
|
351 |
-
$cache = get_transient("pmpro_report_revenue");
|
352 |
-
if(!empty($cache) && !empty($cache[$period]) && !empty($cache[$period][$levels]))
|
353 |
-
return $cache[$period][$levels];
|
354 |
-
|
355 |
-
//a sale is an order with status NOT IN('refunded', 'review', 'token', 'error')
|
356 |
-
if($period == "today")
|
357 |
-
$startdate = date("Y-m-d");
|
358 |
-
elseif($period == "this month")
|
359 |
-
$startdate = date("Y-m") . "-01";
|
360 |
-
elseif($period == "this year")
|
361 |
-
$startdate = date("Y") . "-01-01";
|
362 |
-
else
|
363 |
-
$startdate = "";
|
364 |
-
|
365 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
366 |
-
|
367 |
-
//build query
|
368 |
-
global $wpdb;
|
369 |
-
$sqlQuery = "SELECT SUM(total) FROM $wpdb->pmpro_membership_orders WHERE status NOT IN('refunded', 'review', 'token', 'error') AND timestamp >= '" . $startdate . "' AND gateway_environment = '" . esc_sql($gateway_environment) . "' ";
|
370 |
-
|
371 |
-
//restrict by level
|
372 |
-
if(!empty($levels))
|
373 |
-
$sqlQuery .= "AND membership_id IN(" . $levels . ") ";
|
374 |
-
|
375 |
-
$revenue = $wpdb->get_var($sqlQuery);
|
376 |
-
|
377 |
-
//save in cache
|
378 |
-
if(!empty($cache) && !empty($cache[$period]))
|
379 |
-
$cache[$period][$levels] = $revenue;
|
380 |
-
elseif(!empty($cache))
|
381 |
-
$cache[$period] = array($levels => $revenue);
|
382 |
-
else
|
383 |
-
$cache = array($period => array($levels => $revenue));
|
384 |
-
|
385 |
-
set_transient("pmpro_report_revenue", $cache, 3600*24);
|
386 |
-
|
387 |
-
return $revenue;
|
388 |
-
}
|
389 |
-
|
390 |
-
//delete transients when an order goes through
|
391 |
-
function pmpro_report_sales_delete_transients()
|
392 |
-
{
|
393 |
-
delete_transient("pmpro_report_sales");
|
394 |
-
delete_transient("pmpro_report_revenue");
|
395 |
-
}
|
396 |
-
add_action("pmpro_after_checkout", "pmpro_report_sales_delete_transients");
|
397 |
-
add_action("pmpro_updated_order", "pmpro_report_sales_delete_transients");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/class.memberorder.php
CHANGED
@@ -3,10 +3,6 @@
|
|
3 |
{
|
4 |
function MemberOrder($id = NULL)
|
5 |
{
|
6 |
-
//setup the gateway
|
7 |
-
$this->setGateway(pmpro_getOption("gateway"));
|
8 |
-
|
9 |
-
//get data if an id was passed
|
10 |
if($id)
|
11 |
{
|
12 |
if(is_numeric($id))
|
@@ -16,7 +12,7 @@
|
|
16 |
}
|
17 |
else
|
18 |
return true; //blank constructor
|
19 |
-
}
|
20 |
|
21 |
function getMemberOrderByID($id)
|
22 |
{
|
@@ -29,34 +25,24 @@
|
|
29 |
$dbobj = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(timestamp) + " . ($gmt_offset * 3600) . " as timestamp FROM $wpdb->pmpro_membership_orders WHERE id = '$id' LIMIT 1");
|
30 |
|
31 |
if($dbobj)
|
32 |
-
{
|
33 |
$this->id = $dbobj->id;
|
34 |
$this->code = $dbobj->code;
|
35 |
$this->session_id = $dbobj->session_id;
|
36 |
$this->user_id = $dbobj->user_id;
|
37 |
$this->membership_id = $dbobj->membership_id;
|
38 |
$this->paypal_token = $dbobj->paypal_token;
|
39 |
-
$this->billing = new stdClass();
|
40 |
$this->billing->name = $dbobj->billing_name;
|
41 |
$this->billing->street = $dbobj->billing_street;
|
42 |
$this->billing->city = $dbobj->billing_city;
|
43 |
$this->billing->state = $dbobj->billing_state;
|
44 |
$this->billing->zip = $dbobj->billing_zip;
|
45 |
-
$this->billing->country = $dbobj->billing_country;
|
46 |
$this->billing->phone = $dbobj->billing_phone;
|
47 |
|
48 |
//split up some values
|
49 |
$nameparts = pnp_split_full_name($this->billing->name);
|
50 |
-
|
51 |
-
|
52 |
-
$this->FirstName = $nameparts['fname'];
|
53 |
-
else
|
54 |
-
$this->FirstName = "";
|
55 |
-
if(!empty($nameparts['lname']))
|
56 |
-
$this->LastName = $nameparts['lname'];
|
57 |
-
else
|
58 |
-
$this->LastName = "";
|
59 |
-
|
60 |
$this->Address1 = $this->billing->street;
|
61 |
|
62 |
//get email from user_id
|
@@ -87,45 +73,13 @@
|
|
87 |
$this->affiliate_id = $dbobj->affiliate_id;
|
88 |
$this->affiliate_subid = $dbobj->affiliate_subid;
|
89 |
|
90 |
-
$this->notes = $dbobj->notes;
|
91 |
-
|
92 |
-
//reset the gateway
|
93 |
-
if(empty($this->nogateway))
|
94 |
-
$this->setGateway();
|
95 |
-
|
96 |
return $this->id;
|
97 |
}
|
98 |
else
|
99 |
return false; //didn't find it in the DB
|
100 |
}
|
101 |
|
102 |
-
function
|
103 |
-
{
|
104 |
-
//set the gateway property
|
105 |
-
if(isset($gateway))
|
106 |
-
{
|
107 |
-
$this->gateway = $gateway;
|
108 |
-
}
|
109 |
-
|
110 |
-
//which one to load?
|
111 |
-
$classname = "PMProGateway"; //default test gateway
|
112 |
-
if(!empty($this->gateway) && $this->gateway != "free")
|
113 |
-
$classname .= "_" . $this->gateway; //adding the gateway suffix
|
114 |
-
|
115 |
-
//try to load it
|
116 |
-
include_once(dirname(__FILE__) . "/gateways/class." . strtolower($classname) . ".php");
|
117 |
-
if(class_exists($classname))
|
118 |
-
$this->Gateway = new $classname($this->gateway);
|
119 |
-
else
|
120 |
-
{
|
121 |
-
$error = new WP_Error("PMPro1001", "Could not locate the gateway class file with class name = " . $classname . ".");
|
122 |
-
//die("Could not locate the gateway class file with class name = " . $classname . ".");
|
123 |
-
}
|
124 |
-
|
125 |
-
return $this->Gateway;
|
126 |
-
}
|
127 |
-
|
128 |
-
function getLastMemberOrder($user_id = NULL, $status = 'success', $membership_id = NULL)
|
129 |
{
|
130 |
global $current_user, $wpdb;
|
131 |
if(!$user_id)
|
@@ -134,26 +88,11 @@
|
|
134 |
if(!$user_id)
|
135 |
return false;
|
136 |
|
137 |
-
|
138 |
-
$this->sqlQuery = "SELECT id FROM $wpdb->pmpro_membership_orders WHERE user_id = '" . $user_id . "' ";
|
139 |
-
if(!empty($status) && is_array($status))
|
140 |
-
$this->sqlQuery .= "AND status IN('" . implode("','", $status) . "') ";
|
141 |
-
elseif(!empty($status))
|
142 |
-
$this->sqlQuery .= "AND status = '" . esc_sql($status) . "' ";
|
143 |
-
|
144 |
-
if(!empty($membership_id))
|
145 |
-
$this->sqlQuery .= "AND membership_id = '" . $membership_id . "' ";
|
146 |
-
$this->sqlQuery .= "ORDER BY timestamp DESC LIMIT 1";
|
147 |
-
|
148 |
-
//get id
|
149 |
-
$id = $wpdb->get_var($this->sqlQuery);
|
150 |
|
151 |
return $this->getMemberOrderByID($id);
|
152 |
}
|
153 |
|
154 |
-
/*
|
155 |
-
Returns the order using the given order code.
|
156 |
-
*/
|
157 |
function getMemberOrderByCode($code)
|
158 |
{
|
159 |
global $wpdb;
|
@@ -164,45 +103,10 @@
|
|
164 |
return false;
|
165 |
}
|
166 |
|
167 |
-
/*
|
168 |
-
Returns the last order using the given payment_transaction_id.
|
169 |
-
*/
|
170 |
-
function getMemberOrderByPaymentTransactionID($payment_transaction_id)
|
171 |
-
{
|
172 |
-
//did they pass a trans id?
|
173 |
-
if(empty($payment_transaction_id))
|
174 |
-
return false;
|
175 |
-
|
176 |
-
global $wpdb;
|
177 |
-
$id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_orders WHERE payment_transaction_id = '" . esc_sql($payment_transaction_id) . "' LIMIT 1");
|
178 |
-
if($id)
|
179 |
-
return $this->getMemberOrderByID($id);
|
180 |
-
else
|
181 |
-
return false;
|
182 |
-
}
|
183 |
-
|
184 |
-
/*
|
185 |
-
Returns the last order using the given subscription_transaction_id.
|
186 |
-
*/
|
187 |
-
function getLastMemberOrderBySubscriptionTransactionID($subscription_transaction_id)
|
188 |
-
{
|
189 |
-
//did they pass a sub id?
|
190 |
-
if(empty($subscription_transaction_id))
|
191 |
-
return false;
|
192 |
-
|
193 |
-
global $wpdb;
|
194 |
-
$id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_orders WHERE subscription_transaction_id = '" . esc_sql($subscription_transaction_id) . "' ORDER BY id DESC LIMIT 1");
|
195 |
-
|
196 |
-
if($id)
|
197 |
-
return $this->getMemberOrderByID($id);
|
198 |
-
else
|
199 |
-
return false;
|
200 |
-
}
|
201 |
-
|
202 |
function getMemberOrderByPayPalToken($token)
|
203 |
{
|
204 |
global $wpdb;
|
205 |
-
$id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_orders WHERE paypal_token = '" . $token . "' LIMIT 1");
|
206 |
if($id)
|
207 |
return $this->getMemberOrderByID($id);
|
208 |
else
|
@@ -211,15 +115,12 @@
|
|
211 |
|
212 |
function getDiscountCode($force = false)
|
213 |
{
|
214 |
-
if(
|
215 |
return $this->discount_code;
|
216 |
|
217 |
global $wpdb;
|
218 |
$this->discount_code = $wpdb->get_row("SELECT dc.* FROM $wpdb->pmpro_discount_codes dc LEFT JOIN $wpdb->pmpro_discount_codes_uses dcu ON dc.id = dcu.code_id WHERE dcu.order_id = '" . $this->id . "' LIMIT 1");
|
219 |
|
220 |
-
//filter @since v1.7.14
|
221 |
-
$this->discount_code = apply_filters("pmpro_order_discount_code", $this->discount_code, $this);
|
222 |
-
|
223 |
return $this->discount_code;
|
224 |
}
|
225 |
|
@@ -227,8 +128,8 @@
|
|
227 |
{
|
228 |
global $wpdb;
|
229 |
|
230 |
-
if(
|
231 |
-
return $this->user;
|
232 |
|
233 |
$gmt_offset = get_option('gmt_offset');
|
234 |
$this->user = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(user_registered) + " . ($gmt_offset * 3600) . " as user_registered FROM $wpdb->users WHERE ID = '" . $this->user_id . "' LIMIT 1");
|
@@ -239,34 +140,24 @@
|
|
239 |
{
|
240 |
global $wpdb;
|
241 |
|
242 |
-
if(
|
243 |
return $this->membership_level;
|
244 |
|
245 |
//check if there is an entry in memberships_users first
|
246 |
-
if(
|
247 |
{
|
248 |
-
$this->membership_level = $wpdb->get_row("SELECT l.id
|
249 |
-
|
250 |
-
//fix the membership level id
|
251 |
-
if(!empty($this->membership_level->level_id))
|
252 |
-
$this->membership_level->id = $this->membership_level->level_id;
|
253 |
}
|
254 |
|
255 |
//okay, do I have a discount code to check? (if there is no membership_level->membership_id value, that means there was no entry in memberships_users)
|
256 |
-
if(
|
257 |
{
|
258 |
-
|
259 |
-
$discount_code = $this->discount_code->code;
|
260 |
-
else
|
261 |
-
$discount_code = $this->discount_code;
|
262 |
-
|
263 |
-
$sqlQuery = "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 LEFT JOIN $wpdb->pmpro_discount_codes dc ON dc.id = cl.code_id WHERE dc.code = '" . $discount_code . "' AND cl.level_id = '" . $this->membership_id . "' LIMIT 1";
|
264 |
-
|
265 |
$this->membership_level = $wpdb->get_row($sqlQuery);
|
266 |
}
|
267 |
|
268 |
//just get the info from the membership table (sigh, I really need to standardize the column names for membership_id/level_id) but we're checking if we got the information already or not
|
269 |
-
if(
|
270 |
{
|
271 |
$this->membership_level = $wpdb->get_row("SELECT l.* FROM $wpdb->pmpro_membership_levels l WHERE l.id = '" . $this->membership_id . "' LIMIT 1");
|
272 |
}
|
@@ -279,40 +170,27 @@
|
|
279 |
//get options
|
280 |
$tax_state = pmpro_getOption("tax_state");
|
281 |
$tax_rate = pmpro_getOption("tax_rate");
|
282 |
-
|
283 |
-
//default
|
284 |
-
$tax = 0;
|
285 |
-
|
286 |
//calculate tax
|
287 |
if($tax_state && $tax_rate)
|
288 |
{
|
289 |
//we have values, is this order in the tax state?
|
290 |
-
if(
|
291 |
-
{
|
|
|
|
|
|
|
292 |
//return value, pass through filter
|
293 |
-
|
294 |
}
|
295 |
}
|
296 |
|
297 |
-
|
298 |
-
$values = array("price" => $price, "tax_state" => $tax_state, "tax_rate" => $tax_rate);
|
299 |
-
if(!empty($this->billing->state))
|
300 |
-
$values['billing_state'] = $this->billing->state;
|
301 |
-
if(!empty($this->billing->city))
|
302 |
-
$values['billing_city'] = $this->billing->city;
|
303 |
-
if(!empty($this->billing->zip))
|
304 |
-
$values['billing_zip'] = $this->billing->zip;
|
305 |
-
if(!empty($this->billing->country))
|
306 |
-
$values['billing_country'] = $this->billing->country;
|
307 |
-
|
308 |
-
//filter
|
309 |
-
$tax = apply_filters("pmpro_tax", $tax, $values, $this);
|
310 |
-
return $tax;
|
311 |
}
|
312 |
|
313 |
function getTax($force = false)
|
314 |
{
|
315 |
-
if(
|
316 |
return $this->tax;
|
317 |
|
318 |
//reset
|
@@ -321,122 +199,43 @@
|
|
321 |
return $this->tax;
|
322 |
}
|
323 |
|
324 |
-
function updateTimestamp($year, $month, $day, $time = NULL)
|
325 |
-
{
|
326 |
-
if(empty($this->id))
|
327 |
-
return false; //need a saved order
|
328 |
-
|
329 |
-
if(empty($time))
|
330 |
-
$time = "00:00:00";
|
331 |
-
|
332 |
-
$date = $year . "-" . $month . "-" . $day . " " . $time;
|
333 |
-
|
334 |
-
global $wpdb;
|
335 |
-
$this->sqlQuery = "UPDATE $wpdb->pmpro_membership_orders SET timestamp = '" . $date . "' WHERE id = '" . $this->id . "' LIMIT 1";
|
336 |
-
|
337 |
-
if($wpdb->query($this->sqlQuery) !== "false")
|
338 |
-
return $this->getMemberOrderByID($this->id);
|
339 |
-
else
|
340 |
-
return false;
|
341 |
-
}
|
342 |
-
|
343 |
function saveOrder()
|
344 |
-
{
|
345 |
global $current_user, $wpdb;
|
346 |
|
347 |
//get a random code to use for the public ID
|
348 |
-
if(
|
349 |
$this->code = $this->getRandomCode();
|
350 |
|
351 |
//figure out how much we charged
|
352 |
-
|
353 |
-
$amount = $this->InitialPayment;
|
354 |
-
elseif(!empty($this->subtotal))
|
355 |
-
$amount = $this->subtotal;
|
356 |
-
else
|
357 |
-
$amount = 0;
|
358 |
-
|
359 |
-
//Todo: Tax?!, Coupons, Certificates, affiliates
|
360 |
-
if(empty($this->subtotal))
|
361 |
-
$this->subtotal = $amount;
|
362 |
-
if(isset($this->tax))
|
363 |
-
$tax = $this->tax;
|
364 |
-
else
|
365 |
-
$tax = $this->getTax(true);
|
366 |
-
$this->certificate_id = "";
|
367 |
-
$this->certificateamount = "";
|
368 |
|
369 |
-
//
|
370 |
-
if(!empty($this->total))
|
371 |
-
$total = $this->total;
|
372 |
-
else
|
373 |
-
$total = (float)$amount + (float)$tax;
|
374 |
-
|
375 |
-
//these fix some warnings/notices
|
376 |
-
if(empty($this->billing))
|
377 |
-
{
|
378 |
-
$this->billing = new stdClass();
|
379 |
-
$this->billing->name = $this->billing->street = $this->billing->city = $this->billing->state = $this->billing->zip = $this->billing->country = $this->billing->phone = "";
|
380 |
-
}
|
381 |
-
if(empty($this->user_id))
|
382 |
-
$this->user_id = 0;
|
383 |
-
if(empty($this->paypal_token))
|
384 |
-
$this->paypal_token = "";
|
385 |
-
if(empty($this->couponamount))
|
386 |
-
$this->couponamount = "";
|
387 |
-
if(empty($this->payment_type))
|
388 |
-
$this->payment_type = "";
|
389 |
-
if(empty($this->payment_transaction_id))
|
390 |
-
$this->payment_transaction_id = "";
|
391 |
-
if(empty($this->subscription_transaction_id))
|
392 |
-
$this->subscription_transaction_id = "";
|
393 |
-
if(empty($this->affiliate_id))
|
394 |
-
$this->affiliate_id = "";
|
395 |
-
if(empty($this->affiliate_subid))
|
396 |
-
$this->affiliate_subid = "";
|
397 |
-
if(empty($this->session_id))
|
398 |
-
$this->session_id = "";
|
399 |
-
if(empty($this->accountnumber))
|
400 |
-
$this->accountnumber = "";
|
401 |
-
if(empty($this->cardtype))
|
402 |
-
$this->cardtype = "";
|
403 |
-
if(empty($this->ExpirationDate))
|
404 |
-
$this->ExpirationDate = "";
|
405 |
-
if (empty($this->status))
|
406 |
-
$this->status = "";
|
407 |
-
|
408 |
-
if(empty($this->gateway))
|
409 |
-
$this->gateway = pmpro_getOption("gateway");
|
410 |
-
if(empty($this->gateway_environment))
|
411 |
-
$this->gateway_environment = pmpro_getOption("gateway_environment");
|
412 |
-
|
413 |
-
if(empty($this->notes))
|
414 |
-
$this->notes = "";
|
415 |
|
|
|
|
|
|
|
|
|
416 |
//build query
|
417 |
-
if(
|
418 |
{
|
419 |
-
//set up actions
|
420 |
-
$before_action = "pmpro_update_order";
|
421 |
-
$after_action = "pmpro_updated_order";
|
422 |
//update
|
423 |
$this->sqlQuery = "UPDATE $wpdb->pmpro_membership_orders
|
424 |
SET `code` = '" . $this->code . "',
|
425 |
`session_id` = '" . $this->session_id . "',
|
426 |
-
`user_id` = " .
|
427 |
-
`membership_id` = " .
|
428 |
`paypal_token` = '" . $this->paypal_token . "',
|
429 |
-
`billing_name` = '" .
|
430 |
-
`billing_street` = '" .
|
431 |
-
`billing_city` = '" .
|
432 |
-
`billing_state` = '" .
|
433 |
-
`billing_zip` = '" .
|
434 |
-
`
|
435 |
-
`billing_phone` = '" . esc_sql($this->billing->phone) . "',
|
436 |
`subtotal` = '" . $this->subtotal . "',
|
437 |
`tax` = '" . $this->tax . "',
|
438 |
`couponamount` = '" . $this->couponamount . "',
|
439 |
-
`certificate_id` = " .
|
440 |
`certificateamount` = '" . $this->certificateamount . "',
|
441 |
`total` = '" . $this->total . "',
|
442 |
`payment_type` = '" . $this->payment_type . "',
|
@@ -444,83 +243,68 @@
|
|
444 |
`accountnumber` = '" . $this->accountnumber . "',
|
445 |
`expirationmonth` = '" . $this->expirationmonth . "',
|
446 |
`expirationyear` = '" . $this->expirationyear . "',
|
447 |
-
`status` = '" .
|
448 |
`gateway` = '" . $this->gateway . "',
|
449 |
`gateway_environment` = '" . $this->gateway_environment . "',
|
450 |
-
`payment_transaction_id` = '" .
|
451 |
-
`subscription_transaction_id` = '" .
|
452 |
-
`affiliate_id` = '" .
|
453 |
-
`affiliate_subid` = '" .
|
454 |
-
`notes` = '" . esc_sql($this->notes) . "'
|
455 |
WHERE id = '" . $this->id . "'
|
456 |
LIMIT 1";
|
457 |
}
|
458 |
else
|
459 |
{
|
460 |
-
//set up actions
|
461 |
-
$before_action = "pmpro_add_order";
|
462 |
-
$after_action = "pmpro_added_order";
|
463 |
//insert
|
464 |
$this->sqlQuery = "INSERT INTO $wpdb->pmpro_membership_orders
|
465 |
-
(`code`, `session_id`, `user_id`, `membership_id`, `paypal_token`, `billing_name`, `billing_street`, `billing_city`, `billing_state`, `billing_zip`, `
|
466 |
VALUES('" . $this->code . "',
|
467 |
'" . session_id() . "',
|
468 |
-
" .
|
469 |
-
" .
|
470 |
'" . $this->paypal_token . "',
|
471 |
-
'" .
|
472 |
-
'" .
|
473 |
-
'" .
|
474 |
-
'" .
|
475 |
-
'" .
|
476 |
-
'" . esc_sql($this->billing->country) . "',
|
477 |
'" . cleanPhone($this->billing->phone) . "',
|
478 |
'" . $amount . "',
|
479 |
'" . $tax . "',
|
480 |
-
'" . $
|
481 |
-
" .
|
482 |
-
'" . $
|
483 |
-
'" . $
|
484 |
'" . $this->payment_type . "',
|
485 |
'" . $this->cardtype . "',
|
486 |
'" . hideCardNumber($this->accountnumber, false) . "',
|
487 |
'" . substr($this->ExpirationDate, 0, 2) . "',
|
488 |
'" . substr($this->ExpirationDate, 2, 4) . "',
|
489 |
-
'" .
|
490 |
-
'" .
|
491 |
-
'" .
|
492 |
-
'" .
|
493 |
-
'" .
|
494 |
-
|
495 |
-
'" .
|
496 |
-
'" .
|
497 |
-
|
498 |
-
)";
|
499 |
}
|
500 |
-
|
501 |
-
do_action($before_action, $this);
|
502 |
if($wpdb->query($this->sqlQuery) !== false)
|
503 |
-
|
504 |
-
if(empty($this->id))
|
505 |
-
$this->id = $wpdb->insert_id;
|
506 |
-
do_action($after_action, $this);
|
507 |
-
return $this->getMemberOrderByID($this->id);
|
508 |
-
}
|
509 |
else
|
510 |
-
{
|
511 |
return false;
|
512 |
-
}
|
513 |
}
|
514 |
|
515 |
function getRandomCode()
|
516 |
{
|
517 |
global $wpdb;
|
518 |
|
519 |
-
while(
|
520 |
{
|
521 |
-
$scramble = md5(AUTH_KEY .
|
522 |
$code = substr($scramble, 0, 10);
|
523 |
-
$code = apply_filters("pmpro_random_code", $code, $this); //filter
|
524 |
$check = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_orders WHERE code = '$code' LIMIT 1");
|
525 |
if($check || is_numeric($code))
|
526 |
$code = NULL;
|
@@ -533,11 +317,11 @@
|
|
533 |
{
|
534 |
global $wpdb;
|
535 |
|
536 |
-
if(
|
537 |
return false;
|
538 |
|
539 |
$this->status = $newstatus;
|
540 |
-
$this->sqlQuery = "UPDATE $wpdb->pmpro_membership_orders SET status = '" .
|
541 |
if($wpdb->query($this->sqlQuery) !== false)
|
542 |
return true;
|
543 |
else
|
@@ -546,72 +330,1378 @@
|
|
546 |
|
547 |
function process()
|
548 |
{
|
549 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
550 |
}
|
551 |
|
552 |
function cancel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
{
|
554 |
-
|
555 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
{
|
557 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
$this->updateStatus("cancelled");
|
559 |
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
560 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
else
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
584 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
585 |
}
|
586 |
|
587 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
588 |
{
|
589 |
-
|
590 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
|
592 |
-
function
|
593 |
{
|
594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
}
|
596 |
|
597 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
{
|
599 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
600 |
}
|
601 |
|
602 |
-
|
|
|
603 |
{
|
604 |
-
if(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
606 |
|
607 |
-
|
608 |
-
|
609 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
610 |
{
|
611 |
-
|
|
|
612 |
return true;
|
613 |
}
|
614 |
else
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
615 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
616 |
}
|
617 |
}
|
|
3 |
{
|
4 |
function MemberOrder($id = NULL)
|
5 |
{
|
|
|
|
|
|
|
|
|
6 |
if($id)
|
7 |
{
|
8 |
if(is_numeric($id))
|
12 |
}
|
13 |
else
|
14 |
return true; //blank constructor
|
15 |
+
}
|
16 |
|
17 |
function getMemberOrderByID($id)
|
18 |
{
|
25 |
$dbobj = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(timestamp) + " . ($gmt_offset * 3600) . " as timestamp FROM $wpdb->pmpro_membership_orders WHERE id = '$id' LIMIT 1");
|
26 |
|
27 |
if($dbobj)
|
28 |
+
{
|
29 |
$this->id = $dbobj->id;
|
30 |
$this->code = $dbobj->code;
|
31 |
$this->session_id = $dbobj->session_id;
|
32 |
$this->user_id = $dbobj->user_id;
|
33 |
$this->membership_id = $dbobj->membership_id;
|
34 |
$this->paypal_token = $dbobj->paypal_token;
|
|
|
35 |
$this->billing->name = $dbobj->billing_name;
|
36 |
$this->billing->street = $dbobj->billing_street;
|
37 |
$this->billing->city = $dbobj->billing_city;
|
38 |
$this->billing->state = $dbobj->billing_state;
|
39 |
$this->billing->zip = $dbobj->billing_zip;
|
|
|
40 |
$this->billing->phone = $dbobj->billing_phone;
|
41 |
|
42 |
//split up some values
|
43 |
$nameparts = pnp_split_full_name($this->billing->name);
|
44 |
+
$this->FirstName = $nameparts['fname'];
|
45 |
+
$this->LastName = $nameparts['lname'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
$this->Address1 = $this->billing->street;
|
47 |
|
48 |
//get email from user_id
|
73 |
$this->affiliate_id = $dbobj->affiliate_id;
|
74 |
$this->affiliate_subid = $dbobj->affiliate_subid;
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
return $this->id;
|
77 |
}
|
78 |
else
|
79 |
return false; //didn't find it in the DB
|
80 |
}
|
81 |
|
82 |
+
function getLastMemberOrder($user_id = NULL)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
{
|
84 |
global $current_user, $wpdb;
|
85 |
if(!$user_id)
|
88 |
if(!$user_id)
|
89 |
return false;
|
90 |
|
91 |
+
$id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_orders WHERE user_id = '" . $user_id . "' ORDER BY timestamp DESC LIMIT 1");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
return $this->getMemberOrderByID($id);
|
94 |
}
|
95 |
|
|
|
|
|
|
|
96 |
function getMemberOrderByCode($code)
|
97 |
{
|
98 |
global $wpdb;
|
103 |
return false;
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
function getMemberOrderByPayPalToken($token)
|
107 |
{
|
108 |
global $wpdb;
|
109 |
+
$id = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_orders WHERE paypal_token = '" . $token . "' LIMIT 1");
|
110 |
if($id)
|
111 |
return $this->getMemberOrderByID($id);
|
112 |
else
|
115 |
|
116 |
function getDiscountCode($force = false)
|
117 |
{
|
118 |
+
if($this->discount_code && !$force)
|
119 |
return $this->discount_code;
|
120 |
|
121 |
global $wpdb;
|
122 |
$this->discount_code = $wpdb->get_row("SELECT dc.* FROM $wpdb->pmpro_discount_codes dc LEFT JOIN $wpdb->pmpro_discount_codes_uses dcu ON dc.id = dcu.code_id WHERE dcu.order_id = '" . $this->id . "' LIMIT 1");
|
123 |
|
|
|
|
|
|
|
124 |
return $this->discount_code;
|
125 |
}
|
126 |
|
128 |
{
|
129 |
global $wpdb;
|
130 |
|
131 |
+
if($this->user)
|
132 |
+
return $this->invoice->user;
|
133 |
|
134 |
$gmt_offset = get_option('gmt_offset');
|
135 |
$this->user = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(user_registered) + " . ($gmt_offset * 3600) . " as user_registered FROM $wpdb->users WHERE ID = '" . $this->user_id . "' LIMIT 1");
|
140 |
{
|
141 |
global $wpdb;
|
142 |
|
143 |
+
if($this->membership_level && !$force)
|
144 |
return $this->membership_level;
|
145 |
|
146 |
//check if there is an entry in memberships_users first
|
147 |
+
if($this->user_id)
|
148 |
{
|
149 |
+
$this->membership_level = $wpdb->get_row("SELECT l.id, l.name, l.description, l.allow_signups, mu.*, UNIX_TIMESTAMP(mu.startdate) as startdate, UNIX_TIMESTAMP(mu.enddate) as enddate, l.name, l.description, l.allow_signups FROM $wpdb->pmpro_membership_levels l LEFT JOIN $wpdb->pmpro_memberships_users mu ON l.id = mu.membership_id WHERE l.id = '" . $this->membership_id . "' AND mu.user_id = '" . $this->user_id . "' LIMIT 1");
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
|
152 |
//okay, do I have a discount code to check? (if there is no membership_level->membership_id value, that means there was no entry in memberships_users)
|
153 |
+
if($this->discount_code && !$this->membership_level->membership_id)
|
154 |
{
|
155 |
+
$sqlQuery = "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 LEFT JOIN $wpdb->pmpro_discount_codes dc ON dc.id = cl.code_id WHERE dc.code = '" . $this->discount_code . "' AND cl.level_id = '" . $this->membership_id . "' LIMIT 1";
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
$this->membership_level = $wpdb->get_row($sqlQuery);
|
157 |
}
|
158 |
|
159 |
//just get the info from the membership table (sigh, I really need to standardize the column names for membership_id/level_id) but we're checking if we got the information already or not
|
160 |
+
if(!$this->membership_level->membership_id && !$this->membership_level->level_id)
|
161 |
{
|
162 |
$this->membership_level = $wpdb->get_row("SELECT l.* FROM $wpdb->pmpro_membership_levels l WHERE l.id = '" . $this->membership_id . "' LIMIT 1");
|
163 |
}
|
170 |
//get options
|
171 |
$tax_state = pmpro_getOption("tax_state");
|
172 |
$tax_rate = pmpro_getOption("tax_rate");
|
173 |
+
|
|
|
|
|
|
|
174 |
//calculate tax
|
175 |
if($tax_state && $tax_rate)
|
176 |
{
|
177 |
//we have values, is this order in the tax state?
|
178 |
+
if(trim(strtoupper($this->billing->state)) == trim(strtoupper($tax_state)))
|
179 |
+
{
|
180 |
+
//set values array for filter
|
181 |
+
$values = array("price" => $price, "tax_state" => $tax_state, "tax_rate" => $tax_rate, "billing_state" => $this->billing->state, "billing_city" => $this->billing_city, "billing_zip" => $this->billing->zip, "billing_country" => $this->billing->country);
|
182 |
+
|
183 |
//return value, pass through filter
|
184 |
+
return apply_filters("pmpro_tax", round((float)$price * (float)$tax_rate, 2), $values);
|
185 |
}
|
186 |
}
|
187 |
|
188 |
+
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
function getTax($force = false)
|
192 |
{
|
193 |
+
if($this->tax && !$force)
|
194 |
return $this->tax;
|
195 |
|
196 |
//reset
|
199 |
return $this->tax;
|
200 |
}
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
function saveOrder()
|
203 |
+
{
|
204 |
global $current_user, $wpdb;
|
205 |
|
206 |
//get a random code to use for the public ID
|
207 |
+
if(!$this->code)
|
208 |
$this->code = $this->getRandomCode();
|
209 |
|
210 |
//figure out how much we charged
|
211 |
+
$amount = $this->InitialPayment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
+
//Todo: Make sure the session is started
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
+
//Todo: Tax?!, Coupons, Certificates, affiliates
|
216 |
+
$this->subtotal = $amount;
|
217 |
+
$tax = $this->getTax(true);
|
218 |
+
|
219 |
//build query
|
220 |
+
if($this->id)
|
221 |
{
|
|
|
|
|
|
|
222 |
//update
|
223 |
$this->sqlQuery = "UPDATE $wpdb->pmpro_membership_orders
|
224 |
SET `code` = '" . $this->code . "',
|
225 |
`session_id` = '" . $this->session_id . "',
|
226 |
+
`user_id` = '" . $this->user_id . "',
|
227 |
+
`membership_id` = '" . $this->membership_id . "',
|
228 |
`paypal_token` = '" . $this->paypal_token . "',
|
229 |
+
`billing_name` = '" . $this->billing->name . "',
|
230 |
+
`billing_street` = '" . $this->billing->street . "',
|
231 |
+
`billing_city` = '" . $this->billing->city . "',
|
232 |
+
`billing_state` = '" . $this->billing->state . "',
|
233 |
+
`billing_zip` = '" . $this->billing->zip . "',
|
234 |
+
`billing_phone` = '" . $this->billing->phone . "',
|
|
|
235 |
`subtotal` = '" . $this->subtotal . "',
|
236 |
`tax` = '" . $this->tax . "',
|
237 |
`couponamount` = '" . $this->couponamount . "',
|
238 |
+
`certificate_id` = '" . $this->certificate_id . "',
|
239 |
`certificateamount` = '" . $this->certificateamount . "',
|
240 |
`total` = '" . $this->total . "',
|
241 |
`payment_type` = '" . $this->payment_type . "',
|
243 |
`accountnumber` = '" . $this->accountnumber . "',
|
244 |
`expirationmonth` = '" . $this->expirationmonth . "',
|
245 |
`expirationyear` = '" . $this->expirationyear . "',
|
246 |
+
`status` = '" . $this->status . "',
|
247 |
`gateway` = '" . $this->gateway . "',
|
248 |
`gateway_environment` = '" . $this->gateway_environment . "',
|
249 |
+
`payment_transaction_id` = '" . $this->payment_transaction_id . "',
|
250 |
+
`subscription_transaction_id` = '" . $this->subscription_transaction_id . "',
|
251 |
+
`affiliate_id` = '" . $this->affiliate_id . "',
|
252 |
+
`affiliate_subid` = '" . $this->affiliate_subid . "'
|
|
|
253 |
WHERE id = '" . $this->id . "'
|
254 |
LIMIT 1";
|
255 |
}
|
256 |
else
|
257 |
{
|
|
|
|
|
|
|
258 |
//insert
|
259 |
$this->sqlQuery = "INSERT INTO $wpdb->pmpro_membership_orders
|
260 |
+
(`code`, `session_id`, `user_id`, `membership_id`, `paypal_token`, `billing_name`, `billing_street`, `billing_city`, `billing_state`, `billing_zip`, `billing_phone`, `subtotal`, `tax`, `couponamount`, `certificate_id`, `certificateamount`, `total`, `payment_type`, `cardtype`, `accountnumber`, `expirationmonth`, `expirationyear`, `status`, `gateway`, `gateway_environment`, `payment_transaction_id`, `subscription_transaction_id`, `timestamp`, `affiliate_id`, `affiliate_subid`)
|
261 |
VALUES('" . $this->code . "',
|
262 |
'" . session_id() . "',
|
263 |
+
'" . $this->user_id . "',
|
264 |
+
'" . $this->membership_id . "',
|
265 |
'" . $this->paypal_token . "',
|
266 |
+
'" . $wpdb->escape(trim($this->billing->name)) . "',
|
267 |
+
'" . $wpdb->escape(trim($this->billing->street)) . "',
|
268 |
+
'" . $wpdb->escape($this->billing->city) . "',
|
269 |
+
'" . $wpdb->escape($this->billing->state) . "',
|
270 |
+
'" . $wpdb->escape($this->billing->zip) . "',
|
|
|
271 |
'" . cleanPhone($this->billing->phone) . "',
|
272 |
'" . $amount . "',
|
273 |
'" . $tax . "',
|
274 |
+
'" . $coupon. "',
|
275 |
+
'" . $certificate_id . "',
|
276 |
+
'" . $certficate_amount . "',
|
277 |
+
'" . ((float)$amount + (float)$tax) . "',
|
278 |
'" . $this->payment_type . "',
|
279 |
'" . $this->cardtype . "',
|
280 |
'" . hideCardNumber($this->accountnumber, false) . "',
|
281 |
'" . substr($this->ExpirationDate, 0, 2) . "',
|
282 |
'" . substr($this->ExpirationDate, 2, 4) . "',
|
283 |
+
'" . $this->status . "',
|
284 |
+
'" . pmpro_getOption("gateway") . "',
|
285 |
+
'" . pmpro_getOption("gateway_environment") . "',
|
286 |
+
'" . $this->payment_transaction_id . "',
|
287 |
+
'" . $this->subscription_transaction_id . "',
|
288 |
+
now(),
|
289 |
+
'" . $affiliate_id . "',
|
290 |
+
'" . $affiliate_subid . "'
|
291 |
+
)";
|
|
|
292 |
}
|
293 |
+
|
|
|
294 |
if($wpdb->query($this->sqlQuery) !== false)
|
295 |
+
return $this->getMemberOrderByID($wpdb->insert_id);
|
|
|
|
|
|
|
|
|
|
|
296 |
else
|
|
|
297 |
return false;
|
|
|
298 |
}
|
299 |
|
300 |
function getRandomCode()
|
301 |
{
|
302 |
global $wpdb;
|
303 |
|
304 |
+
while(!$code)
|
305 |
{
|
306 |
+
$scramble = md5(AUTH_KEY . time() . SECURE_AUTH_KEY);
|
307 |
$code = substr($scramble, 0, 10);
|
|
|
308 |
$check = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_orders WHERE code = '$code' LIMIT 1");
|
309 |
if($check || is_numeric($code))
|
310 |
$code = NULL;
|
317 |
{
|
318 |
global $wpdb;
|
319 |
|
320 |
+
if(!$this->id)
|
321 |
return false;
|
322 |
|
323 |
$this->status = $newstatus;
|
324 |
+
$this->sqlQuery = "UPDATE $wpdb->pmpro_membership_orders SET status = '" . $wpdb->escape($newstatus) . "' WHERE id = '" . $this->id . "' LIMIT 1";
|
325 |
if($wpdb->query($this->sqlQuery) !== false)
|
326 |
return true;
|
327 |
else
|
330 |
|
331 |
function process()
|
332 |
{
|
333 |
+
$gateway = pmpro_getOption("gateway");
|
334 |
+
if($gateway == "paypal")
|
335 |
+
{
|
336 |
+
if(floatval($this->InitialPayment) == 0)
|
337 |
+
{
|
338 |
+
//auth first, then process
|
339 |
+
$authorization_id = $this->authorizeWithPayPal();
|
340 |
+
if($authorization_id)
|
341 |
+
{
|
342 |
+
$this->voidAuthorizationWithPayPal($authorization_id);
|
343 |
+
$this->ProfileStartDate = date("Y-m-d", strtotime("+ " . $this->BillingFrequency . " " . $this->BillingPeriod)) . "T0:0:0";
|
344 |
+
$this->ProfileStartDate = apply_filters("pmpro_profile_start_date", $this->ProfileStartDate, $this);
|
345 |
+
return $this->processWithPayPal();
|
346 |
+
}
|
347 |
+
else
|
348 |
+
{
|
349 |
+
if(!$this->error)
|
350 |
+
$this->error = "Unknown error: Authorization failed.";
|
351 |
+
return false;
|
352 |
+
}
|
353 |
+
}
|
354 |
+
else
|
355 |
+
{
|
356 |
+
//charge first payment
|
357 |
+
if($this->chargeWithPayPal())
|
358 |
+
{
|
359 |
+
//setup recurring billing
|
360 |
+
if(pmpro_isLevelRecurring($this->membership_level))
|
361 |
+
{
|
362 |
+
$this->ProfileStartDate = date("Y-m-d", strtotime("+ " . $this->BillingFrequency . " " . $this->BillingPeriod)) . "T0:0:0";
|
363 |
+
$this->ProfileStartDate = apply_filters("pmpro_profile_start_date", $this->ProfileStartDate, $this);
|
364 |
+
return $this->processWithPayPal();
|
365 |
+
}
|
366 |
+
else
|
367 |
+
{
|
368 |
+
//only a one time charge
|
369 |
+
$this->status = "success"; //saved on checkout page
|
370 |
+
$this->saveOrder();
|
371 |
+
return true;
|
372 |
+
}
|
373 |
+
}
|
374 |
+
else
|
375 |
+
{
|
376 |
+
if(!$this->error)
|
377 |
+
$this->error = "Unknown error: Payment failed.";
|
378 |
+
return false;
|
379 |
+
}
|
380 |
+
}
|
381 |
+
}
|
382 |
+
elseif($gateway == "paypalexpress")
|
383 |
+
{
|
384 |
+
if(pmpro_isLevelRecurring($this->membership_level))
|
385 |
+
{
|
386 |
+
$this->ProfileStartDate = date("Y-m-d", strtotime("+ " . $this->BillingFrequency . " " . $this->BillingPeriod)) . "T0:0:0";
|
387 |
+
$this->ProfileStartDate = apply_filters("pmpro_profile_start_date", $this->ProfileStartDate, $this);
|
388 |
+
return $this->processWithPayPalExpress();
|
389 |
+
}
|
390 |
+
else
|
391 |
+
return $this->chargeWithPayPalExpress();
|
392 |
+
}
|
393 |
+
elseif($gateway == "authorizenet")
|
394 |
+
{
|
395 |
+
if(floatval($this->InitialPayment) == 0)
|
396 |
+
{
|
397 |
+
//auth first, then process
|
398 |
+
if($this->authorizeWithAuthorizeNet())
|
399 |
+
{
|
400 |
+
$this->ProfileStartDate = date("Y-m-d", strtotime("+ " . $this->BillingFrequency . " " . $this->BillingPeriod)) . "T0:0:0";
|
401 |
+
$this->ProfileStartDate = apply_filters("pmpro_profile_start_date", $this->ProfileStartDate, $this);
|
402 |
+
return $this->processWithAuthorizeNet();
|
403 |
+
}
|
404 |
+
else
|
405 |
+
{
|
406 |
+
if(!$this->error)
|
407 |
+
$this->error = "Unknown error: Authorization failed.";
|
408 |
+
return false;
|
409 |
+
}
|
410 |
+
}
|
411 |
+
else
|
412 |
+
{
|
413 |
+
//charge first payment
|
414 |
+
if($this->chargeWithAuthorizeNet())
|
415 |
+
{
|
416 |
+
//setup recurring billing
|
417 |
+
if(pmpro_isLevelRecurring($this->membership_level))
|
418 |
+
{
|
419 |
+
$this->ProfileStartDate = date("Y-m-d", strtotime("+ " . $this->BillingFrequency . " " . $this->BillingPeriod)) . "T0:0:0";
|
420 |
+
$this->ProfileStartDate = apply_filters("pmpro_profile_start_date", $this->ProfileStartDate, $this);
|
421 |
+
return $this->processWithAuthorizeNet();
|
422 |
+
}
|
423 |
+
else
|
424 |
+
{
|
425 |
+
//only a one time charge
|
426 |
+
$this->status = "success"; //saved on checkout page
|
427 |
+
return true;
|
428 |
+
}
|
429 |
+
}
|
430 |
+
else
|
431 |
+
{
|
432 |
+
if(!$this->error)
|
433 |
+
$this->error = "Unknown error: Payment failed.";
|
434 |
+
return false;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
}
|
438 |
+
else
|
439 |
+
{
|
440 |
+
if(pmpro_isAdmin())
|
441 |
+
$this->error = "You must <a href=\"" . home_url('/wp-admin/admin.php?page=pmpro-membershiplevels&view=payment') . "\">setup a Payment Gateway</a> before any payments will be processed.";
|
442 |
+
else
|
443 |
+
$this->error = "A Payment Gateway must be setup before any payments will be processed.";
|
444 |
+
return false;
|
445 |
+
}
|
446 |
}
|
447 |
|
448 |
function cancel()
|
449 |
+
{
|
450 |
+
$gateway = $this->gateway;
|
451 |
+
|
452 |
+
//if there is no subscription id or this subscription has a status != success, it was already cancelled (or never existed)
|
453 |
+
if(!$this->subscription_transaction_id || !$this->status != "success")
|
454 |
+
{
|
455 |
+
//cancel
|
456 |
+
$this->updateStatus("cancelled");
|
457 |
+
return true;
|
458 |
+
}
|
459 |
+
|
460 |
+
//if no gateway specified for the order, assume it is the current gateway
|
461 |
+
if(!$gateway)
|
462 |
+
$gateway = pmpro_getOption("gateway");
|
463 |
+
|
464 |
+
if($gateway == "paypal" || $gateway == "paypalexpress")
|
465 |
+
return $this->cancelWithPayPal();
|
466 |
+
elseif($gateway == "authorizenet")
|
467 |
+
return $this->cancelWithAuthorizeNet();
|
468 |
+
else
|
469 |
+
return false;
|
470 |
+
}
|
471 |
+
|
472 |
+
function updateBilling()
|
473 |
+
{
|
474 |
+
$gateway = $this->gateway;
|
475 |
+
|
476 |
+
//if no gateway specified for the order, assume it is the current gateway
|
477 |
+
if(!$gateway)
|
478 |
+
$gateway = pmpro_getOption("gateway");
|
479 |
+
|
480 |
+
if($gateway == "paypal")
|
481 |
+
return $this->updateWithPayPal();
|
482 |
+
elseif($gateway == "authorizenet")
|
483 |
+
return $this->updateWithAuthorizeNet();
|
484 |
+
else
|
485 |
+
return false;
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* PAYPAL Function
|
490 |
+
* Send HTTP POST Request
|
491 |
+
*
|
492 |
+
* @param string The API method name
|
493 |
+
* @param string The POST Message fields in &name=value pair format
|
494 |
+
* @return array Parsed HTTP Response body
|
495 |
+
*/
|
496 |
+
function PPHttpPost($methodName_, $nvpStr_) {
|
497 |
+
global $gateway_environment;
|
498 |
+
$environment = $gateway_environment;
|
499 |
+
|
500 |
+
$API_UserName = pmpro_getOption("apiusername");
|
501 |
+
$API_Password = pmpro_getOption("apipassword");
|
502 |
+
$API_Signature = pmpro_getOption("apisignature");
|
503 |
+
$API_Endpoint = "https://api-3t.paypal.com/nvp";
|
504 |
+
if("sandbox" === $environment || "beta-sandbox" === $environment) {
|
505 |
+
$API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
|
506 |
+
}
|
507 |
+
|
508 |
+
$version = urlencode('72.0');
|
509 |
+
|
510 |
+
// setting the curl parameters.
|
511 |
+
$ch = curl_init();
|
512 |
+
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
|
513 |
+
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
514 |
+
|
515 |
+
// turning off the server and peer verification(TrustManager Concept).
|
516 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
517 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
518 |
+
|
519 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
520 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
521 |
+
|
522 |
+
// NVPRequest for submitting to server
|
523 |
+
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
|
524 |
+
|
525 |
+
// setting the nvpreq as POST FIELD to curl
|
526 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
|
527 |
+
|
528 |
+
// getting response from server
|
529 |
+
$httpResponse = curl_exec($ch);
|
530 |
+
|
531 |
+
if(!$httpResponse) {
|
532 |
+
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
|
533 |
+
}
|
534 |
+
|
535 |
+
// Extract the RefundTransaction response details
|
536 |
+
$httpResponseAr = explode("&", $httpResponse);
|
537 |
+
|
538 |
+
$httpParsedResponseAr = array();
|
539 |
+
foreach ($httpResponseAr as $i => $value) {
|
540 |
+
$tmpAr = explode("=", $value);
|
541 |
+
if(sizeof($tmpAr) > 1) {
|
542 |
+
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
|
543 |
+
}
|
544 |
+
}
|
545 |
+
|
546 |
+
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
|
547 |
+
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
|
548 |
+
}
|
549 |
+
|
550 |
+
return $httpParsedResponseAr;
|
551 |
+
}
|
552 |
+
|
553 |
+
function authorizeWithPayPal()
|
554 |
+
{
|
555 |
+
if(!$this->code)
|
556 |
+
$this->code = $this->getRandomCode();
|
557 |
+
|
558 |
+
//paypal profile stuff
|
559 |
+
$nvpStr = "";
|
560 |
+
if($this->Token)
|
561 |
+
$nvpStr .= "&TOKEN=" . $this->Token;
|
562 |
+
$nvpStr .="&AMT=1.00&CURRENCYCODE=" . pmpro_getOption("currency");
|
563 |
+
$nvpStr .= "&NOTIFYURL=" . urlencode(PMPRO_URL . "/services/ipnhandler.php");
|
564 |
+
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $this->PaymentAmount;
|
565 |
+
|
566 |
+
$nvpStr .= "&PAYMENTACTION=Authorization&IPADDRESS=" . $_SERVER['REMOTE_ADDR'] . "&INVNUM=" . $this->code;
|
567 |
+
|
568 |
+
//credit card fields
|
569 |
+
if($this->cardtype == "American Express")
|
570 |
+
$cardtype = "Amex";
|
571 |
+
else
|
572 |
+
$cardtype = $this->cardtype;
|
573 |
+
|
574 |
+
if($cardtype)
|
575 |
+
$nvpStr .= "&CREDITCARDTYPE=" . $cardtype . "&ACCT=" . $this->accountnumber . "&EXPDATE=" . $this->ExpirationDate . "&CVV2=" . $this->CVV2;
|
576 |
+
|
577 |
+
//Maestro/Solo card fields. (Who uses these?) :)
|
578 |
+
if($this->StartDate)
|
579 |
+
$nvpStr .= "&STARTDATE=" . $this->StartDate . "&ISSUENUMBER=" . $this->IssueNumber;
|
580 |
+
|
581 |
+
//billing address, etc
|
582 |
+
if($this->Address1)
|
583 |
+
{
|
584 |
+
$nvpStr .= "&EMAIL=" . $this->Email . "&FIRSTNAME=" . $this->FirstName . "&LASTNAME=" . $this->LastName . "&STREET=" . $this->Address1;
|
585 |
+
|
586 |
+
if($this->Address2)
|
587 |
+
$nvpStr .= "&STREET2=" . $this->Address2;
|
588 |
+
|
589 |
+
$nvpStr .= "&CITY=" . $this->billing->city . "&STATE=" . $this->billing->state . "&COUNTRYCODE=" . $this->billing->country . "&ZIP=" . $this->billing->zip . "&SHIPTOPHONENUM=" . $this->billing->phone;
|
590 |
+
}
|
591 |
+
|
592 |
+
$this->nvpStr = $nvpStr;
|
593 |
+
|
594 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('DoDirectPayment', $nvpStr);
|
595 |
+
|
596 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
597 |
+
$this->authorization_id = $this->httpParsedResponseAr[TRANSACTIONID];
|
598 |
+
$this->updateStatus("authorized");
|
599 |
+
return $this->authorization_id;
|
600 |
+
} else {
|
601 |
+
$this->status = "error";
|
602 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
603 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
604 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
605 |
+
return false;
|
606 |
+
}
|
607 |
+
}
|
608 |
+
|
609 |
+
function voidAuthorizationWithPayPal($authorization_id)
|
610 |
+
{
|
611 |
+
//paypal profile stuff
|
612 |
+
$nvpStr="&AUTHORIZATIONID=" . $authorization_id . "&NOTE=Voiding an authorization for a recurring payment setup.";
|
613 |
+
|
614 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('DoVoid', $nvpStr);
|
615 |
+
|
616 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
617 |
+
return true;
|
618 |
+
} else {
|
619 |
+
$this->status = "error";
|
620 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
621 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
622 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
623 |
+
return false;
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
function chargeWithPayPal()
|
628 |
{
|
629 |
+
global $pmpro_currency;
|
630 |
+
|
631 |
+
if(!$this->code)
|
632 |
+
$this->code = $this->getRandomCode();
|
633 |
+
|
634 |
+
//taxes on the amount
|
635 |
+
$amount = $this->InitialPayment;
|
636 |
+
$amount_tax = $this->getTaxForPrice($amount);
|
637 |
+
$this->subtotal = $amount;
|
638 |
+
$amount = round((float)$amount + (float)$amount_tax, 2);
|
639 |
+
|
640 |
+
//paypal profile stuff
|
641 |
+
$nvpStr = "";
|
642 |
+
if($this->Token)
|
643 |
+
$nvpStr .= "&TOKEN=" . $this->Token;
|
644 |
+
$nvpStr .="&AMT=" . $amount . "&ITEMAMT=" . $this->InitialPayment . "&TAXAMT=" . $amount_tax . "&CURRENCYCODE=" . $pmpro_currency;
|
645 |
+
$nvpStr .= "&NOTIFYURL=" . urlencode(PMPRO_URL . "/services/ipnhandler.php");
|
646 |
+
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $this->PaymentAmount;
|
647 |
+
|
648 |
+
$nvpStr .= "&PAYMENTACTION=Sale&IPADDRESS=" . $_SERVER['REMOTE_ADDR'] . "&INVNUM=" . $this->code;
|
649 |
+
|
650 |
+
//credit card fields
|
651 |
+
if($this->cardtype == "American Express")
|
652 |
+
$cardtype = "Amex";
|
653 |
+
else
|
654 |
+
$cardtype = $this->cardtype;
|
655 |
+
|
656 |
+
if($cardtype)
|
657 |
+
$nvpStr .= "&CREDITCARDTYPE=" . $cardtype . "&ACCT=" . $this->accountnumber . "&EXPDATE=" . $this->ExpirationDate . "&CVV2=" . $this->CVV2;
|
658 |
+
|
659 |
+
//Maestro/Solo card fields. (Who uses these?) :)
|
660 |
+
if($this->StartDate)
|
661 |
+
$nvpStr .= "&STARTDATE=" . $this->StartDate . "&ISSUENUMBER=" . $this->IssueNumber;
|
662 |
+
|
663 |
+
//billing address, etc
|
664 |
+
if($this->Address1)
|
665 |
+
{
|
666 |
+
$nvpStr .= "&EMAIL=" . $this->Email . "&FIRSTNAME=" . $this->FirstName . "&LASTNAME=" . $this->LastName . "&STREET=" . $this->Address1;
|
667 |
+
|
668 |
+
if($this->Address2)
|
669 |
+
$nvpStr .= "&STREET2=" . $this->Address2;
|
670 |
+
|
671 |
+
$nvpStr .= "&CITY=" . $this->billing->city . "&STATE=" . $this->billing->state . "&COUNTRYCODE=" . $this->billing->country . "&ZIP=" . $this->billing->zip . "&SHIPTOPHONENUM=" . $this->billing->phone;
|
672 |
+
}
|
673 |
+
|
674 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('DoDirectPayment', $nvpStr);
|
675 |
+
|
676 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
677 |
+
$this->payment_transaction_id = $this->httpParsedResponseAr[TRANSACTIONID];
|
678 |
+
$this->updateStatus("firstpayment");
|
679 |
+
return true;
|
680 |
+
} else {
|
681 |
+
$this->status = "error";
|
682 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
683 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
684 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
685 |
+
return false;
|
686 |
+
}
|
687 |
+
}
|
688 |
+
|
689 |
+
function processWithPayPal()
|
690 |
+
{
|
691 |
+
global $pmpro_currency;
|
692 |
+
|
693 |
+
if(!$this->code)
|
694 |
+
$this->code = $this->getRandomCode();
|
695 |
+
|
696 |
+
//taxes on the amount
|
697 |
+
$amount = $this->PaymentAmount;
|
698 |
+
$amount_tax = $this->getTaxForPrice($amount);
|
699 |
+
$this->subtotal = $amount;
|
700 |
+
$amount = round((float)$amount + (float)$amount_tax, 2);
|
701 |
+
|
702 |
+
//paypal profile stuff
|
703 |
+
$nvpStr = "";
|
704 |
+
if($this->Token)
|
705 |
+
$nvpStr .= "&TOKEN=" . $this->Token;
|
706 |
+
$nvpStr .="&AMT=" . $this->PaymentAmount . "&TAXAMT=" . $amount_tax . "&CURRENCYCODE=" . $pmpro_currency . "&PROFILESTARTDATE=" . $this->ProfileStartDate;
|
707 |
+
$nvpStr .= "&BILLINGPERIOD=" . $this->BillingPeriod . "&BILLINGFREQUENCY=" . $this->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling";
|
708 |
+
$nvpStr .= "&DESC=" . $amount;
|
709 |
+
$nvpStr .= "&NOTIFYURL=" . urlencode(PMPRO_URL . "/services/ipnhandler.php");
|
710 |
+
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $this->PaymentAmount;
|
711 |
+
|
712 |
+
//if billing cycles are defined
|
713 |
+
if($this->TotalBillingCycles)
|
714 |
+
$nvpStr .= "&TOTALBILLINGCYCLES=" . $this->TotalBillingCycles;
|
715 |
+
|
716 |
+
//if a trial period is defined
|
717 |
+
if($this->TrialBillingPeriod)
|
718 |
+
{
|
719 |
+
$trial_amount = $this->TrialAmount;
|
720 |
+
$trial_tax = $this->getTaxForPrice($trial_amount);
|
721 |
+
$trial_amount = round((float)$trial_amount + (float)$trial_tax, 2);
|
722 |
+
|
723 |
+
$nvpStr .= "&TRIALBILLINGPERIOD=" . $this->TrialBillingPeriod . "&TRIALBILLINGFREQUENCY=" . $this->TrialBillingFrequency . "&TRIALAMNT=" . $trial_amount;
|
724 |
+
}
|
725 |
+
if($this->TrialBillingCycles)
|
726 |
+
$nvpStr .= "&TRIALTOTALBILLINGCYCLES=" . $this->TrialBillingCycles;
|
727 |
+
|
728 |
+
//credit card fields
|
729 |
+
if($this->cardtype == "American Express")
|
730 |
+
$cardtype = "Amex";
|
731 |
+
else
|
732 |
+
$cardtype = $this->cardtype;
|
733 |
+
|
734 |
+
if($cardtype)
|
735 |
+
$nvpStr .= "&CREDITCARDTYPE=" . $cardtype . "&ACCT=" . $this->accountnumber . "&EXPDATE=" . $this->ExpirationDate . "&CVV2=" . $this->CVV2;
|
736 |
+
|
737 |
+
//Maestro/Solo card fields. (Who uses these?) :)
|
738 |
+
if($this->StartDate)
|
739 |
+
$nvpStr .= "&STARTDATE=" . $this->StartDate . "&ISSUENUMBER=" . $this->IssueNumber;
|
740 |
+
|
741 |
+
//billing address, etc
|
742 |
+
if($this->Address1)
|
743 |
{
|
744 |
+
$nvpStr .= "&EMAIL=" . $this->Email . "&FIRSTNAME=" . $this->FirstName . "&LASTNAME=" . $this->LastName . "&STREET=" . $this->Address1;
|
745 |
+
|
746 |
+
if($this->Address2)
|
747 |
+
$nvpStr .= "&STREET2=" . $this->Address2;
|
748 |
+
|
749 |
+
$nvpStr .= "&CITY=" . $this->billing->city . "&STATE=" . $this->billing->state . "&COUNTRYCODE=" . $this->billing->country . "&ZIP=" . $this->billing->zip . "&SHIPTOPHONENUM=" . $this->billing->phone;
|
750 |
+
}
|
751 |
+
|
752 |
+
$this->nvpStr = $nvpStr;
|
753 |
+
|
754 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
|
755 |
+
|
756 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
757 |
+
$this->status = "success";
|
758 |
+
$this->subscription_transaction_id = urldecode($this->httpParsedResponseAr[PROFILEID]);
|
759 |
+
return true;
|
760 |
+
//exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($this->httpParsedResponseAr, true));
|
761 |
+
} else {
|
762 |
+
$this->status = "error";
|
763 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
764 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
765 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
766 |
+
return false;
|
767 |
+
//exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
|
768 |
+
}
|
769 |
+
}
|
770 |
+
|
771 |
+
function cancelWithPayPal()
|
772 |
+
{
|
773 |
+
//paypal profile stuff
|
774 |
+
$nvpStr = "";
|
775 |
+
$nvpStr .= "&PROFILEID=" . $this->subscription_transaction_id . "&ACTION=Cancel&NOTE=User requested cancel.";
|
776 |
+
|
777 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('ManageRecurringPaymentsProfileStatus', $nvpStr);
|
778 |
+
|
779 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
780 |
$this->updateStatus("cancelled");
|
781 |
return true;
|
782 |
+
//exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($this->httpParsedResponseAr, true));
|
783 |
+
} else {
|
784 |
+
$this->status = "error";
|
785 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
786 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
787 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
788 |
+
return false;
|
789 |
+
//exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
|
790 |
}
|
791 |
+
}
|
792 |
+
|
793 |
+
function updateWithPayPal()
|
794 |
+
{
|
795 |
+
//paypal profile stuff
|
796 |
+
$nvpStr = "";
|
797 |
+
$nvpStr .= "&PROFILEID=" . $this->subscription_transaction_id;
|
798 |
+
|
799 |
+
//credit card fields
|
800 |
+
if($this->cardtype == "American Express")
|
801 |
+
$cardtype = "Amex";
|
802 |
else
|
803 |
+
$cardtype = $this->cardtype;
|
804 |
+
|
805 |
+
//credit card fields
|
806 |
+
if($cardtype)
|
807 |
+
$nvpStr .= "&CREDITCARDTYPE=" . $cardtype . "&ACCT=" . $this->accountnumber . "&EXPDATE=" . $this->ExpirationDate . "&CVV2=" . $this->CVV2;
|
808 |
+
|
809 |
+
//Maestro/Solo card fields. (Who uses these?) :)
|
810 |
+
if($this->StartDate)
|
811 |
+
$nvpStr .= "&STARTDATE=" . $this->StartDate . "&ISSUENUMBER=" . $this->IssueNumber;
|
812 |
+
|
813 |
+
//billing address, etc
|
814 |
+
if($this->Address1)
|
815 |
+
{
|
816 |
+
$nvpStr .= "&EMAIL=" . $this->Email . "&FIRSTNAME=" . $this->FirstName . "&LASTNAME=" . $this->LastName . "&STREET=" . $this->Address1;
|
817 |
+
|
818 |
+
if($this->Address2)
|
819 |
+
$nvpStr .= "&STREET2=" . $this->Address2;
|
820 |
+
|
821 |
+
$nvpStr .= "&CITY=" . $this->billing->city . "&STATE=" . $this->billing->state . "&COUNTRYCODE=" . $this->billing->country . "&ZIP=" . $this->billing->zip;
|
822 |
+
}
|
823 |
+
|
824 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('UpdateRecurringPaymentsProfile', $nvpStr);
|
825 |
+
|
826 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
827 |
+
$this->status = "success";
|
828 |
+
$this->subscription_transaction_id = urldecode($this->httpParsedResponseAr[PROFILEID]);
|
829 |
+
return true;
|
830 |
+
//exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($this->httpParsedResponseAr, true));
|
831 |
+
} else {
|
832 |
+
$this->status = "error";
|
833 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
834 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
835 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
836 |
+
return false;
|
837 |
+
//exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
|
838 |
+
}
|
839 |
+
}
|
840 |
+
|
841 |
+
//PayPal Express, this is run first to authorize from PayPal
|
842 |
+
function setExpressCheckout()
|
843 |
+
{
|
844 |
+
global $pmpro_currency;
|
845 |
+
|
846 |
+
if(!$this->code)
|
847 |
+
$this->code = $this->getRandomCode();
|
848 |
+
|
849 |
+
//clean up a couple values
|
850 |
+
$this->payment_type = "PayPal Express";
|
851 |
+
$this->CardType = "";
|
852 |
+
$this->cardtype = "";
|
853 |
+
|
854 |
+
//taxes on initial amount
|
855 |
+
$initial_payment = $this->InitialPayment;
|
856 |
+
$initial_payment_tax = $this->getTaxForPrice($initial_payment);
|
857 |
+
$initial_payment = round((float)$initial_payment + (float)$initial_payment_tax, 2);
|
858 |
+
|
859 |
+
//taxes on the amount
|
860 |
+
$amount = $this->PaymentAmount;
|
861 |
+
$amount_tax = $this->getTaxForPrice($amount);
|
862 |
+
$this->subtotal = $amount;
|
863 |
+
$amount = round((float)$amount + (float)$amount_tax, 2);
|
864 |
+
|
865 |
+
//paypal profile stuff
|
866 |
+
$nvpStr = "";
|
867 |
+
$nvpStr .="&AMT=" . $initial_payment . "&TAXAMT=" . $amount_tax . "&CURRENCYCODE=" . $pmpro_currency . "&PROFILESTARTDATE=" . $this->ProfileStartDate;
|
868 |
+
$nvpStr .= "&BILLINGPERIOD=" . $this->BillingPeriod . "&BILLINGFREQUENCY=" . $this->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling";
|
869 |
+
$nvpStr .= "&DESC=" . $amount;
|
870 |
+
$nvpStr .= "&NOTIFYURL=" . urlencode(PMPRO_URL . "/services/ipnhandler.php");
|
871 |
+
$nvpStr .= "&NOSHIPPING=1&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . urlencode($this->membership_level->name . " at " . get_bloginfo("name")) . "&L_PAYMENTTYPE0=Any";
|
872 |
|
873 |
+
//if billing cycles are defined
|
874 |
+
if($this->TotalBillingCycles)
|
875 |
+
$nvpStr .= "&TOTALBILLINGCYCLES=" . $this->TotalBillingCycles;
|
876 |
+
|
877 |
+
//if a trial period is defined
|
878 |
+
if($this->TrialBillingPeriod)
|
879 |
+
{
|
880 |
+
$trial_amount = $this->TrialAmount;
|
881 |
+
$trial_tax = $this->getTaxForPrice($trial_amount);
|
882 |
+
$trial_amount = round((float)$trial_amount + (float)$trial_tax, 2);
|
883 |
+
|
884 |
+
$nvpStr .= "&TRIALBILLINGPERIOD=" . $this->TrialBillingPeriod . "&TRIALBILLINGFREQUENCY=" . $this->TrialBillingFrequency . "&TRIALAMNT=" . $trial_amount;
|
885 |
+
}
|
886 |
+
if($this->TrialBillingCycles)
|
887 |
+
$nvpStr .= "&TRIALTOTALBILLINGCYCLES=" . $this->TrialBillingCycles;
|
888 |
+
|
889 |
+
if($this->discount_code)
|
890 |
+
{
|
891 |
+
$nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?level=" . $this->membership_level->id . "&discount_code=" . $this->discount_code . "&review=" . $this->code));
|
892 |
}
|
893 |
+
else
|
894 |
+
{
|
895 |
+
$nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?level=" . $this->membership_level->id . "&review=" . $this->code));
|
896 |
+
}
|
897 |
+
$nvpStr .= "&CANCELURL=" . urlencode(pmpro_url("levels"));
|
898 |
+
|
899 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('SetExpressCheckout', $nvpStr);
|
900 |
+
|
901 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
902 |
+
$this->status = "token";
|
903 |
+
$this->paypal_token = urldecode($this->httpParsedResponseAr[TOKEN]);
|
904 |
+
$this->subscription_transaction_id = urldecode($this->httpParsedResponseAr[PROFILEID]);
|
905 |
+
|
906 |
+
//update order
|
907 |
+
$this->saveOrder();
|
908 |
+
|
909 |
+
//redirect to paypal
|
910 |
+
$paypal_url = "https://www.paypal.com/webscr&cmd=_express-checkout&token=" . $this->httpParsedResponseAr[TOKEN];
|
911 |
+
$environment = pmpro_getOption("gateway_environment");
|
912 |
+
if("sandbox" === $environment || "beta-sandbox" === $environment)
|
913 |
+
{
|
914 |
+
$paypal_url = "https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=" . $this->httpParsedResponseAr[TOKEN];
|
915 |
+
}
|
916 |
+
|
917 |
+
wp_redirect($paypal_url);
|
918 |
+
exit;
|
919 |
+
|
920 |
+
//exit('SetExpressCheckout Completed Successfully: '.print_r($this->httpParsedResponseAr, true));
|
921 |
+
} else {
|
922 |
+
$this->status = "error";
|
923 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
924 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
925 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
926 |
+
return false;
|
927 |
+
//exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
|
928 |
+
}
|
929 |
+
|
930 |
+
//write session?
|
931 |
+
|
932 |
+
//redirect to PayPal
|
933 |
}
|
934 |
|
935 |
+
function getPayPalExpressCheckoutDetails()
|
936 |
+
{
|
937 |
+
$nvpStr="&TOKEN=".$this->Token;
|
938 |
+
|
939 |
+
/* Make the API call and store the results in an array. If the
|
940 |
+
call was a success, show the authorization details, and provide
|
941 |
+
an action to complete the payment. If failed, show the error
|
942 |
+
*/
|
943 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('GetExpressCheckoutDetails', $nvpStr);
|
944 |
+
|
945 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
946 |
+
$this->status = "review";
|
947 |
+
|
948 |
+
//update order
|
949 |
+
$this->saveOrder();
|
950 |
+
|
951 |
+
return true;
|
952 |
+
} else {
|
953 |
+
$this->status = "error";
|
954 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
955 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
956 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
957 |
+
return false;
|
958 |
+
//exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
|
959 |
+
}
|
960 |
+
}
|
961 |
+
|
962 |
+
function chargeWithPayPalExpress()
|
963 |
{
|
964 |
+
global $pmpro_currency;
|
965 |
+
|
966 |
+
if(!$this->code)
|
967 |
+
$this->code = $this->getRandomCode();
|
968 |
+
|
969 |
+
//taxes on the amount
|
970 |
+
$amount = $this->InitialPayment;
|
971 |
+
$amount_tax = $this->getTaxForPrice($amount);
|
972 |
+
$this->subtotal = $amount;
|
973 |
+
$amount = round((float)$amount + (float)$amount_tax, 2);
|
974 |
+
|
975 |
+
//paypal profile stuff
|
976 |
+
$nvpStr = "";
|
977 |
+
if($this->Token)
|
978 |
+
$nvpStr .= "&TOKEN=" . $this->Token;
|
979 |
+
$nvpStr .="&AMT=" . $this->InitialPayment . "&TAXAMT=" . $amount_tax . "&CURRENCYCODE=" . $pmpro_currency . "&PROFILESTARTDATE=" . $this->ProfileStartDate;
|
980 |
+
$nvpStr .= "&BILLINGPERIOD=" . $this->BillingPeriod . "&BILLINGFREQUENCY=" . $this->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling";
|
981 |
+
$nvpStr .= "&DESC=" . $amount;
|
982 |
+
$nvpStr .= "&NOTIFYURL=" . urlencode(PMPRO_URL . "/services/ipnhandler.php");
|
983 |
+
$nvpStr .= "&NOSHIPPING=1";
|
984 |
+
|
985 |
+
$nvpStr .= "&PAYERID=" . $_SESSION['payer_id'] . "&PAYMENTACTION=sale";
|
986 |
+
$this->nvpStr = $nvpStr;
|
987 |
+
|
988 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('DoExpressCheckoutPayment', $nvpStr);
|
989 |
+
|
990 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
991 |
+
$this->payment_transaction_id = urldecode($this->httpParsedResponseAr[PROFILEID]);
|
992 |
+
$this->status = "firstpayment";
|
993 |
+
|
994 |
+
//update order
|
995 |
+
$this->saveOrder();
|
996 |
+
|
997 |
+
return true;
|
998 |
+
} else {
|
999 |
+
$this->status = "error";
|
1000 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
1001 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
1002 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
1003 |
+
return false;
|
1004 |
+
//exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
|
1005 |
+
}
|
1006 |
+
}
|
1007 |
|
1008 |
+
function processWithPayPalExpress()
|
1009 |
{
|
1010 |
+
global $pmpro_currency;
|
1011 |
+
|
1012 |
+
if(!$this->code)
|
1013 |
+
$this->code = $this->getRandomCode();
|
1014 |
+
|
1015 |
+
//taxes on initial amount
|
1016 |
+
$initial_payment = $this->InitialPayment;
|
1017 |
+
$initial_payment_tax = $this->getTaxForPrice($initial_payment);
|
1018 |
+
$initial_payment = round((float)$initial_payment + (float)$initial_payment_tax, 2);
|
1019 |
+
|
1020 |
+
//taxes on the amount
|
1021 |
+
$amount = $this->PaymentAmount;
|
1022 |
+
$amount_tax = $this->getTaxForPrice($amount);
|
1023 |
+
$this->subtotal = $amount;
|
1024 |
+
$amount = round((float)$amount + (float)$amount_tax, 2);
|
1025 |
+
|
1026 |
+
//paypal profile stuff
|
1027 |
+
$nvpStr = "";
|
1028 |
+
if($this->Token)
|
1029 |
+
$nvpStr .= "&TOKEN=" . $this->Token;
|
1030 |
+
$nvpStr .="&INITAMT=" . $initial_payment . "&AMT=" . $this->PaymentAmount . "&TAXAMT=" . $amount_tax . "&CURRENCYCODE=" . $pmpro_currency . "&PROFILESTARTDATE=" . $this->ProfileStartDate;
|
1031 |
+
$nvpStr .= "&BILLINGPERIOD=" . $this->BillingPeriod . "&BILLINGFREQUENCY=" . $this->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling";
|
1032 |
+
$nvpStr .= "&NOTIFYURL=" . urlencode(PMPRO_URL . "/services/ipnhandler.php");
|
1033 |
+
$nvpStr .= "&DESC=" . urlencode($this->membership_level->name . " at " . get_bloginfo("name"));
|
1034 |
+
|
1035 |
+
//if billing cycles are defined
|
1036 |
+
if($this->TotalBillingCycles)
|
1037 |
+
$nvpStr .= "&TOTALBILLINGCYCLES=" . $this->TotalBillingCycles;
|
1038 |
+
|
1039 |
+
//if a trial period is defined
|
1040 |
+
if($this->TrialBillingPeriod)
|
1041 |
+
{
|
1042 |
+
$trial_amount = $this->TrialAmount;
|
1043 |
+
$trial_tax = $this->getTaxForPrice($trial_amount);
|
1044 |
+
$trial_amount = round((float)$trial_amount + (float)$trial_tax, 2);
|
1045 |
+
|
1046 |
+
$nvpStr .= "&TRIALBILLINGPERIOD=" . $this->TrialBillingPeriod . "&TRIALBILLINGFREQUENCY=" . $this->TrialBillingFrequency . "&TRIALAMNT=" . $trial_amount;
|
1047 |
+
}
|
1048 |
+
if($this->TrialBillingCycles)
|
1049 |
+
$nvpStr .= "&TRIALTOTALBILLINGCYCLES=" . $this->TrialBillingCycles;
|
1050 |
+
|
1051 |
+
$this->nvpStr = $nvpStr;
|
1052 |
+
|
1053 |
+
$this->httpParsedResponseAr = $this->PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
|
1054 |
+
|
1055 |
+
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
1056 |
+
$this->status = "success";
|
1057 |
+
$this->payment_transaction_id = urldecode($this->httpParsedResponseAr[PROFILEID]);
|
1058 |
+
$this->subscription_transaction_id = urldecode($this->httpParsedResponseAr[PROFILEID]);
|
1059 |
+
|
1060 |
+
//update order
|
1061 |
+
$this->saveOrder();
|
1062 |
+
|
1063 |
+
return true;
|
1064 |
+
} else {
|
1065 |
+
$this->status = "error";
|
1066 |
+
$this->errorcode = $this->httpParsedResponseAr[L_ERRORCODE0];
|
1067 |
+
$this->error = urldecode($this->httpParsedResponseAr[L_LONGMESSAGE0]);
|
1068 |
+
$this->shorterror = urldecode($this->httpParsedResponseAr[L_SHORTMESSAGE0]);
|
1069 |
+
|
1070 |
+
return false;
|
1071 |
+
}
|
1072 |
}
|
1073 |
|
1074 |
+
//Authorize.net Function
|
1075 |
+
//function to send xml request via fsockopen
|
1076 |
+
function send_request_via_fsockopen($host,$path,$content)
|
1077 |
+
{
|
1078 |
+
$posturl = "ssl://" . $host;
|
1079 |
+
$header = "Host: $host\r\n";
|
1080 |
+
$header .= "User-Agent: PHP Script\r\n";
|
1081 |
+
$header .= "Content-Type: text/xml\r\n";
|
1082 |
+
$header .= "Content-Length: ".strlen($content)."\r\n";
|
1083 |
+
$header .= "Connection: close\r\n\r\n";
|
1084 |
+
$fp = fsockopen($posturl, 443, $errno, $errstr, 30);
|
1085 |
+
if (!$fp)
|
1086 |
+
{
|
1087 |
+
$response = false;
|
1088 |
+
}
|
1089 |
+
else
|
1090 |
+
{
|
1091 |
+
error_reporting(E_ERROR);
|
1092 |
+
fputs($fp, "POST $path HTTP/1.1\r\n");
|
1093 |
+
fputs($fp, $header.$content);
|
1094 |
+
fwrite($fp, $out);
|
1095 |
+
$response = "";
|
1096 |
+
while (!feof($fp))
|
1097 |
+
{
|
1098 |
+
$response = $response . fgets($fp, 128);
|
1099 |
+
}
|
1100 |
+
fclose($fp);
|
1101 |
+
error_reporting(E_ALL ^ E_NOTICE);
|
1102 |
+
}
|
1103 |
+
return $response;
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
//Authorize.net Function
|
1107 |
+
//function to send xml request via curl
|
1108 |
+
function send_request_via_curl($host,$path,$content)
|
1109 |
{
|
1110 |
+
$posturl = "https://" . $host . $path;
|
1111 |
+
$ch = curl_init();
|
1112 |
+
curl_setopt($ch, CURLOPT_URL, $posturl);
|
1113 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
1114 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
|
1115 |
+
curl_setopt($ch, CURLOPT_HEADER, 1);
|
1116 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
1117 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
1118 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
1119 |
+
$response = curl_exec($ch);
|
1120 |
+
return $response;
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
|
1124 |
+
//Authorize.net Function
|
1125 |
+
//function to parse Authorize.net response
|
1126 |
+
function parse_return($content)
|
1127 |
+
{
|
1128 |
+
$refId = $this->substring_between($content,'<refId>','</refId>');
|
1129 |
+
$resultCode = $this->substring_between($content,'<resultCode>','</resultCode>');
|
1130 |
+
$code = $this->substring_between($content,'<code>','</code>');
|
1131 |
+
$text = $this->substring_between($content,'<text>','</text>');
|
1132 |
+
$subscriptionId = $this->substring_between($content,'<subscriptionId>','</subscriptionId>');
|
1133 |
+
return array ($refId, $resultCode, $code, $text, $subscriptionId);
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
//Authorize.net Function
|
1137 |
+
//helper function for parsing response
|
1138 |
+
function substring_between($haystack,$start,$end)
|
1139 |
+
{
|
1140 |
+
if (strpos($haystack,$start) === false || strpos($haystack,$end) === false)
|
1141 |
+
{
|
1142 |
+
return false;
|
1143 |
+
}
|
1144 |
+
else
|
1145 |
+
{
|
1146 |
+
$start_position = strpos($haystack,$start)+strlen($start);
|
1147 |
+
$end_position = strpos($haystack,$end);
|
1148 |
+
return substr($haystack,$start_position,$end_position-$start_position);
|
1149 |
+
}
|
1150 |
}
|
1151 |
|
1152 |
+
//authorize just $1 to test credit card
|
1153 |
+
function authorizeWithAuthorizeNet()
|
1154 |
{
|
1155 |
+
if(!$this->code)
|
1156 |
+
$this->code = $this->getRandomCode();
|
1157 |
+
|
1158 |
+
$gateway_environment = $this->gateway_environment;
|
1159 |
+
if(!$gateway_environment)
|
1160 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
1161 |
+
if($gateway_environment == "live")
|
1162 |
+
$host = "secure.authorize.net";
|
1163 |
+
else
|
1164 |
+
$host = "test.authorize.net";
|
1165 |
+
|
1166 |
+
$path = "/gateway/transact.dll";
|
1167 |
+
$post_url = "https://" . $host . $path;
|
1168 |
+
|
1169 |
+
//what amount to authorize? just $1 to test
|
1170 |
+
$amount = "1.00";
|
1171 |
+
|
1172 |
+
//combine address
|
1173 |
+
$address = $this->Address1;
|
1174 |
+
if($this->Address2)
|
1175 |
+
$address .= "\n" . $this->Address2;
|
1176 |
+
|
1177 |
+
//customer stuff
|
1178 |
+
$customer_email = $this->Email;
|
1179 |
+
$customer_phone = $this->billing->phone;
|
1180 |
+
|
1181 |
+
$post_values = array(
|
1182 |
+
|
1183 |
+
// the API Login ID and Transaction Key must be replaced with valid values
|
1184 |
+
"x_login" => pmpro_getOption("loginname"),
|
1185 |
+
"x_tran_key" => pmpro_getOption("transactionkey"),
|
1186 |
+
|
1187 |
+
"x_version" => "3.1",
|
1188 |
+
"x_delim_data" => "TRUE",
|
1189 |
+
"x_delim_char" => "|",
|
1190 |
+
"x_relay_response" => "FALSE",
|
1191 |
+
|
1192 |
+
"x_type" => "AUTH_ONLY",
|
1193 |
+
"x_method" => "CC",
|
1194 |
+
"x_card_type" => $this->cardtype,
|
1195 |
+
"x_card_num" => $this->accountnumber,
|
1196 |
+
"x_exp_date" => $this->ExpirationDate,
|
1197 |
+
"x_card_code" => $this->CVV2,
|
1198 |
+
|
1199 |
+
"x_amount" => $amount,
|
1200 |
+
"x_description" => $this->level->name . " Membership",
|
1201 |
+
|
1202 |
+
"x_first_name" => $this->FirstName,
|
1203 |
+
"x_last_name" => $this->LastName,
|
1204 |
+
"x_address" => $address,
|
1205 |
+
"x_city" => $this->billing->city,
|
1206 |
+
"x_state" => $this->billing->state,
|
1207 |
+
"x_zip" => $this->billing->zip,
|
1208 |
+
"x_country" => $this->billing->country,
|
1209 |
+
"x_invoice_num" => $this->code,
|
1210 |
+
"x_phone" => $customer_phone,
|
1211 |
+
"x_email" => $this->Email
|
1212 |
+
// Additional fields can be added here as outlined in the AIM integration
|
1213 |
+
// guide at: http://developer.authorize.net
|
1214 |
+
);
|
1215 |
+
|
1216 |
+
// This section takes the input fields and converts them to the proper format
|
1217 |
+
// for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
|
1218 |
+
$post_string = "";
|
1219 |
+
foreach( $post_values as $key => $value )
|
1220 |
+
{ $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&"; }
|
1221 |
+
$post_string = rtrim( $post_string, "& " );
|
1222 |
+
|
1223 |
+
//curl
|
1224 |
+
$request = curl_init($post_url); // initiate curl object
|
1225 |
+
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
1226 |
+
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
1227 |
+
curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
|
1228 |
+
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
|
1229 |
+
$post_response = curl_exec($request); // execute curl post and store results in $post_response
|
1230 |
+
// additional options may be required depending upon your server configuration
|
1231 |
+
// you can find documentation on curl options at http://www.php.net/curl_setopt
|
1232 |
+
curl_close ($request); // close curl object
|
1233 |
+
|
1234 |
+
// This line takes the response and breaks it into an array using the specified delimiting character
|
1235 |
+
$response_array = explode($post_values["x_delim_char"],$post_response);
|
1236 |
+
if($response_array[0] == 1)
|
1237 |
+
{
|
1238 |
+
$this->payment_transaction_id = $response_array[4];
|
1239 |
+
$this->updateStatus("authorized");
|
1240 |
+
return true;
|
1241 |
+
}
|
1242 |
+
else
|
1243 |
+
{
|
1244 |
+
//$this->status = "error";
|
1245 |
+
$this->errorcode = $response_array[2];
|
1246 |
+
$this->error = $response_array[3];
|
1247 |
+
$this->shorterror = $response_array[3];
|
1248 |
return false;
|
1249 |
+
}
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
//charge first periods payment
|
1253 |
+
function chargeWithAuthorizeNet()
|
1254 |
+
{
|
1255 |
+
if(!$this->code)
|
1256 |
+
$this->code = $this->getRandomCode();
|
1257 |
|
1258 |
+
$gateway_environment = $this->gateway_environment;
|
1259 |
+
if(!$gateway_environment)
|
1260 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
1261 |
+
if($gateway_environment == "live")
|
1262 |
+
$host = "secure.authorize.net";
|
1263 |
+
else
|
1264 |
+
$host = "test.authorize.net";
|
1265 |
+
|
1266 |
+
$path = "/gateway/transact.dll";
|
1267 |
+
$post_url = "https://" . $host . $path;
|
1268 |
+
|
1269 |
+
//what amount to charge?
|
1270 |
+
$amount = $this->InitialPayment;
|
1271 |
+
|
1272 |
+
//tax
|
1273 |
+
$this->subtotal = $amount;
|
1274 |
+
$tax = $this->getTax(true);
|
1275 |
+
$amount = round((float)$this->subtotal + (float)$tax, 2);
|
1276 |
+
|
1277 |
+
//combine address
|
1278 |
+
$address = $this->Address1;
|
1279 |
+
if($this->Address2)
|
1280 |
+
$address .= "\n" . $this->Address2;
|
1281 |
+
|
1282 |
+
//customer stuff
|
1283 |
+
$customer_email = $this->Email;
|
1284 |
+
$customer_phone = $this->billing->phone;
|
1285 |
+
|
1286 |
+
$post_values = array(
|
1287 |
+
|
1288 |
+
// the API Login ID and Transaction Key must be replaced with valid values
|
1289 |
+
"x_login" => pmpro_getOption("loginname"),
|
1290 |
+
"x_tran_key" => pmpro_getOption("transactionkey"),
|
1291 |
+
|
1292 |
+
"x_version" => "3.1",
|
1293 |
+
"x_delim_data" => "TRUE",
|
1294 |
+
"x_delim_char" => "|",
|
1295 |
+
"x_relay_response" => "FALSE",
|
1296 |
+
|
1297 |
+
"x_type" => "AUTH_CAPTURE",
|
1298 |
+
"x_method" => "CC",
|
1299 |
+
"x_card_type" => $this->cardtype,
|
1300 |
+
"x_card_num" => $this->accountnumber,
|
1301 |
+
"x_exp_date" => $this->ExpirationDate,
|
1302 |
+
"x_card_code" => $this->CVV2,
|
1303 |
+
|
1304 |
+
"x_amount" => $amount,
|
1305 |
+
"x_tax" => $tax,
|
1306 |
+
"x_description" => $this->level->name . " Membership",
|
1307 |
+
|
1308 |
+
"x_first_name" => $this->FirstName,
|
1309 |
+
"x_last_name" => $this->LastName,
|
1310 |
+
"x_address" => $address,
|
1311 |
+
"x_city" => $this->billing->city,
|
1312 |
+
"x_state" => $this->billing->state,
|
1313 |
+
"x_zip" => $this->billing->zip,
|
1314 |
+
"x_country" => $this->billing->country,
|
1315 |
+
"x_invoice_num" => $this->code,
|
1316 |
+
"x_phone" => $customer_phone,
|
1317 |
+
"x_email" => $this->Email
|
1318 |
+
|
1319 |
+
// Additional fields can be added here as outlined in the AIM integration
|
1320 |
+
// guide at: http://developer.authorize.net
|
1321 |
+
);
|
1322 |
+
|
1323 |
+
// This section takes the input fields and converts them to the proper format
|
1324 |
+
// for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
|
1325 |
+
$post_string = "";
|
1326 |
+
foreach( $post_values as $key => $value )
|
1327 |
+
{ $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&"; }
|
1328 |
+
$post_string = rtrim( $post_string, "& " );
|
1329 |
+
|
1330 |
+
//curl
|
1331 |
+
$request = curl_init($post_url); // initiate curl object
|
1332 |
+
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
1333 |
+
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
1334 |
+
curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
|
1335 |
+
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
|
1336 |
+
$post_response = curl_exec($request); // execute curl post and store results in $post_response
|
1337 |
+
// additional options may be required depending upon your server configuration
|
1338 |
+
// you can find documentation on curl options at http://www.php.net/curl_setopt
|
1339 |
+
curl_close ($request); // close curl object
|
1340 |
+
|
1341 |
+
// This line takes the response and breaks it into an array using the specified delimiting character
|
1342 |
+
$response_array = explode($post_values["x_delim_char"],$post_response);
|
1343 |
+
if($response_array[0] == 1)
|
1344 |
{
|
1345 |
+
$this->payment_transaction_id = $response_array[4];
|
1346 |
+
$this->updateStatus("firstpayment");
|
1347 |
return true;
|
1348 |
}
|
1349 |
else
|
1350 |
+
{
|
1351 |
+
//$this->status = "error";
|
1352 |
+
$this->errorcode = $response_array[2];
|
1353 |
+
$this->error = $response_array[3];
|
1354 |
+
$this->shorterror = $response_array[3];
|
1355 |
+
return false;
|
1356 |
+
}
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
function processWithAuthorizeNet()
|
1360 |
+
{
|
1361 |
+
//define variables to send
|
1362 |
+
|
1363 |
+
if(!$this->code)
|
1364 |
+
$this->code = $this->getRandomCode();
|
1365 |
+
|
1366 |
+
$gateway_environment = $this->gateway_environment;
|
1367 |
+
if(!$gateway_environment)
|
1368 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
1369 |
+
if($gateway_environment == "live")
|
1370 |
+
$host = "api.authorize.net";
|
1371 |
+
else
|
1372 |
+
$host = "apitest.authorize.net";
|
1373 |
+
|
1374 |
+
$path = "/xml/v1/request.api";
|
1375 |
+
|
1376 |
+
$loginname = pmpro_getOption("loginname");
|
1377 |
+
$transactionkey = pmpro_getOption("transactionkey");
|
1378 |
+
|
1379 |
+
$amount = $this->PaymentAmount;
|
1380 |
+
$refId = $this->code;
|
1381 |
+
$name = $this->membership_name;
|
1382 |
+
$length = (int)$this->BillingFrequency;
|
1383 |
+
|
1384 |
+
if($this->BillingPeriod == "Month")
|
1385 |
+
$unit = "months";
|
1386 |
+
elseif($this->BillingPeriod == "Day")
|
1387 |
+
$unit = "days";
|
1388 |
+
elseif($this->BillingPeriod == "Year" && $this->BillingFrequency == 1)
|
1389 |
+
{
|
1390 |
+
$unit = "months";
|
1391 |
+
$length = 12;
|
1392 |
+
}
|
1393 |
+
elseif($this->BillingPeriod == "Week")
|
1394 |
+
{
|
1395 |
+
$unit = "days";
|
1396 |
+
$length = $length * 7; //converting weeks to days
|
1397 |
+
}
|
1398 |
+
else
|
1399 |
+
return false; //authorize.net only supports months and days
|
1400 |
+
|
1401 |
+
$startDate = substr($this->ProfileStartDate, 0, 10);
|
1402 |
+
$totalOccurrences = (int)$this->TotalBillingCycles;
|
1403 |
+
if(!$totalOccurrences)
|
1404 |
+
$totalOccurrences = 9999;
|
1405 |
+
$trialOccurrences = (int)$this->TrialBillingCycles;
|
1406 |
+
$trialAmount = $this->TrialAmount;
|
1407 |
+
|
1408 |
+
//taxes
|
1409 |
+
$amount_tax = $this->getTaxForPrice($amount);
|
1410 |
+
$trial_tax = $this->getTaxForPrice($trialAmount);
|
1411 |
+
|
1412 |
+
$this->subtotal = $amount;
|
1413 |
+
$amount = round((float)$amount + (float)$amount_tax, 2);
|
1414 |
+
$trialAmount = round((float)$trialAmount + (float)$trial_tax, 2);
|
1415 |
+
|
1416 |
+
//authorize.net doesn't support different periods between trial and actual
|
1417 |
+
|
1418 |
+
if($this->TrialBillingPeriod && $this->TrialBillingPeriod != $this->BillingPeriod)
|
1419 |
+
{
|
1420 |
+
echo "F";
|
1421 |
+
return false;
|
1422 |
+
}
|
1423 |
+
|
1424 |
+
$cardNumber = $this->accountnumber;
|
1425 |
+
$expirationDate = $this->ExpirationDate_YdashM;
|
1426 |
+
$cardCode = $this->CVV2;
|
1427 |
+
|
1428 |
+
$firstName = $this->FirstName;
|
1429 |
+
$lastName = $this->LastName;
|
1430 |
+
|
1431 |
+
//do address stuff then?
|
1432 |
+
$address = $this->Address1;
|
1433 |
+
if($this->Address2)
|
1434 |
+
$address .= "\n" . $this->Address2;
|
1435 |
+
$city = $this->billing->city;
|
1436 |
+
$state = $this->billing->state;
|
1437 |
+
$zip = $this->billing->zip;
|
1438 |
+
$country = $this->billing->country;
|
1439 |
+
|
1440 |
+
//customer stuff
|
1441 |
+
$customer_email = $this->Email;
|
1442 |
+
if(strpos($this->billing->phone, "+") === false)
|
1443 |
+
$customer_phone = $this->billing->phone;
|
1444 |
+
else
|
1445 |
+
$customer_phone = "";
|
1446 |
+
|
1447 |
+
//make sure the phone is in an okay format
|
1448 |
+
$customer_phone = preg_replace("/[^0-9]/", "", $customer_phone);
|
1449 |
+
if(strlen($customer_phone) > 10)
|
1450 |
+
$customer_phone = "";
|
1451 |
+
|
1452 |
+
//build xml to post
|
1453 |
+
$content =
|
1454 |
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
1455 |
+
"<ARBCreateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
1456 |
+
"<merchantAuthentication>".
|
1457 |
+
"<name>" . $loginname . "</name>".
|
1458 |
+
"<transactionKey>" . $transactionkey . "</transactionKey>".
|
1459 |
+
"</merchantAuthentication>".
|
1460 |
+
"<refId>" . $refId . "</refId>".
|
1461 |
+
"<subscription>".
|
1462 |
+
"<name>" . $name . "</name>".
|
1463 |
+
"<paymentSchedule>".
|
1464 |
+
"<interval>".
|
1465 |
+
"<length>". $length ."</length>".
|
1466 |
+
"<unit>". $unit ."</unit>".
|
1467 |
+
"</interval>".
|
1468 |
+
"<startDate>" . $startDate . "</startDate>".
|
1469 |
+
"<totalOccurrences>". $totalOccurrences . "</totalOccurrences>";
|
1470 |
+
if($trialOccurrences)
|
1471 |
+
$content .=
|
1472 |
+
"<trialOccurrences>". $trialOccurrences . "</trialOccurrences>";
|
1473 |
+
$content .=
|
1474 |
+
"</paymentSchedule>".
|
1475 |
+
"<amount>". $amount ."</amount>";
|
1476 |
+
if($trialOccurrences)
|
1477 |
+
$content .=
|
1478 |
+
"<trialAmount>" . $trialAmount . "</trialAmount>";
|
1479 |
+
$content .=
|
1480 |
+
"<payment>".
|
1481 |
+
"<creditCard>".
|
1482 |
+
"<cardNumber>" . $cardNumber . "</cardNumber>".
|
1483 |
+
"<expirationDate>" . $expirationDate . "</expirationDate>".
|
1484 |
+
"<cardCode>" . $cardCode . "</cardCode>".
|
1485 |
+
"</creditCard>".
|
1486 |
+
"</payment>".
|
1487 |
+
"<order><invoiceNumber>" . $this->code . "</invoiceNumber></order>".
|
1488 |
+
"<customer>".
|
1489 |
+
"<email>". $customer_email . "</email>".
|
1490 |
+
"<phoneNumber>". $customer_phone . "</phoneNumber>".
|
1491 |
+
"</customer>".
|
1492 |
+
"<billTo>".
|
1493 |
+
"<firstName>". $firstName . "</firstName>".
|
1494 |
+
"<lastName>" . $lastName . "</lastName>".
|
1495 |
+
"<address>". $address . "</address>".
|
1496 |
+
"<city>" . $city . "</city>".
|
1497 |
+
"<state>". $state . "</state>".
|
1498 |
+
"<zip>" . $zip . "</zip>".
|
1499 |
+
"<country>". $country . "</country>".
|
1500 |
+
"</billTo>".
|
1501 |
+
"</subscription>".
|
1502 |
+
"</ARBCreateSubscriptionRequest>";
|
1503 |
+
|
1504 |
+
//send the xml via curl
|
1505 |
+
$response = $this->send_request_via_curl($host,$path,$content);
|
1506 |
+
//if curl is unavilable you can try using fsockopen
|
1507 |
+
/*
|
1508 |
+
$response = send_request_via_fsockopen($host,$path,$content);
|
1509 |
+
*/
|
1510 |
+
|
1511 |
+
if($response) {
|
1512 |
+
list ($refId, $resultCode, $code, $text, $subscriptionId) = $this->parse_return($response);
|
1513 |
+
if($resultCode == "Ok")
|
1514 |
+
{
|
1515 |
+
$this->status = "success"; //saved on checkout page
|
1516 |
+
$this->subscription_transaction_id = $subscriptionId;
|
1517 |
+
return true;
|
1518 |
+
}
|
1519 |
+
else
|
1520 |
+
{
|
1521 |
+
$this->status = "error";
|
1522 |
+
$this->errorcode = $code;
|
1523 |
+
$this->error = $text;
|
1524 |
+
$this->shorterror = $text;
|
1525 |
+
return false;
|
1526 |
+
}
|
1527 |
+
} else {
|
1528 |
+
$this->status = "error";
|
1529 |
+
$this->error = "Could not connect to Authorize.net";
|
1530 |
+
$this->shorterror = "Could not connect to Authorize.net";
|
1531 |
+
return false;
|
1532 |
+
}
|
1533 |
+
}
|
1534 |
+
|
1535 |
+
function cancelWithAuthorizeNet()
|
1536 |
+
{
|
1537 |
+
//define variables to send
|
1538 |
+
$subscriptionId = $this->subscription_transaction_id;
|
1539 |
+
$loginname = pmpro_getOption("loginname");
|
1540 |
+
$transactionkey = pmpro_getOption("transactionkey");
|
1541 |
+
|
1542 |
+
$gateway_environment = $this->gateway_environment;
|
1543 |
+
if(!$gateway_environment)
|
1544 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
1545 |
+
if($gateway_environment == "live")
|
1546 |
+
$host = "api.authorize.net";
|
1547 |
+
else
|
1548 |
+
$host = "apitest.authorize.net";
|
1549 |
+
|
1550 |
+
$path = "/xml/v1/request.api";
|
1551 |
+
|
1552 |
+
if(!$subscriptionId || !$loginname || !$transactionkey)
|
1553 |
return false;
|
1554 |
+
|
1555 |
+
//build xml to post
|
1556 |
+
$content =
|
1557 |
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>".
|
1558 |
+
"<ARBCancelSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
|
1559 |
+
"<merchantAuthentication>".
|
1560 |
+
"<name>" . $loginname . "</name>".
|
1561 |
+
"<transactionKey>" . $transactionkey . "</transactionKey>".
|
1562 |
+
"</merchantAuthentication>" .
|
1563 |
+
"<subscriptionId>" . $subscriptionId . "</subscriptionId>".
|
1564 |
+
"</ARBCancelSubscriptionRequest>";
|
1565 |
+
|
1566 |
+
//send the xml via curl
|
1567 |
+
$response = $this->send_request_via_curl($host,$path,$content);
|
1568 |
+
//if curl is unavilable you can try using fsockopen
|
1569 |
+
/*
|
1570 |
+
$response = send_request_via_fsockopen($host,$path,$content);
|
1571 |
+
*/
|
1572 |
+
|
1573 |
+
//if the connection and send worked $response holds the return from Authorize.net
|
1574 |
+
if ($response)
|
1575 |
+
{
|
1576 |
+
list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($response);
|
1577 |
+
|
1578 |
+
if($resultCode == "Ok" || $code == "Ok")
|
1579 |
+
{
|
1580 |
+
$this->updateStatus("cancelled");
|
1581 |
+
return true;
|
1582 |
+
}
|
1583 |
+
else
|
1584 |
+
{
|
1585 |
+
//$this->status = "error";
|
1586 |
+
$this->errorcode = $code;
|
1587 |
+
$this->error = $text;
|
1588 |
+
$this->shorterror = $text;
|
1589 |
+
return false;
|
1590 |
+
}
|
1591 |
+
}
|
1592 |
+
else
|
1593 |
+
{
|
1594 |
+
$this->status = "error";
|
1595 |
+
$this->error = "Could not connect to Authorize.net";
|
1596 |
+
$this->shorterror = "Could not connect to Authorize.net";
|
1597 |
+
return false;
|
1598 |
+
}
|
1599 |
+
}
|
1600 |
+
|
1601 |
+
function updateWithAuthorizeNet()
|
1602 |
+
{
|
1603 |
+
//define variables to send
|
1604 |
+
$gateway_environment = $this->gateway_environment;
|
1605 |
+
if(!$gateway_environment)
|
1606 |
+
$gateway_environment = pmpro_getOption("gateway_environment");
|
1607 |
+
if($gateway_environment == "live")
|
1608 |
+
$host = "api.authorize.net";
|
1609 |
+
else
|
1610 |
+
$host = "apitest.authorize.net";
|
1611 |
+
|
1612 |
+
$path = "/xml/v1/request.api";
|
1613 |
+
|
1614 |
+
$loginname = pmpro_getOption("loginname");
|
1615 |
+
$transactionkey = pmpro_getOption("transactionkey");
|
1616 |
+
|
1617 |
+
$amount = $this->PaymentAmount;
|
1618 |
+
$refId = $this->code;
|
1619 |
+
$subscriptionId = $this->subscription_transaction_id;
|
1620 |
+
|
1621 |
+
$cardNumber = $this->accountnumber;
|
1622 |
+
$expirationDate = $this->ExpirationDate_YdashM;
|
1623 |
+
$cardCode = $this->CVV2;
|
1624 |
+
|
1625 |
+
$firstName = $this->FirstName;
|
1626 |
+
$lastName = $this->LastName;
|
1627 |
+
|
1628 |
+
//do address stuff then?
|
1629 |
+
$address = $this->Address1;
|
1630 |
+
if($this->Address2)
|
1631 |
+
$address .= "\n" . $this->Address2;
|
1632 |
+
$city = $this->billing->city;
|
1633 |
+
$state = $this->billing->state;
|
1634 |
+
$zip = $this->billing->zip;
|
1635 |
+
$country = $this->billing->country;
|
1636 |
+
|
1637 |
+
//customer stuff
|
1638 |
+
$customer_email = $this->Email;
|
1639 |
+
if(strpos($this->billing->phone, "+") === false)
|
1640 |
+
$customer_phone = $this->billing->phone;
|
1641 |
+
|
1642 |
+
//build xml to post
|
1643 |
+
$content =
|
1644 |
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
1645 |
+
"<ARBUpdateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
|
1646 |
+
"<merchantAuthentication>".
|
1647 |
+
"<name>" . $loginname . "</name>".
|
1648 |
+
"<transactionKey>" . $transactionkey . "</transactionKey>".
|
1649 |
+
"</merchantAuthentication>".
|
1650 |
+
"<refId>" . $refId . "</refId>".
|
1651 |
+
"<subscriptionId>" . $subscriptionId . "</subscriptionId>".
|
1652 |
+
"<subscription>".
|
1653 |
+
"<payment>".
|
1654 |
+
"<creditCard>".
|
1655 |
+
"<cardNumber>" . $cardNumber . "</cardNumber>".
|
1656 |
+
"<expirationDate>" . $expirationDate . "</expirationDate>".
|
1657 |
+
"<cardCode>" . $cardCode . "</cardCode>".
|
1658 |
+
"</creditCard>".
|
1659 |
+
"</payment>".
|
1660 |
+
"<customer>".
|
1661 |
+
"<email>". $customer_email . "</email>".
|
1662 |
+
"<phoneNumber>". formatPhone($customer_phone) . "</phoneNumber>".
|
1663 |
+
"</customer>".
|
1664 |
+
"<billTo>".
|
1665 |
+
"<firstName>". $firstName . "</firstName>".
|
1666 |
+
"<lastName>" . $lastName . "</lastName>".
|
1667 |
+
"<address>". $address . "</address>".
|
1668 |
+
"<city>" . $city . "</city>".
|
1669 |
+
"<state>". $state . "</state>".
|
1670 |
+
"<zip>" . $zip . "</zip>".
|
1671 |
+
"<country>". $country . "</country>".
|
1672 |
+
"</billTo>".
|
1673 |
+
"</subscription>".
|
1674 |
+
"</ARBUpdateSubscriptionRequest>";
|
1675 |
+
|
1676 |
+
//send the xml via curl
|
1677 |
+
$response = $this->send_request_via_curl($host,$path,$content);
|
1678 |
+
//if curl is unavilable you can try using fsockopen
|
1679 |
+
/*
|
1680 |
+
$response = send_request_via_fsockopen($host,$path,$content);
|
1681 |
+
*/
|
1682 |
+
|
1683 |
+
|
1684 |
+
if($response) {
|
1685 |
+
list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($response);
|
1686 |
+
|
1687 |
+
if($resultCode == "Ok" || $code == "Ok")
|
1688 |
+
{
|
1689 |
+
return true;
|
1690 |
+
}
|
1691 |
+
else
|
1692 |
+
{
|
1693 |
+
$this->status = "error";
|
1694 |
+
$this->errorcode = $code;
|
1695 |
+
$this->error = $text;
|
1696 |
+
$this->shorterror = $text;
|
1697 |
+
return false;
|
1698 |
+
}
|
1699 |
+
} else {
|
1700 |
+
$this->status = "error";
|
1701 |
+
$this->error = "Could not connect to Authorize.net";
|
1702 |
+
$this->shorterror = "Could not connect to Authorize.net";
|
1703 |
+
return false;
|
1704 |
+
}
|
1705 |
}
|
1706 |
}
|
1707 |
+
?>
|
classes/class.pmproemail.php
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
{
|
4 |
function PMProEmail()
|
5 |
{
|
6 |
-
$this->email = $this->from = $this->fromname = $this->subject = $this->template = $this->data = $this->body = NULL;
|
7 |
}
|
8 |
|
9 |
function sendEmail($email = NULL, $from = NULL, $fromname = NULL, $subject = NULL, $template = NULL, $data = NULL)
|
@@ -34,37 +33,18 @@
|
|
34 |
$this->fromname = pmpro_getOption("from_name");
|
35 |
|
36 |
if(!$this->subject)
|
37 |
-
$this->subject =
|
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');
|
41 |
-
|
42 |
if(!$this->template)
|
43 |
$this->template = "default";
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
$locale = apply_filters("plugin_locale", get_locale(), "pmpro");
|
51 |
-
if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/email/" . $this->template . ".html"))
|
52 |
-
$this->body = file_get_contents(get_stylesheet_directory() . "/paid-memberships-pro/email/" . $this->template . ".html"); //email folder in pmpro folder in theme
|
53 |
-
elseif(file_exists(get_stylesheet_directory() . "/membership-email-" . $this->template . ".html"))
|
54 |
-
$this->body = file_get_contents(get_stylesheet_directory() . "/membership-email-" . $this->template . ".html"); //membership- file in pmpro folder in theme
|
55 |
-
elseif(file_exists(TEMPLATEPATH . "/membership-email-" . $this->template . ".html"))
|
56 |
-
$this->body = file_get_contents(TEMPLATEPATH . "/membership-email-" . $this->template . ".html"); //membership- file in theme root
|
57 |
-
elseif(file_exists(WP_LANG_DIR . '/pmpro/email/' . $this->template . ".html"))
|
58 |
-
$this->body = file_get_contents(WP_LANG_DIR . '/pmpro/email/' . $this->template . ".html"); //email folder in WP language folder
|
59 |
-
elseif(file_exists(PMPRO_DIR . "/languages/" . $locale . "/" . $this->template . ".html"))
|
60 |
-
$this->body = file_get_contents(PMPRO_DIR . "/languages/" . $locale . "/" . $this->template . ".html"); //email folder in PMPro language folder
|
61 |
-
elseif(file_exists(PMPRO_DIR . "/email/" . $this->template . ".html"))
|
62 |
-
$this->body = file_get_contents(PMPRO_DIR . "/email/" . $this->template . ".html"); //default template in plugin
|
63 |
-
elseif(!empty($this->data) && !empty($this->data['body']))
|
64 |
-
$this->body = $this->data['body'];
|
65 |
|
66 |
//header and footer
|
67 |
-
/* This is handled for all emails via the pmpro_send_html function in paid-memberships-pro now
|
68 |
if(file_exists(TEMPLATEPATH . "/email_header.html"))
|
69 |
{
|
70 |
$this->body = file_get_contents(TEMPLATEPATH . "/email_header.html") . "\n" . $this->body;
|
@@ -72,17 +52,11 @@
|
|
72 |
if(file_exists(TEMPLATEPATH . "/email_footer.html"))
|
73 |
{
|
74 |
$this->body = $this->body . "\n" . file_get_contents(TEMPLATEPATH . "/email_footer.html");
|
75 |
-
}
|
76 |
-
*/
|
77 |
|
78 |
-
//
|
79 |
if(is_string($this->data))
|
80 |
-
$
|
81 |
-
|
82 |
-
//filter for data
|
83 |
-
$this->data = apply_filters("pmpro_email_data", $this->data, $this); //filter
|
84 |
-
|
85 |
-
//swap data into body
|
86 |
if(is_array($this->data))
|
87 |
{
|
88 |
foreach($this->data as $key => $value)
|
@@ -92,24 +66,31 @@
|
|
92 |
}
|
93 |
|
94 |
//filters
|
95 |
-
$
|
96 |
-
$this->
|
97 |
-
$this->
|
98 |
-
$this->
|
99 |
-
$this->
|
100 |
-
$this->
|
101 |
-
|
102 |
-
|
103 |
-
$this->
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
{
|
107 |
return true;
|
108 |
}
|
109 |
else
|
110 |
{
|
111 |
return false;
|
112 |
-
}
|
113 |
}
|
114 |
|
115 |
function sendCancelEmail($user = NULL)
|
@@ -122,46 +103,10 @@
|
|
122 |
return false;
|
123 |
|
124 |
$this->email = $user->user_email;
|
125 |
-
$this->subject =
|
126 |
$this->template = "cancel";
|
127 |
-
$this->data = array("name" => $user->display_name, "
|
128 |
-
|
129 |
-
return $this->sendEmail();
|
130 |
-
}
|
131 |
-
|
132 |
-
function sendCancelAdminEmail($user = NULL, $old_level_id)
|
133 |
-
{
|
134 |
-
global $wpdb, $current_user;
|
135 |
-
if(!$user)
|
136 |
-
$user = $current_user;
|
137 |
-
|
138 |
-
if(!$user)
|
139 |
-
return false;
|
140 |
|
141 |
-
//check settings
|
142 |
-
$send = pmpro_getOption("email_admin_cancels");
|
143 |
-
if(empty($send))
|
144 |
-
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
145 |
-
|
146 |
-
$this->email = get_bloginfo("admin_email");
|
147 |
-
$this->subject = sprintf(__("Membership for %s at %s has been CANCELLED", "pmpro"), $user->user_login, get_option("blogname"));
|
148 |
-
$this->template = "cancel_admin";
|
149 |
-
$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());
|
150 |
-
$this->data['membership_id'] = $old_level_id;
|
151 |
-
$this->data['membership_level_name'] = $wpdb->get_var("SELECT name FROM $wpdb->pmpro_membership_levels WHERE id = '" . $old_level_id . "' LIMIT 1");
|
152 |
-
|
153 |
-
//start and end date
|
154 |
-
$startdate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(startdate) as startdate FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND membership_id = '" . $old_level_id . "' AND status = 'inactive' ORDER BY id DESC");
|
155 |
-
if(!empty($startdate))
|
156 |
-
$this->data['startdate'] = date(get_option('date_format'), $startdate);
|
157 |
-
else
|
158 |
-
$this->data['startdate'] = "";
|
159 |
-
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) as enddate FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND membership_id = '" . $old_level_id . "' AND status = 'inactive' ORDER BY id DESC");
|
160 |
-
if(!empty($enddate))
|
161 |
-
$this->data['enddate'] = date(get_option('date_format'), $enddate);
|
162 |
-
else
|
163 |
-
$this->data['enddate'] = "";
|
164 |
-
|
165 |
return $this->sendEmail();
|
166 |
}
|
167 |
|
@@ -175,178 +120,61 @@
|
|
175 |
return false;
|
176 |
|
177 |
$this->email = $user->user_email;
|
178 |
-
$this->subject =
|
179 |
|
180 |
$this->data = array(
|
181 |
"subject" => $this->subject,
|
182 |
"name" => $user->display_name,
|
183 |
-
"user_login" => $user->user_login,
|
184 |
"sitename" => get_option("blogname"),
|
185 |
"siteemail" => pmpro_getOption("from_email"),
|
186 |
-
"membership_id" => $user->membership_level->id,
|
187 |
"membership_level_name" => $user->membership_level->name,
|
188 |
"membership_cost" => pmpro_getLevelCost($user->membership_level),
|
189 |
-
"login_link" =>
|
190 |
"display_name" => $user->display_name,
|
191 |
"user_email" => $user->user_email,0
|
192 |
);
|
193 |
-
|
194 |
-
if(
|
195 |
{
|
196 |
if($invoice->gateway == "paypalexpress")
|
197 |
$this->template = "checkout_express";
|
198 |
-
elseif($invoice->gateway == "check")
|
199 |
-
{
|
200 |
-
$this->template = "checkout_check";
|
201 |
-
$this->data["instructions"] = wpautop(pmpro_getOption("instructions"));
|
202 |
-
}
|
203 |
elseif(pmpro_isLevelTrial($user->membership_level))
|
204 |
$this->template = "checkout_trial";
|
205 |
else
|
206 |
$this->template = "checkout_paid";
|
207 |
$this->data["invoice_id"] = $invoice->code;
|
208 |
$this->data["invoice_total"] = $pmpro_currency_symbol . number_format($invoice->total, 2);
|
209 |
-
$this->data["invoice_date"] = date(
|
210 |
$this->data["billing_name"] = $invoice->billing->name;
|
211 |
$this->data["billing_street"] = $invoice->billing->street;
|
212 |
$this->data["billing_city"] = $invoice->billing->city;
|
213 |
$this->data["billing_state"] = $invoice->billing->state;
|
214 |
$this->data["billing_zip"] = $invoice->billing->zip;
|
215 |
-
$this->data["billing_country"] = $invoice->billing->country;
|
216 |
$this->data["billing_phone"] = $invoice->billing->phone;
|
217 |
$this->data["cardtype"] = $invoice->cardtype;
|
218 |
$this->data["accountnumber"] = hideCardNumber($invoice->accountnumber);
|
219 |
$this->data["expirationmonth"] = $invoice->expirationmonth;
|
220 |
$this->data["expirationyear"] = $invoice->expirationyear;
|
221 |
-
$this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name,
|
222 |
-
$invoice->billing->street,
|
223 |
-
"", //address 2
|
224 |
-
$invoice->billing->city,
|
225 |
-
$invoice->billing->state,
|
226 |
-
$invoice->billing->zip,
|
227 |
-
$invoice->billing->country,
|
228 |
-
$invoice->billing->phone);
|
229 |
|
230 |
if($invoice->getDiscountCode())
|
231 |
-
$this->data["discount_code"] = "<p>
|
232 |
else
|
233 |
$this->data["discount_code"] = "";
|
234 |
}
|
235 |
elseif(pmpro_isLevelFree($user->membership_level))
|
236 |
{
|
237 |
$this->template = "checkout_free";
|
238 |
-
|
239 |
-
if(!empty($discount_code))
|
240 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code", "pmpro") . ": " . $discount_code . "</p>\n";
|
241 |
-
else
|
242 |
-
$this->data["discount_code"] = "";
|
243 |
}
|
244 |
else
|
245 |
{
|
246 |
$this->template = "checkout_freetrial";
|
247 |
-
global $discount_code;
|
248 |
-
if(!empty($discount_code))
|
249 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code", "pmpro") . ": " . $discount_code . "</p>\n";
|
250 |
-
else
|
251 |
-
$this->data["discount_code"] = "";
|
252 |
-
}
|
253 |
-
|
254 |
-
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' AND status = 'active' LIMIT 1");
|
255 |
-
if($enddate)
|
256 |
-
$this->data["membership_expiration"] = "<p>" . sprintf(__("This membership will expire on %s.", "pmpro"), date(get_option('date_format'), $enddate)) . "</p>\n";
|
257 |
-
else
|
258 |
-
$this->data["membership_expiration"] = "";
|
259 |
-
|
260 |
-
return $this->sendEmail();
|
261 |
-
}
|
262 |
-
|
263 |
-
function sendCheckoutAdminEmail($user = NULL, $invoice = NULL)
|
264 |
-
{
|
265 |
-
global $wpdb, $current_user, $pmpro_currency_symbol;
|
266 |
-
if(!$user)
|
267 |
-
$user = $current_user;
|
268 |
-
|
269 |
-
if(!$user)
|
270 |
-
return false;
|
271 |
-
|
272 |
-
//check settings
|
273 |
-
$send = pmpro_getOption("email_admin_checkout");
|
274 |
-
if(empty($send))
|
275 |
-
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
276 |
-
|
277 |
-
$this->email = get_bloginfo("admin_email");
|
278 |
-
$this->subject = sprintf(__("Member Checkout for %s at %s", "pmpro"), $user->membership_level->name, get_option("blogname"));
|
279 |
-
|
280 |
-
$this->data = array(
|
281 |
-
"subject" => $this->subject,
|
282 |
-
"name" => $user->display_name,
|
283 |
-
"user_login" => $user->user_login,
|
284 |
-
"sitename" => get_option("blogname"),
|
285 |
-
"siteemail" => pmpro_getOption("from_email"),
|
286 |
-
"membership_id" => $user->membership_level->id,
|
287 |
-
"membership_level_name" => $user->membership_level->name,
|
288 |
-
"membership_cost" => pmpro_getLevelCost($user->membership_level),
|
289 |
-
"login_link" => wp_login_url(pmpro_url("account")),
|
290 |
-
"display_name" => $user->display_name,
|
291 |
-
"user_email" => $user->user_email,0
|
292 |
-
);
|
293 |
-
|
294 |
-
if(!empty($invoice) && !pmpro_isLevelFree($user->membership_level))
|
295 |
-
{
|
296 |
-
if($invoice->gateway == "paypalexpress")
|
297 |
-
$this->template = "checkout_express_admin";
|
298 |
-
elseif($invoice->gateway == "check")
|
299 |
-
$this->template = "checkout_check_admin";
|
300 |
-
elseif(pmpro_isLevelTrial($user->membership_level))
|
301 |
-
$this->template = "checkout_trial_admin";
|
302 |
-
else
|
303 |
-
$this->template = "checkout_paid_admin";
|
304 |
-
$this->data["invoice_id"] = $invoice->code;
|
305 |
-
$this->data["invoice_total"] = $pmpro_currency_symbol . number_format($invoice->total, 2);
|
306 |
-
$this->data["invoice_date"] = date(get_option('date_format'), $invoice->timestamp);
|
307 |
-
$this->data["billing_name"] = $invoice->billing->name;
|
308 |
-
$this->data["billing_street"] = $invoice->billing->street;
|
309 |
-
$this->data["billing_city"] = $invoice->billing->city;
|
310 |
-
$this->data["billing_state"] = $invoice->billing->state;
|
311 |
-
$this->data["billing_zip"] = $invoice->billing->zip;
|
312 |
-
$this->data["billing_country"] = $invoice->billing->country;
|
313 |
-
$this->data["billing_phone"] = $invoice->billing->phone;
|
314 |
-
$this->data["cardtype"] = $invoice->cardtype;
|
315 |
-
$this->data["accountnumber"] = hideCardNumber($invoice->accountnumber);
|
316 |
-
$this->data["expirationmonth"] = $invoice->expirationmonth;
|
317 |
-
$this->data["expirationyear"] = $invoice->expirationyear;
|
318 |
-
$this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name,
|
319 |
-
$invoice->billing->street,
|
320 |
-
"", //address 2
|
321 |
-
$invoice->billing->city,
|
322 |
-
$invoice->billing->state,
|
323 |
-
$invoice->billing->zip,
|
324 |
-
$invoice->billing->country,
|
325 |
-
$invoice->billing->phone);
|
326 |
-
|
327 |
-
if($invoice->getDiscountCode())
|
328 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code", "pmpro") . ": " . $invoice->discount_code->code . "</p>\n";
|
329 |
-
else
|
330 |
-
$this->data["discount_code"] = "";
|
331 |
-
}
|
332 |
-
elseif(pmpro_isLevelFree($user->membership_level))
|
333 |
-
{
|
334 |
-
$this->template = "checkout_free_admin";
|
335 |
-
global $discount_code;
|
336 |
-
if(!empty($discount_code))
|
337 |
-
$this->data["discount_code"] = "<p>" . __("Discount Code", "pmpro") . ": " . $discount_code . "</p>\n";
|
338 |
-
else
|
339 |
-
$this->data["discount_code"] = "";
|
340 |
-
}
|
341 |
-
else
|
342 |
-
{
|
343 |
-
$this->template = "checkout_freetrial_admin";
|
344 |
$this->data["discount_code"] = "";
|
345 |
-
}
|
346 |
|
347 |
-
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "'
|
348 |
if($enddate)
|
349 |
-
$this->data["membership_expiration"] = "<p>
|
350 |
else
|
351 |
$this->data["membership_expiration"] = "";
|
352 |
|
@@ -363,16 +191,13 @@
|
|
363 |
return false;
|
364 |
|
365 |
$this->email = $user->user_email;
|
366 |
-
$this->subject =
|
367 |
$this->template = "billing";
|
368 |
|
369 |
$this->data = array(
|
370 |
"subject" => $this->subject,
|
371 |
"name" => $user->display_name,
|
372 |
-
"user_login" => $user->user_login,
|
373 |
"sitename" => get_option("blogname"),
|
374 |
-
"siteemail" => pmpro_getOption("from_email"),
|
375 |
-
"membership_id" => $user->membership_level->id,
|
376 |
"membership_level_name" => $user->membership_level->name,
|
377 |
"display_name" => $user->display_name,
|
378 |
"user_email" => $user->user_email,
|
@@ -381,75 +206,13 @@
|
|
381 |
"billing_city" => $invoice->billing->city,
|
382 |
"billing_state" => $invoice->billing->state,
|
383 |
"billing_zip" => $invoice->billing->zip,
|
384 |
-
"billing_country" => $invoice->billing->country,
|
385 |
"billing_phone" => $invoice->billing->phone,
|
386 |
"cardtype" => $invoice->cardtype,
|
387 |
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
388 |
"expirationmonth" => $invoice->expirationmonth,
|
389 |
"expirationyear" => $invoice->expirationyear,
|
390 |
-
"login_link" =>
|
391 |
);
|
392 |
-
$this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name,
|
393 |
-
$invoice->billing->street,
|
394 |
-
"", //address 2
|
395 |
-
$invoice->billing->city,
|
396 |
-
$invoice->billing->state,
|
397 |
-
$invoice->billing->zip,
|
398 |
-
$invoice->billing->country,
|
399 |
-
$invoice->billing->phone);
|
400 |
-
|
401 |
-
return $this->sendEmail();
|
402 |
-
}
|
403 |
-
|
404 |
-
function sendBillingAdminEmail($user = NULL, $invoice = NULL)
|
405 |
-
{
|
406 |
-
global $current_user;
|
407 |
-
if(!$user)
|
408 |
-
$user = $current_user;
|
409 |
-
|
410 |
-
if(!$user || !$invoice)
|
411 |
-
return false;
|
412 |
-
|
413 |
-
//check settings
|
414 |
-
$send = pmpro_getOption("email_admin_billing");
|
415 |
-
if(empty($send))
|
416 |
-
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
417 |
-
|
418 |
-
$this->email = get_bloginfo("admin_email");
|
419 |
-
$this->subject = sprintf(__("Billing information has been udpated for %s at %s", "pmpro"), $user->user_login, get_option("blogname"));
|
420 |
-
$this->template = "billing_admin";
|
421 |
-
|
422 |
-
$this->data = array(
|
423 |
-
"subject" => $this->subject,
|
424 |
-
"name" => $user->display_name,
|
425 |
-
"user_login" => $user->user_login,
|
426 |
-
"sitename" => get_option("blogname"),
|
427 |
-
"siteemail" => pmpro_getOption("from_email"),
|
428 |
-
"membership_id" => $user->membership_level->id,
|
429 |
-
"membership_level_name" => $user->membership_level->name,
|
430 |
-
"display_name" => $user->display_name,
|
431 |
-
"user_email" => $user->user_email,
|
432 |
-
"billing_name" => $invoice->billing->name,
|
433 |
-
"billing_street" => $invoice->billing->street,
|
434 |
-
"billing_city" => $invoice->billing->city,
|
435 |
-
"billing_state" => $invoice->billing->state,
|
436 |
-
"billing_zip" => $invoice->billing->zip,
|
437 |
-
"billing_country" => $invoice->billing->country,
|
438 |
-
"billing_phone" => $invoice->billing->phone,
|
439 |
-
"cardtype" => $invoice->cardtype,
|
440 |
-
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
441 |
-
"expirationmonth" => $invoice->expirationmonth,
|
442 |
-
"expirationyear" => $invoice->expirationyear,
|
443 |
-
"login_link" => wp_login_url()
|
444 |
-
);
|
445 |
-
$this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name,
|
446 |
-
$invoice->billing->street,
|
447 |
-
"", //address 2
|
448 |
-
$invoice->billing->city,
|
449 |
-
$invoice->billing->state,
|
450 |
-
$invoice->billing->zip,
|
451 |
-
$invoice->billing->country,
|
452 |
-
$invoice->billing->phone);
|
453 |
|
454 |
return $this->sendEmail();
|
455 |
}
|
@@ -464,16 +227,13 @@
|
|
464 |
return false;
|
465 |
|
466 |
$this->email = $user->user_email;
|
467 |
-
$this->subject =
|
468 |
$this->template = "billing_failure";
|
469 |
|
470 |
$this->data = array(
|
471 |
"subject" => $this->subject,
|
472 |
"name" => $user->display_name,
|
473 |
-
"user_login" => $user->user_login,
|
474 |
"sitename" => get_option("blogname"),
|
475 |
-
"siteemail" => pmpro_getOption("from_email"),
|
476 |
-
"membership_id" => $user->membership_level->id,
|
477 |
"membership_level_name" => $user->membership_level->name,
|
478 |
"display_name" => $user->display_name,
|
479 |
"user_email" => $user->user_email,
|
@@ -482,25 +242,16 @@
|
|
482 |
"billing_city" => $invoice->billing->city,
|
483 |
"billing_state" => $invoice->billing->state,
|
484 |
"billing_zip" => $invoice->billing->zip,
|
485 |
-
"billing_country" => $invoice->billing->country,
|
486 |
"billing_phone" => $invoice->billing->phone,
|
487 |
"cardtype" => $invoice->cardtype,
|
488 |
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
489 |
"expirationmonth" => $invoice->expirationmonth,
|
490 |
"expirationyear" => $invoice->expirationyear,
|
491 |
-
"login_link" =>
|
492 |
);
|
493 |
-
$this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name,
|
494 |
-
$invoice->billing->street,
|
495 |
-
"", //address 2
|
496 |
-
$invoice->billing->city,
|
497 |
-
$invoice->billing->state,
|
498 |
-
$invoice->billing->zip,
|
499 |
-
$invoice->billing->country,
|
500 |
-
$invoice->billing->phone);
|
501 |
|
502 |
return $this->sendEmail();
|
503 |
-
}
|
504 |
|
505 |
function sendBillingFailureAdminEmail($email, $invoice = NULL)
|
506 |
{
|
@@ -510,16 +261,13 @@
|
|
510 |
$user = get_userdata($invoice->user_id);
|
511 |
|
512 |
$this->email = $email;
|
513 |
-
$this->subject =
|
514 |
$this->template = "billing_failure_admin";
|
515 |
|
516 |
$this->data = array(
|
517 |
"subject" => $this->subject,
|
518 |
"name" => "Admin",
|
519 |
-
"user_login" => $user->user_login,
|
520 |
"sitename" => get_option("blogname"),
|
521 |
-
"siteemail" => pmpro_getOption("from_email"),
|
522 |
-
"membership_id" => $user->membership_level->id,
|
523 |
"membership_level_name" => $user->membership_level->name,
|
524 |
"display_name" => $user->display_name,
|
525 |
"user_email" => $user->user_email,
|
@@ -528,76 +276,20 @@
|
|
528 |
"billing_city" => $invoice->billing->city,
|
529 |
"billing_state" => $invoice->billing->state,
|
530 |
"billing_zip" => $invoice->billing->zip,
|
531 |
-
"billing_country" => $invoice->billing->country,
|
532 |
"billing_phone" => $invoice->billing->phone,
|
533 |
"cardtype" => $invoice->cardtype,
|
534 |
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
535 |
"expirationmonth" => $invoice->expirationmonth,
|
536 |
"expirationyear" => $invoice->expirationyear,
|
537 |
-
"login_link" =>
|
538 |
);
|
539 |
-
$this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name,
|
540 |
-
$invoice->billing->street,
|
541 |
-
"", //address 2
|
542 |
-
$invoice->billing->city,
|
543 |
-
$invoice->billing->state,
|
544 |
-
$invoice->billing->zip,
|
545 |
-
$invoice->billing->country,
|
546 |
-
$invoice->billing->phone);
|
547 |
-
return $this->sendEmail();
|
548 |
-
}
|
549 |
-
|
550 |
-
function sendCreditCardExpiringEmail($user = NULL, $invoice = NULL)
|
551 |
-
{
|
552 |
-
global $current_user;
|
553 |
-
if(!$user)
|
554 |
-
$user = $current_user;
|
555 |
-
|
556 |
-
if(!$user || !$invoice)
|
557 |
-
return false;
|
558 |
-
|
559 |
-
$this->email = $user->user_email;
|
560 |
-
$this->subject = sprintf(__("Credit Card on File Expiring Soon at %s", "pmpro"), get_option("blogname"));
|
561 |
-
$this->template = "credit_card_expiring";
|
562 |
-
|
563 |
-
$this->data = array(
|
564 |
-
"subject" => $this->subject,
|
565 |
-
"name" => $user->display_name,
|
566 |
-
"user_login" => $user->user_login,
|
567 |
-
"sitename" => get_option("blogname"),
|
568 |
-
"siteemail" => pmpro_getOption("from_email"),
|
569 |
-
"membership_id" => $user->membership_level->id,
|
570 |
-
"membership_level_name" => $user->membership_level->name,
|
571 |
-
"display_name" => $user->display_name,
|
572 |
-
"user_email" => $user->user_email,
|
573 |
-
"billing_name" => $invoice->billing->name,
|
574 |
-
"billing_street" => $invoice->billing->street,
|
575 |
-
"billing_city" => $invoice->billing->city,
|
576 |
-
"billing_state" => $invoice->billing->state,
|
577 |
-
"billing_zip" => $invoice->billing->zip,
|
578 |
-
"billing_country" => $invoice->billing->country,
|
579 |
-
"billing_phone" => $invoice->billing->phone,
|
580 |
-
"cardtype" => $invoice->cardtype,
|
581 |
-
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
582 |
-
"expirationmonth" => $invoice->expirationmonth,
|
583 |
-
"expirationyear" => $invoice->expirationyear,
|
584 |
-
"login_link" => wp_login_url(pmpro_url("billing"))
|
585 |
-
);
|
586 |
-
$this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name,
|
587 |
-
$invoice->billing->street,
|
588 |
-
"", //address 2
|
589 |
-
$invoice->billing->city,
|
590 |
-
$invoice->billing->state,
|
591 |
-
$invoice->billing->zip,
|
592 |
-
$invoice->billing->country,
|
593 |
-
$invoice->billing->phone);
|
594 |
|
595 |
return $this->sendEmail();
|
596 |
}
|
597 |
|
598 |
function sendInvoiceEmail($user = NULL, $invoice = NULL)
|
599 |
{
|
600 |
-
global $
|
601 |
if(!$user)
|
602 |
$user = $current_user;
|
603 |
|
@@ -605,56 +297,44 @@
|
|
605 |
return false;
|
606 |
|
607 |
$this->email = $user->user_email;
|
608 |
-
$this->subject =
|
609 |
$this->template = "invoice";
|
610 |
|
611 |
$this->data = array(
|
612 |
"subject" => $this->subject,
|
613 |
"name" => $user->display_name,
|
614 |
-
"user_login" => $user->user_login,
|
615 |
"sitename" => get_option("blogname"),
|
616 |
-
"siteemail" => pmpro_getOption("from_email"),
|
617 |
-
"membership_id" => $user->membership_level->id,
|
618 |
"membership_level_name" => $user->membership_level->name,
|
619 |
"display_name" => $user->display_name,
|
620 |
"user_email" => $user->user_email,
|
621 |
-
"invoice_id" => $invoice->
|
622 |
"invoice_total" => $pmpro_currency_symbol . number_format($invoice->total, 2),
|
623 |
-
"invoice_date" => date(
|
624 |
"billing_name" => $invoice->billing->name,
|
625 |
"billing_street" => $invoice->billing->street,
|
626 |
"billing_city" => $invoice->billing->city,
|
627 |
"billing_state" => $invoice->billing->state,
|
628 |
"billing_zip" => $invoice->billing->zip,
|
629 |
-
"billing_country" => $invoice->billing->country,
|
630 |
"billing_phone" => $invoice->billing->phone,
|
631 |
"cardtype" => $invoice->cardtype,
|
632 |
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
633 |
"expirationmonth" => $invoice->expirationmonth,
|
634 |
"expirationyear" => $invoice->expirationyear,
|
635 |
-
"login_link" =>
|
636 |
-
"invoice_link" =>
|
637 |
-
)
|
638 |
-
$this->data["billing_address"] = pmpro_formatAddress($invoice->billing->name,
|
639 |
-
$invoice->billing->street,
|
640 |
-
"", //address 2
|
641 |
-
$invoice->billing->city,
|
642 |
-
$invoice->billing->state,
|
643 |
-
$invoice->billing->zip,
|
644 |
-
$invoice->billing->country,
|
645 |
-
$invoice->billing->phone);
|
646 |
|
647 |
if($invoice->getDiscountCode())
|
648 |
-
$this->data["discount_code"] = "<p>
|
649 |
else
|
650 |
$this->data["discount_code"] = "";
|
651 |
|
652 |
-
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "'
|
653 |
if($enddate)
|
654 |
-
$this->data["membership_expiration"] = "<p>
|
655 |
else
|
656 |
$this->data["membership_expiration"] = "";
|
657 |
-
|
658 |
return $this->sendEmail();
|
659 |
}
|
660 |
|
@@ -668,24 +348,21 @@
|
|
668 |
return false;
|
669 |
|
670 |
//make sure we have the current membership level data
|
671 |
-
|
672 |
FROM {$wpdb->pmpro_membership_levels} AS l
|
673 |
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
674 |
WHERE mu.user_id = " . $user->ID . "
|
675 |
-
LIMIT 1")
|
676 |
-
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
677 |
|
678 |
$this->email = $user->user_email;
|
679 |
-
$this->subject =
|
680 |
$this->template = "trial_ending";
|
681 |
$this->data = array(
|
682 |
"subject" => $this->subject,
|
683 |
"name" => $user->display_name,
|
684 |
-
"
|
685 |
-
"sitename" => get_option("blogname"),
|
686 |
-
"membership_id" => $user->membership_level->id,
|
687 |
"membership_level_name" => $user->membership_level->name,
|
688 |
-
"siteemail" =>
|
689 |
"login_link" => wp_login_url(),
|
690 |
"display_name" => $user->display_name,
|
691 |
"user_email" => $user->user_email,
|
@@ -694,7 +371,7 @@
|
|
694 |
"cycle_period" => $user->membership_level->cycle_period,
|
695 |
"trial_amount" => $pmpro_currency_symbol . $user->membership_level->trial_amount,
|
696 |
"trial_limit" => $user->membership_level->trial_limit,
|
697 |
-
"trial_end" => date(
|
698 |
);
|
699 |
|
700 |
return $this->sendEmail();
|
@@ -710,9 +387,9 @@
|
|
710 |
return false;
|
711 |
|
712 |
$this->email = $user->user_email;
|
713 |
-
$this->subject =
|
714 |
$this->template = "membership_expired";
|
715 |
-
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "
|
716 |
|
717 |
return $this->sendEmail();
|
718 |
}
|
@@ -727,17 +404,16 @@
|
|
727 |
return false;
|
728 |
|
729 |
//make sure we have the current membership level data
|
730 |
-
|
731 |
FROM {$wpdb->pmpro_membership_levels} AS l
|
732 |
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
733 |
WHERE mu.user_id = " . $user->ID . "
|
734 |
-
LIMIT 1")
|
735 |
-
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
736 |
|
737 |
$this->email = $user->user_email;
|
738 |
-
$this->subject =
|
739 |
$this->template = "membership_expiring";
|
740 |
-
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "
|
741 |
|
742 |
return $this->sendEmail();
|
743 |
}
|
@@ -752,64 +428,22 @@
|
|
752 |
return false;
|
753 |
|
754 |
//make sure we have the current membership level data
|
755 |
-
$user->membership_level =
|
|
|
|
|
|
|
|
|
756 |
|
757 |
$this->email = $user->user_email;
|
758 |
-
$this->subject =
|
759 |
$this->template = "admin_change";
|
760 |
-
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "
|
761 |
if($user->membership_level->ID)
|
762 |
-
$this->data["membership_change"] =
|
763 |
else
|
764 |
-
$this->data["membership_change"] =
|
765 |
-
|
766 |
-
if(!empty($user->membership_level->enddate))
|
767 |
-
{
|
768 |
-
$this->data["membership_change"] .= ". " . sprintf(__("This membership will expire on %s", "pmpro"), date(get_option('date_format'), $user->membership_level->enddate));
|
769 |
-
}
|
770 |
-
elseif(!empty($this->expiration_changed))
|
771 |
-
{
|
772 |
-
$this->data["membership_change"] .= ". " . __("This membership does not expire", "pmpro");
|
773 |
-
}
|
774 |
-
|
775 |
-
return $this->sendEmail();
|
776 |
-
}
|
777 |
-
|
778 |
-
function sendAdminChangeAdminEmail($user = NULL)
|
779 |
-
{
|
780 |
-
global $current_user, $wpdb;
|
781 |
-
if(!$user)
|
782 |
-
$user = $current_user;
|
783 |
-
|
784 |
-
if(!$user)
|
785 |
-
return false;
|
786 |
-
|
787 |
-
//check settings
|
788 |
-
$send = pmpro_getOption("email_admin_changes");
|
789 |
-
if(empty($send))
|
790 |
-
return true; //didn't send, but we also don't want to indicate failure because the settings say to not send
|
791 |
-
|
792 |
-
//make sure we have the current membership level data
|
793 |
-
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
|
794 |
-
|
795 |
-
$this->email = get_bloginfo("admin_email");
|
796 |
-
$this->subject = sprintf(__("Membership for %s at %s has been changed", "pmpro"), $user->user_login, get_option("blogname"));
|
797 |
-
$this->template = "admin_change_admin";
|
798 |
-
$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());
|
799 |
-
if($user->membership_level->ID)
|
800 |
-
$this->data["membership_change"] = sprintf(__("The new level is %s. This membership is free", "pmpro"), $user->membership_level->name);
|
801 |
-
else
|
802 |
-
$this->data["membership_change"] = __("Membership has been cancelled", "pmpro");
|
803 |
-
|
804 |
-
if(!empty($user->membership_level->enddate))
|
805 |
-
{
|
806 |
-
$this->data["membership_change"] .= ". " . sprintf(__("This membership will expire on %s", "pmpro"), date(get_option('date_format'), $user->membership_level->enddate));
|
807 |
-
}
|
808 |
-
elseif(!empty($this->expiration_changed))
|
809 |
-
{
|
810 |
-
$this->data["membership_change"] .= ". " . __("This membership does not expire", "pmpro");
|
811 |
-
}
|
812 |
|
813 |
return $this->sendEmail();
|
814 |
}
|
815 |
}
|
|
3 |
{
|
4 |
function PMProEmail()
|
5 |
{
|
|
|
6 |
}
|
7 |
|
8 |
function sendEmail($email = NULL, $from = NULL, $fromname = NULL, $subject = NULL, $template = NULL, $data = NULL)
|
33 |
$this->fromname = pmpro_getOption("from_name");
|
34 |
|
35 |
if(!$this->subject)
|
36 |
+
$this->subject = "An Email From " . get_option("blogname");
|
37 |
+
|
|
|
|
|
|
|
38 |
if(!$this->template)
|
39 |
$this->template = "default";
|
40 |
+
|
41 |
+
//load the template
|
42 |
+
if(file_exists(TEMPLATEPATH . "/membership-email-" . $this->template . ".html"))
|
43 |
+
$this->body = file_get_contents(TEMPLATEPATH . "/membership-email-" . $this->template . ".html");
|
44 |
+
else
|
45 |
+
$this->body = file_get_contents(ABSPATH . "/wp-content/plugins/paid-memberships-pro/email/" . $this->template . ".html");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
//header and footer
|
|
|
48 |
if(file_exists(TEMPLATEPATH . "/email_header.html"))
|
49 |
{
|
50 |
$this->body = file_get_contents(TEMPLATEPATH . "/email_header.html") . "\n" . $this->body;
|
52 |
if(file_exists(TEMPLATEPATH . "/email_footer.html"))
|
53 |
{
|
54 |
$this->body = $this->body . "\n" . file_get_contents(TEMPLATEPATH . "/email_footer.html");
|
55 |
+
}
|
|
|
56 |
|
57 |
+
//swap data
|
58 |
if(is_string($this->data))
|
59 |
+
$data = array("body"=>$data);
|
|
|
|
|
|
|
|
|
|
|
60 |
if(is_array($this->data))
|
61 |
{
|
62 |
foreach($this->data as $key => $value)
|
66 |
}
|
67 |
|
68 |
//filters
|
69 |
+
$this->email = apply_filters("pmpro_email_recipient", $this->email, $this);
|
70 |
+
$this->from = apply_filters("pmpro_email_sender", $this->from, $this);
|
71 |
+
$this->fromname = apply_filters("pmpro_email_sender_name", $this->fromname, $this);
|
72 |
+
$this->subject = apply_filters("pmpro_email_subject", $this->subject, $this);
|
73 |
+
$this->template = apply_filters("pmpro_email_template", $this->template, $this);
|
74 |
+
$this->body = apply_filters("pmpro_email_body", $this->body, $this);
|
75 |
+
|
76 |
+
//prep email
|
77 |
+
$this->mailer = new PHPMailer();
|
78 |
+
$this->mailer->From = $this->from;
|
79 |
+
$this->mailer->FromName = $this->fromname;
|
80 |
+
$this->mailer->AddAddress($this->email);
|
81 |
+
$this->mailer->Subject = $this->subject;
|
82 |
+
$this->mailer->Body = $this->body;
|
83 |
+
$this->mailer->AltBody = strip_tags(pmpro_br2nl($this->body, array("br", "p")));
|
84 |
+
|
85 |
+
//send email
|
86 |
+
if($this->mailer->send())
|
87 |
{
|
88 |
return true;
|
89 |
}
|
90 |
else
|
91 |
{
|
92 |
return false;
|
93 |
+
}
|
94 |
}
|
95 |
|
96 |
function sendCancelEmail($user = NULL)
|
103 |
return false;
|
104 |
|
105 |
$this->email = $user->user_email;
|
106 |
+
$this->subject = "Your membership at " . get_option("blogname") . " has been CANCELED";
|
107 |
$this->template = "cancel";
|
108 |
+
$this->data = array("name" => $user->display_name, "sitename" => get_option("blogname"), "siteemail" => pmpro_getOption("from_email"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
return $this->sendEmail();
|
111 |
}
|
112 |
|
120 |
return false;
|
121 |
|
122 |
$this->email = $user->user_email;
|
123 |
+
$this->subject = "Your membership confirmation for " . get_option("blogname");
|
124 |
|
125 |
$this->data = array(
|
126 |
"subject" => $this->subject,
|
127 |
"name" => $user->display_name,
|
|
|
128 |
"sitename" => get_option("blogname"),
|
129 |
"siteemail" => pmpro_getOption("from_email"),
|
|
|
130 |
"membership_level_name" => $user->membership_level->name,
|
131 |
"membership_cost" => pmpro_getLevelCost($user->membership_level),
|
132 |
+
"login_link" => pmpro_url("account"),
|
133 |
"display_name" => $user->display_name,
|
134 |
"user_email" => $user->user_email,0
|
135 |
);
|
136 |
+
|
137 |
+
if($invoice)
|
138 |
{
|
139 |
if($invoice->gateway == "paypalexpress")
|
140 |
$this->template = "checkout_express";
|
|
|
|
|
|
|
|
|
|
|
141 |
elseif(pmpro_isLevelTrial($user->membership_level))
|
142 |
$this->template = "checkout_trial";
|
143 |
else
|
144 |
$this->template = "checkout_paid";
|
145 |
$this->data["invoice_id"] = $invoice->code;
|
146 |
$this->data["invoice_total"] = $pmpro_currency_symbol . number_format($invoice->total, 2);
|
147 |
+
$this->data["invoice_date"] = date("F j, Y", $invoice->timestamp);
|
148 |
$this->data["billing_name"] = $invoice->billing->name;
|
149 |
$this->data["billing_street"] = $invoice->billing->street;
|
150 |
$this->data["billing_city"] = $invoice->billing->city;
|
151 |
$this->data["billing_state"] = $invoice->billing->state;
|
152 |
$this->data["billing_zip"] = $invoice->billing->zip;
|
|
|
153 |
$this->data["billing_phone"] = $invoice->billing->phone;
|
154 |
$this->data["cardtype"] = $invoice->cardtype;
|
155 |
$this->data["accountnumber"] = hideCardNumber($invoice->accountnumber);
|
156 |
$this->data["expirationmonth"] = $invoice->expirationmonth;
|
157 |
$this->data["expirationyear"] = $invoice->expirationyear;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
if($invoice->getDiscountCode())
|
160 |
+
$this->data["discount_code"] = "<p>Discount Code: " . $invoice->discount_code->code . "</p>\n";
|
161 |
else
|
162 |
$this->data["discount_code"] = "";
|
163 |
}
|
164 |
elseif(pmpro_isLevelFree($user->membership_level))
|
165 |
{
|
166 |
$this->template = "checkout_free";
|
167 |
+
$this->data["discount_code"] = "";
|
|
|
|
|
|
|
|
|
168 |
}
|
169 |
else
|
170 |
{
|
171 |
$this->template = "checkout_freetrial";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
$this->data["discount_code"] = "";
|
173 |
+
}
|
174 |
|
175 |
+
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' LIMIT 1");
|
176 |
if($enddate)
|
177 |
+
$this->data["membership_expiration"] = "<p>This membership will expire on " . date("n/j/Y", $enddate) . ".</p>\n";
|
178 |
else
|
179 |
$this->data["membership_expiration"] = "";
|
180 |
|
191 |
return false;
|
192 |
|
193 |
$this->email = $user->user_email;
|
194 |
+
$this->subject = "Your billing information has been udpated at " . get_option("blogname");
|
195 |
$this->template = "billing";
|
196 |
|
197 |
$this->data = array(
|
198 |
"subject" => $this->subject,
|
199 |
"name" => $user->display_name,
|
|
|
200 |
"sitename" => get_option("blogname"),
|
|
|
|
|
201 |
"membership_level_name" => $user->membership_level->name,
|
202 |
"display_name" => $user->display_name,
|
203 |
"user_email" => $user->user_email,
|
206 |
"billing_city" => $invoice->billing->city,
|
207 |
"billing_state" => $invoice->billing->state,
|
208 |
"billing_zip" => $invoice->billing->zip,
|
|
|
209 |
"billing_phone" => $invoice->billing->phone,
|
210 |
"cardtype" => $invoice->cardtype,
|
211 |
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
212 |
"expirationmonth" => $invoice->expirationmonth,
|
213 |
"expirationyear" => $invoice->expirationyear,
|
214 |
+
"login_link" => pmpro_url("account")
|
215 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
return $this->sendEmail();
|
218 |
}
|
227 |
return false;
|
228 |
|
229 |
$this->email = $user->user_email;
|
230 |
+
$this->subject = "Membership Payment Failed at " . get_option("blogname");
|
231 |
$this->template = "billing_failure";
|
232 |
|
233 |
$this->data = array(
|
234 |
"subject" => $this->subject,
|
235 |
"name" => $user->display_name,
|
|
|
236 |
"sitename" => get_option("blogname"),
|
|
|
|
|
237 |
"membership_level_name" => $user->membership_level->name,
|
238 |
"display_name" => $user->display_name,
|
239 |
"user_email" => $user->user_email,
|
242 |
"billing_city" => $invoice->billing->city,
|
243 |
"billing_state" => $invoice->billing->state,
|
244 |
"billing_zip" => $invoice->billing->zip,
|
|
|
245 |
"billing_phone" => $invoice->billing->phone,
|
246 |
"cardtype" => $invoice->cardtype,
|
247 |
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
248 |
"expirationmonth" => $invoice->expirationmonth,
|
249 |
"expirationyear" => $invoice->expirationyear,
|
250 |
+
"login_link" => pmpro_url("billing")
|
251 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
|
253 |
return $this->sendEmail();
|
254 |
+
}
|
255 |
|
256 |
function sendBillingFailureAdminEmail($email, $invoice = NULL)
|
257 |
{
|
261 |
$user = get_userdata($invoice->user_id);
|
262 |
|
263 |
$this->email = $email;
|
264 |
+
$this->subject = "Membership Payment Failed For " . $user->display_name . " at " . get_option("blogname");
|
265 |
$this->template = "billing_failure_admin";
|
266 |
|
267 |
$this->data = array(
|
268 |
"subject" => $this->subject,
|
269 |
"name" => "Admin",
|
|
|
270 |
"sitename" => get_option("blogname"),
|
|
|
|
|
271 |
"membership_level_name" => $user->membership_level->name,
|
272 |
"display_name" => $user->display_name,
|
273 |
"user_email" => $user->user_email,
|
276 |
"billing_city" => $invoice->billing->city,
|
277 |
"billing_state" => $invoice->billing->state,
|
278 |
"billing_zip" => $invoice->billing->zip,
|
|
|
279 |
"billing_phone" => $invoice->billing->phone,
|
280 |
"cardtype" => $invoice->cardtype,
|
281 |
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
282 |
"expirationmonth" => $invoice->expirationmonth,
|
283 |
"expirationyear" => $invoice->expirationyear,
|
284 |
+
"login_link" => pmpro_url("billing")
|
285 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
|
287 |
return $this->sendEmail();
|
288 |
}
|
289 |
|
290 |
function sendInvoiceEmail($user = NULL, $invoice = NULL)
|
291 |
{
|
292 |
+
global $current_user, $pmpro_currency_symbol;
|
293 |
if(!$user)
|
294 |
$user = $current_user;
|
295 |
|
297 |
return false;
|
298 |
|
299 |
$this->email = $user->user_email;
|
300 |
+
$this->subject = "INVOICE for " . get_option("blogname") . " membership";
|
301 |
$this->template = "invoice";
|
302 |
|
303 |
$this->data = array(
|
304 |
"subject" => $this->subject,
|
305 |
"name" => $user->display_name,
|
|
|
306 |
"sitename" => get_option("blogname"),
|
|
|
|
|
307 |
"membership_level_name" => $user->membership_level->name,
|
308 |
"display_name" => $user->display_name,
|
309 |
"user_email" => $user->user_email,
|
310 |
+
"invoice_id" => $invoice->payment_transaction_id,
|
311 |
"invoice_total" => $pmpro_currency_symbol . number_format($invoice->total, 2),
|
312 |
+
"invoice_date" => date("F j, Y", $invoice->timestamp),
|
313 |
"billing_name" => $invoice->billing->name,
|
314 |
"billing_street" => $invoice->billing->street,
|
315 |
"billing_city" => $invoice->billing->city,
|
316 |
"billing_state" => $invoice->billing->state,
|
317 |
"billing_zip" => $invoice->billing->zip,
|
|
|
318 |
"billing_phone" => $invoice->billing->phone,
|
319 |
"cardtype" => $invoice->cardtype,
|
320 |
"accountnumber" => hideCardNumber($invoice->accountnumber),
|
321 |
"expirationmonth" => $invoice->expirationmonth,
|
322 |
"expirationyear" => $invoice->expirationyear,
|
323 |
+
"login_link" => pmpro_url("account"),
|
324 |
+
"invoice_link" => pmpro_url("invoice", "?invoice=" . $invoice->code)
|
325 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
|
327 |
if($invoice->getDiscountCode())
|
328 |
+
$this->data["discount_code"] = "<p>Discount Code: " . $invoice->discount_code . "</p>\n";
|
329 |
else
|
330 |
$this->data["discount_code"] = "";
|
331 |
|
332 |
+
$enddate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(enddate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user->ID . "' LIMIT 1");
|
333 |
if($enddate)
|
334 |
+
$this->data["membership_expiration"] = "<p>This membership will expire on " . date("n/j/Y", $enddate) . ".</p>\n";
|
335 |
else
|
336 |
$this->data["membership_expiration"] = "";
|
337 |
+
|
338 |
return $this->sendEmail();
|
339 |
}
|
340 |
|
348 |
return false;
|
349 |
|
350 |
//make sure we have the current membership level data
|
351 |
+
$user->membership_level = $wpdb->get_row("SELECT l.id AS ID, l.name AS name, UNIX_TIMESTAMP(mu.startdate) as startdate, mu.billing_amount, mu.cycle_number, mu.cycle_period, mu.trial_amount, mu.trial_limit
|
352 |
FROM {$wpdb->pmpro_membership_levels} AS l
|
353 |
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
354 |
WHERE mu.user_id = " . $user->ID . "
|
355 |
+
LIMIT 1");
|
|
|
356 |
|
357 |
$this->email = $user->user_email;
|
358 |
+
$this->subject = "Your trial membership at " . get_option("blogname") . " is ending soon";
|
359 |
$this->template = "trial_ending";
|
360 |
$this->data = array(
|
361 |
"subject" => $this->subject,
|
362 |
"name" => $user->display_name,
|
363 |
+
"sitename" => get_option("blogname"),
|
|
|
|
|
364 |
"membership_level_name" => $user->membership_level->name,
|
365 |
+
"siteemail" => get_bloginfo("admin_email"),
|
366 |
"login_link" => wp_login_url(),
|
367 |
"display_name" => $user->display_name,
|
368 |
"user_email" => $user->user_email,
|
371 |
"cycle_period" => $user->membership_level->cycle_period,
|
372 |
"trial_amount" => $pmpro_currency_symbol . $user->membership_level->trial_amount,
|
373 |
"trial_limit" => $user->membership_level->trial_limit,
|
374 |
+
"trial_end" => date("n/j/Y", strtotime(date("m/d/Y", $user->membership_level->startdate) . " + " . $user->membership_level->trial_limit . " " . $user->membership_level->cycle_period))
|
375 |
);
|
376 |
|
377 |
return $this->sendEmail();
|
387 |
return false;
|
388 |
|
389 |
$this->email = $user->user_email;
|
390 |
+
$this->subject = "Your membership at " . get_option("blogname") . " has ended";
|
391 |
$this->template = "membership_expired";
|
392 |
+
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "sitename" => get_option("blogname"), "siteemail" => get_bloginfo("admin_email"), "login_link" => wp_login_url(), "display_name" => $user->display_name, "user_email" => $user->user_email, "levels_link" => pmpro_url("levels"));
|
393 |
|
394 |
return $this->sendEmail();
|
395 |
}
|
404 |
return false;
|
405 |
|
406 |
//make sure we have the current membership level data
|
407 |
+
$user->membership_level = $wpdb->get_row("SELECT l.id AS ID, l.name AS name, UNIX_TIMESTAMP(mu.enddate) as enddate
|
408 |
FROM {$wpdb->pmpro_membership_levels} AS l
|
409 |
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
410 |
WHERE mu.user_id = " . $user->ID . "
|
411 |
+
LIMIT 1");
|
|
|
412 |
|
413 |
$this->email = $user->user_email;
|
414 |
+
$this->subject = "Your membership at " . get_option("blogname") . " will end soon";
|
415 |
$this->template = "membership_expiring";
|
416 |
+
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "sitename" => get_option("blogname"), "membership_level_name" => $user->membership_level->name, "siteemail" => get_bloginfo("admin_email"), "login_link" => wp_login_url(), "enddate" => date("n/j/Y", $user->membership_level->enddate), "display_name" => $user->display_name, "user_email" => $user->user_email);
|
417 |
|
418 |
return $this->sendEmail();
|
419 |
}
|
428 |
return false;
|
429 |
|
430 |
//make sure we have the current membership level data
|
431 |
+
$user->membership_level = $wpdb->get_row("SELECT l.id AS ID, l.name AS name
|
432 |
+
FROM {$wpdb->pmpro_membership_levels} AS l
|
433 |
+
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
434 |
+
WHERE mu.user_id = " . $user->ID . "
|
435 |
+
LIMIT 1");
|
436 |
|
437 |
$this->email = $user->user_email;
|
438 |
+
$this->subject = "Your membership at " . get_option("blogname") . " has been changed";
|
439 |
$this->template = "admin_change";
|
440 |
+
$this->data = array("subject" => $this->subject, "name" => $user->display_name, "sitename" => get_option("blogname"), "membership_level_name" => $user->membership_level->name, "siteemail" => get_bloginfo("admin_email"), "login_link" => wp_login_url());
|
441 |
if($user->membership_level->ID)
|
442 |
+
$this->data["membership_change"] = "new level is " . $user->membership_level->name . ". This membership is free";
|
443 |
else
|
444 |
+
$this->data["membership_change"] = "membership has been canceled";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
|
446 |
return $this->sendEmail();
|
447 |
}
|
448 |
}
|
449 |
+
?>
|
classes/gateways/class.pmprogateway.php
DELETED
@@ -1,220 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
//require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
class PMProGateway
|
4 |
-
{
|
5 |
-
function PMProGateway($gateway = NULL)
|
6 |
-
{
|
7 |
-
$this->gateway = $gateway;
|
8 |
-
return $this->gateway;
|
9 |
-
}
|
10 |
-
|
11 |
-
function process(&$order)
|
12 |
-
{
|
13 |
-
//check for initial payment
|
14 |
-
if(floatval($order->InitialPayment) == 0)
|
15 |
-
{
|
16 |
-
//auth first, then process
|
17 |
-
if($this->authorize($order))
|
18 |
-
{
|
19 |
-
$this->void($order);
|
20 |
-
if(!pmpro_isLevelTrial($order->membership_level))
|
21 |
-
{
|
22 |
-
//subscription will start today with a 1 period trial
|
23 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
24 |
-
$order->TrialBillingPeriod = $order->BillingPeriod;
|
25 |
-
$order->TrialBillingFrequency = $order->BillingFrequency;
|
26 |
-
$order->TrialBillingCycles = 1;
|
27 |
-
$order->TrialAmount = 0;
|
28 |
-
|
29 |
-
//add a billing cycle to make up for the trial, if applicable
|
30 |
-
if(!empty($order->TotalBillingCycles))
|
31 |
-
$order->TotalBillingCycles++;
|
32 |
-
}
|
33 |
-
elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
|
34 |
-
{
|
35 |
-
//it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
|
36 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
37 |
-
$order->TrialBillingCycles++;
|
38 |
-
|
39 |
-
//add a billing cycle to make up for the trial, if applicable
|
40 |
-
if($order->TotalBillingCycles)
|
41 |
-
$order->TotalBillingCycles++;
|
42 |
-
}
|
43 |
-
else
|
44 |
-
{
|
45 |
-
//add a period to the start date to account for the initial payment
|
46 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
47 |
-
}
|
48 |
-
|
49 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
50 |
-
return $this->subscribe($order);
|
51 |
-
}
|
52 |
-
else
|
53 |
-
{
|
54 |
-
if(empty($order->error))
|
55 |
-
$order->error = __("Unknown error: Authorization failed.", "pmpro");
|
56 |
-
return false;
|
57 |
-
}
|
58 |
-
}
|
59 |
-
else
|
60 |
-
{
|
61 |
-
//charge first payment
|
62 |
-
if($this->charge($order))
|
63 |
-
{
|
64 |
-
//setup recurring billing
|
65 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
66 |
-
{
|
67 |
-
if(!pmpro_isLevelTrial($order->membership_level))
|
68 |
-
{
|
69 |
-
//subscription will start today with a 1 period trial
|
70 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
71 |
-
$order->TrialBillingPeriod = $order->BillingPeriod;
|
72 |
-
$order->TrialBillingFrequency = $order->BillingFrequency;
|
73 |
-
$order->TrialBillingCycles = 1;
|
74 |
-
$order->TrialAmount = 0;
|
75 |
-
|
76 |
-
//add a billing cycle to make up for the trial, if applicable
|
77 |
-
if(!empty($order->TotalBillingCycles))
|
78 |
-
$order->TotalBillingCycles++;
|
79 |
-
}
|
80 |
-
elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
|
81 |
-
{
|
82 |
-
//it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
|
83 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
84 |
-
$order->TrialBillingCycles++;
|
85 |
-
|
86 |
-
//add a billing cycle to make up for the trial, if applicable
|
87 |
-
if(!empty($order->TotalBillingCycles))
|
88 |
-
$order->TotalBillingCycles++;
|
89 |
-
}
|
90 |
-
else
|
91 |
-
{
|
92 |
-
//add a period to the start date to account for the initial payment
|
93 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $this->BillingFrequency . " " . $this->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
94 |
-
}
|
95 |
-
|
96 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
97 |
-
if($this->subscribe($order))
|
98 |
-
{
|
99 |
-
return true;
|
100 |
-
}
|
101 |
-
else
|
102 |
-
{
|
103 |
-
if($this->void($order))
|
104 |
-
{
|
105 |
-
if(!$order->error)
|
106 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
107 |
-
}
|
108 |
-
else
|
109 |
-
{
|
110 |
-
if(!$order->error)
|
111 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
112 |
-
|
113 |
-
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", "pmpro");
|
114 |
-
}
|
115 |
-
|
116 |
-
return false;
|
117 |
-
}
|
118 |
-
}
|
119 |
-
else
|
120 |
-
{
|
121 |
-
//only a one time charge
|
122 |
-
$order->status = "success"; //saved on checkout page
|
123 |
-
return true;
|
124 |
-
}
|
125 |
-
}
|
126 |
-
else
|
127 |
-
{
|
128 |
-
if(empty($order->error))
|
129 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
130 |
-
|
131 |
-
return false;
|
132 |
-
}
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
function authorize(&$order)
|
137 |
-
{
|
138 |
-
//create a code for the order
|
139 |
-
if(empty($order->code))
|
140 |
-
$order->code = $order->getRandomCode();
|
141 |
-
|
142 |
-
//simulate a successful authorization
|
143 |
-
$order->payment_transaction_id = "TEST" . $order->code;
|
144 |
-
$order->updateStatus("authorized");
|
145 |
-
return true;
|
146 |
-
}
|
147 |
-
|
148 |
-
function void(&$order)
|
149 |
-
{
|
150 |
-
//need a transaction id
|
151 |
-
if(empty($order->payment_transaction_id))
|
152 |
-
return false;
|
153 |
-
|
154 |
-
//simulate a successful void
|
155 |
-
$order->payment_transaction_id = "TEST" . $order->code;
|
156 |
-
$order->updateStatus("voided");
|
157 |
-
return true;
|
158 |
-
}
|
159 |
-
|
160 |
-
function charge(&$order)
|
161 |
-
{
|
162 |
-
//create a code for the order
|
163 |
-
if(empty($order->code))
|
164 |
-
$order->code = $order->getRandomCode();
|
165 |
-
|
166 |
-
//simulate a successful charge
|
167 |
-
$order->payment_transaction_id = "TEST" . $order->code;
|
168 |
-
$order->updateStatus("success");
|
169 |
-
return true;
|
170 |
-
}
|
171 |
-
|
172 |
-
function subscribe(&$order)
|
173 |
-
{
|
174 |
-
//create a code for the order
|
175 |
-
if(empty($order->code))
|
176 |
-
$order->code = $order->getRandomCode();
|
177 |
-
|
178 |
-
//filter order before subscription. use with care.
|
179 |
-
$order = apply_filters("pmpro_subscribe_order", $order, $this);
|
180 |
-
|
181 |
-
//simulate a successful subscription processing
|
182 |
-
$order->status = "success";
|
183 |
-
$order->subscription_transaction_id = "TEST" . $order->code;
|
184 |
-
return true;
|
185 |
-
}
|
186 |
-
|
187 |
-
function update(&$order)
|
188 |
-
{
|
189 |
-
//simulate a successful billing update
|
190 |
-
return true;
|
191 |
-
}
|
192 |
-
|
193 |
-
function cancel(&$order)
|
194 |
-
{
|
195 |
-
//require a subscription id
|
196 |
-
if(empty($order->subscription_transaction_id))
|
197 |
-
return false;
|
198 |
-
|
199 |
-
//simulate a successful cancel
|
200 |
-
$order->updateStatus("cancelled");
|
201 |
-
return true;
|
202 |
-
}
|
203 |
-
|
204 |
-
function getSubscriptionStatus(&$order)
|
205 |
-
{
|
206 |
-
//require a subscription id
|
207 |
-
if(empty($order->subscription_transaction_id))
|
208 |
-
return false;
|
209 |
-
|
210 |
-
//this looks different for each gateway, but generally an array of some sort
|
211 |
-
return array();
|
212 |
-
}
|
213 |
-
|
214 |
-
function getTransactionStatus(&$order)
|
215 |
-
{
|
216 |
-
//this looks different for each gateway, but generally an array of some sort
|
217 |
-
return array();
|
218 |
-
}
|
219 |
-
}
|
220 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_authorizenet.php
DELETED
@@ -1,872 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
class PMProGateway_authorizenet extends PMProGateway
|
4 |
-
{
|
5 |
-
function PMProGateway_authorizenet($gateway = NULL)
|
6 |
-
{
|
7 |
-
$this->gateway = $gateway;
|
8 |
-
return $this->gateway;
|
9 |
-
}
|
10 |
-
|
11 |
-
function process(&$order)
|
12 |
-
{
|
13 |
-
//check for initial payment
|
14 |
-
if(floatval($order->InitialPayment) == 0)
|
15 |
-
{
|
16 |
-
//auth first, then process
|
17 |
-
if($this->authorize($order))
|
18 |
-
{
|
19 |
-
$this->void($order);
|
20 |
-
if(!pmpro_isLevelTrial($order->membership_level))
|
21 |
-
{
|
22 |
-
//subscription will start today with a 1 period trial
|
23 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
24 |
-
$order->TrialBillingPeriod = $order->BillingPeriod;
|
25 |
-
$order->TrialBillingFrequency = $order->BillingFrequency;
|
26 |
-
$order->TrialBillingCycles = 1;
|
27 |
-
$order->TrialAmount = 0;
|
28 |
-
|
29 |
-
//add a billing cycle to make up for the trial, if applicable
|
30 |
-
if(!empty($order->TotalBillingCycles))
|
31 |
-
$order->TotalBillingCycles++;
|
32 |
-
}
|
33 |
-
elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
|
34 |
-
{
|
35 |
-
//it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
|
36 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
37 |
-
$order->TrialBillingCycles++;
|
38 |
-
|
39 |
-
//add a billing cycle to make up for the trial, if applicable
|
40 |
-
if(!empty($order->TotalBillingCycles))
|
41 |
-
$order->TotalBillingCycles++;
|
42 |
-
}
|
43 |
-
else
|
44 |
-
{
|
45 |
-
//add a period to the start date to account for the initial payment
|
46 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
47 |
-
}
|
48 |
-
|
49 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
50 |
-
return $this->subscribe($order);
|
51 |
-
}
|
52 |
-
else
|
53 |
-
{
|
54 |
-
if(empty($order->error))
|
55 |
-
$order->error = __("Unknown error: Authorization failed.", "pmpro");
|
56 |
-
return false;
|
57 |
-
}
|
58 |
-
}
|
59 |
-
else
|
60 |
-
{
|
61 |
-
//charge first payment
|
62 |
-
if($this->charge($order))
|
63 |
-
{
|
64 |
-
//setup recurring billing
|
65 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
66 |
-
{
|
67 |
-
if(!pmpro_isLevelTrial($order->membership_level))
|
68 |
-
{
|
69 |
-
//subscription will start today with a 1 period trial
|
70 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
71 |
-
$order->TrialBillingPeriod = $order->BillingPeriod;
|
72 |
-
$order->TrialBillingFrequency = $order->BillingFrequency;
|
73 |
-
$order->TrialBillingCycles = 1;
|
74 |
-
$order->TrialAmount = 0;
|
75 |
-
|
76 |
-
//add a billing cycle to make up for the trial, if applicable
|
77 |
-
if(!empty($order->TotalBillingCycles))
|
78 |
-
$order->TotalBillingCycles++;
|
79 |
-
}
|
80 |
-
elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
|
81 |
-
{
|
82 |
-
//it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
|
83 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
84 |
-
$order->TrialBillingCycles++;
|
85 |
-
|
86 |
-
//add a billing cycle to make up for the trial, if applicable
|
87 |
-
if(!empty($order->TotalBillingCycles))
|
88 |
-
$order->TotalBillingCycles++;
|
89 |
-
}
|
90 |
-
else
|
91 |
-
{
|
92 |
-
//add a period to the start date to account for the initial payment
|
93 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
94 |
-
}
|
95 |
-
|
96 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
97 |
-
if($this->subscribe($order))
|
98 |
-
{
|
99 |
-
return true;
|
100 |
-
}
|
101 |
-
else
|
102 |
-
{
|
103 |
-
if($this->void($order))
|
104 |
-
{
|
105 |
-
if(!$order->error)
|
106 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
107 |
-
}
|
108 |
-
else
|
109 |
-
{
|
110 |
-
if(!$order->error)
|
111 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
112 |
-
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", "pmpro");
|
113 |
-
}
|
114 |
-
|
115 |
-
return false;
|
116 |
-
}
|
117 |
-
}
|
118 |
-
else
|
119 |
-
{
|
120 |
-
//only a one time charge
|
121 |
-
$order->status = "success"; //saved on checkout page
|
122 |
-
return true;
|
123 |
-
}
|
124 |
-
}
|
125 |
-
else
|
126 |
-
{
|
127 |
-
if(empty($order->error))
|
128 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
129 |
-
|
130 |
-
return false;
|
131 |
-
}
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
function authorize(&$order)
|
136 |
-
{
|
137 |
-
if(empty($order->code))
|
138 |
-
$order->code = $order->getRandomCode();
|
139 |
-
|
140 |
-
if(empty($order->gateway_environment))
|
141 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
142 |
-
else
|
143 |
-
$gateway_environment = $order->gateway_environment;
|
144 |
-
if($gateway_environment == "live")
|
145 |
-
$host = "secure.authorize.net";
|
146 |
-
else
|
147 |
-
$host = "test.authorize.net";
|
148 |
-
|
149 |
-
$path = "/gateway/transact.dll";
|
150 |
-
$post_url = "https://" . $host . $path;
|
151 |
-
|
152 |
-
$post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
|
153 |
-
|
154 |
-
//what amount to authorize? just $1 to test
|
155 |
-
$amount = "1.00";
|
156 |
-
|
157 |
-
//combine address
|
158 |
-
$address = $order->Address1;
|
159 |
-
if(!empty($order->Address2))
|
160 |
-
$address .= "\n" . $order->Address2;
|
161 |
-
|
162 |
-
//customer stuff
|
163 |
-
$customer_email = $order->Email;
|
164 |
-
$customer_phone = $order->billing->phone;
|
165 |
-
|
166 |
-
if(!isset($order->membership_level->name))
|
167 |
-
$order->membership_level->name = "";
|
168 |
-
|
169 |
-
$post_values = array(
|
170 |
-
|
171 |
-
// the API Login ID and Transaction Key must be replaced with valid values
|
172 |
-
"x_login" => pmpro_getOption("loginname"),
|
173 |
-
"x_tran_key" => pmpro_getOption("transactionkey"),
|
174 |
-
|
175 |
-
"x_version" => "3.1",
|
176 |
-
"x_delim_data" => "TRUE",
|
177 |
-
"x_delim_char" => "|",
|
178 |
-
"x_relay_response" => "FALSE",
|
179 |
-
|
180 |
-
"x_type" => "AUTH_ONLY",
|
181 |
-
"x_method" => "CC",
|
182 |
-
"x_card_type" => $order->cardtype,
|
183 |
-
"x_card_num" => $order->accountnumber,
|
184 |
-
"x_exp_date" => $order->ExpirationDate,
|
185 |
-
|
186 |
-
"x_amount" => $amount,
|
187 |
-
"x_description" => $order->membership_level->name . " " . __("Membership", "pmpro"),
|
188 |
-
|
189 |
-
"x_first_name" => $order->FirstName,
|
190 |
-
"x_last_name" => $order->LastName,
|
191 |
-
"x_address" => $address,
|
192 |
-
"x_city" => $order->billing->city,
|
193 |
-
"x_state" => $order->billing->state,
|
194 |
-
"x_zip" => $order->billing->zip,
|
195 |
-
"x_country" => $order->billing->country,
|
196 |
-
"x_invoice_num" => $order->code,
|
197 |
-
"x_phone" => $customer_phone,
|
198 |
-
"x_email" => $order->Email
|
199 |
-
// Additional fields can be added here as outlined in the AIM integration
|
200 |
-
// guide at: http://developer.authorize.net
|
201 |
-
);
|
202 |
-
|
203 |
-
if(!empty($order->CVV2))
|
204 |
-
$post_values["x_card_code"] = $order->CVV2;
|
205 |
-
|
206 |
-
// This section takes the input fields and converts them to the proper format
|
207 |
-
// for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
|
208 |
-
$post_string = "";
|
209 |
-
foreach( $post_values as $key => $value )
|
210 |
-
{ $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&"; }
|
211 |
-
$post_string = rtrim( $post_string, "& " );
|
212 |
-
|
213 |
-
//curl
|
214 |
-
$request = curl_init($post_url); // initiate curl object
|
215 |
-
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
216 |
-
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
217 |
-
curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
|
218 |
-
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
|
219 |
-
$post_response = curl_exec($request); // execute curl post and store results in $post_response
|
220 |
-
// additional options may be required depending upon your server configuration
|
221 |
-
// you can find documentation on curl options at http://www.php.net/curl_setopt
|
222 |
-
curl_close ($request); // close curl object
|
223 |
-
|
224 |
-
// This line takes the response and breaks it into an array using the specified delimiting character
|
225 |
-
$response_array = explode($post_values["x_delim_char"],$post_response);
|
226 |
-
|
227 |
-
if($response_array[0] == 1)
|
228 |
-
{
|
229 |
-
$order->payment_transaction_id = $response_array[6];
|
230 |
-
$order->updateStatus("authorized");
|
231 |
-
|
232 |
-
return true;
|
233 |
-
}
|
234 |
-
else
|
235 |
-
{
|
236 |
-
//$order->status = "error";
|
237 |
-
$order->errorcode = $response_array[2];
|
238 |
-
$order->error = $response_array[3];
|
239 |
-
$order->shorterror = $response_array[3];
|
240 |
-
return false;
|
241 |
-
}
|
242 |
-
}
|
243 |
-
|
244 |
-
function void(&$order)
|
245 |
-
{
|
246 |
-
if(empty($order->payment_transaction_id))
|
247 |
-
return false;
|
248 |
-
|
249 |
-
if(empty($order->gateway_environment))
|
250 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
251 |
-
else
|
252 |
-
$gateway_environment = $order->gateway_environment;
|
253 |
-
if($gateway_environment == "live")
|
254 |
-
$host = "secure.authorize.net";
|
255 |
-
else
|
256 |
-
$host = "test.authorize.net";
|
257 |
-
|
258 |
-
$path = "/gateway/transact.dll";
|
259 |
-
$post_url = "https://" . $host . $path;
|
260 |
-
|
261 |
-
$post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
|
262 |
-
|
263 |
-
$post_values = array(
|
264 |
-
|
265 |
-
// the API Login ID and Transaction Key must be replaced with valid values
|
266 |
-
"x_login" => pmpro_getOption("loginname"),
|
267 |
-
"x_tran_key" => pmpro_getOption("transactionkey"),
|
268 |
-
|
269 |
-
"x_version" => "3.1",
|
270 |
-
"x_delim_data" => "TRUE",
|
271 |
-
"x_delim_char" => "|",
|
272 |
-
"x_relay_response" => "FALSE",
|
273 |
-
|
274 |
-
"x_type" => "VOID",
|
275 |
-
"x_trans_id" => $order->payment_transaction_id
|
276 |
-
// Additional fields can be added here as outlined in the AIM integration
|
277 |
-
// guide at: http://developer.authorize.net
|
278 |
-
);
|
279 |
-
|
280 |
-
// This section takes the input fields and converts them to the proper format
|
281 |
-
// for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
|
282 |
-
$post_string = "";
|
283 |
-
foreach( $post_values as $key => $value )
|
284 |
-
{ $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&"; }
|
285 |
-
$post_string = rtrim( $post_string, "& " );
|
286 |
-
|
287 |
-
//curl
|
288 |
-
$request = curl_init($post_url); // initiate curl object
|
289 |
-
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
290 |
-
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
291 |
-
curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
|
292 |
-
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
|
293 |
-
$post_response = curl_exec($request); // execute curl post and store results in $post_response
|
294 |
-
// additional options may be required depending upon your server configuration
|
295 |
-
// you can find documentation on curl options at http://www.php.net/curl_setopt
|
296 |
-
curl_close ($request); // close curl object
|
297 |
-
|
298 |
-
// This line takes the response and breaks it into an array using the specified delimiting character
|
299 |
-
$response_array = explode($post_values["x_delim_char"],$post_response);
|
300 |
-
if($response_array[0] == 1)
|
301 |
-
{
|
302 |
-
$order->payment_transaction_id = $response_array[4];
|
303 |
-
$order->updateStatus("voided");
|
304 |
-
return true;
|
305 |
-
}
|
306 |
-
else
|
307 |
-
{
|
308 |
-
//$order->status = "error";
|
309 |
-
$order->errorcode = $response_array[2];
|
310 |
-
$order->error = $response_array[3];
|
311 |
-
$order->shorterror = $response_array[3];
|
312 |
-
return false;
|
313 |
-
}
|
314 |
-
}
|
315 |
-
|
316 |
-
function charge(&$order)
|
317 |
-
{
|
318 |
-
if(empty($order->code))
|
319 |
-
$order->code = $order->getRandomCode();
|
320 |
-
|
321 |
-
if(!empty($order->gateway_environment))
|
322 |
-
$gateway_environment = $order->gateway_environment;
|
323 |
-
if(empty($gateway_environment))
|
324 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
325 |
-
if($gateway_environment == "live")
|
326 |
-
$host = "secure.authorize.net";
|
327 |
-
else
|
328 |
-
$host = "test.authorize.net";
|
329 |
-
|
330 |
-
$path = "/gateway/transact.dll";
|
331 |
-
$post_url = "https://" . $host . $path;
|
332 |
-
|
333 |
-
$post_url = apply_filters("pmpro_authorizenet_post_url", $post_url, $gateway_environment);
|
334 |
-
|
335 |
-
//what amount to charge?
|
336 |
-
$amount = $order->InitialPayment;
|
337 |
-
|
338 |
-
//tax
|
339 |
-
$order->subtotal = $amount;
|
340 |
-
$tax = $order->getTax(true);
|
341 |
-
$amount = round((float)$order->subtotal + (float)$tax, 2);
|
342 |
-
|
343 |
-
//combine address
|
344 |
-
$address = $order->Address1;
|
345 |
-
if(!empty($order->Address2))
|
346 |
-
$address .= "\n" . $order->Address2;
|
347 |
-
|
348 |
-
//customer stuff
|
349 |
-
$customer_email = $order->Email;
|
350 |
-
$customer_phone = $order->billing->phone;
|
351 |
-
|
352 |
-
if(!isset($order->membership_level->name))
|
353 |
-
$order->membership_level->name = "";
|
354 |
-
|
355 |
-
$post_values = array(
|
356 |
-
|
357 |
-
// the API Login ID and Transaction Key must be replaced with valid values
|
358 |
-
"x_login" => pmpro_getOption("loginname"),
|
359 |
-
"x_tran_key" => pmpro_getOption("transactionkey"),
|
360 |
-
|
361 |
-
"x_version" => "3.1",
|
362 |
-
"x_delim_data" => "TRUE",
|
363 |
-
"x_delim_char" => "|",
|
364 |
-
"x_relay_response" => "FALSE",
|
365 |
-
|
366 |
-
"x_type" => "AUTH_CAPTURE",
|
367 |
-
"x_method" => "CC",
|
368 |
-
"x_card_type" => $order->cardtype,
|
369 |
-
"x_card_num" => $order->accountnumber,
|
370 |
-
"x_exp_date" => $order->ExpirationDate,
|
371 |
-
|
372 |
-
"x_amount" => $amount,
|
373 |
-
"x_tax" => $tax,
|
374 |
-
"x_description" => $order->membership_level->name . " Membership",
|
375 |
-
|
376 |
-
"x_first_name" => $order->FirstName,
|
377 |
-
"x_last_name" => $order->LastName,
|
378 |
-
"x_address" => $address,
|
379 |
-
"x_city" => $order->billing->city,
|
380 |
-
"x_state" => $order->billing->state,
|
381 |
-
"x_zip" => $order->billing->zip,
|
382 |
-
"x_country" => $order->billing->country,
|
383 |
-
"x_invoice_num" => $order->code,
|
384 |
-
"x_phone" => $customer_phone,
|
385 |
-
"x_email" => $order->Email
|
386 |
-
|
387 |
-
// Additional fields can be added here as outlined in the AIM integration
|
388 |
-
// guide at: http://developer.authorize.net
|
389 |
-
);
|
390 |
-
|
391 |
-
if(!empty($order->CVV2))
|
392 |
-
$post_values["x_card_code"] = $order->CVV2;
|
393 |
-
|
394 |
-
// This section takes the input fields and converts them to the proper format
|
395 |
-
// for an http post. For example: "x_login=username&x_tran_key=a1B2c3D4"
|
396 |
-
$post_string = "";
|
397 |
-
foreach( $post_values as $key => $value )
|
398 |
-
{ $post_string .= "$key=" . urlencode( str_replace("#", "%23", $value) ) . "&"; }
|
399 |
-
$post_string = rtrim( $post_string, "& " );
|
400 |
-
|
401 |
-
//curl
|
402 |
-
$request = curl_init($post_url); // initiate curl object
|
403 |
-
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
404 |
-
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
405 |
-
curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
|
406 |
-
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
|
407 |
-
$post_response = curl_exec($request); // execute curl post and store results in $post_response
|
408 |
-
// additional options may be required depending upon your server configuration
|
409 |
-
// you can find documentation on curl options at http://www.php.net/curl_setopt
|
410 |
-
curl_close ($request); // close curl object
|
411 |
-
|
412 |
-
// This line takes the response and breaks it into an array using the specified delimiting character
|
413 |
-
$response_array = explode($post_values["x_delim_char"],$post_response);
|
414 |
-
if($response_array[0] == 1)
|
415 |
-
{
|
416 |
-
$order->payment_transaction_id = $response_array[6];
|
417 |
-
$order->updateStatus("success");
|
418 |
-
return true;
|
419 |
-
}
|
420 |
-
else
|
421 |
-
{
|
422 |
-
//$order->status = "error";
|
423 |
-
$order->errorcode = $response_array[2];
|
424 |
-
$order->error = $response_array[3];
|
425 |
-
$order->shorterror = $response_array[3];
|
426 |
-
return false;
|
427 |
-
}
|
428 |
-
}
|
429 |
-
|
430 |
-
function subscribe(&$order)
|
431 |
-
{
|
432 |
-
//define variables to send
|
433 |
-
|
434 |
-
if(empty($order->code))
|
435 |
-
$order->code = $order->getRandomCode();
|
436 |
-
|
437 |
-
//filter order before subscription. use with care.
|
438 |
-
$order = apply_filters("pmpro_subscribe_order", $order, $this);
|
439 |
-
|
440 |
-
if(!empty($order->gateway_environment))
|
441 |
-
$gateway_environment = $order->gateway_environment;
|
442 |
-
if(empty($gateway_environment))
|
443 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
444 |
-
if($gateway_environment == "live")
|
445 |
-
$host = "api.authorize.net";
|
446 |
-
else
|
447 |
-
$host = "apitest.authorize.net";
|
448 |
-
|
449 |
-
$path = "/xml/v1/request.api";
|
450 |
-
|
451 |
-
$loginname = pmpro_getOption("loginname");
|
452 |
-
$transactionkey = pmpro_getOption("transactionkey");
|
453 |
-
|
454 |
-
$amount = $order->PaymentAmount;
|
455 |
-
$refId = $order->code;
|
456 |
-
$name = $order->membership_name;
|
457 |
-
$length = (int)$order->BillingFrequency;
|
458 |
-
|
459 |
-
if($order->BillingPeriod == "Month")
|
460 |
-
$unit = "months";
|
461 |
-
elseif($order->BillingPeriod == "Day")
|
462 |
-
$unit = "days";
|
463 |
-
elseif($order->BillingPeriod == "Year" && $order->BillingFrequency == 1)
|
464 |
-
{
|
465 |
-
$unit = "months";
|
466 |
-
$length = 12;
|
467 |
-
}
|
468 |
-
elseif($order->BillingPeriod == "Week")
|
469 |
-
{
|
470 |
-
$unit = "days";
|
471 |
-
$length = $length * 7; //converting weeks to days
|
472 |
-
}
|
473 |
-
else
|
474 |
-
return false; //authorize.net only supports months and days
|
475 |
-
|
476 |
-
$startDate = substr($order->ProfileStartDate, 0, 10);
|
477 |
-
if(!empty($order->TotalBillingCycles))
|
478 |
-
$totalOccurrences = (int)$order->TotalBillingCycles;
|
479 |
-
if(empty($totalOccurrences))
|
480 |
-
$totalOccurrences = 9999;
|
481 |
-
if(isset($order->TrialBillingCycles))
|
482 |
-
$trialOccurrences = (int)$order->TrialBillingCycles;
|
483 |
-
else
|
484 |
-
$trialOccurrences = 0;
|
485 |
-
if(isset($order->TrialAmount))
|
486 |
-
$trialAmount = $order->TrialAmount;
|
487 |
-
else
|
488 |
-
$trialAmount = NULL;
|
489 |
-
|
490 |
-
//taxes
|
491 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
492 |
-
$trial_tax = $order->getTaxForPrice($trialAmount);
|
493 |
-
|
494 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
495 |
-
$trialAmount = round((float)$trialAmount + (float)$trial_tax, 2);
|
496 |
-
|
497 |
-
//authorize.net doesn't support different periods between trial and actual
|
498 |
-
|
499 |
-
if(!empty($order->TrialBillingPeriod) && $order->TrialBillingPeriod != $order->BillingPeriod)
|
500 |
-
{
|
501 |
-
echo "F";
|
502 |
-
return false;
|
503 |
-
}
|
504 |
-
|
505 |
-
$cardNumber = $order->accountnumber;
|
506 |
-
$expirationDate = $order->ExpirationDate_YdashM;
|
507 |
-
$cardCode = $order->CVV2;
|
508 |
-
|
509 |
-
$firstName = $order->FirstName;
|
510 |
-
$lastName = $order->LastName;
|
511 |
-
|
512 |
-
//do address stuff then?
|
513 |
-
$address = $order->Address1;
|
514 |
-
if(!empty($order->Address2))
|
515 |
-
$address .= "\n" . $order->Address2;
|
516 |
-
$city = $order->billing->city;
|
517 |
-
$state = $order->billing->state;
|
518 |
-
$zip = $order->billing->zip;
|
519 |
-
$country = $order->billing->country;
|
520 |
-
|
521 |
-
//customer stuff
|
522 |
-
$customer_email = $order->Email;
|
523 |
-
if(strpos($order->billing->phone, "+") === false)
|
524 |
-
$customer_phone = $order->billing->phone;
|
525 |
-
else
|
526 |
-
$customer_phone = "";
|
527 |
-
|
528 |
-
//make sure the phone is in an okay format
|
529 |
-
$customer_phone = preg_replace("/[^0-9]/", "", $customer_phone);
|
530 |
-
if(strlen($customer_phone) > 10)
|
531 |
-
$customer_phone = "";
|
532 |
-
|
533 |
-
//build xml to post
|
534 |
-
$this->content =
|
535 |
-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
536 |
-
"<ARBCreateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" .
|
537 |
-
"<merchantAuthentication>".
|
538 |
-
"<name>" . $loginname . "</name>".
|
539 |
-
"<transactionKey>" . $transactionkey . "</transactionKey>".
|
540 |
-
"</merchantAuthentication>".
|
541 |
-
"<refId><![CDATA[" . substr($refId, 0, 20) . "]]></refId>".
|
542 |
-
"<subscription>".
|
543 |
-
"<name><![CDATA[" . substr($name, 0, 50) . "]]></name>".
|
544 |
-
"<paymentSchedule>".
|
545 |
-
"<interval>".
|
546 |
-
"<length>". $length ."</length>".
|
547 |
-
"<unit>". $unit ."</unit>".
|
548 |
-
"</interval>".
|
549 |
-
"<startDate>" . $startDate . "</startDate>".
|
550 |
-
"<totalOccurrences>". $totalOccurrences . "</totalOccurrences>";
|
551 |
-
if(!empty($trialOccurrences))
|
552 |
-
$this->content .=
|
553 |
-
"<trialOccurrences>". $trialOccurrences . "</trialOccurrences>";
|
554 |
-
$this->content .=
|
555 |
-
"</paymentSchedule>".
|
556 |
-
"<amount>". $amount ."</amount>";
|
557 |
-
if(!empty($trialOccurrences))
|
558 |
-
$this->content .=
|
559 |
-
"<trialAmount>" . $trialAmount . "</trialAmount>";
|
560 |
-
$this->content .=
|
561 |
-
"<payment>".
|
562 |
-
"<creditCard>".
|
563 |
-
"<cardNumber>" . $cardNumber . "</cardNumber>".
|
564 |
-
"<expirationDate>" . $expirationDate . "</expirationDate>";
|
565 |
-
if(!empty($cardCode))
|
566 |
-
$this->content .= "<cardCode>" . $cardCode . "</cardCode>";
|
567 |
-
$this->content .=
|
568 |
-
"</creditCard>".
|
569 |
-
"</payment>".
|
570 |
-
"<order><invoiceNumber>" . substr($order->code, 0, 20) . "</invoiceNumber></order>".
|
571 |
-
"<customer>".
|
572 |
-
"<email>". substr($customer_email, 0, 255) . "</email>".
|
573 |
-
"<phoneNumber>". substr($customer_phone, 0, 25) . "</phoneNumber>".
|
574 |
-
"</customer>".
|
575 |
-
"<billTo>".
|
576 |
-
"<firstName><![CDATA[". substr($firstName, 0, 50) . "]]></firstName>".
|
577 |
-
"<lastName><![CDATA[" . substr($lastName, 0, 50) . "]]></lastName>".
|
578 |
-
"<address><![CDATA[". substr($address, 0, 60) . "]]></address>".
|
579 |
-
"<city><![CDATA[" . substr($city, 0, 40) . "]]></city>".
|
580 |
-
"<state>". substr($state, 0, 2) . "</state>".
|
581 |
-
"<zip>" . substr($zip, 0, 20) . "</zip>".
|
582 |
-
"<country>". substr($country, 0, 60) . "</country>".
|
583 |
-
"</billTo>".
|
584 |
-
"</subscription>".
|
585 |
-
"</ARBCreateSubscriptionRequest>";
|
586 |
-
|
587 |
-
//send the xml via curl
|
588 |
-
$this->response = $this->send_request_via_curl($host,$path,$this->content);
|
589 |
-
//if curl is unavilable you can try using fsockopen
|
590 |
-
/*
|
591 |
-
$response = send_request_via_fsockopen($host,$path,$content);
|
592 |
-
*/
|
593 |
-
|
594 |
-
if(!empty($this->response)) {
|
595 |
-
list ($refId, $resultCode, $code, $text, $subscriptionId) = $this->parse_return($this->response);
|
596 |
-
if($resultCode == "Ok")
|
597 |
-
{
|
598 |
-
$order->status = "success"; //saved on checkout page
|
599 |
-
$order->subscription_transaction_id = $subscriptionId;
|
600 |
-
return true;
|
601 |
-
}
|
602 |
-
else
|
603 |
-
{
|
604 |
-
$order->status = "error";
|
605 |
-
$order->errorcode = $code;
|
606 |
-
$order->error = $text;
|
607 |
-
$order->shorterror = $text;
|
608 |
-
return false;
|
609 |
-
}
|
610 |
-
} else {
|
611 |
-
$order->status = "error";
|
612 |
-
$order->error = "Could not connect to Authorize.net";
|
613 |
-
$order->shorterror = "Could not connect to Authorize.net";
|
614 |
-
return false;
|
615 |
-
}
|
616 |
-
}
|
617 |
-
|
618 |
-
function update(&$order)
|
619 |
-
{
|
620 |
-
//define variables to send
|
621 |
-
$gateway_environment = $order->gateway_environment;
|
622 |
-
if(empty($gateway_environment))
|
623 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
624 |
-
if($gateway_environment == "live")
|
625 |
-
$host = "api.authorize.net";
|
626 |
-
else
|
627 |
-
$host = "apitest.authorize.net";
|
628 |
-
|
629 |
-
$path = "/xml/v1/request.api";
|
630 |
-
|
631 |
-
$loginname = pmpro_getOption("loginname");
|
632 |
-
$transactionkey = pmpro_getOption("transactionkey");
|
633 |
-
|
634 |
-
//$amount = $order->PaymentAmount;
|
635 |
-
$refId = $order->code;
|
636 |
-
$subscriptionId = $order->subscription_transaction_id;
|
637 |
-
|
638 |
-
$cardNumber = $order->accountnumber;
|
639 |
-
$expirationDate = $order->ExpirationDate_YdashM;
|
640 |
-
$cardCode = $order->CVV2;
|
641 |
-
|
642 |
-
$firstName = $order->FirstName;
|
643 |
-
$lastName = $order->LastName;
|
644 |
-
|
645 |
-
//do address stuff then?
|
646 |
-
$address = $order->Address1;
|
647 |
-
if(!empty($order->Address2))
|
648 |
-
$address .= "\n" . $order->Address2;
|
649 |
-
$city = $order->billing->city;
|
650 |
-
$state = $order->billing->state;
|
651 |
-
$zip = $order->billing->zip;
|
652 |
-
$country = $order->billing->country;
|
653 |
-
|
654 |
-
//customer stuff
|
655 |
-
$customer_email = $order->Email;
|
656 |
-
if(strpos($order->billing->phone, "+") === false)
|
657 |
-
$customer_phone = $order->billing->phone;
|
658 |
-
|
659 |
-
|
660 |
-
//build xml to post
|
661 |
-
$this->content =
|
662 |
-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" .
|
663 |
-
"<ARBUpdateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
|
664 |
-
"<merchantAuthentication>".
|
665 |
-
"<name><![CDATA[" . $loginname . "]]></name>".
|
666 |
-
"<transactionKey>" . $transactionkey . "</transactionKey>".
|
667 |
-
"</merchantAuthentication>".
|
668 |
-
"<refId>" . substr($refId, 0, 20) . "</refId>".
|
669 |
-
"<subscriptionId>" . $subscriptionId . "</subscriptionId>".
|
670 |
-
"<subscription>".
|
671 |
-
"<payment>".
|
672 |
-
"<creditCard>".
|
673 |
-
"<cardNumber>" . $cardNumber . "</cardNumber>".
|
674 |
-
"<expirationDate>" . $expirationDate . "</expirationDate>";
|
675 |
-
if(!empty($cardCode))
|
676 |
-
$this->content .= "<cardCode>" . $cardCode . "</cardCode>";
|
677 |
-
$this->content .=
|
678 |
-
"</creditCard>".
|
679 |
-
"</payment>".
|
680 |
-
"<customer>".
|
681 |
-
"<email>". substr($customer_email, 0, 255) . "</email>".
|
682 |
-
"<phoneNumber>". substr(str_replace("1 (", "(", formatPhone($customer_phone)), 0, 25) . "</phoneNumber>".
|
683 |
-
"</customer>".
|
684 |
-
"<billTo>".
|
685 |
-
"<firstName><![CDATA[". substr($firstName, 0, 50) . "]]></firstName>".
|
686 |
-
"<lastName><![CDATA[" . substr($lastName, 0, 50) . "]]></lastName>".
|
687 |
-
"<address><![CDATA[". substr($address, 0, 60) . "]]></address>".
|
688 |
-
"<city><![CDATA[" . substr($city, 0, 40) . "]]></city>".
|
689 |
-
"<state><![CDATA[". substr($state, 0, 2) . "]]></state>".
|
690 |
-
"<zip>" . substr($zip, 0, 20) . "</zip>".
|
691 |
-
"<country>". substr($country, 0, 60) . "</country>".
|
692 |
-
"</billTo>".
|
693 |
-
"</subscription>".
|
694 |
-
"</ARBUpdateSubscriptionRequest>";
|
695 |
-
|
696 |
-
//send the xml via curl
|
697 |
-
$this->response = $this->send_request_via_curl($host,$path,$this->content);
|
698 |
-
//if curl is unavilable you can try using fsockopen
|
699 |
-
/*
|
700 |
-
$response = send_request_via_fsockopen($host,$path,$order->content);
|
701 |
-
*/
|
702 |
-
|
703 |
-
|
704 |
-
if(!empty($this->response)) {
|
705 |
-
list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($this->response);
|
706 |
-
|
707 |
-
if($resultCode == "Ok" || $code == "Ok")
|
708 |
-
{
|
709 |
-
return true;
|
710 |
-
}
|
711 |
-
else
|
712 |
-
{
|
713 |
-
$order->status = "error";
|
714 |
-
$order->errorcode = $code;
|
715 |
-
$order->error = $text;
|
716 |
-
$order->shorterror = $text;
|
717 |
-
return false;
|
718 |
-
}
|
719 |
-
} else {
|
720 |
-
$order->status = "error";
|
721 |
-
$order->error = "Could not connect to Authorize.net";
|
722 |
-
$order->shorterror = "Could not connect to Authorize.net";
|
723 |
-
return false;
|
724 |
-
}
|
725 |
-
}
|
726 |
-
|
727 |
-
function cancel(&$order)
|
728 |
-
{
|
729 |
-
//define variables to send
|
730 |
-
$subscriptionId = $order->subscription_transaction_id;
|
731 |
-
$loginname = pmpro_getOption("loginname");
|
732 |
-
$transactionkey = pmpro_getOption("transactionkey");
|
733 |
-
|
734 |
-
$gateway_environment = $order->gateway_environment;
|
735 |
-
if(empty($gateway_environment))
|
736 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
737 |
-
if($gateway_environment == "live")
|
738 |
-
$host = "api.authorize.net";
|
739 |
-
else
|
740 |
-
$host = "apitest.authorize.net";
|
741 |
-
|
742 |
-
$path = "/xml/v1/request.api";
|
743 |
-
|
744 |
-
if(!$subscriptionId || !$loginname || !$transactionkey)
|
745 |
-
return false;
|
746 |
-
|
747 |
-
//build xml to post
|
748 |
-
$content =
|
749 |
-
"<?xml version=\"1.0\" encoding=\"utf-8\"?>".
|
750 |
-
"<ARBCancelSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">".
|
751 |
-
"<merchantAuthentication>".
|
752 |
-
"<name>" . $loginname . "</name>".
|
753 |
-
"<transactionKey>" . $transactionkey . "</transactionKey>".
|
754 |
-
"</merchantAuthentication>" .
|
755 |
-
"<subscriptionId>" . $subscriptionId . "</subscriptionId>".
|
756 |
-
"</ARBCancelSubscriptionRequest>";
|
757 |
-
|
758 |
-
//send the xml via curl
|
759 |
-
$response = $this->send_request_via_curl($host,$path,$content);
|
760 |
-
//if curl is unavilable you can try using fsockopen
|
761 |
-
/*
|
762 |
-
$response = send_request_via_fsockopen($host,$path,$content);
|
763 |
-
*/
|
764 |
-
|
765 |
-
//if the connection and send worked $response holds the return from Authorize.net
|
766 |
-
if ($response)
|
767 |
-
{
|
768 |
-
list ($resultCode, $code, $text, $subscriptionId) = $this->parse_return($response);
|
769 |
-
|
770 |
-
if($resultCode == "Ok" || $code == "Ok")
|
771 |
-
{
|
772 |
-
$order->updateStatus("cancelled");
|
773 |
-
return true;
|
774 |
-
}
|
775 |
-
else
|
776 |
-
{
|
777 |
-
//$order->status = "error";
|
778 |
-
$order->errorcode = $code;
|
779 |
-
$order->error = $text;
|
780 |
-
$order->shorterror = $text;
|
781 |
-
return false;
|
782 |
-
}
|
783 |
-
}
|
784 |
-
else
|
785 |
-
{
|
786 |
-
$order->status = "error";
|
787 |
-
$order->error = __("Could not connect to Authorize.net", "pmpro");
|
788 |
-
$order->shorterror = __("Could not connect to Authorize.net", "pmpro");
|
789 |
-
return false;
|
790 |
-
}
|
791 |
-
}
|
792 |
-
|
793 |
-
//Authorize.net Function
|
794 |
-
//function to send xml request via fsockopen
|
795 |
-
function send_request_via_fsockopen($host,$path,$content)
|
796 |
-
{
|
797 |
-
$posturl = "ssl://" . $host;
|
798 |
-
$header = "Host: $host\r\n";
|
799 |
-
$header .= "User-Agent: PHP Script\r\n";
|
800 |
-
$header .= "Content-Type: text/xml\r\n";
|
801 |
-
$header .= "Content-Length: ".strlen($content)."\r\n";
|
802 |
-
$header .= "Connection: close\r\n\r\n";
|
803 |
-
$fp = fsockopen($posturl, 443, $errno, $errstr, 30);
|
804 |
-
if (!$fp)
|
805 |
-
{
|
806 |
-
$response = false;
|
807 |
-
}
|
808 |
-
else
|
809 |
-
{
|
810 |
-
error_reporting(E_ERROR);
|
811 |
-
fputs($fp, "POST $path HTTP/1.1\r\n");
|
812 |
-
fputs($fp, $header.$content);
|
813 |
-
fwrite($fp, $out);
|
814 |
-
$response = "";
|
815 |
-
while (!feof($fp))
|
816 |
-
{
|
817 |
-
$response = $response . fgets($fp, 128);
|
818 |
-
}
|
819 |
-
fclose($fp);
|
820 |
-
error_reporting(E_ALL ^ E_NOTICE);
|
821 |
-
}
|
822 |
-
return $response;
|
823 |
-
}
|
824 |
-
|
825 |
-
//Authorize.net Function
|
826 |
-
//function to send xml request via curl
|
827 |
-
function send_request_via_curl($host,$path,$content)
|
828 |
-
{
|
829 |
-
$posturl = "https://" . $host . $path;
|
830 |
-
$posturl = apply_filters("pmpro_authorizenet_post_url", $posturl, pmpro_getOption("gateway_environment"));
|
831 |
-
$ch = curl_init();
|
832 |
-
curl_setopt($ch, CURLOPT_URL, $posturl);
|
833 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
834 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
|
835 |
-
curl_setopt($ch, CURLOPT_HEADER, 1);
|
836 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
837 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
838 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
839 |
-
$response = curl_exec($ch);
|
840 |
-
return $response;
|
841 |
-
}
|
842 |
-
|
843 |
-
|
844 |
-
//Authorize.net Function
|
845 |
-
//function to parse Authorize.net response
|
846 |
-
function parse_return($content)
|
847 |
-
{
|
848 |
-
$refId = $this->substring_between($content,'<refId>','</refId>');
|
849 |
-
$resultCode = $this->substring_between($content,'<resultCode>','</resultCode>');
|
850 |
-
$code = $this->substring_between($content,'<code>','</code>');
|
851 |
-
$text = $this->substring_between($content,'<text>','</text>');
|
852 |
-
$subscriptionId = $this->substring_between($content,'<subscriptionId>','</subscriptionId>');
|
853 |
-
return array ($refId, $resultCode, $code, $text, $subscriptionId);
|
854 |
-
}
|
855 |
-
|
856 |
-
//Authorize.net Function
|
857 |
-
//helper function for parsing response
|
858 |
-
function substring_between($haystack,$start,$end)
|
859 |
-
{
|
860 |
-
if (strpos($haystack,$start) === false || strpos($haystack,$end) === false)
|
861 |
-
{
|
862 |
-
return false;
|
863 |
-
}
|
864 |
-
else
|
865 |
-
{
|
866 |
-
$start_position = strpos($haystack,$start)+strlen($start);
|
867 |
-
$end_position = strpos($haystack,$end);
|
868 |
-
return substr($haystack,$start_position,$end_position-$start_position);
|
869 |
-
}
|
870 |
-
}
|
871 |
-
}
|
872 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_braintree.php
DELETED
@@ -1,422 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
if(!class_exists("Braintree"))
|
4 |
-
require_once(dirname(__FILE__) . "/../../includes/lib/Braintree/Braintree.php");
|
5 |
-
class PMProGateway_braintree
|
6 |
-
{
|
7 |
-
function PMProGateway_braintree($gateway = NULL)
|
8 |
-
{
|
9 |
-
$this->gateway = $gateway;
|
10 |
-
$this->gateway_environment = pmpro_getOption("gateway_environment");
|
11 |
-
|
12 |
-
//convert to braintree nomenclature
|
13 |
-
$environment = $this->gateway_environment;
|
14 |
-
if($environment == "live")
|
15 |
-
$environment = "production";
|
16 |
-
|
17 |
-
Braintree_Configuration::environment($environment);
|
18 |
-
Braintree_Configuration::merchantId(pmpro_getOption("braintree_merchantid"));
|
19 |
-
Braintree_Configuration::publicKey(pmpro_getOption("braintree_publickey"));
|
20 |
-
Braintree_Configuration::privateKey(pmpro_getOption("braintree_privatekey"));
|
21 |
-
|
22 |
-
return $this->gateway;
|
23 |
-
}
|
24 |
-
|
25 |
-
function process(&$order)
|
26 |
-
{
|
27 |
-
//check for initial payment
|
28 |
-
if(floatval($order->InitialPayment) == 0)
|
29 |
-
{
|
30 |
-
//just subscribe
|
31 |
-
return $this->subscribe($order);
|
32 |
-
}
|
33 |
-
else
|
34 |
-
{
|
35 |
-
//charge then subscribe
|
36 |
-
if($this->charge($order))
|
37 |
-
{
|
38 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
39 |
-
{
|
40 |
-
if($this->subscribe($order))
|
41 |
-
{
|
42 |
-
//yay!
|
43 |
-
return true;
|
44 |
-
}
|
45 |
-
else
|
46 |
-
{
|
47 |
-
//try to refund initial charge
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
else
|
52 |
-
{
|
53 |
-
//only a one time charge
|
54 |
-
$order->status = "success"; //saved on checkout page
|
55 |
-
return true;
|
56 |
-
}
|
57 |
-
}
|
58 |
-
else
|
59 |
-
{
|
60 |
-
if(empty($order->error))
|
61 |
-
$order->error = __("Unknown error: Initial payment failed.", "pmpro");
|
62 |
-
return false;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
function charge(&$order)
|
68 |
-
{
|
69 |
-
//create a code for the order
|
70 |
-
if(empty($order->code))
|
71 |
-
$order->code = $order->getRandomCode();
|
72 |
-
|
73 |
-
//what amount to charge?
|
74 |
-
$amount = $order->InitialPayment;
|
75 |
-
|
76 |
-
//tax
|
77 |
-
$order->subtotal = $amount;
|
78 |
-
$tax = $order->getTax(true);
|
79 |
-
$amount = round((float)$order->subtotal + (float)$tax, 2);
|
80 |
-
|
81 |
-
//create a customer
|
82 |
-
$this->getCustomer($order);
|
83 |
-
if(empty($this->customer))
|
84 |
-
{
|
85 |
-
//failed to create customer
|
86 |
-
return false;
|
87 |
-
}
|
88 |
-
|
89 |
-
//charge
|
90 |
-
try
|
91 |
-
{
|
92 |
-
$response = Braintree_Transaction::sale(array(
|
93 |
-
'amount' => $amount,
|
94 |
-
'customerId' => $this->customer->id
|
95 |
-
));
|
96 |
-
}
|
97 |
-
catch (Exception $e)
|
98 |
-
{
|
99 |
-
//$order->status = "error";
|
100 |
-
$order->errorcode = true;
|
101 |
-
$order->error = "Error: " . $e->getMessage();
|
102 |
-
$order->shorterror = $order->error;
|
103 |
-
return false;
|
104 |
-
}
|
105 |
-
|
106 |
-
if($response->success)
|
107 |
-
{
|
108 |
-
//successful charge
|
109 |
-
$transaction_id = $response->transaction->id;
|
110 |
-
$response = Braintree_Transaction::submitForSettlement($transaction_id);
|
111 |
-
if($response->success)
|
112 |
-
{
|
113 |
-
$order->payment_transaction_id = $transaction_id;
|
114 |
-
$order->updateStatus("success");
|
115 |
-
return true;
|
116 |
-
}
|
117 |
-
else
|
118 |
-
{
|
119 |
-
$order->errorcode = true;
|
120 |
-
$order->error = __("Error during settlement:", "pmpro") . " " . $response->message;
|
121 |
-
$order->shorterror = $response->message;
|
122 |
-
return false;
|
123 |
-
}
|
124 |
-
}
|
125 |
-
else
|
126 |
-
{
|
127 |
-
//$order->status = "error";
|
128 |
-
$order->errorcode = true;
|
129 |
-
$order->error = __("Error during charge:", "pmpro") . " " . $response->message;
|
130 |
-
$order->shorterror = $response->message;
|
131 |
-
return false;
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
/*
|
136 |
-
This function will return a Braintree customer object.
|
137 |
-
If $this->customer is set, it returns it.
|
138 |
-
It first checks if the order has a subscription_transaction_id. If so, that's the customer id.
|
139 |
-
If not, it checks for a user_id on the order and searches for a customer id in the user meta.
|
140 |
-
If a customer id is found, it checks for a customer through the Braintree API.
|
141 |
-
If a customer is found and there is an AccountNumber on the order passed, it will update the customer.
|
142 |
-
If no customer is found and there is an AccountNumber on the order passed, it will create a customer.
|
143 |
-
*/
|
144 |
-
function getCustomer(&$order, $force = false)
|
145 |
-
{
|
146 |
-
global $current_user;
|
147 |
-
|
148 |
-
//already have it?
|
149 |
-
if(!empty($this->customer) && !$force)
|
150 |
-
return $this->customer;
|
151 |
-
|
152 |
-
//try based on user id
|
153 |
-
if(!empty($order->user_id))
|
154 |
-
$user_id = $order->user_id;
|
155 |
-
|
156 |
-
//if no id passed, check the current user
|
157 |
-
if(empty($user_id) && !empty($current_user->ID))
|
158 |
-
$user_id = $current_user->ID;
|
159 |
-
|
160 |
-
//check for a braintree customer id
|
161 |
-
if(!empty($user_id))
|
162 |
-
{
|
163 |
-
$customer_id = get_user_meta($user_id, "pmpro_braintree_customerid", true);
|
164 |
-
}
|
165 |
-
|
166 |
-
//check for an existing stripe customer
|
167 |
-
if(!empty($customer_id))
|
168 |
-
{
|
169 |
-
try
|
170 |
-
{
|
171 |
-
$this->customer = Braintree_Customer::find($customer_id);
|
172 |
-
|
173 |
-
//update the customer description and card
|
174 |
-
if(!empty($order->accountnumber))
|
175 |
-
{
|
176 |
-
$response = Braintree_Customer::update(
|
177 |
-
$customer_id,
|
178 |
-
array(
|
179 |
-
'firstName' => $order->FirstName,
|
180 |
-
'lastName' => $order->LastName,
|
181 |
-
'creditCard' => array(
|
182 |
-
'number' => $order->braintree->number,
|
183 |
-
'expirationDate' => $order->braintree->expiration_date,
|
184 |
-
'cardholderName' => trim($order->FirstName . " " . $order->LastName),
|
185 |
-
'options' => array(
|
186 |
-
'updateExistingToken' => $this->customer->creditCards[0]->token
|
187 |
-
)
|
188 |
-
)
|
189 |
-
)
|
190 |
-
);
|
191 |
-
|
192 |
-
if($response->success)
|
193 |
-
{
|
194 |
-
$this->customer = $response->customer;
|
195 |
-
}
|
196 |
-
else
|
197 |
-
{
|
198 |
-
$order->error = __("Failed to update customer.", "pmpro") . " " . $response->message;
|
199 |
-
$order->shorterror = $order->error;
|
200 |
-
return false;
|
201 |
-
}
|
202 |
-
}
|
203 |
-
|
204 |
-
return $this->customer;
|
205 |
-
}
|
206 |
-
catch (Exception $e)
|
207 |
-
{
|
208 |
-
//assume no customer found
|
209 |
-
}
|
210 |
-
}
|
211 |
-
|
212 |
-
//no customer id, create one
|
213 |
-
if(!empty($order->accountnumber))
|
214 |
-
{
|
215 |
-
try
|
216 |
-
{
|
217 |
-
$result = Braintree_Customer::create(array(
|
218 |
-
'firstName' => $order->FirstName,
|
219 |
-
'lastName' => $order->LastName,
|
220 |
-
'email' => $order->Email,
|
221 |
-
'phone' => $order->billing->phone,
|
222 |
-
'creditCard' => array(
|
223 |
-
'number' => $order->braintree->number,
|
224 |
-
'expirationDate' => $order->braintree->expiration_date,
|
225 |
-
'cvv' => $order->braintree->cvv,
|
226 |
-
'cardholderName' => trim($order->FirstName . " " . $order->LastName),
|
227 |
-
'billingAddress' => array(
|
228 |
-
'firstName' => $order->FirstName,
|
229 |
-
'lastName' => $order->LastName,
|
230 |
-
'streetAddress' => $order->Address1,
|
231 |
-
'extendedAddress' => $order->Address2,
|
232 |
-
'locality' => $order->billing->city,
|
233 |
-
'region' => $order->billing->state,
|
234 |
-
'postalCode' => $order->billing->zip,
|
235 |
-
'countryCodeAlpha2' => $order->billing->country
|
236 |
-
)
|
237 |
-
)
|
238 |
-
));
|
239 |
-
|
240 |
-
if($result->success)
|
241 |
-
{
|
242 |
-
$this->customer = $result->customer;
|
243 |
-
}
|
244 |
-
else
|
245 |
-
{
|
246 |
-
$order->error = __("Failed to create customer.", "pmpro") . " " . $result->message;
|
247 |
-
$order->shorterror = $order->error;
|
248 |
-
return false;
|
249 |
-
}
|
250 |
-
}
|
251 |
-
catch (Exception $e)
|
252 |
-
{
|
253 |
-
$order->error = __("Error creating customer record with Braintree:", "pmpro") . " " . $e->getMessage();
|
254 |
-
$order->shorterror = $order->error;
|
255 |
-
return false;
|
256 |
-
}
|
257 |
-
|
258 |
-
update_user_meta($user_id, "pmpro_braintree_customerid", $this->customer->id);
|
259 |
-
return $this->customer;
|
260 |
-
}
|
261 |
-
|
262 |
-
return false;
|
263 |
-
}
|
264 |
-
|
265 |
-
function subscribe(&$order)
|
266 |
-
{
|
267 |
-
//create a code for the order
|
268 |
-
if(empty($order->code))
|
269 |
-
$order->code = $order->getRandomCode();
|
270 |
-
|
271 |
-
//setup customer
|
272 |
-
$this->getCustomer($order);
|
273 |
-
if(empty($this->customer))
|
274 |
-
return false; //error retrieving customer
|
275 |
-
|
276 |
-
//figure out the amounts
|
277 |
-
$amount = $order->PaymentAmount;
|
278 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
279 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
280 |
-
|
281 |
-
/*
|
282 |
-
There are two parts to the trial. Part 1 is simply the delay until the first payment
|
283 |
-
since we are doing the first payment as a separate transaction.
|
284 |
-
The second part is the actual "trial" set by the admin.
|
285 |
-
|
286 |
-
Stripe only supports Year or Month for billing periods, but we account for Days and Weeks just in case.
|
287 |
-
*/
|
288 |
-
//figure out the trial length (first payment handled by initial charge)
|
289 |
-
if($order->BillingPeriod == "Year")
|
290 |
-
$trial_period_days = $order->BillingFrequency * 365; //annual
|
291 |
-
elseif($order->BillingPeriod == "Day")
|
292 |
-
$trial_period_days = $order->BillingFrequency * 1; //daily
|
293 |
-
elseif($order->BillingPeriod == "Week")
|
294 |
-
$trial_period_days = $order->BillingFrequency * 7; //weekly
|
295 |
-
else
|
296 |
-
$trial_period_days = $order->BillingFrequency * 30; //assume monthly
|
297 |
-
|
298 |
-
//convert to a profile start date
|
299 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $trial_period_days . " Day", current_time("timestamp"))) . "T0:0:0";
|
300 |
-
|
301 |
-
//filter the start date
|
302 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
303 |
-
|
304 |
-
//convert back to days
|
305 |
-
$trial_period_days = ceil(abs(strtotime(date("Y-m-d")) - strtotime($order->ProfileStartDate, current_time("timestamp"))) / 86400);
|
306 |
-
|
307 |
-
//now add the actual trial set by the site
|
308 |
-
if(!empty($order->TrialBillingCycles))
|
309 |
-
{
|
310 |
-
$trialOccurrences = (int)$order->TrialBillingCycles;
|
311 |
-
if($order->BillingPeriod == "Year")
|
312 |
-
$trial_period_days = $trial_period_days + (365 * $order->BillingFrequency * $trialOccurrences); //annual
|
313 |
-
elseif($order->BillingPeriod == "Day")
|
314 |
-
$trial_period_days = $trial_period_days + (1 * $order->BillingFrequency * $trialOccurrences); //daily
|
315 |
-
elseif($order->BillingPeriod == "Week")
|
316 |
-
$trial_period_days = $trial_period_days + (7 * $order->BillingFrequency * $trialOccurrences); //weekly
|
317 |
-
else
|
318 |
-
$trial_period_days = $trial_period_days + (30 * $order->BillingFrequency * $trialOccurrences); //assume monthly
|
319 |
-
}
|
320 |
-
|
321 |
-
//subscribe to the plan
|
322 |
-
try
|
323 |
-
{
|
324 |
-
$details = array(
|
325 |
-
'paymentMethodToken' => $this->customer->creditCards[0]->token,
|
326 |
-
'planId' => 'pmpro_' . $order->membership_id,
|
327 |
-
'price' => $amount
|
328 |
-
);
|
329 |
-
|
330 |
-
if(!empty($trial_period_days))
|
331 |
-
{
|
332 |
-
$details['trialPeriod'] = true;
|
333 |
-
$details['trialDuration'] = $trial_period_days;
|
334 |
-
$details['trialDurationUnit'] = "day";
|
335 |
-
}
|
336 |
-
|
337 |
-
if(!empty($order->TotalBillingCycles))
|
338 |
-
$details['numberOfBillingCycles'] = $order->TotalBillingCycles;
|
339 |
-
|
340 |
-
$result = Braintree_Subscription::create($details);
|
341 |
-
}
|
342 |
-
catch (Exception $e)
|
343 |
-
{
|
344 |
-
$order->error = __("Error subscribing customer to plan with Braintree:", "pmpro") . " " . $e->getMessage();
|
345 |
-
//return error
|
346 |
-
$order->shorterror = $order->error;
|
347 |
-
return false;
|
348 |
-
}
|
349 |
-
|
350 |
-
if($result->success)
|
351 |
-
{
|
352 |
-
//if we got this far, we're all good
|
353 |
-
$order->status = "success";
|
354 |
-
$order->subscription_transaction_id = $result->subscription->id;
|
355 |
-
return true;
|
356 |
-
}
|
357 |
-
else
|
358 |
-
{
|
359 |
-
$order->error = __("Failed to subscribe with Braintree:", "pmpro") . " " . $result->message;
|
360 |
-
$order->shorterror = $result->message;
|
361 |
-
return false;
|
362 |
-
}
|
363 |
-
}
|
364 |
-
|
365 |
-
function update(&$order)
|
366 |
-
{
|
367 |
-
//we just have to run getCustomer which will look for the customer and update it with the new token
|
368 |
-
$this->getCustomer($order);
|
369 |
-
|
370 |
-
if(!empty($this->customer) && empty($order->error))
|
371 |
-
{
|
372 |
-
return true;
|
373 |
-
}
|
374 |
-
else
|
375 |
-
{
|
376 |
-
return false; //couldn't find the customer
|
377 |
-
}
|
378 |
-
}
|
379 |
-
|
380 |
-
function cancel(&$order)
|
381 |
-
{
|
382 |
-
//require a subscription id
|
383 |
-
if(empty($order->subscription_transaction_id))
|
384 |
-
return false;
|
385 |
-
|
386 |
-
//find the customer
|
387 |
-
if(!empty($order->subscription_transaction_id))
|
388 |
-
{
|
389 |
-
//cancel
|
390 |
-
try
|
391 |
-
{
|
392 |
-
$result = Braintree_Subscription::cancel($order->subscription_transaction_id);
|
393 |
-
}
|
394 |
-
catch(Exception $e)
|
395 |
-
{
|
396 |
-
$order->updateStatus("cancelled"); //assume it's been cancelled already
|
397 |
-
$order->error = __("Could not find the subscription.", "pmpro") . " " . $e->getMessage();
|
398 |
-
$order->shorterror = $order->error;
|
399 |
-
return false; //no subscription found
|
400 |
-
}
|
401 |
-
|
402 |
-
if($result->success)
|
403 |
-
{
|
404 |
-
$order->updateStatus("cancelled");
|
405 |
-
return true;
|
406 |
-
}
|
407 |
-
else
|
408 |
-
{
|
409 |
-
$order->updateStatus("cancelled"); //assume it's been cancelled already
|
410 |
-
$order->error = __("Could not find the subscription.", "pmpro") . " " . $result->message;
|
411 |
-
$order->shorterror = $order->error;
|
412 |
-
return false; //no subscription found
|
413 |
-
}
|
414 |
-
}
|
415 |
-
else
|
416 |
-
{
|
417 |
-
$order->error = __("Could not find the subscription.", "pmpro");
|
418 |
-
$order->shorterror = $order->error;
|
419 |
-
return false; //no customer found
|
420 |
-
}
|
421 |
-
}
|
422 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_check.php
DELETED
@@ -1,208 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
class PMProGateway_check
|
4 |
-
{
|
5 |
-
function PMProGateway_check($gateway = NULL)
|
6 |
-
{
|
7 |
-
$this->gateway = $gateway;
|
8 |
-
return $this->gateway;
|
9 |
-
}
|
10 |
-
|
11 |
-
function process(&$order)
|
12 |
-
{
|
13 |
-
//clean up a couple values
|
14 |
-
$order->payment_type = "Check";
|
15 |
-
$order->CardType = "";
|
16 |
-
$order->cardtype = "";
|
17 |
-
|
18 |
-
//check for initial payment
|
19 |
-
if(floatval($order->InitialPayment) == 0)
|
20 |
-
{
|
21 |
-
//auth first, then process
|
22 |
-
if($this->authorize($order))
|
23 |
-
{
|
24 |
-
$this->void($order);
|
25 |
-
if(!pmpro_isLevelTrial($order->membership_level))
|
26 |
-
{
|
27 |
-
//subscription will start today with a 1 period trial
|
28 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
29 |
-
$order->TrialBillingPeriod = $order->BillingPeriod;
|
30 |
-
$order->TrialBillingFrequency = $order->BillingFrequency;
|
31 |
-
$order->TrialBillingCycles = 1;
|
32 |
-
$order->TrialAmount = 0;
|
33 |
-
|
34 |
-
//add a billing cycle to make up for the trial, if applicable
|
35 |
-
if(!empty($order->TotalBillingCycles))
|
36 |
-
$order->TotalBillingCycles++;
|
37 |
-
}
|
38 |
-
elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
|
39 |
-
{
|
40 |
-
//it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
|
41 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
42 |
-
$order->TrialBillingCycles++;
|
43 |
-
|
44 |
-
//add a billing cycle to make up for the trial, if applicable
|
45 |
-
if($order->TotalBillingCycles)
|
46 |
-
$order->TotalBillingCycles++;
|
47 |
-
}
|
48 |
-
else
|
49 |
-
{
|
50 |
-
//add a period to the start date to account for the initial payment
|
51 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
52 |
-
}
|
53 |
-
|
54 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
55 |
-
return $this->subscribe($order);
|
56 |
-
}
|
57 |
-
else
|
58 |
-
{
|
59 |
-
if(empty($order->error))
|
60 |
-
$order->error = __("Unknown error: Authorization failed.", "pmpro");
|
61 |
-
return false;
|
62 |
-
}
|
63 |
-
}
|
64 |
-
else
|
65 |
-
{
|
66 |
-
//charge first payment
|
67 |
-
if($this->charge($order))
|
68 |
-
{
|
69 |
-
//setup recurring billing
|
70 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
71 |
-
{
|
72 |
-
if(!pmpro_isLevelTrial($order->membership_level))
|
73 |
-
{
|
74 |
-
//subscription will start today with a 1 period trial
|
75 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
76 |
-
$order->TrialBillingPeriod = $order->BillingPeriod;
|
77 |
-
$order->TrialBillingFrequency = $order->BillingFrequency;
|
78 |
-
$order->TrialBillingCycles = 1;
|
79 |
-
$order->TrialAmount = 0;
|
80 |
-
|
81 |
-
//add a billing cycle to make up for the trial, if applicable
|
82 |
-
if(!empty($order->TotalBillingCycles))
|
83 |
-
$order->TotalBillingCycles++;
|
84 |
-
}
|
85 |
-
elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
|
86 |
-
{
|
87 |
-
//it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
|
88 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
89 |
-
$order->TrialBillingCycles++;
|
90 |
-
|
91 |
-
//add a billing cycle to make up for the trial, if applicable
|
92 |
-
if(!empty($order->TotalBillingCycles))
|
93 |
-
$order->TotalBillingCycles++;
|
94 |
-
}
|
95 |
-
else
|
96 |
-
{
|
97 |
-
//add a period to the start date to account for the initial payment
|
98 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $this->BillingFrequency . " " . $this->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
99 |
-
}
|
100 |
-
|
101 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
102 |
-
if($this->subscribe($order))
|
103 |
-
{
|
104 |
-
return true;
|
105 |
-
}
|
106 |
-
else
|
107 |
-
{
|
108 |
-
if($this->void($order))
|
109 |
-
{
|
110 |
-
if(!$order->error)
|
111 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
112 |
-
}
|
113 |
-
else
|
114 |
-
{
|
115 |
-
if(!$order->error)
|
116 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
117 |
-
|
118 |
-
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", "pmpro");
|
119 |
-
}
|
120 |
-
|
121 |
-
return false;
|
122 |
-
}
|
123 |
-
}
|
124 |
-
else
|
125 |
-
{
|
126 |
-
//only a one time charge
|
127 |
-
$order->status = apply_filters("pmpro_check_status_after_checkout", "success"); //saved on checkout page
|
128 |
-
return true;
|
129 |
-
}
|
130 |
-
}
|
131 |
-
else
|
132 |
-
{
|
133 |
-
if(empty($order->error))
|
134 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
135 |
-
|
136 |
-
return false;
|
137 |
-
}
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
function authorize(&$order)
|
142 |
-
{
|
143 |
-
//create a code for the order
|
144 |
-
if(empty($order->code))
|
145 |
-
$order->code = $order->getRandomCode();
|
146 |
-
|
147 |
-
//simulate a successful authorization
|
148 |
-
$order->payment_transaction_id = "CHECK" . $order->code;
|
149 |
-
$order->updateStatus("authorized");
|
150 |
-
return true;
|
151 |
-
}
|
152 |
-
|
153 |
-
function void(&$order)
|
154 |
-
{
|
155 |
-
//need a transaction id
|
156 |
-
if(empty($order->payment_transaction_id))
|
157 |
-
return false;
|
158 |
-
|
159 |
-
//simulate a successful void
|
160 |
-
$order->payment_transaction_id = "CHECK" . $order->code;
|
161 |
-
$order->updateStatus("voided");
|
162 |
-
return true;
|
163 |
-
}
|
164 |
-
|
165 |
-
function charge(&$order)
|
166 |
-
{
|
167 |
-
//create a code for the order
|
168 |
-
if(empty($order->code))
|
169 |
-
$order->code = $order->getRandomCode();
|
170 |
-
|
171 |
-
//simulate a successful charge
|
172 |
-
$order->payment_transaction_id = "CHECK" . $order->code;
|
173 |
-
$order->updateStatus("success");
|
174 |
-
return true;
|
175 |
-
}
|
176 |
-
|
177 |
-
function subscribe(&$order)
|
178 |
-
{
|
179 |
-
//create a code for the order
|
180 |
-
if(empty($order->code))
|
181 |
-
$order->code = $order->getRandomCode();
|
182 |
-
|
183 |
-
//filter order before subscription. use with care.
|
184 |
-
$order = apply_filters("pmpro_subscribe_order", $order, $this);
|
185 |
-
|
186 |
-
//simulate a successful subscription processing
|
187 |
-
$order->status = "success";
|
188 |
-
$order->subscription_transaction_id = "CHECK" . $order->code;
|
189 |
-
return true;
|
190 |
-
}
|
191 |
-
|
192 |
-
function update(&$order)
|
193 |
-
{
|
194 |
-
//simulate a successful billing update
|
195 |
-
return true;
|
196 |
-
}
|
197 |
-
|
198 |
-
function cancel(&$order)
|
199 |
-
{
|
200 |
-
//require a subscription id
|
201 |
-
if(empty($order->subscription_transaction_id))
|
202 |
-
return false;
|
203 |
-
|
204 |
-
//simulate a successful cancel
|
205 |
-
$order->updateStatus("cancelled");
|
206 |
-
return true;
|
207 |
-
}
|
208 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_cybersource.php
DELETED
@@ -1,765 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
if(!class_exists("CyberSourceSoapClient"))
|
4 |
-
require_once(dirname(__FILE__) . "/../../includes/lib/CyberSource/cyber_source_soap_client.php");
|
5 |
-
class PMProGateway_cybersource
|
6 |
-
{
|
7 |
-
function PMProGateway_cybersource($gateway = NULL)
|
8 |
-
{
|
9 |
-
$this->gateway = $gateway;
|
10 |
-
return $this->gateway;
|
11 |
-
}
|
12 |
-
|
13 |
-
function process(&$order)
|
14 |
-
{
|
15 |
-
//check for initial payment
|
16 |
-
if(floatval($order->InitialPayment) == 0)
|
17 |
-
{
|
18 |
-
//auth first, then process
|
19 |
-
if($this->authorize($order))
|
20 |
-
{
|
21 |
-
$this->void($order);
|
22 |
-
if(!pmpro_isLevelTrial($order->membership_level))
|
23 |
-
{
|
24 |
-
//subscription will start today with a 1 period trial
|
25 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
26 |
-
$order->TrialBillingPeriod = $order->BillingPeriod;
|
27 |
-
$order->TrialBillingFrequency = $order->BillingFrequency;
|
28 |
-
$order->TrialBillingCycles = 1;
|
29 |
-
$order->TrialAmount = 0;
|
30 |
-
|
31 |
-
//add a billing cycle to make up for the trial, if applicable
|
32 |
-
if(!empty($order->TotalBillingCycles))
|
33 |
-
$order->TotalBillingCycles++;
|
34 |
-
}
|
35 |
-
elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
|
36 |
-
{
|
37 |
-
//it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
|
38 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
39 |
-
$order->TrialBillingCycles++;
|
40 |
-
|
41 |
-
//add a billing cycle to make up for the trial, if applicable
|
42 |
-
if($order->TotalBillingCycles)
|
43 |
-
$order->TotalBillingCycles++;
|
44 |
-
}
|
45 |
-
else
|
46 |
-
{
|
47 |
-
//add a period to the start date to account for the initial payment
|
48 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
49 |
-
}
|
50 |
-
|
51 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
52 |
-
return $this->subscribe($order);
|
53 |
-
}
|
54 |
-
else
|
55 |
-
{
|
56 |
-
if(empty($order->error))
|
57 |
-
$order->error = __("Unknown error: Authorization failed.", "pmpro");
|
58 |
-
return false;
|
59 |
-
}
|
60 |
-
}
|
61 |
-
else
|
62 |
-
{
|
63 |
-
//charge first payment
|
64 |
-
if($this->charge($order))
|
65 |
-
{
|
66 |
-
//setup recurring billing
|
67 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
68 |
-
{
|
69 |
-
if(!pmpro_isLevelTrial($order->membership_level))
|
70 |
-
{
|
71 |
-
//subscription will start today with a 1 period trial
|
72 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
73 |
-
$order->TrialBillingPeriod = $order->BillingPeriod;
|
74 |
-
$order->TrialBillingFrequency = $order->BillingFrequency;
|
75 |
-
$order->TrialBillingCycles = 1;
|
76 |
-
$order->TrialAmount = 0;
|
77 |
-
|
78 |
-
//add a billing cycle to make up for the trial, if applicable
|
79 |
-
if(!empty($order->TotalBillingCycles))
|
80 |
-
$order->TotalBillingCycles++;
|
81 |
-
}
|
82 |
-
elseif($order->InitialPayment == 0 && $order->TrialAmount == 0)
|
83 |
-
{
|
84 |
-
//it has a trial, but the amount is the same as the initial payment, so we can squeeze it in there
|
85 |
-
$order->ProfileStartDate = date("Y-m-d") . "T0:0:0";
|
86 |
-
$order->TrialBillingCycles++;
|
87 |
-
|
88 |
-
//add a billing cycle to make up for the trial, if applicable
|
89 |
-
if(!empty($order->TotalBillingCycles))
|
90 |
-
$order->TotalBillingCycles++;
|
91 |
-
}
|
92 |
-
else
|
93 |
-
{
|
94 |
-
//add a period to the start date to account for the initial payment
|
95 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $this->BillingFrequency . " " . $this->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
96 |
-
}
|
97 |
-
|
98 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
99 |
-
if($this->subscribe($order))
|
100 |
-
{
|
101 |
-
return true;
|
102 |
-
}
|
103 |
-
else
|
104 |
-
{
|
105 |
-
if($this->void($order))
|
106 |
-
{
|
107 |
-
if(!$order->error)
|
108 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
109 |
-
}
|
110 |
-
else
|
111 |
-
{
|
112 |
-
if(!$order->error)
|
113 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
114 |
-
|
115 |
-
$order->error .= " " . __("A partial payment was made that we could not void. Please contact the site owner immediately to correct this.", "pmpro");
|
116 |
-
}
|
117 |
-
|
118 |
-
return false;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
else
|
122 |
-
{
|
123 |
-
//only a one time charge
|
124 |
-
$order->status = "success"; //saved on checkout page
|
125 |
-
return true;
|
126 |
-
}
|
127 |
-
}
|
128 |
-
else
|
129 |
-
{
|
130 |
-
if(empty($order->error))
|
131 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
132 |
-
|
133 |
-
return false;
|
134 |
-
}
|
135 |
-
}
|
136 |
-
}
|
137 |
-
|
138 |
-
function getCardType($name)
|
139 |
-
{
|
140 |
-
$card_types = array(
|
141 |
-
'Visa' => '001',
|
142 |
-
'MasterCard' => '002',
|
143 |
-
'Master Card' => '002',
|
144 |
-
'AMEX' => '003',
|
145 |
-
'American Express' => '003',
|
146 |
-
'Discover' => '004',
|
147 |
-
'Diners Club' => '005',
|
148 |
-
'Carte Blanche' => '006',
|
149 |
-
'JCB' => '007'
|
150 |
-
);
|
151 |
-
|
152 |
-
if(isset($card_types[$name]))
|
153 |
-
return $card_types[$name];
|
154 |
-
else
|
155 |
-
return false;
|
156 |
-
}
|
157 |
-
|
158 |
-
function getWSDL($order)
|
159 |
-
{
|
160 |
-
//which gateway environment?
|
161 |
-
if(empty($order->gateway_environment))
|
162 |
-
$gateway_environment = pmpro_getOption("gateway_environment");
|
163 |
-
else
|
164 |
-
$gateway_environment = $order->gateway_environment;
|
165 |
-
|
166 |
-
//which host?
|
167 |
-
if($gateway_environment == "live")
|
168 |
-
$host = "ics2ws.ic3.com";
|
169 |
-
else
|
170 |
-
$host = "ics2wstest.ic3.com";
|
171 |
-
|
172 |
-
//path
|
173 |
-
$path = "/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.90.wsdl";
|
174 |
-
|
175 |
-
//build url
|
176 |
-
$wsdl_url = "https://" . $host . $path;
|
177 |
-
|
178 |
-
//filter
|
179 |
-
$wsdl_url = apply_filters("pmpro_cybersource_wsdl_url", $wsdl_url, $gateway_environment);
|
180 |
-
|
181 |
-
return $wsdl_url;
|
182 |
-
}
|
183 |
-
|
184 |
-
function authorize(&$order)
|
185 |
-
{
|
186 |
-
if(empty($order->code))
|
187 |
-
$order->code = $order->getRandomCode();
|
188 |
-
|
189 |
-
$wsdl_url = $this->getWSDL($order);
|
190 |
-
|
191 |
-
//what amount to authorize? just $1 to test
|
192 |
-
$amount = "1.00";
|
193 |
-
|
194 |
-
//combine address
|
195 |
-
$address = $order->Address1;
|
196 |
-
if(!empty($order->Address2))
|
197 |
-
$address .= "\n" . $order->Address2;
|
198 |
-
|
199 |
-
//customer stuff
|
200 |
-
$customer_email = $order->Email;
|
201 |
-
$customer_phone = $order->billing->phone;
|
202 |
-
|
203 |
-
if(!isset($order->membership_level->name))
|
204 |
-
$order->membership_level->name = "";
|
205 |
-
|
206 |
-
//to store our request
|
207 |
-
$request = new stdClass();
|
208 |
-
|
209 |
-
//which service?
|
210 |
-
$ccAuthService = new stdClass();
|
211 |
-
$ccAuthService->run = "true";
|
212 |
-
$request->ccAuthService = $ccAuthService;
|
213 |
-
|
214 |
-
//merchant id and order code
|
215 |
-
$request->merchantID = pmpro_getOption("cybersource_merchantid");
|
216 |
-
$request->merchantReferenceCode = $order->code;
|
217 |
-
|
218 |
-
//bill to
|
219 |
-
$billTo = new stdClass();
|
220 |
-
$billTo->firstName = $order->FirstName;
|
221 |
-
$billTo->lastName = $order->LastName;
|
222 |
-
$billTo->street1 = $address;
|
223 |
-
$billTo->city = $order->billing->city;
|
224 |
-
$billTo->state = $order->billing->state;
|
225 |
-
$billTo->postalCode = $order->billing->zip;
|
226 |
-
$billTo->country = $order->billing->country;
|
227 |
-
$billTo->email = $order->Email;
|
228 |
-
$billTo->ipAddress = $_SERVER['REMOTE_ADDR'];
|
229 |
-
$request->billTo = $billTo;
|
230 |
-
|
231 |
-
//card
|
232 |
-
$card = new stdClass();
|
233 |
-
$card->cardType = $this->getCardType($order->cardtype);
|
234 |
-
$card->accountNumber = $order->accountnumber;
|
235 |
-
$card->expirationMonth = $order->expirationmonth;
|
236 |
-
$card->expirationYear = $order->expirationyear;
|
237 |
-
$card->cvNumber = $order->CVV2;
|
238 |
-
$request->card = $card;
|
239 |
-
|
240 |
-
//currency
|
241 |
-
$purchaseTotals = new stdClass();
|
242 |
-
$purchaseTotals->currency = pmpro_getOption("currency");
|
243 |
-
$request->purchaseTotals = $purchaseTotals;
|
244 |
-
|
245 |
-
//item/price
|
246 |
-
$item0 = new stdClass();
|
247 |
-
$item0->unitPrice = $amount;
|
248 |
-
$item0->quantity = "1";
|
249 |
-
$item0->productName = $order->membership_level->name . " Membership";
|
250 |
-
$item0->productSKU = $order->membership_level->id;
|
251 |
-
$item0->id = $order->membership_id;
|
252 |
-
$request->item = array($item0);
|
253 |
-
|
254 |
-
$soapClient = new CyberSourceSoapClient($wsdl_url, array("merchantID"=>pmpro_getOption("cybersource_merchantid"), "transactionKey"=>pmpro_getOption("cybersource_securitykey")));
|
255 |
-
$reply = $soapClient->runTransaction($request);
|
256 |
-
|
257 |
-
if($reply->reasonCode == "100")
|
258 |
-
{
|
259 |
-
//success
|
260 |
-
$order->payment_transaction_id = $reply->requestID;
|
261 |
-
$order->updateStatus("authorized");
|
262 |
-
return true;
|
263 |
-
}
|
264 |
-
else
|
265 |
-
{
|
266 |
-
//error
|
267 |
-
$order->errorcode = $reply->reasonCode;
|
268 |
-
$order->error = $this->getErrorFromCode($reply->reasonCode);
|
269 |
-
$order->shorterror = $this->getErrorFromCode($reply->reasonCode);
|
270 |
-
return false;
|
271 |
-
}
|
272 |
-
}
|
273 |
-
|
274 |
-
function void(&$order)
|
275 |
-
{
|
276 |
-
//need a transaction id
|
277 |
-
if(empty($order->payment_transaction_id))
|
278 |
-
return false;
|
279 |
-
|
280 |
-
//get wsdl
|
281 |
-
$wsdl_url = $this->getWSDL($order);
|
282 |
-
|
283 |
-
//to store our request
|
284 |
-
$request = new stdClass();
|
285 |
-
|
286 |
-
//which service?
|
287 |
-
$voidService = new stdClass();
|
288 |
-
$voidService->run = "true";
|
289 |
-
$voidService->voidRequestID = $order->payment_transaction_id;
|
290 |
-
$request->voidService = $voidService;
|
291 |
-
|
292 |
-
//merchant id and order code
|
293 |
-
$request->merchantID = pmpro_getOption("cybersource_merchantid");
|
294 |
-
$request->merchantReferenceCode = $order->code;
|
295 |
-
|
296 |
-
$soapClient = new CyberSourceSoapClient($wsdl_url, array("merchantID"=>pmpro_getOption("cybersource_merchantid"), "transactionKey"=>pmpro_getOption("cybersource_securitykey")));
|
297 |
-
$reply = $soapClient->runTransaction($request);
|
298 |
-
|
299 |
-
if($reply->reasonCode == "100")
|
300 |
-
{
|
301 |
-
//success
|
302 |
-
$order->payment_transaction_id = $reply->requestID;
|
303 |
-
$order->updateStatus("voided");
|
304 |
-
return true;
|
305 |
-
}
|
306 |
-
else
|
307 |
-
{
|
308 |
-
//error
|
309 |
-
$order->errorcode = $reply->reasonCode;
|
310 |
-
$order->error = $this->getErrorFromCode($reply->reasonCode);
|
311 |
-
$order->shorterror = $this->getErrorFromCode($reply->reasonCode);
|
312 |
-
return false;
|
313 |
-
}
|
314 |
-
}
|
315 |
-
|
316 |
-
function charge(&$order)
|
317 |
-
{
|
318 |
-
//get a code
|
319 |
-
if(empty($order->code))
|
320 |
-
$order->code = $order->getRandomCode();
|
321 |
-
|
322 |
-
//get wsdl
|
323 |
-
$wsdl_url = $this->getWSDL($order);
|
324 |
-
|
325 |
-
//what amount to charge?
|
326 |
-
$amount = $order->InitialPayment;
|
327 |
-
|
328 |
-
//tax
|
329 |
-
$order->subtotal = $amount;
|
330 |
-
$tax = $order->getTax(true);
|
331 |
-
$amount = round((float)$order->subtotal + (float)$tax, 2);
|
332 |
-
|
333 |
-
//combine address
|
334 |
-
$address = $order->Address1;
|
335 |
-
if(!empty($order->Address2))
|
336 |
-
$address .= "\n" . $order->Address2;
|
337 |
-
|
338 |
-
//customer stuff
|
339 |
-
$customer_email = $order->Email;
|
340 |
-
$customer_phone = $order->billing->phone;
|
341 |
-
|
342 |
-
if(!isset($order->membership_level->name))
|
343 |
-
$order->membership_level->name = "";
|
344 |
-
|
345 |
-
//to store our request
|
346 |
-
$request = new stdClass();
|
347 |
-
|
348 |
-
//authorize and capture
|
349 |
-
$ccAuthService = new stdClass();
|
350 |
-
$ccAuthService->run = "true";
|
351 |
-
$request->ccAuthService = $ccAuthService;
|
352 |
-
|
353 |
-
$ccCaptureService = new stdClass();
|
354 |
-
$ccCaptureService->run = "true";
|
355 |
-
$request->ccCaptureService = $ccCaptureService;
|
356 |
-
|
357 |
-
//merchant id and order code
|
358 |
-
$request->merchantID = pmpro_getOption("cybersource_merchantid");
|
359 |
-
$request->merchantReferenceCode = $order->code;
|
360 |
-
|
361 |
-
//bill to
|
362 |
-
$billTo = new stdClass();
|
363 |
-
$billTo->firstName = $order->FirstName;
|
364 |
-
$billTo->lastName = $order->LastName;
|
365 |
-
$billTo->street1 = $address;
|
366 |
-
$billTo->city = $order->billing->city;
|
367 |
-
$billTo->state = $order->billing->state;
|
368 |
-
$billTo->postalCode = $order->billing->zip;
|
369 |
-
$billTo->country = $order->billing->country;
|
370 |
-
$billTo->email = $order->Email;
|
371 |
-
$billTo->ipAddress = $_SERVER['REMOTE_ADDR'];
|
372 |
-
$request->billTo = $billTo;
|
373 |
-
|
374 |
-
//card
|
375 |
-
$card = new stdClass();
|
376 |
-
$card->cardType = $this->getCardType($order->cardtype);
|
377 |
-
$card->accountNumber = $order->accountnumber;
|
378 |
-
$card->expirationMonth = $order->expirationmonth;
|
379 |
-
$card->expirationYear = $order->expirationyear;
|
380 |
-
$card->cvNumber = $order->CVV2;
|
381 |
-
$request->card = $card;
|
382 |
-
|
383 |
-
//currency
|
384 |
-
$purchaseTotals = new stdClass();
|
385 |
-
$purchaseTotals->currency = pmpro_getOption("currency");
|
386 |
-
$request->purchaseTotals = $purchaseTotals;
|
387 |
-
|
388 |
-
//item/price
|
389 |
-
$item0 = new stdClass();
|
390 |
-
$item0->unitPrice = $amount;
|
391 |
-
$item0->quantity = "1";
|
392 |
-
$item0->productName = $order->membership_level->name . " Membership";
|
393 |
-
$item0->productSKU = $order->membership_level->id;
|
394 |
-
$item0->id = $order->membership_id;
|
395 |
-
$request->item = array($item0);
|
396 |
-
|
397 |
-
$soapClient = new CyberSourceSoapClient($wsdl_url, array("merchantID"=>pmpro_getOption("cybersource_merchantid"), "transactionKey"=>pmpro_getOption("cybersource_securitykey")));
|
398 |
-
$reply = $soapClient->runTransaction($request);
|
399 |
-
|
400 |
-
if($reply->reasonCode == "100")
|
401 |
-
{
|
402 |
-
//success
|
403 |
-
$order->payment_transaction_id = $reply->requestID;
|
404 |
-
$order->updateStatus("success");
|
405 |
-
return true;
|
406 |
-
}
|
407 |
-
else
|
408 |
-
{
|
409 |
-
//error
|
410 |
-
$order->errorcode = $reply->reasonCode;
|
411 |
-
$order->error = $this->getErrorFromCode($reply->reasonCode);
|
412 |
-
$order->shorterror = $this->getErrorFromCode($reply->reasonCode);
|
413 |
-
return false;
|
414 |
-
}
|
415 |
-
}
|
416 |
-
|
417 |
-
function subscribe(&$order)
|
418 |
-
{
|
419 |
-
//create a code for the order
|
420 |
-
if(empty($order->code))
|
421 |
-
$order->code = $order->getRandomCode();
|
422 |
-
|
423 |
-
//filter order before subscription. use with care.
|
424 |
-
$order = apply_filters("pmpro_subscribe_order", $order, $this);
|
425 |
-
|
426 |
-
//get wsdl
|
427 |
-
$wsdl_url = $this->getWSDL($order);
|
428 |
-
|
429 |
-
//to store our request
|
430 |
-
$request = new stdClass();
|
431 |
-
|
432 |
-
//set service type
|
433 |
-
$paySubscriptionCreateService = new stdClass();
|
434 |
-
$paySubscriptionCreateService->run = 'true';
|
435 |
-
$paySubscriptionCreateService->disableAutoAuth = 'true'; //we do our own auth check
|
436 |
-
$request->paySubscriptionCreateService = $paySubscriptionCreateService;
|
437 |
-
|
438 |
-
//merchant id and order code
|
439 |
-
$request->merchantID = pmpro_getOption("cybersource_merchantid");
|
440 |
-
$request->merchantReferenceCode = $order->code;
|
441 |
-
|
442 |
-
/*
|
443 |
-
setup billing amount/etc
|
444 |
-
*/
|
445 |
-
//figure out the amounts
|
446 |
-
$amount = $order->PaymentAmount;
|
447 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
448 |
-
$order->subtotal = $amount;
|
449 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
450 |
-
|
451 |
-
/*
|
452 |
-
There are two parts to the trial. Part 1 is simply the delay until the first payment
|
453 |
-
since we are doing the first payment as a separate transaction.
|
454 |
-
The second part is the actual "trial" set by the admin.
|
455 |
-
*/
|
456 |
-
//figure out the trial length (first payment handled by initial charge)
|
457 |
-
if($order->BillingPeriod == "Year")
|
458 |
-
$trial_period_days = $order->BillingFrequency * 365; //annual
|
459 |
-
elseif($order->BillingPeriod == "Day")
|
460 |
-
$trial_period_days = $order->BillingFrequency * 1; //daily
|
461 |
-
elseif($order->BillingPeriod == "Week")
|
462 |
-
$trial_period_days = $order->BillingFrequency * 7; //weekly
|
463 |
-
else
|
464 |
-
$trial_period_days = $order->BillingFrequency * 30; //assume monthly
|
465 |
-
|
466 |
-
//convert to a profile start date
|
467 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $trial_period_days . " Day", current_time("timestamp"))) . "T0:0:0";
|
468 |
-
|
469 |
-
//filter the start date
|
470 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
471 |
-
|
472 |
-
//convert back to days
|
473 |
-
$trial_period_days = ceil(abs(strtotime(date("Y-m-d"), current_time('timestamp')) - strtotime($order->ProfileStartDate, current_time("timestamp"))) / 86400);
|
474 |
-
|
475 |
-
//now add the actual trial set by the site
|
476 |
-
if(!empty($order->TrialBillingCycles))
|
477 |
-
{
|
478 |
-
$trialOccurrences = (int)$order->TrialBillingCycles;
|
479 |
-
if($order->BillingPeriod == "Year")
|
480 |
-
$trial_period_days = $trial_period_days + (365 * $order->BillingFrequency * $trialOccurrences); //annual
|
481 |
-
elseif($order->BillingPeriod == "Day")
|
482 |
-
$trial_period_days = $trial_period_days + (1 * $order->BillingFrequency * $trialOccurrences); //daily
|
483 |
-
elseif($order->BillingPeriod == "Week")
|
484 |
-
$trial_period_days = $trial_period_days + (7 * $order->BillingFrequency * $trialOccurrences); //weekly
|
485 |
-
else
|
486 |
-
$trial_period_days = $trial_period_days + (30 * $order->BillingFrequency * $trialOccurrences); //assume monthly
|
487 |
-
}
|
488 |
-
|
489 |
-
//convert back into a date
|
490 |
-
$profile_start_date = date("Ymd", strtotime("+ " . $trial_period_days . " Days"));
|
491 |
-
|
492 |
-
//figure out the frequency
|
493 |
-
if($order->BillingPeriod == "Year")
|
494 |
-
{
|
495 |
-
$frequency = "annually"; //ignoring BillingFrequency set on level.
|
496 |
-
}
|
497 |
-
elseif($order->BillingPeriod == "Month")
|
498 |
-
{
|
499 |
-
if($order->BillingFrequency == 6)
|
500 |
-
$frequency = "semi annually";
|
501 |
-
elseif($order->BillingFrequency == 3)
|
502 |
-
$frequency = "quarterly";
|
503 |
-
else
|
504 |
-
$frequency = "monthly";
|
505 |
-
}
|
506 |
-
elseif($order->BillingPeriod == "Week")
|
507 |
-
{
|
508 |
-
if($order->BillingFrequency == 4)
|
509 |
-
$frequency = "quad-weekly";
|
510 |
-
elseif($order->BillingFrequency == 2)
|
511 |
-
$frequency = "bi-weekly";
|
512 |
-
else
|
513 |
-
$frequency = "weekly";
|
514 |
-
}
|
515 |
-
elseif($order->BillingPeriod == "Day")
|
516 |
-
{
|
517 |
-
if($order->BillingFrequency == 365)
|
518 |
-
$frequency = "annually";
|
519 |
-
elseif($order->BillingFrequency == 182)
|
520 |
-
$frequency = "semi annually";
|
521 |
-
elseif($order->BillingFrequency == 183)
|
522 |
-
$frequency = "semi annually";
|
523 |
-
elseif($order->BillingFrequency == 90)
|
524 |
-
$frequency = "quaterly";
|
525 |
-
elseif($order->BillingFrequency == 30)
|
526 |
-
$frequency = "monthly";
|
527 |
-
elseif($order->BillingFrequency == 15)
|
528 |
-
$frequency = "semi-monthly";
|
529 |
-
elseif($order->BillingFrequency == 28)
|
530 |
-
$frequency = "quad-weekly";
|
531 |
-
elseif($order->BillingFrequency == 14)
|
532 |
-
$frequency = "bi-weekly";
|
533 |
-
elseif($order->BillingFrequency == 7)
|
534 |
-
$frequency = "weekly";
|
535 |
-
}
|
536 |
-
|
537 |
-
//set subscription info for API
|
538 |
-
$subscription = new stdClass();
|
539 |
-
$subscription->title = $order->membership_level->name;
|
540 |
-
$subscription->paymentMethod = "credit card";
|
541 |
-
$request->subscription = $subscription;
|
542 |
-
|
543 |
-
//recurring info
|
544 |
-
$recurringSubscriptionInfo = new stdClass();
|
545 |
-
$recurringSubscriptionInfo->amount = number_format($amount, 2);
|
546 |
-
$recurringSubscriptionInfo->startDate = $profile_start_date;
|
547 |
-
$recurringSubscriptionInfo->frequency = $frequency;
|
548 |
-
if(!empty($order->TotalBillingCycles))
|
549 |
-
$recurringSubscriptionInfo->numberOfPayments = $order->TotalBillingCycles;
|
550 |
-
$request->recurringSubscriptionInfo = $recurringSubscriptionInfo;
|
551 |
-
|
552 |
-
//combine address
|
553 |
-
$address = $order->Address1;
|
554 |
-
if(!empty($order->Address2))
|
555 |
-
$address .= "\n" . $order->Address2;
|
556 |
-
|
557 |
-
//bill to
|
558 |
-
$billTo = new stdClass();
|
559 |
-
$billTo->firstName = $order->FirstName;
|
560 |
-
$billTo->lastName = $order->LastName;
|
561 |
-
$billTo->street1 = $address;
|
562 |
-
$billTo->city = $order->billing->city;
|
563 |
-
$billTo->state = $order->billing->state;
|
564 |
-
$billTo->postalCode = $order->billing->zip;
|
565 |
-
$billTo->country = $order->billing->country;
|
566 |
-
$billTo->email = $order->Email;
|
567 |
-
$billTo->ipAddress = $_SERVER['REMOTE_ADDR'];
|
568 |
-
$request->billTo = $billTo;
|
569 |
-
|
570 |
-
//card
|
571 |
-
$card = new stdClass();
|
572 |
-
$card->cardType = $this->getCardType($order->cardtype);
|
573 |
-
$card->accountNumber = $order->accountnumber;
|
574 |
-
$card->expirationMonth = $order->expirationmonth;
|
575 |
-
$card->expirationYear = $order->expirationyear;
|
576 |
-
$card->cvNumber = $order->CVV2;
|
577 |
-
$request->card = $card;
|
578 |
-
|
579 |
-
//currency
|
580 |
-
$purchaseTotals = new stdClass();
|
581 |
-
$purchaseTotals->currency = pmpro_getOption("currency");
|
582 |
-
$request->purchaseTotals = $purchaseTotals;
|
583 |
-
|
584 |
-
$soapClient = new CyberSourceSoapClient($wsdl_url, array("merchantID"=>pmpro_getOption("cybersource_merchantid"), "transactionKey"=>pmpro_getOption("cybersource_securitykey")));
|
585 |
-
$reply = $soapClient->runTransaction($request);
|
586 |
-
|
587 |
-
if($reply->reasonCode == "100")
|
588 |
-
{
|
589 |
-
//success
|
590 |
-
$order->subscription_transaction_id = $reply->requestID;
|
591 |
-
$order->status = "success";
|
592 |
-
return true;
|
593 |
-
}
|
594 |
-
else
|
595 |
-
{
|
596 |
-
//error
|
597 |
-
$order->status = "error";
|
598 |
-
$order->errorcode = $reply->reasonCode;
|
599 |
-
$order->error = $this->getErrorFromCode($reply->reasonCode);
|
600 |
-
$order->shorterror = $this->getErrorFromCode($reply->reasonCode);
|
601 |
-
return false;
|
602 |
-
}
|
603 |
-
}
|
604 |
-
|
605 |
-
function update(&$order)
|
606 |
-
{
|
607 |
-
//get wsdl
|
608 |
-
$wsdl_url = $this->getWSDL($order);
|
609 |
-
|
610 |
-
//to store our request
|
611 |
-
$request = new stdClass();
|
612 |
-
|
613 |
-
//set service type
|
614 |
-
$paySubscriptionUpdateService = new stdClass();
|
615 |
-
$paySubscriptionUpdateService ->run = "true";
|
616 |
-
$request->paySubscriptionUpdateService = $paySubscriptionUpdateService ;
|
617 |
-
|
618 |
-
//merchant id and order code
|
619 |
-
$request->merchantID = pmpro_getOption("cybersource_merchantid");
|
620 |
-
$request->merchantReferenceCode = $order->code;
|
621 |
-
|
622 |
-
//set subscription info for API
|
623 |
-
$recurringSubscriptionInfo = new stdClass();
|
624 |
-
$recurringSubscriptionInfo->subscriptionID = $order->subscription_transaction_id;
|
625 |
-
$request->recurringSubscriptionInfo = $recurringSubscriptionInfo;
|
626 |
-
|
627 |
-
//combine address
|
628 |
-
$address = $order->Address1;
|
629 |
-
if(!empty($order->Address2))
|
630 |
-
$address .= "\n" . $order->Address2;
|
631 |
-
|
632 |
-
//bill to
|
633 |
-
$billTo = new stdClass();
|
634 |
-
$billTo->firstName = $order->FirstName;
|
635 |
-
$billTo->lastName = $order->LastName;
|
636 |
-
$billTo->street1 = $address;
|
637 |
-
$billTo->city = $order->billing->city;
|
638 |
-
$billTo->state = $order->billing->state;
|
639 |
-
$billTo->postalCode = $order->billing->zip;
|
640 |
-
$billTo->country = $order->billing->country;
|
641 |
-
$billTo->email = $order->Email;
|
642 |
-
$billTo->ipAddress = $_SERVER['REMOTE_ADDR'];
|
643 |
-
$request->billTo = $billTo;
|
644 |
-
|
645 |
-
//card
|
646 |
-
$card = new stdClass();
|
647 |
-
$card->cardType = $this->getCardType($order->cardtype);
|
648 |
-
$card->accountNumber = $order->accountnumber;
|
649 |
-
$card->expirationMonth = $order->expirationmonth;
|
650 |
-
$card->expirationYear = $order->expirationyear;
|
651 |
-
$card->cvNumber = $order->CVV2;
|
652 |
-
$request->card = $card;
|
653 |
-
|
654 |
-
$soapClient = new CyberSourceSoapClient($wsdl_url, array("merchantID"=>pmpro_getOption("cybersource_merchantid"), "transactionKey"=>pmpro_getOption("cybersource_securitykey")));
|
655 |
-
$reply = $soapClient->runTransaction($request);
|
656 |
-
|
657 |
-
if($reply->reasonCode == "100")
|
658 |
-
{
|
659 |
-
//success
|
660 |
-
return true;
|
661 |
-
}
|
662 |
-
else
|
663 |
-
{
|
664 |
-
//error
|
665 |
-
$order->errorcode = $reply->reasonCode;
|
666 |
-
$order->error = $this->getErrorFromCode($reply->reasonCode);
|
667 |
-
$order->shorterror = $this->getErrorFromCode($reply->reasonCode);
|
668 |
-
return false;
|
669 |
-
}
|
670 |
-
}
|
671 |
-
|
672 |
-
function cancel(&$order)
|
673 |
-
{
|
674 |
-
//require a subscription id
|
675 |
-
if(empty($order->subscription_transaction_id))
|
676 |
-
return false;
|
677 |
-
|
678 |
-
//get wsdl
|
679 |
-
$wsdl_url = $this->getWSDL($order);
|
680 |
-
|
681 |
-
//to store our request
|
682 |
-
$request = new stdClass();
|
683 |
-
|
684 |
-
//which service?
|
685 |
-
$paySubscriptionDeleteService = new stdClass();
|
686 |
-
$paySubscriptionDeleteService ->run = "true";
|
687 |
-
$request->paySubscriptionDeleteService = $paySubscriptionDeleteService ;
|
688 |
-
|
689 |
-
//which order
|
690 |
-
$recurringSubscriptionInfo = new stdClass();
|
691 |
-
$recurringSubscriptionInfo->subscriptionID = $order->subscription_transaction_id;
|
692 |
-
$request->recurringSubscriptionInfo = $recurringSubscriptionInfo;
|
693 |
-
|
694 |
-
//merchant id and order code
|
695 |
-
$request->merchantID = pmpro_getOption("cybersource_merchantid");
|
696 |
-
$request->merchantReferenceCode = $order->code;
|
697 |
-
|
698 |
-
$soapClient = new CyberSourceSoapClient($wsdl_url, array("merchantID"=>pmpro_getOption("cybersource_merchantid"), "transactionKey"=>pmpro_getOption("cybersource_securitykey")));
|
699 |
-
$reply = $soapClient->runTransaction($request);
|
700 |
-
|
701 |
-
if($reply->reasonCode == "100")
|
702 |
-
{
|
703 |
-
//success
|
704 |
-
$order->updateStatus("cancelled");
|
705 |
-
return true;
|
706 |
-
}
|
707 |
-
else
|
708 |
-
{
|
709 |
-
//error
|
710 |
-
$order->errorcode = $reply->reasonCode;
|
711 |
-
$order->error = $this->getErrorFromCode($reply->reasonCode);
|
712 |
-
$order->shorterror = $this->getErrorFromCode($reply->reasonCode);
|
713 |
-
return false;
|
714 |
-
}
|
715 |
-
}
|
716 |
-
|
717 |
-
function getErrorFromCode($code)
|
718 |
-
{
|
719 |
-
$error_messages = array(
|
720 |
-
"100" => "Successful transaction.",
|
721 |
-
"101" => "The request is missing one or more required fields.",
|
722 |
-
"102" => "One or more fields in the request contains invalid data. Check that your billing address is valid.",
|
723 |
-
"104" => "Duplicate order detected.",
|
724 |
-
"110" => "Only partial amount was approved.",
|
725 |
-
"150" => "Error: General system failure.",
|
726 |
-
"151" => "Error: The request was received but there was a server timeout.",
|
727 |
-
"152" => "Error: The request was received, but a service did not finish running in time. ",
|
728 |
-
"200" => "Address Verification Service (AVS) failure.",
|
729 |
-
"201" => "Authorization failed.",
|
730 |
-
"202" => "Expired card or invalid expiration date.",
|
731 |
-
"203" => "The card was declined.",
|
732 |
-
"204" => "Insufficient funds in the account.",
|
733 |
-
"205" => "Stolen or lost card.",
|
734 |
-
"207" => "Issuing bank unavailable.",
|
735 |
-
"208" => "Inactive card or card not authorized for card-not-present transactions.",
|
736 |
-
"209" => "American Express Card Identification Digits (CID) did not match.",
|
737 |
-
"210" => "The card has reached the credit limit. ",
|
738 |
-
"211" => "Invalid card verification number.",
|
739 |
-
"221" => "The customer matched an entry on the processors negative file. ",
|
740 |
-
"230" => "Card verification (CV) check failed.",
|
741 |
-
"231" => "Invalid account number.",
|
742 |
-
"232" => "The card type is not accepted by the payment processor.",
|
743 |
-
"233" => "General decline by the processor.",
|
744 |
-
"234" => "There is a problem with your CyberSource merchant configuration.",
|
745 |
-
"235" => "The requested amount exceeds the originally authorized amount.",
|
746 |
-
"236" => "Processor failure.",
|
747 |
-
"237" => "The authorization has already been reversed.",
|
748 |
-
"238" => "The authorization has already been captured.",
|
749 |
-
"239" => "The requested transaction amount must match the previous transaction amount.",
|
750 |
-
"240" => "The card type sent is invalid or does not correlate with the credit card number.",
|
751 |
-
"241" => "The referenced request id is invalid for all follow-on transactions.",
|
752 |
-
"242" => "The request ID is invalid.",
|
753 |
-
"243" => "The transaction has already been settled or reversed.",
|
754 |
-
"246" => "The capture or credit is not voidable because the capture or credit information has already been submitted to your processor. Or, you requested a void for a type of transaction that cannot be voided.",
|
755 |
-
"247" => "You requested a credit for a capture that was previously voided.",
|
756 |
-
"250" => "Error: The request was received, but there was a timeout at the payment processor.",
|
757 |
-
"520" => "Smart Authorization failed."
|
758 |
-
);
|
759 |
-
|
760 |
-
if(isset($error_messages[$code]))
|
761 |
-
return $error_messages[$code];
|
762 |
-
else
|
763 |
-
return "Unknown error.";
|
764 |
-
}
|
765 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_payflowpro.php
DELETED
@@ -1,448 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
class PMProGateway_payflowpro
|
4 |
-
{
|
5 |
-
function PMProGateway_payflowpro($gateway = NULL)
|
6 |
-
{
|
7 |
-
$this->gateway = $gateway;
|
8 |
-
return $this->gateway;
|
9 |
-
}
|
10 |
-
|
11 |
-
function process(&$order)
|
12 |
-
{
|
13 |
-
if(floatval($order->InitialPayment) == 0)
|
14 |
-
{
|
15 |
-
//auth first, then process
|
16 |
-
$authorization_id = $this->authorize($order);
|
17 |
-
if($authorization_id)
|
18 |
-
{
|
19 |
-
$this->void($order, $authorization_id);
|
20 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
21 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
22 |
-
return $this->subscribe($order);
|
23 |
-
}
|
24 |
-
else
|
25 |
-
{
|
26 |
-
if(empty($order->error))
|
27 |
-
$order->error = __("Unknown error: Authorization failed.", "pmpro");
|
28 |
-
return false;
|
29 |
-
}
|
30 |
-
}
|
31 |
-
else
|
32 |
-
{
|
33 |
-
//charge first payment
|
34 |
-
if($this->charge($order))
|
35 |
-
{
|
36 |
-
//setup recurring billing
|
37 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
38 |
-
{
|
39 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
40 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
41 |
-
if($this->subscribe($order))
|
42 |
-
{
|
43 |
-
return true;
|
44 |
-
}
|
45 |
-
else
|
46 |
-
{
|
47 |
-
if($this->void($order, $order->payment_transaction_id))
|
48 |
-
{
|
49 |
-
if(empty($order->error))
|
50 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
51 |
-
}
|
52 |
-
else
|
53 |
-
{
|
54 |
-
if(empty($order->error))
|
55 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
56 |
-
|
57 |
-
$order->error .= " " . __("A partial payment was made that we could not refund. Please contact the site owner immediately to correct this.", "pmpro");
|
58 |
-
}
|
59 |
-
|
60 |
-
return false;
|
61 |
-
}
|
62 |
-
}
|
63 |
-
else
|
64 |
-
{
|
65 |
-
//only a one time charge
|
66 |
-
$order->status = "success"; //saved on checkout page
|
67 |
-
$order->saveOrder();
|
68 |
-
return true;
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
function authorize(&$order)
|
75 |
-
{
|
76 |
-
if(empty($order->code))
|
77 |
-
$order->code = $order->getRandomCode();
|
78 |
-
|
79 |
-
//paypal profile stuff
|
80 |
-
$nvpStr = "";
|
81 |
-
|
82 |
-
$nvpStr .="&AMT=1.00";
|
83 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
84 |
-
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $order->PaymentAmount;
|
85 |
-
|
86 |
-
$nvpStr .= "&CUSTIP=" . $_SERVER['REMOTE_ADDR'] . "&INVNUM=" . $order->code;
|
87 |
-
|
88 |
-
//credit card fields
|
89 |
-
if($order->cardtype == "American Express")
|
90 |
-
$cardtype = "Amex";
|
91 |
-
else
|
92 |
-
$cardtype = $order->cardtype;
|
93 |
-
|
94 |
-
if(!empty($order->accountnumber))
|
95 |
-
$nvpStr .= "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->expirationmonth . substr($order->expirationyear, 2, 2) . "&CVV2=" . $order->CVV2;
|
96 |
-
|
97 |
-
//billing address, etc
|
98 |
-
if(!empty($order->Address1))
|
99 |
-
{
|
100 |
-
$nvpStr .= "&EMAIL=" . $order->Email . "&FIRSTNAME=" . $order->FirstName . "&LASTNAME=" . $order->LastName . "&STREET=" . $order->Address1;
|
101 |
-
|
102 |
-
if($order->Address2)
|
103 |
-
$nvpStr .= " " . $order->Address2;
|
104 |
-
|
105 |
-
$nvpStr .= "&CITY=" . $order->billing->city . "&STATE=" . $order->billing->state . "&BILLTOCOUNTRY=" . $order->billing->country . "&ZIP=" . $order->billing->zip . "&PHONENUM=" . $order->billing->phone;
|
106 |
-
}
|
107 |
-
|
108 |
-
//for debugging, let's attach this to the class object
|
109 |
-
$this->nvpStr = $nvpStr;
|
110 |
-
|
111 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('A', $nvpStr);
|
112 |
-
|
113 |
-
if("0" == strtoupper($this->httpParsedResponseAr["RESULT"])) {
|
114 |
-
$order->authorization_id = $this->httpParsedResponseAr['PNREF'];
|
115 |
-
$order->updateStatus("authorized");
|
116 |
-
return $order->authorization_id;
|
117 |
-
} else {
|
118 |
-
$order->status = "error";
|
119 |
-
$order->errorcode = $this->httpParsedResponseAr['RESULT'];
|
120 |
-
$order->error = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
121 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
122 |
-
return false;
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
function void(&$order, $authorization_id)
|
127 |
-
{
|
128 |
-
if(empty($authorization_id))
|
129 |
-
return false;
|
130 |
-
|
131 |
-
//paypal profile stuff
|
132 |
-
$nvpStr="&ORIGID=" . $authorization_id;
|
133 |
-
|
134 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('V', $nvpStr);
|
135 |
-
|
136 |
-
if("0" == strtoupper($this->httpParsedResponseAr["RESULT"])) {
|
137 |
-
return true;
|
138 |
-
} else {
|
139 |
-
$order->status = "error";
|
140 |
-
$order->errorcode = $this->httpParsedResponseAr['RESULT'];
|
141 |
-
$order->error = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
142 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
143 |
-
return false;
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
function charge(&$order)
|
148 |
-
{
|
149 |
-
global $pmpro_currency;
|
150 |
-
|
151 |
-
if(empty($order->code))
|
152 |
-
$order->code = $order->getRandomCode();
|
153 |
-
|
154 |
-
//taxes on the amount
|
155 |
-
$amount = $order->InitialPayment;
|
156 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
157 |
-
$order->subtotal = $amount;
|
158 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
159 |
-
|
160 |
-
//paypal profile stuff
|
161 |
-
$nvpStr = "";
|
162 |
-
$nvpStr .="&AMT=" . $amount . "&TAXAMT=" . $amount_tax . "&CURRENCY=" . $pmpro_currency;
|
163 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
164 |
-
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $order->PaymentAmount;
|
165 |
-
|
166 |
-
$nvpStr .= "&CUSTIP=" . $_SERVER['REMOTE_ADDR'] . "&INVNUM=" . $order->code;
|
167 |
-
|
168 |
-
if(!empty($order->accountnumber))
|
169 |
-
$nvpStr .= "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->expirationmonth . substr($order->expirationyear, 2, 2) . "&CVV2=" . $order->CVV2;
|
170 |
-
|
171 |
-
//billing address, etc
|
172 |
-
if($order->Address1)
|
173 |
-
{
|
174 |
-
$nvpStr .= "&EMAIL=" . $order->Email . "&FIRSTNAME=" . $order->FirstName . "&LASTNAME=" . $order->LastName . "&STREET=" . $order->Address1;
|
175 |
-
|
176 |
-
if($order->Address2)
|
177 |
-
$nvpStr .= " " . $order->Address2;
|
178 |
-
|
179 |
-
$nvpStr .= "&CITY=" . $order->billing->city . "&STATE=" . $order->billing->state . "&BILLTOCOUNTRY=" . $order->billing->country . "&ZIP=" . $order->billing->zip . "&PHONENUM=" . $order->billing->phone;
|
180 |
-
}
|
181 |
-
|
182 |
-
$this->nvpStr = $nvpStr;
|
183 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('S', $nvpStr);
|
184 |
-
|
185 |
-
if("0" == strtoupper($this->httpParsedResponseAr["RESULT"])) {
|
186 |
-
$order->payment_transaction_id = $this->httpParsedResponseAr['PNREF'];
|
187 |
-
$order->updateStatus("success");
|
188 |
-
return true;
|
189 |
-
} else {
|
190 |
-
$order->status = "error";
|
191 |
-
$order->errorcode = $this->httpParsedResponseAr['RESULT'];
|
192 |
-
$order->error = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
193 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
194 |
-
return false;
|
195 |
-
}
|
196 |
-
}
|
197 |
-
|
198 |
-
function subscribe(&$order)
|
199 |
-
{
|
200 |
-
global $pmpro_currency;
|
201 |
-
|
202 |
-
if(empty($order->code))
|
203 |
-
$order->code = $order->getRandomCode();
|
204 |
-
|
205 |
-
//filter order before subscription. use with care.
|
206 |
-
$order = apply_filters("pmpro_subscribe_order", $order, $this);
|
207 |
-
|
208 |
-
//taxes on the amount
|
209 |
-
$amount = $order->PaymentAmount;
|
210 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
211 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
212 |
-
|
213 |
-
if($order->BillingPeriod == "Week")
|
214 |
-
$payperiod = "WEEK";
|
215 |
-
elseif($order->BillingPeriod == "Month")
|
216 |
-
$payperiod = "MONT";
|
217 |
-
elseif($order->BillingPeriod == "Year")
|
218 |
-
$payperiod = "YEAR";
|
219 |
-
|
220 |
-
//paypal profile stuff
|
221 |
-
$nvpStr = "&ACTION=A";
|
222 |
-
$nvpStr .="&AMT=" . $amount . "&TAXAMT=" . $amount_tax . "&CURRENCY=" . $pmpro_currency;
|
223 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
224 |
-
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $order->PaymentAmount;
|
225 |
-
|
226 |
-
$nvpStr .= "&PROFILENAME=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127));
|
227 |
-
|
228 |
-
$nvpStr .= "&PAYPERIOD=" . $payperiod;
|
229 |
-
|
230 |
-
$nvpStr .= "&CUSTIP=" . $_SERVER['REMOTE_ADDR']; // . "&INVNUM=" . $order->code;
|
231 |
-
|
232 |
-
//if billing cycles are defined
|
233 |
-
if(!empty($order->TotalBillingCycles))
|
234 |
-
$nvpStr .= "&TERM=" . $order->TotalBillingCycles;
|
235 |
-
else
|
236 |
-
$nvpStr .= "&TERM=0";
|
237 |
-
|
238 |
-
if(!empty($order->accountnumber))
|
239 |
-
$nvpStr .= "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->expirationmonth . substr($order->expirationyear, 2, 2) . "&CVV2=" . $order->CVV2;
|
240 |
-
|
241 |
-
/*
|
242 |
-
Let's figure out the start date. There are two parts.
|
243 |
-
1. We need to add the billing period to the start date to account for the initial payment.
|
244 |
-
2. We can allow for free trials by further delaying the start date of the subscription.
|
245 |
-
*/
|
246 |
-
if($order->BillingPeriod == "Year")
|
247 |
-
$trial_period_days = $order->BillingFrequency * 365; //annual
|
248 |
-
elseif($order->BillingPeriod == "Day")
|
249 |
-
$trial_period_days = $order->BillingFrequency * 1; //daily
|
250 |
-
elseif($order->BillingPeriod == "Week")
|
251 |
-
$trial_period_days = $order->BillingFrequency * 7; //weekly
|
252 |
-
else
|
253 |
-
$trial_period_days = $order->BillingFrequency * 30; //assume monthly
|
254 |
-
|
255 |
-
//convert to a profile start date
|
256 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $trial_period_days . " Day", current_time("timestamp"))) . "T0:0:0";
|
257 |
-
|
258 |
-
//filter the start date
|
259 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
260 |
-
|
261 |
-
//convert back to days
|
262 |
-
$trial_period_days = ceil(abs(strtotime(date("Y-m-d"), current_time('timestamp')) - strtotime($order->ProfileStartDate, current_time("timestamp"))) / 86400);
|
263 |
-
|
264 |
-
//now add the actual trial set by the site
|
265 |
-
if(!empty($order->TrialBillingCycles))
|
266 |
-
{
|
267 |
-
$trialOccurrences = (int)$order->TrialBillingCycles;
|
268 |
-
if($order->BillingPeriod == "Year")
|
269 |
-
$trial_period_days = $trial_period_days + (365 * $order->BillingFrequency * $trialOccurrences); //annual
|
270 |
-
elseif($order->BillingPeriod == "Day")
|
271 |
-
$trial_period_days = $trial_period_days + (1 * $order->BillingFrequency * $trialOccurrences); //daily
|
272 |
-
elseif($order->BillingPeriod == "Week")
|
273 |
-
$trial_period_days = $trial_period_days + (7 * $order->BillingFrequency * $trialOccurrences); //weekly
|
274 |
-
else
|
275 |
-
$trial_period_days = $trial_period_days + (30 * $order->BillingFrequency * $trialOccurrences); //assume monthly
|
276 |
-
}
|
277 |
-
|
278 |
-
//convert back into a date
|
279 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $trial_period_days . " Day", current_time("timestamp"))) . "T0:0:0";
|
280 |
-
|
281 |
-
//start date
|
282 |
-
$nvpStr .= "&START=" . date("mdY", strtotime($order->ProfileStartDate));
|
283 |
-
|
284 |
-
if(!empty($order->accountnumber))
|
285 |
-
$nvpStr .= "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->expirationmonth . substr($order->expirationyear, 2, 2) . "&CVV2=" . $order->CVV2;
|
286 |
-
|
287 |
-
//billing address, etc
|
288 |
-
if($order->Address1)
|
289 |
-
{
|
290 |
-
$nvpStr .= "&EMAIL=" . $order->Email . "&FIRSTNAME=" . $order->FirstName . "&LASTNAME=" . $order->LastName . "&STREET=" . $order->Address1;
|
291 |
-
|
292 |
-
if($order->Address2)
|
293 |
-
$nvpStr .= " " . $order->Address2;
|
294 |
-
|
295 |
-
$nvpStr .= "&CITY=" . $order->billing->city . "&STATE=" . $order->billing->state . "&BILLTOCOUNTRY=" . $order->billing->country . "&ZIP=" . $order->billing->zip . "&PHONENUM=" . $order->billing->phone;
|
296 |
-
}
|
297 |
-
|
298 |
-
$this->nvpStr = $nvpStr;
|
299 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('R', $nvpStr);
|
300 |
-
|
301 |
-
if("0" == strtoupper($this->httpParsedResponseAr["RESULT"])) {
|
302 |
-
$order->subscription_transaction_id = $this->httpParsedResponseAr['PROFILEID'];
|
303 |
-
$order->status = "success";
|
304 |
-
return true;
|
305 |
-
} else {
|
306 |
-
$order->status = "error";
|
307 |
-
$order->errorcode = $this->httpParsedResponseAr['RESULT'];
|
308 |
-
$order->error = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
309 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
310 |
-
return false;
|
311 |
-
}
|
312 |
-
}
|
313 |
-
|
314 |
-
function update(&$order)
|
315 |
-
{
|
316 |
-
$order->getMembershipLevel();
|
317 |
-
|
318 |
-
//paypal profile stuff
|
319 |
-
$nvpStr = "&ORIGPROFILEID=" . $order->subscription_transaction_id . "&ACTION=M";
|
320 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
321 |
-
|
322 |
-
$nvpStr .= "&PROFILENAME=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127));
|
323 |
-
|
324 |
-
$nvpStr .= "&CUSTIP=" . $_SERVER['REMOTE_ADDR']; // . "&INVNUM=" . $order->code;
|
325 |
-
|
326 |
-
if(!empty($order->accountnumber))
|
327 |
-
$nvpStr .= "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->expirationmonth . substr($order->expirationyear, 2, 2) . "&CVV2=" . $order->CVV2;
|
328 |
-
|
329 |
-
//billing address, etc
|
330 |
-
if($order->Address1)
|
331 |
-
{
|
332 |
-
$nvpStr .= "&EMAIL=" . $order->Email . "&FIRSTNAME=" . $order->FirstName . "&LASTNAME=" . $order->LastName . "&STREET=" . $order->Address1;
|
333 |
-
|
334 |
-
if($order->Address2)
|
335 |
-
$nvpStr .= " " . $order->Address2;
|
336 |
-
|
337 |
-
$nvpStr .= "&CITY=" . $order->billing->city . "&STATE=" . $order->billing->state . "&BILLTOCOUNTRY=" . $order->billing->country . "&ZIP=" . $order->billing->zip . "&PHONENUM=" . $order->billing->phone;
|
338 |
-
}
|
339 |
-
|
340 |
-
$this->nvpStr = $nvpStr;
|
341 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('R', $nvpStr);
|
342 |
-
|
343 |
-
if("0" == strtoupper($this->httpParsedResponseAr["RESULT"])) {
|
344 |
-
$order->subscription_transaction_id = $this->httpParsedResponseAr['PROFILEID'];
|
345 |
-
$order->updateStatus("success");
|
346 |
-
return true;
|
347 |
-
} else {
|
348 |
-
$order->status = "error";
|
349 |
-
$order->errorcode = $this->httpParsedResponseAr['RESULT'];
|
350 |
-
$order->error = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
351 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
352 |
-
return false;
|
353 |
-
}
|
354 |
-
}
|
355 |
-
|
356 |
-
function cancel(&$order)
|
357 |
-
{
|
358 |
-
//require a subscription id
|
359 |
-
if(empty($order->subscription_transaction_id))
|
360 |
-
return false;
|
361 |
-
|
362 |
-
//paypal profile stuff
|
363 |
-
$nvpStr = "&ORIGPROFILEID=" . $order->subscription_transaction_id . "&ACTION=C";
|
364 |
-
|
365 |
-
$this->nvpStr = $nvpStr;
|
366 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('R', $nvpStr);
|
367 |
-
|
368 |
-
if("0" == strtoupper($this->httpParsedResponseAr["RESULT"]))
|
369 |
-
{
|
370 |
-
$order->updateStatus("cancelled");
|
371 |
-
return true;
|
372 |
-
}
|
373 |
-
else
|
374 |
-
{
|
375 |
-
$order->status = "error";
|
376 |
-
$order->errorcode = $this->httpParsedResponseAr['RESULT'];
|
377 |
-
$order->error = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
378 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['RESPMSG']);
|
379 |
-
return false;
|
380 |
-
}
|
381 |
-
}
|
382 |
-
|
383 |
-
/**
|
384 |
-
* PAYPAL Function
|
385 |
-
* Send HTTP POST Request
|
386 |
-
*
|
387 |
-
* @param string The API method name
|
388 |
-
* @param string The POST Message fields in &name=value pair format
|
389 |
-
* @return array Parsed HTTP Response body
|
390 |
-
*/
|
391 |
-
function PPHttpPost($methodName_, $nvpStr_) {
|
392 |
-
global $gateway_environment;
|
393 |
-
$environment = $gateway_environment;
|
394 |
-
|
395 |
-
$PARTNER = pmpro_getOption("payflow_partner");
|
396 |
-
$VENDOR = pmpro_getOption("payflow_vendor");
|
397 |
-
$USER = pmpro_getOption("payflow_user");
|
398 |
-
$PWD = pmpro_getOption("payflow_pwd");
|
399 |
-
$API_Endpoint = "https://payflowpro.paypal.com";
|
400 |
-
if("sandbox" === $environment || "beta-sandbox" === $environment) {
|
401 |
-
$API_Endpoint = "https://pilot-payflowpro.paypal.com";
|
402 |
-
}
|
403 |
-
|
404 |
-
$version = urlencode('4');
|
405 |
-
|
406 |
-
// setting the curl parameters.
|
407 |
-
$ch = curl_init();
|
408 |
-
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
|
409 |
-
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
410 |
-
|
411 |
-
// turning off the server and peer verification(TrustManager Concept).
|
412 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
413 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
414 |
-
|
415 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
416 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
417 |
-
|
418 |
-
// NVPRequest for submitting to server
|
419 |
-
$nvpreq = "TRXTYPE=" . $methodName_ . "&TENDER=C&PARTNER=" . $PARTNER . "&VENDOR=" . $VENDOR . "&USER=" . $USER . "&PWD=" . $PWD . "&VERBOSITY=medium" . $nvpStr_;
|
420 |
-
|
421 |
-
// setting the nvpreq as POST FIELD to curl
|
422 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
|
423 |
-
|
424 |
-
// getting response from server
|
425 |
-
$httpResponse = curl_exec($ch);
|
426 |
-
|
427 |
-
if(empty($httpResponse)) {
|
428 |
-
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
|
429 |
-
}
|
430 |
-
|
431 |
-
// Extract the RefundTransaction response details
|
432 |
-
$httpResponseAr = explode("&", $httpResponse);
|
433 |
-
|
434 |
-
$httpParsedResponseAr = array();
|
435 |
-
foreach ($httpResponseAr as $i => $value) {
|
436 |
-
$tmpAr = explode("=", $value);
|
437 |
-
if(sizeof($tmpAr) > 1) {
|
438 |
-
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
|
439 |
-
}
|
440 |
-
}
|
441 |
-
|
442 |
-
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('RESULT', $httpParsedResponseAr)) {
|
443 |
-
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
|
444 |
-
}
|
445 |
-
|
446 |
-
return $httpParsedResponseAr;
|
447 |
-
}
|
448 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_paypal.php
DELETED
@@ -1,456 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
class PMProGateway_paypal
|
4 |
-
{
|
5 |
-
function PMProGateway_paypal($gateway = NULL)
|
6 |
-
{
|
7 |
-
$this->gateway = $gateway;
|
8 |
-
return $this->gateway;
|
9 |
-
}
|
10 |
-
|
11 |
-
function process(&$order)
|
12 |
-
{
|
13 |
-
if(floatval($order->InitialPayment) == 0)
|
14 |
-
{
|
15 |
-
//auth first, then process
|
16 |
-
$authorization_id = $this->authorize($order);
|
17 |
-
if($authorization_id)
|
18 |
-
{
|
19 |
-
$this->void($order, $authorization_id);
|
20 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
21 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
22 |
-
return $this->subscribe($order);
|
23 |
-
}
|
24 |
-
else
|
25 |
-
{
|
26 |
-
if(empty($order->error))
|
27 |
-
$order->error = __("Unknown error: Authorization failed.", "pmpro");
|
28 |
-
return false;
|
29 |
-
}
|
30 |
-
}
|
31 |
-
else
|
32 |
-
{
|
33 |
-
//charge first payment
|
34 |
-
if($this->charge($order))
|
35 |
-
{
|
36 |
-
//setup recurring billing
|
37 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
38 |
-
{
|
39 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
40 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
41 |
-
if($this->subscribe($order))
|
42 |
-
{
|
43 |
-
return true;
|
44 |
-
}
|
45 |
-
else
|
46 |
-
{
|
47 |
-
if($this->refund($order, $order->payment_transaction_id))
|
48 |
-
{
|
49 |
-
if(empty($order->error))
|
50 |
-
$order->error = __("Unknown error: Payment failed.", "pmpro");
|
51 |
-
}
|
52 |
-
else
|
53 |
-
{
|
54 |
-
if(empty($order->error))
|
55 |
-
$order->error = "Unknown error: Payment failed.";
|
56 |
-
|
57 |
-
$order->error .= " " . __("A partial payment was made that we could not refund. Please contact the site owner immediately to correct this.", "pmpro");
|
58 |
-
}
|
59 |
-
|
60 |
-
return false;
|
61 |
-
}
|
62 |
-
}
|
63 |
-
else
|
64 |
-
{
|
65 |
-
//only a one time charge
|
66 |
-
$order->status = "success"; //saved on checkout page
|
67 |
-
$order->saveOrder();
|
68 |
-
return true;
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
function authorize(&$order)
|
75 |
-
{
|
76 |
-
if(empty($order->code))
|
77 |
-
$order->code = $order->getRandomCode();
|
78 |
-
|
79 |
-
//paypal profile stuff
|
80 |
-
$nvpStr = "";
|
81 |
-
if(!empty($order->Token))
|
82 |
-
$nvpStr .= "&TOKEN=" . $order->Token;
|
83 |
-
$nvpStr .="&AMT=1.00&CURRENCYCODE=" . pmpro_getOption("currency");
|
84 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
85 |
-
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $order->PaymentAmount;
|
86 |
-
|
87 |
-
$nvpStr .= "&PAYMENTACTION=Authorization&IPADDRESS=" . $_SERVER['REMOTE_ADDR'] . "&INVNUM=" . $order->code;
|
88 |
-
|
89 |
-
//credit card fields
|
90 |
-
if($order->cardtype == "American Express")
|
91 |
-
$cardtype = "Amex";
|
92 |
-
else
|
93 |
-
$cardtype = $order->cardtype;
|
94 |
-
|
95 |
-
if(!empty($cardtype))
|
96 |
-
$nvpStr .= "&CREDITCARDTYPE=" . $cardtype . "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->ExpirationDate . "&CVV2=" . $order->CVV2;
|
97 |
-
|
98 |
-
//Maestro/Solo card fields. (Who uses these?) :)
|
99 |
-
if(!empty($order->StartDate))
|
100 |
-
$nvpStr .= "&STARTDATE=" . $order->StartDate . "&ISSUENUMBER=" . $order->IssueNumber;
|
101 |
-
|
102 |
-
//billing address, etc
|
103 |
-
if(!empty($order->Address1))
|
104 |
-
{
|
105 |
-
$nvpStr .= "&EMAIL=" . $order->Email . "&FIRSTNAME=" . $order->FirstName . "&LASTNAME=" . $order->LastName . "&STREET=" . $order->Address1;
|
106 |
-
|
107 |
-
if($order->Address2)
|
108 |
-
$nvpStr .= "&STREET2=" . $order->Address2;
|
109 |
-
|
110 |
-
$nvpStr .= "&CITY=" . $order->billing->city . "&STATE=" . $order->billing->state . "&COUNTRYCODE=" . $order->billing->country . "&ZIP=" . $order->billing->zip . "&SHIPTOPHONENUM=" . $order->billing->phone;
|
111 |
-
}
|
112 |
-
|
113 |
-
//for debugging, let's attach this to the class object
|
114 |
-
$this->nvpStr = $nvpStr;
|
115 |
-
|
116 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('DoDirectPayment', $nvpStr);
|
117 |
-
|
118 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
119 |
-
$order->authorization_id = $this->httpParsedResponseAr['TRANSACTIONID'];
|
120 |
-
$order->updateStatus("authorized");
|
121 |
-
return $order->authorization_id;
|
122 |
-
} else {
|
123 |
-
$order->status = "error";
|
124 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
125 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
126 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
127 |
-
return false;
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
function void(&$order, $authorization_id)
|
132 |
-
{
|
133 |
-
if(empty($authorization_id))
|
134 |
-
return false;
|
135 |
-
|
136 |
-
//paypal profile stuff
|
137 |
-
$nvpStr="&AUTHORIZATIONID=" . $authorization_id . "&NOTE=Voiding an authorization for a recurring payment setup.";
|
138 |
-
|
139 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('DoVoid', $nvpStr);
|
140 |
-
|
141 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
142 |
-
return true;
|
143 |
-
} else {
|
144 |
-
$order->status = "error";
|
145 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
146 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
147 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
148 |
-
return false;
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
function refund(&$order, $transaction_id)
|
153 |
-
{
|
154 |
-
if(empty($transaction_id))
|
155 |
-
return false;
|
156 |
-
|
157 |
-
//paypal profile stuff
|
158 |
-
$nvpStr="&TRANSACTIONID=" . $transaction_id . "&NOTE=Refunding a charge.";
|
159 |
-
|
160 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('RefundTransaction', $nvpStr);
|
161 |
-
|
162 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
163 |
-
return true;
|
164 |
-
} else {
|
165 |
-
$order->status = "error";
|
166 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
167 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
168 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
169 |
-
return false;
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
function charge(&$order)
|
174 |
-
{
|
175 |
-
global $pmpro_currency;
|
176 |
-
|
177 |
-
if(empty($order->code))
|
178 |
-
$order->code = $order->getRandomCode();
|
179 |
-
|
180 |
-
//taxes on the amount
|
181 |
-
$amount = $order->InitialPayment;
|
182 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
183 |
-
$order->subtotal = $amount;
|
184 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
185 |
-
|
186 |
-
//paypal profile stuff
|
187 |
-
$nvpStr = "";
|
188 |
-
if(!empty($order->Token))
|
189 |
-
$nvpStr .= "&TOKEN=" . $order->Token;
|
190 |
-
$nvpStr .="&AMT=" . $amount . "&ITEMAMT=" . $order->InitialPayment . "&TAXAMT=" . $amount_tax . "&CURRENCYCODE=" . $pmpro_currency;
|
191 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
192 |
-
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $order->PaymentAmount;
|
193 |
-
|
194 |
-
$nvpStr .= "&PAYMENTACTION=Sale&IPADDRESS=" . $_SERVER['REMOTE_ADDR'] . "&INVNUM=" . $order->code;
|
195 |
-
|
196 |
-
//credit card fields
|
197 |
-
if($order->cardtype == "American Express")
|
198 |
-
$cardtype = "Amex";
|
199 |
-
else
|
200 |
-
$cardtype = $order->cardtype;
|
201 |
-
|
202 |
-
if(!empty($cardtype))
|
203 |
-
$nvpStr .= "&CREDITCARDTYPE=" . $cardtype . "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->ExpirationDate . "&CVV2=" . $order->CVV2;
|
204 |
-
|
205 |
-
//Maestro/Solo card fields. (Who uses these?) :)
|
206 |
-
if(!empty($order->StartDate))
|
207 |
-
$nvpStr .= "&STARTDATE=" . $order->StartDate . "&ISSUENUMBER=" . $order->IssueNumber;
|
208 |
-
|
209 |
-
//billing address, etc
|
210 |
-
if($order->Address1)
|
211 |
-
{
|
212 |
-
$nvpStr .= "&EMAIL=" . $order->Email . "&FIRSTNAME=" . $order->FirstName . "&LASTNAME=" . $order->LastName . "&STREET=" . $order->Address1;
|
213 |
-
|
214 |
-
if($order->Address2)
|
215 |
-
$nvpStr .= "&STREET2=" . $order->Address2;
|
216 |
-
|
217 |
-
$nvpStr .= "&CITY=" . $order->billing->city . "&STATE=" . $order->billing->state . "&COUNTRYCODE=" . $order->billing->country . "&ZIP=" . $order->billing->zip . "&SHIPTOPHONENUM=" . $order->billing->phone;
|
218 |
-
}
|
219 |
-
|
220 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('DoDirectPayment', $nvpStr);
|
221 |
-
|
222 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
223 |
-
$order->payment_transaction_id = $this->httpParsedResponseAr['TRANSACTIONID'];
|
224 |
-
$order->updateStatus("success");
|
225 |
-
return true;
|
226 |
-
} else {
|
227 |
-
$order->status = "error";
|
228 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
229 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
230 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
231 |
-
return false;
|
232 |
-
}
|
233 |
-
}
|
234 |
-
|
235 |
-
function subscribe(&$order)
|
236 |
-
{
|
237 |
-
global $pmpro_currency;
|
238 |
-
|
239 |
-
if(empty($order->code))
|
240 |
-
$order->code = $order->getRandomCode();
|
241 |
-
|
242 |
-
//filter order before subscription. use with care.
|
243 |
-
$order = apply_filters("pmpro_subscribe_order", $order, $this);
|
244 |
-
|
245 |
-
//taxes on the amount
|
246 |
-
$amount = $order->PaymentAmount;
|
247 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
248 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
249 |
-
|
250 |
-
//paypal profile stuff
|
251 |
-
$nvpStr = "";
|
252 |
-
if(!empty($order->Token))
|
253 |
-
$nvpStr .= "&TOKEN=" . $order->Token;
|
254 |
-
$nvpStr .="&AMT=" . $order->PaymentAmount . "&TAXAMT=" . $amount_tax . "&CURRENCYCODE=" . $pmpro_currency . "&PROFILESTARTDATE=" . $order->ProfileStartDate;
|
255 |
-
$nvpStr .= "&BILLINGPERIOD=" . $order->BillingPeriod . "&BILLINGFREQUENCY=" . $order->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling";
|
256 |
-
$nvpStr .= "&DESC=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127));
|
257 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
258 |
-
//$nvpStr .= "&L_BILLINGTYPE0=RecurringPayments&L_BILLINGAGREEMENTDESCRIPTION0=" . $order->PaymentAmount;
|
259 |
-
|
260 |
-
//if billing cycles are defined
|
261 |
-
if(!empty($order->TotalBillingCycles))
|
262 |
-
$nvpStr .= "&TOTALBILLINGCYCLES=" . $order->TotalBillingCycles;
|
263 |
-
|
264 |
-
//if a trial period is defined
|
265 |
-
if(!empty($order->TrialBillingPeriod))
|
266 |
-
{
|
267 |
-
$trial_amount = $order->TrialAmount;
|
268 |
-
$trial_tax = $order->getTaxForPrice($trial_amount);
|
269 |
-
$trial_amount = round((float)$trial_amount + (float)$trial_tax, 2);
|
270 |
-
|
271 |
-
$nvpStr .= "&TRIALBILLINGPERIOD=" . $order->TrialBillingPeriod . "&TRIALBILLINGFREQUENCY=" . $order->TrialBillingFrequency . "&TRIALAMT=" . $trial_amount;
|
272 |
-
}
|
273 |
-
if(!empty($order->TrialBillingCycles))
|
274 |
-
$nvpStr .= "&TRIALTOTALBILLINGCYCLES=" . $order->TrialBillingCycles;
|
275 |
-
|
276 |
-
//credit card fields
|
277 |
-
if($order->cardtype == "American Express")
|
278 |
-
$cardtype = "Amex";
|
279 |
-
else
|
280 |
-
$cardtype = $order->cardtype;
|
281 |
-
|
282 |
-
if($cardtype)
|
283 |
-
$nvpStr .= "&CREDITCARDTYPE=" . $cardtype . "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->ExpirationDate . "&CVV2=" . $order->CVV2;
|
284 |
-
|
285 |
-
//Maestro/Solo card fields. (Who uses these?) :)
|
286 |
-
if(!empty($order->StartDate))
|
287 |
-
$nvpStr .= "&STARTDATE=" . $order->StartDate . "&ISSUENUMBER=" . $order->IssueNumber;
|
288 |
-
|
289 |
-
//billing address, etc
|
290 |
-
if($order->Address1)
|
291 |
-
{
|
292 |
-
$nvpStr .= "&EMAIL=" . $order->Email . "&FIRSTNAME=" . $order->FirstName . "&LASTNAME=" . $order->LastName . "&STREET=" . $order->Address1;
|
293 |
-
|
294 |
-
if($order->Address2)
|
295 |
-
$nvpStr .= "&STREET2=" . $order->Address2;
|
296 |
-
|
297 |
-
$nvpStr .= "&CITY=" . $order->billing->city . "&STATE=" . $order->billing->state . "&COUNTRYCODE=" . $order->billing->country . "&ZIP=" . $order->billing->zip . "&SHIPTOPHONENUM=" . $order->billing->phone;
|
298 |
-
}
|
299 |
-
|
300 |
-
//for debugging let's add this to the class object
|
301 |
-
$this->nvpStr = $nvpStr;
|
302 |
-
|
303 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
|
304 |
-
|
305 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
306 |
-
$order->status = "success";
|
307 |
-
$order->subscription_transaction_id = urldecode($this->httpParsedResponseAr['PROFILEID']);
|
308 |
-
return true;
|
309 |
-
//exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($this->httpParsedResponseAr, true));
|
310 |
-
} else {
|
311 |
-
$order->status = "error";
|
312 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
313 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
314 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
315 |
-
return false;
|
316 |
-
//exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
|
317 |
-
}
|
318 |
-
}
|
319 |
-
|
320 |
-
function update(&$order)
|
321 |
-
{
|
322 |
-
//paypal profile stuff
|
323 |
-
$nvpStr = "";
|
324 |
-
$nvpStr .= "&PROFILEID=" . $order->subscription_transaction_id;
|
325 |
-
|
326 |
-
//credit card fields
|
327 |
-
if($order->cardtype == "American Express")
|
328 |
-
$cardtype = "Amex";
|
329 |
-
else
|
330 |
-
$cardtype = $order->cardtype;
|
331 |
-
|
332 |
-
//credit card fields
|
333 |
-
if($cardtype)
|
334 |
-
$nvpStr .= "&CREDITCARDTYPE=" . $cardtype . "&ACCT=" . $order->accountnumber . "&EXPDATE=" . $order->ExpirationDate . "&CVV2=" . $order->CVV2;
|
335 |
-
|
336 |
-
//Maestro/Solo card fields. (Who uses these?) :)
|
337 |
-
if($order->StartDate)
|
338 |
-
$nvpStr .= "&STARTDATE=" . $order->StartDate . "&ISSUENUMBER=" . $order->IssueNumber;
|
339 |
-
|
340 |
-
//billing address, etc
|
341 |
-
if($order->Address1)
|
342 |
-
{
|
343 |
-
$nvpStr .= "&EMAIL=" . $order->Email . "&FIRSTNAME=" . $order->FirstName . "&LASTNAME=" . $order->LastName . "&STREET=" . $order->Address1;
|
344 |
-
|
345 |
-
if($order->Address2)
|
346 |
-
$nvpStr .= "&STREET2=" . $order->Address2;
|
347 |
-
|
348 |
-
$nvpStr .= "&CITY=" . $order->billing->city . "&STATE=" . $order->billing->state . "&COUNTRYCODE=" . $order->billing->country . "&ZIP=" . $order->billing->zip;
|
349 |
-
}
|
350 |
-
|
351 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('UpdateRecurringPaymentsProfile', $nvpStr);
|
352 |
-
|
353 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
354 |
-
$order->status = "success";
|
355 |
-
$order->subscription_transaction_id = urldecode($this->httpParsedResponseAr['PROFILEID']);
|
356 |
-
return true;
|
357 |
-
//exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($this->httpParsedResponseAr, true));
|
358 |
-
} else {
|
359 |
-
$order->status = "error";
|
360 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
361 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
362 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
363 |
-
return false;
|
364 |
-
//exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
|
365 |
-
}
|
366 |
-
}
|
367 |
-
|
368 |
-
function cancel(&$order)
|
369 |
-
{
|
370 |
-
//paypal profile stuff
|
371 |
-
$nvpStr = "";
|
372 |
-
$nvpStr .= "&PROFILEID=" . urlencode($order->subscription_transaction_id) . "&ACTION=Cancel&NOTE=" . urlencode("User requested cancel.");
|
373 |
-
|
374 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('ManageRecurringPaymentsProfileStatus', $nvpStr);
|
375 |
-
|
376 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"]))
|
377 |
-
{
|
378 |
-
$order->updateStatus("cancelled");
|
379 |
-
return true;
|
380 |
-
}
|
381 |
-
else
|
382 |
-
{
|
383 |
-
$order->status = "error";
|
384 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
385 |
-
$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.", "pmpro");
|
386 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
387 |
-
|
388 |
-
return false;
|
389 |
-
}
|
390 |
-
}
|
391 |
-
|
392 |
-
/**
|
393 |
-
* PAYPAL Function
|
394 |
-
* Send HTTP POST Request
|
395 |
-
*
|
396 |
-
* @param string The API method name
|
397 |
-
* @param string The POST Message fields in &name=value pair format
|
398 |
-
* @return array Parsed HTTP Response body
|
399 |
-
*/
|
400 |
-
function PPHttpPost($methodName_, $nvpStr_) {
|
401 |
-
global $gateway_environment;
|
402 |
-
$environment = $gateway_environment;
|
403 |
-
|
404 |
-
$API_UserName = pmpro_getOption("apiusername");
|
405 |
-
$API_Password = pmpro_getOption("apipassword");
|
406 |
-
$API_Signature = pmpro_getOption("apisignature");
|
407 |
-
$API_Endpoint = "https://api-3t.paypal.com/nvp";
|
408 |
-
if("sandbox" === $environment || "beta-sandbox" === $environment) {
|
409 |
-
$API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
|
410 |
-
}
|
411 |
-
|
412 |
-
$version = urlencode('72.0');
|
413 |
-
|
414 |
-
// setting the curl parameters.
|
415 |
-
$ch = curl_init();
|
416 |
-
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
|
417 |
-
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
418 |
-
|
419 |
-
// turning off the server and peer verification(TrustManager Concept).
|
420 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
421 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
422 |
-
|
423 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
424 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
425 |
-
|
426 |
-
// NVPRequest for submitting to server
|
427 |
-
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
|
428 |
-
|
429 |
-
// setting the nvpreq as POST FIELD to curl
|
430 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
|
431 |
-
|
432 |
-
// getting response from server
|
433 |
-
$httpResponse = curl_exec($ch);
|
434 |
-
|
435 |
-
if(empty($httpResponse)) {
|
436 |
-
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
|
437 |
-
}
|
438 |
-
|
439 |
-
// Extract the RefundTransaction response details
|
440 |
-
$httpResponseAr = explode("&", $httpResponse);
|
441 |
-
|
442 |
-
$httpParsedResponseAr = array();
|
443 |
-
foreach ($httpResponseAr as $i => $value) {
|
444 |
-
$tmpAr = explode("=", $value);
|
445 |
-
if(sizeof($tmpAr) > 1) {
|
446 |
-
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
|
447 |
-
}
|
448 |
-
}
|
449 |
-
|
450 |
-
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
|
451 |
-
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
|
452 |
-
}
|
453 |
-
|
454 |
-
return $httpParsedResponseAr;
|
455 |
-
}
|
456 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_paypalexpress.php
DELETED
@@ -1,402 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
class PMProGateway_paypalexpress
|
4 |
-
{
|
5 |
-
function PMProGateway_paypalexpress($gateway = NULL)
|
6 |
-
{
|
7 |
-
$this->gateway = $gateway;
|
8 |
-
return $this->gateway;
|
9 |
-
}
|
10 |
-
|
11 |
-
function process(&$order)
|
12 |
-
{
|
13 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
14 |
-
{
|
15 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
16 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
17 |
-
return $this->subscribe($order);
|
18 |
-
}
|
19 |
-
else
|
20 |
-
return $this->charge($order);
|
21 |
-
}
|
22 |
-
|
23 |
-
//PayPal Express, this is run first to authorize from PayPal
|
24 |
-
function setExpressCheckout(&$order)
|
25 |
-
{
|
26 |
-
global $pmpro_currency;
|
27 |
-
|
28 |
-
if(empty($order->code))
|
29 |
-
$order->code = $order->getRandomCode();
|
30 |
-
|
31 |
-
//clean up a couple values
|
32 |
-
$order->payment_type = "PayPal Express";
|
33 |
-
$order->CardType = "";
|
34 |
-
$order->cardtype = "";
|
35 |
-
|
36 |
-
//taxes on initial amount
|
37 |
-
$initial_payment = $order->InitialPayment;
|
38 |
-
$initial_payment_tax = $order->getTaxForPrice($initial_payment);
|
39 |
-
$initial_payment = round((float)$initial_payment + (float)$initial_payment_tax, 2);
|
40 |
-
|
41 |
-
//taxes on the amount
|
42 |
-
$amount = $order->PaymentAmount;
|
43 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
44 |
-
$order->subtotal = $amount;
|
45 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
46 |
-
|
47 |
-
//paypal profile stuff
|
48 |
-
$nvpStr = "";
|
49 |
-
$nvpStr .="&AMT=" . $initial_payment . "&CURRENCYCODE=" . $pmpro_currency;
|
50 |
-
if(!empty($order->ProfileStartDate) && strtotime($order->ProfileStartDate, current_time("timestamp")) > 0)
|
51 |
-
$nvpStr .= "&PROFILESTARTDATE=" . $order->ProfileStartDate;
|
52 |
-
if(!empty($order->BillingFrequency))
|
53 |
-
$nvpStr .= "&BILLINGPERIOD=" . $order->BillingPeriod . "&BILLINGFREQUENCY=" . $order->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling&L_BILLINGTYPE0=RecurringPayments";
|
54 |
-
$nvpStr .= "&DESC=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127));
|
55 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
56 |
-
$nvpStr .= "&NOSHIPPING=1&L_BILLINGAGREEMENTDESCRIPTION0=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127)) . "&L_PAYMENTTYPE0=Any";
|
57 |
-
|
58 |
-
//if billing cycles are defined
|
59 |
-
if(!empty($order->TotalBillingCycles))
|
60 |
-
$nvpStr .= "&TOTALBILLINGCYCLES=" . $order->TotalBillingCycles;
|
61 |
-
|
62 |
-
//if a trial period is defined
|
63 |
-
if(!empty($order->TrialBillingPeriod))
|
64 |
-
{
|
65 |
-
$trial_amount = $order->TrialAmount;
|
66 |
-
$trial_tax = $order->getTaxForPrice($trial_amount);
|
67 |
-
$trial_amount = round((float)$trial_amount + (float)$trial_tax, 2);
|
68 |
-
|
69 |
-
$nvpStr .= "&TRIALBILLINGPERIOD=" . $order->TrialBillingPeriod . "&TRIALBILLINGFREQUENCY=" . $order->TrialBillingFrequency . "&TRIALAMT=" . $trial_amount;
|
70 |
-
}
|
71 |
-
if(!empty($order->TrialBillingCycles))
|
72 |
-
$nvpStr .= "&TRIALTOTALBILLINGCYCLES=" . $order->TrialBillingCycles;
|
73 |
-
|
74 |
-
if(!empty($order->discount_code))
|
75 |
-
{
|
76 |
-
$nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?level=" . $order->membership_level->id . "&discount_code=" . $order->discount_code . "&review=" . $order->code));
|
77 |
-
}
|
78 |
-
else
|
79 |
-
{
|
80 |
-
$nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?level=" . $order->membership_level->id . "&review=" . $order->code));
|
81 |
-
}
|
82 |
-
|
83 |
-
$additional_parameters = apply_filters("pmpro_paypal_express_return_url_parameters", array());
|
84 |
-
if(!empty($additional_parameters))
|
85 |
-
{
|
86 |
-
foreach($additional_parameters as $key => $value)
|
87 |
-
$nvpStr .= urlencode("&" . $key . "=" . $value);
|
88 |
-
}
|
89 |
-
|
90 |
-
$nvpStr .= "&CANCELURL=" . urlencode(pmpro_url("levels"));
|
91 |
-
|
92 |
-
$account_optional = apply_filters('pmpro_paypal_account_optional', true);
|
93 |
-
if ($account_optional)
|
94 |
-
$nvpStr .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing';
|
95 |
-
|
96 |
-
$nvpStr = apply_filters("pmpro_set_express_checkout_nvpstr", $nvpStr, $order);
|
97 |
-
|
98 |
-
///echo str_replace("&", "&<br />", $nvpStr);
|
99 |
-
///exit;
|
100 |
-
|
101 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('SetExpressCheckout', $nvpStr);
|
102 |
-
|
103 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
104 |
-
$order->status = "token";
|
105 |
-
$order->paypal_token = urldecode($this->httpParsedResponseAr['TOKEN']);
|
106 |
-
$order->subscription_transaction_id = urldecode($this->httpParsedResponseAr['PROFILEID']);
|
107 |
-
|
108 |
-
//update order
|
109 |
-
$order->saveOrder();
|
110 |
-
|
111 |
-
//redirect to paypal
|
112 |
-
$paypal_url = "https://www.paypal.com/webscr&cmd=_express-checkout&useraction=commit&token=" . $this->httpParsedResponseAr['TOKEN'];
|
113 |
-
$environment = pmpro_getOption("gateway_environment");
|
114 |
-
if("sandbox" === $environment || "beta-sandbox" === $environment)
|
115 |
-
{
|
116 |
-
$paypal_url = "https://www.sandbox.paypal.com/webscr&useraction=commit&cmd=_express-checkout&token=" . $this->httpParsedResponseAr['TOKEN'];
|
117 |
-
}
|
118 |
-
|
119 |
-
wp_redirect($paypal_url);
|
120 |
-
exit;
|
121 |
-
|
122 |
-
//exit('SetExpressCheckout Completed Successfully: '.print_r($this->httpParsedResponseAr, true));
|
123 |
-
} else {
|
124 |
-
$order->status = "error";
|
125 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
126 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
127 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
128 |
-
return false;
|
129 |
-
//exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
|
130 |
-
}
|
131 |
-
|
132 |
-
//write session?
|
133 |
-
|
134 |
-
//redirect to PayPal
|
135 |
-
}
|
136 |
-
|
137 |
-
function getExpressCheckoutDetails(&$order)
|
138 |
-
{
|
139 |
-
$nvpStr="&TOKEN=".$order->Token;
|
140 |
-
|
141 |
-
/* Make the API call and store the results in an array. If the
|
142 |
-
call was a success, show the authorization details, and provide
|
143 |
-
an action to complete the payment. If failed, show the error
|
144 |
-
*/
|
145 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('GetExpressCheckoutDetails', $nvpStr);
|
146 |
-
|
147 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
148 |
-
$order->status = "review";
|
149 |
-
|
150 |
-
//update order
|
151 |
-
$order->saveOrder();
|
152 |
-
|
153 |
-
return true;
|
154 |
-
} else {
|
155 |
-
$order->status = "error";
|
156 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
157 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
158 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
159 |
-
return false;
|
160 |
-
//exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
function charge(&$order)
|
165 |
-
{
|
166 |
-
global $pmpro_currency;
|
167 |
-
|
168 |
-
if(empty($order->code))
|
169 |
-
$order->code = $order->getRandomCode();
|
170 |
-
|
171 |
-
//taxes on the amount
|
172 |
-
$amount = $order->InitialPayment;
|
173 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
174 |
-
$order->subtotal = $amount;
|
175 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
176 |
-
|
177 |
-
//paypal profile stuff
|
178 |
-
$nvpStr = "";
|
179 |
-
if(!empty($order->Token))
|
180 |
-
$nvpStr .= "&TOKEN=" . $order->Token;
|
181 |
-
$nvpStr .="&AMT=" . $amount . "&CURRENCYCODE=" . $pmpro_currency;
|
182 |
-
/*
|
183 |
-
if(!empty($amount_tax))
|
184 |
-
$nvpStr .= "&TAXAMT=" . $amount_tax;
|
185 |
-
*/
|
186 |
-
if(!empty($order->BillingFrequency))
|
187 |
-
$nvpStr .= "&BILLINGPERIOD=" . $order->BillingPeriod . "&BILLINGFREQUENCY=" . $order->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling";
|
188 |
-
$nvpStr .= "&DESC=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127));
|
189 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
190 |
-
$nvpStr .= "&NOSHIPPING=1";
|
191 |
-
|
192 |
-
$nvpStr .= "&PAYERID=" . $_SESSION['payer_id'] . "&PAYMENTACTION=sale";
|
193 |
-
$order->nvpStr = $nvpStr;
|
194 |
-
|
195 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('DoExpressCheckoutPayment', $nvpStr);
|
196 |
-
|
197 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
198 |
-
$order->payment_transaction_id = urldecode($this->httpParsedResponseAr['TRANSACTIONID']);
|
199 |
-
$order->status = "success";
|
200 |
-
|
201 |
-
//update order
|
202 |
-
$order->saveOrder();
|
203 |
-
|
204 |
-
return true;
|
205 |
-
} else {
|
206 |
-
$order->status = "error";
|
207 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
208 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
209 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
210 |
-
return false;
|
211 |
-
//exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
function subscribe(&$order)
|
216 |
-
{
|
217 |
-
global $pmpro_currency;
|
218 |
-
|
219 |
-
if(empty($order->code))
|
220 |
-
$order->code = $order->getRandomCode();
|
221 |
-
|
222 |
-
//filter order before subscription. use with care.
|
223 |
-
$order = apply_filters("pmpro_subscribe_order", $order, $this);
|
224 |
-
|
225 |
-
//taxes on initial amount
|
226 |
-
$initial_payment = $order->InitialPayment;
|
227 |
-
$initial_payment_tax = $order->getTaxForPrice($initial_payment);
|
228 |
-
$initial_payment = round((float)$initial_payment + (float)$initial_payment_tax, 2);
|
229 |
-
|
230 |
-
//taxes on the amount
|
231 |
-
$amount = $order->PaymentAmount;
|
232 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
233 |
-
//$amount = round((float)$amount + (float)$amount_tax, 2);
|
234 |
-
|
235 |
-
//paypal profile stuff
|
236 |
-
$nvpStr = "";
|
237 |
-
if(!empty($order->Token))
|
238 |
-
$nvpStr .= "&TOKEN=" . $order->Token;
|
239 |
-
$nvpStr .="&INITAMT=" . $initial_payment . "&AMT=" . $amount . "&CURRENCYCODE=" . $pmpro_currency . "&PROFILESTARTDATE=" . $order->ProfileStartDate;
|
240 |
-
if(!empty($amount_tax))
|
241 |
-
$nvpStr .= "&TAXAMT=" . $amount_tax;
|
242 |
-
$nvpStr .= "&BILLINGPERIOD=" . $order->BillingPeriod . "&BILLINGFREQUENCY=" . $order->BillingFrequency . "&AUTOBILLAMT=AddToNextBilling";
|
243 |
-
$nvpStr .= "&NOTIFYURL=" . urlencode(admin_url('admin-ajax.php') . "?action=ipnhandler");
|
244 |
-
$nvpStr .= "&DESC=" . urlencode(substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127));
|
245 |
-
|
246 |
-
//if billing cycles are defined
|
247 |
-
if($order->TotalBillingCycles)
|
248 |
-
$nvpStr .= "&TOTALBILLINGCYCLES=" . $order->TotalBillingCycles;
|
249 |
-
|
250 |
-
//if a trial period is defined
|
251 |
-
if(!empty($order->TrialBillingPeriod))
|
252 |
-
{
|
253 |
-
$trial_amount = $order->TrialAmount;
|
254 |
-
$trial_tax = $order->getTaxForPrice($trial_amount);
|
255 |
-
$trial_amount = round((float)$trial_amount + (float)$trial_tax, 2);
|
256 |
-
|
257 |
-
$nvpStr .= "&TRIALBILLINGPERIOD=" . $order->TrialBillingPeriod . "&TRIALBILLINGFREQUENCY=" . $order->TrialBillingFrequency . "&TRIALAMT=" . $trial_amount;
|
258 |
-
}
|
259 |
-
if(!empty($order->TrialBillingCycles))
|
260 |
-
$nvpStr .= "&TRIALTOTALBILLINGCYCLES=" . $order->TrialBillingCycles;
|
261 |
-
|
262 |
-
$this->nvpStr = $nvpStr;
|
263 |
-
|
264 |
-
///echo str_replace("&", "&<br />", $nvpStr);
|
265 |
-
///exit;
|
266 |
-
|
267 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
|
268 |
-
|
269 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"])) {
|
270 |
-
$order->status = "success";
|
271 |
-
$order->payment_transaction_id = urldecode($this->httpParsedResponseAr['PROFILEID']);
|
272 |
-
$order->subscription_transaction_id = urldecode($this->httpParsedResponseAr['PROFILEID']);
|
273 |
-
|
274 |
-
//update order
|
275 |
-
$order->saveOrder();
|
276 |
-
|
277 |
-
return true;
|
278 |
-
} else {
|
279 |
-
$order->status = "error";
|
280 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
281 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
282 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
283 |
-
|
284 |
-
return false;
|
285 |
-
}
|
286 |
-
}
|
287 |
-
|
288 |
-
function cancel(&$order)
|
289 |
-
{
|
290 |
-
//paypal profile stuff
|
291 |
-
$nvpStr = "";
|
292 |
-
$nvpStr .= "&PROFILEID=" . urlencode($order->subscription_transaction_id) . "&ACTION=Cancel&NOTE=" . urlencode("User requested cancel.");
|
293 |
-
|
294 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('ManageRecurringPaymentsProfileStatus', $nvpStr);
|
295 |
-
|
296 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"]))
|
297 |
-
{
|
298 |
-
$order->updateStatus("cancelled");
|
299 |
-
return true;
|
300 |
-
}
|
301 |
-
else
|
302 |
-
{
|
303 |
-
$order->status = "error";
|
304 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
305 |
-
$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.", "pmpro");
|
306 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
307 |
-
|
308 |
-
return false;
|
309 |
-
}
|
310 |
-
}
|
311 |
-
|
312 |
-
function getSubscriptionStatus(&$order)
|
313 |
-
{
|
314 |
-
if(empty($order->subscription_transaction_id))
|
315 |
-
return false;
|
316 |
-
|
317 |
-
//paypal profile stuff
|
318 |
-
$nvpStr = "";
|
319 |
-
$nvpStr .= "&PROFILEID=" . urlencode($order->subscription_transaction_id);
|
320 |
-
|
321 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('GetRecurringPaymentsProfileDetails', $nvpStr);
|
322 |
-
|
323 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"]))
|
324 |
-
{
|
325 |
-
return $this->httpParsedResponseAr;
|
326 |
-
}
|
327 |
-
else
|
328 |
-
{
|
329 |
-
$order->status = "error";
|
330 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
331 |
-
$order->error = urldecode($this->httpParsedResponseAr['L_LONGMESSAGE0']);
|
332 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
333 |
-
|
334 |
-
return false;
|
335 |
-
}
|
336 |
-
}
|
337 |
-
|
338 |
-
/**
|
339 |
-
* PAYPAL Function
|
340 |
-
* Send HTTP POST Request
|
341 |
-
*
|
342 |
-
* @param string The API method name
|
343 |
-
* @param string The POST Message fields in &name=value pair format
|
344 |
-
* @return array Parsed HTTP Response body
|
345 |
-
*/
|
346 |
-
function PPHttpPost($methodName_, $nvpStr_) {
|
347 |
-
global $gateway_environment;
|
348 |
-
$environment = $gateway_environment;
|
349 |
-
|
350 |
-
$API_UserName = pmpro_getOption("apiusername");
|
351 |
-
$API_Password = pmpro_getOption("apipassword");
|
352 |
-
$API_Signature = pmpro_getOption("apisignature");
|
353 |
-
$API_Endpoint = "https://api-3t.paypal.com/nvp";
|
354 |
-
if("sandbox" === $environment || "beta-sandbox" === $environment) {
|
355 |
-
$API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
|
356 |
-
}
|
357 |
-
|
358 |
-
$version = urlencode('72.0');
|
359 |
-
|
360 |
-
// setting the curl parameters.
|
361 |
-
$ch = curl_init();
|
362 |
-
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
|
363 |
-
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
364 |
-
|
365 |
-
// turning off the server and peer verification(TrustManager Concept).
|
366 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
367 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
368 |
-
|
369 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
370 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
371 |
-
|
372 |
-
// NVPRequest for submitting to server
|
373 |
-
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
|
374 |
-
|
375 |
-
// setting the nvpreq as POST FIELD to curl
|
376 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
|
377 |
-
|
378 |
-
// getting response from server
|
379 |
-
$httpResponse = curl_exec($ch);
|
380 |
-
|
381 |
-
if(!$httpResponse) {
|
382 |
-
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
|
383 |
-
}
|
384 |
-
|
385 |
-
// Extract the RefundTransaction response details
|
386 |
-
$httpResponseAr = explode("&", $httpResponse);
|
387 |
-
|
388 |
-
$httpParsedResponseAr = array();
|
389 |
-
foreach ($httpResponseAr as $i => $value) {
|
390 |
-
$tmpAr = explode("=", $value);
|
391 |
-
if(sizeof($tmpAr) > 1) {
|
392 |
-
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
|
393 |
-
}
|
394 |
-
}
|
395 |
-
|
396 |
-
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
|
397 |
-
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
|
398 |
-
}
|
399 |
-
|
400 |
-
return $httpParsedResponseAr;
|
401 |
-
}
|
402 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_paypalstandard.php
DELETED
@@ -1,302 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
class PMProGateway_paypalstandard
|
4 |
-
{
|
5 |
-
function PMProGateway_paypalstandard($gateway = NULL)
|
6 |
-
{
|
7 |
-
$this->gateway = $gateway;
|
8 |
-
return $this->gateway;
|
9 |
-
}
|
10 |
-
|
11 |
-
function process(&$order)
|
12 |
-
{
|
13 |
-
if(empty($order->code))
|
14 |
-
$order->code = $order->getRandomCode();
|
15 |
-
|
16 |
-
//clean up a couple values
|
17 |
-
$order->payment_type = "PayPal Standard";
|
18 |
-
$order->CardType = "";
|
19 |
-
$order->cardtype = "";
|
20 |
-
|
21 |
-
//just save, the user will go to PayPal to pay
|
22 |
-
$order->status = "review";
|
23 |
-
$order->saveOrder();
|
24 |
-
|
25 |
-
return true;
|
26 |
-
}
|
27 |
-
|
28 |
-
function sendToPayPal(&$order)
|
29 |
-
{
|
30 |
-
global $pmpro_currency;
|
31 |
-
|
32 |
-
//taxes on initial amount
|
33 |
-
$initial_payment = $order->InitialPayment;
|
34 |
-
$initial_payment_tax = $order->getTaxForPrice($initial_payment);
|
35 |
-
$initial_payment = round((float)$initial_payment + (float)$initial_payment_tax, 2);
|
36 |
-
|
37 |
-
//taxes on the amount
|
38 |
-
$amount = $order->PaymentAmount;
|
39 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
40 |
-
$order->subtotal = $amount;
|
41 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
42 |
-
|
43 |
-
//build PayPal Redirect
|
44 |
-
$environment = pmpro_getOption("gateway_environment");
|
45 |
-
if("sandbox" === $environment || "beta-sandbox" === $environment)
|
46 |
-
$paypal_url ="https://www.sandbox.paypal.com/cgi-bin/webscr?business=" . urlencode(pmpro_getOption("gateway_email"));
|
47 |
-
else
|
48 |
-
$paypal_url = "https://www.paypal.com/cgi-bin/webscr?business=" . urlencode(pmpro_getOption("gateway_email"));
|
49 |
-
|
50 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
51 |
-
{
|
52 |
-
//convert billing period
|
53 |
-
if($order->BillingPeriod == "Day")
|
54 |
-
$period = "D";
|
55 |
-
elseif($order->BillingPeriod == "Week")
|
56 |
-
$period = "W";
|
57 |
-
elseif($order->BillingPeriod == "Month")
|
58 |
-
$period = "M";
|
59 |
-
elseif($order->BillingPeriod == "Year")
|
60 |
-
$period = "Y";
|
61 |
-
else
|
62 |
-
{
|
63 |
-
$order->error = "Invalid billing period: " . $order->BillingPeriod;
|
64 |
-
$order->shorterror = "Invalid billing period: " . $order->BillingPeriod;
|
65 |
-
return false;
|
66 |
-
}
|
67 |
-
|
68 |
-
//other args
|
69 |
-
$paypal_args = array(
|
70 |
-
'cmd' => '_xclick-subscriptions',
|
71 |
-
'a1' => number_format($initial_payment, 2),
|
72 |
-
'p1' => $order->BillingFrequency,
|
73 |
-
't1' => $period,
|
74 |
-
'a3' => number_format($amount, 2),
|
75 |
-
'p3' => $order->BillingFrequency,
|
76 |
-
't3' => $period,
|
77 |
-
'item_name' => substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127),
|
78 |
-
'email' => $order->Email,
|
79 |
-
'no_shipping' => '1',
|
80 |
-
'shipping' => '0',
|
81 |
-
'no_note' => '1',
|
82 |
-
'currency_code' => $pmpro_currency,
|
83 |
-
'item_number' => $order->code,
|
84 |
-
'charset' => get_bloginfo( 'charset' ),
|
85 |
-
'rm' => '2',
|
86 |
-
'return' => pmpro_url("confirmation", "?level=" . $order->membership_level->id),
|
87 |
-
'notify_url' => admin_url("admin-ajax.php") . "?action=ipnhandler",
|
88 |
-
'src' => '1',
|
89 |
-
'sra' => '1'
|
90 |
-
);
|
91 |
-
|
92 |
-
//trial?
|
93 |
-
/*
|
94 |
-
Note here that the TrialBillingCycles value is being ignored. PayPal Standard only offers 1 payment during each trial period.
|
95 |
-
*/
|
96 |
-
if(!empty($order->TrialBillingPeriod))
|
97 |
-
{
|
98 |
-
//if a1 and a2 are 0, let's just combine them. PayPal doesn't like a2 = 0.
|
99 |
-
if($paypal_args['a1'] == 0 && $order->TrialAmount == 0)
|
100 |
-
{
|
101 |
-
$paypal_args['p1'] = $paypal_args['p1'] + $order->TrialBillingFrequency;
|
102 |
-
}
|
103 |
-
else
|
104 |
-
{
|
105 |
-
$trial_amount = $order->TrialAmount;
|
106 |
-
$trial_tax = $order->getTaxForPrice($trial_amount);
|
107 |
-
$trial_amount = round((float)$trial_amount + (float)$trial_tax, 2);
|
108 |
-
|
109 |
-
$paypal_args['a2'] = $trial_amount;
|
110 |
-
$paypal_args['p2'] = $order->TrialBillingFrequency;
|
111 |
-
$paypal_args['t2'] = $period;
|
112 |
-
}
|
113 |
-
}
|
114 |
-
else
|
115 |
-
{
|
116 |
-
//we can try to work in any change in ProfileStartDate
|
117 |
-
$psd = date("Y-m-d", strtotime("+ " . $order->BillingFrequency . " " . $order->BillingPeriod, current_time("timestamp"))) . "T0:0:0";
|
118 |
-
$adjusted_psd = apply_filters("pmpro_profile_start_date", $psd, $order);
|
119 |
-
if($psd != $adjusted_psd)
|
120 |
-
{
|
121 |
-
//someone is trying to push the start date back
|
122 |
-
$adjusted_psd_time = strtotime($adjusted_psd, current_time("timestamp"));
|
123 |
-
$seconds_til_psd = $adjusted_psd_time - current_time('timestamp');
|
124 |
-
$days_til_psd = floor($seconds_til_psd/(60*60*24));
|
125 |
-
|
126 |
-
//push back trial one by days_til_psd
|
127 |
-
if($days_til_psd > 90)
|
128 |
-
{
|
129 |
-
//we need to convert to weeks, because PayPal limits t1 to 90 days
|
130 |
-
$weeks_til_psd = round($days_til_psd / 7);
|
131 |
-
$paypal_args['p1'] = $weeks_til_psd;
|
132 |
-
$paypal_args['t1'] = "W";
|
133 |
-
}
|
134 |
-
elseif($days_til_psd > 0)
|
135 |
-
{
|
136 |
-
//use days
|
137 |
-
$paypal_args['p1'] = $days_til_psd;
|
138 |
-
$paypal_args['t1'] = "D";
|
139 |
-
}
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
//billing limit?
|
144 |
-
if(!empty($order->TotalBillingCycles))
|
145 |
-
{
|
146 |
-
if(!empty($trial_amount))
|
147 |
-
{
|
148 |
-
|
149 |
-
$srt = intval($order->TotalBillingCycles) - 1; //subtract one for the trial period
|
150 |
-
}
|
151 |
-
else
|
152 |
-
{
|
153 |
-
$srt = intval($order->TotalBillingCycles);
|
154 |
-
}
|
155 |
-
|
156 |
-
//srt must be at least 2 or the subscription is not "recurring" according to paypal
|
157 |
-
if($srt > 1)
|
158 |
-
$paypal_args['srt'] = $srt;
|
159 |
-
else
|
160 |
-
$paypal_args['src'] = '0';
|
161 |
-
}
|
162 |
-
else
|
163 |
-
$paypal_args['srt'] = '0'; //indefinite subscription
|
164 |
-
}
|
165 |
-
else
|
166 |
-
{
|
167 |
-
//other args
|
168 |
-
$paypal_args = array(
|
169 |
-
'cmd' => '_xclick',
|
170 |
-
'amount' => number_format($initial_payment, 2),
|
171 |
-
'item_name' => substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127),
|
172 |
-
'email' => $order->Email,
|
173 |
-
'no_shipping' => '1',
|
174 |
-
'shipping' => '0',
|
175 |
-
'no_note' => '1',
|
176 |
-
'currency_code' => $pmpro_currency,
|
177 |
-
'item_number' => $order->code,
|
178 |
-
'charset' => get_bloginfo( 'charset' ),
|
179 |
-
'rm' => '2',
|
180 |
-
'return' => pmpro_url("confirmation", "?level=" . $order->membership_level->id),
|
181 |
-
'notify_url' => admin_url("admin-ajax.php") . "?action=ipnhandler"
|
182 |
-
);
|
183 |
-
}
|
184 |
-
|
185 |
-
$nvpStr = "";
|
186 |
-
foreach($paypal_args as $key => $value)
|
187 |
-
{
|
188 |
-
$nvpStr .= "&" . $key . "=" . urlencode($value);
|
189 |
-
}
|
190 |
-
|
191 |
-
//anything modders might add
|
192 |
-
$additional_parameters = apply_filters("pmpro_paypal_express_return_url_parameters", array());
|
193 |
-
if(!empty($additional_parameters))
|
194 |
-
{
|
195 |
-
foreach($additional_parameters as $key => $value)
|
196 |
-
$nvpStr .= urlencode("&" . $key . "=" . $value);
|
197 |
-
}
|
198 |
-
|
199 |
-
$account_optional = apply_filters('pmpro_paypal_account_optional', true);
|
200 |
-
if ($account_optional)
|
201 |
-
$nvpStr .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing';
|
202 |
-
|
203 |
-
$nvpStr = apply_filters("pmpro_paypal_standard_nvpstr", $nvpStr, $order);
|
204 |
-
|
205 |
-
//redirect to paypal
|
206 |
-
$paypal_url .= $nvpStr;
|
207 |
-
|
208 |
-
//wp_die(str_replace("&", "<br />", $paypal_url));
|
209 |
-
|
210 |
-
wp_redirect($paypal_url);
|
211 |
-
exit;
|
212 |
-
}
|
213 |
-
|
214 |
-
function cancel(&$order)
|
215 |
-
{
|
216 |
-
//paypal profile stuff
|
217 |
-
$nvpStr = "";
|
218 |
-
$nvpStr .= "&PROFILEID=" . urlencode($order->subscription_transaction_id) . "&ACTION=Cancel&NOTE=" . urlencode("User requested cancel.");
|
219 |
-
|
220 |
-
$this->httpParsedResponseAr = $this->PPHttpPost('ManageRecurringPaymentsProfileStatus', $nvpStr);
|
221 |
-
|
222 |
-
if("SUCCESS" == strtoupper($this->httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($this->httpParsedResponseAr["ACK"]))
|
223 |
-
{
|
224 |
-
$order->updateStatus("cancelled");
|
225 |
-
return true;
|
226 |
-
}
|
227 |
-
else
|
228 |
-
{
|
229 |
-
$order->status = "error";
|
230 |
-
$order->errorcode = $this->httpParsedResponseAr['L_ERRORCODE0'];
|
231 |
-
$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.", "pmpro");
|
232 |
-
$order->shorterror = urldecode($this->httpParsedResponseAr['L_SHORTMESSAGE0']);
|
233 |
-
|
234 |
-
return false;
|
235 |
-
}
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* PAYPAL Function
|
240 |
-
* Send HTTP POST Request
|
241 |
-
*
|
242 |
-
* @param string The API method name
|
243 |
-
* @param string The POST Message fields in &name=value pair format
|
244 |
-
* @return array Parsed HTTP Response body
|
245 |
-
*/
|
246 |
-
function PPHttpPost($methodName_, $nvpStr_) {
|
247 |
-
global $gateway_environment;
|
248 |
-
$environment = $gateway_environment;
|
249 |
-
|
250 |
-
$API_UserName = pmpro_getOption("apiusername");
|
251 |
-
$API_Password = pmpro_getOption("apipassword");
|
252 |
-
$API_Signature = pmpro_getOption("apisignature");
|
253 |
-
$API_Endpoint = "https://api-3t.paypal.com/nvp";
|
254 |
-
if("sandbox" === $environment || "beta-sandbox" === $environment) {
|
255 |
-
$API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
|
256 |
-
}
|
257 |
-
|
258 |
-
$version = urlencode('72.0');
|
259 |
-
|
260 |
-
// setting the curl parameters.
|
261 |
-
$ch = curl_init();
|
262 |
-
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
|
263 |
-
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
264 |
-
|
265 |
-
// turning off the server and peer verification(TrustManager Concept).
|
266 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
267 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
268 |
-
|
269 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
270 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
271 |
-
|
272 |
-
// NVPRequest for submitting to server
|
273 |
-
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
|
274 |
-
|
275 |
-
// setting the nvpreq as POST FIELD to curl
|
276 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
|
277 |
-
|
278 |
-
// getting response from server
|
279 |
-
$httpResponse = curl_exec($ch);
|
280 |
-
|
281 |
-
if(!$httpResponse) {
|
282 |
-
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
|
283 |
-
}
|
284 |
-
|
285 |
-
// Extract the RefundTransaction response details
|
286 |
-
$httpResponseAr = explode("&", $httpResponse);
|
287 |
-
|
288 |
-
$httpParsedResponseAr = array();
|
289 |
-
foreach ($httpResponseAr as $i => $value) {
|
290 |
-
$tmpAr = explode("=", $value);
|
291 |
-
if(sizeof($tmpAr) > 1) {
|
292 |
-
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
|
293 |
-
}
|
294 |
-
}
|
295 |
-
|
296 |
-
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
|
297 |
-
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
|
298 |
-
}
|
299 |
-
|
300 |
-
return $httpParsedResponseAr;
|
301 |
-
}
|
302 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_stripe.php
DELETED
@@ -1,407 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
if(!class_exists("Stripe"))
|
4 |
-
require_once(dirname(__FILE__) . "/../../includes/lib/Stripe/Stripe.php");
|
5 |
-
class PMProGateway_stripe
|
6 |
-
{
|
7 |
-
function PMProGateway_stripe($gateway = NULL)
|
8 |
-
{
|
9 |
-
$this->gateway = $gateway;
|
10 |
-
$this->gateway_environment = pmpro_getOption("gateway_environment");
|
11 |
-
|
12 |
-
Stripe::setApiKey(pmpro_getOption("stripe_secretkey"));
|
13 |
-
|
14 |
-
return $this->gateway;
|
15 |
-
}
|
16 |
-
|
17 |
-
function process(&$order)
|
18 |
-
{
|
19 |
-
//check for initial payment
|
20 |
-
if(floatval($order->InitialPayment) == 0)
|
21 |
-
{
|
22 |
-
//just subscribe
|
23 |
-
return $this->subscribe($order);
|
24 |
-
}
|
25 |
-
else
|
26 |
-
{
|
27 |
-
//charge then subscribe
|
28 |
-
if($this->charge($order))
|
29 |
-
{
|
30 |
-
if(pmpro_isLevelRecurring($order->membership_level))
|
31 |
-
{
|
32 |
-
if($this->subscribe($order))
|
33 |
-
{
|
34 |
-
//yay!
|
35 |
-
return true;
|
36 |
-
}
|
37 |
-
else
|
38 |
-
{
|
39 |
-
//try to refund initial charge
|
40 |
-
return false;
|
41 |
-
}
|
42 |
-
}
|
43 |
-
else
|
44 |
-
{
|
45 |
-
//only a one time charge
|
46 |
-
$order->status = "success"; //saved on checkout page
|
47 |
-
return true;
|
48 |
-
}
|
49 |
-
}
|
50 |
-
else
|
51 |
-
{
|
52 |
-
if(empty($order->error))
|
53 |
-
$order->error = __("Unknown error: Initial payment failed.", "pmpro");
|
54 |
-
return false;
|
55 |
-
}
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
function charge(&$order)
|
60 |
-
{
|
61 |
-
global $pmpro_currency;
|
62 |
-
|
63 |
-
//create a code for the order
|
64 |
-
if(empty($order->code))
|
65 |
-
$order->code = $order->getRandomCode();
|
66 |
-
|
67 |
-
//what amount to charge?
|
68 |
-
$amount = $order->InitialPayment;
|
69 |
-
|
70 |
-
//tax
|
71 |
-
$order->subtotal = $amount;
|
72 |
-
$tax = $order->getTax(true);
|
73 |
-
$amount = round((float)$order->subtotal + (float)$tax, 2);
|
74 |
-
|
75 |
-
//create a customer
|
76 |
-
$this->getCustomer($order);
|
77 |
-
if(empty($this->customer))
|
78 |
-
{
|
79 |
-
//failed to create customer
|
80 |
-
return false;
|
81 |
-
}
|
82 |
-
|
83 |
-
//charge
|
84 |
-
try
|
85 |
-
{
|
86 |
-
$response = Stripe_Charge::create(array(
|
87 |
-
"amount" => $amount * 100, # amount in cents, again
|
88 |
-
"currency" => $pmpro_currency,
|
89 |
-
"customer" => $this->customer->id,
|
90 |
-
"description" => "Order #" . $order->code . ", " . trim($order->FirstName . " " . $order->LastName) . " (" . $order->Email . ")"
|
91 |
-
)
|
92 |
-
);
|
93 |
-
}
|
94 |
-
catch (Exception $e)
|
95 |
-
{
|
96 |
-
//$order->status = "error";
|
97 |
-
$order->errorcode = true;
|
98 |
-
$order->error = "Error: " . $e->getMessage();
|
99 |
-
$order->shorterror = $order->error;
|
100 |
-
return false;
|
101 |
-
}
|
102 |
-
|
103 |
-
if(empty($response["failure_message"]))
|
104 |
-
{
|
105 |
-
//successful charge
|
106 |
-
$order->payment_transaction_id = $response["id"];
|
107 |
-
$order->updateStatus("success");
|
108 |
-
return true;
|
109 |
-
}
|
110 |
-
else
|
111 |
-
{
|
112 |
-
//$order->status = "error";
|
113 |
-
$order->errorcode = true;
|
114 |
-
$order->error = $response['failure_message'];
|
115 |
-
$order->shorterror = $response['failure_message'];
|
116 |
-
return false;
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
/*
|
121 |
-
This function will return a Stripe customer object.
|
122 |
-
If $this->customer is set, it returns it.
|
123 |
-
It first checks if the order has a subscription_transaction_id. If so, that's the customer id.
|
124 |
-
If not, it checks for a user_id on the order and searches for a customer id in the user meta.
|
125 |
-
If a customer id is found, it checks for a customer through the Stripe API.
|
126 |
-
If a customer is found and there is a stripeToken on the order passed, it will update the customer.
|
127 |
-
If no customer is found and there is a stripeToken on the order passed, it will create a customer.
|
128 |
-
*/
|
129 |
-
function getCustomer(&$order, $force = false)
|
130 |
-
{
|
131 |
-
global $current_user;
|
132 |
-
|
133 |
-
//already have it?
|
134 |
-
if(!empty($this->customer) && !$force)
|
135 |
-
return $this->customer;
|
136 |
-
|
137 |
-
//transaction id?
|
138 |
-
if(!empty($order->subscription_transaction_id))
|
139 |
-
$customer_id = $order->subscription_transaction_id;
|
140 |
-
else
|
141 |
-
{
|
142 |
-
//try based on user id
|
143 |
-
if(!empty($order->user_id))
|
144 |
-
$user_id = $order->user_id;
|
145 |
-
|
146 |
-
//if no id passed, check the current user
|
147 |
-
if(empty($user_id) && !empty($current_user->ID))
|
148 |
-
$user_id = $current_user->ID;
|
149 |
-
|
150 |
-
//check for a stripe customer id
|
151 |
-
if(!empty($user_id))
|
152 |
-
{
|
153 |
-
$customer_id = get_user_meta($user_id, "pmpro_stripe_customerid", true);
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
//check for an existing stripe customer
|
158 |
-
if(!empty($customer_id))
|
159 |
-
{
|
160 |
-
try
|
161 |
-
{
|
162 |
-
$this->customer = Stripe_Customer::retrieve($customer_id);
|
163 |
-
|
164 |
-
//update the customer description and card
|
165 |
-
if(!empty($order->stripeToken))
|
166 |
-
{
|
167 |
-
$name = trim($order->FirstName . " " . $order->LastName);
|
168 |
-
|
169 |
-
if (empty($name))
|
170 |
-
{
|
171 |
-
$name = trim($current_user->first_name . " " . $current_user->last_name);
|
172 |
-
}
|
173 |
-
|
174 |
-
$this->customer->description = $name . " (" . $order->Email . ")";
|
175 |
-
$this->customer->email = $order->Email;
|
176 |
-
$this->customer->card = $order->stripeToken;
|
177 |
-
$this->customer->save();
|
178 |
-
}
|
179 |
-
|
180 |
-
return $this->customer;
|
181 |
-
}
|
182 |
-
catch (Exception $e)
|
183 |
-
{
|
184 |
-
//assume no customer found
|
185 |
-
}
|
186 |
-
}
|
187 |
-
|
188 |
-
//no customer id, create one
|
189 |
-
if(!empty($order->stripeToken))
|
190 |
-
{
|
191 |
-
try
|
192 |
-
{
|
193 |
-
$this->customer = Stripe_Customer::create(array(
|
194 |
-
"description" => trim($order->FirstName . " " . $order->LastName) . " (" . $order->Email . ")",
|
195 |
-
"email" => $order->Email,
|
196 |
-
"card" => $order->stripeToken
|
197 |
-
));
|
198 |
-
}
|
199 |
-
catch (Exception $e)
|
200 |
-
{
|
201 |
-
$order->error = __("Error creating customer record with Stripe:", "pmpro") . " " . $e->getMessage();
|
202 |
-
$order->shorterror = $order->error;
|
203 |
-
return false;
|
204 |
-
}
|
205 |
-
|
206 |
-
if(!empty($user_id))
|
207 |
-
{
|
208 |
-
//user logged in/etc
|
209 |
-
update_user_meta($user_id, "pmpro_stripe_customerid", $this->customer->id);
|
210 |
-
}
|
211 |
-
else
|
212 |
-
{
|
213 |
-
//user not registered yet, queue it up
|
214 |
-
global $pmpro_stripe_customer_id;
|
215 |
-
$pmpro_stripe_customer_id = $this->customer->id;
|
216 |
-
function pmpro_user_register_stripe_customerid($user_id)
|
217 |
-
{
|
218 |
-
global $pmpro_stripe_customer_id;
|
219 |
-
update_user_meta($user_id, "pmpro_stripe_customerid", $pmpro_stripe_customer_id);
|
220 |
-
}
|
221 |
-
add_action("user_register", "pmpro_user_register_stripe_customerid");
|
222 |
-
}
|
223 |
-
|
224 |
-
return apply_filters('pmpro_stripe_create_customer', $this->customer);
|
225 |
-
}
|
226 |
-
|
227 |
-
return false;
|
228 |
-
}
|
229 |
-
|
230 |
-
function subscribe(&$order)
|
231 |
-
{
|
232 |
-
global $pmpro_currency;
|
233 |
-
|
234 |
-
//create a code for the order
|
235 |
-
if(empty($order->code))
|
236 |
-
$order->code = $order->getRandomCode();
|
237 |
-
|
238 |
-
//filter order before subscription. use with care.
|
239 |
-
$order = apply_filters("pmpro_subscribe_order", $order, $this);
|
240 |
-
|
241 |
-
//setup customer
|
242 |
-
$this->getCustomer($order);
|
243 |
-
if(empty($this->customer))
|
244 |
-
return false; //error retrieving customer
|
245 |
-
|
246 |
-
//figure out the amounts
|
247 |
-
$amount = $order->PaymentAmount;
|
248 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
249 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
250 |
-
|
251 |
-
/*
|
252 |
-
There are two parts to the trial. Part 1 is simply the delay until the first payment
|
253 |
-
since we are doing the first payment as a separate transaction.
|
254 |
-
The second part is the actual "trial" set by the admin.
|
255 |
-
|
256 |
-
Stripe only supports Year or Month for billing periods, but we account for Days and Weeks just in case.
|
257 |
-
*/
|
258 |
-
//figure out the trial length (first payment handled by initial charge)
|
259 |
-
if($order->BillingPeriod == "Year")
|
260 |
-
$trial_period_days = $order->BillingFrequency * 365; //annual
|
261 |
-
elseif($order->BillingPeriod == "Day")
|
262 |
-
$trial_period_days = $order->BillingFrequency * 1; //daily
|
263 |
-
elseif($order->BillingPeriod == "Week")
|
264 |
-
$trial_period_days = $order->BillingFrequency * 7; //weekly
|
265 |
-
else
|
266 |
-
$trial_period_days = $order->BillingFrequency * 30; //assume monthly
|
267 |
-
|
268 |
-
//convert to a profile start date
|
269 |
-
$order->ProfileStartDate = date("Y-m-d", strtotime("+ " . $trial_period_days . " Day", current_time("timestamp"))) . "T0:0:0";
|
270 |
-
|
271 |
-
//filter the start date
|
272 |
-
$order->ProfileStartDate = apply_filters("pmpro_profile_start_date", $order->ProfileStartDate, $order);
|
273 |
-
|
274 |
-
//convert back to days
|
275 |
-
$trial_period_days = ceil(abs(strtotime(date("Y-m-d"), current_time("timestamp")) - strtotime($order->ProfileStartDate, current_time("timestamp"))) / 86400);
|
276 |
-
|
277 |
-
//now add the actual trial set by the site
|
278 |
-
if(!empty($order->TrialBillingCycles))
|
279 |
-
{
|
280 |
-
$trialOccurrences = (int)$order->TrialBillingCycles;
|
281 |
-
if($order->BillingPeriod == "Year")
|
282 |
-
$trial_period_days = $trial_period_days + (365 * $order->BillingFrequency * $trialOccurrences); //annual
|
283 |
-
elseif($order->BillingPeriod == "Day")
|
284 |
-
$trial_period_days = $trial_period_days + (1 * $order->BillingFrequency * $trialOccurrences); //daily
|
285 |
-
elseif($order->BillingPeriod == "Week")
|
286 |
-
$trial_period_days = $trial_period_days + (7 * $order->BillingFrequency * $trialOccurrences); //weekly
|
287 |
-
else
|
288 |
-
$trial_period_days = $trial_period_days + (30 * $order->BillingFrequency * $trialOccurrences); //assume monthly
|
289 |
-
}
|
290 |
-
|
291 |
-
//create a plan
|
292 |
-
try
|
293 |
-
{
|
294 |
-
$plan = array(
|
295 |
-
"amount" => $amount * 100,
|
296 |
-
"interval_count" => $order->BillingFrequency,
|
297 |
-
"interval" => strtolower($order->BillingPeriod),
|
298 |
-
"trial_period_days" => $trial_period_days,
|
299 |
-
"name" => $order->membership_name . " for order " . $order->code,
|
300 |
-
"currency" => strtolower($pmpro_currency),
|
301 |
-
"id" => $order->code
|
302 |
-
);
|
303 |
-
|
304 |
-
$plan = Stripe_Plan::create(apply_filters('pmpro_stripe_create_plan_array', $plan));
|
305 |
-
}
|
306 |
-
catch (Exception $e)
|
307 |
-
{
|
308 |
-
$order->error = __("Error creating plan with Stripe:", "pmpro") . $e->getMessage();
|
309 |
-
$order->shorterror = $order->error;
|
310 |
-
return false;
|
311 |
-
}
|
312 |
-
|
313 |
-
//subscribe to the plan
|
314 |
-
try
|
315 |
-
{
|
316 |
-
$this->customer->updateSubscription(array("prorate" => false, "plan" => $order->code));
|
317 |
-
}
|
318 |
-
catch (Exception $e)
|
319 |
-
{
|
320 |
-
//try to delete the plan
|
321 |
-
$plan->delete();
|
322 |
-
|
323 |
-
//return error
|
324 |
-
$order->error = __("Error subscribing customer to plan with Stripe:", "pmpro") . $e->getMessage();
|
325 |
-
$order->shorterror = $order->error;
|
326 |
-
return false;
|
327 |
-
}
|
328 |
-
|
329 |
-
//delete the plan
|
330 |
-
$plan = Stripe_Plan::retrieve($plan['id']);
|
331 |
-
$plan->delete();
|
332 |
-
|
333 |
-
//if we got this far, we're all good
|
334 |
-
$order->status = "success";
|
335 |
-
$order->subscription_transaction_id = $this->customer['id']; //transaction id is the customer id, we save it in user meta later too
|
336 |
-
return true;
|
337 |
-
}
|
338 |
-
|
339 |
-
function update(&$order)
|
340 |
-
{
|
341 |
-
//we just have to run getCustomer which will look for the customer and update it with the new token
|
342 |
-
$this->getCustomer($order);
|
343 |
-
|
344 |
-
if(!empty($this->customer))
|
345 |
-
{
|
346 |
-
return true;
|
347 |
-
}
|
348 |
-
else
|
349 |
-
{
|
350 |
-
return false; //couldn't find the customer
|
351 |
-
}
|
352 |
-
}
|
353 |
-
|
354 |
-
function cancel(&$order)
|
355 |
-
{
|
356 |
-
//no matter what happens below, we're going to cancel the order in our system
|
357 |
-
$order->updateStatus("cancelled");
|
358 |
-
|
359 |
-
//require a subscription id
|
360 |
-
if(empty($order->subscription_transaction_id))
|
361 |
-
return false;
|
362 |
-
|
363 |
-
//find the customer
|
364 |
-
$this->getCustomer($order);
|
365 |
-
|
366 |
-
if(!empty($this->customer))
|
367 |
-
{
|
368 |
-
//find subscription with this order code
|
369 |
-
$subscriptions = $this->customer->subscriptions->all();
|
370 |
-
|
371 |
-
if(!empty($subscriptions))
|
372 |
-
{
|
373 |
-
//in case only one is returned
|
374 |
-
if(!is_array($subscriptions))
|
375 |
-
$subscriptions = array($subscriptions);
|
376 |
-
|
377 |
-
foreach($subscriptions as $sub)
|
378 |
-
{
|
379 |
-
if($sub->data[0]->plan->id == $order->code)
|
380 |
-
{
|
381 |
-
//found it, cancel it
|
382 |
-
try
|
383 |
-
{
|
384 |
-
$this->customer->subscriptions->retrieve($sub->data[0]->id)->cancel();
|
385 |
-
break;
|
386 |
-
}
|
387 |
-
catch(Exception $e)
|
388 |
-
{
|
389 |
-
$order->error = __("Could not cancel old subscription.", "pmpro");
|
390 |
-
$order->shorterror = $order->error;
|
391 |
-
|
392 |
-
return false;
|
393 |
-
}
|
394 |
-
}
|
395 |
-
}
|
396 |
-
}
|
397 |
-
|
398 |
-
return true;
|
399 |
-
}
|
400 |
-
else
|
401 |
-
{
|
402 |
-
$order->error = __("Could not find the subscription.", "pmpro");
|
403 |
-
$order->shorterror = $order->error;
|
404 |
-
return false; //no customer found
|
405 |
-
}
|
406 |
-
}
|
407 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/gateways/class.pmprogateway_twocheckout.php
DELETED
@@ -1,145 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . "/class.pmprogateway.php");
|
3 |
-
if(!class_exists("Twocheckout"))
|
4 |
-
require_once(dirname(__FILE__) . "/../../includes/lib/Twocheckout/Twocheckout.php");
|
5 |
-
class PMProGateway_Twocheckout
|
6 |
-
{
|
7 |
-
function PMProGateway_Twocheckout($gateway = NULL)
|
8 |
-
{
|
9 |
-
$this->gateway = $gateway;
|
10 |
-
return $this->gateway;
|
11 |
-
}
|
12 |
-
|
13 |
-
function process(&$order)
|
14 |
-
{
|
15 |
-
if(empty($order->code))
|
16 |
-
$order->code = $order->getRandomCode();
|
17 |
-
|
18 |
-
//clean up a couple values
|
19 |
-
$order->payment_type = "2CheckOut";
|
20 |
-
$order->CardType = "";
|
21 |
-
$order->cardtype = "";
|
22 |
-
|
23 |
-
//just save, the user will go to 2checkout to pay
|
24 |
-
$order->status = "review";
|
25 |
-
$order->saveOrder();
|
26 |
-
|
27 |
-
return true;
|
28 |
-
}
|
29 |
-
|
30 |
-
function sendToTwocheckout(&$order)
|
31 |
-
{
|
32 |
-
global $pmpro_currency;
|
33 |
-
// Set up credentials
|
34 |
-
Twocheckout::setCredentials( pmpro_getOption("twocheckout_apiusername"), pmpro_getOption("twocheckout_apipassword") );
|
35 |
-
|
36 |
-
$tco_args = array(
|
37 |
-
'sid' => pmpro_getOption("twocheckout_accountnumber"),
|
38 |
-
'mode' => '2CO', // will always be 2CO according to docs (@see https://www.2checkout.com/documentation/checkout/parameter-sets/pass-through-products/)
|
39 |
-
'li_0_type' => 'product',
|
40 |
-
'li_0_name' => substr($order->membership_level->name . " at " . get_bloginfo("name"), 0, 127),
|
41 |
-
'li_0_quantity' => 1,
|
42 |
-
'li_0_tangible' => 'N',
|
43 |
-
'li_0_product_id' => $order->code,
|
44 |
-
'merchant_order_id' => $order->code,
|
45 |
-
'currency_code' => $pmpro_currency,
|
46 |
-
'pay_method' => 'CC',
|
47 |
-
'purchase_step' => 'billing-information',
|
48 |
-
'x_receipt_link_url' => admin_url("admin-ajax.php") . "?action=twocheckout-ins" //pmpro_url("confirmation", "?level=" . $order->membership_level->id)
|
49 |
-
);
|
50 |
-
|
51 |
-
//taxes on initial amount
|
52 |
-
$initial_payment = $order->InitialPayment;
|
53 |
-
$initial_payment_tax = $order->getTaxForPrice($initial_payment);
|
54 |
-
$initial_payment = round((float)$initial_payment + (float)$initial_payment_tax, 2);
|
55 |
-
|
56 |
-
//taxes on the amount (NOT CURRENTLY USED)
|
57 |
-
$amount = $order->PaymentAmount;
|
58 |
-
$amount_tax = $order->getTaxForPrice($amount);
|
59 |
-
$order->subtotal = $amount;
|
60 |
-
$amount = round((float)$amount + (float)$amount_tax, 2);
|
61 |
-
|
62 |
-
// Recurring membership
|
63 |
-
if( pmpro_isLevelRecurring( $order->membership_level ) ) {
|
64 |
-
$tco_args['li_0_startup_fee'] = number_format($initial_payment - $amount, 2); //negative amount for lower initial payments
|
65 |
-
$recurring_payment = $order->membership_level->billing_amount;
|
66 |
-
$recurring_payment_tax = $order->getTaxForPrice($recurring_payment);
|
67 |
-
$recurring_payment = round((float)$recurring_payment + (float)$recurring_payment_tax, 2);
|
68 |
-
$tco_args['li_0_price'] = number_format($recurring_payment, 2);
|
69 |
-
|
70 |
-
$tco_args['li_0_recurrence'] = ( $order->BillingFrequency == 1 ) ? $order->BillingFrequency . ' ' . $order->BillingPeriod : $order->BillingFrequency . ' ' . $order->BillingPeriod . 's';
|
71 |
-
|
72 |
-
if( property_exists( $order, 'TotalBillingCycles' ) )
|
73 |
-
$tco_args['li_0_duration'] = ($order->BillingFrequency * $order->TotalBillingCycles ) . ' ' . $order->BillingPeriod;
|
74 |
-
else
|
75 |
-
$tco_args['li_0_duration'] = 'Forever';
|
76 |
-
}
|
77 |
-
// Non-recurring membership
|
78 |
-
else {
|
79 |
-
$tco_args['li_0_price'] = $initial_payment;
|
80 |
-
}
|
81 |
-
|
82 |
-
// Demo mode?
|
83 |
-
$environment = pmpro_getOption("gateway_environment");
|
84 |
-
if("sandbox" === $environment || "beta-sandbox" === $environment)
|
85 |
-
$tco_args['demo'] = 'Y';
|
86 |
-
|
87 |
-
// Trial?
|
88 |
-
//li_#_startup_fee Any start up fees for the product or service. Can be negative to provide discounted first installment pricing, but cannot equal or surpass the product price.
|
89 |
-
if(!empty($order->TrialBillingPeriod)) {
|
90 |
-
$trial_amount = $order->TrialAmount;
|
91 |
-
$trial_tax = $order->getTaxForPrice($trial_amount);
|
92 |
-
$trial_amount = round((float)$trial_amount + (float)$trial_tax, 2);
|
93 |
-
$tco_args['li_0_startup_fee'] = $trial_amount; // Negative trial amount
|
94 |
-
}
|
95 |
-
|
96 |
-
$ptpStr = '';
|
97 |
-
foreach( $tco_args as $key => $value ) {
|
98 |
-
reset( $tco_args ); // Used to verify whether or not we're on the first argument
|
99 |
-
$ptpStr .= ( $key == key($tco_args) ) ? '?' . $key . '=' . urlencode( $value ) : '&' . $key . '=' . urlencode( $value );
|
100 |
-
}
|
101 |
-
|
102 |
-
//anything modders might add
|
103 |
-
$additional_parameters = apply_filters( 'pmpro_twocheckout_return_url_parameters', array() );
|
104 |
-
if( ! empty( $additional_parameters ) )
|
105 |
-
foreach( $additional_parameters as $key => $value )
|
106 |
-
$ptpStr .= "&" . urlencode($key) . "=" . urlencode($value);
|
107 |
-
|
108 |
-
$ptpStr = apply_filters( 'pmpro_twocheckout_ptpstr', $ptpStr, $order );
|
109 |
-
|
110 |
-
//echo str_replace("&", "&<br />", $ptpStr);
|
111 |
-
//exit;
|
112 |
-
|
113 |
-
//redirect to 2checkout
|
114 |
-
$tco_url = 'https://www.2checkout.com/checkout/purchase' . $ptpStr;
|
115 |
-
|
116 |
-
//echo $tco_url;
|
117 |
-
//die();
|
118 |
-
wp_redirect( $tco_url );
|
119 |
-
exit;
|
120 |
-
}
|
121 |
-
|
122 |
-
function cancel(&$order) {
|
123 |
-
// If recurring, stop the recurring payment
|
124 |
-
if(pmpro_isLevelRecurring($order->membership_level)) {
|
125 |
-
$params['sale_id'] = $order->payment_transaction_id;
|
126 |
-
$result = Twocheckout_Sale::stop( $params ); // Stop the recurring billing
|
127 |
-
|
128 |
-
// Successfully cancelled
|
129 |
-
if (isset($result['response_code']) && $result['response_code'] === 'OK') {
|
130 |
-
$order->updateStatus("cancelled");
|
131 |
-
return true;
|
132 |
-
}
|
133 |
-
// Failed
|
134 |
-
else {
|
135 |
-
$order->status = "error";
|
136 |
-
$order->errorcode = $result->getCode();
|
137 |
-
$order->error = $result->getMessage();
|
138 |
-
|
139 |
-
return false;
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
return $order;
|
144 |
-
}
|
145 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/admin-rtl.css
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
.pmpro_admin {
|
2 |
-
background: url(../images/Paid-Memberships-Pro_watermark.png) bottom left no-repeat !important;
|
3 |
-
}
|
4 |
-
|
5 |
-
.pmpro_admin .pmpro_banner h2 {
|
6 |
-
float: right;
|
7 |
-
}
|
8 |
-
|
9 |
-
.pmpro_admin .pmpro_banner .pmpro_meta {
|
10 |
-
float: right;
|
11 |
-
}
|
12 |
-
|
13 |
-
.pmpro_admin .pmpro_banner .pmpro_meta .pmpro_tag-blue {
|
14 |
-
margin: 0 5px 0 0;
|
15 |
-
}
|
16 |
-
|
17 |
-
.pmpro_admin .pmpro_banner .pmpro_logo {
|
18 |
-
float: right;
|
19 |
-
margin: 0 0 0 1em;
|
20 |
-
}
|
21 |
-
|
22 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu li {
|
23 |
-
border-left: 1px solid #CCC;
|
24 |
-
border-right: none;
|
25 |
-
}
|
26 |
-
|
27 |
-
/* messages */
|
28 |
-
.pmpro_message {
|
29 |
-
padding: 6px 25px 6px 6px;
|
30 |
-
}
|
31 |
-
|
32 |
-
/* highlighted trs */
|
33 |
-
|
34 |
-
/* discount levels */
|
35 |
-
|
36 |
-
/* pagination */
|
37 |
-
div.pmpro_pagination {
|
38 |
-
float: left;
|
39 |
-
}
|
40 |
-
|
41 |
-
/* add ons */
|
42 |
-
|
43 |
-
.pmpro_admin .widgets-holder-wrap .widget {
|
44 |
-
float: right;
|
45 |
-
margin: 0 0 1% 1%;
|
46 |
-
}
|
47 |
-
|
48 |
-
.pmpro_admin .widgets-holder-wrap .widget-title .status-label {
|
49 |
-
float: right;
|
50 |
-
margin: 0 0 0 5px;
|
51 |
-
}
|
52 |
-
|
53 |
-
.pmpro_admin .widgets-holder-wrap .widget-title .version {
|
54 |
-
left: 10px;
|
55 |
-
left: auto;
|
56 |
-
}
|
57 |
-
|
58 |
-
.pmpro_admin .widgets-holder-wrap .widget-inside .addon-thumb {
|
59 |
-
float: left;
|
60 |
-
margin: 10px 10px 0 0;
|
61 |
-
}
|
62 |
-
|
63 |
-
/* Generated by the RTLer - http://l0uy.com/rtler/ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/admin.css
CHANGED
@@ -1,97 +1,53 @@
|
|
1 |
-
.pmpro_admin {background: url(../images/
|
2 |
-
|
3 |
-
.pmpro_admin .pmpro_banner
|
4 |
-
.pmpro_admin .pmpro_banner .pmpro_meta {float:
|
5 |
-
.pmpro_admin .pmpro_banner .
|
6 |
-
.pmpro_admin .pmpro_banner .
|
7 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu {clear: both; border: 1px solid #CCC; border-radius: 5px; -moz-border-radius: 5px; background: #FFF; }
|
8 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu li {display: inline-block; margin: 10px 0; padding: 0px 10px; border-right: 1px solid #CCC; }
|
9 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu li a, .pmpro_admin .pmpro_banner ul.pmpro_menu li a:link {color: #1e0741; text-decoration: none; }
|
10 |
-
.pmpro_admin .pmpro_banner ul.pmpro_menu li a:hover {text-decoration: underline; color: #412f5b; }
|
11 |
-
|
12 |
-
.pmpro_admin .
|
13 |
-
.pmpro_admin
|
14 |
-
.pmpro_admin
|
15 |
-
|
16 |
-
.
|
17 |
-
.
|
18 |
-
.
|
19 |
-
|
20 |
-
.
|
21 |
-
.
|
22 |
-
|
23 |
-
.
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
.
|
31 |
-
|
32 |
-
.
|
33 |
-
.
|
34 |
-
.
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
.
|
39 |
-
.
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
.
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
div.pmpro_pagination a {padding: 2px 5px 2px 5px; margin: 1px; border: 1px solid #666; text-decoration: none; /* no underline */ color: #666; background: #EEE; }
|
55 |
-
div.pmpro_pagination a:hover, div.pmpro_pagination a:active {background: #FFF; }
|
56 |
-
div.pmpro_pagination span.current {border: 1px solid #FFF; color: #FFF; background: #666; padding: 2px 5px 2px 5px; margin: 1px; font-weight: bold; }
|
57 |
-
div.pmpro_pagination span.disabled {padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #BBB; color: #BBB; background: #EFEFEF;}
|
58 |
-
|
59 |
-
p.pmpro_meta_notice {font-size: .8em; padding-top: 5px; border-top: 1px solid #CCC;}
|
60 |
-
|
61 |
-
/* add ons */
|
62 |
-
.pmpro_admin .widgets-holder-wrap {clear: both; margin-top: 20px; padding: 0 8px; }
|
63 |
-
.pmpro_admin .widgets-holder-wrap .widget {float: left; width: 32%; margin: 0 1% 1% 0; position: relative; }
|
64 |
-
.pmpro_admin .widgets-holder-wrap p.description {padding: 0; }
|
65 |
-
.pmpro_admin .widgets-holder-wrap .widget-top {height: auto; cursor: default; }
|
66 |
-
.pmpro_admin .widgets-holder-wrap .widget-inside {display: block; height: 130px; overflow: hidden; }
|
67 |
-
.pmpro_admin .widgets-holder-wrap .widget-inside p {height: 80px; overflow: hidden; }
|
68 |
-
.pmpro_admin #pmpro-gists.widgets-holder-wrap .widget-inside, .pmpro_admin #pmpro-gists.widgets-holder-wrap .widget-inside p {height: auto; }
|
69 |
-
.pmpro_admin .widgets-holder-wrap .widget-title { }
|
70 |
-
.pmpro_admin .widgets-holder-wrap .widget-title h4 { }
|
71 |
-
.pmpro_admin .widgets-holder-wrap .widget-title .status-label {display: block; float: left; margin: 0 5px 0 0; width: 10px;
|
72 |
-
height: 10px; overflow: hidden; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border: 1px solid #DFDFDF; text-indent: -9999em; }
|
73 |
-
.pmpro_admin .widgets-holder-wrap .disabled .widget-title .status-label {background: #F00; }
|
74 |
-
.pmpro_admin .widgets-holder-wrap .enabled .widget-title .status-label {background: #0C0; }
|
75 |
-
|
76 |
-
.pmpro_admin .widgets-holder-wrap .widget-title .version {position: absolute; top: 13px; right: 10px; }
|
77 |
-
.pmpro_admin .widgets-holder-wrap .widget-inside .addon-thumb {width: 100px; height: 100px; float: right; margin: 10px 0 0 10px; border: 1px solid #DFDFDF; background: #FFF; padding: 2px;}
|
78 |
-
|
79 |
-
/*@media (min-width: 1200px) {
|
80 |
-
.auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside, .auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside p {height: auto; }
|
81 |
-
}
|
82 |
-
*/
|
83 |
-
@media (max-width:900px) {
|
84 |
-
.auto-fold .pmpro_admin .widgets-holder-wrap .widget {float: none; width: 100%; }
|
85 |
-
.auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside, .auto-fold .pmpro_admin .widgets-holder-wrap .widget-inside p {height: auto; }
|
86 |
-
}
|
87 |
-
|
88 |
-
/* misc */
|
89 |
-
.pmpro_lite {color: #AAA;}
|
90 |
-
.pmpro_pad20 {padding: 20px !important;}
|
91 |
-
.pmpro_red {color: #CC0000;}
|
92 |
-
.pmpro_green {color: #00AA00;}
|
93 |
-
|
94 |
-
/* reports */
|
95 |
-
.pmpro_reports-holder { }
|
96 |
-
.pmpro_clickable {cursor: pointer;}
|
97 |
-
.js .postbox.pmpro_clickable h3 {cursor: pointer;}
|
1 |
+
.pmpro_admin {background: url(../images/PaidMembershipsPro-grey.gif) bottom right no-repeat !important; padding-bottom: 70px; }
|
2 |
+
|
3 |
+
.pmpro_admin .pmpro_banner {margin: 2em 0; font-family: Georgia, "Times New Roman", Times, serif; }
|
4 |
+
.pmpro_admin .pmpro_banner .pmpro_meta {float: right; margin: 2em 0 1em 1em; font-size: 12px; font-style: italic; }
|
5 |
+
.pmpro_admin .pmpro_banner .pmpro_logo {float: left; margin: 0 1em 1em 0; width: 350px; }
|
6 |
+
.pmpro_admin .pmpro_banner .pmpro_tagline {float: left; width: 350px; font-family: "Arial Black", Gadget, sans-serif; color: #412f5b; text-transform: uppercase; font-size: 13px; padding: 15px 0; }
|
7 |
+
.pmpro_admin .pmpro_banner ul.pmpro_menu {clear: both; border: 1px solid #CCC; border-radius: 5px; -moz-border-radius: 5px; background: #FFF; }
|
8 |
+
.pmpro_admin .pmpro_banner ul.pmpro_menu li {display: inline-block; margin: 10px 0; padding: 0px 10px; border-right: 1px solid #CCC; }
|
9 |
+
.pmpro_admin .pmpro_banner ul.pmpro_menu li a, .pmpro_admin .pmpro_banner ul.pmpro_menu li a:link {color: #1e0741; text-decoration: none; }
|
10 |
+
.pmpro_admin .pmpro_banner ul.pmpro_menu li a:hover {text-decoration: underline; color: #412f5b; }
|
11 |
+
|
12 |
+
.pmpro_admin .topborder {border-top: 1px solid #CCC; margin-top: 1em; padding-top: 1em; }
|
13 |
+
.pmpro_admin #editorcontainer #description {width: 100%; height: 180px; }
|
14 |
+
.pmpro_admin .widefat {margin-top: 1em; }
|
15 |
+
|
16 |
+
.ssp_description #description {width: 100%;}
|
17 |
+
.checkbox_box {width: 300px; background: #FFFFFF; border: 1px solid #CCC;}
|
18 |
+
.checkbox_box div {border-bottom: 1px solid #CCC; padding: 3px;}
|
19 |
+
.checkbox_box .clickable {cursor: pointer;}
|
20 |
+
.checkbox_box .clickable:hover {background: #FFC;}
|
21 |
+
.top0em {margin-top: 0;}
|
22 |
+
|
23 |
+
tr.pmpro_gray td {color: #AAA;}
|
24 |
+
|
25 |
+
/* messages */
|
26 |
+
.pmpro_message {background-color: #D5E4F7; background-image: url(../images/icon_information.gif); background-position: 3px 5px; background-repeat: no-repeat; margin: .5em 0; padding: 6px 6px 6px 25px; color: #345395; font-size: 11px; font-weight: bold; line-height: 1.3em; }
|
27 |
+
|
28 |
+
.pmpro_success {background-color: #CFEECA; background-image: url(../images/icon_success.gif); color: #208A1B; }
|
29 |
+
.pmpro_error {background-color: #F9D6CB; background-image: url(../images/icon_error.gif); color: #E36154; }
|
30 |
+
.pmpro_alert {background-color: #FFF6CC; background-image: url(../images/icon_alert.gif); color: #CF8516; }
|
31 |
+
|
32 |
+
.pmpro_message a {color: #345395; }
|
33 |
+
.pmpro_success a {color: #208A1B; }
|
34 |
+
.pmpro_error a {color: #E36154; }
|
35 |
+
.pmpro_alert a {color: #CF8516; }
|
36 |
+
|
37 |
+
/* discount levels */
|
38 |
+
.pmpro_discount_levels {border: 1px solid #CCC;}
|
39 |
+
.pmpro_discount_levels div {padding: 5px; border: 1px solid #CCC;}
|
40 |
+
.pmpro_discount_levels div div {margin-top: 5px; background: #F5F5F5;}
|
41 |
+
|
42 |
+
/* pagination */
|
43 |
+
div.pmpro_pagination {padding: 3px; margin: 5px 0px 5px 0px; font-size: 10px; float: right; }
|
44 |
+
div.pmpro_pagination a {padding: 2px 5px 2px 5px; margin: 1px; border: 1px solid #666; text-decoration: none; /* no underline */ color: #666; background: #EEE; }
|
45 |
+
div.pmpro_pagination a:hover, div.pmpro_pagination a:active {background: #FFF; }
|
46 |
+
div.pmpro_pagination span.current {border: 1px solid #FFF; color: #FFF; background: #666; padding: 2px 5px 2px 5px; margin: 1px; font-weight: bold; }
|
47 |
+
div.pmpro_pagination span.disabled {padding: 2px 5px 2px 5px; margin: 2px; border: 1px solid #BBB; color: #BBB; background: #EFEFEF;}
|
48 |
+
|
49 |
+
p.pmpro_meta_notice {font-size: .6em; padding-top: 5px; border-top: 1px solid #CCC;}
|
50 |
+
|
51 |
+
/* misc */
|
52 |
+
.pmpro_lite {color: #AAA;}
|
53 |
+
.pmpro_pad20 {padding: 20px !important;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/frontend-rtl.css
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
/*---------------------------------------
|
2 |
-
Buttons
|
3 |
-
---------------------------------------*/
|
4 |
-
|
5 |
-
/*---------------------------------------
|
6 |
-
Forms
|
7 |
-
---------------------------------------*/
|
8 |
-
form.pmpro_form div {
|
9 |
-
clear: right;
|
10 |
-
}
|
11 |
-
|
12 |
-
form.pmpro_form label {
|
13 |
-
float: right;
|
14 |
-
margin: 3px 0 0 10px;
|
15 |
-
text-align: left;
|
16 |
-
}
|
17 |
-
|
18 |
-
form.pmpro_form .input, form.pmpro_form textarea, .input, form.pmpro_form select {
|
19 |
-
margin: 0 0 0 3px;
|
20 |
-
}
|
21 |
-
|
22 |
-
form.pmpro_form .leftmar {
|
23 |
-
margin: 8px 130px 0 0;
|
24 |
-
}
|
25 |
-
|
26 |
-
form.pmpro_form .pmpro_captcha {
|
27 |
-
margin: 0 130px 0 0 !important;
|
28 |
-
}
|
29 |
-
|
30 |
-
form.pmpro_form .pmpro_submit {
|
31 |
-
margin-right: 130px;
|
32 |
-
margin-left: auto;
|
33 |
-
}
|
34 |
-
|
35 |
-
form.pmpro_form .pmpro_submit span {
|
36 |
-
float: right;
|
37 |
-
}
|
38 |
-
|
39 |
-
form.pmpro_form #pmpro_processing_message {
|
40 |
-
margin: 5px 10px 0 0;
|
41 |
-
}
|
42 |
-
|
43 |
-
/*--------------------------------------------------
|
44 |
-
Messages - Success, Error, Alert
|
45 |
-
----------------------------------------------------*/
|
46 |
-
|
47 |
-
.pmpro_content_message a {
|
48 |
-
margin: 5px 0 0 5px;
|
49 |
-
}
|
50 |
-
|
51 |
-
/*---------------------------------------
|
52 |
-
Membership Checkout
|
53 |
-
---------------------------------------*/
|
54 |
-
|
55 |
-
.pmpro_checkout ul {
|
56 |
-
margin: 5px 20px 0 0;
|
57 |
-
}
|
58 |
-
|
59 |
-
.pmpro_checkout td.rtbdr {
|
60 |
-
border-left: 1px solid #CCC;
|
61 |
-
border-right: none;
|
62 |
-
}
|
63 |
-
|
64 |
-
.pmpro_thead-msg {
|
65 |
-
float: left;
|
66 |
-
text-align: left;
|
67 |
-
}
|
68 |
-
|
69 |
-
.pmpro_ordersummary {
|
70 |
-
float: left;
|
71 |
-
}
|
72 |
-
|
73 |
-
.pmpro_sslseal {
|
74 |
-
float: left;
|
75 |
-
}
|
76 |
-
|
77 |
-
/*---------------------------------------
|
78 |
-
Membership Invoice
|
79 |
-
---------------------------------------*/
|
80 |
-
|
81 |
-
/*---------------------------------------
|
82 |
-
Membership Account
|
83 |
-
---------------------------------------*/
|
84 |
-
|
85 |
-
li.pmpro_more {
|
86 |
-
margin-right: -20px;
|
87 |
-
padding-right: 0;
|
88 |
-
padding-left: 0;
|
89 |
-
margin-left: auto;
|
90 |
-
}
|
91 |
-
|
92 |
-
/*---------------------------------------
|
93 |
-
Membership Levels
|
94 |
-
---------------------------------------*/
|
95 |
-
|
96 |
-
/*---------------------------------------
|
97 |
-
Misc
|
98 |
-
---------------------------------------*/
|
99 |
-
.pmpro_a-right {
|
100 |
-
float: left;
|
101 |
-
text-align: left;
|
102 |
-
}
|
103 |
-
|
104 |
-
.pmpro_a-print {
|
105 |
-
float: left;
|
106 |
-
background: url(../images/printer.gif) top right no-repeat;
|
107 |
-
padding: 0px 20px 2px 0px;
|
108 |
-
}
|
109 |
-
|
110 |
-
|
111 |
-
/* Generated by the RTLer - http://l0uy.com/rtler/ */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/frontend.css
CHANGED
@@ -1,174 +1,98 @@
|
|
1 |
-
/*---------------------------------------
|
2 |
-
Buttons
|
3 |
-
---------------------------------------*/
|
4 |
-
.pmpro_btn
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
.
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
}
|
41 |
-
|
42 |
-
.
|
43 |
-
.
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
.
|
51 |
-
.
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
.
|
88 |
-
.
|
89 |
-
|
90 |
-
.
|
91 |
-
|
92 |
-
|
93 |
-
.
|
94 |
-
.
|
95 |
-
.
|
96 |
-
|
97 |
-
|
98 |
-
select.pmpro_error {background-image: none;}
|
99 |
-
|
100 |
-
/*---------------------------------------
|
101 |
-
Membership Checkout
|
102 |
-
---------------------------------------*/
|
103 |
-
.pmpro_checkout thead th {font-weight: bold; color: #444; padding: 10px; }
|
104 |
-
.pmpro_checkout tbody td {padding: 10px; }
|
105 |
-
.pmpro_checkout tr.odd td {background: rgba(125,125,125,.1); }
|
106 |
-
.pmpro_checkout tr.selected td {background: #FFC; }
|
107 |
-
.pmpro_checkout tr.active td {background: #FFC; }
|
108 |
-
.pmpro_checkout .name {font-weight: bold; }
|
109 |
-
.pmpro_checkout ul {margin: 5px 0 0 20px; padding: 0; font-size: .8em; color: #444; }
|
110 |
-
|
111 |
-
.pmpro_checkout tfoot td {padding: 10px; color: #444; }
|
112 |
-
.pmpro_checkout .topfoot td {border-top: 2px solid #CCC;}
|
113 |
-
.pmpro_checkout .total td {border-top: 1px solid #CCC; font-size: 1.2em; font-weight: bold; padding-bottom: 30px;}
|
114 |
-
.pmpro_checkout tfoot .entercode td {background: #EEE; }
|
115 |
-
|
116 |
-
.pmpro_checkout td.rtbdr {border-right: 1px solid #CCC; }
|
117 |
-
|
118 |
-
.pmpro_checkout select {font-size: 11px; }
|
119 |
-
|
120 |
-
.pmpro_thead-msg {display: block; float: right; width: auto; font-style: italic; font-weight: normal; text-align: right; white-space: nowrap; }
|
121 |
-
|
122 |
-
.pmpro_ordersummary {float: right; }
|
123 |
-
|
124 |
-
#pmpro_license { background: #FFF; padding: 5px; border: 1px solid #CCC; height: 200px; margin: 3px; color: #666; overflow: auto; }
|
125 |
-
|
126 |
-
.pmpro_sslseal {float: right; clear: none !important; margin: 0 !important; }
|
127 |
-
|
128 |
-
a.pmpro_radio {text-decoration: none; color: #000;}
|
129 |
-
|
130 |
-
/*---------------------------------------
|
131 |
-
Membership Invoice
|
132 |
-
---------------------------------------*/
|
133 |
-
.pmpro_invoice { }
|
134 |
-
|
135 |
-
|
136 |
-
/*---------------------------------------
|
137 |
-
Membership Account
|
138 |
-
---------------------------------------*/
|
139 |
-
#pmpro_account .pmpro_box {border-top: 1px solid #CCC; padding: 1em 0; margin: 1em 0; }
|
140 |
-
#pmpro_account .pmpro_box h3 {margin: 0; padding: 0; border: none; background: none; }
|
141 |
-
#pmpro_account .pmpro_box p {margin: .5em 0 0 0; padding: 0; }
|
142 |
-
#pmpro_account .pmpro_box ul {margin-bottom: 0; }
|
143 |
-
|
144 |
-
#pmpro_account #pmpro_account-membership { }
|
145 |
-
#pmpro_account #pmpro_account-profile { }
|
146 |
-
#pmpro_account #pmpro_account-billing { }
|
147 |
-
#pmpro_account #pmpro_account-invoices { }
|
148 |
-
#pmpro_account #pmpro_account-links { }
|
149 |
-
|
150 |
-
|
151 |
-
.pmpro_hidden {display: none;}
|
152 |
-
li.pmpro_more {list-style-type: none; text-align: center; margin-left: -20px; padding-left: 0;}
|
153 |
-
|
154 |
-
/*---------------------------------------
|
155 |
-
Membership Levels
|
156 |
-
---------------------------------------*/
|
157 |
-
#pmpro_levels_table {background: #FFF; }
|
158 |
-
#pmpro_levels_table .pmpro_btn {display: block; }
|
159 |
-
|
160 |
-
/*---------------------------------------
|
161 |
-
Misc
|
162 |
-
---------------------------------------*/
|
163 |
-
.pmpro_a-right {float: right; width: auto; text-align: right; text-decoration: underline; font-size: 11px; }
|
164 |
-
.pmpro_a-print {float: right; width: auto; text-decoration: none; color: #345395; background: url(../images/printer.gif) top left no-repeat; padding: 0px 0px 2px 20px; font-size: 11px; line-height: 16px; cursor: pointer; }
|
165 |
-
|
166 |
-
.pmpro_red {color: #CC0000; }
|
167 |
-
.pmpro_grey {color: #999; }
|
168 |
-
|
169 |
-
.top1em {margin-top: 1em;}
|
170 |
-
.bot1em {margin-bottom: 1em;}
|
171 |
-
.bot0em {margin-bottom: 0em;}
|
172 |
-
.clear {clear: both; }
|
173 |
-
|
174 |
.pmpro_small {font-size: .8em;}
|
1 |
+
/*---------------------------------------
|
2 |
+
Buttons
|
3 |
+
---------------------------------------*/
|
4 |
+
.pmpro_btn {display: inline-block; margin: 0; cursor: pointer; }
|
5 |
+
.pmpro_btn:hover { }
|
6 |
+
|
7 |
+
/*---------------------------------------
|
8 |
+
Forms
|
9 |
+
---------------------------------------*/
|
10 |
+
form.pmpro_form div {clear: left; margin: .5em 0 1em 0; }
|
11 |
+
form.pmpro_form label {float: left; margin: 3px 10px 0 0; width: 120px; font-weight: bold; text-align: right; }
|
12 |
+
/*form.pmpro_form div div {width: 380px; margin-left: 130px; clear: none;}*/
|
13 |
+
form.pmpro_form .likelabel {font-weight: bold; }
|
14 |
+
form.pmpro_form .input, form.pmpro_form textarea, .input, form.pmpro_form select {padding: 3px; border: 1px solid #AAA; margin: 0 3px 0 0; }
|
15 |
+
form.pmpro_form textarea {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
|
16 |
+
form.pmpro_form select {margin: 2px 0 0 0 ; font-size: 12px;}
|
17 |
+
form.pmpro_form .lite {color: #666; }
|
18 |
+
form.pmpro_form .leftmar {margin: 8px 0 0 130px; }
|
19 |
+
|
20 |
+
form.pmpro_form .pmpro_captcha {margin: 0 0 0 130px !important; }
|
21 |
+
form.pmpro_form .pmpro_captcha div {clear: none; margin: 0; }
|
22 |
+
|
23 |
+
/*--------------------------------------------------
|
24 |
+
Messages - Success, Error, Alert
|
25 |
+
----------------------------------------------------*/
|
26 |
+
.pmpro_message {background-color: #D5E4F7; background-image: url(../images/icon_information.gif); background-position: 3px 5px; background-repeat: no-repeat; margin: .5em 0; padding: 6px 6px 6px 25px; color: #345395; font-size: 11px; font-weight: bold; line-height: 1.3em; }
|
27 |
+
|
28 |
+
.pmpro_success {background-color: #CFEECA; background-image: url(../images/icon_success.gif); color: #208A1B; }
|
29 |
+
.pmpro_error {background-color: #F9D6CB; background-image: url(../images/icon_error.gif); color: #E36154; }
|
30 |
+
.pmpro_alert {background-color: #FFF6CC; background-image: url(../images/icon_alert.gif); color: #CF8516; }
|
31 |
+
|
32 |
+
.pmpro_message a {color: #345395; }
|
33 |
+
.pmpro_success a {color: #208A1B; }
|
34 |
+
.pmpro_error a {color: #E36154; }
|
35 |
+
.pmpro_alert a {color: #CF8516; }
|
36 |
+
|
37 |
+
/*---------------------------------------
|
38 |
+
Membership Checkout
|
39 |
+
---------------------------------------*/
|
40 |
+
.pmpro_checkout thead th {font-weight: bold; color: #444; padding: 10px; }
|
41 |
+
.pmpro_checkout tbody td {padding: 10px; }
|
42 |
+
.pmpro_checkout tr.odd td {background: #FAFAFA; }
|
43 |
+
.pmpro_checkout tr.selected td {background: #FFC; }
|
44 |
+
.pmpro_checkout tr.active td {background: #FFC; }
|
45 |
+
.pmpro_checkout .name {font-weight: bold; }
|
46 |
+
.pmpro_checkout ul {margin: 5px 0 0 20px; padding: 0; font-size: .8em; color: #444; }
|
47 |
+
|
48 |
+
.pmpro_checkout tfoot td {padding: 10px; color: #444; }
|
49 |
+
.pmpro_checkout .topfoot td {border-top: 2px solid #CCC;}
|
50 |
+
.pmpro_checkout .total td {border-top: 1px solid #CCC; font-size: 1.2em; font-weight: bold; padding-bottom: 30px;}
|
51 |
+
.pmpro_checkout tfoot .entercode td {background: #EEE; }
|
52 |
+
|
53 |
+
.pmpro_checkout td.rtbdr {border-right: 1px solid #CCC; }
|
54 |
+
|
55 |
+
.pmpro_checkout select {font-size: 11px; }
|
56 |
+
|
57 |
+
.pmpro_thead-msg {display: block; float: right; width: auto; font-style: italic; font-weight: normal; text-align: right; }
|
58 |
+
|
59 |
+
.pmpro_ordersummary {float: right; }
|
60 |
+
|
61 |
+
#pmpro_license { background: #FFF; padding: 5px; border: 1px solid #CCC; height: 200px; margin: 3px; color: #666; overflow: auto; }
|
62 |
+
|
63 |
+
.pmpro_sslseal {float: right; clear: none !important; margin: 0 !important; }
|
64 |
+
|
65 |
+
/*---------------------------------------
|
66 |
+
Membership Invoice
|
67 |
+
---------------------------------------*/
|
68 |
+
.pmpro_invoice { }
|
69 |
+
|
70 |
+
|
71 |
+
/*---------------------------------------
|
72 |
+
Membership Account
|
73 |
+
---------------------------------------*/
|
74 |
+
.pmpro_left {float: left; width: 49%; }
|
75 |
+
.pmpro_right {float: right; width: 49%; }
|
76 |
+
|
77 |
+
.pmpro_box {border: 1px solid #CCC; padding: 1em; margin: 0 0 1em 0; }
|
78 |
+
.pmpro_box h3 {border:none; background: none; border-bottom: 1px solid #CCC; padding: 0 0 .5em 0; margin: 0 0 .5em 0; }
|
79 |
+
|
80 |
+
.pmpro_hidden {display: none;}
|
81 |
+
li.pmpro_more {list-style-type: none; text-align: center; margin-left: -20px; padding-left: 0;}
|
82 |
+
|
83 |
+
|
84 |
+
/*---------------------------------------
|
85 |
+
Misc
|
86 |
+
---------------------------------------*/
|
87 |
+
.pmpro_a-right {float: right; width: auto; text-align: right; text-decoration: underline; font-size: 11px; }
|
88 |
+
.pmpro_a-print {float: right; width: auto; text-decoration: none; color: #345395; background: url(../images/printer.gif) top left no-repeat; padding: 0px 0px 2px 20px; font-size: 11px; line-height: 16px; cursor: pointer; }
|
89 |
+
|
90 |
+
.pmpro_red {color: #CC0000; }
|
91 |
+
.pmpro_grey {color: #999; }
|
92 |
+
|
93 |
+
.top1em {margin-top: 1em;}
|
94 |
+
.bot1em {margin-bottom: 1em;}
|
95 |
+
.bot0em {margin-bottom: 0em;}
|
96 |
+
.clear {clear: both; }
|
97 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
.pmpro_small {font-size: .8em;}
|
email/admin_change.html
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<p>An administrator at !!sitename!! has changed your membership level.</p>
|
2 |
|
3 |
-
<p
|
4 |
|
5 |
<p>If you did not request this membership change and would like more information please contact us at !!siteemail!!</p>
|
6 |
|
1 |
<p>An administrator at !!sitename!! has changed your membership level.</p>
|
2 |
|
3 |
+
<p>Your !!membership_change!!.</p>
|
4 |
|
5 |
<p>If you did not request this membership change and would like more information please contact us at !!siteemail!!</p>
|
6 |
|
email/admin_change_admin.html
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
<p>An administrator at !!sitename!! has changed a membership level.</p>
|
2 |
-
|
3 |
-
<p>!!membership_change!!.</p>
|
4 |
-
|
5 |
-
<p>Log in to your WordPress admin here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
email/billing.html
CHANGED
@@ -3,7 +3,10 @@
|
|
3 |
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
<p>
|
5 |
Billing Information:<br />
|
6 |
-
!!
|
|
|
|
|
|
|
7 |
</p>
|
8 |
|
9 |
<p>
|
3 |
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
<p>
|
5 |
Billing Information:<br />
|
6 |
+
!!billing_name!!<br />
|
7 |
+
!!billing_street!!<br />
|
8 |
+
!!billing_city!!, !!billing_state!! !!billing_zip!!<br />
|
9 |
+
!!billing_phone!!
|
10 |
</p>
|
11 |
|
12 |
<p>
|
email/billing_admin.html
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<p>The billing information for !!display_name!! at !!sitename!! has been changed.</p>
|
2 |
-
|
3 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
-
<p>
|
5 |
-
Billing Information:<br />
|
6 |
-
!!billing_name!!<br />
|
7 |
-
!!billing_street!!<br />
|
8 |
-
!!billing_city!!, !!billing_state!! !!billing_zip!! !!billing_country!!
|
9 |
-
!!billing_phone!!
|
10 |
-
</p>
|
11 |
-
|
12 |
-
<p>
|
13 |
-
!!cardtype!!: !!accountnumber!!<br />
|
14 |
-
Expires: !!expirationmonth!!/!!expirationyear!!
|
15 |
-
</p>
|
16 |
-
|
17 |
-
<p>Log in to your WordPress dashboard here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/billing_failure.html
CHANGED
@@ -3,7 +3,11 @@
|
|
3 |
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
<p>The most recent account information we have on file is:</p>
|
5 |
|
6 |
-
<p>!!
|
|
|
|
|
|
|
|
|
7 |
|
8 |
<p>
|
9 |
!!cardtype!!: !!accountnumber!!<br />
|
3 |
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
<p>The most recent account information we have on file is:</p>
|
5 |
|
6 |
+
<p>!!billing_name!!</br />
|
7 |
+
!!billing_street!!<br />
|
8 |
+
!!billing_city!!, !!billing_state!! !!billing_zip!!<br />
|
9 |
+
!!billing_phone!!
|
10 |
+
</p>
|
11 |
|
12 |
<p>
|
13 |
!!cardtype!!: !!accountnumber!!<br />
|
email/billing_failure_admin.html
CHANGED
@@ -3,7 +3,11 @@
|
|
3 |
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
<p>The most recent account information we have on file is:</p>
|
5 |
|
6 |
-
<p>!!
|
|
|
|
|
|
|
|
|
7 |
|
8 |
<p>
|
9 |
!!cardtype!!: !!accountnumber!!<br />
|
3 |
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
<p>The most recent account information we have on file is:</p>
|
5 |
|
6 |
+
<p>!!billing_name!!</br />
|
7 |
+
!!billing_street!!<br />
|
8 |
+
!!billing_city!!, !!billing_state!! !!billing_zip!!<br />
|
9 |
+
!!billing_phone!!
|
10 |
+
</p>
|
11 |
|
12 |
<p>
|
13 |
!!cardtype!!: !!accountnumber!!<br />
|
email/cancel.html
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
<p>Your membership at !!sitename!! has been
|
2 |
|
3 |
<p>If you did not request this cancellation and would like more information please contact us at !!siteemail!!</p>
|
1 |
+
<p>Your membership at !!sitename!! has been canceled.</p>
|
2 |
|
3 |
<p>If you did not request this cancellation and would like more information please contact us at !!siteemail!!</p>
|
email/cancel_admin.html
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<p>The membership for !!user_login!! at !!sitename!! has been cancelled.</p>
|
2 |
-
|
3 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
-
<p>Membership Level: !!membership_level_name!!</p>
|
5 |
-
<p>Start Date: !!startdate!!</p>
|
6 |
-
<p>Cancellation Date: !!enddate!!</p>
|
7 |
-
|
8 |
-
<p>Log in to your WordPress admin here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/checkout_check.html
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<p>Thank you for your membership to !!sitename!!. Your membership account is now active.</p>
|
2 |
-
|
3 |
-
!!instructions!!
|
4 |
-
|
5 |
-
<p>Below are details about your membership account and a receipt for your initial membership invoice.</p>
|
6 |
-
|
7 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
8 |
-
<p>Membership Level: !!membership_level_name!!</p>
|
9 |
-
<p>Membership Fee: !!membership_cost!!</p>
|
10 |
-
!!membership_expiration!! !!discount_code!!
|
11 |
-
|
12 |
-
<p>
|
13 |
-
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
14 |
-
Total Billed: !!invoice_total!!
|
15 |
-
</p>
|
16 |
-
|
17 |
-
<p>Log in to your membership account here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/checkout_check_admin.html
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<p>There was a new member checkout at !!sitename!!.</p>
|
2 |
-
|
3 |
-
<p><strong>They have chosen to pay by check.</strong></p>
|
4 |
-
|
5 |
-
<p>Below are details about the new membership account and a receipt for the initial membership invoice.</p>
|
6 |
-
|
7 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
8 |
-
<p>Membership Level: !!membership_level_name!!</p>
|
9 |
-
<p>Membership Fee: !!membership_cost!!</p>
|
10 |
-
!!membership_expiration!! !!discount_code!!
|
11 |
-
|
12 |
-
<p>
|
13 |
-
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
14 |
-
Total Billed: $!!invoice_total!!
|
15 |
-
</p>
|
16 |
-
|
17 |
-
<p>Log in to your membership account here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/checkout_express.html
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
|
9 |
<p>
|
10 |
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
11 |
-
Total Billed:
|
12 |
</p>
|
13 |
|
14 |
-
<p>Log in to your membership account here: !!login_link!!</p>
|
8 |
|
9 |
<p>
|
10 |
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
11 |
+
Total Billed: $!!invoice_total!!
|
12 |
</p>
|
13 |
|
14 |
+
<p>Log in to your membership account here: !!login_link!!</p>
|
email/checkout_express_admin.html
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
<p>There was a new member checkout at !!sitename!!.</p>
|
2 |
-
<p>Below are details about the new membership account and a receipt for the initial membership invoice.</p>
|
3 |
-
|
4 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
5 |
-
<p>Membership Level: !!membership_level_name!!</p>
|
6 |
-
<p>Membership Fee: !!membership_cost!!</p>
|
7 |
-
!!membership_expiration!! !!discount_code!!
|
8 |
-
|
9 |
-
<p>
|
10 |
-
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
11 |
-
Total Billed: !!invoice_total!!
|
12 |
-
</p>
|
13 |
-
|
14 |
-
<p>Log in to your membership account here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/checkout_free_admin.html
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<p>There was a new member checkout at !!sitename!!.</p>
|
2 |
-
<p>Below are details about the new membership account.</p>
|
3 |
-
|
4 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
5 |
-
<p>Membership Level: !!membership_level_name!!</p>
|
6 |
-
!!membership_expiration!! !!discount_code!!
|
7 |
-
|
8 |
-
<p>Log in to your membership account here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/checkout_freetrial.html
CHANGED
@@ -8,7 +8,10 @@
|
|
8 |
|
9 |
<p>
|
10 |
Billing Information on File:<br />
|
11 |
-
!!
|
|
|
|
|
|
|
12 |
</p>
|
13 |
|
14 |
<p>
|
8 |
|
9 |
<p>
|
10 |
Billing Information on File:<br />
|
11 |
+
!!billing_name!!<br />
|
12 |
+
!!billing_street!!<br />
|
13 |
+
!!billing_city!!, !!billing_state!! !!billing_zip!!<br />
|
14 |
+
!!billing_phone!!
|
15 |
</p>
|
16 |
|
17 |
<p>
|
email/checkout_freetrial_admin.html
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<p>There was a new member checkout at !!sitename!!.</p>
|
2 |
-
<p>Below are details about the new membership account and a receipt for the initial membership invoice.</p>
|
3 |
-
|
4 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
5 |
-
<p>Membership Level: !!membership_level_name!!</p>
|
6 |
-
<p>Membership Fee: !!membership_cost!!</p>
|
7 |
-
!!membership_expiration!! !!discount_code!!
|
8 |
-
|
9 |
-
<p>
|
10 |
-
Billing Information on File:<br />
|
11 |
-
!!billing_address!!
|
12 |
-
</p>
|
13 |
-
|
14 |
-
<p>
|
15 |
-
!!cardtype!!: !!accountnumber!!<br />
|
16 |
-
Expires: !!expirationmonth!!/!!expirationyear!!
|
17 |
-
</p>
|
18 |
-
|
19 |
-
<p>Log in to your membership account here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/checkout_paid.html
CHANGED
@@ -12,7 +12,10 @@
|
|
12 |
</p>
|
13 |
<p>
|
14 |
Billing Information:<br />
|
15 |
-
!!
|
|
|
|
|
|
|
16 |
</p>
|
17 |
|
18 |
<p>
|
12 |
</p>
|
13 |
<p>
|
14 |
Billing Information:<br />
|
15 |
+
!!billing_name!!<br />
|
16 |
+
!!billing_street!!<br />
|
17 |
+
!!billing_city!!, !!billing_state!! !!billing_zip!!<br />
|
18 |
+
!!billing_phone!!
|
19 |
</p>
|
20 |
|
21 |
<p>
|
email/checkout_paid_admin.html
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<p>There was a new member checkout at !!sitename!!.</p>
|
2 |
-
<p>Below are details about the new membership account and a receipt for the initial membership invoice.</p>
|
3 |
-
|
4 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
5 |
-
<p>Membership Level: !!membership_level_name!!</p>
|
6 |
-
<p>Membership Fee: !!membership_cost!!</p>
|
7 |
-
!!membership_expiration!! !!discount_code!!
|
8 |
-
|
9 |
-
<p>
|
10 |
-
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
11 |
-
Total Billed: !!invoice_total!!
|
12 |
-
</p>
|
13 |
-
<p>
|
14 |
-
Billing Information:<br />
|
15 |
-
!!billing_address!!
|
16 |
-
</p>
|
17 |
-
|
18 |
-
<p>
|
19 |
-
!!cardtype!!: !!accountnumber!!<br />
|
20 |
-
Expires: !!expirationmonth!!/!!expirationyear!!
|
21 |
-
</p>
|
22 |
-
|
23 |
-
<p>Log in to your membership account here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/checkout_trial.html
CHANGED
@@ -12,7 +12,10 @@
|
|
12 |
</p>
|
13 |
<p>
|
14 |
Billing Information:<br />
|
15 |
-
!!
|
|
|
|
|
|
|
16 |
</p>
|
17 |
|
18 |
<p>
|
12 |
</p>
|
13 |
<p>
|
14 |
Billing Information:<br />
|
15 |
+
!!billing_name!!<br />
|
16 |
+
!!billing_street!!<br />
|
17 |
+
!!billing_city!!, !!billing_state!! !!billing_zip!!<br />
|
18 |
+
!!billing_phone!!
|
19 |
</p>
|
20 |
|
21 |
<p>
|
email/checkout_trial_admin.html
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<p>There was a new member checkout at !!sitename!!.</p>
|
2 |
-
<p>Below are details about the new membership account and a receipt for the initial membership invoice.</p>
|
3 |
-
|
4 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
5 |
-
<p>Membership Level: !!membership_level_name!!</p>
|
6 |
-
<p>Membership Fee: !!membership_cost!!</p>
|
7 |
-
!!membership_expiration!! !!discount_code!!
|
8 |
-
|
9 |
-
<p>
|
10 |
-
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
11 |
-
Total Billed: !!invoice_total!!
|
12 |
-
</p>
|
13 |
-
<p>
|
14 |
-
Billing Information:<br />
|
15 |
-
!!billing_address!!
|
16 |
-
</p>
|
17 |
-
|
18 |
-
<p>
|
19 |
-
!!cardtype!!: !!accountnumber!!<br />
|
20 |
-
Expires: !!expirationmonth!!/!!expirationyear!!
|
21 |
-
</p>
|
22 |
-
|
23 |
-
<p>Log in to your membership account here: !!login_link!!</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/credit_card_expiring.html
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
<p>The payment method used for your membership at !!sitename!! will expire soon. <strong>Please click the following link to log in and update your billing information to avoid account suspension. !!login_link!!</strong></p>
|
2 |
-
|
3 |
-
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
-
<p>The most recent account information we have on file is:</p>
|
5 |
-
|
6 |
-
<p>!!billing_name!!</br />
|
7 |
-
!!billing_address!!
|
8 |
-
</p>
|
9 |
-
|
10 |
-
<p>
|
11 |
-
!!cardtype!!: !!accountnumber!!<br />
|
12 |
-
Expires: !!expirationmonth!!/!!expirationyear!!
|
13 |
-
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
email/invoice.html
CHANGED
@@ -3,11 +3,14 @@
|
|
3 |
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
<p>
|
5 |
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
6 |
-
Total Billed:
|
7 |
</p>
|
8 |
<p>
|
9 |
Billing Information:<br />
|
10 |
-
!!
|
|
|
|
|
|
|
11 |
</p>
|
12 |
|
13 |
<p>
|
3 |
<p>Account: !!display_name!! (!!user_email!!)</p>
|
4 |
<p>
|
5 |
Invoice #!!invoice_id!! on !!invoice_date!!<br />
|
6 |
+
Total Billed: $!!invoice_total!!
|
7 |
</p>
|
8 |
<p>
|
9 |
Billing Information:<br />
|
10 |
+
!!billing_name!!<br />
|
11 |
+
!!billing_street!!<br />
|
12 |
+
!!billing_city!!, !!billing_state!! !!billing_zip!!<br />
|
13 |
+
!!billing_phone!!
|
14 |
</p>
|
15 |
|
16 |
<p>
|
email/membership_expired.html
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<p>Your membership at !!sitename!! has
|
2 |
|
3 |
<p>Thank you for your support.</p>
|
4 |
|
1 |
+
<p>Your membership at !!sitename!! has eneded.</p>
|
2 |
|
3 |
<p>Thank you for your support.</p>
|
4 |
|
images/Paid-Memberships-Pro.png
DELETED
Binary file
|
images/Paid-Memberships-Pro_watermark.png
DELETED
Binary file
|
images/bg_grad-chrome.gif
DELETED
Binary file
|
images/bg_grad-grey.gif
DELETED
Binary file
|
images/icon-pmproadmin16-sprite.png
DELETED
Binary file
|
images/icon-pmproadmin16-sprite_2x.png
DELETED
Binary file
|
images/icon-pmproadmin32.png
DELETED
Binary file
|
images/icon-pmproadmin32_2x.png
DELETED
Binary file
|
includes/adminpages.php
DELETED
@@ -1,226 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Get array of PMPro Capabilities
|
4 |
-
*/
|
5 |
-
function pmpro_getPMProCaps()
|
6 |
-
{
|
7 |
-
$pmpro_caps = array(
|
8 |
-
//pmpro_memberships_menu //this controls viewing the menu itself
|
9 |
-
'pmpro_membershiplevels',
|
10 |
-
'pmpro_pagesettings',
|
11 |
-
'pmpro_paymentsettings',
|
12 |
-
'pmpro_emailsettings',
|
13 |
-
'pmpro_advancedsettings',
|
14 |
-
'pmpro_addons',
|
15 |
-
'pmpro_memberslist',
|
16 |
-
'pmpro_reports',
|
17 |
-
'pmpro_orders',
|
18 |
-
'pmpro_discountcodes'
|
19 |
-
);
|
20 |
-
|
21 |
-
return $pmpro_caps;
|
22 |
-
}
|
23 |
-
|
24 |
-
/*
|
25 |
-
Dashboard Menu
|
26 |
-
*/
|
27 |
-
function pmpro_add_pages()
|
28 |
-
{
|
29 |
-
global $wpdb;
|
30 |
-
|
31 |
-
//array of all caps in the menu
|
32 |
-
$pmpro_caps = pmpro_getPMProCaps();
|
33 |
-
|
34 |
-
//the top level menu links to the first page they have access to
|
35 |
-
foreach($pmpro_caps as $cap)
|
36 |
-
{
|
37 |
-
if(current_user_can($cap))
|
38 |
-
{
|
39 |
-
$top_menu_cap = $cap;
|
40 |
-
break;
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
if(empty($top_menu_cap))
|
45 |
-
return;
|
46 |
-
|
47 |
-
add_menu_page(__('Memberships', 'pmpro'), __('Memberships', 'pmpro'), 'pmpro_memberships_menu', 'pmpro-membershiplevels', $top_menu_cap, PMPRO_URL . '/images/menu_users.png');
|
48 |
-
add_submenu_page('pmpro-membershiplevels', __('Page Settings', 'pmpro'), __('Page Settings', 'pmpro'), 'pmpro_pagesettings', 'pmpro-pagesettings', 'pmpro_pagesettings');
|
49 |
-
add_submenu_page('pmpro-membershiplevels', __('Payment Settings', 'pmpro'), __('Payment Settings', 'pmpro'), 'pmpro_paymentsettings', 'pmpro-paymentsettings', 'pmpro_paymentsettings');
|
50 |
-
add_submenu_page('pmpro-membershiplevels', __('Email Settings', 'pmpro'), __('Email Settings', 'pmpro'), 'pmpro_emailsettings', 'pmpro-emailsettings', 'pmpro_emailsettings');
|
51 |
-
add_submenu_page('pmpro-membershiplevels', __('Advanced Settings', 'pmpro'), __('Advanced Settings', 'pmpro'), 'pmpro_advancedsettings', 'pmpro-advancedsettings', 'pmpro_advancedsettings');
|
52 |
-
add_submenu_page('pmpro-membershiplevels', __('Add Ons', 'pmpro'), __('Add Ons', 'pmpro'), 'pmpro_addons', 'pmpro-addons', 'pmpro_addons');
|
53 |
-
add_submenu_page('pmpro-membershiplevels', __('Members List', 'pmpro'), __('Members List', 'pmpro'), 'pmpro_memberslist', 'pmpro-memberslist', 'pmpro_memberslist');
|
54 |
-
add_submenu_page('pmpro-membershiplevels', __('Reports', 'pmpro'), __('Reports', 'pmpro'), 'pmpro_reports', 'pmpro-reports', 'pmpro_reports');
|
55 |
-
add_submenu_page('pmpro-membershiplevels', __('Orders', 'pmpro'), __('Orders', 'pmpro'), 'pmpro_orders', 'pmpro-orders', 'pmpro_orders');
|
56 |
-
add_submenu_page('pmpro-membershiplevels', __('Discount Codes', 'pmpro'), __('Discount Codes', 'pmpro'), 'pmpro_discountcodes', 'pmpro-discountcodes', 'pmpro_discountcodes');
|
57 |
-
|
58 |
-
//rename the automatically added Memberships submenu item
|
59 |
-
global $submenu;
|
60 |
-
if(!empty($submenu['pmpro-membershiplevels']))
|
61 |
-
{
|
62 |
-
if(current_user_can("pmpro_membershiplevels"))
|
63 |
-
{
|
64 |
-
$submenu['pmpro-membershiplevels'][0][0] = __( 'Membership Levels', 'pmpro' );
|
65 |
-
$submenu['pmpro-membershiplevels'][0][3] = __( 'Membership Levels', 'pmpro' );
|
66 |
-
}
|
67 |
-
else
|
68 |
-
{
|
69 |
-
unset($submenu['pmpro-membershiplevels']);
|
70 |
-
}
|
71 |
-
}
|
72 |
-
}
|
73 |
-
add_action('admin_menu', 'pmpro_add_pages');
|
74 |
-
|
75 |
-
/*
|
76 |
-
Admin Bar
|
77 |
-
*/
|
78 |
-
function pmpro_admin_bar_menu() {
|
79 |
-
global $wp_admin_bar;
|
80 |
-
|
81 |
-
//view menu at all?
|
82 |
-
if ( !current_user_can('pmpro_memberships_menu') || !is_admin_bar_showing() )
|
83 |
-
return;
|
84 |
-
|
85 |
-
//array of all caps in the menu
|
86 |
-
$pmpro_caps = pmpro_getPMProCaps();
|
87 |
-
|
88 |
-
//the top level menu links to the first page they have access to
|
89 |
-
foreach($pmpro_caps as $cap)
|
90 |
-
{
|
91 |
-
if(current_user_can($cap))
|
92 |
-
{
|
93 |
-
$top_menu_page = str_replace("_", "-", $cap);
|
94 |
-
break;
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
$wp_admin_bar->add_menu( array(
|
99 |
-
'id' => 'paid-memberships-pro',
|
100 |
-
'title' => __( 'Memberships', 'pmpro'),
|
101 |
-
'href' => get_admin_url(NULL, '/admin.php?page=' . $top_menu_page) ) );
|
102 |
-
|
103 |
-
if(current_user_can('pmpro_membershiplevels'))
|
104 |
-
$wp_admin_bar->add_menu( array(
|
105 |
-
'id' => 'pmpro-membership-levels',
|
106 |
-
'parent' => 'paid-memberships-pro',
|
107 |
-
'title' => __( 'Membership Levels', 'pmpro'),
|
108 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-membershiplevels') ) );
|
109 |
-
|
110 |
-
if(current_user_can('pmpro_pagesettings'))
|
111 |
-
$wp_admin_bar->add_menu( array(
|
112 |
-
'id' => 'pmpro-page-settings',
|
113 |
-
'parent' => 'paid-memberships-pro',
|
114 |
-
'title' => __( 'Page Settings', 'pmpro'),
|
115 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-pagesettings') ) );
|
116 |
-
|
117 |
-
if(current_user_can('pmpro_paymentsettings'))
|
118 |
-
$wp_admin_bar->add_menu( array(
|
119 |
-
'id' => 'pmpro-payment-settings',
|
120 |
-
'parent' => 'paid-memberships-pro',
|
121 |
-
'title' => __( 'Payment Settings', 'pmpro'),
|
122 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-paymentsettings') ) );
|
123 |
-
|
124 |
-
if(current_user_can('pmpro_emailsettings'))
|
125 |
-
$wp_admin_bar->add_menu( array(
|
126 |
-
'id' => 'pmpro-email-settings',
|
127 |
-
'parent' => 'paid-memberships-pro',
|
128 |
-
'title' => __( 'Email Settings', 'pmpro'),
|
129 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-emailsettings') ) );
|
130 |
-
|
131 |
-
if(current_user_can('pmpro_advancedsettings'))
|
132 |
-
$wp_admin_bar->add_menu( array(
|
133 |
-
'id' => 'pmpro-advanced-settings',
|
134 |
-
'parent' => 'paid-memberships-pro',
|
135 |
-
'title' => __( 'Advanced Settings', 'pmpro'),
|
136 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-advancedsettings') ) );
|
137 |
-
|
138 |
-
if(current_user_can('pmpro_addons'))
|
139 |
-
$wp_admin_bar->add_menu( array(
|
140 |
-
'id' => 'pmpro-addons',
|
141 |
-
'parent' => 'paid-memberships-pro',
|
142 |
-
'title' => __( 'Add Ons', 'pmpro'),
|
143 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-addons') ) );
|
144 |
-
|
145 |
-
if(current_user_can('pmpro_memberslist'))
|
146 |
-
$wp_admin_bar->add_menu( array(
|
147 |
-
'id' => 'pmpro-members-list',
|
148 |
-
'parent' => 'paid-memberships-pro',
|
149 |
-
'title' => __( 'Members List', 'pmpro'),
|
150 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-memberslist') ) );
|
151 |
-
|
152 |
-
if(current_user_can('pmpro_reports'))
|
153 |
-
$wp_admin_bar->add_menu( array(
|
154 |
-
'id' => 'pmpro-reports',
|
155 |
-
'parent' => 'paid-memberships-pro',
|
156 |
-
'title' => __( 'Reports', 'pmpro'),
|
157 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-reports') ) );
|
158 |
-
|
159 |
-
if(current_user_can('pmpro_orders'))
|
160 |
-
$wp_admin_bar->add_menu( array(
|
161 |
-
'id' => 'pmpro-orders',
|
162 |
-
'parent' => 'paid-memberships-pro',
|
163 |
-
'title' => __( 'Orders', 'pmpro'),
|
164 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-orders') ) );
|
165 |
-
|
166 |
-
if(current_user_can('pmpro_discountcodes'))
|
167 |
-
$wp_admin_bar->add_menu( array(
|
168 |
-
'id' => 'pmpro-discount-codes',
|
169 |
-
'parent' => 'paid-memberships-pro',
|
170 |
-
'title' => __( 'Discount Codes', 'pmpro'),
|
171 |
-
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-discountcodes') ) );
|
172 |
-
}
|
173 |
-
add_action('admin_bar_menu', 'pmpro_admin_bar_menu', 1000);
|
174 |
-
|
175 |
-
/*
|
176 |
-
Functions to load pages from adminpages directory
|
177 |
-
*/
|
178 |
-
function pmpro_reports()
|
179 |
-
{
|
180 |
-
require_once(PMPRO_DIR . "/adminpages/reports.php");
|
181 |
-
}
|
182 |
-
|
183 |
-
function pmpro_memberslist()
|
184 |
-
{
|
185 |
-
require_once(PMPRO_DIR . "/adminpages/memberslist.php");
|
186 |
-
}
|
187 |
-
|
188 |
-
function pmpro_discountcodes()
|
189 |
-
{
|
190 |
-
require_once(PMPRO_DIR . "/adminpages/discountcodes.php");
|
191 |
-
}
|
192 |
-
|
193 |
-
function pmpro_membershiplevels()
|
194 |
-
{
|
195 |
-
require_once(PMPRO_DIR . "/adminpages/membershiplevels.php");
|
196 |
-
}
|
197 |
-
|
198 |
-
function pmpro_pagesettings()
|
199 |
-
{
|
200 |
-
require_once(PMPRO_DIR . "/adminpages/pagesettings.php");
|
201 |
-
}
|
202 |
-
|
203 |
-
function pmpro_paymentsettings()
|
204 |
-
{
|
205 |
-
require_once(PMPRO_DIR . "/adminpages/paymentsettings.php");
|
206 |
-
}
|
207 |
-
|
208 |
-
function pmpro_emailsettings()
|
209 |
-
{
|
210 |
-
require_once(PMPRO_DIR . "/adminpages/emailsettings.php");
|
211 |
-
}
|
212 |
-
|
213 |
-
function pmpro_advancedsettings()
|
214 |
-
{
|
215 |
-
require_once(PMPRO_DIR . "/adminpages/advancedsettings.php");
|
216 |
-
}
|
217 |
-
|
218 |
-
function pmpro_addons()
|
219 |
-
{
|
220 |
-
require_once(PMPRO_DIR . "/adminpages/addons.php");
|
221 |
-
}
|
222 |
-
|
223 |
-
function pmpro_orders()
|
224 |
-
{
|
225 |
-
require_once(PMPRO_DIR . "/adminpages/orders.php");
|
226 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/cleanup.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Clean things up when deletes happen, etc. (This stuff needs a better home.)
|
4 |
-
*/
|
5 |
-
//deleting a user? remove their account info.
|
6 |
-
function pmpro_delete_user($user_id = NULL)
|
7 |
-
{
|
8 |
-
global $wpdb;
|
9 |
-
|
10 |
-
//changing their membership level to 0 will cancel any subscription and remove their membership level entry
|
11 |
-
//we don't remove the orders because it would affect reporting
|
12 |
-
if(pmpro_changeMembershipLevel(0, $user_id))
|
13 |
-
{
|
14 |
-
//okay
|
15 |
-
}
|
16 |
-
else
|
17 |
-
{
|
18 |
-
//okay, guessing they didn't have a level
|
19 |
-
}
|
20 |
-
}
|
21 |
-
add_action('delete_user', 'pmpro_delete_user');
|
22 |
-
add_action('wpmu_delete_user', 'pmpro_delete_user');
|
23 |
-
|
24 |
-
//deleting a category? remove any level associations
|
25 |
-
function pmpro_delete_category($cat_id = NULL)
|
26 |
-
{
|
27 |
-
global $wpdb;
|
28 |
-
$sqlQuery = "DELETE FROM $wpdb->pmpro_memberships_categories WHERE category_id = '" . $cat_id . "'";
|
29 |
-
$wpdb->query($sqlQuery);
|
30 |
-
}
|
31 |
-
add_action('delete_category', 'pmpro_delete_category');
|
32 |
-
|
33 |
-
//deleting a post? remove any level associations
|
34 |
-
function pmpro_delete_post($post_id = NULL)
|
35 |
-
{
|
36 |
-
global $wpdb;
|
37 |
-
$sqlQuery = "DELETE FROM $wpdb->pmpro_memberships_pages WHERE page_id = '" . $post_id . "'";
|
38 |
-
$wpdb->query($sqlQuery);
|
39 |
-
}
|
40 |
-
add_action('delete_post', 'pmpro_delete_post');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/content.php
DELETED
@@ -1,405 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Functions to detect member content and protect it.
|
4 |
-
*/
|
5 |
-
function pmpro_has_membership_access($post_id = NULL, $user_id = NULL, $return_membership_levels = false)
|
6 |
-
{
|
7 |
-
global $post, $wpdb, $current_user;
|
8 |
-
//use globals if no values supplied
|
9 |
-
if(!$post_id)
|
10 |
-
$post_id = $post->ID;
|
11 |
-
if(!$user_id)
|
12 |
-
$user_id = $current_user->ID;
|
13 |
-
|
14 |
-
//no post, return true (changed from false in version 1.7.2)
|
15 |
-
if(!$post_id)
|
16 |
-
return true;
|
17 |
-
|
18 |
-
//if no post or current_user object, set them up
|
19 |
-
if(!empty($post->ID) && $post_id == $post->ID)
|
20 |
-
$mypost = $post;
|
21 |
-
else
|
22 |
-
$mypost = get_post($post_id);
|
23 |
-
|
24 |
-
if($user_id == $current_user->ID)
|
25 |
-
$myuser = $current_user;
|
26 |
-
else
|
27 |
-
$myuser = get_userdata($user_id);
|
28 |
-
|
29 |
-
//for these post types, we want to check the parent
|
30 |
-
if($mypost->post_type == "attachment" || $mypost->post_type == "revision")
|
31 |
-
{
|
32 |
-
$mypost = get_post($mypost->post_parent);
|
33 |
-
}
|
34 |
-
|
35 |
-
if($mypost->post_type == "post")
|
36 |
-
{
|
37 |
-
$post_categories = wp_get_post_categories($mypost->ID);
|
38 |
-
|
39 |
-
if(!$post_categories)
|
40 |
-
{
|
41 |
-
//just check for entries in the memberships_pages table
|
42 |
-
$sqlQuery = "SELECT m.id, m.name FROM $wpdb->pmpro_memberships_pages mp LEFT JOIN $wpdb->pmpro_membership_levels m ON mp.membership_id = m.id WHERE mp.page_id = '" . $mypost->ID . "'";
|
43 |
-
}
|
44 |
-
else
|
45 |
-
{
|
46 |
-
//are any of the post categories associated with membership levels? also check the memberships_pages table
|
47 |
-
$sqlQuery = "(SELECT m.id, m.name FROM $wpdb->pmpro_memberships_categories mc LEFT JOIN $wpdb->pmpro_membership_levels m ON mc.membership_id = m.id WHERE mc.category_id IN(" . implode(",", $post_categories) . ") AND m.id IS NOT NULL) UNION (SELECT m.id, m.name FROM $wpdb->pmpro_memberships_pages mp LEFT JOIN $wpdb->pmpro_membership_levels m ON mp.membership_id = m.id WHERE mp.page_id = '" . $mypost->ID . "')";
|
48 |
-
}
|
49 |
-
}
|
50 |
-
else
|
51 |
-
{
|
52 |
-
//are any membership levels associated with this page?
|
53 |
-
$sqlQuery = "SELECT m.id, m.name FROM $wpdb->pmpro_memberships_pages mp LEFT JOIN $wpdb->pmpro_membership_levels m ON mp.membership_id = m.id WHERE mp.page_id = '" . $mypost->ID . "'";
|
54 |
-
}
|
55 |
-
|
56 |
-
|
57 |
-
$post_membership_levels = $wpdb->get_results($sqlQuery);
|
58 |
-
|
59 |
-
$post_membership_levels_ids = array();
|
60 |
-
$post_membership_levels_names = array();
|
61 |
-
|
62 |
-
if(!$post_membership_levels)
|
63 |
-
{
|
64 |
-
$hasaccess = true;
|
65 |
-
}
|
66 |
-
else
|
67 |
-
{
|
68 |
-
//we need to see if the user has access
|
69 |
-
foreach($post_membership_levels as $level)
|
70 |
-
{
|
71 |
-
$post_membership_levels_ids[] = $level->id;
|
72 |
-
$post_membership_levels_names[] = $level->name;
|
73 |
-
}
|
74 |
-
|
75 |
-
//levels found. check if this is in a feed or if the current user is in at least one of those membership levels
|
76 |
-
if(is_feed())
|
77 |
-
{
|
78 |
-
//always block restricted feeds
|
79 |
-
$hasaccess = false;
|
80 |
-
}
|
81 |
-
elseif(!empty($myuser->ID))
|
82 |
-
{
|
83 |
-
$myuser->membership_level = pmpro_getMembershipLevelForUser($myuser->ID);
|
84 |
-
if(!empty($myuser->membership_level->ID) && in_array($myuser->membership_level->ID, $post_membership_levels_ids))
|
85 |
-
{
|
86 |
-
//the users membership id is one that will grant access
|
87 |
-
$hasaccess = true;
|
88 |
-
}
|
89 |
-
else
|
90 |
-
{
|
91 |
-
//user isn't a member of a level with access
|
92 |
-
$hasaccess = false;
|
93 |
-
}
|
94 |
-
}
|
95 |
-
else
|
96 |
-
{
|
97 |
-
//user is not logged in and this content requires membership
|
98 |
-
$hasaccess = false;
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
/*
|
103 |
-
Filters
|
104 |
-
The generic filter is run first. Then if there is a filter for this post type, that is run.
|
105 |
-
*/
|
106 |
-
//general filter for all posts
|
107 |
-
$hasaccess = apply_filters("pmpro_has_membership_access_filter", $hasaccess, $mypost, $myuser, $post_membership_levels);
|
108 |
-
//filter for this post type
|
109 |
-
if(has_filter("pmpro_has_membership_access_filter_" . $mypost->post_type))
|
110 |
-
$hasaccess = apply_filters("pmpro_has_membership_access_filter_" . $mypost->post_type, $hasaccess, $mypost, $myuser, $post_membership_levels);
|
111 |
-
|
112 |
-
//return
|
113 |
-
if($return_membership_levels)
|
114 |
-
return array($hasaccess, $post_membership_levels_ids, $post_membership_levels_names);
|
115 |
-
else
|
116 |
-
return $hasaccess;
|
117 |
-
}
|
118 |
-
|
119 |
-
function pmpro_search_filter($query)
|
120 |
-
{
|
121 |
-
global $current_user, $wpdb, $pmpro_pages;
|
122 |
-
|
123 |
-
//hide pmpro pages from search results
|
124 |
-
if(!$query->is_admin && $query->is_search && empty($query->query['post_parent']))
|
125 |
-
{
|
126 |
-
$query->set('post__not_in', $pmpro_pages ); // id of page or post
|
127 |
-
}
|
128 |
-
|
129 |
-
//hide member pages from non-members (make sure they aren't hidden from members)
|
130 |
-
if(!$query->is_admin &&
|
131 |
-
!$query->is_singular &&
|
132 |
-
empty($query->query['post_parent']) &&
|
133 |
-
(
|
134 |
-
empty($query->query_vars['post_type']) ||
|
135 |
-
in_array($query->query_vars['post_type'], apply_filters('pmpro_search_filter_post_types', array("page", "post")))
|
136 |
-
)
|
137 |
-
)
|
138 |
-
{
|
139 |
-
//get page ids that are in my levels
|
140 |
-
$levels = pmpro_getMembershipLevelsForUser($current_user->ID);
|
141 |
-
$my_pages = array();
|
142 |
-
|
143 |
-
if($levels) {
|
144 |
-
foreach($levels as $key => $level) {
|
145 |
-
//get restricted posts for level
|
146 |
-
$sql = "SELECT page_id FROM $wpdb->pmpro_memberships_pages WHERE membership_id=" . $current_user->membership_level->ID;
|
147 |
-
$member_pages = $wpdb->get_col($sql);
|
148 |
-
$my_pages = array_unique(array_merge($my_pages, $member_pages));
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
//get hidden page ids
|
153 |
-
if(!empty($my_pages))
|
154 |
-
$sql = "SELECT page_id FROM $wpdb->pmpro_memberships_pages WHERE page_id NOT IN(" . implode(',', $my_pages) . ")";
|
155 |
-
else
|
156 |
-
$sql = "SELECT page_id FROM $wpdb->pmpro_memberships_pages";
|
157 |
-
$hidden_page_ids = array_values(array_unique($wpdb->get_col($sql)));
|
158 |
-
|
159 |
-
if($hidden_page_ids)
|
160 |
-
$query->set('post__not_in', $hidden_page_ids);
|
161 |
-
|
162 |
-
//get categories that are filtered by level, but not my level
|
163 |
-
$my_cats = array();
|
164 |
-
|
165 |
-
if($levels) {
|
166 |
-
foreach($levels as $key => $level) {
|
167 |
-
$member_cats = pmpro_getMembershipCategories($level->id);
|
168 |
-
$my_cats = array_unique(array_merge($my_cats, $member_cats));
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
//get hidden cats
|
173 |
-
if(!empty($my_cats))
|
174 |
-
$sql = "SELECT category_id FROM $wpdb->pmpro_memberships_categories WHERE category_id NOT IN(" . implode(',', $my_cats) . ")";
|
175 |
-
else
|
176 |
-
$sql = "SELECT category_id FROM $wpdb->pmpro_memberships_categories";
|
177 |
-
|
178 |
-
$hidden_cat_ids = array_values(array_unique($wpdb->get_col($sql)));
|
179 |
-
|
180 |
-
//make this work
|
181 |
-
if($hidden_cat_ids)
|
182 |
-
$query->set('category__not_in', $hidden_cat_ids);
|
183 |
-
}
|
184 |
-
|
185 |
-
return $query;
|
186 |
-
}
|
187 |
-
$filterqueries = pmpro_getOption("filterqueries");
|
188 |
-
if(!empty($filterqueries))
|
189 |
-
add_filter( 'pre_get_posts', 'pmpro_search_filter' );
|
190 |
-
|
191 |
-
function pmpro_membership_content_filter($content, $skipcheck = false)
|
192 |
-
{
|
193 |
-
global $post, $current_user;
|
194 |
-
|
195 |
-
if(!$skipcheck)
|
196 |
-
{
|
197 |
-
$hasaccess = pmpro_has_membership_access(NULL, NULL, true);
|
198 |
-
if(is_array($hasaccess))
|
199 |
-
{
|
200 |
-
//returned an array to give us the membership level values
|
201 |
-
$post_membership_levels_ids = $hasaccess[1];
|
202 |
-
$post_membership_levels_names = $hasaccess[2];
|
203 |
-
$hasaccess = $hasaccess[0];
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
if($hasaccess)
|
208 |
-
{
|
209 |
-
//all good, return content
|
210 |
-
return $content;
|
211 |
-
}
|
212 |
-
else
|
213 |
-
{
|
214 |
-
//if show excerpts is set, return just the excerpt
|
215 |
-
if(pmpro_getOption("showexcerpts"))
|
216 |
-
{
|
217 |
-
//show excerpt
|
218 |
-
global $post;
|
219 |
-
if($post->post_excerpt)
|
220 |
-
{
|
221 |
-
//defined exerpt
|
222 |
-
$content = wpautop($post->post_excerpt);
|
223 |
-
}
|
224 |
-
elseif(strpos($content, "<span id=\"more-" . $post->ID . "\"></span>") !== false)
|
225 |
-
{
|
226 |
-
//more tag
|
227 |
-
$pos = strpos($content, "<span id=\"more-" . $post->ID . "\"></span>");
|
228 |
-
$content = wpautop(substr($content, 0, $pos));
|
229 |
-
}
|
230 |
-
elseif(strpos($content, 'class="more-link">') !== false)
|
231 |
-
{
|
232 |
-
//more link
|
233 |
-
$content = preg_replace("/\<a.*class\=\"more\-link\".*\>.*\<\/a\>/", "", $content);
|
234 |
-
}
|
235 |
-
else
|
236 |
-
{
|
237 |
-
//auto generated excerpt. pulled from wp_trim_excerpt
|
238 |
-
$content = strip_shortcodes( $content );
|
239 |
-
$content = str_replace(']]>', ']]>', $content);
|
240 |
-
$content = strip_tags($content);
|
241 |
-
$excerpt_length = apply_filters('excerpt_length', 55);
|
242 |
-
$words = preg_split("/[\n\r\t ]+/", $content, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
|
243 |
-
if ( count($words) > $excerpt_length ) {
|
244 |
-
array_pop($words);
|
245 |
-
$content = implode(' ', $words);
|
246 |
-
$content = $content . "... ";
|
247 |
-
} else {
|
248 |
-
$content = implode(' ', $words) . "... ";
|
249 |
-
}
|
250 |
-
|
251 |
-
$content = wpautop($content);
|
252 |
-
}
|
253 |
-
}
|
254 |
-
else
|
255 |
-
{
|
256 |
-
//else hide everything
|
257 |
-
$content = "";
|
258 |
-
}
|
259 |
-
|
260 |
-
if(empty($post_membership_levels_ids))
|
261 |
-
$post_membership_levels_ids = array();
|
262 |
-
|
263 |
-
if(empty($post_membership_levels_names))
|
264 |
-
$post_membership_levels_names = array();
|
265 |
-
|
266 |
-
$pmpro_content_message_pre = '<div class="pmpro_content_message">';
|
267 |
-
$pmpro_content_message_post = '</div>';
|
268 |
-
|
269 |
-
$sr_search = array("!!levels!!", "!!referrer!!");
|
270 |
-
$sr_replace = array(pmpro_implodeToEnglish($post_membership_levels_names), $_SERVER['REQUEST_URI']);
|
271 |
-
|
272 |
-
//get the correct message to show at the bottom
|
273 |
-
if(is_feed())
|
274 |
-
{
|
275 |
-
$newcontent = apply_filters("pmpro_rss_text_filter", stripslashes(pmpro_getOption("rsstext")));
|
276 |
-
$content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
|
277 |
-
}
|
278 |
-
elseif($current_user->ID)
|
279 |
-
{
|
280 |
-
//not a member
|
281 |
-
$newcontent = apply_filters("pmpro_non_member_text_filter", stripslashes(pmpro_getOption("nonmembertext")));
|
282 |
-
$content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
|
283 |
-
}
|
284 |
-
else
|
285 |
-
{
|
286 |
-
//not logged in!
|
287 |
-
$newcontent = apply_filters("pmpro_not_logged_in_text_filter", stripslashes(pmpro_getOption("notloggedintext")));
|
288 |
-
$content .= $pmpro_content_message_pre . str_replace($sr_search, $sr_replace, $newcontent) . $pmpro_content_message_post;
|
289 |
-
}
|
290 |
-
}
|
291 |
-
|
292 |
-
return $content;
|
293 |
-
}
|
294 |
-
add_filter('the_content', 'pmpro_membership_content_filter', 5);
|
295 |
-
add_filter('the_content_rss', 'pmpro_membership_content_filter', 5);
|
296 |
-
add_filter('comment_text_rss', 'pmpro_membership_content_filter', 5);
|
297 |
-
|
298 |
-
/*
|
299 |
-
If the_excerpt is called, we want to disable the_content filters so the PMPro messages aren't added to the content before AND after the ecerpt.
|
300 |
-
*/
|
301 |
-
function pmpro_membership_excerpt_filter($content, $skipcheck = false)
|
302 |
-
{
|
303 |
-
remove_filter('the_content', 'pmpro_membership_content_filter', 5);
|
304 |
-
$content = pmpro_membership_content_filter($content, $skipcheck);
|
305 |
-
add_filter('the_content', 'pmpro_membership_content_filter', 5);
|
306 |
-
|
307 |
-
return $content;
|
308 |
-
}
|
309 |
-
function pmpro_membership_get_excerpt_filter_start($content, $skipcheck = false)
|
310 |
-
{
|
311 |
-
remove_filter('the_content', 'pmpro_membership_content_filter', 5);
|
312 |
-
return $content;
|
313 |
-
}
|
314 |
-
function pmpro_membership_get_excerpt_filter_end($content, $skipcheck = false)
|
315 |
-
{
|
316 |
-
add_filter('the_content', 'pmpro_membership_content_filter', 5);
|
317 |
-
return $content;
|
318 |
-
}
|
319 |
-
add_filter('the_excerpt', 'pmpro_membership_excerpt_filter', 15);
|
320 |
-
add_filter('get_the_excerpt', 'pmpro_membership_get_excerpt_filter_start', 1);
|
321 |
-
add_filter('get_the_excerpt', 'pmpro_membership_get_excerpt_filter_end', 100);
|
322 |
-
|
323 |
-
function pmpro_comments_filter($comments, $post_id = NULL)
|
324 |
-
{
|
325 |
-
global $post, $wpdb, $current_user;
|
326 |
-
if(!$post_id)
|
327 |
-
$post_id = $post->ID;
|
328 |
-
|
329 |
-
if(!$comments)
|
330 |
-
return $comments; //if they are closed anyway, we don't need to check
|
331 |
-
|
332 |
-
global $post, $current_user;
|
333 |
-
|
334 |
-
$hasaccess = pmpro_has_membership_access(NULL, NULL, true);
|
335 |
-
if(is_array($hasaccess))
|
336 |
-
{
|
337 |
-
//returned an array to give us the membership level values
|
338 |
-
$post_membership_levels_ids = $hasaccess[1];
|
339 |
-
$post_membership_levels_names = $hasaccess[2];
|
340 |
-
$hasaccess = $hasaccess[0];
|
341 |
-
}
|
342 |
-
|
343 |
-
if($hasaccess)
|
344 |
-
{
|
345 |
-
//all good, return content
|
346 |
-
return $comments;
|
347 |
-
}
|
348 |
-
else
|
349 |
-
{
|
350 |
-
if(!$post_membership_levels_ids)
|
351 |
-
$post_membership_levels_ids = array();
|
352 |
-
|
353 |
-
if(!$post_membership_levels_names)
|
354 |
-
$post_membership_levels_names = array();
|
355 |
-
|
356 |
-
//get the correct message
|
357 |
-
if(is_feed())
|
358 |
-
{
|
359 |
-
if(is_array($comments))
|
360 |
-
return array();
|
361 |
-
else
|
362 |
-
return false;
|
363 |
-
}
|
364 |
-
elseif($current_user->ID)
|
365 |
-
{
|
366 |
-
//not a member
|
367 |
-
if(is_array($comments))
|
368 |
-
return array();
|
369 |
-
else
|
370 |
-
return false;
|
371 |
-
}
|
372 |
-
else
|
373 |
-
{
|
374 |
-
//not logged in!
|
375 |
-
if(is_array($comments))
|
376 |
-
return array();
|
377 |
-
else
|
378 |
-
return false;
|
379 |
-
}
|
380 |
-
}
|
381 |
-
|
382 |
-
return $comments;
|
383 |
-
}
|
384 |
-
add_filter("comments_array", "pmpro_comments_filter");
|
385 |
-
add_filter("comments_open", "pmpro_comments_filter");
|
386 |
-
|
387 |
-
//keep non-members from getting to certain pages (attachments, etc)
|
388 |
-
function pmpro_hide_pages_redirect()
|
389 |
-
{
|
390 |
-
global $post;
|
391 |
-
|
392 |
-
if(!is_admin() && !empty($post->ID))
|
393 |
-
{
|
394 |
-
if($post->post_type == "attachment")
|
395 |
-
{
|
396 |
-
//check if the user has access to the parent
|
397 |
-
if(!pmpro_has_membership_access($post->ID))
|
398 |
-
{
|
399 |
-
wp_redirect(pmpro_url("levels"));
|
400 |
-
exit;
|
401 |
-
}
|
402 |
-
}
|
403 |
-
}
|
404 |
-
}
|
405 |
-
add_action('wp', 'pmpro_hide_pages_redirect');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/countries.php
CHANGED
@@ -254,6 +254,5 @@
|
|
254 |
'VE' => 'Venezuela',
|
255 |
);
|
256 |
|
257 |
-
|
258 |
-
|
259 |
-
$pmpro_countries = apply_filters("pmpro_countries", $pmpro_countries);
|
254 |
'VE' => 'Venezuela',
|
255 |
);
|
256 |
|
257 |
+
$pmpro_countries = apply_filters("pmpro_countries", $pmpro_countries);
|
258 |
+
?>
|
|
includes/currencies.php
CHANGED
@@ -10,13 +10,10 @@
|
|
10 |
'AUD' => __('Australian Dollars ($)', 'pmpro'),
|
11 |
'BRL' => __('Brazilian Real ($)', 'pmpro'),
|
12 |
'CAD' => __('Canadian Dollars ($)', 'pmpro'),
|
13 |
-
'CNY' => __('Chinese Yuan', 'pmpro'),
|
14 |
'CZK' => __('Czech Koruna', 'pmpro'),
|
15 |
'DKK' => __('Danish Krone', 'pmpro'),
|
16 |
'HKD' => __('Hong Kong Dollar ($)', 'pmpro'),
|
17 |
'HUF' => __('Hungarian Forint', 'pmpro'),
|
18 |
-
'INR' => __('Indian Rupee', 'pmpro'),
|
19 |
-
'IDR' => __('Indonesia Rupiah', 'pmpro'),
|
20 |
'ILS' => __('Israeli Shekel', 'pmpro'),
|
21 |
'JPY' => __('Japanese Yen (¥)', 'pmpro'),
|
22 |
'MYR' => __('Malaysian Ringgits', 'pmpro'),
|
@@ -26,24 +23,11 @@
|
|
26 |
'PHP' => __('Philippine Pesos', 'pmpro'),
|
27 |
'PLN' => __('Polish Zloty', 'pmpro'),
|
28 |
'SGD' => __('Singapore Dollar ($)', 'pmpro'),
|
29 |
-
'ZAR' => __('South African Rand', 'pmpro'),
|
30 |
-
'KRW' => __('South Korean Won', 'pmpro'),
|
31 |
'SEK' => __('Swedish Krona', 'pmpro'),
|
32 |
'CHF' => __('Swiss Franc', 'pmpro'),
|
33 |
'TWD' => __('Taiwan New Dollars', 'pmpro'),
|
34 |
-
'THB' => __('Thai Baht', 'pmpro')
|
35 |
-
'TRY' => __('Turkish Lira', 'pmpro'),
|
36 |
-
'VND' => __('Vietnamese Dong', 'pmpro')
|
37 |
);
|
38 |
|
39 |
$pmpro_currencies = apply_filters("pmpro_currencies", $pmpro_currencies);
|
40 |
-
|
41 |
-
//stripe only supports a few (not using this anymore since 1.7.4)
|
42 |
-
global $pmpro_stripe_currencies;
|
43 |
-
$pmpro_stripe_currencies = array(
|
44 |
-
'USD' => __('US Dollars ($)', 'pmpro'),
|
45 |
-
'CAD' => __('Canadian Dollars ($)', 'pmpro'),
|
46 |
-
'GBP' => __('Pounds Sterling (£)', 'pmpro'),
|
47 |
-
'EUR' => __('Euros (€)', 'pmpro')
|
48 |
-
);
|
49 |
?>
|
10 |
'AUD' => __('Australian Dollars ($)', 'pmpro'),
|
11 |
'BRL' => __('Brazilian Real ($)', 'pmpro'),
|
12 |
'CAD' => __('Canadian Dollars ($)', 'pmpro'),
|
|
|
13 |
'CZK' => __('Czech Koruna', 'pmpro'),
|
14 |
'DKK' => __('Danish Krone', 'pmpro'),
|
15 |
'HKD' => __('Hong Kong Dollar ($)', 'pmpro'),
|
16 |
'HUF' => __('Hungarian Forint', 'pmpro'),
|
|
|
|
|
17 |
'ILS' => __('Israeli Shekel', 'pmpro'),
|
18 |
'JPY' => __('Japanese Yen (¥)', 'pmpro'),
|
19 |
'MYR' => __('Malaysian Ringgits', 'pmpro'),
|
23 |
'PHP' => __('Philippine Pesos', 'pmpro'),
|
24 |
'PLN' => __('Polish Zloty', 'pmpro'),
|
25 |
'SGD' => __('Singapore Dollar ($)', 'pmpro'),
|
|
|
|
|
26 |
'SEK' => __('Swedish Krona', 'pmpro'),
|
27 |
'CHF' => __('Swiss Franc', 'pmpro'),
|
28 |
'TWD' => __('Taiwan New Dollars', 'pmpro'),
|
29 |
+
'THB' => __('Thai Baht', 'pmpro')
|
|
|
|
|
30 |
);
|
31 |
|
32 |
$pmpro_currencies = apply_filters("pmpro_currencies", $pmpro_currencies);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
?>
|
includes/email.php
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Nicer default emails
|
4 |
-
*/
|
5 |
-
function pmpro_wp_mail_from_name($from_name)
|
6 |
-
{
|
7 |
-
$default_from_name = 'WordPress';
|
8 |
-
|
9 |
-
//make sure it's the default from name
|
10 |
-
if($from_name == $default_from_name)
|
11 |
-
{
|
12 |
-
$pmpro_from_name = pmpro_getOption("from_name");
|
13 |
-
if ($pmpro_from_name)
|
14 |
-
$from_name = $pmpro_from_name;
|
15 |
-
}
|
16 |
-
|
17 |
-
return $from_name;
|
18 |
-
}
|
19 |
-
function pmpro_wp_mail_from($from_email)
|
20 |
-
{
|
21 |
-
// default from email wordpress@sitename
|
22 |
-
$sitename = strtolower( $_SERVER['SERVER_NAME'] );
|
23 |
-
if ( substr( $sitename, 0, 4 ) == 'www.' ) {
|
24 |
-
$sitename = substr( $sitename, 4 );
|
25 |
-
}
|
26 |
-
$default_from_email = 'wordpress@' . $sitename;
|
27 |
-
|
28 |
-
//make sure it's the default email address
|
29 |
-
if($from_email == $default_from_email)
|
30 |
-
{
|
31 |
-
$pmpro_from_email = pmpro_getOption("from_email");
|
32 |
-
if ($pmpro_from_email && is_email( $pmpro_from_email ) )
|
33 |
-
$from_email = $pmpro_from_email;
|
34 |
-
}
|
35 |
-
|
36 |
-
return $from_email;
|
37 |
-
}
|
38 |
-
|
39 |
-
$only_filter_pmpro_emails = pmpro_getOption("only_filter_pmpro_emails");
|
40 |
-
if($only_filter_pmpro_emails)
|
41 |
-
{
|
42 |
-
add_filter('pmpro_email_sender_name', 'pmpro_wp_mail_from_name');
|
43 |
-
add_filter('pmpro_email_sender', 'pmpro_wp_mail_from');
|
44 |
-
}
|
45 |
-
else
|
46 |
-
{
|
47 |
-
add_filter('wp_mail_from_name', 'pmpro_wp_mail_from_name');
|
48 |
-
add_filter('wp_mail_from', 'pmpro_wp_mail_from');
|
49 |
-
}
|
50 |
-
|
51 |
-
/*
|
52 |
-
If the $email_member_notification option is empty, disable the wp_new_user_notification email at checkout.
|
53 |
-
*/
|
54 |
-
$email_member_notification = pmpro_getOption("email_member_notification");
|
55 |
-
if(empty($email_member_notification))
|
56 |
-
add_filter("pmpro_wp_new_user_notification", "__return_false", 0);
|
57 |
-
|
58 |
-
/*
|
59 |
-
Adds template files and changes content type to html if using PHPMailer directly.
|
60 |
-
*/
|
61 |
-
function pmpro_send_html( $phpmailer ) {
|
62 |
-
|
63 |
-
// Set the original plain text message
|
64 |
-
$phpmailer->AltBody = wp_specialchars_decode($phpmailer->Body, ENT_QUOTES);
|
65 |
-
// Clean < and > around text links in WP 3.1
|
66 |
-
$phpmailer->Body = preg_replace('#<(http://[^*]+)>#', '$1', $phpmailer->Body);
|
67 |
-
// Convert line breaks & make links clickable
|
68 |
-
$phpmailer->Body = make_clickable ($phpmailer->Body);
|
69 |
-
|
70 |
-
// Add header to message if found
|
71 |
-
if(file_exists(get_stylesheet_directory() . "/email_header.html"))
|
72 |
-
$phpmailer->Body = file_get_contents(get_stylesheet_directory() . "/email_header.html") . "\n" . $phpmailer->Body;
|
73 |
-
elseif(file_exists(get_template_directory() . "/email_header.html"))
|
74 |
-
$phpmailer->Body = file_get_contents(get_template_directory() . "/email_header.html") . "\n" . $phpmailer->Body;
|
75 |
-
|
76 |
-
// Add footer to message if found
|
77 |
-
if(file_exists(get_stylesheet_directory() . "/email_footer.html"))
|
78 |
-
$phpmailer->Body = $phpmailer->Body . "\n" . file_get_contents(get_stylesheet_directory() . "/email_footer.html");
|
79 |
-
elseif(file_exists(get_template_directory() . "/email_footer.html"))
|
80 |
-
$phpmailer->Body = $phpmailer->Body . "\n" . file_get_contents(get_template_directory() . "/email_footer.html");
|
81 |
-
|
82 |
-
// Replace variables in email
|
83 |
-
global $current_user;
|
84 |
-
$data = array(
|
85 |
-
"name" => $current_user->display_name,
|
86 |
-
"sitename" => get_option("blogname"),
|
87 |
-
"login_link" => pmpro_url("account"),
|
88 |
-
"display_name" => $current_user->display_name,
|
89 |
-
"user_email" => $current_user->user_email,
|
90 |
-
"subject" => $phpmailer->Subject
|
91 |
-
);
|
92 |
-
foreach($data as $key => $value)
|
93 |
-
{
|
94 |
-
$phpmailer->Body = str_replace("!!" . $key . "!!", $value, $phpmailer->Body);
|
95 |
-
}
|
96 |
-
|
97 |
-
do_action("pmpro_after_phpmailer_init", $phpmailer);
|
98 |
-
do_action("pmpro_after_pmpmailer_init", $phpmailer); //typo left in for backwards compatibility
|
99 |
-
}
|
100 |
-
|
101 |
-
function pmpro_wp_mail_content_type( $content_type ) {
|
102 |
-
add_action('phpmailer_init', 'pmpro_send_html');
|
103 |
-
|
104 |
-
//change to html if not already
|
105 |
-
if( $content_type == 'text/plain')
|
106 |
-
{
|
107 |
-
$content_type = 'text/html';
|
108 |
-
}
|
109 |
-
return $content_type;
|
110 |
-
}
|
111 |
-
add_filter('wp_mail_content_type', 'pmpro_wp_mail_content_type');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/filters.php
DELETED
@@ -1,150 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
This file was added in version 1.5.5 of the plugin. This file is meant to store various hacks, filters, and actions that were originally developed outside of the PMPro core and brought in later... or just things that are cleaner/easier to impement via hooks and filters.
|
4 |
-
*/
|
5 |
-
|
6 |
-
/*
|
7 |
-
If checking out for the same level, add remaining days to the enddate.
|
8 |
-
Pulled in from: https://gist.github.com/3678054
|
9 |
-
*/
|
10 |
-
function pmpro_checkout_level_extend_memberships($level)
|
11 |
-
{
|
12 |
-
global $pmpro_msg, $pmpro_msgt;
|
13 |
-
|
14 |
-
//does this level expire? are they an existing user of this level?
|
15 |
-
if(!empty($level) && !empty($level->expiration_number) && pmpro_hasMembershipLevel($level->id))
|
16 |
-
{
|
17 |
-
//get the current enddate of their membership
|
18 |
-
global $current_user;
|
19 |
-
$expiration_date = $current_user->membership_level->enddate;
|
20 |
-
|
21 |
-
//calculate days left
|
22 |
-
$todays_date = current_time('timestamp');
|
23 |
-
$time_left = $expiration_date - $todays_date;
|
24 |
-
|
25 |
-
//time left?
|
26 |
-
if($time_left > 0)
|
27 |
-
{
|
28 |
-
//convert to days and add to the expiration date (assumes expiration was 1 year)
|
29 |
-
$days_left = floor($time_left/(60*60*24));
|
30 |
-
|
31 |
-
//figure out days based on period
|
32 |
-
if($level->expiration_period == "Day")
|
33 |
-
$total_days = $days_left + $level->expiration_number;
|
34 |
-
elseif($level->expiration_period == "Week")
|
35 |
-
$total_days = $days_left + $level->expiration_number * 7;
|
36 |
-
elseif($level->expiration_period == "Month")
|
37 |
-
$total_days = $days_left + $level->expiration_number * 30;
|
38 |
-
elseif($level->expiration_period == "Year")
|
39 |
-
$total_days = $days_left + $level->expiration_number * 365;
|
40 |
-
|
41 |
-
//update number and period
|
42 |
-
$level->expiration_number = $total_days;
|
43 |
-
$level->expiration_period = "Day";
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
return $level;
|
48 |
-
}
|
49 |
-
add_filter("pmpro_checkout_level", "pmpro_checkout_level_extend_memberships");
|
50 |
-
/*
|
51 |
-
Same thing as above but when processed by the ipnhandler for PayPal standard.
|
52 |
-
*/
|
53 |
-
function pmpro_ipnhandler_level_extend_memberships($level, $user_id)
|
54 |
-
{
|
55 |
-
global $pmpro_msg, $pmpro_msgt;
|
56 |
-
|
57 |
-
//does this level expire? are they an existing user of this level?
|
58 |
-
if(!empty($level) && !empty($level->expiration_number) && pmpro_hasMembershipLevel($level->id, $user_id))
|
59 |
-
{
|
60 |
-
//get the current enddate of their membership
|
61 |
-
$user_level = pmpro_getMembershipLevelForUser($user_id);
|
62 |
-
$expiration_date = $user_level->enddate;
|
63 |
-
|
64 |
-
//calculate days left
|
65 |
-
$todays_date = current_time('timestamp');
|
66 |
-
$time_left = $expiration_date - $todays_date;
|
67 |
-
|
68 |
-
//time left?
|
69 |
-
if($time_left > 0)
|
70 |
-
{
|
71 |
-
//convert to days and add to the expiration date (assumes expiration was 1 year)
|
72 |
-
$days_left = floor($time_left/(60*60*24));
|
73 |
-
|
74 |
-
//figure out days based on period
|
75 |
-
if($level->expiration_period == "Day")
|
76 |
-
$total_days = $days_left + $level->expiration_number;
|
77 |
-
elseif($level->expiration_period == "Week")
|
78 |
-
$total_days = $days_left + $level->expiration_number * 7;
|
79 |
-
elseif($level->expiration_period == "Month")
|
80 |
-
$total_days = $days_left + $level->expiration_number * 30;
|
81 |
-
elseif($level->expiration_period == "Year")
|
82 |
-
$total_days = $days_left + $level->expiration_number * 365;
|
83 |
-
|
84 |
-
//update number and period
|
85 |
-
$level->expiration_number = $total_days;
|
86 |
-
$level->expiration_period = "Day";
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
return $level;
|
91 |
-
}
|
92 |
-
add_filter("pmpro_ipnhandler_level", "pmpro_ipnhandler_level_extend_memberships", 10, 2);
|
93 |
-
|
94 |
-
/*
|
95 |
-
If checking out for the same level, keep your old startdate.
|
96 |
-
Added with 1.5.5
|
97 |
-
*/
|
98 |
-
function pmpro_checkout_start_date_keep_startdate($startdate, $user_id, $level)
|
99 |
-
{
|
100 |
-
if(pmpro_hasMembershipLevel($level->id, $user_id))
|
101 |
-
{
|
102 |
-
global $wpdb;
|
103 |
-
$sqlQuery = "SELECT startdate FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . esc_sql($user_id) . "' AND membership_id = '" . esc_sql($level->id) . "' AND status = 'active' ORDER BY id DESC LIMIT 1";
|
104 |
-
$old_startdate = $wpdb->get_var($sqlQuery);
|
105 |
-
|
106 |
-
if(!empty($old_startdate))
|
107 |
-
$startdate = "'" . $old_startdate . "'";
|
108 |
-
}
|
109 |
-
|
110 |
-
return $startdate;
|
111 |
-
}
|
112 |
-
add_filter("pmpro_checkout_start_date", "pmpro_checkout_start_date_keep_startdate", 10, 3);
|
113 |
-
|
114 |
-
/*
|
115 |
-
Stripe Lite Pulled into Core Plugin
|
116 |
-
*/
|
117 |
-
//Stripe Lite, Set the Globals/etc
|
118 |
-
$stripe_billingaddress = pmpro_getOption("stripe_billingaddress");
|
119 |
-
if(empty($stripe_billingaddress))
|
120 |
-
{
|
121 |
-
global $pmpro_stripe_lite;
|
122 |
-
$pmpro_stripe_lite = true;
|
123 |
-
add_filter("pmpro_stripe_lite", "__return_true");
|
124 |
-
add_filter("pmpro_required_billing_fields", "pmpro_required_billing_fields_stripe_lite");
|
125 |
-
}
|
126 |
-
|
127 |
-
//Stripe Lite, Don't Require Billing Fields
|
128 |
-
function pmpro_required_billing_fields_stripe_lite($fields)
|
129 |
-
{
|
130 |
-
global $gateway;
|
131 |
-
|
132 |
-
//ignore if not using stripe
|
133 |
-
if($gateway != "stripe")
|
134 |
-
return $fields;
|
135 |
-
|
136 |
-
//some fields to remove
|
137 |
-
$remove = array('bfirstname', 'blastname', 'baddress1', 'bcity', 'bstate', 'bzipcode', 'bphone', 'bcountry', 'CardType');
|
138 |
-
|
139 |
-
//if a user is logged in, don't require bemail either
|
140 |
-
global $current_user;
|
141 |
-
if(!empty($current_user->user_email))
|
142 |
-
$remove[] = 'bemail';
|
143 |
-
|
144 |
-
//remove the fields
|
145 |
-
foreach($remove as $field)
|
146 |
-
unset($fields[$field]);
|
147 |
-
|
148 |
-
//ship it!
|
149 |
-
return $fields;
|
150 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions.php
CHANGED
@@ -1,1742 +1,1045 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
$
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
function
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
if($
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
}
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
{
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
$r =
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
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 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
}
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
}
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
}
|
400 |
-
|
401 |
-
if
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
$
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
{
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
$
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
$
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
$
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
$
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
$
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
}
|
941 |
-
|
942 |
-
//
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
$
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
if($
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
$
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
$
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
$
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
$email = preg_replace("/[^A-Za-z]/", "", $emailparts[0]);
|
1047 |
-
|
1048 |
-
if($email)
|
1049 |
-
{
|
1050 |
-
$username = $email;
|
1051 |
-
}
|
1052 |
-
|
1053 |
-
//is this taken? if not, add numbers until it works
|
1054 |
-
$taken = true;
|
1055 |
-
$count = 0;
|
1056 |
-
while($taken)
|
1057 |
-
{
|
1058 |
-
//add a # to the end
|
1059 |
-
if($count)
|
1060 |
-
{
|
1061 |
-
$username = preg_replace("/[0-9]/", "", $username) . $count;
|
1062 |
-
}
|
1063 |
-
|
1064 |
-
//taken?
|
1065 |
-
$taken = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '" . $username . "' LIMIT 1");
|
1066 |
-
|
1067 |
-
//increment the number
|
1068 |
-
$count++;
|
1069 |
-
}
|
1070 |
-
|
1071 |
-
//must have a good username now
|
1072 |
-
return $username;
|
1073 |
-
}
|
1074 |
-
|
1075 |
-
//get a new random code for discount codes
|
1076 |
-
function pmpro_getDiscountCode($seed = NULL)
|
1077 |
-
{
|
1078 |
-
global $wpdb;
|
1079 |
-
|
1080 |
-
while(empty($code))
|
1081 |
-
{
|
1082 |
-
$scramble = md5(AUTH_KEY . current_time('timestamp') . $seed . SECURE_AUTH_KEY);
|
1083 |
-
$code = substr($scramble, 0, 10);
|
1084 |
-
$check = $wpdb->get_var("SELECT code FROM $wpdb->pmpro_discount_codes WHERE code = '$code' LIMIT 1");
|
1085 |
-
if($check || is_numeric($code))
|
1086 |
-
$code = NULL;
|
1087 |
-
}
|
1088 |
-
|
1089 |
-
return strtoupper($code);
|
1090 |
-
}
|
1091 |
-
|
1092 |
-
//is a discount code valid
|
1093 |
-
function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false)
|
1094 |
-
{
|
1095 |
-
global $wpdb;
|
1096 |
-
|
1097 |
-
$error = false;
|
1098 |
-
|
1099 |
-
//no code, no code
|
1100 |
-
if(empty($code))
|
1101 |
-
$error = __("No code was given to check.", "pmpro");
|
1102 |
-
|
1103 |
-
//get code from db
|
1104 |
-
if(!$error)
|
1105 |
-
{
|
1106 |
-
$dbcode = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes WHERE code ='" . $code . "' LIMIT 1");
|
1107 |
-
|
1108 |
-
//did we find it?
|
1109 |
-
if(empty($dbcode->id))
|
1110 |
-
$error = __("The discount code could not be found.", "pmpro");
|
1111 |
-
}
|
1112 |
-
|
1113 |
-
//check if the code has started
|
1114 |
-
if(!$error)
|
1115 |
-
{
|
1116 |
-
//fix the date timestamps
|
1117 |
-
$dbcode->starts = strtotime(date("m/d/Y", $dbcode->starts));
|
1118 |
-
$dbcode->expires = strtotime(date("m/d/Y", $dbcode->expires));
|
1119 |
-
|
1120 |
-
//today
|
1121 |
-
$today = strtotime(date("m/d/Y 00:00:00", current_time("timestamp")));
|
1122 |
-
|
1123 |
-
//has this code started yet?
|
1124 |
-
if(!empty($dbcode->starts) && $dbcode->starts > $today)
|
1125 |
-
$error = sprintf(__("This discount code goes into effect on %s.", "pmpro"), date(get_option('date_format'), $dbcode->starts));
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
//check if the code is expired
|
1129 |
-
if(!$error)
|
1130 |
-
{
|
1131 |
-
if(!empty($dbcode->expires) && $dbcode->expires < $today)
|
1132 |
-
$error = sprintf(__("This discount code expired on %s.", "pmpro"), date(get_option('date_format'), $dbcode->expires));
|
1133 |
-
}
|
1134 |
-
|
1135 |
-
//have we run out of uses?
|
1136 |
-
if(!$error)
|
1137 |
-
{
|
1138 |
-
if($dbcode->uses > 0)
|
1139 |
-
{
|
1140 |
-
$used = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $dbcode->id . "'");
|
1141 |
-
if($used >= $dbcode->uses)
|
1142 |
-
$error = __("This discount code is no longer valid.", "pmpro");
|
1143 |
-
}
|
1144 |
-
}
|
1145 |
-
|
1146 |
-
//if a level was passed check if this code applies
|
1147 |
-
if(!$error)
|
1148 |
-
{
|
1149 |
-
$pmpro_check_discount_code_levels = apply_filters("pmpro_check_discount_code_levels", true, $dbcode->id);
|
1150 |
-
if(!empty($level_id) && $pmpro_check_discount_code_levels)
|
1151 |
-
{
|
1152 |
-
$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 = '" . $level_id . "' LIMIT 1");
|
1153 |
-
|
1154 |
-
if(empty($code_level))
|
1155 |
-
$error = __("This discount code does not apply to this membership level.", "pmpro");
|
1156 |
-
}
|
1157 |
-
}
|
1158 |
-
|
1159 |
-
//allow filter
|
1160 |
-
$pmpro_check_discount_code = apply_filters("pmpro_check_discount_code", !$error, $dbcode, $level_id, $code);
|
1161 |
-
if(is_string($pmpro_check_discount_code))
|
1162 |
-
$error = $pmpro_check_discount_code; //string returned, this is an error
|
1163 |
-
elseif(!$pmpro_check_discount_code && !$error)
|
1164 |
-
$error = true; //no error before, but filter returned error
|
1165 |
-
elseif($pmpro_check_discount_code)
|
1166 |
-
$error = false; //filter is true, so error false
|
1167 |
-
|
1168 |
-
//return
|
1169 |
-
if($error)
|
1170 |
-
{
|
1171 |
-
//there was an error
|
1172 |
-
if(!empty($return_errors))
|
1173 |
-
return array(false, $error);
|
1174 |
-
else
|
1175 |
-
return false;
|
1176 |
-
}
|
1177 |
-
else
|
1178 |
-
{
|
1179 |
-
//guess we're all good
|
1180 |
-
if(!empty($return_errors))
|
1181 |
-
return array(true, __("This discount code is okay.", "pmpro"));
|
1182 |
-
else
|
1183 |
-
return true;
|
1184 |
-
}
|
1185 |
-
}
|
1186 |
-
|
1187 |
-
function pmpro_no_quotes($s, $quotes = array("'", '"'))
|
1188 |
-
{
|
1189 |
-
return str_replace($quotes, "", $s);
|
1190 |
-
}
|
1191 |
-
|
1192 |
-
//from: http://www.php.net/manual/en/function.implode.php#86845
|
1193 |
-
function pmpro_implodeToEnglish($array)
|
1194 |
-
{
|
1195 |
-
// sanity check
|
1196 |
-
if (!$array || !count ($array))
|
1197 |
-
return '';
|
1198 |
-
|
1199 |
-
// get last element
|
1200 |
-
$last = array_pop ($array);
|
1201 |
-
|
1202 |
-
// if it was the only element - return it
|
1203 |
-
if (!count ($array))
|
1204 |
-
return $last;
|
1205 |
-
|
1206 |
-
return implode (', ', $array).' ' . __('and', 'pmpro') . ' '.$last;
|
1207 |
-
}
|
1208 |
-
|
1209 |
-
//from yoast wordpress seo
|
1210 |
-
function pmpro_text_limit( $text, $limit, $finish = '…')
|
1211 |
-
{
|
1212 |
-
if( strlen( $text ) > $limit ) {
|
1213 |
-
$text = substr( $text, 0, $limit );
|
1214 |
-
$text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
|
1215 |
-
$text .= $finish;
|
1216 |
-
}
|
1217 |
-
return $text;
|
1218 |
-
}
|
1219 |
-
|
1220 |
-
/* pmpro_getMembershipLevelForUser() returns the first active membership level for a user
|
1221 |
-
*
|
1222 |
-
* If $user_id is omitted, the value will be retrieved from $current_user.
|
1223 |
-
*
|
1224 |
-
* Return values:
|
1225 |
-
* Success returns the level object.
|
1226 |
-
* Failure returns false.
|
1227 |
-
*/
|
1228 |
-
function pmpro_getMembershipLevelForUser($user_id = NULL, $force = false)
|
1229 |
-
{
|
1230 |
-
if(empty($user_id))
|
1231 |
-
{
|
1232 |
-
global $current_user;
|
1233 |
-
$user_id = $current_user->ID;
|
1234 |
-
}
|
1235 |
-
|
1236 |
-
if(empty($user_id))
|
1237 |
-
{
|
1238 |
-
return false;
|
1239 |
-
}
|
1240 |
-
|
1241 |
-
global $all_membership_levels;
|
1242 |
-
|
1243 |
-
if(isset($all_membership_levels[$user_id]) && !$force)
|
1244 |
-
{
|
1245 |
-
return $all_membership_levels[$user_id];
|
1246 |
-
}
|
1247 |
-
else
|
1248 |
-
{
|
1249 |
-
global $wpdb;
|
1250 |
-
$all_membership_levels[$user_id] = $wpdb->get_row("SELECT
|
1251 |
-
l.id AS ID,
|
1252 |
-
l.id as id,
|
1253 |
-
mu.id as subscription_id,
|
1254 |
-
l.name AS name,
|
1255 |
-
l.description,
|
1256 |
-
l.expiration_number,
|
1257 |
-
l.expiration_period,
|
1258 |
-
mu.initial_payment,
|
1259 |
-
mu.billing_amount,
|
1260 |
-
mu.cycle_number,
|
1261 |
-
mu.cycle_period,
|
1262 |
-
mu.billing_limit,
|
1263 |
-
mu.trial_amount,
|
1264 |
-
mu.trial_limit,
|
1265 |
-
mu.code_id as code_id,
|
1266 |
-
UNIX_TIMESTAMP(startdate) as startdate,
|
1267 |
-
UNIX_TIMESTAMP(enddate) as enddate
|
1268 |
-
FROM {$wpdb->pmpro_membership_levels} AS l
|
1269 |
-
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
1270 |
-
WHERE mu.user_id = $user_id AND mu.status = 'active'
|
1271 |
-
LIMIT 1");
|
1272 |
-
return $all_membership_levels[$user_id];
|
1273 |
-
}
|
1274 |
-
}
|
1275 |
-
|
1276 |
-
/* pmpro_getMembershipLevelsForUser() returns the membership levels for a user
|
1277 |
-
*
|
1278 |
-
* If $user_id is omitted, the value will be retrieved from $current_user.
|
1279 |
-
* By default it only includes actvie memberships.
|
1280 |
-
*
|
1281 |
-
* Return values:
|
1282 |
-
* Success returns an array of level objects.
|
1283 |
-
* Failure returns false.
|
1284 |
-
*/
|
1285 |
-
function pmpro_getMembershipLevelsForUser($user_id = NULL, $include_inactive = false)
|
1286 |
-
{
|
1287 |
-
if(empty($user_id))
|
1288 |
-
{
|
1289 |
-
global $current_user;
|
1290 |
-
$user_id = $current_user->ID;
|
1291 |
-
}
|
1292 |
-
|
1293 |
-
if(empty($user_id))
|
1294 |
-
{
|
1295 |
-
return false;
|
1296 |
-
}
|
1297 |
-
|
1298 |
-
global $wpdb;
|
1299 |
-
return $wpdb->get_results("SELECT
|
1300 |
-
l.id AS ID,
|
1301 |
-
l.id as id,
|
1302 |
-
mu.id as subscription_id,
|
1303 |
-
l.name,
|
1304 |
-
l.description,
|
1305 |
-
l.expiration_number,
|
1306 |
-
l.expiration_period,
|
1307 |
-
mu.initial_payment,
|
1308 |
-
mu.billing_amount,
|
1309 |
-
mu.cycle_number,
|
1310 |
-
mu.cycle_period,
|
1311 |
-
mu.billing_limit,
|
1312 |
-
mu.trial_amount,
|
1313 |
-
mu.trial_limit,
|
1314 |
-
mu.code_id as code_id,
|
1315 |
-
UNIX_TIMESTAMP(startdate) as startdate,
|
1316 |
-
UNIX_TIMESTAMP(enddate) as enddate
|
1317 |
-
FROM {$wpdb->pmpro_membership_levels} AS l
|
1318 |
-
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
1319 |
-
WHERE mu.user_id = $user_id".($include_inactive?"":" AND mu.status = 'active'"));
|
1320 |
-
}
|
1321 |
-
|
1322 |
-
/* pmpro_getLevel() returns the level object for a level
|
1323 |
-
*
|
1324 |
-
* $level may be the level id or name
|
1325 |
-
*
|
1326 |
-
* Return values:
|
1327 |
-
* Success returns the level object.
|
1328 |
-
* Failure returns false.
|
1329 |
-
*/
|
1330 |
-
function pmpro_getLevel($level)
|
1331 |
-
{
|
1332 |
-
global $pmpro_levels;
|
1333 |
-
|
1334 |
-
if(is_object($level) && !empty($level->id))
|
1335 |
-
$level = $level->id;
|
1336 |
-
|
1337 |
-
//was a name passed? (Todo: make sure level names have at least one non-numeric character.
|
1338 |
-
if(is_numeric($level))
|
1339 |
-
{
|
1340 |
-
$level_id = intval($level);
|
1341 |
-
if(isset($pmpro_levels[$level_id]))
|
1342 |
-
{
|
1343 |
-
return $pmpro_levels[$level_id];
|
1344 |
-
}
|
1345 |
-
else
|
1346 |
-
{
|
1347 |
-
global $wpdb;
|
1348 |
-
$pmpro_levels[$level_id] = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = '" . $level_id . "' LIMIT 1");
|
1349 |
-
return $pmpro_levels[$level_id];
|
1350 |
-
}
|
1351 |
-
}
|
1352 |
-
else
|
1353 |
-
{
|
1354 |
-
global $wpdb;
|
1355 |
-
$level_obj = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_membership_levels WHERE name = '" . $level . "' LIMIT 1");
|
1356 |
-
$level_id = $level_obj->id;
|
1357 |
-
$pmpro_levels[$level_id] = $level_obj;
|
1358 |
-
return $pmpro_levels[$level_id];
|
1359 |
-
}
|
1360 |
-
}
|
1361 |
-
|
1362 |
-
/*
|
1363 |
-
Function to populate pmpro_levels with all levels. We query the DB every time just to be sure we have the latest.
|
1364 |
-
This should be called if you want to be sure you get all levels as $pmpro_levels may only have a subset of levels.
|
1365 |
-
*/
|
1366 |
-
function pmpro_getAllLevels($include_hidden = false, $force = false)
|
1367 |
-
{
|
1368 |
-
global $pmpro_levels, $wpdb;
|
1369 |
-
|
1370 |
-
//just use what's cached (doesn't take into account include_hidden setting)
|
1371 |
-
if(!empty($pmpro_levels) && !$force)
|
1372 |
-
return $pmpro_levels;
|
1373 |
-
|
1374 |
-
//build query
|
1375 |
-
$sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levels ";
|
1376 |
-
if(!$include_hidden)
|
1377 |
-
$sqlQuery .= " WHERE allow_signups = 1 ORDER BY id";
|
1378 |
-
|
1379 |
-
//get levels from the DB
|
1380 |
-
$raw_levels = $wpdb->get_results($sqlQuery);
|
1381 |
-
|
1382 |
-
//lets put them into an array where the key is the id of the level
|
1383 |
-
$pmpro_levels = array();
|
1384 |
-
foreach($raw_levels as $raw_level)
|
1385 |
-
{
|
1386 |
-
$pmpro_levels[$raw_level->id] = $raw_level;
|
1387 |
-
}
|
1388 |
-
|
1389 |
-
return $pmpro_levels;
|
1390 |
-
}
|
1391 |
-
|
1392 |
-
function pmpro_getCheckoutButton($level_id, $button_text = NULL, $classes = NULL)
|
1393 |
-
{
|
1394 |
-
if(empty($button_text))
|
1395 |
-
$button_text = __("Sign Up for !!name!! Now", "pmpro");
|
1396 |
-
|
1397 |
-
if(empty($classes))
|
1398 |
-
$classes = "btn btn-primary";
|
1399 |
-
|
1400 |
-
if(empty($level_id))
|
1401 |
-
$r = __("Please specify a level id.", "pmpro");
|
1402 |
-
else
|
1403 |
-
{
|
1404 |
-
//get level
|
1405 |
-
$level = pmpro_getLevel($level_id);
|
1406 |
-
|
1407 |
-
//replace vars
|
1408 |
-
$replacements = array(
|
1409 |
-
"!!id!!" => $level->id,
|
1410 |
-
"!!name!!" => $level->name,
|
1411 |
-
"!!description!!" => $level->description,
|
1412 |
-
"!!confirmation!!" => $level->confirmation,
|
1413 |
-
"!!initial_payment!!" => $level->initial_payment,
|
1414 |
-
"!!billing_amount!!" => $level->billing_amount,
|
1415 |
-
"!!cycle_number!!" => $level->cycle_number,
|
1416 |
-
"!!cycle_period!!" => $level->cycle_period,
|
1417 |
-
"!!billing_limit!!" => $level->billing_limit,
|
1418 |
-
"!!trial_amount!!" => $level->trial_amount,
|
1419 |
-
"!!trial_limit!!" => $level->trial_limit,
|
1420 |
-
"!!expiration_number!!" => $level->expiration_number,
|
1421 |
-
"!!expiration_period!!" => $level->expiration_period
|
1422 |
-
);
|
1423 |
-
$button_text = str_replace(array_keys($replacements), $replacements, $button_text);
|
1424 |
-
|
1425 |
-
//button text
|
1426 |
-
$r = "<a href=\"" . pmpro_url("checkout", "?level=" . $level_id) . "\" class=\"" . $classes . "\">" . $button_text . "</a>";
|
1427 |
-
}
|
1428 |
-
return $r;
|
1429 |
-
}
|
1430 |
-
|
1431 |
-
/**
|
1432 |
-
* Get the "domain" from a URL. By domain, we mean the host name, minus any subdomains. So just the domain and TLD.
|
1433 |
-
*
|
1434 |
-
* @param string $url The URL to parse. (generally pass site_url() in WP)
|
1435 |
-
* @return string The domain.
|
1436 |
-
*/
|
1437 |
-
function pmpro_getDomainFromURL($url = NULL)
|
1438 |
-
{
|
1439 |
-
$domainparts = parse_url($url);
|
1440 |
-
$domainparts = explode(".", $domainparts['host']);
|
1441 |
-
if(count($domainparts) > 1)
|
1442 |
-
{
|
1443 |
-
//check for ips
|
1444 |
-
$isip = true;
|
1445 |
-
foreach($domainparts as $part)
|
1446 |
-
{
|
1447 |
-
if(!is_numeric($part))
|
1448 |
-
{
|
1449 |
-
$isip = false;
|
1450 |
-
break;
|
1451 |
-
}
|
1452 |
-
}
|
1453 |
-
|
1454 |
-
if($isip)
|
1455 |
-
{
|
1456 |
-
//ip, e.g. 127.1.1.1
|
1457 |
-
$domain = implode(".", $domainparts);
|
1458 |
-
}
|
1459 |
-
else
|
1460 |
-
{
|
1461 |
-
//www.something.com, etc.
|
1462 |
-
$domain = $domainparts[count($domainparts)-2] . "." . $domainparts[count($domainparts)-1];
|
1463 |
-
}
|
1464 |
-
}
|
1465 |
-
else
|
1466 |
-
{
|
1467 |
-
//localhost or another single word domain
|
1468 |
-
$domain = $domainparts[0];
|
1469 |
-
}
|
1470 |
-
|
1471 |
-
return $domain;
|
1472 |
-
}
|
1473 |
-
|
1474 |
-
/*
|
1475 |
-
Get a member's start date... either in general or for a specific level_id.
|
1476 |
-
*/
|
1477 |
-
if(!function_exists("pmpro_getMemberStartdate"))
|
1478 |
-
{
|
1479 |
-
function pmpro_getMemberStartdate($user_id = NULL, $level_id = 0)
|
1480 |
-
{
|
1481 |
-
if(empty($user_id))
|
1482 |
-
{
|
1483 |
-
global $current_user;
|
1484 |
-
$user_id = $current_user->ID;
|
1485 |
-
}
|
1486 |
-
|
1487 |
-
global $pmpro_startdates; //for cache
|
1488 |
-
if(empty($pmpro_startdates[$user_id][$level_id]))
|
1489 |
-
{
|
1490 |
-
global $wpdb;
|
1491 |
-
|
1492 |
-
if(!empty($level_id))
|
1493 |
-
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND membership_id IN(" . esc_sql($level_id) . ") AND user_id = '" . $user_id . "' ORDER BY id LIMIT 1";
|
1494 |
-
else
|
1495 |
-
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND user_id = '" . $user_id . "' ORDER BY id LIMIT 1";
|
1496 |
-
|
1497 |
-
$startdate = apply_filters("pmpro_member_startdate", $wpdb->get_var($sqlQuery), $user_id, $level_id);
|
1498 |
-
|
1499 |
-
$pmpro_startdates[$user_id][$level_id] = $startdate;
|
1500 |
-
}
|
1501 |
-
|
1502 |
-
return $pmpro_startdates[$user_id][$level_id];
|
1503 |
-
}
|
1504 |
-
}
|
1505 |
-
|
1506 |
-
/*
|
1507 |
-
How long has this member been a member
|
1508 |
-
*/
|
1509 |
-
if(!function_exists("pmpro_getMemberDays"))
|
1510 |
-
{
|
1511 |
-
function pmpro_getMemberDays($user_id = NULL, $level_id = 0)
|
1512 |
-
{
|
1513 |
-
if(empty($user_id))
|
1514 |
-
{
|
1515 |
-
global $current_user;
|
1516 |
-
$user_id = $current_user->ID;
|
1517 |
-
}
|
1518 |
-
|
1519 |
-
global $pmpro_member_days;
|
1520 |
-
if(empty($pmpro_member_days[$user_id][$level_id]))
|
1521 |
-
{
|
1522 |
-
$startdate = pmpro_getMemberStartdate($user_id, $level_id);
|
1523 |
-
|
1524 |
-
//check that there was a startdate at all
|
1525 |
-
if(empty($startdate))
|
1526 |
-
$pmpro_member_days[$user_id][$level_id] = 0;
|
1527 |
-
else
|
1528 |
-
{
|
1529 |
-
$now = current_time('timestamp');
|
1530 |
-
$days = ($now - $startdate)/3600/24;
|
1531 |
-
|
1532 |
-
$pmpro_member_days[$user_id][$level_id] = $days;
|
1533 |
-
}
|
1534 |
-
}
|
1535 |
-
|
1536 |
-
return $pmpro_member_days[$user_id][$level_id];
|
1537 |
-
}
|
1538 |
-
}
|
1539 |
-
|
1540 |
-
//the start of a message handling script
|
1541 |
-
function pmpro_setMessage($message, $type, $force = false)
|
1542 |
-
{
|
1543 |
-
global $pmpro_msg, $pmpro_msgt;
|
1544 |
-
|
1545 |
-
//for now, we only show the first message generated
|
1546 |
-
if($force || empty($pmpro_msg))
|
1547 |
-
{
|
1548 |
-
$pmpro_msg = $message;
|
1549 |
-
$pmpro_msgt = $type;
|
1550 |
-
}
|
1551 |
-
}
|
1552 |
-
|
1553 |
-
//used in class definitions for input fields to see if there was an error
|
1554 |
-
function pmpro_getClassForField($field)
|
1555 |
-
{
|
1556 |
-
global $pmpro_error_fields, $pmpro_required_billing_fields, $pmpro_required_user_fields;
|
1557 |
-
$classes = array();
|
1558 |
-
|
1559 |
-
//error on this field?
|
1560 |
-
if(in_array($field, $pmpro_error_fields))
|
1561 |
-
{
|
1562 |
-
$classes[] = "pmpro_error";
|
1563 |
-
}
|
1564 |
-
|
1565 |
-
$required_fields = array_merge(array_keys($pmpro_required_billing_fields), array_keys($pmpro_required_user_fields));
|
1566 |
-
|
1567 |
-
//required?
|
1568 |
-
if(in_array($field, $required_fields))
|
1569 |
-
{
|
1570 |
-
$classes[] = "pmpro_required";
|
1571 |
-
}
|
1572 |
-
|
1573 |
-
$classes = apply_filters("pmpro_field_classes", $classes, $field);
|
1574 |
-
|
1575 |
-
if(!empty($classes))
|
1576 |
-
return implode(" ", $classes);
|
1577 |
-
else
|
1578 |
-
return "";
|
1579 |
-
}
|
1580 |
-
|
1581 |
-
//get a var from $_GET or $_POST
|
1582 |
-
function pmpro_getParam($index, $method = "REQUEST", $default = "")
|
1583 |
-
{
|
1584 |
-
if($method == "REQUEST")
|
1585 |
-
{
|
1586 |
-
if(!empty($_REQUEST[$index]))
|
1587 |
-
return $_REQUEST[$index];
|
1588 |
-
}
|
1589 |
-
elseif($method == "POST")
|
1590 |
-
{
|
1591 |
-
if(!empty($_POST[$index]))
|
1592 |
-
return $_POST[$index];
|
1593 |
-
}
|
1594 |
-
elseif($method == "GET")
|
1595 |
-
{
|
1596 |
-
if(!empty($_GET[$index]))
|
1597 |
-
return $_GET[$index];
|
1598 |
-
}
|
1599 |
-
|
1600 |
-
return $default;
|
1601 |
-
}
|
1602 |
-
|
1603 |
-
/*
|
1604 |
-
Format an address from address, city, state, zip, country, and phone
|
1605 |
-
*/
|
1606 |
-
function pmpro_formatAddress($name, $address1, $address2, $city, $state, $zip, $country, $phone, $nl2br = true)
|
1607 |
-
{
|
1608 |
-
$address = "";
|
1609 |
-
|
1610 |
-
if(!empty($name))
|
1611 |
-
$address .= $name . "\n";
|
1612 |
-
|
1613 |
-
if(!empty($address1))
|
1614 |
-
$address .= $address1 . "\n";
|
1615 |
-
|
1616 |
-
if(!empty($address2))
|
1617 |
-
$address .= $address2 . "\n";
|
1618 |
-
|
1619 |
-
if(!empty($city) && !empty($state))
|
1620 |
-
{
|
1621 |
-
$address .= $city . ", " . $state;
|
1622 |
-
|
1623 |
-
if(!empty($zip))
|
1624 |
-
$address .= " " . $zip;
|
1625 |
-
|
1626 |
-
$address .= "\n";
|
1627 |
-
}
|
1628 |
-
|
1629 |
-
if(!empty($country))
|
1630 |
-
$address .= $country . "\n";
|
1631 |
-
|
1632 |
-
if(!empty($phone))
|
1633 |
-
$address .= formatPhone($phone);
|
1634 |
-
|
1635 |
-
if($nl2br)
|
1636 |
-
$address = nl2br($address);
|
1637 |
-
|
1638 |
-
return $address;
|
1639 |
-
}
|
1640 |
-
|
1641 |
-
/*
|
1642 |
-
Checks if all required settings are set.
|
1643 |
-
*/
|
1644 |
-
function pmpro_is_ready()
|
1645 |
-
{
|
1646 |
-
global $wpdb, $pmpro_pages, $pmpro_level_ready, $pmpro_gateway_ready, $pmpro_pages_ready;
|
1647 |
-
|
1648 |
-
//check if there is at least one level
|
1649 |
-
$pmpro_level_ready = (bool)$wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels LIMIT 1");
|
1650 |
-
|
1651 |
-
//check if the gateway settings are good. first check if it's needed (is there paid membership level)
|
1652 |
-
$paid_membership_level = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels WHERE allow_signups = 1 AND (initial_payment > 0 OR billing_amount > 0 OR trial_amount > 0) LIMIT 1");
|
1653 |
-
$paid_user_subscription = $wpdb->get_var("SELECT user_id FROM $wpdb->pmpro_memberships_users WHERE initial_payment > 0 OR billing_amount > 0 OR trial_amount > 0 LIMIT 1");
|
1654 |
-
|
1655 |
-
if(empty($paid_membership_level) && empty($paid_user_subscription))
|
1656 |
-
{
|
1657 |
-
//no paid membership level now or attached to a user. we don't need the gateway setup
|
1658 |
-
$pmpro_gateway_ready = true;
|
1659 |
-
}
|
1660 |
-
else
|
1661 |
-
{
|
1662 |
-
$gateway = pmpro_getOption("gateway");
|
1663 |
-
if($gateway == "authorizenet")
|
1664 |
-
{
|
1665 |
-
if(pmpro_getOption("gateway_environment") && pmpro_getOption("loginname") && pmpro_getOption("transactionkey"))
|
1666 |
-
$pmpro_gateway_ready = true;
|
1667 |
-
else
|
1668 |
-
$pmpro_gateway_ready = false;
|
1669 |
-
}
|
1670 |
-
elseif($gateway == "paypal" || $gateway == "paypalexpress")
|
1671 |
-
{
|
1672 |
-
if(pmpro_getOption("gateway_environment") && pmpro_getOption("gateway_email") && pmpro_getOption("apiusername") && pmpro_getOption("apipassword") && pmpro_getOption("apisignature"))
|
1673 |
-
$pmpro_gateway_ready = true;
|
1674 |
-
else
|
1675 |
-
$pmpro_gateway_ready = false;
|
1676 |
-
}
|
1677 |
-
elseif($gateway == "paypalstandard")
|
1678 |
-
{
|
1679 |
-
if(pmpro_getOption("gateway_environment") && pmpro_getOption("gateway_email"))
|
1680 |
-
$pmpro_gateway_ready = true;
|
1681 |
-
else
|
1682 |
-
$pmpro_gateway_ready = false;
|
1683 |
-
}
|
1684 |
-
elseif($gateway == "payflowpro")
|
1685 |
-
{
|
1686 |
-
if(pmpro_getOption("payflow_partner") && pmpro_getOption("payflow_vendor") && pmpro_getOption("payflow_user") && pmpro_getOption("payflow_pwd"))
|
1687 |
-
$pmpro_gateway_ready = true;
|
1688 |
-
else
|
1689 |
-
$pmpro_gateway_ready = false;
|
1690 |
-
}
|
1691 |
-
elseif($gateway == "stripe")
|
1692 |
-
{
|
1693 |
-
if(pmpro_getOption("gateway_environment") && pmpro_getOption("stripe_secretkey") && pmpro_getOption("stripe_publishablekey"))
|
1694 |
-
$pmpro_gateway_ready = true;
|
1695 |
-
else
|
1696 |
-
$pmpro_gateway_ready = false;
|
1697 |
-
}
|
1698 |
-
elseif($gateway == "braintree")
|
1699 |
-
{
|
1700 |
-
if(pmpro_getOption("gateway_environment") && pmpro_getOption("braintree_merchantid") && pmpro_getOption("braintree_publickey") && pmpro_getOption("braintree_privatekey"))
|
1701 |
-
$pmpro_gateway_ready = true;
|
1702 |
-
else
|
1703 |
-
$pmpro_gateway_ready = false;
|
1704 |
-
}
|
1705 |
-
elseif($gateway == "twocheckout")
|
1706 |
-
{
|
1707 |
-
if(pmpro_getOption("gateway_environment") && pmpro_getOption("twocheckout_apiusername") && pmpro_getOption("twocheckout_apipassword"))
|
1708 |
-
$pmpro_gateway_ready = true;
|
1709 |
-
else
|
1710 |
-
$pmpro_gateway_ready = false;
|
1711 |
-
}
|
1712 |
-
elseif($gateway == "cybersource")
|
1713 |
-
{
|
1714 |
-
if(pmpro_getOption("gateway_environment") && pmpro_getOption("cybersource_merchantid") && pmpro_getOption("cybersource_securitykey"))
|
1715 |
-
$pmpro_gateway_ready = true;
|
1716 |
-
else
|
1717 |
-
$pmpro_gateway_ready = false;
|
1718 |
-
}
|
1719 |
-
else
|
1720 |
-
{
|
1721 |
-
$pmpro_gateway_ready = false;
|
1722 |
-
}
|
1723 |
-
}
|
1724 |
-
|
1725 |
-
//check if we have all pages
|
1726 |
-
if($pmpro_pages["account"] &&
|
1727 |
-
$pmpro_pages["billing"] &&
|
1728 |
-
$pmpro_pages["cancel"] &&
|
1729 |
-
$pmpro_pages["checkout"] &&
|
1730 |
-
$pmpro_pages["confirmation"] &&
|
1731 |
-
$pmpro_pages["invoice"] &&
|
1732 |
-
$pmpro_pages["levels"])
|
1733 |
-
$pmpro_pages_ready = true;
|
1734 |
-
else
|
1735 |
-
$pmpro_pages_ready = false;
|
1736 |
-
|
1737 |
-
//now check both
|
1738 |
-
if($pmpro_gateway_ready && $pmpro_pages_ready)
|
1739 |
-
return true;
|
1740 |
-
else
|
1741 |
-
return false;
|
1742 |
-
}
|
1 |
+
<?php
|
2 |
+
if(!function_exists("sornot"))
|
3 |
+
{
|
4 |
+
function sornot($t, $n)
|
5 |
+
{
|
6 |
+
if($n == 1)
|
7 |
+
return $t;
|
8 |
+
else
|
9 |
+
return $t . "s";
|
10 |
+
}
|
11 |
+
}
|
12 |
+
|
13 |
+
//from: http://stackoverflow.com/questions/5266945/wordpress-how-detect-if-current-page-is-the-login-page/5892694#5892694
|
14 |
+
function pmpro_is_login_page() {
|
15 |
+
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
|
16 |
+
}
|
17 |
+
|
18 |
+
//thanks: http://wordpress.org/support/topic/is_plugin_active
|
19 |
+
function pmpro_is_plugin_active( $plugin ) {
|
20 |
+
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) );
|
21 |
+
}
|
22 |
+
|
23 |
+
//scraping - override n if you have more than 1 group of matches and don't want the first group
|
24 |
+
function pmpro_getMatches($p, $s, $firstvalue = FALSE, $n = 1)
|
25 |
+
{
|
26 |
+
$ok = preg_match_all($p, $s, $matches);
|
27 |
+
|
28 |
+
if(!$ok)
|
29 |
+
return false;
|
30 |
+
else
|
31 |
+
{
|
32 |
+
if($firstvalue)
|
33 |
+
return $matches[$n][0];
|
34 |
+
else
|
35 |
+
return $matches[$n];
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
function pmpro_br2nl($text, $tags = "br")
|
40 |
+
{
|
41 |
+
if(!is_array($tags))
|
42 |
+
$tags = explode(" ", $tags);
|
43 |
+
|
44 |
+
foreach($tags as $tag)
|
45 |
+
{
|
46 |
+
$text = eregi_replace("<" . $tag . "[^>]*>", "\n", $text);
|
47 |
+
$text = eregi_replace("</" . $tag . "[^>]*>", "\n", $text);
|
48 |
+
}
|
49 |
+
|
50 |
+
return($text);
|
51 |
+
}
|
52 |
+
|
53 |
+
function pmpro_getOption($s)
|
54 |
+
{
|
55 |
+
if(isset($_REQUEST[$s]))
|
56 |
+
return $_REQUEST[$s];
|
57 |
+
elseif(get_option("pmpro_" . $s))
|
58 |
+
return get_option("pmpro_" . $s);
|
59 |
+
else
|
60 |
+
return "";
|
61 |
+
}
|
62 |
+
|
63 |
+
function pmpro_setOption($s, $v = NULL)
|
64 |
+
{
|
65 |
+
//no value is given, set v to the request var
|
66 |
+
if($v === NULL)
|
67 |
+
$v = $_REQUEST[$s];
|
68 |
+
|
69 |
+
if(is_array($v))
|
70 |
+
$v = implode(",", $v);
|
71 |
+
|
72 |
+
return update_option("pmpro_" . $s, $v);
|
73 |
+
}
|
74 |
+
|
75 |
+
function pmpro_get_slug($post_id)
|
76 |
+
{
|
77 |
+
global $pmpro_slugs, $wpdb;
|
78 |
+
if(!$pmpro_slugs[$post_id])
|
79 |
+
$pmpro_slugs[$post_id] = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE ID = '" . $post_id . "' LIMIT 1");
|
80 |
+
|
81 |
+
return $pmpro_slugs[$post_id];
|
82 |
+
}
|
83 |
+
|
84 |
+
function pmpro_url($page = NULL, $querystring = "", $scheme = NULL)
|
85 |
+
{
|
86 |
+
global $besecure;
|
87 |
+
$besecure = apply_filters("besecure", $besecure);
|
88 |
+
|
89 |
+
if(!$scheme && $besecure)
|
90 |
+
$scheme = "https";
|
91 |
+
elseif(!$scheme)
|
92 |
+
$scheme = "http";
|
93 |
+
|
94 |
+
if(!$page)
|
95 |
+
$page = "levels";
|
96 |
+
|
97 |
+
global $pmpro_pages;
|
98 |
+
|
99 |
+
//? vs &
|
100 |
+
if(strpos(get_permalink($pmpro_pages[$page]), "?"))
|
101 |
+
return home_url(str_replace(home_url(), "", get_permalink($pmpro_pages[$page])) . str_replace("?", "&", $querystring), $scheme);
|
102 |
+
else
|
103 |
+
return home_url(str_replace(home_url(), "", get_permalink($pmpro_pages[$page])) . $querystring, $scheme);
|
104 |
+
}
|
105 |
+
|
106 |
+
function pmpro_isLevelFree(&$level)
|
107 |
+
{
|
108 |
+
if($level->initial_payment <= 0 && $level->billing_amount <= 0 && $level->trial_amount <= 0)
|
109 |
+
return true;
|
110 |
+
else
|
111 |
+
return false;
|
112 |
+
}
|
113 |
+
|
114 |
+
function pmpro_isLevelRecurring(&$level)
|
115 |
+
{
|
116 |
+
if($level->billing_amount > 0 || $level->trial_amount > 0)
|
117 |
+
return true;
|
118 |
+
else
|
119 |
+
return false;
|
120 |
+
}
|
121 |
+
|
122 |
+
function pmpro_isLevelTrial(&$level)
|
123 |
+
{
|
124 |
+
if($level->trial_limit > 0)
|
125 |
+
{
|
126 |
+
return true;
|
127 |
+
}
|
128 |
+
else
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
function pmpro_isLevelExpiring(&$level)
|
133 |
+
{
|
134 |
+
if($level->expiration_number > 0)
|
135 |
+
return true;
|
136 |
+
else
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
function pmpro_getLevelCost(&$level)
|
141 |
+
{
|
142 |
+
global $pmpro_currency_symbol;
|
143 |
+
$r = '
|
144 |
+
The price for membership is <strong>' . $pmpro_currency_symbol . number_format($level->initial_payment, 2) . '</strong> now';
|
145 |
+
if($level->billing_amount != '0.00')
|
146 |
+
{
|
147 |
+
$r .= ' and then <strong>' . $pmpro_currency_symbol . $level->billing_amount;
|
148 |
+
if($level->cycle_number == '1')
|
149 |
+
{
|
150 |
+
$r .= ' per ';
|
151 |
+
}
|
152 |
+
elseif($level->billing_limit == 1)
|
153 |
+
{
|
154 |
+
$r .= ' after ' . $level->cycle_number . ' ';
|
155 |
+
}
|
156 |
+
else
|
157 |
+
{
|
158 |
+
$r .= ' every ' . $level->cycle_number . ' ';
|
159 |
+
}
|
160 |
+
|
161 |
+
$r .= sornot($level->cycle_period,$level->cycle_number);
|
162 |
+
|
163 |
+
if($level->billing_limit > 1)
|
164 |
+
{
|
165 |
+
$r .= ' for ' . $level->billing_limit . ' more ' . sornot("payment",$level->billing_limit) . '.';
|
166 |
+
}
|
167 |
+
else
|
168 |
+
$r .= '.';
|
169 |
+
|
170 |
+
$r .= '</strong>';
|
171 |
+
}
|
172 |
+
else
|
173 |
+
$r .= '.';
|
174 |
+
|
175 |
+
if($level->trial_limit)
|
176 |
+
{
|
177 |
+
$r .= ' After your initial payment, your first ';
|
178 |
+
if($level->trial_amount == '0.00')
|
179 |
+
{
|
180 |
+
if($level->trial_limit == '1')
|
181 |
+
{
|
182 |
+
$r .= 'payment is Free.';
|
183 |
+
}
|
184 |
+
else
|
185 |
+
{
|
186 |
+
$r .= $level->trial_limit . ' payments are Free.';
|
187 |
+
}
|
188 |
+
}
|
189 |
+
else
|
190 |
+
{
|
191 |
+
$r .= $level->trial_limit.' ' .sornot("payment", $level->trial_limit) . ' will cost ' . $pmpro_currency_symbol . $level->trial_amount . '.';
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
//taxes?
|
196 |
+
$tax_state = pmpro_getOption("tax_state");
|
197 |
+
$tax_rate = pmpro_getOption("tax_rate");
|
198 |
+
|
199 |
+
if($tax_state && $tax_rate && !pmpro_isLevelFree($level))
|
200 |
+
{
|
201 |
+
$r .= " Customers in " . $tax_state . " will be charged " . round($tax_rate * 100, 2) . "% tax.";
|
202 |
+
}
|
203 |
+
|
204 |
+
$r = apply_filters("pmpro_level_cost_text", $r, $level);
|
205 |
+
return $r;
|
206 |
+
}
|
207 |
+
|
208 |
+
function pmpro_getLevelExpiration(&$level)
|
209 |
+
{
|
210 |
+
if($level->expiration_number)
|
211 |
+
{
|
212 |
+
$expiration_text = "Membership expires after " . $level->expiration_number . " " . sornot(strtolower($level->expiration_period), $level->expiration_number) . ".";
|
213 |
+
}
|
214 |
+
else
|
215 |
+
$expiration_text = "";
|
216 |
+
|
217 |
+
$expiration_text = apply_filters("pmpro_level_expiration_text", $expiration_text, $level);
|
218 |
+
return $expiration_text;
|
219 |
+
}
|
220 |
+
|
221 |
+
function pmpro_hideAds()
|
222 |
+
{
|
223 |
+
global $pmpro_display_ads;
|
224 |
+
return !$pmpro_display_ads;
|
225 |
+
}
|
226 |
+
|
227 |
+
function pmpro_displayAds()
|
228 |
+
{
|
229 |
+
global $pmpro_display_ads;
|
230 |
+
return $pmpro_display_ads;
|
231 |
+
}
|
232 |
+
|
233 |
+
function pmpro_next_payment($user_id = NULL)
|
234 |
+
{
|
235 |
+
global $wpdb, $current_user;
|
236 |
+
if(!$user_id)
|
237 |
+
$user_id = $current_user->ID;
|
238 |
+
|
239 |
+
if(!$user_id)
|
240 |
+
return false;
|
241 |
+
|
242 |
+
//when were they last billed
|
243 |
+
$lastdate = $wpdb->get_var("SELECT UNIX_TIMESTAMP(timestamp) as timestamp FROM $wpdb->pmpro_membership_orders WHERE user_id = '" . $user_id . "' ORDER BY timestamp DESC LIMIT 1");
|
244 |
+
|
245 |
+
if($lastdate)
|
246 |
+
{
|
247 |
+
//next payment will be same day, following month
|
248 |
+
$lastmonth = date("n", $lastdate);
|
249 |
+
$lastday = date("j", $lastdate);
|
250 |
+
$lastyear = date("Y", $lastdate);
|
251 |
+
|
252 |
+
$nextmonth = ((int)$lastmonth) + 1;
|
253 |
+
if($nextmonth == 13)
|
254 |
+
{
|
255 |
+
$nextmonth = 1;
|
256 |
+
$nextyear = ((int)$lastyear) + 1;
|
257 |
+
}
|
258 |
+
else
|
259 |
+
$nextyear = $lastyear;
|
260 |
+
|
261 |
+
$daysinnextmonth = date("t", strtotime($nextyear . "-" . $nextmonth . "-1"));
|
262 |
+
|
263 |
+
if($daysinnextmonth < $lastday)
|
264 |
+
{
|
265 |
+
$nextday = $daysinnextmonth;
|
266 |
+
}
|
267 |
+
else
|
268 |
+
$nextday = $lastday;
|
269 |
+
|
270 |
+
return strtotime($nextyear . "-" . $nextmonth . "-" . $nextday);
|
271 |
+
}
|
272 |
+
else
|
273 |
+
{
|
274 |
+
return false;
|
275 |
+
}
|
276 |
+
|
277 |
+
}
|
278 |
+
|
279 |
+
if(!function_exists("last4"))
|
280 |
+
{
|
281 |
+
function last4($t)
|
282 |
+
{
|
283 |
+
return substr($t, strlen($t) - 4, 4);
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
if(!function_exists("hideCardNumber"))
|
288 |
+
{
|
289 |
+
function hideCardNumber($c, $dashes = true)
|
290 |
+
{
|
291 |
+
if($c)
|
292 |
+
{
|
293 |
+
if($dashes)
|
294 |
+
return "XXXX-XXXX-XXXX-" . substr($c, strlen($c) - 4, 4);
|
295 |
+
else
|
296 |
+
return "XXXXXXXXXXXX" . substr($c, strlen($c) - 4, 4);
|
297 |
+
}
|
298 |
+
else
|
299 |
+
{
|
300 |
+
return "";
|
301 |
+
}
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
if(!function_exists("cleanPhone"))
|
306 |
+
{
|
307 |
+
function cleanPhone($phone)
|
308 |
+
{
|
309 |
+
//if a + is passed, just pass it along
|
310 |
+
if(strpos($phone, "+") !== false)
|
311 |
+
return $phone;
|
312 |
+
|
313 |
+
//clean the phone
|
314 |
+
$phone = str_replace("-", "", $phone);
|
315 |
+
$phone = str_replace(".", "", $phone);
|
316 |
+
$phone = str_replace("(", "", $phone);
|
317 |
+
$phone = str_replace(")", "", $phone);
|
318 |
+
$phone = str_replace(" ", "", $phone);
|
319 |
+
|
320 |
+
return $phone;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
if(!function_exists("formatPhone"))
|
325 |
+
{
|
326 |
+
function formatPhone($phone)
|
327 |
+
{
|
328 |
+
$phone = cleanPhone($phone);
|
329 |
+
|
330 |
+
if(strlen($phone) == 11)
|
331 |
+
return substr($phone, 0, 1) . " (" . substr($phone, 1, 3) . ") " . substr($phone, 4, 3) . "-" . substr($phone, 7, 4);
|
332 |
+
elseif(strlen($phone) == 10)
|
333 |
+
return "(" . substr($phone, 0, 3) . ") " . substr($phone, 3, 3) . "-" . substr($phone, 6, 4);
|
334 |
+
elseif(strlen($phone) == 7)
|
335 |
+
return substr($phone, 0, 3) . "-" . substr($phone, 3, 4);
|
336 |
+
else
|
337 |
+
return $phone;
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
function pmpro_showRequiresMembershipMessage()
|
342 |
+
{
|
343 |
+
//get the correct message
|
344 |
+
if(is_feed())
|
345 |
+
{
|
346 |
+
$content = pmpro_getOption("rsstext");
|
347 |
+
$content = str_replace("!!levels!!", implode(", ", $post_membership_levels_names), $content);
|
348 |
+
}
|
349 |
+
elseif($current_user->ID)
|
350 |
+
{
|
351 |
+
//not a member
|
352 |
+
$content = pmpro_getOption("nonmembertext");
|
353 |
+
$content = str_replace("!!levels!!", implode(", ", $post_membership_levels_names), $content);
|
354 |
+
}
|
355 |
+
else
|
356 |
+
{
|
357 |
+
//not logged in!
|
358 |
+
$content = pmpro_getOption("notloggedintext");
|
359 |
+
$content = str_replace("!!levels!!", implode(", ", $post_membership_levels_names), $content);
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
/* pmpro_hasMembershipLevel() checks if the passed user is a member of the passed level
|
364 |
+
*
|
365 |
+
* $level may either be the ID or name of the desired membership_level. (or an array of such)
|
366 |
+
* If $user_id is omitted, the value will be retrieved from $current_user.
|
367 |
+
*
|
368 |
+
* Return values:
|
369 |
+
* Success returns boolean true.
|
370 |
+
* Failure returns a string containing the error message.
|
371 |
+
*/
|
372 |
+
function pmpro_hasMembershipLevel($levels = NULL, $user_id = NULL)
|
373 |
+
{
|
374 |
+
global $current_user, $all_membership_levels, $wpdb;
|
375 |
+
|
376 |
+
if($user_id)
|
377 |
+
{
|
378 |
+
//get the membership level from the global array
|
379 |
+
$membership_level = $all_membership_levels[$user_id];
|
380 |
+
if(!$membership_level)
|
381 |
+
{
|
382 |
+
//no level, check the db and add to array
|
383 |
+
$membership_level = $wpdb->get_row("SELECT l.id AS ID, l.*
|
384 |
+
FROM {$wpdb->pmpro_membership_levels} AS l
|
385 |
+
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
|
386 |
+
WHERE mu.user_id = $user_id
|
387 |
+
LIMIT 1");
|
388 |
+
if($membership_level)
|
389 |
+
$all_membership_levels[$user_id] = $membership_level;
|
390 |
+
else
|
391 |
+
$all_memberships_levels[$user_id] = -1; //not a member of anything
|
392 |
+
}
|
393 |
+
}
|
394 |
+
else
|
395 |
+
{
|
396 |
+
//no user_id passed, check the current user
|
397 |
+
$user_id = $current_user->ID;
|
398 |
+
$membership_level = $current_user->membership_level;
|
399 |
+
}
|
400 |
+
|
401 |
+
//if 0 was passed, return true if they have no level and false if they have any
|
402 |
+
if(is_array($levels))
|
403 |
+
{
|
404 |
+
if($levels[0] === "0")
|
405 |
+
{
|
406 |
+
if($membership_level->ID)
|
407 |
+
return false;
|
408 |
+
else
|
409 |
+
return true;
|
410 |
+
}
|
411 |
+
}
|
412 |
+
else
|
413 |
+
{
|
414 |
+
if($levels === "0")
|
415 |
+
{
|
416 |
+
if($membership_level->ID)
|
417 |
+
return false;
|
418 |
+
else
|
419 |
+
return true;
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
//no levels?
|
424 |
+
if($membership_level == "-1" || !$membership_level)
|
425 |
+
return false;
|
426 |
+
|
427 |
+
//if no level var was passed, we're just checking if they have any level
|
428 |
+
if(!$levels)
|
429 |
+
{
|
430 |
+
if($membership_level->ID)
|
431 |
+
return true;
|
432 |
+
else
|
433 |
+
return false;
|
434 |
+
}
|
435 |
+
|
436 |
+
//okay, so something to check let's set the levels
|
437 |
+
if(!is_array($levels))
|
438 |
+
$levels = array($levels);
|
439 |
+
|
440 |
+
//and check each one
|
441 |
+
foreach($levels as $level)
|
442 |
+
{
|
443 |
+
if($level == $membership_level->ID || $level == $membership_level->name)
|
444 |
+
{
|
445 |
+
return true;
|
446 |
+
}
|
447 |
+
}
|
448 |
+
|
449 |
+
return false;
|
450 |
+
}
|
451 |
+
|
452 |
+
/* pmpro_changeMembershipLevel() creatues or updates the membership level of the given user to the given level.
|
453 |
+
*
|
454 |
+
* $level may either be the ID or name of the desired membership_level.
|
455 |
+
* If $user_id is omitted, the value will be retrieved from $current_user.
|
456 |
+
*
|
457 |
+
* Return values:
|
458 |
+
* Success returns boolean true.
|
459 |
+
* Failure returns boolean false.
|
460 |
+
*/
|
461 |
+
function pmpro_changeMembershipLevel($level, $user_id = NULL)
|
462 |
+
{
|
463 |
+
global $wpdb;
|
464 |
+
global $current_user, $pmpro_error;
|
465 |
+
|
466 |
+
if(!$user_id)
|
467 |
+
$user_id = $current_user->ID;
|
468 |
+
|
469 |
+
if(!$user_id)
|
470 |
+
{
|
471 |
+
$pmpro_error = "User ID not found.";
|
472 |
+
return false;
|
473 |
+
}
|
474 |
+
|
475 |
+
//was a name passed? (Todo: make sure level names have at least one non-numeric character.
|
476 |
+
if($level !== "" && $level !== false && $level !== NULL && !is_numeric($level))
|
477 |
+
{
|
478 |
+
$level = $wpdb->get_var("SELECT id FROM $wpdb->pmpro_membership_levels WHERE name = '" . $wpdb->escape($level) . "' LIMIT 1");
|
479 |
+
if(!$level)
|
480 |
+
{
|
481 |
+
$pmpro_error = "Membership level not found.";
|
482 |
+
return false;
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
//are they even changing?
|
487 |
+
$old_level = $wpdb->get_row("SELECT * FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $user_id . "'");
|
488 |
+
if($old_level->membership_id == $level)
|
489 |
+
return false; //not changing
|
490 |
+
|
491 |
+
//are they paying? may need to cancel their old membership
|
492 |
+
if(!pmpro_isLevelFree($old_level))
|
493 |
+
$paying = true;
|
494 |
+
|
495 |
+
if($paying)
|
496 |
+
{
|
497 |
+
//get last order
|
498 |
+
$order = new MemberOrder();
|
499 |
+
$order->getLastMemberOrder($user_id);
|
500 |
+
|
501 |
+
if($order->cancel())
|
502 |
+
{
|
503 |
+
//we're good
|
504 |
+
}
|
505 |
+
else
|
506 |
+
{
|
507 |
+
//uh oh
|
508 |
+
$pmpro_error = "There was an error canceling your membership: " . $order->error;
|
509 |
+
return false;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
|
513 |
+
//adding, changing, or deleting
|
514 |
+
if($level)
|
515 |
+
{
|
516 |
+
//adding, changing
|
517 |
+
$sql = "REPLACE INTO $wpdb->pmpro_memberships_users (`membership_id`,`user_id`) VALUES ('" . $level . "','" . $user_id . "')";
|
518 |
+
}
|
519 |
+
else
|
520 |
+
{
|
521 |
+
//false or null or 0 was passed, so we're deleting removing
|
522 |
+
$sql = "DELETE FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . $wpdb->escape($user_id) . "' LIMIT 1";
|
523 |
+
}
|
524 |
+
|
525 |
+
//run the query, return
|
526 |
+
if(!$wpdb->query($sql))
|
527 |
+
{
|
528 |
+
if(mysql_errno())
|
529 |
+
$pmpro_error = "Error: " . mysql_error();
|
530 |
+
return false;
|
531 |
+
}
|
532 |
+
else
|
533 |
+
{
|
534 |
+
pmpro_set_current_user();
|
535 |
+
do_action("pmpro_after_change_membership_level", $level, $user_id);
|
536 |
+
return true;
|
537 |
+
}
|
538 |
+
}
|
539 |
+
|
540 |
+
/* pmpro_toggleMembershipCategory() creates or deletes a linking entry between the membership level and post category tables.
|
541 |
+
*
|
542 |
+
* $level may either be the ID or name of the desired membership_level.
|
543 |
+
* $category must be a valid post category ID.
|
544 |
+
*
|
545 |
+
* Return values:
|
546 |
+
* Success returns boolean true.
|
547 |
+
* Failure returns a string containing the error message.
|
548 |
+
*/
|
549 |
+
function pmpro_toggleMembershipCategory( $level, $category, $value )
|
550 |
+
{
|
551 |
+
global $wpdb;
|
552 |
+
$category = intval($category);
|
553 |
+
|
554 |
+
if ( ($level = intval($level)) <= 0 )
|
555 |
+
{
|
556 |
+
$safe = addslashes($level);
|
557 |
+
if ( ($level = intval($wpdb->get_var("SELECT id FROM {$wpdb->pmpro_membership_levels} WHERE name = '$safe' LIMIT 1"))) <= 0 )
|
558 |
+
{
|
559 |
+
return "Membership level not found.";
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
if ( $value )
|
564 |
+
{
|
565 |
+
$sql = "REPLACE INTO {$wpdb->pmpro_memberships_categories} (`membership_id`,`category_id`) VALUES ('$level','$category')";
|
566 |
+
$wpdb->query($sql);
|
567 |
+
if(mysql_errno()) return mysql_error();
|
568 |
+
}
|
569 |
+
else
|
570 |
+
{
|
571 |
+
$sql = "DELETE FROM {$wpdb->pmpro_memberships_categories} WHERE `membership_id` = '$level' AND `category_id` = '$category' LIMIT 1";
|
572 |
+
$wpdb->query($sql);
|
573 |
+
if(mysql_errno()) return mysql_error();
|
574 |
+
}
|
575 |
+
|
576 |
+
return true;
|
577 |
+
}
|
578 |
+
|
579 |
+
/* pmpro_updateMembershipCategories() ensures that all those and only those categories given
|
580 |
+
* are associated with the given membership level.
|
581 |
+
*
|
582 |
+
* $level is a valid membership level ID or name
|
583 |
+
* $categories is an array of post category IDs
|
584 |
+
*
|
585 |
+
* Return values:
|
586 |
+
* Success returns boolean true.
|
587 |
+
* Failure returns a string containing the error message.
|
588 |
+
*/
|
589 |
+
function pmpro_updateMembershipCategories( $level, $categories ) {
|
590 |
+
global $wpdb;
|
591 |
+
$category = intval($category);
|
592 |
+
|
593 |
+
if ( ($level = intval($level)) <= 0 )
|
594 |
+
{
|
595 |
+
$safe = addslashes($level);
|
596 |
+
if ( ($level = intval($wpdb->get_var("SELECT id FROM {$wpdb->pmpro_membership_levels} WHERE name = '$safe' LIMIT 1"))) <= 0 )
|
597 |
+
{
|
598 |
+
return "Membership level not found.";
|
599 |
+
}
|
600 |
+
}
|
601 |
+
|
602 |
+
// remove all existing links...
|
603 |
+
$sql = "DELETE FROM {$wpdb->pmpro_memberships_categories} WHERE `membership_id` = '$level'";
|
604 |
+
$wpdb->query($sql);
|
605 |
+
if(mysql_errno()) return mysql_error();
|
606 |
+
|
607 |
+
// add the given links [back?] in...
|
608 |
+
foreach ( $categories as $cat )
|
609 |
+
{
|
610 |
+
if ( is_string( $r = pmpro_toggleMembershipCategory( $level, $cat, true ) ) )
|
611 |
+
{
|
612 |
+
return $r;
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
return true;
|
617 |
+
}
|
618 |
+
|
619 |
+
function pmpro_isAdmin($user_id = NULL)
|
620 |
+
{
|
621 |
+
global $current_user, $wpdb;
|
622 |
+
if(!$user_id)
|
623 |
+
$user_id = $current_user->ID;
|
624 |
+
|
625 |
+
if(!$user_id)
|
626 |
+
return false;
|
627 |
+
|
628 |
+
$admincap = user_can($user_id, "manage_options");
|
629 |
+
if($admincap)
|
630 |
+
return true;
|
631 |
+
else
|
632 |
+
return false;
|
633 |
+
}
|
634 |
+
|
635 |
+
function pmpro_replaceUserMeta($user_id, $meta_keys, $meta_values, $prev_values = NULL)
|
636 |
+
{
|
637 |
+
//expects all arrays for last 3 params or all strings
|
638 |
+
if(!is_array($meta_keys))
|
639 |
+
{
|
640 |
+
$meta_keys = array($meta_keys);
|
641 |
+
$meta_values = array($meta_values);
|
642 |
+
$prev_values = array($prev_values);
|
643 |
+
}
|
644 |
+
|
645 |
+
for($i = 0; $i < count($meta_values); $i++)
|
646 |
+
{
|
647 |
+
if($prev_values[$i])
|
648 |
+
{
|
649 |
+
update_user_meta($user_id, $meta_keys[$i], $meta_values[$i], $prev_values[$i]);
|
650 |
+
}
|
651 |
+
else
|
652 |
+
{
|
653 |
+
$old_value = get_user_meta($user_id, $meta_keys[$i], true);
|
654 |
+
if($old_value)
|
655 |
+
{
|
656 |
+
update_user_meta($user_id, $meta_keys[$i], $meta_values[$i], $old_value);
|
657 |
+
}
|
658 |
+
else
|
659 |
+
{
|
660 |
+
update_user_meta($user_id, $meta_keys[$i], $meta_values[$i]);
|
661 |
+
}
|
662 |
+
}
|
663 |
+
}
|
664 |
+
|
665 |
+
return $i;
|
666 |
+
}
|
667 |
+
|
668 |
+
function pmpro_getMetavalues($query)
|
669 |
+
{
|
670 |
+
global $wpdb;
|
671 |
+
|
672 |
+
$results = $wpdb->get_results($query);
|
673 |
+
foreach($results as $result)
|
674 |
+
{
|
675 |
+
$r->{$result->key} = $result->value;
|
676 |
+
}
|
677 |
+
|
678 |
+
return $r;
|
679 |
+
}
|
680 |
+
|
681 |
+
//function to return the pagination string
|
682 |
+
function pmpro_getPaginationString($page = 1, $totalitems, $limit = 15, $adjacents = 1, $targetpage = "/", $pagestring = "&pn=")
|
683 |
+
{
|
684 |
+
//defaults
|
685 |
+
if(!$adjacents) $adjacents = 1;
|
686 |
+
if(!$limit) $limit = 15;
|
687 |
+
if(!$page) $page = 1;
|
688 |
+
if(!$targetpage) $targetpage = "/";
|
689 |
+
|
690 |
+
//other vars
|
691 |
+
$prev = $page - 1; //previous page is page - 1
|
692 |
+
$next = $page + 1; //next page is page + 1
|
693 |
+
$lastpage = ceil($totalitems / $limit); //lastpage is = total items / items per page, rounded up.
|
694 |
+
$lpm1 = $lastpage - 1; //last page minus 1
|
695 |
+
|
696 |
+
/*
|
697 |
+
Now we apply our rules and draw the pagination object.
|
698 |
+
We're actually saving the code to a variable in case we want to draw it more than once.
|
699 |
+
*/
|
700 |
+
$pagination = "";
|
701 |
+
if($lastpage > 1)
|
702 |
+
{
|
703 |
+
$pagination .= "<div class=\"pmpro_pagination\"";
|
704 |
+
if($margin || $padding)
|
705 |
+
{
|
706 |
+
$pagination .= " style=\"";
|
707 |
+
if($margin)
|
708 |
+
$pagination .= "margin: $margin;";
|
709 |
+
if($padding)
|
710 |
+
$pagination .= "padding: $padding;";
|
711 |
+
$pagination .= "\"";
|
712 |
+
}
|
713 |
+
$pagination .= ">";
|
714 |
+
|
715 |
+
//previous button
|
716 |
+
if ($page > 1)
|
717 |
+
$pagination .= "<a href=\"$targetpage$pagestring$prev\">« prev</a>";
|
718 |
+
else
|
719 |
+
$pagination .= "<span class=\"disabled\">« prev</span>";
|
720 |
+
|
721 |
+
//pages
|
722 |
+
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
|
723 |
+
{
|
724 |
+
for ($counter = 1; $counter <= $lastpage; $counter++)
|
725 |
+
{
|
726 |
+
if ($counter == $page)
|
727 |
+
$pagination .= "<span class=\"current\">$counter</span>";
|
728 |
+
else
|
729 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
|
730 |
+
}
|
731 |
+
}
|
732 |
+
elseif($lastpage >= 7 + ($adjacents * 2)) //enough pages to hide some
|
733 |
+
{
|
734 |
+
//close to beginning; only hide later pages
|
735 |
+
if($page < 1 + ($adjacents * 3))
|
736 |
+
{
|
737 |
+
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
|
738 |
+
{
|
739 |
+
if ($counter == $page)
|
740 |
+
$pagination .= "<span class=\"current\">$counter</span>";
|
741 |
+
else
|
742 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
|
743 |
+
}
|
744 |
+
$pagination .= "...";
|
745 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lpm1 . "\">$lpm1</a>";
|
746 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lastpage . "\">$lastpage</a>";
|
747 |
+
}
|
748 |
+
//in middle; hide some front and some back
|
749 |
+
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
|
750 |
+
{
|
751 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . "1\">1</a>";
|
752 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . "2\">2</a>";
|
753 |
+
$pagination .= "...";
|
754 |
+
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
|
755 |
+
{
|
756 |
+
if ($counter == $page)
|
757 |
+
$pagination .= "<span class=\"current\">$counter</span>";
|
758 |
+
else
|
759 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
|
760 |
+
}
|
761 |
+
$pagination .= "...";
|
762 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lpm1 . "\">$lpm1</a>";
|
763 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lastpage . "\">$lastpage</a>";
|
764 |
+
}
|
765 |
+
//close to end; only hide early pages
|
766 |
+
else
|
767 |
+
{
|
768 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . "1\">1</a>";
|
769 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . "2\">2</a>";
|
770 |
+
$pagination .= "...";
|
771 |
+
for ($counter = $lastpage - (1 + ($adjacents * 3)); $counter <= $lastpage; $counter++)
|
772 |
+
{
|
773 |
+
if ($counter == $page)
|
774 |
+
$pagination .= "<span class=\"current\">$counter</span>";
|
775 |
+
else
|
776 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
|
777 |
+
}
|
778 |
+
}
|
779 |
+
}
|
780 |
+
|
781 |
+
//next button
|
782 |
+
if ($page < $counter - 1)
|
783 |
+
$pagination .= "<a href=\"" . $targetpage . $pagestring . $next . "\">next »</a>";
|
784 |
+
else
|
785 |
+
$pagination .= "<span class=\"disabled\">next »</span>";
|
786 |
+
$pagination .= "</div>\n";
|
787 |
+
}
|
788 |
+
|
789 |
+
return $pagination;
|
790 |
+
|
791 |
+
}
|
792 |
+
|
793 |
+
function pmpro_calculateInitialPaymentRevenue($s = NULL, $l = NULL)
|
794 |
+
{
|
795 |
+
global $wpdb;
|
796 |
+
|
797 |
+
//if we're limiting users by search
|
798 |
+
if($s || $l)
|
799 |
+
{
|
800 |
+
$user_ids_query = "SELECT ID FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id WHERE 1 ";
|
801 |
+
if($s)
|
802 |
+
$user_ids_query .= "AND (u.user_login LIKE '%$s%' OR u.user_email LIKE '%$s%' OR um.meta_value LIKE '%$s%') ";
|
803 |
+
if($l)
|
804 |
+
$user_ids_query .= "AND mu.membership_id = '$l' ";
|
805 |
+
}
|
806 |
+
|
807 |
+
//query to sum initial payments
|
808 |
+
$sqlQuery = "SELECT SUM(initial_payment) FROM $wpdb->pmpro_memberships_users WHERE 1 ";
|
809 |
+
if($user_ids_query)
|
810 |
+
$sqlQuery .= "AND user_id IN(" . $user_ids_query . ") ";
|
811 |
+
|
812 |
+
$total = $wpdb->get_var($sqlQuery);
|
813 |
+
|
814 |
+
return (double)$total;
|
815 |
+
}
|
816 |
+
|
817 |
+
function pmpro_calculateRecurringRevenue($s, $l)
|
818 |
+
{
|
819 |
+
global $wpdb;
|
820 |
+
|
821 |
+
//if we're limiting users by search
|
822 |
+
if($s || $l)
|
823 |
+
{
|
824 |
+
$user_ids_query = "AND user_id IN(SELECT ID FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON u.ID = um.user_id LEFT JOIN $wpdb->pmpro_memberships_users mu ON u.ID = mu.user_id WHERE 1 ";
|
825 |
+
if($s)
|
826 |
+
$user_ids_query .= "AND (u.user_login LIKE '%$s%' OR u.user_email LIKE '%$s%' OR um.meta_value LIKE '%$s%') ";
|
827 |
+
if($l)
|
828 |
+
$user_ids_query .= "AND mu.membership_id = '$l' ";
|
829 |
+
$user_ids_query .= ")";
|
830 |
+
}
|
831 |
+
|
832 |
+
//4 queries to get annual earnings for each cycle period. currently ignoring trial periods and billing limits.
|
833 |
+
$sqlQuery = "
|
834 |
+
SELECT SUM((12/cycle_number)*billing_amount) FROM $wpdb->pmpro_memberships_users WHERE cycle_period = 'Month' AND cycle_number <> 12 $user_ids_query
|
835 |
+
UNION
|
836 |
+
SELECT SUM((365/cycle_number)*billing_amount) FROM $wpdb->pmpro_memberships_users WHERE cycle_period = 'Day' AND cycle_number <> 365 $user_ids_query
|
837 |
+
UNION
|
838 |
+
SELECT SUM((52/cycle_number)*billing_amount) FROM $wpdb->pmpro_memberships_users WHERE cycle_period = 'Week' AND cycle_number <> 52 $user_ids_query
|
839 |
+
UNION
|
840 |
+
SELECT SUM(billing_amount) FROM $wpdb->pmpro_memberships_users WHERE cycle_period = 'Year' $user_ids_query
|
841 |
+
";
|
842 |
+
$annual_revenues = $wpdb->get_col($sqlQuery);
|
843 |
+
|
844 |
+
$total = 0;
|
845 |
+
foreach($annual_revenues as $r)
|
846 |
+
{
|
847 |
+
$total += $r;
|
848 |
+
}
|
849 |
+
|
850 |
+
return $total;
|
851 |
+
}
|
852 |
+
|
853 |
+
function pmpro_generateUsername($firstname = "", $lastname = "", $email = "")
|
854 |
+
{
|
855 |
+
global $wpdb;
|
856 |
+
|
857 |
+
//try first initial + last name, firstname, lastname
|
858 |
+
$firstname = preg_replace("/[^A-Za-z]/", "", $firstname);
|
859 |
+
$lastname = preg_replace("/[^A-Za-z]/", "", $lastname);
|
860 |
+
if($firstname && $lastname)
|
861 |
+
{
|
862 |
+
$username = substr($firstname, 0, 1) . $lastname;
|
863 |
+
}
|
864 |
+
elseif($firstname)
|
865 |
+
{
|
866 |
+
$username = $firstname;
|
867 |
+
}
|
868 |
+
elseif($lastname)
|
869 |
+
{
|
870 |
+
$username = $lastname;
|
871 |
+
}
|
872 |
+
|
873 |
+
//is it taken?
|
874 |
+
$taken = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '" . $username . "' LIMIT 1");
|
875 |
+
|
876 |
+
if(!$taken)
|
877 |
+
return $username;
|
878 |
+
|
879 |
+
//try the beginning of the email address
|
880 |
+
$emailparts = explode("@", "email");
|
881 |
+
if(is_array($emailparts))
|
882 |
+
$email = preg_replace("/[^A-Za-z]/", "", $emailparts[0]);
|
883 |
+
|
884 |
+
if($email)
|
885 |
+
{
|
886 |
+
$username = $email;
|
887 |
+
}
|
888 |
+
|
889 |
+
//is this taken? if not, add numbers until it works
|
890 |
+
$taken = true;
|
891 |
+
$count = 0;
|
892 |
+
while($taken)
|
893 |
+
{
|
894 |
+
//add a # to the end
|
895 |
+
if($count)
|
896 |
+
{
|
897 |
+
$username = preg_replace("/[0-9]/", "", $username) . $count;
|
898 |
+
}
|
899 |
+
|
900 |
+
//taken?
|
901 |
+
$taken = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '" . $username . "' LIMIT 1");
|
902 |
+
|
903 |
+
//increment the number
|
904 |
+
$count++;
|
905 |
+
}
|
906 |
+
|
907 |
+
//must have a good username now
|
908 |
+
return $username;
|
909 |
+
}
|
910 |
+
|
911 |
+
//get a new random code for discount codes
|
912 |
+
function pmpro_getDiscountCode()
|
913 |
+
{
|
914 |
+
global $wpdb;
|
915 |
+
|
916 |
+
while(!$code)
|
917 |
+
{
|
918 |
+
$scramble = md5(AUTH_KEY . time() . SECURE_AUTH_KEY);
|
919 |
+
$code = substr($scramble, 0, 10);
|
920 |
+
$check = $wpdb->get_var("SELECT code FROM $wpdb->pmpro_discount_codes WHERE code = '$code' LIMIT 1");
|
921 |
+
if($check || is_numeric($code))
|
922 |
+
$code = NULL;
|
923 |
+
}
|
924 |
+
|
925 |
+
return strtoupper($code);
|
926 |
+
}
|
927 |
+
|
928 |
+
//is a discount code valid
|
929 |
+
function pmpro_checkDiscountCode($code, $level_id = NULL, $return_errors = false)
|
930 |
+
{
|
931 |
+
global $wpdb;
|
932 |
+
|
933 |
+
//no code, no code
|
934 |
+
if(!$code)
|
935 |
+
{
|
936 |
+
if($return_errors)
|
937 |
+
return array(false, "No code was given to check.");
|
938 |
+
else
|
939 |
+
return false;
|
940 |
+
}
|
941 |
+
|
942 |
+
//get code from db
|
943 |
+
$dbcode = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(starts) as starts, UNIX_TIMESTAMP(expires) as expires FROM $wpdb->pmpro_discount_codes WHERE code ='" . $code . "' LIMIT 1");
|
944 |
+
|
945 |
+
//fix the date timestamps
|
946 |
+
$dbcode->starts = strtotime(date("m/d/Y", $dbcode->starts));
|
947 |
+
$dbcode->expires = strtotime(date("m/d/Y", $dbcode->expires));
|
948 |
+
|
949 |
+
//did we find it?
|
950 |
+
if(!$dbcode->id)
|
951 |
+
{
|
952 |
+
if($return_errors)
|
953 |
+
return array(false, "The code could not be found.");
|
954 |
+
else
|
955 |
+
return false;
|
956 |
+
}
|
957 |
+
|
958 |
+
//today
|
959 |
+
$today = strtotime(date("m/d/Y 00:00:00"));
|
960 |
+
|
961 |
+
//has this code started yet?
|
962 |
+
if($dbcode->starts && $dbcode->starts > $today)
|
963 |
+
{
|
964 |
+
if($return_errors)
|
965 |
+
return array(false, "This discount code goes into effect on " . date("m/d/Y", $dbcode->starts) . ".");
|
966 |
+
else
|
967 |
+
return false;
|
968 |
+
}
|
969 |
+
|
970 |
+
//has this code expired?
|
971 |
+
if($dbcode->expires && $dbcode->expires < $today)
|
972 |
+
{
|
973 |
+
if($return_errors)
|
974 |
+
return array(false, "This discount code expired on " . date("m/d/Y", $dbcode->expires) . ".");
|
975 |
+
else
|
976 |
+
return false;
|
977 |
+
}
|
978 |
+
|
979 |
+
//have we run out of uses?
|
980 |
+
if($dbcode->uses > 0)
|
981 |
+
{
|
982 |
+
$used = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->pmpro_discount_codes_uses WHERE code_id = '" . $dbcode->id . "'");
|
983 |
+
if($used >= $dbcode->uses)
|
984 |
+
{
|
985 |
+
if($return_errors)
|
986 |
+
return array(false, "This discount code is no longer valid.");
|
987 |
+
else
|
988 |
+
return false;
|
989 |
+
}
|
990 |
+
}
|
991 |
+
|
992 |
+
//if a level was passed check if this code applies
|
993 |
+
if($level_id)
|
994 |
+
{
|
995 |
+
$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 = '" . $level_id . "' LIMIT 1");
|
996 |
+
|
997 |
+
if(!$code_level)
|
998 |
+
{
|
999 |
+
if($return_errors)
|
1000 |
+
return array(false, "This code does not apply to this membership level.");
|
1001 |
+
else
|
1002 |
+
return false;
|
1003 |
+
}
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
//guess we're all good
|
1007 |
+
if($return_errors)
|
1008 |
+
return array(true, "This discount code is okay.");
|
1009 |
+
else
|
1010 |
+
return true;
|
1011 |
+
}
|
1012 |
+
|
1013 |
+
function pmpro_no_quotes($s, $quotes = array("'", '"'))
|
1014 |
+
{
|
1015 |
+
return str_replace($quotes, "", $s);
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
//from: http://www.php.net/manual/en/function.implode.php#86845
|
1019 |
+
function pmpro_implodeToEnglish($array)
|
1020 |
+
{
|
1021 |
+
// sanity check
|
1022 |
+
if (!$array || !count ($array))
|
1023 |
+
return '';
|
1024 |
+
|
1025 |
+
// get last element
|
1026 |
+
$last = array_pop ($array);
|
1027 |
+
|
1028 |
+
// if it was the only element - return it
|
1029 |
+
if (!count ($array))
|
1030 |
+
return $last;
|
1031 |
+
|
1032 |
+
return implode (', ', $array).' and '.$last;
|
1033 |
+
}
|
1034 |
+
|
1035 |
+
//from yoast wordpress seo
|
1036 |
+
function pmpro_text_limit( $text, $limit, $finish = '…')
|
1037 |
+
{
|
1038 |
+
if( strlen( $text ) > $limit ) {
|
1039 |
+
$text = substr( $text, 0, $limit );
|
1040 |
+
$text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
|
1041 |
+
$text .= $finish;
|
1042 |
+
}
|
1043 |
+
return $text;
|
1044 |
+
}
|
1045 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/https.php
DELETED
@@ -1,185 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Code related to HTTPS/SSL
|
4 |
-
*/
|
5 |
-
|
6 |
-
//this function checks if we have set the $isapage variable, and if so prevents WP from sending a 404
|
7 |
-
function pmpro_status_filter($s)
|
8 |
-
{
|
9 |
-
global $isapage;
|
10 |
-
if($isapage && strpos($s, "404"))
|
11 |
-
return false; //don't send the 404
|
12 |
-
else
|
13 |
-
return $s;
|
14 |
-
}
|
15 |
-
|
16 |
-
//filters links/etc to add HTTPS to URL if needed
|
17 |
-
function pmpro_https_filter($s)
|
18 |
-
{
|
19 |
-
global $besecure;
|
20 |
-
$besecure = apply_filters('pmpro_besecure', $besecure);
|
21 |
-
|
22 |
-
if($besecure || is_ssl())
|
23 |
-
return str_replace("http:", "https:", $s);
|
24 |
-
else
|
25 |
-
return str_replace("https:", "http:", $s);
|
26 |
-
}
|
27 |
-
add_filter('status_header', 'pmpro_status_filter');
|
28 |
-
add_filter('bloginfo_url', 'pmpro_https_filter');
|
29 |
-
add_filter('wp_list_pages', 'pmpro_https_filter');
|
30 |
-
add_filter('option_home', 'pmpro_https_filter');
|
31 |
-
add_filter('option_siteurl', 'pmpro_https_filter');
|
32 |
-
add_filter('logout_url', 'pmpro_https_filter');
|
33 |
-
add_filter('login_url', 'pmpro_https_filter');
|
34 |
-
add_filter('home_url', 'pmpro_https_filter');
|
35 |
-
|
36 |
-
//this function sets the besecure global which may be used in early code
|
37 |
-
/*
|
38 |
-
function pmpro_besecure_set()
|
39 |
-
{
|
40 |
-
global $besecure;
|
41 |
-
if(force_ssl_admin() || force_ssl_login() || is_ssl())
|
42 |
-
$besecure = true;
|
43 |
-
|
44 |
-
$besecure = apply_filters("pmpro_besecure", $besecure);
|
45 |
-
}
|
46 |
-
add_action('init', 'pmpro_besecure_set', 2);
|
47 |
-
*/
|
48 |
-
|
49 |
-
//this function updates the besecure global with post data and redirects if needed
|
50 |
-
function pmpro_besecure()
|
51 |
-
{
|
52 |
-
global $besecure, $post;
|
53 |
-
|
54 |
-
//check the post option
|
55 |
-
if(!is_admin() && !empty($post->ID) && !$besecure)
|
56 |
-
$besecure = get_post_meta($post->ID, "besecure", true);
|
57 |
-
|
58 |
-
//if forcing ssl on admin, be secure in admin and login page
|
59 |
-
if(!$besecure && force_ssl_admin() && (is_admin() || pmpro_is_login_page()))
|
60 |
-
$besecure = true;
|
61 |
-
|
62 |
-
//if forcing ssl on login, be secure on the login page
|
63 |
-
if(!$besecure && force_ssl_login() && pmpro_is_login_page())
|
64 |
-
$besecure = true;
|
65 |
-
|
66 |
-
$besecure = apply_filters("pmpro_besecure", $besecure);
|
67 |
-
|
68 |
-
$use_ssl = pmpro_getOption("use_ssl");
|
69 |
-
if($use_ssl == 1)
|
70 |
-
{
|
71 |
-
if($besecure && (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off" || $_SERVER['HTTPS'] == "false"))
|
72 |
-
{
|
73 |
-
//need to be secure
|
74 |
-
wp_redirect("https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
75 |
-
exit;
|
76 |
-
}
|
77 |
-
elseif(!$besecure && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" && $_SERVER['HTTPS'] != "false")
|
78 |
-
{
|
79 |
-
//don't need to be secure
|
80 |
-
wp_redirect("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
81 |
-
exit;
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
add_action('wp', 'pmpro_besecure', 2);
|
86 |
-
add_action('login_init', 'pmpro_besecure', 2);
|
87 |
-
|
88 |
-
//JavaScript SSL redirect
|
89 |
-
function pmpro_ssl_javascript_redirect()
|
90 |
-
{
|
91 |
-
global $besecure;
|
92 |
-
$use_ssl = pmpro_getOption("use_ssl");
|
93 |
-
if(!is_admin() && $use_ssl == 2)
|
94 |
-
{
|
95 |
-
if($besecure)
|
96 |
-
{
|
97 |
-
?>
|
98 |
-
<script lang="JavaScript">
|
99 |
-
//needs to be secure
|
100 |
-
if (window.location.protocol != "https:")
|
101 |
-
window.location.href = "https:" + window.location.href.substring(window.location.protocol.length);
|
102 |
-
</script>
|
103 |
-
<?php
|
104 |
-
}
|
105 |
-
else
|
106 |
-
{
|
107 |
-
?>
|
108 |
-
<script lang="JavaScript">
|
109 |
-
//should be over http
|
110 |
-
if (window.location.protocol != "http:")
|
111 |
-
window.location.href = "http:" + window.location.href.substring(window.location.protocol.length);
|
112 |
-
</script>
|
113 |
-
<?php
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
117 |
-
add_action('wp_print_scripts', 'pmpro_ssl_javascript_redirect');
|
118 |
-
|
119 |
-
//If the site URL starts with https:, then force SSL/besecure to true. (Added 1.5.2)
|
120 |
-
function pmpro_check_site_url_for_https($besecure)
|
121 |
-
{
|
122 |
-
global $wpdb, $pmpro_siteurl;
|
123 |
-
|
124 |
-
//need to get this from the database because we filter get_option
|
125 |
-
if(empty($pmpro_siteurl))
|
126 |
-
$pmpro_siteurl = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl' LIMIT 1");
|
127 |
-
|
128 |
-
//entire site is over https?
|
129 |
-
if(strpos($pmpro_siteurl, "https:") !== false)
|
130 |
-
$besecure = true;
|
131 |
-
|
132 |
-
return $besecure;
|
133 |
-
}
|
134 |
-
add_filter("pmpro_besecure", "pmpro_check_site_url_for_https");
|
135 |
-
|
136 |
-
//capturing case where a user links to https admin without admin over https
|
137 |
-
function pmpro_admin_https_handler()
|
138 |
-
{
|
139 |
-
if(!empty($_SERVER['HTTPS']))
|
140 |
-
{
|
141 |
-
if($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off" && $_SERVER['HTTPS'] != "false" && is_admin())
|
142 |
-
{
|
143 |
-
if(substr(get_option("siteurl"), 0, 5) == "http:" && !force_ssl_admin())
|
144 |
-
{
|
145 |
-
//need to redirect to non https
|
146 |
-
wp_redirect("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
147 |
-
exit;
|
148 |
-
}
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
add_action('init', 'pmpro_admin_https_handler');
|
153 |
-
|
154 |
-
/*
|
155 |
-
This code is for the "nuke" option to make URLs secure on secure pages.
|
156 |
-
*/
|
157 |
-
function pmpro_NuclearHTTPS()
|
158 |
-
{
|
159 |
-
//did they choose the option?
|
160 |
-
$nuking = pmpro_getOption("nuclear_HTTPS");
|
161 |
-
if(!empty($nuking))
|
162 |
-
{
|
163 |
-
ob_start("pmpro_replaceURLsInBuffer");
|
164 |
-
}
|
165 |
-
}
|
166 |
-
add_action("init", "pmpro_NuclearHTTPS");
|
167 |
-
|
168 |
-
function pmpro_replaceURLsInBuffer($buffer)
|
169 |
-
{
|
170 |
-
global $besecure;
|
171 |
-
|
172 |
-
//only swap URLs if this page is secure
|
173 |
-
if($besecure)
|
174 |
-
{
|
175 |
-
/*
|
176 |
-
okay swap out all links like these:
|
177 |
-
* http://domain.com
|
178 |
-
* http://anysubdomain.domain.com
|
179 |
-
* http://any.number.of.sub.domains.domain.com
|
180 |
-
*/
|
181 |
-
$buffer = preg_replace("/http\:\/\/([a-zA-Z0-9\.\-]*" . str_replace(".", "\.", PMPRO_DOMAIN) . ")/i", "https://$1", $buffer);
|
182 |
-
}
|
183 |
-
|
184 |
-
return $buffer;
|
185 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/init.php
DELETED
@@ -1,240 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Code that runs on the init, set_current_user, or wp hooks to setup PMPro
|
4 |
-
*/
|
5 |
-
//init code
|
6 |
-
function pmpro_init()
|
7 |
-
{
|
8 |
-
require_once(PMPRO_DIR . "/includes/countries.php");
|
9 |
-
require_once(PMPRO_DIR . "/includes/states.php");
|
10 |
-
require_once(PMPRO_DIR . "/includes/currencies.php");
|
11 |
-
|
12 |
-
wp_enqueue_script('ssmemberships_js', plugins_url('js/paid-memberships-pro.js',dirname(__FILE__) ), array('jquery'));
|
13 |
-
|
14 |
-
if(is_admin())
|
15 |
-
{
|
16 |
-
$admin_css_rtl = false;
|
17 |
-
if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/admin.css")) {
|
18 |
-
$admin_css = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/admin.css";
|
19 |
-
if( is_rtl() && file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/admin-rtl.css") ) {
|
20 |
-
$admin_css_rtl = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/admin-rtl.css";
|
21 |
-
}
|
22 |
-
} elseif(file_exists(get_template_directory() . "/paid-memberships-pro/admin.css")) {
|
23 |
-
$admin_css = get_template_directory_uri() . "/paid-memberships-pro/admin.css";
|
24 |
-
if( is_rtl() && file_exists(get_template_directory() . "/paid-memberships-pro/css/admin-rtl.css") ) {
|
25 |
-
$admin_css_rtl = get_template_directory_uri() . "/paid-memberships-pro/css/admin-rtl.css";
|
26 |
-
}
|
27 |
-
} else {
|
28 |
-
$admin_css = plugins_url('css/admin.css',dirname(__FILE__) );
|
29 |
-
if( is_rtl() ) {
|
30 |
-
$admin_css_rtl = plugins_url('css/admin-rtl.css',dirname(__FILE__) );
|
31 |
-
}
|
32 |
-
}
|
33 |
-
wp_enqueue_style('pmpro_admin', $admin_css, array(), PMPRO_VERSION, "screen");
|
34 |
-
if( $admin_css_rtl ) {
|
35 |
-
wp_enqueue_style('pmpro_admin_rtl', $admin_css_rtl, array(), PMPRO_VERSION, "screen");
|
36 |
-
}
|
37 |
-
}
|
38 |
-
else
|
39 |
-
{
|
40 |
-
$frontend_css_rtl = false;
|
41 |
-
if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/frontend.css")) {
|
42 |
-
$frontend_css = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/frontend.css";
|
43 |
-
if( is_rtl() && file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/frontend-rtl.css") ) {
|
44 |
-
$frontend_css_rtl = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/frontend-rtl.css";
|
45 |
-
}
|
46 |
-
} elseif(file_exists(get_template_directory() . "/paid-memberships-pro/frontend.css")) {
|
47 |
-
$frontend_css = get_template_directory_uri() . "/paid-memberships-pro/frontend.css";
|
48 |
-
if( is_rtl() && file_exists(get_template_directory() . "/paid-memberships-pro/css/frontend-rtl.css") ) {
|
49 |
-
$frontend_css_rtl = get_template_directory_uri() . "/paid-memberships-pro/css/frontend-rtl.css";
|
50 |
-
}
|
51 |
-
} else {
|
52 |
-
$frontend_css = plugins_url('css/frontend.css',dirname(__FILE__) );
|
53 |
-
if( is_rtl() ) {
|
54 |
-
$frontend_css_rtl = plugins_url('css/frontend-rtl.css',dirname(__FILE__) );
|
55 |
-
}
|
56 |
-
}
|
57 |
-
wp_enqueue_style('pmpro_frontend', $frontend_css, array(), PMPRO_VERSION, "screen");
|
58 |
-
if( $frontend_css_rtl ) {
|
59 |
-
wp_enqueue_style('pmpro_frontend_rtl', $frontend_css_rtl, array(), PMPRO_VERSION, "screen");
|
60 |
-
}
|
61 |
-
|
62 |
-
if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/print.css"))
|
63 |
-
$print_css = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/print.css";
|
64 |
-
elseif(file_exists(get_template_directory() . "/paid-memberships-pro/print.css"))
|
65 |
-
$print_css = get_template_directory_uri() . "/paid-memberships-pro/print.css";
|
66 |
-
else
|
67 |
-
$print_css = plugins_url('css/print.css',dirname(__FILE__) );
|
68 |
-
wp_enqueue_style('pmpro_print', $print_css, array(), PMPRO_VERSION, "print");
|
69 |
-
}
|
70 |
-
|
71 |
-
global $pmpro_pages, $pmpro_ready, $pmpro_currency, $pmpro_currency_symbol;
|
72 |
-
$pmpro_pages = array();
|
73 |
-
$pmpro_pages["account"] = pmpro_getOption("account_page_id");
|
74 |
-
$pmpro_pages["billing"] = pmpro_getOption("billing_page_id");
|
75 |
-
$pmpro_pages["cancel"] = pmpro_getOption("cancel_page_id");
|
76 |
-
$pmpro_pages["checkout"] = pmpro_getOption("checkout_page_id");
|
77 |
-
$pmpro_pages["confirmation"] = pmpro_getOption("confirmation_page_id");
|
78 |
-
$pmpro_pages["invoice"] = pmpro_getOption("invoice_page_id");
|
79 |
-
$pmpro_pages["levels"] = pmpro_getOption("levels_page_id");
|
80 |
-
|
81 |
-
$pmpro_ready = pmpro_is_ready();
|
82 |
-
|
83 |
-
//set currency
|
84 |
-
$pmpro_currency = pmpro_getOption("currency");
|
85 |
-
if(!$pmpro_currency)
|
86 |
-
{
|
87 |
-
global $pmpro_default_currency;
|
88 |
-
$pmpro_currency = $pmpro_default_currency;
|
89 |
-
}
|
90 |
-
|
91 |
-
//figure out what symbol to show for currency
|
92 |
-
if(in_array($pmpro_currency, array("USD", "AUD", "BRL", "CAD", "HKD", "MXN", "NZD", "SGD")))
|
93 |
-
$pmpro_currency_symbol = "$";
|
94 |
-
elseif($pmpro_currency == "EUR")
|
95 |
-
$pmpro_currency_symbol = "€";
|
96 |
-
elseif($pmpro_currency == "GBP")
|
97 |
-
$pmpro_currency_symbol = "£";
|
98 |
-
elseif($pmpro_currency == "JPY")
|
99 |
-
$pmpro_currency_symbol = "¥";
|
100 |
-
else
|
101 |
-
$pmpro_currency_symbol = $pmpro_currency . " "; //just use the code
|
102 |
-
}
|
103 |
-
add_action("init", "pmpro_init");
|
104 |
-
|
105 |
-
//this code runs after $post is set, but before template output
|
106 |
-
function pmpro_wp()
|
107 |
-
{
|
108 |
-
if(!is_admin())
|
109 |
-
{
|
110 |
-
global $post, $pmpro_pages, $pmpro_page_name, $pmpro_page_id, $pmpro_body_classes;
|
111 |
-
|
112 |
-
//run the appropriate preheader function
|
113 |
-
foreach($pmpro_pages as $pmpro_page_name => $pmpro_page_id)
|
114 |
-
{
|
115 |
-
if(!empty($post->post_content) && strpos($post->post_content, "[pmpro_" . $pmpro_page_name . "]") !== false)
|
116 |
-
{
|
117 |
-
//preheader
|
118 |
-
require_once(PMPRO_DIR . "/preheaders/" . $pmpro_page_name . ".php");
|
119 |
-
|
120 |
-
//add class to body
|
121 |
-
$pmpro_body_classes[] = "pmpro-" . str_replace("_", "-", $pmpro_page_name);
|
122 |
-
|
123 |
-
//shortcode
|
124 |
-
function pmpro_pages_shortcode($atts, $content=null, $code="")
|
125 |
-
{
|
126 |
-
global $pmpro_page_name;
|
127 |
-
ob_start();
|
128 |
-
if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/pages/" . $pmpro_page_name . ".php"))
|
129 |
-
include(get_stylesheet_directory() . "/paid-memberships-pro/pages/" . $pmpro_page_name . ".php");
|
130 |
-
else
|
131 |
-
include(PMPRO_DIR . "/pages/" . $pmpro_page_name . ".php");
|
132 |
-
|
133 |
-
$temp_content = ob_get_contents();
|
134 |
-
ob_end_clean();
|
135 |
-
return apply_filters("pmpro_pages_shortcode_" . $pmpro_page_name, $temp_content);
|
136 |
-
}
|
137 |
-
add_shortcode("pmpro_" . $pmpro_page_name, "pmpro_pages_shortcode");
|
138 |
-
break; //only the first page found gets a shortcode replacement
|
139 |
-
}
|
140 |
-
}
|
141 |
-
}
|
142 |
-
}
|
143 |
-
add_action("wp", "pmpro_wp", 1);
|
144 |
-
|
145 |
-
/*
|
146 |
-
Add PMPro page names to the BODY class.
|
147 |
-
*/
|
148 |
-
function pmpro_body_class($classes)
|
149 |
-
{
|
150 |
-
global $pmpro_body_classes;
|
151 |
-
|
152 |
-
if(is_array($pmpro_body_classes))
|
153 |
-
$classes = array_merge($pmpro_body_classes, $classes);
|
154 |
-
|
155 |
-
return $classes;
|
156 |
-
}
|
157 |
-
add_filter("body_class", "pmpro_body_class");
|
158 |
-
|
159 |
-
//add membership level to current user object
|
160 |
-
function pmpro_set_current_user()
|
161 |
-
{
|
162 |
-
//this code runs at the beginning of the plugin
|
163 |
-
global $current_user, $wpdb;
|
164 |
-
get_currentuserinfo();
|
165 |
-
$id = intval($current_user->ID);
|
166 |
-
if($id)
|
167 |
-
{
|
168 |
-
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
|
169 |
-
if(!empty($current_user->membership_level))
|
170 |
-
{
|
171 |
-
$current_user->membership_level->categories = pmpro_getMembershipCategories($current_user->membership_level->ID);
|
172 |
-
}
|
173 |
-
$current_user->membership_levels = pmpro_getMembershipLevelsForUser($current_user->ID);
|
174 |
-
}
|
175 |
-
|
176 |
-
//hiding ads?
|
177 |
-
$hideads = pmpro_getOption("hideads");
|
178 |
-
$hideadslevels = pmpro_getOption("hideadslevels");
|
179 |
-
if(!is_array($hideadslevels))
|
180 |
-
$hideadslevels = explode(",", $hideadslevels);
|
181 |
-
if($hideads == 1 && pmpro_hasMembershipLevel() || $hideads == 2 && pmpro_hasMembershipLevel($hideadslevels))
|
182 |
-
{
|
183 |
-
//disable ads in ezAdsense
|
184 |
-
if(class_exists("ezAdSense"))
|
185 |
-
{
|
186 |
-
global $ezCount, $urCount;
|
187 |
-
$ezCount = 100;
|
188 |
-
$urCount = 100;
|
189 |
-
}
|
190 |
-
|
191 |
-
//disable ads in Easy Adsense (newer versions)
|
192 |
-
if(class_exists("EzAdSense"))
|
193 |
-
{
|
194 |
-
global $ezAdSense;
|
195 |
-
$ezAdSense->ezCount = 100;
|
196 |
-
$ezAdSense->urCount = 100;
|
197 |
-
}
|
198 |
-
|
199 |
-
//set a global variable to hide ads
|
200 |
-
global $pmpro_display_ads;
|
201 |
-
$pmpro_display_ads = false;
|
202 |
-
}
|
203 |
-
else
|
204 |
-
{
|
205 |
-
global $pmpro_display_ads;
|
206 |
-
$pmpro_display_ads = true;
|
207 |
-
}
|
208 |
-
|
209 |
-
do_action("pmpro_after_set_current_user");
|
210 |
-
}
|
211 |
-
add_action('set_current_user', 'pmpro_set_current_user');
|
212 |
-
add_action('init', 'pmpro_set_current_user');
|
213 |
-
|
214 |
-
/*
|
215 |
-
* Add Membership Level to Users page in WordPress dashboard.
|
216 |
-
*/
|
217 |
-
function pmpro_manage_users_columns($columns) {
|
218 |
-
$columns['pmpro_membership_level'] = __('Membership Level', 'pmpro');
|
219 |
-
return $columns;
|
220 |
-
}
|
221 |
-
|
222 |
-
function pmpro_manage_users_custom_column($column_data, $column_name, $user_id) {
|
223 |
-
|
224 |
-
if($column_name == 'pmpro_membership_level') {
|
225 |
-
$levels = pmpro_getMembershipLevelsForUser($user_id);
|
226 |
-
$level_names = array();
|
227 |
-
if(!empty($levels)) {
|
228 |
-
foreach($levels as $key => $level)
|
229 |
-
$level_names[] = $level->name;
|
230 |
-
$column_data = implode(',', $level_names);
|
231 |
-
}
|
232 |
-
else
|
233 |
-
$column_data = __('None', 'pmpro');
|
234 |
-
}
|
235 |
-
return $column_data;
|
236 |
-
}
|
237 |
-
|
238 |
-
add_filter('manage_users_columns', 'pmpro_manage_users_columns');
|
239 |
-
add_filter('manage_users_custom_column', 'pmpro_manage_users_custom_column', 10, 3);
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Collection.php
DELETED
@@ -1,159 +0,0 @@
|
|
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 |
-
class Braintree_Collection implements Countable, IteratorAggregate, ArrayAccess
|
22 |
-
{
|
23 |
-
/**
|
24 |
-
*
|
25 |
-
* @var array $_collection collection storage
|
26 |
-
*/
|
27 |
-
protected $_collection = array();
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Add a value into the collection
|
31 |
-
* @param string $value
|
32 |
-
*/
|
33 |
-
public function add($value)
|
34 |
-
{
|
35 |
-
$this->_collection[] = $value;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Set index's value
|
40 |
-
* @param integer $index
|
41 |
-
* @param mixed $value
|
42 |
-
* @throws OutOfRangeException
|
43 |
-
*/
|
44 |
-
public function set($index, $value)
|
45 |
-
{
|
46 |
-
if($index >= $this->count())
|
47 |
-
throw new OutOfRangeException('Index out of range');
|
48 |
-
|
49 |
-
$this->_collection[$index] = $value;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Remove a value from the collection
|
54 |
-
* @param integer $index index to remove
|
55 |
-
* @throws OutOfRangeException if index is out of range
|
56 |
-
*/
|
57 |
-
public function remove($index)
|
58 |
-
{
|
59 |
-
if($index >= $this->count())
|
60 |
-
throw new OutOfRangeException('Index out of range');
|
61 |
-
|
62 |
-
array_splice($this->_collection, $index, 1);
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Return value at index
|
67 |
-
* @param integer $index
|
68 |
-
* @return mixed
|
69 |
-
* @throws OutOfRangeException
|
70 |
-
*/
|
71 |
-
public function get($index)
|
72 |
-
{
|
73 |
-
if($index >= $this->count())
|
74 |
-
throw new OutOfRangeException('Index out of range');
|
75 |
-
|
76 |
-
return $this->_collection[$index];
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Determine if index exists
|
81 |
-
* @param integer $index
|
82 |
-
* @return boolean
|
83 |
-
*/
|
84 |
-
public function exists($index)
|
85 |
-
{
|
86 |
-
if($index >= $this->count())
|
87 |
-
return false;
|
88 |
-
|
89 |
-
return true;
|
90 |
-
}
|
91 |
-
/**
|
92 |
-
* Return count of items in collection
|
93 |
-
* Implements countable
|
94 |
-
* @return integer
|
95 |
-
*/
|
96 |
-
public function count()
|
97 |
-
{
|
98 |
-
return count($this->_collection);
|
99 |
-
}
|
100 |
-
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Return an iterator
|
104 |
-
* Implements IteratorAggregate
|
105 |
-
* @return ArrayIterator
|
106 |
-
*/
|
107 |
-
public function getIterator()
|
108 |
-
{
|
109 |
-
return new ArrayIterator($this->_collection);
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Set offset to value
|
114 |
-
* Implements ArrayAccess
|
115 |
-
* @see set
|
116 |
-
* @param integer $offset
|
117 |
-
* @param mixed $value
|
118 |
-
*/
|
119 |
-
public function offsetSet($offset, $value)
|
120 |
-
{
|
121 |
-
$this->set($offset, $value);
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Unset offset
|
126 |
-
* Implements ArrayAccess
|
127 |
-
* @see remove
|
128 |
-
* @param integer $offset
|
129 |
-
*/
|
130 |
-
public function offsetUnset($offset)
|
131 |
-
{
|
132 |
-
$this->remove($offset);
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* get an offset's value
|
137 |
-
* Implements ArrayAccess
|
138 |
-
* @see get
|
139 |
-
* @param integer $offset
|
140 |
-
* @return mixed
|
141 |
-
*/
|
142 |
-
public function offsetGet($offset)
|
143 |
-
{
|
144 |
-
return $this->get($offset);
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Determine if offset exists
|
149 |
-
* Implements ArrayAccess
|
150 |
-
* @see exists
|
151 |
-
* @param integer $offset
|
152 |
-
* @return boolean
|
153 |
-
*/
|
154 |
-
public function offsetExists($offset)
|
155 |
-
{
|
156 |
-
return $this->exists($offset);
|
157 |
-
}
|
158 |
-
|
159 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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('mY', $startDate) . '&end=' . date('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('mY', $startDate) . '&end=' . date('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/Digest.php
DELETED
@@ -1,59 +0,0 @@
|
|
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 2010 Braintree Payment Solutions
|
12 |
-
*/
|
13 |
-
class Braintree_Digest
|
14 |
-
{
|
15 |
-
public static function hexDigest($string)
|
16 |
-
{
|
17 |
-
if(function_exists('hash_hmac')) {
|
18 |
-
return self::_builtInHmacSha1($string, Braintree_Configuration::privateKey());
|
19 |
-
} else {
|
20 |
-
return self::_hmacSha1($string, Braintree_Configuration::privateKey());
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
public static function secureCompare($left, $right)
|
25 |
-
{
|
26 |
-
if (strlen($left) != strlen($right)) {
|
27 |
-
return false;
|
28 |
-
}
|
29 |
-
|
30 |
-
$leftBytes = unpack("C*", $left);
|
31 |
-
$rightBytes = unpack("C*", $right);
|
32 |
-
|
33 |
-
$result = 0;
|
34 |
-
for ($i = 0; $i < strlen($left); $i++) {
|
35 |
-
$result = $result | ($left[$i] ^ $right[$i]);
|
36 |
-
}
|
37 |
-
return $result == 0;
|
38 |
-
}
|
39 |
-
|
40 |
-
public static function _builtInHmacSha1($message, $key)
|
41 |
-
{
|
42 |
-
return hash_hmac('sha1', $message, sha1(Braintree_Configuration::privateKey(), true));
|
43 |
-
}
|
44 |
-
|
45 |
-
public static function _hmacSha1($message, $key)
|
46 |
-
{
|
47 |
-
$pack = 'H40';
|
48 |
-
$keyDigest = sha1($key,true);
|
49 |
-
$innerPad = str_repeat(chr(0x36), 64);
|
50 |
-
$outerPad = str_repeat(chr(0x5C), 64);
|
51 |
-
|
52 |
-
for ($i = 0; $i < 20; $i++) {
|
53 |
-
$innerPad{$i} = $keyDigest{$i} ^ $innerPad{$i};
|
54 |
-
$outerPad{$i} = $keyDigest{$i} ^ $outerPad{$i};
|
55 |
-
}
|
56 |
-
|
57 |
-
return sha1($outerPad.pack($pack, sha1($innerPad.$message)));
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/EqualityNode.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Braintree_EqualityNode extends Braintree_IsNode
|
4 |
-
{
|
5 |
-
function isNot($value)
|
6 |
-
{
|
7 |
-
$this->searchTerms['is_not'] = strval($value);
|
8 |
-
return $this;
|
9 |
-
}
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Error/ErrorCollection.php
DELETED
@@ -1,118 +0,0 @@
|
|
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
|
17 |
-
*
|
18 |
-
* @package Braintree
|
19 |
-
* @subpackage Errors
|
20 |
-
* @category Errors
|
21 |
-
* @copyright 2010 Braintree Payment Solutions
|
22 |
-
*
|
23 |
-
* @property-read object $errors
|
24 |
-
*/
|
25 |
-
class Braintree_Error_ErrorCollection
|
26 |
-
{
|
27 |
-
private $_errors;
|
28 |
-
|
29 |
-
public function __construct($errorData)
|
30 |
-
{
|
31 |
-
$this->_errors =
|
32 |
-
new Braintree_Error_ValidationErrorCollection($errorData);
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Returns all of the validation errors at all levels of nesting in a single, flat array.
|
38 |
-
*/
|
39 |
-
public function deepAll()
|
40 |
-
{
|
41 |
-
return $this->_errors->deepAll();
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Returns the total number of validation errors at all levels of nesting. For example,
|
46 |
-
*if creating a customer with a credit card and a billing address, and each of the customer,
|
47 |
-
* credit card, and billing address has 1 error, this method will return 3.
|
48 |
-
*
|
49 |
-
* @return int size
|
50 |
-
*/
|
51 |
-
public function deepSize()
|
52 |
-
{
|
53 |
-
$size = $this->_errors->deepSize();
|
54 |
-
return $size;
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* return errors for the passed key name
|
59 |
-
*
|
60 |
-
* @param string $key
|
61 |
-
* @return mixed
|
62 |
-
*/
|
63 |
-
public function forKey($key)
|
64 |
-
{
|
65 |
-
return $this->_errors->forKey($key);
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* return errors for the passed html field.
|
70 |
-
* For example, $result->errors->onHtmlField("transaction[customer][last_name]")
|
71 |
-
*
|
72 |
-
* @param string $field
|
73 |
-
* @return array
|
74 |
-
*/
|
75 |
-
public function onHtmlField($field)
|
76 |
-
{
|
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(Braintree_Util::delimiterToCamelCase($key));
|
81 |
-
if (!isset($errors)) { return array(); }
|
82 |
-
}
|
83 |
-
$finalKey = Braintree_Util::delimiterToCamelCase(end($pieces));
|
84 |
-
return $errors->onAttribute($finalKey);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Returns the errors at the given nesting level (see forKey) in a single, flat array:
|
89 |
-
*
|
90 |
-
* <code>
|
91 |
-
* $result = Braintree_Customer::create(...);
|
92 |
-
* $customerErrors = $result->errors->forKey('customer')->shallowAll();
|
93 |
-
* </code>
|
94 |
-
*/
|
95 |
-
public function shallowAll()
|
96 |
-
{
|
97 |
-
return $this->_errors->shallowAll();
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
*
|
102 |
-
* @ignore
|
103 |
-
*/
|
104 |
-
public function __get($name)
|
105 |
-
{
|
106 |
-
$varName = "_$name";
|
107 |
-
return isset($this->$varName) ? $this->$varName : null;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
*
|
112 |
-
* @ignore
|
113 |
-
*/
|
114 |
-
public function __toString()
|
115 |
-
{
|
116 |
-
return sprintf('%s', $this->_errors);
|
117 |
-
}
|
118 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Error/Validation.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* error object returned as part of a validation error collection
|
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
|
12 |
-
* provides read-only access to $attribute, $code, and $message
|
13 |
-
*
|
14 |
-
* <b>== More information ==</b>
|
15 |
-
*
|
16 |
-
* For more detailed information on Validation errors, see {@link http://www.braintreepayments.com/gateway/validation-errors http://www.braintreepaymentsolutions.com/gateway/validation-errors}
|
17 |
-
*
|
18 |
-
* @package Braintree
|
19 |
-
* @subpackage Error
|
20 |
-
* @copyright 2010 Braintree Payment Solutions
|
21 |
-
*
|
22 |
-
* @property-read string $attribute
|
23 |
-
* @property-read string $code
|
24 |
-
* @property-read string $message
|
25 |
-
*/
|
26 |
-
class Braintree_Error_Validation
|
27 |
-
{
|
28 |
-
private $_attribute;
|
29 |
-
private $_code;
|
30 |
-
private $_message;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @ignore
|
34 |
-
* @param array $attributes
|
35 |
-
*/
|
36 |
-
public function __construct($attributes)
|
37 |
-
{
|
38 |
-
$this->_initializeFromArray($attributes);
|
39 |
-
}
|
40 |
-
/**
|
41 |
-
* initializes instance properties from the keys/values of an array
|
42 |
-
* @ignore
|
43 |
-
* @access protected
|
44 |
-
* @param array $attributes array of properties to set - single level
|
45 |
-
* @return none
|
46 |
-
*/
|
47 |
-
private function _initializeFromArray($attributes)
|
48 |
-
{
|
49 |
-
foreach($attributes AS $name => $value) {
|
50 |
-
$varName = "_$name";
|
51 |
-
$this->$varName = Braintree_Util::delimiterToCamelCase($value, '_');
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
*
|
57 |
-
* @ignore
|
58 |
-
*/
|
59 |
-
public function __get($name)
|
60 |
-
{
|
61 |
-
$varName = "_$name";
|
62 |
-
return isset($this->$varName) ? $this->$varName : null;
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Error/ValidationErrorCollection.php
DELETED
@@ -1,135 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* collection of errors enumerating all validation errors for a given request
|
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
|
12 |
-
*
|
13 |
-
* <b>== More information ==</b>
|
14 |
-
*
|
15 |
-
* For more detailed information on Validation errors, see {@link http://www.braintreepayments.com/gateway/validation-errors http://www.braintreepaymentsolutions.com/gateway/validation-errors}
|
16 |
-
*
|
17 |
-
* @package Braintree
|
18 |
-
* @subpackage Error
|
19 |
-
* @copyright 2010 Braintree Payment Solutions
|
20 |
-
*
|
21 |
-
* @property-read array $errors
|
22 |
-
* @property-read array $nested
|
23 |
-
*/
|
24 |
-
class Braintree_Error_ValidationErrorCollection extends Braintree_Collection
|
25 |
-
{
|
26 |
-
private $_errors = array();
|
27 |
-
private $_nested = array();
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @ignore
|
31 |
-
*/
|
32 |
-
public function __construct($data)
|
33 |
-
{
|
34 |
-
foreach($data AS $key => $errorData)
|
35 |
-
// map errors to new collections recursively
|
36 |
-
if ($key == 'errors') {
|
37 |
-
foreach ($errorData AS $error) {
|
38 |
-
$this->_errors[] = new Braintree_Error_Validation($error);
|
39 |
-
}
|
40 |
-
} else {
|
41 |
-
$this->_nested[$key] = new Braintree_Error_ValidationErrorCollection($errorData);
|
42 |
-
}
|
43 |
-
|
44 |
-
}
|
45 |
-
|
46 |
-
public function deepAll()
|
47 |
-
{
|
48 |
-
$validationErrors = array_merge(array(), $this->_errors);
|
49 |
-
foreach($this->_nested as $nestedErrors)
|
50 |
-
{
|
51 |
-
$validationErrors = array_merge($validationErrors, $nestedErrors->deepAll());
|
52 |
-
}
|
53 |
-
return $validationErrors;
|
54 |
-
}
|
55 |
-
|
56 |
-
public function deepSize()
|
57 |
-
{
|
58 |
-
$total = sizeof($this->_errors);
|
59 |
-
foreach($this->_nested as $_nestedErrors)
|
60 |
-
{
|
61 |
-
$total = $total + $_nestedErrors->deepSize();
|
62 |
-
}
|
63 |
-
return $total;
|
64 |
-
}
|
65 |
-
|
66 |
-
public function forIndex($index)
|
67 |
-
{
|
68 |
-
return $this->forKey("index" . $index);
|
69 |
-
}
|
70 |
-
|
71 |
-
public function forKey($key)
|
72 |
-
{
|
73 |
-
return isset($this->_nested[$key]) ? $this->_nested[$key] : null;
|
74 |
-
}
|
75 |
-
|
76 |
-
public function onAttribute($attribute)
|
77 |
-
{
|
78 |
-
$matches = array();
|
79 |
-
foreach ($this->_errors AS $key => $error) {
|
80 |
-
if($error->attribute == $attribute) {
|
81 |
-
$matches[] = $error;
|
82 |
-
}
|
83 |
-
}
|
84 |
-
return $matches;
|
85 |
-
}
|
86 |
-
|
87 |
-
|
88 |
-
public function shallowAll()
|
89 |
-
{
|
90 |
-
return $this->_errors;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
*
|
95 |
-
* @ignore
|
96 |
-
*/
|
97 |
-
public function __get($name)
|
98 |
-
{
|
99 |
-
$varName = "_$name";
|
100 |
-
return isset($this->$varName) ? $this->$varName : null;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* @ignore
|
105 |
-
*/
|
106 |
-
public function __toString()
|
107 |
-
{
|
108 |
-
$output = array();
|
109 |
-
|
110 |
-
// TODO: implement scope
|
111 |
-
if (!empty($this->_errors)) {
|
112 |
-
$output[] = $this->_inspect($this->_errors);
|
113 |
-
}
|
114 |
-
if (!empty($this->_nested)) {
|
115 |
-
foreach ($this->_nested AS $key => $values) {
|
116 |
-
$output[] = $this->_inspect($this->_nested);
|
117 |
-
}
|
118 |
-
}
|
119 |
-
return join(', ', $output);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* @ignore
|
124 |
-
*/
|
125 |
-
private function _inspect($errors, $scope = null)
|
126 |
-
{
|
127 |
-
$eOutput = '[' . __CLASS__ . '/errors:[';
|
128 |
-
foreach($errors AS $error => $errorObj) {
|
129 |
-
$outputErrs[] = "({$errorObj->error['code']} {$errorObj->error['message']})";
|
130 |
-
}
|
131 |
-
$eOutput .= join(', ', $outputErrs) . ']]';
|
132 |
-
|
133 |
-
return $eOutput;
|
134 |
-
}
|
135 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Authorization.php
DELETED
@@ -1,23 +0,0 @@
|
|
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 2010 Braintree Payment Solutions
|
19 |
-
*/
|
20 |
-
class Braintree_Exception_Authorization extends Braintree_Exception
|
21 |
-
{
|
22 |
-
|
23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Instance.php
DELETED
@@ -1,70 +0,0 @@
|
|
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 |
-
* abstract instance template for various objects
|
12 |
-
*
|
13 |
-
* @package Braintree
|
14 |
-
* @subpackage Utility
|
15 |
-
* @copyright 2010 Braintree Payment Solutions
|
16 |
-
* @abstract
|
17 |
-
*/
|
18 |
-
abstract class Braintree_Instance
|
19 |
-
{
|
20 |
-
/**
|
21 |
-
*
|
22 |
-
* @param array $aAttribs
|
23 |
-
*/
|
24 |
-
public function __construct($attributes)
|
25 |
-
{
|
26 |
-
if (!empty($attributes)) {
|
27 |
-
$this->_initializeFromArray($attributes);
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
/**
|
33 |
-
* returns private/nonexistent instance properties
|
34 |
-
* @access public
|
35 |
-
* @param var $name property name
|
36 |
-
* @return mixed contents of instance properties
|
37 |
-
*/
|
38 |
-
public function __get($name)
|
39 |
-
{
|
40 |
-
if (array_key_exists($name, $this->_attributes)) {
|
41 |
-
return $this->_attributes[$name];
|
42 |
-
} else {
|
43 |
-
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
|
44 |
-
return null;
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* create a printable representation of the object as:
|
50 |
-
* ClassName[property=value, property=value]
|
51 |
-
* @return var
|
52 |
-
*/
|
53 |
-
public function __toString()
|
54 |
-
{
|
55 |
-
$objOutput = Braintree_Util::implodeAssociativeArray($this->_attributes);
|
56 |
-
return get_class($this) .'['.$objOutput.']';
|
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 none
|
64 |
-
*/
|
65 |
-
private function _initializeFromArray($attributes)
|
66 |
-
{
|
67 |
-
$this->_attributes = $attributes;
|
68 |
-
}
|
69 |
-
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/KeyValueNode.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Braintree_KeyValueNode
|
4 |
-
{
|
5 |
-
function __construct($name)
|
6 |
-
{
|
7 |
-
$this->name = $name;
|
8 |
-
$this->searchTerm = True;
|
9 |
-
|
10 |
-
}
|
11 |
-
|
12 |
-
function is($value)
|
13 |
-
{
|
14 |
-
$this->searchTerm = $value;
|
15 |
-
return $this;
|
16 |
-
}
|
17 |
-
|
18 |
-
function toParam()
|
19 |
-
{
|
20 |
-
return $this->searchTerm;
|
21 |
-
}
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/MultipleValueNode.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Braintree_MultipleValueNode
|
4 |
-
{
|
5 |
-
function __construct($name, $allowedValues = array())
|
6 |
-
{
|
7 |
-
$this->name = $name;
|
8 |
-
$this->items = array();
|
9 |
-
$this->allowedValues = $allowedValues;
|
10 |
-
}
|
11 |
-
|
12 |
-
function in($values)
|
13 |
-
{
|
14 |
-
$bad_values = array_diff($values, $this->allowedValues);
|
15 |
-
if (count($this->allowedValues) > 0 && count($bad_values) > 0) {
|
16 |
-
$message = 'Invalid argument(s) for ' . $this->name . ':';
|
17 |
-
foreach ($bad_values AS $bad_value) {
|
18 |
-
$message .= ' ' . $bad_value;
|
19 |
-
}
|
20 |
-
|
21 |
-
throw new InvalidArgumentException($message);
|
22 |
-
}
|
23 |
-
|
24 |
-
$this->items = $values;
|
25 |
-
return $this;
|
26 |
-
}
|
27 |
-
|
28 |
-
function is($value)
|
29 |
-
{
|
30 |
-
return $this->in(array($value));
|
31 |
-
}
|
32 |
-
|
33 |
-
function toParam()
|
34 |
-
{
|
35 |
-
return $this->items;
|
36 |
-
}
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/MultipleValueOrTextNode.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Braintree_MultipleValueOrTextNode extends Braintree_MultipleValueNode
|
4 |
-
{
|
5 |
-
function __construct($name)
|
6 |
-
{
|
7 |
-
parent::__construct($name);
|
8 |
-
$this->textNode = new Braintree_TextNode($name);
|
9 |
-
}
|
10 |
-
|
11 |
-
function contains($value)
|
12 |
-
{
|
13 |
-
$this->textNode->contains($value);
|
14 |
-
return $this;
|
15 |
-
}
|
16 |
-
|
17 |
-
function endsWith($value)
|
18 |
-
{
|
19 |
-
$this->textNode->endsWith($value);
|
20 |
-
return $this;
|
21 |
-
}
|
22 |
-
|
23 |
-
function is($value)
|
24 |
-
{
|
25 |
-
$this->textNode->is($value);
|
26 |
-
return $this;
|
27 |
-
}
|
28 |
-
|
29 |
-
function isNot($value)
|
30 |
-
{
|
31 |
-
$this->textNode->isNot($value);
|
32 |
-
return $this;
|
33 |
-
}
|
34 |
-
|
35 |
-
function startsWith($value)
|
36 |
-
{
|
37 |
-
$this->textNode->startsWith($value);
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
|
41 |
-
function toParam()
|
42 |
-
{
|
43 |
-
return array_merge(parent::toParam(), $this->textNode->toParam());
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Plan.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Braintree_Plan extends Braintree
|
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();
|
22 |
-
$instance->_initialize($attributes);
|
23 |
-
|
24 |
-
return $instance;
|
25 |
-
}
|
26 |
-
|
27 |
-
protected function _initialize($attributes)
|
28 |
-
{
|
29 |
-
$this->_attributes = $attributes;
|
30 |
-
|
31 |
-
$addOnArray = array();
|
32 |
-
if (isset($attributes['addOns'])) {
|
33 |
-
foreach ($attributes['addOns'] AS $addOn) {
|
34 |
-
$addOnArray[] = Braintree_AddOn::factory($addOn);
|
35 |
-
}
|
36 |
-
}
|
37 |
-
$this->_attributes['addOns'] = $addOnArray;
|
38 |
-
|
39 |
-
$discountArray = array();
|
40 |
-
if (isset($attributes['discounts'])) {
|
41 |
-
foreach ($attributes['discounts'] AS $discount) {
|
42 |
-
$discountArray[] = Braintree_Discount::factory($discount);
|
43 |
-
}
|
44 |
-
}
|
45 |
-
$this->_attributes['discounts'] = $discountArray;
|
46 |
-
|
47 |
-
$planArray = array();
|
48 |
-
if (isset($attributes['plans'])) {
|
49 |
-
foreach ($attributes['plans'] AS $plan) {
|
50 |
-
$planArray[] = Braintree_Plan::factory($plan);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
$this->_attributes['plans'] = $planArray;
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/RangeNode.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Braintree_RangeNode
|
4 |
-
{
|
5 |
-
function __construct($name)
|
6 |
-
{
|
7 |
-
$this->name = $name;
|
8 |
-
$this->searchTerms = array();
|
9 |
-
}
|
10 |
-
|
11 |
-
function greaterThanOrEqualTo($value)
|
12 |
-
{
|
13 |
-
$this->searchTerms['min'] = $value;
|
14 |
-
return $this;
|
15 |
-
}
|
16 |
-
|
17 |
-
function lessThanOrEqualTo($value)
|
18 |
-
{
|
19 |
-
$this->searchTerms['max'] = $value;
|
20 |
-
return $this;
|
21 |
-
}
|
22 |
-
|
23 |
-
function is($value)
|
24 |
-
{
|
25 |
-
$this->searchTerms['is'] = $value;
|
26 |
-
return $this;
|
27 |
-
}
|
28 |
-
|
29 |
-
function between($min, $max)
|
30 |
-
{
|
31 |
-
return $this->greaterThanOrEqualTo($min)->lessThanOrEqualTo($max);
|
32 |
-
}
|
33 |
-
|
34 |
-
function toParam()
|
35 |
-
{
|
36 |
-
return $this->searchTerms;
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/ResourceCollection.php
DELETED
@@ -1,148 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree ResourceCollection
|
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 = Braintree_Customer::all();
|
18 |
-
*
|
19 |
-
* foreach($result as $transaction) {
|
20 |
-
* print_r($transaction->id);
|
21 |
-
* }
|
22 |
-
* </code>
|
23 |
-
*
|
24 |
-
* @package Braintree
|
25 |
-
* @subpackage Utility
|
26 |
-
* @copyright 2010 Braintree Payment Solutions
|
27 |
-
*/
|
28 |
-
class Braintree_ResourceCollection implements Iterator
|
29 |
-
{
|
30 |
-
private $_index;
|
31 |
-
private $_batchIndex;
|
32 |
-
private $_items;
|
33 |
-
private $_pageSize;
|
34 |
-
private $_pager;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* set up the resource collection
|
38 |
-
*
|
39 |
-
* expects an array of attributes with literal keys
|
40 |
-
*
|
41 |
-
* @param array $attributes
|
42 |
-
* @param array $pagerAttribs
|
43 |
-
*/
|
44 |
-
public function __construct($response, $pager)
|
45 |
-
{
|
46 |
-
$this->_pageSize = $response["searchResults"]["pageSize"];
|
47 |
-
$this->_ids = $response["searchResults"]["ids"];
|
48 |
-
$this->_pager = $pager;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* returns the current item when iterating with foreach
|
53 |
-
*/
|
54 |
-
public function current()
|
55 |
-
{
|
56 |
-
return $this->_items[$this->_index];
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* returns the first item in the collection
|
61 |
-
*
|
62 |
-
* @return mixed
|
63 |
-
*/
|
64 |
-
public function firstItem()
|
65 |
-
{
|
66 |
-
$ids = $this->_ids;
|
67 |
-
$page = $this->_getPage(array($ids[0]));
|
68 |
-
return $page[0];
|
69 |
-
}
|
70 |
-
|
71 |
-
public function key()
|
72 |
-
{
|
73 |
-
return null;
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* advances to the next item in the collection when iterating with foreach
|
78 |
-
*/
|
79 |
-
public function next()
|
80 |
-
{
|
81 |
-
++$this->_index;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* rewinds thtestIterateOverResultse collection to the first item when iterating with foreach
|
86 |
-
*/
|
87 |
-
public function rewind()
|
88 |
-
{
|
89 |
-
$this->_batchIndex = 0;
|
90 |
-
$this->_getNextPage();
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* returns whether the current item is valid when iterating with foreach
|
95 |
-
*/
|
96 |
-
public function valid()
|
97 |
-
{
|
98 |
-
if ($this->_index == count($this->_items) && $this->_batchIndex < count($this->_ids)) {
|
99 |
-
$this->_getNextPage();
|
100 |
-
}
|
101 |
-
|
102 |
-
if ($this->_index < count($this->_items)) {
|
103 |
-
return true;
|
104 |
-
} else {
|
105 |
-
return false;
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
public function maximumCount()
|
110 |
-
{
|
111 |
-
return count($this->_ids);
|
112 |
-
}
|
113 |
-
|
114 |
-
private function _getNextPage()
|
115 |
-
{
|
116 |
-
if (empty($this->_ids))
|
117 |
-
{
|
118 |
-
$this->_items = array();
|
119 |
-
}
|
120 |
-
else
|
121 |
-
{
|
122 |
-
$this->_items = $this->_getPage(array_slice($this->_ids, $this->_batchIndex, $this->_pageSize));
|
123 |
-
$this->_batchIndex += $this->_pageSize;
|
124 |
-
$this->_index = 0;
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* requests the next page of results for the collection
|
130 |
-
*
|
131 |
-
* @return none
|
132 |
-
*/
|
133 |
-
private function _getPage($ids)
|
134 |
-
{
|
135 |
-
$className = $this->_pager['className'];
|
136 |
-
$classMethod = $this->_pager['classMethod'];
|
137 |
-
$methodArgs = array();
|
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 |
-
array($className, $classMethod),
|
145 |
-
$methodArgs
|
146 |
-
);
|
147 |
-
}
|
148 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Result/CreditCardVerification.php
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree Credit Card Verification Result
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Result
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Braintree Credit Card Verification Result
|
12 |
-
*
|
13 |
-
* This object is returned as part of an Error Result; it provides
|
14 |
-
* access to the credit card verification data from the gateway
|
15 |
-
*
|
16 |
-
*
|
17 |
-
* @package Braintree
|
18 |
-
* @subpackage Result
|
19 |
-
* @copyright 2010 Braintree Payment Solutions
|
20 |
-
*
|
21 |
-
* @property-read string $avsErrorResponseCode
|
22 |
-
* @property-read string $avsPostalCodeResponseCode
|
23 |
-
* @property-read string $avsStreetAddressResponseCode
|
24 |
-
* @property-read string $cvvResponseCode
|
25 |
-
* @property-read string $status
|
26 |
-
*
|
27 |
-
*/
|
28 |
-
class Braintree_Result_CreditCardVerification
|
29 |
-
{
|
30 |
-
// Status
|
31 |
-
const FAILED = 'failed';
|
32 |
-
const GATEWAY_REJECTED = 'gateway_rejected';
|
33 |
-
const PROCESSOR_DECLINED = 'processor_declined';
|
34 |
-
const VERIFIED = 'verified';
|
35 |
-
|
36 |
-
private $_attributes;
|
37 |
-
private $_avsErrorResponseCode;
|
38 |
-
private $_avsPostalCodeResponseCode;
|
39 |
-
private $_avsStreetAddressResponseCode;
|
40 |
-
private $_cvvResponseCode;
|
41 |
-
private $_gatewayRejectionReason;
|
42 |
-
private $_status;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @ignore
|
46 |
-
*/
|
47 |
-
public function __construct($attributes)
|
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 none
|
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)
|
72 |
-
{
|
73 |
-
$varName = "_$name";
|
74 |
-
return isset($this->$varName) ? $this->$varName : null;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* returns a string representation of the customer
|
79 |
-
* @return string
|
80 |
-
*/
|
81 |
-
public function __toString()
|
82 |
-
{
|
83 |
-
return __CLASS__ . '[' .
|
84 |
-
Braintree_Util::attributesToString($this->_attributes) .']';
|
85 |
-
}
|
86 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Result/Error.php
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Braintree Error Result
|
4 |
-
*
|
5 |
-
* @package Braintree
|
6 |
-
* @subpackage Result
|
7 |
-
* @copyright 2010 Braintree Payment Solutions
|
8 |
-
*/
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Braintree Error Result
|
12 |
-
*
|
13 |
-
* An Error Result will be returned from gateway methods when
|
14 |
-
* the gateway responds with an error. It will provide access
|
15 |
-
* to the original request.
|
16 |
-
* For example, when voiding a transaction, Error Result will
|
17 |
-
* respond to the void request if it failed:
|
18 |
-
*
|
19 |
-
* <code>
|
20 |
-
* $result = Braintree_Transaction::void('abc123');
|
21 |
-
* if ($result->success) {
|
22 |
-
* // Successful Result
|
23 |
-
* } else {
|
24 |
-
* // Braintree_Result_Error
|
25 |
-
* }
|
26 |
-
* </code>
|
27 |
-
*
|
28 |
-
* @package Braintree
|
29 |
-
* @subpackage Result
|
30 |
-
* @copyright 2010 Braintree Payment Solutions
|
31 |
-
*
|
32 |
-
* @property-read array $params original passed params
|
33 |
-
* @property-read object $errors Braintree_Error_ErrorCollection
|
34 |
-
* @property-read object $creditCardVerification credit card verification data
|
35 |
-
*/
|
36 |
-
class Braintree_Result_Error extends Braintree
|
37 |
-
{
|
38 |
-
/**
|
39 |
-
*
|
40 |
-
* @var boolean always false
|
41 |
-
*/
|
42 |
-
public $success = false;
|
43 |
-
|
44 |
-
/**
|
45 |
-
* return original value for a field
|
46 |
-
* For example, if a user tried to submit 'invalid-email' in the html field transaction[customer][email],
|
47 |
-
* $result->valueForHtmlField("transaction[customer][email]") would yield "invalid-email"
|
48 |
-
*
|
49 |
-
* @param string $field
|
50 |
-
* @return string
|
51 |
-
*/
|
52 |
-
public function valueForHtmlField($field)
|
53 |
-
{
|
54 |
-
$pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY);
|
55 |
-
$params = $this->params;
|
56 |
-
foreach(array_slice($pieces, 0, -1) as $key) {
|
57 |
-
$params = $params[Braintree_Util::delimiterToCamelCase($key)];
|
58 |
-
}
|
59 |
-
$finalKey = Braintree_Util::delimiterToCamelCase(end($pieces));
|
60 |
-
$fieldValue = isset($params[$finalKey]) ? $params[$finalKey] : null;
|
61 |
-
return $fieldValue;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* overrides default constructor
|
66 |
-
* @ignore
|
67 |
-
* @param array $response gateway response array
|
68 |
-
*/
|
69 |
-
public function __construct($response)
|
70 |
-
{
|
71 |
-
$this->_attributes = $response;
|
72 |
-
$this->_set('errors', new Braintree_Error_ErrorCollection($response['errors']));
|
73 |
-
|
74 |
-
if(isset($response['verification'])) {
|
75 |
-
$this->_set('creditCardVerification', new Braintree_Result_CreditCardVerification($response['verification']));
|
76 |
-
} else {
|
77 |
-
$this->_set('creditCardVerification', null);
|
78 |
-
}
|
79 |
-
|
80 |
-
if(isset($response['transaction'])) {
|
81 |
-
$this->_set('transaction', Braintree_Transaction::factory($response['transaction']));
|
82 |
-
} else {
|
83 |
-
$this->_set('transaction', null);
|
84 |
-
}
|
85 |
-
|
86 |
-
if(isset($response['subscription'])) {
|
87 |
-
$this->_set('subscription', Braintree_Subscription::factory($response['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 var
|
98 |
-
*/
|
99 |
-
public function __toString()
|
100 |
-
{
|
101 |
-
$output = Braintree_Util::attributesToString($this->_attributes);
|
102 |
-
if (isset($this->_creditCardVerification)) {
|
103 |
-
$output .= sprintf('%s', $this->_creditCardVerification);
|
104 |
-
}
|
105 |
-
return __CLASS__ .'['.$output.']';
|
106 |
-
}
|
107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Test/CreditCardNumbers.php
DELETED
@@ -1,76 +0,0 @@
|
|
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 Braintree_Test_CreditCardNumbers class provide
|
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 2010 Braintree Payment Solutions
|
20 |
-
*/
|
21 |
-
class Braintree_Test_CreditCardNumbers
|
22 |
-
{
|
23 |
-
public static $amExes = array(
|
24 |
-
'378282246310005',
|
25 |
-
'371449635398431',
|
26 |
-
'378734493671000',
|
27 |
-
);
|
28 |
-
public static $carteBlanches = array('30569309025904',);
|
29 |
-
public static $dinersClubs = array('38520000023237',);
|
30 |
-
public static $discoverCards = array(
|
31 |
-
'6011111111111117',
|
32 |
-
'6011000990139424',
|
33 |
-
);
|
34 |
-
public static $JCBs = array(
|
35 |
-
'3530111333300000',
|
36 |
-
'3566002020360505',
|
37 |
-
);
|
38 |
-
|
39 |
-
public static $masterCard = '5555555555554444';
|
40 |
-
public static $masterCardInternational = '5105105105105100';
|
41 |
-
public static $masterCards = array(
|
42 |
-
'5105105105105100',
|
43 |
-
'5555555555554444',
|
44 |
-
);
|
45 |
-
|
46 |
-
public static $visa = '4012888888881881';
|
47 |
-
public static $visaInternational = '4009348888881881';
|
48 |
-
public static $visas = array(
|
49 |
-
'4009348888881881',
|
50 |
-
'4012888888881881',
|
51 |
-
'4111111111111111',
|
52 |
-
'4000111111111115',
|
53 |
-
);
|
54 |
-
|
55 |
-
public static $unknowns = array(
|
56 |
-
'1000000000000008',
|
57 |
-
);
|
58 |
-
|
59 |
-
public static $failsSandboxVerification = array(
|
60 |
-
'AmEx' => '378734493671000',
|
61 |
-
'Discover' => '6011000990139424',
|
62 |
-
'MasterCard' => '5105105105105100',
|
63 |
-
'Visa' => '4000111111111115',
|
64 |
-
);
|
65 |
-
|
66 |
-
|
67 |
-
public static function getAll()
|
68 |
-
{
|
69 |
-
return array_merge(
|
70 |
-
self::$amExes,
|
71 |
-
self::$discoverCards,
|
72 |
-
self::$masterCards,
|
73 |
-
self::$visas
|
74 |
-
);
|
75 |
-
}
|
76 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Test/TransactionAmounts.php
DELETED
@@ -1,24 +0,0 @@
|
|
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
|
12 |
-
*
|
13 |
-
* The constants in this class can be used to create transactions with
|
14 |
-
* the desired status in the sandbox environment.
|
15 |
-
*
|
16 |
-
* @package Braintree
|
17 |
-
* @subpackage Test
|
18 |
-
* @copyright 2010 Braintree Payment Solutions
|
19 |
-
*/
|
20 |
-
class Braintree_Test_TransactionAmounts
|
21 |
-
{
|
22 |
-
public static $authorize = '1000.00';
|
23 |
-
public static $decline = '2000.00';
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Transaction/AddressDetails.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Address details from a transaction
|
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
|
12 |
-
*
|
13 |
-
*
|
14 |
-
* @package Braintree
|
15 |
-
* @subpackage Transaction
|
16 |
-
* @copyright 2010 Braintree Payment Solutions
|
17 |
-
*
|
18 |
-
* @property-read string $firstName
|
19 |
-
* @property-read string $lastName
|
20 |
-
* @property-read string $company
|
21 |
-
* @property-read string $streetAddress
|
22 |
-
* @property-read string $extendedAddress
|
23 |
-
* @property-read string $locality
|
24 |
-
* @property-read string $region
|
25 |
-
* @property-read string $postalCode
|
26 |
-
* @property-read string $countryName
|
27 |
-
* @uses Braintree_Instance inherits methods
|
28 |
-
*/
|
29 |
-
class Braintree_Transaction_AddressDetails extends Braintree_Instance
|
30 |
-
{
|
31 |
-
protected $_attributes = array();
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Transaction/CreditCardDetails.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* CreditCard details from a transaction
|
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 2010 Braintree Payment Solutions
|
17 |
-
*
|
18 |
-
* @property-read string $bin
|
19 |
-
* @property-read string $cardType
|
20 |
-
* @property-read string $expirationDate
|
21 |
-
* @property-read string $expirationMonth
|
22 |
-
* @property-read string $expirationYear
|
23 |
-
* @property-read string $issuerLocation
|
24 |
-
* @property-read string $last4
|
25 |
-
* @property-read string $maskedNumber
|
26 |
-
* @property-read string $token
|
27 |
-
* @uses Braintree_Instance inherits methods
|
28 |
-
*/
|
29 |
-
class Braintree_Transaction_CreditCardDetails extends Braintree_Instance
|
30 |
-
{
|
31 |
-
protected $_attributes = array();
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @ignore
|
35 |
-
*/
|
36 |
-
public function __construct($attributes)
|
37 |
-
{
|
38 |
-
parent::__construct($attributes);
|
39 |
-
$this->_attributes['expirationDate'] = $this->expirationMonth . '/' . $this->expirationYear;
|
40 |
-
$this->_attributes['maskedNumber'] = $this->bin . '******' . $this->last4;
|
41 |
-
|
42 |
-
}
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Transaction/CustomerDetails.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Customer details from a transaction
|
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 2010 Braintree Payment Solutions
|
16 |
-
*
|
17 |
-
* @property-read string $company
|
18 |
-
* @property-read string $email
|
19 |
-
* @property-read string $fax
|
20 |
-
* @property-read string $firstName
|
21 |
-
* @property-read string $id
|
22 |
-
* @property-read string $lastName
|
23 |
-
* @property-read string $phone
|
24 |
-
* @property-read string $website
|
25 |
-
* @uses Braintree_Instance inherits methods
|
26 |
-
*/
|
27 |
-
class Braintree_Transaction_CustomerDetails extends Braintree_Instance
|
28 |
-
{
|
29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Transaction/StatusDetails.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Status details from a transaction
|
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 2010 Braintree Payment Solutions
|
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 Braintree_Transaction_StatusDetails extends Braintree_Instance
|
24 |
-
{
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/lib/Braintree/Braintree/Transaction/SubscriptionDetails.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Customer details from a transaction
|
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 2010 Braintree Payment Solutions
|
16 |
-
*
|
17 |
-
* @property-read string $billing_period_start_date
|
18 |
-
* @property-read string $billing_period_end_date
|
19 |
-
*/
|
20 |
-
class Braintree_Transaction_SubscriptionDetails extends Braintree_Instance
|
21 |
-
{
|
22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,290 +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('/' . $delimiter . '(\w)/e', 'strtoupper("$1")',$string);
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* convert alpha-beta-gamma to alpha_beta_gamma
|
144 |
-
*
|
145 |
-
* @access public
|
146 |
-
* @param string $string
|
147 |
-
* @return string modified string
|
148 |
-
*/
|
149 |
-
public static function delimiterToUnderscore($string)
|
150 |
-
{
|
151 |
-
return preg_replace('/-/', '_', $string);
|
152 |
-
}
|
153 |
-
|
154 |
-
|
155 |
-
/**
|
156 |
-
* find capitals and convert to delimiter + lowercase
|
157 |
-
*
|
158 |
-
* @access public
|
159 |
-
* @param var $string
|
160 |
-
* @return var modified string
|
161 |
-
*/
|
162 |
-
public static function camelCaseToDelimiter($string, $delimiter = '-')
|
163 |
-
{
|
164 |
-
return preg_replace('/([A-Z])/e', '"' . $delimiter . '" . strtolower("$1")', $string);
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
*
|
169 |
-
* @param array $array associative array to implode
|
170 |
-
* @param string $separator (optional, defaults to =)
|
171 |
-
* @param string $glue (optional, defaults to ', ')
|
172 |
-
*/
|
173 |
-
public static function implodeAssociativeArray($array, $separator = '=', $glue = ', ')
|
174 |
-
{
|
175 |
-
// build a new array with joined keys and values
|
176 |
-
$tmpArray = null;
|
177 |
-
foreach ($array AS $key => $value) {
|
178 |
-
$tmpArray[] = $key . $separator . $value;
|
179 |
-
|
180 |
-
}
|
181 |
-
// implode and return the new array
|
182 |
-
return (is_array($tmpArray)) ? implode($glue, $tmpArray) : false;
|
183 |
-
}
|
184 |
-
|
185 |
-
public static function attributesToString($attributes) {
|
186 |
-
$printableAttribs = array();
|
187 |
-
foreach ($attributes AS $key => $value) {
|
188 |
-
if (is_array($value)) {
|
189 |
-
$pAttrib = Braintree_Util::attributesToString($value);
|
190 |
-
} else if ($value instanceof DateTime) {
|
191 |
-
$pAttrib = $value->format(DateTime::RFC850);
|
192 |
-
} else {
|
193 |
-
$pAttrib = $value;
|
194 |
-
}
|
195 |
-
$printableAttribs[$key] = sprintf('%s', $pAttrib);
|
196 |
-
}
|
197 |
-
return Braintree_Util::implodeAssociativeArray($printableAttribs);
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* verify user request structure
|
202 |
-
*
|
203 |
-
* compares the expected signature of a gateway request
|
204 |
-
* against the actual structure sent by the user
|
205 |
-
*
|
206 |
-
* @param array $signature
|
207 |
-
* @param array $attributes
|
208 |
-
*/
|
209 |
-
public static function verifyKeys($signature, $attributes)
|
210 |
-
{
|
211 |
-
$validKeys = self::_flattenArray($signature);
|
212 |
-
$userKeys = self::_flattenUserKeys($attributes);
|
213 |
-
$invalidKeys = array_diff($userKeys, $validKeys);
|
214 |
-
$invalidKeys = self::_removeWildcardKeys($validKeys, $invalidKeys);
|
215 |
-
|
216 |
-
if(!empty($invalidKeys)) {
|
217 |
-
asort($invalidKeys);
|
218 |
-
$sortedList = join(', ', $invalidKeys);
|
219 |
-
throw new InvalidArgumentException('invalid keys: '. $sortedList);
|
220 |
-
}
|
221 |
-
}
|
222 |
-
/**
|
223 |
-
* flattens a numerically indexed nested array to a single level
|
224 |
-
* @param array $keys
|
225 |
-
* @param string $namespace
|
226 |
-
* @return array
|
227 |
-
*/
|
228 |
-
private static function _flattenArray($keys, $namespace = null)
|
229 |
-
{
|
230 |
-
$flattenedArray = array();
|
231 |
-
foreach($keys AS $key) {
|
232 |
-
if(is_array($key)) {
|
233 |
-
$theKeys = array_keys($key);
|
234 |
-
$theValues = array_values($key);
|
235 |
-
$scope = $theKeys[0];
|
236 |
-
$fullKey = empty($namespace) ? $scope : $namespace . '[' . $scope . ']';
|
237 |
-
$flattenedArray = array_merge($flattenedArray, self::_flattenArray($theValues[0], $fullKey));
|
238 |
-
} else {
|
239 |
-
$fullKey = empty($namespace) ? $key : $namespace . '[' . $key . ']';
|
240 |
-
$flattenedArray[] = $fullKey;
|
241 |
-
}
|
242 |
-
}
|
243 |
-
sort($flattenedArray);
|
244 |
-
return $flattenedArray;
|
245 |
-
}
|
246 |
-
|
247 |
-
private static function _flattenUserKeys($keys, $namespace = null)
|
248 |
-
{
|
249 |
-
$flattenedArray = array();
|
250 |
-
|
251 |
-
foreach($keys AS $key => $value) {
|
252 |
-
$fullKey = empty($namespace) ? $key : $namespace;
|
253 |
-
if (!is_numeric($key) && $namespace != null) {
|
254 |
-
$fullKey .= '[' . $key . ']';
|
255 |
-
}
|
256 |
-
if (is_numeric($key) && is_string($value)) {
|
257 |
-
$fullKey .= '[' . $value . ']';
|
258 |
-
}
|
259 |
-
if(is_array($value)) {
|
260 |
-
$more = self::_flattenUserKeys($value, $fullKey);
|
261 |
-
$flattenedArray = array_merge($flattenedArray, $more);
|
262 |
-
} else {
|
263 |
-
$flattenedArray[] = $fullKey;
|
264 |
-
}
|
265 |
-
}
|
266 |
-
sort($flattenedArray);
|
267 |
-
return $flattenedArray;
|
268 |
-
}
|
269 |
-
|
270 |
-
/**
|
271 |
-
* removes wildcard entries from the invalid keys array
|
272 |
-
* @param array $validKeys
|
273 |
-
* @param <array $invalidKeys
|
274 |
-
* @return array
|
275 |
-
*/
|
276 |
-
private static function _removeWildcardKeys($validKeys, $invalidKeys)
|
277 |
-
{
|
278 |
-
foreach($validKeys AS $key) {
|
279 |
-
if (stristr($key, '[_anyKey_]')) {
|
280 |
-
$wildcardKey = str_replace('[_anyKey_]', '', $key);
|
281 |
-
foreach ($invalidKeys AS $index => $invalidKey) {
|
282 |
-
if (stristr($invalidKey, $wildcardKey)) {
|
283 |
-
unset($invalidKeys[$index]);
|
284 |
-
}
|
285 |
-
}
|
286 |
-
}
|
287 |
-
}
|
288 |
-
return $invalidKeys;
|
289 |
-
}
|
290 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|