当前位置: 首页>>代码示例>>PHP>>正文


PHP edd_get_errors函数代码示例

本文整理汇总了PHP中edd_get_errors函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_errors函数的具体用法?PHP edd_get_errors怎么用?PHP edd_get_errors使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了edd_get_errors函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edd_set_error

/**
 * Set Error
 *
 * Stores an error in a session var.
 *
 * @access      public
 * @since       1.0 
 * @param       $error_id string - the ID of the error being set
 * @param       $error_message - the message to store with the error 
 * @return      void
*/
function edd_set_error($error_id, $error_message)
{
    $errors = edd_get_errors();
    if (!$errors) {
        $errors = array();
    }
    $errors[$error_id] = $error_message;
    $_SESSION['edd-errors'] = $errors;
}
开发者ID:ryannmicua,项目名称:Easy-Digital-Downloads,代码行数:20,代码来源:error-tracking.php

示例2: edd_process_purchase_form

/**
 * Process Purchase Form
 *
 * Handles the purchase form process.
 *
 * @access      private
 * @since       1.0
 * @version     1.0.8.1
 * @return      void
*/
function edd_process_purchase_form()
{
    // no need to run on admin
    if (is_admin()) {
        return;
    }
    // verify the nonce for this action
    if (!isset($_POST['edd-nonce']) || !wp_verify_nonce($_POST['edd-nonce'], 'edd-purchase-nonce')) {
        return;
    }
    // make sure the cart isn't empty
    $cart = edd_get_cart_contents();
    if (empty($cart)) {
        wp_die(sprintf(__('Your cart is empty, please return to the %ssite%s and try again.', 'edd'), '<a href="' . esc_url(home_url()) . '" title="' . get_bloginfo('name') . '">', '</a>'), __('Error', 'edd'));
    }
    // validate the form $_POST data
    $valid_data = edd_purchase_form_validate_fields();
    // allow themes and plugins to hoook to errors
    do_action('edd_checkout_error_checks', $_POST);
    // check errors
    if (false !== ($errors = edd_get_errors())) {
        // we have errors, send back to checkout
        edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
        exit;
    }
    // check user
    if (false === ($user = edd_get_purchase_form_user($valid_data))) {
        // something went wrong when collecting data, send back to checkout
        edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
        exit;
    }
    // setup user information
    $user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'discount' => $valid_data['discount']);
    // setup purchase information
    $purchase_data = array('downloads' => edd_get_cart_contents(), 'subtotal' => edd_get_cart_amount(false), 'tax' => edd_get_cart_tax(), 'price' => edd_get_cart_amount(), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s'), 'user_info' => $user_info, 'post_data' => $_POST, 'cart_details' => edd_get_cart_content_details(), 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
    // add the user data for hooks
    $valid_data['user'] = $user;
    // allow themes and plugins to hook before the gateway
    do_action('edd_checkout_before_gateway', $_POST, $user_info, $valid_data);
    // allow the purchase data to be modified before it is sent to the gateway
    $purchase_data = apply_filters('edd_purchase_data_before_gateway', $purchase_data, $valid_data);
    // if the total amount in the cart is 0, send to the manaul gateway. This emulates a free download purchase
    if ($purchase_data['price'] <= 0) {
        // revert to manual
        $valid_data['gateway'] = 'manual';
    }
    // used for showing download links to non logged-in users after purchase, and for other plugins needing purchase data.
    edd_set_purchase_session($purchase_data);
    // send info to the gateway for payment processing
    edd_send_to_gateway($valid_data['gateway'], $purchase_data);
    exit;
}
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:62,代码来源:process-purchase.php

示例3: edd_process_purchase_form

