Paypal Mobile Library IPN verification - php

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

Related

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

PayPal Sandbox "Sorry, we can’t complete your purchase at this time "

I have set up PayPal Sandbox to test my PayPal Express integration, but whenever I log in to the sandbox from the payment page, I get greeted by the following error message;
I am using laravel-omnipay and omnipay-paypal with the PayPal_Express gateway.
I think this is likely to be a configuration issue (or a bug..? Although I'm hoping it's not.) in PayPal, but this is the piece of code I am using to initiate the payment:
public function checkout ()
{
$cart = Cart::forSession ();
$response = Omnipay::purchase
(
[
'amount' => $cart->getPrice (),
'currency' => preferred_currency ()->name,
'description' => (string) $cart,
'returnUrl' => URL::action ('OrderController#checkoutReturn'),
'cancelUrl' => URL::action ('OrderController#checkoutCancel')
]
)->send ();
if ($response->isSuccessful ())
dd ('successful', $response);
else if ($response->isRedirect ())
return $response->getRedirectResponse ();
else
return Redirect::to ('/cart')->with ('alerts', [new Alert ('An error occurred while attempting to process your order: ' . $response->getMessage (), Alert::TYPE_ALERT)]);
}
And the omnipay.php configuration file:
return array(
'gateway' => 'PayPal_Express',
'defaults' => array(
'testMode' => true,
),
'gateways' => array(
'PayPal_Express' => array(
'username' => '<>',
'password' => '<>',
'signature' => '<>',
'landingPage' => array('billing', 'login'),
),
),
);
The username, password and signature I am using are the ones I created in the PayPal Sandbox for my account.
The sandbox account I am using to test this is a "personal"/buyer account, with funding sources and "Payment Review" disabled. The Sandbox Accounts overview on the PayPal Developer website indicates the sandbox account's status as "complete".
I'm hoping I didn't miss something obvious. I checked out some of the other answers on Stack Overflow but none of those seemed to offer a solution for this exact problem.
Contact PayPal support, as there is something wrong on their end.

