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


PHP give_update_payment_status函数代码示例

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


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

示例1: setUp

 /**
  * Set it up
  */
 public function setUp()
 {
     parent::setUp();
     //Create a Donation Form
     $this->_post_id = $this->factory->post->create(array('post_title' => 'Test Form', 'post_type' => 'give_forms', 'post_status' => 'publish'));
     $_multi_level_donations = array(array('_give_id' => array('level_id' => '1'), '_give_amount' => '10.00', '_give_text' => 'Basic Level'), array('_give_id' => array('level_id' => '2'), '_give_amount' => '20.00', '_give_text' => 'Intermediate Level'), array('_give_id' => array('level_id' => '3'), '_give_amount' => '40.00', '_give_text' => 'Advanced Level'));
     $meta = array('give_price' => '0.00', '_give_price_option' => 'multi', '_give_price_options_mode' => 'on', '_give_donation_levels' => array_values($_multi_level_donations), 'give_product_notes' => 'Donation Notes', '_give_product_type' => 'default');
     foreach ($meta as $key => $value) {
         update_post_meta($this->_post_id, $key, $value);
     }
     //Generate Donations
     $this->_user_id = $this->factory->user->create(array('role' => 'administrator'));
     $user = get_userdata($this->_user_id);
     $user_info = array('id' => $user->ID, 'email' => 'testadmin@domain.com', 'first_name' => $user->first_name, 'last_name' => $user->last_name);
     $donation_details = array(array('id' => $this->_post_id, 'options' => array('price_id' => 1)));
     $total = 0;
     $prices = get_post_meta($donation_details[0]['id'], '_give_donation_levels', true);
     $item_price = $prices[1]['_give_amount'];
     $total += $item_price;
     $purchase_data = array('price' => number_format((double) $total, 2), 'give_form_title' => get_the_title($this->_post_id), 'give_form_id' => $this->_post_id, 'date' => date('Y-m-d H:i:s', strtotime('-1 day')), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user_info['email'], 'user_info' => $user_info, 'currency' => 'USD', 'status' => 'pending', 'gateway' => 'manual');
     $_SERVER['REMOTE_ADDR'] = '10.0.0.0';
     $_SERVER['SERVER_NAME'] = 'give_virtual';
     $payment_id = give_insert_payment($purchase_data);
     give_update_payment_status($payment_id, 'complete');
 }
开发者ID:helgatheviking,项目名称:Give,代码行数:28,代码来源:tests-customers.php

示例2: setUp

 /**
  * Set it Up
  */
 public function setUp()
 {
     parent::setUp();
     $this->_payment_id = Give_Helper_Payment::create_simple_payment();
     //$20
     $this->_payment_id2 = Give_Helper_Payment::create_multilevel_payment();
     //$25
     give_update_payment_status($this->_payment_id);
     give_update_payment_status($this->_payment_id2);
 }
开发者ID:wordimpress,项目名称:give,代码行数:13,代码来源:tests-stats.php

示例3: give_manual_payment

/**
 * Processes the purchase data and uses the Manual Payment gateway to record
 * the transaction in the Purchase History
 *
 * @since 1.0
 *
 * @param array $purchase_data Purchase Data
 *
 * @return void
 */
function give_manual_payment($purchase_data)
{
    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
        wp_die(esc_html__('Nonce verification has failed', 'give'), esc_html__('Error', 'give'), array('response' => 403));
    }
    //Create payment_data array
    $payment_data = array('price' => $purchase_data['price'], 'give_form_title' => $purchase_data['post_data']['give-form-title'], 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => give_get_currency(), 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
    // Record the pending payment
    $payment = give_insert_payment($payment_data);
    if ($payment) {
        give_update_payment_status($payment, 'publish');
        give_send_to_success_page();
    } else {
        give_record_gateway_error(esc_html__('Payment Error', 'give'), sprintf(esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), json_encode($payment_data)), $payment);
        // If errors are present, send the user back to the purchase page so they can be corrected
        give_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['give-gateway']);
    }
}
开发者ID:wordimpress,项目名称:give,代码行数:28,代码来源:manual.php

