empty related_resources in response from credit card payment - paypal

I'm using paypalrestsdk for Credit Card Payment. When I switch to SANDBOX mode and make a request, the paypal service return me this:
{'update_time': u'2016-11-17T16:47:46Z',
'payer':
{'payment_method': u'credit_card',
'funding_instruments': [
{'credit_card':
{'first_name': u'first_name',
'billing_address': {'city': u'London', 'postal_code': u'123','line1': u'fooo', 'country_code': u'EN'},
'expire_month': u'12',
'number': u'xxxxxxxxxxxx1111',
'last_name': u'last_name',
'expire_year': u'2020',
'type': u'visa'}}]},
'links': [
{'href': u'https://api.sandbox.paypal.com/v1/payments/payment/PAY-1GH35642K71421451LAW56MQ',
'method': u'GET',
'rel': u'self'}
],
'transactions': [
{'item_list': {
'items': [
{'currency': u'USD',
'price': u'367.77',
'name': u'Foooo',
'quantity': u'10'}],
'shipping_address': {'city': u'London', 'line1': u'line1', 'recipient_name': u'name', 'phone': u'321312', 'state': u'state', 'postal_code': u'123', 'country_code': u'EN'}},
'related_resources': [],
'amount': {'currency': u'USD', 'total': u'3688.77', 'details': {'subtotal': u'3677.70', 'shipping': u'11.07'}},
'description': u'Charge for order: #1'}],
'state': u'created',
'create_time': u'2016-11-17T16:47:46Z',
'intent': u'sale',
'id': u'PAY-1GH35642K71421451LAW56MQ'}
why is the related_resources empty? How can i test my code in sandbox mode? Of course in PRODUCTION mode related_resources contain sales as in example: https://developer.paypal.com/docs/integration/direct/accept-credit-cards/
The number of credit card is 4111111111111111.

4111111111111111 is not working anymore, you can try with an other one like 4929931129414294

Related

How to group FCM notifications in flutter

How to group FCM notifications (having in one stack if there is more than one notification),
I tried using the 'tag' key in my payload (as It was suggested in other answers) but it makes that new notification replaces the last notification.
This what I am using for notification:
data: {
'notification': {
'title': notificationTitle,
'body': notificationBody,
},
'priority': 'high',
'data': {
'click_action': 'FLUTTER_NOTIFICATION_CLICK',
'id': '1',
'status': 'done'
},
'to': userToken
},
}

Google home device and dialogflow

