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

时间:2014-02-04 17:16:19

标签: ios paypal

**已更新为送货/税务帮助**

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.
}

1 个答案:

答案 0 :(得分:0)

戴夫来自PayPal。

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