abcaeffchen / sephpa Goto Github PK
View Code? Open in Web Editor NEWPHP class to create SEPA xml files for credit transfer and direct debit
License: GNU Lesser General Public License v3.0
PHP class to create SEPA xml files for credit transfer and direct debit
License: GNU Lesser General Public License v3.0
Is it possible to add the postal address to the Dbtr-Tag? Right now it seems like you can only add the "Nm"-Tag but not the address-fields (PstlAdr, Ctry, AdrLine, etc.)
<Dbtr> <Nm>John Doe</Nm> <PstlAdr> <Ctry>CH</Ctry> <AdrLine>Testway 123</AdrLine> <AdrLine>1234 Testingen, Thurgau</AdrLine> </PstlAdr> </Dbtr>
It seems that direct debits fail if you use a foreign IBAN but don't provide any address-informations (at least Postbank denied all foreign transfers with that explaination)
Hello,
since the last Update 5 days ago the function of addPayment in the code of the direct debits is lost.
It seems to be that the clean up of the code have been a bit to much.
Thanks to fix it.
Kind regards
Timo
First of all many thanks for publishing this great tool. There are loads of SEPA-Export tools here on GitHub but this one is clearly on of the best in my opinion.
I just found a minor bug yesterday which I would like to report.
In the file SepaDirectDebit.php on line 212 the condition
if(isset($payment['rmtinf'])) must be if(isset($payment['rmtInf'])) with a capital I.
The evaluation of the key name is case sensitive, so the remittance information is never added if the key is given in correct camel case as in your example
Best regards
Paul Morphy
Looking at SepaCreditTransfer00100103::addPayment, a check is done to determine if a BIC code is required.
This is done by checking SepaUtilities::isEEATransaction and then flipping the result. So if the 2 IBANs are both EEA accounts, SepaUtilities::isEEATransaction will return true, which will be flipped so $bicRequired becomes false.
Next, we see this call:
SepaUtilities::checkAndSanitizeAll(
$paymentInfo,
$this->sanitizeFlags,
['allowEmptyBic' => $bicRequired]
);
This would imply that if $bicRequired is false, allowEmptyBic will also be false, so even though no BIC code is required, no empty BIC code is allowed.
At the moment the only way to work around this would be to remove the 'bic' element from the payment array.
From the list of Direct Debit supported versions, SEPA_PAIN_008_001_02 raises an error.
Version 008_002 and 003 are working fine.
I wonder whats wrongs
Edit: There are discrepancies between the github and the version of composer. Composer has other code and not all PAIN Methodes are available. Big issue if we want to depend on this solution
Edit: After cleaning the entire solution and get the recent non-production version from composer fixed the issue.
In my composer.json I have got the following lines:
"abcaeffchen/sephpa": "~1.3", "abcaeffchen/sepa-utilities": "~1.2",
I want to use the newest stable releases. But I get the following error:
abcaeffchen/sephpa 1.3.0 requires abcaeffchen/sepa-utilities ~1.1.0
When will a new release of sephpa, which supports sepa-utilities 1.2 ?
I don't want to use dev-master in my project.
Hi,
I am trying to generate a First time transaction file but even though I am using the SEQUENCE_TYPE_FIRST constant to define the Sequence Type, the code keeps on generating RCUR type entries.
Should I do something more on collection creation ?
Hi,
I saw the multiple collections support is unfortunately removed from the new 2.x beta version. Our bank still supports this version, and I really need this functionality, so first of all, I would like to know, if there is an option, the old functionality to be added to new 2.x branch?
If not, I would like to know, if there is any way in the new version, to somehow still create multiple batch XML files, as in previous version, and if so, how would I do this? Could this be done with the new Multi File class and how?
Best,
According to the latest (German) official documentation, the most recent PAIN versions are indeed pain.001.001.03 for Credit Transfer and pain.008.001.02 for Direct Debit. These are valid since November 20th, 2016. They feature even more simplifications than the former PAIN versions. The versions pain.001.003.03 and pain.008.003.02 remain valid, but are outdated.
I want to set up a new project using PHP with the latest SEPA support. At the moment being, my old project is made up as a VBA project in MS Access, and I am using the latest PAIN versions there. I wonder if there are plans to add the new versions to this library. I could perhaps try and make them up on my own, but I'm new to GitHub and do not know how to contribute without disturbing the original workflow.
Make the generateXml() function public allow a direct access to php to the generated xml wihtout using the store or download function
The output of a SephpaCreditTransfer is invalid when working with a locale that uses commas as decimal_point for floats. $amount = filter_var($amount, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND)
in SepaUtilities replaces my dots with comma's, causing instdAmt to be invalid.
Is there a way around this, besides something like setlocale(LC_NUMERIC, 'en_US.UTF-8')
?
Hi,
it would be nice to have the ability to create a sepa-xml with the iban-only procedure. Is it possible now?
Thanks.
The generated xml is not formated.
The commit 1029ca0 Allow to get a formatted XML output.
The array key 'PrettyXML' have been added to the download and store functions parameter.
The generateXml function have a $prettyXML parameter how default to false for api stability
According to #21, direct access to the xml content is not useful due to missing validation etc.
I don't really understand the argument behind that. E.g. in my case, I just want to download/stream one generated xml file and upload it directly to my online banking. The file isn't too big and does not have to be compressed.
In the only current way possible, I would have to store the generated zip archive, download it, delete it from the server and unarchive it at my machine..
However, I could solve my issue by just extending the file like so (which I'm not the greatest fan of):
class MyDirectDebitFile extends SephpaDirectDebit
{
public function convertToXmlString(): string
{
return $this->generateXml();
}
}
But still, it would be nice to just have access to SephpaDirectDebit::generateXml()
from outside the object..
Anyway, thank you so much for this library! I was struggling to generate valid PAIN00800102
for some time now and Sparkasse never accepted my xml files without any details or useful error messages.
After trying this lib it worked like a charm in no time at all 🤓
The Sepa format pain.001.001.03 is abandoned this year.
In future pain.001.001.09 needs to be used for Sepa-transfers.
Here is a link with background information about the issue: https://banking.vision/umstellung-auf-pain-001-pain-008-camt-formate/
Any plans, when you plan to implement the new format @AbcAeffchen ?
I'm missing for example SEPA_PAIN_001_001_03 in de composer version (1.3.0).
I'm trying to add support for SEPA on FacturaScripts, but with no doc from sephpa is not easy to understand what is every value and option and why I needed.
Fatal error: Uncaught exception 'AbcAeffchen\Sephpa\SephpaInputException' with message 'The values of iban, ci are invalid.
In this case, I know that IBAN is really invalid, I'm using some default values, but I don't know what is CI (Creditor-Identifier), I never use it before SEPA on Spain.
Also, I'm supossing that I need to use SephpaDirectDebit::SEPA_PAIN_008_003_02, but I really don't know what difference exists between the 4 types. I'm assuming that I need to use SEPA Core Direct Debit.
Can you add some little explanation please?
complete working on local but, i upload on the server then generating error 2 line.
The French public administrations having a bank account in the Trésor Public must advise the UltimateDebtor Name and Identification.
In CreditPayement 001_001_03, the UltmtDbtr markup inside the CdtTrfTxInf (creditTransfertInformation) markup shoul be like
<CdtTrfTxInf>
...
<UltmtDbtr>
<Nm>$payment['ultmtDbtr']</Nm>
<Id>
<OrgId>
<Othr>
<Id>$payment['ultmtDbtrId']</Id>
</Othr>
</OrgId>
</Id>
</UltmtDbtr>
</CdtTrfTxInf>
The ultmtDbtrId array key is added in the in the addPayment function
$creditTransferFile->addPayment([
...
'ultmtDbtr' => 'Debitor Name',
'ultmtDbtrId'=> 'Debitor real iban'
]);
ultmtDbtrId array key need an sephpa and sepautilities update. check :
https://github.com/jmbIFR/Sephpa/commit/6cfe50d042e085e88ae29aa0f30aa5cf62935e38
https://github.com/jmbIFR/SepaUtilities/commit/c8fee55f2aa1c795c1338c0573c8fdab0dd372d5
I just tried to upload a Direct debit 008.001.02 file to my bank. It is the format required by my bank.
But i had to add some data at the header of the xml file to be acepted by my bank. (Cajamar Spain)
The data i added is the Id Tag inside InitgPty.
Is there a solution for this?
<GrpHdr>
<MsgId>MessageID-1235</MsgId>
<CreDtTm>2018-09-12T17:15:26</CreDtTm>
<NbOfTxs>1</NbOfTxs>
<CtrlSum>2.34</CtrlSum>
<InitgPty>
<Nm>MY COMPANY NAME</Nm>
<Id>
<PrvtId>
<Othr>
<Id>ES43000MYCOMPANYID</Id>
<SchmeNm>
<Prtry>SEPA</Prtry>
</SchmeNm>
</Othr>
</PrvtId>
</Id>
</InitgPty>
</GrpHdr>
I there anything known about this lib in case of huge PAIN files? let's say with 100k transactions in it?
Hello,
I've noticed that by merely turning checkAndSanitize value to false, the whole XML structure becomes modified, and does not validate anymore.
For instance, when checkAndSanitize is true (default), there is a s <BtchBookg>false</BtchBookg>
tag, and <AmdmntInd>false</AmdmntInd>
and when checkAndSanitize is false, there is no BtchBookg tag at all, and Amdmntlnd ist empty -- <Amdmntlnd/>
.
Please advise.
Hello.
I have all the depencies but this error generates me.
I checked all the routes and all is correct.
Does anyone know where the error may come from?
$directDebitFile = new SephpaDirectDebit($initator_name , $message_id , SephpaDirectDebit::SEPA_PAIN_008_001_02 , $collectionData);
Based on my analysis, I was not able to merge the two sepa types FRST and RCUR in one file.
The $directDebitFile is expecting 4 parameters, and is dependent on $collectionData (array).
The $collectionData expects seqTp.
When you have two different seqTp, and defined two directDebitFile classes, only one seqTp is being saved in the xml batch.
The workaround is saving FRST and RCUR in two seperate files (works). Which is not user friendly and sensitive to errors.
I'm using the version 2.0, as this version supports DD 80102
Thanks a bunch for making this solution possible!
Hello Can you please tag a new release? I really want to use the 008.001.002 pain version but the newest release of this moment (1.3.0) does not provide this pain. I saw you added it to master, but haven't tagged a release since?
The core-point of this project is the creation of a sepa-file.
Would it be possible and meaningfull to integrate a file-READER?
Hi,
ich habe eure Funktionalitäten bisher gerne genutzt... Nun habe ich in meinem Laravel - Projekt mal wieder einen "Zahllauf" starten wollen und nun fiel mir auf dass es scheinbar nicht mehr "addPayment()" gibt?! Die hatte ich in der DirectDebit Datei aber eigentlich immer angesprochen und nichts geändert... Was ist zutun? Bzw. was wurde hier verändert?
Über kurzes Feedback wäre ich dankbar.
$directDebitFile = new SephpaDirectDebit(.............)
...
$directDebitFile->addPayment([....])
daraus resultiert dann nachfolgender "Fehler"...
"Error
Call to undefined method AbcAeffchen\Sephpa\SephpaDirectDebit::addPayment()"
Grüße
Malte
Ich habe per Composer alles installiert und vor dem Erstellen eines SephpaCreditTransfer's die autoload.php von Composer aus dem vendor Ordner required, jedoch funktioniert es immer noch nicht. Selbst eine manuelle Installation führt nicht zum gewünschten Erfolg.
Ich habe alle Pfade überprüft und die autoload.php wird geladen.
require_once get_home_path() . 'sepa-payment-xml-generator/vendor/autoload.php';
require 'admin/functions/generate-sepa-xml-file.php';
In der generate-sepa-xml-file.php
erstelle ich meine SEPA-Überweisung und füge die einzelnen Zahlungsempfänger hinzu:
//DB
global $wpdb;
//Get all results from the wp_accepted_jobs table which are not payed out
$jobs = $wpdb->get_results( 'SELECT * FROM wp_accepted_jobs WHERE paid_out = 0' );
//Loop over accepted jobs and add payments to the transfer file
if ( ! empty( $jobs ) ) {
//Create new sepa transfer file
$creditTransferFile = new SephpaCreditTransfer( get_option( 'wc_job_tab_email_shop_name' ), md5( uniqid( mt_rand(), true ) ), SephpaCreditTransfer::SEPA_PAIN_001_002_03 );
//Add required information's about the debtor
$creditTransferCollection = $creditTransferFile->addCollection( [
'pmtInfId' => md5( uniqid( mt_rand(), true ) ), // ID of the payment collection
'dbtr' => get_option( 'wc_job_tab_email_shop_name' ), // (max 70 characters)
'iban' => get_option( 'wc_job_tab_payment_company_iban' ), // IBAN of the Debtor
'bic' => get_option( 'wc_job_tab_payment_company_bic' ), // BIC of the Debtor
// optional
'ccy' => 'EUR', // Currency. Default is 'EUR'
'btchBookg' => 'true', // BatchBooking, only 'true' or 'false'
//'ctgyPurp' => , // Category Purpose. Do not use this if you do not know how. For further information read the SEPA documentation
'reqdExctnDt' => date( 'Y-m-d', strtotime( 'tomorrow' ) ), // Requested Execution Date: YYYY-MM-DD
'ultmtDebtr' => get_option( 'wc_job_tab_email_shop_name' ) // Just an information, this do not affect the payment (max 70 characters)
] );
//Add payments
foreach ( $jobs as $job ) {
//Get userdata from developer
$developer_info = get_userdata( $job->developer_id );
//Add required information about the creditor
$creditTransferCollection->addPayment( [
'pmtId' => md5( uniqid( mt_rand(), true ) ), // ID of the payment (EndToEndId)
'instdAmt' => $job->job_pay, // Amount
'iban' => get_user_meta( $job->developer_id, 'user_iban', true ), // IBAN of the Creditor
'bic' => get_user_meta( $job->developer_id, 'user_bic', true ), // BIC of the Creditor (only required for pain.001.002.03)
'cdtr' => $developer_info->first_name . ' ' . $developer_info->last_name, // (max 70 characters)
// optional
'ultmtCdrt' => $developer_info->first_name . ' ' . $developer_info->last_name, // Just an information, this do not affect the payment (max 70 characters)
//'purp' => , // Do not use this if you do not know how. For further information read the SEPA documentation
'rmtInf' => 'Deine Entlohnung für den Auftrag: ' . $job->job_id // unstructured information about the remittance (max 140 characters)
] );
}
//Download XML file
$creditTransferFile->download();
} else {
wp_send_json_error( null, 500 );
wp_die();
}
Es ist nicht die erste Library, welche ich an dieser Stelle einbinde und bei allen anderen hat es einwandfrei funktioniert. Mittlerweile gehen mir die Ideen aus.
Was kann ich tun?
Add the setFileName function to allow set the file name prefix
Travis support HHVM only on Ubuntu Trusty 14.04
https://docs.travis-ci.com/user/languages/php/#hhvm-versions-are-available-on-trusty-only
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.