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


PHP edd_update_payment_meta函数代码示例

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


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

示例1: edd_set_payment_transaction_id

/**
 * Sets a Transaction ID in post meta for the given Payment ID
 *
 * @since  2.1
 * @param int payment_id Payment ID
 * @param string transaction_id The transaciton ID from the gateway
 */
function edd_set_payment_transaction_id($payment_id = 0, $transaction_id = '')
{
    if (empty($payment_id) || empty($transaction_id)) {
        return false;
    }
    $transaction_id = apply_filters('edd_set_payment_transaction_id', $transaction_id, $payment_id);
    return edd_update_payment_meta($payment_id, '_edd_payment_transaction_id', $transaction_id);
}
开发者ID:ankitpokhrel,项目名称:Easy-Digital-Downloads,代码行数:15,代码来源:functions.php

示例2: 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

示例3: maybe_insert_user

 /**
  * When a payment is inserted, possibly registers a user
  *
  * If this is the first purchase, disables the EDD Core user verification system
  *
  * @since 1.3
  */
 public function maybe_insert_user($payment_id, $payment_data)
 {
     // It's possible that a extension (like recurring) has already auto-inserted a user, let's verify
     if (!is_user_logged_in()) {
         $customer = new EDD_Customer($payment_data['user_info']['email']);
         $payment_ids = explode(',', $customer->payment_ids);
         if (is_array($payment_ids) && !empty($payment_ids)) {
             $payment_ids = array_map('absint', $payment_ids);
             // If the payment inserted is the only payment, we don't need verification
             if (1 === count($payment_ids) && in_array($payment_id, $payment_ids)) {
                 remove_action('user_register', 'edd_connect_existing_customer_to_new_user', 10, 1);
                 remove_action('user_register', 'edd_add_past_purchases_to_new_user', 10, 1);
             }
         }
         $user_id = $this->create_user($payment_data, $payment_id);
     } else {
         $user_id = get_current_user_id();
     }
     // Validate inserted user
     if (is_wp_error($user_id) || empty($user_id)) {
         return;
     }
     $payment_meta = edd_get_payment_meta($payment_id);
     $payment_meta['user_info']['id'] = $user_id;
     edd_update_payment_meta($payment_id, '_edd_payment_user_id', $user_id);
     edd_update_payment_meta($payment_id, '_edd_payment_meta', $payment_meta);
 }
开发者ID:grappler,项目名称:edd-auto-register,代码行数:34,代码来源:edd-auto-register.php

示例4: edd_add_past_purchases_to_new_user

/**
 * Looks up purchases by email that match the registering user
 *
 * This is for users that purchased as a guest and then came
 * back and created an account.
 *
 * @access      public
 * @since       1.6
 * @param       $user_id INT - the new user's ID
 * @return      void
 */
function edd_add_past_purchases_to_new_user($user_id)
{
    $email = get_the_author_meta('user_email', $user_id);
    $payments = edd_get_payments(array('s' => $email));
    if ($payments) {
        foreach ($payments as $payment) {
            if (intval(edd_get_payment_user_id($payment->ID)) > 0) {
                continue;
            }
            // This payment already associated with an account
            $meta = edd_get_payment_meta($payment->ID);
            $meta['user_info'] = maybe_unserialize($meta['user_info']);
            $meta['user_info']['id'] = $user_id;
            $meta['user_info'] = $meta['user_info'];
            // Store the updated user ID in the payment meta
            edd_update_payment_meta($payment->ID, '_edd_payment_meta', $meta);
            edd_update_payment_meta($payment->ID, '_edd_payment_user_id', $user_id);
        }
    }
}
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:31,代码来源:user-functions.php

示例5: edd_update_payment_details


