Version Description
- Add - Filter to modify plugin modules list. #203
- Add - Filters to move PayPal buttons and Pay Later messages. #203
- Fix - Remove redirection when enabling payment gateway with setup already done. #206
- Add - PayPal Express Checkout compatibility layer. #207
- Fix - Use correct API to obtain credit card icons. #210
- Fix - Hide mini cart height field when mini cart is disabled. #213
- Fix - Address possible error on frontend pages due to an empty gateway description. #214
Download this release
Release Info
Developer | woothemes |
Plugin | WooCommerce PayPal Payments |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.0 to 1.5.0
- changelog.txt +9 -0
- modules/ppcp-api-client/src/Entity/class-paymenttoken.php +17 -5
- modules/ppcp-button/src/Assets/class-smartbutton.php +71 -11
- modules/ppcp-compat/services.php +28 -1
- modules/ppcp-compat/src/PPEC/class-deactivatenote.php +111 -0
- modules/ppcp-compat/src/PPEC/class-mockgateway.php +49 -0
- modules/ppcp-compat/src/PPEC/class-ppechelper.php +81 -0
- modules/ppcp-compat/src/PPEC/class-settingsimporter.php +235 -0
- modules/ppcp-compat/src/PPEC/class-subscriptionshandler.php +202 -0
- modules/ppcp-compat/src/class-compatmodule.php +30 -0
- modules/ppcp-onboarding/assets/js/settings.js +1 -0
- modules/ppcp-subscription/src/class-renewalhandler.php +4 -0
- modules/ppcp-subscription/src/class-subscriptionmodule.php +1 -1
- modules/ppcp-wc-gateway/services.php +4 -4
- modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php +7 -11
- modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php +26 -2
- readme.txt +33 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_classmap.php +5 -0
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +9 -4
- vendor/composer/installed.php +2 -2
- woocommerce-paypal-payments.php +6 -1
changelog.txt
CHANGED
@@ -1,5 +1,14 @@
|
|
1 |
*** Changelog ***
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
= 1.4.0 - 2021-07-27 =
|
4 |
* Add - Venmo update #169
|
5 |
* Add - Pay Later Button –Global Expansion #182
|
1 |
*** Changelog ***
|
2 |
|
3 |
+
= 1.5.0 - 2021-08-09 =
|
4 |
+
* Add - Filter to modify plugin modules list. #203
|
5 |
+
* Add - Filters to move PayPal buttons and Pay Later messages. #203
|
6 |
+
* Fix - Remove redirection when enabling payment gateway with setup already done. #206
|
7 |
+
* Add - PayPal Express Checkout compatibility layer. #207
|
8 |
+
* Fix - Use correct API to obtain credit card icons. #210
|
9 |
+
* Fix - Hide mini cart height field when mini cart is disabled. #213
|
10 |
+
* Fix - Address possible error on frontend pages due to an empty gateway description. #214
|
11 |
+
|
12 |
= 1.4.0 - 2021-07-27 =
|
13 |
* Add - Venmo update #169
|
14 |
* Add - Pay Later Button –Global Expansion #182
|
modules/ppcp-api-client/src/Entity/class-paymenttoken.php
CHANGED
@@ -16,11 +16,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|
16 |
*/
|
17 |
class PaymentToken {
|
18 |
|
19 |
-
|
20 |
const TYPE_PAYMENT_METHOD_TOKEN = 'PAYMENT_METHOD_TOKEN';
|
21 |
-
const VALID_TYPES = array(
|
22 |
-
self::TYPE_PAYMENT_METHOD_TOKEN,
|
23 |
-
);
|
24 |
|
25 |
/**
|
26 |
* The Id.
|
@@ -52,7 +48,7 @@ class PaymentToken {
|
|
52 |
* @throws RuntimeException When the type is not valid.
|
53 |
*/
|
54 |
public function __construct( string $id, string $type = self::TYPE_PAYMENT_METHOD_TOKEN, \stdClass $source ) {
|
55 |
-
if ( ! in_array( $type, self::
|
56 |
throw new RuntimeException(
|
57 |
__( 'Not a valid payment source type.', 'woocommerce-paypal-payments' )
|
58 |
);
|
@@ -101,4 +97,20 @@ class PaymentToken {
|
|
101 |
'source' => $this->source(),
|
102 |
);
|
103 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
16 |
*/
|
17 |
class PaymentToken {
|
18 |
|
|
|
19 |
const TYPE_PAYMENT_METHOD_TOKEN = 'PAYMENT_METHOD_TOKEN';
|
|
|
|
|
|
|
20 |
|
21 |
/**
|
22 |
* The Id.
|
48 |
* @throws RuntimeException When the type is not valid.
|
49 |
*/
|
50 |
public function __construct( string $id, string $type = self::TYPE_PAYMENT_METHOD_TOKEN, \stdClass $source ) {
|
51 |
+
if ( ! in_array( $type, self::get_valid_types(), true ) ) {
|
52 |
throw new RuntimeException(
|
53 |
__( 'Not a valid payment source type.', 'woocommerce-paypal-payments' )
|
54 |
);
|
97 |
'source' => $this->source(),
|
98 |
);
|
99 |
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Returns a list of valid token types.
|
103 |
+
* Can be modified through the `woocommerce_paypal_payments_valid_payment_token_types` filter.
|
104 |
+
*
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
public static function get_valid_types() {
|
108 |
+
return apply_filters(
|
109 |
+
'woocommerce_paypal_payments_valid_payment_token_types',
|
110 |
+
array(
|
111 |
+
self::TYPE_PAYMENT_METHOD_TOKEN,
|
112 |
+
)
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
}
|
modules/ppcp-button/src/Assets/class-smartbutton.php
CHANGED
@@ -182,7 +182,7 @@ class SmartButton implements SmartButtonInterface {
|
|
182 |
&& ! $this->session_handler->order()
|
183 |
) {
|
184 |
add_action(
|
185 |
-
|
186 |
array(
|
187 |
$this,
|
188 |
'dcc_renderer',
|
@@ -191,7 +191,7 @@ class SmartButton implements SmartButtonInterface {
|
|
191 |
);
|
192 |
|
193 |
add_action(
|
194 |
-
|
195 |
array(
|
196 |
$this,
|
197 |
'dcc_renderer',
|
@@ -255,7 +255,7 @@ class SmartButton implements SmartButtonInterface {
|
|
255 |
&& ! $not_enabled_on_cart
|
256 |
) {
|
257 |
add_action(
|
258 |
-
|
259 |
array(
|
260 |
$this,
|
261 |
'message_renderer',
|
@@ -271,7 +271,7 @@ class SmartButton implements SmartButtonInterface {
|
|
271 |
&& ! $not_enabled_on_product_page
|
272 |
) {
|
273 |
add_action(
|
274 |
-
|
275 |
array(
|
276 |
$this,
|
277 |
'message_renderer',
|
@@ -284,7 +284,7 @@ class SmartButton implements SmartButtonInterface {
|
|
284 |
! $this->settings->get( 'message_enabled' );
|
285 |
if ( ! $not_enabled_on_checkout ) {
|
286 |
add_action(
|
287 |
-
|
288 |
array(
|
289 |
$this,
|
290 |
'message_renderer',
|
@@ -292,7 +292,7 @@ class SmartButton implements SmartButtonInterface {
|
|
292 |
11
|
293 |
);
|
294 |
add_action(
|
295 |
-
|
296 |
array(
|
297 |
$this,
|
298 |
'message_renderer',
|
@@ -318,7 +318,7 @@ class SmartButton implements SmartButtonInterface {
|
|
318 |
&& ! $not_enabled_on_cart
|
319 |
) {
|
320 |
add_action(
|
321 |
-
|
322 |
array(
|
323 |
$this,
|
324 |
'button_renderer',
|
@@ -334,7 +334,7 @@ class SmartButton implements SmartButtonInterface {
|
|
334 |
&& ! $not_enabled_on_product_page
|
335 |
) {
|
336 |
add_action(
|
337 |
-
|
338 |
array(
|
339 |
$this,
|
340 |
'button_renderer',
|
@@ -349,7 +349,7 @@ class SmartButton implements SmartButtonInterface {
|
|
349 |
! $not_enabled_on_minicart
|
350 |
) {
|
351 |
add_action(
|
352 |
-
|
353 |
static function () {
|
354 |
echo '<p
|
355 |
id="ppc-button-minicart"
|
@@ -360,8 +360,8 @@ class SmartButton implements SmartButtonInterface {
|
|
360 |
);
|
361 |
}
|
362 |
|
363 |
-
add_action(
|
364 |
-
add_action(
|
365 |
|
366 |
return true;
|
367 |
}
|
@@ -963,4 +963,64 @@ class SmartButton implements SmartButtonInterface {
|
|
963 |
|
964 |
return $height;
|
965 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
}
|
182 |
&& ! $this->session_handler->order()
|
183 |
) {
|
184 |
add_action(
|
185 |
+
$this->checkout_dcc_button_renderer_hook(),
|
186 |
array(
|
187 |
$this,
|
188 |
'dcc_renderer',
|
191 |
);
|
192 |
|
193 |
add_action(
|
194 |
+
$this->pay_order_renderer_hook(),
|
195 |
array(
|
196 |
$this,
|
197 |
'dcc_renderer',
|
255 |
&& ! $not_enabled_on_cart
|
256 |
) {
|
257 |
add_action(
|
258 |
+
$this->proceed_to_checkout_button_renderer_hook(),
|
259 |
array(
|
260 |
$this,
|
261 |
'message_renderer',
|
271 |
&& ! $not_enabled_on_product_page
|
272 |
) {
|
273 |
add_action(
|
274 |
+
$this->single_product_renderer_hook(),
|
275 |
array(
|
276 |
$this,
|
277 |
'message_renderer',
|
284 |
! $this->settings->get( 'message_enabled' );
|
285 |
if ( ! $not_enabled_on_checkout ) {
|
286 |
add_action(
|
287 |
+
$this->checkout_dcc_button_renderer_hook(),
|
288 |
array(
|
289 |
$this,
|
290 |
'message_renderer',
|
292 |
11
|
293 |
);
|
294 |
add_action(
|
295 |
+
$this->pay_order_renderer_hook(),
|
296 |
array(
|
297 |
$this,
|
298 |
'message_renderer',
|
318 |
&& ! $not_enabled_on_cart
|
319 |
) {
|
320 |
add_action(
|
321 |
+
$this->proceed_to_checkout_button_renderer_hook(),
|
322 |
array(
|
323 |
$this,
|
324 |
'button_renderer',
|
334 |
&& ! $not_enabled_on_product_page
|
335 |
) {
|
336 |
add_action(
|
337 |
+
$this->single_product_renderer_hook(),
|
338 |
array(
|
339 |
$this,
|
340 |
'button_renderer',
|
349 |
! $not_enabled_on_minicart
|
350 |
) {
|
351 |
add_action(
|
352 |
+
$this->mini_cart_button_renderer_hook(),
|
353 |
static function () {
|
354 |
echo '<p
|
355 |
id="ppc-button-minicart"
|
360 |
);
|
361 |
}
|
362 |
|
363 |
+
add_action( $this->checkout_button_renderer_hook(), array( $this, 'button_renderer' ), 10 );
|
364 |
+
add_action( $this->pay_order_renderer_hook(), array( $this, 'button_renderer' ), 10 );
|
365 |
|
366 |
return true;
|
367 |
}
|
963 |
|
964 |
return $height;
|
965 |
}
|
966 |
+
|
967 |
+
/**
|
968 |
+
* Return action name PayPal buttons will be rendered at on checkout page.
|
969 |
+
*
|
970 |
+
* @return string Action name.
|
971 |
+
*/
|
972 |
+
private function checkout_button_renderer_hook(): string {
|
973 |
+
return (string) apply_filters( 'woocommerce_paypal_payments_checkout_button_renderer_hook', 'woocommerce_review_order_after_payment' );
|
974 |
+
}
|
975 |
+
|
976 |
+
/**
|
977 |
+
* Return action name PayPal DCC button will be rendered at on checkout page.
|
978 |
+
*
|
979 |
+
* @return string
|
980 |
+
*/
|
981 |
+
private function checkout_dcc_button_renderer_hook(): string {
|
982 |
+
return (string) apply_filters( 'woocommerce_paypal_payments_checkout_dcc_renderer_hook', 'woocommerce_review_order_after_submit' );
|
983 |
+
}
|
984 |
+
|
985 |
+
/**
|
986 |
+
* Return action name PayPal button and Pay Later message will be rendered at on pay-order page.
|
987 |
+
*
|
988 |
+
* @return string
|
989 |
+
*/
|
990 |
+
private function pay_order_renderer_hook(): string {
|
991 |
+
return (string) apply_filters( 'woocommerce_paypal_payments_pay_order_dcc_renderer_hook', 'woocommerce_pay_order_after_submit' );
|
992 |
+
}
|
993 |
+
|
994 |
+
/**
|
995 |
+
* Return action name PayPal button will be rendered next to Proceed to checkout button (normally displayed in cart).
|
996 |
+
*
|
997 |
+
* @return string
|
998 |
+
*/
|
999 |
+
private function proceed_to_checkout_button_renderer_hook(): string {
|
1000 |
+
return (string) apply_filters(
|
1001 |
+
'woocommerce_paypal_payments_proceed_to_checkout_button_renderer_hook',
|
1002 |
+
'woocommerce_proceed_to_checkout'
|
1003 |
+
);
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
/**
|
1007 |
+
* Return action name PayPal button will be rendered in the WC mini cart.
|
1008 |
+
*
|
1009 |
+
* @return string
|
1010 |
+
*/
|
1011 |
+
private function mini_cart_button_renderer_hook(): string {
|
1012 |
+
return (string) apply_filters(
|
1013 |
+
'woocommerce_paypal_payments_mini_cart_button_renderer_hook',
|
1014 |
+
'woocommerce_widget_shopping_cart_after_buttons'
|
1015 |
+
);
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
/**
|
1019 |
+
* Return action name PayPal button and Pay Later message will be rendered at on the single product page.
|
1020 |
+
*
|
1021 |
+
* @return string
|
1022 |
+
*/
|
1023 |
+
private function single_product_renderer_hook(): string {
|
1024 |
+
return (string) apply_filters( 'woocommerce_paypal_payments_single_product_renderer_hook', 'woocommerce_single_product_summary' );
|
1025 |
+
}
|
1026 |
}
|
modules/ppcp-compat/services.php
CHANGED
@@ -9,4 +9,31 @@ declare(strict_types=1);
|
|
9 |
|
10 |
namespace WooCommerce\PayPalCommerce\Compat;
|
11 |
|
12 |
-
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
namespace WooCommerce\PayPalCommerce\Compat;
|
11 |
|
12 |
+
return array(
|
13 |
+
|
14 |
+
'compat.ppec.mock-gateway' => static function( $container ) {
|
15 |
+
$settings = $container->get( 'wcgateway.settings' );
|
16 |
+
$title = $settings->has( 'title' ) ? $settings->get( 'title' ) : __( 'PayPal', 'woocommerce-paypal-payments' );
|
17 |
+
$title = sprintf(
|
18 |
+
/* Translators: placeholder is the gateway name. */
|
19 |
+
__( '%s (Legacy)', 'woocommerce-paypal-payments' ),
|
20 |
+
$title
|
21 |
+
);
|
22 |
+
|
23 |
+
return new PPEC\MockGateway( $title );
|
24 |
+
},
|
25 |
+
|
26 |
+
'compat.ppec.subscriptions-handler' => static function ( $container ) {
|
27 |
+
$ppcp_renewal_handler = $container->get( 'subscription.renewal-handler' );
|
28 |
+
$gateway = $container->get( 'compat.ppec.mock-gateway' );
|
29 |
+
|
30 |
+
return new PPEC\SubscriptionsHandler( $ppcp_renewal_handler, $gateway );
|
31 |
+
},
|
32 |
+
|
33 |
+
'compat.ppec.settings_importer' => static function( $container ) : PPEC\SettingsImporter {
|
34 |
+
$settings = $container->get( 'wcgateway.settings' );
|
35 |
+
|
36 |
+
return new PPEC\SettingsImporter( $settings );
|
37 |
+
},
|
38 |
+
|
39 |
+
);
|
modules/ppcp-compat/src/PPEC/class-deactivatenote.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Deactivate PayPal Express Checkout inbox note.
|
4 |
+
*
|
5 |
+
* @package WooCommerce\PayPalCommerce\Compat\PPEC
|
6 |
+
*/
|
7 |
+
|
8 |
+
declare(strict_types=1);
|
9 |
+
|
10 |
+
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
|
11 |
+
|
12 |
+
use Automattic\WooCommerce\Admin\Notes\Note;
|
13 |
+
use Automattic\WooCommerce\Admin\Notes\Notes;
|
14 |
+
use Automattic\WooCommerce\Admin\Notes\NoteTraits;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Inbox note for PayPal Express Checkout deactivation.
|
18 |
+
*/
|
19 |
+
class DeactivateNote {
|
20 |
+
|
21 |
+
use NoteTraits;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Name of the note for use in the database.
|
25 |
+
*/
|
26 |
+
const NOTE_NAME = 'ppcp-disable-ppxo-note';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Note initialization.
|
30 |
+
*/
|
31 |
+
public static function init() {
|
32 |
+
if ( ! PPECHelper::is_plugin_active() ) {
|
33 |
+
self::maybe_mark_note_as_actioned();
|
34 |
+
return;
|
35 |
+
}
|
36 |
+
|
37 |
+
self::possibly_add_note();
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get the note.
|
42 |
+
*
|
43 |
+
* @return Automatic\WooCommerce\Admin\Notes\Note
|
44 |
+
*/
|
45 |
+
public static function get_note() {
|
46 |
+
if ( PPECHelper::site_has_ppec_subscriptions() ) {
|
47 |
+
$msg = __(
|
48 |
+
'As of 1 Sept 2021, PayPal Checkout will be officially retired from WooCommerce.com, and support for this product will end as of 1 March 2022. PayPal Payments can now handle all your subscription renewals even if they were first created using PayPal Checkout. To fully switch over, all you need to do is deactivate and/or remove the PayPal Checkout plugin from your store.',
|
49 |
+
'woocommerce-paypal-payments'
|
50 |
+
);
|
51 |
+
} else {
|
52 |
+
$msg = __(
|
53 |
+
'As of 1 Sept 2021, PayPal Checkout will be officially retired from WooCommerce.com, and support for this product will end as of 1 March 2022. To fully switch over, all you need to do is deactivate and/or remove the PayPal Checkout plugin from your store.',
|
54 |
+
'woocommerce-paypal-payments'
|
55 |
+
);
|
56 |
+
}
|
57 |
+
|
58 |
+
$note = new Note();
|
59 |
+
$note->set_name( self::NOTE_NAME );
|
60 |
+
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
|
61 |
+
$note->set_source( 'woocommerce-paypal-payments' );
|
62 |
+
$note->set_title(
|
63 |
+
__( 'Action Required: Deactivate PayPal Checkout', 'woocommerce-paypal-payments' )
|
64 |
+
);
|
65 |
+
$note->set_content( $msg );
|
66 |
+
$note->add_action(
|
67 |
+
'deactivate-paypal-checkout-plugin',
|
68 |
+
__( 'Deactivate PayPal Checkout', 'woocommerce-paypal-payments' ),
|
69 |
+
admin_url( 'plugins.php?action=deactivate&plugin=' . rawurlencode( PPECHelper::PPEC_PLUGIN_FILE ) . '&plugin_status=all&paged=1&_wpnonce=' . wp_create_nonce( 'deactivate-plugin_' . PPECHelper::PPEC_PLUGIN_FILE ) ),
|
70 |
+
Note::E_WC_ADMIN_NOTE_UNACTIONED,
|
71 |
+
true
|
72 |
+
);
|
73 |
+
$note->add_action(
|
74 |
+
'learn-more',
|
75 |
+
__( 'Learn More', 'woocommerce-paypal-payments' ),
|
76 |
+
'https://docs.woocommerce.com/document/woocommerce-paypal-payments/paypal-payments-upgrade-guide/',
|
77 |
+
Note::E_WC_ADMIN_NOTE_UNACTIONED
|
78 |
+
);
|
79 |
+
|
80 |
+
return $note;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Marks the inbox note as actioned so that it doesn't re-appear.
|
85 |
+
*/
|
86 |
+
private static function maybe_mark_note_as_actioned() {
|
87 |
+
try {
|
88 |
+
$data_store = \WC_Data_Store::load( 'admin-note' );
|
89 |
+
} catch ( \Exception $e ) {
|
90 |
+
$data_store = null;
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( ! $data_store ) {
|
94 |
+
return;
|
95 |
+
}
|
96 |
+
|
97 |
+
$note_ids = $data_store->get_notes_with_name( self::NOTE_NAME );
|
98 |
+
|
99 |
+
if ( empty( $note_ids ) ) {
|
100 |
+
return;
|
101 |
+
}
|
102 |
+
|
103 |
+
$note = Notes::get_note( $note_ids[0] );
|
104 |
+
|
105 |
+
if ( Note::E_WC_ADMIN_NOTE_ACTIONED !== $note->get_status() ) {
|
106 |
+
$note->set_status( Note::E_WC_ADMIN_NOTE_ACTIONED );
|
107 |
+
$note->save();
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
modules/ppcp-compat/src/PPEC/class-mockgateway.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mock PayPal Express Checkout class.
|
4 |
+
*
|
5 |
+
* @package WooCommerce\PayPalCommerce\Compat\PPEC
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Mocks the PayPal Express Checkout gateway.
|
12 |
+
*/
|
13 |
+
class MockGateway extends \WC_Payment_Gateway {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Constructor.
|
17 |
+
*
|
18 |
+
* @param string $title Gateway title.
|
19 |
+
*/
|
20 |
+
public function __construct( $title ) {
|
21 |
+
$this->id = PPECHelper::PPEC_GATEWAY_ID;
|
22 |
+
$this->title = $title;
|
23 |
+
$this->method_title = $this->title;
|
24 |
+
$this->description = '';
|
25 |
+
$this->supports = array(
|
26 |
+
'subscriptions',
|
27 |
+
'subscription_cancellation',
|
28 |
+
'subscription_suspension',
|
29 |
+
'subscription_reactivation',
|
30 |
+
'subscription_amount_changes',
|
31 |
+
'subscription_date_changes',
|
32 |
+
'subscription_payment_method_change',
|
33 |
+
'subscription_payment_method_change_customer',
|
34 |
+
'subscription_payment_method_change_admin',
|
35 |
+
'multiple_subscriptions',
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Check if the gateway is available for use.
|
41 |
+
*
|
42 |
+
* @return bool
|
43 |
+
*/
|
44 |
+
public function is_available() {
|
45 |
+
// Hide mock gateway, except on admin.
|
46 |
+
return is_admin();
|
47 |
+
}
|
48 |
+
|
49 |
+
}
|
modules/ppcp-compat/src/PPEC/class-ppechelper.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PayPal Express Checkout helper class.
|
4 |
+
*
|
5 |
+
* @package WooCommerce\PayPalCommerce\Compat\PPEC
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Helper class with various constants associated to the PayPal Express Checkout plugin, as well as methods for figuring
|
12 |
+
* out the status of the gateway.
|
13 |
+
*/
|
14 |
+
class PPECHelper {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* The PayPal Express Checkout gateway ID.
|
18 |
+
*/
|
19 |
+
const PPEC_GATEWAY_ID = 'ppec_paypal';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* The path to the PayPal Express Checkout main plugin file.
|
23 |
+
*/
|
24 |
+
const PPEC_PLUGIN_FILE = 'woocommerce-gateway-paypal-express-checkout/woocommerce-gateway-paypal-express-checkout.php';
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Option name for PayPal Express Checkout settings.
|
28 |
+
*/
|
29 |
+
const PPEC_SETTINGS_OPTION_NAME = 'woocommerce_ppec_paypal_settings';
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Checks if the PayPal Express Checkout plugin is active.
|
34 |
+
*
|
35 |
+
* @return bool
|
36 |
+
*/
|
37 |
+
public static function is_plugin_active() {
|
38 |
+
return is_callable( 'wc_gateway_ppec' );
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Checks whether the PayPal Express Checkout plugin is available (plugin active and gateway configured).
|
43 |
+
*
|
44 |
+
* @return bool
|
45 |
+
*/
|
46 |
+
public static function is_gateway_available() {
|
47 |
+
return self::is_plugin_active() && is_callable( 'wc_gateway_ppec' ) && wc_gateway_ppec()->settings->get_active_api_credentials();
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Checks whether the site has subscriptions handled through PayPal Express Checkout.
|
52 |
+
*
|
53 |
+
* @return bool
|
54 |
+
*/
|
55 |
+
public static function site_has_ppec_subscriptions() {
|
56 |
+
global $wpdb;
|
57 |
+
|
58 |
+
$result = $wpdb->get_var(
|
59 |
+
$wpdb->prepare(
|
60 |
+
"SELECT 1 FROM {$wpdb->posts} p JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID
|
61 |
+
WHERE p.post_type = %s AND p.post_status != %s AND pm.meta_key = %s AND pm.meta_value = %s LIMIT 1",
|
62 |
+
'shop_subscription',
|
63 |
+
'trash',
|
64 |
+
'_payment_method',
|
65 |
+
self::PPEC_GATEWAY_ID
|
66 |
+
)
|
67 |
+
);
|
68 |
+
|
69 |
+
return ! empty( $result );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Checks whether the compatibility layer for PPEC Subscriptions should be initialized.
|
74 |
+
*
|
75 |
+
* @return bool
|
76 |
+
*/
|
77 |
+
public static function use_ppec_compat_layer_for_subscriptions() {
|
78 |
+
return ( ! self::is_gateway_available() ) && self::site_has_ppec_subscriptions() && apply_filters( 'woocommerce_paypal_payments_process_legacy_subscriptions', true );
|
79 |
+
}
|
80 |
+
|
81 |
+
}
|
modules/ppcp-compat/src/PPEC/class-settingsimporter.php
ADDED
@@ -0,0 +1,235 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PayPal Checkout settings importer.
|
4 |
+
*
|
5 |
+
* @package WooCommerce\PayPalCommerce\Compat\PPEC
|
6 |
+
*/
|
7 |
+
|
8 |
+
declare(strict_types=1);
|
9 |
+
|
10 |
+
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
|
11 |
+
|
12 |
+
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Handles import of settings from PayPal Checkout into PayPal Payments.
|
16 |
+
*/
|
17 |
+
class SettingsImporter {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* PPCP settings.
|
21 |
+
*
|
22 |
+
* @var Settings
|
23 |
+
*/
|
24 |
+
private $ppcp_settings;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* PayPal Checkout database option.
|
28 |
+
*
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
private $ppec_settings;
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Constructor.
|
36 |
+
*
|
37 |
+
* @param Settings $settings PPCP settings instance.
|
38 |
+
*/
|
39 |
+
public function __construct( Settings $settings ) {
|
40 |
+
$this->ppcp_settings = $settings;
|
41 |
+
$this->ppec_settings = (array) get_option( PPECHelper::PPEC_SETTINGS_OPTION_NAME, array() );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Sets up WP hooks to import PayPal Checkout settings into PPCP when needed.
|
46 |
+
*
|
47 |
+
* @return void
|
48 |
+
*/
|
49 |
+
public function maybe_hook() {
|
50 |
+
// Import settings the first time the PPCP option is created.
|
51 |
+
if ( PPECHelper::is_gateway_available() && false === get_option( $this->ppcp_settings::KEY ) ) {
|
52 |
+
add_action( 'add_option_' . $this->ppcp_settings::KEY, array( $this, 'import_settings' ), 10, 2 );
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Updates PayPal Payments settings with values taken from PayPal Checkout settings.
|
58 |
+
*
|
59 |
+
* @return void
|
60 |
+
*/
|
61 |
+
public function import_settings() {
|
62 |
+
foreach ( $this->get_settings_translated() as $key => $value ) {
|
63 |
+
$this->ppcp_settings->set( $key, $value );
|
64 |
+
$this->ppcp_settings->persist();
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Determines whether PayPal Checkout is in use.
|
70 |
+
*
|
71 |
+
* @return boolean true if PayPal Checkout is available and correctly configured.
|
72 |
+
*/
|
73 |
+
private function is_ppec_active() {
|
74 |
+
return ! empty( $this->ppec_settings ) && is_callable( 'wc_gateway_ppec' ) && wc_gateway_ppec()->settings->get_active_api_credentials();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Translates available PayPal Checkout settings to key/value pairs understood by PayPal Payments settings class.
|
79 |
+
*
|
80 |
+
* @return array An array of key => value pairs of PayPal Payments options.
|
81 |
+
*/
|
82 |
+
private function get_settings_translated() {
|
83 |
+
static $context_translations = array(
|
84 |
+
'' => 'cart',
|
85 |
+
'mark' => '',
|
86 |
+
'single_product' => 'product',
|
87 |
+
'mini_cart' => 'mini-cart',
|
88 |
+
);
|
89 |
+
|
90 |
+
static $credit_messaging_translations = array(
|
91 |
+
'credit_message_layout' => 'layout',
|
92 |
+
'credit_message_logo' => 'logo',
|
93 |
+
'credit_message_logo_position' => 'position',
|
94 |
+
'credit_message_text_color' => 'color',
|
95 |
+
'credit_message_flex_color' => 'flex_color',
|
96 |
+
'credit_message_flex_ratio' => 'flex_ratio',
|
97 |
+
);
|
98 |
+
|
99 |
+
$result = array();
|
100 |
+
|
101 |
+
foreach ( $this->ppec_settings as $option_key => $option_value ) {
|
102 |
+
$key = false;
|
103 |
+
$value = false;
|
104 |
+
|
105 |
+
switch ( $option_key ) {
|
106 |
+
case 'title':
|
107 |
+
case 'description':
|
108 |
+
case 'brand_name':
|
109 |
+
$key = $option_key;
|
110 |
+
$value = $option_value;
|
111 |
+
|
112 |
+
break;
|
113 |
+
case 'invoice_prefix':
|
114 |
+
$key = 'prefix';
|
115 |
+
$value = $option_value;
|
116 |
+
|
117 |
+
break;
|
118 |
+
case 'landing_page':
|
119 |
+
$key = $option_key;
|
120 |
+
$value = strtoupper( $option_value );
|
121 |
+
|
122 |
+
break;
|
123 |
+
case 'paymentaction':
|
124 |
+
if ( 'authorization' === $option_value ) {
|
125 |
+
$key = 'intent';
|
126 |
+
$value = 'authorize';
|
127 |
+
}
|
128 |
+
|
129 |
+
break;
|
130 |
+
case 'instant_payments':
|
131 |
+
$key = 'payee_preferred';
|
132 |
+
$value = wc_string_to_bool( $option_value );
|
133 |
+
|
134 |
+
break;
|
135 |
+
case 'debug':
|
136 |
+
$key = 'logging_enabled';
|
137 |
+
$value = wc_string_to_bool( $option_value );
|
138 |
+
|
139 |
+
break;
|
140 |
+
case 'hide_funding_methods':
|
141 |
+
$key = 'disable_funding';
|
142 |
+
$value = array_values(
|
143 |
+
array_intersect(
|
144 |
+
array_map( 'strtolower', is_array( $option_value ) ? $option_value : array() ),
|
145 |
+
array( 'card', 'credit', 'sepa', 'bancontact', 'eps', 'giropay', 'ideal', 'mybank', 'p24', 'sofort', 'venmo' )
|
146 |
+
)
|
147 |
+
);
|
148 |
+
|
149 |
+
break;
|
150 |
+
|
151 |
+
case 'cart_checkout_enabled':
|
152 |
+
$key = 'button_cart_enabled';
|
153 |
+
$value = wc_string_to_bool( $option_value );
|
154 |
+
|
155 |
+
break;
|
156 |
+
case 'mark_enabled':
|
157 |
+
$key = 'button_enabled';
|
158 |
+
$value = wc_string_to_bool( $option_value );
|
159 |
+
|
160 |
+
break;
|
161 |
+
case 'checkout_on_single_product_enabled':
|
162 |
+
$key = 'button_product_enabled';
|
163 |
+
$value = wc_string_to_bool( $option_value );
|
164 |
+
|
165 |
+
break;
|
166 |
+
default:
|
167 |
+
break;
|
168 |
+
}
|
169 |
+
|
170 |
+
if ( ! $key || is_null( $value ) ) {
|
171 |
+
continue;
|
172 |
+
}
|
173 |
+
|
174 |
+
$result[ $key ] = $value;
|
175 |
+
}
|
176 |
+
|
177 |
+
// Mini-cart enabled is tied to cart in PPEC.
|
178 |
+
$result['button_mini-cart_enabled'] = isset( $result['button_cart_enabled'] ) ? $result['button_cart_enabled'] : false;
|
179 |
+
|
180 |
+
// PayPal Credit enabled?
|
181 |
+
if ( isset( $this->ppec_settings['credit_enabled'] ) && 'no' === $this->ppec_settings['credit_enabled'] ) {
|
182 |
+
$result['disable_funding'] = array_merge(
|
183 |
+
isset( $result['disable_funding'] ) ? $result['disable_funding'] : array(),
|
184 |
+
array( 'credit' )
|
185 |
+
);
|
186 |
+
}
|
187 |
+
|
188 |
+
foreach ( $context_translations as $old_context => $new_context ) {
|
189 |
+
$old_prefix = $old_context ? $old_context . '_' : '';
|
190 |
+
$new_prefix = $new_context ? $new_context . '_' : '';
|
191 |
+
|
192 |
+
$use_cart_settings = ( $old_context && ( ! isset( $this->ppec_settings[ $old_context . '_settings_toggle' ] ) || 'yes' !== $this->ppec_settings[ $old_context . '_settings_toggle' ] ) );
|
193 |
+
|
194 |
+
// If context not enabled, skip the rest of the settings.
|
195 |
+
if ( isset( $result[ 'button_' . $new_prefix . 'enabled' ] ) && ! $result[ 'button_' . $new_prefix . 'enabled' ] ) {
|
196 |
+
continue;
|
197 |
+
}
|
198 |
+
|
199 |
+
foreach ( array( 'layout', 'label', 'shape', 'color' ) as $button_prop ) {
|
200 |
+
$old_key = ( ( $use_cart_settings || 'color' === $button_prop ) ? '' : $old_prefix ) . 'button_' . $button_prop;
|
201 |
+
$new_key = 'button_' . $new_prefix . $button_prop;
|
202 |
+
|
203 |
+
if ( isset( $this->ppec_settings[ $old_key ] ) ) {
|
204 |
+
$result[ $new_key ] = $this->ppec_settings[ $old_key ];
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
// Handle Pay Later settings.
|
209 |
+
if ( 'mini_cart' === $old_context ) {
|
210 |
+
continue;
|
211 |
+
}
|
212 |
+
|
213 |
+
$skip_messaging = ( $use_cart_settings && isset( $this->ppec_settings['credit_message_enabled'] ) && ( 'yes' !== $this->ppec_settings['credit_message_enabled'] ) );
|
214 |
+
$skip_messaging = $skip_messaging || ( ! $use_cart_settings && isset( $this->ppec_settings[ $old_prefix . 'credit_message_enabled' ] ) && ( 'yes' !== $this->ppec_settings[ $old_prefix . 'credit_message_enabled' ] ) );
|
215 |
+
|
216 |
+
$result[ 'message_' . $new_prefix . 'enabled' ] = ! $skip_messaging;
|
217 |
+
|
218 |
+
if ( $skip_messaging ) {
|
219 |
+
continue;
|
220 |
+
}
|
221 |
+
|
222 |
+
foreach ( $credit_messaging_translations as $old_message_key => $new_message_key ) {
|
223 |
+
$old_key = ( $use_cart_settings ? '' : $old_prefix ) . $old_message_key;
|
224 |
+
$new_key = 'message_' . $new_prefix . $new_message_key;
|
225 |
+
|
226 |
+
if ( isset( $this->ppec_settings[ $old_key ] ) ) {
|
227 |
+
$result[ $new_key ] = $this->ppec_settings[ $old_key ];
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
return $result;
|
233 |
+
}
|
234 |
+
|
235 |
+
}
|
modules/ppcp-compat/src/PPEC/class-subscriptionshandler.php
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Compatibility layer for subscriptions paid via PayPal Express Checkout.
|
4 |
+
*
|
5 |
+
* @package WooCommerce\PayPalCommerce\Compat\PPEC
|
6 |
+
*/
|
7 |
+
|
8 |
+
declare(strict_types=1);
|
9 |
+
|
10 |
+
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
|
11 |
+
|
12 |
+
use WooCommerce\PayPalCommerce\Subscription\RenewalHandler;
|
13 |
+
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Handles renewals and edit/display matters for subscriptions renewed via PayPal Express Checkout.
|
17 |
+
*/
|
18 |
+
class SubscriptionsHandler {
|
19 |
+
|
20 |
+
const BILLING_AGREEMENT_TOKEN_TYPE = 'BILLING_AGREEMENT';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* PayPal Payments subscription renewal handler.
|
24 |
+
*
|
25 |
+
* @var RenewalHandler
|
26 |
+
*/
|
27 |
+
private $ppcp_renewal_handler;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Mock gateway instance.
|
31 |
+
*
|
32 |
+
* @var MockGateway
|
33 |
+
*/
|
34 |
+
private $mock_gateway;
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Constructor.
|
39 |
+
*
|
40 |
+
* @param RenewalHandler $ppcp_renewal_handler PayPal Payments Subscriptions renewal handler.
|
41 |
+
* @param MockGateway $gateway Mock gateway instance.
|
42 |
+
*/
|
43 |
+
public function __construct( RenewalHandler $ppcp_renewal_handler, MockGateway $gateway ) {
|
44 |
+
$this->ppcp_renewal_handler = $ppcp_renewal_handler;
|
45 |
+
$this->mock_gateway = $gateway;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Sets up hooks.
|
50 |
+
*
|
51 |
+
* @return void
|
52 |
+
*/
|
53 |
+
public function maybe_hook() {
|
54 |
+
if ( ! PPECHelper::use_ppec_compat_layer_for_subscriptions() ) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
// "Mock" PPEC when needed.
|
59 |
+
add_filter( 'woocommerce_payment_gateways', array( $this, 'add_mock_ppec_gateway' ) );
|
60 |
+
|
61 |
+
// Add billing agreement as a valid token type.
|
62 |
+
add_filter( 'woocommerce_paypal_payments_valid_payment_token_types', array( $this, 'add_billing_agreement_as_token_type' ) );
|
63 |
+
|
64 |
+
// Process PPEC renewals through PayPal Payments.
|
65 |
+
add_action( 'woocommerce_scheduled_subscription_payment_' . PPECHelper::PPEC_GATEWAY_ID, array( $this, 'process_renewal' ), 10, 2 );
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Adds a mock gateway to disguise as PPEC when needed. Hooked onto `woocommerce_payment_gateways`.
|
70 |
+
* The mock gateway fixes display issues where subscriptions paid via PPEC appear as "via Manual Renewal" and also
|
71 |
+
* prevents Subscriptions from automatically changing the payment method to "manual" when a subscription is edited.
|
72 |
+
*
|
73 |
+
* @param array $gateways List of gateways.
|
74 |
+
* @return array
|
75 |
+
*/
|
76 |
+
public function add_mock_ppec_gateway( $gateways ) {
|
77 |
+
if ( ! isset( $gateways[ PPECHelper::PPEC_GATEWAY_ID ] ) && $this->should_mock_ppec_gateway() ) {
|
78 |
+
$gateways[ PPECHelper::PPEC_GATEWAY_ID ] = $this->mock_gateway;
|
79 |
+
}
|
80 |
+
|
81 |
+
return $gateways;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Registers BILLING_AGREEMENT as a valid token type for using with the PayPal REST API.
|
86 |
+
*
|
87 |
+
* @param array $types List of token types.
|
88 |
+
* @return array
|
89 |
+
*/
|
90 |
+
public function add_billing_agreement_as_token_type( $types ) {
|
91 |
+
if ( ! in_array( self::BILLING_AGREEMENT_TOKEN_TYPE, $types, true ) ) {
|
92 |
+
$types[] = self::BILLING_AGREEMENT_TOKEN_TYPE;
|
93 |
+
}
|
94 |
+
|
95 |
+
return $types;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Processes subscription renewals on behalf of PayPal Express Checkout.
|
100 |
+
* Hooked onto `woocommerce_scheduled_subscription_payment_ppec_paypal`.
|
101 |
+
*
|
102 |
+
* @param float $amount The order amount.
|
103 |
+
* @param \WC_Order $order The renewal order.
|
104 |
+
* @return void
|
105 |
+
*/
|
106 |
+
public function process_renewal( $amount, $order ) {
|
107 |
+
add_filter( 'woocommerce_paypal_payments_subscriptions_get_token_for_customer', array( $this, 'use_billing_agreement_as_token' ), 10, 3 );
|
108 |
+
|
109 |
+
$this->ppcp_renewal_handler->renew( $order );
|
110 |
+
|
111 |
+
remove_filter( 'woocommerce_paypal_payments_subscriptions_get_token_for_customer', array( $this, 'use_billing_agreement_as_token' ) );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Short-circuits `RenewalHandler::get_token_for_customer()` to use a Billing Agreement ID for PPEC orders
|
116 |
+
* instead of vaulted tokens.
|
117 |
+
*
|
118 |
+
* @param null|PaymentToken $token Current token value.
|
119 |
+
* @param \WC_Customer $customer Customer object.
|
120 |
+
* @param \WC_Order $order Renewal order.
|
121 |
+
* @return null|PaymentToken
|
122 |
+
*/
|
123 |
+
public function use_billing_agreement_as_token( $token, $customer, $order ) {
|
124 |
+
if ( PPECHelper::PPEC_GATEWAY_ID === $order->get_payment_method() && wcs_order_contains_renewal( $order ) ) {
|
125 |
+
$billing_agreement_id = $order->get_meta( '_ppec_billing_agreement_id', true );
|
126 |
+
|
127 |
+
if ( $billing_agreement_id ) {
|
128 |
+
$token = new PaymentToken( $billing_agreement_id, 'BILLING_AGREEMENT', new \stdClass() );
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
return $token;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Checks whether the mock PPEC gateway should be used or not.
|
137 |
+
*
|
138 |
+
* @return bool
|
139 |
+
*/
|
140 |
+
private function should_mock_ppec_gateway() {
|
141 |
+
// Are we processing a renewal?
|
142 |
+
if ( doing_action( 'woocommerce_scheduled_subscription_payment' ) ) {
|
143 |
+
return true;
|
144 |
+
}
|
145 |
+
|
146 |
+
// My Account > Subscriptions.
|
147 |
+
if ( is_wc_endpoint_url( 'subscriptions' ) ) {
|
148 |
+
return true;
|
149 |
+
}
|
150 |
+
|
151 |
+
// Checks that require Subscriptions.
|
152 |
+
if ( class_exists( \WC_Subscriptions::class ) ) {
|
153 |
+
// My Account > Subscriptions > (Subscription).
|
154 |
+
if ( wcs_is_view_subscription_page() ) {
|
155 |
+
$subscription = wcs_get_subscription( absint( get_query_var( 'view-subscription' ) ) );
|
156 |
+
|
157 |
+
return ( $subscription && PPECHelper::PPEC_GATEWAY_ID === $subscription->get_payment_method() );
|
158 |
+
}
|
159 |
+
|
160 |
+
// Changing payment method?
|
161 |
+
if ( is_wc_endpoint_url( 'order-pay' ) && isset( $_GET['change_payment_method'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
162 |
+
$subscription = wcs_get_subscription( absint( get_query_var( 'order-pay' ) ) );
|
163 |
+
|
164 |
+
return ( $subscription && PPECHelper::PPEC_GATEWAY_ID === $subscription->get_payment_method() );
|
165 |
+
}
|
166 |
+
|
167 |
+
// Early renew (via modal).
|
168 |
+
if ( isset( $_GET['process_early_renewal'], $_GET['subscription_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
169 |
+
$subscription = wcs_get_subscription( absint( $_GET['subscription_id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
170 |
+
|
171 |
+
return ( $subscription && PPECHelper::PPEC_GATEWAY_ID === $subscription->get_payment_method() );
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
// Admin-only from here onwards.
|
176 |
+
if ( ! is_admin() ) {
|
177 |
+
return false;
|
178 |
+
}
|
179 |
+
|
180 |
+
// Are we saving metadata for a subscription?
|
181 |
+
if ( doing_action( 'woocommerce_process_shop_order_meta' ) ) {
|
182 |
+
return true;
|
183 |
+
}
|
184 |
+
|
185 |
+
if ( function_exists( 'get_current_screen' ) && get_current_screen() ) {
|
186 |
+
// Are we on the WC > Subscriptions screen?
|
187 |
+
if ( 'edit-shop_subscription' === get_current_screen()->id ) {
|
188 |
+
return true;
|
189 |
+
}
|
190 |
+
|
191 |
+
// Are we editing an order or subscription tied to PPEC?
|
192 |
+
if ( in_array( get_current_screen()->id, array( 'shop_subscription', 'shop_order' ), true ) ) {
|
193 |
+
$order = wc_get_order( $GLOBALS['post']->ID );
|
194 |
+
|
195 |
+
return ( $order && PPECHelper::PPEC_GATEWAY_ID === $order->get_payment_method() );
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
return false;
|
200 |
+
}
|
201 |
+
|
202 |
+
}
|
modules/ppcp-compat/src/class-compatmodule.php
CHANGED
@@ -13,6 +13,7 @@ use Dhii\Container\ServiceProvider;
|
|
13 |
use Dhii\Modular\Module\ModuleInterface;
|
14 |
use Interop\Container\ServiceProviderInterface;
|
15 |
use Psr\Container\ContainerInterface;
|
|
|
16 |
|
17 |
/**
|
18 |
* Class CompatModule
|
@@ -37,6 +38,7 @@ class CompatModule implements ModuleInterface {
|
|
37 |
* @param ContainerInterface|null $container The Container.
|
38 |
*/
|
39 |
public function run( ContainerInterface $container ): void {
|
|
|
40 |
}
|
41 |
|
42 |
/**
|
@@ -46,4 +48,32 @@ class CompatModule implements ModuleInterface {
|
|
46 |
*/
|
47 |
public function getKey() {
|
48 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
13 |
use Dhii\Modular\Module\ModuleInterface;
|
14 |
use Interop\Container\ServiceProviderInterface;
|
15 |
use Psr\Container\ContainerInterface;
|
16 |
+
use WooCommerce\PayPalCommerce\Compat\PPEC\PPECHelper;
|
17 |
|
18 |
/**
|
19 |
* Class CompatModule
|
38 |
* @param ContainerInterface|null $container The Container.
|
39 |
*/
|
40 |
public function run( ContainerInterface $container ): void {
|
41 |
+
$this->initialize_ppec_compat_layer( $container );
|
42 |
}
|
43 |
|
44 |
/**
|
48 |
*/
|
49 |
public function getKey() {
|
50 |
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Sets up the PayPal Express Checkout compatibility layer.
|
54 |
+
*
|
55 |
+
* @param ContainerInterface|null $container The Container.
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
+
private function initialize_ppec_compat_layer( $container ): void {
|
59 |
+
// Process PPEC subscription renewals through PayPal Payments.
|
60 |
+
$handler = $container->get( 'compat.ppec.subscriptions-handler' );
|
61 |
+
$handler->maybe_hook();
|
62 |
+
|
63 |
+
// Settings.
|
64 |
+
$ppec_import = $container->get( 'compat.ppec.settings_importer' );
|
65 |
+
$ppec_import->maybe_hook();
|
66 |
+
|
67 |
+
// Inbox note inviting merchant to disable PayPal Express Checkout.
|
68 |
+
add_action(
|
69 |
+
'woocommerce_init',
|
70 |
+
function() {
|
71 |
+
if ( is_callable( array( WC(), 'is_wc_admin_active' ) ) && WC()->is_wc_admin_active() ) {
|
72 |
+
PPEC\DeactivateNote::init();
|
73 |
+
}
|
74 |
+
}
|
75 |
+
);
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
}
|
modules/ppcp-onboarding/assets/js/settings.js
CHANGED
@@ -253,6 +253,7 @@ document.addEventListener(
|
|
253 |
'#field-button_mini-cart_label',
|
254 |
'#field-button_mini-cart_color',
|
255 |
'#field-button_mini-cart_shape',
|
|
|
256 |
]
|
257 |
);
|
258 |
|
253 |
'#field-button_mini-cart_label',
|
254 |
'#field-button_mini-cart_color',
|
255 |
'#field-button_mini-cart_shape',
|
256 |
+
'#field-button_mini-cart_height',
|
257 |
]
|
258 |
);
|
259 |
|
modules/ppcp-subscription/src/class-renewalhandler.php
CHANGED
@@ -175,6 +175,10 @@ class RenewalHandler {
|
|
175 |
* @return PaymentToken|null
|
176 |
*/
|
177 |
private function get_token_for_customer( \WC_Customer $customer, \WC_Order $wc_order ) {
|
|
|
|
|
|
|
|
|
178 |
|
179 |
$tokens = $this->repository->all_for_user_id( (int) $customer->get_id() );
|
180 |
if ( ! $tokens ) {
|
175 |
* @return PaymentToken|null
|
176 |
*/
|
177 |
private function get_token_for_customer( \WC_Customer $customer, \WC_Order $wc_order ) {
|
178 |
+
$token = apply_filters( 'woocommerce_paypal_payments_subscriptions_get_token_for_customer', null, $customer, $wc_order );
|
179 |
+
if ( null !== $token ) {
|
180 |
+
return $token;
|
181 |
+
}
|
182 |
|
183 |
$tokens = $this->repository->all_for_user_id( (int) $customer->get_id() );
|
184 |
if ( ! $tokens ) {
|
modules/ppcp-subscription/src/class-subscriptionmodule.php
CHANGED
@@ -80,7 +80,7 @@ class SubscriptionModule implements ModuleInterface {
|
|
80 |
$settings = $container->get( 'wcgateway.settings' );
|
81 |
$subscription_helper = $container->get( 'subscription.helper' );
|
82 |
|
83 |
-
return $this->display_saved_paypal_payments( $settings, $id, $payment_token_repository, $description, $subscription_helper );
|
84 |
},
|
85 |
10,
|
86 |
2
|
80 |
$settings = $container->get( 'wcgateway.settings' );
|
81 |
$subscription_helper = $container->get( 'subscription.helper' );
|
82 |
|
83 |
+
return $this->display_saved_paypal_payments( $settings, (string) $id, $payment_token_repository, (string) $description, $subscription_helper );
|
84 |
},
|
85 |
10,
|
86 |
2
|
modules/ppcp-wc-gateway/services.php
CHANGED
@@ -761,7 +761,7 @@ return array(
|
|
761 |
'type' => 'select',
|
762 |
'class' => array(),
|
763 |
'input_class' => array( 'wc-enhanced-select' ),
|
764 |
-
'default' => 'paypal',
|
765 |
'desc_tip' => true,
|
766 |
'description' => __(
|
767 |
'This controls the label on the primary button.',
|
@@ -1063,7 +1063,7 @@ return array(
|
|
1063 |
'type' => 'select',
|
1064 |
'class' => array(),
|
1065 |
'input_class' => array( 'wc-enhanced-select' ),
|
1066 |
-
'default' => 'paypal',
|
1067 |
'desc_tip' => true,
|
1068 |
'description' => __(
|
1069 |
'This controls the label on the primary button.',
|
@@ -1366,7 +1366,7 @@ return array(
|
|
1366 |
'type' => 'select',
|
1367 |
'class' => array(),
|
1368 |
'input_class' => array( 'wc-enhanced-select' ),
|
1369 |
-
'default' => 'paypal',
|
1370 |
'desc_tip' => true,
|
1371 |
'description' => __(
|
1372 |
'This controls the label on the primary button.',
|
@@ -1669,7 +1669,7 @@ return array(
|
|
1669 |
'type' => 'select',
|
1670 |
'class' => array(),
|
1671 |
'input_class' => array( 'wc-enhanced-select' ),
|
1672 |
-
'default' => 'paypal',
|
1673 |
'desc_tip' => true,
|
1674 |
'description' => __(
|
1675 |
'This controls the label on the primary button.',
|
761 |
'type' => 'select',
|
762 |
'class' => array(),
|
763 |
'input_class' => array( 'wc-enhanced-select' ),
|
764 |
+
'default' => apply_filters( 'woocommerce_paypal_payments_button_label_default', 'paypal' ),
|
765 |
'desc_tip' => true,
|
766 |
'description' => __(
|
767 |
'This controls the label on the primary button.',
|
1063 |
'type' => 'select',
|
1064 |
'class' => array(),
|
1065 |
'input_class' => array( 'wc-enhanced-select' ),
|
1066 |
+
'default' => apply_filters( 'woocommerce_paypal_payments_button_product_label_default', 'paypal' ),
|
1067 |
'desc_tip' => true,
|
1068 |
'description' => __(
|
1069 |
'This controls the label on the primary button.',
|
1366 |
'type' => 'select',
|
1367 |
'class' => array(),
|
1368 |
'input_class' => array( 'wc-enhanced-select' ),
|
1369 |
+
'default' => apply_filters( 'woocommerce_paypal_payments_button_cart_label_default', 'paypal' ),
|
1370 |
'desc_tip' => true,
|
1371 |
'description' => __(
|
1372 |
'This controls the label on the primary button.',
|
1669 |
'type' => 'select',
|
1670 |
'class' => array(),
|
1671 |
'input_class' => array( 'wc-enhanced-select' ),
|
1672 |
+
'default' => apply_filters( 'woocommerce_paypal_payments_button_mini_cart_label_default', 'paypal' ),
|
1673 |
'desc_tip' => true,
|
1674 |
'description' => __(
|
1675 |
'This controls the label on the primary button.',
|
modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php
CHANGED
@@ -236,21 +236,16 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|
236 |
}
|
237 |
|
238 |
/**
|
239 |
-
* Returns the
|
240 |
*
|
241 |
* @return string
|
242 |
*/
|
243 |
-
public function
|
|
|
244 |
|
245 |
-
//phpcs:disable WordPress.Security.NonceVerification.Recommended
|
246 |
-
if ( ! is_checkout() || ( is_ajax() && isset( $_GET['wc-ajax'] ) && 'update_order_review' !== $_GET['wc-ajax'] ) ) {
|
247 |
-
return parent::get_title();
|
248 |
-
}
|
249 |
-
//phpcs:enable WordPress.Security.NonceVerification.Recommended
|
250 |
-
$title = parent::get_title();
|
251 |
$icons = $this->config->has( 'card_icons' ) ? (array) $this->config->get( 'card_icons' ) : array();
|
252 |
if ( empty( $icons ) ) {
|
253 |
-
return $
|
254 |
}
|
255 |
|
256 |
$title_options = $this->card_labels();
|
@@ -258,13 +253,14 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|
258 |
function ( string $type ) use ( $title_options ): string {
|
259 |
return '<img
|
260 |
title="' . esc_attr( $title_options[ $type ] ) . '"
|
261 |
-
src="' . esc_url( $this->module_url ) . '
|
262 |
class="ppcp-card-icon"
|
263 |
> ';
|
264 |
},
|
265 |
$icons
|
266 |
);
|
267 |
-
|
|
|
268 |
}
|
269 |
|
270 |
/**
|
236 |
}
|
237 |
|
238 |
/**
|
239 |
+
* Returns the icons of the gateway.
|
240 |
*
|
241 |
* @return string
|
242 |
*/
|
243 |
+
public function get_icon() {
|
244 |
+
$icon = parent::get_icon();
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
$icons = $this->config->has( 'card_icons' ) ? (array) $this->config->get( 'card_icons' ) : array();
|
247 |
if ( empty( $icons ) ) {
|
248 |
+
return $icon;
|
249 |
}
|
250 |
|
251 |
$title_options = $this->card_labels();
|
253 |
function ( string $type ) use ( $title_options ): string {
|
254 |
return '<img
|
255 |
title="' . esc_attr( $title_options[ $type ] ) . '"
|
256 |
+
src="' . esc_url( $this->module_url ) . 'assets/images/' . esc_attr( $type ) . '.svg"
|
257 |
class="ppcp-card-icon"
|
258 |
> ';
|
259 |
},
|
260 |
$icons
|
261 |
);
|
262 |
+
|
263 |
+
return implode( '', $images );
|
264 |
}
|
265 |
|
266 |
/**
|
modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php
CHANGED
@@ -96,6 +96,13 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
96 |
*/
|
97 |
private $refund_processor;
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
/**
|
100 |
* PayPalGateway constructor.
|
101 |
*
|
@@ -132,8 +139,9 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
132 |
$this->session_handler = $session_handler;
|
133 |
$this->refund_processor = $refund_processor;
|
134 |
$this->transaction_url_provider = $transaction_url_provider;
|
|
|
135 |
|
136 |
-
if ( $
|
137 |
$this->supports = array( 'refunds' );
|
138 |
}
|
139 |
if (
|
@@ -185,7 +193,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
185 |
*/
|
186 |
public function needs_setup(): bool {
|
187 |
|
188 |
-
return
|
189 |
}
|
190 |
|
191 |
/**
|
@@ -373,4 +381,20 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
373 |
|
374 |
return parent::get_transaction_url( $order );
|
375 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
}
|
96 |
*/
|
97 |
private $refund_processor;
|
98 |
|
99 |
+
/**
|
100 |
+
* Whether the plugin is in onboarded state.
|
101 |
+
*
|
102 |
+
* @var bool
|
103 |
+
*/
|
104 |
+
private $onboarded;
|
105 |
+
|
106 |
/**
|
107 |
* PayPalGateway constructor.
|
108 |
*
|
139 |
$this->session_handler = $session_handler;
|
140 |
$this->refund_processor = $refund_processor;
|
141 |
$this->transaction_url_provider = $transaction_url_provider;
|
142 |
+
$this->onboarded = $state->current_state() === State::STATE_ONBOARDED;
|
143 |
|
144 |
+
if ( $this->onboarded ) {
|
145 |
$this->supports = array( 'refunds' );
|
146 |
}
|
147 |
if (
|
193 |
*/
|
194 |
public function needs_setup(): bool {
|
195 |
|
196 |
+
return ! $this->onboarded;
|
197 |
}
|
198 |
|
199 |
/**
|
381 |
|
382 |
return parent::get_transaction_url( $order );
|
383 |
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Updates WooCommerce gateway option.
|
387 |
+
*
|
388 |
+
* @param string $key The option key.
|
389 |
+
* @param string $value The option value.
|
390 |
+
* @return bool|void
|
391 |
+
*/
|
392 |
+
public function update_option( $key, $value = '' ) {
|
393 |
+
parent::update_option( $key, $value );
|
394 |
+
|
395 |
+
if ( 'enabled' === $key ) {
|
396 |
+
$this->config->set( 'enabled', 'yes' === $value );
|
397 |
+
$this->config->persist();
|
398 |
+
}
|
399 |
+
}
|
400 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: woocommerce, paypal, payments, ecommerce, e-commerce, store, sales, sell,
|
|
4 |
Requires at least: 5.3
|
5 |
Tested up to: 5.8
|
6 |
Requires PHP: 7.1
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -15,6 +15,29 @@ PayPal's latest payments processing solution. Accept PayPal, Pay Later, credit/d
|
|
15 |
PayPal's latest, most complete payment processing solution. Accept PayPal exclusives, credit/debit cards and local payment methods. Turn on only PayPal options or process a full suite of payment methods. Enable global transactions with extensive currency and country coverage.
|
16 |
Built and supported by [WooCommerce](https://woocommerce.com) and [PayPal](https://paypal.com).
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
== Installation ==
|
19 |
|
20 |
= Requirements =
|
@@ -58,6 +81,15 @@ Follow the steps below to connect the plugin to your PayPal account:
|
|
58 |
|
59 |
== Changelog ==
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
= 1.4.0 =
|
62 |
* Add - Venmo update #169
|
63 |
* Add - Pay Later Button –Global Expansion #182
|
4 |
Requires at least: 5.3
|
5 |
Tested up to: 5.8
|
6 |
Requires PHP: 7.1
|
7 |
+
Stable tag: 1.5.0
|
8 |
License: GPLv2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
15 |
PayPal's latest, most complete payment processing solution. Accept PayPal exclusives, credit/debit cards and local payment methods. Turn on only PayPal options or process a full suite of payment methods. Enable global transactions with extensive currency and country coverage.
|
16 |
Built and supported by [WooCommerce](https://woocommerce.com) and [PayPal](https://paypal.com).
|
17 |
|
18 |
+
= Give your customers their preferred ways to pay with one checkout solution =
|
19 |
+
|
20 |
+
Streamline your business with one simple, powerful solution.
|
21 |
+
|
22 |
+
With the latest PayPal extension, your customers can pay with PayPal, Pay Later options, credit & debit cards, and country-specific, local payment methods on any device — all with one seamless checkout experience.
|
23 |
+
|
24 |
+
= Reach more customers in 200+ markets worldwide =
|
25 |
+
|
26 |
+
Expand your business by connecting with over 370+ million active PayPal accounts around the globe. With PayPal, you can:
|
27 |
+
|
28 |
+
- Sell in 200+ markets and accept 100+ currencies
|
29 |
+
- Identify customer locations and offer country-specific, local payment methods
|
30 |
+
|
31 |
+
= Offer subscription payments to help drive repeat business =
|
32 |
+
|
33 |
+
Create stable, predictable income by offering subscription plans.
|
34 |
+
|
35 |
+
With the vaulting feature on PayPal, you can offer flexible plans with fixed or quantity pricing, set billing cycles for the time period you want, and offer subscriptions with discounted trial periods.
|
36 |
+
|
37 |
+
It’s easy for shoppers, simple for you, and great for your business–with no monthly or setup fees.
|
38 |
+
|
39 |
+
PayPal is also compatible with [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/).
|
40 |
+
|
41 |
== Installation ==
|
42 |
|
43 |
= Requirements =
|
81 |
|
82 |
== Changelog ==
|
83 |
|
84 |
+
= 1.5.0 =
|
85 |
+
* Add - Filter to modify plugin modules list. #203
|
86 |
+
* Add - Filters to move PayPal buttons and Pay Later messages. #203
|
87 |
+
* Fix - Remove redirection when enabling payment gateway with setup already done. #206
|
88 |
+
* Add - PayPal Express Checkout compatibility layer. #207
|
89 |
+
* Fix - Use correct API to obtain credit card icons. #210
|
90 |
+
* Fix - Hide mini cart height field when mini cart is disabled. #213
|
91 |
+
* Fix - Address possible error on frontend pages due to an empty gateway description. #214
|
92 |
+
|
93 |
= 1.4.0 =
|
94 |
* Add - Venmo update #169
|
95 |
* Add - Pay Later Button –Global Expansion #182
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit66bca0ec46d311fe385c37586d44ac5c::getLoader();
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -103,6 +103,11 @@ return array(
|
|
103 |
'WooCommerce\\PayPalCommerce\\Button\\Helper\\MessagesDisclaimers' => $baseDir . '/modules/ppcp-button/src/Helper/class-messagesdisclaimers.php',
|
104 |
'WooCommerce\\PayPalCommerce\\Button\\Helper\\ThreeDSecure' => $baseDir . '/modules/ppcp-button/src/Helper/class-threedsecure.php',
|
105 |
'WooCommerce\\PayPalCommerce\\Compat\\CompatModule' => $baseDir . '/modules/ppcp-compat/src/class-compatmodule.php',
|
|
|
|
|
|
|
|
|
|
|
106 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Assets\\OnboardingAssets' => $baseDir . '/modules/ppcp-onboarding/src/Assets/class-onboardingassets.php',
|
107 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Endpoint\\LoginSellerEndpoint' => $baseDir . '/modules/ppcp-onboarding/src/Endpoint/class-loginsellerendpoint.php',
|
108 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Environment' => $baseDir . '/modules/ppcp-onboarding/src/class-environment.php',
|
103 |
'WooCommerce\\PayPalCommerce\\Button\\Helper\\MessagesDisclaimers' => $baseDir . '/modules/ppcp-button/src/Helper/class-messagesdisclaimers.php',
|
104 |
'WooCommerce\\PayPalCommerce\\Button\\Helper\\ThreeDSecure' => $baseDir . '/modules/ppcp-button/src/Helper/class-threedsecure.php',
|
105 |
'WooCommerce\\PayPalCommerce\\Compat\\CompatModule' => $baseDir . '/modules/ppcp-compat/src/class-compatmodule.php',
|
106 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\DeactivateNote' => $baseDir . '/modules/ppcp-compat/src/PPEC/class-deactivatenote.php',
|
107 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\MockGateway' => $baseDir . '/modules/ppcp-compat/src/PPEC/class-mockgateway.php',
|
108 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\PPECHelper' => $baseDir . '/modules/ppcp-compat/src/PPEC/class-ppechelper.php',
|
109 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\SettingsImporter' => $baseDir . '/modules/ppcp-compat/src/PPEC/class-settingsimporter.php',
|
110 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\SubscriptionsHandler' => $baseDir . '/modules/ppcp-compat/src/PPEC/class-subscriptionshandler.php',
|
111 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Assets\\OnboardingAssets' => $baseDir . '/modules/ppcp-onboarding/src/Assets/class-onboardingassets.php',
|
112 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Endpoint\\LoginSellerEndpoint' => $baseDir . '/modules/ppcp-onboarding/src/Endpoint/class-loginsellerendpoint.php',
|
113 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Environment' => $baseDir . '/modules/ppcp-onboarding/src/class-environment.php',
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -24,15 +24,15 @@ class ComposerAutoloaderInite10b41e28707caa8003f07ad0a5b2aa3
|
|
24 |
|
25 |
require __DIR__ . '/platform_check.php';
|
26 |
|
27 |
-
spl_autoload_register(array('
|
28 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
29 |
-
spl_autoload_unregister(array('
|
30 |
|
31 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
32 |
if ($useStaticLoader) {
|
33 |
require __DIR__ . '/autoload_static.php';
|
34 |
|
35 |
-
call_user_func(\Composer\Autoload\
|
36 |
} else {
|
37 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
38 |
foreach ($map as $namespace => $path) {
|
@@ -53,19 +53,19 @@ class ComposerAutoloaderInite10b41e28707caa8003f07ad0a5b2aa3
|
|
53 |
$loader->register(true);
|
54 |
|
55 |
if ($useStaticLoader) {
|
56 |
-
$includeFiles = Composer\Autoload\
|
57 |
} else {
|
58 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
59 |
}
|
60 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
61 |
-
|
62 |
}
|
63 |
|
64 |
return $loader;
|
65 |
}
|
66 |
}
|
67 |
|
68 |
-
function
|
69 |
{
|
70 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
71 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit66bca0ec46d311fe385c37586d44ac5c
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
24 |
|
25 |
require __DIR__ . '/platform_check.php';
|
26 |
|
27 |
+
spl_autoload_register(array('ComposerAutoloaderInit66bca0ec46d311fe385c37586d44ac5c', 'loadClassLoader'), true, true);
|
28 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
29 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit66bca0ec46d311fe385c37586d44ac5c', 'loadClassLoader'));
|
30 |
|
31 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
32 |
if ($useStaticLoader) {
|
33 |
require __DIR__ . '/autoload_static.php';
|
34 |
|
35 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit66bca0ec46d311fe385c37586d44ac5c::getInitializer($loader));
|
36 |
} else {
|
37 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
38 |
foreach ($map as $namespace => $path) {
|
53 |
$loader->register(true);
|
54 |
|
55 |
if ($useStaticLoader) {
|
56 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit66bca0ec46d311fe385c37586d44ac5c::$files;
|
57 |
} else {
|
58 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
59 |
}
|
60 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
61 |
+
composerRequire66bca0ec46d311fe385c37586d44ac5c($fileIdentifier, $file);
|
62 |
}
|
63 |
|
64 |
return $loader;
|
65 |
}
|
66 |
}
|
67 |
|
68 |
+
function composerRequire66bca0ec46d311fe385c37586d44ac5c($fileIdentifier, $file)
|
69 |
{
|
70 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
71 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
@@ -178,6 +178,11 @@ class ComposerStaticInite10b41e28707caa8003f07ad0a5b2aa3
|
|
178 |
'WooCommerce\\PayPalCommerce\\Button\\Helper\\MessagesDisclaimers' => __DIR__ . '/../..' . '/modules/ppcp-button/src/Helper/class-messagesdisclaimers.php',
|
179 |
'WooCommerce\\PayPalCommerce\\Button\\Helper\\ThreeDSecure' => __DIR__ . '/../..' . '/modules/ppcp-button/src/Helper/class-threedsecure.php',
|
180 |
'WooCommerce\\PayPalCommerce\\Compat\\CompatModule' => __DIR__ . '/../..' . '/modules/ppcp-compat/src/class-compatmodule.php',
|
|
|
|
|
|
|
|
|
|
|
181 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Assets\\OnboardingAssets' => __DIR__ . '/../..' . '/modules/ppcp-onboarding/src/Assets/class-onboardingassets.php',
|
182 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Endpoint\\LoginSellerEndpoint' => __DIR__ . '/../..' . '/modules/ppcp-onboarding/src/Endpoint/class-loginsellerendpoint.php',
|
183 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Environment' => __DIR__ . '/../..' . '/modules/ppcp-onboarding/src/class-environment.php',
|
@@ -237,9 +242,9 @@ class ComposerStaticInite10b41e28707caa8003f07ad0a5b2aa3
|
|
237 |
public static function getInitializer(ClassLoader $loader)
|
238 |
{
|
239 |
return \Closure::bind(function () use ($loader) {
|
240 |
-
$loader->prefixLengthsPsr4 =
|
241 |
-
$loader->prefixDirsPsr4 =
|
242 |
-
$loader->classMap =
|
243 |
|
244 |
}, null, ClassLoader::class);
|
245 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit66bca0ec46d311fe385c37586d44ac5c
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
178 |
'WooCommerce\\PayPalCommerce\\Button\\Helper\\MessagesDisclaimers' => __DIR__ . '/../..' . '/modules/ppcp-button/src/Helper/class-messagesdisclaimers.php',
|
179 |
'WooCommerce\\PayPalCommerce\\Button\\Helper\\ThreeDSecure' => __DIR__ . '/../..' . '/modules/ppcp-button/src/Helper/class-threedsecure.php',
|
180 |
'WooCommerce\\PayPalCommerce\\Compat\\CompatModule' => __DIR__ . '/../..' . '/modules/ppcp-compat/src/class-compatmodule.php',
|
181 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\DeactivateNote' => __DIR__ . '/../..' . '/modules/ppcp-compat/src/PPEC/class-deactivatenote.php',
|
182 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\MockGateway' => __DIR__ . '/../..' . '/modules/ppcp-compat/src/PPEC/class-mockgateway.php',
|
183 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\PPECHelper' => __DIR__ . '/../..' . '/modules/ppcp-compat/src/PPEC/class-ppechelper.php',
|
184 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\SettingsImporter' => __DIR__ . '/../..' . '/modules/ppcp-compat/src/PPEC/class-settingsimporter.php',
|
185 |
+
'WooCommerce\\PayPalCommerce\\Compat\\PPEC\\SubscriptionsHandler' => __DIR__ . '/../..' . '/modules/ppcp-compat/src/PPEC/class-subscriptionshandler.php',
|
186 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Assets\\OnboardingAssets' => __DIR__ . '/../..' . '/modules/ppcp-onboarding/src/Assets/class-onboardingassets.php',
|
187 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Endpoint\\LoginSellerEndpoint' => __DIR__ . '/../..' . '/modules/ppcp-onboarding/src/Endpoint/class-loginsellerendpoint.php',
|
188 |
'WooCommerce\\PayPalCommerce\\Onboarding\\Environment' => __DIR__ . '/../..' . '/modules/ppcp-onboarding/src/class-environment.php',
|
242 |
public static function getInitializer(ClassLoader $loader)
|
243 |
{
|
244 |
return \Closure::bind(function () use ($loader) {
|
245 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit66bca0ec46d311fe385c37586d44ac5c::$prefixLengthsPsr4;
|
246 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit66bca0ec46d311fe385c37586d44ac5c::$prefixDirsPsr4;
|
247 |
+
$loader->classMap = ComposerStaticInit66bca0ec46d311fe385c37586d44ac5c::$classMap;
|
248 |
|
249 |
}, null, ClassLoader::class);
|
250 |
}
|
vendor/composer/installed.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
'type' => 'wordpress-plugin',
|
6 |
'install_path' => __DIR__ . '/../../',
|
7 |
'aliases' => array(),
|
8 |
-
'reference' => '
|
9 |
'name' => 'woocommerce/woocommerce-paypal-payments',
|
10 |
'dev' => false,
|
11 |
),
|
@@ -124,7 +124,7 @@
|
|
124 |
'type' => 'wordpress-plugin',
|
125 |
'install_path' => __DIR__ . '/../../',
|
126 |
'aliases' => array(),
|
127 |
-
'reference' => '
|
128 |
'dev_requirement' => false,
|
129 |
),
|
130 |
),
|
5 |
'type' => 'wordpress-plugin',
|
6 |
'install_path' => __DIR__ . '/../../',
|
7 |
'aliases' => array(),
|
8 |
+
'reference' => '095acaee4e556f5342c4508b320a28ef9dee8cc2',
|
9 |
'name' => 'woocommerce/woocommerce-paypal-payments',
|
10 |
'dev' => false,
|
11 |
),
|
124 |
'type' => 'wordpress-plugin',
|
125 |
'install_path' => __DIR__ . '/../../',
|
126 |
'aliases' => array(),
|
127 |
+
'reference' => '095acaee4e556f5342c4508b320a28ef9dee8cc2',
|
128 |
'dev_requirement' => false,
|
129 |
),
|
130 |
),
|
woocommerce-paypal-payments.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WooCommerce PayPal Payments
|
4 |
* Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/
|
5 |
* Description: PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
|
6 |
-
* Version: 1.
|
7 |
* Author: WooCommerce
|
8 |
* Author URI: https://woocommerce.com/
|
9 |
* License: GPL-2.0
|
@@ -77,6 +77,11 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
|
|
77 |
$modules[] = ( require $module_file )();
|
78 |
}
|
79 |
$providers = array();
|
|
|
|
|
|
|
|
|
|
|
80 |
foreach ( $modules as $module ) {
|
81 |
/* @var $module ModuleInterface module */
|
82 |
$providers[] = $module->setup();
|
3 |
* Plugin Name: WooCommerce PayPal Payments
|
4 |
* Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/
|
5 |
* Description: PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
|
6 |
+
* Version: 1.5.0
|
7 |
* Author: WooCommerce
|
8 |
* Author URI: https://woocommerce.com/
|
9 |
* License: GPL-2.0
|
77 |
$modules[] = ( require $module_file )();
|
78 |
}
|
79 |
$providers = array();
|
80 |
+
|
81 |
+
// Use this filter to add custom module or remove some of existing ones.
|
82 |
+
// Modules able to access container, add services and modify existing ones.
|
83 |
+
$modules = apply_filters( 'woocommerce_paypal_payments_modules', $modules );
|
84 |
+
|
85 |
foreach ( $modules as $module ) {
|
86 |
/* @var $module ModuleInterface module */
|
87 |
$providers[] = $module->setup();
|