wip trying to create better options to include scripts with attributes
This commit is contained in:
@@ -10,7 +10,7 @@ sendButton.addEventListener('click', () => {
|
||||
inputValue = JSON.stringify(inputValue);
|
||||
console.log("inputValue:");
|
||||
console.log(inputValue);
|
||||
PLGNTLS_ajax('get_data', inputValue)
|
||||
PLGNTLS_fetch('/get_data', {inputValue})
|
||||
//PLGNTLS_fetch('get_data', {body: {inputValue}})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
|
||||
//import { resultMessage } from './result_message.js';
|
||||
import { resultMessage } from './result_message.js';
|
||||
import { PLGNTLS_fetch } from '../../utils/plgntls_fetch.js';
|
||||
|
||||
/**
|
||||
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
|
||||
*/
|
||||
//export async function createOrder() {
|
||||
async function createOrder() {
|
||||
//async function createOrder() {
|
||||
export async function createOrder() {
|
||||
try {
|
||||
//const fetch_create_url = PLGNTLS_data.fetch_url + "/fipf_plugin/api/v1/orders";
|
||||
//console.log("fetch_create_url:", fetch_create_url);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
|
||||
//import { resultMessage } from './result_message.js';
|
||||
import { resultMessage } from './result_message.js';
|
||||
import { PLGNTLS_fetch } from '../../utils/plgntls_fetch.js';
|
||||
|
||||
/**
|
||||
* @see https://developer.paypal.com/docs/checkout/standard/integrate/#link-integratebackend
|
||||
*/
|
||||
//export async function onApprove(data, actions) {
|
||||
async function onApprove(data, actions) {
|
||||
//async function onApprove(data, actions) {
|
||||
export async function onApprove(data, actions) {
|
||||
try {
|
||||
const fetch_approve_url = PLGNTLS_data.fetch_url + "/fipf_plugin/api/v1/orders/" + data.orderID + "/capture";
|
||||
console.log("fetch_approve_url:", fetch_approve_url);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//import { createOrder } from './create_order.js';
|
||||
//import { onApprove } from './on_approve.js';
|
||||
import { createOrder } from './create_order.js';
|
||||
import { onApprove } from './on_approve.js';
|
||||
|
||||
|
||||
window.paypal.Buttons({
|
||||
|
||||
13
plugins/fipfcard_plugin/js/paypal/plgntls_fetch.js
Normal file
13
plugins/fipfcard_plugin/js/paypal/plgntls_fetch.js
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
//function PLGNTLS_fetch(url, options = {}) {
|
||||
export function PLGNTLS_fetch(url, options = {}) {
|
||||
console.log("inside PLGNTLS_fetch");
|
||||
url = PLGNTLS_data.fetch_url + url;
|
||||
|
||||
options.headers = options.headers || {};
|
||||
options.headers['X-WP-Nonce'] = PLGNTLS_data.fetch_nonce,
|
||||
console.log("options:", options);
|
||||
|
||||
return fetch(url, options);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
// Example function to show a result to the user. Your site's UI library can be used instead.
|
||||
//export function resultMessage(message) {
|
||||
function resultMessage(message) {
|
||||
//function resultMessage(message) {
|
||||
export function resultMessage(message) {
|
||||
const container = document.querySelector("#result-message");
|
||||
container.innerHTML = message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user