Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yproximite/payum-system-pay
System Pay gateway for Payum
https://github.com/yproximite/payum-system-pay
gateway payum payum-extension systempay
Last synced: about 1 month ago
JSON representation
System Pay gateway for Payum
- Host: GitHub
- URL: https://github.com/yproximite/payum-system-pay
- Owner: Yproximite
- License: mit
- Created: 2019-01-28T09:57:32.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-19T19:07:03.000Z (over 1 year ago)
- Last Synced: 2024-10-12T22:58:23.631Z (2 months ago)
- Topics: gateway, payum, payum-extension, systempay
- Language: PHP
- Homepage:
- Size: 188 KB
- Stars: 5
- Watchers: 12
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Payum System Pay
> A Payum gateway to use [SystemPay](https://paiement.systempay.fr) (a French payment system)
[![Latest Stable Version](https://poser.pugx.org/yproximite/payum-system-pay/version)](https://packagist.org/packages/yproximite/payum-system-pay)
[![Build Status](https://travis-ci.com/Yproximite/payum-system-pay.svg?token=pNBs2oaRpfxdyhqWf28h&branch=master)](https://travis-ci.com/Yproximite/payum-system-pay)## Requirements
- PHP 7.2+
- [Payum](https://github.com/Payum/Payum)
- Optionally [PayumBundle](https://github.com/Payum/PayumBundle) and Symfony 3 or 4+## Installation
```bash
$ composer require yproximite/payum-system-pay
```## Configuration
### With PayumBundle (Symfony)
First register the gateway factory in your services definition:
```yaml
# config/services.yaml or app/config/services.yml
services:
yproximite.system_pay_gateway_factory:
class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
arguments: [Yproximite\Payum\SystemPay\SystemPayGatewayFactory]
tags:
- { name: payum.gateway_factory_builder, factory: system_pay }
```Then configure the gateway:
```yaml
# config/packages/payum.yaml or app/config/config.ymlpayum:
gateways:
system_pay:
factory: system_pay
vads_site_id: 'change it' # required
certif_prod: 'change it' # required
certif_test: 'change it' # required
sandbox: true
hash_algorithm: 'algo-sha1' # or 'algo-hmac-sha256'
```### With Payum
```php
addDefaultStorages()->addGateway('gatewayName', [
'factory' => 'system_pay',
'vads_site_id' => 'change it', // required
'certif_prod' => 'change it', // required
'certif_test' => 'change it', // required
'sandbox' => true,
'hash_algorithm' => 'algo-sha1' // or 'algo-hmac-sha256'
])->getPayum()
;
```### Why `hash_algorithm` is prefixed by `algo-`?
We wanted to use `sha1` or `hmac-256`, but there is currently a [Payum limitation](https://github.com/Payum/Payum/issues/692) which try to call `sha1` because it's a valid callable.
As a workaround, the only easy solution we thought was to prefix them with `algo-`.
Since `algo-sha1` is not a valid callable, there is no Payum issues and everything works well.## Usage
Make sure your `Payment` entity overrides `getNumber()` method like this:
```php
id;
}
}
```By doing this, the library will be able to pick the payment's id and use it for the payment with System Pay (we should send a transaction id between `000000` and `999999`).
### Payment in several instalments
If you planned to support payments in several instalments, somewhere in your code you will need to call `Payment#setPartialAmount` to keep a trace of the amount per payment:
```php
partialAmount;
}public function setPartialAmount(?int $partialAmount): void
{
$this->partialAmount = $partialAmount;
}
}
```#### Usage
```php
1000, 'date' => new \DateTime()],
['amount' => 2000, 'date' => (new \DateTime())->add(new \DateInterval('P1M'))],
['amount' => 3000, 'date' => (new \DateTime())->add(new \DateInterval('P2M'))],
];// Compute total amount
$totalAmount = array_sum(array_column($periods, 'amount'));// Compute `paymentConfig` fields that will be sent to the API
// It will generates something like this: MULTI_EXT:20190102=1000;20190202=2000;20190302=3000
$paymentConfig = (new PaymentConfigGenerator())->generate($periods);// Then create payments
$storage = $payum->getStorage(Payment::class);
$payments = [];foreach ($periods as $period) {
$payment = $storage->create();
$payment->setTotalAmount($totalAmount);
$payment->setPartialAmount($period['amount']);$details = $payment->getDetails();
$details[Api::FIELD_VADS_PAYMENT_CONFIG] = $generatedPaymentConfig;
$payment->setDetails($details);$storage->update($payment);
$payments[] = $payment;
}
```