-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,469 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace SlevomatCsobGateway\Call\Masterpass; | ||
|
||
use DateTimeImmutable; | ||
use SlevomatCsobGateway\Api\ApiClient; | ||
use SlevomatCsobGateway\Call\PaymentStatus; | ||
use SlevomatCsobGateway\Call\ResultCode; | ||
use SlevomatCsobGateway\Crypto\SignatureDataFormatter; | ||
use SlevomatCsobGateway\Validator; | ||
|
||
class BasicCheckoutRequest | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $merchantId; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $payId; | ||
|
||
/** @var string */ | ||
private $callbackUrl; | ||
|
||
public function __construct( | ||
string $merchantId, | ||
string $payId, | ||
string $callbackUrl | ||
) | ||
{ | ||
Validator::checkPayId($payId); | ||
Validator::checkReturnUrl($callbackUrl); | ||
|
||
$this->merchantId = $merchantId; | ||
$this->payId = $payId; | ||
$this->callbackUrl = $callbackUrl; | ||
} | ||
|
||
public function send(ApiClient $apiClient): CheckoutResponse | ||
{ | ||
$requestData = [ | ||
'merchantId' => $this->merchantId, | ||
'payId' => $this->payId, | ||
'callbackUrl' => $this->callbackUrl, | ||
]; | ||
|
||
$response = $apiClient->post( | ||
'masterpass/basic/checkout', | ||
$requestData, | ||
new SignatureDataFormatter([ | ||
'merchantId' => null, | ||
'payId' => null, | ||
'dttm' => null, | ||
'callbackUrl' => null, | ||
]), | ||
new SignatureDataFormatter([ | ||
'payId' => null, | ||
'dttm' => null, | ||
'resultCode' => null, | ||
'resultMessage' => null, | ||
'paymentStatus' => null, | ||
'lightboxParams' => [ | ||
'requestToken' => null, | ||
'callbackUrl' => null, | ||
'merchantCheckoutId' => null, | ||
'allowedCardTypes' => null, | ||
'suppressShippingAddressEnable' => null, | ||
'loyaltyEnabled' => null, | ||
'version' => null, | ||
'shippingLocationProfile' => null, | ||
], | ||
]) | ||
); | ||
|
||
$data = $response->getData(); | ||
|
||
return new CheckoutResponse( | ||
$data['payId'], | ||
DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']), | ||
ResultCode::get($data['resultCode']), | ||
$data['resultMessage'], | ||
isset($data['paymentStatus']) ? PaymentStatus::get($data['paymentStatus']) : null, | ||
$data['lightboxParams'] ?? null | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace SlevomatCsobGateway\Call\Masterpass; | ||
|
||
use DateTimeImmutable; | ||
use SlevomatCsobGateway\Api\ApiClient; | ||
use SlevomatCsobGateway\Call\PaymentResponse; | ||
use SlevomatCsobGateway\Call\PaymentStatus; | ||
use SlevomatCsobGateway\Call\ResultCode; | ||
use SlevomatCsobGateway\Crypto\SignatureDataFormatter; | ||
use SlevomatCsobGateway\Validator; | ||
|
||
class BasicFinishRequest | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $merchantId; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $payId; | ||
|
||
/** @var mixed[] */ | ||
private $callbackParams; | ||
|
||
/** | ||
* @param string $merchantId | ||
* @param string $payId | ||
* @param mixed[] $callbackParams | ||
*/ | ||
public function __construct( | ||
string $merchantId, | ||
string $payId, | ||
array $callbackParams | ||
) | ||
{ | ||
Validator::checkPayId($payId); | ||
|
||
$this->merchantId = $merchantId; | ||
$this->payId = $payId; | ||
$this->callbackParams = $callbackParams; | ||
} | ||
|
||
public function send(ApiClient $apiClient): PaymentResponse | ||
{ | ||
$requestData = [ | ||
'merchantId' => $this->merchantId, | ||
'payId' => $this->payId, | ||
'callbackParams' => $this->callbackParams, | ||
]; | ||
|
||
$response = $apiClient->post( | ||
'masterpass/basic/finish', | ||
$requestData, | ||
new SignatureDataFormatter([ | ||
'merchantId' => null, | ||
'payId' => null, | ||
'dttm' => null, | ||
'callbackParams' => [ | ||
'mpstatus' => null, | ||
'oauthToken' => null, | ||
'checkoutResourceUrl' => null, | ||
'oauthVerifier' => null, | ||
], | ||
]), | ||
new SignatureDataFormatter([ | ||
'payId' => null, | ||
'dttm' => null, | ||
'resultCode' => null, | ||
'resultMessage' => null, | ||
'paymentStatus' => null, | ||
]) | ||
); | ||
|
||
$data = $response->getData(); | ||
|
||
return new PaymentResponse( | ||
$data['payId'], | ||
DateTimeImmutable::createFromFormat('YmdHis', $data['dttm']), | ||
ResultCode::get($data['resultCode']), | ||
$data['resultMessage'], | ||
isset($data['paymentStatus']) ? PaymentStatus::get($data['paymentStatus']) : null | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace SlevomatCsobGateway\Call\Masterpass; | ||
|
||
use DateTimeImmutable; | ||
use SlevomatCsobGateway\Call\PaymentStatus; | ||
use SlevomatCsobGateway\Call\ResultCode; | ||
use SlevomatCsobGateway\Validator; | ||
|
||
class CheckoutResponse | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $payId; | ||
|
||
/** | ||
* @var DateTimeImmutable | ||
*/ | ||
private $responseDateTime; | ||
|
||
/** | ||
* @var ResultCode | ||
*/ | ||
private $resultCode; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $resultMessage; | ||
|
||
/** | ||
* @var PaymentStatus|null | ||
*/ | ||
private $paymentStatus; | ||
|
||
/** @var mixed[]|null */ | ||
private $lightboxParams; | ||
|
||
/** | ||
* @param string $payId | ||
* @param \DateTimeImmutable $responseDateTime | ||
* @param \SlevomatCsobGateway\Call\ResultCode $resultCode | ||
* @param string $resultMessage | ||
* @param \SlevomatCsobGateway\Call\PaymentStatus|null $paymentStatus | ||
* @param mixed[]|null $lightboxParams | ||
*/ | ||
public function __construct( | ||
string $payId, | ||
DateTimeImmutable $responseDateTime, | ||
ResultCode $resultCode, | ||
string $resultMessage, | ||
?PaymentStatus $paymentStatus, | ||
?array $lightboxParams | ||
) | ||
{ | ||
Validator::checkPayId($payId); | ||
|
||
$this->payId = $payId; | ||
$this->responseDateTime = $responseDateTime; | ||
$this->resultCode = $resultCode; | ||
$this->resultMessage = $resultMessage; | ||
$this->paymentStatus = $paymentStatus; | ||
$this->lightboxParams = $lightboxParams; | ||
} | ||
|
||
public function getPayId(): string | ||
{ | ||
return $this->payId; | ||
} | ||
|
||
public function getResponseDateTime(): DateTimeImmutable | ||
{ | ||
return $this->responseDateTime; | ||
} | ||
|
||
public function getResultCode(): ResultCode | ||
{ | ||
return $this->resultCode; | ||
} | ||
|
||
public function getResultMessage(): string | ||
{ | ||
return $this->resultMessage; | ||
} | ||
|
||
public function getPaymentStatus(): ?PaymentStatus | ||
{ | ||
return $this->paymentStatus; | ||
} | ||
|
||
/** | ||
* @return mixed[]|null | ||
*/ | ||
public function getLightboxParams(): ?array | ||
{ | ||
return $this->lightboxParams; | ||
} | ||
|
||
} |
Oops, something went wrong.