1: <?php
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: class Mage_Paypal_Model_Report_Settlement_Row extends Mage_Core_Model_Abstract
73: {
74: 75: 76: 77: 78:
79: protected static $_eventList = array();
80:
81: 82: 83: 84: 85:
86: protected $_castedAmounts = array();
87:
88: 89: 90:
91: protected function _construct()
92: {
93: $this->_init('paypal/report_settlement_row');
94: }
95:
96: 97: 98: 99: 100: 101: 102:
103: public function getReferenceType($code = null)
104: {
105: $types = array(
106: 'TXN' => Mage::helper('paypal')->__('Transaction ID'),
107: 'ODR' => Mage::helper('paypal')->__('Order ID'),
108: 'SUB' => Mage::helper('paypal')->__('Subscription ID'),
109: 'PAP' => Mage::helper('paypal')->__('Preapproved Payment ID')
110: );
111: if($code === null) {
112: asort($types);
113: return $types;
114: }
115: if (isset($types[$code])) {
116: return $types[$code];
117: }
118: return $code;
119: }
120:
121: 122: 123: 124: 125: 126:
127: public function getTransactionEvent($code)
128: {
129: $this->_generateEventLabels();
130: if (isset(self::$_eventList[$code])) {
131: return self::$_eventList[$code];
132: }
133: return $code;
134: }
135:
136: 137: 138: 139: 140:
141: public function &getTransactionEvents()
142: {
143: $this->_generateEventLabels();
144: return self::$_eventList;
145: }
146:
147: 148: 149: 150: 151: 152: 153:
154: public function getDebitCreditText($code = null)
155: {
156: $options = array(
157: 'CR' => Mage::helper('paypal')->__('Credit'),
158: 'DR' => Mage::helper('paypal')->__('Debit'),
159: );
160: if($code === null) {
161: return $options;
162: }
163: if (isset($options[$code])) {
164: return $options[$code];
165: }
166: return $code;
167: }
168:
169: 170: 171: 172: 173: 174: 175:
176: public function getData($key = '', $index = null)
177: {
178: $this->_castAmount('fee_amount', 'fee_debit_or_credit');
179: $this->_castAmount('gross_transaction_amount', 'transaction_debit_or_credit');
180: return parent::getData($key, $index);
181: }
182:
183: 184: 185: 186: 187: 188: 189: 190: 191:
192: public function _castAmount($key, $creditKey)
193: {
194: if (isset($this->_castedAmounts[$key]) || !isset($this->_data[$key]) || !isset($this->_data[$creditKey])) {
195: return;
196: }
197: if (empty($this->_data[$key])) {
198: return;
199: }
200: $amount = $this->_data[$key] / 100;
201: if ('CR' === $this->_data[$creditKey]) {
202: $amount = -1 * $amount;
203: }
204: $this->_data[$key] = $amount;
205: $this->_castedAmounts[$key] = true;
206: }
207:
208: 209: 210:
211: protected function _generateEventLabels()
212: {
213: if (!self::$_eventList) {
214: self::$_eventList = array(
215: 'T0000' => Mage::helper('paypal')->__('General: received payment of a type not belonging to the other T00xx categories'),
216: 'T0001' => Mage::helper('paypal')->__('Mass Pay Payment'),
217: 'T0002' => Mage::helper('paypal')->__('Subscription Payment, either payment sent or payment received'),
218: 'T0003' => Mage::helper('paypal')->__('Preapproved Payment (BillUser API), either sent or received'),
219: 'T0004' => Mage::helper('paypal')->__('eBay Auction Payment'),
220: 'T0005' => Mage::helper('paypal')->__('Direct Payment API'),
221: 'T0006' => Mage::helper('paypal')->__('Express Checkout APIs'),
222: 'T0007' => Mage::helper('paypal')->__('Website Payments Standard Payment'),
223: 'T0008' => Mage::helper('paypal')->__('Postage Payment to either USPS or UPS'),
224: 'T0009' => Mage::helper('paypal')->__('Gift Certificate Payment: purchase of Gift Certificate'),
225: 'T0010' => Mage::helper('paypal')->__('Auction Payment other than through eBay'),
226: 'T0011' => Mage::helper('paypal')->__('Mobile Payment (made via a mobile phone)'),
227: 'T0012' => Mage::helper('paypal')->__('Virtual Terminal Payment'),
228: 'T0100' => Mage::helper('paypal')->__('General: non-payment fee of a type not belonging to the other T01xx categories'),
229: 'T0101' => Mage::helper('paypal')->__('Fee: Web Site Payments Pro Account Monthly'),
230: 'T0102' => Mage::helper('paypal')->__('Fee: Foreign ACH Withdrawal'),
231: 'T0103' => Mage::helper('paypal')->__('Fee: WorldLink Check Withdrawal'),
232: 'T0104' => Mage::helper('paypal')->__('Fee: Mass Pay Request'),
233: 'T0200' => Mage::helper('paypal')->__('General Currency Conversion'),
234: 'T0201' => Mage::helper('paypal')->__('User-initiated Currency Conversion'),
235: 'T0202' => Mage::helper('paypal')->__('Currency Conversion required to cover negative balance'),
236: 'T0300' => Mage::helper('paypal')->__('General Funding of PayPal Account '),
237: 'T0301' => Mage::helper('paypal')->__('PayPal Balance Manager function of PayPal account'),
238: 'T0302' => Mage::helper('paypal')->__('ACH Funding for Funds Recovery from Account Balance'),
239: 'T0303' => Mage::helper('paypal')->__('EFT Funding (German banking)'),
240: 'T0400' => Mage::helper('paypal')->__('General Withdrawal from PayPal Account'),
241: 'T0401' => Mage::helper('paypal')->__('AutoSweep'),
242: 'T0500' => Mage::helper('paypal')->__('General: Use of PayPal account for purchasing as well as receiving payments'),
243: 'T0501' => Mage::helper('paypal')->__('Virtual PayPal Debit Card Transaction'),
244: 'T0502' => Mage::helper('paypal')->__('PayPal Debit Card Withdrawal from ATM'),
245: 'T0503' => Mage::helper('paypal')->__('Hidden Virtual PayPal Debit Card Transaction'),
246: 'T0504' => Mage::helper('paypal')->__('PayPal Debit Card Cash Advance'),
247: 'T0600' => Mage::helper('paypal')->__('General: Withdrawal from PayPal Account'),
248: 'T0700' => Mage::helper('paypal')->__('General (Purchase with a credit card)'),
249: 'T0701' => Mage::helper('paypal')->__('Negative Balance'),
250: 'T0800' => Mage::helper('paypal')->__('General: bonus of a type not belonging to the other T08xx categories'),
251: 'T0801' => Mage::helper('paypal')->__('Debit Card Cash Back'),
252: 'T0802' => Mage::helper('paypal')->__('Merchant Referral Bonus'),
253: 'T0803' => Mage::helper('paypal')->__('Balance Manager Account Bonus'),
254: 'T0804' => Mage::helper('paypal')->__('PayPal Buyer Warranty Bonus'),
255: 'T0805' => Mage::helper('paypal')->__('PayPal Protection Bonus'),
256: 'T0806' => Mage::helper('paypal')->__('Bonus for first ACH Use'),
257: 'T0900' => Mage::helper('paypal')->__('General Redemption'),
258: 'T0901' => Mage::helper('paypal')->__('Gift Certificate Redemption'),
259: 'T0902' => Mage::helper('paypal')->__('Points Incentive Redemption'),
260: 'T0903' => Mage::helper('paypal')->__('Coupon Redemption'),
261: 'T0904' => Mage::helper('paypal')->__('Reward Voucher Redemption'),
262: 'T1000' => Mage::helper('paypal')->__('General. Product no longer supported'),
263: 'T1100' => Mage::helper('paypal')->__('General: reversal of a type not belonging to the other T11xx categories'),
264: 'T1101' => Mage::helper('paypal')->__('ACH Withdrawal'),
265: 'T1102' => Mage::helper('paypal')->__('Debit Card Transaction'),
266: 'T1103' => Mage::helper('paypal')->__('Reversal of Points Usage'),
267: 'T1104' => Mage::helper('paypal')->__('ACH Deposit (Reversal)'),
268: 'T1105' => Mage::helper('paypal')->__('Reversal of General Account Hold'),
269: 'T1106' => Mage::helper('paypal')->__('Account-to-Account Payment, initiated by PayPal'),
270: 'T1107' => Mage::helper('paypal')->__('Payment Refund initiated by merchant'),
271: 'T1108' => Mage::helper('paypal')->__('Fee Reversal'),
272: 'T1110' => Mage::helper('paypal')->__('Hold for Dispute Investigation'),
273: 'T1111' => Mage::helper('paypal')->__('Reversal of hold for Dispute Investigation'),
274: 'T1200' => Mage::helper('paypal')->__('General: adjustment of a type not belonging to the other T12xx categories'),
275: 'T1201' => Mage::helper('paypal')->__('Chargeback'),
276: 'T1202' => Mage::helper('paypal')->__('Reversal'),
277: 'T1203' => Mage::helper('paypal')->__('Charge-off'),
278: 'T1204' => Mage::helper('paypal')->__('Incentive'),
279: 'T1205' => Mage::helper('paypal')->__('Reimbursement of Chargeback'),
280: 'T1300' => Mage::helper('paypal')->__('General (Authorization)'),
281: 'T1301' => Mage::helper('paypal')->__('Reauthorization'),
282: 'T1302' => Mage::helper('paypal')->__('Void'),
283: 'T1400' => Mage::helper('paypal')->__('General (Dividend)'),
284: 'T1500' => Mage::helper('paypal')->__('General: temporary hold of a type not belonging to the other T15xx categories'),
285: 'T1501' => Mage::helper('paypal')->__('Open Authorization'),
286: 'T1502' => Mage::helper('paypal')->__('ACH Deposit (Hold for Dispute or Other Investigation)'),
287: 'T1503' => Mage::helper('paypal')->__('Available Balance'),
288: 'T1600' => Mage::helper('paypal')->__('Funding'),
289: 'T1700' => Mage::helper('paypal')->__('General: Withdrawal to Non-Bank Entity'),
290: 'T1701' => Mage::helper('paypal')->__('WorldLink Withdrawal'),
291: 'T1800' => Mage::helper('paypal')->__('Buyer Credit Payment'),
292: 'T1900' => Mage::helper('paypal')->__('General Adjustment without businessrelated event'),
293: 'T2000' => Mage::helper('paypal')->__('General (Funds Transfer from PayPal Account to Another)'),
294: 'T2001' => Mage::helper('paypal')->__('Settlement Consolidation'),
295: 'T9900' => Mage::helper('paypal')->__('General: event not yet categorized'),
296: );
297: asort(self::$_eventList);
298: }
299: }
300: }
301: