Skip to content

Commit

Permalink
sync with changes in payum 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Apr 29, 2015
1 parent 8a526e0 commit abdfd46
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 55 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Payum Laravel Bundle

The extension integrates [payum](http://payum.forma-dev.com/documentation#Payum) into [laravel](http://laravel.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 and lots of other features.

## Resources
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"illuminate/container": "~4.0",
"illuminate/routing": "~4.0",
"illuminate/support": "~4.0",
"payum/core": "0.15.*@dev"
"payum/core": "0.15.*"
},
"suggest": {
"payum/paypal-express-checkout-nvp": "If you want to use paypal express checkout nvp gateway",
Expand Down
13 changes: 6 additions & 7 deletions docs/eloquent_storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Create an eloquent model:

```php
<?php
class Order extends Illuminate\Database\Eloquent\Model
class Payment extends Illuminate\Database\Eloquent\Model
{
protected $table = 'orders';
protected $table = 'payments';
}
```

Expand All @@ -23,21 +23,21 @@ use Payum\LaravelPackage\Storage\EloquentStorage;

return array(
'storages' => array(
'Order' => new EloquentStorage('Order'),
'Payment' => new EloquentStorage('Payment'),
)
);
```

## Models

The package provides two models `Payum\LaravelPackage\Model\Token` and `Payum\LaravelPackage\Model\Order` which may be reused directly or extend with some custom logic.
The package provides two models `Payum\LaravelPackage\Model\Token` and `Payum\LaravelPackage\Model\Payment` which may be reused directly or extend with some custom logic.
Here's the models schemas:

Order:
```php
<?php

\Schema::create('payum_orders', function($table) {
\Schema::create('payum_payments', function($table) {
/** @var \Illuminate\Database\Schema\Blueprint $table */
$table->bigIncrements('id');
$table->text('details');
Expand All @@ -47,7 +47,6 @@ Order:
$table->string('clientEmail');
$table->string('totalAmount');
$table->string('currencyCode');
$table->string('currencyDigitsAfterDecimalPoint');
$table->timestamps();
});
```
Expand All @@ -64,7 +63,7 @@ Token:
$table->text('details');
$table->string('targetUrl');
$table->string('afterUrl');
$table->string('paymentName');
$table->string('gatewayName');
$table->timestamps();
});
```
Expand Down
18 changes: 9 additions & 9 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use Payum\Core\Storage\FilesystemStorage;
$detailsClass = 'Payum\Core\Model\ArrayObject';
$tokenClass = 'Payum\Core\Model\Token';

$stripeJsPaymentFactory = new \Payum\Stripe\JsPaymentFactory();
$stripeJsGatewayFactory = new \Payum\Stripe\StripeJsGatewayFactory();

return array(
'token_storage' => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $tokenClass, 'hash'),
'payments' => array(
'stripe_js' => $stripeJsPaymentFactory->create(array(
'gateways' => array(
'stripe_js' => $stripeJsGatewayFactory->create(array(
'publishable_key' => $_SERVER['payum.stripe.publishable_key'],
'secret_key' => $_SERVER['payum.stripe.secret_key'],
'payum.action.get_http_request' => new GetHttpRequestAction(),
Expand Down Expand Up @@ -82,12 +82,12 @@ use Payum\Core\Storage\FilesystemStorage;
$detailsClass = 'Payum\Core\Model\ArrayObject';
$tokenClass = 'Payum\Core\Model\Token';

$stripeCheckoutPaymentFactory = new \Payum\Stripe\CheckoutPaymentFactory();
$stripeCheckoutGatewayFactory = new \Payum\Stripe\StripeCheckoutGatewayFactory();

return array(
'token_storage' => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $tokenClass, 'hash'),
'payments' => array(
'stripe_checkout' => $stripeCheckoutPaymentFactory->create(array(
'gateways' => array(
'stripe_checkout' => $stripeCheckoutGatewayFactory->create(array(
'publishable_key' => 'EDIT ME',
'secret_key' => 'EDIT ME',
'payum.action.get_http_request' => new GetHttpRequestAction(),
Expand Down Expand Up @@ -142,12 +142,12 @@ use Payum\Core\Storage\FilesystemStorage;
$detailsClass = 'Payum\Core\Model\ArrayObject';
$tokenClass = 'Payum\Core\Model\Token';

$omnipayDirectPaymentFactory = new \Payum\OmnipayBridge\DirectPaymentFactory();
$omnipayDirectGatewayFactory = new \Payum\OmnipayBridge\OmnipayDirectGatewayFactory();

return array(
'token_storage' => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $tokenClass, 'hash'),
'payments' => array(
'stripe_direct' => $omnipayDirectPaymentFactory->create(array(
'gateways' => array(
'stripe_direct' => $omnipayDirectGatewayFactory->create(array(
'type' => 'Stripe',
'options' => array(
'apiKey' => 'EDIT ME',
Expand Down
10 changes: 5 additions & 5 deletions docs/get-it-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Look at sandbox to find more examples.
php composer.phar require payum/payum-laravel-package payum/xxx
```

_**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 All @@ -34,12 +34,12 @@ use Payum\Core\Storage\FilesystemStorage;
$detailsClass = 'Payum\Core\Model\ArrayObject';
$tokenClass = 'Payum\Core\Model\Token';

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

return array(
'token_storage' => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $tokenClass, 'hash'),
'payments' => array(
'paypal_ec' => $paypalExpressCheckoutPaymentFactory->create(array(
'gateways' => array(
'paypal_ec' => $paypalExpressCheckoutGatewayFactory->create(array(
'username' => 'EDIT ME',
'password' => 'EDIT ME',
'signature' => 'EDIT ME',
Expand Down
4 changes: 2 additions & 2 deletions docs/payment_done_controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class PaymentController extends BaseController

$token = $this->getHttpRequestVerifier()->verify($request);

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

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

return \Response::json(array(
'status' => $status->getValue(),
Expand Down
4 changes: 2 additions & 2 deletions src/Payum/LaravelPackage/Controller/AuthorizeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public function doAction($payum_token)

$token = $this->getHttpRequestVerifier()->verify($request);

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

$payment->execute(new Authorize($token));
$gateway->execute(new Authorize($token));

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

Expand Down
4 changes: 2 additions & 2 deletions src/Payum/LaravelPackage/Controller/CaptureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public function doAction($payum_token)

$token = $this->getHttpRequestVerifier()->verify($request);

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

$payment->execute(new Capture($token));
$gateway->execute(new Capture($token));

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

Expand Down
8 changes: 4 additions & 4 deletions src/Payum/LaravelPackage/Controller/NotifyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class NotifyController extends PayumController
{
public function doUnsafeAction(Request $request)
{
$payment = $this->getPayum()->getPayment($request->get('payment_name'));
$gateway = $this->getPayum()->getGateway($request->get('gateway_name'));

$payment->execute(new Notify(null));
$gateway->execute(new Notify(null));

return \Response::make(null, 204);
}
Expand All @@ -19,9 +19,9 @@ public function doAction(Request $request)
{
$token = $this->getHttpRequestVerifier()->verify($request);

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

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

return \Response::make(null, 204);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Payum/LaravelPackage/Controller/RefundController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public function doAction($payum_token)

$token = $this->getHttpRequestVerifier()->verify($request);

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

$payment->execute(new Refund($token));
$gateway->execute(new Refund($token));

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
namespace Payum\LaravelPackage\Model;

use Illuminate\Database\Eloquent\Model;
use Payum\Core\Model\OrderInterface;
use Payum\Core\Model\CreditCardInterface;
use Payum\Core\Model\PaymentInterface;

class Order extends Model implements OrderInterface
class Payment extends Model implements PaymentInterface
{
protected $creditCard;

/**
* @var string
*/
protected $table = 'payum_orders';
protected $table = 'payum_payments';

/**
* {@inheritDoc}
Expand Down Expand Up @@ -124,18 +127,18 @@ public function setCurrencyCode($currencyCode)
}

/**
* {@inheritDoc}
* @return mixed
*/
public function getCurrencyDigitsAfterDecimalPoint()
public function getCreditCard()
{
return $this->getAttribute('currencyDigitsAfterDecimalPoint');
return $this->creditCard;
}

/**
* {@inheritDoc}
* @param CreditCardInterface $creditCard
*/
public function setCurrencyDigitsAfterDecimalPoint($currencyDigitsAfterDecimalPoint)
public function setCreditCard(CreditCardInterface $creditCard = null)
{
$this->setAttribute('currencyDigitsAfterDecimalPoint', $currencyDigitsAfterDecimalPoint);
$this->creditCard = $creditCard;
}
}
10 changes: 5 additions & 5 deletions src/Payum/LaravelPackage/Model/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ public function setAfterUrl($afterUrl)
/**
* @return string
*/
public function getPaymentName()
public function getGatewayName()
{
return $this->getAttribute('paymentName');
return $this->getAttribute('gatewayName');
}

/**
* @param string $paymentName
* @param string $gatewayName
*/
public function setPaymentName($paymentName)
public function setGatewayName($gatewayName)
{
$this->setAttribute('paymentName', $paymentName);
$this->setAttribute('gatewayName', $gatewayName);
}
}
8 changes: 4 additions & 4 deletions src/Payum/LaravelPackage/PayumServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ public function boot()
'uses' => 'Payum\LaravelPackage\Controller\NotifyController@doAction'
));

\Route::get('/payment/notify/unsafe/{payment_name}', array(
\Route::get('/payment/notify/unsafe/{gateway_name}', array(
'as' => 'payum_notify_do_unsafe',
'uses' => 'Payum\LaravelPackage\Controller\NotifyController@doUnsafeAction'
));

$this->app['payum'] = $this->app->share(function($app) {
//TODO add exceptions if invalid payments and storages options set.
//TODO add exceptions if invalid gateways and storages options set.

$payum = new ContainerAwareRegistry(
\Config::get('payum-laravel-package::payments'),
\Config::get('payum-laravel-package::gateways'),
\Config::get('payum-laravel-package::storages')
);

Expand All @@ -87,7 +87,7 @@ public function boot()
});

$this->app['payum.security.token_storage'] = $this->app->share(function($app) {
//TODO add exceptions if invalid payments and storages options set.
//TODO add exceptions if invalid gateways and storages options set.

$tokenStorage = \Config::get('payum-laravel-package::token_storage');

Expand Down
4 changes: 2 additions & 2 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
return array(
// You can pass on object or a service id from container.
'token_storage' => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $tokenClass, 'hash'),
'payments' => array(
// Put here any payment you want too, omnipay, payex, paypa, be2bill or any other. Here's example of paypal and stripe:
'gateways' => array(
// Put here any gateway you want too, omnipay, payex, paypa, be2bill or any other. Here's example of paypal and stripe:
),
'storages' => array(
$detailsClass => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $detailsClass),
Expand Down

0 comments on commit abdfd46

Please sign in to comment.