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;
|
||||
|
||||
use stdClass;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
|
@ -43,11 +44,11 @@ class PaymentToken {
|
|||
* PaymentToken constructor.
|
||||
*
|
||||
* @param string $id The Id.
|
||||
* @param stdClass $source The source.
|
||||
* @param string $type The type.
|
||||
* @param \stdClass $source The source.
|
||||
* @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 ) ) {
|
||||
throw new RuntimeException(
|
||||
__( 'Not a valid payment source type.', 'woocommerce-paypal-payments' )
|
||||
|
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
||||
|
||||
use stdClass;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
|
||||
|
@ -25,7 +26,7 @@ class PaymentTokenFactory {
|
|||
* @return PaymentToken
|
||||
* @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 ) ) {
|
||||
throw new RuntimeException(
|
||||
__( 'No id for payment token given', 'woocommerce-paypal-payments' )
|
||||
|
@ -34,8 +35,8 @@ class PaymentTokenFactory {
|
|||
|
||||
return new PaymentToken(
|
||||
$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;
|
||||
|
||||
use stdClass;
|
||||
use WooCommerce\PayPalCommerce\Subscription\RenewalHandler;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
||||
|
||||
|
@ -125,7 +126,7 @@ class SubscriptionsHandler {
|
|||
$billing_agreement_id = $order->get_meta( '_ppec_billing_agreement_id', true );
|
||||
|
||||
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,6 +251,13 @@ class PayUponInvoice {
|
|||
|
||||
$order = $this->pui_order_endpoint->order( $order_id );
|
||||
|
||||
if (
|
||||
property_exists( $order, 'payment_source' )
|
||||
&& property_exists( $order->payment_source, 'pay_upon_invoice' )
|
||||
&& property_exists( $order->payment_source->pay_upon_invoice, 'payment_reference' )
|
||||
&& property_exists( $order->payment_source->pay_upon_invoice, 'deposit_bank_details' )
|
||||
) {
|
||||
|
||||
$payment_instructions = array(
|
||||
$order->payment_source->pay_upon_invoice->payment_reference,
|
||||
$order->payment_source->pay_upon_invoice->deposit_bank_details,
|
||||
|
@ -261,6 +268,7 @@ class PayUponInvoice {
|
|||
);
|
||||
$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] );
|
||||
$breakdown = $capture->seller_receivable_breakdown();
|
||||
|
|
|
@ -52,7 +52,7 @@ class PaymentTokenRepositoryTest extends TestCase
|
|||
{
|
||||
$id = 1;
|
||||
$source = new \stdClass();
|
||||
$paymentToken = new PaymentToken('foo', 'PAYMENT_METHOD_TOKEN', $source);
|
||||
$paymentToken = new PaymentToken('foo', $source, 'PAYMENT_METHOD_TOKEN');
|
||||
|
||||
when('get_user_meta')->justReturn([]);
|
||||
$this->endpoint->shouldReceive('for_user')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue