-
-
Save zhiyao/4187119 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
# config/environment.rb | |
config.gem "bitfluent-activemerchant", :lib => "activemerchant" |
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
# config/initializers/ipay88.rb | |
ActiveMerchant::Billing::Integrations::Ipay88.merchant_key = "t6mqZRi6UB" | |
require 'active_merchant/billing/integrations/action_view_helper' | |
ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper) |
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
# app/controllers/orders_controller.rb | |
class OrdersController < ApplicationController | |
def pay | |
@order = Order.find(params[:id]) | |
end | |
def return | |
ret = ActiveMerchant::Billing::Integrations::Ipay88.return(request.raw_post) | |
if ret.success? | |
@order = Order.find(ret.order) | |
@order.capture!(:amount => ret.amount) | |
flash[:notice] = "Thanks for the payment!" | |
else | |
flash[:error] = "Payment was unsuccessful: #{ret.error}" | |
end | |
end | |
end |
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
<form action="https://www.mobile88.com/epayment/entry.asp" method="post"> | |
<input id="RefNo" name="RefNo" type="hidden" value="1" /> | |
<input id="UserContact" name="UserContact" type="hidden" value="0128888888" /> | |
<input id="UserName" name="UserName" type="hidden" value="Kamal" /> | |
<input id="Signature" name="Signature" type="hidden" value="dpBSyeFdjmlLug36ao1HsIwNoW0=" /> | |
<input id="UserEmail" name="UserEmail" type="hidden" value="[email protected]" /> | |
<input id="Amount" name="Amount" type="hidden" value="10.00" /> | |
<input id="ProdDesc" name="ProdDesc" type="hidden" value="Bioshock 2 and Portal" /> | |
<input id="Currency" name="Currency" type="hidden" value="MYR" /> | |
<input id="MerchantCode" name="MerchantCode" type="hidden" value="YOUR-IPAY88-MERCHANT-CODE" /> | |
</form> |
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
<% payment_service_for @order.id, 'YOUR-IPAY88-MERCHANT-CODE', | |
:amount => @order.total, | |
:currency => 'MYR', | |
:service => :ipay88 do |service| %> | |
<% service.customer :name => @order.customer_name, | |
:email => @order.customer_email, | |
:phone => @order.customer_phone %> | |
<% service.description @order.items.to_sentence %> | |
<% end %> |
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
# config/routes.rb | |
ActionController::Routing::Routes.draw do |map| | |
map.resources :orders, :member => { :pay => :get }, :collection => { :return => :post } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment