Class: OffsitePayments::Integrations::Migs::Helper
- Inherits:
-
Helper
- Object
- Helper
- OffsitePayments::Integrations::Migs::Helper
- Defined in:
- lib/offsite_payments/integrations/migs.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#credential_based_url ⇒ Object
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.
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
15 16 17 18 19 |
# File 'lib/offsite_payments/integrations/migs.rb', line 15 def initialize(order, account, = {}) @credentials = { login: account, password: .fetch(:password) } @secure_hash = .fetch(:secure_hash) = .merge(order_id: order) end |
Class Method Details
.base_url ⇒ Object
11 12 13 |
# File 'lib/offsite_payments/integrations/migs.rb', line 11 def self.base_url 'https://migs.mastercard.com.au/vpcpay' end |
Instance Method Details
#credential_based_url ⇒ Object
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.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/offsite_payments/integrations/migs.rb', line 36 def credential_based_url cents = .fetch(:cents) builder = TransactionBuilder.new(@credentials) builder.add_invoice() builder.add_creditcard_type([:card_type]) if [:card_type] builder.add_amount(cents) builder.add_standard_parameters('pay', [:unique_id]) post = builder.post.merge( Locale: [:locale] || 'en', ReturnURL: .fetch(:return_url) ) post[:SecureHash] = SecureHash.calculate(@secure_hash, post) post[:SecureHashType] = 'SHA256' self.class.base_url + '?' + post_data(post) end |