getnet-adquirencia /
payment-magento
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Copyright © Getnet. All rights reserved. |
||
| 4 | * |
||
| 5 | * @author Bruno Elisei <[email protected]> |
||
| 6 | * See LICENSE for license details. |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace Getnet\PaymentMagento\Gateway\Request; |
||
| 10 | |||
| 11 | use Getnet\PaymentMagento\Gateway\Data\Order\OrderAdapterFactory; |
||
|
0 ignored issues
–
show
|
|||
| 12 | use Getnet\PaymentMagento\Gateway\SubjectReader; |
||
| 13 | use InvalidArgumentException; |
||
| 14 | use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; |
||
| 15 | use Magento\Payment\Gateway\Request\BuilderInterface; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Class Customer Data Request - Customer structure. |
||
| 19 | */ |
||
| 20 | class CustomerDataRequest implements BuilderInterface |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Customer block name. |
||
| 24 | */ |
||
| 25 | public const CUSTOMER = 'customer'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Unique user id. |
||
| 29 | * Required. |
||
| 30 | */ |
||
| 31 | public const CUSTOMER_ID = 'customer_id'; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * The first name value must be less than or equal to 255 characters. |
||
| 35 | * Required. |
||
| 36 | */ |
||
| 37 | public const FIRST_NAME = 'first_name'; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * The last name value must be less than or equal to 255 characters. |
||
| 41 | * Required. |
||
| 42 | */ |
||
| 43 | public const LAST_NAME = 'last_name'; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * The full name value must be less than or equal to 255 characters. |
||
| 47 | * Required. |
||
| 48 | */ |
||
| 49 | public const NAME = 'name'; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * The customer’s email address. |
||
| 53 | * Required. |
||
| 54 | */ |
||
| 55 | public const EMAIL = 'email'; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Phone Number block name. |
||
| 59 | */ |
||
| 60 | public const PHONE_NUMBER = 'phone_number'; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var SubjectReader |
||
| 64 | */ |
||
| 65 | protected $subjectReader; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var OrderAdapterFactory |
||
| 69 | */ |
||
| 70 | protected $orderAdapterFactory; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param SubjectReader $subjectReader |
||
| 74 | * @param OrderAdapterFactory $orderAdapterFactory |
||
| 75 | */ |
||
| 76 | public function __construct( |
||
| 77 | SubjectReader $subjectReader, |
||
| 78 | OrderAdapterFactory $orderAdapterFactory |
||
| 79 | ) { |
||
| 80 | $this->subjectReader = $subjectReader; |
||
| 81 | $this->orderAdapterFactory = $orderAdapterFactory; |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Build. |
||
| 86 | * |
||
| 87 | * @param array $buildSubject |
||
| 88 | */ |
||
| 89 | public function build(array $buildSubject) |
||
| 90 | { |
||
| 91 | if (!isset($buildSubject['payment']) |
||
| 92 | || !$buildSubject['payment'] instanceof PaymentDataObjectInterface |
||
| 93 | ) { |
||
| 94 | throw new InvalidArgumentException('Payment data object should be provided'); |
||
| 95 | } |
||
| 96 | |||
| 97 | $paymentDO = $this->subjectReader->readPayment($buildSubject); |
||
| 98 | $payment = $paymentDO->getPayment(); |
||
| 99 | $result = []; |
||
| 100 | |||
| 101 | /** @var OrderAdapterFactory $orderAdapter * */ |
||
| 102 | $orderAdapter = $this->orderAdapterFactory->create( |
||
| 103 | ['order' => $payment->getOrder()] |
||
| 104 | ); |
||
| 105 | |||
| 106 | $billingAddress = $orderAdapter->getBillingAddress(); |
||
| 107 | |||
| 108 | $name = $billingAddress->getFirstname().' '.$billingAddress->getLastname(); |
||
| 109 | $result[self::CUSTOMER] = [ |
||
| 110 | self::CUSTOMER_ID => $billingAddress->getEmail(), |
||
| 111 | self::FIRST_NAME => $billingAddress->getFirstname(), |
||
| 112 | self::LAST_NAME => $billingAddress->getLastname(), |
||
| 113 | self::NAME => $name, |
||
| 114 | self::EMAIL => $billingAddress->getEmail(), |
||
| 115 | self::PHONE_NUMBER => preg_replace('/[^0-9]/', '', $billingAddress->getTelephone()), |
||
| 116 | ]; |
||
| 117 | |||
| 118 | return $result; |
||
| 119 | } |
||
| 120 | } |
||
| 121 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths