# coding: utf-8 require_relative 'spec_helper' RSpec.describe 'IyziPay' do before :all do @options = IyziPay::Options.new @options.api_key = YAML.load_file('.secrets.yml')['test']['api_key'] @options.secret_key = YAML.load_file('.secrets.yml')['test']['secret_key'] @options.base_url = YAML.load_file('.secrets.yml')['test']['base_url'] end it 'should initialize checkout form' do buyer = { id: 'BY789', name: 'John', surname: 'Doe', gsmNumber: '+905350000000', email: 'email@email.com', identityNumber: '74300864791', lastLoginDate: '2015-10-05 12:43:35', registrationDate: '2013-04-21 15:12:09', registrationAddress: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', ip: '85.34.78.112', city: 'Istanbul', country: 'Turkey', zipCode: '34732' } address = { contactName: 'Jane Doe', city: 'Istanbul', country: 'Turkey', address: 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', zipCode: '34732' } item1 = { id: 'BI101', name: 'Binocular', category1: 'Collectibles', category2: 'Accessories', itemType: IyziPay::Model::BasketItemType::PHYSICAL, price: '0.3' } item2 = { id: 'BI102', name: 'Game code', category1: 'Game', category2: 'Online Game Items', itemType: IyziPay::Model::BasketItemType::VIRTUAL, price: '0.5' } item3 = { id: 'BI103', name: 'Usb', category1: 'Electronics', category2: 'Usb / Cable', itemType: IyziPay::Model::BasketItemType::PHYSICAL, price: '0.2' } request = { locale: IyziPay::Model::Locale::TR, conversationId: '123456789', price: '1', paidPrice: '1.2', currency: IyziPay::Model::Currency::TRY, basketId: 'B67832', paymentGroup: IyziPay::Model::PaymentGroup::PRODUCT, callbackUrl: 'https://www.example.com/callback', enabledInstallments: [2, 3, 6, 9], buyer: buyer, billingAddress: address, shippingAddress: address, basketItems: [item1, item2, item3] } checkout_form_initialize = IyziPay::Model::CheckoutFormInitialize.new.create(request, @options) begin $stderr.puts checkout_form_initialize.inspect rescue $stderr.puts 'oops' raise end end it 'should retrieve checkout form result' do request = { locale: IyziPay::Model::Locale::TR, conversationId: '123456789', token: 'token' } checkout_form_payment = IyziPay::Model::CheckoutForm.new.retrieve(request, @options) begin $stderr.puts checkout_form_payment.inspect rescue $stderr.puts 'oops' raise end end after :each do end end