README.markdown in datatrans-2.4.0 vs README.markdown in datatrans-3.0.0
- old
+ new
@@ -4,42 +4,43 @@
Ruby adapter for the Datatrans payment gateway (http://www.datatrans.ch).
Configuration
-------------
-Set your datatrans credentials in your environment.
+Buidl your Datatrans Configuration like so:
- Datatrans.configure do |config|
- config.merchant_id = '1234567'
- config.sign_key = 'ab739fd5b7c2a1...'
- config.environment = :production
- config.proxy = {
- :host => "proxy.com",
- :port => 80,
- :user => "hans",
- :password => "xxx",
+ datatrans = Datatrans::Config.new(
+ :merchant_id => '1234567',
+ :sign_key => 'ab739fd5b7c2a1...',
+ :environment => :production,
+ :proxy => {
+ :http_proxyaddr => "proxy.com",
+ :http_proxyport => 80,
+ :http_proxyuser => "hans",
+ :http_proxpass => "xxx",
}
- end
+ )
-If you don't want to use signed requests (disabled in datatrans web console), you must set `config.sign_key` to `false`.
+If you don't want to use signed requests (disabled in datatrans web console), you can set `config.sign_key` to `false`.
+The configuration is then used as parameter to all the constructors and helpers, see examples below.
+
Possible values for the environment: `:production`, `:development`
Web Authorization
=================
If you want to process a credit card the first time a web authorization is
necessary. Add the following code to a controller action that shows the form.
You need to pass at least `amount`, `currency` and `refno` (order number).
-
- @transaction = Datatrans::Web::Transaction.new({
+ @transaction = datatrans.web_transaction(
:amount => 1000, # in cents!
:currency => 'CHF',
:refno => 'ABCDEF',
- :uppCustomerEmail => 'customer@email.com'
+ :uppCustomerEmail => 'customer@email.com',
# feel free to add more upp infos here ...
- })
+ )
In your View your show the credit card form with a convenient helper:
= form_tag Datatrans.web_authorize_url do
@@ -51,11 +52,11 @@
= hidden_field_tag :successUrl, <your_application_return_url>
= hidden_field_tag :cancelUrl, <your_application_return_url>
= hidden_field_tag :errorUrl, <your_application_return_url>
- = datatrans_notification_request_hidden_fields(@transaction)
+ = datatrans_notification_request_hidden_fields(datatrans, @transaction)
= submit_tag "send"
In this example we use just ECA (Mastercard) as paymentmethod. Feel free to
provide an appropriate select field to offer more payment methods. Don't forget
@@ -64,11 +65,11 @@
After you submit the request to Datatrans they redirect back to your application.
Now you can process the transaction like this:
begin
- transaction = Datatrans::Web::Transaction.new(params)
+ transaction = datatrans.web_transaction(params)
if transaction.authorize
# transaction was successful, access the following attributes
# transaction.transaction_id
# transaction.creditcard_alias
@@ -92,17 +93,17 @@
use the convenient XML methods to process payments.
Authorize
---------
- transaction = Datatrans::XML::Transaction.new(
+ transaction = datatrans.xml_transaction(
:refno => 'ABCDEF',
:amount => 1000, # in cents!
:currency => 'CHF',
:aliasCC => '8383843729284848348',
:expm => 12,
- :expy => 15
+ :expy => 15,
)
if transaction.authorize
# ok, the transaction is authorized...
# access same values as in the web authorization (e.g. transaction.transaction_id)
@@ -114,15 +115,15 @@
Capture
-------
To capture an authorized transaction you use the following code:
- transaction = Datatrans::XML::Transaction.new(
+ transaction = datatrans.xml_transaction(
:refno => 'ABCDEF',
:amount => 1000, # in cents!
:currency => 'CHF',
- :transaction_id => 19834324987349723948729834
+ :transaction_id => 19834324987349723948729834,
)
if transaction.capture
# ok, the money is yours...
else
@@ -133,15 +134,15 @@
Void
----
To make an authorized transaction invalid use void.
- transaction = Datatrans::XML::Transaction.new(
+ transaction = datatrans.xml_transaction(
:refno => 'ABCDEF',
:amount => 1000, # in cents!
:currency => 'CHF',
- :transaction_id => 19834324987349723948729834
+ :transaction_id => 19834324987349723948729834,
)
if transaction.void
# ok, the transaction is not longer valid...
else
@@ -149,9 +150,14 @@
end
CHANGELOG
=========
+
+3.0.0
+-------
+* Refactored Code to allow multiple configurations
+* Proxy config now uses HTTParty naming convention.
2.2.2
-------
* added ability to skip signing by setting config.sign_key = false