PayPal iOS SDK中的多个项目或多个数量

PayPal iOS SDK中的多个项目或多个数量,ios,paypal,Ios,Paypal,**已更新装运/税务帮助** NSDecimalNumber *totalPriceNumber = [NSDecimalNumber decimalNumberWithDecimal:[@(totalAmount) decimalValue]]; NSDecimalNumber *taxAmount = [NSDecimalNumber decimalNumberWithString:@"0.07"]; NSDecimalNumber *shippingAmount = [NSDecimalN

**已更新装运/税务帮助**

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;
- (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.
}
有没有人有过使用PayPal iOS SDK的经验

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

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

因此,在这个应用程序中,你需要选择一个医用手套,然后选择一个尺寸,然后选择一个数量。然后需要计算总数

这里是github上项目的链接

任何帮助或建议,我可以得到这项工作将不胜感激。谢谢

*已更新***

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;
- (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.
}
这里是贝宝的戴夫


@用户3014076,PayPal iOS SDK目前仅支持每次付款的单一总额。您需要在应用程序中进行加法和乘法运算,然后只向SDK提交最终结果。

感谢Dave的回复。我不确定您是否查看过GitHub文件,但我尝试过这样做。现在我不知道我是否走对了这条路。但我确实试过这个。添加了上述部分的一些代码。@user3014076快速浏览一下,我觉得这些代码基本正确。你遇到问题了吗?是的,payment.amount字符串对我来说是空白的。但是如果我使用普通字符串[NSDecimal Number inItWithString=@“5.69”](我从头开始思考),那么5.69就会出现。因此,这就像不理解所有这些字符串/文本字段的计算一样。我想添加图像,但没有声誉。@user3014076我很乐意帮助解决涉及PayPal iOS SDK的问题。但听起来剩下的问题实际上涉及将
totalpricecomputed
对象(其类我不知道)转换为
NSDecimalNumber
。这是一个通用的Objective C问题,而不是PayPal iOS SDK问题。嘿,Dave,Noobish问你一个问题,你如何将新的“税”和“运费”应用到视图控制器?有在线教程可以帮忙吗?