当前位置: 首页 > news >正文

Google Play服务端获取订单和核销订单

官方文档地址:https://developers.google.cn/android-publisher/api-ref/rest/v3/purchases.products?hl=zh-cn

java依赖

        <!-- google play --><dependency><groupId>com.google.apis</groupId><artifactId>google-api-services-androidpublisher</artifactId><version>v3-rev20241003-2.0.0</version></dependency><dependency><groupId>com.google.http-client</groupId><artifactId>google-http-client-jackson2</artifactId><version>1.45.0</version></dependency><dependency><groupId>com.google.auth</groupId><artifactId>google-auth-library-oauth2-http</artifactId><version>1.28.0</version></dependency><!-- google play -->

java代码,

credential json文件再谷歌后台配置后获取,支付凭证让前端APP拉取支付后获取后给到服务端。

参考这个文档在Google后台配置服务端验证Google Pay订单的两种方式_谷歌支付验证-CSDN博客

@Testvoid test2() throws Exception {// GoogleCredentials credential = GoogleCredentials//         .fromStream(FileUtil.getInputStream("/opt/api-project-20840613-43d15092b1b0.json"))//         .createScoped(Collections.singletonList(AndroidPublisherScopes.ANDROIDPUBLISHER));String token = "json字符串base64编码";GoogleCredentials credential = GoogleCredentials.fromStream(new ByteArrayInputStream(Base64.decode(token))).createScoped(Collections.singletonList(AndroidPublisherScopes.ANDROIDPUBLISHER));HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credential);AndroidPublisher publisher = new AndroidPublisher.Builder(new NetHttpTransport(), new GsonFactory(), requestInitializer).build();AndroidPublisher.Purchases purchases = publisher.purchases();//获取凭证对应google订单信息final AndroidPublisher.Purchases.Products.Get request = purchases.products().get("com.tangwan.xxx", "test01", "支付凭证token");final ProductPurchase purchase = request.execute();//凭证核销purchases.products().consume("com.tangwan.cn", "test01", "支付凭证token").execute();System.out.println(JSONUtil.toJsonStr(purchase));}

http://www.lryc.cn/news/459330.html

相关文章:

  • Spring Security 与 OAuth 2.0 登录实现指南
  • 02 django管理系统 - base.html模板的搭建
  • ES6语法有哪些
  • 每天一个数据分析题(五百零四)- 抽取样本
  • SAP动态安全库存(Dynamic Safety stock)配置及计算逻辑说明测试
  • 什么是TDZ?在JavaScript当中怎么避免?
  • 电阻分压电路:【图文讲解】
  • 【AI论文精读14】RAG论文综述2(微软亚研院 2409)P6(完)-隐含推理查询L4
  • FFmpeg的简单使用【Windows】--- 视频倒叙播放
  • 5分钟了解docker的Swarm机制
  • python实现ppt转pdf
  • VS2017 编译 SQLite3 动态库
  • Linux运维_Apache更改默认网站目录
  • QT QString学习笔记
  • 4.stm32 GPIO输入
  • GPT系列
  • Chromium 前端window对象c++实现定义
  • 【力扣算法题】每天一道,健康生活
  • Android Camera系列(四):TextureView+OpenGL ES+Camera
  • 03 django管理系统 - 部门管理 - 部门列表
  • L1 Sklearn 衍生概念辨析 - 回归/分类/聚类/降维
  • 【畅捷通-注册安全分析报告】
  • TCP IP网络编程
  • libssh2编译部署详解
  • IPv4数据报的首部格式 -计算机网络
  • 小米电机与STM32——CAN通信
  • 2.2.ReactOS系统KSERVICE_TABLE_DESCRIPTOR结构体的声明
  • 前端接口报500如何解决 | 发生的原因以及处理步骤
  • 图书馆自习室座位预约管理微信小程序+ssm(lw+演示+源码+运行)
  • 谷歌-BERT-第一步:模型下载