# Scrip

## [![Hex pm](]( [![License](](![.github/workflows/elixir.yml](

<!-- MDOC !-->

Scrip is a library to verify Apple App Store receipts. See the [Apple docs]( for more information

## Installation

The package can be installed by adding `scrip` to your list of dependencies in `mix.exs`:

def deps do
    {:script, "~> 1.0.0"},
    {:jason, "~> 1.1"}, # optional
    {:httpoison, "~> 1.7"}, # optional

`Jason` and `HTTPoison` are optional and can be overriden with other implementations
but these are the default implementations. See `Scrip.Config` for more information.

## Usage

First set up In-App Purchases in App Store Connect. For your app should set the App-Specific Shared Secret, we can
use this later on to verify the receipt.

The usual flow is that your app does an in app purchase. This returns a Base64 receipt to the app. Your app can send the
receipt data to your backend to validate against the Apple servers.

The backend can verify the validity of this receipt using `Scrip.verify_receipt("BASE64_RECEIPT_DATA", password: "*App-Specific Shared Secret*")`. It needs the earlier create App-Specific Shared Secret.

If all goes well, it returns an `:ok` tuple with the IAP information you can store on your backend.
Otherwise an `:error` tuple is returned.

See `Scrip.verify_receipt/3` for more information