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


PHP edd_get_purchase_id_by_key函数代码示例

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


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

示例1: check_ip

 /**
  * Check the IP address during file download and display an error if it doesn't match the purchase records
  *
  * @access      public
  * @since       1.0
  * @return      void
  */
 public function check_ip($download_id = 0, $email = 0)
 {
     $payment_key = isset($_GET['download_key']) ? urldecode($_GET['download_key']) : false;
     if (empty($payment_key)) {
         return;
     }
     $payment_id = edd_get_purchase_id_by_key($payment_key);
     if (empty($payment_id)) {
         return;
     }
     $payment_ip = get_post_meta($payment_id, '_edd_payment_user_ip', true);
     if ($payment_ip !== edd_get_ip()) {
         wp_die(__('You do not have permission to download this file because your IP address doesn\'t match our records.', 'edd-iplock'), __('Error', 'edd-iplock'));
     }
 }
开发者ID:Rexix,项目名称:edd-lock-downloads-to-ip,代码行数:22,代码来源:edd-lock-downloads-to-ip.php

示例2: edd_receipt_shortcode

/**
 * Receipt Shortcode
 *
 * Shows an order receipt.
 *
 * @since 1.4
 * @param array $atts Shortcode attributes
 * @param string $content
 * @return string
 */
function edd_receipt_shortcode($atts, $content = null)
{
    global $edd_receipt_args;
    $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'edd'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => true, 'payment_method' => true, 'payment_id' => true), $atts);
    $session = edd_get_purchase_session();
    if (isset($_GET['purchase_key'])) {
        $purchase_key = urldecode($_GET['purchase_key']);
    } else {
        if ($session) {
            $purchase_key = $session['purchase_key'];
        }
    }
    // No key found
    if (!isset($purchase_key)) {
        return $edd_receipt_args['error'];
    }
    $edd_receipt_args['id'] = edd_get_purchase_id_by_key($purchase_key);
    $user = edd_get_payment_meta_user_info($edd_receipt_args['id']);
    // Not the proper user
    if (is_user_logged_in() && $user['id'] != get_current_user_id()) {
        return $edd_receipt_args['error'];
    }
    ob_start();
    edd_get_template_part('shortcode', 'receipt');
    $display = ob_get_clean();
    return $display;
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:37,代码来源:shortcodes.php

示例3: prevent_expired_downloads

 /**
  * Prevent file downloads on expired license keys
  *
  * @access      public
  * @since       2.3
  */
 public function prevent_expired_downloads($download_id = 0, $email = '')
 {
     $payment_id = edd_get_purchase_id_by_key($_GET['download_key']);
     $license = self::get_license_by_purchase($payment_id, $download_id);
     if (!$license) {
         return;
     }
     if ('expired' == self::get_license_status($license->ID)) {
         wp_die(__('Your license key for this purchase is expired. Renew your license key and you will be allowed to download your files again.', 'edd_sl'), __('Expired License', 'edd_sl'), array('response' => 401));
     } elseif ('publish' != $license->post_status) {
         wp_die(__('Your license key for this purchase has been revoked.', 'edd_sl'), __('Expired License', 'edd_sl'), array('response' => 401));
     }
 }
开发者ID:SelaInc,项目名称:eassignment,代码行数:19,代码来源:edd-software-licenses.php

示例4: edd_paypal_success_page_content

/**
 * Shows "Purchase Processing" message for PayPal payments are still pending on site return
 *
 * This helps address the Race Condition, as detailed in issue #1839
 *
 * @since 1.9
 * @return string
 */