//.........这里部分代码省略.........
    $status = $data['edd-payment-status'];
    $unlimited = isset($data['edd-unlimited-downloads']) ? '1' : '';
    $user_id = intval($data['edd-payment-user-id']);
    $date = sanitize_text_field($data['edd-payment-date']);
    $hour = sanitize_text_field($data['edd-payment-time-hour']);
    $minute = sanitize_text_field($data['edd-payment-time-min']);
    $email = sanitize_text_field($data['edd-payment-user-email']);
    $names = sanitize_text_field($data['edd-payment-user-name']);
    $address = array_map('trim', $data['edd-payment-address'][0]);
    $total = edd_sanitize_amount($_POST['edd-payment-total']);
    $tax = isset($_POST['edd-payment-tax']) ? edd_sanitize_amount($_POST['edd-payment-tax']) : 0;
    // Setup date from input values
    $date = date('Y-m-d', strtotime($date)) . ' ' . $hour . ':' . $minute . ':00';
    // Setup first and last name from input values
    $names = explode(' ', $names);
    $first_name = !empty($names[0]) ? $names[0] : '';
    $last_name = '';
    if (!empty($names[1])) {
        unset($names[0]);
        $last_name = implode(' ', $names);
    }
    // Setup purchased Downloads and price options
    $updated_downloads = isset($_POST['edd-payment-details-downloads']) ? $_POST['edd-payment-details-downloads'] : false;
    if ($updated_downloads && !empty($_POST['edd-payment-downloads-changed'])) {
        $downloads = array();
        $cart_details = array();
        $i = 0;
        foreach ($updated_downloads as $download) {
            if (empty($download['amount'])) {
                $download['amount'] = '0.00';
            }
            $item = array();
            $item['id'] = absint($download['id']);
            $item['quantity'] = absint($download['quantity']) > 0 ? absint($download['quantity']) : 1;
            $price_id = (int) $download['price_id'];
            if ($price_id !== false && edd_has_variable_prices($item['id'])) {
                $item['options'] = array('price_id' => $price_id);
            }
            $downloads[] = $item;
            $cart_item = array();
            $cart_item['item_number'] = $item;
            $item_price = round($download['amount'] / $item['quantity'], edd_currency_decimal_filter());
            $cart_details[$i] = array('name' => get_the_title($download['id']), 'id' => $download['id'], 'item_number' => $item, 'price' => $download['amount'], 'item_price' => $item_price, 'quantity' => $download['quantity'], 'discount' => 0, 'tax' => 0);
            $i++;
        }
        $meta['downloads'] = $downloads;
        $meta['cart_details'] = $cart_details;
    }
    if ($user_id !== $user_info['id'] || $email !== $user_info['email']) {
        $user = get_user_by('id', $user_id);
        if (!empty($user) && strtolower($user->data->user_email) !== strtolower($email)) {
            // protect a purcahse from being assigned to a customer with a user ID and Email that belong to different users
            wp_die('User ID and User Email do not match.');
            exit;
        }
        // Remove the stats and payment from the previous customer
        $previous_customer = EDD()->customers->get_by('email', $user_info['email']);
        EDD()->customers->remove_payment($previous_customer->id, $payment_id);
        // Attribute the payment to the new customer and update the payment post meta
        $new_customer_id = EDD()->customers->get_column_by('id', 'email', $email);
        if (!$new_customer) {
            // No customer exists for the given email so create one
            $new_customer_id = EDD()->customers->add(array('email' => $email, 'name' => $first_name . ' ' . $last_name));
        }
        EDD()->customers->attach_payment($new_customer_id, $payment_id);
        // If purchase was completed and not ever refunded, adjust stats of customers
        if ('revoked' == $status || 'publish' == $status) {
            EDD()->customers->decrement_stats($previous_customer->id, $total);
            EDD()->customers->increment_stats($new_customer_id, $total);
        }
        update_post_meta($payment_id, '_edd_payment_customer_id', $new_customer_id);
    }
    // Set new meta values
    $user_info['id'] = $user_id;
    $user_info['email'] = $email;
    $user_info['first_name'] = $first_name;
    $user_info['last_name'] = $last_name;
    $user_info['address'] = $address;
    $meta['user_info'] = $user_info;
    $meta['tax'] = $tax;
    // Check for payment notes
    if (!empty($data['edd-payment-note'])) {
        $note = wp_kses($data['edd-payment-note'], array());
        edd_insert_payment_note($payment_id, $note);
    }
    do_action('edd_update_edited_purchase', $payment_id);
    // Update main payment record
    wp_update_post(array('ID' => $payment_id, 'post_date' => $date));
    // Set new status
    edd_update_payment_status($payment_id, $status);
    edd_update_payment_meta($payment_id, '_edd_payment_user_id', $user_id);
    edd_update_payment_meta($payment_id, '_edd_payment_user_email', $email);
    edd_update_payment_meta($payment_id, '_edd_payment_meta', $meta);
    edd_update_payment_meta($payment_id, '_edd_payment_total', $total);
    edd_update_payment_meta($payment_id, '_edd_payment_downloads', $total);
    edd_update_payment_meta($payment_id, '_edd_payment_unlimited_downloads', $unlimited);
    do_action('edd_updated_edited_purchase', $payment_id);
    wp_safe_redirect(admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&edd-message=payment-updated&id=' . $payment_id));
    exit;
}
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:101,代码来源:actions.php

