Skip to content

Commit 98e889c

Browse files
authored
Revert "Revert "[Feature] Add support for Shopify Payments resources""
1 parent 782e5a6 commit 98e889c

15 files changed

+756
-0
lines changed

shopify/resources/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
from .image import Image
4646
from .variant import Variant
4747
from .order import Order
48+
from .balance import Balance
49+
from .disputes import Disputes
50+
from .payouts import Payouts
51+
from .transactions import Transactions
4852
from .order_risk import OrderRisk
4953
from .policy import Policy
5054
from .smart_collection import SmartCollection

shopify/resources/balance.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from ..base import ShopifyResource
2+
from shopify import mixins
3+
4+
5+
class Balance(ShopifyResource, mixins.Metafields):
6+
_prefix_source = "/shopify_payments/"
7+
_singular = _plural = 'balance'

shopify/resources/disputes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ..base import ShopifyResource
2+
from shopify import mixins
3+
4+
5+
class Disputes(ShopifyResource, mixins.Metafields):
6+
_prefix_source = "/shopify_payments/"

shopify/resources/payouts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ..base import ShopifyResource
2+
from shopify import mixins
3+
4+
5+
class Payouts(ShopifyResource, mixins.Metafields):
6+
_prefix_source = "/shopify_payments/"

shopify/resources/transactions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ..base import ShopifyResource
2+
from shopify import mixins
3+
4+
5+
class Transactions(ShopifyResource, mixins.Metafields):
6+
_prefix_source = "/shopify_payments/balance/"

test/balance_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import shopify
2+
from test.test_helper import TestCase
3+
4+
5+
class BalanceTest(TestCase):
6+
prefix = '/admin/api/unstable/shopify_payments'
7+
8+
def test_get_balance(self):
9+
self.fake('balance', method='GET', prefix=self.prefix, body=self.load_fixture('balance'))
10+
balance = shopify.Balance.find()
11+
self.assertGreater(len(balance), 0)

test/disputes_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import shopify
2+
from test.test_helper import TestCase
3+
4+
5+
class DisputeTest(TestCase):
6+
prefix = '/admin/api/unstable/shopify_payments'
7+
8+
def test_get_dispute(self):
9+
self.fake('disputes', method='GET', prefix=self.prefix, body=self.load_fixture('disputes'))
10+
disputes = shopify.Disputes.find()
11+
self.assertGreater(len(disputes), 0)
12+
13+
def test_get_one_dispute(self):
14+
self.fake('disputes/1052608616', method='GET',
15+
prefix=self.prefix, body=self.load_fixture('dispute'))
16+
disputes = shopify.Disputes.find(1052608616)
17+
self.assertEqual('won', disputes.status)

test/fixtures/balance.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"balance": [
3+
{
4+
"currency": "USD",
5+
"amount": "53.99"
6+
}
7+
]
8+
}

test/fixtures/dispute.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"dispute": {
3+
"id": 1052608616,
4+
"order_id": null,
5+
"type": "chargeback",
6+
"amount": "100.00",
7+
"currency": "USD",
8+
"reason": "fraudulent",
9+
"network_reason_code": "4827",
10+
"status": "won",
11+
"evidence_due_by": "2013-07-03T19:00:00-04:00",
12+
"evidence_sent_on": "2013-07-04T07:00:00-04:00",
13+
"finalized_on": null,
14+
"initiated_at": "2013-05-03T20:00:00-04:00"
15+
}
16+
}

test/fixtures/disputes.json

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"disputes": [
3+
{
4+
"id": 1052608616,
5+
"order_id": null,
6+
"type": "chargeback",
7+
"amount": "100.00",
8+
"currency": "USD",
9+
"reason": "fraudulent",
10+
"network_reason_code": "4827",
11+
"status": "won",
12+
"evidence_due_by": "2013-07-03T19:00:00-04:00",
13+
"evidence_sent_on": "2013-07-04T07:00:00-04:00",
14+
"finalized_on": null,
15+
"initiated_at": "2013-05-03T20:00:00-04:00"
16+
},
17+
{
18+
"id": 815713555,
19+
"order_id": 625362839,
20+
"type": "chargeback",
21+
"amount": "11.50",
22+
"currency": "USD",
23+
"reason": "credit_not_processed",
24+
"network_reason_code": "4827",
25+
"status": "needs_response",
26+
"evidence_due_by": "2020-11-17T19:00:00-05:00",
27+
"evidence_sent_on": null,
28+
"finalized_on": null,
29+
"initiated_at": "2013-05-03T20:00:00-04:00"
30+
},
31+
{
32+
"id": 782360659,
33+
"order_id": 625362839,
34+
"type": "chargeback",
35+
"amount": "11.50",
36+
"currency": "USD",
37+
"reason": "fraudulent",
38+
"network_reason_code": "4827",
39+
"status": "won",
40+
"evidence_due_by": "2013-07-03T19:00:00-04:00",
41+
"evidence_sent_on": "2013-07-04T07:00:00-04:00",
42+
"finalized_on": null,
43+
"initiated_at": "2013-05-03T20:00:00-04:00"
44+
},
45+
{
46+
"id": 670893524,
47+
"order_id": 625362839,
48+
"type": "inquiry",
49+
"amount": "11.50",
50+
"currency": "USD",
51+
"reason": "fraudulent",
52+
"network_reason_code": "4827",
53+
"status": "needs_response",
54+
"evidence_due_by": "2020-11-17T19:00:00-05:00",
55+
"evidence_sent_on": null,
56+
"finalized_on": null,
57+
"initiated_at": "2013-05-03T20:00:00-04:00"
58+
},
59+
{
60+
"id": 598735659,
61+
"order_id": 625362839,
62+
"type": "chargeback",
63+
"amount": "11.50",
64+
"currency": "USD",
65+
"reason": "fraudulent",
66+
"network_reason_code": "4827",
67+
"status": "needs_response",
68+
"evidence_due_by": "2020-11-17T19:00:00-05:00",
69+
"evidence_sent_on": null,
70+
"finalized_on": null,
71+
"initiated_at": "2013-05-03T20:00:00-04:00"
72+
},
73+
{
74+
"id": 85190714,
75+
"order_id": 625362839,
76+
"type": "chargeback",
77+
"amount": "11.50",
78+
"currency": "USD",
79+
"reason": "fraudulent",
80+
"network_reason_code": "4827",
81+
"status": "under_review",
82+
"evidence_due_by": "2020-11-17T19:00:00-05:00",
83+
"evidence_sent_on": "2020-11-04T19:00:00-05:00",
84+
"finalized_on": null,
85+
"initiated_at": "2013-05-03T20:00:00-04:00"
86+
},
87+
{
88+
"id": 35982383,
89+
"order_id": 625362839,
90+
"type": "chargeback",
91+
"amount": "11.50",
92+
"currency": "USD",
93+
"reason": "subscription_canceled",
94+
"network_reason_code": "4827",
95+
"status": "needs_response",
96+
"evidence_due_by": "2020-11-17T19:00:00-05:00",
97+
"evidence_sent_on": null,
98+
"finalized_on": null,
99+
"initiated_at": "2013-05-03T20:00:00-04:00"
100+
}
101+
]
102+
}

0 commit comments

Comments
 (0)