@@ -0,0 +1,97 @@ | |||
<?php | |||
namespace backend\controllers; | |||
use Yii; | |||
use yii\filters\AccessControl; | |||
use yii\data\ActiveDataProvider; | |||
use yii\web\Controller; | |||
use yii\web\NotFoundHttpException; | |||
use yii\filters\VerbFilter; | |||
use common\models\User; | |||
use c006\paypal_ipn\PayPal_Ipn; | |||
/** | |||
* ProduitController implements the CRUD actions for Produit model. | |||
*/ | |||
class PaiementController extends Controller | |||
{ | |||
var $enableCsrfValidation = false ; | |||
public function behaviors() | |||
{ | |||
return [ | |||
'verbs' => [ | |||
'class' => VerbFilter::className(), | |||
'actions' => [ | |||
], | |||
], | |||
'access' => [ | |||
'class' => AccessControl::className(), | |||
'rules' => [ | |||
[ | |||
'allow' => true, | |||
'roles' => ['@'], | |||
'matchCallback' => function ($rule, $action) { | |||
return Yii::$app->user->identity->status == USER::STATUS_ADMIN | |||
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER; | |||
} | |||
] | |||
], | |||
], | |||
]; | |||
} | |||
/** | |||
* Lists all Produit models. | |||
* @return mixed | |||
*/ | |||
public function actionIndex() | |||
{ | |||
return $this->render('index', [ | |||
]); | |||
} | |||
public function actionAnnuler() | |||
{ | |||
return $this->render('annuler', [ | |||
]); | |||
} | |||
public function actionSucces() | |||
{ | |||
return $this->render('succes', [ | |||
]); | |||
} | |||
public function beforeAction($action) | |||
{ | |||
if(Yii::$app->controller->action->id=="ipn") | |||
$this->enableCsrfValidation = false; | |||
return parent::beforeAction($action); | |||
} | |||
public function actionIpn() | |||
{ | |||
if (isset($_POST)) { | |||
$ipn = new PayPal_Ipn(true); | |||
if ($ipn->init()) | |||
{ | |||
/* Get any key/value */ | |||
$custom = $ipn->getKeyValue('custom'); | |||
/* | |||
Add your code here | |||
*/ | |||
} | |||
} | |||
/* Enable again if you use it */ | |||
Yii::$app->request->enableCsrfValidation = true; | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
<?php | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
?> | |||
<h1>Paiement annulé</h1> | |||
@@ -0,0 +1,27 @@ | |||
<?php | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
?> | |||
<h1>Paiement</h1> | |||
<h2>Prod</h2> | |||
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top"> | |||
<input type="hidden" name="cmd" value="_s-xclick"> | |||
<input type="hidden" name="hosted_button_id" value="K96K2WLBSBDSA"> | |||
<input type="image" src="https://www.paypalobjects.com/fr_FR/FR/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal, le réflexe sécurité pour payer en ligne"> | |||
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1"> | |||
</form> | |||
<h2>Test</h2> | |||
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top"> | |||
<input type="hidden" name="cmd" value="_s-xclick"> | |||
<input type="hidden" name="hosted_button_id" value="USASPWAC39S4N"> | |||
<input type="image" src="https://www.sandbox.paypal.com/fr_FR/FR/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal, le réflexe sécurité pour payer en ligne"> | |||
<img alt="" border="0" src="https://www.sandbox.paypal.com/fr_FR/i/scr/pixel.gif" width="1" height="1"> | |||
</form> |
@@ -0,0 +1,12 @@ | |||
<?php | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
?> | |||
<h1>Paiement validé</h1> | |||
@@ -20,7 +20,8 @@ | |||
"yiisoft/yii2-swiftmailer": "*", | |||
"2amigos/yii2-chartjs-widget": "~2.0.0", | |||
"2amigos/yii2-leaflet-extension" : "*", | |||
"kartik-v/yii2-mpdf": "dev-master" | |||
"kartik-v/yii2-mpdf": "dev-master", | |||
"c006/yii2-paypal-ipn": "dev-master" | |||
}, | |||
"require-dev": { | |||
"yiisoft/yii2-codeception": "*", |
@@ -4,8 +4,8 @@ | |||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | |||
"This file is @generated automatically" | |||
], | |||
"hash": "0a96d7573d54afab6210cfabf212aae2", | |||
"content-hash": "e287d89eaeb34db8a7f1cc53b4b790b8", | |||
"hash": "f8681a0fe3b2338999c789985d8bc0a0", | |||
"content-hash": "9ea68729b85dcd5dfed9eb8bb575dbde", | |||
"packages": [ | |||
{ | |||
"name": "2amigos/yii2-chartjs-widget", | |||
@@ -380,6 +380,45 @@ | |||
"MIT" | |||
] | |||
}, | |||
{ | |||
"name": "c006/yii2-paypal-ipn", | |||
"version": "dev-master", | |||
"source": { | |||
"type": "git", | |||
"url": "https://github.com/c006/yii2-paypal-ipn.git", | |||
"reference": "992cb6fc6b2beeb8dd61095a7ead7276de328686" | |||
}, | |||
"dist": { | |||
"type": "zip", | |||
"url": "https://api.github.com/repos/c006/yii2-paypal-ipn/zipball/992cb6fc6b2beeb8dd61095a7ead7276de328686", | |||
"reference": "992cb6fc6b2beeb8dd61095a7ead7276de328686", | |||
"shasum": "" | |||
}, | |||
"type": "yii2-extension", | |||
"autoload": { | |||
"psr-4": { | |||
"c006\\paypal_ipn\\": "" | |||
} | |||
}, | |||
"notification-url": "https://packagist.org/downloads/", | |||
"license": [ | |||
"MIT" | |||
], | |||
"authors": [ | |||
{ | |||
"name": "Jon Chambers", | |||
"email": "jchambers.dev@gmail.com" | |||
} | |||
], | |||
"description": "This is a simple PayPal IPN listener, no other files required.", | |||
"keywords": [ | |||
"extension", | |||
"ipn", | |||
"paypal", | |||
"yii2" | |||
], | |||
"time": "2015-08-08 18:07:32" | |||
}, | |||
{ | |||
"name": "cebe/markdown", | |||
"version": "1.1.1", | |||
@@ -1242,7 +1281,8 @@ | |||
"aliases": [], | |||
"minimum-stability": "stable", | |||
"stability-flags": { | |||
"kartik-v/yii2-mpdf": 20 | |||
"kartik-v/yii2-mpdf": 20, | |||
"c006/yii2-paypal-ipn": 20 | |||
}, | |||
"prefer-stable": false, | |||
"prefer-lowest": false, |
@@ -0,0 +1 @@ | |||
Subproject commit 992cb6fc6b2beeb8dd61095a7ead7276de328686 |
@@ -18,5 +18,6 @@ return array( | |||
'dosamigos\\leaflet\\' => array($vendorDir . '/2amigos/yii2-leaflet-extension/src'), | |||
'dosamigos\\chartjs\\' => array($vendorDir . '/2amigos/yii2-chartjs-widget/src'), | |||
'cebe\\markdown\\' => array($vendorDir . '/cebe/markdown'), | |||
'c006\\paypal_ipn\\' => array($vendorDir . '/c006/yii2-paypal-ipn'), | |||
'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'), | |||
); |
@@ -1279,5 +1279,46 @@ | |||
"utf8", | |||
"yii2" | |||
] | |||
}, | |||
{ | |||
"name": "c006/yii2-paypal-ipn", | |||
"version": "dev-master", | |||
"version_normalized": "9999999-dev", | |||
"source": { | |||
"type": "git", | |||
"url": "https://github.com/c006/yii2-paypal-ipn.git", | |||
"reference": "992cb6fc6b2beeb8dd61095a7ead7276de328686" | |||
}, | |||
"dist": { | |||
"type": "zip", | |||
"url": "https://api.github.com/repos/c006/yii2-paypal-ipn/zipball/992cb6fc6b2beeb8dd61095a7ead7276de328686", | |||
"reference": "992cb6fc6b2beeb8dd61095a7ead7276de328686", | |||
"shasum": "" | |||
}, | |||
"time": "2015-08-08 18:07:32", | |||
"type": "yii2-extension", | |||
"installation-source": "source", | |||
"autoload": { | |||
"psr-4": { | |||
"c006\\paypal_ipn\\": "" | |||
} | |||
}, | |||
"notification-url": "https://packagist.org/downloads/", | |||
"license": [ | |||
"MIT" | |||
], | |||
"authors": [ | |||
{ | |||
"name": "Jon Chambers", | |||
"email": "jchambers.dev@gmail.com" | |||
} | |||
], | |||
"description": "This is a simple PayPal IPN listener, no other files required.", | |||
"keywords": [ | |||
"extension", | |||
"ipn", | |||
"paypal", | |||
"yii2" | |||
] | |||
} | |||
] |
@@ -84,4 +84,13 @@ return array ( | |||
'@kartik/mpdf' => $vendorDir . '/kartik-v/yii2-mpdf', | |||
), | |||
), | |||
'c006/yii2-paypal-ipn' => | |||
array ( | |||
'name' => 'c006/yii2-paypal-ipn', | |||
'version' => '9999999-dev', | |||
'alias' => | |||
array ( | |||
'@c006/paypal_ipn' => $vendorDir . '/c006/yii2-paypal-ipn', | |||
), | |||
), | |||
); |