/** * Adds the standard transaction data to the order * * @since 1.0.0 * @see SV_WC_Payment_Gateway::add_transaction_data() * @param WC_Order $order the order object * @param SV_WC_Payment_Gateway_API_Response|null $response optional transaction response */ public function add_transaction_data($order, $response = null) { // add parent transaction data parent::add_transaction_data($order, $response); // payment info if (isset($order->payment->token) && $order->payment->token) { $this->update_order_meta($order->id, 'payment_token', $order->payment->token); } // account number if (isset($order->payment->account_number) && $order->payment->account_number) { $this->update_order_meta($order->id, 'account_four', substr($order->payment->account_number, -4)); } if ($this->is_credit_card_gateway()) { // credit card gateway data if ($response && $response instanceof SV_WC_Payment_Gateway_API_Authorization_Response) { if ($response->get_authorization_code()) { $this->update_order_meta($order->id, 'authorization_code', $response->get_authorization_code()); } if ($order->payment_total > 0) { // mark as captured if ($this->perform_credit_card_charge()) { $captured = 'yes'; } else { $captured = 'no'; } $this->update_order_meta($order->id, 'charge_captured', $captured); } } if (isset($order->payment->exp_year) && $order->payment->exp_year && isset($order->payment->exp_month) && $order->payment->exp_month) { $this->update_order_meta($order->id, 'card_expiry_date', $order->payment->exp_year . '-' . $order->payment->exp_month); } if (isset($order->payment->card_type) && $order->payment->card_type) { $this->update_order_meta($order->id, 'card_type', $order->payment->card_type); } } elseif ($this->is_echeck_gateway()) { // checking gateway data // optional account type (checking/savings) if (isset($order->payment->account_type) && $order->payment->account_type) { $this->update_order_meta($order->id, 'account_type', $order->payment->account_type); } // optional check number if (isset($order->payment->check_number) && $order->payment->check_number) { $this->update_order_meta($order->id, 'check_number', $order->payment->check_number); } } }
/** * Adds the standard transaction data to the order * * @since 2.2.0 * @see SV_WC_Payment_Gateway::add_transaction_data() * @param WC_Order $order the order object * @param SV_WC_Payment_Gateway_API_Response|null $response optional transaction response */ public function add_transaction_data($order, $response = null) { // add parent transaction data parent::add_transaction_data($order, $response); // account number if ($response->get_account_number()) { $this->update_order_meta($order->id, 'account_four', substr($response->get_account_number(), -4)); } if (self::PAYMENT_TYPE_CREDIT_CARD == $response->get_payment_type()) { if ($response->get_authorization_code()) { $this->update_order_meta($order->id, 'authorization_code', $response->get_authorization_code()); } if ($order->get_total() > 0) { // mark as captured if ($response->is_charge()) { $captured = 'yes'; } else { $captured = 'no'; } $this->update_order_meta($order->id, 'charge_captured', $captured); } if ($response->get_exp_month() && $response->get_exp_year()) { $this->update_order_meta($order->id, 'card_expiry_date', $response->get_exp_year() . '-' . $response->get_exp_month()); } if ($response->get_card_type()) { $this->update_order_meta($order->id, 'card_type', $response->get_card_type()); } } elseif (self::PAYMENT_TYPE_ECHECK == $response->get_payment_type()) { // optional account type (checking/savings) if ($response->get_account_type()) { $this->update_order_meta($order->id, 'account_type', $response->get_account_type()); } // optional check number if ($response->get_check_number()) { $this->update_order_meta($order->id, 'check_number', $response->get_check_number()); } } }