I finally managed to figure out what to do to migrate a Perl shopping cart to SagePay version 3.0. I went down a ton of blind alleys and this was an excellent article but I had problems installing Crypt::Cipher::AES. The solution I found that works avoiding a bunch of SagePay Gotchas is:

use Crypt::CBC; # The Sagepay test login is at: # https://test.sagepay.com/mysagepay # Login using your administrator username and password. If # you don't know what they are contact SagePay support and # they will send a reset link to the registered email # address of the administrator. After you login you # will see Encryption Password: <16 character long string> my $id = <16 char long Encryption Password>; # e.g. AbcdeFghiJkLmNoP my $iv = $id; my $cipher = Crypt::CBC->new( -key => $id, -iv => $iv, -cipher => 'OpenSSL::AES', -literal_key => 1, -header => "none", -padding => "standard", -keysize => 16 ); $crypt = uc $cipher->encrypt_hex($crypt); $crypt = "@".$crypt;

$crypt is what you submit via your shopping cart CGI form to SagePay. For the test environment the URL to submit your form to is:

https://test.sagepay.com/gateway/service/vspform-register.vsp

To go live you need the live Encryption Password. Its not the same as the test Encryption Password. You can ask SagePay support where to find this.

For the live environment the URL to submit your form to is:

https://live.sagepay.com/gateway/service/vspform-register.vsp

I hope this helps someone else avoid spending ages working through this like I did.


In reply to Re^2: Encrypt using AES(block size 128-bit) in CBC by Anonymous Monk
in thread Encrypt using AES(block size 128-bit) in CBC by mikemc24

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.