PaylineByMonext / payline-magento-2

Payline module for Magento 2
6 stars 3 forks source link

Don't Work with CETELEM and probably others #8

Open yanncharlou opened 6 years ago

yanncharlou commented 6 years ago

This module don't send required informations about buyer to CETELEM. CETELEM 3X and 4X can't work.

buyer data sent by module contain only few informations. It's missing at least : buyer.title buyer.mobilePhone

In vendor/monext/module-payline/PaylineApi/Request/DoWebPayment.php, function prepareBuyerData(&$data) near from line 192. Function should be adapted to be like prepareBillingAddressData for example and provide all mandatory informations about buyer.

yanncharlou commented 6 years ago

Here is a replacement function wich work for me :

protected function prepareBuyerData(&$data)
    {
        $customer = $this->cart->getCustomer();
        $paymentMethod = $this->payment->getMethod();

        $data['buyer']['title'] = $this->helperData->encodeString($this->billingAddress->getPrefix());
        if(!$data['buyer']['title']){
            $data['buyer']['title'] = $this->helperData->encodeString('M');
        }

        $data['buyer']['firstName'] = $this->helperData->encodeString(substr($this->billingAddress->getFirstname(), 0, 100));
        $data['buyer']['lastName'] = $this->helperData->encodeString(substr($this->billingAddress->getLastname(), 0, 100));
        //$data['buyer']['email'] = $this->helperData->encodeString(substr($this->billingAddress->getEmail(), 0, 100));
        $email = $this->billingAddress->getEmail();
        if($this->helperData->isEmailValid($email)) {
            $data['buyer']['email'] = $this->helperData->encodeString($email);
        }
        $data['buyer']['customerId'] = $this->helperData->encodeString($email);

        $data['buyer']['mobilePhone'] = $this->helperData->getNormalizedPhoneNumber($this->billingAddress->getTelephone());
        if(!$data['buyer']['mobilePhone']){
            $data['buyer']['mobilePhone'] = $this->helperData->encodeString('0000000000');
        }

        if($customer->getId()) {
            $data['buyer']['accountCreateDate'] = $this->formatDateTime($customer->getCreatedAt(), 'd/m/y');
        }

        if($this->helperData->isWalletEnabled($paymentMethod)) {
            if($customer->getId() && $customer->getCustomAttribute('wallet_id')->getValue()) {
                $data['buyer']['walletId'] = $customer->getCustomAttribute('wallet_id')->getValue();
            } else {
                $data['buyer']['walletId'] = $this->helperData->generateRandomWalletId();
            }
        }
    }
yanncharlou commented 5 years ago

Nobody here ?