Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mkreusch committed Aug 25, 2021
1 parent fbc5aed commit f047e17
Show file tree
Hide file tree
Showing 10 changed files with 506 additions and 18 deletions.
20 changes: 19 additions & 1 deletion Client/Client.php
Expand Up @@ -6,6 +6,7 @@
use AmazonPayApiSdkExtension\Struct\Charge;
use AmazonPayApiSdkExtension\Struct\ChargePermission;
use AmazonPayApiSdkExtension\Struct\CheckoutSession;
use AmazonPayApiSdkExtension\Struct\DeliveryTracker;
use AmazonPayApiSdkExtension\Struct\PaymentDetails;
use AmazonPayApiSdkExtension\Struct\Refund;
use AmazonPayApiSdkExtension\Exceptions\AmazonPayException;
Expand Down Expand Up @@ -72,6 +73,23 @@ public function updateCheckoutSession($checkoutSessionId, $checkoutSession, $hea
return new CheckoutSession(json_decode($result['response'], true));
}

/**
* @param \AmazonPayApiSdkExtension\Struct\DeliveryTracker|array|string $deliveryTracker
* @param null $headers
* @return DeliveryTracker
*/
public function deliveryTrackers($deliveryTracker, $headers = null)
{
if ($deliveryTracker instanceof DeliveryTracker) {
$deliveryTracker = $deliveryTracker->toArray();
}
$result = parent::deliveryTrackers($deliveryTracker, $headers);
if ((int)$result['status'] !== 200) {
throw new AmazonPayException($result['response']);
}
return new DeliveryTracker(json_decode($result['response'], true));
}

/**
* @param string $checkoutSessionId
* @param \AmazonPayApiSdkExtension\Struct\PaymentDetails|array|string $paymentDetails
Expand Down Expand Up @@ -250,4 +268,4 @@ public function updateChargePermission($chargePermissionId, $chargePermission, $
return new ChargePermission($response);
}

}
}
237 changes: 237 additions & 0 deletions Struct/AddressDetails.php
@@ -0,0 +1,237 @@
<?php
namespace AmazonPayApiSdkExtension\Struct;

class AddressDetails extends StructBase {
/**
* @var string
*/
protected $name;

/**
* @var string
*/
protected $addressLine1;

/**
* @var string
*/
protected $addressLine2;

/**
* @var string
*/
protected $addressLine3;

/**
* @var string
*/
protected $city;


/**
* @var string
*/
protected $districtOrCounty;

/**
* @var string
*/
protected $stateOrRegion;

/**
* @var string
*/
protected $postalCode;

/**
* @var string
*/
protected $countryCode;

/**
* @var string
*/
protected $phoneNumber;

/**
* @return string
*/
public function getName()
{
return $this->name;
}

/**
* @param string $name
* @return AddressDetails
*/
public function setName($name)
{
$this->name = $name;
return $this;
}

/**
* @return string
*/
public function getAddressLine1()
{
return $this->addressLine1;
}

/**
* @param string $addressLine1
* @return AddressDetails
*/
public function setAddressLine1($addressLine1)
{
$this->addressLine1 = $addressLine1;
return $this;
}

/**
* @return string
*/
public function getAddressLine2()
{
return $this->addressLine2;
}

/**
* @param string $addressLine2
* @return AddressDetails
*/
public function setAddressLine2($addressLine2)
{
$this->addressLine2 = $addressLine2;
return $this;
}

/**
* @return string
*/
public function getAddressLine3()
{
return $this->addressLine3;
}

/**
* @param string $addressLine3
* @return AddressDetails
*/
public function setAddressLine3($addressLine3)
{
$this->addressLine3 = $addressLine3;
return $this;
}

/**
* @return string
*/
public function getCity()
{
return $this->city;
}

/**
* @param string $city
* @return AddressDetails
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}

/**
* @return string
*/
public function getDistrictOrCounty()
{
return $this->districtOrCounty;
}

/**
* @param string $districtOrCounty
* @return AddressDetails
*/
public function setDistrictOrCounty($districtOrCounty)
{
$this->districtOrCounty = $districtOrCounty;
return $this;
}

/**
* @return string
*/
public function getStateOrRegion()
{
return $this->stateOrRegion;
}

/**
* @param string $stateOrRegion
* @return AddressDetails
*/
public function setStateOrRegion($stateOrRegion)
{
$this->stateOrRegion = $stateOrRegion;
return $this;
}

/**
* @return string
*/
public function getPostalCode()
{
return $this->postalCode;
}

/**
* @param string $postalCode
* @return AddressDetails
*/
public function setPostalCode($postalCode)
{
$this->postalCode = $postalCode;
return $this;
}

/**
* @return string
*/
public function getCountryCode()
{
return $this->countryCode;
}

/**
* @param string $countryCode
* @return AddressDetails
*/
public function setCountryCode($countryCode)
{
$this->countryCode = $countryCode;
return $this;
}

/**
* @return string
*/
public function getPhoneNumber()
{
return $this->phoneNumber;
}

/**
* @param string $phoneNumber
* @return AddressDetails
*/
public function setPhoneNumber($phoneNumber)
{
$this->phoneNumber = $phoneNumber;
return $this;
}


}
52 changes: 37 additions & 15 deletions Struct/Buyer.php
Expand Up @@ -28,6 +28,11 @@ class Buyer extends StructBase
*/
protected $countryCode;

/**
* @var ShippingAddress
*/
protected $shippingAddress;

/**
* @return string
*/
Expand Down Expand Up @@ -71,8 +76,7 @@ public function setCountryCode($countryCode)
/**
* @return string
*/
public
function getBuyerId()
public function getBuyerId()
{
return $this->buyerId;
}
Expand All @@ -82,10 +86,10 @@ function getBuyerId()
*
* @return Buyer
*/
public
function setBuyerId(
public function setBuyerId(
$buyerId
) {
)
{
$this->buyerId = $buyerId;

return $this;
Expand All @@ -94,8 +98,7 @@ function setBuyerId(
/**
* @return string
*/
public
function getName()
public function getName()
{
return $this->name;
}
Expand All @@ -105,10 +108,10 @@ function getName()
*
* @return Buyer
*/
public
function setName(
public function setName(
$name
) {
)
{
$this->name = $name;

return $this;
Expand All @@ -117,8 +120,7 @@ function setName(
/**
* @return string
*/
public
function getEmail()
public function getEmail()
{
return $this->email;
}
Expand All @@ -128,13 +130,33 @@ function getEmail()
*
* @return Buyer
*/
public
function setEmail(
public function setEmail(
$email
) {
)
{
$this->email = $email;

return $this;
}

/**
* @return ShippingAddress
*/
public function getShippingAddress()
{
return $this->shippingAddress;
}

/**
* @param ShippingAddress $shippingAddress
* @return Buyer
*/
public function setShippingAddress($shippingAddress)
{
$this->shippingAddress = $shippingAddress;
return $this;
}



}

0 comments on commit f047e17

Please sign in to comment.