ob-dj-store 0.0.15.9__py3-none-any.whl → 0.0.15.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ob_dj_store/apis/stores/rest/serializers/serializers.py +10 -2
- ob_dj_store/apis/stores/views.py +5 -2
- ob_dj_store/core/stores/models/_wallet.py +13 -7
- {ob_dj_store-0.0.15.9.dist-info → ob_dj_store-0.0.15.11.dist-info}/METADATA +1 -1
- {ob_dj_store-0.0.15.9.dist-info → ob_dj_store-0.0.15.11.dist-info}/RECORD +7 -7
- {ob_dj_store-0.0.15.9.dist-info → ob_dj_store-0.0.15.11.dist-info}/WHEEL +0 -0
- {ob_dj_store-0.0.15.9.dist-info → ob_dj_store-0.0.15.11.dist-info}/top_level.txt +0 -0
@@ -1383,23 +1383,31 @@ class WalletSerializer(serializers.ModelSerializer):
|
|
1383
1383
|
|
1384
1384
|
class WalletTopUpSerializer(serializers.Serializer):
|
1385
1385
|
amount = serializers.DecimalField(
|
1386
|
-
max_digits=10, decimal_places=2, min_value=1, required=True
|
1386
|
+
max_digits=10, decimal_places=2, min_value=1, required=True, write_only=True
|
1387
1387
|
)
|
1388
1388
|
payment_method = serializers.PrimaryKeyRelatedField(
|
1389
|
+
write_only=True,
|
1389
1390
|
queryset=PaymentMethod.objects.filter(
|
1390
1391
|
payment_provider__in=[
|
1391
1392
|
store_settings.TAP_CREDIT_CARD,
|
1392
1393
|
store_settings.TAP_KNET,
|
1393
1394
|
store_settings.TAP_ALL,
|
1395
|
+
store_settings.APPLE_PAY,
|
1394
1396
|
]
|
1395
1397
|
),
|
1396
1398
|
required=True,
|
1397
1399
|
)
|
1400
|
+
extra_infos = serializers.JSONField(required=False, write_only=True)
|
1401
|
+
payment_url = serializers.CharField(read_only=True)
|
1402
|
+
charge_id = serializers.CharField(read_only=True)
|
1398
1403
|
|
1399
1404
|
def top_up_wallet(self, wallet):
|
1400
1405
|
amount = self.validated_data["amount"]
|
1401
1406
|
payment_method = self.validated_data["payment_method"]
|
1402
|
-
|
1407
|
+
extra_infos = self.validated_data.get("extra_infos", {})
|
1408
|
+
return wallet.top_up_wallet(
|
1409
|
+
amount=amount, payment_method=payment_method, extra_infos=extra_infos
|
1410
|
+
)
|
1403
1411
|
|
1404
1412
|
|
1405
1413
|
class WalletTransactionSerializer(serializers.ModelSerializer):
|
ob_dj_store/apis/stores/views.py
CHANGED
@@ -1194,10 +1194,13 @@ class WalletViewSet(
|
|
1194
1194
|
serializer.is_valid(raise_exception=True)
|
1195
1195
|
instance = self.get_object()
|
1196
1196
|
try:
|
1197
|
-
payment_url = serializer.top_up_wallet(instance)
|
1197
|
+
payment_url, charge_id = serializer.top_up_wallet(instance)
|
1198
1198
|
except TapException as err:
|
1199
1199
|
raise ValidationError({"tap": _(f"{str(err)}")})
|
1200
|
-
return Response(
|
1200
|
+
return Response(
|
1201
|
+
{"payment_url": payment_url, "charge_id": charge_id},
|
1202
|
+
status=status.HTTP_200_OK,
|
1203
|
+
)
|
1201
1204
|
|
1202
1205
|
@swagger_auto_schema(
|
1203
1206
|
operation_summary="List Wallet's transactions",
|
@@ -103,18 +103,23 @@ class Wallet(models.Model):
|
|
103
103
|
image = self.media_image.image_thumbnail_medium
|
104
104
|
return image.url if image else None
|
105
105
|
|
106
|
-
def top_up_wallet(
|
106
|
+
def top_up_wallet(
|
107
|
+
self, amount: Decimal, payment_method: PaymentMethod, extra_infos: dict = {}
|
108
|
+
):
|
107
109
|
from ob_dj_store.core.stores.models import Order, Payment
|
108
110
|
|
111
|
+
extra_infos.update(
|
112
|
+
{
|
113
|
+
"is_wallet_fill_up": True,
|
114
|
+
"amount": str(amount),
|
115
|
+
"currency": self.currency,
|
116
|
+
}
|
117
|
+
)
|
109
118
|
user = self.user
|
110
119
|
order = Order.objects.create(
|
111
120
|
customer=user,
|
112
121
|
payment_method=payment_method,
|
113
|
-
extra_infos=
|
114
|
-
"is_wallet_fill_up": True,
|
115
|
-
"amount": str(amount),
|
116
|
-
"currency": self.currency,
|
117
|
-
},
|
122
|
+
extra_infos=extra_infos,
|
118
123
|
)
|
119
124
|
payment = Payment.objects.create(
|
120
125
|
orders=[
|
@@ -125,7 +130,8 @@ class Wallet(models.Model):
|
|
125
130
|
method=payment_method,
|
126
131
|
amount=amount,
|
127
132
|
)
|
128
|
-
|
133
|
+
tap_payment = payment.tap_payment
|
134
|
+
return (tap_payment.payment_url, tap_payment.charge_id)
|
129
135
|
|
130
136
|
|
131
137
|
class WalletTransaction(models.Model):
|
@@ -2,8 +2,8 @@ ob_dj_store/apis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
2
2
|
ob_dj_store/apis/stores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
ob_dj_store/apis/stores/filters.py,sha256=XEdKExJGKPGszKUxS5_LtyrAyGv3VyI-z8X5K6c5sxQ,8681
|
4
4
|
ob_dj_store/apis/stores/urls.py,sha256=P4d0iamg2R5lTwc5DTIuhLzJTMSH4f5QpHzGR1_PWE0,1676
|
5
|
-
ob_dj_store/apis/stores/views.py,sha256=
|
6
|
-
ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=
|
5
|
+
ob_dj_store/apis/stores/views.py,sha256=v-WZCpvY3Y9N3rmC6bG3R2NrhikFUDLey5KzaShwgs4,38160
|
6
|
+
ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=Ci4sVCaI56oOcT-e2thBc8EiOL_NB-ok2vMkzVvq-d0,50663
|
7
7
|
ob_dj_store/apis/tap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
ob_dj_store/apis/tap/serializers.py,sha256=KPrBK4h2-fWvEVf6vOj2ww5-USV9WqpyYicIqoHIiXI,1065
|
9
9
|
ob_dj_store/apis/tap/urls.py,sha256=bnOTv6an11kxpo_FdqlhsizlGPLVpNxBjCyKcf3_C9M,367
|
@@ -129,12 +129,12 @@ ob_dj_store/core/stores/models/_order.py,sha256=VHBp3LMveedHNbS7vxP7PE_H_g9t8qgs
|
|
129
129
|
ob_dj_store/core/stores/models/_payment.py,sha256=mz54fuxmcNQ1pVBC959f7gnbIld1haxIYK0Xuv6UVoM,6320
|
130
130
|
ob_dj_store/core/stores/models/_product.py,sha256=jWbhk-oXngLdHqBTnHNokzN_MhcBArsD1R7UjOnfAzY,15287
|
131
131
|
ob_dj_store/core/stores/models/_store.py,sha256=NnyXG7_L_UYrNKaQYuHOBEWc6DQqAPd1OZJg0xOccKk,8005
|
132
|
-
ob_dj_store/core/stores/models/_wallet.py,sha256=
|
132
|
+
ob_dj_store/core/stores/models/_wallet.py,sha256=8wi-H0HMFOdDPc1LbKkQBMGAymiLvBWq2djnN_BicRI,5327
|
133
133
|
ob_dj_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
134
134
|
ob_dj_store/utils/helpers.py,sha256=o7wgypM7mI2vZqZKkhxnTcnHJC8GMQDOuYMnRwXr6tY,2058
|
135
135
|
ob_dj_store/utils/model.py,sha256=DV7hOhTaZL3gh9sptts2jTUFlTArKG3i7oPioq9HLFE,303
|
136
136
|
ob_dj_store/utils/utils.py,sha256=8UVAFB56qUSjJJ5f9vnermtw638gdFy4CFRCuMbns_M,1342
|
137
|
-
ob_dj_store-0.0.15.
|
138
|
-
ob_dj_store-0.0.15.
|
139
|
-
ob_dj_store-0.0.15.
|
140
|
-
ob_dj_store-0.0.15.
|
137
|
+
ob_dj_store-0.0.15.11.dist-info/METADATA,sha256=YtVs5vlD_R72FW4Xq4IAQzLxVUFrN9iF6N8O9NZtEUM,2828
|
138
|
+
ob_dj_store-0.0.15.11.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
139
|
+
ob_dj_store-0.0.15.11.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
|
140
|
+
ob_dj_store-0.0.15.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|