Skip to content

Commit

Permalink
Issue #64 extent response factory to work with server requests
Browse files Browse the repository at this point in the history
Since we now have v1 and v2 3DS callbacks, being able to detect which one
we have and instantiating the correct response model, is now vert useful.
  • Loading branch information
judgej committed Sep 1, 2021
1 parent 4b6e6fb commit 211ff57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Factory/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Academe\Opayo\Pi\Request\AbstractRequest;
use Psr\Http\Message\ResponseInterface;
use Academe\Opayo\Pi\Response;
use Academe\Opayo\Pi\ServerRequest;
use Academe\Opayo\Pi\Helper;
use Teapot\StatusCode\Http;

Expand Down Expand Up @@ -138,6 +139,18 @@ public static function fromData($data, $httpCode = null)
return Response\InstructionCollection::fromData($data, $httpCode);
}

// A 3DS v2 callback result, aka notification (this is a server request).

if (Helper::dataGet($data, 'cres')) {
return ServerRequest\Secure3Dv2Notification::fromData($data, $httpCode);
}

// A 3DS v1 callbacl result (this is a server request).

if (Helper::dataGet($data, 'PaRes')) {
return ServerRequest\Secure3DAcs::fromData($data, $httpCode);
}

// A 204 with an empty body is a quiet accpetance that what was send is successful.
// e.g. returned when a CVV is linked to a card.

Expand Down
2 changes: 1 addition & 1 deletion src/Request/Model/StrongCustomerAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function __construct(
string $browserUserAgent,
string $challengeWindowSize,
string $transType,
array $additionalOptions = [],
array $additionalOptions = []
)
{
$this->notificationUrl = $notificationUrl;
Expand Down
2 changes: 1 addition & 1 deletion src/Response/Model/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Card implements JsonSerializable
/**
* @var Flag indicates this is a reusable card identifier; it has been used before.
*/
protected $reusable;
protected $reusable = false;

/**
* @var Captured (safe) details for the card.
Expand Down

0 comments on commit 211ff57

Please sign in to comment.