【问题标题】:Multiple Items or Multiple Quanities in PayPal iOS SDKPayPal iOS SDK 上的多个项目或多个数量
【发布时间】:2014-02-28 19:26:54
【问题描述】:

**针对运费/税务帮助更新**

NSDecimalNumber *totalPriceNumber = [NSDecimalNumber decimalNumberWithDecimal:[@(totalAmount) decimalValue]];
NSDecimalNumber *taxAmount = [NSDecimalNumber decimalNumberWithString:@"0.07"];
NSDecimalNumber *shippingAmount = [NSDecimalNumber decimalNumberWithString:@"20.00"];
NSDecimalNumber *subtotalAmount = [NSDecimalNumber decimalNumberWithString:@"5.00"];


NSString *productFirst = [hiddenGloveIDOne text];
NSString *productSecond = [hiddenGloveIDTwo text];
NSString *productThird = [hiddenGloveIDThree text];
NSString *productFourth = [hiddenGloveIDFour text];

NSString *productCheckOut = [NSString stringWithFormat:@"%@%@%@%@", productFirst, productSecond, productThird, productFourth];

self.resultText = nil;

PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.paymentDetails = [[PayPalPaymentDetails alloc] init];

payment.amount = totalPriceNumber;
payment.currencyCode = @"USD";
payment.shortDescription = productCheckOut;
payment.paymentDetails.subtotal = subtotalAmount;
payment.paymentDetails.shipping = shippingAmount;
payment.paymentDetails.tax = taxAmount;

有人对 PayPal iOS SDK 资源有任何经验吗?

现在我正在尝试将多个产品添加到总价格中。我已经看到这在后来的 iOS SDK 中是不允许的。有人知道这是否已更新为允许这样做吗?

如果没有。是否有可能拥有一种单独的产品,但允许价格乘以数量?

所以在这个应用程序中发生的事情是您选择一个医用手套 - 然后是尺寸 - 然后是数量。然后需要计算总数。

这里是github上的项目链接https://github.com/BG-Designs/MedExpress-Glove-App

如果我能得到这项工作的任何帮助或建议,我将不胜感激。谢谢!

*已更新***

- (IBAction)pay{

NSString *priceStringOne = [hiddenPriceOneTF text];

float priceFloatOne = [priceStringOne floatValue];

NSString *priceStringTwo = [hiddenPriceTwoTF text];

float priceFloatTwo = [priceStringTwo floatValue];

NSString *priceStringThree = [hiddenPriceThreeTF text];

float priceFloatThree = [priceStringThree floatValue];

NSString *priceStringFour = [hiddenPriceFourTF text];

float priceFloatFour = [priceStringFour floatValue];

NSString *quanityStringOne = [quanityFirstTF text];

float quanityFloatOne = [quanityStringOne floatValue];

NSString *quanityStringTwo = [quanitySecondTF text];

float quanityFloatTwo = [quanityStringTwo floatValue];

NSString *quanityStringThree = [quanityThirdTF text];

float quanityFloatThree = [quanityStringThree floatValue];

NSString *quanityStringFour = [quanityFourthTF text];

float quanityFloatFour = [quanityStringFour floatValue];

float totalAmount = priceFloatOne * quanityFloatOne + priceFloatTwo * quanityFloatTwo + priceFloatThree * quanityFloatThree + priceFloatFour * quanityFloatFour ;

NSString *result = [NSString stringWithFormat:@" $ %0.2f", totalAmount];

[totalPriceCalculated setText:result];

// Remove our last completed payment, just for demo purposes.
self.completedPayment = nil;

PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%@", totalPriceCalculated.text]];
payment.currencyCode = @"USD";
payment.shortDescription = @"Hipster t-shirt";

if (!payment.processable) {
    // This particular payment will always be processable. If, for
    // example, the amount was negative or the shortDescription was
    // empty, this payment wouldn't be processable, and you'd want
    // to handle that here.
}

【问题讨论】:

    标签: ios paypal


    【解决方案1】:

    这里是来自 PayPal 的戴夫。

    @user3014076,PayPal iOS SDK 目前仅支持每次付款的单个总金额。您需要在应用中进行加法和乘法运算,然后仅将最终结果提交给 SDK。

    【讨论】:

    • 感谢戴夫的回复。我不确定你是否看过 GitHub 文件,但我已经尝试过了。现在我不知道我是否走对了这条路。但我确实尝试过这个。从上面那部分添加了一些代码。
    • @user3014076 代码对我来说基本上是正确的,快速浏览一下。您遇到问题了吗?
    • 是的,payment.amount 字符串对我来说是空白的。但是,如果我执行普通字符串 [NSDecimal Number inItWithString = @"5.69"] (我想了想),那么 5.69 就会出现。所以就像不理解所有这些字符串/文本字段正在完成的计算一样。我想添加图片,但也没有声誉。
    • @user3014076 我很乐意帮助解决涉及 PayPal iOS SDK 的问题。但听起来您剩下的问题实际上涉及将您的totalPriceCalculated 对象(我不知道其类)转换为NSDecimalNumber。这是一般的 Objective C 问题,而不是 PayPal iOS SDK 问题。
    • 嘿,戴夫,你的问题很愚蠢,你如何将新的“税”和“运费”应用到视图控制器?有没有在线教程可以帮忙?
    猜你喜欢
    • 2013-08-03
    • 2013-04-02
    • 2011-04-30
    • 2012-05-30
    • 2021-10-15
    • 2015-01-28
    • 2015-08-01
    • 2015-05-23
    • 1970-01-01
    相关资源
    最近更新 更多