forked from angellops/paypal-php-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddPaymentCard.php
More file actions
78 lines (68 loc) · 4.02 KB
/
Copy pathAddPaymentCard.php
File metadata and controls
78 lines (68 loc) · 4.02 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
// Include required library files.
require_once('includes/config.php');
require_once('includes/paypal.class.php');
// Create PayPal object.
$PayPalConfig = array(
'Sandbox' => $sandbox,
'DeveloperAccountEmail' => $developer_account_email,
'ApplicationID' => $application_id,
'DeviceID' => $device_id,
'IPAddress' => $_SERVER['REMOTE_ADDR'],
'APIUsername' => $api_username,
'APIPassword' => $api_password,
'APISignature' => $api_signature,
'APISubject' => $api_subject
);
$PayPal = new PayPal_Adaptive($PayPalConfig);
// Prepare request arrays
$AddPaymentCardFields = array(
'AccountID' => '', // The ID number of the PayPal account for which the payment card is being added. You must specify either AccountID or EmailAdddress
'CardNumber' => '', // Required. The credit card number.
'CardOwnerDateOfBirth' => '', // The date of birth of the card holder.
'CardType' => '', // Required. The type of card being added. Values are: Visa, MasterCard, AmericanExpress, Discover, SwitchMaestro, Solo, CarteAurore, CarteBleue, Cofinoga, 4etoiles, CarteAura, TarjetaAurora, JCB
'CardVerificationNumber' => '', // The verification code for the card. Generally required for calls where ConfirmationType is set to NONE. With the appropriate account review, this param is optional.
'ConfirmationType' => '', // Required. Whether the account holder is redirected to PayPal.com to confirm the card addition. Values are: WEB, NONE
'CreateAccountKey' => '', // The key returned in a CreateAccount response. Required for calls where the ConfirmationType is NONE.
'EmailAddress' => '', // Email address of the account holder adding the card. Must specify either AccountID or EmailAddress.
'IssueNumber' => '', // The 2-digit issue number for Switch, Maestro, and Solo cards.
'StartDate' => '' // The element containing the start date for the payment card.
);
$NameOnCard = array(
'Salutation' => '', // A salutation for the card owner.
'FirstName' => '', // Required. First name of the card holder.
'MiddleName' => '', // Middle name of the card holder.
'LastName' => '', // Required. Last name of the card holder.
'Suffix' => '' // A suffix for the card holder.
);
$BillingAddress = array(
'Line1' => '', // Required. Billing street address.
'Line2' => '', // Billing street address 2
'City' => '', // Required. Billing city.
'State' => '', // Billing state.
'PostalCode' => '', // Billing postal code
'CountryCode' => '' // Required. Billing country code.
);
$ExpirationDate = array(
'Month' => '', // Expiration month.
'Year' => '' // Required. Expiration Year.
);
$WebOptions = array(
'CancelURL' => '', // The URL to which the user is returned when they cancel the flow at PayPal.com
'CancelURLDescription' => '', // A description for the CancelURL
'ReturnURL' => '', // The URL to which the user is returned when they complete the process.
'ReturnURLDescription' => '' // A description for the ReturnURL
);
$PayPalRequestData = array(
'AddPaymentCardFields' => $AddPaymentCardFields,
'NameOnCard' => $NameOnCard,
'BillingAddress' => $BillingAddress,
'ExpirationDate' => $ExpirationDate,
'WebOptions' => $WebOptions
);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->AddPaymentCard($PayPalRequestData);
// Write the contents of the response array to the screen for demo purposes.
echo '<pre />';
print_r($PayPalResult);
?>