Class: Mpp::Receipt
- Inherits:
-
Data
- Object
- Data
- Mpp::Receipt
- Defined in:
- lib/mpp/receipt.rb
Instance Attribute Summary collapse
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#extra ⇒ Object
readonly
Returns the value of attribute extra.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
-
.from_payment_receipt(header) ⇒ Object
Parse a Receipt from a Payment-Receipt header value.
-
.success(reference, timestamp: nil, method: "tempo", external_id: nil) ⇒ Object
Create a success receipt with current timestamp.
Instance Method Summary collapse
-
#initialize(status:, timestamp:, reference:, method: "", external_id: nil, extra: nil) ⇒ Receipt
constructor
A new instance of Receipt.
-
#to_payment_receipt ⇒ Object
Serialize to a Payment-Receipt header value.
Constructor Details
#initialize(status:, timestamp:, reference:, method: "", external_id: nil, extra: nil) ⇒ Receipt
Returns a new instance of Receipt.
6 7 8 |
# File 'lib/mpp/receipt.rb', line 6 def initialize(status:, timestamp:, reference:, method: "", external_id: nil, extra: nil) super end |
Instance Attribute Details
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id
5 6 7 |
# File 'lib/mpp/receipt.rb', line 5 def external_id @external_id end |
#extra ⇒ Object (readonly)
Returns the value of attribute extra
5 6 7 |
# File 'lib/mpp/receipt.rb', line 5 def extra @extra end |
#method ⇒ Object (readonly)
Returns the value of attribute method
5 6 7 |
# File 'lib/mpp/receipt.rb', line 5 def method @method end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference
5 6 7 |
# File 'lib/mpp/receipt.rb', line 5 def reference @reference end |
#status ⇒ Object (readonly)
Returns the value of attribute status
5 6 7 |
# File 'lib/mpp/receipt.rb', line 5 def status @status end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp
5 6 7 |
# File 'lib/mpp/receipt.rb', line 5 def @timestamp end |
Class Method Details
.from_payment_receipt(header) ⇒ Object
Parse a Receipt from a Payment-Receipt header value.
11 12 13 |
# File 'lib/mpp/receipt.rb', line 11 def self.from_payment_receipt(header) Mpp::Parsing.parse_payment_receipt(header) end |
.success(reference, timestamp: nil, method: "tempo", external_id: nil) ⇒ Object
Create a success receipt with current timestamp.
21 22 23 24 25 26 27 28 29 |
# File 'lib/mpp/receipt.rb', line 21 def self.success(reference, timestamp: nil, method: "tempo", external_id: nil) new( status: "success", timestamp: || Time.now.utc, reference: reference, method: method, external_id: external_id ) end |
Instance Method Details
#to_payment_receipt ⇒ Object
Serialize to a Payment-Receipt header value.
16 17 18 |
# File 'lib/mpp/receipt.rb', line 16 def to_payment_receipt Mpp::Parsing.format_payment_receipt(self) end |