Coder Social home page Coder Social logo

gwiap's Introduction

GWIap 功能

简化苹果app内购买

使用方式

//pid是产品id,这个id需要你在itunes connect里面新建
 NSSet* dataSet = [[NSSet alloc] initWithObjects:pid, nil];
 if([IAPShare sharedHelper].iap){
    [[SKPaymentQueue defaultQueue] removeTransactionObserver:[IAPShare sharedHelper].iap];
 }
 [IAPShare sharedHelper].iap = [[IAPHelper alloc] initWithProductIdentifiers:dataSet];
 [IAPShare sharedHelper].iap.production = YES;//是真实产品,而不是测试。本lib支持客户端验证是否支付成功,但是将验证过程放在服务器更安全。
 [[IAPShare sharedHelper].iap requestProductsWithCompletion:^(SKProductsRequest* request,SKProductsResponse* response){
      if(response > 0 ) {
          SKProduct* product =[[IAPShare sharedHelper].iap.products objectAtIndex:0];
	  [[IAPShare sharedHelper].iap buyProduct:product onCompletion:^(SKPaymentTransaction* trans){  
	      if(trans.error){
	         NSLog(@"Fail %@",[trans.error localizedDescription]);
              }else if(trans.transactionState == SKPaymentTransactionStatePurchased) {
	         receipt = trans.transactionReceipt;
		 //   服务器验证,将receipt上传到服务器,服务器通过苹果接口进行验证。
	      }else if(trans.transactionState == SKPaymentTransactionStateFailed) {
	          NSLog(@"Fail");
	     }
	   }];
      }
 }];

安装

源码安装

  1. 直接下载文件,将源文件集成到你的工程

cocopods安装

  1. 未安装cocopods请自行安装.
  2. 在terminal中执行pod search GWIap.
  3. 编辑Podfile,添加 pod 'GWIap','~> 0.0.1'
  4. 执行pod install --verbose --no-repo-update,后面加了参数,目的是快速安装.

gwiap's People

Contributors

yaonimingsanqian avatar

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.