complete rewrite, version 0.10
[Business-OnlineThirdPartyPayment.git] / notes_for_module_writers
1 Information on creating a new processor backend to go with
2 Business::OnlineThirdPartyPayment.
3 -----------------------------------------------------------
4
5 NOTE: 
6
7     You should read the notes in Business::OnlinePayment first.
8
9 Create a subclass of Business::OnlineThirdPartyPayment called
10 Business::OnlineThirdPartyPayment::(processor name).  You should override at
11 least the set_defaults, create, and execute methods.
12
13 See Business::OnlineThirdPartyPayment::PayPal as an example.
14
15 create(%content):
16 This method's primary functions are:
17 - to determine/create the URL the purchaser must visit to make payment, and
18 - to assign a token to the transaction.
19
20 %content will always include 'amount' (the amount of the payment) and 
21 'description' (a text description of the product being purchased).
22
23 If the processor requires the merchant to initiate the transaction (e.g.
24 PayPal), then create() should do that, and store the transaction ID assigned
25 by the processor in 'token'.  Otherwise, create() can simply assign a 
26 semi-random, unique string to 'token', and additionally pass it to the 
27 processor as the order number or other identifier.
28
29 The URL the purchaser needs to visit should be assigned to the 'redirect'
30 property of the object.  If the processor expects to receive the transaction
31 parameters from the purchaser's browser in the form of a POST request,
32 create() can store them in a hashref in the 'post_params' property.
33
34 execute(%params):
35 This method's primary function is to determine whether the transaction
36 was successful.  The 'token' property should already be set to whatever it 
37 was after the initial create().  %params is everything passed back by the 
38 processor to the callback URL.
39
40 If the merchant is required to confirm or "capture" the payment after 
41 authorization, execute() should do that.  (PayPal again.)  Other processors
42 (see B:OTP:FCMB for an example) provide a separate API to query the 
43 transaction status; execute() should do that.  In either case, it should
44 set the 'is_success' property to 0 or 1, and set 'error_message' if the 
45 payment failed, or 'order_number' and 'authorization' if it succeeded.
46
47 set_defaults(%arguments):
48 This is called from the constructor.  The build_subs() method of 
49 Business::OnlinePayment is available for creating accessor methods.
50 In general, modules should look for the merchant ID in 'username', any
51 password or shared secret in 'password', and the callback URL in
52 'return_url'.
53