Class: ActiveMerchant::Billing::BogusBraintreeGateway
- Inherits:
-
BogusGateway
- Object
- BogusGateway
- ActiveMerchant::Billing::BogusBraintreeGateway
- Defined in:
- lib/active_merchant/billing/bogus_braintree_gateway.rb
Instance Method Summary collapse
- #authorize(money, credit_card_or_vault_id, options = {}) ⇒ Object
- #capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ BogusBraintreeGateway
constructor
A new instance of BogusBraintreeGateway.
- #method_missing(method, *args) ⇒ Object
- #purchase(money, credit_card_or_vault_id, options = {}) ⇒ Object
- #refund(*args) ⇒ Object
- #store(paysource, options = {}) ⇒ Object
- #void(authorization, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ BogusBraintreeGateway
Returns a new instance of BogusBraintreeGateway.
4 5 6 |
# File 'lib/active_merchant/billing/bogus_braintree_gateway.rb', line 4 def initialize( = {}) #noop end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
189 190 191 192 |
# File 'lib/active_merchant/billing/bogus_braintree_gateway.rb', line 189 def method_missing(method, *args) return Response.new(true, "Bogus Gateway: Forced success", {}, { test: true }) if self.class.supported_methods.include?(method) super end |
Instance Method Details
#authorize(money, credit_card_or_vault_id, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/active_merchant/billing/bogus_braintree_gateway.rb', line 8 def (money, credit_card_or_vault_id, = {}) case normalize(credit_card_or_vault_id) when /1$/ succuessful_auth_response when /2$/ Response.new(false, FAILURE_MESSAGE, { authorized_amount: money, error: FAILURE_MESSAGE }, { test: true, error_code: STANDARD_ERROR_CODE[:processing_error] }) else raise Error, (credit_card_or_vault_id) end end |
#capture(money, authorization, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/active_merchant/billing/bogus_braintree_gateway.rb', line 19 def capture(money, , = {}) params = { "customer_vault_id" => nil, "braintree_transaction" => { "order_id" => nil, "status" => "submitted_for_settlement", "credit_card_details" => { "masked_number" => "411111******1111", "bin" => "411111", "last_4" => "1111", "card_type" => "Visa", "token" => nil }, "customer_details" => { "id" => nil, "email" => nil }, "billing_details" => { "street_address" => "22 South 3rd St", "extended_address" => nil, "company" => nil, "locality" => "Philadelphia", "region" => "PA", "postal_code" => "19106", "country_name" => "United States of America" }, "shipping_details" => { "street_address" => nil, "extended_address" => nil, "company" => nil, "locality" => nil, "region" => nil, "postal_code" => nil, "country_name" => nil }, "vault_customer" => nil, "merchant_account_id" => "a", "processor_response_code" => "1000" } } Response.new(true, SUCCESS_MESSAGE, params, test: true) end |
#purchase(money, credit_card_or_vault_id, options = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/active_merchant/billing/bogus_braintree_gateway.rb', line 62 def purchase(money, credit_card_or_vault_id, = {}) case normalize(credit_card_or_vault_id) when /1$/ succuessful_purchase_response when /2$/ Response.new(false, FAILURE_MESSAGE, { paid_amount: money, error: FAILURE_MESSAGE }, { test: true, error_code: STANDARD_ERROR_CODE[:processing_error] }) else raise Error, (credit_card_or_vault_id) end end |
#refund(*args) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/active_merchant/billing/bogus_braintree_gateway.rb', line 73 def refund(*args) params = { "braintree_transaction" => { "order_id" => nil, "status" => "submitted_for_settlement", "credit_card_details" => { "masked_number" => "424242******4242", "bin" => "424242", "last_4" => "4242", "card_type" => "Visa", "token" => nil }, "customer_details" => { "id" => nil, "email" => nil }, "billing_details" => { "street_address" => nil, "extended_address" => nil, "company" => nil, "locality" => "Philadelphia", "region" => nil, "postal_code" => nil, "country_name" => "United States of America" }, "shipping_details" => { "street_address" => nil, "extended_address" => nil, "company" => nil, "locality" => nil, "region" => nil, "postal_code" => nil, "country_name" => nil }, "vault_customer" => nil, "merchant_account_id" => "a", "processor_response_code" => "1002" } } Response.new(true, SUCCESS_MESSAGE, params, test: true) end |
#store(paysource, options = {}) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/active_merchant/billing/bogus_braintree_gateway.rb', line 115 def store(paysource, = {}) params = { "braintree_customer" => { "email" => "[email protected]", "first_name" => "Bob", "last_name" => "Bobsen", "id" => "65236875", "credit_cards" => [ { "bin" => "424242", "expiration_date" => "08/2022", "token" => "f94qx1", "last_4" => "4242", "card_type" => "Visa", "masked_number" => "424242******4242" } ] }, "customer_vault_id" => "65236875", "credit_card_token" => "f94qx1" } case normalize(paysource) when /1$/ Response.new(true, SUCCESS_MESSAGE, params, test: true) when /2$/ Response.new(false, FAILURE_MESSAGE, { billingid: nil, error: FAILURE_MESSAGE }, { test: true, error_code: STANDARD_ERROR_CODE[:processing_error] }) else raise Error, (paysource) end end |
#void(authorization, options = {}) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/active_merchant/billing/bogus_braintree_gateway.rb', line 147 def void(, = {}) params = { "braintree_transaction" => { "order_id" => nil, "status" => "voided", "credit_card_details" => { "masked_number" => "424242******4242", "bin" => "424242", "last_4" => "4242", "card_type" => "Visa", "token" => nil }, "customer_details" => { "id" => nil, "email" => nil }, "billing_details" => { "street_address" => nil, "extended_address" => nil, "company" => nil, "locality" => nil, "region" => nil, "postal_code" => nil, "country_name" => nil }, "shipping_details" => { "street_address" => nil, "extended_address" => nil, "company" => nil, "locality" => nil, "region" => nil, "postal_code" => nil, "country_name" => nil }, "vault_customer" => nil, "merchant_account_id" => "a", "processor_response_code" => "1000" } } Response.new(true, SUCCESS_MESSAGE, params, test: true) end |