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

Payment Contexts Support (CS2) #229

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
1 change: 1 addition & 0 deletions .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: vendor/bin/phpstan analyse --no-progress
- name: Run PHPUnit
env:
CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
CHECKOUT_PREVIOUS_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_PUBLIC_KEY }}
CHECKOUT_DEFAULT_SECRET_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_SECRET_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: vendor/bin/phpstan analyse --no-progress
- name: Run PHPUnit
env:
CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
CHECKOUT_PREVIOUS_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_PUBLIC_KEY }}
CHECKOUT_DEFAULT_SECRET_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_SECRET_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
run: composer install
- name: Run PHPUnit
env:
CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
CHECKOUT_PREVIOUS_PUBLIC_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_PUBLIC_KEY }}
CHECKOUT_DEFAULT_SECRET_KEY: ${{ secrets.IT_CHECKOUT_DEFAULT_SECRET_KEY }}
Expand Down
11 changes: 11 additions & 0 deletions lib/Checkout/CheckoutApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Checkout\Instruments\InstrumentsClient;
use Checkout\Issuing\IssuingClient;
use Checkout\Metadata\MetadataClient;
use Checkout\Payments\Contexts\PaymentContextsClient;
use Checkout\Payments\PaymentsClient;
use Checkout\Payments\Hosted\HostedPaymentsClient;
use Checkout\Payments\Links\PaymentLinksClient;
Expand Down Expand Up @@ -41,6 +42,7 @@ final class CheckoutApi extends CheckoutApmApi
private $metadataClient;
private $financialClient;
private $issuingClient;
private $paymentContextClient;

public function __construct(CheckoutConfiguration $configuration)
{
Expand All @@ -61,6 +63,7 @@ public function __construct(CheckoutConfiguration $configuration)
$this->metadataClient = new MetadataClient($baseApiClient, $configuration);
$this->financialClient = new FinancialClient($baseApiClient, $configuration);
$this->issuingClient = new IssuingClient($baseApiClient, $configuration);
$this->paymentContextClient = new PaymentContextsClient($baseApiClient, $configuration);
$this->balancesClient = new BalancesClient(
$this->getBalancesApiClient($configuration),
$configuration
Expand Down Expand Up @@ -220,6 +223,14 @@ public function getIssuingClient()
return $this->issuingClient;
}

/**
* @return PaymentContextsClient
*/
public function getPaymentContextsClient()
{
return $this->paymentContextClient;
}

/**
* @param CheckoutConfiguration $configuration
* @return ApiClient
Expand Down
1 change: 1 addition & 0 deletions lib/Checkout/OAuthScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ class OAuthScope
public static $issuingCardMgmt = "issuing:card-mgmt";
public static $issuingControlsRead = "issuing:controls-read";
public static $issuingControlsWrite = "issuing:controls-write";
public static $PaymentContexts = "Payment Contexts";
}
21 changes: 21 additions & 0 deletions lib/Checkout/Payments/Contexts/PaymentContextsAirlineData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Checkout\Payments\Contexts;

class PaymentContextsAirlineData
{
/**
* @var array of Checkout\Payments\Contexts\PaymentContextsTicket
*/
public $tickets;

/**
* @var array of Checkout\Payments\Contexts\PaymentContextsPassenger
*/
public $passengers;

/**
* @var array of Checkout\Payments\Contexts\PaymentContextsFlightLegDetails
*/
public $flight_leg_details;
}
41 changes: 41 additions & 0 deletions lib/Checkout/Payments/Contexts/PaymentContextsClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Checkout\Payments\Contexts;

use Checkout\ApiClient;
use Checkout\AuthorizationType;
use Checkout\CheckoutApiException;
use Checkout\CheckoutConfiguration;
use Checkout\Client;

class PaymentContextsClient extends Client
{

const PAYMENT_CONTEXTS = "payment-contexts";

public function __construct(ApiClient $apiClient, CheckoutConfiguration $configuration)
{
parent::__construct($apiClient, $configuration, AuthorizationType::$secretKeyOrOAuth);
}

/**
* @param PaymentContextsRequest $paymentContextsRequest
* @return array
* @throws CheckoutApiException
*/
public function createPaymentContexts(PaymentContextsRequest $paymentContextsRequest)
{
return $this->apiClient->post(self::PAYMENT_CONTEXTS, $paymentContextsRequest, $this->sdkAuthorization());
}

/**
* @param $id
* @return array
* @throws CheckoutApiException
*/
public function getPaymentContextDetails($id)
{
return $this->apiClient->get($this->buildPath(self::PAYMENT_CONTEXTS, $id), $this->sdkAuthorization());
}

}
51 changes: 51 additions & 0 deletions lib/Checkout/Payments/Contexts/PaymentContextsFlightLegDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Checkout\Payments\Contexts;

class PaymentContextsFlightLegDetails
{
/**
* @var string
*/
public $flight_number;

/**
* @var string
*/
public $carrier_code;

/**
* @var string
*/
public $class_of_travelling;

/**
* @var string
*/
public $departure_airport;

/**
* @var DateTime
*/
public $departure_date;

/**
* @var string
*/
public $departure_time;

/**
* @var string
*/
public $arrival_airport;

/**
* @var string
*/
public $stop_over_code;

/**
* @var string
*/
public $fare_basis_code;
}
51 changes: 51 additions & 0 deletions lib/Checkout/Payments/Contexts/PaymentContextsItems.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Checkout\Payments\Contexts;

class PaymentContextsItems
{
/**
* @var string
*/
public $name;

/**
* @var int
*/
public $quantity;

/**
* @var int
*/
public $unit_price;

/**
* @var string
*/
public $reference;

/**
* @var int
*/
public $total_amount;

/**
* @var int
*/
public $tax_amount;

/**
* @var int
*/
public $discount_amount;

/**
* @var string
*/
public $url;

/**
* @var string
*/
public $image_url;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Checkout\Payments\Contexts;

class PaymentContextsPartnerCustomerRiskData
{
/**
* @var string
*/
public $key;

/**
* @var string
*/
public $value;
}
28 changes: 28 additions & 0 deletions lib/Checkout/Payments/Contexts/PaymentContextsPassenger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Checkout\Payments\Contexts;

use Checkout\Common\Address;

class PaymentContextsPassenger
{
/**
* @var string
*/
public $first_name;

/**
* @var string
*/
public $last_name;

/**
* @var DateTime
*/
public $date_of_birth;

/**
* @var Address
*/
public $address;
}
51 changes: 51 additions & 0 deletions lib/Checkout/Payments/Contexts/PaymentContextsProcessing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Checkout\Payments\Contexts;

class PaymentContextsProcessing
{
/**
* @var string value of BillingPlan
*/
public $billing_plan;

/**
* @var int
*/
public $shipping_amount;

/**
* @var string
*/
public $invoice_id;

/**
* @var string
*/
public $brand_name;

/**
* @var string
*/
public $locale;

/**
* @var string value of ShippingPreference
*/
public $shipping_preference;

/**
* @var string value of UserAction
*/
public $user_action;

/**
* @var string value of PaymentContextsPartnerCustomerRiskData
*/
public $partner_customer_risk_data;

/**
* @var array of Checkout\Payments\Contexts\PaymentContextsAirlineData
*/
public $airline_data;
}
Loading
Loading