示例4: setUp

 public function setUp()
 {
     parent::setUp();
     global $wp_rewrite, $wp_query;
     $GLOBALS['wp_rewrite']->init();
     flush_rewrite_rules(false);
     $this->_api = new Give_API();
     $roles = new Give_Roles();
     $roles->add_roles();
     $roles->add_caps();
     $this->_api->add_endpoint($wp_rewrite);
     $this->_rewrite = $wp_rewrite;
     $this->_query = $wp_query;
     //Create a Donation Form
     $post_id = $this->factory->post->create(array('post_title' => 'Test Form', 'post_type' => 'give_forms', 'post_status' => 'publish'));
     $this->_user_id = $this->factory->user->create(array('role' => 'administrator'));
     wp_set_current_user($this->_user_id);
     $_multi_level_donations = array(array('_give_id' => array('level_id' => '1'), '_give_amount' => '10.00', '_give_text' => 'Basic Level'), array('_give_id' => array('level_id' => '2'), '_give_amount' => '20.00', '_give_text' => 'Intermediate Level'), array('_give_id' => array('level_id' => '3'), '_give_amount' => '40.00', '_give_text' => 'Advanced Level'));
     $meta = array('give_price' => '0.00', '_give_price_option' => 'multi', '_give_price_options_mode' => 'on', '_give_donation_levels' => array_values($_multi_level_donations), '_give_form_earnings' => 120, '_give_form_sales' => 59);
     foreach ($meta as $key => $value) {
         update_post_meta($post_id, $key, $value);
     }
     $this->_post = get_post($post_id);
     $user = get_userdata(1);
     $user_info = array('id' => $user->ID, 'email' => 'testadmin@domain.com', 'first_name' => $user->first_name, 'last_name' => $user->last_name);
     $prices = get_post_meta($post_id, '_give_donation_levels', true);
     $total = $prices[1]['_give_amount'];
     //Add a payment
     $purchase_data = array('price' => number_format((double) $total, 2), 'give_form_title' => get_the_title($post_id), 'give_form_id' => $post_id, 'date' => date('Y-m-d H:i:s', strtotime('-1 day')), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user_info['email'], 'user_info' => $user_info, 'currency' => 'USD', 'status' => 'pending', 'gateway' => 'manual');
     $_SERVER['REMOTE_ADDR'] = '10.0.0.0';
     $this->_payment_id = give_insert_payment($purchase_data);
     give_update_payment_status($this->_payment_id, 'complete');
     $this->_api_output = $this->_api->get_forms();
     $this->_api_output_sales = $this->_api->get_recent_donations();
     global $wp_query;
     $wp_query->query_vars['format'] = 'override';
 }
开发者ID:wordimpress,项目名称:give,代码行数:37,代码来源:tests-api.php

示例5: give_listen_for_failed_payments

/**
 * Mark payments as Failed when returning to the Failed Transaction page
 *
 * @access      public
 * @since       1.0
 * @return      void
 */
function give_listen_for_failed_payments()
{
    $failed_page = give_get_option('failure_page', 0);
    if (!empty($failed_page) && is_page($failed_page) && !empty($_GET['payment-id'])) {
        $payment_id = absint($_GET['payment-id']);
        give_update_payment_status($payment_id, 'failed');
    }
}
开发者ID:helgatheviking,项目名称:Give,代码行数:15,代码来源:functions.php

示例6: give_v134_upgrade_give_offline_status

/**
 * Upgrades the Offline Status
 *
 * @description: Reverses the issue where offline donation transactions in "pending" status where inappropriately marked as abandoned
 *
 * @since      1.3.4
 *
 */
