Paypal PHP SDK payment status and no shipping please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using paypal php sdk. I have the following code:
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require __DIR__ . '/vendor/PayPal-PHP-SDK/autoload.php'; $dev_ClientID = 'xxxxxxxxxx'; $dev_ClientSecret = 'xxxxxxxxxx'; $apiContext = new \PayPal\Rest\ApiContext( new \PayPal\Auth\OAuthTokenCredential( $dev_ClientID ,$dev_ClientSecret ) ); $payer = new \PayPal\Api\Payer(); $payer->setPaymentMethod('paypal'); $amount = new \PayPal\Api\Amount(); $amount->setTotal('1.00'); $amount->setCurrency('USD'); $transaction = new \PayPal\Api\Transaction(); $transaction->setAmount($amount); $redirectUrls = new \PayPal\Api\RedirectUrls(); $redirectUrls->setReturnUrl("https://www.somedomain.com/paypal_success.php") ->setCancelUrl("https://www.somedomain.com/paypal_cancel.php"); // Create the WebProfile $presentation = new \PayPal\Api\Presentation(); $presentation->setLogoImage("http://www.yeowza.com/favico.ico") ->setBrandName("YeowZa! Paypal") ->setLocaleCode("US"); $inputfields = new \PayPal\Api\InputFields(); $inputfields ->getNoShipping(1); $webProfile = new \PayPal\Api\WebProfile(); $webProfile ->setName('somename' . uniqid()) ->setInputFields($inputfields) ->setTemporary(true); $webProfileId = $webProfile->create($apiContext)->getId(); $payment = new \PayPal\Api\Payment(); $payment->setExperienceProfileId($webProfileId); $payment->setIntent('sale') ->setPayer($payer) ->setTransactions(array($transaction)) ->setRedirectUrls($redirectUrls); try { $payment->create($apiContext); echo "\n\nRedirect user to approval_url: " . $payment->getApprovalLink() . "\n"; } catch (\PayPal\Exception\PayPalConnectionException $ex) { // This will print the detailed information on the exception. echo $ex->getData(); } ?>
I get the payment link but i still see the shipping info.
I have defined getNoShipping to true, maybe hooked web profile wrong. So thats one thing. The second thing I am not sure about is this.
I passed a payment and got redirected back to paypal_success.php with paymentId, token and PayerID. How would I use these to receive info about the transaction. I wish to make sure it actually occured.
I tried the following:
$paymentId = $_GET["paymentId"]; $token = $_GET["token"]; $PayerID = $_GET["PayerID"]; echo "paymentId: " . $paymentId . "<br>"; echo "token: " .$token . "<br>"; echo "PayerID: " .$PayerID . "<br>"; $curl = curl_init("https://api.sandbox.paypal.com/v1/checkout/orders/$paymentId"); curl_setopt($curl, CURLOPT_POST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $token, 'Accept: application/json', 'Content-Type: application/json' )); $response = curl_exec($curl); $result = json_decode($response); var_dump($result);
with the following result:
{ ["error"]=> string(13) "invalid_token" ["error_description"]=> string(35) "Token signature verification failed" }
Will appreciate any help rendered. Thanks

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- where does paypal payments go to if there is no linked phone or email to the seller ? in PayPal Payments Standard
- Couldn't receive International payment in PayPal Payments Standard
- Is it possible to make payments in RON (Romanian Leu) through PayPal? in REST APIs
- Sandbox account collect billing and shipping address in Sandbox Environment
- My PayPal is not allowing me to receive or send requests. in PayPal Payments Standard