Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wp-e-commerce",
"version": "3.12.0",
"version": "3.12.2",
"private": true,
"devDependencies": {
"grunt": "^0.4.5",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you're looking for general user support, please submit your support request o
Development status
-------------------------

* The latest stable version is [3.12.0](http://wordpress.org/extend/plugins/wp-e-commerce).
* The latest stable version is [3.12.2](http://wordpress.org/extend/plugins/wp-e-commerce).
* Active development version: 4.0-dev (branch [master](https://github.com/wp-e-commerce/WP-e-Commerce))
* [Roadmap for 4.0](https://github.com/wp-e-commerce/wp-e-commerce/wiki/Roadmap)
* [4.0 tickets](https://github.com/wp-e-commerce/WP-e-Commerce/milestones/4.0)
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://wpecommerce.org
Tags: e-commerce, digital downloads, wp-e-commerce, shop, cart, paypal, authorize, stock control, ecommerce, shipping, tax
Requires at least: 4.5
Tested up to: 4.7.2
Stable tag: 3.12.0
Stable tag: 3.12.2

WP eCommerce is a free, powerful plugin that empowers you to sell anything online, quickly and easily.

Expand Down Expand Up @@ -36,6 +36,15 @@ After upgrading from earlier versions look for link "Update Store". This will up

== Changelog ==

= 3.12.2 [2017-3-25] =

* Enhancement: Default PayPal Credit to On, and ensure it is functional for our 1.0 theme engine.

= 3.12.1 [2017-3-24] =

* New: Addition of PayPal Credit to PayPal Express Checkout.
* Fix: Ensure WPEC works via WP-CLI.

= 3.12.0 [2017-2-17] =

* Fix: When updating a pending order, ensure that the order object's total price is updated as well.
Expand Down
2 changes: 1 addition & 1 deletion wp-shopping-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP eCommerce
* Plugin URI: http://wpecommerce.org/
* 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>
* Version: 3.12.0
* Version: 3.12.2
* Author: WP eCommerce
* Author URI: http://wpecommerce.org/
* Text Domain: wp-e-commerce
Expand Down
34 changes: 29 additions & 5 deletions wpsc-components/fancy-notifications/fancy-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
* WP eCommerce Fancy Notifications
*/

add_action( 'wp_enqueue_scripts', array( 'WPSC_Fancy_Notifications', 'enqueue_styles' ) );
add_action( 'wp_enqueue_scripts', array( 'WPSC_Fancy_Notifications', 'enqueue_scripts' ) );
add_action( 'wpsc_add_to_cart_button_form_begin', array( 'WPSC_Fancy_Notifications', 'add_fancy_notifications' ) );
add_action( 'wpsc_theme_footer', array( 'WPSC_Fancy_Notifications', 'fancy_notifications' ) );
add_filter( 'wpsc_add_to_cart_json_response', array( 'WPSC_Fancy_Notifications', 'wpsc_add_to_cart_json_response' ) );
add_action( 'plugins_loaded', array( 'WPSC_Fancy_Notifications', 'setup_hooks' ) );

/**
* WP eCommerce Fancy Notifications Class
Expand All @@ -17,6 +13,23 @@
*/
class WPSC_Fancy_Notifications {

/**
* Setup Hooks
*/
public static function setup_hooks() {

if ( self::is_active() ) {

add_action( 'wp_enqueue_scripts', array( get_class(), 'enqueue_styles' ) );
add_action( 'wp_enqueue_scripts', array( get_class(), 'enqueue_scripts' ) );
add_action( 'wpsc_add_to_cart_button_form_begin', array( get_class(), 'add_fancy_notifications' ) );
add_action( 'wpsc_theme_footer', array( get_class(), 'fancy_notifications' ) );
add_filter( 'wpsc_add_to_cart_json_response', array( get_class(), 'wpsc_add_to_cart_json_response' ) );

}

}

/**
* Fancy Notifications
*
Expand Down Expand Up @@ -128,6 +141,17 @@ public static function enqueue_scripts() {

}

/**
* Is Active?
*
* @return boolean
*/
public static function is_active() {

return get_option( 'fancy_notifications' ) == 1;

}

/**
* Plugin URL
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public function add_ecs_button( $cart_table, $context ) {
*
* @return void
*/
public function get_shortcut_url() {
public function get_shortcut_url( $callback = 'shortcut_process' ) {
$location = add_query_arg( array(
'payment_gateway' => 'paypal-digital-goods',
'payment_gateway_callback' => 'shortcut_process',
'payment_gateway_callback' => $callback,
), home_url( 'index.php' ) );

return apply_filters( 'wpsc_paypal_digital_goods_shortcut_url', $location );
Expand Down
151 changes: 147 additions & 4 deletions wpsc-components/merchant-core-v3/gateways/paypal-express-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,36 @@ public function __construct( $options, $child = false ) {
'cart_border' => $this->setting->get( 'cart_border' ),
'incontext' => (bool) $this->setting->get( 'incontext', '1' ),
'shortcut' => (bool) $this->setting->get( 'shortcut' , '1' ),
'credit' => (bool) $this->setting->get( 'credit' , '1' ),
) );

// Express Checkout Button
if ( (bool) $this->setting->get( 'shortcut' ) ) {
add_action( 'wpsc_cart_item_table_form_actions_left', array( $this, 'add_ecs_button' ), 2, 2 );
}

// Incontext Checkout Scripts
if ( (bool) $this->setting->get( 'incontext' ) ) {
add_action( 'wp_enqueue_scripts', array( $this, 'incontext_load_scripts' ) );
}

// PayPal Credit Button
if ( (bool) $this->setting->get( 'credit' ) ) {
add_action( 'wpsc_gateway_v2_inside_gateway_label', array( $this, 'add_credit_button_tev1' ) );
add_action( 'wpsc_cart_item_table_form_actions_left', array( $this, 'add_credit_button' ), 1, 2 );
}

}
}

public function add_credit_button_tev1( $gateway ) {
if ( 'paypal-express-checkout' !== $gateway ) { return; }

$url = $this->get_shortcut_url( 'credit_process' );
echo '<em class="paypal-express-credit-separator">' . __( '&mdash; or &mdash;', 'wp-e-commerce' ) . '</em>';
echo '<a class="express-checkout-credit-button" href="'. esc_url( $url ) .'" id="express-checkout-cart-button"><img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-small.png" alt="' . __( 'PayPal Credit', 'wp-e-commerce' ) . '" /></a>';
}

public function incontext_load_scripts() {

$is_cart = wpsc_is_theme_engine( '1.0' ) ? wpsc_is_checkout() : ( wpsc_is_checkout() || wpsc_is_cart() );
Expand Down Expand Up @@ -89,15 +106,34 @@ public function add_ecs_button( $cart_table, $context ) {
}
}

/**
* Insert the Credit Shortcut Button
*
* @return void
*/
public function add_credit_button( $cart_table, $context ) {

if ( wpsc_is_gateway_active( 'paypal-digital-goods' ) || ! wpsc_is_gateway_active( 'paypal-express-checkout' ) ) {
return;
}

if ( _wpsc_get_current_controller_name() === 'cart' ) {
$url = $this->get_shortcut_url( 'credit_process' );
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>';
echo '<em class="paypal-express-credit-separator">' . __( '&mdash; or &mdash;', 'wp-e-commerce' ) . '</em>';
}
}

/**
* Return the ExpressCheckout Shortcut redirection URL
*
* @param string $callback
* @return void
*/
public function get_shortcut_url() {
public function get_shortcut_url( $callback = 'shortcut_process' ) {
$location = add_query_arg( array(
'payment_gateway' => 'paypal-express-checkout',
'payment_gateway_callback' => 'shortcut_process',
'payment_gateway_callback' => $callback,
), home_url( 'index.php' ) );

return apply_filters( 'wpsc_paypal_express_checkout_shortcut_url', $location );
Expand All @@ -112,6 +148,7 @@ public function callback_shortcut_process() {
if ( ! isset( $_GET['payment_gateway'] ) ) {
return;
}

$payment_gateway = $_GET['payment_gateway'];

global $wpsc_cart;
Expand All @@ -136,6 +173,7 @@ public function callback_shortcut_process() {
$tax = 0;
$tax_percentage = 0;
}

$purchase_log->set( array(
'wpec_taxes_total' => $tax,
'wpec_taxes_rate' => $tax_percentage,
Expand Down Expand Up @@ -182,6 +220,88 @@ public function callback_shortcut_process() {
return $sessionid;
}

/**
* Credit Shortcut Callback
*
* @return int
*/
public function callback_credit_process() {
if ( ! isset( $_GET['payment_gateway'] ) ) {
return;
}

$payment_gateway = $_GET['payment_gateway'];

global $wpsc_cart;
// Create a new PurchaseLog Object
$purchase_log = new WPSC_Purchase_Log();

// Create a Sessionid
$sessionid = ( mt_rand( 100, 999 ) . time() );
wpsc_update_customer_meta( 'checkout_session_id', $sessionid );
$purchase_log->set( array(
'user_ID' => get_current_user_id(),
'date' => time(),
'plugin_version' => WPSC_VERSION,
'statusno' => '0',
'sessionid' => $sessionid,
) );

if ( wpsc_tax_isincluded() ) {
$tax = $wpsc_cart->calculate_total_tax();
$tax_percentage = $wpsc_cart->tax_percentage;
} else {
$tax = 0;
$tax_percentage = 0;
}

$purchase_log->set( array(
'wpec_taxes_total' => $tax,
'wpec_taxes_rate' => $tax_percentage,
) );

// Save the purchase_log object to generate it's id
$purchase_log->save();
$purchase_log_id = $purchase_log->get( 'id' );

$wpsc_cart->log_id = $purchase_log_id;
wpsc_update_customer_meta( 'current_purchase_log_id', $purchase_log_id );

$purchase_log->set( array(
'gateway' => $payment_gateway,
'base_shipping' => $wpsc_cart->calculate_base_shipping(),
'totalprice' => $wpsc_cart->calculate_total_price(),
) );

$purchase_log->save();

$wpsc_cart->empty_db( $purchase_log_id );
$wpsc_cart->save_to_db( $purchase_log_id );
$wpsc_cart->submit_stock_claims( $purchase_log_id );

// Save an empty Form
$form = WPSC_Checkout_Form::get();
$fields = $form->get_fields();

WPSC_Checkout_Form_Data::save_form( $purchase_log, $fields, array(), false );

// Return Customer to Review Order Page if there is Shipping
add_filter( 'wpsc_paypal_express_checkout_transact_url', array( &$this, 'review_order_url' ) );
add_filter( 'wpsc_paypal_express_checkout_return_url', array( &$this, 'review_order_callback' ) );

// Set a Temporary Option for EC Shortcut
wpsc_update_customer_meta( 'esc-' . $sessionid, true );

// Apply Checkout Actions
do_action( 'wpsc_submit_checkout', array(
'purchase_log_id' => $purchase_log_id,
'our_user_id' => get_current_user_id(),
) );
do_action( 'wpsc_submit_checkout_gateway', $payment_gateway, $purchase_log );

return $sessionid;
}

/**
* Return Customer to Review Order Page if there are Shipping Costs.
*
Expand Down Expand Up @@ -417,7 +537,7 @@ public function pull_paypal_details() {
}

// Save details to the Forms Table
WPSC_Checkout_Form_Data::save_form( $this->purchase_log, $fields );
WPSC_Checkout_Form_Data::save_form( $this->purchase_log, $fields, array(), false );
}

/**
Expand Down Expand Up @@ -884,7 +1004,21 @@ public function setup_form() {
<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>
</td>
</tr>

<!-- PayPal Credit Shortcut -->
<tr>
<td colspan="2">
<h4><?php _e( 'PayPal Credit Support', 'wp-e-commerce' ); ?></h4>
</td>
</tr>
<tr>
<td>
<label for="wpsc-paypal-express-cart-border"><?php _e( 'Enable PayPal Credit', 'wp-e-commerce' ); ?></label>
</td>
<td>
<label><input <?php checked( $this->setting->get( 'credit', '1' ) ); ?> 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;
<label><input <?php checked( (bool) $this->setting->get( 'credit', '1' ), false ); ?> type="radio" name="<?php echo esc_attr( $this->setting->get_field_name( 'credit' ) ); ?>" value="0" /> <?php _e( 'No', 'wp-e-commerce' ); ?></label>
</td>
</tr>
<!-- Currency Conversion -->
<?php if ( ! $this->is_currency_supported() ) : ?>
<tr>
Expand Down Expand Up @@ -997,6 +1131,7 @@ protected function convert( $amt ) {
* @since 3.9.0
*/
public function process() {

$total = $this->convert( $this->purchase_log->get( 'totalprice' ) );
$options = array(
'return_url' => $this->get_return_url(),
Expand All @@ -1012,6 +1147,14 @@ public function process() {
$options['notify_url'] = $this->get_notify_url();
}

// Check if its a Credit transaction and pass required params.
if ( isset( $_GET['payment_gateway_callback'] ) && $_GET['payment_gateway_callback'] == 'credit_process' ) {
$options += array(
'solution_type' => 'SOLE',
'user_funding_source' => 'Finance',
);
}

// SetExpressCheckout
$response = $this->gateway->setup_purchase( $options );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ protected function build_checkout_request( $action, $options = array() ) {
'MSGSUBID' => 'message_id',
'INVOICEID' => 'invoice',
'NOTE' => 'note',
'USERSELECTEDFUNDINGSOURCE' => 'user_funding_source',
) );

// Cart Customization Fields
Expand Down Expand Up @@ -243,7 +244,6 @@ public function setup_purchase( $options = array(), $action = 'Sale' ) {
$this->options = array_merge( $this->options, $options );
$this->requires( array( 'amount', 'return_url', 'cancel_url' ) );
$request = $this->build_checkout_request( $action, $options );

$response_str = $this->commit( 'SetExpressCheckout', $request );
return new PHP_Merchant_Paypal_Express_Checkout_Response( $response_str );
}
Expand Down
4 changes: 2 additions & 2 deletions wpsc-core/wpsc-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ function wpsc_core_constants() {

// Define Plugin version
if ( ! defined( 'WPSC_VERSION' ) ) {
define( 'WPSC_VERSION' , '3.12.0' );
define( 'WPSC_VERSION' , '3.12.2' );
}

if ( ! defined( 'WPSC_MINOR_VERSION' ) ) {
define( 'WPSC_MINOR_VERSION' , 'fb03617' );
}

if ( ! defined( 'WPSC_PRESENTABLE_VERSION' ) ) {
define( 'WPSC_PRESENTABLE_VERSION', '3.12.0' );
define( 'WPSC_PRESENTABLE_VERSION', '3.12.2' );
}

// Define a salt to use when we hash, WPSC_SALT may be defined for us in our config file, so check first
Expand Down
Loading