function _filter_postdata($gateway_method, $post_data, $return = 'string')
 {
     // card holder name
     list($ch_first_name, $ch_last_name) = explode(' ', $post_data['mgm_card_holder_name']);
     // gateway method
     switch ($gateway_method) {
         case 'arb':
             // request xml
             $content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" . "<ARBCreateSubscriptionRequest xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">" . "<merchantAuthentication>" . "<name>" . $post_data['x_login'] . "</name>" . "<transactionKey>" . $post_data['x_tran_key'] . "</transactionKey>" . "</merchantAuthentication>" . "<refId>" . $post_data['x_cust_id'] . "</refId>" . "<subscription>" . "<name>" . substr($post_data['x_description'], 0, 50) . "</name>" . "<paymentSchedule>" . "<interval>" . "<length>" . $post_data['x_interval_length'] . "</length>" . "<unit>" . $post_data['x_interval_unit'] . "</unit>" . "</interval>" . "<startDate>" . $post_data['x_start_date'] . "</startDate>" . "<totalOccurrences>" . $post_data['x_total_occurrences'] . "</totalOccurrences>";
             $content .= isset($post_data['x_trial_occurrences']) ? "<trialOccurrences>" . $post_data['x_trial_occurrences'] . "</trialOccurrences>" : "";
             $content .= "</paymentSchedule>" . "<amount>" . $post_data['x_amount'] . "</amount>";
             $content .= isset($post_data['x_trial_occurrences']) ? "<trialAmount>" . $post_data['x_trial_amount'] . "</trialAmount>" : "";
             $content .= "<payment>" . "<creditCard>" . "<cardNumber>" . $post_data['mgm_card_number'] . "</cardNumber>" . "<expirationDate>" . $post_data['mgm_card_expiry_year'] . '-' . $post_data['mgm_card_expiry_month'] . "</expirationDate>" . "</creditCard>" . "</payment>";
             //include transaction id as invoice number(to be processed in Silent Post)
             $content .= "<order>" . "<invoiceNumber>" . $post_data['x_custom'] . "</invoiceNumber>" . "<description>" . substr($post_data['x_description'], 0, 254) . "</description>" . "</order>";
             $content .= "<customer>" . "<id>" . $post_data['x_cust_id'] . "</id>" . "<email>" . $post_data['x_email'] . "</email>";
             $content .= isset($post_data['x_phone']) ? "<phoneNumber>" . $this->_format_phone($post_data['x_phone']) . "</phoneNumber>" : "";
             $content .= "</customer>" . "<billTo>" . "<firstName>" . ($post_data['x_first_name'] ? $post_data['x_first_name'] : $ch_first_name) . "</firstName>" . "<lastName>" . ($post_data['x_last_name'] ? $post_data['x_last_name'] : $ch_last_name) . "</lastName>";
             // address
             if (isset($post_data['x_address'])) {
                 $content .= "<address>" . substr($post_data['x_address'], 0, 60) . "</address>";
             }
             // city
             if (isset($post_data['x_city'])) {
                 $content .= "<city>" . substr($post_data['x_city'], 0, 40) . "</city>";
             }
             // city
             if (isset($post_data['x_state']) && strlen($post_data['x_state']) == 2) {
                 $content .= "<state>" . substr($post_data['x_state'], 0, 2) . "</state>";
             }
             // city
             if (isset($post_data['x_zip'])) {
                 $content .= "<zip>" . substr($post_data['x_zip'], 0, 20) . "</zip>";
             }
             // city
             if (isset($post_data['x_country'])) {
                 $content .= "<country>" . substr($post_data['x_country'], 0, 60) . "</country>";
             }
             $content .= "</billTo>" . "</subscription>" . "</ARBCreateSubscriptionRequest>";
             // return
             return $content;
             break;
         case 'aim':
             // set delim
             $this->delim_char = '|';
             // custom set
             $aim_fields = array('x_version' => '3.1', 'x_type' => 'AUTH_CAPTURE', 'x_invoice_num' => $post_data['x_invoice_num'], 'x_delim_data' => 'TRUE', 'x_delim_char' => $this->delim_char, 'x_method' => 'CC', 'x_relay_response' => 'FALSE', 'x_email_customer' => 'TRUE', 'x_card_num' => $post_data['mgm_card_number'], 'x_card_code' => $post_data['mgm_card_code'], 'x_exp_date' => $post_data['mgm_card_expiry_month'] . '-' . $post_data['mgm_card_expiry_year']);
             // capture some as sent
             $fields_sent = array('x_login', 'x_tran_key', 'x_description', 'x_first_name', 'x_last_name', 'x_email', 'x_cust_id', 'x_amount', 'x_address', 'x_city', 'x_state', 'x_zip', 'x_country', 'x_phone');
             // first last name
             if ($post_data['x_first_name'] == '' || $post_data['x_first_name'] == $post_data['x_last_name']) {
                 $post_data['x_first_name'] = $ch_first_name;
             }
             // last name
             if ($post_data['x_last_name'] == '' || $post_data['x_first_name'] == $post_data['x_last_name']) {
                 $post_data['x_last_name'] = $ch_last_name;
             }
             // set
             foreach ($fields_sent as $field) {
                 // take only when set
                 if (isset($post_data[$field]) && !empty($post_data[$field])) {
                     $aim_fields[$field] = $post_data[$field];
                 }
             }
             // format
             if (isset($aim_fields['x_phone'])) {
                 // format phone
                 $phone = $this->_format_phone($aim_fields['x_phone']);
                 // check
                 if ($phone) {
                     $aim_fields['x_phone'] = $phone;
                 } else {
                     unset($aim_fields['x_phone']);
                 }
             }
             // send filtered
             return $return == 'string' ? mgm_http_build_query($aim_fields) : $aim_fields;
             break;
     }
 }
