module SkroutzPay::Gateways::AmericanExpress

Public Instance Methods

authorize(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 [Date] expiration date @param [String] cvv2 @param [Integer] amount to preauth in cents

# File lib/skroutz_pay/gateways/american_express.rb, line 14
def authorize(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 [Date] expiration date @param [String] cvv2 @param [Integer] amount to preauth in euros

# File lib/skroutz_pay/gateways/american_express.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/american_express.rb, line 30
def request(ccn, expiration_date, cvv2, amount, type = :auth)
  if expiration_date < Date.today
    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