Class: Kakeibo
- Inherits:
-
Object
- Object
- Kakeibo
- Defined in:
- lib/kakeibo.rb,
lib/kakeibo/error.rb,
lib/kakeibo/client.rb,
lib/kakeibo/client/iab.rb,
lib/kakeibo/client/iap.rb,
lib/kakeibo/client/base.rb,
lib/kakeibo/client/receipt/iab.rb,
lib/kakeibo/client/receipt/iap.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#receipt ⇒ Object
readonly
Returns the value of attribute receipt.
Instance Method Summary collapse
- #error ⇒ Object
-
#fetch(data, option = {}) ⇒ Object
option For IAP :transaction_id -> SKPaymentTransaction#transactionIdentifier OPTIONAL For IAB :signature => included IAB response REQUIRED :base64_encoded_public_key => license key REQUIRED :developer_payload => developer payload OPTIONAL.
-
#initialize(platform, retry_count: 1, logger: nil) ⇒ Kakeibo
constructor
A new instance of Kakeibo.
- #valid? ⇒ Boolean
Constructor Details
#initialize(platform, retry_count: 1, logger: nil) ⇒ Kakeibo
Returns a new instance of Kakeibo.
7 8 9 10 11 12 |
# File 'lib/kakeibo.rb', line 7 def initialize(platform, retry_count: 1, logger: nil) @platform = platform # :Iap or :Iab @retry_count = retry_count @logger = logger || Logger.new(STDOUT) @receipt = nil end |
Instance Attribute Details
#receipt ⇒ Object (readonly)
Returns the value of attribute receipt.
5 6 7 |
# File 'lib/kakeibo.rb', line 5 def receipt @receipt end |
Instance Method Details
#error ⇒ Object
51 52 53 54 |
# File 'lib/kakeibo.rb', line 51 def error return nil if @receipt.nil? @receipt.error end |
#fetch(data, option = {}) ⇒ Object
option For IAP :transaction_id -> SKPaymentTransaction#transactionIdentifier OPTIONAL For IAB :signature => included IAB response REQUIRED :base64_encoded_public_key => license key REQUIRED :developer_payload => developer payload OPTIONAL
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kakeibo.rb', line 21 def fetch(data, option={}) client = ::Kakeibo::Client.new @platform count = 0 response = nil begin count += 1 response = client.fetch(data, option) rescue => e @logger.error("ERROR #{e} #{e.}") if count < @retry_count retry else raise e end end @receipt = client.get_receipt # IAP sandboxの場合の処理 if @receipt.instance_of?(Kakeibo::Client::Receipt::Iap) && @receipt.status == Kakeibo::Client::Receipt::Iap::IS_SANDBOX_STATUS response = client.fetch(data, option.merge({environment: :sandbox})) @receipt = client.get_receipt end @receipt end |
#valid? ⇒ Boolean
46 47 48 49 |
# File 'lib/kakeibo.rb', line 46 def valid? return false if @receipt.nil? @receipt.valid? end |