paddle payment webhook data error in nestjs - nestjs

I am writing the payment code in the sandbox of paddle using nestjs and html.
I made two products, a regular product and a plan.
If I paid for the plan, I could receive checkout_id information from the webhook.
However, when purchasing a general product, the following information was obtained through the webhook.
{
event_time: '2022-08-22 08:54:19',
p_country: 'CN',
p_coupon: '',
p_coupon_savings: '0.00',
p_currency: 'CNY',
p_custom_data: '',
p_earnings: '{"7668":"3.2000"}',
p_order_id: '407118',
p_paddle_fee: '3.77',
p_price: '6.97',
p_product_id: '33625',
p_quantity: '1',
p_sale_gross: '6.97',
p_tax_amount: '0.00',
p_used_price_override: '0',
passthrough: '{"userId":9}',
quantity: '1',
p_signature: 'bZhkDR+M/G...HIU+D8ZaQ9BKMGL2a/K63eoAdkU='
}
And on the order page, I selected the quantity as 3, the quantity is 1 and the webhook is called 3 times...
//sandbox
Paddle.Environment.set('sandbox');
Paddle.Setup({
vendor: xxxx,
eventCallback: function (data) {
// The data.event will specify the event type
if (data.event === 'Checkout.Loaded') {
console.log(data.eventData) // Data specifics on the event
} else if (data.event === 'Checkout.Complete') {
console.log(data.eventData) // Data specifics on the event
} else if (data.event === 'Checkout.Close') {
console.log(data.eventData) // Data specifics on the event
}
}
});
Paddle.Checkout.open({
product: xxxxx
, allowQuantity:true
, passthrough:{
userId:9
}
});
Above is my html code. The eventCallback function is not called on that page.
Is it a sandbox issue? Please let me know how I can solve the above problems!
[summary]
I want to get checkout_id through webhook in general product payment.
If I select quantity 3 when paying for a product, the quantity is displayed as 1 in the webhook and the webhook is called 3 times.
The eventCallback function is not called in the html.

Related

Mutable Value in Firebase Push Notification Node.js 10 correct syntax?

