up_the_irons / ebay4r

eBay4R is a Ruby wrapper for eBay's Web Services SOAP API

This URL has Read+Write access

up_the_irons (author)
Sat Oct 04 02:16:38 -0700 2008
commit  eac0ae73c6dd3fb14fea20afd1ee0b69788e8e0b
tree    dec33f4ba28d202e17e041062c8954d4bcb6ec09
parent  3fb3b21ca36a45aec135a9cd5329fb07abbf4ed9
ebay4r / contrib / ebay_platform_notifications.txt
100644 69 lines (53 sloc) 2.713 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
[Author's note: the example code for SetNotificationPreferences below is old
and won't work with eBay4R v1.0 or above. See
examples/set_notification_preferences.rb for a more up-to-date code sample]
 
Below is a bit of documentation contributed by David Balatero regarding eBay
Platform Notifications:
 
Tips on how to handle eBay Platform Notifications within a Rails app
====================================================================
 
One quick way to handle incoming notifications from eBay is to setup a Rails
controller to receive them. There are a few tricks you need to do in order to
receive them, however.
 
1. First, you need to create a controller.
 
  script/generate controller Ebay
 
2. Next, you need to tell eBay to send all notifications to this new controller.
You can do this from script/console, if you want (just make sure that in the
console, you load the appropriate eBay4r classes)
 
{{{
@ebay = EBay::API.new('auth_token', 'dev_id', 'app_id', 'cert_id', :sandbox => true)
resp = @ebay.SetNotificationPreferences(:ApplicationDeliveryPreferences => {
                                         :ApplicationEnable => 'Enable',
                                         :ApplicationURL => 'http://' + request.env["SERVER_NAME"] + '/ebay/notification',
                                         :NotificationPayloadType => 'eBLSchemaSOAP' },
                                       :UserDeliveryPreferenceArray => {
                                         :NotificationEnable => [
                                           { :EventEnable => 'Enable',
                                             :EventType => 'EndOfAuction' },
                                           { :EventEnable => 'Enable',
                                             :EventType => 'Feedback' },
                                           { :EventEnable => 'Enable',
                                             :EventType => 'AskSellerQuestion' }
                                         ]
                                       })
}}}
 
3. Finally, you need to write some controller methods to handle the incoming notifications.
 
{{{
def notification
  # Grab the raw SOAP XML into a string
  post_data = request.raw_post
 
  # Unmarshal the XML into a SOAP object
  resp = SOAP::Marshal.unmarshal(post_data)
 
  # Now it's business as usual -- use the resp object like you would
  # use any outgoing eBay call object.
 
  case resp.notificationEventName
    when 'AskSellerQuestion'
      # code here
    when 'EndOfAuction'
      # end of auction code
    when 'Feedback'
      # feedback received code
  end
end
}}}
 
 
Hope this helps!
 
- David Balatero ezwelty [at] NOSPAM- u.washington.edu