SwissPayment
SwissPayment is a PHP library to generate Swiss pain.001 XML messages (complies with ISO-20022).
Installation
Just install Composer and run composer require z38/swiss-payment
in your project directory.
Usage
To get a basic understanding on how the messages are structured, take a look the resources mentioned below. The following example shows how to create a message containing two transactions:
<?php require_once __DIR__.'/vendor/autoload.php'; use Z38SwissPaymentBIC; use Z38SwissPaymentIBAN; use Z38SwissPaymentMessageCustomerCreditTransfer; use Z38SwissPaymentMoney; use Z38SwissPaymentPaymentInformationPaymentInformation; use Z38SwissPaymentPostalAccount; use Z38SwissPaymentStructuredPostalAddress; use Z38SwissPaymentTransactionInformationBankCreditTransfer; use Z38SwissPaymentTransactionInformationIS1CreditTransfer; use Z38SwissPaymentUnstructuredPostalAddress; $transaction1 = new BankCreditTransfer( 'instr-001', 'e2e-001', new MoneyCHF(130000), // CHF 1300.00 'Muster Transport AG', new StructuredPostalAddress('Wiesenweg', '14b', '8058', 'Zürich-Flughafen'), new IBAN('CH51 0022 5225 9529 1301 C'), new BIC('UBSWCHZH80A') ); $transaction2 = new IS1CreditTransfer( 'instr-002', 'e2e-002', new MoneyCHF(30000), // CHF 300.00 'Finanzverwaltung Stadt Musterhausen', UnstructuredPostalAddress::sanitize('Altstadt 1a', '4998 Musterhausen'), new PostalAccount('80-151-4') ); $payment = new PaymentInformation( 'payment-001', 'InnoMuster AG', new BIC('ZKBKCHZZ80A'), new IBAN('CH6600700110000204481') ); $payment->addTransaction($transaction1); $payment->addTransaction($transaction2); $message = new CustomerCreditTransfer('message-001', 'InnoMuster AG'); $message->addPayment($payment); echo $message->asXml();
Tip: Take a look at Z38SwissPaymentTestsMessageCustomerCreditTransferTest
to see all payment types in action.
Caveats
Not all business rules and recommendations are enforced, consult the documentation and validate the resulting transaction file in cooperation with your bank. At the moment cheque transfers are not supported (for details consult chapter 2.2 of the Implementation Guidelines) The whole project is still under development and therefore BC breaks can occur. Please contact me if you need a stable code base.Contributing
If you want to get your hands dirty, great! Here's a couple of steps/guidelines:
Fork this repository Add your changes & tests for those changes (intests/
).
Remember to stick to the existing code style as best as possible. When in doubt, follow PSR-2
.
Send me a pull request!
If you don't want to go through all this, but still found something wrong or missing, please let me know, and/or open a new issue report so that I or others may take care of it.
Further Resources
www.iso-payments.ch General website about the Swiss recommendations regarding ISO 20022 Swiss Business Rules for Customer-Bank Messages Swiss Implementation Guidelines for pain.001 and pain.002 Messages SIX Validation Portal PostFinance Validation Portal
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。