美文网首页
iOS 集成PayPal付款

iOS 集成PayPal付款

作者: 寒雨晚风 | 来源:发表于2020-01-03 17:17 被阅读0次

1、使用cocoapods

   pod'PayPal-iOS-SDK'

2、AppDelegate 中key 的设置

   [PayPalMobile initializeWithClientIdsForEnvironments:@{PayPalEnvironmentProduction:PAYPAL_PRODUCTION,PayPalEnvironmentSandbox:PAYPAL_SANDBOX}];

3、设置支付环境

  [PayPalMobile preconnectWithEnvironment:PayPalEnvironmentProduction];

PayPalEnvironmentProduction  正式环境

 PayPalEnvironmentSandbox

 PayPalEnvironmentNoNetwork

4、付款页面

一、@property(nonatomic, strong, readwrite) PayPalConfiguration *payPalConfig;

二、实现代理 PayPalPaymentDelegate

三、点击付款

- (void)onClickPayPalButtonAction:(NSString *)orderId{

    _payPalConfig = [[PayPalConfiguration alloc] init];

    _payPalConfig.acceptCreditCards = NO;

    _payPalConfig.languageOrLocale = [NSLocale preferredLanguages][0];

    NSString*priceString =grand_total;

    NSDecimalNumber*total = [NSDecimalNumberdecimalNumberWithString:priceString];

    PayPalPayment *payment = [[PayPalPayment alloc] init];

    payment.amount= total;

    payment.currencyCode = currency_info.code;

    payment.shortDescription=@"order summary";

    payment.custom=orderId;//self.order.order_no;

    //  payment.shippingAddress=  [PayPalShippingAddress shippingAddressWithRecipientName:@"1" withLine1:@"2" withLine2:@"3" withCity:@"3" withState:@"3" withPostalCode:@"4" withCountryCode:@"5"];

    PayPalPaymentViewController *paymentViewController = [[PayPalPaymentViewController alloc]initWithPayment:payment configuration:self.payPalConfig delegate:self];

    paymentViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;

    [self presentViewController:paymentViewController animated:YES completion:nil];

}

五、付款后代理方法 PayPalPaymentDelegate methods

- (void)payPalPaymentViewController:(PayPalPaymentViewController*)paymentViewControllerdidCompletePayment:(PayPalPayment*)completedPayment {

    NSLog(@"PayPal Payment Success!");

      [self dismissViewControllerAnimated:YES completion:nil];

        [MBProgressHUD showSuccess:@"PayPal Payment Success!" toView:self.view];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

        PaySuccess*pay=[[PaySuccessalloc]init];

        pay.order_id=completedPayment.custom;

        [self.navigationController pushViewController:pay animated:YES];

              });

}

- (void)payPalPaymentDidCancel:(PayPalPaymentViewController*)paymentViewController {

    NSLog(@"PayPal Payment Canceled");

      [self dismissViewControllerAnimated:YES completion:nil];

       dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

            [MBProgressHUD showSuccess:@"PayPal Payment failed!" toView:self.view];

                 });

}

相关文章

  • iOS 集成PayPal付款

    1、使用cocoapods pod'PayPal-iOS-SDK' 2、AppDelegate 中key 的设置...

  • Paypal支付集成 iOS

    集成流程: 1.去paypal开发者网站注册开发账号,在Dashboard里新增sandbox测试账号,并注册ap...

  • PayPal iOS 集成攻略

    这两天在研究如何在项目中集成PayPal的iOS SDK 但是百度到的资料很少,研究了两天拿出来和大家分享下,共同...

  • iOS braintree sdk for paypal 集成

    1、创建paypal的App 注册paypal business账号点击My Apps & Credentials...

  • iOS 集成 Braintree (Paypal) 支付

    我这里用到的是 自定义 UI 以及 一次性付款,也就是官方所说的 Checkout with PayPal 。 参...

  • iOS PayPal集成和使用

    一、创建并获取对应的ClientID 1、登录paypal开发者网站 PayPal开发者官网地址:https://...

  • 苹果牵手支付宝和 PayPal,实则是无奈的选择

    PayPal 宣布其付款服务即将在美国和其他国家/地区的加拿大和墨西哥等地 iOS 设备和 Mac 设备上使用,包...

  • Android接入PayPal支付

    前言 因业务需要,需要集成PayPal支付,故一边研究并顺便分享一下集成步骤。附上相关文档:PayPal集成官方文...

  • 无标题文章

    **thugslab**付款方式 > **英国** :银行卡转账 > **美国** :PayPal > **加拿大...

  • Paypal

    sdk下载地址: https://github.com/paypal/PayPal-iOS-SDK 最近项目要求做...

网友评论

      本文标题:iOS 集成PayPal付款

      本文链接:https://www.haomeiwen.com/subject/fgxtactx.html