内购遇见的那些坑

1. 苹果需要上传内购手机截屏  截到的图片上传失败 提示你上传有效的图片。 记着 你的图片一定要把手机连接电脑直接取 不要经过第三方的应用传递!

2. 内购支付的时候 上传给苹果的是。内购的项目ID。不是订单号码。另外苹果没有一个字段是记录订单号码的  

需要我们手动的改变苹果API的某一个字段的值。例如::


// 收到商品详细信息回掉的方法

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    self.request = nil;

    NSLog(@"response.products = %@", response.products);

    NSLog(@"-----------收到产品反馈信息--------------");

    

    NSArray *products = response.products;

    if (products.count != 0) {

        SKProduct *product = products[0];

        SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];

        

      //这里赋值。商品订单

        if (_IAPOrderId.length > 0) {

            payment.applicationUsername = _IAPOrderId;//充值用户的id,也就是uid.

        }

        [[SKPaymentQueue defaultQueue] addPayment:payment];//发起购买

    }


3.支付完成之后 需要服务器验证。我们需要传递给服务器支付凭证。目前该是这样的

332.

}33

    NSURL *receiptUrl;

    NSData *receiptData;

  receiptUrl = [[NSBundle mainBundle] appStoreReceiptURL];

    receiptData = [NSData dataWithContentsOfURL:receiptUrl];


  进行 base64转码
-(NSString *)encode:(const uint8_t *)input length:(NSInteger)length
{
    static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    NSMutableData *data = [NSMutableData dataWithLength:((length + 2) / 3) * 4];
    uint8_t *output = (uint8_t *)data.mutableBytes;
    for (NSInteger i = 0; i < length; i += 3)
    {
        NSInteger value = 0;
        for (NSInteger j = i; j < (i + 3); j++)
        {
            value <<= 8;
            if (j < length)
            {
                value |= (0xFF & input[j]);
            }
        }
        NSInteger index = (i / 3) * 4;
        output[index + 0] =                    table[(value >> 18) & 0x3F];
        output[index + 1] =                    table[(value >> 12) & 0x3F];
        output[index + 2] = (i + 1) < length ? table[(value >> 6)  & 0x3F] : '=';
        output[index + 3] = (i + 2) < length ? table[(value >> 0)  & 0x3F] : '=';
    }
    return [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值