123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- /**
- *
- * PHP Pro Bid $Id$ +spayWRTYaFwFUEhxXH5dAlBSNazHRQkRs9oOBNtJKM=
- *
- * @link http://www.phpprobid.com
- * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
- * @license http://www.phpprobid.com/license Commercial License
- *
- * @version 7.2
- */
- /**
- * paymate payment gateway model class
- */
- namespace Ppb\Model\PaymentGateway;
- use Cube\Controller\Request\AbstractRequest;
- class Paymate extends AbstractPaymentGateway
- {
- /**
- * payment gateway name
- */
- const NAME = 'Paymate';
- /**
- * required settings
- */
- const MERCHANT_ID = 'mid';
- /**
- * form post url
- */
- const POST_URL = 'https://www.paymate.com/PayMate/ExpressPayment';
- /**
- * paymate description
- */
- protected $_description = 'Click to pay using Paymate Express Payments.';
- public function __construct($userId = null)
- {
- parent::__construct(self::NAME, $userId);
- }
- /**
- *
- * check if the gateway is enabled
- *
- * @return bool
- */
- public function enabled()
- {
- if (!empty($this->_data[self::MERCHANT_ID])) {
- return true;
- }
- return false;
- }
- /**
- *
- * get setup form elements
- *
- * @return array
- */
- public function getElements()
- {
- $translate = $this->getTranslate();
- return array(
- array(
- 'form_id' => 'Paymate',
- 'id' => self::MERCHANT_ID,
- 'element' => 'text',
- 'label' => $this->_('Paymate Username'),
- 'description' => $translate->_('Enter the username you use to log into the Paymate website <br>'
- . 'Paymate IPN URL: <br>') . $this->getIpnUrl(),
- 'attributes' => array(
- 'class' => 'form-control input-medium',
- ),
- ),
- );
- }
- public function formElements()
- {
- return array(
- array(
- 'id' => self::MERCHANT_ID,
- 'value' => $this->_data[self::MERCHANT_ID],
- 'element' => 'hidden',
- ),
- array(
- 'id' => 'amt',
- 'value' => $this->getAmount(),
- 'element' => 'hidden',
- ),
- array(
- 'id' => 'amt_editable',
- 'value' => 'N',
- 'element' => 'hidden',
- ),
- array(
- 'id' => 'currency',
- 'value' => $this->getCurrency(),
- 'element' => 'hidden',
- ),
- array(
- 'id' => 'return',
- 'value' => $this->getIpnUrl(),
- 'element' => 'hidden',
- ),
- array(
- 'id' => 'ref',
- 'value' => $this->getTransactionId(),
- 'element' => 'hidden',
- ),
- array(
- 'id' => 'popup',
- 'value' => 'false',
- 'element' => 'hidden',
- ),
- );
- }
- public function getPostUrl()
- {
- return self::POST_URL;
- }
- /**
- *
- * process ipn
- *
- * @param \Cube\Controller\Request\AbstractRequest $request
- *
- * @return bool
- */
- public function processIpn(AbstractRequest $request)
- {
- $response = false;
- if ($request->isPost()) {
- $paymentStatus = $request->getParam('responseCode');
- $this->setTransactionId($request->getParam('ref'))
- ->setAmount($request->getParam('paymentAmount'))
- ->setCurrency($request->getParam('currency'))
- ->setGatewayPaymentStatus($request->getParam('responseCode'))
- ->setGatewayTransactionCode($request->getParam('transactionID'));
- if ($paymentStatus == 'PA') {
- $response = true;
- }
- }
- return $response;
- }
- }
|