Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Paypal_Adminhtml_Paypal_ReportsController
  • Mage_Paypal_Block_Adminhtml_Settlement_Details
  • Mage_Paypal_Block_Adminhtml_Settlement_Details_Form
  • Mage_Paypal_Block_Adminhtml_Settlement_Report
  • Mage_Paypal_Block_Adminhtml_Settlement_Report_Grid
  • Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard
  • Mage_Paypal_Block_Adminhtml_System_Config_Field_Country
  • Mage_Paypal_Block_Adminhtml_System_Config_Field_Hidden
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Expanded
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Group
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Location
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Payment
  • Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Store
  • Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Advanced
  • Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info
  • Mage_Paypal_Block_Express_Form
  • Mage_Paypal_Block_Express_Review
  • Mage_Paypal_Block_Express_Review_Billing
  • Mage_Paypal_Block_Express_Review_Details
  • Mage_Paypal_Block_Express_Review_Shipping
  • Mage_Paypal_Block_Express_Shortcut
  • Mage_Paypal_Block_Hosted_Pro_Form
  • Mage_Paypal_Block_Hosted_Pro_Iframe
  • Mage_Paypal_Block_Hosted_Pro_Info
  • Mage_Paypal_Block_Iframe
  • Mage_Paypal_Block_Logo
  • Mage_Paypal_Block_Payflow_Advanced_Form
  • Mage_Paypal_Block_Payflow_Advanced_Iframe
  • Mage_Paypal_Block_Payflow_Advanced_Info
  • Mage_Paypal_Block_Payflow_Link_Form
  • Mage_Paypal_Block_Payflow_Link_Iframe
  • Mage_Paypal_Block_Payflow_Link_Info
  • Mage_Paypal_Block_Payment_Info
  • Mage_Paypal_Block_Standard_Form
  • Mage_Paypal_Block_Standard_Redirect
  • Mage_Paypal_Controller_Express_Abstract
  • Mage_Paypal_ExpressController
  • Mage_Paypal_Helper_Data
  • Mage_Paypal_Helper_Hss
  • Mage_Paypal_HostedproController
  • Mage_Paypal_IpnController
  • Mage_Paypal_Model_Api_Abstract
  • Mage_Paypal_Model_Api_Nvp
  • Mage_Paypal_Model_Api_Standard
  • Mage_Paypal_Model_Cart
  • Mage_Paypal_Model_Cert
  • Mage_Paypal_Model_Config
  • Mage_Paypal_Model_Direct
  • Mage_Paypal_Model_Express
  • Mage_Paypal_Model_Express_Checkout
  • Mage_Paypal_Model_Hostedpro
  • Mage_Paypal_Model_Hostedpro_Request
  • Mage_Paypal_Model_Info
  • Mage_Paypal_Model_Ipn
  • Mage_Paypal_Model_Method_Agreement
  • Mage_Paypal_Model_Mysql4_Cert
  • Mage_Paypal_Model_Mysql4_Report_Settlement
  • Mage_Paypal_Model_Mysql4_Report_Settlement_Row
  • Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection
  • Mage_Paypal_Model_Mysql4_Setup
  • Mage_Paypal_Model_Observer
  • Mage_Paypal_Model_Payflow_Request
  • Mage_Paypal_Model_Payflowadvanced
  • Mage_Paypal_Model_Payflowlink
  • Mage_Paypal_Model_Payflowpro
  • Mage_Paypal_Model_Payment_Transaction
  • Mage_Paypal_Model_Pro
  • Mage_Paypal_Model_Report_Settlement
  • Mage_Paypal_Model_Report_Settlement_Row
  • Mage_Paypal_Model_Resource_Cert
  • Mage_Paypal_Model_Resource_Report_Settlement
  • Mage_Paypal_Model_Resource_Report_Settlement_Row
  • Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection
  • Mage_Paypal_Model_Resource_Setup
  • Mage_Paypal_Model_Session
  • Mage_Paypal_Model_Standard
  • Mage_Paypal_Model_System_Config_Backend_Cert
  • Mage_Paypal_Model_System_Config_Backend_Cron
  • Mage_Paypal_Model_System_Config_Backend_MerchantCountry
  • Mage_Paypal_Model_System_Config_Source_BuyerCountry
  • Mage_Paypal_Model_System_Config_Source_FetchingSchedule
  • Mage_Paypal_Model_System_Config_Source_Logo
  • Mage_Paypal_Model_System_Config_Source_MerchantCountry
  • Mage_Paypal_Model_System_Config_Source_PaymentActions
  • Mage_Paypal_Model_System_Config_Source_PaymentActions_Express
  • Mage_Paypal_Model_System_Config_Source_RequireBillingAddress
  • Mage_Paypal_Model_System_Config_Source_UrlMethod
  • Mage_Paypal_PayflowadvancedController
  • Mage_Paypal_PayflowController
  • Mage_Paypal_StandardController