示例6: edd_v23_upgrade_payment_taxes

/**
 * Upgrades payment taxes for 2.3
 *
 * @since 2.3
 * @return void
 */
function edd_v23_upgrade_payment_taxes()
{
    global $wpdb;
    if (!current_user_can('manage_shop_settings')) {
        wp_die(__('You do not have permission to do shop upgrades', 'edd'), __('Error', 'edd'), array('response' => 403));
    }
    ignore_user_abort(true);
    if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
        @set_time_limit(0);
    }
    $step = isset($_GET['step']) ? absint($_GET['step']) : 1;
    $number = 50;
    $offset = $step == 1 ? 0 : ($step - 1) * $number;
    if ($step < 2) {
        // Check if we have any payments before moving on
        $sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'edd_payment' LIMIT 1";
        $has_payments = $wpdb->get_col($sql);
        if (empty($has_payments)) {
            // We had no payments, just complete
            update_option('edd_version', preg_replace('/[^0-9.].*/', '', EDD_VERSION));
            edd_set_upgrade_complete('upgrade_payment_taxes');
            delete_option('edd_doing_upgrade');
            wp_redirect(admin_url());
            exit;
        }
    }
    $total = isset($_GET['total']) ? absint($_GET['total']) : false;
    if (empty($total) || $total <= 1) {
        $total_sql = "SELECT COUNT(ID) as total_payments FROM {$wpdb->posts} WHERE post_type = 'edd_payment'";
        $results = $wpdb->get_row($total_sql, 0);
        $total = $results->total_payments;
    }
    $payment_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'edd_payment' ORDER BY post_date DESC LIMIT %d,%d;", $offset, $number));
    if ($payment_ids) {
        foreach ($payment_ids as $payment_id) {
            // Add the new _edd_payment_meta item
            $payment_tax = edd_get_payment_tax($payment_id);
            edd_update_payment_meta($payment_id, '_edd_payment_tax', $payment_tax);
        }
        // Payments found so upgrade them
        $step++;
        $redirect = add_query_arg(array('page' => 'edd-upgrades', 'edd-upgrade' => 'upgrade_payment_taxes', 'step' => $step, 'number' => $number, 'total' => $total), admin_url('index.php'));
        wp_redirect($redirect);
        exit;
    } else {
        // No more payments found, finish up
        update_option('edd_version', preg_replace('/[^0-9.].*/', '', EDD_VERSION));
        edd_set_upgrade_complete('upgrade_payment_taxes');
        delete_option('edd_doing_upgrade');
        wp_redirect(admin_url());
        exit;
    }
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:59,代码来源:upgrade-functions.php

示例7: edd_update_payment_details


