Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ipizza/payment.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Ipizza
class Payment

attr_accessor :provider, :stamp, :amount, :currency, :refnum, :receiver_account, :receiver_name, :sender_account, :sender_name, :message, :transaction_id, :transaction_time
attr_accessor :provider, :stamp, :amount, :currency, :refnum, :receiver_account, :receiver_name, :sender_account, :sender_name, :message, :transaction_id, :transaction_time, :return_url, :cancel_url

def initialize(attribs = {})
attribs.each do |key, value|
Expand Down
4 changes: 2 additions & 2 deletions lib/ipizza/provider/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def payment_request(payment, service_no = 1012)
'VK_CURR' => payment.currency,
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
'VK_MSG' => payment.message,
'VK_RETURN' => self.class.return_url,
'VK_CANCEL' => self.class.cancel_url,
'VK_RETURN' => (payment.return_url || self.class.return_url),
'VK_CANCEL' => (payment.cancel_url || self.class.cancel_url),
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now)
}

Expand Down
18 changes: 18 additions & 0 deletions spec/ipizza/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,23 @@
it 'returns nothing for "unkn" attribute' do
Ipizza::Provider.get('unkn').should be_nil
end

describe '#payment_request' do
let(:payment) { Ipizza::Payment.new(stamp: 1, amount: '123.34', refnum: 1, message: 'Payment message', currency: 'EUR') }
before(:each) do
Ipizza::PaymentRequest.any_instance.stub(:sign)
end

it 'should assign return_url from payment' do
payment.return_url = "new url"
Ipizza::Provider::Base.new.payment_request(payment).sign_params['VK_RETURN'].should == "new url"
end

it 'should assign cancel_url from payment' do
payment.cancel_url = "new url"
Ipizza::Provider::Base.new.payment_request(payment).sign_params['VK_CANCEL'].should == "new url"
end

end
end
end