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 partial authorization in payment request #260

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
11 changes: 11 additions & 0 deletions lib/Checkout/Payments/Request/PartialAuthorization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Checkout\Payments\Request;

class PartialAuthorization
{
/**
* @var bool
*/
public $enabled;
}
5 changes: 5 additions & 0 deletions lib/Checkout/Payments/Request/PaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class PaymentRequest
*/
public $authorization_type;

/**
* @var PartialAuthorization
*/
public $partial_authorization;

/**
* @var bool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Checkout\Common\CustomerRequest;
use Checkout\Payments\AuthorizationRequest;
use Checkout\Payments\AuthorizationType;
use Checkout\Payments\Request\PartialAuthorization;
use Checkout\Payments\Request\PaymentRequest;
use Checkout\Payments\Request\Source\RequestCardSource;
use Checkout\Payments\Sender\PaymentIndividualSender;
Expand All @@ -27,7 +28,10 @@ public function shouldIncrementPaymentAuthorization()
$authorizationRequest->reference = uniqid();
$authorizationRequest->metadata = array("param1" => "value1", "param2" => "value2");

$authorizationResponse = $this->checkoutApi->getPaymentsClient()->incrementPaymentAuthorization($paymentResponse["id"], $authorizationRequest);
$authorizationResponse = $this->checkoutApi->getPaymentsClient()->incrementPaymentAuthorization(
$paymentResponse["id"],
$authorizationRequest
);

$this->assertResponse(
$authorizationResponse,
Expand Down Expand Up @@ -60,8 +64,16 @@ public function shouldIncrementPaymentAuthorizationIdempotent()

$idempotencyKey = $this->idempotencyKey();

$authorizationResponse = $this->checkoutApi->getPaymentsClient()->incrementPaymentAuthorization($paymentResponse["id"], $authorizationRequest, $idempotencyKey);
$authorizationResponse2 = $this->checkoutApi->getPaymentsClient()->incrementPaymentAuthorization($paymentResponse["id"], $authorizationRequest, $idempotencyKey);
$authorizationResponse = $this->checkoutApi->getPaymentsClient()->incrementPaymentAuthorization(
$paymentResponse["id"],
$authorizationRequest,
$idempotencyKey
);
$authorizationResponse2 = $this->checkoutApi->getPaymentsClient()->incrementPaymentAuthorization(
$paymentResponse["id"],
$authorizationRequest,
$idempotencyKey
);

$this->assertEquals($authorizationResponse["action_id"], $authorizationResponse2["action_id"]);
}
Expand Down Expand Up @@ -91,12 +103,16 @@ private function makeEstimatedAuthorizedPayment()
$paymentIndividualSender->last_name = "Test";
$paymentIndividualSender->address = $address;

$partialAuthorization = new PartialAuthorization();
$partialAuthorization->enabled = true;

$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->currency = Currency::$EUR;
$paymentRequest->customer = $customerRequest;
$paymentRequest->sender = $paymentIndividualSender;
Expand Down
Loading