mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Merge branch 'trunk' into PCP-81-de-now-has-12-month-installments
This commit is contained in:
commit
faf7e86e51
6 changed files with 88 additions and 7 deletions
|
@ -23,6 +23,7 @@ class MessagesApply {
|
||||||
private $countries = array(
|
private $countries = array(
|
||||||
'US',
|
'US',
|
||||||
'DE',
|
'DE',
|
||||||
|
'GB',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -541,7 +541,7 @@ return array(
|
||||||
'default' => false,
|
'default' => false,
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'description' => __(
|
'description' => __(
|
||||||
'If you enable this setting, PayPal will be instructed not to allow the buyer to use funding sources that take additional time to complete (for example, eChecks). Instead, the buyer will be required to use an instant funding source, such as an instant transfer, a credit/debit card, or PayPal Credit.',
|
'If you enable this setting, PayPal will be instructed not to allow the buyer to use funding sources that take additional time to complete (for example, eChecks). Instead, the buyer will be required to use an instant funding source, such as an instant transfer, a credit/debit card, or Pay Later.',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
),
|
),
|
||||||
'label' => __( 'Require Instant Payment', 'woocommerce-paypal-payments' ),
|
'label' => __( 'Require Instant Payment', 'woocommerce-paypal-payments' ),
|
||||||
|
@ -603,7 +603,7 @@ return array(
|
||||||
),
|
),
|
||||||
'options' => array(
|
'options' => array(
|
||||||
'card' => _x( 'Credit or debit cards', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
'card' => _x( 'Credit or debit cards', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||||
'credit' => _x( 'PayPal Credit', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
'credit' => _x( 'Pay Later', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||||
'sepa' => _x( 'SEPA-Lastschrift', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
'sepa' => _x( 'SEPA-Lastschrift', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||||
'bancontact' => _x( 'Bancontact', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
'bancontact' => _x( 'Bancontact', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||||
'eps' => _x( 'eps', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
'eps' => _x( 'eps', 'Name of payment method', 'woocommerce-paypal-payments' ),
|
||||||
|
@ -804,7 +804,7 @@ return array(
|
||||||
),
|
),
|
||||||
'requirements' => array( 'messages' ),
|
'requirements' => array( 'messages' ),
|
||||||
'gateway' => 'paypal',
|
'gateway' => 'paypal',
|
||||||
'description' => str_replace( '<a>', '<a href="https://www.paypal.com/us/business/buy-now-pay-later">', __( 'Customize the appearance of <a>PayPal Credit messages</a> on checkout to promote special financing offers, which help increase sales.', 'woocommerce-paypal-payments' ) ),
|
'description' => str_replace( '<a>', '<a href="https://www.paypal.com/us/business/buy-now-pay-later">', __( 'Customize the appearance of <a>Pay Later messages</a> on checkout to promote special financing offers, which help increase sales.', 'woocommerce-paypal-payments' ) ),
|
||||||
'class' => array( 'ppcp-subheading' ),
|
'class' => array( 'ppcp-subheading' ),
|
||||||
),
|
),
|
||||||
'message_enabled' => array(
|
'message_enabled' => array(
|
||||||
|
@ -1107,7 +1107,7 @@ return array(
|
||||||
),
|
),
|
||||||
'requirements' => array( 'messages' ),
|
'requirements' => array( 'messages' ),
|
||||||
'gateway' => 'paypal',
|
'gateway' => 'paypal',
|
||||||
'description' => str_replace( '<a>', '<a href="https://www.paypal.com/us/business/buy-now-pay-later">', __( 'Customize the appearance of <a>PayPal Credit messages</a> on product pages to promote special financing offers, which help increase sales.', 'woocommerce-paypal-payments' ) ),
|
'description' => str_replace( '<a>', '<a href="https://www.paypal.com/us/business/buy-now-pay-later">', __( 'Customize the appearance of <a>Pay Later messages</a> on product pages to promote special financing offers, which help increase sales.', 'woocommerce-paypal-payments' ) ),
|
||||||
'class' => array( 'ppcp-subheading' ),
|
'class' => array( 'ppcp-subheading' ),
|
||||||
),
|
),
|
||||||
'message_product_enabled' => array(
|
'message_product_enabled' => array(
|
||||||
|
@ -1410,7 +1410,7 @@ return array(
|
||||||
),
|
),
|
||||||
'requirements' => array( 'messages' ),
|
'requirements' => array( 'messages' ),
|
||||||
'gateway' => 'paypal',
|
'gateway' => 'paypal',
|
||||||
'description' => str_replace( '<a>', '<a href="https://www.paypal.com/us/business/buy-now-pay-later">', __( 'Customize the appearance of <a>PayPal Credit messages</a> on your cart page to promote special financing offers, which help increase sales.', 'woocommerce-paypal-payments' ) ),
|
'description' => str_replace( '<a>', '<a href="https://www.paypal.com/us/business/buy-now-pay-later">', __( 'Customize the appearance of <a>Pay Later messages</a> on your cart page to promote special financing offers, which help increase sales.', 'woocommerce-paypal-payments' ) ),
|
||||||
'class' => array( 'ppcp-subheading' ),
|
'class' => array( 'ppcp-subheading' ),
|
||||||
),
|
),
|
||||||
'message_cart_enabled' => array(
|
'message_cart_enabled' => array(
|
||||||
|
@ -1785,6 +1785,48 @@ return array(
|
||||||
unset( $fields['disable_funding']['options']['card'] );
|
unset( $fields['disable_funding']['options']['card'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable Pay in 3 for UK.
|
||||||
|
*/
|
||||||
|
if ( 'GB' === $country ) {
|
||||||
|
$fields['message_heading'] = array(
|
||||||
|
'heading' => __( 'Pay Later Messaging on Checkout', 'woocommerce-paypal-payments' ),
|
||||||
|
'type' => 'ppcp-heading',
|
||||||
|
'screens' => array(
|
||||||
|
State::STATE_PROGRESSIVE,
|
||||||
|
State::STATE_ONBOARDED,
|
||||||
|
),
|
||||||
|
'requirements' => array( 'messages' ),
|
||||||
|
'gateway' => 'paypal',
|
||||||
|
'description' => __( 'Display pay later messaging on your site for offers like Pay in 3, which lets customers pay with 3 interest-free monthly payments. We’ll show messages on your site to promote this feature for you. You may not promote pay later offers with any other content, marketing, or materials.', 'woocommerce-paypal-payments' ),
|
||||||
|
'class' => array( 'ppcp-subheading' ),
|
||||||
|
);
|
||||||
|
$fields['message_product_heading'] = array(
|
||||||
|
'heading' => __( 'Pay Later Messaging on Single Product Page', 'woocommerce-paypal-payments' ),
|
||||||
|
'type' => 'ppcp-heading',
|
||||||
|
'screens' => array(
|
||||||
|
State::STATE_PROGRESSIVE,
|
||||||
|
State::STATE_ONBOARDED,
|
||||||
|
),
|
||||||
|
'requirements' => array( 'messages' ),
|
||||||
|
'gateway' => 'paypal',
|
||||||
|
'description' => __( 'Display pay later messaging on your site for offers like Pay in 3, which lets customers pay with 3 interest-free monthly payments. We’ll show messages on your site to promote this feature for you. You may not promote pay later offers with any other content, marketing, or materials.', 'woocommerce-paypal-payments' ),
|
||||||
|
'class' => array( 'ppcp-subheading' ),
|
||||||
|
);
|
||||||
|
$fields['message_cart_heading'] = array(
|
||||||
|
'heading' => __( 'Pay Later Messaging on Cart', 'woocommerce-paypal-payments' ),
|
||||||
|
'type' => 'ppcp-heading',
|
||||||
|
'screens' => array(
|
||||||
|
State::STATE_PROGRESSIVE,
|
||||||
|
State::STATE_ONBOARDED,
|
||||||
|
),
|
||||||
|
'requirements' => array( 'messages' ),
|
||||||
|
'gateway' => 'paypal',
|
||||||
|
'description' => __( 'Display pay later messaging on your site for offers like Pay in 3, which lets customers pay with 3 interest-free monthly payments. We’ll show messages on your site to promote this feature for you. You may not promote pay later offers with any other content, marketing, or materials.', 'woocommerce-paypal-payments' ),
|
||||||
|
'class' => array( 'ppcp-subheading' ),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
||||||
/**
|
/**
|
||||||
* Depending on your store location, some credit cards can't be used.
|
* Depending on your store location, some credit cards can't be used.
|
||||||
|
|
|
@ -290,7 +290,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
||||||
}
|
}
|
||||||
|
|
||||||
return __(
|
return __(
|
||||||
'Accept PayPal, PayPal Credit and alternative payment types.',
|
'Accept PayPal, Pay Later and alternative payment types.',
|
||||||
'woocommerce-paypal-payments'
|
'woocommerce-paypal-payments'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,12 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Endpoint;
|
||||||
use Hamcrest\Matchers;
|
use Hamcrest\Matchers;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||||
|
use Woocommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PatchCollection;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\PatchCollection;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
||||||
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payments;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Token;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\Token;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
|
@ -238,6 +240,13 @@ class OrderEndpointTest extends TestCase
|
||||||
);
|
);
|
||||||
expect('is_wp_error')->with($rawResponse)->andReturn(false);
|
expect('is_wp_error')->with($rawResponse)->andReturn(false);
|
||||||
expect('wp_remote_retrieve_response_code')->with($rawResponse)->andReturn(201);
|
expect('wp_remote_retrieve_response_code')->with($rawResponse)->andReturn(201);
|
||||||
|
$purchaseUnit = Mockery::mock(PurchaseUnit::class);
|
||||||
|
$payment = Mockery::mock(Payments::class);
|
||||||
|
$capture = Mockery::mock(Capture::class);
|
||||||
|
$expectedOrder->shouldReceive('purchase_units')->once()->andReturn(['0'=>$purchaseUnit]);
|
||||||
|
$purchaseUnit->shouldReceive('payments')->once()->andReturn($payment);
|
||||||
|
$payment->shouldReceive('captures')->once()->andReturn(['0'=>$capture]);
|
||||||
|
$capture->shouldReceive('status')->once()->andReturn('');
|
||||||
|
|
||||||
$result = $testee->capture($orderToCapture);
|
$result = $testee->capture($orderToCapture);
|
||||||
$this->assertEquals($expectedOrder, $result);
|
$this->assertEquals($expectedOrder, $result);
|
||||||
|
|
|
@ -16,6 +16,9 @@ class PayerTest extends TestCase
|
||||||
$address
|
$address
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
->andReturn(['address']);
|
->andReturn(['address']);
|
||||||
|
$address
|
||||||
|
->expects('country_code')
|
||||||
|
->andReturn('UK');
|
||||||
$phone = Mockery::mock(PhoneWithType::class);
|
$phone = Mockery::mock(PhoneWithType::class);
|
||||||
$phone
|
$phone
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
|
@ -65,6 +68,9 @@ class PayerTest extends TestCase
|
||||||
$address
|
$address
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
->andReturn(['address']);
|
->andReturn(['address']);
|
||||||
|
$address
|
||||||
|
->expects('country_code')
|
||||||
|
->andReturn('UK');
|
||||||
$phone = Mockery::mock(PhoneWithType::class);
|
$phone = Mockery::mock(PhoneWithType::class);
|
||||||
$phone
|
$phone
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
|
@ -102,6 +108,9 @@ class PayerTest extends TestCase
|
||||||
$address
|
$address
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
->andReturn(['address']);
|
->andReturn(['address']);
|
||||||
|
$address
|
||||||
|
->expects('country_code')
|
||||||
|
->andReturn('UK');
|
||||||
$phone = null;
|
$phone = null;
|
||||||
$taxInfo = Mockery::mock(PayerTaxInfo::class);
|
$taxInfo = Mockery::mock(PayerTaxInfo::class);
|
||||||
$taxInfo
|
$taxInfo
|
||||||
|
@ -136,6 +145,9 @@ class PayerTest extends TestCase
|
||||||
$address
|
$address
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
->andReturn(['address']);
|
->andReturn(['address']);
|
||||||
|
$address
|
||||||
|
->expects('country_code')
|
||||||
|
->andReturn('UK');
|
||||||
$phone = Mockery::mock(PhoneWithType::class);
|
$phone = Mockery::mock(PhoneWithType::class);
|
||||||
$phone
|
$phone
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
|
@ -170,6 +182,9 @@ class PayerTest extends TestCase
|
||||||
$address
|
$address
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
->andReturn(['address']);
|
->andReturn(['address']);
|
||||||
|
$address
|
||||||
|
->expects('country_code')
|
||||||
|
->andReturn('UK');
|
||||||
$phone = Mockery::mock(PhoneWithType::class);
|
$phone = Mockery::mock(PhoneWithType::class);
|
||||||
$phone
|
$phone
|
||||||
->expects('to_array')
|
->expects('to_array')
|
||||||
|
|
|
@ -48,7 +48,9 @@ class ItemFactoryTest extends TestCase
|
||||||
expect('wc_get_price_excluding_tax')
|
expect('wc_get_price_excluding_tax')
|
||||||
->with($product)
|
->with($product)
|
||||||
->andReturn(1);
|
->andReturn(1);
|
||||||
|
expect('wp_strip_all_tags')
|
||||||
|
->with('description')
|
||||||
|
->andReturn('description');
|
||||||
$result = $testee->from_wc_cart($cart);
|
$result = $testee->from_wc_cart($cart);
|
||||||
|
|
||||||
$this->assertCount(1, $result);
|
$this->assertCount(1, $result);
|
||||||
|
@ -102,6 +104,9 @@ class ItemFactoryTest extends TestCase
|
||||||
expect('wc_get_price_excluding_tax')
|
expect('wc_get_price_excluding_tax')
|
||||||
->with($product)
|
->with($product)
|
||||||
->andReturn(1);
|
->andReturn(1);
|
||||||
|
expect('wp_strip_all_tags')
|
||||||
|
->with('description')
|
||||||
|
->andReturn('description');
|
||||||
|
|
||||||
$result = $testee->from_wc_cart($cart);
|
$result = $testee->from_wc_cart($cart);
|
||||||
|
|
||||||
|
@ -126,6 +131,9 @@ class ItemFactoryTest extends TestCase
|
||||||
$product
|
$product
|
||||||
->expects('is_virtual')
|
->expects('is_virtual')
|
||||||
->andReturn(false);
|
->andReturn(false);
|
||||||
|
expect('wp_strip_all_tags')
|
||||||
|
->with('description')
|
||||||
|
->andReturn('description');
|
||||||
|
|
||||||
$item = Mockery::mock(\WC_Order_Item_Product::class);
|
$item = Mockery::mock(\WC_Order_Item_Product::class);
|
||||||
$item
|
$item
|
||||||
|
@ -183,6 +191,9 @@ class ItemFactoryTest extends TestCase
|
||||||
$product
|
$product
|
||||||
->expects('is_virtual')
|
->expects('is_virtual')
|
||||||
->andReturn(true);
|
->andReturn(true);
|
||||||
|
expect('wp_strip_all_tags')
|
||||||
|
->with('description')
|
||||||
|
->andReturn('description');
|
||||||
|
|
||||||
$item = Mockery::mock(\WC_Order_Item_Product::class);
|
$item = Mockery::mock(\WC_Order_Item_Product::class);
|
||||||
$item
|
$item
|
||||||
|
@ -235,6 +246,9 @@ class ItemFactoryTest extends TestCase
|
||||||
$product
|
$product
|
||||||
->expects('is_virtual')
|
->expects('is_virtual')
|
||||||
->andReturn(true);
|
->andReturn(true);
|
||||||
|
expect('wp_strip_all_tags')
|
||||||
|
->with($description)
|
||||||
|
->andReturn(mb_substr( $description, 0, 127 ));
|
||||||
|
|
||||||
$item = Mockery::mock(\WC_Order_Item_Product::class);
|
$item = Mockery::mock(\WC_Order_Item_Product::class);
|
||||||
$item
|
$item
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue