Skip to content

add temporary branch for heartland recurring fixes #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
13 changes: 13 additions & 0 deletions src/Builders/AuthorizationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1077,4 +1077,17 @@ public function withHostedPaymentData($hostedPaymentData)
$this->hostedPaymentData = $hostedPaymentData;
return $this;
}

/**
* Set the associated schedule ID
*
* @param string $scheduleId
*
* @return AuthorizationBuilder
*/
public function withScheduleId($scheduleId)
{
$this->scheduleId = $scheduleId;
return $this;
}
}
2 changes: 1 addition & 1 deletion src/Entities/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Schedule extends RecurringEntity
*
* @var EmailReceipt
*/
public $emailReceipt;
public $emailReceipt = 'Never';

/**
* The end date of a schedule, if any.
Expand Down
2 changes: 0 additions & 2 deletions src/Gateways/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ protected function sendRequest(
curl_setopt($request, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($request, CURLOPT_SSL_CIPHER_LIST, implode(':', $supportedCiphers));

// error_log($data);
$curlResponse = curl_exec($request);
// error_log($curlResponse);
$curlInfo = curl_getinfo($request);
$curlError = curl_errno($request);

Expand Down
8 changes: 4 additions & 4 deletions src/Gateways/PayPlanConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,12 @@ protected function buildSchedule($request, Schedule $schedule, $type)

if ($type === TransactionType::CREATE) {
$request['customerKey'] = $schedule->customerKey;
$request['startDate'] = $schedule->startDate;
$request = $this->buildDate($request, 'startDate', $schedule->startDate);
$request['frequency'] = $schedule->frequency;
$request['duration'] = $mapDuration();
} else { // Edit Fields
if (!$schedule->hasStarted) {
$request['startDate'] = $schedule->startDate;
$request = $this->buildDate($request, 'startDate', $schedule->startDate);
$request['frequency'] = $schedule->frequency;
$request['duration'] = $mapDuration();
} else {
Expand All @@ -494,7 +494,7 @@ protected function buildSchedule($request, Schedule $schedule, $type)
protected function buildDate($request, $name, \DateTime $date = null, $force = false)
{
if ($date !== null || $force) {
$value = $date !== null ? $date->format('MMddyyyy') : null;
$value = $date !== null ? $date->format('mdY') : null;
$request[$name] = $value;
}
return $request;
Expand All @@ -504,7 +504,7 @@ protected function buildAmount($request, $name, $amount, $currency, $type)
{
if ($amount !== null) {
$node = [
'value' => $amount,
'value' => $amount * 100,
];

if ($type === TransactionType::CREATE) {
Expand Down
83 changes: 58 additions & 25 deletions src/Gateways/PorticoConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use GlobalPayments\Api\PaymentMethods\Interfaces\IPinProtected;
use GlobalPayments\Api\PaymentMethods\Interfaces\ITokenizable;
use GlobalPayments\Api\PaymentMethods\Interfaces\ITrackData;
use GlobalPayments\Api\PaymentMethods\RecurringPaymentMethod;
use GlobalPayments\Api\PaymentMethods\TransactionReference;
use GlobalPayments\Api\Entities\Enums\ReportType;
use GlobalPayments\Api\Entities\Reporting\TransactionSummary;
Expand Down Expand Up @@ -196,8 +197,14 @@ public function processAuthorization(AuthorizationBuilder $builder)
$block1->appendChild($xml->createElement('Alias', $builder->alias));
}

$isCheck = $builder->paymentMethod->paymentMethodType === PaymentMethodType::ACH;
if ($isCheck || $builder->billingAddress !== null) {
$isCheck = ($builder->paymentMethod->paymentMethodType === PaymentMethodType::ACH)
|| ($builder->paymentMethod instanceof RecurringPaymentMethod
&& $builder->paymentMethod->paymentType === 'ACH');
$propertyName = $isCheck ? 'checkHolderName' : 'cardHolderName';
if ($isCheck
|| $builder->billingAddress !== null
|| $builder->paymentMethod->{$propertyName} !== null
) {
$address = $this->hydrateHolder($xml, $builder, $isCheck);

if (!empty($address)) {
Expand Down Expand Up @@ -1079,6 +1086,15 @@ protected function hydrateTransactionSummary($item)
$summary->batchSequenceNumber = (string)$item->BatchSeqNbr;
}

if (isset($item) && isset($item->CardHolderData)) {
if (isset($item->CardHolderData->CardHolderFirstName)) {
$summary->cardHolderFirstName = $item->CardHolderData->CardHolderFirstName;
}
if (isset($item->CardHolderData->CardHolderLastName)) {
$summary->cardHolderLastName = $item->CardHolderData->CardHolderLastName;
}
}

if (isset($item) && isset($item->CardSwiped)) {
$summary->cardSwiped = (string)$item->CardSwiped;
}
Expand Down Expand Up @@ -1301,7 +1317,7 @@ protected function hydrateTransactionSummary($item)
$summary->fullyCaptured = (string)$item->FullyCapturedInd;
}

// lodging data
// lodging data
if (isset($item) && isset($item->LodgingData)) {
$summary->lodgingData = new LodgingData();
$summary->lodgingData->prestigiousPropertyLimit = (string)$item->LodgingData->PrestigiousPropertyLimit;
Expand Down Expand Up @@ -1379,6 +1395,8 @@ protected function mapRequestType(BaseBuilder $builder)
return 'CreditIncrementalAuth';
} elseif ($builder->transactionModifier === TransactionModifier::OFFLINE) {
return 'CreditOfflineAuth';
} elseif ($builder->transactionModifier == TransactionModifier::RECURRING) {
return 'RecurringBillingAuth';
} elseif ($builder->transactionModifier === TransactionModifier::ENCRYPTED_MOBILE) {
throw new UnsupportedTransactionException('Transaction not supported for this payment method.');
}
Expand All @@ -1394,9 +1412,16 @@ protected function mapRequestType(BaseBuilder $builder)
return 'CreditOfflineSale';
} elseif ($builder->transactionModifier === TransactionModifier::ENCRYPTED_MOBILE) {
throw new UnsupportedTransactionException('Transaction not supported for this payment method.');
} elseif ($builder->transactionModifier == TransactionModifier::RECURRING) {
return 'RecurringBilling';
} else {
return 'CreditSale';
}
} elseif ($builder->paymentMethod->paymentMethodType == PaymentMethodType::RECURRING) {
if ($builder->paymentMethod->paymentType == 'ACH') {
return 'CheckSale';
}
return 'RecurringBilling';
} elseif ($builder->paymentMethod->paymentMethodType === PaymentMethodType::DEBIT) {
return 'DebitSale';
} elseif ($builder->paymentMethod->paymentMethodType === PaymentMethodType::CASH) {
Expand Down Expand Up @@ -1571,33 +1596,41 @@ protected function normalizeResponse($input)
protected function hydrateHolder(DOMDocument $xml, BaseBuilder $builder, $isCheck = false)
{
$holder = $xml->createElement($isCheck ? 'ConsumerInfo' : 'CardHolderData');
$holder->appendChild(
$xml->createElement($isCheck ? 'Address1' : 'CardHolderAddr', $builder->billingAddress->streetAddress1)
);
$holder->appendChild(
$xml->createElement($isCheck ? 'City' : 'CardHolderCity', $builder->billingAddress->city)
);
$holder->appendChild(
$xml->createElement($isCheck ? 'State' : 'CardHolderState', $builder->billingAddress->getProvince())
);
$holder->appendChild(
$xml->createElement($isCheck ? 'Zip' : 'CardHolderZip', $builder->billingAddress->postalCode)
);

if ($isCheck) {
if (!empty($builder->paymentMethod->checkHolderName)) {
$names = explode(' ', $builder->paymentMethod->checkHolderName, 2);
if ($isCheck && $builder->paymentMethod instanceof RecurringPaymentMethod) {
return null;
}

if ($builder->billingAddress !== null) {
$holder->appendChild(
$xml->createElement($isCheck ? 'Address1' : 'CardHolderAddr', $builder->billingAddress->streetAddress1)
);
$holder->appendChild(
$xml->createElement($isCheck ? 'City' : 'CardHolderCity', $builder->billingAddress->city)
);
$holder->appendChild(
$xml->createElement($isCheck ? 'State' : 'CardHolderState', $builder->billingAddress->getProvince())
);
$holder->appendChild(
$xml->createElement($isCheck ? 'Zip' : 'CardHolderZip', $builder->billingAddress->postalCode)
);
}

$propertyName = $isCheck ? 'checkHolderName' : 'cardHolderName';
if (!empty($builder->paymentMethod->{$propertyName})) {
$names = explode(' ', $builder->paymentMethod->{$propertyName}, 2);
$holder->appendChild(
$xml->createElement($isCheck ? 'FirstName' : 'CardHolderFirstName', $names[0])
);

if (isset($names[1])) {
$holder->appendChild(
$xml->createElement('FirstName', $names[0])
$xml->createElement($isCheck ? 'LastName' : 'CardHolderLastName', $names[1])
);

if (isset($names[1])) {
$holder->appendChild(
$xml->createElement('LastName', $names[1])
);
}
}
}

if ($isCheck) {
if ($builder->paymentMethod->checkHolderName !== null) {
$holder->appendChild($xml->createElement('CheckName', $builder->paymentMethod->checkHolderName));
}
Expand Down
19 changes: 16 additions & 3 deletions src/PaymentMethods/RecurringPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use GlobalPayments\Api\Builders\AuthorizationBuilder;
use GlobalPayments\Api\Entities\RecurringEntity;
use GlobalPayments\Api\Entities\Enums\PaymentMethodType;
use GlobalPayments\Api\Entities\Exceptions\ArgumentException;
use GlobalPayments\Api\Entities\Exceptions\UnsupportedTransactionException;
use GlobalPayments\Api\Entities\Schedule;
use GlobalPayments\Api\PaymentMethods\Interfaces\IAuthable;
Expand Down Expand Up @@ -196,6 +197,10 @@ public function __get($name)
switch ($name) {
case 'paymentMethod':
return $this->paymentMethod;
case 'cardHolderName':
return $this->nameOnAccount;
case 'checkHolderName':
return $this->nameOnAccount;
default:
break;
}
Expand All @@ -204,14 +209,22 @@ public function __get($name)
return $this->{$name};
}

throw new ArgumentException(sprintf('Property `%s` does not exist on Transaction', $name));
if ($this->paymentMethod && property_exists($this->paymentMethod, $name)) {
return $this->paymentMethod->{$name};
}

throw new ArgumentException(sprintf('Property `%s` does not exist on RecurringPaymentMethod', $name));
}

public function __isset($name)
{
return in_array($name, [
'paymentMethod',
]) || isset($this->{$name});
'paymentMethod',
'cardHolderName',
'checkHolderName',
])
|| isset($this->{$name})
|| ($this->paymentMethod && isset($this->paymentMethod->{$name}));
}

public function __set($name, $value)
Expand Down
Loading