Skip to content

Commit

Permalink
Restored current version
Browse files Browse the repository at this point in the history
  • Loading branch information
gnat42 committed Aug 27, 2024
0 parents commit a81a2a9
Show file tree
Hide file tree
Showing 13 changed files with 613 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Controller/StripeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Created by PhpStorm.
* User: mark
* Date: 13/07/16
* Time: 2:25 PM
*/

namespace NS\StripeBundle\Controller;


class StripeController
{

}
29 changes: 29 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace NS\StripeBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This is the class that validates and merges configuration from your app/config files.
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('ns_stripe');

// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.

return $treeBuilder;
}
}
29 changes: 29 additions & 0 deletions DependencyInjection/NSStripeExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace NS\StripeBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
* This is the class that loads and manages your bundle configuration.
*
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
*/
class NSStripeExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
141 changes: 141 additions & 0 deletions Entity/CreditCard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php

namespace NS\StripeBundle\Entity;

/**
* Description of CreditCard
*
* @author gnat
*/
class CreditCard
{
/**
*
* @var string
*/
private $name;

/**
*
* @var integer
*/
private $number;

/**
*
* @var integer
*/
private $expiryYear;

/**
*
* @var integer
*/
private $expiryMonth;

/**
*
* @var integer
*/
private $cvv;

/**
*
* @return string
*/
public function getName()
{
return $this->name;
}

/**
*
* @return string
*/
public function getNumber()
{
return $this->number;
}

/**
*
* @return integer
*/
public function getExpiryYear()
{
return $this->expiryYear;
}

/**
*
* @return integer
*/
public function getExpiryMonth()
{
return $this->expiryMonth;
}

/**
*
* @return integer
*/
public function getCvv()
{
return $this->cvv;
}

/**
*
* @param string $name
* @return CreditCard
*/
public function setName($name)
{
$this->name = $name;
return $this;
}

/**
*
* @param string $number
* @return CreditCard
*/
public function setNumber($number)
{
$this->number = $number;
return $this;
}

/**
*
* @param integer $expiryYear
* @return CreditCard
*/
public function setExpiryYear($expiryYear)
{
$this->expiryYear = $expiryYear;
return $this;
}

/**
*
* @param integer $expiryMonth
* @return CreditCard
*/
public function setExpiryMonth($expiryMonth)
{
$this->expiryMonth = $expiryMonth;
return $this;
}

/**
*
* @param integer $cvv
* @return CreditCard
*/
public function setCvv($cvv)
{
$this->cvv = $cvv;
return $this;
}
}
167 changes: 167 additions & 0 deletions Entity/StripeResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?php

namespace NS\StripeBundle\Entity;

use \Symfony\Component\Validator\Constraints as Assert;

class StripeResponse
{
/**
* @var string $token
* @Assert\NotBlank()
*/
private $token;

/**
* @var string $last4
* @Assert\NotBlank()
* @Assert\Length(min=4, max=4)
*/
private $last4;

/**
* @var string $brand
* @Assert\NotBlank()
*/
private $brand;

/**
* @var integer $exp_month
* @Assert\NotNull()
* @Assert\Type(type="integer")
* @Assert\Range(min=1, max=12)
*/
private $exp_month;

/**
* @var integer $exp_year
* @Assert\NotNull()
* @Assert\Type(type="integer")
* @Assert\GreaterThanOrEqual(value=2015)
*/
private $exp_year;

/**
* @var string $client_ip
* @Assert\NotNull()
*/
private $client_ip;

/**
*
* @return string
*/
public function getToken()
{
return $this->token;
}

/**
*
* @return string
*/
public function getLast4()
{
return $this->last4;
}

/**
*
* @return string
*/
public function getBrand()
{
return $this->brand;
}

/**
*
* @return integer
*/
public function getExpMonth()
{
return $this->exp_month;
}

/**
*
* @return integer
*/
public function getExpYear()
{
return $this->exp_year;
}

/**
*
* @return string
*/
public function getClientIp()
{
return $this->client_ip;
}

/**
*
* @param string $token
*/
public function setToken($token)
{
$this->token = $token;
}

/**
*
* @param string $last4
*/
public function setLast4($last4)
{
$this->last4 = $last4;
}

/**
*
* @param string $brand
*/
public function setBrand($brand)
{
$this->brand = $brand;
}

/**
*
* @param integer $exp_month
*/
public function setExpMonth($exp_month)
{
$this->exp_month = $exp_month;
}

/**
*
* @param integer $exp_year
*/
public function setExpYear($exp_year)
{
$this->exp_year = $exp_year;
}

/**
*
* @param string $client_ip
*/
public function setClientIp($client_ip)
{
$this->client_ip = $client_ip;
}

public function fromResponse($response)
{
$this->token = $response->id;
$this->last4 = $response->card->last4;
$this->brand = $response->card->brand;
$this->exp_month = $response->card->exp_month;
$this->exp_year = $response->card->exp_year;
$this->client_ip = $response->client_ip;
}
}
Loading

0 comments on commit a81a2a9

Please sign in to comment.