AliAPP 支付宝支付
2016-05-17 17:33
344 查看
#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);
}];
}
}
#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);
}];
}
}
相关文章推荐
- [Mapped]
- 【JNI】拒绝各种坑!Android Studio 下创建JNI项目
- 强制开启android webview debug模式使用Chrome inspect
- 检测App采集IDFA及app上架要点
- Android 6.0 Runtime Permission API使用
- android5.0文字自动大写
- android最简洁的定时器源代码
- iOS 提交app错误 90096解决办法
- [__NSCFArray insertObject:atIndex:]: mutating method sent to immutable objec
- dialog 中显示listview
- android 6.0 指纹识别调用 Demo
- android 按home键返回到桌面后,再按桌面应用图标又重新打开该应用的解决方法
- ios开发——xcode重构(修改类名、文件名等)
- unity 3d实验屏幕坐标到世界坐标
- AppStore下载慢的真实原因
- iOS8 屏幕横竖屏分析
- Android Studio项目结构&AS构建基础
- AndroidTV桌面BriskTVLanucher
- Android中进程和线程
- iOS锄大地发牌算法