# In-App Purchases


## Create In-App Purchase Transaction

<small class="badge badge-darkred">requires authentication</small>

Use this endpoint to store a new in-app purchase transaction for the authenticated user.

> Example request:

```bash
curl -X POST \
    "https://apiqa.bettorfantasy.com/in-app-purchases/transactions" \
    -H "Authorization: Bearer {YOUR_AUTH_KEY}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{"transaction_id":"\"1000000987654321\"","product_id":"\"com.app.tokenpack100\"","platform":"\"ios\"","payment_status":"\"success\"","token_amount":"100","plan_amount":"499.99","currency":"\"USD\""}'

```


> Example response (200):

```json
{
    "message": "In-App Purchase Transaction Created"
}
```
> Example response (404):

```json
{
    "message": "User not found"
}
```
> Example response (422):

```json
{
    "message": "Validation Failed!",
    "errors": {
        "transaction_id": [
            "The transaction_id field is required."
        ],
        "product_id": [
            "The product_id field is required."
        ],
        "platform": [
            "The platform field is required."
        ],
        "payment_status": [
            "The payment_status field is required."
        ],
        "token_amount": [
            "The token_amount field is required."
        ],
        "plan_amount": [
            "The plan_amount field is required."
        ],
        "currency": [
            "The currency field is required."
        ]
    }
}
```
<div id="execution-results-POSTin-app-purchases-transactions" hidden>
    <blockquote>Received response<span id="execution-response-status-POSTin-app-purchases-transactions"></span>:</blockquote>
    <pre class="json"><code id="execution-response-content-POSTin-app-purchases-transactions"></code></pre>
</div>
<div id="execution-error-POSTin-app-purchases-transactions" hidden>
    <blockquote>Request failed with error:</blockquote>
    <pre><code id="execution-error-message-POSTin-app-purchases-transactions"></code></pre>
</div>
<form id="form-POSTin-app-purchases-transactions" data-method="POST" data-path="in-app-purchases/transactions" data-authed="1" data-hasfiles="0" data-headers='{"Authorization":"Bearer {YOUR_AUTH_KEY}","Content-Type":"application\/json","Accept":"application\/json"}' onsubmit="event.preventDefault(); executeTryOut('POSTin-app-purchases-transactions', this);">
<h3>
    Request&nbsp;&nbsp;&nbsp;
        <button type="button" style="background-color: #8fbcd4; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-tryout-POSTin-app-purchases-transactions" onclick="tryItOut('POSTin-app-purchases-transactions');">Try it out ⚡</button>
    <button type="button" style="background-color: #c97a7e; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-canceltryout-POSTin-app-purchases-transactions" onclick="cancelTryOut('POSTin-app-purchases-transactions');" hidden>Cancel</button>&nbsp;&nbsp;
    <button type="submit" style="background-color: #6ac174; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-executetryout-POSTin-app-purchases-transactions" hidden>Send Request 💥</button>
    </h3>
<p>
<small class="badge badge-black">POST</small>
 <b><code>in-app-purchases/transactions</code></b>
</p>
<p>
<label id="auth-POSTin-app-purchases-transactions" hidden>Authorization header: <b><code>Bearer </code></b><input type="text" name="Authorization" data-prefix="Bearer " data-endpoint="POSTin-app-purchases-transactions" data-component="header"></label>
</p>
<h4 class="fancy-heading-panel"><b>Body Parameters</b></h4>
<p>
<b><code>transaction_id</code></b>&nbsp;&nbsp;<small>string</small>  &nbsp;
<input type="text" name="transaction_id" data-endpoint="POSTin-app-purchases-transactions" data-component="body" required  hidden>
<br>
The unique transaction ID.
</p>
<p>
<b><code>product_id</code></b>&nbsp;&nbsp;<small>string</small>  &nbsp;
<input type="text" name="product_id" data-endpoint="POSTin-app-purchases-transactions" data-component="body" required  hidden>
<br>
The product identifier.
</p>
<p>
<b><code>platform</code></b>&nbsp;&nbsp;<small>string</small>  &nbsp;
<input type="text" name="platform" data-endpoint="POSTin-app-purchases-transactions" data-component="body" required  hidden>
<br>
The platform of purchase (ios/android).
</p>
<p>
<b><code>payment_status</code></b>&nbsp;&nbsp;<small>string</small>  &nbsp;
<input type="text" name="payment_status" data-endpoint="POSTin-app-purchases-transactions" data-component="body" required  hidden>
<br>
The payment status of the transaction.
</p>
<p>
<b><code>token_amount</code></b>&nbsp;&nbsp;<small>numeric</small>  &nbsp;
<input type="text" name="token_amount" data-endpoint="POSTin-app-purchases-transactions" data-component="body" required  hidden>
<br>
The number of tokens purchased.
</p>
<p>
<b><code>plan_amount</code></b>&nbsp;&nbsp;<small>numeric</small>  &nbsp;
<input type="text" name="plan_amount" data-endpoint="POSTin-app-purchases-transactions" data-component="body" required  hidden>
<br>
The plan amount charged.
</p>
<p>
<b><code>currency</code></b>&nbsp;&nbsp;<small>string</small>  &nbsp;
<input type="text" name="currency" data-endpoint="POSTin-app-purchases-transactions" data-component="body" required  hidden>
<br>
The currency code used.
</p>

