mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Merge branch 'master' into feature/create-order-intent-authorize
This commit is contained in:
commit
1cbcd8af72
2 changed files with 11 additions and 11 deletions
|
@ -21,16 +21,15 @@ class Order
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $id,
|
string $id,
|
||||||
\DateTime $createTime,
|
|
||||||
array $purchaseUnits,
|
array $purchaseUnits,
|
||||||
OrderStatus $orderStatus,
|
OrderStatus $orderStatus,
|
||||||
Payer $payer = null,
|
Payer $payer = null,
|
||||||
string $intent = 'CAPTURE',
|
string $intent = 'CAPTURE',
|
||||||
|
\DateTime $createTime = null,
|
||||||
\DateTime $updateTime = null
|
\DateTime $updateTime = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->createTime = $createTime;
|
|
||||||
//phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration.NoArgumentType
|
//phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration.NoArgumentType
|
||||||
$this->purchaseUnits = array_values(array_filter(
|
$this->purchaseUnits = array_values(array_filter(
|
||||||
$purchaseUnits,
|
$purchaseUnits,
|
||||||
|
@ -43,6 +42,7 @@ class Order
|
||||||
$this->orderStatus = $orderStatus;
|
$this->orderStatus = $orderStatus;
|
||||||
$this->intent = ($intent === 'CAPTURE') ? 'CAPTURE' : 'AUTHORIZE';
|
$this->intent = ($intent === 'CAPTURE') ? 'CAPTURE' : 'AUTHORIZE';
|
||||||
$this->purchaseUnits = $purchaseUnits;
|
$this->purchaseUnits = $purchaseUnits;
|
||||||
|
$this->createTime = $createTime;
|
||||||
$this->updateTime = $updateTime;
|
$this->updateTime = $updateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class Order
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createTime() : \DateTime
|
public function createTime() : ?\DateTime
|
||||||
{
|
{
|
||||||
return $this->createTime;
|
return $this->createTime;
|
||||||
}
|
}
|
||||||
|
@ -96,8 +96,10 @@ class Order
|
||||||
},
|
},
|
||||||
$this->purchaseUnits()
|
$this->purchaseUnits()
|
||||||
),
|
),
|
||||||
'create_time' => $this->createTime()->format(\DateTimeInterface::ISO8601),
|
|
||||||
];
|
];
|
||||||
|
if ($this->createTime()) {
|
||||||
|
$order['create_time'] = $this->createTime()->format(\DateTimeInterface::ISO8601);
|
||||||
|
}
|
||||||
if ($this->payer()) {
|
if ($this->payer()) {
|
||||||
$order['payer'] =$this->payer()->toArray();
|
$order['payer'] =$this->payer()->toArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,11 @@ class OrderFactory
|
||||||
|
|
||||||
return new Order(
|
return new Order(
|
||||||
$order->id(),
|
$order->id(),
|
||||||
$order->createTime(),
|
|
||||||
$purchaseUnits,
|
$purchaseUnits,
|
||||||
$order->status(),
|
$order->status(),
|
||||||
$order->payer(),
|
$order->payer(),
|
||||||
$order->intent(),
|
$order->intent(),
|
||||||
|
$order->createTime(),
|
||||||
$order->updateTime()
|
$order->updateTime()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,6 @@ class OrderFactory
|
||||||
__('Order does not contain an id.', 'woocommerce-paypal-commerce-gateway')
|
__('Order does not contain an id.', 'woocommerce-paypal-commerce-gateway')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (! isset($orderData->create_time)) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
__('Order does not contain a create time.', 'woocommerce-paypal-commerce-gateway')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (! isset($orderData->purchase_units) || !is_array($orderData->purchase_units)) {
|
if (! isset($orderData->purchase_units) || !is_array($orderData->purchase_units)) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
__('Order does not contain items.', 'woocommerce-paypal-commerce-gateway')
|
__('Order does not contain items.', 'woocommerce-paypal-commerce-gateway')
|
||||||
|
@ -72,6 +67,9 @@ class OrderFactory
|
||||||
$orderData->purchase_units
|
$orderData->purchase_units
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$createTime = (isset($orderData->create_time)) ?
|
||||||
|
\DateTime::createFromFormat(\DateTime::ISO8601, $orderData->create_time)
|
||||||
|
: null;
|
||||||
$updateTime = (isset($orderData->update_time)) ?
|
$updateTime = (isset($orderData->update_time)) ?
|
||||||
\DateTime::createFromFormat(\DateTime::ISO8601, $orderData->update_time)
|
\DateTime::createFromFormat(\DateTime::ISO8601, $orderData->update_time)
|
||||||
: null;
|
: null;
|
||||||
|
@ -81,11 +79,11 @@ class OrderFactory
|
||||||
|
|
||||||
return new Order(
|
return new Order(
|
||||||
$orderData->id,
|
$orderData->id,
|
||||||
\DateTime::createFromFormat(\DateTime::ISO8601, $orderData->create_time),
|
|
||||||
$purchaseUnits,
|
$purchaseUnits,
|
||||||
new OrderStatus($orderData->status),
|
new OrderStatus($orderData->status),
|
||||||
$payer,
|
$payer,
|
||||||
$orderData->intent,
|
$orderData->intent,
|
||||||
|
$createTime,
|
||||||
$updateTime
|
$updateTime
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue