Class: ActiveMerchant::Billing::BraspagGateway
- Defined in:
- lib/active_merchant/billing/gateways/braspag.rb
Constant Summary collapse
- TEST_URL =
'https://homologacao.pagador.com.br/webservice/pagador.asmx'
- LIVE_URL =
'https://www.pagador.com.br/webservice/pagador.asmx'
- CREDIT_CARD_CODES =
map credit card to the Braspag expected representation
{ :visa => 22, :master => 23, :american_express => 18 }
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, creditcard, options = {}) ⇒ Object
Performs an authorization, which reserves the funds on the customer’s credit card, but does not charge the card.
-
#capture(money, authorization, options = {}) ⇒ Object
Captures the funds from an authorized transaction.
-
#initialize(options = {}) ⇒ BraspagGateway
constructor
Creates a new BraspagGateway.
-
#purchase(money, creditcard, options = {}) ⇒ Object
Perform a purchase, which is essentially an authorization and capture in a single operation.
-
#void(authorization, options = {}) ⇒ Object
Void a transaction.
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?
Methods included from Utils
#deprecated, generate_unique_id
Methods included from CreditCardFormatting
Methods included from RequiresParameters
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ BraspagGateway
Creates a new BraspagGateway
The gateway requires that a valid login in the options
hash.
Options
-
:login
– The Braspag Merchant ID (REQUIRED) -
:test
–true
orfalse
. If true, perform transactions against the test server.
Otherwise, perform transactions against the production server.
30 31 32 33 34 |
# File 'lib/active_merchant/billing/gateways/braspag.rb', line 30 def initialize( = {}) requires!(, :login) @options = super end |
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
Performs an authorization, which reserves the funds on the customer’s credit card, but does not charge the card.
Parameters
-
money
– The amount to be authorized as an Integer value in cents. -
creditcard
– The CreditCard details for the transaction.
Options
* <tt>:order_id</tt> - A unique reference for this order (REQUIRED).
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/active_merchant/billing/gateways/braspag.rb', line 47 def (money, creditcard, = {}) post = PostData.new add_invoice(post, ) add_amount(post, money) add_creditcard(post, money, creditcard) add_customer_data(post, creditcard) add_extra_data(post) commit(:authorize, post) end |
#capture(money, authorization, options = {}) ⇒ Object
Captures the funds from an authorized transaction.
Parameters
-
money
– The amount to be captured as an Integer value in cents. -
authorization
- The authorization string returned from the initial authorization
Options
* <tt>:order_id</tt> - A unique reference for this order (REQUIRED).
67 68 69 70 71 72 73 74 75 |
# File 'lib/active_merchant/billing/gateways/braspag.rb', line 67 def capture(money, , = {}) if .success? post = PostData.new add_invoice(post, ) commit(:capture, post) else end end |
#purchase(money, creditcard, options = {}) ⇒ Object
Perform a purchase, which is essentially an authorization and capture in a single operation.
Parameters
-
money
– The amount to be purchased as an Integer value in cents. -
creditcard
– The CreditCard details for the transaction. -
options
– A hash of optional parameters.
84 85 86 |
# File 'lib/active_merchant/billing/gateways/braspag.rb', line 84 def purchase(money, creditcard, = {}) capture(money, (money, creditcard, ), ) end |
#void(authorization, options = {}) ⇒ Object
Void a transaction.
Parameters
-
authorization
- The authorization string returned from the initial authorization or purchase.
Options
* <tt>:order_id</tt> - A unique reference for this order (REQUIRED).
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/active_merchant/billing/gateways/braspag.rb', line 96 def void(, = {}) if .success? requires!(, :order_id) post = PostData.new post[:order] = [:order_id] commit(:void_transaction, post) else end end |