Clickbank INS V6.0 Integration c# - clickbank

I am trying to integrate CLickBankINSV6.0 to my c# application.
I have tried by using a sample response like:
{
"notification": {
"version": 6,
"attemptCount": 0,
"role": "VENDOR",
"site": "nicholeen",
"receipt": "********",
"currency": "USD",
"transactionType": "TEST",
"transactionTime": 1406070122781,
"paymentMethod": "VISA",
"totalProductAmount": 1,
"totalTaxAmount": 0,
"totalShippingAmount": 0,
"customer": {
"shipping": {
"firstName": "TEST",
"lastName": "USER",
"fullName": "Test User",
"email": "testuser#somesite.com",
"address": {}
},
"billing": {
"firstName": "TEST",
"lastName": "USER",
"fullName": "Test User",
"email": "testuser#somesite.com",
"address": {}
}
},
"lineItems": [
{
"itemNo": "1",
"productTitle": "A passed in title",
"shippable": false,
"recurring": false,
"customerProductAmount": 1,
"customerTaxAmount": 0
}
]
},
"iv": "1A0b7S1R"
}
But always I am getting "Test Notification Failed to send" message from clickbank.
Is there a sample test response available with anyone who could get a success from test?

string sContent = "";
string encryptednotfication = "";
string vector = "";
using (System.IO.Stream receiveStream = Request.InputStream)
{
// Move to begining of input stream and read
receiveStream.Position = 0;
using (System.IO.StreamReader readStream =
new System.IO.StreamReader(receiveStream, Encoding.UTF8))
{
// Load into XML document
sContent = readStream.ReadToEnd();
}
}

Related

How to findOneAndUpdate MongoDB object inside array from multiple arrays inside object

