-
Notifications
You must be signed in to change notification settings - Fork 0
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
3b958eb
commit 57f8c2b
Showing
6 changed files
with
94 additions
and
2 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
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,50 @@ | ||
<?php | ||
|
||
namespace Ampeco\OmnipayWlValina\Message; | ||
|
||
class InitialPurchaseRequest extends AbstractRequest | ||
{ | ||
public function getEndpoint(): string | ||
{ | ||
return '/payments'; | ||
} | ||
|
||
public function getRequestMethod(): string | ||
{ | ||
return 'POST'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return [ | ||
'cardPaymentMethodSpecificInput' => [ | ||
'authorizationMode' => 'FINAL_AUTHORIZATION', | ||
'transactionChannel' => 'ECOMMERCE', | ||
'returnUrl' => $this->getReturnUrl(), | ||
'threeDSecure' => [ | ||
'skipAuthentication' => false, | ||
'challengeIndicator' => 'no-preference', | ||
], | ||
], | ||
'order' => [ | ||
'amountOfMoney' => [ | ||
//EUR is a 2-decimals currency, the value 1234 will result in EUR 12.34 | ||
'amount' => number_format($this->getAmount(), 2, '', ''), | ||
'currencyCode' => $this->getCurrency(), | ||
], | ||
'customer' => [ | ||
'device' => [ | ||
'acceptHeader' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8', | ||
'userAgent' => 'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/75.0.3770.142Safari/537.36', | ||
], | ||
], | ||
], | ||
'hostedTokenizationId' => $this->getHostedTokenizationId(), | ||
]; | ||
} | ||
|
||
protected function createResponse(array $data, int $statusCode): Response | ||
{ | ||
return $this->response = new InitialPurchaseResponse($this, $data, $statusCode); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Ampeco\OmnipayWlValina\Message; | ||
|
||
class InitialPurchaseResponse extends Response | ||
{ | ||
public function isSuccessful(): bool | ||
{ | ||
return parent::isSuccessful() && in_array(@$this->data['payment']['status'], [self::STATUS_REDIRECTED, self::STATUS_PENDING_CAPTURE]); | ||
} | ||
|
||
public function getRedirectUrl() | ||
{ | ||
return $this->data['merchantAction']['redirectData']['redirectURL'] ?? null; | ||
} | ||
|
||
public function getTransactionReference(): ?string | ||
{ | ||
return $this->data['payment']['id'] ?? 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