/** * get transaction page html * * @param bool $return * @return string * @since 1.5 */ function mgm_get_transaction_page_html($return = false, $method = NULL) { // get method if (!$method) { $method = mgm_request_var('method', '', true); } // switch $method switch ($method) { case 'payment_return': // after payment return with get/post values and process // after payment return with get/post values and process case 'payment_notify': // silent post back, IPN, just after first payment // silent post back, IPN, just after first payment case 'payment_status_notify': // INS, post back, at each payment cycle,i.e, 2CO INS, PayPal IPN // INS, post back, at each payment cycle,i.e, 2CO INS, PayPal IPN case 'payment_cancel': // cancelled // cancelled case 'payment_unsubscribe': // unsubscribe tracking // unsubscribe tracking case 'payment_html_redirect': // proxy for html redirect // proxy for html redirect case 'payment_credit_card': // proxy for credit_card processing // get module $module = mgm_request_var('module', '', true); // validate module if ($module_obj = mgm_is_valid_module($module, 'payment', 'object')) { // process, invoke process_return,process_notify,process_cancel,process_unsubscribe $output = $module_obj->invoke(str_replace(array('payment_'), 'process_', $method)); // html redirect if ($method == 'payment_html_redirect') { // set in globals $GLOBALS['mgm_html_outout'] = $output; // if template exists if ($return) { $template_file = MGM_CORE_DIR . 'html/payment_processing_return.php'; } else { if (file_exists(TEMPLATEPATH . '/payment_processing.php')) { $template_file = TEMPLATEPATH . '/payment_processing.php'; } else { $template_file = MGM_CORE_DIR . 'html/payment_processing.php'; } } // apply template filter $template_file = apply_filters('mgm_page_template', $template_file, $method); // return template if ($return) { return mgm_get_include($template_file); } // @todo check payment // include template @(include $template_file); } } else { // not a valiud module, call default for unsubscribe if ($method == 'payment_unsubscribe') { // default unsubscribe return mgm_member_unsubscribe(); } else { // error return __('Invalid module supplied', 'mgm'); } } break; case 'payment_processed': // processed // get module $module = mgm_request_var('module', '', true); // validate module if ($module_obj = mgm_is_valid_module($module, 'payment', 'object')) { // redirect logic moved, in all cases same page is loaded // if template exists if ($return) { $template_file = MGM_CORE_DIR . 'html/payment_processed_return.php'; } else { if (file_exists(TEMPLATEPATH . '/payment_processed.php')) { $template_file = TEMPLATEPATH . '/payment_processed.php'; } else { $template_file = MGM_CORE_DIR . 'html/payment_processed.php'; } } // apply template filter $template_file = apply_filters('mgm_page_template', $template_file, $method); // return template if ($return) { return mgm_get_include($template_file); } // include template @(include $template_file); } else { return __('Invalid module supplied', 'mgm'); } break; case 'payment_purchase': // post purchase // if template exists if ($return) { $template_file = MGM_CORE_DIR . 'html/payment_post_purchase_return.php'; } else { if (file_exists(TEMPLATEPATH . '/payment_post_purchase.php')) { $template_file = TEMPLATEPATH . '/payment_post_purchase.php'; } else { $template_file = MGM_CORE_DIR . 'html/payment_post_purchase.php'; } } // apply template filter $template_file = apply_filters('mgm_page_template', $template_file, $method); // return template if ($return) { return mgm_get_include($template_file); } // include template @(include $template_file); break; case 'guest_purchase': // form // if template exists if ($return) { $template_file = MGM_CORE_DIR . 'html/guest_purchase_return.php'; } else { if (file_exists(TEMPLATEPATH . '/guest_purchase.php')) { $template_file = TEMPLATEPATH . '/guest_purchase.php'; } else { $template_file = MGM_CORE_DIR . 'html/guest_purchase.php'; } } // apply template filter $template_file = apply_filters('mgm_page_template', $template_file, $method); // return template if ($return) { return mgm_get_include($template_file); } // include template @(include $template_file); break; case 'register': // if template exists $template = mgm_get_page_template($method, $return); // return template if ($return) { return mgm_get_include($template); } // include template @(include $template); break; case 'profile': //user profile page // if template exists $template = mgm_get_page_template($method, $return); // return template if ($return) { return mgm_get_include($template); } // include template @(include $template); break; case 'lost_password': // if template exists $template = mgm_get_page_template($method, $return); // return template if ($return) { return mgm_get_include($template); } // include template @(include $template); break; case 'user_login': case 'login': // if template exists $template = mgm_get_page_template('login', $return); // return template if ($return) { return mgm_get_include($template); } // include template @(include $template); break; case 'payment_subscribe': // form // form case 'payment': // form // form default: // if template exists if ($return) { $template_file = MGM_CORE_DIR . 'html/payment_subscribe_return.php'; } elseif (file_exists(TEMPLATEPATH . '/payment_subscribe.php')) { $template_file = TEMPLATEPATH . '/payment_subscribe.php'; } else { $template_file = MGM_CORE_DIR . 'html/payment_subscribe.php'; } // apply template filter $template_file = apply_filters('mgm_page_template', $template_file, $method); // return template if ($return) { return mgm_get_include($template_file); } // include template @(include $template_file); break; } }
function _default_setting() { // worldpay specific $this->setting['inst_id'] = ''; $this->setting['md5_sig'] = ''; $this->setting['currency'] = mgm_get_class('system')->setting['currency']; $this->setting['lang'] = 'en'; //Worldpay resultY.html page contents $this->setting['gateway_successpage'] = mgm_get_include(MGM_MODULE_BASE_DIR . 'payment' . $this->module . 'html/gateway_successpage.html'); //Worldpay resultC.html page contents $this->setting['gateway_failedpage'] = mgm_get_include(MGM_MODULE_BASE_DIR . 'payment' . $this->module . 'html/gateway_failedpage.html'); // purchase price if (in_array('buypost', $this->supported_buttons)) { $this->setting['purchase_price'] = 4.0; } // callback messages $this->_setup_callback_messages(); // callback urls $this->_setup_callback_urls(); }
/** * API helper method get credit card page html * * @param array $user * @param array $tran * @param string $html_type (div|table) * @return string $html */ function _get_ccfields($user = NULL, $tran = NULL, $html_type = 'div') { // data $data = array(); // name, amount $data['name'] = $data['billing_info'] = $purchase_desc = ''; // address $address_fields = array(); // user id if (isset($user->ID) && (int) $user->ID > 0) { // name $data['name'] = isset($user->first_name) && isset($user->last_name) ? mgm_str_concat($user->first_name, $user->last_name) : $user->display_name; // member $member = mgm_get_member($user->ID); // packs $packs_obj = mgm_get_class('subscription_packs'); //issue #806 // pack if (isset($tran['data']['pack_id']) && !empty($tran['data']['pack_id'])) { $pack_id = $tran['data']['pack_id']; } elseif (isset($tran['data']['id']) && !empty($tran['data']['id'])) { //Issue #1058 $pack_id = $tran['data']['id']; } else { $pack_id = $member->pack_id; } $pack = $packs_obj->get_pack($pack_id); // using coupon - issue #1501 if (isset($tran['data']['subscription_option']) && $tran['data']['subscription_option'] == 'create') { mgm_get_register_coupon_pack($member, $pack); } // pack desc $purchase_desc = sprintf('<div class="ccfields_pack_desc">%s</div>', $packs_obj->get_pack_desc($pack)); // buypost if (isset($tran['payment_type']) && $tran['payment_type'] == 'post_purchase') { $purchase_desc = $tran['data']['item_name'] . ' [' . $tran['data']['cost'] . ' ' . $tran['data']['currency'] . ']'; } } // address fields $address_fields = $this->_get_address_fields($user, 'both'); // cancel $data['cancel_url'] = $this->_get_endpoint('cancel'); // head $html = $purchase_desc; // billing_info if (!empty($address_fields['fields'])) { // get mgm_form_fields generator $form_fields = new mgm_form_fields(); // info $billing_info = sprintf('<h2>%s</h2><br>', __('Billing Info', 'mgm')); // check if (isset($address_fields['fields'])) { // row template $row_template = ''; $req_tag = "<span class='required'>*</span>"; // template switch ($html_type) { case 'table': $row_template = "<tr>\r\r\n\t\t\t\t\t\t\t\t\t\t\t<td valign='top'><label for='%s'>%s %s</label></td>\r\r\n\t\t\t\t\t\t\t\t\t\t\t<td valign='top'>%s</td>\t\r\r\n\t\t\t\t\t\t\t\t\t\t </tr>"; break; case 'div': default: $row_template = "<p><label for='%s'>%s %s</label><br />%s</p>"; break; } // form_html $form_html = ''; // loop foreach ($address_fields['fields'] as $field) { // req $req = (bool) $field['attributes']['required'] == true ? $req_tag : ''; // value $value = isset($address_fields['captured'][$field['name']]) ? $address_fields['captured'][$field['name']] : ''; // type cls $type_class = $field['type'] == 'select' ? 'select' : 'input'; // class if ((bool) $field['attributes']['required'] == true) { // append $type_class .= ' {required: true}'; // reset to skip default required class $field['attributes']['required'] = false; } // set class $field['attributes']['class'] = $type_class; // elem $elem = $form_fields->get_field_element($field, 'mgm_payment_field', $value); // form $form_html .= sprintf($row_template, $field['name'], $field['label'], $req, $elem); } // set $billing_info .= $form_html; // set $data['billing_info'] = $billing_info; } } // credit card types: read from settings $card_types = array(); // loop foreach ($this->card_types as $type => $label) { // check if (isset($this->setting['supported_card_types']) && is_array($this->setting['supported_card_types'])) { if (in_array($type, $this->setting['supported_card_types'])) { $card_types[$type] = $label; } } } // set $data['card_types'] = $card_types; // code $data['code'] = $this->code; // html $html .= mgm_get_include(MGM_CORE_DIR . sprintf('html/payment_cc_form_%s.php', $html_type), array('data' => $data)); // cc form $cc_form = sprintf("<div id='%s_form_cc' class='ccfields ccfields_block_left'>%s</div>", $this->code, $html); // apply filter return apply_filters('mgm_cc_form_html', $cc_form, $this->code, $data); }