function give_v134_upgrade_give_offline_status()
{
    global $wpdb;
    if (!current_user_can('manage_give_settings')) {
        wp_die(__('You do not have permission to do Give upgrades', 'give'), __('Error', 'give'), array('response' => 403));
    }
    ignore_user_abort(true);
    if (!give_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
        @set_time_limit(0);
    }
    // Get abandoned offline payments
    $select = "SELECT ID FROM {$wpdb->posts} p ";
    $join = "LEFT JOIN {$wpdb->postmeta} m ON p.ID = m.post_id ";
    $where = "WHERE p.post_type = 'give_payment' ";
    $where .= "AND ( p.post_status = 'abandoned' )";
    $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
    $sql = $select . $join . $where;
    $found_payments = $wpdb->get_col($sql);
    foreach ($found_payments as $payment) {
        //Only change ones marked abandoned since our release last week
        //because the admin may have marked some abandoned themselves
        $modified_time = get_post_modified_time('U', false, $payment);
        //1450124863 =  12/10/2015 20:42:25
        if ($modified_time >= 1450124863) {
            give_update_payment_status($payment, 'pending');
        }
    }
    update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
    give_set_upgrade_complete('upgrade_give_offline_status');
    delete_option('give_doing_upgrade');
    wp_redirect(admin_url());
    exit;
}
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:41,代码来源:upgrade-functions.php

示例7: give_process_paypal_refund

/**
 * Process PayPal IPN Refunds
 *
 * @since 1.0
 *
 * @param array $data       IPN Data
 * @param int   $payment_id The payment ID.
 *
 * @return void
 */
function give_process_paypal_refund($data, $payment_id = 0)
{
    // Collect payment details
    if (empty($payment_id)) {
        return;
    }
    if (get_post_status($payment_id) == 'refunded') {
        return;
        // Only refund payments once
    }
    $payment_amount = give_get_payment_amount($payment_id);
    $refund_amount = $data['payment_gross'] * -1;
    if (number_format((double) $refund_amount, 2) < number_format((double) $payment_amount, 2)) {
        give_insert_payment_note($payment_id, sprintf(esc_html__('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id']));
        return;
        // This is a partial refund
    }
    give_insert_payment_note($payment_id, sprintf(esc_html__('PayPal Payment #%s Refunded for reason: %s', 'give'), $data['parent_txn_id'], $data['reason_code']));
    give_insert_payment_note($payment_id, sprintf(esc_html__('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id']));
    give_update_payment_status($payment_id, 'refunded');
}
开发者ID:wordimpress,项目名称:give,代码行数:31,代码来源:paypal-standard.php

示例8: process_bulk_action

 /**
  * Process the bulk actions
  *
  * @access public
  * @since  1.0
  * @return void
  */
 public function process_bulk_action()
 {
     $ids = isset($_GET['payment']) ? $_GET['payment'] : false;
     $action = $this->current_action();
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     if (empty($action)) {
         return;
     }
     foreach ($ids as $id) {
         // Detect when a bulk action is being triggered...
         if ('delete' === $this->current_action()) {
             give_delete_purchase($id);
         }
         if ('set-status-publish' === $this->current_action()) {
             give_update_payment_status($id, 'publish');
         }
         if ('set-status-pending' === $this->current_action()) {
             give_update_payment_status($id, 'pending');
         }
         if ('set-status-refunded' === $this->current_action()) {
             give_update_payment_status($id, 'refunded');
         }
         if ('set-status-revoked' === $this->current_action()) {
             give_update_payment_status($id, 'revoked');
         }
         if ('set-status-failed' === $this->current_action()) {
             give_update_payment_status($id, 'failed');
         }
         if ('set-status-abandoned' === $this->current_action()) {
             give_update_payment_status($id, 'abandoned');
         }
         if ('resend-receipt' === $this->current_action()) {
             give_email_donation_receipt($id, false);
         }
         do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
     }
 }
开发者ID:helgatheviking,项目名称:Give,代码行数:46,代码来源:class-payments-table.php

示例9: status_update

 /**
  * Update lead status of the specified payment
  *
  * @see https://github.com/Charitable/Charitable/blob/1.1.4/includes/gateways/class-charitable-gateway-paypal.php#L229-L357
  * @param Pronamic_Pay_Payment $payment
  */
 public static function status_update(Pronamic_Pay_Payment $payment)
 {
     $donation_id = $payment->get_source_id();
     switch ($payment->get_status()) {
         case Pronamic_WP_Pay_Statuses::CANCELLED:
             give_update_payment_status($donation_id, 'cancelled');
             break;
         case Pronamic_WP_Pay_Statuses::EXPIRED:
             give_update_payment_status($donation_id, 'abandoned');
             break;
         case Pronamic_WP_Pay_Statuses::FAILURE:
             give_update_payment_status($donation_id, 'failed');
             break;
         case Pronamic_WP_Pay_Statuses::SUCCESS:
             give_update_payment_status($donation_id, 'publish');
             break;
         case Pronamic_WP_Pay_Statuses::OPEN:
         default:
             give_update_payment_status($donation_id, 'pending');
             break;
     }
 }
