summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2025-09-08 10:19:30 +0000
committerIT Fixcomart <it@fixcomart.co.id>2025-09-08 10:19:30 +0000
commit4db6034c07414dcd09292e3c41d6fd4598868148 (patch)
treed551d57e6e13c35673f309be1a844d8cd1db98dd /indoteknik_custom/models
parent59f5cc5ffdfccbcbeaacc150457c57625344f49b (diff)
parent8cf34c73b9276f88499b056c0a7070a3464f3367 (diff)
Merged in regenerate_midtrans_web (pull request #397)
<Miqdad> Regenerate midtrans web
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/sale_order.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 903f834b..9952af9a 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -1899,26 +1899,30 @@ class SaleOrder(models.Model):
# raise UserError('Kelurahan Real Delivery Address harus diisi')
def generate_payment_link_midtrans_sales_order(self):
- # midtrans_url = 'https://app.sandbox.midtrans.com/snap/v1/transactions' # dev - sandbox
- # midtrans_auth = 'Basic U0ItTWlkLXNlcnZlci1uLVY3ZDJjMlpCMFNWRUQyOU95Q1dWWXA6' # dev - sandbox
- midtrans_url = 'https://app.midtrans.com/snap/v1/transactions' # production
- midtrans_auth = 'Basic TWlkLXNlcnZlci1SbGMxZ2gzWGpSVW5scl9JblZzTV9OTnU6' # production
+ # midtrans_url = 'https://app.sandbox.midtrans.com/snap/v1/transactions' # dev - sandbox
+ # midtrans_auth = 'Basic U0ItTWlkLXNlcnZlci1uLVY3ZDJjMlpCMFNWRUQyOU95Q1dWWXA6' # dev - sandbox
+ midtrans_url = 'https://app.midtrans.com/snap/v1/transactions' # production
+ midtrans_auth = 'Basic TWlkLXNlcnZlci1SbGMxZ2gzWGpSVW5scl9JblZzTV9OTnU6' # production
+
so_number = self.name
so_number = so_number.replace('/', '-')
so_grandtotal = math.floor(self.grand_total)
+
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': midtrans_auth,
}
- check_url = f'https://api.midtrans.com/v2/{so_number}/status'
- check_response = requests.get(check_url, headers=headers)
+ # ==== ENV ====
+ # check_url = f'https://api.sandbox.midtrans.com/v2/{so_number}/status' # dev - sandbox
+ check_url = f'https://api.midtrans.com/v2/{so_number}/status' # production
+ # =============================================
+ check_response = requests.get(check_url, headers=headers)
if check_response.status_code == 200:
status_response = check_response.json()
- if status_response.get('transaction_status') == 'expire' or status_response.get(
- 'transaction_status') == 'cancel':
+ if status_response.get('transaction_status') in ('expire', 'cancel'):
so_number = so_number + '-cpl'
json_data = {
@@ -1950,7 +1954,6 @@ class SaleOrder(models.Model):
buffer = BytesIO()
img.save(buffer, format="PNG")
qr_code_img = base64.b64encode(buffer.getvalue()).decode()
-
self.payment_qr_code = qr_code_img
@api.model