FCM link not working in desktop notification - php

We are trying to send a desktop notification calling the FCM rest api via a php service.
We call the https://fcm.googleapis.com/fcm/send service, passing the following payload:
"data" => [
"notification" => [
"title" => $content->title,
"body" => "notification body",
"icon" => url('assets/images/logo_3.png'),
],
"webpush" => [
"headers" => [
"Urgency" => "high",
],
"fcm_options" => [
"link" => url($content->url)
]
],
],
The notification is received in desktop (tested on windows 10) but when we click on the popup the link is not opened in the browser.
What are we doing wrong?

It turns out that we must use click_action field, like this:
"notification" => [
"title" => $content->title,
"body" => "body",
"icon" => "assets/icon.png",
"click_action" => "https://www.example.com",
]
Docs here:https://firebase.google.com/docs/cloud-messaging/http-server-ref

Related

telegram bot buttons change into one

what I am trying to achieve is that when someone clicks button for example 'done' there should be one button with 'done' text in it and if user clicks that single button - all three previous buttons should be shown again.
The text above the buttons should remain the same all the time.
All of it should be in php.
My code is:
$data = [
'text' => 'some text here'
];
$keyboard = json_encode([
"inline_keyboard" => [
[
[
"text" => "Done",
"callback_data" => "done"
],
[
"text" => "Cancel",
"callback_data" => "cancel"
],
[
"text" => "processing",
"callback_data" => "processing"
],
]
]
],true);
$url ="https://api.telegram.org/bot$token/sendMessage?".http_build_query($data). "&parse_mode=html".'&reply_markup='.$keyboard;

Paypal / field missing when I try to capture a multiseller payment

Here is the response, I don't urdestand what is the problem.
{
"name": "INVALID_REQUEST",
"message": "Request is not well-formed, syntactically incorrect, or violates schema.",
"debug_id": "5939e86ea6f6e",
"details": [
{
"field": "/",
"location": "body",
"issue": "MALFORMED_REQUEST_JSON",
"description": "The request JSON is not well formed."
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-MALFORMED_REQUEST_JSON",
"rel": "information_link",
"encType": "application/json"
}
]
}
And the code, what calls the capture endpoint:
$headerForBasicAuth = $this->paypalModel->getBasicAuthHeader();
$http = Http::withHeaders([
'Authorization' => 'Basic '.$headerForBasicAuth,
'Content-Type' => 'application/json'
]);
$response = $http->post($this->paypalModel->getBasePath().'/v2/checkout/orders/'.$request->orderID.'/capture')->body();
If needed, there is the code, how I create the order:
$headerForBasicAuth = $this->paypalModel->getBasicAuthHeader();
$http = Http::withHeaders([
'Authorization' => 'Basic '.$headerForBasicAuth,
'Content-Type' => 'application/json'
]);
$body = [
'intent' => "CAPTURE",
'purchase_units' => [
[
'payee' => [
"merchant_id" => "V2B4REMFCWFE6"
],
'amount' => [
'currency_code' => 'USD',
//'value' => $data['price']
'value' => '15'
],
'payment_instruction' => [
'disbursement_mode' => 'INSTANT',
'platform_fees' => [
[
'amount' => [
'currency_code' => 'USD',
'value' => '5'
]
]
]
]
]
],
'application_context' => [
'cancel_url' => 'http://laravel-paypal-example.test',
'return_url' => 'http://laravel-paypal-example.test',
'shipping_preference' => 'NO_SHIPPING'
]
];
$response = $http->post($this->paypalModel->getBasePath().'/v2/checkout/orders', $body)->body();
I'm using platform fee, but in admin menu, I can't enable the platform fees checkbox, every time give an error: "Your settings weren't saved. Please try again later."
The orderID is okay, I checked many times. So, when I create an order, I can accept the payment in the PayPal checkout, but when the transaction is approved, I can't capture it with orderID.
Somehow there is a request body in what you are posting to the /capture endpoint. From looking at your code I can't tell how/why a body is being added, but it is in fact being added, and whatever is added is not valid JSON, and hence the request is rejected.

