mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix merge conflicts
This commit is contained in:
commit
ccff0fa586
9 changed files with 94 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
*** Changelog ***
|
||||
|
||||
= 1.6.5 - 2022-01-31 =
|
||||
* Fix - Allow guest users to purchase subscription products #422
|
||||
* Fix - Allow guest users to purchase subscription products from checkout page #422
|
||||
* Fix - Transaction ID missing for renewal order #424
|
||||
* Fix - Save your credit card checkbox should be removed in pay for order for subscriptions #420
|
||||
* Fix - Null currency error when the Aelia currency switcher plugin is active #426
|
||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Address;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PayerName;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PayerTaxInfo;
|
||||
|
@ -147,4 +148,55 @@ class PayerFactory {
|
|||
$tax_info
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Payer object based off the given checkout form fields.
|
||||
*
|
||||
* @param array $form_fields The checkout form fields.
|
||||
* @return Payer
|
||||
*/
|
||||
public function from_checkout_form( array $form_fields ): Payer {
|
||||
|
||||
$first_name = $form_fields['billing_first_name'] ?? '';
|
||||
$last_name = $form_fields['billing_last_name'] ?? '';
|
||||
$billing_email = $form_fields['billing_email'] ?? '';
|
||||
$billing_country = $form_fields['billing_country'] ?? '';
|
||||
$billing_address_1 = $form_fields['billing_address_1'] ?? '';
|
||||
$billing_address_2 = $form_fields['billing_address_2'] ?? '';
|
||||
$admin_area_1 = $form_fields['billing_state'] ?? '';
|
||||
$admin_area_2 = $form_fields['billing_city'] ?? '';
|
||||
$billing_postcode = $form_fields['billing_postcode'] ?? '';
|
||||
|
||||
$phone = null;
|
||||
if ( isset( $form_fields['billing_phone'] ) && '' !== $form_fields['billing_phone'] ) {
|
||||
// make sure the phone number contains only numbers and is max 14. chars long.
|
||||
$national_number = $form_fields['billing_phone'];
|
||||
$national_number = preg_replace( '/[^0-9]/', '', $national_number );
|
||||
|
||||
if ( null !== $national_number ) {
|
||||
$national_number = substr( $national_number, 0, 14 );
|
||||
|
||||
$phone = new PhoneWithType(
|
||||
'HOME',
|
||||
new Phone( $national_number )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return new Payer(
|
||||
new PayerName( $first_name, $last_name ),
|
||||
$billing_email,
|
||||
'',
|
||||
new Address(
|
||||
$billing_country,
|
||||
$billing_address_1,
|
||||
$billing_address_2,
|
||||
$admin_area_1,
|
||||
$admin_area_2,
|
||||
$billing_postcode
|
||||
),
|
||||
null,
|
||||
$phone
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,10 @@ namespace WooCommerce\PayPalCommerce\Button\Endpoint;
|
|||
use Exception;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Address;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PayerName;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentMethod;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
||||
|
@ -337,6 +339,15 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
|
||||
$payer = $this->payer_factory->from_paypal_response( json_decode( wp_json_encode( $data['payer'] ) ) );
|
||||
}
|
||||
|
||||
if ( ! $payer && isset( $data['form'] ) ) {
|
||||
parse_str( $data['form'], $form_fields );
|
||||
|
||||
if ( isset( $form_fields['billing_email'] ) && '' !== $form_fields['billing_email'] ) {
|
||||
return $this->payer_factory->from_checkout_form( $form_fields );
|
||||
}
|
||||
}
|
||||
|
||||
return $payer;
|
||||
}
|
||||
|
||||
|
|
|
@ -741,7 +741,7 @@ return array(
|
|||
'gateway' => 'paypal',
|
||||
),
|
||||
'disable_funding' => array(
|
||||
'title' => __( 'Disable funding sources', 'woocommerce-paypal-payments' ),
|
||||
'title' => __( 'Hide Funding Source(s)', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'ppcp-multiselect',
|
||||
'class' => array(),
|
||||
'input_class' => array( 'wc-enhanced-select' ),
|
||||
|
|
|
@ -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' )
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -21,6 +21,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;
|
||||
|
@ -132,6 +133,23 @@ class WCGatewayModule implements ModuleInterface {
|
|||
$endpoint->handle_request();
|
||||
}
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,13 +10,14 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\Webhooks\Handler;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Processor\TransactionIdHandlingTrait;
|
||||
|
||||
/**
|
||||
* Class PaymentCaptureRefunded
|
||||
*/
|
||||
class PaymentCaptureRefunded implements RequestHandler {
|
||||
|
||||
use PrefixTrait;
|
||||
use PrefixTrait, TransactionIdHandlingTrait;
|
||||
|
||||
/**
|
||||
* The logger.
|
||||
|
@ -150,6 +151,11 @@ class PaymentCaptureRefunded implements RequestHandler {
|
|||
'order' => $wc_order,
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_array( $request['resource'] ) && isset( $request['resource']['id'] ) ) {
|
||||
$this->update_transaction_id( $request['resource']['id'], $wc_order, $this->logger );
|
||||
}
|
||||
|
||||
$response['success'] = true;
|
||||
return rest_ensure_response( $response );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Contributors: woocommerce, automattic
|
||||
Tags: woocommerce, paypal, payments, ecommerce, e-commerce, store, sales, sell, shop, shopping, cart, checkout
|
||||
Requires at least: 5.3
|
||||
Tested up to: 5.8
|
||||
Tested up to: 5.9
|
||||
Requires PHP: 7.1
|
||||
Stable tag: 1.6.5
|
||||
License: GPLv2
|
||||
|
@ -82,7 +82,7 @@ Follow the steps below to connect the plugin to your PayPal account:
|
|||
== Changelog ==
|
||||
|
||||
= 1.6.5 =
|
||||
* Fix - Allow guest users to purchase subscription products #422
|
||||
* Fix - Allow guest users to purchase subscription products from checkout page #422
|
||||
* Fix - Transaction ID missing for renewal order #424
|
||||
* Fix - Save your credit card checkbox should be removed in pay for order for subscriptions #420
|
||||
* Fix - Null currency error when the Aelia currency switcher plugin is active #426
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue