Skip to content

Commit

Permalink
Initial fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
RadoslavGeorgiev committed Apr 22, 2024
1 parent da0a15c commit 9e1f3c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ public function process_payment_for_order( $cart, $payment_information, $schedul
$request->set_cvc_confirmation( $payment_information->get_cvc_confirmation() );
$request->set_hook_args( $payment_information );
if ( $payment_information->is_using_saved_payment_method() ) {
$billing_details = WC_Payments_Utils::get_billing_details_from_order( $order );
$billing_details = WC_Payments_Utils::get_billing_details_from_order( $order, $payment_information->is_merchant_initiated() );

$is_legacy_card_object = strpos( $payment_information->get_payment_method() ?? '', 'card_' ) === 0;

Expand Down
23 changes: 22 additions & 1 deletion includes/class-wc-payments-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,31 @@ public static function map_search_orders_to_charge_ids( $search ) {
* It only returns the fields that are present in the billing section of the checkout.
*
* @param WC_Order $order Order to extract the billing details from.
* @param bool $legacy Whether to use the legacy way of loading straight from the order.
* @todo The $legacy flag is just a patch for the current approach, fixing the linked issue.
* @see https://github.com/Automattic/woocommerce-payments/issues/8678
*
* @return array
*/
public static function get_billing_details_from_order( $order ) {
public static function get_billing_details_from_order( $order, $legacy = true ) {
if ( $legacy ) {
$billing_details = [
'address' => [
'city' => $order->get_billing_city(),
'country' => $order->get_billing_country(),
'line1' => $order->get_billing_address_1(),
'line2' => $order->get_billing_address_2(),
'postal_code' => $order->get_billing_postcode(),
'state' => $order->get_billing_state(),
],
'email' => $order->get_billing_email(),
'name' => trim( $order->get_formatted_billing_full_name() ),
'phone' => $order->get_billing_phone(),
];

return array_filter( $billing_details );
}

$billing_fields = array_keys( WC()->checkout()->get_checkout_fields( 'billing' ) );
$address_field_to_key = [
'billing_city' => 'city',
Expand Down

0 comments on commit 9e1f3c6

Please sign in to comment.