-
Notifications
You must be signed in to change notification settings - Fork 67
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
1 parent
683c89b
commit 836cc93
Showing
25 changed files
with
499 additions
and
52 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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<xml> | ||
<releaseNumber>12.0.3</releaseNumber> | ||
<releaseNumber>12.0.4</releaseNumber> | ||
</xml> |
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
85 changes: 85 additions & 0 deletions
85
src/Builders/RequestBuilder/GpApi/GpApiRecurringRequestBuilder.php
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,85 @@ | ||
<?php | ||
|
||
namespace GlobalPayments\Api\Builders\RequestBuilder\GpApi; | ||
|
||
use GlobalPayments\Api\Builders\BaseBuilder; | ||
use GlobalPayments\Api\Builders\RecurringBuilder; | ||
use GlobalPayments\Api\Entities\Customer; | ||
use GlobalPayments\Api\Entities\Enums\TransactionType; | ||
use GlobalPayments\Api\Entities\GpApi\GpApiRequest; | ||
use GlobalPayments\Api\Entities\IRequestBuilder; | ||
use GlobalPayments\Api\Entities\Request; | ||
use GlobalPayments\Api\ServiceConfigs\Gateways\GpApiConfig; | ||
|
||
class GpApiRecurringRequestBuilder implements IRequestBuilder | ||
{ | ||
private $builder; | ||
/*** | ||
* @param RecurringBuilder $builder | ||
* | ||
* @return bool | ||
*/ | ||
public static function canProcess($builder = null) | ||
{ | ||
if ($builder instanceof RecurringBuilder) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* @param BaseBuilder $builder | ||
* @param GpApiConfig $config | ||
* | ||
* @return Request | ||
*/ | ||
public function buildRequest(BaseBuilder $builder, $config) | ||
{ | ||
/** @var RecurringBuilder $builder */ | ||
$this->builder = $builder; | ||
$requestData = []; | ||
/** | ||
* @var RecurringBuilder $builder | ||
*/ | ||
switch ($builder->transactionType) { | ||
case TransactionType::CREATE: | ||
$endpoint = GpApiRequest::PAYERS_ENDPOINT; | ||
$verb = 'POST'; | ||
if ($builder->entity instanceof Customer) { | ||
$this->preparePayerRequest($requestData); | ||
} | ||
break; | ||
case TransactionType::EDIT: | ||
$endpoint = GpApiRequest::PAYERS_ENDPOINT . '/' . $this->builder->entity->id; | ||
$verb = 'PATCH'; | ||
if ($builder->entity instanceof Customer) { | ||
$this->preparePayerRequest($requestData); | ||
} | ||
break; | ||
} | ||
return new GpApiRequest($endpoint, $verb, $requestData); | ||
} | ||
|
||
private function preparePayerRequest(array &$requestData) | ||
{ | ||
/** @var Customer $customer */ | ||
$customer = $this->builder->entity; | ||
$requestData['first_name'] = $customer->firstName; | ||
$requestData['last_name'] = $customer->lastName; | ||
$requestData['reference'] = $customer->key; | ||
if (!empty($customer->paymentMethods)) { | ||
foreach ($customer->paymentMethods as $index => $paymentMethod) { | ||
$requestData['payment_methods'][] = [ | ||
'id' => $index, | ||
'default' => $index === array_key_first($customer->paymentMethods) ? 'YES' : 'NO', | ||
]; | ||
} | ||
} | ||
} | ||
|
||
public function buildRequestFromJson($jsonRequest, $config) | ||
{ | ||
// TODO: Implement buildRequestFromJson() method. | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
class UserType extends Enum | ||
{ | ||
const MERCHANT = 'MERCHANT'; | ||
const PAYER = 'PAYER'; | ||
} |
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
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
Oops, something went wrong.