This repository was archived by the owner on Dec 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRazorPayForm.inc.php
More file actions
64 lines (53 loc) · 2.08 KB
/
RazorPayForm.inc.php
File metadata and controls
64 lines (53 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
import('lib.pkp.classes.form.Form');
class RazorPayForm extends Form
{
var $plugin;
/** @var QueuedPayment */
var $queuedPayment;
/**
* @param $plugin
* @param $queuedPayment QueuedPayment
*/
function __construct($plugin, $queuedPayment)
{
$this->plugin = $plugin;
$this->queuedPayment = $queuedPayment;
parent::__construct(null);
}
/**
* @copydoc Form::display()
*/
function display($request = null, $template = null)
{
// solution for the queuedPayment bug which should be related to the author but instead to the editor
if ($this->queuedPayment->type == 7) {
$user = Registry::get('user');
$this->queuedPayment->userId = $user->getId();
$queuedPaymentDao = DAORegistry::getDAO('QueuedPaymentDAO');
$queuedPaymentDao->updateObject($this->queuedPayment->getId(), $this->queuedPayment);
}
$templateMgr = TemplateManager::getManager($request);
try {
$amount = (float) $this->queuedPayment->amount * 100;
$journal = $request->getJournal();
$api = $this->plugin->getApi();
$order = $api->order->create([
'amount' => $amount,
'currency' => $this->queuedPayment->currencyCode,
]);
$templateMgr->assign('key_id', $this->plugin->getSetting($this->plugin->getCurrentContextId(), 'key_id'));
$templateMgr->assign('amount', $amount);
$templateMgr->assign('currency', $this->queuedPayment->currencyCode);
$templateMgr->assign('order_id', $order->id);
$templateMgr->assign('name', $journal->getLocalizedName());
$templateMgr->assign('callback_url', $request->url(null, 'payment', 'plugin', array($this->plugin->getName(), 'return'), array('queuedPaymentId' => $this->queuedPayment->getId())));
$templateMgr->assign('cancel_url', $request->url(null, 'index'));
$templateMgr->display($this->plugin->getTemplateResource('paymentForm.tpl'));
} catch (\Throwable $th) {
error_log('RazorPay transaction exception: ' . $th->getMessage());
$templateMgr->assign('messageTranslated', 'A transaction error occurred. Please contact the journal manager for details.');
$templateMgr->display('frontend/pages/message.tpl');
}
}
}