-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee9b91b
commit 376732c
Showing
5 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 12.10.2015 | ||
*/ | ||
namespace skeeks\cms\shop\paySystems; | ||
use skeeks\cms\shop\components\PaySystemHandlerComponent; | ||
use skeeks\cms\shop\models\ShopOrder; | ||
use yii\base\Component; | ||
use yii\helpers\ArrayHelper; | ||
use yii\widgets\ActiveForm; | ||
|
||
/** | ||
* Class PayPalPaySystem | ||
* @package skeeks\cms\shop\paySystems | ||
*/ | ||
class PayPalPaySystem extends PaySystemHandlerComponent | ||
{ | ||
public $payNowButtonUrl = 'https://www.sandbox.paypal.com/cgi-bin/websc'; //https://auth.robokassa.ru/Merchant/Index.aspx | ||
public $receiverEmail = '[email protected]'; | ||
public $sMerchantPass1 = ''; | ||
public $sMerchantPass2 = ''; | ||
|
||
/** | ||
* Можно задать название и описание компонента | ||
* @return array | ||
*/ | ||
static public function descriptorConfig() | ||
{ | ||
return array_merge(parent::descriptorConfig(), [ | ||
'name' => \skeeks\cms\shop\Module::t('app', 'PayPal'), | ||
]); | ||
} | ||
|
||
public function rules() | ||
{ | ||
return ArrayHelper::merge(parent::rules(), [ | ||
[['payNowButtonUrl'], 'string'], | ||
[['payNowButtonUrl'], 'url'], | ||
[['receiverEmail'], 'string'], | ||
]); | ||
} | ||
|
||
public function attributeLabels() | ||
{ | ||
return ArrayHelper::merge(parent::attributeLabels(), [ | ||
'payNowButtonUrl' => \skeeks\cms\shop\Module::t('app', 'Road to the api service paypal'), | ||
'receiverEmail' => 'PayPal account email', | ||
]); | ||
} | ||
|
||
/** | ||
* @return \skeeks\cms\shop\paySystems\robokassa\Merchant | ||
* @throws \yii\base\InvalidConfigException | ||
*/ | ||
public function getMerchant() | ||
{ | ||
/** | ||
* @var \skeeks\cms\shop\paySystems\robokassa\Merchant $merchant | ||
*/ | ||
$merchant = \Yii::createObject(ArrayHelper::merge($this->toArray(['baseUrl', 'sMerchantLogin', 'sMerchantPass1', 'sMerchantPass2']), [ | ||
'class' => '\skeeks\cms\shop\paySystems\robokassa\Merchant', | ||
])); | ||
|
||
return $merchant; | ||
} | ||
|
||
/** | ||
* @param ShopOrder $shopOrder | ||
* @return $this | ||
*/ | ||
public function paymentResponse(ShopOrder $shopOrder) | ||
{ | ||
return \Yii::$app->response->redirect(['shop/order/pay-pal', 'id' => $shopOrder->id]); | ||
|
||
/*return \Yii::$app->view->render('@skeeks/cms/shop/views/pay-system/pay-pal', [ | ||
'model' => $shopOrder | ||
], $this);*/ | ||
} | ||
|
||
public function renderConfigForm(ActiveForm $activeForm) | ||
{ | ||
echo $activeForm->field($this, 'payNowButtonUrl')->textInput(); | ||
echo $activeForm->field($this, 'receiverEmail')->textInput(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<? | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 07.04.2016 | ||
*/ | ||
/* @var $this yii\web\View */ | ||
/* @var $payPal skeeks\cms\shop\paySystems\PayPalPaySystem */ | ||
/* @var $model \skeeks\cms\shop\models\ShopOrder */ | ||
|
||
$payPal = $model->paySystem->paySystemHandler; | ||
|
||
$returnUrl = \yii\helpers\Url::to(['/shop/order/view', 'id' => $model->id], true); | ||
$notifyUrl = \yii\helpers\Url::to(['/shop/order/pay-pal-notify'], true); | ||
|
||
$money = $model->money->convertToCurrency("RUB"); | ||
|
||
$customData = ['product_id' => $model->id]; | ||
$this->registerJs(<<<JS | ||
$(function() | ||
{ | ||
$('#payPal').submit(); | ||
}); | ||
JS | ||
) | ||
?> | ||
<div style="text-align: center; margin: 100px; font-size: 20px;"> | ||
Wait, is redirected to the payment system... | ||
</div> | ||
<div style="display: none"> | ||
<form action="<?php echo $payPal->payNowButtonUrl; ?>" method="post" id="payPal"> | ||
<input type="hidden" name="cmd" value="_xclick"> | ||
<input type="hidden" name="business" value="<?php echo $payPal->receiverEmail; ?>"> | ||
<input id="paypalItemName" type="hidden" name="item_name" value="Order #<?= $model->id; ?>"> | ||
<input id="paypalQuantity" type="hidden" name="quantity" value="1"> | ||
<input id="paypalAmmount" type="hidden" name="amount" value="<?= $money->getValue(); ?>"> | ||
<input type="hidden" name="no_shipping" value="1"> | ||
<input type="hidden" name="return" value="<?php echo $returnUrl; ?>"> | ||
<input type="hidden" name="cancel_return" value="<?php echo $returnUrl; ?>"> | ||
<input type="hidden" name="notify_url" value="<?php echo $notifyUrl; ?>"> | ||
|
||
<input type="hidden" name="custom" value="<?php echo json_encode($customData);?>"> | ||
|
||
<input type="hidden" name="currency_code" value="RUB"> | ||
<input type="hidden" name="lc" value="US"> | ||
<input type="hidden" name="bn" value="PP-BuyNowBF"> | ||
|
||
<button type="submit"> | ||
Pay Now | ||
</button> | ||
</form> | ||
</div> |