function _get_button_data($pack, $tran_id = NULL) { // system $system_obj = mgm_get_class('system'); $user_id = $pack['user_id']; $user = get_userdata($user_id); // item $item = $this->get_pack_item($pack); // set data $data = array('invoice_num' => $tran_id, 'description' => $item['name'], 'email' => $user->user_email, 'currency' => strtolower($this->setting['currency'])); // additional fields,see parent for all fields, only different given here $this->_set_address_fields($user, $data); // product based if (isset($pack['product']['stripe_plan_id'])) { $data['plan'] = $pack['product']['stripe_plan_id']; $data['quantity'] = 1; } else { // use total $data['amount'] = mgm_convert_to_cents($pack['cost']); } // custom passthrough $data['custom'] = $tran_id; // update currency if ($pack['currency'] != $this->setting['currency']) { $pack['currency'] = $this->setting['currency']; } // strip $data = mgm_stripslashes_deep($data); // add filter @todo test $data = apply_filters('mgm_payment_button_data', $data, $tran_id, $this->module, $pack); // update pack/transaction mgm_update_transaction(array('data' => json_encode($pack), 'module' => $this->module), $tran_id); // return data return $data; }
function _get_button_data($pack, $tran_id = NULL) { // system $system_obj = mgm_get_class('system'); // item $item = $this->get_pack_item($pack); //pack currency over rides genral setting currency - issue #1602 if (!isset($pack['currency']) || empty($pack['currency'])) { $pack['currency'] = $this->setting['currency']; } // type $membership_type = md5($pack['membership_type']); $user_id = mgm_get_user_id(); $user = get_userdata($user_id); $member = mgm_get_member($user_id); $amount = mgm_convert_to_cents($pack['cost']); $payment_type = (int) $pack['num_cycles'] == 1 ? 'one-time' : 'subscription'; $s_valid_until = date('Y-m-d\\TG:i:s\\Z', strtotime('+1 hour')); $description = substr($item['name'], 0, 32); // Setup hash string $hash_string = $this->setting['secret_key'] . $this->setting['merchant_id'] . $this->setting['sub_id'] . $amount . $tran_id . $payment_type . $s_valid_until . '1' . $description . '1' . $amount; // Remove HTML Entities $hash_string = html_entity_decode($hash_string); // Remove space characters: "\t", "\n", "\r" and " " $hash_string = str_replace(array("\t", "\n", "\r", " "), '', $hash_string); // Generate hash $hash_string = sha1($hash_string); $enc_trans_id = $this->_encode_id($tran_id); $cancel_url = add_query_arg(array('status' => 'cancel', 'extra' => $enc_trans_id), $this->setting['cancel_url']); $success_url = add_query_arg(array('status' => 'success', 'extra' => $enc_trans_id), $this->setting['return_url']); $error_url = add_query_arg(array('status' => 'error', 'extra' => $enc_trans_id), $this->setting['return_url']); // set data $data = array('merchantID' => $this->setting['merchant_id'], 'subID' => $this->setting['sub_id'], 'language' => $this->setting['language'], 'currency' => $pack['currency'], 'amount' => $amount, 'purchaseID' => $tran_id, 'description' => $description, 'hash' => $hash_string, 'paymentType' => $payment_type, 'validUntil' => $s_valid_until, 'itemNumber1' => '1', 'itemDescription1' => $description, 'itemQuantity1' => '1', 'itemPrice1' => $amount, 'urlCancel' => $cancel_url, 'urlSuccess' => $success_url, 'urlError' => $error_url); // add filter @todo test $data = apply_filters('mgm_payment_button_data', $data, $tran_id, $this->module, $pack); // rabo changes if ($this->setting['aquirer'] == 'rabo_omnikassa') { // convert for rabobank $data = $this->_get_rabobank_data($data, $tran_id); } elseif ($this->setting['aquirer'] == 'sisow') { // convert for rabobank $data = $this->_get_sisow_data($data, $tran_id); } // update pack/transaction mgm_update_transaction(array('data' => json_encode($pack), 'module' => $this->module), $tran_id); // data return $data; }
function _get_button_data($pack, $tran_id = NULL) { // system setting $system_obj = mgm_get_class('system'); $user_id = $pack['user_id']; $user = get_userdata($user_id); // item $item = $this->get_pack_item($pack); //pack currency over rides genral setting currency - issue #1602 if (!isset($pack['currency']) || empty($pack['currency'])) { $pack['currency'] = $this->setting['currency']; } // setup data array $data = array('PSPID' => $this->setting['pspid'], 'ORDERID' => $tran_id, 'AMOUNT' => mgm_convert_to_cents($pack['cost']), 'CURRENCY' => $pack['currency'], 'LANGUAGE' => $this->setting['language'], 'COM' => $item['name'], 'OPERATION' => 'SAL', 'EMAIL' => $user->user_email, 'CANCELURL' => $this->setting['cancel_url'], 'BACKURL' => $this->setting['cancel_url'], 'ACCEPTURL' => $this->setting['return_url'], 'DECLINEURL' => $this->setting['return_url']); // address fields $this->_set_address_fields($user, $data); // subscription purchase with ongoing/limited if (!isset($pack['buypost']) && isset($pack['duration_type']) && $pack['num_cycles'] != 1) { // does not support one-time recurring // if ($pack['num_cycles'] != 1 && $pack['duration_type']) { // old style $data['ALIAS'] = 'user-' . $user_id; $data['ALIASUSAGE'] = $system_obj->get_subscription_name($pack); $data['ALIASOPERATION'] = 'BYMERCHANT'; // 'BYPSP'; } else { // post purchase // apply addons $this->_apply_addons($pack, $data, array('amount' => 'AMOUNT', 'description' => 'COM')); } // custom/passthrough $data['COMPLUS'] = $tran_id; // update currency - issue #1602 /* if($pack['currency'] != $this->setting['currency']){ $pack['currency'] = $this->setting['currency']; }*/ // SHASIGN if (!empty($this->setting['sha1_passphrase'])) { $data['SHASIGN'] = $this->_generate_shasign($data); } // add filter @todo test $data = apply_filters('mgm_payment_button_data', $data, $tran_id, $this->module, $pack); // update pack/transaction mgm_update_transaction(array('data' => json_encode($pack), 'module' => $this->module), $tran_id); // return data return $data; }