Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/ARBUpdateSubscriptionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ class ARBUpdateSubscriptionRequest extends ARBCreateSubscriptionRequest
public function __construct(
Configuration $configuration,
Client $client,
$subscriptionId
Subscription $subscription,
string $subscriptionId
) {
parent::__construct($configuration, $client);
$this->subscriptionId = $subscription;
$this->subscriptionId = $subscriptionId;
// Authnet does not allow an interval to be updated
$subscription->removeInterval();
parent::__construct($configuration, $client, $subscription);
}

protected function attachData(RequestInterface $request)
{
$request->addData('subscriptionId', $this->subscriptionId);
parent::attachData($request);
}
}
13 changes: 13 additions & 0 deletions src/DataTypes/ArbTransaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CommerceGuys\AuthNet\DataTypes;

class ArbTransaction extends BaseDataType {
protected $propertyMap = [
'transId',
'response',
'submitTimeUTC',
'payNum',
'attemptNum',
];
}
12 changes: 11 additions & 1 deletion src/DataTypes/Interval.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function validate(array $values)
throw new \InvalidArgumentException('Interval must have a unit.');
}
if (!array_intersect(['days', 'months'], (array) $values['unit'])) {
throw new \InvalidArgumentException('Interval unit must be days or months.');
throw new \InvalidArgumentException('Interval unit must be days or months.' . $values['unit']);
}
switch ($values['unit']) {
case 'days':
Expand All @@ -41,4 +41,14 @@ protected function validate(array $values)
break;
}
}

public function addLength(int $length)
{
$this->propertyMap['length'] = $length;
}

public function addUnit(String $unit)
{
$this->propertyMap['unit'] = $unit;
}
}
9 changes: 9 additions & 0 deletions src/DataTypes/PaymentSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ public function addInterval(Interval $interval)
{
$this->properties['interval'] = $interval->toArray();
}

public function addTotalOccurrences(String $totalOccurrences)
{
$this->properties['totalOccurrences'] = $totalOccurrences;
}

public function addStartDate(string $startDate) {
$this->properties['startDate'] = $startDate;
}
}
66 changes: 66 additions & 0 deletions src/DataTypes/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,70 @@ public function addProfile(CustomerProfileId $profile)
{
$this->properties['profile'] = $profile->toArray();
}

public function addAmount(string $amount)
{
$this->properties['amount'] = $amount;
}

public function getAmount()
{
return $this->properties['amount'];
}

public function getInterval() {
if(is_array($this->properties['paymentSchedule'])) {
return $this->properties['paymentSchedule']['interval'];
}
return $this->properties['paymentSchedule']->interval;
}

public function getPaymentSchedule() {
return $this->properties['paymentSchedule'];
}

public function removeInterval()
{
unset($this->properties['paymentSchedule']['interval']);
}

public function getStartDate()
{
if(is_array($this->properties['paymentSchedule'])) {
return $this->properties['paymentSchedule']['startDate'];
}
return $this->properties['paymentSchedule']->startDate;
}

public function addStartDate(string $startDate)
{
if(is_object($this->properties['paymentSchedule'])) {
$this->properties['paymentSchedule']->startDate = $startDate;
}
$this->properties['paymentSchedule']['startDate'] = $startDate;
}

public function removeStartDate() {
unset($this->properties['paymentSchedule']['startDate']);
}

public function getArbTransactions() {
return $this->properties['arbTransactions'];
}

public function addArbTransactions($arbTransactions) {
if( is_array($arbTransactions)) {
$arbTransactions = $arbTransactions['arbTransaction'];
}
else {
$arbTransactions = $arbTransactions->arbTransaction;
}
foreach( $arbTransactions as $arbTransaction ) {
$this->properties['arbTransactions']['arbTransaction'][] = (array) $arbTransaction;
}
}

public function addArbTransaction(ArbTransaction $arbTransaction) {
$this->properties['arbTransactions']['arbTransaction'][] = $arbTransaction->toArray();
}
}