Last active
August 29, 2015 14:03
-
-
Save UsinaSites/45e96e84b489bdd29dfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cart_controller.rb | |
def paymentcheckout | |
@value = "version=2<LF>cdr=0<LF>" | |
if params['MAC'] | |
oTpe = CMCIC_Tpe.new("FR", checkout_cart_url("fr", 4)) | |
oHmac = CMCIC_Hmac.new(oTpe) | |
sChaineMAC = [oTpe.sNumero, params["date"], params['montant'], params['reference'], params['texte-libre'], oTpe.sVersion, params['code-retour'], params['cvx'], params['vld'], params['brand'], params['status3ds'], params['numauto'], params['motifrefus'], params['originecb'], params['bincb'], params['hpancb'], params['ipclient'], params['originetr'], params['veres'], params['pares']].join('*') + "*"; | |
if oHmac.isValidHmac?(sChaineMAC, params['MAC']) | |
case params['code-retour'] | |
when "Annulation" | |
when "payetest" | |
User.find(params['reference'].split("-")[1].to_i).checkout(1) | |
@value = "version=2<LF>cdr=1<LF>" | |
when "paiement" | |
User.find(params['reference'].split("-")[1].to_i).checkout(1) | |
@value = "version=2<LF>cdr=1<LF>" | |
end | |
sResult = "0" | |
else | |
sResult = "1\n" + sChaineMAC | |
end | |
end | |
render :text => @value | |
end | |
# routes.rb | |
resources :cart do | |
post :paymentcheckout, on: :collection | |
get :paymentcheckout, on: :collection | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment