Sha256: a28ab55f8da9124a6916b9f502ac2be0e9e1fc5bdb6c1fd42b7f7333cb04a070

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

module Trade
  module ApplePayApi
    URL = 'https://buy.itunes.apple.com/verifyReceipt'
    SANDBOX_URL = 'https://sandbox.itunes.apple.com/verifyReceipt'
    extend self

    def detect_verify(receipt_data)
      r = verify(receipt_data)

      if r['status'] == 21007
        verify(receipt_data, true)
      else
        r
      end
    end

    def verify(receipt_data, sandbox = false)
      if sandbox
        url = SANDBOX_URL
      else
        url = URL
      end

      body = {
        'receipt-data': receipt_data
      }

      r = HTTPX.post(url, form: body)
      JSON.parse(r.body)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_trade-0.0.3 app/apis/trade/apple_pay_api.rb