Skip to content

Commit

Permalink
update app controller use default price for each pay call like SDK de…
Browse files Browse the repository at this point in the history
…fault
  • Loading branch information
dgobaud committed Apr 16, 2018
1 parent fe7e3bb commit 402df8a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/controllers/app_controller.rb
@@ -1,12 +1,15 @@
class AppController < ApplicationController
skip_before_action :verify_authenticity_token, :only => [:pay]

ROUND_PRICE = 5

# GET /
# User opens the application passing in the token variable.
def index
# User has opened application page directly
return render plain: "Visit https://store.mobius.network to register in DApp Store" unless app
# User has opened application page without a token
return render plain: "Visit https://store.mobius.network to register in the DApp Store" unless app

# User has not granted his account access to this application, "Visit store.mobius.wallet and allow"
# User has not granted access to his MOBI account so we can't use it for payments
return render plain: "Visit https://store.mobius.network and open our app" unless app.authorized?

redirect_to "/flappy_bird/index.html?token=#{token_s}"
Expand All @@ -19,7 +22,7 @@ def balance

# POST /pay
def pay
app.pay(params[:num_tokens])
app.pay(ROUND_PRICE)
render plain: app.balance
rescue Mobius::Client::Error::InsufficientFunds
render :gone
Expand All @@ -43,4 +46,4 @@ def app
token.public_key # Current user
)
end
end
end

0 comments on commit 402df8a

Please sign in to comment.