WP eCommerce - Version 3.12.1

Version Description

[2017-2-17] =

  • New: Addition of PayPal Credit to PayPal Express Checkout.
  • Fix: Ensure WPEC works via WP-CLI.
Download this release

Release Info

Developer JustinSainton
Plugin Icon 128x128 WP eCommerce
Version 3.12.1
Comparing to
See all releases

Code changes from version 3.12.0 to 3.12.1

readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpecommerce.org
4
  Tags: e-commerce, digital downloads, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 4.5
6
  Tested up to: 4.7.2
7
- Stable tag: 3.12.0
8
 
9
  WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
10
 
@@ -36,6 +36,11 @@ After upgrading from earlier versions look for link "Update Store". This will up
36
 
37
  == Changelog ==
38
 
 
 
 
 
 
39
  = 3.12.0 [2017-2-17] =
40
 
41
  * Fix: When updating a pending order, ensure that the order object's total price is updated as well.
4
  Tags: e-commerce, digital downloads, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
5
  Requires at least: 4.5
6
  Tested up to: 4.7.2
7
+ Stable tag: 3.12.1
8
 
9
  WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.
10
 
36
 
37
  == Changelog ==
38
 
39
+ = 3.12.1 [2017-2-17] =
40
+
41
+ * New: Addition of PayPal Credit to PayPal Express Checkout.
42
+ * Fix: Ensure WPEC works via WP-CLI.
43
+
44
  = 3.12.0 [2017-2-17] =
45
 
46
  * Fix: When updating a pending order, ensure that the order object's total price is updated as well.
wp-shopping-cart.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP eCommerce
4
  * Plugin URI: http://wpecommerce.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://wpecommerce.org" target="_blank">WPeCommerce.org</a> | <a href="https://wordpress.org/support/plugin/wp-e-commerce/" target="_blank">Support Forum</a> | <a href="http://docs.wpecommerce.org/" target="_blank">Documentation</a>
6
- * Version: 3.12.0
7
  * Author: WP eCommerce
8
  * Author URI: http://wpecommerce.org/
9
  * Text Domain: wp-e-commerce
3
  * Plugin Name: WP eCommerce
4
  * Plugin URI: http://wpecommerce.org/
5
  * Description: A plugin that provides a WordPress Shopping Cart. See also: <a href="http://wpecommerce.org" target="_blank">WPeCommerce.org</a> | <a href="https://wordpress.org/support/plugin/wp-e-commerce/" target="_blank">Support Forum</a> | <a href="http://docs.wpecommerce.org/" target="_blank">Documentation</a>
6
+ * Version: 3.12.1
7
  * Author: WP eCommerce
8
  * Author URI: http://wpecommerce.org/
9
  * Text Domain: wp-e-commerce
wpsc-components/merchant-core-v3/gateways/paypal-digital-goods.php CHANGED
@@ -119,10 +119,10 @@ class WPSC_Payment_Gateway_Paypal_Digital_Goods extends WPSC_Payment_Gateway_Pay
119
  *
120
  * @return void
121
  */
122
- public function get_shortcut_url() {
123
  $location = add_query_arg( array(
124
  'payment_gateway' => 'paypal-digital-goods',
125
- 'payment_gateway_callback' => 'shortcut_process',
126
  ), home_url( 'index.php' ) );
127
 
128
  return apply_filters( 'wpsc_paypal_digital_goods_shortcut_url', $location );
119
  *
120
  * @return void
121
  */
122
+ public function get_shortcut_url( $callback = 'shortcut_process' ) {
123
  $location = add_query_arg( array(
124
  'payment_gateway' => 'paypal-digital-goods',
125
+ 'payment_gateway_callback' => $callback,
126
  ), home_url( 'index.php' ) );
127
 
128
  return apply_filters( 'wpsc_paypal_digital_goods_shortcut_url', $location );
wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php CHANGED
@@ -42,16 +42,23 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
42
  'cart_border' => $this->setting->get( 'cart_border' ),
43
  'incontext' => (bool) $this->setting->get( 'incontext', '1' ),
44
  'shortcut' => (bool) $this->setting->get( 'shortcut' , '1' ),
 
45
  ) );