//.........这里部分代码省略.........
    }
    do_action('edd_update_edited_purchase', $payment_id);
    // Update main payment record
    $updated = wp_update_post(array('ID' => $payment_id, 'post_date' => $date));
    if (0 === $updated) {
        wp_die(__('Error Updating Payment', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 400));
    }
    $customer_changed = false;
    if (isset($data['edd-new-customer']) && $data['edd-new-customer'] == '1') {
        $email = isset($data['edd-new-customer-email']) ? sanitize_text_field($data['edd-new-customer-email']) : '';
        $names = isset($data['edd-new-customer-name']) ? sanitize_text_field($data['edd-new-customer-name']) : '';
        if (empty($email) || empty($names)) {
            wp_die(__('New Customers require a name and email address', 'easy-digital-downloads'));
        }
        $customer = new EDD_Customer($email);
        if (empty($customer->id)) {
            $customer_data = array('name' => $names, 'email' => $email);
            $user_id = email_exists($email);
            if (false !== $user_id) {
                $customer_data['user_id'] = $user_id;
            }
            if (!$customer->create($customer_data)) {
                // Failed to crete the new customer, assume the previous customer
                $customer_changed = false;
                $customer = new EDD_Customer($curr_customer_id);
                edd_set_error('edd-payment-new-customer-fail', __('Error creating new customer', 'easy-digital-downloads'));
            }
        }
        $new_customer_id = $customer->id;
        $previous_customer = new EDD_Customer($curr_customer_id);
        $customer_changed = true;
    } elseif ($curr_customer_id !== $new_customer_id) {
        $customer = new EDD_Customer($new_customer_id);
        $email = $customer->email;
        $names = $customer->name;
        $previous_customer = new EDD_Customer($curr_customer_id);
        $customer_changed = true;
    } else {
        $customer = new EDD_Customer($curr_customer_id);
        $email = $customer->email;
        $names = $customer->name;
    }
    // Setup first and last name from input values
    $names = explode(' ', $names);
    $first_name = !empty($names[0]) ? $names[0] : '';
    $last_name = '';
    if (!empty($names[1])) {
        unset($names[0]);
        $last_name = implode(' ', $names);
    }
    if ($customer_changed) {
        // Remove the stats and payment from the previous customer and attach it to the new customer
        $previous_customer->remove_payment($payment_id, false);
        $customer->attach_payment($payment_id, false);
        // If purchase was completed and not ever refunded, adjust stats of customers
        if ('revoked' == $status || 'publish' == $status) {
            $previous_customer->decrease_purchase_count();
            $previous_customer->decrease_value($new_total);
            $customer->increase_purchase_count();
            $customer->increase_value($new_total);
        }
        update_post_meta($payment_id, '_edd_payment_customer_id', $customer->id);
    }
    // Set new meta values
    $user_info['id'] = $customer->user_id;
    $user_info['email'] = $customer->email;
    $user_info['first_name'] = $first_name;
    $user_info['last_name'] = $last_name;
    $user_info['address'] = $address;
    $meta['user_info'] = $user_info;
    $meta['tax'] = $tax;
    // Check for payment notes
    if (!empty($data['edd-payment-note'])) {
        $note = wp_kses($data['edd-payment-note'], array());
        edd_insert_payment_note($payment_id, $note);
    }
    // Set new status
    edd_update_payment_status($payment_id, $status);
    edd_update_payment_meta($payment_id, '_edd_payment_user_id', $customer->user_id);
    edd_update_payment_meta($payment_id, '_edd_payment_user_email', $customer->email);
    edd_update_payment_meta($payment_id, '_edd_payment_meta', $meta);
    edd_update_payment_meta($payment_id, '_edd_payment_total', $new_total);
    // Adjust total store earnings if the payment total has been changed
    if ($new_total !== $curr_total && ('publish' == $status || 'revoked' == $status)) {
        if ($new_total > $curr_total) {
            // Increase if our new total is higher
            $difference = $new_total - $curr_total;
            edd_increase_total_earnings($difference);
        } elseif ($curr_total > $new_total) {
            // Decrease if our new total is lower
            $difference = $curr_total - $new_total;
            edd_decrease_total_earnings($difference);
        }
    }
    edd_update_payment_meta($payment_id, '_edd_payment_downloads', $new_total);
    edd_update_payment_meta($payment_id, '_edd_payment_unlimited_downloads', $unlimited);
    do_action('edd_updated_edited_purchase', $payment_id);
    wp_safe_redirect(admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&edd-message=payment-updated&id=' . $payment_id));
    exit;
}
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:101,代码来源:actions.php

示例8: edd_process_paypal_web_accept_and_cart

/**
 * Process web accept (one time) payment IPNs
 *
 * @since 1.3.4
 * @param array   $data IPN Data
 * @return void
 */
