2014-01-07 23 views
0

我需要SEPA直接借記的功能添加到一個Rails應用程序sepa_king寶石,但是我:實現在軌應用

  1. 不熟與生成的XML文檔
  2. 我還是非常的學習,當涉及到Ruby on Rails

我發現this gem但對我來說文檔還不清楚。創建直接付款對象的所有代碼是否都在配置文件或其他位置?創建後如何調用dd對象?

我試過使用谷歌查找有關這個寶石和整合SEPA到一般的軌道應用程序的更多信息,但我沒有成功。如果有人熟悉這個話題並能幫助我,或者指點我其他資源的方向,我會非常感激!

回答

1

免責聲明:尚未完全工作...

我已經做了這樣的:(見下文)

所以我把它變成一個模型,把它稱爲從控制器,並將其發送到一份文件。 轉換可以簡單地通過to_xml

class MyController < ApplicationController 

    def download_sepa 
    content = Pupil.sepa_for_all 
    send_data content, :filename => "sepa.xml" 
    end 
end 

class Pupil < ActiveRecord::Base 
    def sepa_for_all(params={}) 
     sdd = SEPA::DirectDebit.new(
     # Name of the initiating party and creditor, in German: "Auftraggeber" 
     # String, max. 70 char 
     name:  'MEIN NAME', 

     # Business Identifier Code (SWIFT-Code) of the creditor 
     # String, 8 or 11 char 
     bic:  'BICDE33XXX', 

     # International Bank Account Number of the creditor 
     # String, max. 34 chars 
     iban:  'DE14711081500234324766', 

     # Creditor Identifier, in German: Gläubiger-Identifikationsnummer 
     # String, max. 35 chars 
     creditor_identifier: 'DE471108ZZ99999' 
     ) 
     # Second: Add transactions 
     sdd.add_transaction(
     # Name of the debtor, in German: "Zahlungspflichtiger" 
     # String, max. 70 char 
     name:      contract.account.account_holder.asciify, 
     # Put all details of the transaction in the [...] part: 
    [...] 
     ) 

     sdd.to_xml 
    end 
end 

完成XML將成功生成可惜我不能設法接受我的銀行軟件的XML文件。儘管如此,我希望這會讓你走上正確的道路。 T.

+0

這絕對是一個很好的開始!非常感謝!! – SoSimple

+0

請注意,sdd.to_xml必須是_inside_'sepa_for_all'方法。我的縮進是錯誤的。 – fenton