Paypal PHP REST服务-“;访问令牌没有所需的作用域;
我正在使用Paypal REST SDK用PHP编写代码。我已设置我的沙盒帐户以使用AUD。我是在意识到我最初的交易是以美元为单位的,并且交易正在进行中之后才得出这个结论的 使用我修改过的代码,我正在尝试创建付款-我想我会得到一个URL,允许我重定向用户以批准付款 我收到一条信息,上面写着: 异常:访问时获取Http响应代码403。重试0次。 字符串(215)“{”名称“:“必需的\u作用域\u缺少”,“消息“:“访问令牌没有必需的作用域”,“信息\u链接“:“调试\u id:“34683601f5dcd”}” 我的代码是: $apiContext=新的apiContext(新的OAuthTokenCredential)( “xxxxxx”, "xxxxxx");Paypal PHP REST服务-“;访问令牌没有所需的作用域;,php,rest,paypal,Php,Rest,Paypal,我正在使用Paypal REST SDK用PHP编写代码。我已设置我的沙盒帐户以使用AUD。我是在意识到我最初的交易是以美元为单位的,并且交易正在进行中之后才得出这个结论的 使用我修改过的代码,我正在尝试创建付款-我想我会得到一个URL,允许我重定向用户以批准付款 我收到一条信息,上面写着: 异常:访问时获取Http响应代码403。重试0次。 字符串(215)“{”名称“:“必需的\u作用域\u缺少”,“消息“:“访问令牌没有必需的作用域”,“信息\u链接“:“调试\u id:“34683601
任何关于这条信息的想法。在澳大利亚,Paypal似乎不支持直接信用卡支付,但我认为这不是问题所在 在您的Paypal开发者帐户中的“我的应用程序”>“您的应用程序”下,确保在“应用程序设置”部分启用了您尝试使用的功能
我想我可能也有同样的问题,你解决了吗?我想使用支付选项,但得到了同样的错误。我已经在上面的屏幕上启用了相同的功能,但它仍然给我们带来了相同的问题。在我的特殊情况下,当我遇到范围限制时,我正在创建一个计费计划。我必须单击“高级选项”并选中“计费协议-设置和管理客户的预定付款”,以确定范围限制。
//### 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);
}