Skip to content

Commit

Permalink
Merge pull request #127 from SwedbankPay/feature/checkoutv3
Browse files Browse the repository at this point in the history
Checkout v3
  • Loading branch information
olegisk authored Apr 22, 2023
2 parents 30dfed2 + 923bda9 commit e0ed3d1
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
Changelog
6.0.0 - 2023-04-17
Added
- Checkout v3 classes and methods
- Add `setImplementation()` and `getImplementation()` for Paymentorder
- Add classes `TransactionCancelV3`, `TransactionCaptureV3`, `TransactionReversalV3`
- Add methods `getFirstName()`, `setFirstName()`, `getLastName()`, `setLastName()`, `getDigitalProducts()`, `setDigitalProducts()`, `getShippingAddressRestrictedToCountryCodes()`, `setShippingAddressRestrictedToCountryCodes()` in `PaymentorderPayer`

5.6.0 - 2023-04-07
Added
- Add `setProductName()` and `getProductName()` for Paymentorder
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "swedbank-pay/swedbank-pay-sdk-php",
"type": "library",
"description": "The Swedbank Pay SDK for PHP simplifies integrations against Swedbank Pay's API Platform by providing native PHP interface towards the REST API.",
"version": "5.6.0",
"version": "6.0.0",
"authors": [
{
"name": "Sammy Nordstr\u00f6m",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ interface PaymentorderPayerInterface extends ResourceInterface
const PAYER_REFERENCE = 'payer_reference';
const EMAIL = 'email';
const MSISDN = 'msisdn';
const FIRST_NAME = 'first_name';
const LAST_NAME = 'last_name';
const WORK_PHONE_NUMBER = 'work_phone_number';
const HOME_PHONE_NUMBER = 'home_phone_number';
const SHIPPING_ADDRESS = 'shipping_address';
const DIGITAL_PRODUCTS = 'digital_products';
const SHIPPING_ADDRESS_RESTRICTED_COUNTRIES = 'shipping_address_restricted_to_country_codes';

/**
* Get Payer Reference.
Expand Down Expand Up @@ -68,6 +72,28 @@ public function getMsisdn();
*/
public function setMsisdn($msisdn);

/**
* @return string|null
*/
public function getFirstName();

/**
* @param string $firstName
* @return $this
*/
public function setFirstName($firstName);

/**
* @return string|null
*/
public function getLastName();

/**
* @param string $lastName
* @return $this
*/
public function setLastName($lastName);

/**
* @return string
*/
Expand Down Expand Up @@ -100,4 +126,27 @@ public function getShippingAddress();
* @return mixed
*/
public function setShippingAddress($shippingAddress);

/**
* @return bool|null
*/
public function getDigitalProducts();

/**
* @param bool $flag
* @return $this
*/
public function setDigitalProducts($flag);

/**
* @return array|null
*/
public function getShippingAddressRestrictedToCountryCodes();

/**
* @param array $countries
*
* @return $this
*/
public function setShippingAddressRestrictedToCountryCodes($countries);
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,40 @@ public function setMsisdn($msisdn)
return $this->offsetSet(self::MSISDN, $msisdn);
}

/**
* @return string|null
*/
public function getFirstName()
{
return $this->offsetGet(self::FIRST_NAME);
}

/**
* @param string $firstName
* @return $this
*/
public function setFirstName($firstName)
{
return $this->offsetSet(self::FIRST_NAME, $firstName);
}

/**
* @return string|null
*/
public function getLastName()
{
return $this->offsetGet(self::FIRST_NAME);
}

/**
* @param string $lastName
* @return $this
*/
public function setLastName($lastName)
{
return $this->offsetSet(self::LAST_NAME, $lastName);
}

/**
* @return string
*/
Expand Down Expand Up @@ -134,4 +168,39 @@ public function setShippingAddress($shippingAddress)
{
return $this->offsetSet(self::SHIPPING_ADDRESS, $shippingAddress);
}

/**
* @return bool|null
*/
public function getDigitalProducts()
{
return $this->offsetGet(self::DIGITAL_PRODUCTS);
}

/**
* @param bool $flag
* @return $this
*/
public function setDigitalProducts($flag)
{
return $this->offsetSet(self::DIGITAL_PRODUCTS, $flag);
}

/**
* @return array|null
*/
public function getShippingAddressRestrictedToCountryCodes()
{
return $this->offsetGet(self::SHIPPING_ADDRESS_RESTRICTED_COUNTRIES);
}

/**
* @param array $countries
*
* @return $this
*/
public function setShippingAddressRestrictedToCountryCodes($countries)
{
return $this->offsetSet(self::SHIPPING_ADDRESS_RESTRICTED_COUNTRIES, $countries);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use SwedbankPay\Api\Service\Paymentorder\Resource\Data\PaymentorderPayerInterface;
use SwedbankPay\Api\Service\Paymentorder\Resource\Data\PaymentorderRiskIndicatorInterface;
use SwedbankPay\Api\Service\Paymentorder\Resource\Data\PaymentorderUrlInterface;
use SwedbankPay\Api\Service\Paymentorder\Resource\Request\Paymentorder;
use SwedbankPay\Api\Service\Resource\Data\RequestInterface;

/**
Expand Down Expand Up @@ -48,6 +49,8 @@ interface PaymentorderInterface extends RequestInterface
const INITIATING_SYSTEM_AGENT = 'initiatingSystemUserAgent';
const PRODUCT_NAME = 'product_name';

const IMPLEMENTATION = 'implementation';

/**
* Get Initiating System User Agent.
*
Expand Down Expand Up @@ -309,4 +312,19 @@ public function setProductName($productName);
* @return string|null
*/
public function getProductName();

/**
* Set Implementation.
*
* @param $implementation
* @return Paymentorder
*/
public function setImplementation($implementation);

/**
* Get Implementation name.
*
* @return string|null
*/
public function getImplementation();
}
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,25 @@ public function getProductName()
{
return $this->offsetGet(self::PRODUCT_NAME);
}

/**
* Set Implementation.
*
* @param $implementation
* @return Paymentorder
*/
public function setImplementation($implementation)
{
return $this->offsetSet(self::IMPLEMENTATION, $implementation);
}

/**
* Get Implementation name.
*
* @return string|null
*/
public function getImplementation()
{
return $this->offsetGet(self::IMPLEMENTATION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace SwedbankPay\Api\Service\Paymentorder\Transaction\Request;

use SwedbankPay\Api\Service\Paymentorder\Transaction\Resource\Response\TransactionCancel as TransactionCancelResponse;
use SwedbankPay\Api\Service\Request;

/**
* TransactionCancel for Checkout v3
*/
class TransactionCancelV3 extends Request
{
public function setup()
{
$this->setOperationRel('cancel');
$this->setResponseResourceFQCN(TransactionCancelResponse::class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace SwedbankPay\Api\Service\Paymentorder\Transaction\Request;

use SwedbankPay\Api\Service\Paymentorder\Transaction\Resource\Response\TransactionCapture as TransactionCaptureResponse;
use SwedbankPay\Api\Service\Request;

/**
* TransactionCaptureV3 for Checkout v3
*/
class TransactionCaptureV3 extends Request
{
public function setup()
{
$this->setOperationRel('capture');
$this->setResponseResourceFQCN(TransactionCaptureResponse::class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace SwedbankPay\Api\Service\Paymentorder\Transaction\Request;

use SwedbankPay\Api\Service\Paymentorder\Transaction\Resource\Response\TransactionReversal as TransactionRevResponse;
use SwedbankPay\Api\Service\Request;

/**
* TransactionReversalV3 for Checkout v3
*/
class TransactionReversalV3 extends Request
{
public function setup()
{
$this->setOperationRel('reversal');
$this->setResponseResourceFQCN(TransactionRevResponse::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ public function testData()
$object->setShippingAddress($address)
);
$this->assertInstanceOf(ConsumerAddress::class, $object->getShippingAddress());

$this->assertInstanceOf(
PaymentorderPayer::class,
$object->setDigitalProducts(true)
);
$this->assertEquals(true, $object->getDigitalProducts());

$this->assertInstanceOf(
PaymentorderPayer::class,
$object->setShippingAddressRestrictedToCountryCodes(['NO', 'US'])
);
$this->assertIsArray($object->getShippingAddressRestrictedToCountryCodes());
}

public function testMethods()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ public function testData()
$object->setProductName('Checkout3')
);
$this->assertEquals('Checkout3', $object->getProductName());

$this->assertInstanceOf(
Paymentorder::class,
$object->setImplementation('Starter')
);
$this->assertEquals('Starter', $object->getImplementation());
}

public function testInitiatingSystemUserAgent()
Expand Down

0 comments on commit e0ed3d1

Please sign in to comment.