summaryrefslogtreecommitdiff
path: root/notes_for_module_writers
blob: 91c1acb544d31d1a4bd3538160e522aa49627ac4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Information on creating a new processor backend to go with
Business::OnlineThirdPartyPayment.
-----------------------------------------------------------

NOTE: 

    You should read the notes in Business::OnlinePayment first.

Create a subclass of Business::OnlineThirdPartyPayment called
Business::OnlineThirdPartyPayment::(processor name).  You should override at
least the set_defaults, create, and execute methods.

See Business::OnlineThirdPartyPayment::PayPal as an example.

create(%content):
This method's primary functions are:
- to determine/create the URL the purchaser must visit to make payment, and
- to assign a token to the transaction.

%content will always include 'amount' (the amount of the payment) and 
'description' (a text description of the product being purchased).

If the processor requires the merchant to initiate the transaction (e.g.
PayPal), then create() should do that, and store the transaction ID assigned
by the processor in 'token'.  Otherwise, create() can simply assign a 
semi-random, unique string to 'token', and additionally pass it to the 
processor as the order number or other identifier.

The URL the purchaser needs to visit should be assigned to the 'redirect'
property of the object.  If the processor expects to receive the transaction
parameters from the purchaser's browser in the form of a POST request,
create() can store them in a hashref in the 'post_params' property.

execute(%params):
This method's primary function is to determine whether the transaction
was successful.  The 'token' property should already be set to whatever it 
was after the initial create().  %params is everything passed back by the 
processor to the callback URL.

If the merchant is required to confirm or "capture" the payment after 
authorization, execute() should do that.  (PayPal again.)  Other processors
(see B:OTP:FCMB for an example) provide a separate API to query the 
transaction status; execute() should do that.  In either case, it should
set the 'is_success' property to 0 or 1, and set 'error_message' if the 
payment failed, or 'order_number' and 'authorization' if it succeeded.

set_defaults(%arguments):
This is called from the constructor.  The build_subs() method of 
Business::OnlinePayment is available for creating accessor methods.
In general, modules should look for the merchant ID in 'username', any
password or shared secret in 'password', and the callback URL in
'return_url'.