PHP code example of ekyna / payum-monetico

1. Go to this page and download the library: Download ekyna/payum-monetico library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ekyna / payum-monetico example snippets


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());


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);
}