WorldPay JSON API - what is the futurepayID - worldpay

I have integrated the WorldPay JSON API for my client.
They require the futurepayID - is this is the same as the reusable token that is returned or is the futurepayID a different thing?
I have tried going through their documentation but it is a little confusing. For reference, I have set reusable to true and everything else works as it should:
<script type='text/javascript'>
window.onload = function() {
Worldpay.useTemplateForm({
'clientKey':"xxx",
'form':'paymentForm',
'saveButton':false,
'paymentSection':'paymentSection',
'display':'inline',
'reusable':true,
'callback': function(obj) {
if (obj && obj.token) {
var _el = document.createElement('input');
_el.value = obj.token;
_el.type = 'hidden';
_el.name = 'token';
document.getElementById('paymentForm').appendChild(_el);
document.getElementById('paymentForm').submit();
}
}
});
}
</script>

I have spoken with WorldPay support and they told me there are two types of gateways - business and online. The business gateway uses futurepayID and uses HTML redirects (payments are taken on their server), whereas the online gateway uses the JSON API and uses tokenisation.
I'm not clear on the difference between the business and online gateways as surely anyone integrating the online gateway would be used by businesses.

Related

problem when making call interconnection using the plivo api

I am currently working with the plivo api to build an ivr, however, I have used all the recommendations given by the documentation and so far I can not establish a successful connection within the conference calls in the application, below I attach the code that is involved in the conference function.
getDialConnecting(numberFrom, numberTo, route){
let ivr = new Ivr();
let client = ivr.getClient();
client.calls.create(
`${numberFrom}`,
`${numberTo}`,
`${process.env.HOST}${route}`,
{
answerMethod: "POST"
},
).then(function(response){
console.log(response);
}, function(err){
console.log(err);
});
this function is called each time I make a conference call and enter the following parameters
I am currently working with the plivo api to build an ivr, however, I have used all the recommendations given by the documentation and so far I can not establish a successful connection within the conference calls in the application, below I attach the code that is involved in the conference function.
call.getDialConnecting(`${incomingNumber}`, `${incomingNumberTransmitter}`, 'conference');
in addition this is the path that is performing the handling of the function that accepts the call
const ivrGetConference = route.post('/voice/conference', call.callRequestConfirmed);
My name is Mohammed Huzaif, and I work at Plivo as a Product Evangelist.
From the information shared, I'm unable to determine the error you may have received on your end or the documents utilised.
However, you can follow the below steps to build an IVR.
First, we'll create our IVR, To do so, follow the directions in this documentation.
Once the IVR system is developed, we will make a call to the destination number by using the URL generated in above step.
To make a call, use the below code.
Note: Replace the placeholders "from": with the caller_id, "to": Destination number, and "answer_url": the url generated in above step.
var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client("<auth_id>","<auth_token>"); // https://console.plivo.com/dashboard/
client.calls.create(
"+14151234567", // from
"+15671234567", // to
"https://s3.amazonaws.com/static.plivo.com/answer.xml", // answer url
{
answerMethod: "POST",
},
).then(function (response) {
console.log(response);
}, function (err) {
console.error(err);
});})();
In case, if you still need any assistance, feel free to reach out to our support-team.

Why is the equation object empty in json when returned from the google doc api?

I am trying to fetch the google doc content using the google doc api but I see that the json returned from the google doc api is missing eqaution information.
Example content :-
google doc excerpt
Example request :-
const baseUrl = `https://docs.googleapis.com/v1/documents/${doc_id}`
const response = await googleReq(baseUrl, ctx.accessToken).then(res => {
let data = res.json()
return data
}).catch(err => console.log(err))
const googleReq = (url, token) => {
if (!token) return new Error("No accessToken")
return fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`
}
})
}
example response :-
...
{
"startIndex": 321,
"endIndex": 330,
"equation": {}
}
...
As you can see the equation block is not returning anything. I am not sure why it would be the case.
Answer:
Unfortunately, at present, you can not get equation information from the Google Docs API.
More Information:
As per the developer documentation, the equation block returned by the API should contain:
suggestedInsertionIds[]
suggestedDeletionIds[]
These IDs would be alphanumeric strings which indicate the suggestions that an editor would have inserted or deleted.
This block will not contain any equation text or other related info.
The Only Way:
At present, there is only one to get the equation text programmatically, and that is using Google Apps Script methods.
An example script to do this would be:
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0
function getEquations() {
const searchElementType = DocumentApp.ElementType.EQUATION
const documentBody = DocumentApp.getActiveDocument().getBody()
const searchResult = null
while (searchResult = documentBody.findElement(searchElementType,searchResult)) {
let par = searchResult.getElement().asEquation()
console.log("Search Result : " + par.getText())
}
}
As a workaround, you could deploy this as a web app which serves the equation text as JSON content, and then use the fetch API in JavaScript to get this data rather than using the Google Docs API directly.
Feature Request:
You can however let Google know that this is a feature that is important for access to their APIs, and that you would like to request they implement it.
Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services, I'd urge you to make a feature request there. The best component to file this under would be the Google Docs component, with the Feature Request template.
References:
REST Resource: documents | Google Docs API | Google Developers
Enum ElementType | Apps Script | Google Developers
Class DocumentApp | Apps Script | Google Developers
Class ContainerElement | Apps Script | Google Developers
References for Web App-based Workround:
Web Apps | Apps Script | Google Developers
Content Service | Apps Script | Google Developers
Serving JSON from scripts
Class ContentService | Apps Script | Google Developers

Azure mobile apps CRUD operations on SQL table (node.js backend)

This is my first post here so please don't get mad if my formatting is a bit off ;-)
I'm trying to develop a backend solution using Azure mobile apps and node.js for server side scripts. It is a steep curve as I am new to javaScript and node.js coming from the embedded world. What I have made is a custom API that can add users to a MSSQL table, which is working fine using the tables object. However, I also need to be able to delete users from the same table. My code for adding a user is:
var userTable = req.azureMobile.tables('MyfUserInfo');
item.id = uuid.v4();
userTable.insert(item).then( function (){
console.log("inserted data");
res.status(200).send(item);
});
It works. The Azure node.js documentation is really not in good shape and I keep searching for good example on how to do simple things. Pretty annoying and time consuming.
The SDK documentation on delete operations says it works the same way as read, but that is not true. Or I am dumb as a wet door. My code for deleting looks like this - it results in exception
query = queries.create('MyfUserInfo')
.where({ id: results[i].id });
userTable.delete(query).then( function(delet){
console.log("deleted id ", delet);
});
I have also tried this and no success either
userTable.where({ id: item.id }).read()
.then( function(results) {
if (results.length > 0)
{
for (var i = 0; i < results.length; i++)
{
userTable.delete(results[i].id);
});
}
}
Can somebody please point me in the right direction on the correct syntax for this and explain why it has to be so difficult doing basic stuff here ;-) It seems like there are many ways of doing the exact same thing, which really confuses me.
Thanks alot
Martin
You could issue SQL in your api
var api = {
get: (request, response, next) => {
var query = {
sql: 'UPDATE TodoItem SET complete=#completed',
parameters: [
{ name: 'completed', value: request.params.completed }
]
};
request.azureMobile.data.execute(query)
.then(function (results) {
response.json(results);
});
}};
module.exports = api;
That is from their sample on GitHub
Here is the full list of samples to take a look at
Why are you doing a custom API for a table? Just define the table within the tables directory and add any custom authorization / authentication.

How to asynchronously service multiple QBWC clients with Node.js

The idea is to implement a QBWC web service using Node.js which can serve multiple incoming requests in an asynchronous fashion. Currently I am looking into qbws which is a Node.js web service for QuickBooks Desktop Web Connector. Any ideas on how I can extend this to support an asynchronous architecture for the service methods?
Thanks in Advance!
The soap module supports asynchronous function calls which makes this easy to do. To use the same template as my other answer, here's how you'd do that:
var soap = require('soap');
var yourService = {
QBWebConnectorSvc: {
QBWebConnectorSvcSoap: {
serverVersion: function (args, callback) {
// serverVersion code here
callback({
serverVersionResult: { string: retVal }
});
},
clientVersion: function (args, callback) {
//clientVersion code here
callback({
clientVersionResult: { string: retVal }
});
},
// and all other service functions required by QBWC
}
}
};
There are two differences:
Each method signature has an additional callback parameter
There is no return, that's handled by callback() instead.
I don't currently have a suitable environment to test this, but I created a client to imitate QuickBooks Web Connector and it worked fine. Converting the qbws methods to asynchronous allowed it to service multiple clients simultaneously (including one legitimate QBWC client).

Stripe module issues at Parse

I am developing a project which integrates Stripe + Parse for iOS. It uses web hooks and Cloud code via node js. Currently i am in need of implementing a couple of functions:
cancel user subscription with flag atPeriodEnd;
subscribe cancelled customer once again (named multiple subscriptions via Stripe docs).
As for the first one: I'm sending a request as follows in Parse's API -
Stripe.Customers.cancelSubscription(request.params.customerID, 1, null)
but the second parameter, i.e. atPeriodEnd remains 0 when i receive Stripe's response and my webhook catches request for cancelling user immediately. Also i have checked Stripe's dashboard to see parameters that i pass and it says 'No query parameters'. Hope you can help me with this one out.
Second one: as i mentioned earlier user needs to have ability to subscribe once again after cancellation. That means that i already have a valid customer saved at Stripe and all i need is to 'attach' to him a new subscription. There is a method for this at Stripe docs:
stripe.customers.createSubscription("cus_00000000000", { plan: "planName" }, function(err, subscription) {
});
But i can't find similar to this in Parse's API. Hope you can help with this one out.
Sorry if there are some mistakes or misunderstandings for you - feel free to ask, i will answer as much clear as i can. Thanks!
Here is a workaround to #1 - make an http call directly to the stripe endpoint using Parse.Cloud.httpRequest. (I agree that Stripe.Customers.cancelSubscription in the Parse cloud module does not seem to be working)
Parse.Cloud.define("cancel", function(request, response) {
var user = request.user;
var customerStripeId = user.get("stripeId");
var key = "<stripe_api_key>"
var url = "https://api.stripe.com/v1/customers/" + customerStripeId + "/subscription"
Parse.Cloud.httpRequest({
method: 'DELETE',
params: { at_period_end: true, key: key },
url: url,
success: function() {
response.success()
},
error: function(httpResponse) {
console.error('Delete failed with response code ' + httpResponse.status);
response.failure()
}
});
});

Resources