Giter VIP home page Giter VIP logo

iappurchasing's Introduction

IAPPurchasing

App内购demo

使用方法

//product_id 是需要在开发者账号注册的内购产品的id,这个id是自定义的,最好定义要有规律

//此外在开发者账号平台上注册一个沙箱测试账号,用于内购支付(这个邮箱不能跟苹果有任何关联,最好使用企业邮箱)如:com.harryTest.kid.test_12 这里我在为测试使用的id

[[YMApplePay shareIAPManager] addPurchWithProductID:produc_id completeHandle:^(IAPPurchType type, NSData * _Nonnull data) { //购买成功后的操作 }];

成功下单,获取苹果服务器返回的订单数据,在SKProductsRequestDelegate 代理方法

// 交易结束

  • (void)completeTransaction:(SKPaymentTransaction *)transaction ;

中 获取

NSString * productIdentifier = transaction.payment.productIdentifier;

NSData *data = [productIdentifier dataUsingEncoding:NSUTF8StringEncoding];

NSString *receipt = [data base64EncodedStringWithOptions:0];

NSString *receipt_data = [data base64EncodedStringWithOptions:0];

/** 事务标识符(交易编号) 交易编号(必传:防止越狱下内购被破解,校验 in_app 参数)*/

NSString *transaction_id = transaction.transactionIdentifier;

NSString *goodID = transaction.payment.productIdentifier;

得到的 transaction_id receipt_data goodID需要上传到app 服务器校验(具体看后端的需求)

点击购买,成功下单,苹果会返回内购产品的数据,如图:

image

成功下单后,会弹出一个界面,这里是输入已经在沙箱注册的app id

image

购买成功后,苹果服务器会返回,订单信息

image

iappurchasing's People

Contributors

andrewljj 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.