-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
167 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
__version__ = '1.21.0' | ||
__version__ = '1.22.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
8 changes: 8 additions & 0 deletions
8
erpnextswiss/erpnextswiss/doctype/payrexx_settings/payrexx_settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2023, libracore (https://www.libracore.com) and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.ui.form.on('Payrexx Settings', { | ||
// refresh: function(frm) { | ||
|
||
// } | ||
}); |
62 changes: 62 additions & 0 deletions
62
erpnextswiss/erpnextswiss/doctype/payrexx_settings/payrexx_settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"creation": "2023-06-08 22:05:50.215665", | ||
"doctype": "DocType", | ||
"editable_grid": 1, | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"payrexx_instance", | ||
"payrexx_api_key", | ||
"col_main", | ||
"success_url" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "payrexx_api_key", | ||
"fieldtype": "Data", | ||
"label": "Payrexx API Key" | ||
}, | ||
{ | ||
"fieldname": "col_main", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fieldname": "success_url", | ||
"fieldtype": "Data", | ||
"label": "Success URL" | ||
}, | ||
{ | ||
"fieldname": "payrexx_instance", | ||
"fieldtype": "Data", | ||
"label": "Payrexx Instance" | ||
} | ||
], | ||
"issingle": 1, | ||
"modified": "2023-06-08 22:19:41.458200", | ||
"modified_by": "Administrator", | ||
"module": "ERPNextSwiss", | ||
"name": "Payrexx Settings", | ||
"owner": "Administrator", | ||
"permissions": [ | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"print": 1, | ||
"read": 1, | ||
"role": "System Manager", | ||
"share": 1, | ||
"write": 1 | ||
}, | ||
{ | ||
"email": 1, | ||
"print": 1, | ||
"read": 1, | ||
"role": "Sales User", | ||
"share": 1 | ||
} | ||
], | ||
"quick_entry": 1, | ||
"sort_field": "modified", | ||
"sort_order": "DESC", | ||
"track_changes": 1 | ||
} |
10 changes: 10 additions & 0 deletions
10
erpnextswiss/erpnextswiss/doctype/payrexx_settings/payrexx_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2023, libracore (https://www.libracore.com) and contributors | ||
# For license information, please see license.txt | ||
|
||
from __future__ import unicode_literals | ||
# import frappe | ||
from frappe.model.document import Document | ||
|
||
class PayrexxSettings(Document): | ||
pass |
10 changes: 10 additions & 0 deletions
10
erpnextswiss/erpnextswiss/doctype/payrexx_settings/test_payrexx_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2023, libracore (https://www.libracore.com) and Contributors | ||
# See license.txt | ||
from __future__ import unicode_literals | ||
|
||
# import frappe | ||
import unittest | ||
|
||
class TestPayrexxSettings(unittest.TestCase): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2021-2023, libracore and contributors | ||
# For license information, please see license.txt | ||
|
||
from __future__ import unicode_literals | ||
import frappe | ||
from frappe import _ | ||
import urllib.request | ||
import requests | ||
import hmac | ||
import hashlib | ||
import base64 | ||
import json | ||
from datetime import date, timedelta | ||
|
||
API_BASE = "https://api.payrexx.com/v1.0/" | ||
|
||
@frappe.whitelist() | ||
def create_payment(title, description, reference, purpose, amount, | ||
vat_rate, sku, currency, success_url): | ||
post_data = { | ||
"title": title, | ||
"description": description, | ||
"psp": 1, | ||
"referenceId": reference, | ||
"purpose": purpose, | ||
"amount": amount, | ||
"vatRate": vat_rate, | ||
"currency": currency, | ||
"sku": sku, | ||
"preAuthorization": 0, | ||
"reservation": 0, | ||
"successRedirectUrl": success_url | ||
} | ||
data = urllib.parse.urlencode(post_data).encode('utf-8') | ||
settings = frappe.get_doc("Payrexx Settings", "Payrexx Settings") | ||
if not settings.payrexx_api_key: | ||
frappe.throw( _("Please set payrexx API key in the Payrexx settings.") ) | ||
dig = hmac.new(settings.payrexx_api_key.encode('utf-8'), msg=data, digestmod=hashlib.sha256).digest() | ||
post_data['ApiSignature'] = base64.b64encode(dig).decode() | ||
data = urllib.parse.urlencode(post_data, quote_via=urllib.parse.quote).encode('utf-8') | ||
r = requests.post("{0}Invoice/?instance={1}".format(API_BASE, settings.payrexx_instance), data=data) | ||
response = json.loads(r.content.decode('utf-8')) | ||
invoice = response['data'][0] | ||
return invoice | ||
|
||
@frappe.whitelist() | ||
def get_payment_status(payrexx_id): | ||
post_data = {} | ||
data = urllib.parse.urlencode(post_data).encode('utf-8') | ||
settings = frappe.get_doc("Payrexx Settings", "Payrexx Settings") | ||
if not settings.payrexx_api_key: | ||
frappe.throw( _("Please set payrexx API key in the Payrexx settings.") ) | ||
dig = hmac.new(settings.payrexx_api_key.encode('utf-8'), msg=data, digestmod=hashlib.sha256).digest() | ||
post_data['ApiSignature'] = base64.b64encode(dig).decode() | ||
data = urllib.parse.urlencode(post_data, quote_via=urllib.parse.quote).encode('utf-8') | ||
r = requests.get("{0}Invoice/{2}/?instance={1}".format(API_BASE, settings.payrexx_instance, payrexx_id), data=data) | ||
response = json.loads(r.content.decode('utf-8')) | ||
invoice = response['data'][0] | ||
return invoice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters