Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paypal #36

Open
wants to merge 61 commits into
base: 0.11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
76b6d0e
master is 0.12.
makasim Sep 11, 2014
17bfd7f
Merge branch '0.11'
makasim Sep 22, 2014
854bdd4
fixes
makasim Oct 29, 2014
a843b99
Release 0.12.0
makasim Oct 29, 2014
c324588
master is 0.13 now.
makasim Oct 29, 2014
a2290fa
Release 0.13.0
makasim Jan 1, 2015
2d8c01a
master is 0.14-dev now
makasim Jan 1, 2015
19596d7
update docs.
makasim Jan 1, 2015
9d9944b
Merge branch '0.13'
makasim Jan 1, 2015
805f80c
fixes.
makasim Feb 23, 2015
1d7efca
Release 0.14.0
makasim Feb 23, 2015
ac39be9
master is 0.15 dev.
makasim Feb 23, 2015
a9a64af
Update RegistryFactory.php
Perfect-Web Mar 11, 2015
2407f6b
Merge pull request #12 from Perfect-Web/patch-1
makasim Mar 11, 2015
80ed823
Update get-it-started.md
Perfect-Web Mar 12, 2015
7038c93
Merge pull request #13 from Perfect-Web/patch-2
makasim Mar 12, 2015
a0a21e6
Update TokenFactory.php
Perfect-Web Mar 12, 2015
a448b3e
Update module.config.routes.php
Perfect-Web Mar 12, 2015
952bb13
Merge pull request #14 from Perfect-Web/patch-3
makasim Mar 12, 2015
843aa1b
Merge pull request #15 from Perfect-Web/patch-4
makasim Mar 12, 2015
2a8fb1b
Update HttpRequestVerifier.php
Perfect-Web Mar 12, 2015
f9587d0
Update CaptureController.php
Perfect-Web Mar 12, 2015
266971e
Update AuthorizeController.php
Perfect-Web Mar 12, 2015
a048342
Update AuthorizeController.php
Perfect-Web Mar 12, 2015
2e70c75
Update CaptureController.php
Perfect-Web Mar 12, 2015
59c2b24
Update NotifyController.php
Perfect-Web Mar 12, 2015
33bb30e
Update RefundController.php
Perfect-Web Mar 12, 2015
bbe554d
Merge pull request #16 from Perfect-Web/patch-5
makasim Mar 12, 2015
83019af
Merge pull request #22 from Perfect-Web/patch-11
makasim Mar 12, 2015
bf50ff7
Merge pull request #21 from Perfect-Web/patch-10
makasim Mar 12, 2015
c9e791e
Merge pull request #20 from Perfect-Web/patch-9
makasim Mar 12, 2015
8f1415c
Merge pull request #19 from Perfect-Web/patch-8
makasim Mar 12, 2015
7a80ff5
Merge pull request #18 from Perfect-Web/patch-7
makasim Mar 12, 2015
f10ed20
Merge pull request #17 from Perfect-Web/patch-6
makasim Mar 12, 2015
daf4c45
Update RegistryFactory.php
Perfect-Web Mar 11, 2015
cb29fa6
Update get-it-started.md
Perfect-Web Mar 12, 2015
ff46b66
Update TokenFactory.php
Perfect-Web Mar 12, 2015
6c245f1
Update module.config.routes.php
Perfect-Web Mar 12, 2015
90de5f3
Merge branch '0.14'
makasim Mar 12, 2015
ed713da
sync module with changes in payum 0.15
makasim Apr 29, 2015
a70630a
master is 1.0-dev
makasim Apr 29, 2015
f3baacd
Update get-it-started.md
EvKoh May 13, 2015
f1820d9
Merge pull request #23 from EvKoh/patch-2
makasim May 14, 2015
65cd2e1
Use classic array declaration instead of the short one
Jun 22, 2015
83c1ced
Merge pull request #24 from steazzalini/fix-array-decl-style
makasim Jun 22, 2015
e684a8f
change owner
makasim Aug 24, 2015
e10f9d3
PR for #25
NiMeDia Nov 9, 2015
abf7215
Update AuthorizeController.php
NiMeDia Nov 9, 2015
2b2cf76
Update RefundController.php
NiMeDia Nov 9, 2015
fc27d1d
Merge pull request #26 from P0rnflake/patch-1
makasim Nov 9, 2015
f801162
Merge pull request #27 from Payum/0.15
makasim Nov 14, 2015
ee530cd
Update README.md
makasim Mar 15, 2016
6cbaeb3
Update README.md
makasim Feb 3, 2017
cc48c2c
Update README.md
makasim Apr 26, 2017
f0757ca
Create README.md
makasim Jun 9, 2017
10c0bac
Payum Core Version Updated to 1.4.*
shahzaibhayatkhan Nov 2, 2017
94be461
Merge pull request #35 from zaibi099/master
makasim Nov 3, 2017
36ab078
Update composer.json
makasim Nov 3, 2017
69ec150
Update copyright license
Jaike Oct 30, 2018
bf11674
Merge pull request #37 from Jaike/patch-1
makasim Oct 30, 2018
ecac058
Update README.md
makasim Nov 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2013 by Forma-Pro
Copyright (C) 2013-2018 Maksim Kotlyar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
<h2 align="center">Supporting Payum</h2>

