-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
308 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Academe\AuthorizeNet\ServerRequest\Collections; | ||
|
||
/** | ||
* Collection of response UserFields. | ||
*/ | ||
|
||
use Academe\AuthorizeNet\Response\HasDataTrait; | ||
use Academe\AuthorizeNet\ServerRequest\Model\CustomerPaymentProfile; | ||
use Academe\AuthorizeNet\AbstractCollection; | ||
|
||
class CustomerPaymentProfiles extends AbstractCollection | ||
{ | ||
use HasDataTrait; | ||
|
||
public function __construct(array $data = []) | ||
{ | ||
$this->setData($data); | ||
|
||
// An array of PaymentProfile records. | ||
|
||
foreach ($data as $item_data) { | ||
$this->push(new CustomerPaymentProfile($item_data)); | ||
} | ||
} | ||
|
||
protected function hasExpectedStrictType($item) | ||
{ | ||
// Make sure the item is the correct type, and is not empty. | ||
|
||
return $item instanceof CustomerPaymentProfile && $item->hasAny(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Academe\AuthorizeNet\ServerRequest\Model; | ||
|
||
/** | ||
* Single payment profile item. | ||
*/ | ||
|
||
use Academe\AuthorizeNet\Response\HasDataTrait; | ||
use Academe\AuthorizeNet\AbstractModel; | ||
|
||
class CustomerPaymentProfile extends AbstractModel | ||
{ | ||
use HasDataTrait; | ||
|
||
protected $id; | ||
protected $customerType; | ||
|
||
public function __construct($data) | ||
{ | ||
$this->setData($data); | ||
|
||
$this->setId($this->getDataValue('id')); | ||
$this->setCustomerType($this->getDataValue('customerType')); | ||
} | ||
|
||
public function jsonSerialize() | ||
{ | ||
$data = [ | ||
'id' => $this->getId(), | ||
'customerType' => $this->getCustomerType(), | ||
]; | ||
|
||
return $data; | ||
} | ||
|
||
protected function setId($value) | ||
{ | ||
$this->id = $value; | ||
} | ||
|
||
protected function setCustomerType($value) | ||
{ | ||
$this->customerType = $value; | ||
} | ||
|
||
public function hasAny() | ||
{ | ||
return $this->id !== null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Academe\AuthorizeNet\ServerRequest\Payload; | ||
|
||
/** | ||
* The customer profile notification payload. | ||
*/ | ||
|
||
use Academe\AuthorizeNet\ServerRequest\Payload\Payment; | ||
use Academe\AuthorizeNet\ServerRequest\Model\Profile; | ||
use Academe\AuthorizeNet\ServerRequest\Collections\CustomerPaymentProfiles; | ||
use Academe\AuthorizeNet\ServerRequest\AbstractPayload; | ||
|
||
class CustomerProfile extends AbstractPayload | ||
{ | ||
protected $merchantCustomerId; | ||
protected $description; | ||
|
||
protected $paymentProfiles; | ||
|
||
public function __construct($data) | ||
{ | ||
parent::__construct($data); | ||
|
||
$this->merchantCustomerId = $this->getDataValue('merchantCustomerId'); | ||
$this->description = $this->getDataValue('description'); | ||
|
||
$paymentProfiles = $this->getDataValue('paymentProfiles'); | ||
|
||
if ($paymentProfiles) { | ||
$this->paymentProfiles = new CustomerPaymentProfiles($paymentProfiles); | ||
} | ||
} | ||
|
||
public function jsonSerialize() | ||
{ | ||
$data = parent::jsonSerialize(); | ||
|
||
$data['merchantCustomerId'] = $this->merchantCustomerId; | ||
$data['description'] = $this->description; | ||
|
||
$data['paymentProfiles'] = $this->paymentProfiles; | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* The customerProfileId is an alias for the id. | ||
*/ | ||
public function getCustomerProfileId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
protected function setMerchantCustomerId($value) | ||
{ | ||
$this->merchantCustomerId = $value; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
protected function setDescription($value) | ||
{ | ||
$this->description = $value; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
protected function setPaymentProfiles(PaymentProfiles $value) | ||
{ | ||
$this->profile = $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.