0
我一直在試圖按照這裏的例子來實現一個PayPal功能集成到我的應用程序:http://www.alexventure.com/2011/04/02/zend-framework-and-paypal-api-part-2-of-2/Zend框架:貝寶
這是我在我的控制器paymentAction。
public function paymentAction()
{
$auth= Zend_Auth::getInstance();
$user= $auth->getIdentity();
$username = $user->username;
$cart = new Application_Model_DbTable_Cart();
$select = $cart->select()
->from(array('c' => 'cart'))
->join(array('p' => 'product'), 'p.productid = c.productid')
->where('username = ?', $username)
->setIntegrityCheck(false);
$fetch = $cart->fetchAll($select)->toArray();
$paypal = new My_Paypal_Client;
$amount = 0.0;
foreach($fetch as $item) {
$amount = $amount + ($item['price']*$item['quantity']);
}
$returnURL = 'http://www.google.com';
$cancelURL = 'http://www.yahoo.com';
$currency_code = 'USD';
$reply = $paypal->ecSetExpressCheckout(
$amount,
$returnURL,
$cancelURL,
$currency_code
);
if ($reply->isSuccessfull())
{
$replyData = $paypal->parse($reply->getBody());
if ($replyData->ACK == 'SUCCESS' || $replyData->ACK == 'SUCCESSWITHWARNING')
{
$token = $replyData->TOKEN;
$_SESSION['CHECKOUT_AMOUNT'] = $amount;
header(
'Location: ' .
$paypal->api_expresscheckout_uri .
'?&cmd=_express-checkout&token=' . $token
);
}
}
else
{
throw new Exception('ECSetExpressCheckout: We failed to get a successfull response from PayPal.');
}
}
但是,這是返回的錯誤。
Message: No valid URI has been passed to the client
我哪裏出錯了?如果需要,我很樂意提供來自我的應用程序其他區域的代碼。謝謝。
我已經修復了新的My_Paypal_Client()行。我已經實現了教程的第1部分。我認爲問題出在我的退貨和取消網址上? – Ayrx 2012-08-11 10:25:09