天天看點

iOS跳轉支付寶 微信支付成功後一直不會傳回

哎, 是後來改過一次Bundle id,URL Schemes 沒改,  支付寶的話appScheme也要和 URL Schemes改一直

iOS跳轉支付寶 微信支付成功後一直不會傳回

- (void)alipayOrderWithOrderNum:(NSString *)orderNum

                    productName:(NSString *)productName

             productDescription:(NSString *)productDescription

                         amount:(double)amount

{

    Order *order = [[Order alloc] init];

    order.partner = KAliPartner;

    order.seller = KAliSeller;

    order.tradeNO = orderNum; //訂單号

    order.productName = productName; //商品标題

    order.productDescription = productDescription; //商品描述

    order.amount = [NSString stringWithFormat:@"%.2f", amount]; //支付總價

    order.notifyURL =  KAliNotifyURL; //回調URL

    order.service = @"mobile.securitypay.pay";

    order.paymentType = @"1";

    order.inputCharset = @"utf-8";

    order.itBPay = @"30m";

    order.showUrl = @"m.alipay.com";

    //應用注冊scheme,在AlixPayDemo-Info.plist定義URL types

    NSString *appScheme = @"BunldId";

    //将商品資訊拼接成字元串

    NSString *orderSpec = [order description];

    //擷取私鑰并将商戶資訊簽名,外部商戶可以根據情況存放私鑰和簽名,隻需要遵循RSA簽名規範,并将簽名字元串base64編碼和UrlEncode

    id<DataSigner> signer = CreateRSADataSigner(KAliPrivateKey);

    NSString *signedString = [signer signString:orderSpec];

    //将簽名成功字元串格式化為訂單字元串,請嚴格按照該格式

    NSString *orderString = nil;

    if (signedString != nil)

    {

        orderString = [NSString stringWithFormat:@"%@&sign=\"%@\"&sign_type=\"%@\"",

                       orderSpec, signedString, @"RSA"];

        [[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {

            [MBProgressHUD hideMessage];

            NSLog(@"reslut = %@",resultDic);

        }];

    }

}