2016-03-21 6 views
0

私は以下のコードに示すようにPayPalサンドボックストランザクションを作成しました。それはうまく動作します。しかし、今私はpaypalサイトでの船積みのアドレスダイアログを無効にしたい。私は、この発見 :PHPでPayPalの配送オプションを無効にする方法

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

を私はそれが動作しませ得ます。何がまだ失われていますか?

$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) { } 

答えて

2

それは古い質問ですが、私は、それはまだ関連だと思う:

あなたは、プロファイル(例えばWebProfile)でInputFieldsをラップする必要があります。

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

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

次に、プロファイルを作成して支払いに追加します。

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

$payment = new Payment(); 
$payment->setExperienceProfileId($webProfileId); 
関連する問題