Class: Rev::Payment
- Inherits:
-
ApiSerializable
- Object
- ApiSerializable
- Rev::Payment
- Defined in:
- lib/rev-api/models/order_request.rb
Overview
Payment Info. Payment can be done either by charging a credit card or by debiting the user’s account balance. If using a credit card, then either the user’s saved credit card can be used or credit card details provided.
For credit card payments, if specifying the credit card details in the request, the required elements are the card number, cardholder name, expiration month and year, and billing zipcode. If using the user’s saved card, you must currently specify the value “1” for the saved card id, as we currently only allow a single card to be saved for a user.
Constant Summary collapse
- TYPES =
use to correctly set payment type
{ :credit_card => 'CreditCard', :balance => 'AccountBalance' }
- CC_ON_FILE_ID =
1
Instance Attribute Summary collapse
-
#credit_card ⇒ Object
Returns the value of attribute credit_card.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .with_account_balance ⇒ Object
- .with_credit_card_on_file ⇒ Object
- .with_saved_credit_card(credit_card) ⇒ Object
Instance Method Summary collapse
-
#initialize(type, credit_card = nil) ⇒ Payment
constructor
A new instance of Payment.
Methods inherited from ApiSerializable
Constructor Details
#initialize(type, credit_card = nil) ⇒ Payment
Returns a new instance of Payment.
57 58 59 60 |
# File 'lib/rev-api/models/order_request.rb', line 57 def initialize(type, credit_card = nil) @type = type @credit_card = credit_card unless credit_card.nil? end |
Instance Attribute Details
#credit_card ⇒ Object
Returns the value of attribute credit_card.
45 46 47 |
# File 'lib/rev-api/models/order_request.rb', line 45 def credit_card @credit_card end |
#type ⇒ Object
Returns the value of attribute type.
45 46 47 |
# File 'lib/rev-api/models/order_request.rb', line 45 def type @type end |
Class Method Details
.with_account_balance ⇒ Object
71 72 73 |
# File 'lib/rev-api/models/order_request.rb', line 71 def with_account_balance() Payment::new(TYPES[:account_balance]) end |
.with_credit_card_on_file ⇒ Object
63 64 65 |
# File 'lib/rev-api/models/order_request.rb', line 63 def with_credit_card_on_file() Payment::new(TYPES[:credit_card], CreditCard.new(:saved_id => CC_ON_FILE_ID)) end |
.with_saved_credit_card(credit_card) ⇒ Object
67 68 69 |
# File 'lib/rev-api/models/order_request.rb', line 67 def with_saved_credit_card(credit_card) Payment::new(TYPES[:credit_card], credit_card) end |