开发者ID:wp-pay-extensions,项目名称:give,代码行数:28,代码来源:Extension.php

示例10: process_bulk_action

 /**
  * Process the bulk actions
  *
  * @access public
  * @since  1.0
  * @return void
  */
 public function process_bulk_action()
 {
     $ids = isset($_GET['payment']) ? $_GET['payment'] : false;
     $action = $this->current_action();
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     if (empty($action)) {
         return;
     }
     foreach ($ids as $id) {
         // Detect when a bulk action is being triggered...
         switch ($this->current_action()) {
             case 'delete':
                 give_delete_purchase($id);
                 break;
             case 'set-status-publish':
                 give_update_payment_status($id, 'publish');
                 break;
             case 'set-status-pending':
                 give_update_payment_status($id, 'pending');
                 break;
             case 'set-status-refunded':
                 give_update_payment_status($id, 'refunded');
                 break;
             case 'set-status-revoked':
                 give_update_payment_status($id, 'revoked');
                 break;
             case 'set-status-failed':
                 give_update_payment_status($id, 'failed');
                 break;
             case 'set-status-cancelled':
                 give_update_payment_status($id, 'cancelled');
                 break;
             case 'set-status-abandoned':
                 give_update_payment_status($id, 'abandoned');
                 break;
             case 'set-status-preapproval':
                 give_update_payment_status($id, 'preapproval');
                 break;
             case 'resend-receipt':
                 give_email_donation_receipt($id, false);
                 break;
         }
         /**
          * Fires after triggering bulk action on payments table.
          *
          * @since 1.0
          *
          * @param int    $id The ID of the payment.
          * @param string $current_action The action that is being triggered.
          */
         do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
     }
 }
开发者ID:wordimpress,项目名称:give,代码行数:62,代码来源:class-payments-table.php

示例11: test_payment_status_update

 /**
  * Test Payment Status Update
  */
 public function test_payment_status_update()
 {
     $payment = new Give_Payment($this->_payment_id);
     $payment->update_status('pending');
     $this->assertEquals('pending', $payment->status);
     $this->assertEquals('Pending', $payment->status_nicename);
     // Test backwards compatibility
     give_update_payment_status($this->_payment_id, 'publish');
     // Need to get the payment again since it's been updated
     $payment = new Give_Payment($this->_payment_id);
     $this->assertEquals('publish', $payment->status);
     $this->assertEquals('Complete', $payment->status_nicename);
 }
开发者ID:wordimpress,项目名称:give,代码行数:16,代码来源:tests-payment-class.php

示例12: give_mark_abandoned_donations

/**
 * Updates week-old+ 'pending' orders to 'abandoned'
 *
 * @since 1.0
 * @return void
 */
function give_mark_abandoned_donations()
{
    $args = array('status' => 'pending', 'number' => -1, 'fields' => 'ids');
    add_filter('posts_where', 'give_filter_where_older_than_week');
    $payments = give_get_payments($args);
    remove_filter('posts_where', 'give_filter_where_older_than_week');
    if ($payments) {
        foreach ($payments as $payment) {
            $gateway = give_get_payment_gateway($payment);
            //Skip offline gateway payments
            if ($gateway == 'offline') {
                continue;
            }
            //Non-offline get marked as 'abandoned'
            give_update_payment_status($payment, 'abandoned');
        }
    }
}
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:24,代码来源:actions.php

示例13: give_mark_abandoned_orders

/**
 * Updates week-old+ 'pending' orders to 'abandoned'
 *
 * @since 1.0
 * @return void
 */
