mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge branch 'trunk' into PCP-2786-do-not-save-payment-token-for-guest-users
This commit is contained in:
commit
16a8c9a313
11 changed files with 71 additions and 35 deletions
|
@ -1,6 +1,6 @@
|
||||||
*** Changelog ***
|
*** Changelog ***
|
||||||
|
|
||||||
= 2.6.0 - xxxx-xx-xx =
|
= 2.6.0 - 2024-03-20 =
|
||||||
* Fix - invoice_id not included in API call when creating payment with saved card #2086
|
* Fix - invoice_id not included in API call when creating payment with saved card #2086
|
||||||
* Fix - Typo in SCA indicators for ACDC Vault transactions #2083
|
* Fix - Typo in SCA indicators for ACDC Vault transactions #2083
|
||||||
* Fix - Payments with saved card tokens use Capture intent when Authorize is configured #2069
|
* Fix - Payments with saved card tokens use Capture intent when Authorize is configured #2069
|
||||||
|
|
|
@ -61,10 +61,10 @@ class ItemFactory {
|
||||||
|
|
||||||
$price = (float) $item['line_subtotal'] / (float) $item['quantity'];
|
$price = (float) $item['line_subtotal'] / (float) $item['quantity'];
|
||||||
return new Item(
|
return new Item(
|
||||||
mb_substr( $product->get_name(), 0, 127 ),
|
$this->prepare_item_string( $product->get_name() ),
|
||||||
new Money( $price, $this->currency ),
|
new Money( $price, $this->currency ),
|
||||||
$quantity,
|
$quantity,
|
||||||
$this->prepare_description( $product->get_description() ),
|
$this->prepare_item_string( $product->get_description() ),
|
||||||
null,
|
null,
|
||||||
$this->prepare_sku( $product->get_sku() ),
|
$this->prepare_sku( $product->get_sku() ),
|
||||||
( $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
( $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
||||||
|
@ -138,10 +138,10 @@ class ItemFactory {
|
||||||
$image = $product instanceof WC_Product ? wp_get_attachment_image_src( (int) $product->get_image_id(), 'full' ) : '';
|
$image = $product instanceof WC_Product ? wp_get_attachment_image_src( (int) $product->get_image_id(), 'full' ) : '';
|
||||||
|
|
||||||
return new Item(
|
return new Item(
|
||||||
mb_substr( $item->get_name(), 0, 127 ),
|
$this->prepare_item_string( $item->get_name() ),
|
||||||
new Money( $price_without_tax_rounded, $currency ),
|
new Money( $price_without_tax_rounded, $currency ),
|
||||||
$quantity,
|
$quantity,
|
||||||
$product instanceof WC_Product ? $this->prepare_description( $product->get_description() ) : '',
|
$product instanceof WC_Product ? $this->prepare_item_string( $product->get_description() ) : '',
|
||||||
null,
|
null,
|
||||||
$product instanceof WC_Product ? $this->prepare_sku( $product->get_sku() ) : '',
|
$product instanceof WC_Product ? $this->prepare_sku( $product->get_sku() ) : '',
|
||||||
( $product instanceof WC_Product && $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
( $product instanceof WC_Product && $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
||||||
|
@ -160,7 +160,7 @@ class ItemFactory {
|
||||||
*/
|
*/
|
||||||
private function from_wc_order_fee( \WC_Order_Item_Fee $item, \WC_Order $order ): Item {
|
private function from_wc_order_fee( \WC_Order_Item_Fee $item, \WC_Order $order ): Item {
|
||||||
return new Item(
|
return new Item(
|
||||||
$item->get_name(),
|
$this->prepare_item_string( $item->get_name() ),
|
||||||
new Money( (float) $item->get_amount(), $order->get_currency() ),
|
new Money( (float) $item->get_amount(), $order->get_currency() ),
|
||||||
$item->get_quantity(),
|
$item->get_quantity(),
|
||||||
'',
|
'',
|
||||||
|
|
|
@ -12,14 +12,14 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Helper;
|
||||||
trait ItemTrait {
|
trait ItemTrait {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanups the description and prepares it for sending to PayPal.
|
* Cleans up item strings (title and description for example) and prepares them for sending to PayPal.
|
||||||
*
|
*
|
||||||
* @param string $description Item description.
|
* @param string $string Item string.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function prepare_description( string $description ): string {
|
protected function prepare_item_string( string $string ): string {
|
||||||
$description = strip_shortcodes( wp_strip_all_tags( $description ) );
|
$string = strip_shortcodes( wp_strip_all_tags( $string ) );
|
||||||
return substr( $description, 0, 127 ) ?: '';
|
return substr( $string, 0, 127 ) ?: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -169,10 +169,10 @@ class Shipment implements ShipmentInterface {
|
||||||
$image = wp_get_attachment_image_src( (int) $product->get_image_id(), 'full' );
|
$image = wp_get_attachment_image_src( (int) $product->get_image_id(), 'full' );
|
||||||
|
|
||||||
$ppcp_order_item = new Item(
|
$ppcp_order_item = new Item(
|
||||||
mb_substr( $item->get_name(), 0, 127 ),
|
$this->prepare_item_string( $item->get_name() ),
|
||||||
new Money( $price_without_tax_rounded, $currency ),
|
new Money( $price_without_tax_rounded, $currency ),
|
||||||
$quantity,
|
$quantity,
|
||||||
$this->prepare_description( $product->get_description() ),
|
$this->prepare_item_string( $product->get_description() ),
|
||||||
null,
|
null,
|
||||||
$this->prepare_sku( $product->get_sku() ),
|
$this->prepare_sku( $product->get_sku() ),
|
||||||
$product->is_virtual() ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
$product->is_virtual() ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
||||||
|
|
|
@ -114,7 +114,7 @@ class SubscriptionsApiHandler {
|
||||||
*/
|
*/
|
||||||
public function create_product( WC_Product $product ) {
|
public function create_product( WC_Product $product ) {
|
||||||
try {
|
try {
|
||||||
$subscription_product = $this->products_endpoint->create( $product->get_title(), $this->prepare_description( $product->get_description() ) );
|
$subscription_product = $this->products_endpoint->create( $this->prepare_item_string( $product->get_title() ), $this->prepare_item_string( $product->get_description() ) );
|
||||||
$product->update_meta_data( 'ppcp_subscription_product', $subscription_product->to_array() );
|
$product->update_meta_data( 'ppcp_subscription_product', $subscription_product->to_array() );
|
||||||
$product->save();
|
$product->save();
|
||||||
} catch ( RuntimeException $exception ) {
|
} catch ( RuntimeException $exception ) {
|
||||||
|
@ -169,7 +169,7 @@ class SubscriptionsApiHandler {
|
||||||
$catalog_product_name = $catalog_product->name() ?: '';
|
$catalog_product_name = $catalog_product->name() ?: '';
|
||||||
$catalog_product_description = $catalog_product->description() ?: '';
|
$catalog_product_description = $catalog_product->description() ?: '';
|
||||||
|
|
||||||
$wc_product_description = $this->prepare_description( $product->get_description() ) ?: $product->get_title();
|
$wc_product_description = $this->prepare_item_string( $product->get_description() ) ?: $this->prepare_item_string( $product->get_title() );
|
||||||
|
|
||||||
if ( $catalog_product_name !== $product->get_title() || $catalog_product_description !== $wc_product_description ) {
|
if ( $catalog_product_name !== $product->get_title() || $catalog_product_description !== $wc_product_description ) {
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
|
@ -313,8 +313,10 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
*/
|
*/
|
||||||
public function form() {
|
public function form() {
|
||||||
add_action( 'gettext', array( $this, 'replace_credit_card_cvv_label' ), 10, 3 );
|
add_action( 'gettext', array( $this, 'replace_credit_card_cvv_label' ), 10, 3 );
|
||||||
|
add_action( 'gettext', array( $this, 'replace_credit_card_cvv_placeholder' ), 10, 3 );
|
||||||
parent::form();
|
parent::form();
|
||||||
remove_action( 'gettext', 'replace_credit_card_cvv_label' );
|
remove_action( 'gettext', 'replace_credit_card_cvv_label' );
|
||||||
|
remove_action( 'gettext', 'replace_credit_card_cvv_placeholder' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,6 +336,23 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
return __( 'CVV', 'woocommerce-paypal-payments' );
|
return __( 'CVV', 'woocommerce-paypal-payments' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace WooCommerce credit card CVV field placeholder.
|
||||||
|
*
|
||||||
|
* @param string $translation Translated text.
|
||||||
|
* @param string $text Original text to translate.
|
||||||
|
* @param string $domain Text domain.
|
||||||
|
*
|
||||||
|
* @return string Translated field.
|
||||||
|
*/
|
||||||
|
public function replace_credit_card_cvv_placeholder( string $translation, string $text, string $domain ): string {
|
||||||
|
if ( 'woocommerce' !== $domain || 'CVC' !== $text || ! apply_filters( 'woocommerce_paypal_payments_card_fields_translate_card_cvv', true ) ) {
|
||||||
|
return $translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __( 'CVV', 'woocommerce-paypal-payments' );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the icons of the gateway.
|
* Returns the icons of the gateway.
|
||||||
*
|
*
|
||||||
|
|
|
@ -202,7 +202,13 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => get_bloginfo( 'name' ) ?? '',
|
'default' => get_bloginfo( 'name' ) ?? '',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'description' => __( 'Merchant name displayed in Ratepay\'s payment instructions.', 'woocommerce-paypal-payments' ),
|
'description' => __( 'Merchant name displayed in Ratepay\'s payment instructions. Should not exceed 127 characters.', 'woocommerce-paypal-payments' ),
|
||||||
|
'maxlength' => 127,
|
||||||
|
'custom_attributes' => array(
|
||||||
|
'pattern' => '.{1,127}',
|
||||||
|
'autocomplete' => 'off',
|
||||||
|
'required' => '',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
'logo_url' => array(
|
'logo_url' => array(
|
||||||
'title' => __( 'Logo URL', 'woocommerce-paypal-payments' ),
|
'title' => __( 'Logo URL', 'woocommerce-paypal-payments' ),
|
||||||
|
@ -210,6 +216,11 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'description' => __( 'Logo to be presented on Ratepay\'s payment instructions.', 'woocommerce-paypal-payments' ),
|
'description' => __( 'Logo to be presented on Ratepay\'s payment instructions.', 'woocommerce-paypal-payments' ),
|
||||||
|
'custom_attributes' => array(
|
||||||
|
'pattern' => '.+',
|
||||||
|
'autocomplete' => 'off',
|
||||||
|
'required' => '',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
'customer_service_instructions' => array(
|
'customer_service_instructions' => array(
|
||||||
'title' => __( 'Customer service instructions', 'woocommerce-paypal-payments' ),
|
'title' => __( 'Customer service instructions', 'woocommerce-paypal-payments' ),
|
||||||
|
@ -217,6 +228,11 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'description' => __( 'Customer service instructions to be presented on Ratepay\'s payment instructions.', 'woocommerce-paypal-payments' ),
|
'description' => __( 'Customer service instructions to be presented on Ratepay\'s payment instructions.', 'woocommerce-paypal-payments' ),
|
||||||
|
'custom_attributes' => array(
|
||||||
|
'pattern' => '.+',
|
||||||
|
'autocomplete' => 'off',
|
||||||
|
'required' => '',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ If you encounter issues with the PayPal buttons not appearing after an update, p
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
|
||||||
= 2.6.0 - xxxx-xx-xx =
|
= 2.6.0 - 2024-03-20 =
|
||||||
* Fix - invoice_id not included in API call when creating payment with saved card #2086
|
* Fix - invoice_id not included in API call when creating payment with saved card #2086
|
||||||
* Fix - Typo in SCA indicators for ACDC Vault transactions #2083
|
* Fix - Typo in SCA indicators for ACDC Vault transactions #2083
|
||||||
* Fix - Payments with saved card tokens use Capture intent when Authorize is configured #2069
|
* Fix - Payments with saved card tokens use Capture intent when Authorize is configured #2069
|
||||||
|
|
|
@ -65,7 +65,7 @@ class FilePathPluginFactory implements FilePathPluginFactoryInterface {
|
||||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
$plugin_data = get_plugin_data( $filePath );
|
$plugin_data = get_plugin_data( $filePath, false );
|
||||||
if ( empty( $plugin_data ) ) {
|
if ( empty( $plugin_data ) ) {
|
||||||
throw new UnexpectedValueException(
|
throw new UnexpectedValueException(
|
||||||
sprintf(
|
sprintf(
|
||||||
|
|
|
@ -312,11 +312,12 @@ class ItemFactoryTest extends TestCase
|
||||||
|
|
||||||
$result = $testee->from_wc_order($order);
|
$result = $testee->from_wc_order($order);
|
||||||
$item = current($result);
|
$item = current($result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Item $item
|
* @var Item $item
|
||||||
*/
|
*/
|
||||||
$this->assertEquals(mb_substr($name, 0, 127), $item->name());
|
$this->assertEquals(substr( strip_shortcodes( wp_strip_all_tags( $name ) ), 0, 127 ), $item->name());
|
||||||
$this->assertEquals(substr($description, 0, 127), $item->description());
|
$this->assertEquals(substr( strip_shortcodes( wp_strip_all_tags( $description ) ), 0, 127 ), $item->description());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFromPayPalResponse()
|
public function testFromPayPalResponse()
|
||||||
|
|
|
@ -97,7 +97,7 @@ define( 'PAYPAL_INTEGRATION_DATE', '2024-03-12' );
|
||||||
*/
|
*/
|
||||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
}
|
}
|
||||||
$plugin_data = get_plugin_data( __DIR__ . '/woocommerce-paypal-payments.php' );
|
$plugin_data = get_plugin_data( __DIR__ . '/woocommerce-paypal-payments.php', false );
|
||||||
$plugin_version = $plugin_data['Version'] ?? null;
|
$plugin_version = $plugin_data['Version'] ?? null;
|
||||||
$installed_plugin_version = get_option( 'woocommerce-ppcp-version' );
|
$installed_plugin_version = get_option( 'woocommerce-ppcp-version' );
|
||||||
if ( $installed_plugin_version !== $plugin_version ) {
|
if ( $installed_plugin_version !== $plugin_version ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue