module SkroutzPay::Gateways::Mastercard

Public Instance Methods

auth(ccn, expiration_date, cvv2, amount) click to toggle source

Authorizes a payment The auth sequence will approve or not the payment for this credit card but will not make any actual transation.

@param [String] ccn, the credit card number @param [String] expiration date in “mm/yy” format @param [String] cvv2 @param [Integer] amount to preauth in cents

# File lib/skroutz_pay/gateways/mastercard.rb, line 14
def auth(ccn, expiration_date, cvv2, amount)
  request(ccn, expiration_date, cvv2, amount)
end
capture(ccn, expiration_date, cvv2, amount) click to toggle source

Captures a payment by charging actual money

@param [String] ccn, the credit card number @param [String] expiration date in “mm/yy” format @param [String] cvv2 @param [Integer] amount to preauth in euros

# File lib/skroutz_pay/gateways/mastercard.rb, line 24
def capture(ccn, expiration_date, cvv2, amount)
  request(ccn, expiration_date, cvv2, amount, :capture)
end

Private Instance Methods

request(ccn, expiration_date, cvv2, amount, type = :auth) click to toggle source
# File lib/skroutz_pay/gateways/mastercard.rb, line 30
def request(ccn, expiration_date, cvv2, amount, type = :auth)
  if expiration_date !~ /\A[0-1]\d\/\d{2}\Z/
    raise SkroutzPay::InvalidCreditCardData
  end

  if !amount.is_a?(Integer)
    raise SkroutzPay::InvalidChargeAmount
  end

  if type == :auth
    # actual code should be here
    rand(100) % 8 != 0
  else type == :capture
    # actual code should be here
    rand(100) % 8 != 0
  end
end