46
 
47
  // Express Checkout Button
48
  if ( (bool) $this->setting->get( 'shortcut' ) ) {
49
  add_action( 'wpsc_cart_item_table_form_actions_left', array( $this, 'add_ecs_button' ), 2, 2 );
50
  }
 
51
  // Incontext Checkout Scripts
52
  if ( (bool) $this->setting->get( 'incontext' ) ) {
53
  add_action( 'wp_enqueue_scripts', array( $this, 'incontext_load_scripts' ) );
54
  }
 
 
 
 
 
55
  }
56
  }
57
 
@@ -89,15 +96,34 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
89
  }
90
  }
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  /**
93
  * Return the ExpressCheckout Shortcut redirection URL
94
  *
 
95
  * @return void
96
  */
97
- public function get_shortcut_url() {
98
  $location = add_query_arg( array(
99
  'payment_gateway' => 'paypal-express-checkout',
100
- 'payment_gateway_callback' => 'shortcut_process',
101
  ), home_url( 'index.php' ) );
102
 
103
  return apply_filters( 'wpsc_paypal_express_checkout_shortcut_url', $location );
@@ -112,6 +138,7 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
112
  if ( ! isset( $_GET['payment_gateway'] ) ) {
113
  return;
114
  }
 
115
  $payment_gateway = $_GET['payment_gateway'];
116
 
117
  global $wpsc_cart;
@@ -136,6 +163,7 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
136
  $tax = 0;
137
  $tax_percentage = 0;
138
  }
 
139
  $purchase_log->set( array(
140
  'wpec_taxes_total' => $tax,
141
  'wpec_taxes_rate' => $tax_percentage,
@@ -182,6 +210,87 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
182
  return $sessionid;
183
  }
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  /**
186
  * Return Customer to Review Order Page if there are Shipping Costs.
187
  *
@@ -884,7 +993,21 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
884
  <label><input <?php checked( (bool) $this->setting->get( 'incontext' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'incontext' ) ); ?>" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label>
885
  </td>
886
  </tr>
887
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
888
  <!-- Currency Conversion -->
889
  <?php if ( ! $this->is_currency_supported() ) : ?>
890
  <tr>
@@ -997,6 +1120,7 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
997
  * @since 3.9.0
998
  */
999
  public function process() {
 
1000
  $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
1001
  $options = array(
1002
  'return_url' => $this->get_return_url(),
@@ -1012,6 +1136,14 @@ class WPSC_Payment_Gateway_Paypal_Express_Checkout extends WPSC_Payment_Gateway
1012
  $options['notify_url'] = $this->get_notify_url();
1013
  }
1014
 
 
 
 
 
 
 
 
 
1015
  // SetExpressCheckout
1016
  $response = $this->gateway->setup_purchase( $options );
1017
 
42
  'cart_border' => $this->setting->get( 'cart_border' ),
43
  'incontext' => (bool) $this->setting->get( 'incontext', '1' ),
44
  'shortcut' => (bool) $this->setting->get( 'shortcut' , '1' ),
45
+ 'credit' => (bool) $this->setting->get( 'credit' , '1' ),
46
  ) );
47
 
48
  // Express Checkout Button
49
  if ( (bool) $this->setting->get( 'shortcut' ) ) {
50
  add_action( 'wpsc_cart_item_table_form_actions_left', array( $this, 'add_ecs_button' ), 2, 2 );
51
  }
52
+
53
  // Incontext Checkout Scripts
54
  if ( (bool) $this->setting->get( 'incontext' ) ) {
55
  add_action( 'wp_enqueue_scripts', array( $this, 'incontext_load_scripts' ) );
56
  }
57
+
58
+ // PayPal Credit Button
59
+ if ( (bool) $this->setting->get( 'credit' ) ) {
60
+ add_action( 'wpsc_cart_item_table_form_actions_left', array( $this, 'add_credit_button' ), 1, 2 );
61
+ }
62
  }
63
  }
64
 
96
  }
97
  }
98
 
99
+ /**
100
+ * Insert the Credit Shortcut Button
101
+ *
102
+ * @return void
103
+ */
104
+ public function add_credit_button( $cart_table, $context ) {
105
+
106
+ if ( wpsc_is_gateway_active( 'paypal-digital-goods' ) || ! wpsc_is_gateway_active( 'paypal-express-checkout' ) ) {
107
+ return;
108
+ }
109
+
110
+ if ( _wpsc_get_current_controller_name() === 'cart' ) {
111
+ $url = $this->get_shortcut_url( 'credit_process' );
112
+ echo '<a class="express-checkout-credit-button" href="'. esc_url( $url ) .'" id="express-checkout-cart-button-' . $context . '"><img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-large.png" alt="' . __( 'PayPal Credit', 'wp-e-commerce' ) . '" /></a>';
113
+ echo '<em class="paypal-express-credit-separator">' . __( '&mdash; or &mdash;', 'wp-e-commerce' ) . '</em>';
114
+ }
115
+ }
116
+
117
  /**
118
  * Return the ExpressCheckout Shortcut redirection URL
119
  *
120
+ * @param string $callback
121
  * @return void
122
  */
123
+ public function get_shortcut_url( $callback = 'shortcut_process' ) {
124
  $location = add_query_arg( array(
125
  'payment_gateway' => 'paypal-express-checkout',
126
+ 'payment_gateway_callback' => $callback,
127
  ), home_url( 'index.php' ) );
128
 
129
  return apply_filters( 'wpsc_paypal_express_checkout_shortcut_url', $location );
138
  if ( ! isset( $_GET['payment_gateway'] ) ) {
139
  return;
140
  }
141
+
142
  $payment_gateway = $_GET['payment_gateway'];
143
 
144
  global $wpsc_cart;
163
  $tax = 0;
164
  $tax_percentage = 0;
165
  }
