Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fullpipe/payum-flexidengi

Flexidengi payment gateway for payum
https://github.com/fullpipe/payum-flexidengi

Last synced: about 4 hours ago
JSON representation

Flexidengi payment gateway for payum

Awesome Lists containing this project

README

        

# Flexidengi payment gateway for [payum](http://payum.org/)

## Instalation (with symfony2 payum bundle)
add to your composer json
```json
{
"require": {
"payum/payum-bundle": "0.14.*",
"fullpipe/payum-flexidengi": "dev-master"
}
}
```

Add FlexidengiPaymentFactory to payum:
```php
getExtension('payum');
$extension->addPaymentFactory(new FlexidengiPaymentFactory());
}
}
```

Since Flexidengi does not supports callback urls.
You will require to implement `notifyAction`

```php
getPayum()->getPayment('flexidengi_gateway');
$payment = $this->getPayum()
->getStorage('Acme\PaymentBundle\Entity\Payment')
->findBy(array(
'number' => $request->query->get(Api::ORDER_ID_PARAM_NAME),
));

if ($reply = $gateway->execute(new Notify($payment), true)) {
if ($reply instanceof HttpResponse) {
$gateway->execute($status = new GetHumanStatus($payment));

if ($status->isCaptured()) {
// Payment is done
// Notify your app here
}

throw $reply;
}

throw new \LogicException('Unsupported reply', null, $reply);
}
return new Response('', 204);
}
}
```
and you in routing.yml
```yaml
acme_payment_notify:
path: /payment_notify
defaults: { _controller: AcmePaymentBundle:Payment:notify }
```

## Configuration (using symfony2 payum bundle)
```yaml
payum:
security:
token_storage:
Acme\PaymentBundle\Entity\PaymentToken: { doctrine: orm }
storages:
Acme\PaymentBundle\Entity\Payment: { doctrine: orm }
payments:
...
flexidengi_gateway:
flexidengi:
service_id: 123
payment_method_id: 45
secret: SECRET_KEY
sandbox: true
...
```

## Usage
```php
get('payum')
->getStorage('Acme\PaymentBundle\Entity\Payment');

$payment = $storage->create();
$payment->setNumber($order->getId());
$payment->setCurrencyCode('RUB');
$payment->setTotalAmount(14025); // 140 руб, 25 коп.

$storage->update($payment);

$captureToken = $this->get('payum.security.token_factory')
->createCaptureToken(
$paymentName,
$payment,
'acme_payment_done'
);

return $this->redirect($captureToken->getTargetUrl());
}
}
```