/**
 * Process Purchase Form
 *
 * Handles the purchase form process.
 *
 * @access      private
 * @since       1.0
 * @version     1.0.8.1
 * @return      void
*/
function edd_process_purchase_form()
{
    global $edd_options;
    // no need to run on admin
    if (is_admin()) {
        return;
    }
    // verify the nonce for this action
    if (!isset($_POST['edd-nonce']) || !wp_verify_nonce($_POST['edd-nonce'], 'edd-purchase-nonce')) {
        return;
    }
    // validate the form $_POST data
    $valid_data = edd_purchase_form_validate_fields();
    // allow themes and plugins to hoook to errors
    do_action('edd_checkout_error_checks', $_POST);
    // check errors
    if (false !== ($errors = edd_get_errors())) {
        // we have errors, send back to checkout
        edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
        exit;
    }
    // check user
    if (false === ($user = edd_get_purchase_form_user($valid_data))) {
        // something went wrong when collecting data, send back to checkout
        edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
        exit;
    }
    // setup user information
    $user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'discount' => $valid_data['discount']);
    // setup purchase information
    $purchase_data = array('downloads' => edd_get_cart_contents(), 'price' => edd_get_cart_amount(), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s'), 'user_info' => $user_info, 'post_data' => $_POST, 'cart_details' => edd_get_cart_content_details(), 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
    // add the user data for hooks
    $valid_data['user'] = $user;
    // allow themes and plugins to hook before the gateway
    do_action('edd_checkout_before_gateway', $_POST, $user_info, $valid_data);
    // allow the purchase data to be modified before it is sent to the gateway
    $purchase_data = apply_filters('edd_purchase_data_before_gateway', $purchase_data, $valid_data);
    // if the total amount in the cart is 0, send to the manaul gateway. This emulates a free download purchase
    if ($purchase_data['price'] <= 0) {
        // revert to manual
        $valid_data['gateway'] = 'manual';
    }
    if (isset($edd_options['show_links_on_success'])) {
        // used for showing download links to non logged-in users after purchase
        edd_set_purchase_session($purchase_data);
    }
    // send info to the gateway for payment processing
    edd_send_to_gateway($valid_data['gateway'], $purchase_data);
    exit;
}
开发者ID:ryannmicua,项目名称:Easy-Digital-Downloads,代码行数:60,代码来源:process-purchase.php

示例4: pw_edd_process_payment

function pw_edd_process_payment($purchase_data)
{
    global $edd_options;
    /**********************************
     * set transaction mode
     **********************************/
    if (edd_is_test_mode()) {
        $paytm_redirect = 'https://pguat.paytm.com/oltp-web/processTransaction?';
    } else {
        if ($edd_options['paytm_select_mode'] == '1') {
            $paytm_redirect = 'https://secure.paytm.in/oltp-web/processTransaction?';
        } else {
            $paytm_redirect = 'https://pguat.paytm.com/oltp-web/processTransaction?';
        }
    }
    // check for any stored errors
    $errors = edd_get_errors();
    if (!$errors) {
        $purchase_summary = edd_get_purchase_summary($purchase_data);
        /****************************************
         * setup the payment details to be stored
         ****************************************/
        $payment = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => $edd_options['currency'], 'downloads' => $purchase_data['downloads'], 'gateway' => 'paytm', 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
        // record the pending payment
        $payment = edd_insert_payment($payment);
        $merchant_payment_confirmed = false;
        $secret_key = $edd_options['paytm_mer_access_key'];
        $params = array('REQUEST_TYPE' => 'DEFAULT', 'MID' => $edd_options['paytm_merchant_id'], 'TXN_AMOUNT' => $purchase_data['price'], 'CHANNEL_ID' => "WEB", 'INDUSTRY_TYPE_ID' => $edd_options['paytm_industry_type'], 'WEBSITE' => $edd_options['paytm_website_name'], 'CUST_ID' => $purchase_data['user_email'], 'ORDER_ID' => $purchase_data['purchase_key'], 'EMAIL' => $purchase_data['user_email']);
        if ($edd_options['paytm_callback'] == '1') {
            $params['CALLBACK_URL'] = get_site_url() . '/?edd-listener=PAYTM_IPN&payment_id=' . $payment;
        }
        $checksum = getChecksumFromArray($params, $secret_key);
        $params['CHECKSUMHASH'] = $checksum;
        foreach ($params as $key => $val) {
            $submit_Params .= trim($key) . '=' . trim(urlencode($val)) . '&';
        }
        $submit_Params = substr($submit_Params, 0, -1);
        $request = $paytm_redirect . $submit_Params;
        wp_redirect($request);
        exit;
    } else {
        $fail = true;
        // errors were detected
    }
    if ($fail !== false) {
        // if errors are present, send the user back to the purchase page so they can be corrected
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    }
}
开发者ID:Paytm-Payments,项目名称:Paytm_EasyDigital_Kit,代码行数:49,代码来源:edd-paytm-gateway.php

示例5: sofort_process_payment

function sofort_process_payment($purchase_data)
{
    global $edd_options;
    // check there is a gateway name
    if (!isset($purchase_data['post_data']['edd-gateway'])) {
        return;
    }
    // collect payment data
    $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => $edd_options['currency'], 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'status' => 'pending');
    $errors = edd_get_errors();
    if ($errors) {
        // problems? send back
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    } else {
        $payment = edd_insert_payment($payment_data);
        // check payment
        if (!$payment) {
            edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
        } else {
            if (!class_exists('SofortLib')) {
                require_once 'library/sofortLib.php';
            }
            $return_url = add_query_arg('payment-confirmation', 'paypal', get_permalink($edd_options['success_page']));
            $Sofort = new SofortLib_Multipay(trim($edd_options['sofort_config_id']));
            $Sofort->setSofortueberweisung();
            $Sofort->setAmount($purchase_data['price']);
            $Sofort->setReason('CartId ' . $payment, $purchase_data['post_data']['edd_first'] . ' ' . $purchase_data['post_data']['edd_last']);
            $Sofort->addUserVariable($payment);
            $Sofort->setSuccessUrl($return_url);
            $Sofort->setAbortUrl(edd_get_failed_transaction_uri());
            $Sofort->setTimeoutUrl(edd_get_failed_transaction_uri());
            $Sofort->setNotificationUrl(home_url('/?sofort=ipn'));
            $Sofort->sendRequest();
            if ($Sofort->isError()) {
                //PNAG-API didn't accept the data
                wp_die($Sofort->getError(), 'Error');
            } else {
                //buyer must be redirected to $paymentUrl else payment cannot be successfully completed!
                $paymentUrl = $Sofort->getPaymentUrl();
                edd_empty_cart();
                wp_redirect($paymentUrl);
                exit;
            }
        }
    }
}
开发者ID:easydigitaldownloads,项目名称:edd-sofort-banking,代码行数:46,代码来源:edd-sofort.php

示例6: edd_process_purchase_form

/**
 * Process Purchase Form
 *
 * Handles the purchase form process.
 *
 * @access      private
 * @since       1.0
 * @version     1.0.8.1
 * @return      void
 */
