2012-03-01 210 views
0

我目前想實現Django的貝寶自適應支付到我的應用程序,並已運行到哪裏鏈支付的情況下不能正常工作,由於589023 - If a fractional amount is rounded due to currency conversion, funds could be lost貝寶自適應支付589023

在我們的網站上,我們採取6%的佣金和下面是我們的代碼的一個簡單例子。

amount = 5 
commission = amount * 0.06 
# commission = 0.3 
data['receiverList'] = {'receiver': [{'email': settings.PAYPAL_EMAIL, 
    'amount': unicode(amount), 
    'primary': 'true'}, 
    {'email': secondary_receiver, 
    # 'amount': unicode(5 - 0.3), 
    'amount': unicode(amount - commission), 
    'primary': 'false'}]} 

是否有不同的方法我應該計算出金額? 我應該爲佣金做一個不同的計算嗎?

任何提示將受到歡迎。

回答

1

這就是我們解決了一個iPhone應用程序的貝寶(沙盒)錯誤 「589023」:

-(void)payWithPayPal{ 
    for (int i=0;i<numberOfReceipents; i++) { 
     PayPal *payPal=[PayPal getPayPalInst]; 
     payPal.shippingEnabled = FALSE; 
     payPal.dynamicAmountUpdateEnabled = NO; 
     payPal.feePayer = FEEPAYER_EACHRECEIVER; 

     PayPalPayment *payment = [[[PayPalPayment alloc] init] autorelease]; 
     payment.recipient = @"[email protected]";  
     payment.paymentCurrency = @"USD"; 
     payment.description = @"Payment Discription here..."; 

     SampleSingleton *sample=[SampleSingleton sharedInstance]; 
     payment.merchantName =[sample getStrRestaurantName]; 
     payment.invoiceData = [[[PayPalInvoiceData alloc] init] autorelease]; 
     payment.invoiceData.invoiceItems = [NSMutableArray array]; 

     PayPalInvoiceItem *item = [[PayPalInvoiceItem alloc] init];    
     item.totalPrice=[NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%.2f", 126.34545]]; // If u give xxx.xx , no need to give the %.2f , u can give directly %f 

     item.name = objTempReceived.strItemName; 
     item.itemId = @"Item ID"; 

     [payment.invoiceData.invoiceItems addObject:item]; 

     [item release]; 
    } 

    payment.subTotal = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%.2f",126.34545]]; //Total and Subtotal must be equal 
    payment.invoiceData.totalTax = [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%.2f",3.34]]; 

    NSLog(@"Total Tax is :%@",[payment.invoiceData.totalTax stringValue]); 

    [payPal checkoutWithPayment:payment]; 
}