function update_referal_signup($user_id)
{
    try {
        if ($user_id != '-') {
            $user = User::find($user_id);
            if (isset($user->id)) {
                $month = date('m');
                $year = date('Y');
                $referral = Referral::where('user_id', '=', $user_id)->where(DB::raw('month(created_at)'), '=', $month)->where(DB::raw('year(created_at)'), '=', $year)->first();
                if (!isset($referral->id)) {
                    $referral = new Referral();
                    $referral->user_id = $user_id;
                }
                $referral->total_signup = $referral->total_signup + 1;
                if ($referral->proposal_gained <= 30) {
                    $proposal = 5;
                    $referral->proposal_gained = $referral->proposal_gained + $proposal;
                    $account = Account::where('user_id', '=', $user_id)->first();
                    $account->monthly_proposal_limit = $account->monthly_proposal_limit + $proposal;
                    $account->save();
                }
                $referral->save();
            }
        }
    } catch (Exception $e) {
    }
}
    $r->save();
    return View::make('recurly.confirm')->with('response', $response);
});
Route::post('recurly-notification', array('before' => 'postnotification', function () {
    $o = Option::find('1');
    //need to handle
    $post_xml = file_get_contents("php://input");
    $notification = new Recurly_PushNotification($post_xml);
    $raw = new RawNotification();
    $raw->type = $notification->type;
    $raw->xml = $post_xml;
    $raw->save();
    if ($notification->type == 'successful_payment_notification') {
        //check if need to have sent commission event
        if ($notification->transaction->subscription_id != '' && $notification->transaction->subscription_id != null) {
            $r = Referral::where('uuid', '=', $notification->transaction->subscription_id)->first();
            if ($r == null) {
                //save to process later
                $n = new Notification();
                $n->uuid = $notification->transaction->subscription_id;
                $n->revenue = $notification->transaction->amount_in_cents;
                $n->save();
            } else {
                /*$rev = $notification->transaction->amount_in_cents / 100.00;
                		$campaign_id = '';
                		$username = '';
                		$api_key = '';
                		$api_url = "https://getambassador.com/api/v2/$username/$api_key/xml/event/record";
                		$data = array( 
                			'email' => $r->email,
                			'campaign_uid' => $campaign_id,