function edd_process_purchase_form()
{
    // Make sure the cart isn't empty
    if (!edd_get_cart_contents()) {
        edd_set_error('empty_cart', __('Your cart is empty', 'edd'));
    } else {
        // Validate the form $_POST data
        $valid_data = edd_purchase_form_validate_fields();
        // Allow themes and plugins to hoook to errors
        do_action('edd_checkout_error_checks', $valid_data, $_POST);
    }
    $is_ajax = isset($_POST['edd_ajax']);
    $user = edd_get_purchase_form_user($valid_data);
    if (edd_get_errors() || !$user) {
        if ($is_ajax) {
            do_action('edd_ajax_checkout_errors');
            edd_die();
        } else {
            return false;
        }
    }
    if ($is_ajax) {
        echo 'success';
        edd_die();
    }
    // Setup user information
    $user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'discount' => $valid_data['discount']);
    // Setup purchase information
    $purchase_data = array('downloads' => edd_get_cart_contents(), 'fees' => edd_get_cart_fees(), 'subtotal' => edd_get_cart_subtotal(), 'discount' => edd_get_cart_discounted_amount(), 'tax' => edd_get_cart_tax(), 'price' => edd_get_cart_total(), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s'), 'user_info' => $user_info, 'post_data' => $_POST, 'cart_details' => edd_get_cart_content_details(), 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
    // Add the user data for hooks
    $valid_data['user'] = $user;
    // Allow themes and plugins to hook before the gateway
    do_action('edd_checkout_before_gateway', $_POST, $user_info, $valid_data);
    // Allow the purchase data to be modified before it is sent to the gateway
    $purchase_data = apply_filters('edd_purchase_data_before_gateway', $purchase_data, $valid_data);
    // If the total amount in the cart is 0, send to the manaul gateway. This emulates a free download purchase
    if (!$purchase_data['price']) {
        // Revert to manual
        $valid_data['gateway'] = 'manual';
    }
    // Used for showing download links to non logged-in users after purchase, and for other plugins needing purchase data.
    edd_set_purchase_session($purchase_data);
    // Send info to the gateway for payment processing
    edd_send_to_gateway($valid_data['gateway'], $purchase_data);
    edd_die();
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:56,代码来源:process-purchase.php

示例7: edd_fd_process_payment

function edd_fd_process_payment($purchase_data)
{
    global $edd_options;
    // setup gateway appropriately for test mode
    if (edd_is_test_mode()) {
        $endpoint = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v11/wsdl';
    } else {
        $endpoint = 'https://api.globalgatewaye4.firstdata.com/transaction/v11/wsdl';
    }
    // check the posted cc deails
    $cc = edd_fd_check_cc_details($purchase_data);
    // fcheck for errors before we continue to processing
    if (!edd_get_errors()) {
        $purchase_summary = edd_get_purchase_summary($purchase_data);
        $payment = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
        // record the pending payment
        $payment = edd_insert_payment($payment);
        $address = esc_textarea($_POST['card_address'] . ' ' . $_POST['card_address_2'] . '|' . $_POST['card_zip'] . '|' . $_POST['card_city'] . '|' . $_POST['card_state'] . '|' . $_POST['billing_country']);
        $firstdata['Transaction'] = array('ExactID' => $edd_options['firstdata_gateway_id'], 'Password' => $edd_options['firstdata_gateway_password'], 'Transaction_Type' => $edd_options['firstdata_transaction_type'], 'DollarAmount' => $purchase_data['price'], 'Card_Number' => $cc['card_number'], 'Expiry_Date' => $cc['card_exp_month'] . $cc['card_exp_year'], 'CardHoldersName' => $cc['card_name'], 'VerificationStr1' => $address, 'VerificationStr2' => $cc['card_cvc'], 'CVD_Presence_Ind' => 1, 'Reference_No' => $payment, 'ZipCode' => $cc['card_zip'], 'Customer_Ref' => $purchase_data['user_info']['id'], 'Client_IP' => $_SERVER['REMOTE_ADDR'], 'Client_Email' => $purchase_data['user_email'], 'Currency' => $edd_options['currency'], 'Ecommerce_Flag' => is_ssl() ? 8 : 7);
        try {
            $api = @new SoapClient($endpoint);
            $result = $api->__soapCall('SendAndCommit', $firstdata);
        } catch (Exception $e) {
            edd_set_error('firstdata_api_error', sprintf(__('FirstData System Error: %s', 'edd_firstdata'), $e->getMessage()));
            edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
            $fail = true;
        }
        if (isset($result) && $result->Transaction_Approved) {
            edd_update_payment_status($payment, 'complete');
            edd_send_to_success_page();
        } elseif ($result->Transaction_Error) {
            edd_set_error('firstdata_decline', sprintf(__('Transaction Declined: %s', 'edd_firstdata'), $result->EXact_Message));
            edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
            $fail = true;
        }
    } else {
        $fail = true;
    }
}
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:39,代码来源:edd-gateway-firstdata.php

示例8: process_purchase

 /**
  * Process the purchase and create the charge in Amazon
  *
  * @access public
  * @since  2.4
  * @param  $purchase_data array Cart details
  * @return void
  */
 public function process_purchase($purchase_data)
 {
     if (empty($purchase_data['post_data']['edd_amazon_reference_id'])) {
         edd_set_error('missing_reference_id', __('Missing Reference ID, please try again', 'edd'));
     }
     $errors = edd_get_errors();
     if ($errors) {
         edd_send_back_to_checkout('?payment-mode=amazon');
     }
     $args = apply_filters('edd_amazon_charge_args', array('merchant_id' => edd_get_option('amazon_seller_id', ''), 'amazon_reference_id' => $purchase_data['post_data']['edd_amazon_reference_id'], 'authorization_reference_id' => $purchase_data['purchase_key'], 'charge_amount' => $purchase_data['price'], 'currency_code' => edd_get_currency(), 'charge_note' => html_entity_decode(edd_get_purchase_summary($purchase_data, false)), 'charge_order_id' => $purchase_data['purchase_key'], 'store_name' => remove_accents(wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)), 'transaction_timeout' => 0), $purchase_data);
     $args['platform_id'] = 'A3JST9YM1SX7LB';
     $charge = $this->client->charge($args);
     if (200 == $charge->response['Status']) {
         $charge = new ResponseParser($charge->response);
         $charge = $charge->toArray();
         $status = $charge['AuthorizeResult']['AuthorizationDetails']['AuthorizationStatus']['State'];
         if ('Declined' === $status) {
             $reason = $charge['AuthorizeResult']['AuthorizationDetails']['AuthorizationStatus']['ReasonCode'];
             edd_set_error('payment_declined', sprintf(__('Your payment could not be authorized, please try a different payment method. Reason: %s', 'edd'), $reason));
             edd_send_back_to_checkout('?payment-mode=amazon&amazon_reference_id=' . $purchase_data['post_data']['edd_amazon_reference_id']);
         }
         // Setup payment data to be recorded
         $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => $this->gateway_id, 'status' => 'pending');
         $payment_id = edd_insert_payment($payment_data);
         $authorization_id = $charge['AuthorizeResult']['AuthorizationDetails']['AmazonAuthorizationId'];
         $capture_id = str_replace('-A', '-C', $authorization_id);
         $reference_id = sanitize_text_field($_POST['edd_amazon_reference_id']);
         // Confirm the capture was completed
         $capture = $this->client->getCaptureDetails(array('merchant_id' => edd_get_option('amazon_seller_id', ''), 'amazon_capture_id' => $capture_id));
         $capture = new ResponseParser($capture->response);
         $capture = $capture->toArray();
         // Check capture status
         edd_update_payment_meta($payment_id, '_edd_amazon_authorization_id', $authorization_id);
         edd_update_payment_meta($payment_id, '_edd_amazon_capture_id', $capture_id);
         edd_set_payment_transaction_id($payment_id, $reference_id);
         edd_update_payment_status($payment_id, 'publish');
         // Empty the shopping cart
         edd_empty_cart();
         edd_send_to_success_page();
     } else {
         // Set an error
         edd_set_error('amazon_error', sprintf(__('There was an issue processing your payment. Amazon error: %s', 'edd'), print_r($charge, true)));
         edd_send_back_to_checkout('?payment-mode=amazon&amazon_reference_id=' . $purchase_data['post_data']['edd_amazon_reference_id']);
     }
 }
