d1e6f4966f5a40c9103f0ffe41aabb3e8060a902
[WP-Plugins/glm-member-db-registrations.git] /
1 <?php
2 namespace PayPal\Auth;
3 use PayPal\Exception\PPMissingCredentialException;
4 /**
5  * API signature (3-token) based credentials
6  */
7 class PPSignatureCredential extends IPPCredential {
8
9         /**
10          * API username
11          * @var string
12          */
13         protected $userName;
14
15         /**
16          * API password
17          * @var string
18          */
19         protected $password;
20         /**
21          * API Signature
22          * @var string
23          */
24         protected $signature;
25
26         /**
27          * Application Id that uniquely identifies an application that uses the
28          * Platform APIs - Not required for Express Checkout / MassPay / DCC etc
29          * Application Ids are issued by PayPal.
30          * Test application Ids are available for the sandbox environment
31          * @var string
32          */
33         protected $applicationId;
34
35         public function __construct($userName, $password, $signature) {
36                 $this->userName = trim($userName);
37                 $this->password = trim($password);
38                 $this->signature = trim($signature);
39                 $this->validate();
40         }
41
42         public function validate() {
43
44                 if (empty($this->userName)) {
45                         throw new PPMissingCredentialException("username cannot be empty");
46                 }
47                 if (empty($this->password)) {
48                         throw new PPMissingCredentialException("password cannot be empty");
49                 }
50                 // Signature can be empty if using 3-rd party auth tokens from permissions API
51         }
52
53         public function getUserName() {
54                 return $this->userName;
55         }
56         public function getPassword() {
57                 return $this->password;
58         }
59         public function getSignature() {
60                 return $this->signature;
61         }
62
63         public function setApplicationId($applicationId) {
64                 $this->applicationId = trim($applicationId);
65         }
66         public function getApplicationId() {
67                 return $this->applicationId;
68         }
69 }