Closed Shigeki1120 closed 5 years ago
Sample Code snippet:
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')
->setCurrency('USD')
->setQuantity(1)
->setSku("123123")
->setPrice(7.5);
$item2 = new Item();
$item2->setName('Granola bars')
->setCurrency('USD')
->setQuantity(5)
->setSku("321321")
->setPrice(2);
// adding ShippingAddress
$shippingAddress = new ShippingAddress();
$shippingAddress->setRecipientName("Brian Robinson")
->setLine1("4th Floor")
->setLine2("Unit #34")
->setCity("San Jose")
->setCountryCode("US")
->setPostalCode("95131")
->setPhone("2025550110")
->setState("CA");
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
$itemList->setShippingAddress($shippingAddress);
// adding shipping phone number
//$itemList->setShippingPhoneNumber("2025550110");
$details = new Details();
$details->setShipping(1.2)
->setTax(1.3)
->setSubtotal(17.50);
$amount = new Amount();
$amount->setCurrency("USD")
->setTotal(20)
->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
$baseUrl = "https://example.com";
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("$baseUrl/ExecutePayment.php?success=true")
->setCancelUrl("$baseUrl/ExecutePayment.php?success=false");
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
// Create payment with valid API context
try {
$payment->create($apiContext);
echo $payment;
} catch (PayPal\Exception\PayPalConnectionException $ex) {
echo $ex->getCode();
echo $ex->getData();
die($ex);
} catch (Exception $ex) {
die($ex);
}
Hi @Shigeki1120 , you can try adding Shipping Address along with phone number [ using $shippingAddress->setPhone("2025550110") ] or try adding the phone number using $itemList->setShippingPhoneNumber("2025550110") method. Both the ways prefill the phone number during the guest checkout . Please refer the above code snippet and below screen shot for the reference.
Guest Flow Screenshot:
General information
Issue description
I've been trying to pre-fill a billing address on the Paypal landing page for the guest checkout. Here is the code
As you can see, I am trying to set
payer_info
to thePayer
object. However, no matter what format I use I cannot populate the phone input on the Paypal landing page. Everything else can be filled without any problems.I have used this format
+13104039128
13104039128
1 310 403 9128
+1 310 403 9128
3104039128
310 403 9128
for the phone input but no luckDo you have any idea what's causing this issue?
P.S the phone number above is a valid U.S number, and the country and state input are pre-filled properly
Json payload
Here is a image with the pre populated inputs with the exception of the phone input