ekyna/payum-monetico

Payum Monetico (Credit Mutuel/CIC) gateway

Installs: 18 964

Dependents: 4

Suggesters: 0

Security: 0

Stars: 8

Watchers: 4

Forks: 5

Open Issues: 1

Type:component

1.6.1 2021-08-26 16:59 UTC

This package is auto-updated.

Last update: 2021-12-26 17:45:55 UTC


README

Payum Monetico (Credit Mutuel/CIC/OBC) payment gateway.

Build Status

  • Symfony bundle available here.
  • Sylius plugin available here.

Installation / Configuration

composer req ekyna/payum-monetico
use Ekyna\Component\Payum\Monetico\Api\Api;
use Ekyna\Component\Payum\Monetico\MoneticoGatewayFactory;

$factory = new MoneticoGatewayFactory();

$gateway = $factory->create([
    'mode'      => Api::MODE_PRODUCTION,
    'tpe'       => '123456',
    'key'       => '123456',
    'company'   => 'foobar',
]);

// Register your convert payment action
// $gateway->addAction(new \Acme\ConvertPaymentAction());

Create your convert action

See src/Action/ConvertPaymentAction.php sample.

Create your notify controller

Example (Symfony):

public function notifyAction(Request $request)
{
    // Get the reference you set in your ConvertAction
    if (null === $reference = $request->request->get('reference')) {
        throw new NotFoundHttpException();
    }

    // Find your payment entity
    $payment = $this
        ->get('acme.repository.payment')
        ->findOneBy(['number' => $reference]);

    if (null === $payment) {
        throw new NotFoundHttpException();
    }

    $payum = $this->get('payum');

    // Execute notify & status actions.
    $gateway = $payum->getGateway('monetico');
    $gateway->execute(new Notify($payment));
    $gateway->execute(new GetHumanStatus($payment));

    // Get the payment identity
    $identity = $payum->getStorage($payment)->identify($payment);

    // Invalidate payment tokens
    $tokens = $payum->getTokenStorage()->findBy([
        'details' => $identity,
    ]);
    foreach ($tokens as $token) {
        $payum->getHttpRequestVerifier()->invalidate($token);
    }

    // Return expected response
    return new Response(\Ekyna\Component\Payum\Monetico\Api\Api::NOTIFY_SUCCESS);
}