Exceptions

  • Mage_Paypal_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Paypal
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * PayPal payment information model
 29:  *
 30:  * Aware of all PayPal payment methods
 31:  * Collects and provides access to PayPal-specific payment data
 32:  * Provides business logic information about payment flow
 33:  */
 34: class Mage_Paypal_Model_Info
 35: {
 36:     /**
 37:      * Cross-models public exchange keys
 38:      *
 39:      * @var string
 40:      */
 41:     const PAYER_ID       = 'payer_id';
 42:     const PAYER_EMAIL    = 'email';
 43:     const PAYER_STATUS   = 'payer_status';
 44:     const ADDRESS_ID     = 'address_id';
 45:     const ADDRESS_STATUS = 'address_status';
 46:     const PROTECTION_EL  = 'protection_eligibility';
 47:     const FRAUD_FILTERS  = 'collected_fraud_filters';
 48:     const CORRELATION_ID = 'correlation_id';
 49:     const AVS_CODE       = 'avs_result';
 50:     const CVV2_MATCH     = 'cvv2_check_result';
 51:     const CENTINEL_VPAS  = 'centinel_vpas_result';
 52:     const CENTINEL_ECI   = 'centinel_eci_result';
 53: 
 54:     // Next two fields are required for Brazil
 55:     const BUYER_TAX_ID   = 'buyer_tax_id';
 56:     const BUYER_TAX_ID_TYPE = 'buyer_tax_id_type';
 57: 
 58:     const PAYMENT_STATUS = 'payment_status';
 59:     const PENDING_REASON = 'pending_reason';
 60:     const IS_FRAUD       = 'is_fraud_detected';
 61:     const PAYMENT_STATUS_GLOBAL = 'paypal_payment_status';
 62:     const PENDING_REASON_GLOBAL = 'paypal_pending_reason';
 63:     const IS_FRAUD_GLOBAL       = 'paypal_is_fraud_detected';
 64: 
 65:     /**
 66:      * Possible buyer's tax id types (Brazil only)
 67:      */
 68:     const BUYER_TAX_ID_TYPE_CPF = 'BR_CPF';
 69:     const BUYER_TAX_ID_TYPE_CNPJ = 'BR_CNPJ';
 70: 
 71:     /**
 72:      * All payment information map
 73:      *
 74:      * @var array
 75:      */
 76:     protected $_paymentMap = array(
 77:         self::PAYER_ID       => 'paypal_payer_id',
 78:         self::PAYER_EMAIL    => 'paypal_payer_email',
 79:         self::PAYER_STATUS   => 'paypal_payer_status',
 80:         self::ADDRESS_ID     => 'paypal_address_id',
 81:         self::ADDRESS_STATUS => 'paypal_address_status',
 82:         self::PROTECTION_EL  => 'paypal_protection_eligibility',
 83:         self::FRAUD_FILTERS  => 'paypal_fraud_filters',
 84:         self::CORRELATION_ID => 'paypal_correlation_id',
 85:         self::AVS_CODE       => 'paypal_avs_code',
 86:         self::CVV2_MATCH     => 'paypal_cvv2_match',
 87:         self::CENTINEL_VPAS  => self::CENTINEL_VPAS,
 88:         self::CENTINEL_ECI   => self::CENTINEL_ECI,
 89:         self::BUYER_TAX_ID   => self::BUYER_TAX_ID,
 90:         self::BUYER_TAX_ID_TYPE => self::BUYER_TAX_ID_TYPE,
 91:     );
 92: 
 93:     /**
 94:      * System information map
 95:      *
 96:      * @var array
 97:      */
 98:     protected $_systemMap = array(
 99:         self::PAYMENT_STATUS => self::PAYMENT_STATUS_GLOBAL,
100:         self::PENDING_REASON => self::PENDING_REASON_GLOBAL,
101:         self::IS_FRAUD       => self::IS_FRAUD_GLOBAL,
102:     );
103: 
104:     /**
105:      * PayPal payment status possible values
106:      *
107:      * @var string
108:      */
109:     const PAYMENTSTATUS_NONE         = 'none';
110:     const PAYMENTSTATUS_COMPLETED    = 'completed';
111:     const PAYMENTSTATUS_DENIED       = 'denied';
112:     const PAYMENTSTATUS_EXPIRED      = 'expired';
113:     const PAYMENTSTATUS_FAILED       = 'failed';
114:     const PAYMENTSTATUS_INPROGRESS   = 'in_progress';
115:     const PAYMENTSTATUS_PENDING      = 'pending';
116:     const PAYMENTSTATUS_REFUNDED     = 'refunded';
117:     const PAYMENTSTATUS_REFUNDEDPART = 'partially_refunded';
118:     const PAYMENTSTATUS_REVERSED     = 'reversed';
119:     const PAYMENTSTATUS_UNREVERSED   = 'canceled_reversal';
120:     const PAYMENTSTATUS_PROCESSED    = 'processed';
121:     const PAYMENTSTATUS_VOIDED       = 'voided';
122: 
123:     /**
124:      * Map of payment information available to customer
125:      *
126:      * @var array
127:      */
128:     protected $_paymentPublicMap = array(
129:         'paypal_payer_email',
130:         self::BUYER_TAX_ID,
131:         self::BUYER_TAX_ID_TYPE
132:     );
133: 
134:     /**
135:      * Rendered payment map cache
136:      *
137:      * @var array
138:      */
139:     protected $_paymentMapFull = array();
140: 
141:     /**
142:      * All available payment info getter
143:      *
144:      * @param Mage_Payment_Model_Info $payment
145:      * @param bool $labelValuesOnly
146:      * @return array
147:      */
148:     public function getPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
149:     {
150:         // collect paypal-specific info
151:         $result = $this->_getFullInfo(array_values($this->_paymentMap), $payment, $labelValuesOnly);
152: 
153:         // add last_trans_id
154:         $label = Mage::helper('paypal')->__('Last Transaction ID');
155:         $value = $payment->getLastTransId();
156:         if ($labelValuesOnly) {
157:             $result[$label] = $value;
158:         } else {
159:             $result['last_trans_id'] = array('label' => $label, 'value' => $value);
160:         }
161: 
162:         return $result;
163:     }
164: 
165:     /**
166:      * Public payment info getter
167:      *
168:      * @param Mage_Payment_Model_Info $payment
169:      * @param bool $labelValuesOnly
170:      * @return array
171:      */
172:     public function getPublicPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
173:     {
174:         return $this->_getFullInfo($this->_paymentPublicMap, $payment, $labelValuesOnly);
175:     }
176: 
177:     /**
178:      * Grab data from source and map it into payment
179:      *
180:      * @param array|Varien_Object|callback $from
181:      * @param Mage_Payment_Model_Info $payment
182:      */
183:     public function importToPayment($from, Mage_Payment_Model_Info $payment)
184:     {
185:         $fullMap = array_merge($this->_paymentMap, $this->_systemMap);
186:         if (is_object($from)) {
187:             $from = array($from, 'getDataUsingMethod');
188:         }
189:         Varien_Object_Mapper::accumulateByMap($from, array($payment, 'setAdditionalInformation'), $fullMap);
190:     }
191: 
192:     /**
193:      * Grab data from payment and map it into target
194:      *
195:      * @param Mage_Payment_Model_Info $payment
196:      * @param array|Varien_Object|callback $to
197:      * @param array $map
198:      * @return array|Varien_Object
199:      */
200:     public function &exportFromPayment(Mage_Payment_Model_Info $payment, $to, array $map = null)
201:     {
202:         $fullMap = array_merge($this->_paymentMap, $this->_systemMap);
203:         Varien_Object_Mapper::accumulateByMap(array($payment, 'getAdditionalInformation'), $to,
204:             $map ? $map : array_flip($fullMap)
205:         );
206:         return $to;
207:     }
208: 
209:     /**
210:      * Check whether the payment is in review state
211:      *
212:      * @param Mage_Payment_Model_Info $payment
213:      * @return bool
214:      */
215:     public static function isPaymentReviewRequired(Mage_Payment_Model_Info $payment)
216:     {
217:         $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
218:         if (self::PAYMENTSTATUS_PENDING === $paymentStatus) {
219:             $pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
220:             return !in_array($pendingReason, array('authorization', 'order'));
221:         }
222:         return false;
223:     }
224: 
225:     /**
226:      * Check whether fraud order review detected and can be reviewed
227:      *
228:      * @param Mage_Payment_Model_Info $payment
229:      * @return bool
230:      */
231:     public static function isFraudReviewAllowed(Mage_Payment_Model_Info $payment)
232:     {
233:         return self::isPaymentReviewRequired($payment)
234:             && 1 == $payment->getAdditionalInformation(self::IS_FRAUD_GLOBAL);
235:     }
236: 
237:     /**
238:      * Check whether the payment is completed
239:      *
240:      * @param Mage_Payment_Model_Info $payment
241:      * @return bool
242:      */
243:     public static function isPaymentCompleted(Mage_Payment_Model_Info $payment)
244:     {
245:         $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
246:         return self::PAYMENTSTATUS_COMPLETED === $paymentStatus;
247:     }
248: 
249:     /**
250:      * Check whether the payment was processed successfully
251:      *
252:      * @param Mage_Payment_Model_Info $payment
253:      * @return bool
254:      */
255:     public static function isPaymentSuccessful(Mage_Payment_Model_Info $payment)
256:     {
257:         $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
258:         if (in_array($paymentStatus, array(
259:             self::PAYMENTSTATUS_COMPLETED, self::PAYMENTSTATUS_INPROGRESS, self::PAYMENTSTATUS_REFUNDED,
260:             self::PAYMENTSTATUS_REFUNDEDPART, self::PAYMENTSTATUS_UNREVERSED, self::PAYMENTSTATUS_PROCESSED,
261:         ))) {
262:             return true;
263:         }
264:         $pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
265:         return self::PAYMENTSTATUS_PENDING === $paymentStatus
266:             && in_array($pendingReason, array('authorization', 'order'));
267:     }
268: 
269:     /**
270:      * Check whether the payment was processed unsuccessfully or failed
271:      *
272:      * @param Mage_Payment_Model_Info $payment
273:      * @return bool
274:      */
275:     public static function isPaymentFailed(Mage_Payment_Model_Info $payment)
276:     {
277:         $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
278:         return in_array($paymentStatus, array(
279:             self::PAYMENTSTATUS_DENIED, self::PAYMENTSTATUS_EXPIRED, self::PAYMENTSTATUS_FAILED,
280:             self::PAYMENTSTATUS_REVERSED, self::PAYMENTSTATUS_VOIDED,
281:         ));
282:     }
283: 
284:     /**
285:      * Explain pending payment reason code
286:      *
287:      * @param string $code
288:      * @return string
289:      * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables
290:      * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails
291:      */
292:     public static function explainPendingReason($code)
293:     {
294:         switch ($code) {
295:             case 'address':
296:                 return Mage::helper('paypal')->__('Customer did not include a confirmed address.');
297:             case 'authorization':
298:             case 'order':
299:                 return Mage::helper('paypal')->__('The payment is authorized but not settled.');
300:             case 'echeck':
301:                 return Mage::helper('paypal')->__('The payment eCheck is not yet cleared.');
302:             case 'intl':
303:                 return Mage::helper('paypal')->__('Merchant holds a non-U.S. account and does not have a withdrawal mechanism.');
304:             case 'multi-currency': // break is intentionally omitted
305:             case 'multi_currency': // break is intentionally omitted
306:             case 'multicurrency':
307:                 return Mage::helper('paypal')->__('The payment curency does not match any of the merchant\'s balances currency.');
308:             case 'paymentreview':
309:                 return Mage::helper('paypal')->__('The payment is pending while it is being reviewed by PayPal for risk.');
310:             case 'unilateral':
311:                 return Mage::helper('paypal')->__('The payment is pending because it was made to an email address that is not yet registered or confirmed.');
312:             case 'verify':
313:                 return Mage::helper('paypal')->__('The merchant account is not yet verified.');
314:             case 'upgrade':
315:                 return Mage::helper('paypal')->__('The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.');
316:             case 'none': // break is intentionally omitted
317:             case 'other': // break is intentionally omitted
318:             default:
319:                 return Mage::helper('paypal')->__('Unknown reason. Please contact PayPal customer service.');
320:         }
321:     }
322: 
323:     /**
324:      * Explain the refund or chargeback reason code
325:      *
326:      * @param $code
327:      * @return string
328:      * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables
329:      * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails
330:      */
331:     public static function explainReasonCode($code)
332:     {
333:         switch ($code) {
334:             case 'chargeback':
335:                 return Mage::helper('paypal')->__('Chargeback by customer.');
336:             case 'guarantee':
337:                 return Mage::helper('paypal')->__('Customer triggered a money-back guarantee.');
338:             case 'buyer-complaint':
339:                 return Mage::helper('paypal')->__('Customer complaint.');
340:             case 'refund':
341:                 return Mage::helper('paypal')->__('Refund issued by merchant.');
342:             case 'adjustment_reversal':
343:                 return Mage::helper('paypal')->__('Reversal of an adjustment.');
344:             case 'chargeback_reimbursement':
345:                 return Mage::helper('paypal')->__('Reimbursement for a chargeback.');
346:             case 'chargeback_settlement':
347:                 return Mage::helper('paypal')->__('Settlement of a chargeback.');
348:             case 'none': // break is intentionally omitted
349:             case 'other':
350:             default:
351:                 return Mage::helper('paypal')->__('Unknown reason. Please contact PayPal customer service.');
352:         }
353:     }
354: 
355:     /**
356:      * Whether a reversal/refund can be disputed with PayPal
357:      *
358:      * @param string $code
359:      * @return bool;
360:      */
361:     public static function isReversalDisputable($code)
362:     {
363:         switch ($code) {
364:             case 'none':
365:             case 'other':
366:             case 'chargeback':
367:             case 'buyer-complaint':
368:             case 'adjustment_reversal':
369:                 return true;
370:             case 'guarantee':
371:             case 'refund':
372:             case 'chargeback_reimbursement':
373:             case 'chargeback_settlement':
374:             default:
375:                 return false;
376:         }
377:     }
378: 
379:     /**
380:      * Render info item
381:      *
382:      * @param array $keys
383:      * @param Mage_Payment_Model_Info $payment
384:      * @param bool $labelValuesOnly
385:      */
386:     protected function _getFullInfo(array $keys, Mage_Payment_Model_Info $payment, $labelValuesOnly)
387:     {
388:         $result = array();
389:         foreach ($keys as $key) {
390:             if (!isset($this->_paymentMapFull[$key])) {
391:                 $this->_paymentMapFull[$key] = array();
392:             }
393:             if (!isset($this->_paymentMapFull[$key]['label'])) {
394:                 if (!$payment->hasAdditionalInformation($key)) {
395:                     $this->_paymentMapFull[$key]['label'] = false;
396:                     $this->_paymentMapFull[$key]['value'] = false;
397:                 } else {
398:                     $value = $payment->getAdditionalInformation($key);
399:                     $this->_paymentMapFull[$key]['label'] = $this->_getLabel($key);
400:                     $this->_paymentMapFull[$key]['value'] = $this->_getValue($value, $key);
401:                 }
402:             }
403:             if (!empty($this->_paymentMapFull[$key]['value'])) {
404:                 if ($labelValuesOnly) {
405:                     $result[$this->_paymentMapFull[$key]['label']] = $this->_paymentMapFull[$key]['value'];
406:                 } else {
407:                     $result[$key] = $this->_paymentMapFull[$key];
408:                 }
409:             }
410:         }
411:         return $result;
412:     }
413: 
414:     /**
415:      * Render info item labels
416:      *
417:      * @param string $key
418:      */
419:     protected function _getLabel($key)
420:     {
421:         switch ($key) {
422:             case 'paypal_payer_id':
423:                 return Mage::helper('paypal')->__('Payer ID');
424:             case 'paypal_payer_email':
425:                 return Mage::helper('paypal')->__('Payer Email');
426:             case 'paypal_payer_status':
427:                 return Mage::helper('paypal')->__('Payer Status');
428:             case 'paypal_address_id':
429:                 return Mage::helper('paypal')->__('Payer Address ID');
430:             case 'paypal_address_status':
431:                 return Mage::helper('paypal')->__('Payer Address Status');
432:             case 'paypal_protection_eligibility':
433:                 return Mage::helper('paypal')->__('Merchant Protection Eligibility');
434:             case 'paypal_fraud_filters':
435:                 return Mage::helper('paypal')->__('Triggered Fraud Filters');
436:             case 'paypal_correlation_id':
437:                 return Mage::helper('paypal')->__('Last Correlation ID');
438:             case 'paypal_avs_code':
439:                 return Mage::helper('paypal')->__('Address Verification System Response');
440:             case 'paypal_cvv2_match':
441:                 return Mage::helper('paypal')->__('CVV2 Check Result by PayPal');
442:             case self::BUYER_TAX_ID :
443:                 return Mage::helper('paypal')->__('Buyer\'s Tax ID');
444:             case self::BUYER_TAX_ID_TYPE :
445:                 return Mage::helper('paypal')->__('Buyer\'s Tax ID Type');
446:             case self::CENTINEL_VPAS:
447:                 return Mage::helper('paypal')->__('PayPal/Centinel Visa Payer Authentication Service Result');
448:             case self::CENTINEL_ECI:
449:                 return Mage::helper('paypal')->__('PayPal/Centinel Electronic Commerce Indicator');
450:         }
451:         return '';
452:     }
453: 
454:     /**
455:      * Apply a filter upon value getting
456:      *
457:      * @param string $value
458:      * @param string $key
459:      * @return string
460:      */
461:     protected function _getValue($value, $key)
462:     {
463:         $label = '';
464:         switch ($key) {
465:             case 'paypal_avs_code':
466:                 $label = $this->_getAvsLabel($value);
467:                 break;
468:             case 'paypal_cvv2_match':
469:                 $label = $this->_getCvv2Label($value);
470:                 break;
471:             case self::CENTINEL_VPAS:
472:                 $label = $this->_getCentinelVpasLabel($value);
473:                 break;
474:             case self::CENTINEL_ECI:
475:                 $label = $this->_getCentinelEciLabel($value);
476:                 break;
477:             case self::BUYER_TAX_ID_TYPE :
478:                 $value = $this->_getBuyerIdTypeValue($value);
479:             default:
480:                 return $value;
481:         }
482:         return sprintf('#%s%s', $value, $value == $label ? '' : ': ' . $label);
483:     }
484: 
485:     /**
486:      * Attempt to convert AVS check result code into label
487:      *
488:      * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_AVSResponseCodes
489:      * @param string $value
490:      * @return string
491:      */
492:     protected function _getAvsLabel($value)
493:     {
494:         switch ($value) {
495:             // Visa, MasterCard, Discover and American Express
496:             case 'A':
497:             case 'YN':
498:                 return Mage::helper('paypal')->__('Matched Address only (no ZIP)');
499:             case 'B': // international "A"
500:                 return Mage::helper('paypal')->__('Matched Address only (no ZIP). International');
501:             case 'N':
502:                 return Mage::helper('paypal')->__('No Details matched');
503:             case 'C': // international "N"
504:                 return Mage::helper('paypal')->__('No Details matched. International');
505:             case 'X':
506:                 return Mage::helper('paypal')->__('Exact Match. Address and nine-digit ZIP code');
507:             case 'D': // international "X"
508:                 return Mage::helper('paypal')->__('Exact Match. Address and Postal Code. International');
509:             case 'F': // UK-specific "X"
510:                 return Mage::helper('paypal')->__('Exact Match. Address and Postal Code. UK-specific');
511:             case 'E':
512:                 return Mage::helper('paypal')->__('N/A. Not allowed for MOTO (Internet/Phone) transactions');
513:             case 'G':
514:                 return Mage::helper('paypal')->__('N/A. Global Unavailable');
515:             case 'I':
516:                 return Mage::helper('paypal')->__('N/A. International Unavailable');
517:             case 'Z':
518:             case 'NY':
519:                 return Mage::helper('paypal')->__('Matched five-digit ZIP only (no Address)');
520:             case 'P': // international "Z"
521:             case 'NY':
522:                 return Mage::helper('paypal')->__('Matched Postal Code only (no Address)');
523:             case 'R':
524:                 return Mage::helper('paypal')->__('N/A. Retry');
525:             case 'S':
526:                 return Mage::helper('paypal')->__('N/A. Service not Supported');
527:             case 'U':
528:                 return Mage::helper('paypal')->__('N/A. Unavailable');
529:             case 'W':
530:                 return Mage::helper('paypal')->__('Matched whole nine-didgit ZIP (no Address)');
531:             case 'Y':
532:                 return Mage::helper('paypal')->__('Yes. Matched Address and five-didgit ZIP');
533:             // Maestro and Solo
534:             case '0':
535:                 return Mage::helper('paypal')->__('All the address information matched');
536:             case '1':
537:                 return Mage::helper('paypal')->__('None of the address information matched');
538:             case '2':
539:                 return Mage::helper('paypal')->__('Part of the address information matched');
540:             case '3':
541:                 return Mage::helper('paypal')->__('N/A. The merchant did not provide AVS information');
542:             case '4':
543:                 return Mage::helper('paypal')->__('N/A. Address not checked, or acquirer had no response. Service not available');
544:             default:
545:                 return $value;
546:         }
547:     }
548: 
549:     /**
550:      * Attempt to convert CVV2 check result code into label
551:      *
552:      * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_AVSResponseCodes
553:      * @param string $value
554:      * @return string
555:      */
556:     protected function _getCvv2Label($value)
557:     {
558:         switch ($value) {
559:             // Visa, MasterCard, Discover and American Express
560:             case 'M':
561:                 return Mage::helper('paypal')->__('Matched (CVV2CSC)');
562:             case 'N':
563:                 return Mage::helper('paypal')->__('No match');
564:             case 'P':
565:                 return Mage::helper('paypal')->__('N/A. Not processed');
566:             case 'S':
567:                 return Mage::helper('paypal')->__('N/A. Service not supported');
568:             case 'U':
569:                 return Mage::helper('paypal')->__('N/A. Service not available');
570:             case 'X':
571:                 return Mage::helper('paypal')->__('N/A. No response');
572:             // Maestro and Solo
573:             case '0':
574:                 return Mage::helper('paypal')->__('Matched (CVV2)');
575:             case '1':
576:                 return Mage::helper('paypal')->__('No match');
577:             case '2':
578:                 return Mage::helper('paypal')->__('N/A. The merchant has not implemented CVV2 code handling');
579:             case '3':
580:                 return Mage::helper('paypal')->__('N/A. Merchant has indicated that CVV2 is not present on card');
581:             case '4':
582:                 return Mage::helper('paypal')->__('N/A. Service not available');
583:             default:
584:                 return $value;
585:         }
586:     }
587: 
588:     /**
589:      * Attempt to convert centinel VPAS result into label
590:      *
591:      * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoDirectPayment
592:      * @param string $value
593:      * @return string
594:      */
595:     private function _getCentinelVpasLabel($value)
596:     {
597:         switch ($value) {
598:             case '2':
599:             case 'D':
600:                 return Mage::helper('paypal')->__('Authenticated, Good Result');
601:             case '1':
602:                 return Mage::helper('paypal')->__('Authenticated, Bad Result');
603:             case '3':
604:             case '6':
605:             case '8':
606:             case 'A':
607:             case 'C':
608:                 return Mage::helper('paypal')->__('Attempted Authentication, Good Result');
609:             case '4':
610:             case '7':
611:             case '9':
612:                 return Mage::helper('paypal')->__('Attempted Authentication, Bad Result');
613:             case '':
614:             case '0':
615:             case 'B':
616:                 return Mage::helper('paypal')->__('No Liability Shift');
617:             default:
618:                 return $value;
619:         }
620:     }
621: 
622:     /**
623:      * Attempt to convert centinel ECI result into label
624:      *
625:      * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoDirectPayment
626:      * @param string $value
627:      * @return string
628:      */
629:     private function _getCentinelEciLabel($value)
630:     {
631:         switch ($value) {
632:             case '01':
633:             case '07':
634:                 return Mage::helper('paypal')->__('Merchant Liability');
635:             case '02':
636:             case '05':
637:             case '06':
638:                 return Mage::helper('paypal')->__('Issuer Liability');
639:             default:
640:                 return $value;
641:         }
642:     }
643: 
644:     /**
645:      * Retrieve buyer id type value based on code received from PayPal (Brazil only)
646:      *
647:      * @param string $code
648:      * @return string
649:      */
650:     protected function _getBuyerIdTypeValue($code)
651:     {
652:         $value = '';
653:         switch ($code) {
654:             case self::BUYER_TAX_ID_TYPE_CNPJ :
655:                 $value = Mage::helper('paypal')->__('CNPJ');
656:                 break;
657:             case self::BUYER_TAX_ID_TYPE_CPF :
658:                 $value = Mage::helper('paypal')->__('CPF');
659:                 break;
660:         }
661:         return $value;
662:     }
663: }
664: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0