HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/app/KommaApp/Shop/Checkout/Payment/IngenicoService.php
<?php

namespace KommaApp\Shop\Checkout\Payment;

class IngenicoService
{
    /*
     * Return Ingenico form data
     * @return array
     */
    public function formData($input)
    {
        // Prepare full name
        $fullName = $input['invoice_first_name'];
        if( ! empty($input['invoice_name_insertion'])) $fullName .= ' ' . $input['invoice_name_insertion'];
        $fullName .= ' ' . $input['invoice_last_name'];

        // Prepare full address
        $fullAddress = $input['invoice_street'] . ' ' . $input['invoice_house_number'];
        if( ! empty($input['invoice_house_number_suffix'])) $fullAddress .= $input['invoice_house_number_suffix'];

        // Switch language QnD
        switch( \Shop::getLanguageService()->getCurrentLanguage() )
        {
            case 'nl':
                $language = 'nl_NL';
                break;
            case 'de':
                $language = 'de_DE';
                break;
            default:
                $language = 'en_GB';
        }

        // Fill Data array
        $data = [];
        if(isset($input['orderId'])) $data['orderId'] = $input['orderId'];
        $data['pspId'] = \Config::get('komma/ingenico.pspId');
        $data['amount'] = $input['price_total'];
        $data['currency'] = 'EUR';
        $data['language'] = $language;
        $data['cn'] = $fullName;
        $data['email'] = $input['invoice_email'];
        $data['ownerAddress'] = $fullAddress;
        $data['ownerZip'] = $input['invoice_postal'];
        $data['ownerTown'] = $input['invoice_city'];
        $data['ownerCty'] = $input['invoice_country'];

        return $data;
    }

    /**
     * @param $input
     * @return array
     */
    public function paymentData($input)
    {
        $data = [];
        if(isset($input['pm']))
        {
            $json = json_decode($input['pm']);
            $data['pm'] = $json->pm;
            $data['brand'] = $json->brand;
            if(isset($input['issuerId'])) $data['issuerId'] = $input['issuerId'];
        }
        return $data;
    }

    /**
     * Return default form data
     */
    public function defaultFormData($token)
    {
        $default = [];

        // Template
        $default['tp'] = \URL::to('/') . '/ingenico-template';

        // Urls
        $default['acceptUrl'] = \URL::to('/') . '/' .\Shop::getPageService()->page('processPayment')->route;
        $default['declineUrl'] = \URL::to('/') . '/' .\Shop::getPageService()->page('processPayment')->route;
        $default['exceptionUrl'] = \URL::to('/') . '/' .\Shop::getPageService()->page('processPayment')->route;
        $default['cancelUrl'] = \URL::to('/') . '/' .\Shop::getPageService()->page('processPayment')->route;
        $default['backUrl'] = \URL::to('/') . '/' .\Shop::getPageService()->page('paymentFailed')->route . '?token=' . $token;

        return $default;
    }
}