Example #1
0
 function onTP_Processpayment($data, $vars)
 {
     /*NOTE : for onsite payment the code for sending data to payment gateway via cURL or any other method will come here*/
     $isValid = true;
     $error = array();
     $error['code'] = '';
     $error['desc'] = '';
     $trxnstatus = '';
     $verify = plgPaymentBlankHelper::validateIPN($data);
     /*verification of IPN*/
     if (!$verify) {
         return false;
     }
     //3.compare response order id and send order id in notify URL
     $res_orderid = '';
     /* // SAMPLE CODE
     		 $res_orderid = $result->InvoiceReference; // THIS SHOULD BE RESPONSE ORDERID
     		if($isValid ) {
     		if(!empty($vars) && $res_orderid != $vars->order_id )
     			{
     				$trxnstatus = 'ERROR';
     				$isValid = false;
     				$error['desc'] = "ORDER_MISMATCH " . " Invalid ORDERID; notify order_is ". $vars->order_id .", and response ".$res_orderid;
     			}
     		}*/
     // SAMPLE CODE TO CHECK RESPONSE AMOUNT AND ORIGINAL AMOUNT
     /*if($isValid ) {
     			if(!empty($vars))
     			{
     				// Check that the amount is correct
     				$order_amount=(float) $vars->amount; 
     				$retrunamount =  (float)$gross_amt; //RESPONSE AMOUNT
     				$epsilon = 0.01;
     				
     				if(($order_amount - $retrunamount) > $epsilon)
     				{
     					$trxnstatus = 'ERROR';  // change response status to ERROR FOR AMOUNT ONLY
     					$isValid = false;
     					$error['desc'] = "ORDER_AMOUNT_MISTMATCH - order amount= ".$order_amount . ' response order amount = '.$retrunamount;
     				}
     			}
     		}*/
     /*translate the status response depending upon you payment gateway*/
     $payment_status = '';
     // Translaet Payment status
     if ($trxnstatus == 'ERROR') {
         $payment_status = $this->translateResponse($trxnstatus);
     } else {
         $payment_status = $this->translateResponse($data['payment_status']);
     }
     $result = array('order_id' => $data['custom'], 'transaction_id' => $data['txn_id'], 'buyer_email' => $data['payer_email'], 'status' => $payment_status, 'subscribe_id' => $data['subscr_id'], 'txn_type' => $data['txn_type'], 'total_paid_amt' => $data['mc_gross'], 'raw_data' => $data, 'error' => $error);
     return $result;
 }