Php Paypal/Laravel可以';我不能实时付款
我遵循本教程在我的网站上使用Paypal服务实现支付: 但当我想从沙盒模式切换到实时模式(这是真正的支付)时,我的所有交易都会进入沙盒历史记录(你可以在Paypal帐户中查看) 以下是用于支付的函数“store()”的代码:Php Paypal/Laravel可以';我不能实时付款,php,laravel,paypal,Php,Laravel,Paypal,我遵循本教程在我的网站上使用Paypal服务实现支付: 但当我想从沙盒模式切换到实时模式(这是真正的支付)时,我的所有交易都会进入沙盒历史记录(你可以在Paypal帐户中查看) 以下是用于支付的函数“store()”的代码: public function store(Request $request) { // ### CreditCard $card = Paypalpayment::creditCard(); $card->setType("visa")
public function store(Request $request)
{
// ### CreditCard
$card = Paypalpayment::creditCard();
$card->setType("visa")
->setNumber("Some_Numbers")
->setExpireMonth("05")
->setExpireYear("2017")
->setCvv2("smth")
->setFirstName("MyName")
->setLastName("MyLastName");
$fi = Paypalpayment::fundingInstrument();
$fi->setCreditCard($card);
$payer = Paypalpayment::payer();
$payer->setPaymentMethod("credit_card")
->setFundingInstruments(array($fi));
//Payment Amount
$amount = Paypalpayment::amount();
$amount->setCurrency("EUR")
->setTotal("3");
$transaction = Paypalpayment::transaction();
$transaction->setAmount($amount)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
// ### Payment
// A Payment Resource; create one using
// the above types and intent as 'sale'
$payment = Paypalpayment::payment();
$payment->setIntent("sale")
->setPayer($payer)
->setTransactions(array($transaction));
try {
$payment->create($this->_apiContext);
} catch (\PPConnectionException $ex) {
return "Exception: " . $ex->getMessage() . PHP_EOL;
exit(1);
}
dd($payment);
}看看$this->\u apiContext包含什么。有一种模式需要设置为
live
才能工作
如果未找到,您可以创建apiContext对象,如下所示:
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'Live ClientId', // ClientID
'Live Client Secret' // ClientSecret
)
);
$apiContext->setConfig(
array(
'mode' => 'live',
'log.LogEnabled' => true,
'log.FileName' => 'PayPal.log',
'log.LogLevel' => 'FINE'
)
);
并在调用
$payment->create()时使用$apiContext代码>谢谢,但实际上我找不到您所说的这种模式,我在package webage上搜索了关键字“apiContext”,但什么也没有