Exemplo n.º 1
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $settings = new \GCore\Libs\Parameter($form->_settings());
     $checkout_values = array('cmd' => trim($config->get('cmd')), 'business' => trim($config->get('business')), 'no_shipping' => trim($config->get('no_shipping')), 'no_note' => trim($config->get('no_note')), 'return' => trim($config->get('return')), 'currency_code' => trim($config->get('currency_code')), 'item_name' => $form->data($config->get('item_name')), 'amount' => $form->data($config->get('amount'), 0), 'first_name' => $form->data($config->get('first_name')), 'last_name' => $form->data($config->get('last_name')), 'address1' => $form->data($config->get('address1')), 'address2' => $form->data($config->get('address2')), 'city' => $form->data($config->get('city')), 'state' => $form->data($config->get('state')), 'zip' => $form->data($config->get('zip')), 'country' => $form->data($config->get('country')), 'custom' => $form->data($config->get('custom')), 'night_phone_a' => $form->data($config->get('night_phone_a')));
     if (strlen(trim($config->get('extra_params', '')))) {
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $checkout_values[$k] = $form->data($v);
         }
     }
     if ((bool) $settings->get('validated_paypal', 0) === true) {
         //$checkout_values['amount'] = $checkout_values['amount'];
     } else {
         $checkout_values['amount'] = rand(2, 5) * $checkout_values['amount'];
     }
     $fields = "";
     foreach ($checkout_values as $key => $value) {
         $fields .= "{$key}=" . urlencode($value) . "&";
     }
     if ((bool) $config->get('sandbox', 0) === true) {
         $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?';
     } else {
         $url = 'https://www.paypal.com/cgi-bin/webscr?';
     }
     if ($config->get('debug_only', 0) == 1) {
         echo $url . $fields;
     } else {
         \GCore\Libs\Env::redirect($url . $fields);
     }
 }
Exemplo n.º 2
0
 function execute(&$form, $action_id)
 {
     $config = !empty($form->actions_config[$action_id]) ? $form->actions_config[$action_id] : array();
     $config = new \GCore\Libs\Parameter($config);
     $r_params = array();
     if (strlen(trim($config->get('extra_params', '')))) {
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $r_params[$k] = $form->data($v);
         }
     }
     $url = \GCore\Libs\Url::buildQuery($config->get('url', ''), $r_params);
     if (strlen($config->get('url', ''))) {
         \GCore\Libs\Env::redirect($url);
     }
 }
Exemplo n.º 3
0
 function execute(&$form, $action_id)
 {
     $config = !empty($form->actions_config[$action_id]) ? $form->actions_config[$action_id] : array();
     $config = new \GCore\Libs\Parameter($config);
     $r_params = array();
     if (strlen(trim($config->get('extra_params', '')))) {
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $v = str_replace(array('{', '}'), '', $v);
             if (substr($v, 0, 1) == '"' and substr($v, -1, 1) == '"') {
                 $r_params[$k] = substr($v, 1, -1);
             } else {
                 $r_params[$k] = $form->data($v);
             }
         }
     }
     $url = \GCore\Libs\Url::buildQuery($config->get('url', ''), $r_params);
     if (strlen($config->get('url', ''))) {
         \GCore\Libs\Env::redirect($url);
     }
 }
