chenkby / apple-pay
苹果内购
v1.0
2018-01-25 07:45 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2025-01-24 03:43:23 UTC
README
安装
composer
$ php composer.phar require chenkby/apple-pay:1.0
或者添加以下代码到composer.json
文件的require
块中:
"chenkby/apple-pay": "1.0"
使用
// $orderId 本地订单号 // $storeProductId 苹果商店产品ID // $tradeNo 苹果交易号 $order = findOrder($orderId); $order->updateReceipt($data['receipt']); $applePay = new ApplePay($_POST['receipt'], $orderId); if ($applePay->verifyReceipt()) { $result = $applePay->query($storeProductId, 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(); }