🔀 Merge branch 'trunk'

This commit is contained in:
Philipp Stracker 2024-06-07 21:16:40 +02:00
commit ab0f25ffd7
No known key found for this signature in database
6 changed files with 25 additions and 6 deletions

View file

@ -8,6 +8,7 @@
* Fix - Google Pay and Apple Pay Settings button from Connection tab have wrong links #2273
* Fix - Smart Buttons in Block Checkout not respecting the location setting (2830) #2278
* Fix - Disable Pay Upon Invoice if billing/shipping country not set #2281
* Fix - Critical error on pay for order page when we try to pay with ACDC gateway #2321
* Enhancement - Enable shipping callback for WC subscriptions #2259
* Enhancement - Disable the shipping callback for "venmo" when vaulting is active #2269
* Enhancement - Improve "Could not retrieve order" error message #2271

View file

@ -25,6 +25,14 @@ export function CardFields({config, eventRegistration, emitResponse, components}
}
const hasSubscriptionProducts = cartHasSubscriptionProducts(config.scriptData);
useEffect(() => {
localStorage.removeItem('ppcp-save-card-payment');
if(hasSubscriptionProducts) {
localStorage.setItem('ppcp-save-card-payment', 'true');
}
}, [hasSubscriptionProducts])
useEffect(
() =>

View file

@ -35,7 +35,6 @@ export async function onApprove(data) {
})
.then((response) => response.json())
.then((data) => {
console.log(data)
localStorage.removeItem('ppcp-save-card-payment');
})
.catch((err) => {

View file

@ -12,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Endpoint;
use Psr\Log\LoggerInterface;
use RuntimeException;
use stdClass;
use WC_Order;
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\RequestTrait;
@ -131,16 +132,25 @@ class CaptureCardPayment {
/**
* Creates PayPal order from the given card vault id.
*
* @param string $vault_id Vault id.
* @param string $custom_id Custom id.
* @param string $invoice_id Invoice id.
* @param string $vault_id Vault id.
* @param string $custom_id Custom id.
* @param string $invoice_id Invoice id.
* @param WC_Order $wc_order The WC order.
* @return stdClass
* @throws RuntimeException When request fails.
*/
public function create_order( string $vault_id, string $custom_id, string $invoice_id ): stdClass {
public function create_order( string $vault_id, string $custom_id, string $invoice_id, WC_Order $wc_order ): stdClass {
$intent = $this->settings->has( 'intent' ) && strtoupper( (string) $this->settings->get( 'intent' ) ) === 'AUTHORIZE' ? 'AUTHORIZE' : 'CAPTURE';
$items = array( $this->purchase_unit_factory->from_wc_cart() );
// phpcs:disable WordPress.Security.NonceVerification
$pay_for_order = wc_clean( wp_unslash( $_GET['pay_for_order'] ?? '' ) );
$order_key = wc_clean( wp_unslash( $_GET['key'] ?? '' ) );
// phpcs:enable
if ( $pay_for_order && $order_key === $wc_order->get_order_key() ) {
$items = array( $this->purchase_unit_factory->from_wc_order( $wc_order ) );
}
$data = array(
'intent' => $intent,
'purchase_units' => array_map(

View file

@ -490,7 +490,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
$custom_id = $wc_order->get_order_number();
$invoice_id = $this->prefix . $wc_order->get_order_number();
$create_order = $this->capture_card_payment->create_order( $token->get_token(), $custom_id, $invoice_id );
$create_order = $this->capture_card_payment->create_order( $token->get_token(), $custom_id, $invoice_id, $wc_order );
$order = $this->order_endpoint->order( $create_order->id );
$wc_order->update_meta_data( PayPalGateway::INTENT_META_KEY, $order->intent() );

View file

@ -187,6 +187,7 @@ If you encounter issues with the PayPal buttons not appearing after an update, p
* Fix - Google Pay and Apple Pay Settings button from Connection tab have wrong links #2273
* Fix - Smart Buttons in Block Checkout not respecting the location setting (2830) #2278
* Fix - Disable Pay Upon Invoice if billing/shipping country not set #2281
* Fix - Critical error on pay for order page when we try to pay with ACDC gateway #2321
* Enhancement - Enable shipping callback for WC subscriptions #2259
* Enhancement - Disable the shipping callback for "venmo" when vaulting is active #2269
* Enhancement - Improve "Could not retrieve order" error message #2271