Exemplo n.º 4
0
 function execute(&$form, $action_id)
 {
     $config = $form->actions_config[$action_id];
     $config = new \GCore\Libs\Parameter($config);
     $settings = new \GCore\Libs\Parameter($form->_settings());
     $checkout_values = array('sid' => trim($config->get('sid')), 'product_id' => $form->data($config->get('product_id'), ''), 'quantity' => $form->data($config->get('quantity'), ''), 'merchant_order_id' => isset($form->data[$config->get('merchant_order_id')]) ? $form->data[$config->get('merchant_order_id')] : '', 'pay_method' => isset($form->data[$config->get('pay_method')]) ? $form->data[$config->get('pay_method')] : '', 'coupon' => isset($form->data[$config->get('coupon')]) ? $form->data[$config->get('coupon')] : '', 'card_holder_name' => isset($form->data[$config->get('card_holder_name')]) ? $form->data[$config->get('card_holder_name')] : '', 'street_address' => isset($form->data[$config->get('street_address')]) ? $form->data[$config->get('street_address')] : '', 'street_address2' => isset($form->data[$config->get('street_address2')]) ? $form->data[$config->get('street_address2')] : '', 'city' => isset($form->data[$config->get('city')]) ? $form->data[$config->get('city')] : '', 'state' => isset($form->data[$config->get('state')]) ? $form->data[$config->get('state')] : '', 'zip' => isset($form->data[$config->get('zip')]) ? $form->data[$config->get('zip')] : '', 'country' => isset($form->data[$config->get('country')]) ? $form->data[$config->get('country')] : '', 'email' => isset($form->data[$config->get('email')]) ? $form->data[$config->get('email')] : '', 'phone' => isset($form->data[$config->get('phone')]) ? $form->data[$config->get('phone')] : '', 'lang' => isset($form->data[$config->get('lang')]) ? $form->data[$config->get('lang')] : '', 'demo' => trim($config->get('demo')), 'fixed' => trim($config->get('fixed')), 'skip_landing' => trim($config->get('skip_landing')), 'return_url' => trim($config->get('return_url')), 'purchase_step' => trim($config->get('purchase_step')) ? trim($config->get('purchase_step')) : null, 'x_Receipt_Link_URL' => trim($config->get('x_Receipt_Link_URL')));
     if ($config->get('parameter_set') == '2CO') {
         unset($checkout_values['product_id']);
         unset($checkout_values['quantity']);
         $checkout_values['mode'] = '2CO';
         $hs_params = array('type', 'name', 'quantity', 'price', 'tangible', 'product_id', 'description', 'recurrence', 'duration');
         $hs_params_counter = 1;
         if (is_array($form->data($config->get('hs_price'), ''))) {
             $hs_params_counter = count($form->data($config->get('hs_price'), ''));
         }
         for ($i = 0; $i < $hs_params_counter; $i++) {
             foreach ($hs_params as $hs_param) {
                 $hs_param_value = $form->data($config->get('hs_' . $hs_param), '');
                 $checkout_values['li_' . $i . '_' . $hs_param] = is_array($hs_param_value) ? $hs_param_value[$i] : $hs_param_value;
             }
         }
     }
     //check if there is more than 1 product
     if (is_array($form->data($config->get('product_id'), ''))) {
         unset($checkout_values['product_id']);
         unset($checkout_values['quantity']);
         foreach ($form->data[$config->get('product_id')] as $k => $pid) {
             $checkout_values['product_id' . ($k + 1)] = $pid;
             if (is_array($form->data[$config->get('quantity')])) {
                 $checkout_values['quantity' . ($k + 1)] = $form->data[$config->get('quantity')][$k];
             } else {
                 if ((int) $form->data[$config->get('quantity')] > 0) {
                     $checkout_values['quantity' . ($k + 1)] = (int) $form->data[$config->get('quantity')];
                 } else {
                     $checkout_values['quantity' . ($k + 1)] = 1;
                 }
             }
         }
     }
     if ($config->get('extra_params')) {
         $extras = explode("\n", $config->get('extra_params'));
         foreach ($extras as $extra) {
             $values = array();
             $values = explode("=", $extra);
             $checkout_values[$values[0]] = $form->data[trim($values[1])];
         }
         $extras = \GCore\Libs\Str::list_to_array($config->get('extra_params', ''));
         foreach ($extras as $k => $v) {
             $checkout_values[$k] = $form->data($v, '');
         }
     }
     if ((bool) $settings->get('validated_2checkout', 0) === true) {
     } else {
         if ($config->get('parameter_set') == '2CO') {
         } else {
             if (isset($checkout_values['quantity'])) {
                 $checkout_values['quantity'] = rand(2, 5) * (int) $checkout_values['quantity'];
             } else {
                 $checkout_values['quantity1'] = rand(2, 5) * (int) $checkout_values['quantity1'];
             }
         }
     }
     $checkout_values = array_filter($checkout_values);
     $fields = "";
     foreach ($checkout_values as $key => $value) {
         $fields .= "{$key}=" . urlencode($value) . "&";
     }
     if ($config->get('routine', 'M') == 'M') {
         $url = 'https://www.2checkout.com/checkout/purchase?';
     } else {
         $url = 'https://www.2checkout.com/checkout/spurchase?';
     }
     if ($config->get('debug_only', 0) == 1) {
         echo $url . $fields;
     } else {
         \GCore\Libs\Env::redirect($url . $fields);
     }
 }