require 'test_helper' require 'unit/response_stubs/purchase_stubs' class PurchaseTest < Test::Unit::TestCase include PurchaseStubs def setup @environment = Spreedly::Environment.new("key", "secret") end def test_successful_purchase t = purchase_using(successful_purchase_response) assert_kind_of(Spreedly::Purchase, t) assert_equal 'Btcyks35m4JLSNOs9ymJoNQLjeX', t.token assert_equal 144, t.amount assert t.on_test_gateway? assert_equal Time.parse("2013-07-31 19:46:26 UTC"), t.created_at assert_equal Time.parse("2013-07-31 19:46:32 UTC"), t.updated_at assert_equal 'USD', t.currency_code assert t.succeeded? assert_equal 'succeeded', t.state assert_equal '187A', t.order_id assert_equal '', t.ip assert_equal '4 Shardblades', t.description assert_equal '', t.merchant_name_descriptor assert_equal '', t.merchant_location_descriptor assert_equal 'YOaCn5a9xRaBTGgmGAWbkgWUuqv', t.gateway_token assert_equal '8xXXIPGXTaPXysDA5OUpgnjTEjK', t.payment_method.token assert_equal "44", t.gateway_transaction_id assert_equal "Purchase", t.transaction_type assert_equal "three-ds-context", t.three_ds_context assert t.response.success assert_equal 'Successful purchase', t.response.message assert_equal '22', t.response.avs_code assert_equal 'I will be back', t.response.avs_message assert_equal '31', t.response.cvv_code assert_equal 'Rutabaga', t.response.cvv_message assert !t.response.pending assert !t.response.fraud_review assert_equal '899', t.response.error_code assert_equal 'The eagle lives!', t.response.error_detail assert !t.response.cancelled assert_equal Time.parse('2013-07-31T19:46:26Z'), t.response.created_at assert_equal Time.parse('2013-07-31T19:46:27Z'), t.response.updated_at assert_equal '', t.shipping_address.name assert_equal '', t.shipping_address.address1 assert_equal '', t.shipping_address.address2 assert_equal '', t.shipping_address.city assert_equal '', t.shipping_address.state assert_equal '', t.shipping_address.zip assert_equal '', t.shipping_address.country assert_equal '', t.shipping_address.phone_number end def test_successful_3dsecure_purchase_attempt t = purchase_using(successful_purchase_3dsecure_attempt_response) assert_kind_of(Spreedly::Purchase, t) assert_equal 'Btcyks35m4JLSNOs9ymJoNQLjeX', t.token assert_equal 144, t.amount assert t.on_test_gateway? assert_equal Time.parse("2013-07-31 19:46:26 UTC"), t.created_at assert_equal Time.parse("2013-07-31 19:46:32 UTC"), t.updated_at assert_equal 'USD', t.currency_code assert !t.succeeded? assert_equal 'pending', t.state assert_equal 'none', t.required_action assert_equal 'http://challenge_url.test', t.challenge_url assert_equal 'challenge form data', t.challenge_form assert_equal 'device fingerprint form data', t.device_fingerprint_form assert_equal '', t.order_id assert_equal '', t.ip assert_equal '4 Shardblades', t.description assert_equal '', t.merchant_name_descriptor assert_equal '', t.merchant_location_descriptor assert_equal 'YOaCn5a9xRaBTGgmGAWbkgWUuqv', t.gateway_token assert_equal '8xXXIPGXTaPXysDA5OUpgnjTEjK', t.payment_method.token assert_equal "44", t.gateway_transaction_id assert t.response.success assert_equal 'Checked enrollment status', t.response.message assert !t.response.pending assert !t.response.fraud_review assert_equal '', t.response.error_code assert_equal Time.parse('2013-07-31T19:46:26Z'), t.response.created_at assert_equal Time.parse('2013-07-31T19:46:27Z'), t.response.updated_at assert_equal 'https://example.com/callback_url', t.callback_url assert_equal 'https://example.com/redirect_url', t.redirect_url assert_equal '', t.checkout_url assert t.checkout_form.include?('