public function postTransfer() { $email = Input::get('number'); $amounttosend = Input::get('amount'); $transaction_id = str_random(10); $transaction = new IcePayTransaction(); $transaction->user_id = Auth::user()->id; $transaction->tid = $transaction_id; $transaction->sender_email = Auth::user()->email; $transaction->receiver_email = $email; $transaction->type = 'MM_TRANSFER'; $transaction->status = 'pending'; $transaction->amount = $amounttosend; $transaction->currency = 'XAF'; $transaction->save(); return Redirect::route('dashboard')->with('alertMessage', 'Transaction Successful'); }
/** * manage confirm requests from EWAY API server */ public function confirmPayment() { $response = $this->client->queryTransaction(Input::get('AccessCode')); $transactionResponse = $response->Transactions[0]; if ($transactionResponse->TransactionStatus) { //echo 'Payment successful! ID: '.$transactionResponse->TransactionID; /* echo $transactionResponse->Options[0]['Value'].' <br/>'; echo $transactionResponse->Options[1]['Value'].' <br/>'; echo $transactionResponse->Options[2]['Value']; */ $transaction = new IcePayTransaction(); $transaction->user_id = Auth::user()->id; $transaction->tid = $transactionResponse->TransactionID; //transaction id or transaction bordereaux $transaction->sender_email = Auth::user()->email; //$payer['email']; //sender's email $transaction->receiver_email = $transactionResponse->Options[1]['Value']; //receiver's email or number $transaction->type = 'EWAY_' . $transactionResponse->Options[0]['Value']; $transaction->status = 'pending'; //$transaction_json['related_resources'][0]['sale']['state']; $transaction->amount = $transactionResponse->TotalAmount / 100; //total amount deducted and transferred $transaction->currency = $transactionResponse->Options[2]['Value']; $transaction->save(); $email = Auth::user()->email; //$payer['email']; $username = Auth::user()->username; Mail::send(['html' => 'emails.auth.transactions'], array('tdate' => date('Y-m-d H:i:s'), 'tid' => $transactionResponse->TransactionID, 'sender_email' => Auth::user()->email, 'sender_number' => Auth::user()->number, 'receiver_email' => $transaction->receiver_email, 'receiver_number' => $transaction->receiver_email, 'status' => 'PENDING', 'amount' => $transaction->amount - $transactionResponse->Options[3]['Value'] . ' ' . $transaction->currency, 'charge' => $transactionResponse->Options[3]['Value'] . ' ' . $transaction->currency, 'total' => $transaction->amount . ' ' . $transaction->currency, 'mode' => $transaction->type), function ($message) use($email, $username) { $message->to(array($email, '*****@*****.**', '*****@*****.**', '*****@*****.**'), $username)->subject('Transaction Receipt'); }); return Redirect::route('dashboard')->with('alertMessage', 'EWAY Transaction Successful'); } else { $errors = str_split($transactionResponse->ResponseMessage); //previously splitte the string at the ', ' points foreach ($errors as $error) { $errmsg .= "Payment failed: " . \Eway\Rapid::getMessage($error) . "<br>"; } return Redirect::route('dashboard')->with('alertError', $errmsg); } }
/** * Manage confirm requests from STP API server * Confirm payment was actually made and effective. * Notify platform admin to proceed with payment to the receiver from the appropriate platform */ public function confirmPayment() { $payment = array('stp_transact_status' => Input::get('merchantAccount'), 'date' => Input::get('date'), 'amount' => Input::get('amount'), 'member' => Input::get('member'), 'item_id' => Input::get('item_id'), 'email' => Input::get('email'), 'memo' => Input::get('memo'), 'tr_id' => Input::get('tr_id'), 'receiver' => Input::get('user1'), 'provider' => Input::get('user2')); print_r($payment); //transaction verification and authentication scheme $secondary_password = '******'; $secondary_password = md5($secondary_password . 's+E_a*'); //encryption for db $hash_received = MD5($_POST['tr_id'] . ":" . MD5($secondary_password) . ":" . $_POST['amount'] . "\n :" . $_POST['merchantAccount'] . ":" . $_POST['payerAccount']); if ($hash_received == $_POST['hash']) { // valid payment $transaction = new IcePayTransaction(); $transaction->user_id = Auth::user()->id; $transaction->tid = $payment['tr_id']; //transaction id or transaction bordereaux $transaction->sender_email = Auth::user()->email; //$payer['email']; //sender's email $transaction->receiver_email = $payment['receiver']; //receiver's email or number $transaction->type = 'STP to ' . $payment['provider']; $transaction->status = 'pending'; //$transaction_json['related_resources'][0]['sale']['state']; $transaction->amount = $payment['amount']; //total amount deducted and transferred $transaction->currency = ''; $transaction->save(); Mail::send(['html' => 'emails.auth.transactionemail'], array('tdate' => $payment['date'], 'tid' => $payment['tr_id'], 'sender_email' => Auth::user()->email, 'sender_number' => Auth::user()->number, 'receiver_email' => 'TEST', 'receiver_number' => $payment['receiver'], 'status' => 'PENDING', 'amount' => $payment['amount'], 'charge' => '0.0 USD', 'total' => $payment['amount'] . ' ', 'mode' => 'STP to ' . $payment['provider']), function ($message) use($email, $username) { $message->to($email, $username)->subject('Transaction Receipt'); }); return Redirect::route('dashboard')->with('alertMessage', 'STP Transaction successful'); } else { // invalid payment; the payment has been altered return Redirect::route('dashboard')->with('alertError', 'Invalid Payment. The payment may have been altered. Please try again'); } }
/** * Make a MM payment to the destined user from the main business account. * @return void */ public function requestPayment() { //parameters fetched from ajax request $AccountID = 4420274; $Phonenumber = Input::get('to'); //number of the person who initiated the request $Amount = Input::get('amount'); //amount to charge the sender $destination = Input::get('receivercontact'); //other address of the receiver $dest_provider = Input::get('provider'); //provider platform to send the funds in $currency = Input::get('currency'); //currency to use $sendto = Input::get('receiver'); //funds are sent to this user $initAmount = $Amount; $Amount = (int) $Amount + 2 / 100 * $Amount; $mes_donnees = array('MyAccountID' => $AccountID, 'CustomerPhonenumber' => $Phonenumber, 'Amount' => $Amount); $postdata = http_build_query($mes_donnees); $url = 'http://api.furthermarket.com/FM/MTN/MoMo/requestpayment?'; //make request and fetch result $ch = curl_init(); // Initiate curl curl_setopt($ch, CURLOPT_TIMEOUT, 300); //timeout in seconds (300) // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); // curl_setopt($ch, CURLOPT_POST, 1); // curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); // curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml','Content-Length:'.strlen($url.$postdata))); curl_setopt($ch, CURLOPT_HEADER, 0); //TRUE to include the header in the output. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); //0 = wait indefinitely while trying to connect curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Will return the response, if false it print the response curl_setopt($ch, CURLOPT_URL, $url . $postdata); // Set the url $result = curl_exec($ch); // Execute $httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curl_errno = curl_errno($ch); /* $opts = array('http' => array( 'method' => 'GET', 'header' => 'Content-type: text/xml', 'CharSet' => 'utf-8', 'content' => $postdata ) ); $context = stream_context_create($opts); $UssdResult = file_get_contents('http://api.furthermarket.com/FM/MTN/MoMo/requestpayment?MyaccountID='.$AccountID .'&CustomerPhonenumber='.$Phonenumber .'&Amount='.$Amount .'&ItemDesignation=MoMoPayment&ItemDescription=SendMomoto_'.$dest_provider.'_user', 1, $context); header('Content-Type:text/javascript'); */ //process the result here $params = explode(',', $result, 3); //[0] = 1 or 0, [1] = payment id, [2] = message for success //create amount to send to user provider in USD $montant = new PlatformCharges($initAmount, 'XAF', $dest_provider); if ($params[0] == 1 && isset($params[2])) { //verify for successful transaction and save to db and email receipt $transaction = new IcePayTransaction(); $transaction->user_id = Auth::user()->id; $transaction->tid = $params[1]; //transaction id or transaction bordereaux $transaction->sender_email = Auth::user()->email; //sender's email $transaction->receiver_email = $sendto; //receiver's email or number) $transaction->type = 'MOMO_TO_' . $dest_provider; $transaction->status = 'pending'; $transaction->amount = $Amount; //total amount deducted and transferred. The amount to be transfered to the receiver is initial $amount without our charges(2%) applied. $transaction->currency = $currency; $transaction->save(); $email = Auth::user()->email; // $username = Auth::user()->username; //send transaction email to sender confirming transactions in a professional way. send copy to company(Paygray) Mail::send(['html' => 'emails.auth.transactions'], array('tdate' => date('Y-m-d H:i:s'), 'tid' => $result->getId(), 'sender_email' => Auth::user()->email, 'sender_number' => Auth::user()->number, 'receiver_email' => $sendto, 'receiver_number' => $destination, 'status' => 'PENDING', 'amount' => $initAmount, 'charge' => '2% of ' . $initAmount . ' in ' . $currency, 'total' => $montant->getDueAmount('mm', $dest_provider), 'mode' => $result->getPayer()->getPayerInfo()->getLastName()), function ($message) use($email, $username) { $message->to(array($email, '*****@*****.**', '*****@*****.**'), $username)->subject('Transaction Receipt - Incoming'); }); echo json_encode(array('paymentresult' => $result, 'message' => 'Transaction successful', 'error_no' => $curl_errno)); } else { echo json_encode(array('paymentresult' => $result, 'message' => 'Transaction failed', 'error_no' => $curl_errno)); } }
public function postTransfer() { $email = Input::get('email'); $amounttosend = Input::get('amount'); $transaction_id = str_random(10); $add = 'FCFA'; $transaction = new IcePayTransaction(); $transaction->user_id = Auth::user()->id; $transaction->tid = $transaction_id; $transaction->sender_email = User::find(Auth::user()->id)->number; $transaction->receiver_email = $email; $transaction->type = 'MM_TRANSFER'; $transaction->status = 'completed'; $transaction->amount = $amounttosend . $add; $transaction->save(); return Redirect::route('dashboard')->with('alertMessage', 'Transaction Successful'); }
public function ppconfirm() { echo 'Transaction confirmed'; // Get the payment ID before session clear $payment_id = Session::get('paypal_payment_id'); // clear the session payment ID Session::forget('paypal_payment_id'); // Get the Payer id and token $payer_id = Input::get('PayerID'); $token = Input::get('token'); // If any of the two is empty, payment was not made if (empty($payer_id) || empty($token)) { return Redirect::route('home')->with('alertError', 'Paypal Transaction aborted'); } if ($payment_id == null) { return Redirect::route('home')->with('alertError', 'Transaction Cancelled'); } $payment = Payment::get($payment_id, $this->_api_context); // PaymentExecution object includes information necessary // to execute a PayPal account payment. // The payer_id is added to the request query parameters // when the user is redirected from paypal back to your site $execution = new PaymentExecution(); $execution->setPayerId(Input::get('PayerID')); //Execute the payment $result = $payment->execute($execution, $this->_api_context); $transaction_json = json_decode($result->getTransactions()[0], TRUE); //get Payer details $payer['email'] = $result->getPayer()->getPayerInfo()->getEmail(); $payer['phone'] = $result->getPayer()->getPayerInfo()->getPhone(); $payer['name'] = $result->getPayer()->getPayerInfo()->getFirstName() . $result->getPayer()->getPayerInfo()->getLastName() . $result->getPayer()->getPayerInfo()->getMiddleName(); //retrieve transaction destination user NOT our business account, set before transaction request was sent to paypal $transaction = new IcePayTransaction(); $transaction->user_id = Auth::user()->id; $transaction->tid = $result->getId(); //transaction id or transaction bordereaux $transaction->sender_email = Auth::user()->email; //$payer['email']; //sender's email $transaction->receiver_email = Session::get('destination'); //receiver's email or number) $transaction->type = 'PAYPAL_TO_' . Session::get('destProvider') . '_' . $transaction_json['related_resources'][0]['sale']['payment_mode']; $transaction->status = 'pending'; //$transaction_json['related_resources'][0]['sale']['state']; $transaction->amount = $transaction_json['amount']['total']; //total amount deducted and transferred $transaction->currency = $transaction_json['amount']['currency']; $transaction->save(); $email = Auth::user()->email; //$payer['email']; $username = Auth::user()->username; //send transaction email to sender confirming transactions in a much professional way. Mail::send(['html' => 'emails.auth.transactionemail'], array('tdate' => date('Y-m-d H:i:s'), 'tid' => $result->getId(), 'sender_email' => Auth::user()->email, 'sender_number' => Auth::user()->number, 'receiver_email' => $result->getPayer()->getPayerInfo()->getFirstName(), 'receiver_number' => $result->getPayer()->getPayerInfo()->getFirstName(), 'status' => 'PENDING', 'amount' => $transaction_json['amount']['total'] - 0.5 . ' ' . $transaction_json['amount']['currency'], 'charge' => '0.5 ' . $transaction_json['amount']['currency'], 'total' => $transaction_json['amount']['total'] . ' ' . $transaction_json['amount']['currency'], 'mode' => $result->getPayer()->getPayerInfo()->getLastName()), function ($message) use($email, $username) { $message->to(array($email, '*****@*****.**'), $username)->subject('Transaction Receipt'); }); return Redirect::route('dashboard')->with('alertMessage', 'Transaction Successful'); if ($result->getState() == 'approved') { // payment made return Redirect::route('original.route')->with('success', 'Payment successful'); } return "Error!!!"; }