AWS SNS push notification clarification - php

I have few doubts regarding sending SNS Push Notifications.
1) I referred this stackoverflow discussion where we can set sound for APNS. But how we do it for GCM ?
2) How to configure no sound alert ?
3) Is it possible to set sound for each Endpoint in PHP while creating them ? I just want to know this so that while sending message I can send to those with sound enabled and to those disabled while sending it with topicARN.
4) I referred this document for getting the delivery status of push notification as logs in cloudwatch. Is there any API to retrieve the delivery status of those endpoints which failed to receive in PHP ?

For GCM, you can do like this:
$send = $sns->publish(array(
'TargetArn' => $EndpointArn, // to send notification to single user
'MessageStructure' => 'json',
'Message' => json_encode(array(
'default' => '',
'APNS' => json_encode(array(
'aps' => array(
'alert' => 'message to topic',
'sound'=> 'default',
'badge'=> 1
),
'userid' => '1'
)),
'GCM' => json_encode(array(
'data' => array(
'alert' => 'message to topic',
'userid' => '1'
),
))
))
));
Do you want to create a custom sound alert for each endpoint arn?
For 4th point refer this links:
1) http://docs.aws.amazon.com/sns/latest/dg/sns-msg-status.html?ref_=pe_411040_132389510
2) How to confirm delivery status when using amazonSNS mobile push?

Related

What values can we send to Stripe using Omnipay

I have two questions
One:
What values can we send to Stripe using Omnipay authorize(), example below is only sending amount and description
$response = $gateway->authorize([
'amount' => '10.00',
'currency' => 'USD',
'description' => 'This is a test purchase transaction.',
'paymentMethod' => $paymentMethod,
'returnUrl' => $completePaymentUrl,
'confirm' => true,
])->send();
what if we want name and email to be sent, how can we achieve this also
Two:
the payment intent we get back from the above request, is generating error log on Godaddy server, I am using the following code;
$paymentIntentReference = $response->getPaymentIntentReference();
$response = $gateway->confirm([
'paymentIntentReference' => $paymentIntentReference,
'returnUrl' => $completePaymentUrl,
])->send();
error log: PHP Fatal error: Uncaught Omnipay\Common\Exception\InvalidRequestException: The paymentIntentReference parameter is required
by my confusion is that in spite of this error log the payment process is being complete, so should I worry about this error or not,
and I hope this time I asked my question in the right manner
thanks in advance

How to use AWS SDK for PHP to send email by SES with dedicated IP?

My aws/aws-sdk-php version is 2.7.27. The emails we sent are marked as spam. I found that my AWS account has got 8 dedicated IPs in Dedicated IPs page. But the sender IP of my email isn't any of the dedicated IPs, it's a shared IP of amazon SES. In developer document of SES, I found that they said I can make a Configuration Set to specify whick IP pool is used for sending. I add a param called 'ConfigurationSetName' as the doc said but it doesn't work, my emails are still sending through shared IPs. My code is like:
$sendingParams = array(
'Source' => $fromEmail,
'Destination' => array(
'ToAddresses' => is_array($email) ? $email : array($email),
//'CcAddresses' => is_array($ccEmail) ? $ccEmail : array($ccEmail),
//'BccAddresses' => is_array($bccEmail) ? $bccEmail : array($bccEmail),
),
'Message' => array(
// Subject is required
'Subject' => array(
// Data is required
'Data' => $subject,
'Charset' => 'utf-8',
),
// Body is required
'Body' => array(
'Html' => array(
// Data is required
'Data' => $content,
'Charset' => 'utf-8',
),
),
),
'ReplyToAddresses' => array($fromEmail),
'ReturnPath' => $returnPath,
'ConfigurationSetName' => 'system',
);
if (!empty($ccEmail)) {
$sendingParams['Destination']['CcAddresses'] = is_array($ccEmail) ? $ccEmail : array($ccEmail);
}
if (!empty($bccEmail)) {
$sendingParams['Destination']['BccAddresses'] = is_array($bccEmail) ? $bccEmail : array($bccEmail);
}
$result = $this->sdkClient->sendEmail($sendingParams);
What's the problem with my code? Should I change the version of the SDK?
I find the problem. My dedicated IPs are warming up, and I can't use them before they were totally warmed up.

Amazon AWS SNS Delivery Status For SMS has random Log Streams