Пример #2
0
 function _crypt($data = NULL)
 {
     // if array : encode
     if (is_array($data)) {
         $str = mgm_http_build_query($data, false);
         return $this->_base64_encode($this->_simpleXor($str, $this->setting['encryption_key']));
     } elseif (is_string($data)) {
         // if string : decode
         $str_decoded = $this->_simpleXor($this->_base64_decode($data), $this->setting['encryption_key']);
         return $this->_get_token($str_decoded);
     }
 }
 /**
  * Button code wrapper
  *
  * @param unknown_type $pack
  * @param unknown_type $tran_id
  * @return unknown
  */
 function _get_button_code($pack, $tran_id = NULL)
 {
     // get data
     $data = $this->_get_button_data($pack, $tran_id);
     // strip
     $data = mgm_stripslashes_deep($data);
     // log
     mgm_log($data, __FUNCTION__);
     // return
     return mgm_http_build_query($data);
 }
Пример #4
0
 function _filter_postdata($action, $post_data, $join = false)
 {
     // card holder name
     // list($ch_first_name, $ch_last_name) = explode(' ', $post_data['mgm_card_holder_name']);
     // init
     $filtered = array();
     // action
     switch ($action) {
         case 'create_customer':
             // desc
             $filtered['description'] = $post_data['description'];
             $filtered['plan'] = $post_data['plan'];
             $filtered['email'] = $post_data['email'];
             break;
         case 'create_charge':
             // desc
             $filtered['description'] = $post_data['description'];
             $filtered['amount'] = $post_data['amount'];
             $filtered['currency'] = $post_data['currency'];
             break;
         case 'upgrade_subscription':
             $filtered['plan'] = $post_data['plan'];
             break;
     }
     // quantity
     if (isset($post_data['quantity'])) {
         $filtered['quantity'] = $post_data['quantity'];
     }
     // trial end
     if (isset($post_data['trial_end'])) {
         $filtered['trial_end'] = $post_data['trial_end'];
     }
     $filtered['card']['number'] = $post_data['mgm_card_number'];
     $filtered['card']['exp_month'] = $post_data['mgm_card_expiry_month'];
     $filtered['card']['exp_year'] = $post_data['mgm_card_expiry_year'];
     $filtered['card']['cvc'] = $post_data['mgm_card_code'];
     $filtered['card']['name'] = $post_data['mgm_card_holder_name'];
     // street
     if (isset($post_data['address_line1'])) {
         $filtered['card']['address_line1'] = $post_data['address_line1'];
     }
     if (isset($post_data['address_line2'])) {
         $filtered['card']['address_line2'] = $post_data['address_line2'];
     }
     // zip
     if (isset($post_data['address_zip'])) {
         $filtered['card']['address_zip'] = $post_data['address_zip'];
     }
     // state
     if (isset($post_data['address_state'])) {
         $filtered['card']['address_state'] = $post_data['address_state'];
     }
     // country
     if (isset($post_data['address_country'])) {
         $filtered['card']['address_country'] = $post_data['address_country'];
     }
     // send filtered
     return $join ? mgm_http_build_query($filtered) : $filtered;
 }
