From f765599a29261fa2424a01d1fb6036b2d694ac9c Mon Sep 17 00:00:00 2001 From: Preshh0 Date: Mon, 9 May 2022 13:56:48 +0100 Subject: [PATCH] Changed sdk ile, trying to see if this will work. --- .gitignore | 3 +- db.sqlite3 | Bin 188416 -> 196608 bytes myshop/__pycache__/settings.cpython-38.pyc | Bin 3071 -> 3201 bytes myshop/settings.py | 7 +- .../0003_alter_order_id_alter_orderitem_id.py | 23 ++++ ...order_id_alter_orderitem_id.cpython-38.pyc | Bin 0 -> 691 bytes payment/__pycache__/models.cpython-38.pyc | Bin 173 -> 940 bytes payment/__pycache__/urls.cpython-38.pyc | Bin 408 -> 437 bytes payment/__pycache__/views.cpython-38.pyc | Bin 1442 -> 2827 bytes payment/migrations/0001_initial.py | 26 +++++ payment/migrations/0002_paywithcrypto_coin.py | 18 +++ .../__pycache__/0001_initial.cpython-38.pyc | Bin 0 -> 843 bytes .../0002_paywithcrypto_coin.cpython-38.pyc | Bin 0 -> 594 bytes payment/models.py | 7 +- payment/services.py | 105 ++++++------------ payment/urls.py | 5 +- payment/views.py | 92 +++++++++++---- requirements.txt | 13 +++ ...0002_alter_category_id_alter_product_id.py | 23 ++++ ...ategory_id_alter_product_id.cpython-38.pyc | Bin 0 -> 679 bytes 20 files changed, 221 insertions(+), 101 deletions(-) create mode 100644 orders/migrations/0003_alter_order_id_alter_orderitem_id.py create mode 100644 orders/migrations/__pycache__/0003_alter_order_id_alter_orderitem_id.cpython-38.pyc create mode 100644 payment/migrations/0001_initial.py create mode 100644 payment/migrations/0002_paywithcrypto_coin.py create mode 100644 payment/migrations/__pycache__/0001_initial.cpython-38.pyc create mode 100644 payment/migrations/__pycache__/0002_paywithcrypto_coin.cpython-38.pyc create mode 100644 shop/migrations/0002_alter_category_id_alter_product_id.py create mode 100644 shop/migrations/__pycache__/0002_alter_category_id_alter_product_id.cpython-38.pyc diff --git a/.gitignore b/.gitignore index a89c381..b12df90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ venv db.sqlite3 -Pipfile \ No newline at end of file +Pipfile* +staticfiles \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index 7b2b5e793bbe96f172daf25d9e6145eb661e2821..664d9c3c9505ca80b6ae883f3d3b5f4897f63463 100644 GIT binary patch delta 2170 zcmah~Yitu&7M^=&#`f5buUSG~X2~QFf{7pF@fh2QU~AGq2?@cJN9aSw*kgMjv5n&p z2UeSmP$CgZLTZUCAyq}Rs#I;ou8E3&wA~`M6;*eaA#uDO*=48yz2((|JJ<#0XiBDfv_^H=fOBBC(8;76nms3O=V0-YU5xic{-g=g5JQ~X6;&N_;g!3+e7Zv}DwfL*#<>4oyRf35=zu*zYI#O6$Rbifp zl2-Ccbf|g<7O~Uo@APFWgqj)j01cpb&}no5T|u9qAbJzYsJW#6 zY}wFEHPq35!xCl7>8f2@>~eR2b;YE6BXATixSK(3@we_RIukhy>o1D;-J6>mjbv>? zTPXAp{Rw@F-a}W>5wsI+A-Tp;s-zlGQzK(*2TK{2orkHo^H;aY4%;d84Z4p$M(?6m z(F`h}Bsz>jsJ*0esHwrkP`38f;Kk6uA8CiVP}J`a8_ajiZ<*)Kg_7D}PBt*W15BqC zd2D$_jwS~9fGI8y$$5FXsiR_wrK0KN3e(nl2DpJK8jmlB*cZNfp~ZXo7St{1uKt9| z%p>p^-S|Dj(+O99XJRVe6=rg@DRo-oR5t-)7%L+T(1UuacsG)#rFCs11} zs1>vgEVi2ls~A?oTy_F;cRfj|1|dAJ^e;cY512ZQ>9WoWzenrIrPCfjWHXUXL^cv> zCBiSP$^HYC0S|w6Uz@a+t^464gde>RYs*X)K1Me$L14ABS12pI3k_|CFZHwR7sg+6 z|Kxg^FW777T+K&Joc;AlQUU7vZyD0JF0& zh(DZ#>+yzJSc}uMa1+>v&2z93zcmXRL96Cy)7CZk;Vk?m=+}%Q;4Av)=AfNc1AA~R z1vZ1Ncs>Ev;#X4OH&)KZ*(d`khzj=V>igSqivk*OcM7a$gmbPQ{Ph&c(s!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$+p1ey zAhVlIX3-1l*|jWw@gMT3X*3YdnELx*(H$M^=hLWxmwD3YX1|}tRVhw7viB@PU^{LZRJ#$vugEdwP#X zw7&6^!Q&%=MBn)S<73_7@#s+Za4--Iwge(AZEc=lC>GfiYtvdo(P(=xD${)ds31^* w?&n>}IT9N!J-~jt&TsVV9o%3CdMMCCy32<*2{z~AwRO*1;_&~DIJ=DMKlN}200000 diff --git a/myshop/__pycache__/settings.cpython-38.pyc b/myshop/__pycache__/settings.cpython-38.pyc index a7a14d567d13cc49e0d7d5b2499b0b3c3759bfd9..c68b612879e7c711db91aa88aa1112167fcae296 100644 GIT binary patch delta 598 zcmZuuO>YuW6rDGWWnlPjDWwJaMODDk`dPmfZApwInpieBF%#fC#;L%N8Hj?5#)a-& zG;CSO#>9;q{ta6b|ABF-50W-rcu&sBy*DTK-n{oW_A#C-`~6-?gyZW~{{$uJ=d?H< znkXI%IuB2BnPbd-k!g;zBllPJoO-x-#HJt(Zt_7TKRob4Gh7sa4}Js?LTrQV6RQ#+o5P#X2^yi8Quw(YRnTTpAuL2BQcr(>yZB&JI}M z8ge5USBA35D2i?5g>@S{Gu@r(Rg)PCE#ex*aGjRKd2zvI!IiTaH%2lgaFdc}om(Th z&M1XFT0QM0a9h~caEI1$mo{*ZHgTWQkY7oe2je>1W5GbF(&zTeO7CgIXHHz#C5fiD?wN9jj>a1~OX{x30sg>H0*r911t4``eXXUJSOnc8w1{c`{y7 zPy6E^o+e99BKrr$Lb-IP7s`h(^y0IF(*AeJ&WfM5vxBtuXm==5#iuf#tO)pA3Af@> SWbd5J{)692XmFyngz+EKvzVIz delta 441 zcmYjNIZpy%5Z&)%We=81P*_Az@LJdVz@t%nJEO%UW`jQ5U{nk?YN0Vkd$Wy&g==SH zgFnLGU~BBHZ1sag;!NJl94|AIxiWuJ_GUP&OTup6wstO}lJwC`{#&!VDsWP|v#rZ( zPQ1eQgOAETRx6s%noc@`6oNtqRA|uM0EH2PfiNP7B8E6RkwDVbDS|F^BZV|fWYB}G zt5Oub6hqFHpdgPv^rL_x2HcJ+!{CGLGP;aoh&nNhk=FV|MTg~cj6U!xqa->rEI%0=kq;Ay_lz5yH@gflJZ!fJ}go{ zmZ$)}Az90fBeuXab-jFEsUMfmyjOnOSPN{k#*18)IR(9(c57P2cg1l~+jX3GUOOT6 t;7|UkS&g)Q$h2pvZiz?NE$=C`61^9pY^coOvT)t|3S|S|a>R=pN5Av=Yg7OL diff --git a/myshop/settings.py b/myshop/settings.py index 2fa38c1..8d0d58f 100644 --- a/myshop/settings.py +++ b/myshop/settings.py @@ -11,13 +11,13 @@ """ import os -from lazerpay import Lazerpay +from lazerpay.resource import LazerPayClient LAZER_PUBLIC_KEY = 'pk_test_XN33dNcIN8nOsaOc90ZYdjIn176Ix8unyqr9KRLtURL8ZgSPbo' LAZER_SECRET_KEY = 'sk_test_vvqDUkFETASs5U7eA6awsRBd1e6pVvb0cwuecK6GNaFeVwSJb2' -lazerpay = Lazerpay(LAZER_PUBLIC_KEY, LAZER_SECRET_KEY) +lazerpay = LazerPayClient(pubKey=LAZER_PUBLIC_KEY, secretKey=LAZER_SECRET_KEY) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -138,7 +138,7 @@ STATIC_URL = '/static/' STATICFILES_DIRS = ( - os.path.join(BASE_DIR, 'static'), + os.path.join(BASE_DIR, 'shop/static'), ) MEDIA_URL = '/media/' @@ -150,3 +150,4 @@ STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' \ No newline at end of file diff --git a/orders/migrations/0003_alter_order_id_alter_orderitem_id.py b/orders/migrations/0003_alter_order_id_alter_orderitem_id.py new file mode 100644 index 0000000..ab012f6 --- /dev/null +++ b/orders/migrations/0003_alter_order_id_alter_orderitem_id.py @@ -0,0 +1,23 @@ +# Generated by Django 4.0.3 on 2022-05-09 12:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('orders', '0002_order_lazerpay_id'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='orderitem', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + ] diff --git a/orders/migrations/__pycache__/0003_alter_order_id_alter_orderitem_id.cpython-38.pyc b/orders/migrations/__pycache__/0003_alter_order_id_alter_orderitem_id.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8955b544de282fa66c4d08639a2c390aaf00c003 GIT binary patch literal 691 zcmZuv&2H2%5O$oOCTS}5gn$P?%B5Ms6`>ZPA`a|@a>>Q=?hIKk`NPg4rB}G_gYZhe za^e*#AsBm$x(CMcX#VV(@3TLio#l*VF6PyqGxpOt#}biqN!vUl1q_0gbwM3;yygLW z%YZ}pok57fHvAUWAw(Zo8ULbMR&twns?l;%LvL)-4S=m#yVS9`_LsEHk`%H!09JDd znxGCb+QzN{CfgH;XvL7g$v%Q~f5>J3&o#VGA*Vr3ZT9}(1T;=EXh3c3qs3zJTzE&c z@)q?dXQ9BxK4iIqn`_J8y(uGG$lWxEwMIE1*way~PU=~F#@S{DwUVv6MO%DDy&4RP zUUpc9gxg{Do{e10#-9|nP-nh_ny_1znN5W+5yIv|(2-q>WEVnw*~!)&a~|M`Jz&39 zXf(YLv-wp!p}uw(>d*y>*Q&XqIep0H!-)5!|6uwt6?k=bQ*DM0t5KubY!($24dc)% zoT>vY)x%>|M9>Q%U7LHF6dbz_01IcD2@V7>-_hTb?57rL}&(E h**C)ltUMSGz$YIjJy=iZKAXNg(DKURG!FfF_!r((zX|{V literal 0 HcmV?d00001 diff --git a/payment/__pycache__/models.cpython-38.pyc b/payment/__pycache__/models.cpython-38.pyc index 04c04927cdb4ec80d465c497cd8cffd3831c0f68..6e7a03ac400c359d43cd5b07e07c0ec985114247 100644 GIT binary patch literal 940 zcmY*Y%}yIJ5VrR(n{5&(s*3su;XwKTsH&i)>Y)e;p-OwP%zBdS;@u6lmy#+yfy9YE z0~~pip85d3RXybudg^#XrF5kE^Vr|~?Cfd3pAe)UgZbG{kC5NaS*HMg6xYk98&`zhV-qiJ7Ls>B+l;p{GI&*^YoQZ=_kiLho=$ zRfIaDDE^Ua#Yf&i)_W)xq`-+8dhZGPK)?A0+bY6^?@Dw{X|nJagpmtkI@hF#7j)r$ zrxXW^1^P$JO~k;Gx(ddipvqv_Rb4!@9SxZRqix^R=TNamNzL(&%WgaMSpgXaqj4?` zC>z05uF(&5GebAf{1S!%YLH_aa5cfJ=U<#|(H}7*W0~YyGxkXS?2M*$38R?;J)OQD zAw)f^We#RE-fP2QJ0m#dQyoNc#{Yn_|?687`S$I8G2o?b+} zteeW%IBS%f;@k#VomZ<#_V(*q0rXi&=>m&f0du z&D<@BcD={6hwVB!K<;^MbQmf(4%-z4uO{`bI9qiUesaG=du0u|&Eb%3ytkUk8@FWI JZ5IOje*qb1@9zKr literal 173 zcmWIL<>g`kg0vH1NtQtRF^Gc(44TX@fuanW zjJMcw^HWlDiv2X1ZgHk$CFZ5)>!lz}fqp@1 qQGP*wPG)L}enDboZfahMKExcog34PQHb8c1PO2RvQ2S>fW&i*HrYMX6 diff --git a/payment/__pycache__/urls.cpython-38.pyc b/payment/__pycache__/urls.cpython-38.pyc index cffd8f2076cd4d514cf298623a7445b12d3b7562..5b3332994fa366d44170381d95f8ee93bf5ad24a 100644 GIT binary patch literal 437 zcmYk2u};G<5Qgm}t=%LoJO*WGcmRZuSP`lOUA$B#KAJ!hTXqU+S7zP;MqbG)Q^gy= zf=yDySw8)Dw*K$z#dsVe7oYLwc7YN4@WuZit~htw%v};l;0o24VT?o|!Ya5yB4Qz6 zF@Q)61$ptB!a$6A9mDXIyrJj7^%J0-UPWvq(rYvw@0=@|VjC&m7CSe9FYvJ?if?LY z+AURD=3q?bTAlK@8(zb9l=CKs3Pi@}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`%EuxqOnYnUZS>1)FrAaeBeorJk>^>_K0{ z9w(Qgeg*@=3A`~Gk_icMhzTKxd?0_uaY#Zk#Ie(PKK3zj?+5=c^*NmS7v~-S-4E7r z-dzd?SWoda0e+FA=CIGk^{{J@a(BZWR-eGsm9iT?gQe{|o_E%;qn$Cr>Pr~^PuNF& z*q$u^gjQdGum1+_$(8r^Pr;}U{utz=*@2zXRZ%bGTrZ_E<;Li)i(O+oI@!_Qpp^BQ zau-21?x?8em84AQ9pB>qhf*<^xSK~^aG;a=7?vHtUAfAIy_cu!y6RAhzXo?3!CpG- T^#d3Z?_t+U*G!+pk7Ms|3&eVO diff --git a/payment/migrations/0001_initial.py b/payment/migrations/0001_initial.py new file mode 100644 index 0000000..8d86f79 --- /dev/null +++ b/payment/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 4.0.3 on 2022-05-09 12:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='PayWithCrypto', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=225)), + ('email', models.EmailField(max_length=254)), + ('amount', models.PositiveBigIntegerField()), + ('currency', models.CharField(max_length=225)), + ('reference', models.CharField(max_length=25)), + ('successful', models.BooleanField(default=False)), + ], + ), + ] diff --git a/payment/migrations/0002_paywithcrypto_coin.py b/payment/migrations/0002_paywithcrypto_coin.py new file mode 100644 index 0000000..5844de3 --- /dev/null +++ b/payment/migrations/0002_paywithcrypto_coin.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.3 on 2022-05-09 12:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('payment', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='paywithcrypto', + name='coin', + field=models.CharField(default='USDC', max_length=225), + ), + ] diff --git a/payment/migrations/__pycache__/0001_initial.cpython-38.pyc b/payment/migrations/__pycache__/0001_initial.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..83d5b237696692d1a7f1fd6e97bdf3f93771fb0e GIT binary patch literal 843 zcmY*X&u`N(6t=8_1VNDv5gyQ`_tA?y;lCoI)*55Uh}j^MiRPtLxv}j`2}sS%U0q)xf_*&Z zGa4Wf6(nMUMqWZ9A6m<{O97o_S5Vx(Xo>d9pEJ?HZ#~f!y%j|iAPPi(i$dsp>3=2o zeehq@ut7JrQ9Fo2WW4DZl8(5wVhN1~;x*6nQ!V=DbSF5!0@t zwmp}S3Ue|V+HTzBjbj_cF}^~T0{USbzpHraYC+VIxh%0-8ww~O7nnwZ(acfxr;WU0 z_kJ2@gxK&vCeKj#q03==(*@TXH+bO`Z2UW?${^D9&-;( zm-)>1eahG_9pVleJN(5i{Xb3Q2|i>`EP0-&J#p5EZge)6S0!z{2gqoe^vk Hmv+3r3A67s literal 0 HcmV?d00001 diff --git a/payment/migrations/__pycache__/0002_paywithcrypto_coin.cpython-38.pyc b/payment/migrations/__pycache__/0002_paywithcrypto_coin.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b9606d13d8d285823e0dfd2df736c162aa52f694 GIT binary patch literal 594 zcmY*WJ#X7E5apL_*|3XD?LR2s#d13rMT!*3)GR?3Ed=AcSTrb7m1MM@+bzfs$xkY` zqEr4tfFM08DUzOW4}826-#zktKA$p*U$6ETSDdjwiM$L&K^%ElR=J z2?GK0Cj*ImD}TsRf;wZ1?3Q}jLd0opH?8Sy@Le3$0nl~pRC*a>B8QaSk^ouBft3RI zhL;l6HcJ9H+Kxd%2BT{M<7-K^9C8wx#L1U`3M4mf%)Un7$JuJNdZ(?oy)~|!)Al#p zSL=4)^dYKsus*8uv(HDjzezLw2zY6BuBU;`ckR$``f4GGrIEEaHAXdHc4^VUDGBF# z*w;EvwWhwELt4+Y{<fOmuQonReiD8XA1Ms~gt7 zrs@E9$3+!tESeU(s#+D)6q?{H_QjLi;`x#b^8H@_XICe;%VyuEha6FM2L!nk4=Ph! u&^NnR4@32Iq2dI##&5zBE{1uBDTm_oM31XCbV|%WJUaiF%yh}%f&2@X2%szg literal 0 HcmV?d00001 diff --git a/payment/models.py b/payment/models.py index 335db34..2d4f493 100644 --- a/payment/models.py +++ b/payment/models.py @@ -7,12 +7,13 @@ class PayWithCrypto(models.Model): email = models.EmailField() amount = models.PositiveBigIntegerField() currency = models.CharField(max_length=225) + coin = models.CharField(max_length=225, default="USDC") reference = models.CharField(max_length=25) + successful = models.BooleanField(default=False) - def save(self): + def save(self, *args, **kwargs): while not self.reference: reference = secrets.token_urlsafe(16) if not PayWithCrypto.objects.filter(reference=reference).exists(): self.reference = reference - - super().save() \ No newline at end of file + super().save(*args, **kwargs) \ No newline at end of file diff --git a/payment/services.py b/payment/services.py index 1b6430c..15d2e9e 100644 --- a/payment/services.py +++ b/payment/services.py @@ -1,86 +1,53 @@ -from lazerpay import Lazerpay +from lazerpay.resource import LazerPayClient from myshop.settings import * -lazerpay = Lazerpay(LAZER_PUBLIC_KEY, LAZER_SECRET_KEY) -from myshop.settings import lazerpay -''' -Initialize payment -''' -async def payment_tx(data): - transaction_payload = { - 'reference': data['reference'], # Replace with a reference you generated - 'customer_name': 'Njoku Emmanuel', - 'customer_email': 'kalunjoku123@gmail.com', - 'coin': 'BUSD', # BUSD, DAI, USDC or USDT - 'currency': 'USD', # NGN, AED, GBP, EUR - 'amount': 100, - 'accept_partial_payment': True, # By default it's false - } - - response = await lazerpay.payment.initialize_payment(transaction_payload) - print(response) -''' -Confirm Payment -''' +lazerpay = LazerPayClient(pubKey=LAZER_PUBLIC_KEY, secretKey=LAZER_SECRET_KEY) -async def confirm_tx (): - transaction_payload = { - 'identifier': '0xa523F92BBF59bB19FCc7020A7e9004A05B697C25', - } - response = await lazerpay.payment.confirm_payment(transaction_payload) - print(response) ''' -Create a payment link +Initialize payment ''' -async def test_create_link(): - transaction_payload = { - 'title': 'Njoku Test', - 'description': 'Testing this sdk', - 'logo': - 'https://assets.audiomack.com/fireboydml/bbbd8710eff038d4f603cc39ec94a6a6c2c5b6f4100b28d62557d10d87246f27.jpeg?width=340&height=340&max=true', - 'currency': 'USD', - 'type': 'standard', - 'amount': 100, - 'redirect_url': "https://keosariel.github.io" - } - - response = await lazerpay.payment_links.create_payment_link(transaction_payload) - print(response) - -''' -Update a payment link -''' -async def update_paymentLink (): - transaction_payload = { - "identifier": "pq9pgb", - "status": "inactive" - } - - response = await lazerpay.payment_links.update_payment_link(transaction_payload) - print(response) +try: + response = lazerpay.initTransaction( + reference="YOUR_REFERENCE", # Replace with a reference you generated + amount="10", + customer_name="Njoku Emmanuel", + customer_email="kalunjoku123@gmail.com", + coin="USDC", + currency="NGN", + accept_partial_payment=True # By default, it's false + ) +except Exception as e: + raise e ''' -Get all payment links +Confirm Payment ''' -async def get_all_paymentlinks(): - response = await lazerpay.payment_links.get_all_paymentlinks() - print(response) +try: + response = lazerpay.confirmPayment( + identifier="address generated or the reference generated by you from initializing payment" + ) +except Exception as e: + raise e ''' -Get a single payment link +Get Accepted Coins ''' -async def get_paymentlink (): - identifier = 'pq9pgb' - - response = await lazerpay.payment_links.get_paymentlink(identifier) - print(response) +try: + response = lazerpay.getAcceptedCoins() +except Exception as e: + raise e ''' -Get Accepted Coins +Payout ''' -async def get_accepted_coins (): - response = await lazerpay.misc.test_get_links() - print(response) \ No newline at end of file +try: + response = lazerpay.payout(amount=1, + recipient="0x0B4d358D349809037003F96A3593ff9015E89efA", + coin="BUSD", + blockchain="Binance Smart Chain" + ) +except Exception as e: + raise e \ No newline at end of file diff --git a/payment/urls.py b/payment/urls.py index 6ce2b1c..0be16b8 100644 --- a/payment/urls.py +++ b/payment/urls.py @@ -5,7 +5,8 @@ urlpatterns = [ path('process/', payment_process, name='process'), - path('done/', payment_done, name='done'), + # path('done/', payment_done, name='done'), path('canceled/', payment_canceled, name='canceled'), - path('apitest', PaymentLink.as_view()) + path('apitest', PaymentLink.as_view()), + path('confirm', ConfirmPayment.as_view()) ] \ No newline at end of file diff --git a/payment/views.py b/payment/views.py index afd3980..e4b9dcd 100644 --- a/payment/views.py +++ b/payment/views.py @@ -6,30 +6,38 @@ from django.shortcuts import render, redirect, get_object_or_404 from myshop.settings import lazerpay from orders.models import Order +from .models import PayWithCrypto -gateway = 'uwjdksidljjzld' +# gateway = 'uwjdksidljjzld' -async def payment_process(request): +def payment_process(request): order_id = request.session.get('order_id') order = get_object_or_404(Order, id=order_id) total_cost = order.get_total_cost() if request.method == 'POST': - transaction_payload = { - 'reference': 'YOUR_REFERENCE', # Replace with a reference you generated - 'customer_name': 'Njoku Emmanuel', - 'customer_email': 'kalunjoku123@gmail.com', - 'coin': 'BUSD', # BUSD, DAI, USDC or USDT - 'currency': 'USD', # NGN, AED, GBP, EUR - 'amount': total_cost, - 'accept_partial_payment': True, # By default it's false - } - - result = await lazerpay.payment.initialize_payment(transaction_payload) - result = result.json() - - if result['is_success']: + try: + payment_info = PayWithCrypto.objects.create( + name=request.data['name'], + email=request.data['email'], + currency=request.data['currency'], + coin=request.data['coin'] + ) + response = lazerpay.initTransaction( + reference=payment_info['reference'], # Replace with a reference you generated + amount=amount, + customer_name=payment_info['name'], + customer_email=payment_info['email'], + coin=payment_info['coin'], + currency=payment_info['currency'], + accept_partial_payment=True # By default, it's false + ) + return Response(response, status=status.HTTP_200_OK) + except Exception as e: + return Response(e, status=status.HTTP_400_BAD_REQUEST) + + if response['is_success']: #mark the order as paid order.paid = True @@ -40,13 +48,51 @@ def payment_canceled(request): class PaymentLink(APIView): def post(self, request): + order_id = request.session.get('order_id') + order = get_object_or_404(Order, id=order_id) + amount = order.get_total_cost() + try: - response = test_create_link(request.data) + payment_info = PayWithCrypto.objects.create( + name=request.data['name'], + email=request.data['email'], + currency=request.data['currency'], + amount=request.data['amount'], + coin=request.data['coin'] + ) + response = lazerpay.initTransaction( + reference=payment_info['reference'], # Replace with a reference you generated + amount=payment_info['amount'], + customer_name=payment_info['name'], + customer_email=payment_info['email'], + coin=payment_info['coin'], + currency=payment_info['currency'], + accept_partial_payment=True # By default, it's false + ) return Response(response, status=status.HTTP_200_OK) except Exception as e: - return Response( - { - 'message':e - }, - status=status.HTTP_400_BAD_REQUEST - ) \ No newline at end of file + return Response(e, status=status.HTTP_400_BAD_REQUEST) + +class ConfirmPayment(APIView): + def post(self, request): + try: + response_1 = lazerpay.confirmPayment( + identifier = request.data['reference']|request.data['address'] + ) + if response_1: + PayWithCrypto.objects.filter(reference=request.data['reference']).update(successful=True) + return Response( + { + 'message':'Payment Successful' + }, + status=status.HTTP_200_OK + ) + else: + return Response( + { + "message":"Payment Failed" + }, + status=status.HTTP_200_OK + ) + except Exception as e: + return Response(e, status=status.HTTP_400_BAD_REQUEST) diff --git a/requirements.txt b/requirements.txt index 682fef6..e535474 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,22 +1,35 @@ +aiohttp==3.8.1 +aiosignal==1.2.0 amqp==5.1.0 asgiref==3.5.0 +async-timeout==4.0.2 +attrs==21.4.0 backports.zoneinfo==0.2.1 billiard==3.6.4.0 celery==5.2.6 +charset-normalizer==2.0.12 click==8.1.2 click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.2.0 Django==4.0.3 djangorestframework==3.13.1 +flower==1.0.0 +frozenlist==1.3.0 gunicorn==20.1.0 +humanize==4.0.0 +idna==3.3 kombu==5.2.4 +multidict==6.0.2 Pillow==9.0.1 +prometheus-client==0.14.1 prompt-toolkit==3.0.29 pytz==2021.3 six==1.16.0 sqlparse==0.4.2 +tornado==6.1 tzdata==2022.1 vine==5.0.0 wcwidth==0.2.5 whitenoise==6.0.0 +yarl==1.7.2 diff --git a/shop/migrations/0002_alter_category_id_alter_product_id.py b/shop/migrations/0002_alter_category_id_alter_product_id.py new file mode 100644 index 0000000..764c6ac --- /dev/null +++ b/shop/migrations/0002_alter_category_id_alter_product_id.py @@ -0,0 +1,23 @@ +# Generated by Django 4.0.3 on 2022-05-09 12:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='category', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + migrations.AlterField( + model_name='product', + name='id', + field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), + ), + ] diff --git a/shop/migrations/__pycache__/0002_alter_category_id_alter_product_id.cpython-38.pyc b/shop/migrations/__pycache__/0002_alter_category_id_alter_product_id.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..69e77a927650ab48fc98843ce4b468ce74289449 GIT binary patch literal 679 zcmZuv&2H2%5O(bBZjz=_ujK)da%mRM2(<_m^}t>Vmt3rDX2^O;;$UZy(j#!~gYZhe za^e*#AsA=3>K+(tM)T|WX6%orrwJn(({cTcGxp0H#}txrNo=2!00u$B+MozpUhsgu zW57ZDU?4EqitnNj5Zw+jgA%wP_S`w*i0eJuWetmZ`o2?05A@%u*v1Shl`-Me(TT)vR1Q-dlS z7ggnewKk*U3O-yre)Bd9U0Uu2Eh~c*1b5OK)s|+IpK)}tMMH(^4qf^c&01TOUD;wL zXk0(yWVz7$-0YLW2Hc`I8g|vN%3>GEDM3n?NJ#~|21!q){IV+>U*s*o9y`FUQfLi5 z3v