Automattic\WooCommerce\Internal\ReceiptRendering

ReceiptRenderingEngine::get_woo_pay_dataprivateWC 1.0

Get the order data related to WooCommerce Payments.

It will return null if any of these is true:

  • Payment method is not "woocommerce_payments".
  • WooCommerce Payments is not installed.
  • No intent id is stored for the order.
  • Retrieving the payment information from Stripe API (providing the intent id) fails.
  • The received data set doesn't contain the expected information.

Method of the class: ReceiptRenderingEngine{}

No Hooks.

Returns

Array|null. An array of payment information for the order, or null if not available.

Usage

// private - for code of main (parent) class only
$result = $this->get_woo_pay_data( $order ): ?array;
$order(WC_Abstract_Order) (required)
The order to get the data from.

ReceiptRenderingEngine::get_woo_pay_data() code WC 10.5.0

private function get_woo_pay_data( WC_Abstract_Order $order ): ?array {
	$card_info = PaymentInfo::get_card_info( $order );

	if ( empty( $card_info ) ) {
		return null;
	}

	// Backcompat for custom templates.
	$card_info['card_icon']  = $card_info['icon'];
	$card_info['card_last4'] = $card_info['last4'];

	return $card_info;
}