Changeset 25735
- Timestamp:
- 12/21/09 17:35:47 (3 years ago)
- Files:
-
- plugins/sfPaymentPlugin/branches/1.2-marijn/lib/sfSellable.php (modified) (1 diff)
- plugins/sfPaymentPlugin/branches/1.2-marijn/lib/transaction (added)
- plugins/sfPaymentPlugin/branches/1.2-marijn/lib/transaction/sfTransaction.php (moved) (moved from plugins/sfPaymentPlugin/branches/1.2-marijn/lib/sfTransaction.php) (3 diffs)
- plugins/sfPaymentPlugin/branches/1.2-marijn/lib/transaction/sfTransactionInterface.php (moved) (moved from plugins/sfPaymentPlugin/branches/1.2-marijn/lib/sfTransactionInterface.php) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPaymentPlugin/branches/1.2-marijn/lib/sfSellable.php
r25580 r25735 26 26 function getAmount (); 27 27 28 /** 29 * Get the description for the transaction. 30 * 31 * @return string The description for the transaction. 32 */ 33 function getDescription (); 34 28 35 } plugins/sfPaymentPlugin/branches/1.2-marijn/lib/transaction/sfTransaction.php
r25619 r25735 2 2 3 3 /** 4 * General transaction implementation.4 * Base class for sfTransactionInterface implementations. 5 5 * 6 6 * @package sfPaymentPlugin … … 202 202 if ($this->_amount !== (int) $arg_amount) 203 203 { 204 throw new sfTransactionException(sprintf('Amount returned by gateway %d doesn\'t match requested amount %d.', $arg_amount, $this->_amount));204 throw new sfTransactionException(sprintf('Amount returned by gateway "%d" doesn\'t match requested amount "%d".', $arg_amount, $this->_amount)); 205 205 } 206 206 } … … 217 217 if ($this->_currency !== $arg_currency) 218 218 { 219 throw new sfTransactionException(sprintf('Currency returned by gateway %s doesn\'t match requested currency %s.', $arg_currency, $this->_currency)); 220 } 219 throw new sfTransactionException(sprintf('Currency returned by gateway "%s" doesn\'t match requested currency "%s".', $arg_currency, $this->_currency)); 220 } 221 } 222 223 /** 224 * Cast the object to an XML notation. 225 * 226 * @return DomDocument 227 */ 228 public function toXmlElement () 229 { 230 return sprintf("<transaction%s>\n <!-- test -->\n</transaction>" 231 ,$this->_getTransactionNodeAttributes() ?: ''); 232 } 233 234 /** 235 * Create an object from an XML node. 236 * 237 * @param string $arg_xmlElement The XML representation. 238 * 239 * @return void 240 */ 241 public function fromXmlElement (SimpleXMLElement $arg_xmlElement) 242 { 243 $attributes = $arg_xmlElement->attributes; 244 245 foreach ($attributes as $key => $value) 246 { 247 if (NULL !== $value) 248 { 249 $method = 'set' . ucfirst($key); 250 251 $this->$method($value); 252 } 253 } 254 } 255 256 /** 257 * Get the XML attributes for the transaction node. 258 * 259 * @return string 260 */ 261 private function _getTransactionNodeAttributes () 262 { 263 $fields = array('transactionId', 'status'); 264 $attributes = array(); 265 266 foreach ($fields as $fieldName) 267 { 268 $method = 'get' . ucfirst($fieldName); 269 $value = $this->$method(); 270 271 if (NULL !== $value) 272 { 273 $attributes[] = $fieldName . '="' . $value . '"'; 274 } 275 } 276 277 return implode(' ', $attributes); 221 278 } 222 279 plugins/sfPaymentPlugin/branches/1.2-marijn/lib/transaction/sfTransactionInterface.php
r25619 r25735 9 9 * @version $Revision$ changed by $Author$ 10 10 */ 11 interface sfTransactionInterface 11 interface sfTransactionInterface extends sfSellable 12 12 { 13 13 … … 63 63 64 64 /** 65 * Get the amount for the transaction.66 *67 * @return integer The amount for the transaction in cents.68 */69 function getAmount ();70 71 /**72 65 * Set the amount for the transaction. 73 66 * … … 95 88 96 89 /** 97 * Get the currency for the transaction.98 *99 * @return string The currency for the transaction.100 */101 function getCurrency ();102 103 /**104 90 * Set the currency for the transaction. 105 91 * … … 109 95 */ 110 96 function setCurrency ($arg_currency); 111 112 /**113 * Get the description for the transaction.114 *115 * @return string The description for the transaction.116 */117 function getDescription ();118 97 119 98 /** … … 144 123 function checkCurrency ($arg_currency); 145 124 125 /** 126 * Cast the object to an XML notation. 127 * 128 * @return DomDocument 129 */ 130 function toXml (); 131 132 /** 133 * Create an object from an XML data source. 134 * 135 * @param string $arg_xml The XML representation. 136 * 137 * @return void 138 */ 139 function fromXml ($arg_xml); 140 146 141 }