Skip to content

Commit a233b8d

Browse files
authored
Merge pull request #162 from vkislichenko/feature/payments-disputes
Added ShopifyPayment Dispute resource
2 parents d66b266 + 270b7dd commit a233b8d

File tree

5 files changed

+70
-1
lines changed

5 files changed

+70
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ Some resources are available directly, some resources are only available through
359359
- [Shop](https://help.shopify.com/api/reference/shop) _(read only)_
360360
- [SmartCollection](https://help.shopify.com/api/reference/smartcollection)
361361
- SmartCollection -> [Event](https://help.shopify.com/api/reference/event/)
362+
- [ShopifyPayment](https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/)
363+
- ShopifyPayment -> [Dispute](https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/dispute/) _(read only)_
362364
- [Theme](https://help.shopify.com/api/reference/theme)
363365
- Theme -> [Asset](https://help.shopify.com/api/reference/asset/)
364366
- [User](https://help.shopify.com/api/reference/user) _(read only, Shopify Plus Only)_

lib/Dispute.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* @author Victor Kislichenko <v.kislichenko@gmail.com>
5+
* Created at 01/06/2020 16:45 AM UTC+03:00
6+
*
7+
* @see https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/dispute Shopify API Reference for Dispute
8+
*/
9+
10+
namespace PHPShopify;
11+
12+
13+
/**
14+
* --------------------------------------------------------------------------
15+
* ShopifyPayment -> Child Resources
16+
* --------------------------------------------------------------------------
17+
* @property-read ShopifyResource $DiscountCode
18+
*
19+
* @method ShopifyResource DiscountCode(integer $id = null)
20+
*
21+
*/
22+
class Dispute extends ShopifyResource
23+
{
24+
/**
25+
* @inheritDoc
26+
*/
27+
public $resourceKey = 'dispute';
28+
29+
30+
}

lib/ShopifyPayment.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* @author Victor Kislichenko <v.kislichenko@gmail.com>
5+
* Created at 01/06/2020 16:45 AM UTC+03:00
6+
*
7+
* @see https://shopify.dev/docs/admin-api/rest/reference/shopify_payments Shopify API Reference for ShopifyPayment
8+
*/
9+
10+
namespace PHPShopify;
11+
12+
13+
/**
14+
* --------------------------------------------------------------------------
15+
* ShopifyPayment -> Child Resources
16+
* --------------------------------------------------------------------------
17+
* @property-read ShopifyResource $Dispute
18+
*
19+
* @method ShopifyResource Dispute(integer $id = null)
20+
*
21+
*/
22+
class ShopifyPayment extends ShopifyResource
23+
{
24+
/**
25+
* @inheritDoc
26+
*/
27+
public $resourceKey = 'shopify_payment';
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
protected $childResource = array(
33+
'Dispute'
34+
);
35+
}

lib/ShopifyResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ public function processResponse($responseArray, $dataKey = null)
530530
$httpCode = CurlRequest::$lastHttpCode;
531531

532532
if ($httpCode != null && $httpCode != $httpOK && $httpCode != $httpCreated && $httpCode != $httpDeleted) {
533-
throw new Exception\CurlException("Request failed with HTTP Code $httpCode.");
533+
throw new Exception\CurlException("Request failed with HTTP Code $httpCode.", $httpCode);
534534
}
535535
}
536536

lib/ShopifySDK.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
* @property-read ShippingZone $ShippingZone
105105
* @property-read Shop $Shop
106106
* @property-read SmartCollection $SmartCollection
107+
* @property-read ShopifyPayment $ShopifyPayment
107108
* @property-read Theme $Theme
108109
* @property-read User $User
109110
* @property-read Webhook $Webhook
@@ -196,6 +197,7 @@ class ShopifySDK
196197
'ShippingZone',
197198
'Shop',
198199
'SmartCollection',
200+
'ShopifyPayment',
199201
'Theme',
200202
'User',
201203
'Webhook',

0 commit comments

Comments
 (0)