Skip to content

Commit

Permalink
fixed eCoin to work, it sends on notify only return
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Mar 25, 2016
1 parent 04f8df2 commit e2bc574
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function items()
],
'merchant' => [
'class' => 'hiqdev\yii2\merchant\Module',
'returnPage' => '/finance/pay/return',
'notifyPage' => '/finance/pay/notify',
'finishPage' => '/finance/bill',
'depositClass' => 'hipanel\modules\finance\merchant\Deposit',
Expand Down
39 changes: 15 additions & 24 deletions src/controllers/PayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,37 @@
/**
* Class PayController.
*/
class PayController extends \yii\web\Controller
class PayController extends \hiqdev\yii2\merchant\controllers\PayController
{
/**
* {@inheritdoc}
* @var \hipanel\modules\finance\Module
*/
public $module;
public function getMerchantModule()
{
return $this->module->getMerchant();
}

/**
* {@inheritdoc}
*/
public $enableCsrfValidation = false;
public function render($view, $params = [])
{
return $this->getMerchantModule()->getPayController()->render($view, $params);
}

/**
* Action is designed to get the system notification from payment system,
* process it and report success or error for the payment system.
*
* @throws \yii\base\InvalidConfigException
* @return mixed
*/
public function actionNotify($transactionId = null)
public function checkNotify()
{
if (!$transactionId) {
$transactionId = Yii::$app->request->post('transactionId');
}
$history = $this->module->getMerchant()->readHistory($transactionId);
$transactionId = Yii::$app->request->get('transactionId') ?: Yii::$app->request->post('transactionId');
$history = $this->getMerchantModule()->readHistory($transactionId);
$data = array_merge([
'username' => $history['username'],
'merchant' => $history['merchant'],
'transactionId' => $transactionId,
], $_REQUEST);
#$data = array_merge($history, $_REQUEST);
Yii::info(http_build_query($data), 'merchant');
Yii::$app->get('hiresource')->setAuth([]);
Yii::$app->get('hiresource')->disableAuth();
try {
$result = Merchant::perform('Pay', $data);
} catch (HiArtException $e) {
$result = Err::set($data, $e->getMessage());
}
Yii::$app->get('hiresource')->enableAuth();

return $this->module->getMerchant()->renderNotify($result);
return $this->getMerchantModule()->completeHistory($result);
}
}

0 comments on commit e2bc574

Please sign in to comment.