function edd_paypal_success_page_content($content)
{
    if (!isset($_GET['payment-id']) && !edd_get_purchase_session()) {
        return $content;
    }
    $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false;
    if (!$payment_id) {
        $session = edd_get_purchase_session();
        $payment_id = edd_get_purchase_id_by_key($session['purchase_key']);
    }
    $payment = get_post($payment_id);
    if ($payment && 'pending' == $payment->post_status) {
        // Payment is still pending so show processing indicator to fix the Race Condition, issue #
        ob_start();
        edd_get_template_part('payment', 'processing');
        $content = ob_get_clean();
    }
    return $content;
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:27,代码来源:paypal-standard.php

示例5: edd_receipt_shortcode

/**
 * Receipt Shortcode
 *
 * Shows an order receipt.
 *
 * @since 1.4
 * @param array $atts Shortcode attributes
 * @param string $content
 * @return string
 */
function edd_receipt_shortcode($atts, $content = null)
{
    global $edd_receipt_args;
    $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'easy-digital-downloads'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'edd_receipt');
    $session = edd_get_purchase_session();
    if (isset($_GET['payment_key'])) {
        $payment_key = urldecode($_GET['payment_key']);
    } elseif ($edd_receipt_args['payment_key']) {
        $payment_key = $edd_receipt_args['payment_key'];
    } else {
        if ($session) {
            $payment_key = $session['purchase_key'];
        }
    }
    // No key found
    if (!isset($payment_key)) {
        return '<p class="edd-alert edd-alert-error">' . $edd_receipt_args['error'] . '</p>';
    }
    $payment_id = edd_get_purchase_id_by_key($payment_key);
    $user_can_view = edd_can_view_receipt($payment_key);
    // Key was provided, but user is logged out. Offer them the ability to login and view the receipt
    if (!$user_can_view && !empty($payment_key) && !is_user_logged_in() && !edd_is_guest_payment($payment_id)) {
        global $edd_login_redirect;
        $edd_login_redirect = edd_get_current_page_url();
        ob_start();
        echo '<p class="edd-alert edd-alert-warn">' . __('You must be logged in to view this payment receipt.', 'easy-digital-downloads') . '</p>';
        edd_get_template_part('shortcode', 'login');
        $login_form = ob_get_clean();
        return $login_form;
    }
    /*
     * Check if the user has permission to view the receipt
     *
     * If user is logged in, user ID is compared to user ID of ID stored in payment meta
     *
     * Or if user is logged out and purchase was made as a guest, the purchase session is checked for
     *
     * Or if user is logged in and the user can view sensitive shop data
     *
     */
    if (!apply_filters('edd_user_can_view_receipt', $user_can_view, $edd_receipt_args)) {
        return '<p class="edd-alert edd-alert-error">' . $edd_receipt_args['error'] . '</p>';
    }
    ob_start();
    edd_get_template_part('shortcode', 'receipt');
    $display = ob_get_clean();
    return $display;
}
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:58,代码来源:shortcodes.php

示例6: process_ipn

 /**
  * Process IPN messages from Amazon
  *
  * @access public
  * @since  2.4
  * @return void
  */
 public function process_ipn()
 {
     if (!isset($_GET['edd-listener']) || $_GET['edd-listener'] !== 'amazon') {
         return;
     }
     if (isset($_GET['state'])) {
         return;
     }
     // Get the IPN headers and Message body
     $headers = getallheaders();
     $body = file_get_contents('php://input');
     $this->doing_ipn = true;
     try {
         $ipn = new IpnHandler($headers, $body);
         $data = $ipn->toArray();
         $seller_id = $data['SellerId'];
         if ($seller_id != edd_get_option('amazon_seller_id', '')) {
             wp_die(__('Invalid Amazon seller ID', 'edd'), __('IPN Error', 'edd'), array('response' => 401));
         }
         switch ($data['NotificationType']) {
             case 'OrderReferenceNotification':
                 break;
             case 'PaymentAuthorize':
                 break;
             case 'PaymentCapture':
                 $key = $data['CaptureDetails']['CaptureReferenceId'];
                 $status = $data['CaptureDetails']['CaptureStatus']['State'];
                 if ('Declined' === $status) {
                     $payment_id = edd_get_purchase_id_by_key($key);
                     edd_update_payment_status($payment_id, 'failed');
                     edd_insert_payment_note($payment_id, __('Capture declined in Amazon', 'edd'));
                 }
                 break;
             case 'PaymentRefund':
                 $trans_id = substr($data['RefundDetails']['AmazonRefundId'], 0, 19);
                 $status = $data['RefundDetails']['RefundStatus']['State'];
                 if ('Completed' === $status) {
                     $payment_id = edd_get_purchase_id_by_transaction_id($trans_id);
                     edd_update_payment_status($payment_id, 'refunded');
                     edd_insert_payment_note($payment_id, sprintf(__('Refund completed in Amazon. Refund ID: %s', 'edd'), $data['RefundDetails']['AmazonRefundId']));
                 }
                 break;
         }
     } catch (Exception $e) {
         wp_die($e->getErrorMessage(), __('IPN Error', 'edd'), array('response' => 401));
     }
 }
