Class: StarkInfra::IssuingAuthorization
- Inherits:
-
Utils::Resource
- Object
- Utils::SubResource
- Utils::Resource
- StarkInfra::IssuingAuthorization
- Defined in:
- lib/issuingauthorization/issuingauthorization.rb
Overview
# IssuingAuthorization object
An IssuingAuthorization presents purchase data to be analysed and answered with an approval or a declination.
## Attributes (return-only):
-
id [string]: unique id returned when the IssuingAuthorization is created. ex: ‘5656565656565656’
-
end_to_end_id [string]: central bank’s unique transaction ID. ex: “E79457883202101262140HHX553UPqeq”
-
amount [integer]: IssuingPurchase value in cents. Minimum = 0. ex: 1234 (= R$ 12.34)
-
tax [integer]: IOF amount taxed for international purchases. ex: 1234 (= R$ 12.34)
-
card_id [string]: unique id returned when IssuingCard is created. ex: “5656565656565656”
-
issuer_amount [integer]: issuer amount. ex: 1234 (= R$ 12.34)
-
issuer_currency_code [string]: issuer currency code. ex: “USD”
-
merchant_amount [integer]: merchant amount. ex: 1234 (= R$ 12.34)
-
merchant_currency_code [string]: merchant currency code. ex: “USD”
-
merchant_category_code [string]: merchant category code. ex: “fastFoodRestaurants”
-
merchant_country_code [string]: merchant country code. ex: “USA”
-
acquirer_id [string]: acquirer ID. ex: “5656565656565656”
-
merchant_id [string]: merchant ID. ex: “5656565656565656”
-
merchant_name [string]: merchant name. ex: “Google Cloud Platform”
-
merchant_fee [integer]: merchant fee charged. ex: 200 (= R$ 2.00)
-
wallet_id [string]: virtual wallet ID. ex: “googlePay”
-
method_code [string]: method code. ex: “chip”, “token”, “server”, “manual”, “magstripe” or “contactless”
-
score [float]: internal score calculated for the authenticity of the purchase. nil in case of insufficient data. ex: 7.6
-
is_partial_allowed [bool]: true if the the merchant allows partial purchases. ex: False
-
purpose [string]: purchase purpose. ex: “purchase”
-
card_tags [list of strings]: tags of the IssuingCard responsible for this purchase. ex: [“travel”, “food”]
-
holder_tags [list of strings]: tags of the IssuingHolder responsible for this purchase. ex: [“technology”, “john snow”]
Instance Attribute Summary collapse
-
#acquirer_id ⇒ Object
readonly
Returns the value of attribute acquirer_id.
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#card_id ⇒ Object
readonly
Returns the value of attribute card_id.
-
#card_tags ⇒ Object
readonly
Returns the value of attribute card_tags.
-
#end_to_end_id ⇒ Object
readonly
Returns the value of attribute end_to_end_id.
-
#holder_tags ⇒ Object
readonly
Returns the value of attribute holder_tags.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_partial_allowed ⇒ Object
readonly
Returns the value of attribute is_partial_allowed.
-
#issuer_amount ⇒ Object
readonly
Returns the value of attribute issuer_amount.
-
#issuer_currency_code ⇒ Object
readonly
Returns the value of attribute issuer_currency_code.
-
#merchant_amount ⇒ Object
readonly
Returns the value of attribute merchant_amount.
-
#merchant_category_code ⇒ Object
readonly
Returns the value of attribute merchant_category_code.
-
#merchant_country_code ⇒ Object
readonly
Returns the value of attribute merchant_country_code.
-
#merchant_currency_code ⇒ Object
readonly
Returns the value of attribute merchant_currency_code.
-
#merchant_fee ⇒ Object
readonly
Returns the value of attribute merchant_fee.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
-
#merchant_name ⇒ Object
readonly
Returns the value of attribute merchant_name.
-
#method_code ⇒ Object
readonly
Returns the value of attribute method_code.
-
#purpose ⇒ Object
readonly
Returns the value of attribute purpose.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#tax ⇒ Object
readonly
Returns the value of attribute tax.
-
#wallet_id ⇒ Object
readonly
Returns the value of attribute wallet_id.
Class Method Summary collapse
-
.parse(content:, signature:, user: nil) ⇒ Object
# Create single IssuingAuthorization from a content string.
- .resource ⇒ Object
-
.response(status:, amount: nil, reason: nil, tags: nil) ⇒ Object
# Helps you respond IssuingAuthorization requests.
Instance Method Summary collapse
-
#initialize(id: nil, end_to_end_id: nil, amount: nil, tax: nil, card_id: nil, issuer_amount: nil, issuer_currency_code: nil, merchant_amount: nil, merchant_currency_code: nil, merchant_category_code: nil, merchant_country_code: nil, acquirer_id: nil, merchant_id: nil, merchant_name: nil, merchant_fee: nil, wallet_id: nil, method_code: nil, score: nil, is_partial_allowed: nil, purpose: nil, card_tags: nil, holder_tags: nil) ⇒ IssuingAuthorization
constructor
A new instance of IssuingAuthorization.
Methods inherited from Utils::SubResource
Constructor Details
#initialize(id: nil, end_to_end_id: nil, amount: nil, tax: nil, card_id: nil, issuer_amount: nil, issuer_currency_code: nil, merchant_amount: nil, merchant_currency_code: nil, merchant_category_code: nil, merchant_country_code: nil, acquirer_id: nil, merchant_id: nil, merchant_name: nil, merchant_fee: nil, wallet_id: nil, method_code: nil, score: nil, is_partial_allowed: nil, purpose: nil, card_tags: nil, holder_tags: nil) ⇒ IssuingAuthorization
Returns a new instance of IssuingAuthorization.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 41 def initialize( id: nil, end_to_end_id: nil, amount: nil, tax: nil, card_id: nil, issuer_amount: nil, issuer_currency_code: nil, merchant_amount: nil, merchant_currency_code: nil, merchant_category_code: nil, merchant_country_code: nil, acquirer_id: nil, merchant_id: nil, merchant_name: nil, merchant_fee: nil, wallet_id: nil, method_code: nil, score: nil, is_partial_allowed: nil, purpose: nil, card_tags: nil, holder_tags: nil ) super(id) @end_to_end_id = end_to_end_id @amount = amount @tax = tax @card_id = card_id @issuer_amount = issuer_amount @issuer_currency_code = issuer_currency_code @merchant_amount = merchant_amount @merchant_currency_code = merchant_currency_code @merchant_category_code = merchant_category_code @merchant_country_code = merchant_country_code @acquirer_id = acquirer_id @merchant_id = merchant_id @merchant_name = merchant_name @merchant_fee = merchant_fee @wallet_id = wallet_id @method_code = method_code @score = score @is_partial_allowed = is_partial_allowed @purpose = purpose @card_tags = @holder_tags = end |
Instance Attribute Details
#acquirer_id ⇒ Object (readonly)
Returns the value of attribute acquirer_id.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def acquirer_id @acquirer_id end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def amount @amount end |
#card_id ⇒ Object (readonly)
Returns the value of attribute card_id.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def card_id @card_id end |
#card_tags ⇒ Object (readonly)
Returns the value of attribute card_tags.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def @card_tags end |
#end_to_end_id ⇒ Object (readonly)
Returns the value of attribute end_to_end_id.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def end_to_end_id @end_to_end_id end |
#holder_tags ⇒ Object (readonly)
Returns the value of attribute holder_tags.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def @holder_tags end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def id @id end |
#is_partial_allowed ⇒ Object (readonly)
Returns the value of attribute is_partial_allowed.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def is_partial_allowed @is_partial_allowed end |
#issuer_amount ⇒ Object (readonly)
Returns the value of attribute issuer_amount.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def issuer_amount @issuer_amount end |
#issuer_currency_code ⇒ Object (readonly)
Returns the value of attribute issuer_currency_code.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def issuer_currency_code @issuer_currency_code end |
#merchant_amount ⇒ Object (readonly)
Returns the value of attribute merchant_amount.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def merchant_amount @merchant_amount end |
#merchant_category_code ⇒ Object (readonly)
Returns the value of attribute merchant_category_code.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def merchant_category_code @merchant_category_code end |
#merchant_country_code ⇒ Object (readonly)
Returns the value of attribute merchant_country_code.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def merchant_country_code @merchant_country_code end |
#merchant_currency_code ⇒ Object (readonly)
Returns the value of attribute merchant_currency_code.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def merchant_currency_code @merchant_currency_code end |
#merchant_fee ⇒ Object (readonly)
Returns the value of attribute merchant_fee.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def merchant_fee @merchant_fee end |
#merchant_id ⇒ Object (readonly)
Returns the value of attribute merchant_id.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def merchant_id @merchant_id end |
#merchant_name ⇒ Object (readonly)
Returns the value of attribute merchant_name.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def merchant_name @merchant_name end |
#method_code ⇒ Object (readonly)
Returns the value of attribute method_code.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def method_code @method_code end |
#purpose ⇒ Object (readonly)
Returns the value of attribute purpose.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def purpose @purpose end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def score @score end |
#tax ⇒ Object (readonly)
Returns the value of attribute tax.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def tax @tax end |
#wallet_id ⇒ Object (readonly)
Returns the value of attribute wallet_id.
37 38 39 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 37 def wallet_id @wallet_id end |
Class Method Details
.parse(content:, signature:, user: nil) ⇒ Object
# Create single IssuingAuthorization from a content string
Create a single IssuingAuthorization object received from IssuingAuthorization at the informed endpoint. If the provided digital signature does not check out with the StarkInfra public key, a StarkInfra.Error.InvalidSignatureError will be raised.
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
IssuingAuthorization object with updated attributes
83 84 85 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 83 def self.parse(content:, signature:, user: nil) StarkInfra::Utils::Parse.parse_and_verify(content: content, signature: signature, user: user, resource: resource) end |
.resource ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 109 def self.resource { resource_name: 'IssuingAuthorization', resource_maker: proc { |json| IssuingAuthorization.new( id: json['id'], end_to_end_id: json['end_to_end_id'], amount: json['amount'], tax: json['tax'], card_id: json['card_id'], issuer_amount: json['issuer_amount'], issuer_currency_code: json['issuer_currency_code'], merchant_amount: json['merchant_amount'], merchant_currency_code: json['merchant_currency_code'], merchant_category_code: json['merchant_category_code'], merchant_country_code: json['merchant_country_code'], acquirer_id: json['acquirer_id'], merchant_id: json['merchant_id'], merchant_name: json['merchant_name'], merchant_fee: json['merchant_fee'], wallet_id: json['wallet_id'], method_code: json['method_code'], score: json['score'], is_partial_allowed: json['is_partial_allowed'], purpose: json['purpose'], card_tags: json['card_tags'], holder_tags: json['holder_tags'] ) } } end |
.response(status:, amount: nil, reason: nil, tags: nil) ⇒ Object
# Helps you respond IssuingAuthorization requests.
## Parameters (required):
-
status [string]: sub-issuer response to the authorization. ex: ‘accepted’ or ‘denied’
## Parameters (optional):
-
amount [integer, default 0]: amount in cents that was authorized. ex: 1234 (= R$ 12.34)
-
reason [string, default ”]: denial reason. ex: ‘other’
-
tags [list of strings, default []]: tags to filter retrieved object. ex: [‘tony’, ‘stark’]
## Return:
-
Dumped JSON string that must be returned to us on the IssuingAuthorization request
99 100 101 102 103 104 105 106 107 |
# File 'lib/issuingauthorization/issuingauthorization.rb', line 99 def self.response(status:, amount: nil, reason: nil, tags: nil) response_hash = { "status": status, "amount": amount || 0, "reason": reason || '', "tags": || [] } response_hash.to_json end |