I need to integrate paypal payments advanced in a website. I have configured the required settings on manager.paypal.com.
Now I am making secure http request using curl. But curl_exec doesn't returns anything.
Here is my code. I have confirmed that all the variables have correct values.
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $pf_host_addr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , TRUE);
curl_setopt($ch,CURLOPT_POST,TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS, $postdata);
$resp=curl_exec($ch);
if(!$resp)
{
return "<p>Failed</p>";
}
I get failed as output.
Official documentation on this page is quite helpful
https://www.x.com/developers/paypal/documentation-tools/quick-start-guides/paypal-payments-advanced-hosted-pages
Related
Seems like a simple task but despite having read their docs I can't figure it out. I've gotten a Storefront Access Token, as per https://help.shopify.com/en/api/storefront-api/getting-started. Then I've used it in the CURL request below. However this just returns: {"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}
I found their documentation a bit confusing as they have quite a few different APIs, and whilst it seems that this Storefront Access Token should work for this particular API, perhaps it doesn't?
$url = "https://mysite.myshopify.com/admin/api/2019-07/products/count.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$headers = array(
'X-Shopify-Storefront-Access-Token: 2400d...........a999'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
print_r( $result);
curl_close($ch);
If you are using the Stronfront API your request should point to
https://mysite.myshopify.com/api/2019-07/products/count.json
and not to
https://mysite.myshopify.com/admin/api/2019-07/products/count.json
In addition Storefront Api request are different from the standard ones, have that in mind.
I create a paypal plus (only avaible in germany) payment process via php and curl. I can successfully create a payment and in the next step paypal redirect me to my shop. At this point i want to check if the customer has changed the shipping address and what payment method he choosed. (paypal plus includes various payment methods like invoice)
I have a valid access token and try this piece of code:
$ch = curl_init();
$headers=array('Content-Type:application/json','Authorization:Bearer '.$access_token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, "https://api.paypal.com/v1/payments/payment/".$_GET['paymentId']);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'SSLv3');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$json = json_decode($result);
I looked in the documentation and it looks right to me.
https://developer.paypal.com/docs/api/payments/#payment_get
The problem is the following. I dont receive information about the created payment with the submitted id($_GET['paymentId']). Instead of this i receive informations about my own payments made with this paypal accounts by other merchants.
What i am doing wrong?
It was my fault. The code is fully correct, but the $_GET var was empty, because of a mod_rewrite rule.
we are currently trying to integrate into the Netsuite webservice, however we do not wish to use their PHP connector kit. we have already got a script we have developed using Coldfusion and cfhttp to post data into Netsuite without any issue.
Right now we currently have the scripts converted into PHP and are using the curl function to send data to Netsuite.
We can successfully create a new sales order record without any issue, however obtaining the return response message is proving to quite difficult as all we are getting is 302 redirects.
Im assuming that this may have something to do with login credentials for performing the collecting of the return object, however I have no idea on how to store this data in a cookie value so it can continue to be read across the system to system integration.
Below is our CURL code
$http_header = array(
'Content-Type: text/xml; charset="utf-8"',
'SOAPAction: getItemAvailability',
'Content-Length: ' . strlen($myXml),
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->wdsl);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $myXml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$returnObj = curl_exec($ch);
curl_close($ch);
we have tried various things but cannot seem to get it to work so we can obtain the return xml data, its creating the records with no issue what so ever.. Any suggestions would be greatly appreciated
I would recommend using a wrapper library instead of curl for NetSuite communication. I've done a lot of work with the ruby wrapper and it's worked great for me.
One of the reasons you can get a 302 is that account you are trying to access is in a different datacenter than the current WSDL you are pointing to. The standard WSDL domain is system.netsuite.com but many NetSuite installations are on system.na1.netsuite.com. The easiest way to check which datacenter you are on is to login to the GUI and look at the domain.
I am developing site which has the cart page.I am trying to integrate Google sandbox Checkout payment gateway. I don't want to redirect to Google checkout page when user click Google Checkout button. I want to validate or authorize the user card details with Google checkout ,also pass all cart details to Google Checkout.So we can achieve this by using php curl.Once we pass our details as request and will get response from Google Checkout.By using that response i can proceed further.Is it possible to do that in Google Checkout. If yes kindly give some example.
First make sure that your sandbox merchant id / password are correct. They are different than the ones from production accounts.
Since the error is related to Basic Authentication, use the command line version of curl to verify that you have the right credentials. Post something like this and verify that you get a correct response back:
curl -d "some xml"
https://1234567890:abcd1234#sandbox.google.com/checkout/api/checkout/v2/request/Merchant/1234567890
This doc has more details on posting XML carts with curl to Google Checkout:
https://checkout.google.com/support/sell/bin/answer.py?hl=en&answer=70646
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$merchant_id:$merchant_key");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, $_header_array);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $cart->GetXML());
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Make it 4
$debugData['result'] = curl_exec($ch);
curl_close($ch);
I've set up a PHP IPN Paypal notification handler on my site to notify me of payments through PayPal. I have a Joomla install which uses an elaborate, uncommented and undocumented component for processing bookings.
I know I need to call a certain PHP script with a series of arguments once a valid IPN has been received. However, as it's Joomla I have the script in the form:
/index.php?option=com_component&controller=contr
Though obviously this isn't the actual PHP script - like I say, an elaborate framework in MVC.
What is the best method to then call this script? I was thinking of using
header("Location: index.php?opt....");
however given I've got processing before (with no output) and potentially processing after, I'm not sure if this is the best call.
Appreciate this question is rather obtuse, but any help appreciated!
You can try using CURL, if it's installed/enabled on your server.
$ch = curl_init("path/to/your/script.php");
//Include your headers here
$headers = array('');
//Set the data you want to send, as an associative array.
$postData = array("foo" => "bar", 12 => true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($ch);
if($output == FALSE){
// Error reporting
}
curl_close($ch);
You can't rely on PayPal to follow your redirect, or at least I wouldn't.
How about including the php-script that you want to invoke?