本文整理汇总了PHP中Paypal::buildNVPString方法的典型用法代码示例。如果您正苦于以下问题:PHP Paypal::buildNVPString方法的具体用法?PHP Paypal::buildNVPString怎么用?PHP Paypal::buildNVPString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paypal
的用法示例。
在下文中一共展示了Paypal::buildNVPString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: paypal_set_ec
/**
* Starts the transaction and gets the token. Afterwards it's passed off to the final transaction method.
* @param
*/
public function paypal_set_ec()
{
if ($this->request->is('post')) {
//Abort if cancel button was pressed
if (isset($this->request->data['cancel'])) {
//Pass the user along to an action that will clear the account and the upload
$this->redirect(array('controller' => 'users', 'action' => 'clear_user_data', $this->request->data['Upload']['user_id']));
break;
}
//Check to make sure that the total codes haven't already been added to this file
$upload = $this->Upload->read(null, $this->request->data['Upload']['id']);
if (intval($upload['Upload']['total_codes']) > 0) {
if (intval($upload['Upload']['total_codes']) == count($upload['Code'])) {
$this->Session->setFlash(__('Error! No more codes can be added to this upload. Please re-upload the file.', true), 'message_fail');
$this->render('paypal_back_to_add');
return;
}
}
//do paypal setECCheckout
App::import('Model', 'Paypal');
$paypal = new Paypal();
$codePrice = $this->Upload->Code->getPrice($this->request->data['Upload']['total_codes']);
$itemName = $this->Upload->Code->getItemName($this->request->data['Upload']['total_codes']);
$nvpStr = $paypal->buildNVPString($codePrice, $itemName, $this->request->data['Upload']['user_id'], $this->request->data['Upload']['id'], $this->request->data['Upload']['total_codes']);
if ($paypal->setExpressCheckout($nvpStr)) {
$result = $paypal->getPaypalUrl($paypal->token);
} else {
$this->log($paypal->errors);
$result = false;
}
//debug($this->request);
if (false !== $result) {
//The result should look like the following
//https://www.sandbox.paypal.com/incontext?token=EC-09N44269CG053064W
$this->redirect($result);
} else {
$this->Session->setFlash(__('Error while connecting to PayPal, Please try again', true));
}
}
$payment_options = $this->Upload->Code->getPaymentOptions();
//Get the options array for the select list
$this->set(compact('payment_options'));
}