1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Paypal\Model;
use Magento\Payment\Model\Method\AbstractMethod;
/**
* Class PayflowConfig
* @todo ELiminate current configuration class
*/
class PayflowConfig extends Config
{
/**#@-*/
/**#@+
* Payment transaction types
*/
const TRXTYPE_AUTH_ONLY = 'A';
const TRXTYPE_SALE = 'S';
/**#@-*/
/**
* Mapper from Magento payment actions to PayPal-specific transaction types
*
* @return string|null
*/
public function getTrxType()
{
switch ($this->getValue('payment_action')) {
case self::PAYMENT_ACTION_AUTH:
return self::TRXTYPE_AUTH_ONLY;
case self::PAYMENT_ACTION_SALE:
return self::TRXTYPE_SALE;
default:
break;
}
return null;
}
/**
* Getter for URL to perform Payflow requests, based on test mode by default
*
* @param bool|null $testMode Ability to specify test mode using
* @return string
*/
public function getTransactionUrl($testMode = null)
{
$testMode = $testMode === null ? $this->getValue('sandbox_flag') : (bool)$testMode;
if ($testMode) {
return $this->methodInstance->getConfigData('transaction_url_test_mode');
}
return $this->methodInstance->getConfigData('transaction_url');
}
/**
* Payment action getter compatible with payment model
*
* @return string|null
*/
public function getPaymentAction()
{
switch ($this->getValue('payment_action')) {
case self::PAYMENT_ACTION_AUTH:
return AbstractMethod::ACTION_AUTHORIZE;
case self::PAYMENT_ACTION_SALE:
return AbstractMethod::ACTION_AUTHORIZE_CAPTURE;
default:
break;
}
return null;
}
/**
* Check whether method active in configuration and supported for merchant country or not
*
* @param string $method Method code
* @return bool
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function isMethodActive($method)
{
return parent::isMethodActive(Config::METHOD_PAYMENT_PRO)
|| parent::isMethodActive(Config::METHOD_PAYFLOWPRO);
}
/**
* Map any supported payment method into a config path by specified field name
*
* @param string $fieldName
* @return string|null
*/
protected function _getSpecificConfigPath($fieldName)
{
if ($this->pathPattern) {
return sprintf($this->pathPattern, $this->_methodCode, $fieldName);
}
return "payment/{$this->_methodCode}/{$fieldName}";
}
}