Passed
Push — master ( 5addfc...e8c424 )
by Manuel
59s queued 11s
created

SecureAliasStore/3-example-insert-direct.php (1 issue)

Labels
Severity
1
<?php declare(strict_types=1);
2
3
use \Ticketpark\SaferpayJson\Container;
4
use Ticketpark\SaferpayJson\Request\SecureAliasStore\InsertDirectRequest;
5
use \Ticketpark\SaferpayJson\Response\ErrorResponse;
6
7
require_once __DIR__ . '/../../vendor/autoload.php';
8
require_once __DIR__ . '/../credentials.php';
9
10
// Step 1:
11
// Prepare the insert direct request
12
// See https://saferpay.github.io/jsonapi/1.2/#Payment_v1_Alias_InsertDirect
13
14
$requestHeader = (new Container\RequestHeader())
15
    ->setCustomerId($customerId)
16
    ->setRequestId(uniqid());
17
18
$card = (new Container\Card())
19
    ->setNumber('9030101052000008')
20
    ->setExpYear(2025)
21
    ->setExpMonth(10)
22
    ->setHolderName('Johnny Cash');
23
24
$paymentMeans = (new Container\PaymentMeans())
25
    ->setCard($card);
26
27
$response = (new InsertDirectRequest($apiKey, $apiSecret))
28
    ->setRequestHeader($requestHeader)
29
    ->setRegisterAlias(new Container\RegisterAlias())
30
    ->setPaymentMeans($paymentMeans)
31
    ->execute();
32
33
// Step 2:
34
// Check for successful response
35
36
if ($response instanceof ErrorResponse) {
37
    die($response->getErrorMessage());
38
}
39
40
// Step 3:
41
// You are done!
42
43
echo 'The insert has been successful! Insert alias: ' . $response->getAlias()->getId() . "<br>\n";
0 ignored issues
show
The method getAlias() does not exist on Ticketpark\SaferpayJson\Response\ResponseInterface. It seems like you code against a sub-type of Ticketpark\SaferpayJson\Response\ResponseInterface such as Ticketpark\SaferpayJson\...re\InsertDirectResponse or Ticketpark\SaferpayJson\...re\AssertInsertResponse. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
echo 'The insert has been successful! Insert alias: ' . $response->/** @scrutinizer ignore-call */ getAlias()->getId() . "<br>\n";
Loading history...
44