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

网站 搜索引擎 提交南昌市科协网站

网站 搜索引擎 提交,南昌市科协网站,无锡房地产开发公司,上海十大好厂流程: 申请 Amazon 开发者帐号 ---> 在 amazon 控制台添加应用 ---> 添加应用内商品(消费类商品,授权类商品,订阅类商品)---> 导出 JSON 文件 --->集成 Amazon 支付 ---> 将导出的 JSON 文件 copy 到 …

流程:

申请 Amazon 开发者帐号 ---> 在 amazon 控制台添加应用 ---> 添加应用内商品(消费类商品,授权类商品,订阅类商品)---> 导出 JSON 文件 --->集成 Amazon 支付 ---> 将导出的 JSON 文件 copy 到 /mnt/sdcard/目录下---> 沙河模式下测试支付 ---> 上传发布

注意:亚马逊目前使用 V1 签名;2.targetSdkVersion 版本必须小于等于29

SDK运行模式一共三种

①:SANDBOX 沙河模式,用于测试,与 Amazon App Tester 测试工具交互

②:PRODUCTION 提交到亚马逊应用商店才可测试

③:UNKNOWN 尚未通过调用verifyLicense()初始化SDK。
 

步骤一:集成亚马逊内购SDK

    implementation 'com.amazon.device:amazon-appstore-sdk:3.0.4'

步骤二:在 AndroidManifest.xml 文件中添加 ResponseReceiver 配置,如果应用 targetSdkVersion 设置的是 31 或更高版本,必须显式地将 android:exported 设置 ResponseReceiver 中android:exported 设置为true

<receiver android:name="com.amazon.device.iap.ResponseReceiver" android:exported="true"android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" ><intent-filter><actionandroid:name="com.amazon.inapp.purchasing.NOTIFY" /></intent-filter></receiver>

步骤三:实现并注册PurchasingListener (onCreate 生命周期方法中调用)

 purchasingListener = new PurchasingListener() {/*** 确定当前登录用户的UserId和marketplace。* @param response*/@Overridepublic void onUserDataResponse(final UserDataResponse response) {Log.d(LOG_TAG, "onUserDataResponse: requestId (" + response.getRequestId()+ ") userIdRequestStatus: "+ response.getRequestStatus()+ ")");//当前用户相关信息(用户ID和市场final UserDataResponse.RequestStatus status = response.getRequestStatus();switch (status) {case SUCCESSFUL:Log.d(LOG_TAG, "onUserDataResponse: get user id " + response.getUserData().getUserId()+ ", marketplace "+ response.getUserData().getMarketplace());currentUserId = response.getUserData().getUserId();currentMarketplace = response.getUserData().getMarketplace();break;case FAILED:Log.d(LOG_TAG, "onUserDataResponse FAILED failed, status code is " + status);case NOT_SUPPORTED:Log.d(LOG_TAG, "onUserDataResponse NOT_SUPPORTED failed, status code is " + status);break;}}/*** 检索应用中销售的SKU的信息* 使用来自ProductDataResponse对象的有效SKU。** @param response*/@Overridepublic void onProductDataResponse(final ProductDataResponse response) {final ProductDataResponse.RequestStatus status = response.getRequestStatus();Log.d(LOG_TAG, "onProductDataResponse: RequestStatus (" + status + ")");switch (status) {case SUCCESSFUL:Log.d(LOG_TAG, "onProductDataResponse: successful.  The item data map in this response includes the valid SKUs");final Set<String> unavailableSkus = response.getUnavailableSkus();for (final String s : response.getUnavailableSkus()) {Log.v(LOG_TAG, unavailableSkus.size() + " 不可用SKU:" + s);}final Map<String, Product> products = response.getProductData();for (final String key : products.keySet()) {Product product = products.get(key);Log.v(LOG_TAG, String.format("可购买的产品:%s\n 类型:%s\n SKU:%s\n 价格:%s\n 描述:%s\n", product.getTitle(), product.getProductType(), product.getSku(), product.getPrice(), product.getDescription()));// 处理产品}break;case FAILED:case NOT_SUPPORTED:Log.d(LOG_TAG, "onProductDataResponse: failed, should retry request");break;}}/*** 检索自上次调用该方法之后用户完成的所有购买交易* 仅可检索未履行和已取消的消费品购买* @param response*/@Overridepublic void onPurchaseUpdatesResponse(final PurchaseUpdatesResponse response) {Log.d(LOG_TAG, "PurchaseUpdatesResponse: requestId (" + response.getRequestId()+ ") Status ("+ response.getRequestStatus()+ ") userId ("+ response.getUserData().getUserId()+ ")");//获取请求状态final PurchaseUpdatesResponse.RequestStatus status = response.getRequestStatus();switch (status) {case SUCCESSFUL:Log.e(LOG_TAG, "========no consumeProduct==========" + response.getReceipts());//PurchasingService.getProductDatafor (final Receipt receipt : response.getReceipts()) {LogD("购买收据 + receipt " + receipt.isCanceled() + "\n" + "收据:" + receipt.getReceiptId());if (!receipt.isCanceled()) {String localReceipt = SharedPreferencesUtil.getString(mContext, receipt.getReceiptId(), "");Gson gson = new Gson();Type type = new TypeToken<Hashtable<String, String>>(){}.getType();Hashtable<String, String> localPurchase= gson.fromJson(localReceipt, type);if(null!=localPurchase){myProductInfo = localPurchase;}receiptID = receipt.getReceiptId();Log.e(LOG_TAG, "----------myProductInfo------------: " + myProductInfo);consumeProduct(receipt,"2");}}//                        if (response.hasMore()) {
//                            //如果不启用“待定购买”,则在每次getPurchaseUpdates(false)调用中只返回未履行的消费品收据
//                            PurchasingService.getPurchaseUpdates(false);
//                            return;
//                        }break;case NOT_SUPPORTED:Log.d(LOG_TAG, "onProductDataResponse: failed, should retry request");break;}}/*** purchase()用户拉起支付后,用于确定购买状态。** @param response*/@Overridepublic void onPurchaseResponse(final PurchaseResponse response) {final String requestId = response.getRequestId().toString();final String userId = response.getUserData().getUserId();final PurchaseResponse.RequestStatus status = response.getRequestStatus();Log.d(LOG_TAG, "支付成功回调 onPurchaseResponse: requestId (" + requestId+ ") userId ("+ userId+ ") purchaseRequestStatus ("+ status+ ")");switch (status) {case SUCCESSFUL://交易成功final Receipt receipt = response.getReceipt();Log.d(LOG_TAG, "onPurchaseResponse: receipt json:" + receipt.toJSON());receiptID = receipt.getReceiptId();Log.d(LOG_TAG, "onPurchaseResponse: receipt receiptID:" + receipt.getReceiptId());//请求服务端跟amazon校验//校验成功去消耗PurchasingService.notifyFulfillment(receiptID, FulfillmentResult.FULFILLED);break;
//                    case PENDING:
//                        Log.d(LOG_TAG, "onPurchaseResponse: 等待远程批准——如果获得批准,购买将在 getPurchaseUpdates 中返回");
//                        break;case ALREADY_PURCHASED://已经授权过的,属于成功,此时将道具给玩家即可Log.d(LOG_TAG, "onPurchaseResponse: 已经授权过的,属于成功,此时将道具给玩家即可");break;case INVALID_SKU:Log.d(LOG_TAG, "onPurchaseResponse: invalid SKU!无效SKU,无法识别");break;case FAILED:case NOT_SUPPORTED:Log.e(LOG_TAG, "支付失败 用户在完成之前取消了购买");break;}}};

步骤四:注册监听(onCreate 生命周期方法中调用)

PurchasingService.registerListener(mContext, purchasingListener);

步骤五:通过 getUserData() 当前用户相关(用户ID和市场),我这边是放在了onCreate 生命周期方法中 

PurchasingService.getUserData();(onCreate 生命周期方法中调用)

步骤六:检索自上次调用该方法之后用户完成的所有购买交易,以确保获取最新的更新

PurchasingService.getPurchaseUpdates(true);(onCreate 生命周期方法中调用)
  • false - 返回自上次调用getPurchaseUpdates()之后的购买记录的分页响应。检索用户的未履行消费品、权利和订阅购买的收据。亚马逊应用商店建议在大部分情况下使用此方法。

     注意: 如果您的应用启用了待定购买,则亚马逊应用商店会在每次getPurchaseUpdates(false)调用中为用户返回所有未履行的消费品和权利收据,直到您的应用调用notifyFulfillment()为止。如果不启用“待定购买”,则在每次getPurchaseUpdates(false)调用中只返回未履行的消费品收据。

  • true - 检索用户的完整购买记录。需要将数据存储在某个位置(例如服务器端数据缓存),或将所有数据保留在内存中。

步骤七:验证SKU,购买中不会因 SKU 无效而意外失败。

 Set<String> productSkus = new HashSet<>();productSkus.add("skus1");productSkus.add("skus12");productSkus.add("skus3");....PurchasingService.getProductData(productSkus);// 触发PurchasingListener.onProductDataResponse()

步骤八:拉起支付弹框支付

            final RequestId requestId =  PurchasingService.purchase("Product_Id");

注意:在消耗商品前,先完成后端服务器通过亚马逊的Receipt Verification Service (RVS)验证receiptId,从而验证购买所产生的收据。验证后再去消耗。

测试流程

1:从亚马逊应用商店将Amazon App Tester下载到手机上。App Tester模拟生产环境,下载链接

2:下载后台的amazon.sdktester.json 文件复制到手机的/sdcard/文件夹中,在Amazon App Tester应用中找到 IAP items in JSON File,看下是否有数据

       adb push F:/download/amazon.sdktester.json /mnt/sdcard/

3:adb shell setprop debug.amazon.sandboxmode debug 设置为沙盒模式

//检查应用是否处于测试模式

  Log.d(TAG, "Appstore SDK Mode: " + LicensingService.getAppstoreSDKMode()); 

  以上就是 Amazon 支付的接入流程,发布到 Amazon 后才可以正式付费,但正式付费跟测试付费显示效果是一样的.

http://www.yayakq.cn/news/660174/

相关文章:

  • 网站维护项目那些网站百度抓取率比较高
  • 绿色食品网站建设论文企业电子邮箱怎么申请注册
  • 博客网站模板有哪些苏醒8 WordPress
  • 南昌寻南昌网站设计电商商城网站开发
  • 江苏网站开发公司外贸网站有什么
  • 哈密网站建设肥城网站建设哪家好
  • 城阳区网站建设公司WordPress设置页面宽度占满
  • 怒江州住房和城乡建设局网站素材免费下载素材库
  • 旅游网站建设目标网站分类html编辑器的程序怎么设置
  • 国外专门做图像增强的网站广州seo招聘
  • 鲜花网站前台数据库建设优秀大校网站
  • 个人外贸网站建设深圳招聘信息最新招聘信息查询
  • 网站建设哪里最好接单子做网站办公室图片
  • 免费做网站的网址有哪些淘宝这种网站怎么做的
  • 个人博客网站实验报告微信主题wordpress
  • 怎样将自己做的网页加入网站o2o网站制作
  • 英文企业网站建设做名片去哪个网站
  • wordpress新站不收录百度一下就会知道了
  • 网站镜像 cdn吉林中岩峰建设有限公司网站
  • 壁纸网站模板wordpress主题租房
  • 做外贸网站选择服务器七台河新闻联播今天的
  • 石家庄网站建设模板服务wordpress主体
  • 网站备案服务内容wordpress wvip
  • 西宁高端网站建设公司html5网页开发工具
  • 网站开发公司网站泰安网课
  • 网站网页设计模板下载wp打开wordpress
  • 网站sessionwordpress 分享后可见
  • 网站服务合同模板广告传媒公司简介
  • 网站推广方案的构成ip设计
  • 公司做二手网站的用意公共营养师报考条件