PHP code example of ongoing / saferpay-bundle

1. Go to this page and download the library: Download ongoing/saferpay-bundle 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/ */

    

ongoing / saferpay-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Ongoing\Payment\SaferpayBundle\OngoingPaymentSaferpayBundle()
        );
    }

    // ...
}



    $form = $this->createForm(ChoosePaymentMethodType::class, null, [
        'amount'   => $order->getAmount(),
        'currency' => 'CHF',
        'predefined_data' => [          
            'saferpay_checkout' => [
                'checkout_params' => [
                    'orderid' => $order->getId(),
                    'description' => $order->getOrderItems()->first()->getName()
                ],
                'return_url' => 'example.com/saferpay/success',
                'cancel_url' => 'example.com/saferpay/cancel',
                'error_url' => 'example.com/saferpay/error'
            ]   
        ],
    ]);
}

//showAction -> http://jmspaymentcorebundle.readthedocs.io/en/stable/guides/accepting_payments.html
$ppc = $this->get('payment.plugin_controller');
$ppc->createPaymentInstruction($instruction = $form->getData());
$instrucation->getExtendedData()->set('creditcard_alias', 'validcreditcardalias');