-1

How should I encode 'Crypt' field to make it valid with protocol 3.00 in Ruby? Currently my string looks as follow:

=hidden_field_tag 'Crypt', Base64.encode64('VendorTxCode=406227821909&Amount=32.00&Currency=GBP&Description=Test&SuccessURL=http://example.com/success.php&FailureURL=http://example.com/fail.php&BillingSurname=Smith&BillingFirstnames=John&BillingAddress1=123 Main Street&BillingCity=Anywhere&BillingPostCode=29555&BillingCountry=UK&DeliverySurname=Smith&DeliveryFirstnames=John&DeliverAddress1=123 Main Street&DeliveryCity=Anywhere&DeliveryPostCode=29555&DeliveryCountry=UK')

But each time I get this error as response:

Status Detail:  5068 : The encryption method is not supported by this protocol version.

Thanks in advance, Oskar

Kerozu
  • 673
  • 5
  • 15
  • Have you checked the docs here? https://www.sagepay.co.uk/file/1151/download-document/FORMProtocolandIntegrationGuidelinesV3%200.pdf, it says "The Crypt field should contain all the other transaction information (see the next section) in plain text as Name=Value fields separated by ‘&’ characters. This string should then be encrypted using the AES/CBC/PCKS#5 algorithm and the pre-registered Encryption password, then subsequently Base64 encoded to allow safe transport in an HTML form." So its not just encoding with Base64 – Pablo Jan 29 '14 at 11:24
  • I was using Encryptor gem and then base64 encode and it doesn't work also :-(. I was using [link]http://stackoverflow.com/questions/18374550/rijndael-aes-128-encryption-decryption-in-ruby this answer (at the bottom) with the same values except of message and key :-). Iv was the same. – Kerozu Jan 29 '14 at 14:50
  • have you checked sagepay docs? I think that the general information on what needs to be done is there, despite what programming languague you use. – Pablo Jan 29 '14 at 22:55
  • If you solved this, you should say so or update your q. If the only answer fixed it, please mark as so – simonmorley Dec 16 '15 at 12:24

1 Answers1

0

The AES encrypted string should be prefixed with '@' in order to identify the encryption method to the Sage Pay gateway. Conversely, the '@' should be removed before decoding.

Also using AES, there is no requirement for base64 encoding....

Rik Blacow
  • 1,139
  • 1
  • 7
  • 12