Skip to content

Commit

Permalink
exclude-old-transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
sn01615 committed Sep 4, 2020
1 parent fbe1c03 commit b6ec0a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ use sn01615\iap\ios\Verify;
include "../vendor/autoload.php";

$cc = new Verify();

$receipt = ".."; // 凭据

$cc->endpoint(true);// 可选,切换到沙盒环境

$cc->setPassword('123');// 可选,如果是连续订阅需要密码
$cc->setExcludeOldTransactions(true);// 可选,将此值设置为,true以使响应仅包括任何订阅的最新续订交易。
// 仅对包含自动续订的应用收据使用此字段。

$vv = $cc->query($receipt);

Expand Down Expand Up @@ -108,8 +107,5 @@ object(stdClass)#648 (3) {

## 参考链接

订阅
https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html

收据
https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106
#### Validating Receipts with the App Store
https://developer.apple.com/documentation/storekit/in-app_purchase/validating_receipts_with_the_app_store
14 changes: 11 additions & 3 deletions src/iap/ios/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Verify

private $url;
private $password;
private $exclude_old_transactions;

public function __construct($sandbox = null)
{
Expand Down Expand Up @@ -44,9 +45,10 @@ private function buildRequestBody($receipt)
$jsonData = [
'receipt-data' => $receipt,
];
if ($this->password) {
if ($this->password)
$jsonData['password'] = $this->password;
}
if ($this->password)
$jsonData['exclude-old-transactions'] = $this->exclude_old_transactions ? true : false;
return json_encode($jsonData);
}

Expand Down Expand Up @@ -76,4 +78,10 @@ public function setPassword($password)
$this->password = $password;
return $this;
}
}

public function setExcludeOldTransactions($exclude)
{
$this->exclude_old_transactions = $exclude;
return $this;
}
}

0 comments on commit b6ec0a1

Please sign in to comment.