Class: RubyNative::IAP::RestoresController

Inherits:
ActionController::Base
  • Object
show all
Includes:
Decodable, Verifiable
Defined in:
app/controllers/ruby_native/iap/restores_controller.rb

Constant Summary

Constants included from Verifiable

Verifiable::APPLE_ROOT_CERT_PATH

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/ruby_native/iap/restores_controller.rb', line 9

def create
  return head :bad_request if params[:customer_id].blank?

  transactions = Array(params[:signed_transactions])
  return head :bad_request if transactions.empty?

  transactions.each { |signed_transaction| restore(decode_and_verify_jws(signed_transaction)) }

  head :ok
rescue VerificationError, JWT::DecodeError => e
  Rails.logger.warn "[RubyNative] Restore verification failed: #{e.message}"
  head :unprocessable_entity
end