Function Reference: geodir_ipn_handler_googlewallet

Summary

This function has not been documented yet.

Source File

geodir_ipn_handler_googlewallet() is located in geodir_payment_manager/geodir_payment_actions.php [Line: 860]

Source Code

function geodir_ipn_handler_googlewallet()
{
global $wpdb;
require_once  (GEODIR_PAYMENT_MANAGER_PATH.'/googlewallet/JWT.php');
$paymentOpts = get_payment_options('googlechkout');
$merchantkey = $paymentOpts['merchantsecret'];
	$currency_code = geodir_get_currency_type();
	$merchantid = $paymentOpts['merchantid'];
	$merchantkey = $paymentOpts['merchantsecret'];
	
	$encoded_jwt = $_POST['jwt']; 
$decodedJWT = JWT::decode($encoded_jwt, $merchantkey);


	$post_title = $decodedJWT->request->name;
	$payable_amount = $decodedJWT->request->price;
	
	// yes valid recipt
		$p_arr = explode(",", $decodedJWT->request->sellerData);
		$p_arr2 = explode(":", $p_arr[1]);
		
		
		$last_postid = $p_arr2[1];
require_once  (GEODIR_PAYMENT_MANAGER_PATH.'/googlewallet/generate_token.php');
//$encoded_jwt = $_POST['jwt']; 


// get orderId
$orderId = $decodedJWT->response->orderId;

		if( $_POST['jwt']){
				if ($orderId) 
				{		// yes valid recipt
		$p_arr = explode(",", $decodedJWT->request->sellerData);
		$p_arr2 = explode(":", $p_arr[1]);
		
		
		$postid               = $p_arr2[1];
		$item_name			  = $decodedJWT->request->name;
		$txn_id				  = $orderId;
		$payment_status       = 'PAID';
		$payment_type         = 'Google Wallet';
		$payment_date         = date("F j, Y, g:i a");
		$txn_type             = $decodedJWT->typ;
		
		$mc_currency          = $decodedJWT->request->currencyCode; // get curancy code
		$mc_gross             = $decodedJWT->request->price;
		$mc_amount3           = $decodedJWT->request->price;
################################################################################################################################################################################
	global $wpdb;
	$header='';

				// get current post status
				$current_post_status = get_post_status($postid);
				
				$post_pkg = geodir_get_post_meta($postid, 'package_id',true); /* get the post price package ID*/
				
				global $wpdb;
				
				$pricesql = $wpdb->prepare(
											"select * from ".GEODIR_PRICE_TABLE." where status=1 and pid=%d", 
											array($post_pkg)
										);
				
				
				$priceinfo = $wpdb->get_row($pricesql, ARRAY_A); /* Get the price package info*/
				
				$pkg_price = $priceinfo['amount']; /* get the price of the package		*/
				$currency_code = geodir_get_currency_type(); /* get the actual curency code		*/
				$merchantid = $paymentOpts['merchantid']; /* Get the site paypal address*/
				if($mc_gross){$paid_amt = $mc_gross;}else{$paid_amt = $mc_amount3;}
				
				$productinfosql = $wpdb->prepare(
														"select ID,post_title,guid,post_author from $wpdb->posts where ID = %d",
														array($postid) 
													);
				$productinfo = $wpdb->get_results($productinfosql);
				foreach($productinfo as $productinfoObj)
				{
					/*$post_link = home_url().'/?ptype=preview&alook=1&pid='.$postid;*/
					$post_title = ''.$productinfoObj->post_title.''; 
					$aid = $productinfoObj->post_author;
					$userInfo = geodir_get_author_info($aid);
					$to_name = $userInfo->user_nicename;
					$to_email = $userInfo->user_email;
					$user_email = $userInfo->user_email;
				}
				
			
				/*######################################
				######## PAYMENT SUCCESSFUL ##########
				######################################*/
				
				if($txn_type){
					$post_default_status = geodir_new_post_default_status();
					if($post_default_status=='')
					{
						$post_default_status = 'publish';
					}
					geodir_set_post_status($postid,$post_default_status);
					
					$transaction_details ='';
					$paid_amount_with_currency = get_option('geodir_currencysym') .$paid_amt;
					
					$transaction_details .= "--------------------------------------------------
"; $transaction_details .= sprintf(__("Payment Details for Listing ID #%s", GEODIRPAYMENT_TEXTDOMAIN), $postid ) ."
"; $transaction_details .= "--------------------------------------------------
"; $transaction_details .= sprintf(__("Listing Title: %s", GEODIRPAYMENT_TEXTDOMAIN),$item_name)."
"; $transaction_details .= "--------------------------------------------------
"; $transaction_details .= sprintf(__("Trans ID: %s", GEODIRPAYMENT_TEXTDOMAIN), $txn_id)."
"; $transaction_details .= sprintf(__("Status: %s", GEODIRPAYMENT_TEXTDOMAIN), $payment_status)."
"; $transaction_details .= sprintf(__("Amount: %s", GEODIRPAYMENT_TEXTDOMAIN),$paid_amount_with_currency)."
" ; $transaction_details .= sprintf(__("Type: %s", GEODIRPAYMENT_TEXTDOMAIN),$payment_type)."
"; $transaction_details .= sprintf(__("Date: %s", GEODIRPAYMENT_TEXTDOMAIN), $payment_date)."
"; $transaction_details .= sprintf(__(" Method: %s", GEODIRPAYMENT_TEXTDOMAIN), $txn_type)."
"; $transaction_details .= "--------------------------------------------------
"; $transaction_details .= __("Information Submitted URL", GEODIRPAYMENT_TEXTDOMAIN)."
"; $transaction_details .= "--------------------------------------------------
"; $transaction_details .= " $post_title
"; // Extend expire date start $invoice_info = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".INVOICE_TABLE." WHERE post_id = %d AND is_current=%s", array($postid,'1'))); $invoice_id = $invoice_info->id; $invoice_package_id = ''; if (!empty($invoice_info) && isset($invoice_info->package_id) ) { $invoice_package_id = $invoice_info->package_id; $invoice_alive_days = $invoice_info->alive_days; $invoice_status = $invoice_info->status; } $geodir_post_info = geodir_get_post_info($postid); if (!empty($geodir_post_info)) { $post_package_id = $geodir_post_info->package_id; $post_expire_date = $geodir_post_info->expire_date; if (!empty($invoice_package_id) && $invoice_alive_days>0 && $invoice_package_id==$post_package_id && strtolower($post_expire_date)!='never' && strtotime($post_expire_date) >= strtotime(date('Y-m-d')) && $current_post_status=='publish') { $alive_days = (int)($geodir_post_info->alive_days + $invoice_alive_days); $expire_date = date('Y-m-d', strtotime($post_expire_date."+".$invoice_alive_days." days")); } else { $alive_days = (int)$geodir_post_info->alive_days; if (strtolower($post_expire_date)!='never' && strtotime($post_expire_date) < strtotime(date('Y-m-d'))) { $alive_days = $invoice_alive_days; } $expire_date = $alive_days>0 ? date('Y-m-d', strtotime(date('Y-m-d')."+".$alive_days." days")) : 'Never'; } geodir_save_post_meta($postid, 'alive_days', $alive_days); geodir_save_post_meta($postid, 'expire_date', $expire_date); } // Extend expire date start end /*############ SET THE INVOICE STATUS START ############*/ // update invoice statuse and transactio details geodir_update_invoice_status($invoice_id, 'Paid'); geodir_update_invoice_transaction_details($invoice_id, $transaction_details); /*############ SET THE INVOICE STATUS END ############*/ geodir_payment_adminEmail($postid,$aid,'payment_success',$transaction_details); /*email to admin*/ geodir_payment_clientEmail($postid,$aid,'payment_success',$transaction_details); /*email to client*/ } /*###################################### ######## PAYMENT SUCCESSFUL ########## ######################################*/ header("HTTP/1.0 200 OK"); echo $orderId; }else if (strcmp ($res, "INVALID") == 0){ geodir_payment_adminEmail($_POST['custom'],'1','payment_fail'); /* email to admin*/ } } }