Git Product home page Git Product logo

receipt_verifier's Introduction

ReceiptVerifier

CI Hex.pm codebeat badge Inline docs

Verify iOS App receipt with the App Store.

⚠️ Only iOS 7 style app receipt is supported. Please check AppStore for the package for App Store Server API.

Installation

Simply add receipt_verifier to your list of dependencies in mix.exs:

def deps do
  [
    {:receipt_verifier, "~> 0.14"},
    {:jason, "~> 1.0"}
  ]
end

then run mix deps.get and you are ready to go.

Usage

ReceiptVerifier.verify(BASE64_ENCODED_RECEIPT_DATA, env: :production)
# {:ok, %ReceiptVerifier.ResponseData{...}}

Please view the detailed documentation at https://hexdocs.pm/receipt_verifier.

Changes

See CHANGELOG.md

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/linjunpop/receipt_verifier.

See also

receipt_verifier's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

receipt_verifier's Issues

Don't change the json_library

I change the json library in my config files

# config/config.exs
......
config :receipt_verifier, :json_library, Poison

But I'm getting this error.

** (UndefinedFunctionError) function Jason.encode!/1 is undefined (module Jason is not available)
    Jason.encode!(%{"receipt-data" => "BASE64_ENCODED_RECEIPT_DATA"})
    (receipt_verifier) lib/receipt_verifier/client.ex:36: ReceiptVerifier.Client.do_request/2
    (receipt_verifier) lib/receipt_verifier/client.ex:19: ReceiptVerifier.Client.request/2
    (receipt_verifier) lib/receipt_verifier.ex:87: ReceiptVerifier.do_verify/2

parser doesn't seem to work in sandbox anymore

I see the latest response from apple store for a sandbox environment item purchase is as follows:

%{"receipt" => %{"bid" => "com.google.www", "bvrs" => "1",
    "is_in_intro_offer_period" => "false", "is_trial_period" => "false",
    "item_id" => "1322556240",
    "original_purchase_date" => "2017-12-22 18:16:14 Etc/GMT",
    "original_purchase_date_ms" => "1513262574202",
    "original_purchase_date_pst" => "2017-12-22 10:16:14 America/Los_Angeles",
    "original_transaction_id" => "1000020362025483",
    "product_id" => "com.google.001",
    "purchase_date" => "2017-12-22 18:16:14 Etc/GMT",
    "purchase_date_ms" => "1512966574202",
    "purchase_date_pst" => "2017-12-22 10:16:14 America/Los_Angeles",
    "quantity" => "1", "transaction_id" => "1000000362015483",
    "unique_identifier" => "0fcea4121732845ec3123dff859af528faaa75f85",
    "unique_vendor_identifier" => "AAAAAAAA-4D7A-DDAD-9126-922A7A34FD72"},
  "status" => 0}

And it seems the parser is not able to handle this. Wondering if there's something that I can do? Thanks.

Deprecated time units in Elixir v1.8.0

This warning is printed during use on Elixir v1.8.0:

warning: deprecated time unit: :milliseconds. A time unit should be :second, :millisecond, :microsecond, :nanosecond, or a positive integer

Looks like there's two places the code needs to be updated:

|> DateTime.from_unix!(:milliseconds)
and
|> DateTime.from_unix!(:milliseconds)

Since you have already specified Elixir v1.4+, you should not run into any backwards compatibility issues with just changing those to :millisecond.

Thanks for your work!

No function clause matching parse_response

Hi there - after submitting a base64 encoded receipt string through your package, I get the following error.

** (FunctionClauseError) no function clause matching in ReceiptVerifier.Parser.parse_response/1

A response does come back which properly identifies the IAP i was trying to verify by original_transaction_id, original_purchase_date and several other fields. The status returns 0.

However, looking at the function clauses in parser.ex, it looks like the two fields that are missing from the response I get back are: latest_receipt & receipt

I have tried adding our shared secret, but get the same result. Any idea what might be the issue?

Thanks so much for the package!

TLS Error

Getting this error when verifying a receipt in sanbox:

{_, data} = ReceiptVerifier.verify(attrs["receipt-data"], env: :sandbox)

Got:

{:error,
{:failed_connect,
[
{:to_address, {'sandbox.itunes.apple.com', 443}},
{:inet, [:inet], {:tls_alert, 'handshake failure'}}
]}}

Terminal:
['TLS', 32, 'client', 58, 32, 73, 110, 32, 115, 116, 97, 116, 101, 32, 'hello', 32, 'received SERVER ALERT: Fatal - Handshake Failure', 10]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.