Class: Braintree::WebhookTestingGateway
- Inherits:
-
Object
- Object
- Braintree::WebhookTestingGateway
- Defined in:
- lib/braintree/webhook_testing_gateway.rb
Overview
:nodoc:
Instance Method Summary collapse
- #_disbursement_exception_sample_xml(id) ⇒ Object
- #_disbursement_sample_xml(id) ⇒ Object
- #_dispute_lost_sample_xml(id) ⇒ Object
- #_dispute_opened_sample_xml(id) ⇒ Object
- #_dispute_won_sample_xml(id) ⇒ Object
- #_merchant_account_approved_sample_xml(id) ⇒ Object
- #_merchant_account_declined_sample_xml(id) ⇒ Object
- #_partner_merchant_connected_sample_xml(data) ⇒ Object
- #_partner_merchant_declined_sample_xml(data) ⇒ Object
- #_partner_merchant_disconnected_sample_xml(data) ⇒ Object
- #_sample_xml(kind, data) ⇒ Object
- #_subject_sample_xml(kind, id) ⇒ Object
- #_subscription_charged_successfully(id) ⇒ Object
- #_subscription_sample_xml(id) ⇒ Object
- #_transaction_disbursed_sample_xml(id) ⇒ Object
-
#initialize(gateway) ⇒ WebhookTestingGateway
constructor
A new instance of WebhookTestingGateway.
- #sample_notification(kind, id) ⇒ Object
Constructor Details
#initialize(gateway) ⇒ WebhookTestingGateway
Returns a new instance of WebhookTestingGateway.
3 4 5 6 7 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 3 def initialize(gateway) @gateway = gateway @config = gateway.config @config.assert_has_access_token_or_keys end |
Instance Method Details
#_disbursement_exception_sample_xml(id) ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 237 def _disbursement_exception_sample_xml(id) <<-XML <disbursement> <id>#{id}</id> <transaction-ids type="array"> <item>afv56j</item> <item>kj8hjk</item> </transaction-ids> <success type="boolean">false</success> <retry type="boolean">false</retry> <merchant-account> <id>merchant_account_token</id> <currency-iso-code>USD</currency-iso-code> <sub-merchant-account type="boolean">false</sub-merchant-account> <status>active</status> </merchant-account> <amount>100.00</amount> <disbursement-date type="date">2014-02-10</disbursement-date> <exception-message>bank_rejected</exception-message> <follow-up-action>update_funding_information</follow-up-action> </disbursement> XML end |
#_disbursement_sample_xml(id) ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 262 def _disbursement_sample_xml(id) <<-XML <disbursement> <id>#{id}</id> <transaction-ids type="array"> <item>afv56j</item> <item>kj8hjk</item> </transaction-ids> <success type="boolean">true</success> <retry type="boolean">false</retry> <merchant-account> <id>merchant_account_token</id> <currency-iso-code>USD</currency-iso-code> <sub-merchant-account type="boolean">false</sub-merchant-account> <status>active</status> </merchant-account> <amount>100.00</amount> <disbursement-date type="date">2014-02-10</disbursement-date> <exception-message nil="true"/> <follow-up-action nil="true"/> </disbursement> XML end |
#_dispute_lost_sample_xml(id) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 199 def _dispute_lost_sample_xml(id) <<-XML <dispute> <amount>250.00</amount> <currency-iso-code>USD</currency-iso-code> <received-date type="date">2014-03-01</received-date> <reply-by-date type="date">2014-03-21</reply-by-date> <status>lost</status> <reason>fraud</reason> <id>#{id}</id> <transaction> <id>#{id}</id> <amount>250.00</amount> </transaction> </dispute> XML end |
#_dispute_opened_sample_xml(id) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 180 def _dispute_opened_sample_xml(id) <<-XML <dispute> <amount>250.00</amount> <currency-iso-code>USD</currency-iso-code> <received-date type="date">2014-03-01</received-date> <reply-by-date type="date">2014-03-21</reply-by-date> <status>open</status> <reason>fraud</reason> <id>#{id}</id> <transaction> <id>#{id}</id> <amount>250.00</amount> </transaction> </dispute> XML end |
#_dispute_won_sample_xml(id) ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 218 def _dispute_won_sample_xml(id) <<-XML <dispute> <amount>250.00</amount> <currency-iso-code>USD</currency-iso-code> <received-date type="date">2014-03-01</received-date> <reply-by-date type="date">2014-03-21</reply-by-date> <status>won</status> <reason>fraud</reason> <id>#{id}</id> <transaction> <id>#{id}</id> <amount>250.00</amount> </transaction> </dispute> XML end |
#_merchant_account_approved_sample_xml(id) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 124 def _merchant_account_approved_sample_xml(id) <<-XML <merchant_account> <id>#{id}</id> <master_merchant_account> <id>master_ma_for_#{id}</id> <status>active</status> </master_merchant_account> <status>active</status> </merchant_account> XML end |
#_merchant_account_declined_sample_xml(id) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 138 def _merchant_account_declined_sample_xml(id) <<-XML <api-error-response> <message>Credit score is too low</message> <errors> <errors type="array"/> <merchant-account> <errors type="array"> <error> <code>82621</code> <message>Credit score is too low</message> <attribute type="symbol">base</attribute> </error> </errors> </merchant-account> </errors> <merchant-account> <id>#{id}</id> <status>suspended</status> <master-merchant-account> <id>master_ma_for_#{id}</id> <status>suspended</status> </master-merchant-account> </merchant-account> </api-error-response> XML end |
#_partner_merchant_connected_sample_xml(data) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 93 def _partner_merchant_connected_sample_xml(data) <<-XML <partner-merchant> <merchant-public-id>public_id</merchant-public-id> <public-key>public_key</public-key> <private-key>private_key</private-key> <partner-merchant-id>abc123</partner-merchant-id> <client-side-encryption-key>cse_key</client-side-encryption-key> </partner-merchant> XML end |
#_partner_merchant_declined_sample_xml(data) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 115 def _partner_merchant_declined_sample_xml(data) <<-XML <partner-merchant> <partner-merchant-id>abc123</partner-merchant-id> </partner-merchant> XML end |
#_partner_merchant_disconnected_sample_xml(data) ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 106 def _partner_merchant_disconnected_sample_xml(data) <<-XML <partner-merchant> <partner-merchant-id>abc123</partner-merchant-id> </partner-merchant> XML end |
#_sample_xml(kind, data) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 16 def _sample_xml(kind, data) <<-XML <notification> <timestamp type="datetime">#{Time.now.utc.iso8601}</timestamp> <kind>#{kind}</kind> <subject> #{_subject_sample_xml(kind, data)} </subject> </notification> XML end |
#_subject_sample_xml(kind, id) ⇒ Object
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 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 28 def _subject_sample_xml(kind, id) case kind when Braintree::WebhookNotification::Kind::DisputeOpened _dispute_opened_sample_xml(id) when Braintree::WebhookNotification::Kind::DisputeLost _dispute_lost_sample_xml(id) when Braintree::WebhookNotification::Kind::DisputeWon _dispute_won_sample_xml(id) when Braintree::WebhookNotification::Kind::PartnerMerchantConnected _partner_merchant_connected_sample_xml(id) when Braintree::WebhookNotification::Kind::PartnerMerchantDisconnected _partner_merchant_disconnected_sample_xml(id) when Braintree::WebhookNotification::Kind::PartnerMerchantDeclined _partner_merchant_declined_sample_xml(id) when Braintree::WebhookNotification::Kind::SubMerchantAccountApproved _merchant_account_approved_sample_xml(id) when Braintree::WebhookNotification::Kind::SubMerchantAccountDeclined _merchant_account_declined_sample_xml(id) when Braintree::WebhookNotification::Kind::TransactionDisbursed _transaction_disbursed_sample_xml(id) when Braintree::WebhookNotification::Kind::DisbursementException _disbursement_exception_sample_xml(id) when Braintree::WebhookNotification::Kind::Disbursement _disbursement_sample_xml(id) when Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully _subscription_charged_successfully(id) else _subscription_sample_xml(id) end end |
#_subscription_charged_successfully(id) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 59 def _subscription_charged_successfully(id) <<-XML <subscription> <id>#{id}</id> <transactions type="array"> <transaction> <status>submitted_for_settlement</status> <amount>49.99</amount> </transaction> </transactions> <add_ons type="array"> </add_ons> <discounts type="array"> </discounts> </subscription> XML end |
#_subscription_sample_xml(id) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 78 def _subscription_sample_xml(id) <<-XML <subscription> <id>#{id}</id> <transactions type="array"> </transactions> <add_ons type="array"> </add_ons> <discounts type="array"> </discounts> </subscription> XML end |
#_transaction_disbursed_sample_xml(id) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 167 def _transaction_disbursed_sample_xml(id) <<-XML <transaction> <id>#{id}</id> <amount>100</amount> <disbursement-details> <disbursement-date type="date">2013-07-09</disbursement-date> </disbursement-details> </transaction> XML end |
#sample_notification(kind, id) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/braintree/webhook_testing_gateway.rb', line 9 def sample_notification(kind, id) payload = Base64.encode64(_sample_xml(kind, id)) signature_string = "#{@config.public_key}|#{Braintree::Digest.hexdigest(@config.private_key, payload)}" return {:bt_signature => signature_string, :bt_payload => payload} end |