</form>


## Get User Transaction IDs

<small class="badge badge-darkred">requires authentication</small>

Use this endpoint to retrieve all in-app purchase transaction IDs for the authenticated user.

> Example request:

```bash
curl -X GET \
    -G "https://apiqa.bettorfantasy.com/in-app-purchases/transactions/user/ids" \
    -H "Authorization: Bearer {YOUR_AUTH_KEY}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json"
```


> Example response (200):

```json
{
    "message": "User Transaction IDs Fetched Successfully",
    "data": {
        "user_transaction_ids": [
            "1000000987654321",
            "1000000987654322",
            "1000000987654323"
        ]
    }
}
```
> Example response (404):

```json
{
    "message": "User Not Found"
}
```
<div id="execution-results-GETin-app-purchases-transactions-user-ids" hidden>
    <blockquote>Received response<span id="execution-response-status-GETin-app-purchases-transactions-user-ids"></span>:</blockquote>
    <pre class="json"><code id="execution-response-content-GETin-app-purchases-transactions-user-ids"></code></pre>
</div>
<div id="execution-error-GETin-app-purchases-transactions-user-ids" hidden>
    <blockquote>Request failed with error:</blockquote>
    <pre><code id="execution-error-message-GETin-app-purchases-transactions-user-ids"></code></pre>
</div>
<form id="form-GETin-app-purchases-transactions-user-ids" data-method="GET" data-path="in-app-purchases/transactions/user/ids" data-authed="1" data-hasfiles="0" data-headers='{"Authorization":"Bearer {YOUR_AUTH_KEY}","Content-Type":"application\/json","Accept":"application\/json"}' onsubmit="event.preventDefault(); executeTryOut('GETin-app-purchases-transactions-user-ids', this);">
<h3>
    Request&nbsp;&nbsp;&nbsp;
        <button type="button" style="background-color: #8fbcd4; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-tryout-GETin-app-purchases-transactions-user-ids" onclick="tryItOut('GETin-app-purchases-transactions-user-ids');">Try it out ⚡</button>
    <button type="button" style="background-color: #c97a7e; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-canceltryout-GETin-app-purchases-transactions-user-ids" onclick="cancelTryOut('GETin-app-purchases-transactions-user-ids');" hidden>Cancel</button>&nbsp;&nbsp;
    <button type="submit" style="background-color: #6ac174; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-executetryout-GETin-app-purchases-transactions-user-ids" hidden>Send Request 💥</button>
    </h3>
<p>
<small class="badge badge-green">GET</small>
 <b><code>in-app-purchases/transactions/user/ids</code></b>
</p>
<p>
<label id="auth-GETin-app-purchases-transactions-user-ids" hidden>Authorization header: <b><code>Bearer </code></b><input type="text" name="Authorization" data-prefix="Bearer " data-endpoint="GETin-app-purchases-transactions-user-ids" data-component="header"></label>
</p>
</form>


## Transactions

<small class="badge badge-darkred">requires authentication</small>

Use this end point to get the list of cash transactions

> Example request:

```bash
curl -X GET \
    -G "https://apiqa.bettorfantasy.com/in-app-purchases/transactions/list?per_page=9&search=qui&sort_field=maiores&sort_method=et&page=11&status=voluptatem&user_id=2&created_at=sunt&created_at_from=ullam&created_at_to=id" \
    -H "Authorization: Bearer {YOUR_AUTH_KEY}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json"
```


> Example response (&amp;user_id=&amp;created_at=&amp;created_at_from=&amp;created_at_to=&amp;page=1):

```json

{
      "message": "Transactions",
      "data": {
          "transactions": {
              "current_page": 1,
              "data": [
                  {
                      "id": 30,
                      "status": "Success",
                      "user_id": 3,
                      "token_amount": 1000,
                      "plan_amount": 1.99,
                      "currency": "USD",
                      "prior_balance": 0,
                      "updated_balance": 0,
                      "transaction_id": 12345667,
                      "product_id": token_plan_1,
                      "created_at": "2022-06-01T07:56:13.000000Z",
                      "updated_at": "2022-06-01T07:56:55.000000Z",
                      "user": {
                          "id": 3,
                          "email": "taha@elegantmicroweb.com",
                          "username": "tahasethwala"
                      }
                  }
              ],
              "first_page_url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&",
              "from": 1,
              "last_page": 8,
              "last_page_url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=8",
              "links": [
                  {
                      "url": null,
                      "label": "pagination.previous",
                      "active": false
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&",
                      "label": "1",
                      "active": true
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=2",
                      "label": "2",
                      "active": false
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=3",
                      "label": "3",
                      "active": false
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=4",
                      "label": "4",
                      "active": false
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=5",
                      "label": "5",
                      "active": false
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=6",
                      "label": "6",
                      "active": false
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=7",
                      "label": "7",
                      "active": false
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=8",
                      "label": "8",
                      "active": false
                  },
                  {
                      "url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=2",
                      "label": "pagination.next",
                      "active": false
                  }
              ],
              "next_page_url": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list?per_page=1&search=&sort_field=id&sort_method=desc&type=&status=&user_id=&created_at=&created_at_from=&created_at_to=&page=2",
              "path": "http://35.154.99.45/bettorfantasy/dfs/bettor_webapi/public/in-app-purchases/transactions/list",
              "per_page": "1",
              "prev_page_url": null,
              "to": 1,
              "total": 8
          }
      }
  }
```
> Example response (422):

