objective c - IOS PayPal: How to allow user to Enter any amount on payment page of PayPal

i integrate paypal into my app by using the following code:

- (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];

}

In this code i entered amount through codes. But according to the requirement user have to enter any amount manually on payment page. Please suggest me any code by which i can allow user to enter amount manually on payment page by displaying amount field.

1 Answer

  1. Randolph- Reply

    2019-11-14

    If you want to allow your user to enter or select price, then ask user enter manually with textfield before paypal controller appears.

    You can't enter price in paypal controller. Then you can pass price value in paypal controller.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>