PHP code example of guanhui07 / apple_pay
1. Go to this page and download the library: Download guanhui07/apple_pay library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
guanhui07 / apple_pay example snippets
$ composer
// $orderId 本地订单号
// $storeProductId 苹果商店产品ID
// $tradeNo 苹果交易号
$order = findOrder($orderId);
$applePay = new ApplePay($_POST['receipt'], '');
if ($applePay->verifyReceipt()) {
$result = $applePay->query($storeProductId,$bundleId, function ($tradeNo, $returnData) use ($order) {
// 检查此交易号是否被使用
if (!$order->checkTradeNoIsUsed($tradeNo)) {
// 更新本地订单状态等...
return $this->notify($order, $returnData, $tradeNo);
} else {
echo '此笔交易号已经被使用,这笔交易有可能是伪造的!';
return false;
}
});
if ($result) {
echo 'success';
} else {
echo $applePay->getError();
}
} else {
echo $applePay->getError();
}