From dfeee2b1e3b56b2a17f22c91d5c4282ed1fb3166 Mon Sep 17 00:00:00 2001 From: Matthew Crigger Date: Tue, 14 Jul 2020 13:41:55 -0400 Subject: [PATCH 1/3] Initial Commit Initial commit based on code from rjacobso --- lib/Balance.php | 44 ++++++++++++++++++++++++++++++++++++++++++ lib/Payouts.php | 25 ++++++++++++++++++++++++ lib/ShopifyPayment.php | 11 ++++++++++- lib/ShopifySDK.php | 5 +++++ lib/Transactions.php | 19 ++++++++++++++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 lib/Balance.php create mode 100644 lib/Payouts.php create mode 100644 lib/Transactions.php diff --git a/lib/Balance.php b/lib/Balance.php new file mode 100644 index 0000000..112e250 --- /dev/null +++ b/lib/Balance.php @@ -0,0 +1,44 @@ + Child Resources + * -------------------------------------------------------------------------- + * + * + */ +class Balance extends ShopifyResource +{ + /** + * @inheritDoc + */ + protected $resourceKey = 'balance'; + + /** + * Get the pluralized version of the resource key + * + * Normally its the same as $resourceKey appended with 's', when it's different, the specific resource class will override this function + * + * @return string + */ + protected function pluralizeKey() + { + return $this->resourceKey; + } + + /** + * If the resource is read only. (No POST / PUT / DELETE actions) + * + * @var boolean + */ + public $readOnly = true; + + /** + * @inheritDoc + */ + protected $childResource = array( + 'Transactions' + ); +} \ No newline at end of file diff --git a/lib/Payouts.php b/lib/Payouts.php new file mode 100644 index 0000000..0cd2ec6 --- /dev/null +++ b/lib/Payouts.php @@ -0,0 +1,25 @@ + + * Created at 11/11/19 12:26 PM UTC-05:00 + * + * @see https://help.shopify.com/en/api/reference/shopify_payments/payout Shopify API Reference for Shopify Payment Payouts + */ + +namespace PHPShopify; + +/** + * -------------------------------------------------------------------------- + * ShopifyPayment -> Child Resources + * -------------------------------------------------------------------------- + * + * + */ +class Payouts extends ShopifyResource +{ + /** + * @inheritDoc + */ + protected $resourceKey = 'payout'; +} \ No newline at end of file diff --git a/lib/ShopifyPayment.php b/lib/ShopifyPayment.php index a6da406..5577499 100644 --- a/lib/ShopifyPayment.php +++ b/lib/ShopifyPayment.php @@ -26,10 +26,19 @@ class ShopifyPayment extends ShopifyResource */ public $resourceKey = 'shopify_payment'; + /** + * If the resource is read only. (No POST / PUT / DELETE actions) + * + * @var boolean + */ + public $readOnly = true; + /** * @inheritDoc */ protected $childResource = array( - 'Dispute' + 'Balance', + 'Dispute', + 'Payouts', ); } \ No newline at end of file diff --git a/lib/ShopifySDK.php b/lib/ShopifySDK.php index 94dbe81..9000e84 100644 --- a/lib/ShopifySDK.php +++ b/lib/ShopifySDK.php @@ -146,6 +146,7 @@ * @method ScriptTag ScriptTag(integer $id = null) * @method ShippingZone ShippingZone(integer $id = null) * @method Shop Shop(integer $id = null) + * @method ShopifyPayment ShopifyPayment() * @method SmartCollection SmartCollection(integer $id = null) * @method Theme Theme(int $id = null) * @method User User(integer $id = null) @@ -235,16 +236,20 @@ class ShopifySDK protected $childResources = array( 'Article' => 'Blog', 'Asset' => 'Theme', + 'Balance' => 'ShopifyPayment', 'CustomerAddress' => 'Customer', + 'Dispute' => 'ShopifyPayment', 'Fulfillment' => 'Order', 'FulfillmentEvent' => 'Fulfillment', 'OrderRisk' => 'Order', + 'Payouts' => 'ShopifyPayment', 'ProductImage' => 'Product', 'ProductVariant' => 'Product', 'DiscountCode' => 'PriceRule', 'Province' => 'Country', 'Refund' => 'Order', 'Transaction' => 'Order', + 'Transactions' => 'Balance', 'UsageCharge' => 'RecurringApplicationCharge', ); diff --git a/lib/Transactions.php b/lib/Transactions.php new file mode 100644 index 0000000..792f8b4 --- /dev/null +++ b/lib/Transactions.php @@ -0,0 +1,19 @@ + Date: Fri, 17 Jul 2020 12:30:42 -0400 Subject: [PATCH 2/3] Update ShopifyPayment.php Added property / method lines for balance and payouts. --- lib/ShopifyPayment.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/ShopifyPayment.php b/lib/ShopifyPayment.php index 5577499..54fc6b3 100644 --- a/lib/ShopifyPayment.php +++ b/lib/ShopifyPayment.php @@ -18,6 +18,15 @@ * * @method ShopifyResource Dispute(integer $id = null) * + * @property-read ShopifyResource $Balance + * + * @method ShopifyResource Balance(integer $id = null) + * + * @property-read ShopifyResource $Payouts + * + * @method ShopifyResource Payouts(integer $id = null) + * + */ class ShopifyPayment extends ShopifyResource { From 6a114af6763217d0b32920c09b4a4a55663dca08 Mon Sep 17 00:00:00 2001 From: Matthew Crigger Date: Fri, 17 Jul 2020 12:43:33 -0400 Subject: [PATCH 3/3] Author and Links Updated authoring and help links. --- lib/Balance.php | 7 +++++++ lib/Payouts.php | 2 +- lib/Transactions.php | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Balance.php b/lib/Balance.php index 112e250..4144c5c 100644 --- a/lib/Balance.php +++ b/lib/Balance.php @@ -1,4 +1,11 @@ + * @author Matthew Crigger + * + * @see https://help.shopify.com/en/api/reference/shopify_payments/balance Shopify API Reference for Shopify Payment Balance + */ namespace PHPShopify; diff --git a/lib/Payouts.php b/lib/Payouts.php index 0cd2ec6..e43245b 100644 --- a/lib/Payouts.php +++ b/lib/Payouts.php @@ -2,7 +2,7 @@ /** * Created by PhpStorm. * @author Robert Jacobson - * Created at 11/11/19 12:26 PM UTC-05:00 + * @author Matthew Crigger * * @see https://help.shopify.com/en/api/reference/shopify_payments/payout Shopify API Reference for Shopify Payment Payouts */ diff --git a/lib/Transactions.php b/lib/Transactions.php index 792f8b4..0b45020 100644 --- a/lib/Transactions.php +++ b/lib/Transactions.php @@ -1,4 +1,11 @@ + * @author Matthew Crigger + * + * @see https://help.shopify.com/en/api/reference/shopify_payments/transaction Shopify API Reference for Shopify Payment Transactions + */ namespace PHPShopify;