166
+
167
  $purchase_log->set( array(
168
  'wpec_taxes_total' => $tax,
169
  'wpec_taxes_rate' => $tax_percentage,
210
  return $sessionid;
211
  }
212
 
213
+ /**
214
+ * Credit Shortcut Callback
215
+ *
216
+ * @return int
217
+ */
218
+ public function callback_credit_process() {
219
+ if ( ! isset( $_GET['payment_gateway'] ) ) {
220
+ return;
221
+ }
222
+
223
+ $payment_gateway = $_GET['payment_gateway'];
224
+
225
+ global $wpsc_cart;
226
+ // Create a new PurchaseLog Object
227
+ $purchase_log = new WPSC_Purchase_Log();
228
+
229
+ // Create a Sessionid
230
+ $sessionid = ( mt_rand( 100, 999 ) . time() );
231
+ wpsc_update_customer_meta( 'checkout_session_id', $sessionid );
232
+ $purchase_log->set( array(
233
+ 'user_ID' => get_current_user_id(),
234
+ 'date' => time(),
235
+ 'plugin_version' => WPSC_VERSION,
236
+ 'statusno' => '0',
237
+ 'sessionid' => $sessionid,
238
+ ) );
239
+
240
+ if ( wpsc_is_tax_included() ) {
241
+ $tax = $wpsc_cart->calculate_total_tax();
242
+ $tax_percentage = $wpsc_cart->tax_percentage;
243
+ } else {
244
+ $tax = 0;
245
+ $tax_percentage = 0;
246
+ }
247
+
248
+ $purchase_log->set( array(
249
+ 'wpec_taxes_total' => $tax,
250
+ 'wpec_taxes_rate' => $tax_percentage,
251
+ ) );
252
+
253
+ // Save the purchase_log object to generate it's id
254
+ $purchase_log->save();
255
+ $purchase_log_id = $purchase_log->get( 'id' );
256
+
257
+ $wpsc_cart->log_id = $purchase_log_id;
258
+ wpsc_update_customer_meta( 'current_purchase_log_id', $purchase_log_id );
259
+
260
+ $purchase_log->set( array(
261
+ 'gateway' => $payment_gateway,
262
+ 'base_shipping' => $wpsc_cart->calculate_base_shipping(),
263
+ 'totalprice' => $wpsc_cart->calculate_total_price(),
264
+ ) );
265
+
266
+ $purchase_log->save();
267
+
268
+ $wpsc_cart->empty_db( $purchase_log_id );
269
+ $wpsc_cart->save_to_db( $purchase_log_id );
270
+ $wpsc_cart->submit_stock_claims( $purchase_log_id );
271
+
272
+ // Save an empty Form
273
+ $form = WPSC_Checkout_Form::get();
274
+ $fields = $form->get_fields();
275
+ WPSC_Checkout_Form_Data::save_form( $purchase_log, $fields );
276
+
277
+ // Return Customer to Review Order Page if there is Shipping
278
+ add_filter( 'wpsc_paypal_express_checkout_transact_url', array( &$this, 'review_order_url' ) );
279
+ add_filter( 'wpsc_paypal_express_checkout_return_url', array( &$this, 'review_order_callback' ) );
280
+
281
+ // Set a Temporary Option for EC Shortcut
282
+ wpsc_update_customer_meta( 'esc-' . $sessionid, true );
283
+
284
+ // Apply Checkout Actions
285
+ do_action( 'wpsc_submit_checkout', array(
286
+ 'purchase_log_id' => $purchase_log_id,
287
+ 'our_user_id' => get_current_user_id(),
288
+ ) );
289
+ do_action( 'wpsc_submit_checkout_gateway', $payment_gateway, $purchase_log );
290
+
291
+ return $sessionid;
292
+ }
293
+
294
  /**
295
  * Return Customer to Review Order Page if there are Shipping Costs.
296
  *
993
  <label><input <?php checked( (bool) $this->setting->get( 'incontext' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'incontext' ) ); ?>" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label>
994
  </td>
995
  </tr>
996
+ <!-- PayPal Credit Shortcut -->
997
+ <tr>
998
+ <td colspan="2">
999
+ <h4><?php _e( 'PayPal Credit Support', 'wp-e-commerce' ); ?></h4>
1000
+ </td>
1001
+ </tr>
1002
+ <tr>
1003
+ <td>
1004
+ <label for="wpsc-paypal-express-cart-border"><?php _e( 'Enable PayPal Credit', 'wp-e-commerce' ); ?></label>
1005
+ </td>
1006
+ <td>
1007
+ <label><input <?php checked( $this->setting->get( 'credit', '0' ) ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'credit' ) ); ?>" value="1" /> <?php _e( 'Yes', 'wp-e-commerce' ); ?></label>&nbsp;&nbsp;&nbsp;
1008
+ <label><input <?php checked( (bool) $this->setting->get( 'credit', '0' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'credit' ) ); ?>" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label>
1009
+ </td>
1010
+ </tr>
1011
  <!-- Currency Conversion -->
1012
  <?php if ( ! $this->is_currency_supported() ) : ?>
1013
  <tr>
1120
  * @since 3.9.0
1121
  */
1122
  public function process() {
1123
+
1124
  $total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
1125
  $options = array(
1126
  'return_url' => $this->get_return_url(),
1136
  $options['notify_url'] = $this->get_notify_url();
1137
  }
1138
 
1139
+ // Check if its a Credit transaction and pass required params.
1140
+ if ( isset( $_GET['payment_gateway_callback'] ) && $_GET['payment_gateway_callback'] == 'credit_process' ) {
1141
+ $options += array(
1142
+ 'solution_type' => 'SOLE',
1143
+ 'user_funding_source' => 'Finance',
1144
+ );
1145
+ }
1146
+
1147
  // SetExpressCheckout
1148
  $response = $this->gateway->setup_purchase( $options );
1149
 
wpsc-components/merchant-core-v3/gateways/php-merchant/gateways/paypal-express-checkout.php CHANGED
@@ -193,6 +193,7 @@ class PHP_Merchant_Paypal_Express_Checkout extends PHP_Merchant_Paypal {
193
  'MSGSUBID' => 'message_id',
194
  'INVOICEID' => 'invoice',
195
  'NOTE' => 'note',
 
196
  ) );
197
 
198
  // Cart Customization Fields
@@ -243,7 +244,6 @@ class PHP_Merchant_Paypal_Express_Checkout extends PHP_Merchant_Paypal {
243
  $this->options = array_merge( $this->options, $options );
244
  $this->requires( array( 'amount', 'return_url', 'cancel_url' ) );
245
  $request = $this->build_checkout_request( $action, $options );
246
-
247
  $response_str = $this->commit( 'SetExpressCheckout', $request );
248
  return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
249
  }
193
  'MSGSUBID' => 'message_id',
194
  'INVOICEID' => 'invoice',
195
  'NOTE' => 'note',
196
+ 'USERSELECTEDFUNDINGSOURCE' => 'user_funding_source',
197
  ) );