Payum is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:

- [Become a sponsor](https://www.patreon.com/makasim)
- [Become our client](http://forma-pro.com/)

---

# PayumModule

[![Join the chat at https://gitter.im/Payum/Payum](https://badges.gitter.im/Payum/Payum.svg)](https://gitter.im/Payum/Payum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

The modulee integrates [payum](https://github.com/Payum/Payum) into [zend2](http://framework.zend.com/) framework.
It already supports [+35 payments](https://github.com/Payum/Core/blob/master/Resources/docs/supported-payments.md).
It already supports [+35 gateways](https://github.com/Payum/Core/blob/master/Resources/docs/supported-gateways.md).
Provide nice configuration layer, secured capture controller, storages integration and lots of more features.

## Resources

* [Documentation](http://payum.org/doc#PayumModule)
* [Site](https://payum.forma-pro.com/)
* [Documentation](https://github.com/Payum/PayumModule/blob/master/docs/index.md)
* [Sandbox](https://github.com/makasim/PayumModuleSandbox)
* [Questions](http://stackoverflow.com/questions/tagged/payum)
* [Issue Tracker](https://github.com/Payum/PayumModule/issues)
* [Twitter](https://twitter.com/payumphp)

## Contributing

PayumModule is an open source, community-driven project. Pull requests are very welcome.
## Developed by Forma-Pro

## Like it? Spread the world!
Forma-Pro is a full stack development company which interests also spread to open source development.
Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience.
Our main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture & scalability.

Star payum module on [github](https://github.com/Payum/PayumModule) or [packagist](https://packagist.org/packages/payum/payum-module).
If you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at opensource@forma-pro.com

## License

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "~2.2",
"payum/core": "0.11.*"
"payum/core": "^1.4"
},
"suggest": {
"payum/paypal-express-checkout-nvp": "If you want to use paypal express checkout nvp gateway",
Expand All @@ -39,7 +39,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.11-dev"
"dev-master": "1.0-dev"
}
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
return array(
'payum' => array(
'token_storage' => null,
'payments' => array(),
'gateways' => array(),
'storages' => array(),
),
);
19 changes: 16 additions & 3 deletions config/module.config.routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'options' => array(
'route' => '/payment/capture[/:payum_token]',
'constraints' => array(
'payum_token' => '[a-zA-Z0-9]+'
'payum_token' => '[a-zA-Z0-9_-]+'
),
'defaults' => array(
'controller' => 'PayumCapture',
Expand All @@ -20,7 +20,7 @@
'options' => array(
'route' => '/payment/notify[/:payum_token]',
'constraints' => array(
'payum_token' => '[a-zA-Z0-9]+'
'payum_token' => '[a-zA-Z0-9_-]+'
),
'defaults' => array(
'controller' => 'PayumNotify',
Expand All @@ -33,14 +33,27 @@
'options' => array(
'route' => '/payment/authorize[/:payum_token]',
'constraints' => array(
'payum_token' => '[a-zA-Z0-9]+'
'payum_token' => '[a-zA-Z0-9_-]+'
),
'defaults' => array(
'controller' => 'PayumAuthorize',
'action' => 'do'
),
),
),
'payum_refund_do' => array(
'type' => 'Segment',
'options' => array(
'route' => '/payment/refund[/:payum_token]',
'constraints' => array(
'payum_token' => '[a-zA-Z0-9_-]+'
),
'defaults' => array(
'controller' => 'PayumRefund',
'action' => 'do'
),
),
),
),
),
);
14 changes: 14 additions & 0 deletions config/service/controller.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use Payum\PayumModule\Controller\AuthorizeController;
use Payum\PayumModule\Controller\CaptureController;
use Payum\PayumModule\Controller\NotifyController;
use Payum\PayumModule\Controller\RefundController;

return array(
'factories' => array(
Expand All @@ -17,5 +19,17 @@
// Construct Authorize controller with required Payum Registry and HttpRequestVerifier dependencies.
return new AuthorizeController($sm->get('payum'), $sm->get('payum.security.http_request_verifier'));
},
'PayumNotify' => function ($cm) {
$sm = $cm->getServiceLocator();

// Construct Capture controller with required Payum Registry and HttpRequestVerifier dependencies.
return new NotifyController($sm->get('payum'), $sm->get('payum.security.http_request_verifier'));
},
'PayumRefund' => function ($cm) {
$sm = $cm->getServiceLocator();

// Construct Capture controller with required Payum Registry and HttpRequestVerifier dependencies.
return new RefundController($sm->get('payum'), $sm->get('payum.security.http_request_verifier'));
},
),
);
39 changes: 19 additions & 20 deletions docs/get-it-started.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Get it started.

In this chapter we would show basic setup and usage of payum module for [zf2](http://framework.zend.com/).
We are using paypal here but it could be adopted for any other supported payments.
We are using paypal here but it could be adopted for any other supported gateways.

## Installation

```bash
php composer.phar require "payum/payum-module:*@stable" "payum/xxx:*@stable"
```

_**Note**: Where payum/xxx is a payum package, for example it could be payum/paypal-express-checkout-nvp. Look at [supported payments](https://github.com/Payum/Core/blob/master/Resources/docs/supported-payments.md) to find out what you can use._
_**Note**: Where payum/xxx is a payum package, for example it could be payum/paypal-express-checkout-nvp. Look at [supported gateways](https://github.com/Payum/Core/blob/master/Resources/docs/supported-gateways.md) to find out what you can use._

_**Note**: Use payum/payum if you want to install all payments at once._
_**Note**: Use payum/payum if you want to install all gateways at once._

Now you have all codes prepared and ready to be used.

Expand Down Expand Up @@ -70,24 +70,26 @@ use Buzz\Client\Curl;
use Payum\Core\Extension\StorageExtension;
use Payum\Core\Storage\FilesystemStorage;
use Payum\Paypal\ExpressCheckout\Nvp\Api;
use Payum\Paypal\ExpressCheckout\Nvp\PaymentFactory;
use Payum\Paypal\ExpressCheckout\Nvp\GatewayFactory;

$detailsClass = 'Application\Model\PaymentDetails';

$paypalFactory = new \Payum\Paypal\ExpressCheckout\Nvp\PaypalExpressCheckoutGatewayFactory();

return array(
'payum' => array(
'token_storage' => new FilesystemStorage(
__DIR__.'/../../data',
'Application\Model\PaymentSecurityToken',
'hash'
),
'payments' => array(
'paypal_es' => PaymentFactory::create(new Api(new Curl(), array(
'username' => 'REPLACE WITH YOURS',
'password' => 'REPLACE WITH YOURS',
'signature' => 'REPLACE WITH YOURS',
'gateways' => array(
'paypal_ec' => $paypalFactory->create(array(
'username' => 'EDIT ME',
'password' => 'EDIT ME',
'signature' => 'EDIT ME',
'sandbox' => true
)))
)),
),
'storages' => array(
$detailsClass => new FilesystemStorage(__DIR__.'/../../data', $detailsClass, 'id'),
Expand All @@ -112,16 +114,13 @@ class IndexController extends AbstractActionController
{
$storage = $this->getServiceLocator()->get('payum')->getStorage('Application\Model\PaymentDetails');

$details = $storage->createModel();
$details = $storage->create();
$details['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR';
$details['PAYMENTREQUEST_0_AMT'] = 1.23;
$storage->updateModel($details);

// FIXIT: I dont know how to inject controller plugin to the service.
$this->getServiceLocator()->get('payum.security.token_factory')->setUrlPlugin($this->url());
$storage->update($details);

$captureToken = $this->getServiceLocator()->get('payum.security.token_factory')->createCaptureToken(
'paypal_es', $details, 'payment_done'
'paypal_ec', $details, 'payment_done'
);

$this->redirect()->toUrl($captureToken->getTargetUrl());
Expand All @@ -147,13 +146,13 @@ class IndexController extends AbstractActionController
{
public function doneAction()
{
$token = $this->getServiceLocator()->get('payum.security.http_request_verifier')->verify($this->getRequest());
$token = $this->getServiceLocator()->get('payum.security.http_request_verifier')->verify($this);

$payment = $this->getServiceLocator()->get('payum')->getPayment($token->getPaymentName());
$gateway = $this->getServiceLocator()->get('payum')->getGateway($token->getGatewayName());

$payment->execute($status = new GetHumanStatus($token));
$gateway->execute($status = new GetHumanStatus($token));

return new JsonModel(array('status' => $status->getStatus()) + iterator_to_array($status->getModel()));
return new JsonModel(array('status' => $status->getValue()) + iterator_to_array($status->getModel()));
}
}
```
Expand Down
15 changes: 7 additions & 8 deletions src/Payum/PayumModule/Controller/AuthorizeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@
use Payum\Core\Reply\HttpRedirect;
use Payum\Core\Reply\HttpResponse;
use Payum\Core\Reply\ReplyInterface;
use Payum\Core\Request\SecuredAuthorize;
use Payum\Core\Request\SecuredCapture;
use Payum\Core\Request\Authorize;
use Zend\Http\Response;

class AuthorizeController extends PayumController
{
public function doAction()
{
$token = $this->getHttpRequestVerifier()->verify($this->getRequest());
$token = $this->getHttpRequestVerifier()->verify($this);

$payment = $this->getPayum()->getPayment($token->getPaymentName());
$gateway = $this->getPayum()->getGateway($token->getGatewayName());

try {
$payment->execute(new SecuredAuthorize($token));
$gateway->execute(new Authorize($token));
} catch (ReplyInterface $reply) {
if ($reply instanceof HttpRedirect) {
$this->redirect()->toUrl($reply->getUrl());
return $this->redirect()->toUrl($reply->getUrl());
}

if ($reply instanceof HttpResponse) {
Expand All @@ -38,6 +37,6 @@ public function doAction()

$this->getHttpRequestVerifier()->invalidate($token);

$this->redirect()->toUrl($token->getAfterUrl());
return $this->redirect()->toUrl($token->getAfterUrl());
}
}
}
14 changes: 7 additions & 7 deletions src/Payum/PayumModule/Controller/CaptureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
use Payum\Core\Reply\HttpRedirect;
use Payum\Core\Reply\HttpResponse;
use Payum\Core\Reply\ReplyInterface;
use Payum\Core\Request\SecuredCapture;
use Payum\Core\Request\Capture;
use Zend\Http\Response;

class CaptureController extends PayumController
{
public function doAction()
{
$token = $this->getHttpRequestVerifier()->verify($this->getRequest());
$token = $this->getHttpRequestVerifier()->verify($this);

$payment = $this->getPayum()->getPayment($token->getPaymentName());
$gateway = $this->getPayum()->getGateway($token->getGatewayName());

try {
$payment->execute(new SecuredCapture($token));
$gateway->execute(new Capture($token));
} catch (ReplyInterface $reply) {
if ($reply instanceof HttpRedirect) {
$this->redirect()->toUrl($reply->getUrl());
return $this->redirect()->toUrl($reply->getUrl());
}

if ($reply instanceof HttpResponse) {
Expand All @@ -37,6 +37,6 @@ public function doAction()

$this->getHttpRequestVerifier()->invalidate($token);

$this->redirect()->toUrl($token->getAfterUrl());
return $this->redirect()->toUrl($token->getAfterUrl());
}
}
}
10 changes: 5 additions & 5 deletions src/Payum/PayumModule/Controller/NotifyController.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
namespace Payum\PayumModule\Controller;

use Payum\Core\Request\SecuredNotify;
use Payum\Core\Request\Notify;

class NotifyController extends PayumController
{
public function doAction()
{
$token = $this->getHttpRequestVerifier()->verify($this->getRequest());
$token = $this->getHttpRequestVerifier()->verify($this);

$payment = $this->getPayum()->getPayment($token->getPaymentName());
$gateway = $this->getPayum()->getGateway($token->getGatewayName());

$payment->execute(new SecuredNotify($_REQUEST, $token));
$gateway->execute(new Notify($token));

$this->getResponse()->setStatusCode(204);
}
}
}
41 changes: 41 additions & 0 deletions src/Payum/PayumModule/Controller/RefundController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
namespace Payum\PayumModule\Controller;

use Payum\Core\Reply\HttpRedirect;
use Payum\Core\Reply\HttpResponse;
use Payum\Core\Reply\ReplyInterface;
use Payum\Core\Request\Refund;
use Zend\Http\Response;

class RefundController extends PayumController
{
public function doAction()
{
$token = $this->getHttpRequestVerifier()->verify($this);
$this->getHttpRequestVerifier()->invalidate($token);

$gateway = $this->getPayum()->getGateway($token->getGatewayName());

try {
$gateway->execute(new Refund($token));
} catch (ReplyInterface $reply) {
if ($reply instanceof HttpRedirect) {
return $this->redirect()->toUrl($reply->getUrl());
}

if ($reply instanceof HttpResponse) {
$this->getResponse()->setContent($reply->getContent());

$response = new Response();
$response->setStatusCode(200);
$response->setContent($reply->getContent());

return $response;
}

throw new \LogicException('Unsupported reply', null, $reply);
}

return $this->redirect()->toUrl($token->getAfterUrl());
}
}
Loading