AliAPP 支付宝支付

#import "ViewController.h"


#import "Order.h"


#import


#import "MyPayHeader.h"


#import "DataSigner.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    

}

- (IBAction)buy:(id)sender {

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

    //商户信息

    order.partner = PartnerID;

    order.seller = SellerID;

    //商品订单号

    order.tradeNO = @"1stone"; //订单ID(由商家??行制定)

    order.productName = @"一个宝石"; //商品标题

    order.productDescription = @"支付一分钱,购买十个宝石"; //商品描述

    order.amount = @"0.01"; //商品价格

    order.notifyURL = @"http://www.baidu.com"; //回调URL

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

    order.paymentType = @"1";

    order.inputCharset = @"utf-8";

    order.itBPay = @"30m";

    

    //应用注册scheme,AlixPayDemo-Info.plist定义URL types

    NSString *appScheme = @"alisdkdemo";

    

    //将商品信息拼接成字符串

    NSString *orderSpec = [order description];

    NSLog(@"orderSpec = %@",orderSpec);

    

    //获取私钥并将商户信息签名,外部商户可以根据情况存放私钥和签名,只需要遵循RSA签名规范,并将签名字符串base64编码和UrlEncode

    id signer = CreateRSADataSigner(PartnerPrivKey);

    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) {

            //callback处理支付结果】

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

        }];

    }

}

你可能感兴趣的:(AliAPP 支付宝支付)