开发者ID:EngageWP,项目名称:Easy-Digital-Downloads,代码行数:54,代码来源:amazon-payments.php

示例7: edd_can_view_receipt

/**
 * Determines the receipt visibility status
 *
 * @return bool Whether the receipt is visible or not.
 */
function edd_can_view_receipt($payment_key = '')
{
    $return = false;
    if (empty($payment_key)) {
        return $return;
    }
    global $edd_receipt_args;
    $edd_receipt_args['id'] = edd_get_purchase_id_by_key($payment_key);
    $user_id = (int) edd_get_payment_user_id($edd_receipt_args['id']);
    $payment_meta = edd_get_payment_meta($edd_receipt_args['id']);
    if (is_user_logged_in()) {
        if ($user_id === (int) get_current_user_id()) {
            $return = true;
        } elseif (wp_get_current_user()->user_email === edd_get_payment_user_email($edd_receipt_args['id'])) {
            $return = true;
        } elseif (current_user_can('view_shop_sensitive_data')) {
            $return = true;
        }
    }
    $session = edd_get_purchase_session();
    if (!empty($session) && !is_user_logged_in()) {
        if ($session['purchase_key'] === $payment_meta['key']) {
            $return = true;
        }
    }
    return (bool) apply_filters('edd_can_view_receipt', $return, $payment_key);
}
开发者ID:pderksen,项目名称:Easy-Digital-Downloads,代码行数:32,代码来源:misc-functions.php

示例8: edd_receipt_shortcode

/**
 * Receipt Shortcode
 *
 * Shows an order receipt.
 *
 * @since 1.4
 * @param array $atts Shortcode attributes
 * @param string $content
 * @return string
 */
function edd_receipt_shortcode($atts, $content = null)
{
    global $edd_receipt_args;
    $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'edd'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'edd_receipt');
    $session = edd_get_purchase_session();
    if (isset($_GET['payment_key'])) {
        $payment_key = urldecode($_GET['payment_key']);
    } elseif ($edd_receipt_args['payment_key']) {
        $payment_key = $edd_receipt_args['payment_key'];
    } else {
        if ($session) {
            $payment_key = $session['purchase_key'];
        }
    }
    // No key found
    if (!isset($payment_key)) {
        return $edd_receipt_args['error'];
    }
    $edd_receipt_args['id'] = edd_get_purchase_id_by_key($payment_key);
    $customer_id = edd_get_payment_user_id($edd_receipt_args['id']);
    /*
     * Check if the user has permission to view the receipt
     *
     * If user is logged in, user ID is compared to user ID of ID stored in payment meta
     *
     * Or if user is logged out and purchase was made as a guest, the purchase session is checked for
     *
     * Or if user is logged in and the user can view sensitive shop data
     *
     */
    $user_can_view = is_user_logged_in() && $customer_id == get_current_user_id() || ($customer_id == 0 || $customer_id == '-1') && !is_user_logged_in() && edd_get_purchase_session() || current_user_can('view_shop_sensitive_data');
    if (!apply_filters('edd_user_can_view_receipt', $user_can_view, $edd_receipt_args)) {
        return $edd_receipt_args['error'];
    }
    ob_start();
    edd_get_template_part('shortcode', 'receipt');
    $display = ob_get_clean();
    return $display;
}
开发者ID:Hanistips,项目名称:Easy-Digital-Downloads,代码行数:49,代码来源:shortcodes.php

示例9: affwp_edd_optimizely_revenue_tracking

function affwp_edd_optimizely_revenue_tracking()
{
    $session = edd_get_purchase_session();
    if (!$session || !edd_is_success_page()) {
        return;
    }
    $payment_id = edd_get_purchase_id_by_key($session['purchase_key']);
    ?>
<script>
	var price = <?php 
    echo edd_get_payment_amount($payment_id);
    ?>
;
	window.optimizely = window.optimizely || [];
	window.optimizely.push(['trackEvent', 'purchase_complete', {'revenue': price * 100}]);
</script>
<?php 
}
开发者ID:companyjuice,项目名称:theme,代码行数:18,代码来源:edd.php

示例10: affwp_edd_purchase_get_first_name

/**
 * Get's the customer's first name from purchase session
 * @return [type] [description]
 */
function affwp_edd_purchase_get_first_name()
{
    // get purchase session
    $purchase_session = edd_get_purchase_session();
    // get the key
    $purchase_key = $purchase_session['purchase_key'];
    // get the payment ID from the purchase key
    $payment_id = edd_get_purchase_id_by_key($purchase_key);
    $user_info = edd_get_payment_meta_user_info($payment_id);
    $first_name = $user_info['first_name'];
    if ($first_name) {
        return $first_name;
    }
    return null;
}
开发者ID:apsolut,项目名称:theme,代码行数:19,代码来源:edd.php

示例11: edd_downloads_receipt_shortcode

function edd_downloads_receipt_shortcode($atts, $content = null)
{
    global $edd_receipt_args;
    $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'edd_downloads'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'edd_receipt');
    $session = edd_get_purchase_session();
    if (isset($session['downloads']) && is_array($session['downloads'])) {
        foreach ($session['downloads'] as $download) {
            if (isset($download['upgrade']) && $download['upgrade']['upgrade_license'] > 0) {
                $payment_id_lic = get_post_meta(absint($download['upgrade']['upgrade_license']), '_edd_sl_payment_id', true);
                $payment_key = edd_get_payment_key($payment_id_lic);
                break;
            }
        }
    }
    if (!isset($payment_key)) {
        if (isset($_GET['payment_key'])) {
            $payment_key = urldecode($_GET['payment_key']);
        } elseif ($edd_receipt_args['payment_key']) {
            $payment_key = $edd_receipt_args['payment_key'];
        } else {
            if ($session) {
                $payment_key = $session['purchase_key'];
            }
        }
    }
    // No key found
    if (!isset($payment_key)) {
        return $edd_receipt_args['error'];
    }
    $edd_receipt_args['id'] = edd_get_purchase_id_by_key($payment_key);
    $customer_id = edd_get_payment_user_id($edd_receipt_args['id']);
    /*
     * Check if the user has permission to view the receipt
     *
     * If user is logged in, user ID is compared to user ID of ID stored in payment meta
     *
     * Or if user is logged out and purchase was made as a guest, the purchase session is checked for
     *
     * Or if user is logged in and the user can view sensitive shop data
     *
     */
    $user_can_view = is_user_logged_in() && $customer_id == get_current_user_id() || ($customer_id == 0 || $customer_id == '-1') && !is_user_logged_in() && edd_get_purchase_session() || current_user_can('view_shop_sensitive_data');
    if (!apply_filters('edd_user_can_view_receipt', $user_can_view, $edd_receipt_args)) {
        return $edd_receipt_args['error'];
    }
    require plugin_dir_path(__FILE__) . "template/shortcode-receipt.php";
}
开发者ID:jomsocial,项目名称:eddDownloads,代码行数:47,代码来源:edd_downloads.php

示例12: pp_edd_optimizely_revenue_tracking

function pp_edd_optimizely_revenue_tracking()
{
    if (!function_exists('edd_get_purchase_session')) {
        return;
    }
    $session = edd_get_purchase_session();
    if (!$session) {
        return;
    }
    $payment_id = edd_get_purchase_id_by_key($session['purchase_key']);
    ?>
<script>
	var price = <?php 
    echo edd_get_payment_amount($payment_id);
    ?>
	window.optimizely = window.optimizely || [];
	window.optimizely.push(['trackEvent', 'purchase_complete', {'revenue': price * 100}]);
</script>
<?php 
}
开发者ID:apsolut,项目名称:theme,代码行数:20,代码来源:functions.php


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