Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-braintree
Model
AvsEmsCodeMapper.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Braintree\Model
;
7
8
use
Magento\Braintree\Gateway\Response\PaymentDetailsHandler
;
9
use
Magento\Braintree\Model\Ui\ConfigProvider
;
10
use
Magento\Payment\Api\PaymentVerificationInterface
;
11
use
Magento\Sales\Api\Data\OrderPaymentInterface
;
12
20
class
AvsEmsCodeMapper
implements
PaymentVerificationInterface
21
{
27
private
static
$unavailableCode =
''
;
28
34
private
static
$avsMap = [
35
'MM'
=>
'Y'
,
36
'NM'
=>
'A'
,
37
'MN'
=>
'Z'
,
38
'NN'
=>
'N'
,
39
'UU'
=>
'U'
,
40
'II'
=>
'U'
,
41
'AA'
=>
'E'
42
];
43
51
public
function
getCode
(
OrderPaymentInterface
$orderPayment)
52
{
53
if
($orderPayment->
getMethod
() !==
ConfigProvider::CODE
) {
54
throw
new \InvalidArgumentException(
55
'The "'
. $orderPayment->
getMethod
() .
'" does not supported by Braintree AVS mapper.'
56
);
57
}
58
59
$additionalInfo = $orderPayment->
getAdditionalInformation
();
60
if
(empty($additionalInfo[
PaymentDetailsHandler::AVS_POSTAL_RESPONSE_CODE
]) ||
61
empty($additionalInfo[
PaymentDetailsHandler::AVS_STREET_ADDRESS_RESPONSE_CODE
])
62
) {
63
return
self::$unavailableCode;
64
}
65
66
$streetCode = $additionalInfo[
PaymentDetailsHandler::AVS_STREET_ADDRESS_RESPONSE_CODE
];
67
$zipCode = $additionalInfo[
PaymentDetailsHandler::AVS_POSTAL_RESPONSE_CODE
];
68
$key = $zipCode . $streetCode;
69
return
isset(self::$avsMap[$key]) ? self::$avsMap[$key] : self::$unavailableCode;
70
}
71
}
Magento\Braintree\Model
Magento\Sales\Api\Data\OrderPaymentInterface
Definition:
OrderPaymentInterface.php:17
Magento\Braintree\Gateway\Response\PaymentDetailsHandler
Definition:
PaymentDetailsHandler.php:16
Magento\Payment\Api\PaymentVerificationInterface
Definition:
PaymentVerificationInterface.php:24
Magento\Braintree\Gateway\Response\PaymentDetailsHandler\AVS_POSTAL_RESPONSE_CODE
const AVS_POSTAL_RESPONSE_CODE
Definition:
PaymentDetailsHandler.php:18
Magento\Braintree\Model\Ui\ConfigProvider
Definition:
ConfigProvider.php:17
Magento\Sales\Api\Data\OrderPaymentInterface\getMethod
getMethod()
Magento\Sales\Api\Data\OrderPaymentInterface\getAdditionalInformation
getAdditionalInformation()
Magento\Braintree\Model\AvsEmsCodeMapper\getCode
getCode(OrderPaymentInterface $orderPayment)
Definition:
AvsEmsCodeMapper.php:51
Magento\Braintree\Gateway\Response\PaymentDetailsHandler\AVS_STREET_ADDRESS_RESPONSE_CODE
const AVS_STREET_ADDRESS_RESPONSE_CODE
Definition:
PaymentDetailsHandler.php:20
Magento\Braintree\Model\Ui\ConfigProvider\CODE
const CODE
Definition:
ConfigProvider.php:19
Magento\Braintree\Model\AvsEmsCodeMapper
Definition:
AvsEmsCodeMapper.php:20