【问题标题】:PayPal iOS SDK nil View ControllerPayPal iOS SDK 无视图控制器
【发布时间】:2014-11-05 13:18:45
【问题描述】:

我在我的应用程序中使用最新的 PayPal iOS sdk。出于某种未知原因,当我尝试初始化 PayPalPaymentViewContoller 然后呈现它时,它崩溃了。我已经确定 viewController 是 nil,但我不知道为什么。

以下是与此相关的两行代码。

第一行是init,第二行存在

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

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

有什么想法吗?让我告诉你你需要什么更多的信息。我不太确定还能提供什么。

【问题讨论】:

    标签: ios objective-c paypal


    【解决方案1】:

    这里是来自 PayPal 的戴夫。

    @linuxer 你关注our sample code了吗?特别是从第 5 步开始:

    // Check whether payment is processable. if (!payment.processable) { // If, for example, the amount was negative or the shortDescription was empty, then // this payment would not be processable. You would want to handle that here. }

    如果付款不是“可处理的”,但您仍然继续创建PayPalPaymentViewController,那么您确实会取回nil

    您还应该在控制台日志中看到与此相关的消息。你看过那里吗?

    【讨论】:

    • 谢谢戴夫。我检查了控制台并没有收到任何我尚未意识到的问题。然而,在我看到这个答案之前,我已经删除了所有代码并重新开始,这似乎解决了这个问题。我一定是在某个地方遇到了一些奇怪的事情。但是,我会将其标记为答案,因为我确信它与此有关。
    【解决方案2】:

    当您在此处的withPrice 参数中为PayPalItem 创建对象时,金额始终为小数点后两位。见下例:

    PayPalItem *item1 = [PayPalItem itemWithName:@"T Shirt" withQuantity:1 withPrice:[NSDecimalNumber decimalNumberWithString:**
    
    [NSString stringWithFormat:@"%0.2f",overAllTotalAmt]
    
    **] withCurrency:@"USD" withSku:@"Hip-00037"];
    

    【讨论】:

      猜你喜欢
      • 2020-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多