Example #1
0
 /**
  * callback update option for payment api settings
  */
 public function update_payment_settings($name, $value)
 {
     // update paypal api settings
     if ($name == 'paypal') {
         ET_Paypal::set_api($value);
     }
     // update 2checkout api settings
     if ($name == '2checkout') {
         ET_2CO::set_api($value);
     }
     // update 2checkout api settings
     if ($name == 'cash') {
         ET_Cash::set_message($value['cash_message']);
     }
 }
 function do_checkout(ET_Order $order)
 {
     if (!isset($_REQUEST['order_number'])) {
         return array('ACK' => false, 'payment' => '2checkout', 'reponse' => array('S_MESSAGE' => __("MD5 False", ET_DOMAIN), 'L_MESSAAGE' => __("Md5 check sum not match!", ET_DOMAIN)), 'payment_status' => 'error');
     }
     $order_pay = clone $order;
     $order_pay->set_payment_code($_REQUEST['order_number']);
     $order = $order_pay->generate_data_to_pay();
     if ($order['payment_code'] == '') {
         return false;
     }
     /* The MD5 hash is provided to help you verify the authenticity of a sale. 
      * This is especially useful for vendors that sell downloadable products, or e-goods, 
      * as it can be used to verify whether sale actually came from 2Checkout and was a legitimate live sale. 
      * We intentionally break the hash code for demo orders so that you can compare the hash we provide with 
      * what it should be to determine whether or not to provide the customer with your goods.
      */
     $payment = new ET_2CO();
     $md5_key = $payment->md5($order['payment_code'], $order['total']);
     if ($md5_key == $_REQUEST['key']) {
         // do something update order
         $order_pay->set_status('publish');
         $order_pay->update_order();
         return array('ACK' => true, 'payment' => '2checkout');
     } else {
         if ($payment->get_mode() == 'Y') {
             $order_pay->set_status('publish');
             $order_pay->update_order();
             return array('ACK' => true, 'test_mode' => true, 'payment' => '2checkout', 'reponse' => array('S_MESSAGE' => __("MD5 False", ET_DOMAIN), 'L_MESSAAGE' => __("In  Demo mode the 2Checkout order number is changed to '1' which will cause the hash to fail this. This is intentional so that merchants selling downloadable products and services can compare the hash to determine whether to provide a product to a customer", ET_DOMAIN)), 'payment_status' => 'Completed');
         } else {
             return array('ACK' => false, 'payment' => '2checkout', 'reponse' => array('S_MESSAGE' => __("MD5 False", ET_DOMAIN), 'L_MESSAAGE' => __("Md5 check sum not match!", ET_DOMAIN)), 'payment_status' => 'error');
         }
     }
 }
Example #3
0
/**
 * update payment setting
 * @param name : string api key
 * @param value : string api value
*/
function et_update_payment_setting($name, $value)
{
    $paypal_api = ET_Paypal::get_api();
    $_2co_api = ET_2CO::get_api();
    $google = ET_GoogleCheckout::get_api();
    $value = trim($value);
    $msg = '';
    switch ($name) {
        case 'PAYPAL-APIUSERNAME':
            $validator = new ET_Validator();
            if ($value != '' && !$validator->validate('email', $value)) {
                $msg = __('Please fill in a valid email!', ET_DOMAIN);
                break;
            }
            $paypal_api['api_username'] = $value;
            $msg = ET_Paypal::set_api($paypal_api);
            break;
        case '2CHECKOUT-SID':
            $_2co_api['sid'] = $value;
            $msg = ET_2CO::set_api($_2co_api);
            break;
        case '2CHECKOUT-SECRETKEY':
            $_2co_api['secret_key'] = $value;
            $msg = ET_2CO::set_api($_2co_api);
            break;
        case '2CO_USE_DIRECT':
            $_2co_api['use_direct'] = $value;
            $msg = ET_2CO::set_api($_2co_api);
            break;
            break;
        case 'GOOGLE-MERCHANT-ID':
            $google['merchant_id'] = $value;
            $msg = ET_GoogleCheckout::set_api($google);
            break;
        case 'GOOGLE-MERCHANT-KEY':
            $google['merchant_key'] = $value;
            $msg = ET_GoogleCheckout::set_api($google);
            break;
        case 'CASH-MESSAGE':
            $msg = ET_Cash::set_message($value);
            break;
        default:
            $response = false;
            break;
    }
    $msg = apply_filters('et_update_payment_setting', $msg, $name, $value);
    if (is_string($msg)) {
        $response = array('success' => false, 'msg' => $msg);
    } else {
        $response = array('success' => true, 'msg' => $msg);
    }
    return $response;
}