I have a agent, using V1 dialog flow. Integrated with two Google home devices.
One Google home device is in Europe, one in India. Both the devices are configured ccount. The same account is used to deploy the webhook, deploy and dialogflow agent.
The firmware version is identical.
The agent works perfectly on simulator.
Now when talked on Google home:
Google device in India: When started inovkes, there is a certain pin number which is asked, even when pin is mentioned slowly, spaces are not considered in the dialog flow JSON request pin.original is without spaces, say pin is 12345, JSON request is 12345
Google device in Europe: When started inovkes, there is a certain pin number which is asked, even when pin is mentioned slowly, spaces are considered in the dialog flow JSON request pin.original is with spaces and gets trimmed.
say pin is 12345 but JSON request is 123,
Not sure why this is happening.
Any help, please?
Adding the dialog flow requests.........
DF JSON Request coming to backend from Google Home Device in India - Working Fine
{
data: {
'timestamp': '2018-06-15T17:42:38.261Z',
'id': 'e5acf434-4e03-4c14-b3d9-e8fc98555694',
'status': {
'errorType': 'success', 'code': 200
}
,
'sessionId': '1529084528066',
'originalRequest': {
'source': 'google', 'data': {
'user': {
'userId': '1529084528066', 'locale': 'en-US'
}
,
'surface': {
'capabilities': [{'name': 'actions.capability.MEDIA_RESPONSE_AUDIO'}, {'name': 'actions.capability.AUDIO_OUTPUT'}]
}
,
'isInSandbox': True, 'inputs': [{
'arguments': [{
'name': 'text',
'rawText': 'my pin is 23456',
'textValue': 'my pin is 23456'
}],
'intent': 'actions.intent.TEXT',
'rawInputs': [{'inputType': 'VOICE', 'query': 'my pin is 23456'}]
}], 'conversation': {
'conversationId': '1529084528066',
'conversationToken': '["0748bff2-90d8-4941-8f9f-cf59dd3d009c_id_dialog_context","actions_capability_audio_output","actions_capability_media_response_audio","auth_dialog_context","auth_dialog_params_pin","defaultwelcomeintent-followup","google_assistant_input_type_voice"]',
'type': 'ACTIVE'
}
}
,
'version': '2'
}
,
'lang': 'en-us',
'result': {
'speech': '',
'action': 'DefaultWelcomeIntent.DefaultWelcomeIntent-custom',
'actionIncomplete': False,
'parameters': {
'phone': '1234567890', 'pin': '23456'
}
,
'fulfillment': {
'speech': '', 'messages': [{'speech': '', 'type': 0}]
}
,
'source': 'agent',
'contexts': [{
'name': 'google_assistant_input_type_voice',
'parameters': {
'phone': '1234567890',
'pin': '23456',
'pin.original': '23456',
'phone.original': '12345 67890'
},
'lifespan': 0
}, {
'name': 'actions_capability_audio_output',
'parameters': {
'phone': '1234567890',
'pin': '23456',
'pin.original': '23456',
'phone.original': '12345 67890'
},
'lifespan': 0
}, {
'name': 'auth',
'parameters': {
'phone': '1234567890',
'pin': '23456',
'pin.original': '23456',
'phone.original': '12345 67890'
},
'lifespan': 5
}, {
'name': 'defaultwelcomeintent-followup',
'parameters': {
'phone': '1234567890',
'pin': '23456',
'pin.original': '23456',
'phone.original': '12345 67890'
},
'lifespan': 1
}, {
'name': 'actions_capability_media_response_audio',
'parameters': {
'phone': '1234567890',
'pin': '23456',
'pin.original': '23456',
'phone.original': '12345 67890'
},
'lifespan': 0
}],
'resolvedQuery': 'my pin is 23456',
'score': 1.0,
'metadata': {
'matchedParameters': [{
'prompts': [{'value': 'Please tell us your pin', 'lang': 'en'}],
'required': True,
'name': 'pin',
'value': '$pin',
'dataType': '#sys.phone-number',
'isList': False
}],
'webhookUsed': 'true',
'intentId': '0748bff2-90d8-4941-8f9f-cf59dd3d009c',
'nluResponseTime': 296,
'intentName': 'auth',
'webhookForSlotFillingUsed': 'false',
'isResponseToSlotfilling': False
}
}
}
}
DF JSON Request coming to backend from Google Home Device in Europe - See the pin number issue,
{
data: {
'timestamp': '2018-06-15T13:19:06.014Z',
'id': 'ca0ebb47-8bf1-478b-9c87-c704e0114cf9',
'status': {'errorType': 'success', 'code': 200},
'sessionId': '1529068715507',
'originalRequest': {
'source': 'google',
'data': {
'user': {'userId': '1529068715507', 'locale': 'en-US'},
'surface': {'capabilities': [{'name': 'actions.capability.AUDIO_OUTPUT'}, {'name': 'actions.capability.MEDIA_RESPONSE_AUDIO'}]},
'isInSandbox': True,
'inputs': [{
'arguments': [{
'name': 'text',
'rawText': 'my pin is 2 3 4 5 6',
'textValue': 'my pin is 2 3 4 5 6'
}],
'intent': 'actions.intent.TEXT',
'rawInputs': [{'inputType': 'VOICE', 'query': 'my pin is 2 3 4 5 6'}]
}],
'conversation': {
'conversationId': '1529068715507',
'conversationToken': '["0748bff2-90d8-4941-8f9f-cf59dd3d009c_id_dialog_context","actions_capability_audio_output","actions_capability_media_response_audio","auth_dialog_context","auth_dialog_params_pin","defaultwelcomeintent-followup","google_assistant_input_type_voice"]',
'type': 'ACTIVE'
}
},
'version': '2'
},
'lang': 'en-us',
'result': {
'speech': '',
'action': 'DefaultWelcomeIntent.DefaultWelcomeIntent-custom',
'actionIncomplete': False,
'parameters': {'phone': '1234567890', 'pin': '234'},
'fulfillment': {'speech': '', 'messages': [{'speech': '', 'type': 0}]},
'source': 'agent',
'contexts': [{
'name': 'google_assistant_input_type_voice',
'parameters': {
'phone': '1234567890',
'pin': '234',
'pin.original': '2 3 4',
'phone.original': '123-456-7890'
},
'lifespan': 0
}, {
'name': 'actions_capability_audio_output',
'parameters': {
'phone': '1234567890',
'pin': '234',
'pin.original': '2 3 4',
'phone.original': '123-456-7890'
},
'lifespan': 0
}, {
'name': 'auth',
'parameters': {
'phone': '1234567890',
'pin': '234',
'pin.original': '2 3 4',
'phone.original': '123-456-7890'
},
'lifespan': 5
}, {
'name': 'actions_capability_media_response_audio',
'parameters': {
'phone': '1234567890',
'pin': '234',
'pin.original': '2 3 4',
'phone.original': '123-456-7890'
},
'lifespan': 0
}, {
'name': 'defaultwelcomeintent-followup',
'parameters': {
'phone': '1234567890',
'pin': '234',
'pin.original': '2 3 4',
'phone.original': '123-456-7890'
},
'lifespan': 1
}],
'resolvedQuery': 'my pin is 2 3 4 5 6',
'score': 1.0,
'metadata': {
'matchedParameters': [{
'prompts': [{
'value': 'Please tell us your pin',
'lang': 'en'
}],
'required': True,
'name': 'pin',
'value': '$pin',
'dataType': '#sys.phone-number',
'isList': False
}],
'webhookUsed': 'true',
'intentId': '0748bff2-90d8-4941-8f9f-cf59dd3d009c',
'nluResponseTime': 356,
'intentName': 'auth',
'webhookForSlotFillingUsed': 'false',
'isResponseToSlotfilling': False
}
}
}
}
Even though your locale is the same, your location is different.
I guess, that this influences the interpretation of #sys.phone-number.
So if you would use another dataType (e.g. #sys.number-sequence), I think it would work.
You could probably try this by changing your location in the Google Actions Simulator.
(Training diverse number sequences seems to improve the results.)

Sender field not found in emails sent using a different email address from Gmail browser based client

Let's say there is an email alice#example.com. A send-as has been set up for bob#example.com.
When I send an email to someone from alice# account using bob# as the sender, the headers usually have a key-value pair with Sender as the key. This Sender is used to identify that alice# had sent the email. The From header will be bob#.
But for one Gmail account, there is no Sender in the headers. Is there any other way to reliably identify the sender?
Here is the gmail headers without the Sender
{
'internalDate': '1519112776000',
'historyId': '11018249',
'payload': {
'mimeType': 'multipart/alternative',
'headers': [
{
'name': 'MIME-Version',
'value': '1.0'
},
{
'name': 'Received',
'value': 'by 13.133.13.13 with HTTP; Mon, 19 Feb 2018 23:46:16 -0800 (PST)'
},
{
'name': 'Date',
'value': 'Tue, 20 Feb 2018 15:46:16 +0800'
},
{
'name': 'Delivered-To',
'value': 'alice#example.com'
},
{
'name': 'Message-ID',
'value': '<090-SomeRAnDOMMESsageIDGivenByGoogle#mail.gmail.com>'
},
{
'name': 'Subject',
'value': 'This is some random subject'
},
{
'name': 'From',
'value': 'Alice as Bob <bob#example.com>'
},
{
'name': 'To',
'value': 'Troce <troce#random.com>'
},
{
'name': 'Content-Type',
'value': 'multipart/alternative; boundary="000somerandomboundary"'
}
]
},
'snippet': 'This is some random snippet',
'sizeEstimate': 3368,
'threadId': '161b22d6b3213213',
'labelIds': [
'Label_1',
'Label_2',
'Label_3',
'SENT'
],
'id': '161b22d6b3213213'
}

querying array of object in PHP mongodb

Hi I'm beginner in mongodb, my document looks like this :
{
'_id': ObjectId("599d142a02ae238"),
'name': 'Product One',
'status': 'in stock',
'prices': [ {
'currency': 'USD',
'amount': 1000
}, {
'currency': 'THB',
'amount': 3000
} ]
}
I would like to do a query to search for product in specific price range and specific currency. My query is looks like this:
[
'prices.amount' => ['$gte' => 2000, '$lte' => 5000],
'prices.currency' => 'USD',
]
if I run this query it should not return any value, as the product price in that range is not in USD. But it did return the data. How is the correct query? Any advice pls? Thanks
{"prices":{"$elemMatch":{"amount": {"$gte":2000, "$lte":5000}, "currency":"USD"}}}

Scala - reformatting hash-map

I have some Python code that processes a fairly complex hashmap (Example Input), restructures it and creates (Example Output) a simplified version of it. I'm looking for the best way to tackle this with Scala, i.e. built in or external libs? I'm new to Scala and just getting to grips with it, so some guidance here would be really helpful.
This was fairly easy to do using Python and I'm hoping that will be the with Scala.
Input:
data_in = {
'map': {
'stats': {
'uphosts': u'3',
'timestr': u'Thu Mar 20 18:18:09 2014',
'downhosts': u'0',
'totalhosts': u'3',
'elapsed': u'1.71'
},
'scaninfo': {
u'tcp': {
'services': u'80,443',
'method': u'syn'
}
},
'command_line': u'command goes here'
},
'scan': {
u'2a00:2384:0:208f::15': {
'status': {
'state': u'up',
'reason': u'nd-response'
},
'hostname': u'static.xyz.com',
'vendor': {
u'00:0C:67:99:6f:96': u'VMware'
},
'addresses': {
u'mac': u'00:gf:29:99:6D:96',
u'ipv6': u'a848:2384:0:3456::15'
},
u'tcp': {
80: {
'product': '',
'state': u'open',
'version': '',
'name': u'http',
'conf': u'3',
'extrainfo': '',
'reason': u'syn-ack',
'cpe': ''
},
443: {
'product': '',
'state': u'open',
'version': '',
'name': u'https',
'conf': u'3',
'script': {
u'ssl-cert': u'place holder'
},
'extrainfo': '',
'reason': u'syn-ack',
'cpe': ''
}
}
},
u'2a00:2384:0:208f::16': {
'status': {
'state': u'up',
'reason': u'nd-response'
},
'hostname': u'static.edf.com',
'vendor': {
u'00:0C:55:AE:33:ff': u'VMware'
},
'addresses': {
u'mac': u'00:54:29:fg:55:0F',
u'ipv6': u'8938:8584:0:8685::16'
},
u'tcp': {
80: {
'product': '',
'state': u'open',
'version': '',
'name': u'http',
'conf': u'3',
'extrainfo': '',
'reason': u'syn-ack',
'cpe': ''
},
443: {
'product': '',
'state': u'open',
'version': '',
'name': u'https',
'conf': u'3',
'script': {
u'ssl-cert': u'place holder'
},
'extrainfo': '',
'reason': u'syn-ack',
'cpe': ''
}
}
}
}
}
Required output:
data_out_1 = [
{'address': u'2a00:2384:0:208f::15',
'hostname': u'static.xyz.com',
'ports': {80: {'reason': u'syn-ack', 'state': u'open'},
443: {'reason': u'syn-ack',
'ssl_cert': u'place holder',
'state': u'open'}}},
{'address': u'2a00:2384:0:208f::16',
'hostname': u'static.edf.com',
'ports': {80: {'reason': u'syn-ack', 'state': u'open'},
443: {'reason': u'syn-ack',
'ssl_cert': u'place holder',
'state': u'open'}}}]
That isn't typesafe.
Hashmaps can't store different types of data*. Start by creating datastructures to hold the input data (case classes will help here).
So your stats object might look like
case class Stats(uphosts: Int, timeStr: Datetime, downhosts: Int, totalHosts: Int, elapsed:Double)
ignoring subtyping here for the moment.