function edd_process_paypal_web_accept_and_cart($data, $payment_id)
{
    if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
        return;
    }
    if (empty($payment_id)) {
        return;
    }
    // Collect payment details
    $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
    $paypal_amount = $data['mc_gross'];
    $payment_status = strtolower($data['payment_status']);
    $currency_code = strtolower($data['mc_currency']);
    $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
    $payment_meta = edd_get_payment_meta($payment_id);
    if (edd_get_payment_gateway($payment_id) != 'paypal') {
        return;
        // this isn't a PayPal standard IPN
    }
    // Verify payment recipient
    if (strcasecmp($business_email, trim(edd_get_option('paypal_email', false))) != 0) {
        edd_record_gateway_error(__('IPN Error', 'edd'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'edd'), json_encode($data)), $payment_id);
        edd_update_payment_status($payment_id, 'failed');
        edd_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'edd'));
        return;
    }
    // Verify payment currency
    if ($currency_code != strtolower($payment_meta['currency'])) {
        edd_record_gateway_error(__('IPN Error', 'edd'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'edd'), json_encode($data)), $payment_id);
        edd_update_payment_status($payment_id, 'failed');
        edd_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'edd'));
        return;
    }
    if (!edd_get_payment_user_email($payment_id)) {
        // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
        // No email associated with purchase, so store from PayPal
        edd_update_payment_meta($payment_id, '_edd_payment_user_email', $data['payer_email']);
        // Setup and store the customers's details
        $address = array();
        $address['line1'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
        $address['city'] = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
        $address['state'] = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
        $address['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
        $address['zip'] = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
        $user_info = array('id' => '-1', 'email' => sanitize_text_field($data['payer_email']), 'first_name' => sanitize_text_field($data['first_name']), 'last_name' => sanitize_text_field($data['last_name']), 'discount' => '', 'address' => $address);
        $payment_meta['user_info'] = $user_info;
        edd_update_payment_meta($payment_id, '_edd_payment_meta', $payment_meta);
    }
    if ($payment_status == 'refunded' || $payment_status == 'reversed') {
        // Process a refund
        edd_process_paypal_refund($data, $payment_id);
    } else {
        if (get_post_status($payment_id) == 'publish') {
            return;
            // Only complete payments once
        }
        // Retrieve the total purchase amount (before PayPal)
        $payment_amount = edd_get_payment_amount($payment_id);
        if (number_format((double) $paypal_amount, 2) < number_format((double) $payment_amount, 2)) {
            // The prices don't match
            edd_record_gateway_error(__('IPN Error', 'edd'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'edd'), json_encode($data)), $payment_id);
            edd_update_payment_status($payment_id, 'failed');
            edd_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'edd'));
            return;
        }
        if ($purchase_key != edd_get_payment_key($payment_id)) {
            // Purchase keys don't match
            edd_record_gateway_error(__('IPN Error', 'edd'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'edd'), json_encode($data)), $payment_id);
            edd_update_payment_status($payment_id, 'failed');
            edd_insert_payment_note($payment_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'edd'));
            return;
        }
        if ('completed' == $payment_status || edd_is_test_mode()) {
            edd_insert_payment_note($payment_id, sprintf(__('PayPal Transaction ID: %s', 'edd'), $data['txn_id']));
            edd_set_payment_transaction_id($payment_id, $data['txn_id']);
            edd_update_payment_status($payment_id, 'publish');
        } else {
            if ('pending' == $payment_status && isset($data['pending_reason'])) {
                // Look for possible pending reasons, such as an echeck
                $note = '';
                switch (strtolower($data['pending_reason'])) {
                    case 'echeck':
                        $note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'edd');
                        break;
                    case 'address':
                        $note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'edd');
                        break;
                    case 'intl':
                        $note = __('Payment must be accepted manually through PayPal due to international account regulations', 'edd');
                        break;
                    case 'multi-currency':
                        $note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'edd');
                        break;
//.........这里部分代码省略.........
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:101,代码来源:paypal-standard.php

示例9: edd_process_paypal_web_accept_and_cart

/**
 * Process web accept (one time) payment IPNs
 *
 * @since 1.3.4
 * @global $edd_options Array of all the EDD Options
 * @param array   $data IPN Data
 * @return void
 */
