Max Ciccotosto
posted this on May 23, 2011 10:05 pm
· SavingGoal: Represents and tracks each item a user is saving up for
· PaymentProvider: Information about the service (Paypal, Amazon, Google) that will be used and the users credentials for that service
· Contribution: Tracks who has submitted towards a goal, and how much
<!ELEMENT Savings (SavingGoal*)>
<!ELEMENT SavingGoal (Id, ExternalItemId, Name, StartingAmount, GoalAmount, CurrentAmount, EndDate, Contributions, PaymentProviders, ConfirmationURL, CancelURL, RecordVersionNumber, RecordOwner)>
<!ELEMENT Contributions (Contribution*)>
<!ELEMENT Contribution (Id, Amount, Date, Contributor, Message, Status, ProviderName, ProviderURL)>
<!-- Used for optomistic locking -->
<!ELEMENT RecordVersionNumber (#PCDATA)>
<!ELEMENT ExternalItemId (#ID)>
<!ELEMENT StartingAmount (#PCDATA)>
<!ELEMENT GoalAmount (#PCDATA)>
<!ELEMENT CurrentAmount (#PCDATA)>
<!ELEMENT Contributor (#CDATA)>
<!-- his list will change as I learn more about the providers apis -->
<!ELEMENT Status (Submitted|Pending|Authorized|Settled|Failed|Canceled)>
<!-- This is filled in by the contributions service and it contains the URL to redirect the user to -->
<!ELEMENT ProviderURL (#PCDATA)>
<!-- This is the url for the clients confirmation page -->
<!ELEMENT ConfirmationURL (#PCDATA)>
<!-- This is the url when the customer decides to cancel on the providers site -->
<!ELEMENT CancelURL (#PCDATA)>
<!ELEMENT PaymentProviders (PaymentProvider+)>
<!ELEMENT PaymentProvider (ProviderName, Credentials)>
<!ELEMENT ProviderName (PayPal|Amazon|Google)>
<!-- I'm assuming the credentials will be different by provide. e.g just email for paypal -->
<!ELEMENT Credentials (#CDATA)>
<ExternalItemId>12345</ExternalItemId>
<StartingAmount>0.00</StartingAmount>
<GoalAmount>100000.00</GoalAmount>
<CurrentAmount>1.00</CurrentAmount>
<ProviderName>Paypal</ProviderName>
<Credentials>rob@larubbio.org </Credentials>
<Contributor>Mom</Contributor>
<Message>Happy Birthday! Good luck saving up for the Porsche</Message>
<ProviderName>PayPal</ProviderName>
<ProviderURL>{Payment Provider specific payment URL}</ProviderURL>
<RecordVersionNumber>1</RecordVersionNumber>
<ConfirmationURL>http://www.wishpot.com/contribution/confirm </ConfirmationURL>
<CancelURL>http://www.wishpot.com/contribution/cancel</CancelURL>
<RecordVersionNumber>1</RecordVersionNumber>
· Any externally presented Id's should not be monotonically increasing ints. This is to prevent id phishing and to stop information leakage about service adoption rates. (NOT IMPLEMENTED)
· PaymentProvider credentials are sent to the service, but never returned to a client.
· CRUD operations through the REST api are always restricted to records the client created. In the case where an operation is attempted against a record the client does not own a 403 Forbidden will be returned.
SGRX = Savings Goal Representation XML, SRX = Savings Representation XML, CSRX = Contributions Representation XML, CRX = Contribution Representation XML
POST http://www.wishpot.com/api/savings?ApiKey={RecordOwner} HTTP/1.1
<ExternamItemId>12345</ExternalItemId>
<StartingAmount>0.00</StartingAmount>
<GoalAmount>100000.00</GoalAmount>
<ProviderName>Paypal</ProviderName>
<Credentials>rob@larubbio.org</Credentials>
Date: Thu, 03 Jul 2008 21:31:17 GMT
<ExternalItemId>12345</ExternalItemId>
<StartingAmount>0.00</StartingAmount>
<GoalAmount>100000.00</GoalAmount>
<CurrentAmount>0.00</CurrentAmount>
<ProviderName>Paypal</ProviderName>
<RecordVersionNumber>1</RecordVersionNumber>
GET http://www.wishpot.com/api/savings?Id={id}&ApiKey={RecordOwner} HTTP/1.1
GET http://www.wishpot.com/api/SavingGoal/{id}?ApiKey={RecordOwner} HTTP/1.1
Date: Thu, 03 Jul 2008 21:31:17 GMT
<ExternalItemId>12345</ExternalItemId>
<StartingAmount>0.00</StartingAmount>
<GoalAmount>100000.00</GoalAmount>
<CurrentAmount>1.00</CurrentAmount>
<ProviderName>Paypal</ProviderName>
<Contributor>Mom</Contributor>
<Message>Happy Birthday! Good luck saving up for the Porsche</Message>
<ProviderName>PayPal</ProviderName>
<ProviderURL>https://www.paypal.com/...</providerURL>
<RecordVersionNumber>1</RecordVersionNumber>
<RecordVersionNumber>1</RecordVersionNumber>
GET http://www.wishpot.com/api/SavingGoal/{id}/Contributions?ApiKey={Re... HTTP/1.1
Date: Thu, 03 Jul 2008 21:31:17 GMT
<Contributor>Mom</Contributor>
<Message>Happy Birthday! Good luck saving up for the Porsche</Message>
<ProviderName>PayPal</ProviderName>
<ProviderURL>https://www.paypal.com/...</providerURL>
<RecordVersionNumber>1</RecordVersionNumber>
DELETE http://www.wishpot.com/api/SavingGoal/{id}?ApiKey={RecordOwner} HTTP/1.1
Date: Thu, 03 Jul 2008 21:31:17 GMT
This is a multi-step process consiting of first creating the contribution, then redirecting the user to the payment provider so they can enter their payment details on the providers site. The payment provider is responsible for redirecting the user back to the client's site and for posting an update on the transactions to the contributions service.
POST http://www.wishpot.com/api/SavingGoal/{id}/Contributions?ApiKey={Re... HTTP/1.1
<Contributor>Mom</Contributor>
<Message>Happy Birthday! Good luck saving up for the Porsche</Message>
<ProviderName>PayPal</ProviderName>
Date: Thu, 03 Jul 2008 21:31:17 GMT
<Contributor>Mom</Contributor>
<Message>Happy Birthday! Good luck saving up for the Porsche</Message>
<ProviderName>PayPal</ProviderName>
<ProviderURL>https://www.paypal.com/...</providerURL>
<RecordVersionNumber>1</RecordVersionNumber>
At this point the client is responsible for redirecting the user to the <ProviderURL>. On the payment provider's site the user may complete or cancel the transaction. Either action will redirect the user first to the contribution service which will update the status of the contribution and then back to the client's site (ConfirmationUrl or CancelUrl) with the id of the contribution as an argument (Id={id}). At this point the client has completed it's transaction with the contributions service for that contribution.
GET http://www.wishpot.com/api/Contribution/{id}?ApiKey={RecordOwner} HTTP/1.1
Date: Thu, 03 Jul 2008 21:31:17 GMT
<Contributor>Mom</Contributor>
<Message>Happy Birthday! Good luck saving up for the Porsche</Message>
<ProviderName>PayPal</ProviderName>
<ProviderURL>https://www.paypal.com/...</providerURL>
<RecordVersionNumber>1</RecordVersionNumber>
DELETE http://www.wishpot.com/api/Contribution/{id}?ApiKey={RecordOwner} HTTP/1.1
Date: Thu, 03 Jul 2008 21:31:17 GMT