Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

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
You can’t perform that action at this time.