Class: MercuryPay
Instance Method Summary collapse
-
#charge_with_card(options) ⇒ Object
options = { card_number: 5499990123456781, cvc: 123, expir_month: 8, expir_year: 2016, amount: 5.55, invoice_id: “214dsfav331” }.
-
#charge_with_token(options) ⇒ Object
options = { token: ”, amount: 5.55, invoice_id: “214dsfav331” }.
-
#initialize(merchant_id, password) ⇒ MercuryPay
constructor
A new instance of MercuryPay.
-
#validate_card(options) ⇒ Object
options = { card_number: 5499990123456781, cvc: 123, expir_month: 8, expir_year: 2016 } Response: CmdStatus ::= Approved | Declined | Error.
Constructor Details
#initialize(merchant_id, password) ⇒ MercuryPay
Returns a new instance of MercuryPay.
8 9 10 |
# File 'lib/mercurypay.rb', line 8 def initialize(merchant_id, password) self.class.basic_auth merchant_id, password end |
Instance Method Details
#charge_with_card(options) ⇒ Object
options = { card_number: 5499990123456781, cvc: 123, expir_month: 8, expir_year: 2016,
amount: 5.55,
invoice_id: "214dsfav331"
}
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mercurypay.rb', line 20 def charge_with_card() res = self.class.post("/Sale", body: { :InvoiceNo=> [:invoice_id], :RecordNo=> "RecordNumberRequested", :Frequency=> "OneTime", # OneTime or Recurring :AcctNo=> [:card_number].to_s, :ExpDate=> [:expir_month].to_s.rjust(2, "0")+[:expir_year].to_s[2..3], :Purchase=>[:amount].to_s, :CVVData=> [:cvc].to_s, :OperatorID=> "money2020" }) response = parse_response res end |
#charge_with_token(options) ⇒ Object
options = { token: ”,
amount: 5.55,
invoice_id: "214dsfav331"
}
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mercurypay.rb', line 40 def charge_with_token() res = self.class.post("/SaleByRecordNo", body: { :InvoiceNo=> [:invoice_id], :RecordNo=> [:token], :Frequency=> "OneTime", # OneTime or Recurring :Purchase=>[:amount].to_s, :OperatorID=> "money2020" }) response = parse_response res end |
#validate_card(options) ⇒ Object
options = { card_number: 5499990123456781, cvc: 123, expir_month: 8, expir_year: 2016 } Response: CmdStatus ::= Approved | Declined | Error
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mercurypay.rb', line 59 def validate_card() res = self.class.post("/ZeroAuth", body: { :InvoiceNo=> "1", :RecordNo=> "RecordNumberRequested", :Frequency=> "OneTime", # OneTime or Recurring :AcctNo=> [:card_number].to_s, :ExpDate=> [:expir_month].to_s.rjust(2, "0")+[:expir_year].to_s[2..3], # "Purchase":"1.00", :CVVData=> [:cvc].to_s, :OperatorID=> "money2020" }) response = parse_response res end |