I am new to mongodD. Although i have wrote correct logic to push object inside cardsData bankCardsArray, but i am not able to make logic to edit a card.
**I have following Data in MongoDB, **
UserData = {
"_id": "63b43ab32fc8d3c100cafecc",
"name": "Praveen Lohar",
"email": "pr********#gmail.com",
"password": "$2b$12$3nwifHakrBu94BwLXAC4Nu16Kw0.xyW8vAIPTMSgY7cYttVklDIZq",
"loginIdsArray": [
{
"title": "Airtel App",
"logoIndex": 3,
"category": "Finance",
"app": "Airtel Thanks",
"username": "p******#gmail.com ",
"password": "xxxxxxx",
"isFavourite": false,
"_id":"63b440ee738a50fc333df3ca"
}
],
"cardsData": {
"bankCardsArray": [
{
"title": "SBI CC",
"logoIndex": 72,
"category": "Bank",
"cardHolder": "Prsscscs",
"cardNumber": "524xxxxxxxx20xx",
"expiry": "23/54",
"cvv": "00",
"isFavourite": false,
"_id": "63b974adb9acaa24a4ebec8b"
},
{
"title": "AXIS CC",
"logoIndex": 85,
"category": "Bank",
"cardHolder": "blsllslss",
"cardNumber": "524xxxxxxxx20xx",
"expiry": "23/54",
"cvv": "00",
"isFavourite": false,
"_id": "63b974adb9acaa24a4ebe5f"
}
],
"identityCardsArray": [
{
"title": "Aadhar Card",
"logoIndex": 98,
"category": "Identity",
"cardHolder": "Name_1",
"cardNumber": "54*******455454",
"issueDate": "2012",
"dob": "23/05",
"isFavourite": false,
"_id":"63b974e6bd0d03c116955f67"
}
],
"licenseCardsArray": [
{
"title": "Two Wheeler License",
"logoIndex": 0,
"category": "License",
"cardHolder": "Klaus Michealson",
"licenseNumber": "RJ/22/ADL-542/474/01",
"expiry": "2036",
"dob": "13/06",
"isFavourite": false,
"_id":"63b97535bd0d03c116955f69"
}
]
}
}
I want to find the user with _id
Then for that user i want to got to cardsData object
Then in cardsData object i want to got to bankCardsArray
Then in bankCardsArray , i want to update fields of a card with particular id
Const res = findOneAndUpdate(
{ 'cardsData.bankCardsArray._id':card_id },
{ $set{ 'cardsData.bankCardsArray.$.title': req.body.title });
Use "." operator to access nested fields.
Refer these mongodb documentation
query-array-of-documents
query-embedded-documents.
Hope this helps.

Get json value based on dynamic key mapping for partial path

I am trying to get the values of a key in a json file, but there are several issues that I need to solve.
The key of the JSON is dynamic - I have another JSON in which I am given the path of the key inside the JSON.
For example, I have a json file that contains the following mapping:
{
"addressesPath":"personal.addresses"
}
This tells me that the value I am looking for is inside another key, called personal.
The JSON will look like this:
{
"username": "X1",
"id":"1X",
"type": "patron",
"group": "students",
"personal": {
"lastname": "lname",
"firstname": "fname",
"email": "test#test.test",
"phone": "1-111-111-1111",
"mobilePhone": "(111)111-1111",
"birthDate": "1979-01-23T00:00:00.000+0000",
"addresses":
{
"countryId": "US",
"addressLine1": "1111 Brannon Ford Suite 111",
"city": "Kettering",
"region": "MA",
"postalCode": "11111-1111",
"primaryAddress": true
}
}
}
So for example if the JSON is "user", what I want to get is user.personal.addresses
How can I translate "user.personal.addresses" to "users.+dynamic"?
I tried doing it just like that, but it doesn't seem to work with any type of string I extract from the mapping json file.
I have an issue because I don't know if the location I am getting is a single value or an array of values.
For example, the JSON could look like this:
{
"username": "X1",
"id":"1X",
"type": "patron",
"group": "students",
"personal": {
"lastname": "lname",
"firstname": "fname",
"email": "test#test.test",
"phone": "1-111-111-1111",
"mobilePhone": "(111)111-1111",
"birthDate": "1979-01-23T00:00:00.000+0000",
"addresses":[
{
"countryId": "US",
"addressLine1": "1111 Brannon Ford Suite 111",
"city": "Kettering",
"region": "MA",
"postalCode": "11111-1111",
"primaryAddress": true
}, {
"countryId": "US",
"addressLine1": "1112 Brannon Ford Suite 112",
"city": "Kettering",
"region": "IL",
"postalCode": "11112-1112",
"primaryAddress": false
}
]
}
}
Which means I need to determine the structure of the data I am going to get, whether it is an array or not.
Can I do this by checking if the result is a string or object? I know that arrays from JSON files are read as objects in node js.
You want something like that
With three examples
let object = {
"group": "students",
"personal": {
"addresses": {
"countryId": "US",
}
}
}
let test1 = checkObject(object, "personal.addresses")
console.log(test1);
let object2 = {
"test": {
"test_deep": [
{
"countryId": "US",
"addressLine1": "1111 Brannon Ford Suite 111"
},
{
"countryId": "US",
"addressLine1": "1112 Brannon Ford Suite 112",
}
]
}
}
let test2 = checkObject(object2, "test.test_deep")
console.log(test2);
let object3 = {
"test": {
"test_deep": "test"
}
}
let test3 = checkObject(object3, "test.test_deep")
console.log(test3);
function checkObject(object, addressesPath) {
let addres = addressesPath.split(".")
let item = object
for (let index = 0; index < addres.length; index++) {
if (typeof item[addres[index]] != 'undefined') {
item = item[addres[index]]
} else {
item = null
break
}
}
return {
type: typeof item,
is_array: Array.isArray(item),
data: item
}
}

How can I get init_point or sandbox_init_point after calling payment.create API with mercadopago?

I have implemented the preference API and I am getting the response which I have attached. Now I am confused about how to get refund with this response or is it possible or not. Can you please suggest some API related to the refund policy?
Thanks for the cooperation in advance.
The response which I am getting:
{
"processing_modes": [],
"metadata": {},
"binary_mode": false,
"payment_methods": {
"excluded_payment_methods": [
{
"id": ""
}
],
"excluded_payment_types": [
{
"id": ""
}
],
"installments": null,
"default_payment_method_id": null,
"default_installments": null
},
"collector_id": 472389951,
"operation_type": "regular_payment",
"items": [
{
"id": "",
"picture_url": "",
"title": "Mojito",
"description": "Cheesy 8",
"category_id": "Blah Blah",
"currency_id": "ARS",
"quantity": 11,
"unit_price": 456
}
],
"payer": {
"name": "",
"surname": "",
"email": "pappu#testuser.com",
"date_created": "",
"phone": {
"area_code": "",
"number": ""
},
"identification": {
"type": "",
"number": ""
},
"address": {
"street_name": "",
"street_number": null,
"zip_code": ""
}
},
"back_urls": {
"success": "http://eb7b02b9.ngrok.io/notification/ipn",
"pending": "http://eb7b02b9.ngrok.io/notification/ipn",
"failure": "http://eb7b02b9.ngrok.io/notification/ipn"
},
"auto_return": "",
"client_id": "3767495422255439",
"marketplace": "NONE",
"marketplace_fee": 0,
"shipments": {
"receiver_address": {
"zip_code": "",
"street_number": null,
"street_name": "",
"floor": "",
"apartment": ""
}
},
"notification_url": "http://fd7842f1.ngrok.io/notification/ipn",
"external_reference": "",
"additional_info": "",
"expires": false,
"expiration_date_from": null,
"expiration_date_to": null,
"date_created": "2019-10-03T03:35:03.228-04:00",
"id": "472389951-fdfcf414-18b7-44b3-afd5-5d3cd73fbfc2",
"init_point": "https://www.mercadopago.com.ar/checkout/v1/redirect?pref_id=472389951-fdfcf414-18b7-44b3-afd5-5d3cd73fbfc2",
"sandbox_init_point": "https://sandbox.mercadopago.com.ar/checkout/v1/redirect?pref_id=472389951-fdfcf414-18b7-44b3-afd5-5d3cd73fbfc2"
}

How to make a carousel using Google.Cloud.Dialogflow.V2 Carousel for dialogflow?

Im trying to build a webhook for dialogflow with help from nuget package Google.Cloud.Dialogflow.V2.
Im running the code with .Net Core 2.1.
I get the fullfilmentText to show in dialogflow, but cant make the carousel to show up.
What am I doing wrong?
Here is my method:
[HttpPost]
public ContentResult Post([FromBody] WebhookRequest webhookRequest)
{
var dialogflowResponse = new WebhookResponse { FulfillmentText = "FulfillmentText" };
var carousel = new Intent.Types.Message.Types.CarouselSelect.Types.Item
{
Title = "My title",
Description = "This is a description",
Image = new Intent.Types.Message.Types.Image
{
ImageUri = "https://placekitten.com/200/300",
AccessibilityText = "cat"
},
Info = new Intent.Types.Message.Types.SelectItemInfo
{
Key = "Cats"
}
};
carousel.Info.Synonyms.Add("Synonym 1");
carousel.Info.Synonyms.Add("Synonym 1");
dialogflowResponse.FulfillmentMessages.Add(new Intent.Types.Message {
CarouselSelect = new Intent.Types.Message.Types.CarouselSelect()
});
dialogflowResponse.FulfillmentMessages.First().CarouselSelect.Items.Add(carousel);
return dialogflowResponse;
}
Generates followiing Json:
{
"fulfillmentText": "FulfillmentText",
"fulfillmentMessages": [
{
"carouselSelect": {
"items": [
{
"info": {
"key": "Cats",
"synonyms": [
"Synonym 1",
"Synonym 1"
]
},
"title": "My title",
"description": "This is a description",
"image": {
"imageUri": "https://placekitten.com/200/300",
"accessibilityText": "cat"
}
}
]
}
}
]
}
i ran into the same problem with the java api. Only the basic rich messages (card, quick replies, ...) are working. BasicCard, Suggestions, Carousel, ... doesn't show up in any channel.
I got it to work if i added some of the following custom payload to skype channel:
{
"skype": {
"type": "message",
"attachmentLayout": "carousel",
"text": "Please select your food.",
"attachments": [{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "Sushi",
"subtitle": "Very fresh shrimp or tuna.",
"images": [{
"url": "https://i.ibb.co/87LmvT3/mdi.png"
}
],
"buttons": [{
"type": "imBack",
"title": "1 piece",
"value": "sushi,1"
}, {
"type": "imBack",
"title": "2 piece",
"value": "sushi,2"
}, {
"type": "imBack",
"title": "more",
"value": "sushi,3+"
}
]
}
}, {
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "Tenpura",
"subtitle": "Japanese first-class vegitables.",
"images": [{
"url": "https://i.ibb.co/87LmvT3/mdi.png"
}
],
"buttons": [{
"type": "imBack",
"title": "1 piece",
"value": "tenpura,1"
}, {
"type": "imBack",
"title": "2 piece",
"value": "tenpura,2"
}, {
"type": "imBack",
"title": "more",
"value": "tenpura,3+"
}
]
}
}
]
}}
I hope it helps!

