Merge branch 'trunk' into issue-174-vaulting-pay-later-ux
|
@ -1,10 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="50px" height="50px" viewBox="0 0 50 50" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Amex_acceptancemark_50x50</title>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Amex_acceptancemark_50x50">
|
||||
<polygon id="Shape" fill="#FFFFFF" fill-rule="nonzero" points="50 0 0 0 0 50 50 50"></polygon>
|
||||
<path d="M25.0930414,18.1130368 L21.2948396,18.1130368 L23.1939405,13.5354022 L25.0930414,18.1130368 Z M27.5916246,24.0501324 L31.8892892,24.0501324 L25.7128236,10.0571358 L20.7951652,10.0571358 L14.6182767,24.0501324 L18.8161334,24.0501324 L19.9755555,21.2514908 L26.412114,21.2514908 L27.5916246,24.0501324 Z M46.2218867,24.0501324 L50,24.0501324 L50,10.0571358 L44.1229584,10.0571358 L40.9845044,18.7725731 L37.8661389,10.0571358 L31.8892892,10.0571358 L31.8892892,24.0501324 L35.6671911,24.0501324 L35.6671911,14.255204 L39.2655654,24.0501324 L42.6237239,24.0501324 L46.2218867,14.234904 L46.2218867,24.0501324 Z M23.7946916,36.8350715 L23.7946916,34.6562122 L31.6905191,34.6562122 L31.6905191,31.4978812 L23.7946916,31.4978812 L23.7946916,29.3190219 L31.8903465,29.3190219 L31.8903465,26.0807599 L19.9766128,26.0807599 L19.9766128,40.0733335 L31.8903465,40.0733335 L31.8903465,36.8350715 L23.7946916,36.8350715 Z M46.1576036,33.0427906 L50,37.1306893 L50,28.989148 L46.1576036,33.0427906 Z M44.9840138,40.0733335 L50,40.0733335 L43.3646714,33.0370812 L50,26.0807599 L45.0637333,26.0807599 L40.9661076,30.558375 L36.9078129,26.0807599 L31.8907695,26.0807599 L38.4871899,33.0770467 L31.8907695,40.0733335 L36.7682509,40.0733335 L40.8861766,35.5557529 L44.9840138,40.0733335 Z M50,50 L50,42.0773174 L43.9679599,42.0773174 L40.8622819,38.6432456 L37.7411674,42.0773174 L17.8527325,42.0773174 L17.8527325,26.072513 L11.4335135,26.072513 L19.3957387,8.05336344 L27.0746107,8.05336344 L29.8157358,14.2264457 L29.8157358,8.05336344 L39.3205444,8.05336344 L40.9709711,12.7052196 L42.6319707,8.05336344 L50,8.05336344 L50,0 L0,0 L0,50 L50,50 L50,50 Z" id="Fill-18" fill="#216EA9"></path>
|
||||
<svg width="134px" height="85px" viewBox="0 0 134 85" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>AmEx Card Icon</title>
|
||||
<g id="RD-4" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="LP---venmo---social---primary" transform="translate(-824.000000, -1587.000000)">
|
||||
<g id="AmEx-Card-Icon" transform="translate(824.988647, 1587.578995)">
|
||||
<rect id="Rectangle" fill="#216EA9" x="0" y="0" width="132.39159" height="83.7921454" rx="4.581738"></rect>
|
||||
<g id="Amex" transform="translate(11.042625, 26.813487)" fill-rule="nonzero">
|
||||
<polygon id="path3082" fill="#FFFFFF" points="58.1781633 28.829246 58.1781633 0.111970975 88.752584 0.111970975 92.0328881 4.36473322 95.4216632 0.111970975 111.627357 0.111970975 100.111543 14.3998649 111.627357 28.829246 95.1623158 28.829246 91.8866983 24.4852763 88.560787 28.829246"></polygon>
|
||||
<polygon id="path3080" fill="#FFFFFF" points="12.9456251 0.111970975 24.8692065 0.111970975 28.7820013 9.06638213 28.7820013 0.111970975 43.6041122 0.111970975 45.933401 6.58395398 48.1915676 0.111970975 83.0100213 0.111970975 83.0100213 28.829228 23.1027999 28.829228 21.2713726 24.3023659 16.3877429 24.3023659 14.5692593 28.829228 0.216820214 28.829228"></polygon>
|
||||
<path d="M15.3859151,3.6521988 L6.08653439,25.1547742 L12.140911,25.1547742 L13.8567623,20.8489817 L23.8318149,20.8489817 L25.5387763,25.1547742 L31.7265095,25.1547742 L22.436018,3.6521988 L15.3859151,3.6521988 Z M18.8265072,8.6564979 L21.8670326,16.1806509 L15.7770926,16.1806509 L18.8265072,8.6564979 L18.8265072,8.6564979 Z" id="path3046" fill="#216EA9"></path>
|
||||
<polygon id="path3048" fill="#216EA9" points="32.3666185 25.1511618 32.3666185 3.64856809 40.9702248 3.68034593 45.9743744 17.543851 50.8586955 3.64856809 59.3934994 3.64856809 59.3934994 25.1511618 53.9881232 25.1511618 53.9881232 9.30714548 48.2583106 25.1511618 43.5177841 25.1511618 37.7719947 9.30714548 37.7719947 25.1511618"></polygon>
|
||||
<polygon id="path3050" fill="#216EA9" points="63.091914 25.1511618 63.091914 3.64856809 80.7305103 3.64856809 80.7305103 8.45836792 68.5541888 8.45836792 68.5541888 12.1364341 80.4460167 12.1364341 80.4460167 16.6632958 68.5541888 16.6632958 68.5541888 20.482831 80.7305103 20.482831 80.7305103 25.1511618"></polygon>
|
||||
<polygon id="path3066" fill="#216EA9" points="80.1997365 25.1511618 88.7878839 14.5324773 79.9952578 3.64856809 86.80532 3.64856809 92.0417773 10.3769555 97.2960166 3.64856809 103.839367 3.64856809 95.1623158 14.3998648 103.766272 25.1511618 96.9572869 25.1511618 91.8728606 18.5288349 86.9120057 25.1511618"></polygon>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.8 KiB |
22
modules/ppcp-wc-gateway/assets/images/ideal-dark.svg
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="88px" height="55px" viewBox="0 0 88 55" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>iDEAL_acceptancemark_80x50</title>
|
||||
<g id="RD-4" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="LP---venmo---social---primary" transform="translate(-1290.000000, -1489.000000)">
|
||||
<g id="iDEAL_acceptancemark_80x50" transform="translate(1290.674250, 1489.000000)">
|
||||
<rect id="Rectangle" fill="#000000" x="0" y="0" width="86.55975" height="54.78165" rx="3.55725"></rect>
|
||||
<g id="iDeal" transform="translate(19.722475, 8.569431)" fill-rule="nonzero">
|
||||
<g id="Group-10">
|
||||
<path d="M1.31483165,0.4147596 L1.31483165,38.542788 L23.6150559,38.542788 C38.3257411,38.542788 44.7042759,30.3306152 44.7042759,19.4407953 C44.7042759,8.59428425 38.3257411,0.4147596 23.6150559,0.4147596 L1.31483165,0.4147596 Z" id="Fill-6" fill="#FFFFFF"></path>
|
||||
<path d="M24.4089797,0.0145181949 C43.6643857,0.0145181949 46.5394168,12.2271201 46.5394168,19.5055435 C46.5394168,32.133495 38.680567,39.0878016 24.4089797,39.0878016 L0.807144801,39.0878016 L0.807144801,0.0145181949 L24.4089797,0.0145181949 Z M2.66510307,1.8517804 L2.66510307,37.249739 L24.4089797,37.249739 C37.5392931,37.249739 44.6818631,31.2003587 44.6818631,19.5055435 C44.6818631,7.48721161 36.9395275,1.8517804 24.4089797,1.8517804 L2.66510307,1.8517804 Z" id="Fill-8" fill="#000000"></path>
|
||||
</g>
|
||||
<polygon id="Fill-11" fill="#000000" points="5.58237061 34.364139 12.5430893 34.364139 12.5430893 22.1081216 5.58237061 22.1081216"></polygon>
|
||||
<g id="Group-16" transform="translate(4.652482, 4.673437)">
|
||||
<path d="M8.73559986,11.2615791 C8.73559986,13.6248309 6.79935854,15.5409215 4.40980375,15.5409215 C2.02146263,15.5409215 0.0834007826,13.6248309 0.0834007826,11.2615791 C0.0834007826,8.89992785 2.02146263,6.98303694 4.40980375,6.98303694 C6.79935854,6.98303694 8.73559986,8.89992785 8.73559986,11.2615791" id="Fill-12" fill="#000000"></path>
|
||||
<path d="M22.3930799,13.2641209 L22.3930799,15.2470356 L17.4327257,15.2470356 L17.4327257,7.28636627 L22.233075,7.28636627 L22.233075,9.26848068 L19.4381473,9.26848068 L19.4381473,10.1914133 L22.0813635,10.1914133 L22.0813635,12.1731276 L19.4381473,12.1731276 L19.4381473,13.2641209 L22.3930799,13.2641209 Z M23.3559412,15.2496365 L25.7841318,7.28296504 L28.6367095,7.28296504 L31.0640911,15.2496365 L28.9767452,15.2496365 L28.5218135,13.708481 L25.8990278,13.708481 L25.4426801,15.2496365 L23.3559412,15.2496365 Z M26.4850382,11.7269668 L27.9356009,11.7269668 L27.2723189,9.47555532 L27.1519613,9.47555532 L26.4850382,11.7269668 Z M32.0714544,7.2831651 L34.0764715,7.2831651 L34.0764715,13.2641209 L37.0477888,13.2641209 C36.2329978,2.4118093 27.6012291,0.0671642083 19.7581572,0.0671642083 L11.3960302,0.0671642083 L11.3960302,7.28736663 L12.6337925,7.28736663 C14.8904481,7.28736663 16.2924632,8.80091216 16.2924632,11.2355897 C16.2924632,13.7476951 14.9242292,15.2470356 12.6337925,15.2470356 L11.3960302,15.2470356 L11.3960302,29.6942429 L19.7581572,29.6942429 C32.5104059,29.6942429 36.9480638,23.8371318 37.1046299,15.2470356 L32.0714544,15.2470356 L32.0714544,7.2831651 Z M11.394412,9.26988119 L11.394412,13.2641209 L12.6337925,13.2641209 C13.492681,13.2641209 14.2858279,13.0186324 14.2858279,11.2355897 C14.2858279,9.49336174 13.4030701,9.26988119 12.6337925,9.26988119 L11.394412,9.26988119 Z" id="Fill-14" fill="#CC0066"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.7 KiB |
17
modules/ppcp-wc-gateway/assets/images/mastercard-dark.svg
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="134px" height="84px" viewBox="0 0 134 84" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Mastercard_acceptancemark_80x50</title>
|
||||
<g id="RD-4" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="LP---venmo---social---primary" transform="translate(-967.000000, -1489.000000)">
|
||||
<g id="Mastercard_acceptancemark_80x50" transform="translate(967.005261, 1489.000000)">
|
||||
<rect id="Rectangle" fill="#000000" x="0" y="0" width="132.39159" height="83.7921454" rx="4.581738"></rect>
|
||||
<g id="mc_symbol" transform="translate(16.758429, 11.730900)" fill-rule="nonzero">
|
||||
<rect id="Rectangle" fill="#FF5F00" x="34.961091" y="6.91411461" width="29.2905829" height="48.0845243"></rect>
|
||||
<path d="M37.978038,30.9606238 C37.9706835,21.5790039 42.2555184,12.7149877 49.5979316,6.92260862 C37.1243267,-2.93038543 19.2117299,-1.49521164 8.44863276,10.2195284 C-2.31446439,21.9342684 -2.31446439,39.9954731 8.44863276,51.7102132 C19.2117299,63.4249532 37.1243267,64.8601271 49.5979316,55.0071329 C42.2531818,49.2129145 37.9680851,40.3452244 37.978038,30.9606238 Z" id="Path" fill="#EB001B"></path>
|
||||
<path d="M95.9169404,50.3974171 L95.9169404,49.0088616 L96.3394821,49.0088616 L96.3394821,48.7215742 L95.333833,48.7215742 L95.333833,49.0088616 L95.7310222,49.0088616 L95.7310222,50.3974171 L95.9169404,50.3974171 Z M97.8690825,50.3974171 L97.8690825,48.7215742 L97.5648527,48.7215742 L97.2099177,49.9186049 L96.8549827,48.7215742 L96.5507529,48.7215742 L96.5507529,50.3974171 L96.7704745,50.3974171 L96.7704745,49.1285648 L97.1000568,50.2178626 L97.3282294,50.2178626 L97.6578119,49.1285648 L97.6578119,50.3974171 L97.8690825,50.3974171 Z" id="Shape" fill="#F79E1B"></path>
|
||||
<path d="M98.8240266,30.9606238 C98.8240266,42.6682247 92.1727326,53.3479581 81.695674,58.4641002 C71.2186153,63.5802422 58.7549062,62.2345869 49.5979316,54.9986391 C56.9371412,49.2013423 61.2222985,40.3385046 61.2222985,30.9563768 C61.2222985,21.5742491 56.9371412,12.7114113 49.5979316,6.91411461 C58.7549062,-0.321833201 71.2186153,-1.66748859 81.695674,3.44865344 C92.1727326,8.56479549 98.8240266,19.2445288 98.8240266,30.9521297 L98.8240266,30.9606238 Z" id="Path" fill="#F79E1B"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.4 KiB |
1
modules/ppcp-wc-gateway/assets/images/paylater.svg
Normal file
After Width: | Height: | Size: 16 KiB |
1
modules/ppcp-wc-gateway/assets/images/paypal-button.svg
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
modules/ppcp-wc-gateway/assets/images/paypal.png
Executable file
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 9.7 KiB |
1
modules/ppcp-wc-gateway/assets/images/venmo.svg
Normal file
After Width: | Height: | Size: 15 KiB |
14
modules/ppcp-wc-gateway/assets/images/visa-dark.svg
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="133px" height="84px" viewBox="0 0 133 84" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Visa_acceptancemark_80x50</title>
|
||||
<g id="RD-4" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="LP---venmo---social---primary" transform="translate(-824.000000, -1489.000000)">
|
||||
<g id="Visa_acceptancemark_80x50" transform="translate(824.000000, 1489.000000)">
|
||||
<rect id="Rectangle" fill="#1D1C45" x="0" y="0" width="132.39159" height="83.7921454" rx="4.581738"></rect>
|
||||
<g id="Visa" transform="translate(15.082586, 25.137644)" fill="#FFFFFF" fill-rule="nonzero">
|
||||
<path d="M51.4455687,0.590854329 L44.5028773,32.8958387 L36.1060355,32.8958387 L43.051613,0.590854329 L51.4455687,0.590854329 Z M86.768489,21.4493529 L91.1881833,9.31960182 L93.7323456,21.4493529 L86.768489,21.4493529 Z M96.1370094,32.8958387 L103.90226,32.8958387 L97.1240809,0.590854329 L89.9581922,0.590854329 C88.3462641,0.590854329 86.9873571,1.5231018 86.3841468,2.96001738 L73.7864787,32.8958387 L82.6003729,32.8958387 L84.3517993,28.0694111 L95.1225193,28.0694111 L96.1370094,32.8958387 Z M74.222772,22.3476047 C74.2602923,13.8223523 62.3788765,13.3516799 62.4606514,9.54224952 C62.486627,8.38400266 63.5949177,7.15249753 66.021709,6.83696026 C67.2228384,6.68086746 70.5404952,6.55972795 74.2987747,8.28201565 L75.7740906,1.43212747 C73.7523257,0.701938773 71.1542883,0 67.9188872,0 C59.6211374,0 53.7795214,4.39166605 53.7328615,10.6779922 C53.6775431,15.3310897 57.9014586,17.9238582 61.0839464,19.4709005 C64.3535004,21.0538539 65.4502465,22.0694147 65.4382207,23.4852625 C65.4136884,25.6538032 62.8291196,26.6095125 60.412911,26.6468598 C56.1918816,26.7124572 53.7420011,25.5111171 51.7899855,24.6056832 L50.2699339,31.6849224 C52.2296459,32.581259 55.8508322,33.3626806 59.6062254,33.4009855 C68.4268539,33.4009855 74.1953534,29.0658194 74.222772,22.3476047 L74.222772,22.3476047 Z M39.4487059,0.590854329 L25.8456873,32.8958387 L16.9711835,32.8958387 L10.2771842,7.11419256 C9.87071473,5.52692991 9.51812048,4.94421538 8.28235702,4.2767511 C6.26444044,3.18553796 2.93187165,2.16279498 0,1.52741111 L0.197702912,0.590854329 L14.4847447,0.590854329 C16.3044774,0.590854329 17.9428621,1.79602479 18.3560659,3.88412506 L21.8916291,22.578392 L30.6300016,0.590854329 L39.4487059,0.590854329 L39.4487059,0.590854329 Z" id="Fill-1"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.5 KiB |
|
@ -88,8 +88,7 @@ return array(
|
|||
);
|
||||
},
|
||||
'woocommerce.logger.woocommerce' => function ( ContainerInterface $container ): LoggerInterface {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
if ( ! function_exists( 'wc_get_logger' ) || ! $settings->has( 'logging_enabled' ) || ! $settings->get( 'logging_enabled' ) ) {
|
||||
if ( ! function_exists( 'wc_get_logger' ) || ! $container->get( 'wcgateway.logging.is-enabled' ) ) {
|
||||
return new NullLogger();
|
||||
}
|
||||
|
||||
|
|
86
modules/ppcp-wc-gateway/src/Admin/FeesRenderer.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Renders the PayPal fees in the order details.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\WcGateway\Admin
|
||||
*/
|
||||
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Admin;
|
||||
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
||||
/**
|
||||
* Class FeesRenderer
|
||||
*/
|
||||
class FeesRenderer {
|
||||
/**
|
||||
* Renders the PayPal fees in the order details.
|
||||
*
|
||||
* @param WC_Order $wc_order The order for which to render the fees.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render( WC_Order $wc_order ) : string {
|
||||
$breakdown = $wc_order->get_meta( PayPalGateway::FEES_META_KEY );
|
||||
if ( ! is_array( $breakdown ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = '';
|
||||
|
||||
$fee = $breakdown['paypal_fee'] ?? null;
|
||||
if ( is_array( $fee ) ) {
|
||||
$html .= $this->render_money_row(
|
||||
__( 'PayPal Fee:', 'woocommerce-paypal-payments' ),
|
||||
__( 'The fee PayPal collects for the transaction.', 'woocommerce-paypal-payments' ),
|
||||
$fee['value'],
|
||||
$fee['currency_code'],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$net = $breakdown['net_amount'] ?? null;
|
||||
if ( is_array( $net ) ) {
|
||||
$html .= $this->render_money_row(
|
||||
__( 'PayPal Payout:', 'woocommerce-paypal-payments' ),
|
||||
__( 'The net total that will be credited to your PayPal account.', 'woocommerce-paypal-payments' ),
|
||||
$net['value'],
|
||||
$net['currency_code']
|
||||
);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a row in the order price breakdown table.
|
||||
*
|
||||
* @param string $title The row title.
|
||||
* @param string $tooltip The title tooltip.
|
||||
* @param string|float $value The money value.
|
||||
* @param string $currency The currency code.
|
||||
* @param bool $negative Whether to add the minus sign.
|
||||
* @return string
|
||||
*/
|
||||
private function render_money_row( string $title, string $tooltip, $value, string $currency, bool $negative = false ): string {
|
||||
/**
|
||||
* Bad type hint in WC phpdoc.
|
||||
*
|
||||
* @psalm-suppress InvalidScalarArgument
|
||||
*/
|
||||
return '
|
||||
<tr>
|
||||
<td class="label">' . wc_help_tip( $tooltip ) . ' ' . esc_html( $title ) . '
|
||||
</td>
|
||||
<td width="1%"></td>
|
||||
<td class="total">
|
||||
' .
|
||||
( $negative ? ' - ' : '' ) .
|
||||
wc_price( $value, array( 'currency' => $currency ) ) . '
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
|
@ -24,21 +24,21 @@ class SettingsPageAssets {
|
|||
private $module_url;
|
||||
|
||||
/**
|
||||
* The filesystem path to the module dir.
|
||||
* The assets version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $module_path;
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Assets constructor.
|
||||
*
|
||||
* @param string $module_url The url of this module.
|
||||
* @param string $module_path The filesystem path to this module.
|
||||
* @param string $version The assets version.
|
||||
*/
|
||||
public function __construct( string $module_url, string $module_path ) {
|
||||
$this->module_url = $module_url;
|
||||
$this->module_path = $module_path;
|
||||
public function __construct( string $module_url, string $version ) {
|
||||
$this->module_url = $module_url;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ class SettingsPageAssets {
|
|||
add_action(
|
||||
'admin_enqueue_scripts',
|
||||
function() {
|
||||
if ( ! is_admin() || is_ajax() ) {
|
||||
if ( ! is_admin() || wp_doing_ajax() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -89,13 +89,11 @@ class SettingsPageAssets {
|
|||
* Register assets for admin pages.
|
||||
*/
|
||||
private function register_admin_assets() {
|
||||
$gateway_settings_script_path = trailingslashit( $this->module_path ) . 'assets/js/gateway-settings.js';
|
||||
|
||||
wp_enqueue_script(
|
||||
'ppcp-gateway-settings',
|
||||
trailingslashit( $this->module_url ) . 'assets/js/gateway-settings.js',
|
||||
array(),
|
||||
file_exists( $gateway_settings_script_path ) ? (string) filemtime( $gateway_settings_script_path ) : null,
|
||||
$this->version,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Checkout;
|
||||
|
||||
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
@ -34,29 +33,19 @@ class DisableGateways {
|
|||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* The subscription helper
|
||||
*
|
||||
* @var SubscriptionHelper
|
||||
*/
|
||||
private $subscription_helper;
|
||||
|
||||
/**
|
||||
* DisableGateways constructor.
|
||||
*
|
||||
* @param SessionHandler $session_handler The Session Handler.
|
||||
* @param ContainerInterface $settings The Settings.
|
||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||
*/
|
||||
public function __construct(
|
||||
SessionHandler $session_handler,
|
||||
ContainerInterface $settings,
|
||||
SubscriptionHelper $subscription_helper
|
||||
ContainerInterface $settings
|
||||
) {
|
||||
|
||||
$this->session_handler = $session_handler;
|
||||
$this->settings = $settings;
|
||||
$this->subscription_helper = $subscription_helper;
|
||||
$this->session_handler = $session_handler;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,10 +99,6 @@ class DisableGateways {
|
|||
return true;
|
||||
}
|
||||
|
||||
if ( $this->subscription_helper->cart_contains_subscription() && ! is_user_logged_in() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/**
|
||||
* Renders info about funding sources like Venmo.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\WcGateway\FundingSource
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\FundingSource;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Class FundingSourceRenderer
|
||||
*/
|
||||
class FundingSourceRenderer {
|
||||
/**
|
||||
* The settings.
|
||||
*
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* FundingSourceRenderer constructor.
|
||||
*
|
||||
* @param ContainerInterface $settings The settings.
|
||||
*/
|
||||
public function __construct( ContainerInterface $settings ) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns name of the funding source (suitable for displaying to user).
|
||||
*
|
||||
* @param string $id The ID of the funding source, such as 'venmo'.
|
||||
*/
|
||||
public function render_name( string $id ): string {
|
||||
if ( 'venmo' === $id ) {
|
||||
return __( 'Venmo', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
return $this->settings->has( 'title' ) ?
|
||||
$this->settings->get( 'title' )
|
||||
: __( 'PayPal', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of the funding source (for checkout).
|
||||
*
|
||||
* @param string $id The ID of the funding source, such as 'venmo'.
|
||||
*/
|
||||
public function render_description( string $id ): string {
|
||||
if ( 'venmo' === $id ) {
|
||||
return __( 'Pay via Venmo.', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
return $this->settings->has( 'description' ) ?
|
||||
$this->settings->get( 'description' )
|
||||
: __( 'Pay via PayPal.', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
}
|
|
@ -331,8 +331,9 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
$title_options = $this->card_labels();
|
||||
$images = array_map(
|
||||
function ( string $type ) use ( $title_options ): string {
|
||||
$striped_dark = str_replace( '-dark', '', $type );
|
||||
return '<img
|
||||
title="' . esc_attr( $title_options[ $type ] ) . '"
|
||||
title="' . esc_attr( $title_options[ $striped_dark ] ) . '"
|
||||
src="' . esc_url( $this->module_url ) . 'assets/images/' . esc_attr( $type ) . '.svg"
|
||||
class="ppcp-card-icon"
|
||||
> ';
|
||||
|
@ -439,7 +440,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
parent::init_settings();
|
||||
|
||||
// looks like in some cases WC uses this field instead of get_option.
|
||||
$this->enabled = $this->is_enabled();
|
||||
$this->enabled = $this->is_enabled() ? 'yes' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -468,7 +469,9 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
$ret = parent::update_option( $key, $value );
|
||||
|
||||
if ( 'enabled' === $key ) {
|
||||
|
||||
$this->config->set( 'dcc_enabled', 'yes' === $value );
|
||||
$this->config->set( 'enabled', 'yes' === $value );
|
||||
$this->config->persist();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -18,6 +18,7 @@ use WooCommerce\PayPalCommerce\Onboarding\State;
|
|||
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
use WooCommerce\PayPalCommerce\Vaulting\PaymentTokenRepository;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\FundingSource\FundingSourceRenderer;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor;
|
||||
|
@ -36,6 +37,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
const INTENT_META_KEY = '_ppcp_paypal_intent';
|
||||
const ORDER_ID_META_KEY = '_ppcp_paypal_order_id';
|
||||
const ORDER_PAYMENT_MODE_META_KEY = '_ppcp_paypal_payment_mode';
|
||||
const FEES_META_KEY = '_ppcp_paypal_fees';
|
||||
|
||||
/**
|
||||
* The Settings Renderer.
|
||||
|
@ -44,6 +46,13 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
*/
|
||||
protected $settings_renderer;
|
||||
|
||||
/**
|
||||
* The funding source renderer.
|
||||
*
|
||||
* @var FundingSourceRenderer
|
||||
*/
|
||||
protected $funding_source_renderer;
|
||||
|
||||
/**
|
||||
* The processor for orders.
|
||||
*
|
||||
|
@ -153,6 +162,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
* PayPalGateway constructor.
|
||||
*
|
||||
* @param SettingsRenderer $settings_renderer The Settings Renderer.
|
||||
* @param FundingSourceRenderer $funding_source_renderer The funding source renderer.
|
||||
* @param OrderProcessor $order_processor The Order Processor.
|
||||
* @param AuthorizedPaymentsProcessor $authorized_payments_processor The Authorized Payments Processor.
|
||||
* @param ContainerInterface $config The settings.
|
||||
|
@ -170,6 +180,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
*/
|
||||
public function __construct(
|
||||
SettingsRenderer $settings_renderer,
|
||||
FundingSourceRenderer $funding_source_renderer,
|
||||
OrderProcessor $order_processor,
|
||||
AuthorizedPaymentsProcessor $authorized_payments_processor,
|
||||
ContainerInterface $config,
|
||||
|
@ -190,6 +201,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
$this->order_processor = $order_processor;
|
||||
$this->authorized_payments_processor = $authorized_payments_processor;
|
||||
$this->settings_renderer = $settings_renderer;
|
||||
$this->funding_source_renderer = $funding_source_renderer;
|
||||
$this->config = $config;
|
||||
$this->session_handler = $session_handler;
|
||||
$this->refund_processor = $refund_processor;
|
||||
|
@ -241,6 +253,12 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
$this->description = $this->config->has( 'description' ) ?
|
||||
$this->config->get( 'description' ) : $this->method_description;
|
||||
|
||||
$funding_source = $this->session_handler->funding_source();
|
||||
if ( $funding_source ) {
|
||||
$this->title = $this->funding_source_renderer->render_name( $funding_source );
|
||||
$this->description = $this->funding_source_renderer->render_description( $funding_source );
|
||||
}
|
||||
|
||||
$this->init_form_fields();
|
||||
$this->init_settings();
|
||||
|
||||
|
@ -344,8 +362,15 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
);
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
return __(
|
||||
'Accept PayPal, Pay Later and alternative payment types.',
|
||||
'woocommerce-paypal-payments'
|
||||
);
|
||||
}
|
||||
|
||||
return __(
|
||||
'Accept PayPal, Pay Later and alternative payment types.',
|
||||
'Pay via PayPal.',
|
||||
'woocommerce-paypal-payments'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ declare( strict_types=1 );
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Gateway;
|
||||
|
||||
use Exception;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Authorization;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\AuthorizationStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Subscription\FreeTrialHandlerTrait;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderMetaTrait;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\PaymentsStatusHandlingTrait;
|
||||
|
@ -26,7 +26,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
|
|||
*/
|
||||
trait ProcessPaymentTrait {
|
||||
|
||||
use OrderMetaTrait, PaymentsStatusHandlingTrait, TransactionIdHandlingTrait;
|
||||
use OrderMetaTrait, PaymentsStatusHandlingTrait, TransactionIdHandlingTrait, FreeTrialHandlerTrait;
|
||||
|
||||
/**
|
||||
* Process a payment for an WooCommerce order.
|
||||
|
@ -54,12 +54,14 @@ trait ProcessPaymentTrait {
|
|||
return $failure_data;
|
||||
}
|
||||
|
||||
$payment_method = filter_input( INPUT_POST, 'payment_method', FILTER_SANITIZE_STRING );
|
||||
|
||||
/**
|
||||
* If customer has chosen a saved credit card payment.
|
||||
*/
|
||||
$saved_credit_card = filter_input( INPUT_POST, 'saved_credit_card', FILTER_SANITIZE_STRING );
|
||||
$pay_for_order = filter_input( INPUT_GET, 'pay_for_order', FILTER_SANITIZE_STRING );
|
||||
if ( $saved_credit_card && ! isset( $pay_for_order ) ) {
|
||||
$change_payment = filter_input( INPUT_POST, 'woocommerce_change_payment', FILTER_SANITIZE_STRING );
|
||||
if ( CreditCardGateway::ID === $payment_method && $saved_credit_card && ! isset( $change_payment ) ) {
|
||||
|
||||
$user_id = (int) $wc_order->get_customer_id();
|
||||
$customer = new \WC_Customer( $user_id );
|
||||
|
@ -115,7 +117,10 @@ trait ProcessPaymentTrait {
|
|||
|
||||
$this->handle_new_order_status( $order, $wc_order );
|
||||
|
||||
if ( $this->config->has( 'intent' ) && strtoupper( (string) $this->config->get( 'intent' ) ) === 'CAPTURE' ) {
|
||||
if ( $this->is_free_trial_order( $wc_order ) ) {
|
||||
$this->authorized_payments_processor->void_authorizations( $order );
|
||||
$wc_order->payment_complete();
|
||||
} elseif ( $this->config->has( 'intent' ) && strtoupper( (string) $this->config->get( 'intent' ) ) === 'CAPTURE' ) {
|
||||
$this->authorized_payments_processor->capture_authorized_payment( $wc_order );
|
||||
}
|
||||
|
||||
|
@ -130,6 +135,28 @@ trait ProcessPaymentTrait {
|
|||
}
|
||||
}
|
||||
|
||||
if ( PayPalGateway::ID === $payment_method && $this->is_free_trial_order( $wc_order ) ) {
|
||||
$user_id = (int) $wc_order->get_customer_id();
|
||||
$tokens = $this->payment_token_repository->all_for_user_id( $user_id );
|
||||
if ( ! array_filter(
|
||||
$tokens,
|
||||
function ( PaymentToken $token ): bool {
|
||||
return isset( $token->source()->paypal );
|
||||
}
|
||||
) ) {
|
||||
$this->handle_failure( $wc_order, new Exception( 'No saved PayPal account.' ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
$wc_order->payment_complete();
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
return array(
|
||||
'result' => 'success',
|
||||
'redirect' => $this->get_return_url( $wc_order ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* If customer has chosen change Subscription payment.
|
||||
*/
|
||||
|
@ -171,95 +198,21 @@ trait ProcessPaymentTrait {
|
|||
|
||||
try {
|
||||
if ( $this->order_processor->process( $wc_order ) ) {
|
||||
|
||||
if ( $this->subscription_helper->has_subscription( $order_id ) ) {
|
||||
$this->logger->info( "Trying to save payment for subscription parent order #{$order_id}." );
|
||||
|
||||
$tokens = $this->payment_token_repository->all_for_user_id( $wc_order->get_customer_id() );
|
||||
if ( $tokens ) {
|
||||
$this->logger->info( "Payment for subscription parent order #{$order_id} was saved correctly." );
|
||||
|
||||
if ( $this->config->has( 'intent' ) && strtoupper( (string) $this->config->get( 'intent' ) ) === 'CAPTURE' ) {
|
||||
$this->authorized_payments_processor->capture_authorized_payment( $wc_order );
|
||||
}
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
|
||||
return array(
|
||||
'result' => 'success',
|
||||
'redirect' => $this->get_return_url( $wc_order ),
|
||||
);
|
||||
}
|
||||
|
||||
$this->logger->error( "Payment for subscription parent order #{$order_id} was not saved." );
|
||||
|
||||
$paypal_order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
|
||||
if ( ! $paypal_order_id ) {
|
||||
throw new RuntimeException( 'PayPal order ID not found in meta.' );
|
||||
}
|
||||
$order = $this->order_endpoint->order( $paypal_order_id );
|
||||
|
||||
$purchase_units = $order->purchase_units();
|
||||
if ( ! $purchase_units ) {
|
||||
throw new RuntimeException( 'No purchase units.' );
|
||||
}
|
||||
|
||||
$payments = $purchase_units[0]->payments();
|
||||
if ( ! $payments ) {
|
||||
throw new RuntimeException( 'No payments.' );
|
||||
}
|
||||
|
||||
$this->logger->debug(
|
||||
sprintf(
|
||||
'Trying to void order %1$s, payments: %2$s.',
|
||||
$order->id(),
|
||||
wp_json_encode( $payments->to_array() )
|
||||
as_schedule_single_action(
|
||||
time() + ( 1 * MINUTE_IN_SECONDS ),
|
||||
'woocommerce_paypal_payments_check_saved_payment',
|
||||
array(
|
||||
'order_id' => $order_id,
|
||||
'customer_id' => $wc_order->get_customer_id(),
|
||||
'intent' => $this->config->has( 'intent' ) ? $this->config->get( 'intent' ) : '',
|
||||
)
|
||||
);
|
||||
|
||||
$voidable_authorizations = array_filter(
|
||||
$payments->authorizations(),
|
||||
function ( Authorization $authorization ): bool {
|
||||
return $authorization->is_voidable();
|
||||
}
|
||||
);
|
||||
if ( ! $voidable_authorizations ) {
|
||||
throw new RuntimeException( 'No voidable authorizations.' );
|
||||
}
|
||||
|
||||
foreach ( $voidable_authorizations as $authorization ) {
|
||||
$this->payments_endpoint->void( $authorization );
|
||||
}
|
||||
|
||||
$this->logger->debug(
|
||||
sprintf(
|
||||
'Order %1$s voided successfully.',
|
||||
$order->id()
|
||||
)
|
||||
);
|
||||
|
||||
$error_message = __( 'Could not process order because it was not possible to save the payment.', 'woocommerce-paypal-payments' );
|
||||
$wc_order->update_status( 'failed', $error_message );
|
||||
|
||||
$subscriptions = wcs_get_subscriptions_for_order( $order_id );
|
||||
foreach ( $subscriptions as $key => $subscription ) {
|
||||
if ( $subscription->get_parent_id() === $order_id ) {
|
||||
try {
|
||||
$subscription->update_status( 'cancelled' );
|
||||
break;
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->error( "Could not update cancelled status on subscription #{$subscription->get_id()} " . $exception->getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
wc_add_notice( $error_message, 'error' );
|
||||
|
||||
return $failure_data;
|
||||
}
|
||||
|
||||
WC()->cart->empty_cart();
|
||||
$this->session_handler->destroy_session_data();
|
||||
|
||||
return array(
|
||||
'result' => 'success',
|
||||
'redirect' => $this->get_return_url( $wc_order ),
|
||||
|
@ -269,7 +222,7 @@ trait ProcessPaymentTrait {
|
|||
if ( $error->has_detail( 'INSTRUMENT_DECLINED' ) ) {
|
||||
$wc_order->update_status(
|
||||
'failed',
|
||||
__( 'Instrument declined.', 'woocommerce-paypal-payments' )
|
||||
__( 'Instrument declined. ', 'woocommerce-paypal-payments' ) . $error->details()[0]->description ?? ''
|
||||
);
|
||||
|
||||
$this->session_handler->increment_insufficient_funding_tries();
|
||||
|
@ -290,6 +243,19 @@ trait ProcessPaymentTrait {
|
|||
);
|
||||
}
|
||||
|
||||
$error_message = $error->getMessage();
|
||||
if ( $error->issues() ) {
|
||||
$error_message = implode(
|
||||
array_map(
|
||||
function( $issue ) {
|
||||
return $issue->issue . ' ' . $issue->description . '<br/>';
|
||||
},
|
||||
$error->issues()
|
||||
)
|
||||
);
|
||||
}
|
||||
wc_add_notice( $error_message, 'error' );
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
} catch ( RuntimeException $error ) {
|
||||
$this->handle_failure( $wc_order, $error );
|
||||
|
@ -300,9 +266,10 @@ trait ProcessPaymentTrait {
|
|||
$this->order_processor->last_error(),
|
||||
'error'
|
||||
);
|
||||
|
||||
$wc_order->update_status(
|
||||
'failed',
|
||||
__( 'Could not process order.', 'woocommerce-paypal-payments' )
|
||||
__( 'Could not process order. ', 'woocommerce-paypal-payments' ) . $this->order_processor->last_error()
|
||||
);
|
||||
|
||||
return $failure_data;
|
||||
|
@ -347,7 +314,7 @@ trait ProcessPaymentTrait {
|
|||
|
||||
$wc_order->update_status(
|
||||
'failed',
|
||||
__( 'Could not process order.', 'woocommerce-paypal-payments' )
|
||||
__( 'Could not process order. ', 'woocommerce-paypal-payments' ) . $error->getMessage()
|
||||
);
|
||||
|
||||
$this->session_handler->destroy_session_data();
|
||||
|
|
|
@ -57,7 +57,7 @@ class ConnectAdminNotice {
|
|||
$message = sprintf(
|
||||
/* translators: %1$s the gateway name. */
|
||||
__(
|
||||
'PayPal Checkout is almost ready. To get started, <a href="%1$s">connect your account</a>.',
|
||||
'PayPal Payments is almost ready. To get started, <a href="%1$s">connect your account</a>.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' )
|
||||
|
@ -71,6 +71,6 @@ class ConnectAdminNotice {
|
|||
* @return bool
|
||||
*/
|
||||
protected function should_display(): bool {
|
||||
return $this->state->current_state() < State::STATE_PROGRESSIVE;
|
||||
return $this->state->current_state() !== State::STATE_ONBOARDED;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,19 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Processor;
|
||||
|
||||
use Exception;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Authorization;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\AuthorizationStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\CaptureStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Money;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
|
||||
|
||||
|
@ -72,6 +77,20 @@ class AuthorizedPaymentsProcessor {
|
|||
*/
|
||||
private $notice;
|
||||
|
||||
/**
|
||||
* The settings.
|
||||
*
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* The subscription helper.
|
||||
*
|
||||
* @var SubscriptionHelper
|
||||
*/
|
||||
private $subscription_helper;
|
||||
|
||||
/**
|
||||
* AuthorizedPaymentsProcessor constructor.
|
||||
*
|
||||
|
@ -79,28 +98,34 @@ class AuthorizedPaymentsProcessor {
|
|||
* @param PaymentsEndpoint $payments_endpoint The Payments endpoint.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param AuthorizeOrderActionNotice $notice The notice.
|
||||
* @param ContainerInterface $config The settings.
|
||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||
*/
|
||||
public function __construct(
|
||||
OrderEndpoint $order_endpoint,
|
||||
PaymentsEndpoint $payments_endpoint,
|
||||
LoggerInterface $logger,
|
||||
AuthorizeOrderActionNotice $notice
|
||||
AuthorizeOrderActionNotice $notice,
|
||||
ContainerInterface $config,
|
||||
SubscriptionHelper $subscription_helper
|
||||
) {
|
||||
|
||||
$this->order_endpoint = $order_endpoint;
|
||||
$this->payments_endpoint = $payments_endpoint;
|
||||
$this->logger = $logger;
|
||||
$this->notice = $notice;
|
||||
$this->order_endpoint = $order_endpoint;
|
||||
$this->payments_endpoint = $payments_endpoint;
|
||||
$this->logger = $logger;
|
||||
$this->notice = $notice;
|
||||
$this->config = $config;
|
||||
$this->subscription_helper = $subscription_helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a WooCommerce order.
|
||||
*
|
||||
* @param \WC_Order $wc_order The WooCommerce order.
|
||||
* @param WC_Order $wc_order The WooCommerce order.
|
||||
*
|
||||
* @return string One of the AuthorizedPaymentsProcessor status constants.
|
||||
*/
|
||||
public function process( \WC_Order $wc_order ): string {
|
||||
public function process( WC_Order $wc_order ): string {
|
||||
$this->captures = array();
|
||||
|
||||
try {
|
||||
|
@ -123,7 +148,7 @@ class AuthorizedPaymentsProcessor {
|
|||
}
|
||||
|
||||
try {
|
||||
$this->capture_authorizations( ...$authorizations );
|
||||
$this->captures[] = $this->capture_authorization( $wc_order, ...$authorizations );
|
||||
} catch ( Exception $exception ) {
|
||||
$this->logger->error( 'Failed to capture authorization: ' . $exception->getMessage() );
|
||||
return self::FAILED;
|
||||
|
@ -144,11 +169,11 @@ class AuthorizedPaymentsProcessor {
|
|||
/**
|
||||
* Captures an authorized payment for an WooCommerce order.
|
||||
*
|
||||
* @param \WC_Order $wc_order The WooCommerce order.
|
||||
* @param WC_Order $wc_order The WooCommerce order.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function capture_authorized_payment( \WC_Order $wc_order ): bool {
|
||||
public function capture_authorized_payment( WC_Order $wc_order ): bool {
|
||||
$result_status = $this->process( $wc_order );
|
||||
$this->render_authorization_message_for_status( $result_status );
|
||||
|
||||
|
@ -188,6 +213,71 @@ class AuthorizedPaymentsProcessor {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures the authorized payments for the given customer.
|
||||
*
|
||||
* @param int $customer_id The customer id.
|
||||
*/
|
||||
public function capture_authorized_payments_for_customer( int $customer_id ): void {
|
||||
|
||||
$wc_orders = wc_get_orders(
|
||||
array(
|
||||
'customer_id' => $customer_id,
|
||||
'status' => array( 'wc-on-hold' ),
|
||||
'limit' => -1,
|
||||
)
|
||||
);
|
||||
|
||||
if (
|
||||
$this->config->has( 'intent' )
|
||||
&& strtoupper( (string) $this->config->get( 'intent' ) ) === 'CAPTURE'
|
||||
&& is_array( $wc_orders )
|
||||
) {
|
||||
foreach ( $wc_orders as $wc_order ) {
|
||||
if (
|
||||
$this->subscription_helper->has_subscription( $wc_order->get_id() )
|
||||
&& $wc_order->get_meta( '_ppcp_captured_vault_webhook' ) === 'false'
|
||||
) {
|
||||
$this->capture_authorized_payment( $wc_order );
|
||||
$wc_order->update_meta_data( '_ppcp_captured_vault_webhook', 'true' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Voids authorizations for the given PayPal order.
|
||||
*
|
||||
* @param Order $order The PayPal order.
|
||||
* @return void
|
||||
* @throws RuntimeException When there is a problem voiding authorizations.
|
||||
*/
|
||||
public function void_authorizations( Order $order ): void {
|
||||
$purchase_units = $order->purchase_units();
|
||||
if ( ! $purchase_units ) {
|
||||
throw new RuntimeException( 'No purchase units.' );
|
||||
}
|
||||
|
||||
$payments = $purchase_units[0]->payments();
|
||||
if ( ! $payments ) {
|
||||
throw new RuntimeException( 'No payments.' );
|
||||
}
|
||||
|
||||
$voidable_authorizations = array_filter(
|
||||
$payments->authorizations(),
|
||||
function ( Authorization $authorization ): bool {
|
||||
return $authorization->is_voidable();
|
||||
}
|
||||
);
|
||||
if ( ! $voidable_authorizations ) {
|
||||
throw new RuntimeException( 'No voidable authorizations.' );
|
||||
}
|
||||
|
||||
foreach ( $voidable_authorizations as $authorization ) {
|
||||
$this->payments_endpoint->void( $authorization );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the notice for a status.
|
||||
*
|
||||
|
@ -211,11 +301,11 @@ class AuthorizedPaymentsProcessor {
|
|||
/**
|
||||
* Returns the PayPal order from a given WooCommerce order.
|
||||
*
|
||||
* @param \WC_Order $wc_order The WooCommerce order.
|
||||
* @param WC_Order $wc_order The WooCommerce order.
|
||||
*
|
||||
* @return Order
|
||||
*/
|
||||
private function paypal_order_from_wc_order( \WC_Order $wc_order ): Order {
|
||||
private function paypal_order_from_wc_order( WC_Order $wc_order ): Order {
|
||||
$order_id = $wc_order->get_meta( PayPalGateway::ORDER_ID_META_KEY );
|
||||
return $this->order_endpoint->order( $order_id );
|
||||
}
|
||||
|
@ -239,15 +329,21 @@ class AuthorizedPaymentsProcessor {
|
|||
}
|
||||
|
||||
/**
|
||||
* Captures the authorizations.
|
||||
* Captures the authorization.
|
||||
*
|
||||
* @param WC_Order $order The order.
|
||||
* @param Authorization ...$authorizations All authorizations.
|
||||
* @throws Exception If capture failed.
|
||||
*/
|
||||
private function capture_authorizations( Authorization ...$authorizations ) {
|
||||
private function capture_authorization( WC_Order $order, Authorization ...$authorizations ): Capture {
|
||||
$uncaptured_authorizations = $this->authorizations_to_capture( ...$authorizations );
|
||||
foreach ( $uncaptured_authorizations as $authorization ) {
|
||||
$this->captures[] = $this->payments_endpoint->capture( $authorization->id() );
|
||||
if ( ! $uncaptured_authorizations ) {
|
||||
throw new Exception( 'No authorizations to capture.' );
|
||||
}
|
||||
|
||||
$authorization = end( $uncaptured_authorizations );
|
||||
|
||||
return $this->payments_endpoint->capture( $authorization->id(), new Money( (float) $order->get_total(), $order->get_currency() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
|||
use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
use WooCommerce\PayPalCommerce\Vaulting\PaymentTokenRepository;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
@ -98,6 +99,13 @@ class OrderProcessor {
|
|||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* The subscription helper.
|
||||
*
|
||||
* @var SubscriptionHelper
|
||||
*/
|
||||
private $subscription_helper;
|
||||
|
||||
/**
|
||||
* OrderProcessor constructor.
|
||||
*
|
||||
|
@ -109,6 +117,7 @@ class OrderProcessor {
|
|||
* @param Settings $settings The Settings.
|
||||
* @param LoggerInterface $logger A logger service.
|
||||
* @param Environment $environment The environment.
|
||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||
*/
|
||||
public function __construct(
|
||||
SessionHandler $session_handler,
|
||||
|
@ -118,7 +127,8 @@ class OrderProcessor {
|
|||
AuthorizedPaymentsProcessor $authorized_payments_processor,
|
||||
Settings $settings,
|
||||
LoggerInterface $logger,
|
||||
Environment $environment
|
||||
Environment $environment,
|
||||
SubscriptionHelper $subscription_helper
|
||||
) {
|
||||
|
||||
$this->session_handler = $session_handler;
|
||||
|
@ -129,6 +139,7 @@ class OrderProcessor {
|
|||
$this->settings = $settings;
|
||||
$this->environment = $environment;
|
||||
$this->logger = $logger;
|
||||
$this->subscription_helper = $subscription_helper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,6 +152,7 @@ class OrderProcessor {
|
|||
public function process( \WC_Order $wc_order ): bool {
|
||||
$order = $this->session_handler->order();
|
||||
if ( ! $order ) {
|
||||
$this->last_error = __( 'No PayPal order found in the current WooCommerce session.', 'woocommerce-paypal-payments' );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -172,6 +184,10 @@ class OrderProcessor {
|
|||
$order = $this->order_endpoint->authorize( $order );
|
||||
|
||||
$wc_order->update_meta_data( AuthorizedPaymentsProcessor::CAPTURED_META_KEY, 'false' );
|
||||
|
||||
if ( $this->subscription_helper->has_subscription( $wc_order->get_id() ) ) {
|
||||
$wc_order->update_meta_data( '_ppcp_captured_vault_webhook', 'false' );
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_id = $this->get_paypal_order_transaction_id( $order );
|
||||
|
@ -189,8 +205,6 @@ class OrderProcessor {
|
|||
$wc_order->update_meta_data( AuthorizedPaymentsProcessor::CAPTURED_META_KEY, 'true' );
|
||||
$wc_order->update_status( 'processing' );
|
||||
}
|
||||
WC()->cart->empty_cart();
|
||||
$this->session_handler->destroy_session_data();
|
||||
$this->last_error = '';
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,10 @@ trait PaymentsStatusHandlingTrait {
|
|||
switch ( $status->name() ) {
|
||||
case CaptureStatus::COMPLETED:
|
||||
$wc_order->payment_complete();
|
||||
/**
|
||||
* Fired when PayPal order is captured.
|
||||
*/
|
||||
do_action( 'woocommerce_paypal_payments_order_captured', $wc_order, $capture );
|
||||
break;
|
||||
// It is checked in the capture endpoint already, but there are other ways to capture,
|
||||
// such as when paid via saved card.
|
||||
|
|
|
@ -36,6 +36,15 @@ trait TransactionIdHandlingTrait {
|
|||
try {
|
||||
$wc_order->set_transaction_id( $transaction_id );
|
||||
$wc_order->save();
|
||||
|
||||
$wc_order->add_order_note(
|
||||
sprintf(
|
||||
/* translators: %s is the PayPal transaction ID */
|
||||
__( 'PayPal transaction ID: %s', 'woocommerce-paypal-payments' ),
|
||||
$transaction_id
|
||||
)
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch ( Exception $exception ) {
|
||||
if ( $logger ) {
|
||||
|
|
|
@ -14,9 +14,9 @@ use WooCommerce\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
use WooCommerce\PayPalCommerce\Webhooks\WebhookRegistrar;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
|
||||
/**
|
||||
* Class SettingsListener
|
||||
|
@ -146,8 +146,14 @@ class SettingsListener {
|
|||
}
|
||||
$this->settings->persist();
|
||||
|
||||
/**
|
||||
* The hook fired before performing the redirect at the end of onboarding after saving the merchant ID/email.
|
||||
*/
|
||||
do_action( 'woocommerce_paypal_payments_onboarding_before_redirect' );
|
||||
|
||||
/**
|
||||
* The URL opened at the end of onboarding after saving the merchant ID/email.
|
||||
*/
|
||||
$redirect_url = apply_filters( 'woocommerce_paypal_payments_onboarding_redirect_url', admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' ) );
|
||||
if ( ! $this->settings->has( 'client_id' ) || ! $this->settings->get( 'client_id' ) ) {
|
||||
$redirect_url = add_query_arg( 'ppcp-onboarding-error', '1', $redirect_url );
|
||||
|
@ -203,7 +209,7 @@ class SettingsListener {
|
|||
$this->settings->set( 'message_cart_enabled', false );
|
||||
$this->settings->persist();
|
||||
|
||||
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' );
|
||||
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway&ppcp-tab=ppcp-credit-card-gateway' );
|
||||
wp_safe_redirect( $redirect_url, 302 );
|
||||
exit;
|
||||
}
|
||||
|
@ -372,14 +378,11 @@ class SettingsListener {
|
|||
case 'text':
|
||||
case 'number':
|
||||
case 'ppcp-text-input':
|
||||
case 'ppcp-password':
|
||||
$settings[ $key ] = isset( $raw_data[ $key ] ) ? sanitize_text_field( $raw_data[ $key ] ) : '';
|
||||
$settings[ $key ] = isset( $raw_data[ $key ] ) ? wp_kses_post( $raw_data[ $key ] ) : '';
|
||||
break;
|
||||
case 'ppcp-password':
|
||||
case 'password':
|
||||
if ( empty( $raw_data[ $key ] ) ) {
|
||||
break;
|
||||
}
|
||||
$settings[ $key ] = sanitize_text_field( $raw_data[ $key ] );
|
||||
$settings[ $key ] = $raw_data[ $key ] ?? '';
|
||||
break;
|
||||
case 'ppcp-multiselect':
|
||||
$values = isset( $raw_data[ $key ] ) ? (array) $raw_data[ $key ] : array();
|
||||
|
@ -451,7 +454,7 @@ class SettingsListener {
|
|||
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
if ( ! current_user_can( 'manage_woocommerce' ) ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -357,8 +357,18 @@ $data_rows_html
|
|||
?>
|
||||
<input type="hidden" name="ppcp-nonce" value="<?php echo esc_attr( $nonce ); ?>">
|
||||
<?php
|
||||
|
||||
// Create a hidden first row with 2 cells to avoid issues with table-layout: fixed
|
||||
// when the first visible row needs to have one cell.
|
||||
?>
|
||||
<tr style="height: 1px; padding-top: 0; padding-bottom: 0;">
|
||||
<th style="padding-top: 0; padding-bottom: 0;"></th>
|
||||
<td style="padding-top: 0; padding-bottom: 0;"></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach ( $this->fields as $field => $config ) :
|
||||
if ( ! in_array( $this->state->current_state(), $config['screens'], true ) ) {
|
||||
if ( ! in_array( $this->state->environment_state( $config['state_from'] ?? null ), $config['screens'], true ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! $this->field_matches_page( $config, $this->page_id ) ) {
|
||||
|
@ -386,14 +396,18 @@ $data_rows_html
|
|||
$key = 'ppcp[' . $field . ']';
|
||||
$id = 'ppcp-' . $field;
|
||||
$config['id'] = $id;
|
||||
$colspan = 'ppcp-heading' !== $config['type'] ? 1 : 2;
|
||||
$colspan = ( 'ppcp-heading' !== $config['type'] && isset( $config['title'] ) ) ? 1 : 2;
|
||||
$classes = isset( $config['classes'] ) ? $config['classes'] : array();
|
||||
$classes[] = 'ppcp-settings-field';
|
||||
$classes[] = sprintf( 'ppcp-settings-field-%s', str_replace( 'ppcp-', '', $config['type'] ) );
|
||||
$description = isset( $config['description'] ) ? $config['description'] : '';
|
||||
if ( 1 !== $colspan ) {
|
||||
$classes[] = 'ppcp-settings-no-title-col';
|
||||
}
|
||||
$description = isset( $config['description'] ) ? $config['description'] : '';
|
||||
unset( $config['description'] );
|
||||
?>
|
||||
<tr valign="top" id="<?php echo esc_attr( 'field-' . $field ); ?>" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
|
||||
<?php if ( 'ppcp-heading' !== $config['type'] ) : ?>
|
||||
<?php if ( 'ppcp-heading' !== $config['type'] && isset( $config['title'] ) ) : ?>
|
||||
<th scope="row">
|
||||
<label
|
||||
for="<?php echo esc_attr( $id ); ?>"
|
||||
|
@ -442,7 +456,14 @@ $data_rows_html
|
|||
* @param array $config The configuration array.
|
||||
*/
|
||||
private function render_text( array $config ) {
|
||||
echo wp_kses_post( $config['text'] );
|
||||
$raw = $config['raw'] ?? false;
|
||||
if ( $raw ) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo $config['text'];
|
||||
} else {
|
||||
echo wp_kses_post( $config['text'] );
|
||||
}
|
||||
|
||||
if ( isset( $config['hidden'] ) ) {
|
||||
$value = $this->settings->has( $config['hidden'] ) ?
|
||||
(string) $this->settings->get( $config['hidden'] )
|
||||
|
@ -518,6 +539,14 @@ $data_rows_html
|
|||
'woocommerce-paypal-payments'
|
||||
);
|
||||
?>
|
||||
<a href="https://developer.paypal.com/docs/checkout/advanced/currency-availability-advanced-cards/">
|
||||
<?php
|
||||
esc_html_e(
|
||||
'Advanced credit and debit country and currency availability.',
|
||||
'woocommerce-paypal-payments'
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -11,9 +11,12 @@ namespace WooCommerce\PayPalCommerce\WcGateway;
|
|||
|
||||
use Dhii\Container\ServiceProvider;
|
||||
use Dhii\Modular\Module\ModuleInterface;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\AdminNotices\Repository\Repository;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayPalRequestIdRepository;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Admin\FeesRenderer;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Admin\PaymentStatusOrderDetail;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Admin\RenderAuthorizeAction;
|
||||
|
@ -21,6 +24,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Assets\SettingsPageAssets;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Checkout\CheckoutPayPalAddressPreset;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Checkout\DisableGateways;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\ReturnUrlEndpoint;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Notice\ConnectAdminNotice;
|
||||
|
@ -70,10 +74,39 @@ class WCGatewayModule implements ModuleInterface {
|
|||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_order_captured',
|
||||
function ( WC_Order $wc_order, Capture $capture ) {
|
||||
$breakdown = $capture->seller_receivable_breakdown();
|
||||
if ( $breakdown ) {
|
||||
$wc_order->update_meta_data( PayPalGateway::FEES_META_KEY, $breakdown->to_array() );
|
||||
$wc_order->save_meta_data();
|
||||
}
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
|
||||
$fees_renderer = $c->get( 'wcgateway.admin.fees-renderer' );
|
||||
assert( $fees_renderer instanceof FeesRenderer );
|
||||
|
||||
add_action(
|
||||
'woocommerce_admin_order_totals_after_total',
|
||||
function ( int $order_id ) use ( $fees_renderer ) {
|
||||
$wc_order = wc_get_order( $order_id );
|
||||
if ( ! $wc_order instanceof WC_Order ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo $fees_renderer->render( $wc_order );
|
||||
}
|
||||
);
|
||||
|
||||
if ( $c->has( 'wcgateway.url' ) ) {
|
||||
$assets = new SettingsPageAssets(
|
||||
$c->get( 'wcgateway.url' ),
|
||||
$c->get( 'wcgateway.absolute-path' )
|
||||
$c->get( 'ppcp.asset-version' )
|
||||
);
|
||||
$assets->register_assets();
|
||||
}
|
||||
|
@ -132,16 +165,21 @@ class WCGatewayModule implements ModuleInterface {
|
|||
}
|
||||
);
|
||||
|
||||
add_filter(
|
||||
'woocommerce_email_recipient_customer_on_hold_order',
|
||||
function( $recipient, $order ) {
|
||||
if ( $order->get_payment_method() === PayPalGateway::ID || $order->get_payment_method() === CreditCardGateway::ID ) {
|
||||
$recipient = '';
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_gateway_migrate',
|
||||
static function () use ( $c ) {
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
try {
|
||||
if ( $settings->get( '3d_secure_contingency' ) === '3D_SECURE' ) {
|
||||
$settings->set( '3d_secure_contingency', 'SCA_ALWAYS' );
|
||||
$settings->persist();
|
||||
}
|
||||
} catch ( NotFoundException $exception ) {
|
||||
return;
|
||||
}
|
||||
return $recipient;
|
||||
},
|
||||
10,
|
||||
2
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -242,7 +280,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
static function ( $order_actions ) use ( $container ): array {
|
||||
global $theorder;
|
||||
|
||||
if ( ! is_a( $theorder, \WC_Order::class ) ) {
|
||||
if ( ! is_a( $theorder, WC_Order::class ) ) {
|
||||
return $order_actions;
|
||||
}
|
||||
|
||||
|
@ -258,7 +296,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
|
||||
add_action(
|
||||
'woocommerce_order_action_ppcp_authorize_order',
|
||||
static function ( \WC_Order $wc_order ) use ( $container ) {
|
||||
static function ( WC_Order $wc_order ) use ( $container ) {
|
||||
|
||||
/**
|
||||
* The authorized payments processor.
|
||||
|
|
|
@ -1639,9 +1639,9 @@ mimic-fn@^2.1.0:
|
|||
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
|
||||
|
||||
minimist@^1.2.0, minimist@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||
version "1.2.6"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||
|
||||
ms@2.1.2:
|
||||
version "2.1.2"
|
||||
|
|