tomash/spree-pp-website-standard — pull request #12 by hector (2012-02-28 03:13:27+00:00)
Title: Handle IPN encoding (ArgumentError (invalid byte sequence in UTF-8))

I was having trouble when receiving IPN messages from the PayPal sandbox. Since I am form Spain, some strings that came from the IPN parameters had special characters, like tilde. PayPal is sending the data encoded in windows-1252 and by default ruby expects utf-8 strings.
Luckly one of the IPN parameters received is the encoding PayPal has used, so I just added a before_filter to reencode these parameters in case our encoding is different.
Above I post an example of the error. To reproduce try to save a new PaymentNotification with this has on the params attribute. Things like "address_name"=>"Pepe Garc\xEDa" make it fail.

```ruby
Started POST "/payment_notifications?secret=1234" for 173.0.82.126 at 2012-02-27 18:11:45 +0100
Processing by PaymentNotificationsController#create as HTML
Parameters: {"mc_gross"=>"22.92", "invoice"=>"R143801041", "protection_eligibility"=>"Ineligible", "address_status"=>"unconfirmed", "item_number1"=>"[FILTERED]", "payer_id"=>"G2K26WSJJ5ZGC", "tax"=>"0.00", "address_street"=>"calle Vilamar 76993- 17469", "payment_date"=>"08:50:12 Feb 27, 2012 PST", "payment_status"=>"Completed", "charset"=>"windows-1252", "address_zip"=>"02001", "mc_shipping"=>"0.00", "mc_handling"=>"0.00", "first_name"=>"Pepe", "mc_fee"=>"1.13", "address_country_code"=>"ES", "address_name"=>"Pepe Garc\xEDa", "notify_version"=>"3.4", "custom"=>"", "payer_status"=>"verified", "business"=>"venta_1330311618_biz@camuber.es", "address_country"=>"Spain", "num_cart_items"=>"1", "mc_handling1"=>"0.00", "address_city"=>"Albacete", "verify_sign"=>"Aaekt-ook78znSghzEZW5FreMIK7ADyH7zElHAX8rt7KYIgxWJvfZ27K", "payer_email"=>"compra_1330311564_per@camuber.es", "mc_shipping1"=>"0.00", "txn_id"=>"3HS13290BJ013401P", "payment_type"=>"instant", "last_name"=>"Garc\xEDa", "address_state"=>"Albacete", "item_name1"=>"Horca de acero forjado de 4 p\xFAas con mango.", "receiver_email"=>"venta_1330311618_biz@camuber.es", "payment_fee"=>"", "quantity1"=>"1", "receiver_id"=>"35BX5YMNYMW6G", "txn_type"=>"cart", "mc_gross_1"=>"22.92", "mc_currency"=>"EUR", "residence_country"=>"ES", "test_ipn"=>"1", "transaction_subject"=>"Shopping CartHorca de acero forjado de 4 p\xFAas con mango.", "payment_gross"=>"", "ipn_track_id"=>"7ff71ef78d547", "secret"=>"1234"}
Completed 500 Internal Server Error in 24ms

ArgumentError (invalid byte sequence in UTF-8):
```