/**
 * Get all the payment gateways
 *
 * @return array
 */
function wpuf_get_gateways($context = 'admin')
{
    $gateways = WPUF_Payment::get_payment_gateways();
    $return = array();
    foreach ($gateways as $id => $gate) {
        if ($context == 'admin') {
            $return[$id] = $gate['admin_label'];
        } else {
            $return[$id] = array('label' => $gate['checkout_label'], 'icon' => isset($gate['icon']) ? $gate['icon'] : '');
        }
    }
    return $return;
}
Esempio n. 2
0
 /**
  * Handle the payment info sent from paypal
  *
  * @since 0.8
  */
 function paypal_success()
 {
     if (isset($_GET['action']) && $_GET['action'] == 'wpuf_paypal_success') {
         $postdata = $_POST;
         //var_dump( $postdata );exit;
         $type = $postdata['custom'];
         $item_number = $postdata['item_number'];
         $amount = $postdata['mc_gross'];
         $payment_status = strtolower($postdata['payment_status']);
         //verify payment
         $verified = $this->validateIpn();
         switch ($type) {
             case 'post':
                 $post_id = $item_number;
                 $pack_id = 0;
                 break;
             case 'pack':
                 $post_id = 0;
                 $pack_id = $item_number;
                 break;
         }
         if ($verified || $this->test_mode) {
             $data = array('user_id' => get_current_user_id(), 'status' => 'completed', 'cost' => $postdata['mc_gross'], 'post_id' => $post_id, 'pack_id' => $pack_id, 'payer_first_name' => $postdata['first_name'], 'payer_last_name' => $postdata['last_name'], 'payer_email' => $postdata['payer_email'], 'payment_type' => 'Paypal', 'payer_address' => $postdata['residence_country'], 'transaction_id' => $postdata['txn_id'], 'created' => current_time('mysql'));
             WPUF_Payment::insert_payment($data, $postdata['txn_id']);
         }
     }
 }
    $order_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
    $info = get_post_meta($order_id, '_data', true);
    if ($info) {
        switch ($info['type']) {
            case 'post':
                $post_id = $info['item_number'];
                $pack_id = 0;
                break;
            case 'pack':
                $post_id = 0;
                $pack_id = $info['item_number'];
                break;
        }
        $transaction = array('user_id' => $info['user_info']['id'], 'status' => 'completed', 'cost' => $info['price'], 'post_id' => $post_id, 'pack_id' => $pack_id, 'payer_first_name' => $info['user_info']['first_name'], 'payer_last_name' => $info['user_info']['last_name'], 'payer_email' => $info['user_info']['email'], 'payment_type' => 'Bank/Manual', 'transaction_id' => $order_id, 'created' => current_time('mysql'));
        do_action('wpuf_gateway_bank_order_complete', $transaction, $order_id);
        WPUF_Payment::insert_payment($transaction);
        wp_delete_post($order_id, true);
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'order_reject') {
    $order_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
    do_action('wpuf_gateway_bank_order_reject', $order_id);
    wp_delete_post($order_id, true);
}
if (isset($_POST['delete_selected'])) {
    if (!wp_verify_nonce($_POST['_wpnonce'], 'wpuf_delete_transactions')) {
        wp_die("Cheating?");
    }
    if (isset($_POST['tr_id'])) {
        foreach ($_POST['tr_id'] as $tr_id) {
            $wpdb->delete($wpdb->prefix . 'wpuf_transaction', array('id' => $tr_id), array('%d'));
Esempio n. 4
0
 /**
  * Handle the payment info sent from paypal
  *
  * @since 0.8
  */
 function paypal_success()
 {
     $postdata = $_POST;
     //cancel subscription form admin panel
     if (isset($_POST['wpuf_payment_cancel_submit']) && $_POST['action'] == 'wpuf_cancel_pay' && wp_verify_nonce($_POST['wpuf_payment_cancel'], '_wpnonce')) {
         $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : '';
         $this->recurring_change_status($user_id, 'Cancel');
         return;
     }
     //when subscription expire
     if (isset($postdata['txn_type']) && $postdata['txn_type'] == 'subscr_eot') {
         $custom = json_decode(stripcslashes($postdata['custom']));
         $this->subscription_cancel($custom->user_id);
         return;
     }
     //when subscription cancel
     if (isset($postdata['txn_type']) && $postdata['txn_type'] == 'subscr_cancel') {
         $custom = json_decode(stripcslashes($postdata['custom']));
         $this->subscription_cancel($custom->user_id);
         return;
     }
     $insert_payment = false;
     if (isset($_GET['action']) && $_GET['action'] == 'wpuf_paypal_success') {
         WP_User_Frontend::log($postdata, print_r($_POST, true));
         $postdata = $_POST;
         $type = $postdata['custom'];
         $item_number = $postdata['item_number'];
         $amount = $postdata['mc_gross'];
         $is_recurring = false;
         $custom = json_decode(stripcslashes($postdata['custom']));
         $coupon_id = isset($custom->coupon_id) ? $custom->coupon_id : false;
         // check if recurring payment
         if (isset($postdata['txn_type']) && $postdata['txn_type'] == 'subscr_payment' && strtolower($postdata['payment_status']) == 'completed') {
             if ($postdata['mc_gross'] == $custom->billing_amount || $postdata['mc_gross'] == $custom->trial_cost && $custom->trial_cost > 0) {
                 $insert_payment = true;
                 $post_id = 0;
                 $pack_id = $item_number;
                 $is_recurring = true;
                 $status = 'subscr_payment';
                 WP_User_Frontend::log('paypal-recurring', 'got subscr_payment, should insert of pack_id: ' . $pack_id);
             } else {
                 $this->subscription_cancel($custom->user_id);
                 WP_User_Frontend::log('paypal-recurring', 'got subscr_payment. billing validation failed, cancel subscription. user_id: ' . $custom->user_id);
             }
         } else {
             if (isset($postdata['txn_type']) && $postdata['txn_type'] == 'web_accept' && strtolower($postdata['payment_status']) == 'completed') {
                 WP_User_Frontend::log('paypal', 'got web_accept. type: ' . $custom->type . '. item_number: ' . $item_number);
                 //verify payment
                 $verified = $this->validateIpn();
                 $status = 'web_accept';
                 switch ($custom->type) {
                     case 'post':
                         $post_id = $item_number;
                         $pack_id = 0;
                         break;
                     case 'pack':
                         $post_id = 0;
                         $pack_id = $item_number;
                         break;
                 }
                 if ($verified) {
                     $insert_payment = true;
                 }
             } else {
                 if (isset($postdata['verify_sign']) && !empty($postdata['verify_sign']) && isset($postdata['payment_status']) && $postdata['payment_status'] == 'Pending' && isset($postdata['pending_reason']) && $postdata['pending_reason'] == 'multi_currency' && isset($postdata['txn_type']) && $postdata['txn_type'] == 'web_accept') {
                     //verify payment
                     $verified = $this->validateIpn();
                     $status = 'web_accept';
                     switch ($custom->type) {
                         case 'post':
                             $post_id = $item_number;
                             $pack_id = 0;
                             break;
                         case 'pack':
                             $post_id = 0;
                             $pack_id = $item_number;
                             break;
                     }
                     if ($verified) {
                         $insert_payment = true;
                     }
                 }
             }
         }
         // payment type
         if ($insert_payment) {
             $data = array('user_id' => (int) $custom->user_id, 'status' => $status, 'cost' => $postdata['mc_gross'], 'post_id' => $post_id, 'pack_id' => $pack_id, 'payer_first_name' => $postdata['first_name'], 'payer_last_name' => $postdata['last_name'], 'payer_email' => $postdata['payer_email'], 'payment_type' => 'Paypal', 'payer_address' => $postdata['residence_country'], 'transaction_id' => $postdata['txn_id'], 'created' => current_time('mysql'), 'profile_id' => isset($postdata['subscr_id']) ? $postdata['subscr_id'] : null);
             WP_User_Frontend::log('payment', 'inserting payment to database. ' . print_r($data, true));
             $transaction_id = wp_strip_all_tags($postdata['txn_id']);
             WPUF_Payment::insert_payment($data, $transaction_id, $is_recurring);
             if ($coupon_id) {
                 $pre_usage = get_post_meta($post_id, '_coupon_used', true);
                 $new_use = $pre_usage + 1;
                 update_post_meta($post_id, '_coupon_used', $coupon_id);
             }
             delete_user_meta($custom->user_id, '_wpuf_user_active');
             delete_user_meta($custom->user_id, '_wpuf_activation_key');
         } else {
             WP_User_Frontend::log('payment', 'inserting payment failed.');
         }
     }
 }