-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCreateCustomerPaymentProfile.php
89 lines (72 loc) · 2.37 KB
/
CreateCustomerPaymentProfile.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
namespace Academe\AuthorizeNet\Request;
/**
* This function is used to create a new customer payment profile
* for an existing customer profile.
* CHECKME: customer profile ID should therefore be required?
*/
use Academe\AuthorizeNet\Request\Model\PaymentProfile;
use Academe\AuthorizeNet\Auth\MerchantAuthentication;
use Academe\AuthorizeNet\Request\AbstractRequest;
class CreateCustomerPaymentProfile extends AbstractRequest
{
/**
* How the card or bank details are validated when setting
* up the payment profile.
* Also defined in CreateCustomerProfile
*/
const VALIDATION_MODE_NONE = 'none';
const VALIDATION_MODE_TESTMODE = 'testMode';
const VALIDATION_MODE_LIVEMODE = 'liveMode';
protected $refId;
protected $customerProfileId;
// Single payment profile.
protected $paymentProfile;
protected $validationMode;
public function __construct(
MerchantAuthentication $merchantAuthentication,
PaymentProfile $paymentProfile
) {
parent::__construct($merchantAuthentication);
}
public function jsonSerialize()
{
$data = [];
// Start with the authentication details.
$data[$this->getMerchantAuthentication()->getObjectName()] = $this->getMerchantAuthentication();
if ($this->hasRefId()) {
$data['refId'] = $this->getRefId();
}
if ($this->hasCustomerProfileId()) {
$data['customerProfileId'] = $this->getCustomerProfileId();
}
if ($this->hasPaymentProfile()) {
$data['paymentProfile'] = $this->getPaymentProfile();
}
if ($this->hasValidationMode()) {
$data['validationMode'] = $this->getValidationMode();
}
return [
$this->getObjectName() => $data,
];
}
// Merchant-assigned reference ID for the request. Up to 20 characters.
protected function setRefId($value)
{
$this->refId = $value;
}
// Payment gateway assigned ID. Numeric.
protected function setCustomerProfileId($value)
{
$this->customerProfileId = $value;
}
protected function setPaymentProfile(PaymentProfile $value)
{
$this->paymentProfile = $value;
}
protected function setValidationMode($value)
{
$this->assertValueValidationMode($value);
$this->validationMode = $value;
}
}