2014-02-08 2 views
5

Ich bin in PHP mit dem Paypal REST SDK codieren. Ich habe meinen Sandbox-Account eingerichtet, um AUD zu verwenden. Ich habe das herausgefunden, nachdem ich festgestellt hatte, dass meine ersten Transaktionen in USD stattfanden und die Transaktionen gehalten wurden.Paypal PHP REST-Dienst - "Zugriff Token hat keinen erforderlichen Umfang"

Mit meinem überarbeiteten Code versuche ich, eine Zahlung zu erstellen - ich nehme an, dass ich eine URL zurückbekomme, die es mir erlaubt, den Benutzer umzuleiten, die Zahlung zu genehmigen.

Ich erhalte eine Nachricht, die sagt:

Ausnahme: Got Http-Response-Code 403 beim Zugriff auf https://api.sandbox.paypal.com/v1/payments/payment. 0 mal wiederholt. string (215) "{" name ":" REQUIRED_SCOPE_MISSING " "message": "Access-Token haben nicht erforderlichen Umfang", "information_link":" https://developer.paypal.com/webapps/developer/docs/api/#REQUIRED_SCOPE_MISSING " "debug_id": "34683601f5dcd"}"

Mein Code ist: $ apiContext = neuer ApiContext (neuer OAuthTokenCredential ( 'xxxxxx', 'xxxxxx'));

//### FundingInstrument 
    // A resource representing a Payer's funding instrument. 
    // For direct credit card payments, set the CreditCard 
    // field on this object. 
    $fi = new FundingInstrument(); 
    $creditCardToken = new CreditCardToken(); 
    $creditCardToken->setCreditCardId($creditcard->cardToken); 
    $fi->setCreditCardToken($creditCardToken); 

    // ### Payer 
    // A resource representing a Payer that funds a payment 
    // For direct credit card payments, set payment method 
    // to 'credit_card' and add an array of funding instruments. 
    $payer = new Payer(); 
    $payer->setPaymentMethod("credit_card") 
     ->setFundingInstruments(array($fi)); 

    // ### Itemized information 
    // (Optional) Lets you specify item wise 
    // information 
    $paymentItems=Yii::app()->session['paymentitems']; 
    $items=array(); 
    $total=0; 
    foreach ($paymentItems as $item) 
    { 
     $pp_item = new Item(); 
     $pp_item->setName("Donation to ".$item->organisation->organisationName) 
      ->setCurrency('AUD') 
      ->setQuantity(1) 
      ->setPrice($item->amount); 
     array_push($items,$pp_item); 
     $total+=(float)$item->amount; 
    } 
    $itemList = new ItemList(); 
    $itemList->setItems($items);   
    // ### Amount 
    // Lets you specify a payment amount. 
    // You can also specify additional details 
    // such as shipping, tax. 
    $amount = new Amount(); 
    $amount->setCurrency("AUD") 
     ->setTotal($total); 

    // ### Transaction 
    // A transaction defines the contract of a 
    // payment - what is the payment for and who 
    // is fulfilling it. 
    $transaction = new Transaction(); 
    $transaction->setAmount($amount) 
     ->setItemList($itemList) 
     ->setDescription("Payment description"); 

    // ### Payment 
    // A Payment Resource; create one using 
    // the above types and intent set to sale 'sale' 
    $payment = new Payment(); 
    $payment->setIntent("sale") 
     ->setPayer($payer) 
     ->setTransactions(array($transaction)); 
    // ### Create Payment 
    // Create a payment by calling the payment->create() method 
    // with a valid ApiContext (See bootstrap.php for more on `ApiContext`) href 

    // The return object contains the state. 
    try { 
     $response=$payment->create($apiContext); 
     var_dump($response); 
     //$this->redirect($response->links[0]->href); 
    } catch (PayPal\Exception\PPConnectionException $ex) { 
     echo "Exception: " . $ex->getMessage() . PHP_EOL; 
     var_dump($ex->getData()); 
     exit(1); 
    } 

Alle Gedanken, was diese Nachricht bedeutet. Es scheint, dass direkte Kreditkartenzahlungen von Paypal in Australien nicht unterstützt werden, aber ich denke nicht, dass das das Problem ist.

+0

Ich glaube, ich könnte das gleiche Problem haben, haben Sie es herausfinden? –

Antwort

6

Stellen Sie in Ihrem Paypal-Entwicklerkonto unter Meine Apps> [Ihre App] sicher, dass die Funktion, die Sie verwenden möchten, im Abschnitt APP-EINSTELLUNGEN aktiviert ist.

Example App Settings

+0

Ich möchte die Auszahlungsoption verwenden, bekomme aber den gleichen Fehler. Ich habe das gleiche auf dem Bildschirm oben aktiviert, aber es gibt uns immer noch das gleiche Problem. –