I have the following code in php
$postData = "USER=xxxxxx"
. "&PWD=xxxxxxxx"
. "&SIGNATURE=xxxxxxx"
. "&METHOD=SetExpressCheckout"
. "&VERSION=93"
. "&EMAIL=" . $_POST['email']
. "&PAYMENTREQUEST_0_SHIPTOPHONENUM=" . $_POST['phone']
. "&PAYMENTREQUEST_0_AMT=" . $price
. "&PAYMENTREQUEST_0_ITEMAMT=" . $price
. "&PAYMENTREQUEST_0_PAYMENTACTION=SALE"
. "&PAYMENTREQUEST_0_DESC=" . $plan['fullname']
. "&L_PAYMENTREQUEST_0_NAME0=" .$plan['fullname']
. "&L_PAYMENTREQUEST_0_AMT0=$price"
. "&L_PAYMENTREQUEST_0_QTY0=1"
. "&RETURNURL=http://localhost/bemo/casperreg"
. "&CANCELURL=http://bemoacademicconsulting.com/casperprep-internal";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // this line makes it work under https
curl_setopt($ch, CURLOPT_URL, "https://api-3t.paypal.com/nvp");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
// Ready the postData to send
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
// Send the data to Paypal and assign the repsonse
$resp = curl_exec($ch);
parse_str($resp,$arr);
redirect::to("https://www.paypal.com/checkoutnow?token=" . $arr['TOKEN'] . "&useraction=commit");
Now technically everything here works except for the fact that even though it says useraction=commit I don't get a pay now button. Can anyone help me please?
Also as a bonus question, even though I pass the phone number to paypal, I don't see it on the paypal page. Is this something I can do?
Thanks!
Nur
The correct redirect address for express checkout should be
https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=[token number]
Source: Developer Guide
As to your bonus question
1. Try doing a field mask on number xxx-xxx-xxxx
2. Check if phone number is set to required in your merchant profile
Related
I'm trying to use an API that requires authentication with a private key pair.
Here is the API documentation:
Authentication API Docs
SubmitOrder API Docs
This is my code. I'm not getting any errors, but no trades are being placed. My coding skills are not the sharpest and without errors, I'm stuck!
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
// Generate random amount between 28.00 and 30.00
$ran1 = mt_rand(2800, 3000);
$ran2 = $ran1/100;
// Config
$sAPIKey = "mykey"; // private key
$sAPISecret = "mysecret"; // api secret
$sPair = "GLD_BTC";
// $sAmount = "1.00";
$sRate = "0.0001";
$sNonce = time();
// Request
$sRequest = "https://tradesatoshi.com/api/private/submitorder?API_PUBLIC_KEY=" . $sAPIKey . "&Market=" . $sPair . "&Type=" . 'Buy' . "&Amount=" . $ran2 . "&Price=" . $sRate . "&nonce=" . $sNonce;
$sSign=hash_hmac('sha512', $sRequest, $sAPISecret);
$ch = curl_init($sRequest);
// disable cert validation
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // shouldn't need this
// curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:' . $sSign));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('apisign:' . $sSign));
$execResult = curl_exec($ch);
?>
Any guidance would be sincerely appreciated.
I am trying to get output of this API using php. It's a Australia Post Freight calculator. I am not sure what is wrong with it, can some one please suggest. It will be really helpful.
// Set your API key: remember to change this to your live API key in production
$apiKey = API_KEY;
// Set the URL for the Domestic Parcel Size service
$urlPrefix = URL_PREFIX;
$parcelTypesURL = 'https://' . $urlPrefix . '/postage/parcel/domestic/size.json';
// Lookup domestic parcel types (different kinds of standard boxes etc)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $parcelTypesURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('AUTH-KEY: ' . $apiKey));
$rawBody = curl_exec($ch);
// Check the response: if the body is empty then an error occurred
if(!$rawBody){
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
// All good, lets parse the response into a JSON object
$parcelTypesJSON = json_decode($rawBody);
curl_init() is disabled for security reasons...
This means that the server has disabled that function.
If you have control of the server, then enable curl_init() in the php.ini.
More information here.
If you do not, try using file_get_contents(). more information here
I am using smsindiahub to send sms as below but it is not sending the message,
function send_user_pickup_sms($mobile_number = '', $verification_code = '', $smsemailarray=array(),$date="",$time="") {
if ($mobile_number != '' && $verification_code != '') {
//$customer_name = $userDetails['FirstName'].' '.$userDetails['LastName'];
$message = 'projectname Order ID '.$verification_code.' picked up on '.$date.' at '.$time.': ';
foreach($smsemailarray as $item){
$message .= $item["Qty"].$item["name"].' ';
}
$message = urlencode($message);
//Send Registration code to user via sms
$apiURL = "http://login.smsindiahub.in/vendorsms/pushsms.aspx?user=" . SMSHUB_USERNAME . "&password=" . SMSHUB_PASSWORD . "&msisdn=" . $mobile_number . "&sid=" . SMSHUB_SENDERID . "&msg=" . $message . "&fl=" . SMSHUB_FLAG . "&gwid=" . SMSHUB_GWID;
// Initiate curl
$ch = curl_init();
// Set The Response Format to Json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL, $apiURL);
// Execute
$result = curl_exec($ch);
echo"<pre>";print_R($result);die;
// Closing
curl_close($ch);
return $result;
}
return false;
}
it print a result as below :
{"ErrorCode":"24","ErrorMessage":"Invalid template or template mismatchInvalid template or template mismatch","JobId":null,"MessageData":null}
I am not understand where is fault,can any one help me to resolve it?
Please check it in your smsindiahub panel. Please check the status of your template. Make sure that, your template is approved and not pending.
Thanks
I'm trying to submit a form to Hubspot on the success page of Magento. I confirmed already that the variable $str_post contains all of the info that's needed. Unfortunately, I can't determine why $response is empty. It seems like the CURL connection is not being made but I can't seem to determine why. Is there something I need to do to trigger the CURL connection other than just loading the page?
Please note I've removed the GUI/Form ID from the URL.
<?php
//Process a new form submission in HubSpot in order to create a new Contact.
$hubspotutk = $_COOKIE['hubspotutk']; //grab the cookie from the visitors browser.
$ip_addr = $_SERVER['REMOTE_ADDR']; //IP address too.
$hs_context = array(
'hutk' => $hubspotutk,
'ipAddress' => $ip_addr,
'pageUrl' => 'https://www.myfoodstorage.com/onestepcheckout/',
'pageTitle' => 'MyFoodStorage.com Cart Checkout'
);
$hs_context_json = json_encode($hs_context);
//Need to populate these varilables with values from the form.
$str_post = "firstname=" . urlencode($firstname)
. "&lastname=" . urlencode($lastname)
. "&email=" . urlencode($email)
. "&phone=" . urlencode($telephone)
. "&address=" . urlencode($street)
. "&city=" . urlencode($city)
. "&state=" . urlencode($region)
. "&country=" . urlencode($country)
. "&hs_context=" . urlencode($hs_context_json); //Leave this one be :)
//replace the values in this URL with your portal ID and your form GUID
$endpoint = 'https://forms.hubspot.com/uploads/form/v2/GUI-ID/FORM-ID';
$ch = #curl_init();
#curl_setopt($ch, CURLOPT_POST, true);
#curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post);
#curl_setopt($ch, CURLOPT_URL, $endpoint);
#curl_setopt($ch, CURLOPT_HTTPHEADER, array('application/x-www-form-urlencoded'));
#curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = #curl_exec($ch); //Log the response from HubSpot as needed.
#curl_close($ch);
echo $response;
?>
A successful submission to the Forms API will return a 204 (No Content) response, so there would be nothing in the body of the response. You can get the status code using curl_getinfo.
$response = #curl_exec($ch); //Log the response from HubSpot as needed.
echo #curl_getinfo($ch, CURLINFO_HTTP_CODE);
#curl_close($ch);
echo $response;
I am working on an app through my developer test account and all I am doing is trying to post a test notification to my user. I am doing this using the facebook requests 2.0 documentation, so my code looks like this:
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=" . $app_id .
"&client_secret=" . $app_secret .
"&grant_type=client_credentials";
$app_access_token = file_get_contents($token_url);
$user_id = $this->user->id;
$apprequest_url ="https://graph.facebook.com/" .
$user_id .
"/apprequests?message='testing notification'" .
"&" .
$app_access_token . "&method=post";
$result = file_get_contents($apprequest_url);
echo "Request id number: " . $result;
When i do this I get an error on the page that says "failed to open stream", however when I copy and paste the url into the address bar I don't get any errors and get returned a request id. Anybody know why this might be happening?
I solved it using curl instead of file_get_contents. file_get_contents used to throw errors for some reason.
the cpde for the curl is:
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_URL, $apprequest_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
curl_close($ch);
I know I'm a litle late, but I hope it helps somebody.
You should set allow_url_fopen to On