-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpurchase_confirmation.php
More file actions
34 lines (25 loc) · 1.1 KB
/
purchase_confirmation.php
File metadata and controls
34 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// **************************************************************************
//
// This file implements the endpoint for the "purchase confirmation" API call.
//
require_once 'header.php';
$base64_receipt = stripcslashes($_POST['receipt_data']);
$purchase_type = $_POST['type'];
$data = verifyReceipt($base64_receipt);
$receipt = $data->receipt;
$product_id = $receipt->product_id;
$transaction_id = $receipt->transaction_id;
$log->LogDebug("Saving $purchase_type $product_id in the receipt database");
$file_db->query(
"INSERT OR IGNORE INTO receipts (transaction_id, app_id, user_id, product_id, type, base64_receipt)
VALUES ('$transaction_id', '$app_id', '$user_id', '$product_id', '$purchase_type', '$base64_receipt')"
);
if ($purchase_type == 'auto-renewable-subscription') {
markIssuesAsPurchased($data, $app_id, $user_id);
} else if ($purchase_type == 'issue') {
markIssueAsPurchased($product_id, $app_id, $user_id);
} else if ($purchase_type == 'free-subscription') {
// Nothing to do, as the server assumes free subscriptions won't be enabled
}
?>