Anonymous avatar Anonymous committed 04b8298

* Fixed a bug in facebook_payments_get_items decorator.
* Added oredr_info attribute on FacebookCreditsContext.

Comments (0)

Files changed (2)

pyramid_facebook/__init__.py

 
     * ``request``: The request itself.
 
-    * Keyword argument ``order_info``: The order information passed
-      when the `FB.ui method <http://developers.facebook.com/docs/reference/javascript/FB.ui/>`_
-      is invoked.
+    It is possible to access `order_info` via :attr:`context.order_info
+    <pyramid_facebook.security.FacebookCreditsContext.order_info>`:
 
     Decorated function must return a dictionary structured as::
 
     Example::
 
         @facebook_payments_get_items()
-        def get_item(context, request, order_info=None):
+        def get_item(context, request):
             ...
             return {
                 "title": a_title,
         """
         config = scanner.config
         config.add_view(
-            view=wrapped,
+            view=self._decorate(wrapped),
             permission=ViewCanvas,
             route_name='facebook_payments_get_items',
-            decorator=self._decorate
+            renderer='json'
             )
 
     def _validate(self, item_content):
     def _decorate(self, wrapped):
         def wrapper(context, request):
             info = context.facebook_data["credits"]["order_info"]
-            result = self._validate(wrapped(context, request, order_info=info))
-            return json.dumps({
+            result = self._validate(wrapped(context, request))
+            return {
                 "content": [result],
                 "method": "payments_get_items"
-                })
+                }
         return wrapper

pyramid_facebook/security.py

         return self._order_details
 
     @property
+    def order_info(self):
+        """Order info being the order information passed when the `FB.ui method
+        <http://developers.facebook.com/docs/reference/javascript/FB.ui/>`_
+        is invoked."""
+        return context.facebook_data["credits"]["order_info"]
+
+    @property
     def earned_currency_data(self):
         """Modified field received in `facebook credits callback for payment
         status update for earned app currency
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.