Sha256: b37d68ad97ce425c99ecabc9874de8cb72ffaee86305b1f5d2d13182ebbc3988
Contents?: true
Size: 1.46 KB
Versions: 7
Compression:
Stored size: 1.46 KB
Contents
require 'test_helper' module Workarea module Paypal class HandleWebhookEventTest < TestCase setup :payment def payment @payment ||= create_payment(paypal: { paypal_id: '123', approved: true }).tap do |p| p.paypal.build_transaction( action: 'authorize', amount: 5.to_m, response: ActiveMerchant::Billing::Response.new( true, 'PayPal capture succeeded', id: 'CAPTURE001', status: 'PENDING' ) ).save! end end def test_payment_capture_completed payload = webhook_capture_completed_payload HandleWebhookEvent.new.perform( payload['event_type'], payload['resource'] ) payment.reload assert_equal(2, payment.paypal.transactions.count) txn = payment.paypal.transactions.captures.first assert(txn.success?) assert_equal(5.to_m, txn.amount) end def test_payment_capture_denied payload = webhook_capture_denied_payload HandleWebhookEvent.new.perform( payload['event_type'], payload['resource'] ) payment.reload assert_equal(1, payment.paypal.transactions.count) txn = payment.paypal.transactions.first assert(txn.success?) assert(txn.canceled?) assert(txn.cancellation.success?) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems