Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. # API CALL #1 - Fetch Purchases from backend
  2. # REQUEST:
  3. # - GET /android/purchases/:app_id/:user_id
  4. # PARAMS:
  5. # - requires "user_id", type: String, regexp: /[a-zA-Z0-9_.\-@+]*/, desc: "Android device/user id (e.g. com.google_xxx_xxx@gmail.com)"
  6. # - requires "app_id", type: String, regexp: /[a-zA-Z0-9_.\-]*/, desc: "Magazine App id (e.g. com.chuj.magazine)"
  7. # DESCRIPTION:
  8. # - Fetch all purchased issues (single issue purchase) and subscription information
  9. # - This request is sent when the app launches, and whenever the issue shelf refreshes
  10. # LOGIC:
  11. # - First, create an empty array of strings ($issue_id_array) that will be filled with purchased issue product ids.
  12. # - Next, check if there is any active subscription available for this user_id and app_id. If so, append all issue ids within the subscription period to $issue_id_array
  13. # - Next, fetch all individual issue purchases that have been made for this user_id and app_id. Append them to $issue_id_array
  14. # - Finally, return a json response as below
  15. # RESPONSE:
  16. # - JSON: {"issues":["issue_product_id_1","issue_product_id_2"],"subscribed":true}
  17.  
  18. # API CALL #2 - Verify purchase receipts and register purchased issues/subscriptions
  19. # REQUEST:
  20. # - POST /android/verify_multi/:app_id/:user_id
  21. # PARAMS:
  22. # - requires "purchases", type: Array, desc: "Array containing purchase information from google play"
  23. # - > requires "data", type: String, desc: "Product data"
  24. # - > requires "order_id", type: String, desc: "Product order id"
  25. # - > requires "package_name", type: String, desc: "Product package name / app_id"
  26. # - > requires "payload", type: String, desc: "Product payload"
  27. # - > requires "signature", type: String, desc: "Product signature"
  28. # - > requires "sku", type: String, desc: "Product sku"
  29. # - > requires "state", type: String, desc: "Product state"
  30. # - > requires "token", type: String, desc: "Product token"
  31. # - > requires "time", type: Integer, desc: "Product time"
  32. # - > requires "purchase_type", type: String, desc: "Purchase type", values: ["product", "subscription"]
  33. # - requires "user_id", type: String, regexp: /[a-zA-Z0-9_.\-@+]*/, desc: "Android device/user id (e.g. com.google_XXXX_xxx@gmail.com)"
  34. # - requires "app_id", type: String, regexp: /[a-zA-Z0-9_.\-]*/, desc: "Magazine App id (e.g. com.chuj.magazine)"
  35. # DESCRIPTION:
  36. # - Verify purchases made from google play with the backend
  37. # - This request is sent when the app launches, and whenever the issue shelf refreshes
  38. # - The backend should verify and store the receipt information and register receipts and purchases in the database
  39. # LOGIC:
  40. # - First, verify the receipt information by testing signature and payload
  41. # - Store the purchase information (= receipt data) in the database
  42. # - Find the related issues or subscriptions and unlock them for the provided user_id (e.g. tables "purchased_issues", "purchased_subscriptions")
  43. # - Finally, return a json response as below
  44. # RESPONSE:
  45. # - STATUS 204 (Success, no body)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement