Class: ActiveMerchant::Billing::OpenpayGateway
- Defined in:
- lib/active_merchant/billing/gateways/openpay.rb
Constant Summary
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
- #authorize(money, creditcard, options = {}) ⇒ Object
- #capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ OpenpayGateway
constructor
Instantiate a instance of OpenpayGateway by passing through your merchant id and private api key.
- #purchase(money, creditcard, options = {}) ⇒ Object
- #refund(money, identification, options = {}) ⇒ Object
- #store(creditcard, options = {}) ⇒ Object
- #unstore(customer_id, card_id = nil, options = {}) ⇒ Object
- #void(identification, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, #generate_unique_id, inherited, non_fractional_currency?, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ OpenpayGateway
Instantiate a instance of OpenpayGateway by passing through your merchant id and private api key.
To obtain your own credentials
-
Visit openpay.mx
-
Sign up
-
Activate your account clicking on the email confirmation
20 21 22 23 24 25 |
# File 'lib/active_merchant/billing/gateways/openpay.rb', line 20 def initialize( = {}) requires!(, :key, :merchant_id) @api_key = [:key] @merchant_id = [:merchant_id] super end |
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/active_merchant/billing/gateways/openpay.rb', line 32 def (money, creditcard, = {}) post = create_post_for_auth_or_purchase(money, creditcard, ) post[:capture] = false commit(:post, 'charges', post, ) end |
#capture(money, authorization, options = {}) ⇒ Object
38 39 40 41 42 |
# File 'lib/active_merchant/billing/gateways/openpay.rb', line 38 def capture(money, , = {}) post = {} post[:amount] = amount(money) if money commit(:post, "charges/#{CGI.escape()}/capture", post, ) end |
#purchase(money, creditcard, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/active_merchant/billing/gateways/openpay.rb', line 27 def purchase(money, creditcard, = {}) post = create_post_for_auth_or_purchase(money, creditcard, ) commit(:post, 'charges', post, ) end |
#refund(money, identification, options = {}) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/active_merchant/billing/gateways/openpay.rb', line 48 def refund(money, identification, = {}) post = {} post[:description] = [:description] post[:amount] = amount(money) commit(:post, "charges/#{CGI.escape(identification)}/refund", post, ) end |
#store(creditcard, options = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/active_merchant/billing/gateways/openpay.rb', line 55 def store(creditcard, = {}) card_params = {} add_creditcard(card_params, creditcard, ) card = card_params[:card] if [:customer].present? commit(:post, "customers/#{CGI.escape([:customer])}/cards", card, ) else requires!(, :email, :name) post = {} post[:name] = [:name] post[:email] = [:email] MultiResponse.run(:first) do |r| r.process { commit(:post, 'customers', post, ) } if(r.success? && !r.params['id'].blank?) customer_id = r.params['id'] r.process { commit(:post, "customers/#{customer_id}/cards", card, ) } end end end end |
#unstore(customer_id, card_id = nil, options = {}) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/active_merchant/billing/gateways/openpay.rb', line 78 def unstore(customer_id, card_id = nil, = {}) if card_id.nil? commit(:delete, "customers/#{CGI.escape(customer_id)}", nil, ) else commit(:delete, "customers/#{CGI.escape(customer_id)}/cards/#{CGI.escape(card_id)}", nil, ) end end |
#void(identification, options = {}) ⇒ Object
44 45 46 |
# File 'lib/active_merchant/billing/gateways/openpay.rb', line 44 def void(identification, = {}) commit(:post, "charges/#{CGI.escape(identification)}/refund", nil, ) end |