Giter Site home page Giter Site logo

apple-pay's Introduction

苹果内购

安装

composer

$ php composer.phar require minz/apple-pay

使用

// $receipt apple支付凭据
$receipt = request()->get('receipt');
// 内购商品id
$productId = request()->get('productId');
// notice 如果商品为续订类产品,password需要输入 提供的共享密码,否则无需传递参数
$applePay = new ApplePay($receipt, $password);
if ($applePay->verifyReceipt(true)) {
    $result = $applePay->query($productId, function ($tradeNo, $returnData) use ($productId) {
        // 检查此交易号是否被使用
        $transaction = Transaction::find($tradeNo);
        if ($transaction) {
            throw new Exception("此笔交易号已经被使用");
        }
    
        //进行本身业务操作
        DB::transaction(function () use ($tradeNo, $productId) {
            //.....
            //db操作
        });
        return true;
    });
    if (!$result) {
        throw new Exception("app上报productId与apple返回数据不统一");
    }
    // 验证成功...
    // return response
} else {
    throw new Exception("applePay验证异常,请关注"); 
}

apple-pay's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.