Developer's Guide
Mobile Payments Library Developer Guide and Reference –iOS Edition August 2012 35
- (NSMutableArray *)adjustAmountsAdvancedForAddress:(PayPalAddress const
*)inAddress andCurrency:(NSString const *)inCurrency
andReceiverAmounts:(NSMutableArray *)receiverAmounts
andErrorCode:(PayPalAmountErrorCode *)outErrorCode {
NSMutableArray *returnArray = [NSMutableArray
arrayWithCapacity:[receiverAmounts count]];
for (PayPalReceiverAmounts *amounts in receiverAmounts) {
//leave the shipping the same, change the tax based on the
state
if ([inAddress.state isEqualToString:@"CA"]) {
amounts.amounts.tax = [NSDecimalNumber
decimalNumberWithString:[NSString
stringWithFormat:@"%.2f",[amounts.amounts.payment_amount floatValue] *
.1]];
} else {
amounts.amounts.tax = [NSDecimalNumber
decimalNumberWithString:[NSString
stringWithFormat:@"%.2f",[amounts.amounts.payment_amount floatValue] *
.08]];
}
[returnArray addObject:amounts];
}
//if you need to notify the library of an error condition, do one of
the
following
//*outErrorCode = AMOUNT_ERROR_SERVER;
//*outErrorCode = AMOUNT_ERROR_OTHER;
return returnArray;
}