```json
{
    "message": "Please enter required information",
    "errors": {
        "sort_field": [
            "The selected sort field is invalid."
        ]
    }
}
```
<div id="execution-results-GETin-app-purchases-transactions-list" hidden>
    <blockquote>Received response<span id="execution-response-status-GETin-app-purchases-transactions-list"></span>:</blockquote>
    <pre class="json"><code id="execution-response-content-GETin-app-purchases-transactions-list"></code></pre>
</div>
<div id="execution-error-GETin-app-purchases-transactions-list" hidden>
    <blockquote>Request failed with error:</blockquote>
    <pre><code id="execution-error-message-GETin-app-purchases-transactions-list"></code></pre>
</div>
<form id="form-GETin-app-purchases-transactions-list" data-method="GET" data-path="in-app-purchases/transactions/list" data-authed="1" data-hasfiles="0" data-headers='{"Authorization":"Bearer {YOUR_AUTH_KEY}","Content-Type":"application\/json","Accept":"application\/json"}' onsubmit="event.preventDefault(); executeTryOut('GETin-app-purchases-transactions-list', this);">
<h3>
    Request&nbsp;&nbsp;&nbsp;
        <button type="button" style="background-color: #8fbcd4; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-tryout-GETin-app-purchases-transactions-list" onclick="tryItOut('GETin-app-purchases-transactions-list');">Try it out ⚡</button>
    <button type="button" style="background-color: #c97a7e; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-canceltryout-GETin-app-purchases-transactions-list" onclick="cancelTryOut('GETin-app-purchases-transactions-list');" hidden>Cancel</button>&nbsp;&nbsp;
    <button type="submit" style="background-color: #6ac174; padding: 5px 10px; border-radius: 5px; border-width: thin;" id="btn-executetryout-GETin-app-purchases-transactions-list" hidden>Send Request 💥</button>
    </h3>
<p>
<small class="badge badge-green">GET</small>
 <b><code>in-app-purchases/transactions/list</code></b>
</p>
<p>
<label id="auth-GETin-app-purchases-transactions-list" hidden>Authorization header: <b><code>Bearer </code></b><input type="text" name="Authorization" data-prefix="Bearer " data-endpoint="GETin-app-purchases-transactions-list" data-component="header"></label>
</p>
<h4 class="fancy-heading-panel"><b>Query Parameters</b></h4>
<p>
<b><code>per_page</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="per_page" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Number of records per page. Send '-1' for all records. Default: 10. Ex: 15
</p>
<p>
<b><code>search</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="search" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Search string searched in type, status, transaction_id, total_amount. Ex: Approved
</p>
<p>
<b><code>sort_field</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="sort_field" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Sort by field. Possible values: id, status, user_id, total_amount, created_at, updated_at, prior_balance, updated_balance, transaction_id. Ex: id
</p>
<p>
<b><code>sort_method</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="sort_method" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Sort by method. Possible values: asc, desc. Ex: desc
</p>
<p>
<b><code>page</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="page" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Page number. Ex: 1
</p>
<p>
<b><code>status</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="status" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Status. Possible values: Approved, Pending, Declined. Ex: Approved
</p>
<p>
<b><code>user_id</code></b>&nbsp;&nbsp;<small>integer</small>     <i>optional</i> &nbsp;
<input type="number" name="user_id" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
User ID. Ex: 14
</p>
<p>
<b><code>created_at</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="created_at" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Filter by date (Format YYYY-MM-DD): Ex: 2021-07-05
</p>
<p>
<b><code>created_at_from</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="created_at_from" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Filter by from date (Format YYYY-MM-DD), Requires:created_at_to  Ex: 2021-07-04
</p>
<p>
<b><code>created_at_to</code></b>&nbsp;&nbsp;<small>string</small>     <i>optional</i> &nbsp;
<input type="text" name="created_at_to" data-endpoint="GETin-app-purchases-transactions-list" data-component="query"  hidden>
<br>
Filter by to date (Format YYYY-MM-DD), Requires:created_at_from Ex: 2021-07-07
</p>
</form>