ADYEN Payment - SOAP Error on test SoapFault Object ( [message:protected] => security 010 Not allowed

This is my first post in this forum.
I'm trying to develop all the payments to Adyen using the WS, instead of the skin/post method that I was using until now.
So, I downloaded from their example, this code (I'm posting also the class method to connect by WS)
function Adyen($login, $password, $host ="live", $debug=FALSE ) {
$this->DEBUG = $debug;
$this->client = new SoapClient( "https://pal-$host.adyen.com/pal/Payment.wsdl",
array(
"login" => $login,
"password" => $password,
'trace' => 1,
'soap_version' => SOAP_1_1,
'style' => SOAP_DOCUMENT,
'encoding' => SOAP_LITERAL
)
);
}
function authorise( $amount,$currencyCode,$cardHolder,$cardNumber,$expm,$expy,$cvc,$reference) {
global $merchantAccount;
$response = $this->client->authorise( array(
"paymentRequest" => array
(
"amount" => array (
"value" => $amount,
"currency" => $currencyCode),
"card" => array (
"cvc" => $cvc,
"expiryMonth" => $expm,
"expiryYear" => $expy,
"holderName" => $cardHolder,
"number" => $cardNumber,
),
"merchantAccount" => $merchantAccount,
"reference" => $reference,
)
)
);
When I'm executing this code, it returns this error
#!/usr/bin/php SOAP Error on test SoapFault Object ( [message:protected] => security 010 Not allowed [string:Exception:private] =>
Do you have any suggestions to solve it?
Best Regards.
Edit:
It's too strange, cause with the same method, but with different parameters (In case of the recurring payment, I haven't this error. This the case runs
$response = $this->client->authorise(
array(
"paymentRequest" =>
array(
"amount" => array("value" => $amount,
"currency" => $currencyCode),
"merchantAccount" => $merchantAccount,
"reference" => $reference,
"shopperReference" => $reference",
"shopperEmail" => $email,
"recurring" => array("contract" => "RECURRING"),
"selectedRecurringDetailReference" => "LATEST",
"shopperInteraction" => "ContAuth"
)
)
);
Had the same question, here is the support answer:
You are trying to make an API payment. Please be aware that there are a few downsides using the direct integration API.
Most important, due to strict industry regulations, the Merchant is required to be PCI DSS (Payment Card Industry Data Security Standard) compliant at Level 1 or 2. The PCI DSS certification process requires a big contribution from you in both time and money.
http://en.wikipedia.org/wiki/PCI_DSS
The direct integration also offers a limited set of payment methods and might require you to implement features like the 3D secure mechanism.
The normal integration works as follow:
Redirect the shopper from your website to our Hosted Payment Pages.
Shopper can choose several payment methods and makes the payment.
Shopper is redirected back to your website and we pass back a result code of the payment.
We sent also a notification via SOAP or HTTP Post.
From Adyen documentation
010 Not allowed You are not allowed to perform this action
I think you should send email to their support. May be your account not ready for use.
You need to add your ip in the ca admin area for the user 'Edit Allowed User IP Range'.
I think in this code you have mistakenly put extra double quotes( "shopperReference" => $reference",).
$response = $this->client->authorise(
array(
"paymentRequest" =>
array(
"amount" => array("value" => $amount,
"currency" => $currencyCode),
"merchantAccount" => $merchantAccount,
"reference" => $reference,
"shopperReference" => $reference",
"shopperEmail" => $email,
"recurring" => array("contract" => "RECURRING"),
"selectedRecurringDetailReference" => "LATEST",
"shopperInteraction" => "ContAuth"
)
)
);

paypal API doExpressCheckoutPayment status Pending

I am testing recurring payments. After doExpressCheckoutPayment action i recieved status Pending in my sandbox paypal account. Why status not completed? How much time need to set status Complete? Or maybe need set some params in sandbox. I am used default settings. Payment review - disabled.
Thanks!)
UPD 1:
Here is my request code:
public function setPayment($plan){
$params = array(
'PAYMENTREQUEST_0_AMT' => '10.00',
'RETURNURL' => $this->base_url.'/paypal/response',
'CANCELURL' => $this->base_url.'/paypal/paypal',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP',
'PAYMENTREQUEST_0_DESC' => 'Testing PayPal recurring',
'PAYMENTREQUEST_0_NOTIFYURL' => 'http://barton.netai.net/ipn.php',
'L_BILLINGTYPE0' => 'RecurringPayments',
'L_BILLINGAGREEMENTDESCRIPTION0' => 'SamePayments'
);
$this->_paypal->addFields($params);
$response = $this->_paypal->request('SetExpressCheckout');
if (strtoupper($response['ACK'])=='SUCCESS'){
$token=$response['TOKEN'];
header('Location: '.$this->_paypal->getPaypalUrl().'?cmd=_express-checkout&token='.$token);
return true;
} else {
return false;
}
}
public function responseAction(){
if (isset($_GET['token']) && isset($_GET['PayerID'])){
$this->_paypal->addFields(array('TOKEN'=>$_GET['token']));
$response=$this->_paypal->request('GetExpressCheckoutDetails');
if ($response['ACK']=='Success'){
$response=array();
$this->_paypal->addFields(array(
'TOKEN' => $_GET['token'],
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
'PAYERID' => $_GET['PayerID'],
'L_BILLINGTYPE0' => 'RecurringPayments',
'L_BILLINGAGREEMENTDESCRIPTION0' => 'SamePayments',
'PAYMENTREQUEST_0_AMT' => '10.00',
'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP'
));
$response=$this->_paypal->request('DoExpressCheckoutPayment');
show($response); exit;
}
}
}
SetExpressCheckout response:
Array
(
[TOKEN] => EC-01C99915Y11155245
[TIMESTAMP] => 2012-02-24T10:23:32Z
[CORRELATIONID] => 69e91a5abc347
[ACK] => Success
[VERSION] => 84
[BUILD] => 2571254
)
doExpressCheckoutPayment response:
Array
(
[TOKEN] => EC-2FR88291S31672645
[SUCCESSPAGEREDIRECTREQUESTED] => false
[TIMESTAMP] => 2012-02-24T10:26:08Z
[CORRELATIONID] => a95c7a9bb64b3
[ACK] => Success
[VERSION] => 84
[BUILD] => 2571254
[INSURANCEOPTIONSELECTED] => false
[SHIPPINGOPTIONISDEFAULT] => false
[PAYMENTINFO_0_TRANSACTIONID] => 2RN165632T770592L
[PAYMENTINFO_0_TRANSACTIONTYPE] => expresscheckout
[PAYMENTINFO_0_PAYMENTTYPE] => instant
[PAYMENTINFO_0_ORDERTIME] => 2012-02-24T10:26:06Z
[PAYMENTINFO_0_AMT] => 10.00
[PAYMENTINFO_0_TAXAMT] => 0.00
[PAYMENTINFO_0_CURRENCYCODE] => GBP
[PAYMENTINFO_0_PAYMENTSTATUS] => Pending
[PAYMENTINFO_0_PENDINGREASON] => authorization
[PAYMENTINFO_0_REASONCODE] => None
[PAYMENTINFO_0_PROTECTIONELIGIBILITY] => Eligible
[PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE] => ItemNotReceivedEligible,UnauthorizedPaymentEligible
[PAYMENTINFO_0_SECUREMERCHANTACCOUNTID] => WLC8CZSP2C5L8
[PAYMENTINFO_0_ERRORCODE] => 0
[PAYMENTINFO_0_ACK] => Success
)
In my previous question you advised me to install PAYMENTREQUEST_0_PAYMENTACTION to Sale,
Maybe this help me to decide this problem?
As mentioned in the other question, replace;
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Authorization',
by
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
When you set the PAYMENTREQUEST_0_PAYMENTACTION to 'Authorization' , means that you are asking PayPal to check whether the funds are available, and if they are, to place a hold on them for 72 hours. You have up to 29 days to capture an authorization, and when you do, the funds are on hold for three days only. The first 72 hours of the 29-day period are known as the "honor period", meaning that PayPal guarantees that the funds are available.
The three-day hold occurs in most cases, depending on the
card-issuing bank, or the bank itself in ACH transactions, such as a
debit card. In some cases, the three-day hold is waived, whereas in
other cases there may be a hold on the card for up to 30 days or
until the next billing cycle.
If you decide to capture the funds within the last three days of the
29-day period, those funds are held until the end of the 29th day
instead of the usual three days.
You can capture less than the original authorization amount, the full
amount, or up to 115% of or $75 more than the original authorization,
whichever is less.
And when you set the PAYMENTREQUEST_0_PAYMENTACTION to 'Sale' , the payment is processed without holding the funds. The funds are transferred from the buyer's funding source to your PayPal account balance immediately.
You would use the 'Sale' option for something that is delivered
quickly, such as digital goods or a product that ships as soon as you
receive the order.
The funds are immediately taken from the buyer's funding source and
sent to your PayPal account balance.

cURL vs __SoapClient for PHP Soap Application

I'm having a recurring issue with PHP's inbuilt SOAP client where it returns the same error response regardless of the input paramaters.
Is there an advantage to using the SOAP library built into PHP or a disadvantage to directly querying via cURL through GET?
$client = new SoapClient("http://example.com/wdsl");
$params = array(
'Username' => 'username',
'Password' => 'pass',
'EventName' => 'Test Event',
'EventDate' => '2011-06-15T13:45:30',
'Destination' => '447987654321',
'Carrier' => '1',
'PhoneType' => '13',
'Originator' => 'ukflive',
'MessageText' => 'Test',
'LogoURL' => 'http://example.com/mail.gif',
'BookingReference' => '123456',
'Tickets' => '1',
'CollectionValidFrom' => '2011-06-15T13:45:30',
'CollectionValidTo' => '2011-06-15T18:45:30',
'TemplatePath' => '',
'PostBack' => 'http://example.com/'
);
$response = $client->__soapCall("SendManagedMobileTicket", $params);
print_r($response);
SoapClient is an integrated, actively maintained part of PHP5. cURL is the quick and dirty way to send HTTP data. The smart long term decision is to stick with SoapClient and its methods.
You may also want to look into the response headers, as shown in the notes section of the __soapCall() documentation page: http://www.php.net/manual/en/soapclient.soapcall.php#102387

Categories