I got resource not found error when run on a sandbox version but it work find when run on a live.
can someone please advise how can I resolve the error?
here's my code
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"plan_id\": \"P-97A61885CU957844JMFV\",\n \"start_time\": \"2021-10-19T00:00:00Z\",\n \"shipping_amount\": {\n \"currency_code\": \"USD\",\n \"custom_id\": \"xxxxdxxx\",\n \"value\": \"10.00\"\n },\n \"subscriber\": {\n \"name\": {\n \"given_name\": \"John\",\n \"surname\": \"Doe\"\n },\n \"email_address\": \"customer#example.com\",\n \"shipping_address\": {\n \"name\": {\n \"full_name\": \"John Doe\"\n },\n \"address\": {\n \"address_line_1\": \"2211 N First Street\",\n \"address_line_2\": \"Building 17\",\n \"admin_area_2\": \"San Jose\",\n \"admin_area_1\": \"CA\",\n \"postal_code\": \"95131\",\n \"country_code\": \"US\"\n }\n }\n },\n \"application_context\": {\n \"brand_name\": \"SAMPLEBRAND\",\n \"locale\": \"en-US\",\n \"shipping_preference\": \"SET_PROVIDED_ADDRESS\",\n \"user_action\": \"SUBSCRIBE_NOW\",\n \"payment_method\": {\n \"payer_selected\": \"PAYPAL\",\n \"payee_preferred\": \"IMMEDIATE_PAYMENT_REQUIRED\"\n },\n \"return_url\": \"https://sample.com/webhook_paypal.php\",\n \"cancel_url\": \"https://sample.com/webhook_paypal.php\"\n }\n}");
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer '.$token;
$headers[] = 'Paypal-Request-Id: SUBSCRIPTION-21092019-001';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
echo $result;
P-97A61885CU957844JMFV
Create such a Plan ID (and Product ID) for the sanbox environment, using the appropriate sandbox account, and use those sandbox IDs instead. You can do so either via https://www.sandbox.paypal.com/billing (logging in with the sandbox account's credentials), or via API (using the sandbox account's client ID and secret)
Live Plan IDs will never work to create subscriptions in the sandbox environment, nor sandbox ones for the live environment. The two environments are completely separate.
Manage your sandbox accounts and sandbox apps in the developer.paypal.com dashboard.
Related
i am trying to list all resources client have access to. I am unable to figure out how to to make the call. I have used this curl
curl -X GET \
http://$URL/auth/realms/$RELM/authz/resource-server/resource \
-H 'Authorization: Bearer$TOKEN' \
-H 'cache-control: no-cache'
so far but i am getting this response :
{"error":"RESTEASY003210: Could not find resource for full path: http://localhost:8070/auth/realms/argo/authz/resource-server/resource"}
Can someone help me to figure out how i can list all resources and if resource is not in the list to create new one ?
SOLUTION that is implementd:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->keyCloakURL . '/realms/' . $this->relmName . '/protocol/openid-connect/token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"audience=" . KEYCLOAK_CLIENT_NAME . "&grant_type=urn:ietf:params:oauth:grant-type:uma-ticket&response_include_resource_name=true");
$authorization = "Authorization: Bearer " . $user_token['access_token'];
curl_setopt($ch, CURLOPT_HTTPHEADER, array (
'Content-Type: application/x-www-form-urlencoded',
$authorization
));
$result = curl_exec($ch);
if(curl_errno($ch))
{
echo 'curl error';
return false;
}
$result = json_decode($result, true);
curl_close($ch);
if(isset($result['access_token']) && !empty($result['access_token']))
{
$parts = explode('.', $result['access_token']);
if(!isset($parts[1]))
{
return false;
}
$info = $this->base64UrlDecode($parts[1]);
$info = json_decode($info, true);
$return = array ();
if(isset($info['authorization']['permissions']))
{
$permissions = $info['authorization']['permissions'];
foreach($permissions as $ecahPermission)
{
if(isset($ecahPermission['scopes']))
{
// $scopes = array_map('strtolower', $ecahPermission['scopes']);
$return[$ecahPermission['rsname']] = $ecahPermission['scopes'];
}
}
}
return $return;
}
return false;
I am trying to implement ipn in my system but shows error
SSL connect error
TLS version shows TLS 1.0
It is a client's system. I downloaded the code from paypal website. I am currently testing it.
but it throws error
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
$ch = curl_init('https://www.howsmyssl.com/a/check');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data);
echo $json->tls_version;
file_put_contents('NAB/paypal-ipn.txt', var_export($_POST, true));
echo "ipn processing";
// STEP 1: read POST data
// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
// Instead, read raw POST data from the input stream.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
echo "<br>1";
// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
$req = 'cmd=_notify-validate';
if (function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
echo "<br>2";
foreach ($myPost as $key => $value) {
if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
echo "<br>3";
// Step 2: POST IPN data back to PayPal to validate
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
//$ch = curl_init('https://www.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
// In wamp-like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set
// the directory path of the certificate as shown below:
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
echo "<br>3";
if ( !($res = curl_exec($ch)) ) {
error_log("Got " . curl_error($ch) . " when processing IPN data");
echo curl_error($ch);
curl_close($ch);
//exit;
}
If 'howsmyssl' is reporting that the systems supports only TLS v 1.0, it is likely that an upgrade is necessary to support TLS v 1.2. The curl_setopt($ch, CURLOPT_SSLVERSION, 6); is requesting TLS v 1.2 (see list in PHP Curl (with NSS) is probably using SSLv3 insted of TLS when connecting to https).
Also, as of June 30,2017, PayPal will be requiring TLS v 1.2 (see https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US and Php curl set ssl version).
You may be able to test your integration using TLS v 1.0 (until 6/30/2017) by changing to curl_setopt($ch, CURLOPT_SSLVERSION, 4);.
I had a similar problem problem when implementing the paypal ipn listener code. The script would stop executing where step 2 starts in the code you've provided. I solved it by downloading cacert.pem from http://curl.haxx.se/docs/caextract.html. Then I copied the downloaded file to the same folder as paypalipnlistener.php and then uncommented the following code in paypalipnlistener.php // curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); to curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); and the script executed successfully.
I'm using this link in order to add new subsciption entry:
https://graph.facebook.com/XXX/subscriptions?access_token=YYY&object=payments&callback_url=http://xxx/rlcallback.php&fields=actions,disputes&verify_token=ZZZ
For some reason, I get error:
{
"error": {
"message": "(#100) Invalid object. object should be url or open graph object id.",
"type": "OAuthException",
"code": 100
}
}
But the object "payments" inside my link is clearly valid. What am I missing here?
Make sure you are using the correct parameters: object, callback_url, fields, verify_token...and of course the access_token.
Also (and that may be the problem in this case), you have to use POST, not GET. You can either use CURL with POST to subscribe to the Realtime API, or you just use one of the SDKs as explained in the Facebook docs: https://developers.facebook.com/docs/graph-api/reference/v2.1/app/subscriptions
Here is one example with CURL:
$appsecretProof = hash_hmac('sha256', FBAPPID . '|' . FBSECRET, FBSECRET);
$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'facebook-php');
$postData = 'object=page' .
'&callback_url=' . urlencode('http://yourdomain.com/callback.php') .
'&fields=feed' .
'&verify_token=somethingfancy' .
'&access_token=' . FBAPPID . '|' . FBSECRET .
'&appsecret_proof=' . $appsecretProof;
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/' . FBAPPID . '/subscriptions');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$curlResult = curl_exec($ch);
you need to specify object, callback_url, fields and verify_token parameters as your curl post parameters
example:
curl -F 'object=user' \
-F 'callback_url=' \
-F 'fields=checkins' \
-F 'verify_token=' \
"https://graph.facebook.com//subscriptions?access_token=
I'm trying to set up a credit card interface on a website using Intuit's QBMS and I've got the XML request set up per the specifications on the Intuit documentation. I've also got my AppID, Connection Ticket, and Application Login set up. But when I do a test, I'm getting the following error:
Unknown error returned by SAX parser. Exception from other package: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
Here is the XML Request:
$productionUrl = 'https://merchantaccount.quickbooks.com/j/AppGateway';
$connectionTicket = 'SDK-xxx-xxx-xxxxxxxxxxxxxxxxxxxxxxxx';
$applicationLogin = 'qbms.site.com';
$appID = "111111111";
$xml = rawurlencode('<?xml version="1.0"?>
<?qbmsxml version="4.1"?>
<QBMSXML>
<SignonMsgsRq>
<SignonDesktopRq>
<ClientDateTime>' . date('Y-m-d\TH:i:s') . '</ClientDateTime>
<ApplicationLogin>' . $applicationLogin . '</ApplicationLogin>
<ConnectionTicket>' . $connectionTicket . '</ConnectionTicket>
<Language>English</Language>
<AppID>' . $appID . '</AppID>
<AppVer>1.0</AppVer>
</SignonDesktopRq>
</SignonMsgsRq>
<QBMSXMLMsgsRq>
<CustomerCreditCardChargeRq>
<TransRequestID>' . $_transId . '</TransRequestID>
<CreditCardNumber>' . $_cc_number . '</CreditCardNumber>
<ExpirationMonth>' . $_cc_exp_month . '</ExpirationMonth>
<ExpirationYear>' . $_cc_exp_year . '</ExpirationYear>
<IsCardPresent>false</IsCardPresent>
<Amount>' . $_amount . '</Amount>
<NameOnCard>' . $_cc_name . '</NameOnCard>
<CreditCardAddress>' . $_cc_address . '</CreditCardAddress>
<CreditCardPostalCode>' . $_cc_zip . '</CreditCardPostalCode>
<SalesTaxAmount>' . $_tax . '</SalesTaxAmount>
</CustomerCreditCardChargeRq>
</QBMSXMLMsgsRq>
</QBMSXML>');
$header[] = "Content-type: application/x-qbmsxml";
$header[] = "Content-length: " . strlen($xml);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_URL, $productionUrl);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
Since the documentation is still not available, in particular https://developer.intuit.com/qbsdk-current/Common/newOSR/index.html
This is speculation based on my testing. Check to see that the <TransRequestID>
contains a number, with only leading or following alpha characters (if any).
The response contains this xml: <TxnAuthorizationStamp>
which is your TransRequestID incremented by 1. I think if it can't figure out how to increment it will fail.
Please update any progress you have.
I know that this is an old question but I ran into similar problems and was able to get it working.
When I removed this phrase from the request xml packet:
<?xml version="1.0"?>
The SAX parser error went away and it works.
I'm trying to use this site https://www.oneall.com/ to add social login to a test site. After setting up the code and the login I still don't know how to extract user data from access token. Here's the link I get:
http://MYACCOUNT.api.oneall.com/socialize/redirect.html?provider_connection_token=ACCESS TOKEN HERE
I get this code by the call back page like this
if ( ! empty ($_POST['connection_token']))
{
echo "Connection token received: ".$_POST['connection_token'];
}
else
{
echo "No connection token received";
}
if ( ! empty ($_POST['connection_token']))
{
$token = $_POST['connection_token'];
$site_subdomain = 'myaccountname';
$site_public_key = 'public key';
$site_private_key = 'private key';
$site_domain = $site_subdomain.'.api.oneall.com';
$resource_uri = 'https://'.$site_domain.'/connections/'.$token .'.json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $resource_uri);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_USERPWD, $site_public_key . ":" . $site_private_key);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_FAILONERROR, 0);
$result_json = curl_exec($curl);
if ($result_json === false)
{
echo 'Curl error: ' . curl_error($curl). '<br />';
echo 'Curl info: ' . curl_getinfo($curl). '<br />';
curl_close($curl);
}
else
{
curl_close($curl);
$json = json_decode ($result_json);
$data = $json->response->result->data;
if ($data->plugin->key == 'social_login')
{
if ($data->plugin->data->status == 'success')
{
$user_token = $data->user->user_token;
$user_id = GetUserIdForUserToken($user_token);
if ($user_id === null)
{
LinkUserTokenToUserId ($user_token, $user_id);
}
else
{
}
}
}
}
}
I need to learn how to extract data now and a little example about extracting the user name by this code.
You can use the access token to get the connection details from oneall using their api
You use the connection_token to get the connection details (including
the user's Facebook profile data).
example
http://MYACCOUNT.api.oneall.com/connections/ACCESS TOKEN HERE.json -->>for json formatted data
oneall docs
Once you get the user's token, you then need to make a API call to Facebook, e.g. https://graph.facebook.com/me/?access_token={$access_token}
If the $access_token is correct, Facebook should return the user's details, including name, username and any other details you've asked for.