Пример #5
0
 function _filter_postdata($post_data, $join = false)
 {
     // card holder name
     list($ch_first_name, $ch_last_name) = explode(' ', $post_data['mgm_card_holder_name']);
     // init
     $filtered = array();
     // capture some as sent
     $fields_sent = array('USER', 'PWD', 'SIGNATURE', 'VERSION', 'IPADDRESS', 'CURRENCYCODE');
     // set
     foreach ($fields_sent as $field) {
         // take only when set
         if (isset($post_data[$field]) && !empty($post_data[$field])) {
             $filtered[$field] = $post_data[$field];
         }
     }
     // common
     $filtered['FIRSTNAME'] = isset($post_data['firstname']) ? $post_data['firstname'] : $ch_first_name;
     $filtered['LASTNAME'] = isset($post_data['lastname']) ? $post_data['lastname'] : $ch_last_name;
     $filtered['EMAIL'] = $post_data['email'];
     $filtered['DESC'] = $filtered['SUBSCRIBERNAME'] = $post_data['description'];
     $filtered['AMT'] = $post_data['amount'];
     // street
     if (isset($post_data['street'])) {
         $filtered['STREET'] = $post_data['street'];
     }
     if (isset($post_data['street2'])) {
         $filtered['STREET2'] = $post_data['street2'];
     }
     // city
     if (isset($post_data['city'])) {
         $filtered['CITY'] = $post_data['city'];
     }
     // state
     if (isset($post_data['state'])) {
         $filtered['STATE'] = $post_data['state'];
     }
     // zip
     if (isset($post_data['zip'])) {
         $filtered['ZIP'] = $post_data['zip'];
     }
     // country
     if (isset($post_data['countrycode'])) {
         $filtered['COUNTRYCODE'] = $post_data['countrycode'];
     }
     // notifyurl
     if (isset($post_data['notifyurl'])) {
         $filtered['NOTIFYURL'] = $post_data['notifyurl'];
     }
     //issue #974
     if (is_numeric($this->setting['max_failed_payments'])) {
         $max_failed_payments = round($this->setting['max_failed_payments']);
     } else {
         $max_failed_payments = 3;
     }
     // mgm_log('max_failed_payments '.$max_failed_payments);
     // subscription purchase
     if ($post_data['recurring_billing'] == 'TRUE') {
         $filtered['METHOD'] = 'CreateRecurringPaymentsProfile';
         $filtered['PROFILEREFERENCE'] = $post_data['invnum'];
         $filtered['PROFILESTARTDATE'] = $post_data['start_date'];
         //issue #974
         $filtered['MAXFAILEDPAYMENTS'] = $max_failed_payments;
         $filtered['AUTOBILLAMT'] = 'AddToNextBilling';
         // period
         $filtered['BILLINGPERIOD'] = $post_data['billing_period'];
         // Day|Month|Year
         $filtered['BILLINGFREQUENCY'] = $post_data['billing_frequency'];
         // 3|12 etc.	frequency
         if ($post_data['total_billing_cycles']) {
             $filtered['TOTALBILLINGCYCLES'] = $post_data['total_billing_cycles'];
         }
         // trial
         if ($post_data['trial_billing_period']) {
             $filtered['TRIALBILLINGPERIOD'] = $post_data['trial_billing_period'];
             $filtered['TRIALBILLINGFREQUENCY'] = $post_data['trial_billing_frequency'];
             if ($post_data['trial_total_billing_cycles']) {
                 // need this checked
                 $filtered['TRIALTOTALBILLINGCYCLES'] = $post_data['trial_total_billing_cycles'];
             }
             $filtered['TRIALAMT'] = $post_data['trial_amt'];
         }
     } else {
         // post purchase
         $filtered['METHOD'] = 'DoDirectPayment';
         $filtered['INVNUM'] = $post_data['invnum'];
         $filtered['PAYMENTACTION'] = 'Sale';
         // Sale/Authorization/Order
         // custom
         if (isset($post_data['custom'])) {
             $filtered['CUSTOM'] = $post_data['custom'];
         }
     }
     // card data
     $filtered['CREDITCARDTYPE'] = $post_data['mgm_card_type'];
     $filtered['ACCT'] = $post_data['mgm_card_number'];
     $filtered['EXPDATE'] = $post_data['mgm_card_expiry_month'] . $post_data['mgm_card_expiry_year'];
     $filtered['CVV2'] = $post_data['mgm_card_code'];
     // send filtered
     return $join ? mgm_http_build_query($filtered) : $filtered;
 }