I am using Amazon's php sdk.
I use Amazon SNS service to send direct sms. When I send an sms from my php application it gives me a message ID.
I have to track the delivery status of each of my message. I have enabled cloud watch logs for Text Messaging using Manage text messaging preferences settings. The IAM role is properly configured and logs end in Cloudwatch.
Now the problem I am facing is that the system creates a random log stream for every message i send.
Here is a screen shot.
I have sent six messages and all of them has been successful( I am sending them to myself). And against every message a single log stream exists.
API gives me a function to get logs based upon LogGroupName and LogGroupStream. The LogGroupName remains the same but LogGroupStream is differnt for every message.
here is the sdk call
$result = $client->getLogEvents([
'endTime' => <integer>,
'limit' => <integer>,
'logGroupName' => '<string>', // REQUIRED
'logStreamName' => '<string>', // REQUIRED
'nextToken' => '<string>',
'startFromHead' => true || false,
'startTime' => <integer>,
]);
How should i get the Logs? Is there a way to tell amazon to log all of sms deliveries to a single LOG STREAM. So i know the stream and can query for logs.
With a Query:
$result = $CloudWatchclient->startQuery([
'endTime' => strtotime("+5 minutes", strtotime($creation_date)) * 1000,
'limit' => 1,
'logGroupName' => '.....DirectPublishToPhoneNumber',
'queryString' => 'field #message like /'.$awsmessageid.'/',
'startTime' => strtotime($creation_date)*1000,
]);
$queryid = $result->get('queryId');
sleep(2);
$result = $CloudWatchclient->getQueryResults([
'queryId' => $queryid, // REQUIRED
]);
$result = $result->get('results');
The result containt the event log with sms data success
You could use filterLogEventsMethod from CloudWatchLogsClient:
$result = $client->filterLogEvents(array(
'logGroupName' => 'string', //Required
'startTime' => integer,
'endTime' => integer,
'filterPattern' => 'string',
'nextToken' => 'string',
'limit' => integer,
'interleaved' => true || false));
Reference: Aws Docs

AWS SDK Guzzle error when sending email with SES

I am attempting to send mail using AWS SES sendEmail method, and I'm having trouble with an error. I have read this question: AWS SDK Guzzle error when trying to send a email with SES
I am dealing with a very similar issue. The original poster indicates that they have a solution, but did not post the solution.
My code:
$response = $this->sesClient->sendEmail('example#example.com',
array('ToAddresses' => array($to)),
array('Subject.Data' => array($subject), 'Body.Text.Data' => array($message)));
Guzzle code producing the error (from aws/Guzzle/Service/Client.php):
return $this->getCommand($method, isset($args[0]) ? $args[0] : array())->getResult();
Error produced:
Catchable fatal error: Argument 2 passed to Guzzle\Service\Client::getCommand() must be of the type array, string given
Looking at the Guzzle code, I can see that the call to getCommand will send a string if args[0] is set and is a string. If args[0] is NOT set then an empty array is sent.
What am I missing here please?
SOLUTION:
It turns out I was trying to use SDK1 data structures on the SDK2 code base. Thanks to Charlie Smith for helping me to understand what I was doing wrong.
For others (using AWS SDK for PHP 2) :
Create the client -
$this->sesClient = \Aws\Ses\SesClient::factory(array(
'key' =>AWS_ACCESS_KEY_ID,
'secret' => AWS_SECRET_KEY,
'region' => Region::US_EAST_1
));
Now, structure the email (don't forget that if you're using the sandbox you will need to verify any addresses you send to. This restriction doesn't apply if you have been granted production status) -
$from = "Example name <example#example.com>";
$to ="example#verified.domain.com";
$subject = "Testing AWS SES SendEmail()";
$response = $this->sesClient->getCommand('SendEmail', array(
'Source' => $from,
'Destination' => array(
'ToAddresses' => array($to)
),
'Message' => array(
'Subject' => array(
'Data' => $subject
),
'Body' => array(
'Text' => array(
'Data' => "Hello World!\n Testing AWS email sending."
),
'Html' => array(
'Data' => "<h1>Hello World!</h1><p>Testing AWS email sending</p>"
)
),
),
))->execute();
That should work now.
Here is the relevant section in the AWS SDK for PHP 2 documentation:
http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.Ses.SesClient.html#_sendEmail

Paypal Mobile Library IPN verification

I'm a PHP developer. I've implemented Paypal Mobile Library IPN.
Here is what i receive in test mode.
$_POST = array(
'payment_request_date' => 'Wed Jun 15 07:21:26 PDT 2011',
'return_url' => 'https://www.paypal.com',
'fees_payer' => 'EACHRECEIVER',
'ipn_notification_url' => 'http://mysite.com/myscript.php',
'verify_sign' => 'AsPVXqWsrQkFWs.gl9jI5iQU2b53AiFm-2O-GeHSy9tAKrrPm327E81P',
'test_ipn' => 1,
'transaction' => array('USD 9.99'),
'cancel_url' => 'https://www.paypal.com',
'pay_key' => 'AP-725112792Y356822X',
'action_type' => 'CREATE',
'memo' => '55547098#1 month platinum membership',
'transaction_type' => 'Adaptive Payment PAY',
'status' => 'COMPLETED',
'log_default_shipping_address_in_transaction' => false,
'charset' => 'windows-1252',
'sender_useCredentials' => true,
'notify_version' => 'UNVERSIONED',
'reverse_all_parallel_payments_on_error' => false,
);
As I see there is a field verify_sign, so I guess that it should be verified by sending to
https://www.sandbox.paypal.com/cgi-bin/webscr
following POST request:
$req = 'cmd=_notify-validate&'.http_build_query($_POST);
But it always returns INVALID.
I also tried using SOAP request to GetTransactionDetails for validation of this transaction, asTransactionID I specified $_POST['pay_key'] (AP-725112792Y356822X) and this service returns error
10004 The transaction id is not valid
So how can I verify the Paypal Mobile Library response?
Can i check it's verification in sandbox mode or only on live.
Thank you for any suggestions.
I would recommend trying to use the IPN code sample in PHP on PayPal developer network here: https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623

Categories