Skip to content

Commit

Permalink
release 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Jan 2, 2015
1 parent 6afc74b commit e1a51c6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"require": {
"php": ">=5.3.2",
"payum/core": "0.13.*@dev"
"payum/core": "0.13.*"
},
"suggest": {
"yiisoft/yii": "If you plan to use this extension outside of a Yii project",
Expand Down
20 changes: 11 additions & 9 deletions docs/get-it-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Your configuration may look like this:
// app/config/main.php

use Payum\Core\Storage\FilesystemStorage;
use Payum\Paypal\ExpressCheckout\Nvp\Api;
use Payum\Paypal\ExpressCheckout\Nvp\PaymentFactory as PaypalEcPaymentFactory;

$paypalExpressCheckoutPaymentFactory = new \Payum\Paypal\ExpressCheckout\Nvp\PaymentFactory();

return array(
'controllerMap'=>array(
Expand All @@ -53,12 +53,14 @@ return array(
'class' => '\Payum\YiiExtension\PayumComponent',
'tokenStorage' => new FilesystemStorage(__DIR__.'/../data', 'PaymentSecurityToken', 'hash'),
'payments' => array(
'paypal_ec' => PaypalEcPaymentFactory::create(new Api(array(
'username' => 'REPLACE WITH YOURS',
'password' => 'REPLACE WITH YOURS',
'signature' => 'REPLACE WITH YOURS',
// you can add other payments here.

'paypal_ec' => $paypalExpressCheckoutPaymentFactory->create(array(
'username' => 'EDIT ME',
'password' => 'EDIT ME',
'signature' => 'EDIT ME',
'sandbox' => true
)))
)),
),
'storages' => array(
'PaymentDetails' => new FilesystemStorage(__DIR__.'/../data', 'PaymentDetails', 'id'),
Expand Down Expand Up @@ -96,10 +98,10 @@ class PaypalController extends CController
$paymentName
);

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

$captureToken = $payum->getTokenFactory()->createCaptureToken($paymentName, $details, 'paypal/done');

Expand Down
29 changes: 27 additions & 2 deletions src/Payum/YiiExtension/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
use Payum\Core\Exception\LogicException;
use Payum\Core\Reply\HttpRedirect;
use Payum\Core\Reply\ReplyInterface;
use Payum\Core\Request\Authorize;
use Payum\Core\Request\Capture;
use Payum\Core\Request\Notify;
use Payum\Core\Request\Refund;

class PaymentController extends \CController
{
Expand All @@ -29,12 +32,34 @@ public function actionCapture()

public function actionAuthorize()
{
throw new \LogicException('Not Implemented');
$token = $this->getPayum()->getHttpRequestVerifier()->verify($_REQUEST);
$payment = $this->getPayum()->getRegistry()->getPayment($token->getPaymentName());

$payment->execute($capture = new Authorize($token));

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

$this->redirect($token->getAfterUrl());
}

public function actionNotify()
{
throw new \LogicException('Not Implemented');
$token = $this->getPayum()->getHttpRequestVerifier()->verify($_REQUEST);
$payment = $this->getPayum()->getRegistry()->getPayment($token->getPaymentName());

$payment->execute($capture = new Notify($token));
}

public function actionRefund()
{
$token = $this->getPayum()->getHttpRequestVerifier()->verify($_REQUEST);
$this->getPayum()->getHttpRequestVerifier()->invalidate($token);

$payment = $this->getPayum()->getRegistry()->getPayment($token->getPaymentName());

$payment->execute($capture = new Refund($token));

$this->redirect($token->getAfterUrl());
}

public function handleException(\CExceptionEvent $event)
Expand Down
9 changes: 8 additions & 1 deletion src/Payum/YiiExtension/PayumComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ public function init()
$this->registry = new SimpleRegistry($this->payments, $this->storages, null);

$this->httpRequestVerifier = new PlainHttpRequestVerifier($this->tokenStorage);
$this->tokenFactory = new TokenFactory($this->tokenStorage, $this->registry, 'payment/capture', 'payment/notify', 'payment/authorize');
$this->tokenFactory = new TokenFactory(
$this->tokenStorage,
$this->registry,
'payment/capture',
'payment/notify',
'payment/authorize',
'payment/refund'
);
}

/**
Expand Down

0 comments on commit e1a51c6

Please sign in to comment.