Checking for empty strings in Joi (hapi.js)

I am using the Hapi.js framework along with Joi for data validation. I am trying to validate a JSON file using Joi. I have defined a schema and wanted to check whether the JSON file had all the fields from my schema.
Some of the string fields can be empty. In my schema file when I defined min as 0, it is saying name is a required field.
I am using the schema below:
module.exports = {
"name": { "type": "string", "min": 0, "max": 30},
"age": { "type": "number", "min": 1, "max": 36},
"dob": { "type": "string", "min": 0, "max": 100 }
}
How can I modify this schema to handle empty strings?
If you want to allow empty strings, you need to explicitly allow them with joi.string().allow('').
var joi = require('joi');
var schema = joi.object().keys({
name: joi.string().min(0).allow('').allow(null),
age: joi.number().min(1).max(36),
dob: joi.string().min(0).max(100)
});
var obj = {
name: '',
age: '18',
dob: '11/11/2998'
};
var result = joi.validate(obj, schema);
console.log(JSON.stringify(result, null, 2));
The output of the above schema after using joi.describe is:
{
"type": "object",
"children": {
"name": {
"type": "string",
"valids": [
"",
null
],
"rules": [
{
"name": "min",
"arg": 0
}
]
},
"age": {
"type": "number",
"invalids": [
null,
null
],
"rules": [
{
"name": "min",
"arg": 1
},
{
"name": "max",
"arg": 36
}
]
},
"dob": {
"type": "string",
"invalids": [
""
],
"rules": [
{
"name": "min",
"arg": 0
},
{
"name": "max",
"arg": 100
}
]
}
}
}

Resources