5

在 iphone 应用程序中,当使用 Paypal 沙盒测试帐户结帐所选购物车项目时,我收到错误“尚未收到 PayPal 令牌以进行此交易”。任何人都可以澄清错误是在服务器端还是在应用程序端?我的代码是---

- ( IBAction ) btnPaybyClicked:( id ) sender {
    HUD = [[MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES] retain];
    HUD.labelText = NSLocalizedString(@"hud_redirecting_to_paypal", @"");
    JBMLog(@"strPaypalDevicetoken %@", _strPaypalDevicetoken);

//    NSLog(@"strPaypalDevicetoken %@", _strPaypalDevicetoken);

    //NSURL *url = [NSURL URLWithString:PAYPAL_URL];
    NSURL *url = [NSURL URLWithString:PAYPAL_AIW_URL];
    NSLog(@"URLlll = %@",url);
    User *currentUserObj = [UserDefaults getUserProfile];

    float deliveryCharge = 0.0;

    _asiFormRequest = [ASIFormDataRequest requestWithURL:url];
    [_asiFormRequest addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded"];
    [_asiFormRequest setPostValue:[sender tag] == 0 ? PAYPAL_PAYWITH_PAYPAL: PAYPAL_PAYWITH_CREDITCARD forKey:@"landingPage"];
    [_asiFormRequest setPostValue:[NSNumber numberWithInt:currentUserObj.userId] forKey:@"userid"];
    [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%@ %@", currentUserObj.firstName, currentUserObj.lastName] forKey:@"custName"];
    [_asiFormRequest setPostValue:currentUserObj.address forKey:@"custAdress"];
    [_asiFormRequest setPostValue:currentUserObj.suburb forKey:@"custSuberb"];
    [_asiFormRequest setPostValue:currentUserObj.postalcode forKey:@"custPostCode"];
    [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%.2f", deliveryCharge] forKey:@"DeliveryCharge"];

    [_asiFormRequest setPostValue:currentUserObj.phone forKey:@"custPhone"];
    [_asiFormRequest setPostValue:currentUserObj.email forKey:@"custEmail"];


    NSMutableArray *mArCart = [[DBModel database] shoppingList];


    int i = 0;
    float totalAmount = 0.0;
    for (Product *productObj in mArCart) {
        [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%d",productObj.productId] forKey:[NSString stringWithFormat:@"productArray[%d][productId]", i]];

        [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%d",productObj.selectedColorId] forKey:[NSString stringWithFormat:@"productArray[%d][colorId]", i]];

        [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%d",productObj.selectedSizeId] forKey:[NSString stringWithFormat:@"productArray[%d][sizeId]", i]];

        [_asiFormRequest setPostValue:productObj.productName forKey:[NSString stringWithFormat:@"productArray[%d][name]", i]];

        [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%.2f", productObj.selectedPrice] forKey:[NSString stringWithFormat:@"productArray[%d][price]", i]];


        [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%d", productObj.selectedQuantity] forKey:[NSString stringWithFormat:@"productArray[%d][qty]", i]];

        i++;
        totalAmount += productObj.selectedPrice*productObj.selectedQuantity;
    }
    [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%.2f",totalAmount+deliveryCharge] forKey:@"amount"];

    [_asiFormRequest setPostValue:[NSString stringWithFormat:@"%.2f",totalAmount] forKey:@"ItemTotal"];

    NSURL *url1 = [NSURL URLWithString:[NSString stringWithFormat:@"%@?token=%@", PAYPAL_AIW_URL, _payPalToken]];
    NSLog(@"uuu%@",url1);

    paymentTotal = totalAmount+deliveryCharge;
    [_asiFormRequest setDelegate:self];
    [_asiFormRequest setTimeOutSeconds:REQEST_TIMEOUT];

    [_asiFormRequest setDidFinishSelector:@selector(finishedPayPalFirstCallReqest:)];  
    [_asiFormRequest setDidFailSelector:@selector(failedPayPalFirstCallReqest:)];
    [_asiFormRequest startAsynchronous];
}
4

0 回答 0