本文整理汇总了PHP中OJSPaymentManager::getQueuedPayment方法的典型用法代码示例。如果您正苦于以下问题:PHP OJSPaymentManager::getQueuedPayment方法的具体用法?PHP OJSPaymentManager::getQueuedPayment怎么用?PHP OJSPaymentManager::getQueuedPayment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OJSPaymentManager
的用法示例。
在下文中一共展示了OJSPaymentManager::getQueuedPayment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle incoming requests/notifications
* @param $args array
* @param $request PKPRequest
*/
function handle($args, $request)
{
$journal = $request->getJournal();
$templateMgr = TemplateManager::getManager($request);
$user = $request->getUser();
$op = isset($args[0]) ? $args[0] : null;
$queuedPaymentId = isset($args[1]) ? (int) $args[1] : 0;
import('classes.payment.ojs.OJSPaymentManager');
$ojsPaymentManager = new OJSPaymentManager($request);
$queuedPayment =& $ojsPaymentManager->getQueuedPayment($queuedPaymentId);
// if the queued payment doesn't exist, redirect away from payments
if (!$queuedPayment) {
$request->redirect(null, 'index');
}
switch ($op) {
case 'notify':
import('lib.pkp.classes.mail.MailTemplate');
AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON);
$contactName = $journal->getSetting('contactName');
$contactEmail = $journal->getSetting('contactEmail');
$mail = new MailTemplate('MANUAL_PAYMENT_NOTIFICATION');
$mail->setReplyTo(null);
$mail->addRecipient($contactEmail, $contactName);
$mail->assignParams(array('journalName' => $journal->getLocalizedName(), 'userFullName' => $user ? $user->getFullName() : '(' . __('common.none') . ')', 'userName' => $user ? $user->getUsername() : '(' . __('common.none') . ')', 'itemName' => $queuedPayment->getName(), 'itemCost' => $queuedPayment->getAmount(), 'itemCurrencyCode' => $queuedPayment->getCurrencyCode()));
$mail->send();
$templateMgr->assign(array('currentUrl' => $request->url(null, null, 'payment', 'plugin', array('notify', $queuedPaymentId)), 'pageTitle' => 'plugins.paymethod.manual.paymentNotification', 'message' => 'plugins.paymethod.manual.notificationSent', 'backLink' => $queuedPayment->getRequestUrl(), 'backLinkLabel' => 'common.continue'));
$templateMgr->display('common/message.tpl');
exit;
}
parent::handle($args, $request);
// Don't know what to do with it
}
示例2: handle
/**
* Handle incoming requests/notifications
* @param $args array
* @param $request PKPRequest
*/
function handle($args, &$request)
{
$user =& $request->getUser();
$templateMgr =& TemplateManager::getManager();
$journal =& $request->getJournal();
if (!$journal) {
return parent::handle($args, $request);
}
// Just in case we need to contact someone
import('classes.mail.MailTemplate');
// Prefer technical support contact
$contactName = $journal->getSetting('supportName');
$contactEmail = $journal->getSetting('supportEmail');
if (!$contactEmail) {
// Fall back on primary contact
$contactName = $journal->getSetting('contactName');
$contactEmail = $journal->getSetting('contactEmail');
}
$mail = new MailTemplate('DPS_INVESTIGATE_PAYMENT');
$mail->setReplyTo(null);
$mail->addRecipient($contactEmail, $contactName);
$paymentStatus = $request->getUserVar('payment_status');
@session_start();
switch (array_shift($args)) {
case 'purchase':
error_log("Forming XML for transaction API call");
try {
# get access to queuedPayment
$orderId = $_SESSION['dps_plugin_payment_id'];
import('classes.payment.ojs.OJSPaymentManager');
$ojsPaymentManager = new OJSPaymentManager($request);
$queuedPayment =& $ojsPaymentManager->getQueuedPayment($orderId);
if (!$queuedPayment) {
throw new Exception("OJS: DPS: No order for this transaction or transaction ID lost from session. See DPS statement for OJS order number: TxnData1.");
}
$amount = sprintf("%01.2f", $queuedPayment->amount);
$domDoc = new DOMDocument('1.0', 'UTF-8');
$rootElt = $domDoc->createElement('GenerateRequest');
$rootNode = $domDoc->appendChild($rootElt);
$rootNode->appendChild($domDoc->createElement('PxPayUserId', $this->getSetting($journal->getId(), 'dpsuser')));
$rootNode->appendChild($domDoc->createElement('PxPayKey', $this->getSetting($journal->getId(), 'dpskey')));
$rootNode->appendChild($domDoc->createElement('MerchantReference', $this->getSetting($journal->getId(), 'dpsmerchant')));
$rootNode->appendChild($domDoc->createElement('AmountInput', $amount));
$rootNode->appendChild($domDoc->createElement('CurrencyInput', 'NZD'));
$rootNode->appendChild($domDoc->createElement('TxnType', 'Purchase'));
$rootNode->appendChild($domDoc->createElement('TxnData1', $orderId));
$rootNode->appendChild($domDoc->createElement('TxnData2', $user->getUserName()));
$rootNode->appendChild($domDoc->createElement('EmailAddress', $user->getEmail()));
$rootNode->appendChild($domDoc->createElement('UrlSuccess', $request->url(null, 'payment', 'plugin', array($this->getName(), 'success'))));
$rootNode->appendChild($domDoc->createElement('UrlFail', $request->url(null, 'payment', 'plugin', array($this->getName(), 'failure'))));
$xmlRequest = $domDoc->saveXML();
if (!$xmlRequest) {
throw new Exception("DPS: Generating XML API call failed ", "119");
}
error_log("xmlrequest: " . print_r($xmlRequest, true));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->getSetting($journal->getId(), 'dpsurl'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $domDoc->saveXML());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, $this->getSetting($journal->getId(), 'dpscertpath'));
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$result = curl_exec($ch);
$curlError = curl_error($ch);
$curlErrorNo = curl_errno($ch);
curl_close($ch);
# check that we got a response
if ($result == false) {
error_log("DPS error: {$curlError} ({$curlErrorNo})");
throw new Exception("DPS error: {$curlError}", $curlErrorNo);
}
# make sure response is valid.
error_log("Parsing response XML");
libxml_use_internal_errors(true);
$rexml = simplexml_load_string($result);
error_log("XML response: " . print_r($rexml, true));
if (!$rexml) {
error_log("Invalid XML response from DPS");
throw new Exception("Invalid XML response from DPS");
}
# check URL exists in response
if (!isset($rexml->URI[0])) {
throw new Exception("URI not returned: " . $rexml->ResponseText[0]);
}
$payment_url = (string) $rexml->URI[0];
# redirect to that URL
header("Location: {$payment_url}");
exit;
} catch (exception $e) {
@curl_close($ch);
error_log("Fatal error with credit card entry stage: " . $e->getCode() . ": " . $e->getMessage());
# create a notification about this error
//.........这里部分代码省略.........
示例3: handle
/**
* Handle incoming requests/notifications
* @param $args array
* @param $request PKPRequest
*/
function handle($args, $request)
{
$templateMgr = TemplateManager::getManager($request);
$journal = $request->getJournal();
if (!$journal) {
return parent::handle($args, $request);
}
// Just in case we need to contact someone
import('lib.pkp.classes.mail.MailTemplate');
// Prefer technical support contact
$contactName = $journal->getSetting('supportName');
$contactEmail = $journal->getSetting('supportEmail');
if (!$contactEmail) {
// Fall back on primary contact
$contactName = $journal->getSetting('contactName');
$contactEmail = $journal->getSetting('contactEmail');
}
$mail = new MailTemplate('PAYPAL_INVESTIGATE_PAYMENT');
$mail->setReplyTo(null);
$mail->addRecipient($contactEmail, $contactName);
$paymentStatus = $request->getUserVar('payment_status');
switch (array_shift($args)) {
case 'ipn':
// Build a confirmation transaction.
$req = 'cmd=_notify-validate';
if (get_magic_quotes_gpc()) {
foreach ($_POST as $key => $value) {
$req .= '&' . urlencode(stripslashes($key)) . '=' . urlencode(stripslashes($value));
}
} else {
foreach ($_POST as $key => $value) {
$req .= '&' . urlencode($key) . '=' . urlencode($value);
}
}
// Create POST response
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->getSetting($journal->getId(), 'paypalurl'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: PKP PayPal Service', 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: ' . strlen($req)));
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
$ret = curl_exec($ch);
$curlError = curl_error($ch);
curl_close($ch);
// Check the confirmation response and handle as necessary.
if (strcmp($ret, 'VERIFIED') == 0) {
switch ($paymentStatus) {
case 'Completed':
$payPalDao = DAORegistry::getDAO('PayPalDAO');
$transactionId = $request->getUserVar('txn_id');
if ($payPalDao->transactionExists($transactionId)) {
// A duplicate transaction was received; notify someone.
$mail->assignParams(array('journalName' => $journal->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Duplicate transaction ID: {$transactionId}", 'serverVars' => print_r($_SERVER, true)));
$mail->send();
exit;
} else {
// New transaction succeeded. Record it.
$payPalDao->insertTransaction($transactionId, $request->getUserVar('txn_type'), String::strtolower($request->getUserVar('payer_email')), String::strtolower($request->getUserVar('receiver_email')), $request->getUserVar('item_number'), $request->getUserVar('payment_date'), $request->getUserVar('payer_id'), $request->getUserVar('receiver_id'));
$queuedPaymentId = $request->getUserVar('custom');
import('classes.payment.ojs.OJSPaymentManager');
$ojsPaymentManager = new OJSPaymentManager($request);
// Verify the cost and user details as per PayPal spec.
$queuedPayment =& $ojsPaymentManager->getQueuedPayment($queuedPaymentId);
if (!$queuedPayment) {
// The queued payment entry is missing. Complain.
$mail->assignParams(array('journalName' => $journal->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Missing queued payment ID: {$queuedPaymentId}", 'serverVars' => print_r($_SERVER, true)));
$mail->send();
exit;
}
//NB: if/when paypal subscriptions are enabled, these checks will have to be adjusted
// because subscription prices may change over time
$queuedAmount = $queuedPayment->getAmount();
$grantedAmount = $request->getUserVar('mc_gross');
$queuedCurrency = $queuedPayment->getCurrencyCode();
$grantedCurrency = $request->getUserVar('mc_currency');
$grantedEmail = String::strtolower($request->getUserVar('receiver_email'));
$queuedEmail = String::strtolower($this->getSetting($journal->getId(), 'selleraccount'));
if ($queuedAmount != $grantedAmount && $queuedAmount > 0 || $queuedCurrency != $grantedCurrency || $grantedEmail != $queuedEmail) {
// The integrity checks for the transaction failed. Complain.
$mail->assignParams(array('journalName' => $journal->getLocalizedName(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Granted amount: {$grantedAmount}\n" . "Queued amount: {$queuedAmount}\n" . "Granted currency: {$grantedCurrency}\n" . "Queued currency: {$queuedCurrency}\n" . "Granted to PayPal account: {$grantedEmail}\n" . "Configured PayPal account: {$queuedEmail}", 'serverVars' => print_r($_SERVER, true)));
$mail->send();
exit;
}
// Update queued amount if amount set by user (e.g. donation)
if ($queuedAmount == 0 && $grantedAmount > 0) {
$queuedPaymentDao = DAORegistry::getDAO('QueuedPaymentDAO');
$queuedPayment->setAmount($grantedAmount);
$queuedPayment->setCurrencyCode($grantedCurrency);
$queuedPaymentDao->updateQueuedPayment($queuedPaymentId, $queuedPayment);
}
// Fulfill the queued payment.
if ($ojsPaymentManager->fulfillQueuedPayment($request, $queuedPayment, $this->getName())) {
exit;
}
// If we're still here, it means the payment couldn't be fulfilled.
//.........这里部分代码省略.........
示例4: handle
/**
* Handle incoming requests/notifications
* @param $args array
* @param $request PKPRequest
*/
function handle($args, &$request)
{
file_put_contents("outputfile2.txt", file_get_contents("php://input"));
$liqPayDao = DAORegistry::getDAO('LiqPayDAO');
//
$templateMgr =& TemplateManager::getManager();
$journal =& $request->getJournal();
// $liqPayDao->transactionExists('3333333');
// var_dump( $this->getSetting($journal->getId(), 'liqpaydebug'));
//
// if ($this->getSetting($journal->getId(), 'liqpaydebug')){
// die('wwww');
// }
// die('222ee');
if (!$journal) {
return parent::handle($args, $request);
}
// Just in case we need to contact someone
import('classes.mail.MailTemplate');
// Prefer technical support contact
$contactName = $journal->getSetting('supportName');
$contactEmail = $journal->getSetting('supportEmail');
if (!$contactEmail) {
// Fall back on primary contact
$contactName = $journal->getSetting('contactName');
$contactEmail = $journal->getSetting('contactEmail');
}
$mail = new MailTemplate('LIQPAY_INVESTIGATE_PAYMENT');
$mail->setReplyTo(null);
$mail->addRecipient($contactEmail, $contactName);
$liqpay = new LiqPay($this->getSetting($journal->getId(), 'liqpaypubkey'), $this->getSetting($journal->getId(), 'liqpayprivatkey'));
switch (array_shift($args)) {
case 'notification':
// data - результат функции base64_encode( $json_string )
//signature - результат функции base64_encode( sha1( $private_key . $data . $private_key ) )
$sign = base64_encode(sha1($this->getSetting($journal->getId(), 'liqpayprivatkey') . $request->getUserVar('data') . $this->getSetting($journal->getId(), 'liqpayprivatkey'), 1));
$this->log->info('Start transaction ' . $sign);
//var_dump($sign, $request->getUserVar('signature'), $_REQUEST);
// $params = json_decode (base64_decode($request->getUserVar('data')), true);
// var_dump($params);
//
// die;
// Check signature
if ((string) $sign == (string) $request->getUserVar('signature')) {
$params = json_decode(base64_decode($request->getUserVar('data')), true);
$this->log->info('Input parameters ' . var_export($params, true));
// Check transactions exist
$transactionId = $params['transaction_id'];
$this->log->info('Transaction ID ' . var_export($transactionId, true));
if ($liqPayDao->transactionExists($transactionId . rand(0, 100))) {
$this->log->info('Transaction is exists ' . var_export($transactionId, true));
// A duplicate transaction was received; notify someone.
$mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'data' => print_r($params, true), 'additionalInfo' => "Duplicate transaction ID: {$transactionId}", 'serverVars' => print_r($_SERVER, true)));
$mail->send();
exit;
} else {
$this->log->info('Payment status ' . var_export($params['status'], true));
// New transaction succeeded. Record it.
// $liqPayDao->insertTransaction(
// $transactionId,
// $params['type'],
// String::strtolower($params['sender_phone']),
// $params['status'],
// $params['liqpay_order_id'],
// date('Y-m-d H:i:s')
// );
//if debug mode turn on the all payments is success
if ($this->getSetting($journal->getId(), 'liqpaydebug')) {
$params['status'] = 'success';
}
switch ($params['status']) {
case 'success':
$params['description'];
preg_match('/\\/(\\d+$)/', $params['description'], $matches);
$this->log->info('Input queuedPaymentId ' . var_export($matches[1], true));
$queuedPaymentId = $matches[1];
import('classes.payment.ojs.OJSPaymentManager');
$ojsPaymentManager = new OJSPaymentManager($request);
// Verify the cost and user details as per PayPal spec.
$queuedPayment = $ojsPaymentManager->getQueuedPayment($queuedPaymentId);
if (!$queuedPayment) {
$this->log->info('Not found queued payment for ' . var_export($queuedPaymentId, true));
// The queued payment entry is missing. Complain.
$mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Missing queued payment ID: {$queuedPaymentId}", 'serverVars' => print_r($_SERVER, true)));
$mail->send();
exit;
}
//NB: if/when paypal subscriptions are enabled, these checks will have to be adjusted
// because subscription prices may change over time
$queuedAmount = $queuedPayment->getAmount();
var_dump($queuedPayment->getCurrencyCode());
die;
if ($queuedAmount || ($queuedCurrency = $queuedPayment->getCurrencyCode()) != ($grantedCurrency = $request->getUserVar('mc_currency')) || ($grantedEmail = String::strtolower($request->getUserVar('receiver_email'))) != ($queuedEmail = String::strtolower($this->getSetting($journal->getId(), 'selleraccount')))) {
// The integrity checks for the transaction failed. Complain.
$mail->assignParams(array('journalName' => $journal->getLocalizedTitle(), 'postInfo' => print_r($_POST, true), 'additionalInfo' => "Granted amount: {$grantedAmount}\n" . "Queued amount: {$queuedAmount}\n" . "Granted currency: {$grantedCurrency}\n" . "Queued currency: {$queuedCurrency}\n" . "Granted to PayPal account: {$grantedEmail}\n" . "Configured PayPal account: {$queuedEmail}", 'serverVars' => print_r($_SERVER, true)));
//.........这里部分代码省略.........