PageRenderTime 72ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/index.html

https://github.com/dmilith/payments-pl
HTML | 170 lines | 151 code | 19 blank | 0 comment | 0 complexity | f669c7cec771b88ba604335f45e640fb MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta name="Content-Type" content="text/html; charset=utf-8" />
  6. <title>payments-pl 0.4.1
  7. </title>
  8. <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
  9. <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
  10. <script type="text/javascript" charset="utf-8">
  11. relpath = '';
  12. if (relpath != '') relpath += '/';
  13. </script>
  14. <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
  15. <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
  16. </head>
  17. <body>
  18. <script type="text/javascript" charset="utf-8">
  19. if (window.top.frames.main) document.body.className = 'frames';
  20. </script>
  21. <div id="header">
  22. <div id="menu">
  23. <a href="_index.html" title="Index">Index</a> &raquo;
  24. <span class="title">File: README</span>
  25. <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
  26. </div>
  27. <div id="search">
  28. <a id="class_list_link" href="#">Class List</a>
  29. <a id="method_list_link" href="#">Method List</a>
  30. <a id ="file_list_link" href="#">File List</a>
  31. </div>
  32. <div class="clear"></div>
  33. </div>
  34. <iframe id="search_frame"></iframe>
  35. <div id="content"><div id='filecontents'><h1>payments-pl</h1>
  36. <p>
  37. Simple library for handling payments via platnosci.pl
  38. </p>
  39. <h2>Features</h2>
  40. <ul>
  41. <li>Simple configuration (multiple POS-es)
  42. </li>
  43. <li>Transactions: create, get state, confirm, cancel
  44. </li>
  45. <li>View helper for generating payment form
  46. </li>
  47. </ul>
  48. <h2>Installation</h2>
  49. <p>
  50. Install gem:
  51. </p>
  52. <pre class="code">
  53. <span class='sudo identifier id'>sudo</span> <span class='gem identifier id'>gem</span> <span class='install identifier id'>install</span> <span class='payments identifier id'>payments</span><span class='minus op'>-</span><span class='pl identifier id'>pl</span>
  54. </pre>
  55. <p>
  56. And add it n your environment.rb file:
  57. </p>
  58. <pre class="code">
  59. <span class='config identifier id'>config</span><span class='dot token'>.</span><span class='gem identifier id'>gem</span> <span class='string val'>'payments-pl'</span><span class='comma token'>,</span> <span class='symbol val'>:lib</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'payments_pl'</span>
  60. </pre>
  61. <h2>Configuration</h2>
  62. <p>
  63. First add POS informations in config/payments.yml file:
  64. </p>
  65. <pre class="code">
  66. <span class='bank identifier id'>bank</span><span class='colon op'>:</span>
  67. <span class='pos_id identifier id'>pos_id</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
  68. <span class='pos_auth_key identifier id'>pos_auth_key</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
  69. <span class='key1 identifier id'>key1</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
  70. <span class='key2 identifier id'>key2</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
  71. <span class='type identifier id'>type</span><span class='colon op'>:</span> <span class='express_gateway identifier id'>express_gateway</span>
  72. <span class='sms identifier id'>sms</span><span class='colon op'>:</span>
  73. <span class='pos_id identifier id'>pos_id</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
  74. <span class='pos_auth_key identifier id'>pos_auth_key</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
  75. <span class='key1 identifier id'>key1</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
  76. <span class='key2 identifier id'>key2</span><span class='colon op'>:</span> <span class='XXX constant id'>XXX</span>
  77. <span class='type identifier id'>type</span><span class='colon op'>:</span> <span class='sms_premium identifier id'>sms_premium</span>
  78. </pre>
  79. <p>
  80. Next add some routes so platnosci.pl can send messages to your application:
  81. </p>
  82. <pre class="code">
  83. <span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/ok'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'ok'</span>
  84. <span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/error'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'error'</span>
  85. <span class='map identifier id'>map</span><span class='dot token'>.</span><span class='connect identifier id'>connect</span> <span class='string val'>'/payments/report'</span><span class='comma token'>,</span> <span class='symbol val'>:controller</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'payments'</span><span class='comma token'>,</span> <span class='symbol val'>:action</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'report'</span>
  86. </pre>
  87. <p>
  88. These urls must be the same as those you entered on platnosci.pl site.
  89. </p>
  90. <h2>Usage</h2>
  91. <p>
  92. Creating new transaction in controller:
  93. </p>
  94. <pre class="code">
  95. <span class='def def kw'>def</span> <span class='some_action identifier id'>some_action</span>
  96. <span class='@transaction ivar id'>@transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='string val'>'bank'</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='new_transaction identifier id'>new_transaction</span><span class='lparen token'>(</span><span class='symbol val'>:amount</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='integer val'>100</span><span class='comma token'>,</span> <span class='symbol val'>:desc</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'Abonament'</span><span class='comma token'>,</span> <span class='symbol val'>:client_ip</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='request identifier id'>request</span><span class='dot token'>.</span><span class='remote_addr identifier id'>remote_addr</span><span class='comma token'>,</span> <span class='symbol val'>:js</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'0'</span><span class='rparen token'>)</span>
  97. <span class='end end kw'>end</span>
  98. </pre>
  99. <p>
  100. Rendering payment form:
  101. </p>
  102. <pre class="code">
  103. <span class='minus op'>-</span> <span class='form_tag identifier id'>form_tag</span> <span class='@transaction ivar id'>@transaction</span><span class='dot token'>.</span><span class='new_url identifier id'>new_url</span> <span class='do do kw'>do</span>
  104. <span class='assign token'>=</span> <span class='transaction_hidden_fields identifier id'>transaction_hidden_fields</span> <span class='@transaction ivar id'>@transaction</span>
  105. <span class='assign token'>=</span> <span class='submit_tag identifier id'>submit_tag</span> <span class='string val'>'Pay'</span>
  106. </pre>
  107. <p>
  108. Controller for receiving messages from platnosci.pl:
  109. </p>
  110. <pre class="code">
  111. <span class='class class kw'>class</span> <span class='PaymentsController constant id'>PaymentsController</span> <span class='lt op'>&lt;</span> <span class='ApplicationController constant id'>ApplicationController</span>
  112. <span class='skip_before_filter identifier id'>skip_before_filter</span> <span class='symbol val'>:verify_authenticity_token</span>
  113. <span class='def def kw'>def</span> <span class='error identifier id'>error</span>
  114. <span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='Payments constant id'>Payments</span><span class='dot token'>.</span><span class='error_text identifier id'>error_text</span><span class='lparen token'>(</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span><span class='rparen token'>)</span>
  115. <span class='end end kw'>end</span>
  116. <span class='def def kw'>def</span> <span class='ok identifier id'>ok</span>
  117. <span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'Payment OK'</span>
  118. <span class='end end kw'>end</span>
  119. <span class='def def kw'>def</span> <span class='report identifier id'>report</span>
  120. <span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='get identifier id'>get</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
  121. <span class='if if kw'>if</span> <span class='status identifier id'>status</span> <span class='eq op'>==</span> <span class='string val'>'OK'</span>
  122. <span class='if if kw'>if</span> <span class='transaction identifier id'>transaction</span><span class='dot token'>.</span><span class='trans_status identifier id'>trans_status</span> <span class='eq op'>==</span> <span class='string val'>'99'</span>
  123. <span class='comment val'># paid, money received</span>
  124. <span class='else else kw'>else</span>
  125. <span class='comment val'># other stuff</span>
  126. <span class='end end kw'>end</span>
  127. <span class='end end kw'>end</span>
  128. <span class='render identifier id'>render</span> <span class='symbol val'>:text</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='string val'>'OK'</span>
  129. <span class='end end kw'>end</span>
  130. <span class='end end kw'>end</span>
  131. </pre>
  132. <p>
  133. Cancelling and confirming transaction is similar to getting transaction
  134. state:
  135. </p>
  136. <pre class="code">
  137. <span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='cancel identifier id'>cancel</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
  138. <span class='status identifier id'>status</span><span class='comma token'>,</span> <span class='transaction identifier id'>transaction</span> <span class='assign token'>=</span> <span class='Payments constant id'>Payments</span><span class='lbrack token'>[</span><span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:pos_id</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='confirm identifier id'>confirm</span> <span class='params identifier id'>params</span><span class='lbrack token'>[</span><span class='symbol val'>:session_id</span><span class='rbrack token'>]</span>
  139. </pre>
  140. <h2>Copyright</h2>
  141. <p>
  142. Copyright &#169; 2010 Michał Młoźniak. See LICENSE for details.
  143. </p>
  144. </div></div>
  145. <div id="footer">
  146. Generated on Wed Aug 18 22:12:44 2010 by
  147. <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
  148. 0.5.8 (ruby-1.8.7).
  149. </div>
  150. </body>
  151. </html>