2017-03-24 42 views
0

我的PayPal融入我的應用程序的支付頁面上的任何金額:IOS貝寶:如何讓用戶通過使用下面的代碼進入貝寶

- (IBAction)MakePayment:(id)sender 
{ 
    PayPalItem * item1 = [PayPalItem itemWithName:@"Item" withQuantity:1 withPrice:[NSDecimalNumber decimalNumberWithString:@"0.04"] withCurrency:@"USD" withSku:@"SKU-Item"]; 

    NSArray * items = @[item1]; 
    NSDecimalNumber * subtotal = [PayPalItem totalPriceForItems:items]; 

    NSDecimalNumber * shipping = [[NSDecimalNumber alloc]initWithString:@"0.0"]; 
    NSDecimalNumber * tax = [[NSDecimalNumber alloc]initWithString:@"0.0"]; 

    PayPalPaymentDetails * paymentDetails = [PayPalPaymentDetails paymentDetailsWithSubtotal:subtotal withShipping:shipping withTax:tax]; 

    NSDecimalNumber * total = [[subtotal decimalNumberByAdding:shipping]decimalNumberByAdding:tax]; 

    PayPalPayment * payment = [[PayPalPayment alloc]init]; 
    payment.amount = total; 

    payment.currencyCode = @"USD"; 
    payment .shortDescription = @"My Payment"; 

    payment.items = items; 
    payment.paymentDetails = paymentDetails; 

    if(!payment.processable) 
    { 

    } 

    PayPalPaymentViewController * paymentViewController = [[PayPalPaymentViewController alloc]initWithPayment:payment configuration:self.payPalconfig delegate:self]; 
    [self presentViewController:paymentViewController animated:YES completion:nil]; 

} 

在這段代碼中我通過代碼輸入量。但根據要求,用戶必須在付款頁面上手動輸入任何金額。 請給我建議任何代碼,我可以讓用戶通過顯示金額字段在付款頁面上手動輸入金額。

回答

2

如果您希望允許用戶輸入或選擇價格,那麼請用戶在出現paypal控制器之前用textfield手動輸入。

您不能在貝寶控制器中輸入價格。然後你可以在貝寶控制器中傳遞價格值。

+0

感謝您的回答 – Abhi

+0

歡迎@Abhi :) –