Give_Payment::setup_payment PHP Method

setup_payment() private method

Setup payment properties
Since: 1.5
private setup_payment ( integer $payment_id ) : boolean
$payment_id integer The payment ID
return boolean If the setup was successful or not
    private function setup_payment($payment_id)
    {
        $this->pending = array();
        if (empty($payment_id)) {
            return false;
        }
        $payment = get_post($payment_id);
        if (!$payment || is_wp_error($payment)) {
            return false;
        }
        if ('give_payment' !== $payment->post_type) {
            return false;
        }
        // Allow extensions to perform actions before the payment is loaded
        do_action('give_pre_setup_payment', $this, $payment_id);
        // Primary Identifier
        $this->ID = absint($payment_id);
        // Protected ID that can never be changed
        $this->_ID = absint($payment_id);
        // We have a payment, get the generic payment_meta item to reduce calls to it
        $this->payment_meta = $this->get_meta();
        // Status and Dates
        $this->date = $payment->post_date;
        $this->post_date = $payment->post_date;
        $this->completed_date = $this->setup_completed_date();
        $this->status = $payment->post_status;
        $this->post_status = $this->status;
        $this->mode = $this->setup_mode();
        $this->parent_payment = $payment->post_parent;
        $all_payment_statuses = give_get_payment_statuses();
        $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
        // Items
        $this->fees = $this->setup_fees();
        // Currency Based
        $this->total = $this->setup_total();
        $this->fees_total = $this->setup_fees_total();
        $this->subtotal = $this->setup_subtotal();
        $this->currency = $this->setup_currency();
        // Gateway based
        $this->gateway = $this->setup_gateway();
        $this->transaction_id = $this->setup_transaction_id();
        // User based
        $this->ip = $this->setup_ip();
        $this->customer_id = $this->setup_customer_id();
        $this->user_id = $this->setup_user_id();
        $this->email = $this->setup_email();
        $this->user_info = $this->setup_user_info();
        $this->address = $this->setup_address();
        $this->first_name = $this->user_info['first_name'];
        $this->last_name = $this->user_info['last_name'];
        // Other Identifiers
        $this->form_title = $this->setup_form_title();
        $this->form_id = $this->setup_form_id();
        $this->price_id = $this->setup_price_id();
        $this->key = $this->setup_payment_key();
        $this->number = $this->setup_payment_number();
        // Allow extensions to add items to this object via hook
        do_action('give_setup_payment', $this, $payment_id);
        return true;
    }