function give_mark_abandoned_orders()
{
    $args = array('status' => 'pending', 'number' => -1, 'fields' => 'ids');
    add_filter('posts_where', 'give_filter_where_older_than_week');
    $payments = give_get_payments($args);
    remove_filter('posts_where', 'give_filter_where_older_than_week');
    if ($payments) {
        foreach ($payments as $payment) {
            give_update_payment_status($payment, 'abandoned');
        }
    }
}
开发者ID:valeriosouza,项目名称:Give,代码行数:18,代码来源:actions.php

示例14: give_update_payment_details


//.........这里部分代码省略.........
    do_action('give_update_edited_purchase', $payment_id);
    // Update main payment record
    $updated = wp_update_post(array('ID' => $payment_id, 'edit_date' => true, 'post_date' => $date));
    if (0 === $updated) {
        wp_die(esc_attr__('Error Updating Payment', 'give'), esc_attr__('Error', 'give'), array('response' => 400));
    }
    $customer_changed = false;
    if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') {
        $email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : '';
        $names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : '';
        if (empty($email) || empty($names)) {
            wp_die(esc_attr__('New Customers require a name and email address', 'give'));
        }
        $customer = new Give_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 Give_Customer($curr_customer_id);
                give_set_error('give-payment-new-customer-fail', __('Error creating new customer', 'give'));
            }
        }
        $new_customer_id = $customer->id;
        $previous_customer = new Give_Customer($curr_customer_id);
        $customer_changed = true;
    } elseif ($curr_customer_id !== $new_customer_id) {
        $customer = new Give_Customer($new_customer_id);
        $email = $customer->email;
        $names = $customer->name;
        $previous_customer = new Give_Customer($curr_customer_id);
        $customer_changed = true;
    } else {
        $customer = new Give_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, '_give_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;
    // Check for payment notes
    if (!empty($data['give-payment-note'])) {
        $note = wp_kses($data['give-payment-note'], array());
        give_insert_payment_note($payment_id, $note);
    }
    // Set new status
    give_update_payment_status($payment_id, $status);
    give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id);
    give_update_payment_meta($payment_id, '_give_payment_user_email', $customer->email);
    give_update_payment_meta($payment_id, '_give_payment_meta', $meta);
    give_update_payment_meta($payment_id, '_give_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;
            give_increase_total_earnings($difference);
            $form = new Give_Donate_Form($form_id);
            $form->increase_earnings($difference);
        } elseif ($curr_total > $new_total) {
            // Decrease if our new total is lower
            $difference = $curr_total - $new_total;
            give_decrease_total_earnings($difference);
            $form = new Give_Donate_Form($form_id);
            $form->decrease_earnings($difference);
        }
    }
    do_action('give_updated_edited_purchase', $payment_id);
    wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id));
    exit;
}
开发者ID:lots0logs,项目名称:Give,代码行数:101,代码来源:actions.php

