Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add authentication for payment request #274

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading