Package proposal: Payment_Exchange

From: Date: Wed, 27 Aug 2003 03:22:52 +0000
Subject: Package proposal: Payment_Exchange
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20602@lists.php.net to get a copy of this message
Payment_Exchange deals with currency exchange rates. With it, you can currently convert back and forth between 28 different currencies, in any combination. It is *NOT* designed to be used in a shopping cart or for billing purposes (so maybe Payment is the wrong category?), but it could be used to provide a close estimate. The package updates all of its information automatically. I tried to pick reliable, stable, and never-for-profit organizations: 1) The exchange rates are published daily by the European Central Bank as XML. It associates a 3-character code (ISO 4217) with exchange rates relative to the Euro. 2) A list of currencies and their ISO 4217 codes is downloaded from the United Nations as XML. This is associated with the codes from the exchange rate feed to let users pick currencies by name instead of a code. 3) Not currently used, but there for the future: A list of countries and their 2-character codes (ISO 3166-1) is downloaded from the United Nations as XML. It may be possible to associate countries with currencies (the first two characters of ISO 4217 are supposed to be the ISO 3166-1 codes) to let users select by country instead of by currency. If the European Central Bank begins sending rates for other countries, this package will automatically allow them to be converted. This package caches the exchange rate feed hourly, and the other two monthly (they rarely change) with Cache_HTTP_Request. It uses XML_Unserialize to parse the XML feeds (a patch to support attributes is required). The patch for XML_Unserialize that I've provided below works for what I need, but hasn't been tested in other situations, and breaks BC. When we find a better way to support attributes, I'll update this package accordingly. Package: http://www.exclupen.com/misc/php/pear_patches/Payment_Exchange/Payment_Exchange-0.1.tgz Class: http://www.exclupen.com/misc/php/pear_patches/Payment_Exchange/Exchange.phps Example (for source, change extension to .phps): http://www.exclupen.com/misc/php/pear_patches/Payment_Exchange/example.php XML_Unserialize source (needed to test script): http://www.exclupen.com/misc/php/pear_patches/XML_Serializer/Unserializer.phps Tentative XML_Unserialize patch: http://www.exclupen.com/misc/php/pear_patches/XML_Serializer/Unserializer-attributes.diff -- Marshall Roch

« previous php.pear.dev (#20602) next »