Skip to content

Instantly share code, notes, and snippets.

@sparkandy
Created February 26, 2015 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sparkandy/f9da1ee8ab84c521f9e0 to your computer and use it in GitHub Desktop.
Save sparkandy/f9da1ee8ab84c521f9e0 to your computer and use it in GitHub Desktop.
ROUTES
*******************************
Route::get('subscription/{package_id}', ['as' => 'subscribe', 'uses' =>'SubscriptionController@getPackageid']);
Route::post('subscription', 'SubscriptionController@doSubscription');
Route::get('merchantaccount', 'MerchantsController@merchantdetail');
Route::get('acctype', 'MerchantsController@showAcctype');
//Route::get('payment', 'SubscriptionController@showPayment');
Route::get('payment/{transaction_id}', ['as' => 'payment', 'uses' =>'SubscriptionController@showPayment']);
Route::get('paymentcomplete/{transaction_id}', ['as' => 'paymentcomplete', 'uses' =>'SubscriptionController@dopaymentComplete']);
public function dopaymentComplete ($transaction_id){
//dd($transaction_id);
$mertid = '1553';
$type = "";
$response = getStatus($transaction_id,$mertid,$type);
//dd($response);
//echo $transref;
//dd($transaction_id);
//dd($res);
$trancDetails = DB::table('subscriptions')
->where('transaction_id', '=', $transaction_id)
->first();
$packageDetails = DB::table('packages')
//->join('packages', 'packages.package_id', '=', 'subscriptions.package_id')
->where('package_id', '=', $trancDetails->package_id)
->first();
if ($packageDetails->price != 0) {
$response = strip_tags(preg_replace('#(<title.*?>).*?(</title>)#', '$1$2', $response));
$ref = explode('-', $response);
$res = $ref [1];
} else {
$res = 'C03';
}
$start_date=date("d/m/Y");
$end_date = date("d/m/Y", strtotime(+$trancDetails->duration."month"));
//dd($res);
//dd($trancDetails->duration);
//dd($trancDetails->merchant_id);
//dd($end_date);
$updated = DB::table('subscriptions')
->where('transaction_id', $transaction_id)
->update(array('transaction_status' => $res, 'start_date'=>$start_date, 'end_date'=>$end_date));
//dd($updated);
$details = DB::table('subscriptions')
->join('packages', 'packages.package_id', '=', 'subscriptions.package_id')
->join('merchants', 'merchants.merchant_id', '=', 'subscriptions.merchant_id')
->join('users', 'users.user_id', '=', 'merchants.user_id')
->where('transaction_id', $transaction_id)
->first();
//dd($details);
/*
$fromEmail = 'info@martwire.com';
$fromName = 'Martwire';
$subject = 'Welcome to Martwire';
//$data = Input::get('message');
$total = $details->price * $details->duration;
$data = array( 'lastName' => $details->lastName, 'package_name' => $details->package_name, 'price' => $details->price, 'duration' => $details->duration, 'total' => $total, 'description' => $details->description, 'transaction_status' => $details->transaction_status);
//$toEmail = Input::get('email');
//$toName = Input::get('firstname')." ".Input::get('lastname');
$toEmail = $details->email;
$toName = $details->firstName." ".$details->lastName;
Mail::send('emails.subscriptiondetails', $data, function($message) use ($toEmail, $toName, $fromEmail, $fromName, $subject){
$message->to($toEmail, $toName);
$message->from($fromEmail, $fromName);
$message->subject($subject);
});*/
$title = 'Transaction Status - Martwire';
//$categories_menu = getMenu_cart ();
return View::make('paymentcomplete')->with(array('title' => $title, 'res' => $res));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment