Skip to content

Commit

Permalink
fixing paypal ipn received_at time parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
subbarao committed Apr 23, 2012
1 parent cea650f commit 1fcf9b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -54,7 +54,8 @@ def complete?
# One possible scenario is that our web application was down. In this case paypal tries several
# times an hour to inform us about the notification
def received_at
Time.parse params['payment_date']
parsed_time_fields = DateTime._strptime(params['payment_date'], "%H:%M:%S %b %d, %Y %z")
Time.mktime(*parsed_time_fields.values_at(:year, :mon, :mday, :hour, :min, :sec, :zone))
end

# Status of transaction. List of possible values:
Expand Down
Expand Up @@ -76,6 +76,11 @@ def test_nil_notification
Paypal::Notification.any_instance.stubs(:ssl_post).returns('INVALID')
assert !@paypal.acknowledge
end

def test_received_at_time_parsing
paid_at = "15/04/2005 15:23:54 -0400"
assert_equal paid_at, @paypal.received_at.strftime("%d/%m/%Y %H:%M:%S %z")
end

private

Expand Down

0 comments on commit 1fcf9b6

Please sign in to comment.