示例15: give_process_authorize_net_payment

 /**
  * Authorize.net Payments
  *
  * @param $purchase_data
  */
 public function give_process_authorize_net_payment($purchase_data)
 {
     if (!isset($_POST['card_number']) || $_POST['card_number'] == '') {
         give_set_error('empty_card', __('You must enter a card number', 'give'));
     }
     if (!isset($_POST['card_name']) || $_POST['card_name'] == '') {
         give_set_error('empty_card_name', __('You must enter the name on your card', 'give'));
     }
     if (!isset($_POST['card_exp_month']) || $_POST['card_exp_month'] == '') {
         give_set_error('empty_month', __('You must enter an expiration month', 'give'));
     }
     if (!isset($_POST['card_exp_year']) || $_POST['card_exp_year'] == '') {
         give_set_error('empty_year', __('You must enter an expiration year', 'give'));
     }
     if (!isset($_POST['card_cvc']) || $_POST['card_cvc'] == '' || strlen($_POST['card_cvc']) < 3) {
         give_set_error('empty_cvc', __('You must enter a valid CVC', 'give'));
     }
     $errors = give_get_errors();
     //No errors: Continue with payment processing
     if (!$errors) {
         //Include Authorize SDK
         require_once GIVE_AUTHORIZE_PLUGIN_DIR . '/includes/anet_php_sdk/AuthorizeNet.php';
         if (!give_is_test_mode()) {
             //LIVE:
             $authorize_api_login = give_get_option('give_api_login');
             $authorize_trans_key = give_get_option('give_transaction_key');
         } else {
             //SANDBOX
             $authorize_api_login = give_get_option('give_authorize_sandbox_api_login');
             $authorize_trans_key = give_get_option('give_authorize_sandbox_transaction_key');
         }
         //Check for credentials entered
         if (empty($authorize_api_login) || empty($authorize_trans_key)) {
             give_set_error('error_id_here', __('Error: Missing API Login or Transaction key. Please enter them in the plugin settings.', 'give-authorize'));
             return;
         }
         //Proceed with Authorize AIM
         $transaction = new AuthorizeNetAIM($authorize_api_login, $authorize_trans_key);
         $transaction->VERIFY_PEER = false;
         //Sandbox or not?
         if (give_is_test_mode()) {
             $transaction->setSandbox(true);
         } else {
             $transaction->setSandbox(false);
         }
         $card_info = $purchase_data['card_info'];
         $card_names = explode(' ', $card_info['card_name']);
         $first_name = isset($card_names[0]) ? $card_names[0] : $purchase_data['user_info']['first_name'];
         if (!empty($card_names[1])) {
             unset($card_names[0]);
             $last_name = implode(' ', $card_names);
         } else {
             $last_name = $purchase_data['user_info']['last_name'];
         }
         $transaction->amount = $purchase_data['price'];
         $transaction->card_num = strip_tags(trim($card_info['card_number']));
         $transaction->card_code = strip_tags(trim($card_info['card_cvc']));
         $transaction->exp_date = strip_tags(trim($card_info['card_exp_month'])) . '/' . strip_tags(trim($card_info['card_exp_year']));
         $transaction->description = give_get_purchase_summary($purchase_data);
         $transaction->first_name = $first_name;
         $transaction->last_name = $last_name;
         $transaction->address = $card_info['card_address'] . ' ' . $card_info['card_address_2'];
         $transaction->city = $card_info['card_city'];
         $transaction->country = $card_info['card_country'];
         $transaction->state = $card_info['card_state'];
         $transaction->zip = $card_info['card_zip'];
         $transaction->customer_ip = give_get_ip();
         $transaction->email = $purchase_data['user_email'];
         $transaction->invoice_num = $purchase_data['purchase_key'];
         try {
             $response = $transaction->authorizeAndCapture();
             if ($response->approved) {
                 $payment_data = array('price' => $purchase_data['price'], 'give_form_title' => $purchase_data['post_data']['give-form-title'], 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), 'price_id' => isset($purchase_data['post_data']['give-price-id']) ? intval($purchase_data['post_data']['give-price-id']) : '', 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => give_get_currency(), 'user_info' => $purchase_data['user_info'], 'status' => 'pending', 'gateway' => 'authorizenet');
                 $payment = give_insert_payment($payment_data);
                 if ($payment) {
                     give_update_payment_status($payment, 'publish');
                     give_send_to_success_page();
                 } else {
                     give_set_error('authorize_error', __('Error: your payment could not be recorded. Please try again', 'give'));
                     give_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['give-gateway']);
                 }
             } else {
                 if (isset($response->response_reason_text)) {
                     $error = $response->response_reason_text;
                 } elseif (isset($response->error_message)) {
                     $error = $response->error_message;
                 } else {
                     $error = '';
                 }
                 if (strpos(strtolower($error), 'the credit card number is invalid') !== false) {
                     give_set_error('invalid_card', __('Your card number is invalid', 'give'));
                 } elseif (strpos(strtolower($error), 'this transaction has been declined') !== false) {
                     give_set_error('invalid_card', __('Your card has been declined', 'give'));
                 } elseif (isset($response->response_reason_text)) {
                     give_set_error('api_error', $response->response_reason_text);
//.........这里部分代码省略.........
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:101,代码来源:class-authorize-payments.php


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