Skip to content
Kai Hendry edited this page Apr 18, 2014 · 11 revisions

Focus on using Paypal's IPN.

Here is an example $_POST you would get posted to a URL by Paypal, e.g. hackerspace.sg/ipn, when a new user signs up...

Array
(
    [txn_type] => subscr_signup
    [subscr_id] => I-3VHCV0NVV92A
    [last_name] =>
    [option_selection1] => Monthly
    [residence_country] => SG
    [mc_currency] => USD
    [item_name] => SOME_VARIABLE_YOU_CAN_SET
    [business] => [email protected]
    [verify_sign] => AZfKIR4QNcdoQTedJmCA7EfuUEahA7Zoi.r.lcLOl2PKQ6fqKVeojlgg
    [payer_status] => verified
    [payer_email] => [email protected]
    [first_name] =>
    [receiver_email] => [email protected]
    [payer_id] => N5UZEHS4J5BK3
    [option_name1] => Payment options
    [btn_id] => 44361981
    [custom] => SOME_VARIABLE_YOU_CAN_SET
    [charset] => windows-1252
    [notify_version] => 3.7
    [ipn_track_id] => c084cad82eba9
)

txn_type indicates if it is a new subscription, cancelled payment, continued payment etc. I run my business on a ~100LOC PHP script of this nature. You can add variables in the Paypal form to be able to get the NRIC/Passport number, chosen membership tier etc.

Although this assumes most payments come in via Paypal, which is a excellent basis, the PHP script is simply writing out to a flat file structure, e.g. member-$type/email_address, alumni-$type/email_address, trans-$type/email_address and it's easy to append by hand. Most importantly the whole structure can be checked into git and hence you have a complete history and easy backup option (to private github repo?).

$type is a variable I made up for us to track the type of paid service, which could be regular, lglocker, smlocker, hotdesk, broke etc

Example of member-$type/email_address could be member-regular/[email protected] containing: Kai Hendry, passport number, twitter handle, whatever. This can be exposed to the user, e.g. hackerspace.sg/member/[email protected] and it would just write out to a CSV or JSON style flat format to make it easier to extend.

Example of trans-$type/email_address could be trans-regular/[email protected] containing:

1382530103 subscr_signup 
1383138283 subscr_payment
1385825381 subscr_payment 
1388409783 subscr_payment
1391084722 subscr_payment 
1393605943 subscr_payment
1396181416 subscr_payment 

First column is Epoch time. If the payment comes in via Standard Chartered a line like 1397807907 SCpayment someID can be appended manually or via some "admin" PHP script.

Given a flat structure, it's trivial to create a "Member profile page", "Member's directory (Public)", "Payment subscription page", etc.

I imagine the whole thing can be written in a suckless fashion in about 200 lines of PHP.

Concerns

If this is implemented on Microsoft's Azure, you can easily spend a day fucking around getting email working. You don't need email, but whenever there is a change in the transactions, the admin should get an email to make sure everything is OK. This is how to run a company or an organisation.

Clone this wiki locally