Fix incorrect usage of static method in Stripe payment method integration (https://github.com/woocommerce/woocommerce-blocks/pull/3400)

* bump phpcs compat check to php 7

* implement order_meta adjustment directly.
This commit is contained in:
Darren Ethier 2020-11-14 11:04:48 -05:00 committed by GitHub
parent ca8fe37e89
commit 4a488efb56
2 changed files with 20 additions and 2 deletions

View File

@ -10,7 +10,7 @@
<!-- Configs -->
<config name="minimum_supported_wp_version" value="4.7" />
<config name="testVersion" value="5.6-" />
<config name="testVersion" value="7.0-" />
<!-- Rules -->
<rule ref="WooCommerce-Core" />

View File

@ -246,7 +246,7 @@ final class Stripe extends AbstractPaymentMethodType {
// phpcs:ignore WordPress.Security.NonceVerification
$post_data = $_POST;
$_POST = $context->payment_data;
WC_Stripe_Payment_Request::add_order_meta( $context->order->id, $context->payment_data );
$this->add_order_meta( $context->order, $data['payment_request_type'] );
$_POST = $post_data;
}
@ -295,4 +295,22 @@ final class Stripe extends AbstractPaymentMethodType {
$result->set_status( 'success' );
}
}
/**
* Handles adding information about the payment request type used to the order meta.
*
* @param \WC_Order $order The order being processed.
* @param string $payment_request_type The payment request type used for payment.
*/
private function add_order_meta( \WC_Order $order, string $payment_request_type ) {
if ( 'apple_pay' === $payment_request_type ) {
$order->set_payment_method_title( 'Apple Pay (Stripe)' );
$order->save();
}
if ( 'payment_request_api' === $payment_request_type ) {
$order->set_payment_method_title( 'Chrome Payment Request (Stripe)' );
$order->save();
}
}
}