function edd_process_paypal_web_accept_and_cart($data)
{
    global $edd_options;
    if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
        return;
    }
    // Collect payment details
    $payment_id = $data['custom'];
    $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
    $paypal_amount = $data['mc_gross'];
    $payment_status = strtolower($data['payment_status']);
    $currency_code = strtolower($data['mc_currency']);
    $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
    if (edd_get_payment_gateway($payment_id) != 'paypal') {
        return;
        // this isn't a PayPal standard IPN
    }
    // Verify payment recipient
    if (strcasecmp($business_email, trim($edd_options['paypal_email'])) != 0) {
        edd_record_gateway_error(__('IPN Error', 'edd'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'edd'), json_encode($data)), $payment_id);
        edd_update_payment_status($payment_id, 'failed');
        edd_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'edd'));
        return;
    }
    // Verify payment currency
    if ($currency_code != strtolower(edd_get_currency())) {
        edd_record_gateway_error(__('IPN Error', 'edd'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'edd'), json_encode($data)), $payment_id);
        edd_update_payment_status($payment_id, 'failed');
        edd_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'edd'));
        return;
    }
    if (!edd_get_payment_user_email($payment_id)) {
        // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
        // No email associated with purchase, so store from PayPal
        edd_update_payment_meta($payment_id, '_edd_payment_user_email', $data['payer_email']);
        // Setup and store the customers's details
        $address = array();
        $address['line1'] = !empty($data['address_street']) ? $data['address_street'] : false;
        $address['city'] = !empty($data['address_city']) ? $data['address_city'] : false;
        $address['state'] = !empty($data['address_state']) ? $data['address_state'] : false;
        $address['country'] = !empty($data['address_country_code']) ? $data['address_country_code'] : false;
        $address['zip'] = !empty($data['address_zip']) ? $data['address_zip'] : false;
        $user_info = array('id' => '-1', 'email' => $data['payer_email'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'discount' => '', 'address' => $address);
        $payment_meta = get_post_meta($payment_id, '_edd_payment_meta', true);
        $payment_meta['user_info'] = $user_info;
        edd_update_payment_meta($payment_id, '_edd_payment_meta', $payment_meta);
    }
    if ($payment_status == 'refunded' || $payment_status == 'reversed') {
        // Process a refund
        edd_process_paypal_refund($data);
    } else {
        if (get_post_status($payment_id) == 'publish') {
            return;
            // Only complete payments once
        }
        // Retrieve the total purchase amount (before PayPal)
        $payment_amount = edd_get_payment_amount($payment_id);
        if (number_format((double) $paypal_amount, 2) < number_format((double) $payment_amount, 2)) {
            // The prices don't match
            edd_record_gateway_error(__('IPN Error', 'edd'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'edd'), json_encode($data)), $payment_id);
            edd_update_payment_status($payment_id, 'failed');
            edd_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'edd'));
            return;
        }
        if ($purchase_key != edd_get_payment_key($payment_id)) {
            // Purchase keys don't match
            edd_record_gateway_error(__('IPN Error', 'edd'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'edd'), json_encode($data)), $payment_id);
            edd_update_payment_status($payment_id, 'failed');
            edd_insert_payment_note($payment_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'edd'));
            return;
        }
        if ($payment_status == 'completed' || edd_is_test_mode()) {
            edd_insert_payment_note($payment_id, sprintf(__('PayPal Transaction ID: %s', 'edd'), $data['txn_id']));
            edd_set_payment_transaction_id($payment_id, $data['txn_id']);
            edd_update_payment_status($payment_id, 'publish');
        }
    }
}
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:86,代码来源:paypal-standard.php

示例10: edd_add_past_purchases_to_new_user

/**
 * Looks up purchases by email that match the registering user
 *
 * This is for users that purchased as a guest and then came
 * back and created an account.
 *
 * @access      public
 * @since       1.6
 * @param       $user_id INT - the new user's ID
 * @return      void
 */
