module Braintree class WebhookTestingGateway # :nodoc: def initialize(gateway) @gateway = gateway @config = gateway.config end def sample_notification(kind, id) payload = Base64.encode64(_sample_xml(kind, id)) signature_string = "#{Braintree::Configuration.public_key}|#{Braintree::Digest.hexdigest(Braintree::Configuration.private_key, payload)}" return signature_string, payload end def _sample_xml(kind, data) <<-XML #{Time.now.utc.iso8601} #{kind} #{_subject_sample_xml(kind, data)} XML end def _subject_sample_xml(kind, id) case kind when Braintree::WebhookNotification::Kind::PartnerUserCreated _partner_credentials_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) else _subscription_sample_xml(id) end end def _subscription_sample_xml(id) <<-XML #{id} XML end def _partner_credentials_sample_xml(data) <<-XML public_id public_key private_key abc123 XML end def _merchant_account_approved_sample_xml(id) <<-XML #{id} master_ma_for_#{id} active active XML end def _merchant_account_declined_sample_xml(id) <<-XML Credit score is too low 82621 Credit score is too low base #{id} suspended master_ma_for_#{id} suspended XML end def _transaction_disbursed_sample_xml(id) <<-XML #{id} 100 2013-07-09T18:23:29Z XML end end end