I am trying to add Mutable_Content to my push notifications so I can add a badge count.
However I am running into the error:
Messaging payload contains an invalid value for the "notification.mutable_content" property. Values must be strings.
Here is my code for the payload:
const payload = {
notification : {
title: owner + ' has made a post',
body: title + ' - ' + caption,
mutable_content : true
},
};
I have tried many different tutorials to figure out the right syntax but it is not working.
It always comes up with an error.
I am using node.js 10 for the engine and firebase/google cloud platform to trigger the function.
Can anyone help me with this syntax?
Thank you
I had the same question and found unrelated and outdated firebase documentation about it. But you can bypass this by adding a apns field where you can directly put data for the apple notification service. But beware to use the apple syntax with hyphen.
See also: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification
var message = {
notification: {
title: "my notification title",
body: "hello"
},
apns: {
payload: {
aps: {
'mutable-content': true
}
}
},

How to do Autocomplete text suggestion in message box in BOT

I created a BOT with LUIS and node.js and also published in Skype Channel.
Now I wants to add Autocomplete text suggestion in message box.
Am unable to find documentation for node.js
Please assist me.
Autcomplete can be accomplished with a few different NPM packages. Here's one as an example that looks not too bad to implement: https://www.npmjs.com/package/autocompleter
Code example:
var countries = [
{ label: 'United Kingdom', value: 'UK' },
{ label: 'United States', value: 'US' }
];
autocomplete({
input: document.getElementById("country"),
fetch: function(text, update) {
text = text.toLowerCase();
// you can also use AJAX requests instead of preloaded data
var suggestions = countries.filter(n => n.label.toLowerCase().startsWith(text))
update(suggestions);
},
onSelect: function(item) {
alert(item.value); // will display 'US' or 'UK'
}
});
You'll obviously have to adapt this to your needs and exact use case, but should be easy enough to implement.

Suggestions are not working in actions on google

I create a chat bot using dialogflow and actions on google library. In the back-end code I have created function including if else. I added new suggestions in the "else if". That are not display in the actions on google simulator.Another suggestions are working. Only that time it is not displayed. Please give me some instructions for fixed that.
this is my code:
'use strict';
const functions = require('firebase-functions');
const {
dialogflow,
Suggestions,
Carousel,
Image,
Table,
List,
} = require('actions-on-google');
const app = dialogflow({debug: true});
// Constants for list and carousel selection
const Order_Food = 'order food';
const Extra_Product = 'extra product';
const Spa_Reservation = 'spa reservation';
const Restaurant_Booking = 'restaurant booking';
app.intent('user.provide_room_number', (conv) => {
conv.ask('Great! I can help you with the following. Please select
from the options below.');
//conv.ask(new Suggestions('Order Food', 'Extra Product',
'Restaurant', 'Spa'));
// Create a carousel
conv.ask(new Carousel({
items: {
// Add the first item to the carousel
[Order_Food]: {
synonyms: [
'order food',
'food',
],
title: 'Food',
description: 'Can order some food',
image: new Image({
url: 'http://www.restauranteelpalacete.com/wp-content/uploads/2018/01/Online-Food-Ordering.jpg',
alt: 'Food',
}),
},
// Add third item to the carousel
[Spa_Reservation]: {
synonyms: [
'spa',
'spa reservation',
],
title: 'Spa Reservation',
description: 'Can put the reservation on the spa.',
image: new Image({
url: 'https://res.klook.com/images/fl_lossy.progressive,q_65/c_fill,w_1295,h_720,f_auto/w_80,x_15,y_15,g_south_west,l_klook_water/activities/kykzulvt1t71kwhnmkik/OasisSpa.jpg',
alt: 'Spa',
}),
},
// Add fourth item to the carousel
[Restaurant_Booking]: {
synonyms: [
'restaurant',
'restaurant booking',
],
title: 'Restaurant',
description: 'Can put the reservation on the Restaurant.',
image: new Image({
url: 'https://cdn-image.foodandwine.com/sites/default/files/1501607996/opentable-scenic-restaurants-marine-room-FT-BLOG0818.jpg',
alt: 'Restaurant',
}),
},
},
}));
});
app.intent('actions_intent_OPTION-handler', (conv, params, option) => {
// Get the user's selection
// Compare the user's selections to each of the item's keys
if (!option) {
conv.ask('You did not select any item from the list or carousel');
} else if (option === 'order food') {
conv.ask(new SimpleResponse({speech:"Absolutely, have you decided what you like or you could go through the in room dinning menu. \n Do you need order Food.?",text:"Absolutely, have you decided what you like or you could go through the in room dinning menu. Do you need order Food.?"}));
conv.ask(new Suggestions(["Ok", "Done", "Thanks"]));
} else if (option === 'spa reservation') {
conv.ask(new Suggestions('Yes I need Spa.'));
conv.ask(`We have an excellent Spa that offer exquisite treatment packages. You can select one of the options. We have quite a few free slots today. Do you need information about that.`);
} else if (option === 'restaurant booking') {
conv.ask(`We have some dining options for you today. Do you want more information. `);
conv.ask(new Suggestions('I need restaurant.'));
} else {
conv.ask('You selected an unknown item from the list, or carousel');
}
});
You should design your conversation bot more efficiently.In second elseif condition, after a suggestion no further conversation should happen in an intent.Suggestion are for triggering intent. For your case best scenario would be to create a follow up intent.
Suggestion is not appearing in conversation because, in every rich response at least one simple response should be present. Try below code. Hope this helps you.
conv.ask(new SimpleResponse({speech:"Absolutely, have you decided what you like or you could go through the in room dinning menu. \n Do you need order Food.?",text:"Absolutely, have you decided what you like or you could go through the in room dinning menu. Do you need order Food.?"}));
conv.ask(new Suggestions(["Ok", "Done", "Thanks"]));

How to create Onfido Webhook to verify customers

I am trying to create Web-hook to be notified about events that happen After creating Onfido Check for a customer from Back-end. While testing my Web-hook i am getting response as below:
{ resource_type: 'test_resource',
action: 'test_action',
object:
{ id: '1234-1234-2658-3698',
status: 'completed',
completed_at: '2018-03-12 07:06:48 +0000',
href: 'https://api.onfido.com/v2/test_sources//12343-11122-09290/reports/12345-23122-32123' } }
But i don't know What will be the Unique Key or ID (for ex. ApplicantID or CheckID ) which we can save in our database earlier while creating Applicant or while create Check on Applicant and after getting response from Webhook we could update Customer status.
In my case, I receive something like
{
payload: {
action: "check.completed",
resource_type: "check",
object: {
completed_at: "2018-08-15 13:36:30 UTC",
href: "https://api.onfido.com/v2/applicants/<applicant_id>/checks/<check_id>",
id: <check_id>,
status: "complete"
}
}
}
So, Here is applicant_id and check_id in payload.object.href field and check_id in payload.object.id field. (Something like this described in https://documentation.onfido.com/#event-object)
You can know your check_id from id field in a response from POST https://api.onfido.com/v2/applicants/{applicant_id}/checks as described here: https://documentation.onfido.com/#create-check

Cassandra getting data (query on different attributes)

how i can get data from Cassandra using value
posts = {
'1': { //this post id
'user_id': '4',
'body': 'This is awesome!',
},
}
i cen get the post using post id
can i get posts related to certain user
i mean get post related to user_id=4 like an example (query using user_id attribute)
regrads
For that you will need to maintain your own (secondary) index.
e.g
userIds = {
'4': { //this user id
'post_id': '1'
},
}

Resources