开发者ID:EngageWP,项目名称:Easy-Digital-Downloads,代码行数:53,代码来源:amazon-payments.php

示例9: edd_ajax_apply_discount

/**
 * Validates the supplied discount sent via AJAX.
 *
 * @since 1.0
 * @return void
 */
function edd_ajax_apply_discount()
{
    if (isset($_POST['code'])) {
        $discount_code = sanitize_text_field($_POST['code']);
        $return = array('msg' => '', 'code' => $discount_code);
        $user = '';
        if (is_user_logged_in()) {
            $user = get_current_user_id();
        } else {
            parse_str($_POST['form'], $form);
            if (!empty($form['edd_email'])) {
                $user = urldecode($form['edd_email']);
            }
        }
        if (edd_is_discount_valid($discount_code, $user)) {
            $discount = edd_get_discount_by_code($discount_code);
            $amount = edd_format_discount_rate(edd_get_discount_type($discount->ID), edd_get_discount_amount($discount->ID));
            $discounts = edd_set_cart_discount($discount_code);
            $total = edd_get_cart_total($discounts);
            $return = array('msg' => 'valid', 'amount' => $amount, 'total_plain' => $total, 'total' => html_entity_decode(edd_currency_filter(edd_format_amount($total)), ENT_COMPAT, 'UTF-8'), 'code' => $discount_code, 'html' => edd_get_cart_discounts_html($discounts));
        } else {
            $errors = edd_get_errors();
            $return['msg'] = $errors['edd-discount-error'];
            edd_unset_error('edd-discount-error');
        }
        // Allow for custom discount code handling
        $return = apply_filters('edd_ajax_discount_response', $return);
        echo json_encode($return);
    }
    edd_die();
}
开发者ID:upsellpl,项目名称:Easy-Digital-Downloads,代码行数:37,代码来源:ajax-functions.php

