diff --git a/src/Builders/PayFacBuilder.php b/src/Builders/PayFacBuilder.php new file mode 100644 index 00000000..5ab380fa --- /dev/null +++ b/src/Builders/PayFacBuilder.php @@ -0,0 +1,387 @@ +transactionType = $type; + $this->transactionModifier = TransactionModifier::NONE; + } + + /** + * Executes the builder against the gateway. + * + * @return mixed + */ + public function execute(string $configName = 'default') + { + parent::execute($configName); + + $client = ServicesContainer::instance()->getPayFac($configName); + return $client->processPayFac($this); + } + + protected function setupValidations() + { + $this->validations->of( + TransactionType::CREATE_ACCOUNT + ) + ->with(TransactionModifier::NONE) + ->check('beneficialOwnerData')->isNotNull() + ->check('businessData')->isNotNull() + ->check('userPersonalData')->isNotNull() + ->check('creditCardInformation')->isNotNull(); + + $this->validations->of( + TransactionType::EDIT | + TransactionType::RESET_PASSWORD | + TransactionType::RENEW_ACCOUNT | + TransactionType::UPDATE_OWNERSHIP_DETAILS | + TransactionType::DEACTIVATE | + TransactionType::UPLOAD_CHARGEBACK_DOCUMENT | + TransactionType::OBTAIN_SSO_KEY | + TransactionType::UPDATE_BANK_ACCOUNT_OWNERSHIP | + TransactionType::ADD_FUNDS | + TransactionType::SWEEP_FUNDS | + TransactionType::ADD_CARD_FLASH_FUNDS | + TransactionType::PUSH_MONEY_FLASH_FUNDS | + TransactionType::SPEND_BACK | + TransactionType::REVERSE_SPLITPAY | + TransactionType::SPLIT_FUNDS | + TransactionType::GET_ACCOUNT_BALANCE + ) + ->with(TransactionModifier::NONE) + ->check('accountNumber')->isNotNull(); + + $this->validations->of( + TransactionType::UPDATE_OWNERSHIP_DETAILS + ) + ->with(TransactionModifier::NONE) + ->check('beneficialOwnerData')->isNotNull(); + + $this->validations->of( + TransactionType::UPLOAD_CHARGEBACK_DOCUMENT + ) + ->with(TransactionModifier::NONE) + ->check('uploadDocumentData')->isNotNull(); + + $this->validations->of( + TransactionType::OBTAIN_SSO_KEY + ) + ->with(TransactionModifier::NONE) + ->check('singleSignOnData')->isNotNull(); + + $this->validations->of( + TransactionType::UPDATE_BANK_ACCOUNT_OWNERSHIP + ) + ->with(TransactionModifier::NONE) + ->check('beneficialOwnerData')->isNotNull(); + + $this->validations->of( + TransactionType::ADD_FUNDS | + TransactionType::SWEEP_FUNDS | + TransactionType::PUSH_MONEY_FLASH_FUNDS | + TransactionType::SPEND_BACK | + TransactionType::REVERSE_SPLITPAY | + TransactionType::SPLIT_FUNDS + ) + ->with(TransactionModifier::NONE) + ->check('amount')->isNotNull(); + + $this->validations->of(TransactionType::ADD_CARD_FLASH_FUNDS) + ->with(TransactionModifier::NONE) + ->check('flashFundsPaymentCardData')->isNotNull(); + + $this->validations->of(TransactionType::DISBURSE_FUNDS) + ->with(TransactionModifier::NONE) + ->check('receivingAccountNumber')->isNotNull(); + + $this->validations->of(TransactionType::SPEND_BACK) + ->with(TransactionModifier::NONE) + ->check('allowPending')->isNotNull() + ->check('receivingAccountNumber')->isNotNull(); + + $this->validations->of(TransactionType::SPLIT_FUNDS) + ->with(TransactionModifier::NONE) + ->check('transNum')->isNotNull() + ->check('receivingAccountNumber')->isNotNull(); + + $this->validations->of(TransactionType::REVERSE_SPLITPAY) + ->with(TransactionModifier::NONE) + ->check('transNum')->isNotNull() + ->check('requireCCRefund')->isNotNull() + ->check('ccAmount')->isNotNull(); + + } + + /* + * Primary Bank Account Information – Optional. Used to add a bank account to which funds can be settled + * + * var Object GlobalPayments\Api\Entities\PayFac\BankAccountData; + */ + public function withBankAccountData(BankAccountData $bankAccountData) + { + $this->bankAccountData = $bankAccountData; + return $this; + } + /* + * Merchant Beneficiary Owner Information – Required for all merchants validating KYC based off of personal data + * + * var Object GlobalPayments\Api\Entities\PayFac\BeneficialOwnerData; + */ + public function withBeneficialOwnerData(BeneficialOwnerData $beneficialOwnerData) + { + $this->beneficialOwnerData = $beneficialOwnerData; + return $this; + } + /* + * Business Data – Required for business validated accounts. May also be required for personal validated accounts + * by ProPay Risk Team + * + * var Object GlobalPayments\Api\Entities\PayFac\BusinessData; + */ + public function withBusinessData(BusinessData $businessData) + { + $this->businessData = $businessData; + return $this; + } + /* + * Significant Owner Information – May be required for some partners based on ProPay Risk decision + * + * var Object GlobalPayments\Api\Entities\PayFac\SignificantOwnerData; + */ + public function withSignificantOwnerData(SignificantOwnerData $significantOwnerData) + { + $this->significantOwnerData = $significantOwnerData; + return $this; + } + /* + * Threat Risk Assessment Information – May be required based on ProPay Risk Decision + * + * var Object GlobalPayments\Api\Entities\PayFac\ThreatRiskData; + */ + public function withThreatRiskData(ThreatRiskData $threatRiskData) + { + $this->threatRiskData = $threatRiskData; + return $this; + } + + /* + * User / Merchant Personal Data + * + * var Object GlobalPayments\Api\Entities\PayFac\UserPersonalData; + */ + public function withUserPersonalData(UserPersonalData $userPersonalData) + { + $this->userPersonalData = $userPersonalData; + return $this; + } + + public function withCreditCardData($creditCardInformation) + { + $this->creditCardInformation = $creditCardInformation; + return $this; + } + + public function withACHData($achInformation) + { + $this->achInformation = $achInformation; + return $this; + } + + public function withSecondaryBankAccountData($secondaryBankInformation) + { + $this->secondaryBankInformation = $secondaryBankInformation; + return $this; + } + + public function withGrossBillingSettleData($grossBillingInformation) + { + $this->grossBillingInformation = $grossBillingInformation; + return $this; + } + + /* + * The ProPay account to be updated + * + * var int + */ + public function withAccountNumber($accountNumber) + { + $this->accountNumber = $accountNumber; + return $this; + } + + /* + * Temporary password which will allow a onetime login to ProPay’s website. Must be at least eight characters. + * Must not contain part or the entire first or last name. Must contain at least one capital letter, + * one lower case letter, and either one symbol or one number + * + * var string + */ + public function withPassword($password) + { + $this->password = $password; + return $this; + } + + public function withAccountPermissions($accountPermissions) + { + $this->accountPermissions = $accountPermissions; + return $this; + } + + /* + * amount must be greater than zero + */ + public function withNegativeLimit($negativeLimit) + { + $this->negativeLimit = $negativeLimit; + return $this; + } + + public function withRenewalAccountData($renewalAccountData) + { + $this->renewalAccountData = $renewalAccountData; + return $this; + } + + + /* + * Document details + * + * var GlobalPayments\Api\Entities\PayFac\UploadDocumentData + */ + public function withUploadDocumentData($uploadDocumentData) + { + //file validations + if (!file_exists($uploadDocumentData->documentLocation)) { + throw new BuilderException('File not found!'); + } elseif (filesize($uploadDocumentData->documentLocation) > 5000000) { + throw new BuilderException('Max file size 5MB exceeded'); + } + + $fileType = pathinfo($uploadDocumentData->documentLocation, PATHINFO_EXTENSION); + if (!in_array($fileType, self::UPLOAD_FILE_TYPES)) { + throw new BuilderException('File type is not supported.'); + } + + $this->uploadDocumentData = $uploadDocumentData; + return $this; + } + + public function withSingleSignOnData($singleSignOnData) + { + $this->singleSignOnData = $singleSignOnData; + return $this; + } + + public function withAmount($amount) + { + $this->amount = $amount; + return $this; + } + + public function withReceivingAccountNumber($receivingAccountNumber) + { + $this->receivingAccountNumber = $receivingAccountNumber; + return $this; + } + + public function withAllowPending($allowPending) + { + $this->allowPending = $allowPending; + return $this; + } + + public function withCCAmount($ccAmount) + { + $this->ccAmount = $ccAmount; + return $this; + } + + public function withRequireCCRefund($requireCCRefund) + { + $this->requireCCRefund = $requireCCRefund; + return $this; + } + + public function withTransNum($transNum) + { + $this->transNum = $transNum; + return $this; + } + + public function withFlashFundsPaymentCardData($flashFundsPaymentCardData) + { + $this->flashFundsPaymentCardData = $flashFundsPaymentCardData; + return $this; + } + + public function withExternalId($externalId) + { + $this->externalId = $externalId; + return $this; + } + + public function withSourceEmail($sourceEmail) + { + $this->sourceEmail = $sourceEmail; + return $this; + } +} diff --git a/src/ConfiguredServices.php b/src/ConfiguredServices.php index 8060702e..ee877ad4 100644 --- a/src/ConfiguredServices.php +++ b/src/ConfiguredServices.php @@ -10,6 +10,9 @@ class ConfiguredServices { private $secure3dProviders; + + /** @var IPayFacProvider */ + private $payFacProvider; /** @var IPaymentGateway */ public $gatewayConnector; @@ -59,4 +62,24 @@ public function setSecure3dProvider($version, $provider) { $this->secure3dProviders[$version] = $provider; } + + /** + * @return void + */ + public function setPayFacProvider($provider) + { + $this->payFacProvider = $provider; + } + + /** + * @return IPayFacProvider + */ + public function getPayFacProvider() + { + $provider = $this->payFacProvider; + if ($provider != null) { + return $provider; + } + return null; + } } diff --git a/src/Entities/Enums/ProPayAccountStatus.php b/src/Entities/Enums/ProPayAccountStatus.php new file mode 100644 index 00000000..fd8275e7 --- /dev/null +++ b/src/Entities/Enums/ProPayAccountStatus.php @@ -0,0 +1,24 @@ +businessAddress = new Address(); + } +} diff --git a/src/Entities/PayFac/FlashFundsPaymentCardData.php b/src/Entities/PayFac/FlashFundsPaymentCardData.php new file mode 100644 index 00000000..4d52fea5 --- /dev/null +++ b/src/Entities/PayFac/FlashFundsPaymentCardData.php @@ -0,0 +1,18 @@ +creditCard = new CreditCardData(); + $this->cardholderAddress = new Address(); + } +} diff --git a/src/Entities/PayFac/GrossBillingInformation.php b/src/Entities/PayFac/GrossBillingInformation.php new file mode 100644 index 00000000..f59d961d --- /dev/null +++ b/src/Entities/PayFac/GrossBillingInformation.php @@ -0,0 +1,22 @@ +grossSettleAddress = new Address(); + $this->grossSettleBankData = new BankAccountData(); + $this->grossSettleCreditCardData = new CreditCardData(); + } +} diff --git a/src/Entities/PayFac/OwnerDetailsResponseData.php b/src/Entities/PayFac/OwnerDetailsResponseData.php new file mode 100644 index 00000000..f8ab1115 --- /dev/null +++ b/src/Entities/PayFac/OwnerDetailsResponseData.php @@ -0,0 +1,9 @@ +ownerAddress = new Address(); + } +} diff --git a/src/Entities/PayFac/PayFacResponseData.php b/src/Entities/PayFac/PayFacResponseData.php new file mode 100644 index 00000000..71e75efb --- /dev/null +++ b/src/Entities/PayFac/PayFacResponseData.php @@ -0,0 +1,54 @@ +physicalAddress = new Address(); + $this->aCHOut = new AccountBalanceResponseData(); + $this->flashFunds = new AccountBalanceResponseData(); + } +} diff --git a/src/Entities/PayFac/RenewAccountData.php b/src/Entities/PayFac/RenewAccountData.php new file mode 100644 index 00000000..4c27b2d2 --- /dev/null +++ b/src/Entities/PayFac/RenewAccountData.php @@ -0,0 +1,60 @@ +creditCard = new CreditCardData(); + } +} diff --git a/src/Entities/PayFac/SignificantOwnerData.php b/src/Entities/PayFac/SignificantOwnerData.php new file mode 100644 index 00000000..e421b8fb --- /dev/null +++ b/src/Entities/PayFac/SignificantOwnerData.php @@ -0,0 +1,34 @@ +significantOwnerData = new OwnersData(); + } +} diff --git a/src/Entities/PayFac/SingleSignOnData.php b/src/Entities/PayFac/SingleSignOnData.php new file mode 100644 index 00000000..ee8015aa --- /dev/null +++ b/src/Entities/PayFac/SingleSignOnData.php @@ -0,0 +1,29 @@ + if userId is not +provided. + * + * @var string + */ + public $userId; + + /** + * Business Physical Address + * + * @var GlobalPayments\Api\Entities\Address + */ + public $userAddress; + + /** + * Business Physical Address + * + * @var GlobalPayments\Api\Entities\Address + */ + public $mailingAddress; + + + public function __construct() + { + $this->userAddress = new Address(); + $this->mailingAddress = new Address(); + } +} diff --git a/src/Entities/RecurringEntity.php b/src/Entities/RecurringEntity.php index cfd3bcc8..4771393b 100644 --- a/src/Entities/RecurringEntity.php +++ b/src/Entities/RecurringEntity.php @@ -64,7 +64,7 @@ public static function find($id, $configName = 'default') ->execute(); foreach ($response as $entity) { - if ($entity->id === $id) { + if ($entity->id === (string) $id) { return RecurringService::get($entity); } } diff --git a/src/Entities/Transaction.php b/src/Entities/Transaction.php index c299ddbd..c2ae8ffa 100644 --- a/src/Entities/Transaction.php +++ b/src/Entities/Transaction.php @@ -259,6 +259,13 @@ class Transaction * */ public $cardBrandTransactionId; + + /** + * The response from Propay + * + * @var PayFacResponseData + */ + public $payFacData; public $cardNumber; diff --git a/src/Gateways/GeniusConnector.php b/src/Gateways/GeniusConnector.php index 9a85fbe3..b67aad5f 100644 --- a/src/Gateways/GeniusConnector.php +++ b/src/Gateways/GeniusConnector.php @@ -348,14 +348,14 @@ public function processReport($builder) } private function setGatewayParams($paymentMethod) - { + { if (!empty($paymentMethod->paymentMethodType) && $paymentMethod->paymentMethodType === PaymentMethodType::GIFT) { $this->xmlNamespace = 'http://schemas.merchantwarehouse.com/merchantware/46/Giftcard'; $this->serviceUrl .= self::GIFT_SERVICE_END_POINT; - } else { - $this->serviceUrl .= self::CREDIT_SERVICE_END_POINT; - } + } else { + $this->serviceUrl .= self::CREDIT_SERVICE_END_POINT; + } } private function hydratePaymentData($xml, $paymentData, $paymentMethod) @@ -365,7 +365,7 @@ private function hydratePaymentData($xml, $paymentData, $paymentMethod) if ($card->valueType === 'CardNbr') { $paymentData->appendChild($xml->createElement('Source', 'Keyed')); $paymentData->appendChild($xml->createElement('CardNumber', $card->number)); - $paymentData->appendChild($xml->createElement('GiftCardPin', $card->pin)); + $paymentData->appendChild($xml->createElement('GiftCardPin', $card->pin)); } elseif ($card->valueType === 'TrackData') { $paymentData->appendChild($xml->createElement('Source', 'READER')); $paymentData->appendChild($xml->createElement('TrackData', $card->value)); @@ -400,5 +400,5 @@ private function hydratePaymentData($xml, $paymentData, $paymentMethod) $paymentData->appendChild($xml->createElement('TrackData', $track->value)); } } - } + } } diff --git a/src/Gateways/IPayFacProvider.php b/src/Gateways/IPayFacProvider.php new file mode 100644 index 00000000..e46ab52c --- /dev/null +++ b/src/Gateways/IPayFacProvider.php @@ -0,0 +1,17 @@ +format('mdY') : null; $request[$name] = $value; - } + } } return $request; } diff --git a/src/Gateways/PorticoConnector.php b/src/Gateways/PorticoConnector.php index 3ff802a4..76845e69 100644 --- a/src/Gateways/PorticoConnector.php +++ b/src/Gateways/PorticoConnector.php @@ -40,6 +40,7 @@ use GlobalPayments\Api\Services\ReportingService; use GlobalPayments\Api\Entities\Enums\StoredCredentialInitiator; use GlobalPayments\Api\Entities\Exceptions\BuilderException; +use GlobalPayments\Api\Entities\PayFac\PayFacResponseData; class PorticoConnector extends XmlGateway implements IPaymentGateway { @@ -411,6 +412,10 @@ public function processAuthorization(AuthorizationBuilder $builder) $block1->appendChild($data); } + if ($method->paymentType === "ACH" && !empty($method->secCode)) { + $block1->appendChild($xml->createElement('SECCode', $method->secCode)); + } + $data = $xml->createElement('RecurringData'); if ($builder->scheduleId !== null) { $data->appendChild($xml->createElement('ScheduleID', $builder->scheduleId)); @@ -1173,7 +1178,13 @@ protected function mapResponse($rawResponse, BaseBuilder $builder, $request) if (isset($item) && isset($item->CardBrandTxnId)) { $result->cardBrandTransactionId = (string)$item->CardBrandTxnId; } - + + if(!empty($root->PaymentFacilitatorTxnId) || !empty($root->PaymentFacilitatorTxnNbr)){ + $result->payFacData = new PayFacResponseData(); + $result->payFacData->transactionId = !empty($root->PaymentFacilitatorTxnId) ? (string) $root->PaymentFacilitatorTxnId : ''; + $result->payFacData->transactionNumber = !empty($root->PaymentFacilitatorTxnNbr) ? (string) $root->PaymentFacilitatorTxnNbr : ''; + } + return $result; } diff --git a/src/Gateways/ProPayConnector.php b/src/Gateways/ProPayConnector.php new file mode 100644 index 00000000..f71667bd --- /dev/null +++ b/src/Gateways/ProPayConnector.php @@ -0,0 +1,646 @@ +updateGatewaySettings($builder); + + $xml = new DOMDocument(); + $transaction = $xml->createElement('XMLRequest'); + + // Credentials + $transaction->appendChild($xml->createElement('certStr', $this->certStr)); + $transaction->appendChild($xml->createElement('termid', $this->termId)); + $transaction->appendChild($xml->createElement('class', 'partner')); + + // Transaction + $xmlTrans = $xml->createElement('XMLTrans'); + $xmlTrans->appendChild($xml->createElement('transType', $this->mapRequestType($builder))); + + $this->hydrateCommonFields($xml, $xmlTrans, $builder); + + if ($builder->transactionType === TransactionType::CREATE_ACCOUNT) { + $this->hydrateAccountDetails($xml, $xmlTrans, $builder); + } elseif ($builder->transactionType === TransactionType::EDIT) { + $this->hydrateAccountEditDetails($xml, $xmlTrans, $builder); + } elseif ($builder->transactionType === TransactionType::RENEW_ACCOUNT && !empty($builder->renewalAccountData)) { + $this->hydrateAccountRenewDetails($xml, $xmlTrans, $builder->renewalAccountData); + } elseif ($builder->transactionType === TransactionType::UPDATE_OWNERSHIP_DETAILS + && !empty($builder->beneficialOwnerData)) { + $this->hydrateBeneficialOwnerData($xml, $xmlTrans, $builder->beneficialOwnerData); + } elseif (!empty($builder->uploadDocumentData)) { + $this->hydrateUploadDocument($xml, $xmlTrans, $builder->uploadDocumentData); + } elseif (!empty($builder->singleSignOnData)) { + $this->hydrateSingleSignOnData($xml, $xmlTrans, $builder->singleSignOnData); + } elseif ($builder->transactionType === TransactionType::UPDATE_BANK_ACCOUNT_OWNERSHIP + && !empty($builder->beneficialOwnerData)) { + $this->updateBankAccountOwnershipInfo($xml, $xmlTrans, $builder->beneficialOwnerData); + } elseif (!empty($builder->flashFundsPaymentCardData)) { + $this->hydrateFlashFundsData($xml, $xmlTrans, $builder->flashFundsPaymentCardData); + } elseif ($builder->transactionType === TransactionType::GET_ACCOUNT_DETAILS + && empty($builder->accountNumber)) { + if(!empty($builder->externalId)){ + $xmlTrans->appendChild($xml->createElement('externalId', $builder->externalId)); + } elseif(!empty($builder->sourceEmail)){ + $xmlTrans->appendChild($xml->createElement('sourceEmail', $builder->sourceEmail)); + } + } + + $transaction->appendChild($xmlTrans); + + $requestXML = $xml->saveXML($transaction); + $response = $this->doTransaction($requestXML); + + return $this->mapResponse($builder, $response); + } + + public function mapRequestType($builder) + { + switch ($builder->transactionType) { + case TransactionType::CREATE_ACCOUNT: + return '01'; + case TransactionType::EDIT: + return '42'; + case TransactionType::RESET_PASSWORD: + return '32'; + case TransactionType::RENEW_ACCOUNT: + return '39'; + case TransactionType::UPDATE_OWNERSHIP_DETAILS: + return '44'; + case TransactionType::DEACTIVATE: + return '41'; + case TransactionType::UPLOAD_CHARGEBACK_DOCUMENT: + return '46'; + case TransactionType::UPLOAD_DOCUMENT: + return '47'; + case TransactionType::OBTAIN_SSO_KEY: + return '300'; + case TransactionType::UPDATE_BANK_ACCOUNT_OWNERSHIP: + return '210'; + case TransactionType::ADD_FUNDS: + return "37"; + case TransactionType::SWEEP_FUNDS: + return "38"; + case TransactionType::ADD_CARD_FLASH_FUNDS: + return "209"; + case TransactionType::PUSH_MONEY_FLASH_FUNDS: + return "45"; + case TransactionType::DISBURSE_FUNDS: + return "02"; + case TransactionType::SPEND_BACK: + return "11"; + case TransactionType::REVERSE_SPLITPAY: + return "43"; + case TransactionType::SPLIT_FUNDS: + return "16"; + case TransactionType::GET_ACCOUNT_DETAILS: + return "13"; + case TransactionType::GET_ACCOUNT_BALANCE: + return "14"; + default: + throw new UnsupportedTransactionException(); + } + } + + public function mapResponse($builder, $rawResponse) + { + $root = $this->xml2object($rawResponse); + + $responseCode = !empty($root->status) ? $root->status : 'Invalid Status code'; + + if ($responseCode != '00') { + throw new GatewayException( + sprintf( + 'Unexpected Gateway Response: %s. ', + $responseCode + ) + ); + } + + $response = new Transaction(); + $response->payFacData = $this->populateProPayResponse($root); + $response->responseCode = (string) $root->status; + + return $response; + } + + /** + * Converts a XML string to a simple object for use, + * removing extra nodes that are not necessary for + * handling the response + * + * @param string $xml Response XML from the gateway + * + * @return SimpleXMLElement + */ + protected function xml2object($xml) + { + $envelope = simplexml_load_string( + $xml, + 'SimpleXMLElement' + ); + + return !empty($envelope->XMLTrans) ? $envelope->XMLTrans : null; + + throw new \Exception('XML from gateway could not be parsed'); + } + + + private function hydrateAccountDetails($xml, $xmlTrans, PayFacBuilder $builder) + { + if (!empty($builder->userPersonalData)) { + $this->hydrateUserPersonalData($xml, $xmlTrans, $builder->userPersonalData); + } + + if (!empty($builder->businessData)) { + $this->hydrateBusinessData($xml, $xmlTrans, $builder->businessData); + } + + if (!empty($builder->beneficialOwnerData)) { + $this->hydrateBeneficialOwnerData($xml, $xmlTrans, $builder->beneficialOwnerData); + } + + if (!empty($builder->grossBillingInformation)) { + $this->hydrateGrossBillingData($xml, $xmlTrans, $builder->grossBillingInformation); + } + + $this->hydrateBankDetails($xml, $xmlTrans, $builder); + $this->hydratOtherDetails($xml, $xmlTrans, $builder); + } + + private function hydrateAccountEditDetails($xml, $xmlTrans, PayFacBuilder $builder) + { + if (!empty($builder->password)) { + $xmlTrans->appendChild($xml->createElement('password', $builder->password)); + } elseif (!empty($builder->negativeLimit)) { + $xmlTrans->appendChild($xml->createElement('negativelimit', $builder->negativeLimit)); + } elseif (!empty($builder->userPersonalData)) { + $this->hydrateUserPersonalData($xml, $xmlTrans, $builder->userPersonalData); + } elseif (!empty($builder->accountPermissions)) { + $this->hydrateAccountPermissions($xml, $xmlTrans, $builder->accountPermissions); + } elseif (!empty($builder->businessData)) { + $this->hydrateBusinessData($xml, $xmlTrans, $builder->businessData); + } elseif (!empty($builder->grossBillingInformation)) { + $this->hydrateGrossBillingData($xml, $xmlTrans, $builder->grossBillingInformation); + } + //update bank details if any + $this->hydrateBankDetails($xml, $xmlTrans, $builder); + } + + private function hydrateAccountRenewDetails($xml, $xmlTrans, RenewAccountData $renewalAccountData) + { + $elementMap = [ + 'tier' => !empty($renewalAccountData->tier) ? $renewalAccountData->tier : '', + + 'CVV2' => !empty($renewalAccountData->creditCard->cvn) ? $renewalAccountData->creditCard->cvn : '', + 'ccNum' => !empty($renewalAccountData->creditCard->number) ? $renewalAccountData->creditCard->number : '', + 'expDate' => !empty($renewalAccountData->creditCard->expMonth) ? $renewalAccountData->creditCard->getShortExpiry() : '', + 'zip' => !empty($renewalAccountData->zipCode) ? $renewalAccountData->zipCode : '', + + 'PaymentBankAccountNumber' => !empty($renewalAccountData->paymentBankAccountNumber) ? $renewalAccountData->paymentBankAccountNumber : '', + 'PaymentBankRoutingNumber' => !empty($renewalAccountData->paymentBankRoutingNumber) ? $renewalAccountData->paymentBankRoutingNumber : '', + 'PaymentBankAccountType' => !empty($renewalAccountData->paymentBankAccountType) ? $renewalAccountData->paymentBankAccountType : '', + ]; + $this->createNewElements($xml, $xmlTrans, $elementMap); + } + + private function hydrateBeneficialOwnerData($xml, $xmLtransaction, $beneficialOwnerData) + { + $ownerDetails = $xml->createElement('BeneficialOwnerData'); + $ownerDetails->appendChild($xml->createElement('OwnerCount', $beneficialOwnerData->ownersCount)); + + if ($beneficialOwnerData->ownersCount > 0) { + $ownersList = $xml->createElement('Owners'); + + foreach ($beneficialOwnerData->ownersList as $ownerInfo) { + $newOwner = $xml->createElement('Owner'); + + $elements = [ + 'FirstName' => !empty($ownerInfo->firstName) ? $ownerInfo->firstName : '', + 'LastName' => !empty($ownerInfo->lastName) ? $ownerInfo->lastName : '', + 'Email' => !empty($ownerInfo->email) ? $ownerInfo->email : '', + 'SSN' => !empty($ownerInfo->ssn) ? $ownerInfo->ssn : '', + 'DateOfBirth' => !empty($ownerInfo->dateOfBirth) ? $ownerInfo->dateOfBirth : '', + 'Address' => !empty($ownerInfo->ownerAddress->streetAddress1) ? $ownerInfo->ownerAddress->streetAddress1 : '', + 'City' => !empty($ownerInfo->ownerAddress->city) ? $ownerInfo->ownerAddress->city : '', + 'State' => !empty($ownerInfo->ownerAddress->state) ? $ownerInfo->ownerAddress->state : '', + 'Zip' => !empty($ownerInfo->ownerAddress->postalCode) ? $ownerInfo->ownerAddress->postalCode : '', + 'Country' => !empty($ownerInfo->ownerAddress->country) ? $ownerInfo->ownerAddress->country : '', + 'Title' => !empty($ownerInfo->title) ? $ownerInfo->title : '', + 'Percentage' => !empty($ownerInfo->percentage) ? $ownerInfo->percentage : '' + ]; + + $this->createNewElements($xml, $newOwner, $elements); + $ownersList->appendChild($newOwner); + } + $ownerDetails->appendChild($ownersList); + } + + $xmLtransaction->appendChild($ownerDetails); + } + + private function hydrateBusinessData($xml, $transaction, BusinessData $businessData) + { + $propertyElementMap = [ + 'BusinessLegalName' => !empty($businessData->businessLegalName) ? $businessData->businessLegalName : '', + 'DoingBusinessAs' => !empty($businessData->doingBusinessAs) ? $businessData->doingBusinessAs : '', + 'EIN' => !empty($businessData->employerIdentificationNumber) ? $businessData->employerIdentificationNumber : '', + 'MCCCode' => !empty($businessData->merchantCategoryCode) ? $businessData->merchantCategoryCode : '', + 'WebsiteURL' => !empty($businessData->websiteURL) ? $businessData->websiteURL : '', + 'BusinessDesc' => !empty($businessData->businessDescription) ? $businessData->businessDescription : '', + 'MonthlyBankCardVolume' => !empty($businessData->monthlyBankCardVolume) ? $businessData->monthlyBankCardVolume : '', + 'AverageTicket' => !empty($businessData->averageTicket) ? $businessData->averageTicket : '', + 'HighestTicket' => !empty($businessData->highestTicket) ? $businessData->highestTicket : '', + 'BusinessAddress' => !empty($businessData->businessAddress->streetAddress1) ? $businessData->businessAddress->streetAddress1 : '', + 'BusinessAddress2' => !empty($businessData->businessAddress->streetAddress2) ? $businessData->businessAddress->streetAddress2 : '', + 'BusinessCity' => !empty($businessData->businessAddress->city) ? $businessData->businessAddress->city : '', + 'BusinessCountry' => !empty($businessData->businessAddress->country) ? $businessData->businessAddress->country : '', + 'BusinessState' => !empty($businessData->businessAddress->state) ? $businessData->businessAddress->state : '', + 'BusinessZip' => !empty($businessData->businessAddress->postalCode) ? $businessData->businessAddress->postalCode : '' + ]; + + $this->createNewElements($xml, $transaction, $propertyElementMap); + } + + private function hydrateUserPersonalData($xml, $transaction, UserPersonalData $userPersonalData) + { + $merchantAddress = $userPersonalData->userAddress; + $mailingAddress = $userPersonalData->mailingAddress; + + $elementMap = [ + 'firstName' => !empty($userPersonalData->firstName) ? $userPersonalData->firstName : '', + 'mInitial' => !empty($userPersonalData->mInitial) ? $userPersonalData->mInitial : '', + 'lastName' => !empty($userPersonalData->lastName) ? $userPersonalData->lastName : '', + 'dob' => !empty($userPersonalData->dateOfBirth) ? $userPersonalData->dateOfBirth : '', + 'ssn' => !empty($userPersonalData->ssn) ? $userPersonalData->ssn : '', + 'sourceEmail' => !empty($userPersonalData->sourceEmail) ? $userPersonalData->sourceEmail : '', + 'dayPhone' => !empty($userPersonalData->dayPhone) ? $userPersonalData->dayPhone : '', + 'evenPhone' => !empty($userPersonalData->eveningPhone) ? $userPersonalData->eveningPhone : '', + 'NotificationEmail' => !empty($userPersonalData->notificationEmail) ? $userPersonalData->notificationEmail : '', + 'currencyCode' => !empty($userPersonalData->currencyCode) ? $userPersonalData->currencyCode : '', + 'tier' => !empty($userPersonalData->tier) ? $userPersonalData->tier : '', + 'externalId' => !empty($userPersonalData->externalId) ? $userPersonalData->externalId : '', + + 'addr' => !empty($merchantAddress->streetAddress1) ? $merchantAddress->streetAddress1 : '', + 'aptNum' => !empty($merchantAddress->streetAddress2) ? $merchantAddress->streetAddress2 : '', + 'addr3' => !empty($merchantAddress->streetAddress3) ? $merchantAddress->streetAddress3 : '', + 'city' => !empty($merchantAddress->city) ? $merchantAddress->city : '', + 'state' => !empty($merchantAddress->state) ? $merchantAddress->state : '', + 'zip' => !empty($merchantAddress->postalCode) ? $merchantAddress->postalCode : '', + 'country' => !empty($merchantAddress->country) ? $merchantAddress->country : '', + + 'mailAddr' => !empty($mailingAddress->streetAddress1) ? $mailingAddress->streetAddress1 : '', + 'mailApt' => !empty($mailingAddress->streetAddress2) ? $mailingAddress->streetAddress2: '', + 'mailAddr3' => !empty($mailingAddress->streetAddress3) ? $mailingAddress->streetAddress3 : '', + 'mailCity' => !empty($mailingAddress->city) ? $mailingAddress->city : '', + 'mailCountry' => !empty($mailingAddress->country) ? $mailingAddress->country : '', + 'mailState' => !empty($mailingAddress->state) ? $mailingAddress->state : '' , + 'mailZip' => !empty($mailingAddress->postalCode) ? $mailingAddress->postalCode : '', + ]; + + $this->createNewElements($xml, $transaction, $elementMap); + } + + private function hydrateBankDetails($xml, $xmlTrans, $builder) + { + $elementMap = []; + + if (!empty($builder->creditCardInformation)) { + $elementMap = [ + 'NameOnCard' => !empty($builder->creditCardInformation->cardHolderName) ? $builder->creditCardInformation->cardHolderName : '', + 'ccNum' => !empty($builder->creditCardInformation->number) ? $builder->creditCardInformation->number : '', + 'expDate' => !empty($builder->creditCardInformation->number) ? $builder->creditCardInformation->getShortExpiry() : '', + ]; + } + + if (!empty($builder->achInformation)) { + $achInformation = [ + 'PaymentBankAccountNumber' => !empty($builder->achInformation->accountNumber) ? $builder->achInformation->accountNumber : '', + 'PaymentBankRoutingNumber' => !empty($builder->achInformation->routingNumber) ? $builder->achInformation->routingNumber : '', + 'PaymentBankAccountType' => !empty($builder->achInformation->accountType) ? $builder->achInformation->accountType : '', + ]; + + $elementMap = array_merge($elementMap, $achInformation); + } + + if (!empty($builder->bankAccountData)) { + $bankAccountData = [ + 'AccountCountryCode' => !empty($builder->bankAccountData->accountCountryCode) ? $builder->bankAccountData->accountCountryCode : '', + 'accountName' => !empty($builder->bankAccountData->accountName) ? $builder->bankAccountData->accountName : '', + 'AccountNumber' => !empty($builder->bankAccountData->accountNumber) ? $builder->bankAccountData->accountNumber : '', + 'AccountOwnershipType' => !empty($builder->bankAccountData->accountOwnershipType) ? $builder->bankAccountData->accountOwnershipType : '', + 'accountType' => !empty($builder->bankAccountData->accountType) ? $builder->bankAccountData->accountType : '', + 'BankName' => !empty($builder->bankAccountData->bankName) ? $builder->bankAccountData->bankName : '', + 'RoutingNumber' => !empty($builder->bankAccountData->routingNumber) ? $builder->bankAccountData->routingNumber : '', + ]; + + $elementMap = array_merge($elementMap, $bankAccountData); + } + + if (!empty($builder->secondaryBankInformation)) { + $secondaryBankInformation = [ + 'SecondaryAccountCountryCode' => !empty($builder->secondaryBankInformation->accountCountryCode) ? $builder->secondaryBankInformation->accountCountryCode : '', + 'SecondaryAccountName' => !empty($builder->secondaryBankInformation->accountName) ? $builder->secondaryBankInformation->accountName : '', + 'SecondaryAccountNumber' => !empty($builder->secondaryBankInformation->accountNumber) ? $builder->secondaryBankInformation->accountNumber : '', + 'SecondaryAccountOwnershipType' => !empty($builder->secondaryBankInformation->accountOwnershipType) ? $builder->secondaryBankInformation->accountOwnershipType : '', + 'SecondaryAccountType' => !empty($builder->secondaryBankInformation->accountType) ? $builder->secondaryBankInformation->accountType : '', + 'SecondaryBankName' => !empty($builder->secondaryBankInformation->bankName) ? $builder->secondaryBankInformation->bankName : '', + 'SecondaryRoutingNumber' => !empty($builder->secondaryBankInformation->routingNumber) ? $builder->secondaryBankInformation->routingNumber : '' + ]; + + $elementMap = array_merge($elementMap, $secondaryBankInformation); + } + + $this->createNewElements($xml, $xmlTrans, $elementMap); + } + + private function hydratOtherDetails($xml, $xmlTrans, $builder) + { + //threatRiskData, significantOwnerData + $significantData = $builder->significantOwnerData; + $details = [ + 'MerchantSourceip' => !empty($builder->threatRiskData->merchantSourceIp) ? $builder->threatRiskData->merchantSourceIp : '', + 'ThreatMetrixPolicy' => !empty($builder->threatRiskData->threatMetrixPolicy) ? $builder->threatRiskData->threatMetrixPolicy : '', + 'ThreatMetrixSessionid' => !empty($builder->threatRiskData->threatMetrixSessionId) ? $builder->threatRiskData->threatMetrixSessionId : '', + 'AuthorizedSignerFirstName' => !empty($significantData->authorizedSignerFirstName) ? $significantData->authorizedSignerFirstName : '', + 'AuthorizedSignerLastName' => !empty($significantData->authorizedSignerLastName) ? $significantData->authorizedSignerLastName : '', + 'AuthorizedSignerTitle' => !empty($significantData->authorizedSignerTitle) ? $significantData->authorizedSignerTitle : '', + ]; + + if (!empty($significantData->significantOwnerData)) { + $significantOwnerData = $significantData->significantOwnerData; + $details = array_merge($details, [ + 'SignificantOwnerFirstName' => !empty($significantOwnerData->firstName) ? $significantOwnerData->firstName : '', + 'SignificantOwnerLastName' => !empty($significantOwnerData->lastName) ? $significantOwnerData->lastName : '', + 'SignificantOwnerSSN' => !empty($significantOwnerData->ssn) ? $significantOwnerData->ssn : '', + 'SignificantOwnerDateOfBirth' => !empty($significantOwnerData->dateOfBirth) ? $significantOwnerData->dateOfBirth : '', + 'SignificantOwnerStreetAddress' => !empty($significantOwnerData->ownerAddress->streetAddress1) ? $significantOwnerData->ownerAddress->streetAddress1 : '', + 'SignificantOwnerCityName' => !empty($significantOwnerData->ownerAddress->city) ? $significantOwnerData->ownerAddress->city : '', + 'SignificantOwnerRegionCode' => !empty($significantOwnerData->ownerAddress->state) ? $significantOwnerData->ownerAddress->state : '', + 'SignificantOwnerPostalCode' => !empty($significantOwnerData->ownerAddress->postalCode) ? $significantOwnerData->ownerAddress->postalCode : '', + 'SignificantOwnerCountryCode' => !empty($significantOwnerData->ownerAddress->country) ? $significantOwnerData->ownerAddress->country : '', + 'SignificantOwnerTitle' => !empty($significantOwnerData->title) ? $significantOwnerData->title : '', + 'SignificantOwnerPercentage' => !empty($significantOwnerData->percentage) ? $significantOwnerData->percentage : '', + ]); + } + + $this->createNewElements($xml, $xmlTrans, $details); + } + + private function hydrateGrossBillingData($xml, $transaction, $grossBilling) + { + $propertyElementMap = [ + 'GrossSettleAddress' => !empty($grossBilling->grossSettleAddress->streetAddress1) ? $grossBilling->grossSettleAddress->streetAddress1 : '', + 'GrossSettleCity' => !empty($grossBilling->grossSettleAddress->city) ? $grossBilling->grossSettleAddress->city : '', + 'GrossSettleState' => !empty($grossBilling->grossSettleAddress->state) ? $grossBilling->grossSettleAddress->state : '', + 'GrossSettleZipCode' => !empty($grossBilling->grossSettleAddress->postalCode) ? $grossBilling->grossSettleAddress->postalCode : '', + 'GrossSettleCountry' => !empty($grossBilling->grossSettleAddress->country) ? $grossBilling->grossSettleAddress->country : '', + + 'GrossSettleCreditCardNumber' => !empty($grossBilling->grossSettleCreditCardData->number) ? $grossBilling->grossSettleCreditCardData->number : '', + 'GrossSettleNameOnCard' => !empty($grossBilling->grossSettleCreditCardData->cardHolderName) ? $grossBilling->grossSettleCreditCardData->cardHolderName : '', + 'GrossSettleCreditCardExpDate' => $grossBilling->grossSettleCreditCardData->getShortExpiry(), + + 'GrossSettleAccountCountryCode' => !empty($grossBilling->grossSettleBankData->accountCountryCode) ? $grossBilling->grossSettleBankData->accountCountryCode : '', + 'GrossSettleAccountHolderName' => !empty($grossBilling->grossSettleBankData->accountName) ? $grossBilling->grossSettleBankData->accountName : '', + 'GrossSettleAccountNumber' => !empty($grossBilling->grossSettleBankData->accountNumber) ? $grossBilling->grossSettleBankData->accountNumber : '', + 'GrossSettleAccountType' => !empty($grossBilling->grossSettleBankData->accountType) ? $grossBilling->grossSettleBankData->accountType : '', + 'GrossSettleRoutingNumber' => !empty($grossBilling->grossSettleBankData->routingNumber) ? $grossBilling->grossSettleBankData->routingNumber : '' + ]; + + $this->createNewElements($xml, $transaction, $propertyElementMap); + } + + private function hydrateAccountPermissions($xml, $xmlTrans, AccountPermissions $accountPermissions) + { + $propertyElementMap = [ + 'ACHIn' => !empty($accountPermissions->achIn) ? $accountPermissions->achIn : '', + 'ACHOut' => !empty($accountPermissions->achOut) ? $accountPermissions->achOut : '', + 'CCProcessing' => !empty($accountPermissions->ccProcessing) ? $accountPermissions->ccProcessing : '', + 'ProPayIn' => !empty($accountPermissions->proPayIn) ? $accountPermissions->proPayIn : '', + 'ProPayOut' => !empty($accountPermissions->proPayOut) ? $accountPermissions->proPayOut : '', + 'CreditCardMonthLimit' => !empty($accountPermissions->creditCardMonthLimit) ? $accountPermissions->creditCardMonthLimit : '', + 'CreditCardTransactionLimit' => !empty($accountPermissions->creditCardTransactionLimit) ? $accountPermissions->creditCardTransactionLimit : '', + 'MerchantOverallStatus' => !empty($accountPermissions->merchantOverallStatus) ? $accountPermissions->merchantOverallStatus : '', + 'SoftLimitEnabled' => !empty($accountPermissions->softLimitEnabled) ? $accountPermissions->softLimitEnabled : '', + 'AchPaymentSoftLimitEnabled' => !empty($accountPermissions->achPaymentSoftLimitEnabled) ? $accountPermissions->achPaymentSoftLimitEnabled : '', + 'SoftLimitAchOffPercent' => !empty($accountPermissions->softLimitAchOffPercent) ? $accountPermissions->softLimitAchOffPercent : '', + 'AchPaymentAchOffPercent' => !empty($accountPermissions->achPaymentAchOffPercent) ? $accountPermissions->achPaymentAchOffPercent : '', + ]; + + $this->createNewElements($xml, $xmlTrans, $propertyElementMap); + } + + private function createNewElements($xml, $transaction, $mapping) + { + foreach ($mapping as $tagName => $value) { + if (!is_null($value) && $value !== '') { + $transaction->appendChild($xml->createElement($tagName, $value)); + } + } + } + + private function setx509Certificate($certX509File) + { + try { + $cert = file_get_contents($certX509File); + return base64_encode($cert); + } catch (\Exception $e) { + throw new GatewayException( + 'X509 certificate error: ', + $e->getCode(), + $e->getMessage(), + $e + ); + } + } + + private function updateGatewaySettings($builder) + { + $certTransactions = [ + TransactionType::EDIT, + TransactionType::OBTAIN_SSO_KEY, + TransactionType::UPDATE_BANK_ACCOUNT_OWNERSHIP, + TransactionType::ADD_FUNDS, + TransactionType::ADD_CARD_FLASH_FUNDS, + ]; + + if (in_array($builder->transactionType, $certTransactions)) { + $this->headers['X509Certificate'] = $this->setx509Certificate($this->selfSignedCert); + } + } + + private function hydrateUploadDocument($xml, $xmlTrans, UploadDocumentData $uploadDocumentData) + { + $fileType = pathinfo($uploadDocumentData->documentLocation, PATHINFO_EXTENSION); + $elementMap = [ + 'DocumentName' => !empty($uploadDocumentData->documentName) ? $uploadDocumentData->documentName : '', + 'TransactionReference' => !empty($uploadDocumentData->transactionReference) ? $uploadDocumentData->transactionReference : '', + 'DocType' => $fileType, + 'Document' => base64_encode(file_get_contents($uploadDocumentData->documentLocation)), + 'DocCategory' => !empty($uploadDocumentData->documentCategory) ? $uploadDocumentData->documentCategory : '', + ]; + $this->createNewElements($xml, $xmlTrans, $elementMap); + } + + private function hydrateSingleSignOnData($xml, $xmlTrans, SingleSignOnData $singleSignOnData) + { + $elementMap = [ + 'ReferrerUrl' => !empty($singleSignOnData->referrerUrl) ? $singleSignOnData->referrerUrl : '', + 'IpAddress' => !empty($singleSignOnData->ipAddress) ? $singleSignOnData->ipAddress : '', + 'IpSubnetMask' => !empty($singleSignOnData->ipSubnetMask) ? $singleSignOnData->ipSubnetMask : '', + ]; + $this->createNewElements($xml, $xmlTrans, $elementMap); + } + + private function updateBankAccountOwnershipInfo($xml, $xmLtransaction, $beneficialOwnerData) + { + $ownerDetails = $xml->createElement('BankAccountOwnerData'); + + if (!empty($beneficialOwnerData->ownersList)) { + foreach ($beneficialOwnerData->ownersList as $key => $ownerInfo) { + $ownerType = ($key === 0) ? 'PrimaryBankAccountOwner' : 'SecondaryBankAccountOwner'; + $newOwner = $xml->createElement($ownerType); + + $elements = [ + 'FirstName' => !empty($ownerInfo->firstName) ? $ownerInfo->firstName : '', + 'LastName' => !empty($ownerInfo->lastName) ? $ownerInfo->lastName : '', + 'Address1' => !empty($ownerInfo->ownerAddress->streetAddress1) ? $ownerInfo->ownerAddress->streetAddress1 : '', + 'Address2' => !empty($ownerInfo->ownerAddress->streetAddress2) ? $ownerInfo->ownerAddress->streetAddress2 : '', + 'Address3' => !empty($ownerInfo->ownerAddress->streetAddress3) ? $ownerInfo->ownerAddress->streetAddress3 : '', + 'City' => !empty($ownerInfo->ownerAddress->city) ? $ownerInfo->ownerAddress->city : '', + 'StateProvince' => !empty($ownerInfo->ownerAddress->state) ? $ownerInfo->ownerAddress->state : '', + 'PostalCode' => !empty($ownerInfo->ownerAddress->postalCode) ? $ownerInfo->ownerAddress->postalCode : '', + 'Country' => !empty($ownerInfo->ownerAddress->country) ? $ownerInfo->ownerAddress->country : '', + 'Phone' => !empty($ownerInfo->phone) ? $ownerInfo->phone : '', + ]; + + $this->createNewElements($xml, $newOwner, $elements); + $ownerDetails->appendChild($newOwner); + } + } + + $xmLtransaction->appendChild($ownerDetails); + } + + private function hydrateCommonFields($xml, $xmlTrans, $builder) + { + $elementMap = [ + 'accountNum' => !empty($builder->accountNumber) ? $builder->accountNumber : '', + 'amount' => !empty($builder->amount) ? $builder->amount : '', + 'recAccntNum' => !empty($builder->receivingAccountNumber) ? $builder->receivingAccountNumber : '', + 'allowPending' => !empty($builder->allowPending) ? 'Y' : '', + 'ccAmount' => !empty($builder->ccAmount) ? $builder->ccAmount : '', + 'requireCCRefund' => !empty($builder->requireCCRefund) ? 'Y' : 'N', + 'transNum' => !empty($builder->transNum) ? $builder->transNum : '' + ]; + $this->createNewElements($xml, $xmlTrans, $elementMap); + } + + private function hydrateFlashFundsData($xml, $xmlTrans, FlashFundsPaymentCardData $flashFundsData) + { + $elementMap = [ + 'ccNum' => !empty($flashFundsData->creditCard->number) ? $flashFundsData->creditCard->number : '', + 'expDate' => !empty($flashFundsData->creditCard->expMonth) ? $flashFundsData->creditCard->getShortExpiry() : '', + 'CVV2' => !empty($flashFundsData->creditCard->cvn) ? $flashFundsData->creditCard->cvn : '', + 'cardholderName' => !empty($flashFundsData->creditCard->cardHolderName) ? $flashFundsData->creditCard->cardHolderName : '', + 'addr' => !empty($flashFundsData->cardholderAddress->streetAddress1) ? $flashFundsData->cardholderAddress->streetAddress1 : '', + 'city' => !empty($flashFundsData->cardholderAddress->city) ? $flashFundsData->cardholderAddress->city : '', + 'state' => !empty($flashFundsData->cardholderAddress->state) ? $flashFundsData->cardholderAddress->state : '', + 'zip' => !empty($flashFundsData->cardholderAddress->postalCode) ? $flashFundsData->cardholderAddress->postalCode : '', + ]; + $this->createNewElements($xml, $xmlTrans, $elementMap); + } + + private function populateProPayResponse($root) + { + $propayResponse = new PayFacResponseData(); + $propayResponse->password = (!empty($root->password)) ? (string) $root->password : ''; + $propayResponse->sourceEmail = (!empty($root->sourceEmail)) ? (string) $root->sourceEmail : ''; + $propayResponse->authToken = (!empty($root->AuthToken)) ? (string) $root->AuthToken : ''; + $propayResponse->recAccountNum = !empty($root->recAccntNum) ? (string) $root->recAccntNum : ''; + $propayResponse->amount = !empty($root->amount) ? (string) $root->amount : ''; + $propayResponse->transNum = !empty($root->transNum) ? (string) $root->transNum : ''; + $propayResponse->pending = !empty($root->pending) ? (string) $root->pending : ''; + $propayResponse->secondaryAmount = !empty($root->secondaryAmount) ? (string) $root->secondaryAmount : ''; + $propayResponse->secondaryTransNum = !empty($root->secondaryTransNum) ? (string) $root->secondaryTransNum : ''; + $propayResponse->accountStatus = !empty($root->accntStatus) ? (string) $root->accntStatus : ''; + $propayResponse->affiliation = !empty($root->affiliation) ? (string) $root->affiliation : ''; + $propayResponse->aPIReady = !empty($root->apiReady) ? (string) $root->apiReady : ''; + $propayResponse->currencyCode = !empty($root->currencyCode) ? (string) $root->currencyCode : ''; + $propayResponse->expiration = !empty($root->expiration) ? (string) $root->expiration : ''; + $propayResponse->signupDate = !empty($root->signupDate) ? (string) $root->signupDate : ''; + $propayResponse->visaCheckoutMerchantID = !empty($root->visaCheckoutMerchantId) ? (string) $root->visaCheckoutMerchantId : ''; + $propayResponse->creditCardTransactionLimit = !empty($root->CreditCardTransactionLimit) ? (string) $root->CreditCardTransactionLimit : ''; + $propayResponse->creditCardMonthLimit = !empty($root->CreditCardMonthLimit) ? (string) $root->CreditCardMonthLimit : ''; + $propayResponse->aCHPaymentPerTranLimit = !empty($root->ACHPaymentPerTranLimit) ? (string) $root->ACHPaymentPerTranLimit : ''; + $propayResponse->aCHPaymentMonthLimit = !empty($root->ACHPaymentMonthLimit) ? (string) $root->ACHPaymentMonthLimit : ''; + $propayResponse->creditCardMonthlyVolume = !empty($root->CreditCardMonthlyVolume) ? (string) $root->CreditCardMonthlyVolume : ''; + $propayResponse->aCHPaymentMonthlyVolume = !empty($root->ACHPaymentMonthlyVolume) ? (string) $root->ACHPaymentMonthlyVolume : ''; + $propayResponse->reserveBalance = !empty($root->ReserveBalance) ? (string) $root->ReserveBalance : ''; + $propayResponse->masterPassCheckoutMerchantID = !empty($root->MasterPassCheckoutMerchantId) ? (string) $root->MasterPassCheckoutMerchantId : ''; + $propayResponse->pendingAmount = !empty($root->pendingAmount) ? (string) $root->pendingAmount : ''; + $propayResponse->reserveAmount = !empty($root->reserveAmount) ? (string) $root->reserveAmount : ''; + + $propayResponse->physicalAddress->streetAddress1 = !empty($root->addr) ? (string) $root->addr : ''; + $propayResponse->physicalAddress->city = !empty($root->city) ? (string) $root->city : ''; + $propayResponse->physicalAddress->state = !empty($root->state) ? (string) $root->state : ''; + $propayResponse->physicalAddress->postalCode = !empty($root->zip) ? (string) $root->zip : ''; + + if (!empty($root->accntNum)) { + $propayResponse->accountNumber = (string) $root->accntNum; + } elseif (!empty($root->accountNum)) { + $propayResponse->accountNumber = (string) $root->accountNum; + } + + if (!empty($root->achOut)) { + $propayResponse->aCHOut->enabled = !empty($root->achOut->enabled) ? (string) $root->achOut->enabled : ''; + $propayResponse->aCHOut->limitRemaining = !empty($root->achOut->limitRemaining) ? (string) $root->achOut->limitRemaining : ''; + $propayResponse->aCHOut->transferFee = !empty($root->achOut->transferFee) ? (string) $root->achOut->transferFee : ''; + $propayResponse->aCHOut->feeType = !empty($root->achOut->feeType) ? (string) $root->achOut->feeType : ''; + $propayResponse->aCHOut->accountLastFour = !empty($root->achOut->accountLastFour) ? (string) $root->achOut->accountLastFour : ''; + } + + if (!empty($root->flashFunds)) { + $propayResponse->flashFunds->enabled = !empty($root->flashFunds->enabled) ? (string) $root->flashFunds->enabled : ''; + $propayResponse->flashFunds->limitRemaining = !empty($root->flashFunds->limitRemaining) ? (string) $root->flashFunds->limitRemaining : ''; + $propayResponse->flashFunds->transferFee = !empty($root->flashFunds->transferFee) ? (string) $root->flashFunds->transferFee : ''; + $propayResponse->flashFunds->feeType = !empty($root->flashFunds->feeType) ? (string) $root->flashFunds->feeType : ''; + $propayResponse->flashFunds->accountLastFour = !empty($root->flashFunds->accountLastFour) ? (string) $root->flashFunds->accountLastFour : ''; + } + + if (!empty($root->beneficialOwnerDataResult->Owner)) { + foreach ($root->beneficialOwnerDataResult->Owner as $owner) { + $ownerDetails = new OwnerDetailsResponseData(); + $ownerDetails->firstName = (string) $owner->FirstName; + $ownerDetails->lastName = (string) $owner->LastName; + $ownerDetails->validationStatus = (string) $owner->Status; + $propayResponse->beneficialOwnerDataResult[] = $ownerDetails; + } + } + + return $propayResponse; + } +} diff --git a/src/PaymentMethods/GiftCard.php b/src/PaymentMethods/GiftCard.php index bf12f0c1..0d9773c7 100644 --- a/src/PaymentMethods/GiftCard.php +++ b/src/PaymentMethods/GiftCard.php @@ -252,5 +252,5 @@ public function __set($name, $value) $this->valueType = 'TrackData'; return; } - } + } } diff --git a/src/PaymentMethods/RecurringPaymentMethod.php b/src/PaymentMethods/RecurringPaymentMethod.php index b0e22856..4591c538 100644 --- a/src/PaymentMethods/RecurringPaymentMethod.php +++ b/src/PaymentMethods/RecurringPaymentMethod.php @@ -104,6 +104,13 @@ class RecurringPaymentMethod extends RecurringEntity implements */ public $status; + /** + * eCheck Sec Code value + * + * @var string + */ + public $secCode; + /** * The payment method's tax type * diff --git a/src/ServiceConfigs/AcceptorConfig.php b/src/ServiceConfigs/AcceptorConfig.php index f8416900..45bee646 100644 --- a/src/ServiceConfigs/AcceptorConfig.php +++ b/src/ServiceConfigs/AcceptorConfig.php @@ -96,7 +96,8 @@ public function __construct( $this->terminalOutputCapability = $terminalOutputCapability; } - public function validate() { + public function validate() + { // for use in future gateway integrations } } diff --git a/src/ServiceConfigs/Configuration.php b/src/ServiceConfigs/Configuration.php index 050ddf90..e29d2fcc 100644 --- a/src/ServiceConfigs/Configuration.php +++ b/src/ServiceConfigs/Configuration.php @@ -30,7 +30,8 @@ abstract public function configureContainer(ConfiguredServices $services); /** @var bool */ public $forceGatewayTimeout; - public function validate() { + public function validate() + { $this->validated = true; } } diff --git a/src/ServiceConfigs/Gateways/PorticoConfig.php b/src/ServiceConfigs/Gateways/PorticoConfig.php index 219b79b8..40462f51 100644 --- a/src/ServiceConfigs/Gateways/PorticoConfig.php +++ b/src/ServiceConfigs/Gateways/PorticoConfig.php @@ -9,6 +9,7 @@ use GlobalPayments\Api\Entities\Enums\ServiceEndpoints; use GlobalPayments\Api\Gateways\PayPlanConnector; use GlobalPayments\Api\Gateways\PorticoConnector; +use GlobalPayments\Api\Gateways\ProPayConnector; class PorticoConfig extends GatewayConfig { @@ -25,6 +26,11 @@ class PorticoConfig extends GatewayConfig public $versionNumber; public $secretApiKey; public $uniqueDeviceId; + + //ProPay + public $certificationStr; + public $selfSignedCertLocation; + public $proPayUS = true; public function getPayPlanEndpoint() { @@ -89,6 +95,24 @@ public function configureContainer(ConfiguredServices $services) $payplan->serviceUrl = $this->serviceUrl . $this->getPayPlanEndpoint(); $services->recurringConnector = $payplan; + + //propay connector + if (!empty($this->certificationStr)) { + if ($this->environment === Environment::TEST) { + $this->serviceUrl = ($this->proPayUS) ? ServiceEndpoints::PROPAY_TEST : ServiceEndpoints::PROPAY_TEST_CANADIAN; + } else { + $this->serviceUrl = ($this->proPayUS) ? ServiceEndpoints::PROPAY_PRODUCTION : ServiceEndpoints::PROPAY_PRODUCTION_CANADIAN; + } + + $payFac = new ProPayConnector(); + $payFac->certStr = $this->certificationStr; + $payFac->termId = $this->terminalId; + $payFac->timeout = $this->timeout; + $payFac->serviceUrl = $this->serviceUrl; + $payFac->selfSignedCert = $this->selfSignedCertLocation; + + $services->setPayFacProvider($payFac); + } } public function validate() diff --git a/src/Services/PayFacService.php b/src/Services/PayFacService.php new file mode 100644 index 00000000..8933a11d --- /dev/null +++ b/src/Services/PayFacService.php @@ -0,0 +1,146 @@ +getPayFacProvider(); + if ($provider != null) { + return $provider; + } + throw new ConfigurationException('payFacProvider is not configured'); + } } diff --git a/test/Integration/Gateways/ProPay/ProPayAccountTests.php b/test/Integration/Gateways/ProPay/ProPayAccountTests.php new file mode 100644 index 00000000..e82c17de --- /dev/null +++ b/test/Integration/Gateways/ProPay/ProPayAccountTests.php @@ -0,0 +1,290 @@ +getConfig()); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->certificationStr = '5dbacb0fc504dd7bdc2eadeb7039dd'; + $config->terminalId = '7039dd'; + $config->environment = Environment::TEST; + $config->selfSignedCertLocation = __DIR__ . '/TestData/selfSignedCertificate.crt'; + return $config; + } + + public function testCreateAccount() + { + $bankAccountInformation = TestAccountData::getBankAccountData(); + $userBusinessInformation = TestAccountData::getBusinessData(); + $accountPersonalInformation = TestAccountData::getUserPersonalData(); + $threatRiskData = TestAccountData::getThreatRiskData(); + $significantOwnerData = TestAccountData::getSignificantOwnerData(); + $ownersInformation = TestAccountData::getBeneficialOwnerData(); + $creditCardInformation = TestAccountData::getCreditCardData(); + $achInformation = TestAccountData::getACHData(); + $secondaryBankInformation = TestAccountData::getSecondaryBankAccountData(); + + $response = PayFacService::createAccount() + ->withBankAccountData($bankAccountInformation) + ->withBusinessData($userBusinessInformation) + ->withUserPersonalData($accountPersonalInformation) + ->withThreatRiskData($threatRiskData) + ->withSignificantOwnerData($significantOwnerData) + ->withBeneficialOwnerData($ownersInformation) + ->withCreditCardData($creditCardInformation) + ->withACHData($achInformation) + ->withSecondaryBankAccountData($secondaryBankInformation) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->payFacData->accountNumber); + $this->assertNotNull($response->payFacData->password); + $this->assertNotNull($response->payFacData->sourceEmail); + } + + public function testEditAccountInformation() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718138433) + ->withUserPersonalData(TestAccountData::editUserPersonalData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditPassword() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718138433) + ->withPassword('testPwd_'.rand(1, 100)) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditAddress() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718138433) + ->withUserPersonalData(TestAccountData::editAddressData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditAccountPermissions() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718136530) + ->withAccountPermissions(TestAccountData::editAccountPermissions()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditPrimaryBankAccount() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718150930) + ->withBankAccountData(TestAccountData::editBankData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditSecondaryBankAccount() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718150930) + ->withSecondaryBankAccountData(TestAccountData::editBankData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditBusinessData() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718150930) + ->withBusinessData(TestAccountData::getBusinessData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditCreditCard() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718138433) + ->withCreditCardData(TestAccountData::getCreditCardData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditRenewalInformation() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718138433) + ->withACHData(TestAccountData::editACHData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testEditNegativeLimit() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718136530) + ->withNegativeLimit(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testResetPassword() + { + $response = PayFacService::resetPassword() + ->withAccountNumber(718150930) + ->withNegativeLimit(1) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->payFacData->password); + } + + public function testRenewAccount() + { + $response = PayFacService::renewAccount() + ->withAccountNumber(718151055) + ->withRenewalAccountData(TestAccountData::getRenewAccountDetails()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testUpdateBeneficialOwnerData() + { + //Owners count shoud not be excedded 6 + $response = PayFacService::updateBeneficialOwnershipInfo() + ->withAccountNumber(718151188) + ->withBeneficialOwnerData(TestAccountData::getBeneficialOwnerData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->payFacData->beneficialOwnerDataResult); + } + + public function testDisownAccount() + { + //Enter active account number + $response = PayFacService::disownAccount() + ->withAccountNumber(718150922) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testUploadChargebackDocument() + { + $documentDetails = new UploadDocumentData(); + $documentDetails->transactionReference = '123456789'; + $documentDetails->documentName = 'ChargebackDispute'; + $documentDetails->documentLocation = __DIR__ . '/TestData/ChargebackDispute.jpg'; + + $response = PayFacService::uploadDocumentChargeback() + ->withAccountNumber(718134349) + ->withUploadDocumentData($documentDetails) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testUnderwriteDocument() + { + $documentDetails = new UploadDocumentData(); + $documentDetails->documentCategory = 'Verification'; + $documentDetails->documentName = 'ChargebackDispute'; + $documentDetails->documentLocation = __DIR__ . '/TestData/ChargebackDispute.jpg'; + + $response = PayFacService::uploadDocument() + ->withAccountNumber(718150930) + ->withUploadDocumentData($documentDetails) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testObtainSSOKey() + { + $singleSignOnData = new SingleSignOnData(); + $singleSignOnData->referrerUrl = 'https://www.globalpaymentsinc.com/'; + $singleSignOnData->ipAddress = '40.81.11.219'; + $singleSignOnData->ipSubnetMask = '255.255.255.0'; + + $response = PayFacService::obtainSSOKey() + ->withAccountNumber(718150930) + ->withSingleSignOnData($singleSignOnData) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + $this->assertNotNull($response->payFacData->authToken); + } + + public function testUpdateBankAccountOwnershipInfo() + { + $response = PayFacService::updateBankAccountOwnershipInfo() + ->withAccountNumber(718136530) + ->withBeneficialOwnerData(TestAccountData::getBeneficialOwnerData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } + + public function testUpdateGrossBillingInfo() + { + $response = PayFacService::editAccount() + ->withAccountNumber(718151524) + ->withGrossBillingSettleData(TestAccountData::getGrossBillingSettleData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals('00', $response->responseCode); + } +} diff --git a/test/Integration/Gateways/ProPay/ProPayFundsTests.php b/test/Integration/Gateways/ProPay/ProPayFundsTests.php new file mode 100644 index 00000000..e467dd9a --- /dev/null +++ b/test/Integration/Gateways/ProPay/ProPayFundsTests.php @@ -0,0 +1,74 @@ +getConfig()); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->certificationStr = '5dbacb0fc504dd7bdc2eadeb7039dd'; + $config->terminalId = '7039dd'; + $config->environment = Environment::TEST; + $config->selfSignedCertLocation = __DIR__ . '/TestData/selfSignedCertificate.crt'; + return $config; + } + + public function testAddFunds() + { + $response = PayFacService::addFunds() + ->withAccountNumber("718136438") + ->withAmount("300") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + + public function testSweepFunds() + { + $response = PayFacService::sweepFunds() + ->withAccountNumber("718136438") + ->withAmount("10") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + public function testAddFlashFundsPaymentCard() + { + $response = PayFacService::addCardFlashFunds() + ->withAccountNumber("718136438") + ->withFlashFundsPaymentCardData(TestFundsData::getFlashFundsData()) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + public function testPushMoneyToFlashFundsCard() + { + $response = PayFacService::pushMoneyToFlashFundsCard() + ->withAccountNumber("718136438") + ->withAmount("100") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } +} diff --git a/test/Integration/Gateways/ProPay/ProPayGetInformationTests.php b/test/Integration/Gateways/ProPay/ProPayGetInformationTests.php new file mode 100644 index 00000000..0d14ea3e --- /dev/null +++ b/test/Integration/Gateways/ProPay/ProPayGetInformationTests.php @@ -0,0 +1,73 @@ +getConfig()); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->certificationStr = '5dbacb0fc504dd7bdc2eadeb7039dd'; + $config->terminalId = '7039dd'; + $config->environment = Environment::TEST; + $config->selfSignedCertLocation = __DIR__ . '/TestData/selfSignedCertificate.crt'; + return $config; + } + + public function testGetAccountInfo() + { + $response = PayFacService::getAccountDetails() + ->withAccountNumber("718136438") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + + public function testGetAccountBalance() + { + $response = PayFacService::getAccountBalance() + ->withAccountNumber("718136438") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + $this->assertNotNull($response->payFacData->flashFunds); + $this->assertNotNull($response->payFacData->aCHOut); + } + + public function testGetAccountInfoExternalId() + { + $response = PayFacService::getAccountDetails() + ->withExternalId("1") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + + public function testGetAccountInfoSourceEmail() + { + $response = PayFacService::getAccountDetails() + ->withSourceEmail("user4804@user.com") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + +} diff --git a/test/Integration/Gateways/ProPay/ProPayNetworkTests.php b/test/Integration/Gateways/ProPay/ProPayNetworkTests.php new file mode 100644 index 00000000..5f1a663b --- /dev/null +++ b/test/Integration/Gateways/ProPay/ProPayNetworkTests.php @@ -0,0 +1,82 @@ +getConfig()); + } + + protected function getConfig() + { + $config = new PorticoConfig(); + $config->certificationStr = '5dbacb0fc504dd7bdc2eadeb7039dd'; + $config->terminalId = '7039dd'; + $config->environment = Environment::TEST; + $config->selfSignedCertLocation = __DIR__ . '/TestData/selfSignedCertificate.crt'; + return $config; + } + + public function testDisburseFunds() + { + // This method in the ProPay API requires a different, special CertificationStr value from a disbursement account + $response = PayFacService::disburseFunds() + ->withReceivingAccountNumber("718136438") + ->withAmount("100") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + public function testSpendBackTransaction() + { + $response = PayFacService::spendBack() + ->withAccountNumber("718037672") + ->withReceivingAccountNumber("718136438") + ->withAmount("100") + ->withAllowPending(false) + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } + + public function testReverseSplitPay() + { + $response = PayFacService::reverseSplitPay() + ->withAccountNumber("718136438") + ->withAmount("3") + ->withCCAmount("1") + ->withRequireCCRefund(false) + ->withTransNum("35") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + $this->assertNotNull($response->payFacData->amount); + $this->assertNotNull($response->payFacData->recAccountNum); + $this->assertNotNull($response->payFacData->transNum); + } + + public function testSplitFunds() + { + $response = PayFacService::splitFunds() + ->withAccountNumber("718136438") + ->withReceivingAccountNumber("718134204") + ->withAmount("3") + ->withTransNum("35") + ->execute(); + + $this->assertNotNull($response); + $this->assertEquals("00", $response->responseCode); + } +} diff --git a/test/Integration/Gateways/ProPay/TestData/ChargebackDispute.jpg b/test/Integration/Gateways/ProPay/TestData/ChargebackDispute.jpg new file mode 100644 index 00000000..03c7e470 Binary files /dev/null and b/test/Integration/Gateways/ProPay/TestData/ChargebackDispute.jpg differ diff --git a/test/Integration/Gateways/ProPay/TestData/TestAccountData.php b/test/Integration/Gateways/ProPay/TestData/TestAccountData.php new file mode 100644 index 00000000..2ec1fcdf --- /dev/null +++ b/test/Integration/Gateways/ProPay/TestData/TestAccountData.php @@ -0,0 +1,304 @@ +accountCountryCode = 'USA'; + $bankAccountInformation->accountName = 'MyBankAccount'; + $bankAccountInformation->accountNumber = '123456789'; + $bankAccountInformation->accountOwnershipType = 'Personal'; + $bankAccountInformation->accountType = 'C'; + $bankAccountInformation->routingNumber = '102000076'; + + return $bankAccountInformation; + } + public static function getBusinessData() + { + $userBusinessInformation = new BusinessData(); + $userBusinessInformation->businessLegalName = 'Twain Enterprises'; + $userBusinessInformation->doingBusinessAs = 'Twain Enterprises'; + $userBusinessInformation->employerIdentificationNumber = 987654321;//mt_rand(100000000, 999999999); + $userBusinessInformation->businessDescription = 'Accounting Services'; + $userBusinessInformation->websiteURL = 'https://www.Propay.com'; + $userBusinessInformation->merchantCategoryCode = '5399'; + $userBusinessInformation->monthlyBankCardVolume = 50000; + $userBusinessInformation->averageTicket = 100; + $userBusinessInformation->highestTicket = 300; + $userBusinessInformation->businessAddress->streetAddress1 = '3400 Ashton Blvd'; + $userBusinessInformation->businessAddress->city = 'Lehi'; + $userBusinessInformation->businessAddress->state = 'UT'; + $userBusinessInformation->businessAddress->postalCode = '84045'; + $userBusinessInformation->businessAddress->country = 'USA'; + + return $userBusinessInformation; + } + public static function getUserPersonalData() + { + $accountPersonalInformation = new UserPersonalData(); + $accountPersonalInformation->dayPhone = 4464464464; + $accountPersonalInformation->eveningPhone = 4464464464; + $accountPersonalInformation->externalId = uniqid(); + $accountPersonalInformation->firstName = 'David'; + $accountPersonalInformation->lastName = 'Tennant'; + $accountPersonalInformation->phonePin = 1234; + $accountPersonalInformation->sourceEmail = sprintf("user%s@user.com", mt_rand(1, 10000)); + $accountPersonalInformation->notificationEmail = sprintf("user%s@user.com", mt_rand(1, 10000)); + $accountPersonalInformation->ssn = 123456789; + $accountPersonalInformation->dateOfBirth = '01-01-1981'; + $accountPersonalInformation->tier = 'TestEIN'; + + $accountPersonalInformation->userAddress->streetAddress1 = '123 Main St.'; + $accountPersonalInformation->userAddress->city = 'Downtown'; + $accountPersonalInformation->userAddress->state = 'NJ'; + $accountPersonalInformation->userAddress->postalCode = '12345'; + $accountPersonalInformation->userAddress->country = 'USA'; + + $accountPersonalInformation->mailingAddress->streetAddress1 = '123 Main St.'; + $accountPersonalInformation->mailingAddress->city = 'Downtown'; + $accountPersonalInformation->mailingAddress->state = 'NJ'; + $accountPersonalInformation->mailingAddress->postalCode = '12345'; + $accountPersonalInformation->mailingAddress->country = 'USA'; + + return $accountPersonalInformation; + } + public static function getThreatRiskData() + { + $threatRiskData = new ThreatRiskData(); + $threatRiskData->merchantSourceIp = '8.8.8.8'; + $threatRiskData->threatMetrixPolicy = 'Default'; + $threatRiskData->threatMetrixSessionId = 'dad889c1-1ca4-4fq71-8f6f-807eb4408bc7'; + + return $threatRiskData; + } + + public static function getSignificantOwnerData() + { + $significantOwnerData = new SignificantOwnerData(); + $significantOwnerData->authorizedSignerFirstName = 'John'; + $significantOwnerData->authorizedSignerLastName = 'Doe'; + $significantOwnerData->authorizedSignerTitle = 'Director'; + + $significantOwnerData->significantOwnerData->firstName = 'John'; + + return $significantOwnerData; + } + + public static function getBeneficialOwnerData() + { + $ownersInformation = new BeneficialOwnerData(); + $firstOwnerInformation = new OwnersData(); + $firstOwnerInformation->firstName = 'Scott'; + $firstOwnerInformation->lastName = 'Sterling'; + $firstOwnerInformation->title = 'USA'; + $firstOwnerInformation->email = 'TwainEnterprises@Twain.com'; + $firstOwnerInformation->dateOfBirth = '11-11-1988'; + $firstOwnerInformation->ssn = 123456789; + $firstOwnerInformation->percentage = 100; + $firstOwnerInformation->ownerAddress->streetAddress1 = '123 Address'; + $firstOwnerInformation->ownerAddress->streetAddress2 = 'Second'; + $firstOwnerInformation->ownerAddress->streetAddress3 = 'Floor'; + $firstOwnerInformation->ownerAddress->city = 'Lehi'; + $firstOwnerInformation->ownerAddress->state = 'UT'; + $firstOwnerInformation->ownerAddress->postalCode = '84045'; + $firstOwnerInformation->ownerAddress->country = 'USA'; + $firstOwnerInformation->phone = '12233445'; + + $secondOwnerInformation = new OwnersData(); + $secondOwnerInformation->firstName = 'First4'; + $secondOwnerInformation->lastName = 'Last4'; + $secondOwnerInformation->title = 'Director'; + $secondOwnerInformation->email = 'abc1@qamail.com'; + $secondOwnerInformation->dateOfBirth = '11-11-1989'; + $secondOwnerInformation->ssn = 123545677; + $secondOwnerInformation->ownerAddress->streetAddress1 = '125 Main St.'; + $secondOwnerInformation->ownerAddress->streetAddress2 = 'Second'; + $secondOwnerInformation->ownerAddress->streetAddress3 = 'Floor'; + $secondOwnerInformation->ownerAddress->city = 'Downtown'; + $secondOwnerInformation->ownerAddress->state = 'NJ'; + $secondOwnerInformation->ownerAddress->postalCode = '12345'; + $secondOwnerInformation->ownerAddress->country = 'USA'; + $secondOwnerInformation->phone = '12233445'; + + $ownersInformation->ownersCount = 5; + $ownersInformation->ownersList = [$firstOwnerInformation, $secondOwnerInformation]; + + return $ownersInformation; + } + + public static function getCreditCardData() + { + $card = new CreditCardData(); + $card->number = '4111111111111111'; + $card->expMonth = 12; + $card->expYear = 2025; + $card->cvn = '123'; + $card->cardHolderName = 'Joe Smith'; + + return $card; + } + + public static function getACHData() + { + $bankAccountInformation = new BankAccountData(); + $bankAccountInformation->accountNumber = '123456789'; + $bankAccountInformation->accountType = 'C'; + $bankAccountInformation->routingNumber = '102000076'; + + return $bankAccountInformation; + } + + public static function getSecondaryBankAccountData() + { + $bankAccountInformation = new BankAccountData(); + $bankAccountInformation->accountCountryCode = 'USA'; + $bankAccountInformation->accountName = 'MyBankAccount'; + $bankAccountInformation->accountNumber = '123456788'; + $bankAccountInformation->accountOwnershipType = 'Personal'; + $bankAccountInformation->accountType = 'C'; + $bankAccountInformation->routingNumber = '102000076'; + + return $bankAccountInformation; + } + + public static function getGrossBillingSettleData() + { + $grossBillingInformation = new GrossBillingInformation(); + + $grossBillingInformation->grossSettleBankData->accountCountryCode = 'USA'; + $grossBillingInformation->grossSettleBankData->accountName = 'Scott Sterling'; + $grossBillingInformation->grossSettleBankData->accountNumber = '111222333'; + $grossBillingInformation->grossSettleBankData->accountOwnershipType = 'Personal'; + $grossBillingInformation->grossSettleBankData->accountType = 'C'; + $grossBillingInformation->grossSettleBankData->routingNumber = '124002971'; + $grossBillingInformation->grossSettleBankData->accountHolderName = 'Scott Sterling'; + + $grossBillingInformation->grossSettleAddress->streetAddress1 = '123 Main St.'; + $grossBillingInformation->grossSettleAddress->city = 'Downtown'; + $grossBillingInformation->grossSettleAddress->state = 'NJ'; + $grossBillingInformation->grossSettleAddress->postalCode = '12345'; + $grossBillingInformation->grossSettleAddress->country = 'USA'; + + $grossBillingInformation->grossSettleCreditCardData->number = '4111111111111111'; + $grossBillingInformation->grossSettleCreditCardData->expMonth = 12; + $grossBillingInformation->grossSettleCreditCardData->expYear = 2025; + $grossBillingInformation->grossSettleCreditCardData->cvn = '123'; + $grossBillingInformation->grossSettleCreditCardData->cardHolderName = 'Joe Smith'; + + + return $grossBillingInformation; + } + + public static function editAccountPermissions() + { + $accountPermissions = new AccountPermissions(); + $accountPermissions->achIn = 'Y'; + $accountPermissions->achOut = 'N'; + $accountPermissions->ccProcessing = 'Y'; + $accountPermissions->proPayIn = 'Y'; + $accountPermissions->proPayOut = 'N'; + $accountPermissions->creditCardMonthLimit = '10000'; + $accountPermissions->creditCardTransactionLimit = '10000'; + $accountPermissions->merchantOverallStatus = ProPayAccountStatus::READY_TO_PROCESS; + $accountPermissions->softLimitEnabled = 'Y'; + $accountPermissions->achPaymentSoftLimitEnabled = 'N'; + $accountPermissions->softLimitAchOffPercent = '100'; //0-499 + $accountPermissions->achPaymentAchOffPercent = '100'; //0-499 + + return $accountPermissions; + } + + public static function editUserPersonalData() + { + $accountPersonalInformation = new UserPersonalData(); + $accountPersonalInformation->dayPhone = 4464464464; + $accountPersonalInformation->eveningPhone = 4464464464; + $accountPersonalInformation->externalId = uniqid(); + $accountPersonalInformation->firstName = 'John'; + $accountPersonalInformation->lastName = 'Doe'; + $accountPersonalInformation->phonePin = 1234; + $accountPersonalInformation->sourceEmail = sprintf("user%s@user.com", mt_rand(1, 10000)); + $accountPersonalInformation->notificationEmail = sprintf("user%s@user.com", mt_rand(1, 10000)); + $accountPersonalInformation->ssn = 123456789; + $accountPersonalInformation->dateOfBirth = '01-01-1981'; + $accountPersonalInformation->tier = 'TestEIN'; + + return $accountPersonalInformation; + } + + public static function editAddressData() + { + $accountPersonalInformation = new UserPersonalData(); + $accountPersonalInformation->userAddress->streetAddress1 = '124 Main St.'; + $accountPersonalInformation->userAddress->city = 'Downtown'; + $accountPersonalInformation->userAddress->state = 'NJ'; + $accountPersonalInformation->userAddress->postalCode = '12345'; + $accountPersonalInformation->userAddress->country = 'USA'; + + $accountPersonalInformation->mailingAddress->streetAddress1 = '125 Main St.'; + $accountPersonalInformation->mailingAddress->city = 'Downtown'; + $accountPersonalInformation->mailingAddress->state = 'NJ'; + $accountPersonalInformation->mailingAddress->postalCode = '12345'; + $accountPersonalInformation->mailingAddress->country = 'USA'; + + return $accountPersonalInformation; + } + + public static function editBankData() + { + $bankAccountInformation = new BankAccountData(); + $bankAccountInformation->accountCountryCode = 'USA'; + $bankAccountInformation->accountName = 'Sterling'; + $bankAccountInformation->accountNumber = '111111111'; + $bankAccountInformation->accountOwnershipType = 'Business'; + //Valid values are: Checking, Savings, and GeneralLedger + $bankAccountInformation->accountType = 'Checking'; + $bankAccountInformation->routingNumber = '91000019'; + $bankAccountInformation->bankName = 'Bank Name'; + + return $bankAccountInformation; + } + + public static function editACHData() + { + $bankAccountInformation = new BankAccountData(); + $bankAccountInformation->accountNumber = '123456789'; + //Valid values are: Checking, Savings, and GeneralLedger + $bankAccountInformation->accountType = 'Savings'; + $bankAccountInformation->routingNumber = '102000076'; + + return $bankAccountInformation; + } + + public static function getRenewAccountDetails() + { + $renewAccountData = new RenewAccountData(); + $renewAccountData->tier = 'TestEIN'; + $renewAccountData->zipCode = '12345'; + $renewAccountData->creditCard->number = '4111111111111111'; + $renewAccountData->creditCard->expMonth = 12; + $renewAccountData->creditCard->expYear = 2025; + $renewAccountData->creditCard->cvn = 123; + $renewAccountData->paymentBankAccountNumber = '123456789'; + $renewAccountData->paymentBankRoutingNumber = '102000076'; + $renewAccountData->paymentBankAccountType = 'Checking'; + + return $renewAccountData; + } +} diff --git a/test/Integration/Gateways/ProPay/TestData/TestFundsData.php b/test/Integration/Gateways/ProPay/TestData/TestFundsData.php new file mode 100644 index 00000000..997c43fd --- /dev/null +++ b/test/Integration/Gateways/ProPay/TestData/TestFundsData.php @@ -0,0 +1,27 @@ +creditCard->number = '4895142232120006'; + $flashFundsData->creditCard->expMonth = 10; + $flashFundsData->creditCard->expYear = 2025; + $flashFundsData->creditCard->cvn = '022'; + $flashFundsData->creditCard->cardHolderName = 'Clint Eastwood'; + + $flashFundsData->cardholderAddress->streetAddress1 = '900 Metro Center Blv'; + $flashFundsData->cardholderAddress->city = 'San Fransisco'; + $flashFundsData->cardholderAddress->state = 'CA'; + $flashFundsData->cardholderAddress->postalCode = '94404'; + $flashFundsData->cardholderAddress->country = 'USA'; + $flashFundsData->cardholderAddress->phone = '12233445'; + + return $flashFundsData; + } +} diff --git a/test/Integration/Gateways/ProPay/TestData/selfSignedCertificate.crt b/test/Integration/Gateways/ProPay/TestData/selfSignedCertificate.crt new file mode 100644 index 00000000..4e5c4d9b --- /dev/null +++ b/test/Integration/Gateways/ProPay/TestData/selfSignedCertificate.crt @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIICpDCCAYygAwIBAgIIS7Y5fijJytIwDQYJKoZIhvcNAQENBQAwETEPMA0GA1UE +AwwGUFJPUEFZMB4XDTE5MDkxOTAwMDAwMFoXDTI5MDkxOTAwMDAwMFowEzERMA8G +A1UEAwwIMTI3LjAuMDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCC +wvq2ho43oeeGX3L9+2aD7bna7qjdLwWumeIpwhPZLa44MeQ5100wy4W2hKk3pOb5 +yaHqyhzoHDriveQnq/EpZJk9m7sizXsxZtBHtt+wghSZjdNhnon3R54SH5J7oEPy +bRSAKXSEzHjN+kCu7W3TmXSLve6YuODnjUpbOcAsHG2wE+zpCoEbe8toH5Tt7g8H +zEc5mJYkkILTq6j9pwDE50r2NVbV3SXwmQ1ifxf54Z9EFB5bQv5cI3+GL/VwlQeJ +diKMGj1rs8zTR8TjbAjVlJbz6bBkFItUsqexgwAHIJZAaU7an8ZamGRlPjf6dp3m +OEu4B47igNj5KOSgCNdRAgMBAAEwDQYJKoZIhvcNAQENBQADggEBAF88u367yrdu +qd3PfEIo2ClaI2QPRIIWKKACMcZDl3z1BzVzNFOZNG2vLcSuKnGRH89tJPCjyxdJ +a0RyDTkXMSLqb5FgUseEjmj3ULAvFqLZNW35PY9mmlmCY+S3CC/bQR4iyPLo8lsR +q0Nl6hlvB440+9zS8UQjtc2957QgcXfD427UJb698gXzsfQcNeaQWy8pNm7FzDfH +TJbo/t6FOpmfR+RMZky9FrlWabInkrkf3w2XJL0uUAYU9jGQa+l/vnZD2KNzs1mO +1EqkS6yB/fsn85mkgGe4Vfbo9GQ/S+KmDujewFA0ma7O03fy1W5v6Amn/nAcFTCd +dVL3BDNEtOM= +-----END CERTIFICATE----- +