2016-03-21 10 views
0

Ich habe eine PayPal-Sandbox-Transaktion erstellt, wie Sie mit dem folgenden Code sehen. Es funktioniert gut. Aber jetzt möchte ich den Versand Adressdialog auf Paypal Website deaktivieren. Ich fand dies:So deaktivieren Sie die PayPal-Versandoption mit PHP

$inputfields = new \PayPal\Api\InputFields(); 
$inputfields->getNoShipping(1); 

aber ich bekomme es nicht funktioniert. Was fehlt noch?

$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET)); 

$amount = new Amount(); 
$amount->setCurrency('EUR'); 
$amount->setTotal($price);    
$amount->setDetails($details); 

$transaction = new Transaction(); 
$transaction->setAmount($amount) 
    ->setDescription(...) 
    ->setNotifyUrl( ...); 

$redirectUrls = new RedirectUrls(); 
$redirectUrls->setReturnUrl(...); 
    ->setCancelUrl(...);  

$payer = new Payer(); 
$payer->setPaymentMethod("paypal");   

$payment = new Payment(); 
$payment->setIntent("sale") 
    ->setPayer($payer) 
    ->setRedirectUrls($redirectUrls) 
    ->setTransactions(array($transaction)); 

try { 
    $payment->create($apiContext); 
} catch (\PayPal\Exception\PayPalConnectionException $e) { } 

Antwort

2

Es ist eine alte Frage, aber ich denke, es ist immer noch relevant:

Sie haben die Inputfields in einem Profil (WebProfil zum Beispiel) wickeln.

$inputfields = new \PayPal\Api\InputFields(); 
$inputfields 
    ->getNoShipping(1) 
    ->setAddressOverride(0);; 

$webProfile = new \PayPal\Api\WebProfile(); 
$webProfile 
    ->setName('testname' . uniqid()) 
    ->setInputFields($inputFields) 
    ->setTemporary(true); 

Dann erstellen Sie das Profil und fügen Sie es der Zahlung hinzu.

$webProfileId = $webProfile->create($apiContext)->getId(); 

$payment = new Payment(); 
$payment->setExperienceProfileId($webProfileId);