AliAPP 支付宝支付

#import "ViewController.h"


#import "Order.h"


#import <AlipaySDK/AlipaySDK.h>


#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<DataSigner> 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);

        }];

    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值