anchor.diff:      end,
       orders_queue:update_orders().
   
  +make_stripe_cancel_payment(Oid) ->
  +    try
  +        case update_order_for_cancel(Oid) of
  +            ok -> 
  +                [{Order}] = get_order(Oid),
  +                OCost = proplists:get_value(<<"cost">>, Order),
  +                Token = proplists:get_value(<<"token">>, Order),
  +                make_stripe_payment(0, OCost, <<"usd">>, Token, Oid);
  +            nok ->
  +                lager:error("MSCP failed, no stripe payment", []),
  +                {error, <<"no payment">>}
  +        end
  +    catch
  +        throw:price_mismatch -> {error, <<"wrong price">>};
  +        _:R                  -> {error, R}
  +    end.
   make_stripe_payment(Oid) ->
       try
           [{Order}] = get_order(Oid),
  
positive.code:       true ->
          case lists:member(Status, [<<"pending">>, <<"upcoming">>]) of
              true -> 
                  emysql:execute(mysqlpool,<<"update orders set status = 'cancelled' where uid=? and id=?">>,[Uid, Oid]),
                  orders_queue:update_orders()
              ;_   -> {error, non_cancel_status}
          end
        ;_ -> {error, another_user_order} 
  
negative.code:         _:R                  -> {error, R}
      end.
  
  update_order_for_cancel(Oid) ->
  	case emysql:execute(mysqlpool,
              <<"select o.cost, abs(timestampdiff(hour, now(), order_ontime)) ",
              " from orders o where o.id = ?">>, [Oid]) of
  		{result_packet,_,_,[[Amnt, Hrs]],_} when Hrs < 24 -> 
              lager:debug("UOFC < 24 ~p", [Amnt]),
              ok;
  		{result_packet,_,_,[[Amnt, Hrs]],_} when Hrs < 48 -> 
              NAmnt = Amnt div 5,
              Ur = emysql:execute(mysqlpool, <<"update orders set cost=? where id=?">>, [NAmnt, Oid]),
              lager:debug("UOFC < 48 ~p", [{Amnt, NAmnt, Ur}]),
              ok;
  		{result_packet,_,_,[[Amnt, Hrs]],_} when Hrs > 48 ->
              lager:debug("UOFC > 48 ~p", [Amnt]),
              nok
          ;_ -> nok
  	end.
  
  update_order_stripe_token(Orderid, Pid1) ->
      emysql:execute(mysqlpool,<<"update orders set payment_status = 0, payment_id=? where id=?">>,[Pid1, Orderid]).
  
  