Browse Source

Système de paiement

Mise en place d'un système de paiement via Paypal.
master
keun 8 years ago
parent
commit
99e8d3f4ca
11 changed files with 245 additions and 4 deletions
  1. +97
    -0
      backend/controllers/PaiementController.php
  2. +12
    -0
      backend/views/paiement/annuler.php
  3. +27
    -0
      backend/views/paiement/index.php
  4. +12
    -0
      backend/views/paiement/succes.php
  5. +2
    -1
      composer.json
  6. +43
    -3
      composer.lock
  7. BIN
      frontend/web/img/laboulange-paypal.png
  8. +1
    -0
      vendor/c006/yii2-paypal-ipn
  9. +1
    -0
      vendor/composer/autoload_psr4.php
  10. +41
    -0
      vendor/composer/installed.json
  11. +9
    -0
      vendor/yiisoft/extensions.php

+ 97
- 0
backend/controllers/PaiementController.php View File

@@ -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;
}
}

+ 12
- 0
backend/views/paiement/annuler.php View File

@@ -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>


+ 27
- 0
backend/views/paiement/index.php View File

@@ -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>

+ 12
- 0
backend/views/paiement/succes.php View File

@@ -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>


+ 2
- 1
composer.json View File

@@ -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": "*",

+ 43
- 3
composer.lock View File

@@ -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,

BIN
frontend/web/img/laboulange-paypal.png View File

Before After
Width: 60  |  Height: 60  |  Size: 2.0KB

+ 1
- 0
vendor/c006/yii2-paypal-ipn

@@ -0,0 +1 @@
Subproject commit 992cb6fc6b2beeb8dd61095a7ead7276de328686

+ 1
- 0
vendor/composer/autoload_psr4.php View File

@@ -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'),
);

+ 41
- 0
vendor/composer/installed.json View File

@@ -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"
]
}
]

+ 9
- 0
vendor/yiisoft/extensions.php View File

@@ -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',
),
),
);

Loading…
Cancel
Save