/** * Send to Success Page * * Handles to return success page url * * @package Social Deals Engine * @since 1.0.0 */ function wps_deals_send_on_success_page($queryarg = array()) { $options = wps_deals_get_settings(); //get url of thank you page $sendsuccess = wps_deals_checkout_thank_you_url(); //check user is logged in or not if user is not logged in then unset order_id if (!is_user_logged_in() && isset($queryarg['order_id'])) { unset($queryarg['order_id']); } //success page url $sendsuccessurl = add_query_arg($queryarg, $sendsuccess); wp_redirect(apply_filters('wps_deals_success_page_redirect', $sendsuccessurl, $queryarg)); exit; }
<td><?php echo $orderddate; ?> </td> <td><?php echo $payment_status; ?> </td> <td><?php echo $ordertotal; ?> </td> <?php //order view page url $order_query = wps_deals_checkout_thank_you_url(); $order_query = add_query_arg(array('order_id' => $order['ID']), $order_query); ?> <td><a href="<?php echo $order_query; ?> " title="<?php _e('View Details', 'wpsdeals'); ?> "><?php _e('View Details', 'wpsdeals'); ?> </a></td> <?php
/** * Payment Paypal * * Handles functionalities about payment * all gateways * * @package Social Deals Engine * @since 1.0.0 */ function wps_deals_process_payment_paypal($cartdetails, $postdata) { global $wps_deals_paypal, $wps_deals_price, $wps_deals_options, $wps_deals_currency, $wps_deals_model; //price class $price = $wps_deals_price; //model class $model = $wps_deals_model; //paypal class $paypal = $wps_deals_paypal; //currency class $currency = $wps_deals_currency; //get payment gateways //$paymentgateways = wps_deals_get_payment_gateways(); //payment method //$method = isset( $postdata['wps_deals_payment_gateways'] ) ? $postdata['wps_deals_payment_gateways'] : 'paypal'; $purchasedata = array(); $purchasedata['user_info'] = array('first_name' => $postdata['wps_deals_cart_user_first_name'], 'last_name' => $postdata['wps_deals_cart_user_last_name'], 'user_name' => $postdata['user_name'], 'user_email' => $postdata['wps_deals_cart_user_email']); //$purchasedata['payment_method'] = $method; //$purchasedata['admin_label'] = $paymentgateways[$method]['admin_label']; //$purchasedata['checkout_label'] = $paymentgateways[$method]['checkout_label']; $purchasedata['post_data'] = $postdata; $purchasedata['cartdata'] = $cartdetails; $payment_status['payment_status'] = '0'; $salesid = wps_deals_insert_payment_data($purchasedata); $cancelurl = wps_deals_checkout_cancel_url(); $thankyouurl = wps_deals_checkout_thank_you_url(); //$cancelurl = isset($wps_deals_options['payment_cancel_page']) ? get_permalink($wps_deals_options['payment_cancel_page']) : ''; //$thankyouurl = isset($wps_deals_options['payment_thankyou_page']) ? get_permalink($wps_deals_options['payment_thankyou_page']) : ''; $cancelurl = add_query_arg(array('wps_deals_cancel_order' => '1', 'order_id' => $salesid), $cancelurl); $thankyouargs = array(); //check user is logged in or not if (is_user_logged_in()) { $thankyouargs['order_id'] = $salesid; } $thankyouurl = add_query_arg($thankyouargs, $thankyouurl); if (!empty($salesid)) { //get order deals $orderdetailsall = $model->wps_deals_get_post_meta_ordered($salesid); $orderdetails = $orderdetailsall['deals_details']; //get the merchant id from settings page $merchantid = $wps_deals_options['paypal_merchant_email']; //make notify url when payapl ipn is going to validate //$notifyurl = add_query_arg(array( 'dealslistner' => 'paypalipn','order_id' => $salesid),home_url()); $notifyurl = trailingslashit(home_url()) . '?dealslistner=paypalipn'; $paypal->add_field('business', $merchantid); $paypal->add_field('return', $thankyouurl); $paypal->add_field('cancel_return', $cancelurl); $paypal->add_field('notify_url', $notifyurl); $paypal->add_field('first_name', $purchasedata['user_info']['first_name']); $paypal->add_field('last_name', $purchasedata['user_info']['last_name']); $paypal->add_field('currency_code', $wps_deals_options['currency']); $paypal->add_field('cmd', '_ext-enter'); // $paypal->add_field('custom', $salesid); // $paypal->add_field('rm', '2'); $paypal->add_field('redirect_cmd', '_cart'); $paypal->add_field('upload', count($orderdetails)); $i = 1; //made proper data format for sending into paypal foreach ($orderdetails as $order) { $dealid = $order['deal_id']; //get deal title $dealtitle = get_the_title($order['deal_id']); //append item name to string which will send into paypal //$item_name .= $dealtitle.','; $item_name = $dealtitle; //get deal price $dealprice = $order['deal_sale_price']; //get deal quantity $dealqty = $order['deal_quantity']; $paypal->add_field('item_name_' . $i, $item_name); $paypal->add_field('amount_' . $i, $dealprice); $paypal->add_field('quantity_' . $i, $dealqty); $i++; } //do action to add field to paypal form do_action('wps_deals_add_paypal_field', $salesid); //add fee amount to paypal $discounted_amount = 0.0; //check fees is set or not in order meta if (isset($orderdetailsall['fees']) && !empty($orderdetailsall['fees'])) { $i = empty($i) ? 1 : $i; foreach ($orderdetailsall['fees'] as $fee_val) { //check fees amount is greated then 0 if (floatval($fee_val['amount']) > '0') { // this is a positive fee $paypal->add_field('item_name_' . $i, $fee_val['label']); $paypal->add_field('quantity_' . $i, '1'); $paypal->add_field('amount_' . $i, $fee_val['amount']); $i++; } else { // This is a negative fee (discount) $discounted_amount += abs($fee_val['amount']); } //end else } //end foreach loop } //end if $discount_count = '0'; //check discounted amount should not empty then add discount amount as per fees if (!empty($discounted_amount)) { $discount_count = '1'; //initial discount count $paypal->add_field('discount_amount_' . $discount_count, $discounted_amount); } //end if to check discount amount //do action to add discount field into paypal fields do_action('wps_deals_paypal_disocunt_field', $discount_count, $salesid); //empty cart wps_deals_empty_cart(); // submit the fields to paypal $paypal->submit_paypal_post(); exit; } else { //return to checkout page wps_deals_send_on_checkout_page(); } }