diff --git a/includes/data/mutation/class-checkout-mutation.php b/includes/data/mutation/class-checkout-mutation.php index 1c3b104e..5f0531b1 100644 --- a/includes/data/mutation/class-checkout-mutation.php +++ b/includes/data/mutation/class-checkout-mutation.php @@ -92,7 +92,7 @@ class Checkout_Mutation { } else { $value = ! empty( $input[ $fieldset_key ][ $input_key ] ) ? $input[ $fieldset_key ][ $input_key ] : null; } - + if ( $value ) { $data[ $key ] = $value; } elseif ( 'billing_country' === $key || 'shipping_country' === $key ) { diff --git a/tests/wpunit/CheckoutMutationTest.php b/tests/wpunit/CheckoutMutationTest.php index fe5931ce..2aa13725 100644 --- a/tests/wpunit/CheckoutMutationTest.php +++ b/tests/wpunit/CheckoutMutationTest.php @@ -290,6 +290,44 @@ class CheckoutMutationTest extends \Codeception\TestCase\WPTestCase { return $actual; } + private function create_stripe_customer( $email ) { + $customer = \Stripe\Customer::create( array( 'email' => $email ) ); + + // use --debug flag to view. + codecept_debug( $customer ); + + return $customer; + } + + private function create_stripe_source( $customer ) { + $source = \Stripe\Customer::createSource( + $customer['id'], + array( 'source' => 'tok_visa') + ); + + // use --debug flag to view. + codecept_debug( $source ); + + return $source; + } + + private function create_stripe_payment_intent( $amount, $customer ) { + $payment_intent = \Stripe\PaymentIntent::create( + array( + 'amount' => $amount, + 'currency' => 'gbp', + 'payment_method_types' => ['card'], + 'customer' => $customer['id'], + 'payment_method' => $customer['invoice_settings']['default_payment_method'], + ) + ); + + // use --debug flag to view. + codecept_debug( $payment_intent ); + + return $payment_intent; + } + // tests public function testCheckoutMutation() { wp_set_current_user( $this->simple_customer );