/applev

This app validates Apple receipts with the App Store. The code is written in Erlang

Primary LanguageErlangApache License 2.0Apache-2.0

Build Status Coverage Status Erlant/OTP Release

This application validates apple receipts with App Store. How to validate

Getting started

You need to clone the repository and download rebar/rebar3 (if it's not already available in your path).

git clone https://github.com/thiagoesteves/applev.git
cd applev

To compile and run

make

How to use the application

The application has two modes of operation: Sync and Async. If you decide to use the sync mode, when validation function is called, the function will be blocked until it finishes (or timeout). If async mode is selected, you must pass the PID (or process name) of the destination process in order to receive the result and any argument to identify the validated receipt. See the examples:

1> applev:validate(<<"Your Receipt Here">>).
{ok,#{<<"bid">> => <<"com.es.Purchaser">>,<<"bvrs">> => <<"3">>,
      ...
      <<"unique_vendor_identifier">> =>
          <<"5C275B5A-3E66-4026-9523-845B225755FC">>}}
2> applev:validate_async(self(), <<"Your Receipt Here">>, [arg1, arg2]).
{ok,<0.247.0>}
3> flush().
Shell got {apple_receipt_return,{ok,#{<<"bid">> => <<"com.es.Purchaser">>,
                                      ...
                                      <<"unique_vendor_identifier">> =>
                                          <<"5C275B5A-3E66-4026-9523-845B225755FC">>},
                                          [arg1, arg2]} }
ok

How to test the application using the sandbox receipt example

In order to test the connectivity, there are test functions using sandbox receipt

1> applev:validate().
{ok,#{<<"bid">> => <<"com.es.Purchaser">>,<<"bvrs">> => <<"3">>,
      ...
      <<"unique_vendor_identifier">> =>
          <<"5C275B5A-3E66-4026-9523-845B225755FC">>}}
2> applev:validate_async().
{ok,<0.247.0>}
3> flush().
Shell got {apple_receipt_return,{ok,#{<<"bid">> => <<"com.es.Purchaser">>,
                                      ...
                                      <<"unique_vendor_identifier">> =>
                                          <<"5C275B5A-3E66-4026-9523-845B225755FC">>}
                                      none}}
ok

Unit Test and coverage

The following command will invoke common test and coverage.

make test