You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
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')
;
$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();
}
`
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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;
}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
// This will print the detailed information on the exception.
//REALLY HELPFUL FOR DEBUGGING
echo $ex->getData();
}
`
The text was updated successfully, but these errors were encountered: