mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
Merge branch 'version-13-hotfix' of https://github.com/frappe/erpnext into e-commerce-refactor
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: Amazon MWS Settings", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new Amazon MWS Settings
|
||||
() => frappe.tests.make('Amazon MWS Settings', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: GoCardless Mandate", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new GoCardless Mandate
|
||||
() => frappe.tests.make('GoCardless Mandate', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: GoCardless Settings", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new GoCardless Settings
|
||||
() => frappe.tests.make('GoCardless Settings', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: Plaid Settings", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new Plaid Settings
|
||||
() => frappe.tests.make('Plaid Settings', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: QuickBooks Migrator", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new QuickBooks Migrator
|
||||
() => frappe.tests.make('QuickBooks Migrator', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: Tally Migration", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new Tally Migration
|
||||
() => frappe.tests.make('Tally Migration', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: Woocommerce Settings", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new Woocommerce Settings
|
||||
() => frappe.tests.make('Woocommerce Settings', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
||||
@@ -2,11 +2,12 @@
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import stripe
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.integrations.utils import create_request_log
|
||||
import stripe
|
||||
|
||||
|
||||
def create_stripe_subscription(gateway_controller, data):
|
||||
stripe_settings = frappe.get_doc("Stripe Settings", gateway_controller)
|
||||
@@ -23,31 +24,38 @@ def create_stripe_subscription(gateway_controller, data):
|
||||
except Exception:
|
||||
frappe.log_error(frappe.get_traceback())
|
||||
return{
|
||||
"redirect_to": frappe.redirect_to_message(_('Server Error'), _("It seems that there is an issue with the server's stripe configuration. In case of failure, the amount will get refunded to your account.")),
|
||||
"redirect_to": frappe.redirect_to_message(
|
||||
_('Server Error'),
|
||||
_("It seems that there is an issue with the server's stripe configuration. In case of failure, the amount will get refunded to your account.")
|
||||
),
|
||||
"status": 401
|
||||
}
|
||||
|
||||
|
||||
def create_subscription_on_stripe(stripe_settings):
|
||||
items = []
|
||||
for payment_plan in stripe_settings.payment_plans:
|
||||
plan = frappe.db.get_value("Subscription Plan", payment_plan.plan, "payment_plan_id")
|
||||
items.append({"plan": plan, "quantity": payment_plan.qty})
|
||||
items = []
|
||||
for payment_plan in stripe_settings.payment_plans:
|
||||
plan = frappe.db.get_value("Subscription Plan", payment_plan.plan, "product_price_id")
|
||||
items.append({"price": plan, "quantity": payment_plan.qty})
|
||||
|
||||
try:
|
||||
customer = stripe.Customer.create(description=stripe_settings.data.payer_name, email=stripe_settings.data.payer_email, source=stripe_settings.data.stripe_token_id)
|
||||
subscription = stripe.Subscription.create(customer=customer, items=items)
|
||||
try:
|
||||
customer = stripe.Customer.create(
|
||||
source=stripe_settings.data.stripe_token_id,
|
||||
description=stripe_settings.data.payer_name,
|
||||
email=stripe_settings.data.payer_email
|
||||
)
|
||||
|
||||
if subscription.status == "active":
|
||||
stripe_settings.integration_request.db_set('status', 'Completed', update_modified=False)
|
||||
stripe_settings.flags.status_changed_to = "Completed"
|
||||
subscription = stripe.Subscription.create(customer=customer, items=items)
|
||||
|
||||
else:
|
||||
stripe_settings.integration_request.db_set('status', 'Failed', update_modified=False)
|
||||
frappe.log_error('Subscription N°: ' + subscription.id, 'Stripe Payment not completed')
|
||||
if subscription.status == "active":
|
||||
stripe_settings.integration_request.db_set('status', 'Completed', update_modified=False)
|
||||
stripe_settings.flags.status_changed_to = "Completed"
|
||||
|
||||
except Exception:
|
||||
else:
|
||||
stripe_settings.integration_request.db_set('status', 'Failed', update_modified=False)
|
||||
frappe.log_error(frappe.get_traceback())
|
||||
frappe.log_error('Subscription N°: ' + subscription.id, 'Stripe Payment not completed')
|
||||
except Exception:
|
||||
stripe_settings.integration_request.db_set('status', 'Failed', update_modified=False)
|
||||
frappe.log_error(frappe.get_traceback())
|
||||
|
||||
return stripe_settings.finalize_request()
|
||||
return stripe_settings.finalize_request()
|
||||
|
||||
Reference in New Issue
Block a user