Push notification with pusher beam, unable to send data/payload

I am using following php sdk for generating pusher beam push notification. but there is not information provided in the sdk docs on how to send data/payload along with it. the notification is bean sent correctly but I am unable to send data: please guide me how we can send the data: it is showing hasData as false in beam console, please check:
php sdk i am using : https://github.com/pusher/push-notifications-php
my code look like this:
$pushNotification = new PushNotifications([
'instanceId' => env('BEAM_INSTANCE_ID'),
'secretKey' => env('BEAM_PRIMARY_KEY')
]);
$pushNotification->publishToInterests(
['message-notification'],
[
"apns" => [
"aps" => [
"alert" => "Message Received",
],
],
"fcm" => [
"notification" => [
'title' => 'some title',
'body' => 'some body',
'data' => 'some data', //passing data here but not working
],
],
]
);
I got it working, we can pass data in following way:
$publishResponse = $pushNotifications->publishToInterests(
["donuts"],
[
"apns" => [
"aps" => [
"alert" => "Hello!",
],
],
"fcm" => [
"notification" => [
"title" => "Hello!",
"body" => "Hello, world!",
],
"data" => [ // <==== pass data here
"name" => "adam",
"type" => "user",
],
],
]
);

Attributes not visible when sending message to Amazon SQS using PHP SDK

I am trying to send a message to an SQS queue, in PHP with a message body and message attributes. This is how my message looks:
$message = [
'MessageAttributes' => [
"Title" => [
'DataType' => "String",
'StringValue' => "The Hitchhiker's Guide to the Galaxy"
],
"Author" => [
'DataType' => "String",
'StringValue' => "Douglas Adams."
],
"WeeksOn" => [
'DataType' => "Number",
'StringValue' => "6"
]
],
'QueueUrl' => $this->queueUrl,
'MessageBody' => 'Hello SQS testing'
];
I found this example on Github: Sending and Receiving Messages in Amazon SQS.
When I open the console and look for my message in the queue, I can see the message body but I don't see any attributes. I am using Amazon SDK for PHP 3.x.

how to create multiple payments using PHP SDK Quickbooks

I am creating App for Quickbook in PHP
I am using https://github.com/intuit/QuickBooks-V3-PHP-SDK/
I want to make payments to multiple invoice in single API call.
I see their example but those make single payment. I need multiple payments towards various invoice for different customers.
How that is possible?
Their example code is here:
https://github.com/IntuitDeveloper/SampleApp-CRUD-PHP/blob/master/CRUD_Examples/Payment/PaymentCreate.php
So here's a snippet:
$theResourceObj = Payment::create([
"CustomerRef" =>
[
"value" => "1"
],
"TotalAmt" => 100.00,
"Line" => [
[
"Amount" => 100.00,
"LinkedTxn" => [
[
"TxnId" => "210",
"TxnType" => "Invoice"
]]
]]
]);
$resultingObj = $dataService->Add($theResourceObj);
Then if you refer to their documentation:
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment#the-payment-object
You can see that the Line element is composed of Zero or more transactions accounting for this payment. including The invoice to which payment is applied. i.e. you can repeat things within Line, to apply the payment to more than one invoice.
So applying a payment to more than one invoice lists each individual invoice, and the amount of the payment to apply, in the repeating Line node array:
$theResourceObj = Payment::create([
"CustomerRef" =>
[
"value" => "1"
],
"TotalAmt" => 100.00,
"Line" => [
[
"Amount" => 50.00,
"LinkedTxn" => [
[
"TxnId" => "210",
"TxnType" => "Invoice"
]]
],
[
"Amount" => 25.00,
"LinkedTxn" => [
[
"TxnId" => "211",
"TxnType" => "Invoice"
]]
],
[
"Amount" => 25.00,
"LinkedTxn" => [
[
"TxnId" => "212",
"TxnType" => "Invoice"
]]
],
]
]);
$resultingObj = $dataService->Add($theResourceObj);
Finally I found solution for me.
API have Batch Option to add multiple Objects in single Batch.
Thanks to everyone

Categories