198
 
199
  // Cart Customization Fields
244
  $this->options = array_merge( $this->options, $options );
245
  $this->requires( array( 'amount', 'return_url', 'cancel_url' ) );
246
  $request = $this->build_checkout_request( $action, $options );
 
247
  $response_str = $this->commit( 'SetExpressCheckout', $request );
248
  return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
249
  }
wpsc-core/wpsc-constants.php CHANGED
@@ -55,7 +55,7 @@ function wpsc_core_constants() {
55
 
56
  // Define Plugin version
57
  if ( ! defined( 'WPSC_VERSION' ) ) {
58
- define( 'WPSC_VERSION' , '3.12.0' );
59
  }
60
 
61
  if ( ! defined( 'WPSC_MINOR_VERSION' ) ) {
@@ -63,7 +63,7 @@ function wpsc_core_constants() {
63
  }
64
 
65
  if ( ! defined( 'WPSC_PRESENTABLE_VERSION' ) ) {
66
- define( 'WPSC_PRESENTABLE_VERSION', '3.12.0' );
67
  }
68
 
69
  // Define a salt to use when we hash, WPSC_SALT may be defined for us in our config file, so check first
55
 
56
  // Define Plugin version
57
  if ( ! defined( 'WPSC_VERSION' ) ) {
58
+ define( 'WPSC_VERSION' , '3.12.1' );
59
  }
60
 
61
  if ( ! defined( 'WPSC_MINOR_VERSION' ) ) {
63
  }
64
 
65
  if ( ! defined( 'WPSC_PRESENTABLE_VERSION' ) ) {
66
+ define( 'WPSC_PRESENTABLE_VERSION', '3.12.1' );
67
  }
68
 
69
  // Define a salt to use when we hash, WPSC_SALT may be defined for us in our config file, so check first
wpsc-core/wpsc-functions.php CHANGED
@@ -644,12 +644,14 @@ function wpsc_serialize_shopping_cart() {
644
  $wpsc_cart->errors = array();
645
  }
646
 
647
- // need to prevent set_cookie from being called at this stage in case the user just logged out
648
- // because by now, some output must have been printed out
649
- $customer_id = wpsc_get_current_customer_id();
 
650
 
651
- if ( $customer_id ) {
652
- wpsc_update_customer_cart( $wpsc_cart, $customer_id );
 
653
  }
654
 
655
  return true;
644
  $wpsc_cart->errors = array();
645
  }
646
 
647
+ if ( function_exists( 'wpsc_get_current_customer_id' ) ) {
648
+ // Need to prevent set_cookie from being called at this stage in case the user
649
+ // just logged out because by now, some output must have been printed out.
650
+ $customer_id = wpsc_get_current_customer_id();
651
 
652
+ if ( $customer_id ) {
653
+ wpsc_update_customer_cart( $wpsc_cart, $customer_id );
654
+ }
655
  }
656
 
657
  return true;