mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-07 19:54:15 +08:00
Merge pull request #938 from woocommerce/PCP-946-multiple-php-warnings-php-8
Multiple PHP warnings (PHP8)
This commit is contained in:
commit
0c756c0667
5 changed files with 30 additions and 19 deletions
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||||
|
|
||||||
|
use stdClass;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,12 +43,12 @@ class PaymentToken {
|
||||||
/**
|
/**
|
||||||
* PaymentToken constructor.
|
* PaymentToken constructor.
|
||||||
*
|
*
|
||||||
* @param string $id The Id.
|
* @param string $id The Id.
|
||||||
* @param string $type The type.
|
* @param stdClass $source The source.
|
||||||
* @param \stdClass $source The source.
|
* @param string $type The type.
|
||||||
* @throws RuntimeException When the type is not valid.
|
* @throws RuntimeException When the type is not valid.
|
||||||
*/
|
*/
|
||||||
public function __construct( string $id, string $type = self::TYPE_PAYMENT_METHOD_TOKEN, \stdClass $source ) {
|
public function __construct( string $id, stdClass $source, string $type = self::TYPE_PAYMENT_METHOD_TOKEN ) {
|
||||||
if ( ! in_array( $type, self::get_valid_types(), true ) ) {
|
if ( ! in_array( $type, self::get_valid_types(), true ) ) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
__( 'Not a valid payment source type.', 'woocommerce-paypal-payments' )
|
__( 'Not a valid payment source type.', 'woocommerce-paypal-payments' )
|
||||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
||||||
|
|
||||||
|
use stdClass;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ class PaymentTokenFactory {
|
||||||
* @return PaymentToken
|
* @return PaymentToken
|
||||||
* @throws RuntimeException When JSON object is malformed.
|
* @throws RuntimeException When JSON object is malformed.
|
||||||
*/
|
*/
|
||||||
public function from_paypal_response( \stdClass $data ): PaymentToken {
|
public function from_paypal_response( stdClass $data ): PaymentToken {
|
||||||
if ( ! isset( $data->id ) ) {
|
if ( ! isset( $data->id ) ) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
__( 'No id for payment token given', 'woocommerce-paypal-payments' )
|
__( 'No id for payment token given', 'woocommerce-paypal-payments' )
|
||||||
|
@ -34,8 +35,8 @@ class PaymentTokenFactory {
|
||||||
|
|
||||||
return new PaymentToken(
|
return new PaymentToken(
|
||||||
$data->id,
|
$data->id,
|
||||||
( isset( $data->type ) ) ? $data->type : PaymentToken::TYPE_PAYMENT_METHOD_TOKEN,
|
$data->source,
|
||||||
$data->source
|
( isset( $data->type ) ) ? $data->type : PaymentToken::TYPE_PAYMENT_METHOD_TOKEN
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
|
namespace WooCommerce\PayPalCommerce\Compat\PPEC;
|
||||||
|
|
||||||
|
use stdClass;
|
||||||
use WooCommerce\PayPalCommerce\Subscription\RenewalHandler;
|
use WooCommerce\PayPalCommerce\Subscription\RenewalHandler;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ class SubscriptionsHandler {
|
||||||
$billing_agreement_id = $order->get_meta( '_ppec_billing_agreement_id', true );
|
$billing_agreement_id = $order->get_meta( '_ppec_billing_agreement_id', true );
|
||||||
|
|
||||||
if ( $billing_agreement_id ) {
|
if ( $billing_agreement_id ) {
|
||||||
$token = new PaymentToken( $billing_agreement_id, 'BILLING_AGREEMENT', new \stdClass() );
|
$token = new PaymentToken( $billing_agreement_id, new stdClass(), 'BILLING_AGREEMENT' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,16 +251,24 @@ class PayUponInvoice {
|
||||||
|
|
||||||
$order = $this->pui_order_endpoint->order( $order_id );
|
$order = $this->pui_order_endpoint->order( $order_id );
|
||||||
|
|
||||||
$payment_instructions = array(
|
if (
|
||||||
$order->payment_source->pay_upon_invoice->payment_reference,
|
property_exists( $order, 'payment_source' )
|
||||||
$order->payment_source->pay_upon_invoice->deposit_bank_details,
|
&& property_exists( $order->payment_source, 'pay_upon_invoice' )
|
||||||
);
|
&& property_exists( $order->payment_source->pay_upon_invoice, 'payment_reference' )
|
||||||
$wc_order->update_meta_data(
|
&& property_exists( $order->payment_source->pay_upon_invoice, 'deposit_bank_details' )
|
||||||
'ppcp_ratepay_payment_instructions_payment_reference',
|
) {
|
||||||
$payment_instructions
|
|
||||||
);
|
$payment_instructions = array(
|
||||||
$wc_order->save_meta_data();
|
$order->payment_source->pay_upon_invoice->payment_reference,
|
||||||
$this->logger->info( "Ratepay payment instructions added to order #{$wc_order->get_id()}." );
|
$order->payment_source->pay_upon_invoice->deposit_bank_details,
|
||||||
|
);
|
||||||
|
$wc_order->update_meta_data(
|
||||||
|
'ppcp_ratepay_payment_instructions_payment_reference',
|
||||||
|
$payment_instructions
|
||||||
|
);
|
||||||
|
$wc_order->save_meta_data();
|
||||||
|
$this->logger->info( "Ratepay payment instructions added to order #{$wc_order->get_id()}." );
|
||||||
|
}
|
||||||
|
|
||||||
$capture = $this->capture_factory->from_paypal_response( $order->purchase_units[0]->payments->captures[0] );
|
$capture = $this->capture_factory->from_paypal_response( $order->purchase_units[0]->payments->captures[0] );
|
||||||
$breakdown = $capture->seller_receivable_breakdown();
|
$breakdown = $capture->seller_receivable_breakdown();
|
||||||
|
|
|
@ -52,7 +52,7 @@ class PaymentTokenRepositoryTest extends TestCase
|
||||||
{
|
{
|
||||||
$id = 1;
|
$id = 1;
|
||||||
$source = new \stdClass();
|
$source = new \stdClass();
|
||||||
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN', $source);
|
$paymentToken = new PaymentToken('foo', $source, 'PAYMENT_METHOD_TOKEN');
|
||||||
|
|
||||||
when('get_user_meta')->justReturn([]);
|
when('get_user_meta')->justReturn([]);
|
||||||
$this->endpoint->shouldReceive('for_user')
|
$this->endpoint->shouldReceive('for_user')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue