mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
start upgrading eslint
This commit is contained in:
@@ -12,11 +12,12 @@ const nconf = require('nconf');
|
||||
const _ = require('lodash');
|
||||
const paypal = require('paypal-rest-sdk');
|
||||
const blocks = require('../website/common').content.subscriptionBlocks;
|
||||
|
||||
const live = nconf.get('PAYPAL_MODE') === 'live';
|
||||
|
||||
nconf.argv().env().file('user', path.join(path.resolve(__dirname, '../config.json')));
|
||||
|
||||
let OP = 'create'; // list get update create create-webprofile
|
||||
const OP = 'create'; // list get update create create-webprofile
|
||||
|
||||
paypal.configure({
|
||||
mode: nconf.get('PAYPAL_MODE'), // sandbox or live
|
||||
@@ -25,8 +26,8 @@ paypal.configure({
|
||||
});
|
||||
|
||||
// https://developer.paypal.com/docs/api/#billing-plans-and-agreements
|
||||
let billingPlanTitle = 'Habitica Subscription';
|
||||
let billingPlanAttributes = {
|
||||
const billingPlanTitle = 'Habitica Subscription';
|
||||
const billingPlanAttributes = {
|
||||
description: billingPlanTitle,
|
||||
type: 'INFINITE',
|
||||
merchant_preferences: {
|
||||
@@ -41,7 +42,7 @@ let billingPlanAttributes = {
|
||||
}],
|
||||
};
|
||||
|
||||
_.each(blocks, (block) => {
|
||||
_.each(blocks, block => {
|
||||
block.definition = _.cloneDeep(billingPlanAttributes);
|
||||
_.merge(block.definition.payment_definitions[0], {
|
||||
name: `${billingPlanTitle} ($${block.price} every ${block.months} months, recurring)`,
|
||||
@@ -57,17 +58,17 @@ _.each(blocks, (block) => {
|
||||
|
||||
switch (OP) {
|
||||
case 'list':
|
||||
paypal.billingPlan.list({status: 'ACTIVE'}, (err, plans) => {
|
||||
console.log({err, plans});
|
||||
paypal.billingPlan.list({ status: 'ACTIVE' }, (err, plans) => {
|
||||
console.log({ err, plans });
|
||||
});
|
||||
break;
|
||||
case 'get':
|
||||
paypal.billingPlan.get(nconf.get('PAYPAL_BILLING_PLANS_basic_12mo'), (err, plan) => {
|
||||
console.log({err, plan});
|
||||
console.log({ err, plan });
|
||||
});
|
||||
break;
|
||||
case 'update':
|
||||
let updatePayload = {
|
||||
const updatePayload = {
|
||||
op: 'replace',
|
||||
path: '/merchant_preferences',
|
||||
value: {
|
||||
@@ -75,7 +76,7 @@ switch (OP) {
|
||||
},
|
||||
};
|
||||
paypal.billingPlan.update(nconf.get('PAYPAL_BILLING_PLANS_basic_12mo'), updatePayload, (err, res) => {
|
||||
console.log({err, plan: res});
|
||||
console.log({ err, plan: res });
|
||||
});
|
||||
break;
|
||||
case 'create':
|
||||
@@ -83,10 +84,10 @@ switch (OP) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
if (plan.state === 'ACTIVE') {
|
||||
return console.log({err, plan});
|
||||
return console.log({ err, plan });
|
||||
}
|
||||
|
||||
let billingPlanUpdateAttributes = [{
|
||||
const billingPlanUpdateAttributes = [{
|
||||
op: 'replace',
|
||||
path: '/',
|
||||
value: {
|
||||
@@ -96,12 +97,12 @@ switch (OP) {
|
||||
|
||||
// Activate the plan by changing status to Active
|
||||
paypal.billingPlan.update(plan.id, billingPlanUpdateAttributes, (err2, response) => {
|
||||
console.log({err: err2, response, id: plan.id});
|
||||
console.log({ err: err2, response, id: plan.id });
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'create-webprofile':
|
||||
let webexpinfo = {
|
||||
const webexpinfo = {
|
||||
name: 'HabiticaProfile',
|
||||
input_fields: {
|
||||
no_shipping: 1,
|
||||
|
||||
Reference in New Issue
Block a user