| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- # frozen_string_literal: true
- require "test_helper"
- require 'bigdecimal'
- class TestParatika < Minitest::Test
- def setup
- Paratika.configure do |config|
- config.merchant_id = '10002036'
- config.merchant_user = 'paytentest@akillibulut.net'
- config.merchant_password = '3mzVyRKuwnttqRC.'
- config.url = 'https://entegrasyon.paratika.com.tr'
- end
- @@customer = { id: 'c1', name: 'John Doe', email: 'test@example.com', phone: '905531781020', ip: '7.11.7.11' }
- @@card = { name: 'John Doe', number: '4355084355084358', expiry: '12/2030', ccv: '000', save: 'yes' }
- @@pid = -> { { id: SecureRandom.hex(16), amount: BigDecimal('1.00'), currency: 'TRY' } }
- @@refundable, @@payment = @@pid.call, @@pid.call
- @@token = Paratika::Sale.new(@@refundable, @@customer, @@card).send.data[:card_token]
- end
- def test_version_number
- refute_nil ::Paratika::VERSION
- end
- def test_currency_exchange
- result = Paratika::CurrencyExchange.new('USD', 'TRY', BigDecimal('1.00')).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- def test_sale_with_new_card
- result = Paratika::Sale.new(@@payment, @@customer, @@card).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- def test_pre_auth_with_new_card
- result = Paratika::PreAuth.new(@@payment, @@customer, @@card).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- def test_sale_with_saved_card
- result = Paratika::Sale.new(@@payment, @@customer, { token: @@token }).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- def test_pre_auth_with_saved_card
- result = Paratika::PreAuth.new(@@payment, @@customer, { token: @@token }).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- def test_cancel_transaction
- result = Paratika::Void.new(@@refundable).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- def test_refund_money
- result = Paratika::Refund.new(@@refundable).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- def test_query_saved_cards
- result = Paratika::QueryCard.new(@@customer[:id]).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- def test_delete_card
- result = Paratika::EWalletDeleteCard.new(@@token).send
- puts result.to_json + __method__.to_s
- assert result.data[:success]
- end
- end
|