tathevik/fatca
Composer 安装命令:
composer require tathevik/fatca
包简介
PHP library for generation of FATCA IDES submission files
README 文档
README
This is a PHP library that converts bank client data to FATCA files submittable via the IDES gateway. If you find in this library any code that is specific to the Financial Institution for which I did this work, do not hesitate to point them out to me by opening an issue.
For more information check the IRS FATCA IDES Technical FAQs
For other language implementations, please check the IRS github page
Pre-requisites
- php
- client data in php array form
- SSL certificate for your financial institution
- Private and public keys used to get the SSL certificate
Installation instructions
Install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
Install php extensions
sudo apt-get install php7.0-xml php-mbstring php-zip php-mcrypt php-pear libyaml-dev php-dev php-bcmath sudo pecl install yaml-2.0.0 sudo echo "extension=yaml.so" > /etc/php/7.0/mods-available/yaml.ini sudo ln -s /etc/php/7.0/mods-available/yaml.ini /etc/php/7.0/cli/conf.d/20-yaml.ini composer require shadiakiki1986/fatca-ides-php composer require swiftmailer/swiftmailer # To enable sending emails composer install [sudo] apt-get install php5-mcrypt [sudo] php5enmod mcrypt [sudo] service apache2 restart # needed for web applications served with apache
If emails are enabled, pass your config (similar to this ) to the toEmail function of Transmitter class (check example below)
Next, download the financial institution's ssl certificate, private key, and public key. Note that the public key can be extracted from the certificate (on the TODO to be implied without the need for the user to specify it)
Examples
For a complete example of how to use this library, please check IDES-Data-Preparation-Php.
Example 1: generate ZIP file for submission on the IDES gateway
require __DIR__.'/vendor/autoload.php'; use FatcaIdesPhp\Transmitter; // set tax year $taxYear=2014; // example client data $di=array( array("Compte"=>"1234","ENT_FIRSTNAME"=>"Clyde","ENT_LASTNAME"=>"Barrow","ENT_FATCA_ID"=>"123-1234-123","ENT_ADDRESS"=>"Some street somewhere","ResidenceCountry"=>"US","posCur"=>100000000,"cur"=>"USD","ENT_TYPE"=>"Individual"), array("Compte"=>"5678","ENT_FIRSTNAME"=>"Bonnie","ENT_LASTNAME"=>"Parker","ENT_FATCA_ID"=>"456-1234-123","ENT_ADDRESS"=>"Dallas, Texas","ResidenceCountry"=>"US","posCur"=>100,"cur"=>"LBP","ENT_TYPE"=>"Individual") ); // config with paths to files downloaded $config = array( # SSL certificate bought using the private key "FatcaCrt" => "/var/lib/IDES/keys/ssl_certificate.crt", # Private key used to get the SSL certificate "FatcaKeyPrivate" => "/var/lib/IDES/keys/institution-fatca-private.pem", # public key extracted out of private key above "FatcaKeyPublic" => "/var/lib/IDES/keys/institution-fatca-public.pem", # Fatca Sender GIIN "ffaid" => 'A1BBCD.00000.XY.123', # Fatca Receiver GIIN, e.g. IRS "ffaidReceiver" => '000000.00000.TA.840', # email configuration if Transmitter::toEmail is used "swiftmailer" => array( "host" => "my.host.com", "port" => 12345, "username" => "myusername", "password" => "mypassword", "name" => "My Name", "reply" => "myemail@host.com") ); $factory = new \FatcaIdesPhp\Factory(); $fda = new \FatcaIdesPhp\FatcaDataArray($di); $fdo = $factory->array2oecd($fda); // , false, null, $taxYear, "zip", "", $config $tmtr=$factory->transmitter($fdo); $tmtr->getZip();
Example 2: To submit a correction XML file
Use the same code as above, but use
$sxe = simplexml_load_file("path/to/xml"); $fdx = new \FatcaIdesPhp\FatcaDataXml($sxe); $tmtr=$factory->transmitter($fdx);
Also, check the correction.php command-line utility from the IDES-Data-Preparation-PHP project
License
Please check [[LICENSE]]
Testing
composer install
composer run-script test
Schema versions
Current state
The schema files and IRS public key are committed to this repo in assets.
The committed versions are the 2.0 versions.
This package was tested succesfully against the IDES test gateway on Jan 31, 2017. The test included
- submitting test data to the server via SFTP using the IDES-Data-Preparation-Php package
- receiving an ACK for the submission via email
- receiving a response from the IRS using the IDES-Data-Preparation-Php package
Updating
To update them, run the following two scripts:
./assets/update.sh: Downloads files from IRS website
- Note that the URL's in the script may need to be updated because newer versions are usually uploaded to new endpoints
- Note also that there are some file renaming lines in the script so that I can diff versions
- e.g.
git diff ba722d8bcda61f657529a67cdbec873a29dc7d70 5f9545b565ddf0d41997b29c704c3990813f4bb8will diff version 1.1 and 2.0
- e.g.
php updateXsd.php: converts the schema files to PHP classes insrc/FatcaXsdPhp
- I moderate the updates and commit them to the repo if suitable
- Open issues on these are:
- I currently fix the below issues manually after the update
- There seems to be a problem in
src/FatcaXsdPhp/oecd/ties/stffatcatypes/v1/Address_Type.phpby having two AddressFree fields @xmlNamespace urn:oecd:ties:fatca:v1is missing fromsrc/FatcaXsdPhp/FATCA_OECDpending moyarada/XSD-to-PHP#36- The AddressFree field has the wrong namespace: should be urn:oecd:ties:stffatcatypes:v1 instead of
urn:oecd:ties:fatca:v1 - ReportingGroup.php is not generated + its
@varis missing src/FatcaXsdPhp/oecd/ties/stffatcatypes/v1/NamePerson_Type.php- @xmlNamespace urn:oecd:ties:fatca:v1
- changed manually to
- @xmlNamespace urn:oecd:ties:stffatcatypes:v1
Manual validation
The validation of an existing xml file can be done manually against the schema on ubuntu using
sudo apt-get install libxml2-utils xmllint --noout --schema assets/fatcaxml/FatcaXML.xsd path/to/file.xml
tathevik/fatca 适用场景与选型建议
tathevik/fatca 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「encryption」 「decryption」 「FATCA」 「IDES」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tathevik/fatca 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tathevik/fatca 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tathevik/fatca 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple PHP class to encrypt a string and decrypt an encrypted string
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Encryption with AES-256 and HMAC-SHA256
Allows installation of Laravel where the PHP Mcrypt extension is not available. Provides encryption using OpenSSL, or by disabling encryption entierly.
High-level cryptographic primitives and security utilities for Maatify systems including password hashing, reversible encryption, HKDF key derivation, and key rotation.
A library for reading KeePass 2.x databases
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: CC0-1.0
- 更新时间: 2018-02-15