美文网首页
google支付订单查询

google支付订单查询

作者: oryxtc | 来源:发表于2017-10-23 17:03 被阅读0次

官方文档链接:https://developers.google.cn/android-publisher/

github链接:https://github.com/google/google-api-php-client

查询google的支付订单

public static function curl_google_product(){
    // include your composer dependencies
    require_once 'vendor/autoload.php';
    try{
        putenv('GOOGLE_APPLICATION_CREDENTIALS=/PATH/WEB/xx.json'); //配置系统环境变量
        $client = new \Google_Client(); //实例化链接
        $client->useApplicationDefaultCredentials();
        $client->addScope(\Google_Service_AndroidPublisher::ANDROIDPUBLISHER);//添加使用域
        // OR use environment variables (recommended)
        $service = new \Google_Service_AndroidPublisher($client );
        $packageName='XXX';  //App包名
        $productId='com.XXX'; //商品ID
        $token = 'XXX'; 
        $optps=array();
        $resp = $service->purchases_products->get( $packageName, $productId, $token, $optps );
        $resp = (array)$resp;
        return $resp;
    }catch(Exception $e){
        echo $e->getCode(),'|',$e->getMessage();
        exit;
    }
}

如果返回错误为The current user has insufficient permission...

Google_Service_Exception: {
    "error": {
        "errors": [{
            "domain": "androidpublisher",
            "reason": "permissionDenied",
            "message": "The current user has insufficient permissions to perform the requested operation."
        }],
        "code": 401,
        "message": "The current user has insufficient permissions to perform the requested operation."
   }
}

需要在谷歌控制台中将xx.json中的client_email设置为管理员用户

查询google的订阅订单

private static function curl_google_subscription(){
    // include your composer dependencies
    require_once 'vendor/autoload.php';
    try{
        putenv('GOOGLE_APPLICATION_CREDENTIALS=/PATH/WEB/xx.json'); //配置系统环境变量
        $client = new \Google_Client(); //实例化链接
        $client->useApplicationDefaultCredentials();
        $client->addScope(\Google_Service_AndroidPublisher::ANDROIDPUBLISHER);//添加使用域
        // OR use environment variables (recommended)
        $service = new \Google_Service_AndroidPublisher($client );
        $packageName='XXX';  //App包名
        $subscriptionId='com.XXX'; //订购ID
        $token = 'XXX'; 
        $optps=array();
        $resp = $service->purchases_subscriptions->get( $packageName, $subscriptionId, $token, $optps );
        $resp = (array)$resp;
        return $resp;
    }catch(Exception $e){
        echo $e->getCode(),'|',$e->getMessage();
        exit;
    }
}

使用公钥进行算法验证(安全性上不高,不推荐)

    public static function curl_post_google($inapp_purchase_data,$inapp_data_signature){
        //$inapp_purchase_data,$inapp_data_signature 为用户付款后,谷歌返回值(或app端返回)
        $google_public_key='公钥';
        $public_key ="-----BEGIN PUBLIC KEY-----\n".chunk_split($google_public_key, 64, "\n")."-----END PUBLIC KEY-----";
        $public_key_handle = openssl_get_publickey($public_key);
        $result = openssl_verify($inapp_purchase_data, base64_decode($inapp_data_signature), $public_key_handle, OPENSSL_ALGO_SHA1);
        if ($result !== 1) {
            return $result;
        }
        return true;
    }

相关文章

  • google支付订单查询

    官方文档链接:https://developers.google.cn/android-publisher/ gi...

  • 秒杀系统简述

    1.业务分析 商品查询---->创建订单----->订单支付----->卖家发货 其中创建订单又可以分为以下流程:...

  • apple支付订单查询

    内购订单验证

  • Android Google Play 服务器验证

    概要:Google 建议在完成支付后依据服务器返回订单结果为准所以才有了这篇文章。本文针对订单支付完成后 验证购买...

  • Google Play 报错:googleapi: Error

    测试谷歌支付订单的时候,支付成功但是查询订单的时候给出报错如下: 403的意思就是没有权限访问,通过报错给出的链接...

  • 微信支付--PHP 封装

    微信支付开发文档 类的使用方法 笔者阅读微信支付SDK里面的example之后,把下单,查询订单,退款,查询退款等...

  • 下订单去支付服务:支付和提现逻辑设计

    支付和提现 支付 创建订单阶段 根据平台产品创建本地订单本地订单号(唯一) 创建支付订单(支付平台的订单)支付凭证...

  • google支付后台验证操作流程

    整个开发背景是前端在调用完google play支付流程后,需要后台验证支付结果以及在自己的服务生成订单相关信息...

  • Java支付宝订单查询

    电脑网站支付成功后可通过支付宝接口主动查询订单结果 更多精彩 更多技术博客,请移步 asing1elife's b...

  • Day21

    完成订单查询、展示、在线支付功能 实体说明 PageBean分页展示的时候就用PageBean 技术点: 权限控制...

网友评论

      本文标题:google支付订单查询

      本文链接:https://www.haomeiwen.com/subject/tlvauxtx.html