Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make VendorTxCode unique #165

Merged
merged 1 commit into from
Aug 27, 2015
Merged
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
9 changes: 7 additions & 2 deletions lib/offsite_payments/integrations/sage_pay_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,20 @@ def cipher(action, key, payload)

class Helper < OffsitePayments::Helper
include Encryption
attr_reader :timestamp

def initialize(order, account, options = {})
super
@timestamp = Time.now.strftime('%Y%m%d%H%M%S')
add_field 'VendorTxCode', "#{order}#{@timestamp}"
end

mapping :credential2, 'EncryptKey'

mapping :account, 'Vendor'
mapping :amount, 'Amount'
mapping :currency, 'Currency'

mapping :order, 'VendorTxCode'

mapping :customer,
:first_name => 'BillingFirstnames',
:last_name => 'BillingSurname',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_basic_helper_fields
assert_equal 5, @helper.fields.size
assert_field 'Vendor', '[email protected]'
assert_field 'Amount', '5.00'
assert_field 'VendorTxCode', 'order-500'
assert_field 'VendorTxCode', 'order-500' + @helper.timestamp
end

def test_customer_fields
Expand Down