Skip to content

Instantly share code, notes, and snippets.

@barockok
Last active December 24, 2015 02:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barockok/6729605 to your computer and use it in GitHub Desktop.
Save barockok/6729605 to your computer and use it in GitHub Desktop.
Sample code for implementation vt-web with activemerchant
merchant_id = 'XXXXXXXXXXXXXXXXXXX'
merchant_hash_key = 'XXXXXXXXXXXXXXXXXXX'
# implemetation for generating form
payment_service_for @order.id, merchant_id, \
merchant_hash_key: merchant_hash_key,
service: :veritrans,
amount: @order.total_amount,
currency: 'IDR',
html: {:id => 'payment-form' , :authenticity_token => false } do |service|
service.cancel_url = "http://example.com/cancel"
service.error_url = "http://example.com/error"
service.return_url = "http://example.com/return"
service.customer first_name: @order.billing_first_name,
last_name: @order.billing_last_name,
address_1: @order.billing_address_1,
address_2: @order.billing_address_2,
city: @order.billing_city,
zip: @order.billing_postal_code,
phone: @order.billing_phone,
country_code: 'IDN',
email: 'zidmubarock@gmail.com'
service.shipping first_name: @order.shipping_first_name,
last_name: @order.shipping_last_name,
address_1: @order.shipping_address_1,
address_2: @order.shipping_address_2,
city: @order.shipping_city,
zip: @order.shipping_postal_code,
phone: @order.shipping_phone,
country_code: 'IDN'
@order.order_items.each do |item|
service.items << {id: item.product_id,
price: item.price,
qty: item.qty,
name: item.product_name}
end
# implemetation for handle notification
@notification = ActiveMerchant::Billing::Integrations::Veritrans::Notification.new request.raw_post \
merchant_id: merchant_id,
mecrhant_hash_key: merchant_hash_key
@order.paid! if @notification.acknowledge
@Paxa
Copy link

Paxa commented Nov 1, 2013

and also I have wrote a snipet how to use it

So how to use it? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment