Esempio n. 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']);
     }
 }
 /**
  * when the ipn post back fail, check the order status and do a check with the return back 
  * @param $order object ET_Order
  * @since 1.2
  * @author Dakachi
  */
 function do_checkout_get_back(ET_Order $order)
 {
     $order_pay = clone $order;
     $payment = new ET_Paypal();
     $order = $order_pay->generate_data_to_pay();
     /**
      * st request ///
      */
     if (isset($_REQUEST['st']) && ($_REQUEST['st'] == 'Completed' || $_REQUEST['st'] == 'Pending')) {
         /**
          * check amt and currency
          */
         if ($_REQUEST['amt'] == $order['total'] && $_REQUEST['cc'] == $order['currencyCodeType']) {
             /**
              * check status update order
              */
             if ($_REQUEST['st'] == 'Completed') {
                 $order_pay->set_status('publish');
             } else {
                 $order_pay->set_status('pending');
             }
             $order_pay->update_order();
             return array('ACK' => true, 'payment' => 'simplePaypal', 'payment_status' => $_POST['st']);
         } else {
             return array('ACK' => false, 'payment' => 'simplePaypal', 'payment_status' => 'fraud');
         }
     }
     if (isset($_POST['payment_status']) && ($_POST['payment_status'] == 'Completed' || $_POST['payment_status'] == 'Pending')) {
         $order_pay->set_payment_code($_POST['txn_id']);
         $order_pay->set_payer_id($_POST['payer_id']);
         $mc_gross = $_POST['mc_gross'];
         $mc_currency = $_POST['mc_currency'];
         $receiver_email = $_POST['receiver_email'];
         $business = $_POST['business'];
         $api = $payment->get_api();
         // check $mc_gross, $mc_currency and receiver email are match with paid order and setting
         if ($mc_gross == $order['total'] && $mc_currency == $order['currencyCodeType'] && ($receiver_email == trim($api['api_username']) || $business == trim($api['api_username']))) {
             if ($_POST['payment_status'] == 'Completed') {
                 $order_pay->set_status('publish');
             } else {
                 $order_pay->set_status('pending');
             }
             $order_pay->update_order();
             return array('ACK' => true, 'payment' => 'simplePaypal', 'payment_status' => $_POST['payment_status']);
         } else {
             return array('ACK' => false, 'payment' => 'simplePaypal', 'msg' => __("Fraudulent", ET_DOMAIN));
         }
     }
 }
function ae_payment_postback_handle()
{
    /**
     * only paypal using this, and skip if wooCommerce actived
     */
    if (!empty($_GET['paypalListener']) && 'paypal_appengine_IPN' == $_GET['paypalListener']) {
        if (class_exists("ET_Paypal")) {
            $paypal = new ET_Paypal();
            $paypal->check_ipn_response();
        }
    }
}
Esempio n. 4
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;
}