应用内支付IAP&&虚拟支付

 一、微信&&iOS 虚拟支付 

微信开放平台——iOS虚拟支付

“为什么小红书小程序能用虚拟支付,而我的不行?”

小红书属于电商服务,交易的商品都是实物商品,所以他们的会员卡属于实物电商会员体验。”

 

App拉起小程序:

https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Launching_a_Mini_Program/Launching_a_Mini_Program.html

 二、IAP

1、在iOS平台支付主要分为二类:第三方支付和应用内支付

第三方支付:支付宝,微信支付,京东(包含其他App内的支付等),银联支付等;

应用内支付:包含Apple Pay 和IAP-In App Purchase(内购)。

2、IAP:

原则1: 看商品/服务的实际消费场景是在 app 内,还是 app 之外。

原则 2:虽然是虚拟数字产品,但是金钱的最终流向不是平台自身,而是其他用户或第三方服务商(App 作为平台媒介),这时可以使用第三方支付。

3、IAP商品种类

消耗型项目:只可使用一次的产品,使用之后即失效,必须再次购买,如:游戏币、一次性虚拟道具等

非消耗型项目:只需购买一次,不会过期或随着使用而减少的产品。如:电子书

自动续期订阅:允许用户在固定时间段内购买动态内容的产品。除非用户选择取消,否则此类订阅会自动续期,如:Apple Music这类按月订阅的商品

非续期订阅:允许用户购买有时限性服务的产品,此 App 内购买项目的内容可以是静态的。此类订阅不会自动续期。

4、对账问题

1)当用户在同一订阅群组中订阅满一年后,您的订阅收益率将提高至 85%。当用户取消自动续期订阅时,其订阅时长将暂停累积。如果用户在 60 天内恢复订阅,其订阅时长将从恢复当天继续累积。相反,如果用户在 60 天后才恢复订阅,其订阅时长会清零并重新累积,收益率变为 70%。

2)若开发者在上一个日历年的收益100 万美元以下,将有资格参加 App Store 小型企业计划,并享受降至 15% 的佣金费率

3)上线并有付费后,苹果一般会每隔1-2个月给你打一次款,

4、实现

添加监听(addTransactionObserver)-> 添加新的交易(addPayment)-> 付款 -> 成功返回Purchased状态(SKPaymentTransactionStatePurchased)-> 校验支付票据 -> 校验成功则下发道具 -> 结束交易(finishTransaction)

StoreKit、

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

第一种方式:是去苹果后台请求获取商品,成功后将获取到的SKPayment对象添加到充值队列中。这样有个好处时,如果回调成功,说明你这个商品是有效的,这样设置到队列里肯定也是能够正常充值的。

第二种方式:直接将商品ID设置到SKPayment对象中。实际上,只要商品ID是有效的(苹果后台配置了的),那么直接设置后添加到支付队列中,是没问题的。这样,减少了一个向苹果请求SKProduct对象的时间。

- (void) requestProductData{   
    NSArray *arr = [[NSArray alloc]initWithObjects:@"com.test.pay6", nil]; //com.test.pay6是商品ID,苹果后台已经配置了的
    NSSet *productSet = [NSSet setWithArray:arr];
    SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:productSet];
    request.delegate = self; //需要继承<SKProductsRequestDelegate>协议
    [request start];
}

//SKProductsRequestDelegate Methods
//请求成功
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    for (int i = 0; i < response.products.count; ++i)
    {
        SKProduct* product = [response.products objectAtIndex:i];
        NSLog(@"苹果后台获得商品ID:%@ 商品描述:%@",product.productIdentifier,product.localizedDescription);
        SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
        payment.quantity = 1;
        payment.applicationUsername = orderId;  //透传参数,一会儿会说
        [[SKPaymentQueue defaultQueue] addPayment:payment];
    }
}
//请求失败
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
    NSLog(@"苹果后台商品请求失败:%@",error.description);
}

 

5、退款

ustomers request refunds in several ways, such as:

  • Contacting Apple Customer Support and asking for a refund

  • Logging in and using Apple's self-service tool, reportaproblem.apple.com, to request a refund

  • Asking their payment method issuer for a refund

退款

https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/handling_refund_notifications


官方: 

https://developer.apple.com/cn/in-app-purchase/

https://developer.apple.com/app-store/review/guidelines/#payments

 

 

  • 3.1.3(e) Goods and Services Outside of the App: If your app enables people to purchase physical goods or services that will be consumed outside of the app, you must use purchase methods other than in-app purchase to collect those payments, such as Apple Pay or traditional credit card entry.

参考:

如何绕过苹果 IAP 分成,直走第三方支付,老司机亲测七招大放送

IAP 实战之见坑填坑

 

 https://juejin.cn/post/7046969127205863438

https://www.jianshu.com/p/ff4a0597dc8f

https://www.jianshu.com/p/f090740991dd

 

http://www.woshipm.com/u/169185

posted @ 2019-12-23 14:14  尘恍若梦  阅读(1083)  评论(0编辑  收藏  举报