110 likes | 203 Views
Two Wheel Philanthropy And Beyond. Practical uses for PHP. Two Wheel Philanthropy. The Hard Lessons Action-equals-whaa? How does this server thingy work? Solutions Do this and print that! Host base this! Money Issues What do I need? (Linkpoint, merchant accounts, security certificates)
E N D
Two Wheel Philanthropy And Beyond Practical uses for PHP
Two Wheel Philanthropy • The Hard Lessons • Action-equals-whaa? • How does this server thingy work? • Solutions • Do this and print that! • Host base this! • Money Issues • What do I need? (Linkpoint, merchant accounts, security certificates) • How do I do that stuff? (Linkpoint XML sending and responding) • The Big Shabanga-Bang • How it works (our end). • How it works (their end). • Now, Sherman, what did we learn? • More about encapsulation (encapsul-wha-tion?) • Globals and security.
The hard lessons – Action-equals-whaa? • Our menu was controlled by a form, and we planned on separating the files by the different screens. • Issue: only one action can be given to a form, but until we enter information into the menu, we don’t know which file to go to.
The Hard Lessons – How Does This Server Thingy Work? • Assumption 1: We can use globals, right? (By the way, what’s a global?) • Assumption 2: Isn’t PHP just a big program attached to Apache? • Assumption 3: Can’t we just session_start and go?
Do this and print that! • “Print” functions display a page requiring information with a tag of where they are coming from. • “Do” functions process the information and move on to the next print function. • Other functions are for use within these. • We have one BIG file to work with.
Host Base This ! • We’ll store a variable containing our host base URL and add the server variable from there. • We’ll explicitly state where we want our sessions stored. • We’ll deal with globals by declaring everything as global (not the best option).
What do I need? Merchant Account (a place to put your money, not a matress) Security certificate (a reason for people to trust you to take their money) A service provider (to transfer money from their hands to yours) How do I get that? Merchant Accounts: Apply for them through banks and such. Security Certificates: Provide proof of business to a security company (Thawte). Program using an API of a company which has access to bank networks (Linkpoint, in our case). Money Issues
The Big Shabanga-Bang – How it works on our end. • All users are stored in an SQL table (their passwords have been encrypted to protect the innocent). • All transactions are stored in an SQL table (and are tagged with a random ID so PHP can tell the difference between them). • All events are stored in an SQL table (with any notes, the time, date, and location, and price attached).
The Big Shabanga-Bang – How it works on their (Linkpoint’s) end. • We collect the credit card and cost data. • We produce an XML string according to Linkpoint’s specifications. • [Show the code] • We receive a response in XML indicating the success or failure of the transaction, and order number, and a message. • [Show the documentation] • We store this data in a table, noting the server’s response and only the last 4 digit of the credit card number.
Now, Sherman, what did we learn? – More about encapsulation (encapsul-wha-tion?) • Encapsulation- keeping tasks apart from each other so that we can change algorithms without changing the larger program. • Using PHP include files helps solve for this problem. • [Show the code (duh)…] • Not using forms as flow control allows us to split the tasks into different files. • [Yep, show the code again.]
Now, Sherman, what did we learn? – Globals and Security • Globalizing variables means they came from anywhere. • The reason we had to declare each variable global was because PHP was running with a safety protocol. • [Show the dang code] • This opens up doors for people to “trick” the server. We can solve that by explicitly stating where the globals are supposed to come from. • [Okay, last time, show the code.]