Skip to content

Commit

Permalink
Add authentication for payment request (#274)
Browse files Browse the repository at this point in the history
Co-authored-by: jurgis <[email protected]>
  • Loading branch information
JZds and jurgis authored Nov 19, 2024
1 parent f792c39 commit ebe3e76
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Checkout/Payments/PreferredExperiences.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Checkout\Payments;

class PreferredExperiences
{
public static $googleSpa = "google_spa";
public static $threeDs = "3ds";
}
11 changes: 11 additions & 0 deletions lib/Checkout/Payments/Request/Authentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Checkout\Payments\Request;

class Authentication
{
/**
* @var string value of PreferredExperiences
*/
public $preferred_experiences;
}
5 changes: 5 additions & 0 deletions lib/Checkout/Payments/Request/PaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ class PaymentRequest
*/
public $description;

/**
* @var Authentication
*/
public $authentication;

/**
* @var string value of AuthorizationType
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Checkout\Common\CustomerRequest;
use Checkout\Payments\AuthorizationRequest;
use Checkout\Payments\AuthorizationType;
use Checkout\Payments\PreferredExperiences;
use Checkout\Payments\Request\Authentication;
use Checkout\Payments\Request\PartialAuthorization;
use Checkout\Payments\Request\PaymentRequest;
use Checkout\Payments\Request\Source\RequestCardSource;
Expand Down Expand Up @@ -106,13 +108,17 @@ private function makeEstimatedAuthorizedPayment()
$partialAuthorization = new PartialAuthorization();
$partialAuthorization->enabled = true;

$authentication = new Authentication();
$authentication->preferred_experiences = PreferredExperiences::$googleSpa;

$paymentRequest = new PaymentRequest();
$paymentRequest->source = $requestCardSource;
$paymentRequest->capture = false;
$paymentRequest->reference = uniqid();
$paymentRequest->amount = 10;
$paymentRequest->authorization_type = AuthorizationType::$estimated;
$paymentRequest->partial_authorization = $partialAuthorization;
$paymentRequest->authentication = $authentication;
$paymentRequest->currency = Currency::$EUR;
$paymentRequest->customer = $customerRequest;
$paymentRequest->sender = $paymentIndividualSender;
Expand Down

0 comments on commit ebe3e76

Please sign in to comment.