成安网 发表于 2022-10-4 17:05:15

ios使用paypal支付

ios使用paypal支付

zy88 发表于 2022-10-4 17:05:50

1、导入PayPal的SDK

2、添加-lc++和-ObjC到Other Linker Flags

4.导入框架:

```

***.framework

***.framework

***.framework

***.framework

***.framework

***.framework

***.framework

***.framework

***.framework

```

5、在AppDelegate中注册

```

;

```

6、paypal支付可自己封装工具类,便于使用

初始化PayPalConfiguration

```

PayPalConfiguration *payPalConfig = [ init];

    ***.acceptcreditcards=NO;

    ***.merchantname=@"有限公司";

    ***.languageorlocale = ;  //获取本地语言

```

订单信息PayPalPayment

```

PayPalPayment *payment = [ init];

    //订单总额

    OrderInfoModel *tempM = ***.transactions;

    PayInfo*infoM = ;

    ***.amount= ;

    //货币类型-RMB是没用的

    ***.currencycode= ***.currency;

    //订单描述

    ***.shortdescription= ***.desc;

```

7、调用paypal支付

```

;  //注意此处为上线状态  测试状态为PayPalEnvironmentSandbox沙盒测试

- (void)payPal:(PayPalItemModel*)model {

    PayPalConfiguration *con = ; //调用工具类

    if(model && model.***.count) {

        PayPalPayment*payment = ;  //调用工具类

        PayPalPaymentViewController*paymentViewController = [initWithPayment:paymentconfiguration:condelegate:self];

        ;

    }

}

```

8、通过代理获取支付状态

```

- (void)payPalPaymentDidCancel:(PayPalPaymentViewController*)paymentViewController; //取消支付

- (void)payPalPaymentViewController:(PayPalPaymentViewController*)paymentViewController didCompletePayment:(PayPalPayment*)completedPayment; //支付成功

```
页: [1]
查看完整版本: ios使用paypal支付