class OffsitePayments::Integrations::Migs::Helper
Public Class Methods
base_url()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 11 def self.base_url 'https://migs.mastercard.com.au/vpcpay' end
new(order, account, options = {})
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 15 def initialize(order, account, options = {}) @credentials = { login: account, password: options.fetch(:password) } @secure_hash = options.fetch(:secure_hash) @options = options.merge(order_id: order) end
Public Instance Methods
credential_based_url()
click to toggle source
Generates a URL to redirect user to MiGS to process payment Once user is finished MiGS will redirect back to specified URL With a response hash which can be turned into a Response object with purchase_offsite_response
Options¶ ↑
-
:order_id
– A reference for tracking the order (REQUIRED) -
:locale
– Change the language of the redirected page Values are 2 digit locale, e.g. en, es -
:return_url
– the URL to return to once the payment is complete -
:card_type
– Providing this skips the card type step. Values are ActiveMerchant formats: e.g. master, visa, american_express, diners_club -
:unique_id
– Unique id of transaction to find. If not supplied one will be generated.
# File lib/offsite_payments/integrations/migs.rb, line 36 def credential_based_url cents = @options.fetch(:cents) builder = TransactionBuilder.new(@credentials) builder.add_invoice(@options) builder.add_creditcard_type(@options[:card_type]) if @options[:card_type] builder.add_amount(cents) builder.add_standard_parameters('pay', @options[:unique_id]) post = builder.post.merge( Locale: @options[:locale] || 'en', ReturnURL: @options.fetch(:return_url) ) post[:SecureHash] = SecureHash.calculate(@secure_hash, post) post[:SecureHashType] = 'SHA256' self.class.base_url + '?' + post_data(post) end
Private Instance Methods
post_data(post)
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 55 def post_data(post) post.collect { |key, value| "vpc_#{key}=#{CGI.escape(value.to_s)}" }.join("&") end