function edd_add_past_purchases_to_new_user($user_id)
{
    $email = get_the_author_meta('user_email', $user_id);
    $payments = edd_get_payments(array('s' => $email));
    if ($payments) {
        // Set a flag to force the account to be verified before purchase history can be accessed
        edd_set_user_to_pending($user_id);
        edd_send_user_verification_email($user_id);
        foreach ($payments as $payment) {
            if (intval(edd_get_payment_user_id($payment->ID)) > 0) {
                continue;
                // This payment already associated with an account
            }
            $meta = edd_get_payment_meta($payment->ID);
            $meta['user_info'] = maybe_unserialize($meta['user_info']);
            $meta['user_info']['id'] = $user_id;
            $meta['user_info'] = $meta['user_info'];
            // Store the updated user ID in the payment meta
            edd_update_payment_meta($payment->ID, '_edd_payment_meta', $meta);
            edd_update_payment_meta($payment->ID, '_edd_payment_user_id', $user_id);
        }
    }
}
开发者ID:jplhomer,项目名称:Easy-Digital-Downloads,代码行数:34,代码来源:user-functions.php

示例11: edd_v20_upgrade_sequential_payment_numbers

/**
 * Upgrades for EDD v2.0 and sequential payment numbers
 *
 * @since 2.0
 * @return void
 */
function edd_v20_upgrade_sequential_payment_numbers()
{
    ignore_user_abort(true);
    if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
        set_time_limit(0);
    }
    $step = isset($_GET['step']) ? absint($_GET['step']) : 1;
    $total = isset($_GET['total']) ? absint($_GET['total']) : false;
    if (empty($total) || $total <= 1) {
        $payments = edd_count_payments();
        foreach ($payments as $status) {
            $total += $status;
        }
    }
    $args = array('number' => 100, 'page' => $step, 'status' => 'any', 'order' => 'ASC');
    $payments = new EDD_Payments_Query($args);
    $payments = $payments->get_payments();
    if ($payments) {
        $prefix = edd_get_option('sequential_prefix');
        $postfix = edd_get_option('sequential_postfix');
        $number = !empty($_GET['custom']) ? absint($_GET['custom']) : intval(edd_get_option('sequential_start', 1));
        foreach ($payments as $payment) {
            // Re-add the prefix and postfix
            $payment_number = $prefix . $number . $postfix;
            edd_update_payment_meta($payment->ID, '_edd_payment_number', $payment_number);
            // Increment the payment number
            $number++;
        }
        // Payments found so upgrade them
        $step++;
        $redirect = add_query_arg(array('page' => 'edd-upgrades', 'edd-upgrade' => 'upgrade_sequential_payment_numbers', 'step' => $step, 'custom' => $number, 'total' => $total), admin_url('index.php'));
        wp_redirect($redirect);
        exit;
    } else {
        // No more payments found, finish up
        EDD()->session->set('upgrade_sequential', null);
        wp_redirect(admin_url());
        exit;
    }
}
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:46,代码来源:upgrade-functions.php

示例12: edd_ti_send_tracking

function edd_ti_send_tracking($post)
{
    $nonce = !empty($post['nonce']) ? $post['nonce'] : false;
    if (!wp_verify_nonce($nonce, 'edd-ti-send-tracking')) {
        wp_die();
    }
    $tracking_id = edd_ti_get_payment_tracking_id($post['payment_id']);
    if (empty($tracking_id)) {
        return;
    }
    $from_name = edd_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
    $from_email = edd_get_option('from_email', get_bloginfo('admin_email'));
    $to_email = edd_get_payment_user_email($post['payment_id']);
    $subject = 'Your order has shipped';
    $heading = 'Your order has shipped!';
    $message = '<p>Your recent order ' . $post['payment_id'] . ' has been shipped.</p>';
    $message .= '<p>Tracking ID: <a href="' . edd_ti_get_payment_tracking_link($post['payment_id']) . '">' . $tracking_id . '</a></p>';
    $message .= '<p>Thank you!</p>';
    $message .= '<p>The ' . $from_name . ' team</p>';
    $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
    $headers .= "Reply-To: " . $from_email . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=utf-8\r\n";
    $attachments = array();
    $emails = EDD()->emails;
    $emails->__set('from_name', $from_name);
    $emails->__set('from_email', $from_email);
    $emails->__set('heading', $heading);
    $emails->__set('headers', $headers);
    $result = $emails->send($to_email, $subject, $message, $attachments);
    $response = array('success' => $result);
    $response['message'] = $result ? __('Email sent.', 'edd-tracking-info') : __('Error sending email. Try again later.', 'edd-tracking-info');
    if ($result) {
        edd_update_payment_meta($post['payment_id'], 'edd_tracking_info_sent', true);
        edd_insert_payment_note($post['payment_id'], sprintf(__('Tracking information sent to %s.', 'edd-tracking-info'), $to_email));
    }
    echo json_encode($response);
    die;
}
开发者ID:cklosowski,项目名称:edd-tracking-info,代码行数:39,代码来源:metabox.php

示例13: set_primary_email

 /**
  * Set an email address as the customer's primary email
  *
  * This will move the customer's previous primary email to an additional email
  *
  * @since  2.6
  * @param  string $new_primary_email The email address to remove from the customer
  * @return bool                      If the email was set as primary successfully
  */
 public function set_primary_email($new_primary_email = '')
 {
     if (!is_email($new_primary_email)) {
         return false;
     }
     do_action('edd_customer_pre_set_primary_email', $new_primary_email, $this->id, $this);
     $existing = new EDD_Customer($new_primary_email);
     if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
         // This email belongs to another customer
         return false;
     }
     $old_email = $this->email;
     // Update customer record with new email
     $update = $this->update(array('email' => $new_primary_email));
     // Remove new primary from list of additional emails
     $remove = $this->remove_email($new_primary_email);
     // Add old email to additional emails list
     $add = $this->add_email($old_email);
     $ret = $update && $remove && $add;
     if ($ret) {
         $this->email = $new_primary_email;
         $payment_ids = $this->get_payment_ids();
         if ($payment_ids) {
             foreach ($payment_ids as $payment_id) {
                 // Update payment emails to primary email
                 edd_update_payment_meta($payment_id, 'email', $new_primary_email);
             }
         }
     }
     do_action('edd_customer_post_set_primary_email', $new_primary_email, $this->id, $this);
     return $ret;
 }
开发者ID:stephywells,项目名称:Easy-Digital-Downloads,代码行数:41,代码来源:class-edd-customer.php

示例14: update_customer_email_on_user_update

 /**
  * Updates the email address of a customer record when the email on a user is updated
  *
  * @access  public
  * @since   2.4
  */
 public function update_customer_email_on_user_update($user_id = 0, $old_user_data)
 {
     $customer = new EDD_Customer($user_id, true);
     if (!$customer) {
         return false;
     }
     $user = get_userdata($user_id);
     if (!empty($user) && $user->user_email !== $customer->email) {
         if (!$this->get_customer_by('email', $user->user_email)) {
             $success = $this->update($customer->id, array('email' => $user->user_email));
             if ($success) {
                 // Update some payment meta if we need to
                 $payments_array = explode(',', $customer->payment_ids);
                 if (!empty($payments_array)) {
                     foreach ($payments_array as $payment_id) {
                         edd_update_payment_meta($payment_id, 'email', $user->user_email);
                     }
                 }
                 do_action('edd_update_customer_email_on_user_update', $user, $customer);
             }
         }
     }
 }
开发者ID:pderksen,项目名称:Easy-Digital-Downloads,代码行数:29,代码来源:class-edd-db-customers.php

示例15: edd_wallet_add_funds

/**
 * Add the deposited amount to the wallet after payment
 *
 * @since       1.0.0
 * @param       int $payment_id The ID of the payment
 * @return      void
 */
function edd_wallet_add_funds($payment_id)
{
    $fees = edd_get_payment_fees($payment_id);
    if ($fees && count($fees) == 1) {
        if ($fees[0]['id'] == 'edd-wallet-deposit') {
            // Disable purchase receipts... we send our own emails
            remove_action('edd_complete_purchase', 'edd_trigger_purchase_receipt', 999);
            // Send our custom emails
            edd_wallet_send_email('user', $payment_id);
            // Get the ID of the purchaser
            $user_id = edd_get_payment_user_id($payment_id);
            // Deposit the funds
            edd_wallet()->wallet->deposit($user_id, $fees[0]['amount'], 'deposit', $payment_id);
            // Tag the payment so we can find it later
            edd_update_payment_meta($payment_id, '_edd_wallet_deposit', $user_id);
        }
    }
}
开发者ID:easydigitaldownloads,项目名称:edd-wallet,代码行数:25,代码来源:deposit-functions.php


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