直播软件搭建中如何介入iOS海外支付——Braintree+PayPal篇
如果想上架苹果商店,那么直播软件搭建工作中,必不可少的工作之一便是接入IOS支付功能,国内版的具体的操作曾写过,今天主要讲下IOS海外支付接入方式——以Braintree+PayPal为例。
1.首先注册沙盒/生产环境账号
沙盒环境注册/登陆链接: https://www.braintreepayments.com/sandbox
生产环境注册/登陆链接: https://www.braintreegateway.com/login
2.登陆到对应环境的控制台后点击【设置】=> API => 选择Generate New Tokenzstion Key
3.下载SDK
Pod方式
pod ‘BraintreeDropIn’
手动导入
Sdk下载链接https://github.com/braintree/braintree_ios
SDK就这样申请下来了,等直播软件搭建到服务器上以后再进行接入,下载完毕之后导入BraintreeCore、BraintreePaypal到工程中。
4.配置 URL Schemes
格式:bunldID+.payments
在 targets - info - Url Types中添加 bunldID+.payments
5.支付页面代码配置
-(void)viewDidLoad { [super viewDidLoad]; UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 40)]; [button setTitle:@"paypal" forState:UIControlStateNormal]; [button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonOnClick) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; } -(BTPayPalDriver *)payPalDriver{ if (!_payPalDriver) { BTAPIClient *braintreeClient = [[BTAPIClient alloc] initWithAuthorization:@"production_bn7dy6sh_m7rf4gn9dmswttsh"]; _payPalDriver = [[BTPayPalDriver alloc] initWithAPIClient:braintreeClient]; _payPalDriver.viewControllerPresentingDelegate = self; } return _payPalDriver; } -(void)buttonOnClick{ NSString *price = @"199"; NSString *orderNo = @"100320_201222135431766"; BTPayPalRequest *request = [[BTPayPalRequest alloc] initWithAmount:price]; request.currencyCode = @"USD"; BTPayPalLineItem *item = [[BTPayPalLineItem alloc] initWithQuantity:@"1" unitAmount:price name:@"商品名称" kind:BTPayPalLineItemKindDebit]; item.productCode = orderNo; //订单编号 request.lineItems = @[item]; [self.payPalDriver requestOneTimePayment:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error) { if (tokenizedPayPalAccount) { } else if (error) { } else { } }]; } #pragma mark - BTViewControllerPresentingDelegate -(void)paymentDriver:(id)paymentDriver requestsPresentationOfViewController:(UIViewController *)viewController{ viewController.modalPresentationStyle = 0; [self presentViewController:viewController animated:YES completion:nil]; } -(void)paymentDriver:(id)paymentDriver requestsDismissalOfViewController:(UIViewController *)viewController { [viewController dismissViewControllerAnimated:YES completion:^{ }]; }
在直播软件搭建中,如海外支付一样需要申请的SDK还有很多,想了解这方面的知识请看《开发直播app软件一定会用到第三方服务吗?》以及《直播平台建设过程中常用的三方功能都有哪些》
声明:以上内容为云豹科技原创,未经作者本人同意,禁止转载,否则将追究相关法律责任www.yunbaokj.com