示例10: edd_unset_error

/**
 * Removes (unsets) a stored error
 *
 * @since 1.3.4
 * @uses EDD_Session::set()
 * @param int $error_id ID of the error being set
 * @return string
 */
function edd_unset_error($error_id)
{
    $errors = edd_get_errors();
    if ($errors) {
        unset($errors[$error_id]);
        EDD()->session->set('edd_errors', $errors);
    }
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:16,代码来源:error-tracking.php

示例11: edd_register_and_login_new_user

/**
 * Register And Login New User
 *
 * @param array   $user_data
 *
 * @access  private
 * @since  1.0.8.1
 * @return  integer
 */
function edd_register_and_login_new_user($user_data = array())
{
    // Verify the array
    if (empty($user_data)) {
        return -1;
    }
    if (edd_get_errors()) {
        return -1;
    }
    $user_args = apply_filters('edd_insert_user_args', array('user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', 'user_registered' => date('Y-m-d H:i:s'), 'role' => get_option('default_role')), $user_data);
    // Insert new user
    $user_id = wp_insert_user($user_args);
    // Validate inserted user
    if (is_wp_error($user_id)) {
        return -1;
    }
    // Allow themes and plugins to filter the user data
    $user_data = apply_filters('edd_insert_user_data', $user_data, $user_args);
    // Allow themes and plugins to hook
    do_action('edd_insert_user', $user_id, $user_data);
    // Login new user
    edd_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
    // Return user id
    return $user_id;
}
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:34,代码来源:process-purchase.php

示例12: edd_process_login_form

/**
 * Process Login Form
 *
 * @access      private
 * @since       1.0
 * @return      void
*/
function edd_process_login_form($data)
{
    if (wp_verify_nonce($data['edd_login_nonce'], 'edd-login-nonce')) {
        $user_data = get_user_by('login', $data['edd_user_login']);
        if ($user_data) {
            $user_ID = $user_data->ID;
            $user_email = $user_data->user_email;
            if (wp_check_password($data['edd_user_pass'], $user_data->user_pass, $user_data->ID)) {
                edd_log_user_in($user_data->ID, $data['edd_user_login'], $data['edd_user_pass']);
            } else {
                edd_set_error('password_incorrect', __('The password you entered is incorrect', 'edd'));
            }
        } else {
            edd_set_error('username_incorrect', __('The username you entered does not exist', 'edd'));
        }
        // check for errors and redirect if none present
        $errors = edd_get_errors();
        if (!$errors) {
            $redirect = apply_filters('edd_login_redirect', $data['edd_redirect'], $user_ID);
            wp_redirect($redirect);
            exit;
        }
    }
}
开发者ID:vheidari,项目名称:Easy-Digital-Downloads,代码行数:31,代码来源:login-register.php

示例13: edd_veritrans_payment

function edd_veritrans_payment($purchase_data)
{
    global $edd_options;
    require_once plugin_dir_path(__FILE__) . '/lib/Veritrans.php';
    /**********************************
     * set transaction mode
     **********************************/
    if (edd_is_test_mode()) {
        // set test credentials here
        Veritrans_Config::$isProduction = false;
        Veritrans_Config::$serverKey = $edd_options['vt_sandbox_api_key'];
    } else {
        // set live credentials here
        Veritrans_Config::$isProduction = true;
        Veritrans_Config::$serverKey = $edd_options['vt_production_api_key'];
    }
    // check for any stored errors
    $errors = edd_get_errors();
    if (!$errors) {
        $purchase_summary = edd_get_purchase_summary($purchase_data);
        // error_log('purchase data: '.print_r($purchase_data,true)); //debugan
        // error_log('purchase summary: '.print_r($purchase_summary,true)); //debugan
        // error_log('plugin_dir_path : '.plugin_dir_path(__FILE__)); //debugan
        /**********************************
         * setup the payment details
         **********************************/
        // error_log(json_encode($purchase_data, true));
        $payment = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => $edd_options['currency'], 'downloads' => $purchase_data['downloads'], 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
        // record the pending payment
        $payment = edd_insert_payment($payment);
        // create item
        $transaction_details = array();
        foreach ($purchase_data['cart_details'] as $item) {
            $vt_item = array('id' => $item['id'], 'price' => $item['price'], 'quantity' => $item['quantity'], 'name' => $item['name']);
            array_push($transaction_details, $vt_item);
        }
        $vt_params = array('transaction_details' => array('order_id' => $payment, 'gross_amount' => $purchase_data['price']), 'customer_details' => array('first_name' => $purchase_data['user_info']['first_name'], 'last_name' => $purchase_data['user_info']['last_name'], 'email' => $purchase_data['user_info']['email'], 'billing_address' => array('first_name' => $purchase_data['user_info']['first_name'], 'last_name' => $purchase_data['user_info']['last_name'])), 'item_details' => $transaction_details);
        //get enabled payment opts from backend
        $enabled_payments = edd_get_vtpayment_ops();
        if (!empty($enabled_payments)) {
            $vt_params['vtweb']['enabled_payments'] = $enabled_payments;
        }
        // error_log('vt_3ds '.$edd_options['vt_3ds']); //debugan
        // get rid of cart contents
        edd_empty_cart();
        // Redirect to veritrans
        // error_log('vt_params: '.print_r($vt_params,true)); //debugan
        wp_redirect(Veritrans_Vtweb::getRedirectionUrl($vt_params));
        exit;
    } else {
        $fail = true;
        // errors were detected
    }
    if ($fail !== false) {
        // if errors are present, send the user back to the purchase page so they can be corrected
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    }
}
开发者ID:rizdaprasetya,项目名称:vtweb-edd,代码行数:58,代码来源:veritrans-standard.php

示例14: edd_customer_delete

/**
 * Delete a customer
 *
 * @since  2.3
 * @param  array $args The $_POST array being passeed
 * @return int         Wether it was a successful deletion
 */
function edd_customer_delete($args)
{
    $customer_edit_role = apply_filters('edd_edit_customers_role', 'edit_shop_payments');
    if (!is_admin() || !current_user_can($customer_edit_role)) {
        wp_die(__('You do not have permission to delete this customer.', 'edd'));
    }
    if (empty($args)) {
        return;
    }
    $customer_id = (int) $args['customer_id'];
    $confirm = !empty($args['edd-customer-delete-confirm']) ? true : false;
    $remove_data = !empty($args['edd-customer-delete-records']) ? true : false;
    $nonce = $args['_wpnonce'];
    if (!wp_verify_nonce($nonce, 'delete-customer')) {
        wp_die(__('Cheatin\' eh?!', 'edd'));
    }
    if (!$confirm) {
        edd_set_error('customer-delete-no-confirm', __('Please confirm you want to delete this customer', 'edd'));
    }
    if (edd_get_errors()) {
        wp_redirect(admin_url('edit.php?post_type=download&page=edd-customers&view=overview&id=' . $customer_id));
        exit;
    }
    $customer = new EDD_Customer($customer_id);
    do_action('edd_pre_delete_customer', $customer_id, $confirm, $remove_data);
    $success = false;
    if ($customer->id > 0) {
        $payments_array = explode(',', $customer->payment_ids);
        $success = EDD()->customers->delete($customer->id);
        if ($success) {
            if ($remove_data) {
                // Remove all payments, logs, etc
                foreach ($payments_array as $payment_id) {
                    edd_delete_purchase($payment_id, false, true);
                }
            } else {
                // Just set the payments to customer_id of 0
                foreach ($payments_array as $payment_id) {
                    edd_update_payment_meta($payment_id, '_edd_payment_customer_id', 0);
                }
            }
            $redirect = admin_url('edit.php?post_type=download&page=edd-customers&edd-message=customer-deleted');
        } else {
            edd_set_error('edd-customer-delete-failed', __('Error deleting customer', 'edd'));
            $redirect = admin_url('edit.php?post_type=download&page=edd-customers&view=delete&id=' . $customer_id);
        }
    } else {
        edd_set_error('edd-customer-delete-invalid-id', __('Invalid Customer ID', 'edd'));
        $redirect = admin_url('edit.php?post_type=download&page=edd-customers');
    }
    wp_redirect($redirect);
    exit;
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:60,代码来源:customer-actions.php

示例15: atcf_shortcode_submit_process

/**
 * Process shortcode submission.
 *
 * @since Astoundify Crowdfunding 0.1-alpha
 *
 * @param $key The key of the current field.
 * @param $field The array of field arguments.
 * @param $atts The shortcoe attribtues.
 * @param $campaign The current campaign (if editing/previewing).
 * @return void
 */
function atcf_shortcode_submit_process()
{
    global $edd_options, $post;
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    if (empty($_POST['action']) || 'atcf-campaign-submit' !== $_POST['action']) {
        return;
    }
    if (!wp_verify_nonce($_POST['_wpnonce'], 'atcf-campaign-submit')) {
        return;
    }
    $action = esc_attr($_POST['submit']);
    $existing_campaign = isset($_POST['campaign_id']) ? esc_attr($_POST['campaign_id']) : null;
    $fields = atcf_shortcode_submit_fields();
    $status = 'submit' == $action ? 'pending' : 'draft';
    /** If we are submitting, but this is a live campaign, keep published */
    if ($existing_campaign && ('pending' == $status && get_post($existing_campaign)->post_status == 'publish')) {
        $status = 'publish';
    }
    foreach ($fields as $key => $field) {
        $fields[$key]['value'] = isset($_POST[$key]) ? $_POST[$key] : null;
        $fields[$key]['value'] = apply_filters('atcf_shortcode_submit_validate_' . $key, $fields[$key]['value']);
        if (isset($field['required']) && true === $field['required'] && !$fields[$key]['value'] && 'publish' != $status) {
            edd_set_error('required-' . $key, sprintf(__('The <strong>%s</strong> field is required.', 'atcf'), $field['label']));
        }
    }
    do_action('atcf_campaign_submit_validate', $fields, $_POST);
    if (edd_get_errors()) {
        return;
    }
    /** Register a new user, or get the current user */
    $user = get_user_by('email', $fields['contact_email']['value']);
    if (!$user) {
        $user_id = atcf_register_user(array('user_login' => $fields['contact_email']['value'], 'user_email' => $fields['contact_email']['value'], 'display_name' => isset($fields['name']['value']) ? $fields['name']['value'] : $fields['contact_email']['value']));
    } else {
        $user_id = $user->ID;
    }
    /**
     * Create or update a campaign
     */
    $args = apply_filters('atcf_campaign_submit_data', array('post_type' => 'download', 'post_status' => $status, 'post_content' => $fields['description']['value'], 'post_author' => $user_id), $_POST);
    if ($fields['title']['value']) {
        $args['post_title'] = $fields['title']['value'];
    }
    if ($fields['excerpt']['value']) {
        $args['post_excerpt'] = $fields['excerpt']['value'];
    }
    if (!$existing_campaign) {
        $campaign = wp_insert_post($args, true);
    } else {
        $args['ID'] = $existing_campaign;
        $campaign = wp_update_post($args);
    }
    do_action('atcf_submit_process_after', $campaign, $_POST, $status, $fields);
    if ('publish' == $status) {
        wp_safe_redirect(add_query_arg('updated', 'true', get_permalink($campaign)));
        exit;
    } elseif ('submit' == $action) {
        $url = isset($edd_options['submit_success_page']) ? get_permalink($edd_options['submit_success_page']) : home_url();
        $redirect = apply_filters('atcf_submit_campaign_success_redirect', $url);
        wp_safe_redirect(add_query_arg(array('success' => true, 'campaign' => $campaign), $redirect));
        exit;
    } else {
        wp_safe_redirect(add_query_arg('preview', 'true', get_permalink($campaign)));
        exit;
    }
}
开发者ID:ajeremias,项目名称:fundify-child,代码行数:79,代码来源:shortcode-submit.php


注:本文中的edd_get_errors函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。