array( 'card', __( 'Card', 'acrislip-order-receipts' ) ), 'link' => array( 'card', 'Link' ), 'apple_pay' => array( 'card', 'Apple Pay' ), 'google_pay' => array( 'card', 'Google Pay' ), 'amazon_pay' => array( 'wallet', 'Amazon Pay' ), 'cashapp' => array( 'wallet', 'Cash App Pay' ), 'alipay' => array( 'wallet', 'Alipay' ), 'wechat_pay' => array( 'wallet', 'WeChat Pay' ), 'us_bank_account' => array( 'bank', __( 'ACH Direct Debit', 'acrislip-order-receipts' ) ), 'sepa_debit' => array( 'bank', __( 'SEPA Direct Debit', 'acrislip-order-receipts' ) ), 'sepa' => array( 'bank', __( 'SEPA Direct Debit', 'acrislip-order-receipts' ) ), 'bacs_debit' => array( 'bank', __( 'Bacs Direct Debit', 'acrislip-order-receipts' ) ), 'au_becs_debit' => array( 'bank', __( 'BECS Direct Debit', 'acrislip-order-receipts' ) ), 'acss_debit' => array( 'bank', __( 'Pre-authorized debit', 'acrislip-order-receipts' ) ), 'pay_by_bank' => array( 'bank', __( 'Pay by Bank', 'acrislip-order-receipts' ) ), 'customer_balance' => array( 'bank', __( 'Bank transfer', 'acrislip-order-receipts' ) ), 'ideal' => array( 'bank', 'iDEAL' ), 'bancontact' => array( 'bank', 'Bancontact' ), 'eps' => array( 'bank', 'EPS' ), 'p24' => array( 'bank', 'Przelewy24' ), 'blik' => array( 'bank', 'BLIK' ), 'giropay' => array( 'bank', 'giropay' ), 'sofort' => array( 'bank', 'Sofort' ), 'multibanco' => array( 'other', 'Multibanco' ), 'boleto' => array( 'other', 'Boleto' ), 'oxxo' => array( 'other', 'OXXO' ), 'klarna' => array( 'other', 'Klarna' ), 'affirm' => array( 'other', 'Affirm' ), 'afterpay_clearpay' => array( 'other', 'Afterpay / Clearpay' ), ); } /** * Apply. * * @param array $data Data. * @param WC_Order $order Order. * @return array */ public function apply( array $data, $order ) { $intent = $this->meta( $order, '_stripe_intent_id' ); $session = $this->meta( $order, '_stripe_checkout_session_id' ); $data = $this->set( $data, 'transaction_reference', $this->first( array( $order->get_transaction_id(), $intent ) ) ); if ( $intent && $intent !== $data['transaction_reference'] ) { $data['gateway_reference'] = $intent; } $data = $this->set( $data, 'session_reference', $session ); $type = $this->meta( $order, '_stripe_upe_payment_type' ); if ( '' === $type ) { $method = (string) $order->get_payment_method(); $type = 'stripe' === $method ? 'card' : substr( $method, strlen( 'stripe_' ) ); } $types = $this->types(); if ( isset( $types[ $type ] ) ) { $data['payment_type'] = 'wallet' === $types[ $type ][0] ? 'wallet' : $types[ $type ][0]; $data['channel'] = $types[ $type ][1]; } $data = $this->set( $data, 'card_brand', ucfirst( $this->meta( $order, '_stripe_card_brand' ) ) ); $token = $this->local_token( $this->meta( $order, '_stripe_source_id' ), (int) $order->get_customer_id() ); $data = $this->from_token( $data, $token ); if ( 'bank' === $data['payment_type'] && empty( $data['bank_reference'] ) ) { $data = $this->set( $data, 'bank_reference', $data['transaction_reference'] ); } $fee = $this->first( array( $this->meta( $order, '_stripe_fee' ), $this->meta( $order, 'Stripe Fee' ) ) ); $net = $this->first( array( $this->meta( $order, '_stripe_net' ), $this->meta( $order, 'Net Revenue From Stripe' ) ) ); if ( is_numeric( $fee ) ) { $data['fee'] = (float) $fee; } if ( is_numeric( $net ) ) { $data['net_amount'] = (float) $net; } $data = $this->set( $data, 'fee_currency', strtoupper( $this->meta( $order, '_stripe_currency' ) ) ); $p_amount = $this->meta( $order, '_stripe_presentment_amount' ); $p_currency = strtoupper( $this->meta( $order, '_stripe_presentment_currency' ) ); if ( is_numeric( $p_amount ) && $p_currency && $p_currency !== strtoupper( $order->get_currency() ) ) { $data = $this->extra( $data, __( 'Charged to customer (presentment)', 'acrislip-order-receipts' ), VPRWC_Receipt::money( $this->minor_to_major( $p_amount, $p_currency ), $p_currency ) ); } $data = $this->extra( $data, __( 'Stripe payment type', 'acrislip-order-receipts' ), $type ); $data = $this->extra( $data, __( 'Charge captured', 'acrislip-order-receipts' ), $this->meta( $order, '_stripe_charge_captured' ) ); $data = $this->extra( $data, __( 'Mandate', 'acrislip-order-receipts' ), $this->meta( $order, '_stripe_mandate_id' ) ); return $data; } }