forked from angelleye/paypal-php-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMassPay.php
60 lines (49 loc) · 2.82 KB
/
MassPay.php
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
54
55
56
57
58
59
60
<?php
// Include required library files.
require_once('includes/config.php');
require_once('includes/paypal.class.php');
// Create PayPal object.
$PayPalConfig = array(
'Sandbox' => $sandbox,
'APIUsername' => $api_username,
'APIPassword' => $api_password,
'APISignature' => $api_signature
);
$PayPal = new PayPal($PayPalConfig);
// Prepare request arrays
$MPFields = array(
'emailsubject' => '', // The subject line of the email that PayPal sends when the transaction is completed. Same for all recipients. 255 char max.
'currencycode' => '', // Three-letter currency code.
'receivertype' => '' // Indicates how you identify the recipients of payments in this call to MassPay. Must be EmailAddress or UserID
);
// Typically, you'll loop through some sort of records to build your MPItems array.
// Here I simply include 3 items individually.
$Item1 = array(
'l_email' => '', // Required. Email address of recipient. You must specify either L_EMAIL or L_RECEIVERID but you must not mix the two.
'l_receiverid' => '', // Required. ReceiverID of recipient. Must specify this or email address, but not both.
'l_amt' => '', // Required. Payment amount.
'l_uniqueid' => '', // Transaction-specific ID number for tracking in an accounting system.
'l_note' => '' // Custom note for each recipient.
);
$Item2 = array(
'l_email' => '', // Required. Email address of recipient. You must specify either L_EMAIL or L_RECEIVERID but you must not mix the two.
'l_receiverid' => '', // Required. ReceiverID of recipient. Must specify this or email address, but not both.
'l_amt' => '', // Required. Payment amount.
'l_uniqueid' => '', // Transaction-specific ID number for tracking in an accounting system.
'l_note' => '' // Custom note for each recipient.
);
$Item3 = array(
'l_email' => '', // Required. Email address of recipient. You must specify either L_EMAIL or L_RECEIVERID but you must not mix the two.
'l_receiverid' => '', // Required. ReceiverID of recipient. Must specify this or email address, but not both.
'l_amt' => '', // Required. Payment amount.
'l_uniqueid' => '', // Transaction-specific ID number for tracking in an accounting system.
'l_note' => '' // Custom note for each recipient.
);
$MPItems = array($Item1, $Item2, $Item3); // etc
$PayPalRequestData = array('MPFields'=>$MPFields, 'MPItems' => $MPFields);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->MassPay($PayPalRequestData);
// Write the contents of the response array to the screen for demo purposes.
echo '<pre />';
print_r($PayPalResult);
?>