Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Contact Info - Phone Number - Guest Checkout - Missing #1336

Open
galexmay opened this issue Feb 9, 2020 · 0 comments
Open

Contact Info - Phone Number - Guest Checkout - Missing #1336

galexmay opened this issue Feb 9, 2020 · 0 comments

Comments

@galexmay
Copy link

galexmay commented Feb 9, 2020

I am trying to pass my customer's phone number to populate the field in the guest checkout but no matter where I put it, it seem to be ignored. This is the code that I am using.

`
$addr1="First line of address AM";
$addr2="Second line of address AM";
$city="City AM";
$postcode="GL1 5LA";
$email="[email protected]";
$first_name="First name AM";
$last_name="Surname AM";
$phone="012345678890";

$baseaddress = new \PayPal\Api\Address();
// $baseaddress = new \PayPal\Api\BaseAddress();
$baseaddress
->setPhone($phone)
->setLine1($addr1)
->setLine2($addr2)
->setCity($city)
->setCountryCode('GB')
->setPostalCode($postcode)
->setStatus('UNCONFIRMED')
;

$shippingAddress = new \PayPal\Api\ShippingAddress();
$shippingAddress->setRecipientName($first_name." ".$last_name)
->setPhone($phone)
->setLine1($addr1)
->setLine2($addr2)
->setCity($city)
->setCountryCode('GB')
->setPostalCode($postcode)
;

$item1 = new \PayPal\Api\Item();
$item1->setName('Cut 2 the Quick')
->setCurrency('GBP')
->setQuantity(1)
->setSku("123123")
->setPrice(0.01);

$itemList = new \PayPal\Api\ItemList();
$itemList->setItems(array($item1));
$itemList->setShippingAddress($shippingAddress);

$payerinfo = new \PayPal\Api\PayerInfo();
$payerinfo
->setBillingAddress($baseaddress)
->setEmail($email)
->setFirstName($first_name)
->setLastName($last_name)
;

// https://developer.paypal.com/docs/api/payments/#payment_create
$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal')
->setPayerInfo($payerinfo)
;

$amount = new \PayPal\Api\Amount();
$amount->setTotal('0.01');
$amount->setCurrency('GBP');

$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);

$redirectUrls = new \PayPal\Api\RedirectUrls();
$redirectUrls->setReturnUrl("https://bladelaw/veriphy/paypalresponse.php")
->setCancelUrl("https://bladelaw/veriphy/paypalcancel.php");

$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setTransactions(array($transaction))
->setRedirectUrls($redirectUrls);

// 4. Make a Create Call and print the values
try {
$payment->create($apiContext);
echo $payment;

echo "\n\nRedirect user to approval_url: " . $payment->getApprovalLink() . "\n";

}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
// This will print the detailed information on the exception.
//REALLY HELPFUL FOR DEBUGGING
echo $ex->getData();
}
`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant