/** * get_payment_details * * @access public * @param array $payments * @return string */ public function get_payment_details($payments = array()) { //prepare variables for displaying $template_args = array(); $template_args['transaction'] = $this->_current_txn; $template_args['reg_url_link'] = $this->_reg_url_link; $template_args['payments'] = array(); foreach ($payments as $payment) { $template_args['payments'][] = $this->get_payment_row_html($payment); } //create a hacky payment object, but dont save it $payment = EE_Payment::new_instance(array('TXN_ID' => $this->_current_txn->ID(), 'STS_ID' => EEM_Payment::status_id_pending, 'PAY_timestamp' => time(), 'PAY_amount' => $this->_current_txn->total(), 'PMD_ID' => $this->_current_txn->payment_method_ID())); $payment_method = $this->_current_txn->payment_method(); if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); } else { $template_args['gateway_content'] = ''; } // link to SPCO payment_options $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; // verify template arguments EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); EEH_Template_Validator::verify_isnt_null($template_args['show_try_pay_again_link'], '$show_try_pay_again_link'); EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); EEH_Template_Validator::verify_isnt_null($template_args['SPCO_payment_options_url'], '$SPCO_payment_options_url'); return EEH_Template::locate_template(THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', $template_args, TRUE, TRUE); }
/** * * @param EE_Transaction $transaction * @param float $amount * @param EE_Billing_Info_Form $billing_info * @param string $return_url * @param string $fail_url * @param string $method * @param bool $by_admin * @return EE_Payment * @throws EE_Error */ function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false) { // @todo: add surcharge for the payment method, if any if ($this->_gateway) { //there is a gateway, so we're going to make a payment object //but wait! do they already have a payment in progress that we thought was failed? $duplicate_properties = array('STS_ID' => EEM_Payment::status_id_failed, 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $this->_pm_instance->ID(), 'PAY_source' => $method, 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), 'PAY_gateway_response' => null); $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); //if we didn't already have a payment in progress for the same thing, //then we actually want to make a new payment if (!$payment instanceof EE_Payment) { $payment = EE_Payment::new_instance(array_merge($duplicate_properties, array('PAY_timestamp' => time(), 'PAY_txn_id_chq_nmbr' => null, 'PAY_po_number' => null, 'PAY_extra_accntng' => null, 'PAY_details' => null))); } //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it $payment->save(); $billing_values = $this->_get_billing_values_from_form($billing_info); // Offsite Gateway if ($this->_gateway instanceof EE_Offsite_Gateway) { $payment = $this->_gateway->set_redirection_info($payment, $billing_values, $return_url, EE_Config::instance()->core->txn_page_url(array('e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), 'ee_payment_method' => $this->_pm_instance->slug())), $fail_url); $payment->save(); // Onsite Gateway } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { $payment = $this->_gateway->do_direct_payment($payment, $billing_values); $payment->save(); } else { throw new EE_Error(sprintf(__('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), get_class($this), gettype($this->_gateway))); } } else { // no gateway provided // there is no payment. Must be an offline gateway // create a payment object anyways, but dont save it $payment = EE_Payment::new_instance(array('STS_ID' => EEM_Payment::status_id_pending, 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $transaction->payment_method_ID(), 'PAY_amount' => 0.0, 'PAY_timestamp' => time())); } // if there is billing info, clean it and save it now if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { $this->_save_billing_info_to_attendee($billing_info, $transaction); } return $payment; }
/** * This sets up an empty EE_Payment object for the purpose of shortcode parsing. Note that this doesn't actually get saved to the db. * @param \EE_Transaction $txn * @return \EE_Payment */ private function _get_empty_payment_obj(EE_Transaction $txn) { $PMT = EE_Payment::new_instance(array('STS_ID' => EEM_Payment::status_id_pending, 'PAY_timestamp' => time(), 'PMD_ID' => $txn->payment_method_ID(), 'PAY_gateway_response' => $txn->gateway_response_on_transaction())); return $PMT; }