NETELLER TransferIn: Authentication credentials are invalid - php

I'm having a problem in integrating the Neteller API to transfer money from a user account to our merchant account. I've succcessfully received the accessToken (using auth_code grant type), however when I try using transferIn I am getting the error Authentication credentials are invalid.
Here is my code:
//getting the accessToken from NETELLER's response
$accessToken = $_POST['accessToken'];
$service_url = "https://test.api.neteller.com/v1/transferIn";
$curl = curl_init($service_url);
$curl_post_data = array(
"paymentMethod" => array(
"type" => "neteller",
"value" => "netellertest_USD#neteller.com"
),
"transaction" => array(
"merchantRefId" => (string)date('YmdHis'),
"amount" => 25,
"currency" => "USD"
),
"verificationCode" => "234124"
);
$jsonDataEncoded = json_encode($curl_post_data);
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonDataEncoded);
$headers = array(
"Content-type: application/json",
"Authorization: Bearer " . $accessToken
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
$curl_response = curl_exec($curl);
curl_close($curl);
However, I am getting this error:
{ "error":{ "code": "5279", "message": "Authentication credentials are invalid" } }
Am I missing anything in the transferIn curl postfields?
Thanks!

You shouldn't be using the auth_code grant type, the correct one is client_credentials. This is explained in detail on page 41 of the latest REST API guide, which you can download from your merchant account >> "Developer" tab >> "Documentation" page.
Just to clarify - the auth_code flow obtains authorization from the user (for ex. for subscription payments, additional account profile information, etc). Although it will work for payments too, it will add 2 more steps to the flow and can be a conversion killer.
Additionally, I found some issues in your code, which you should also address:
The amount you are trying to deposit is too small -- you need to convert the transaction amount to the smallest currency unit before sending it to the API. For example - you want to request a deposit for $5, the smallest currency unit for USD is cents, which is 1/100 of a dollar, so you need to send $5 * 100 = 500 to the API. Important to note here is that the HUF, KRW and JPY currencies do not have subunits, so the amount needs to be sent to the API as is (no conversion needed).
The verificationCode for the USD test account is 270955. This information is available on page 153 of the REST API guide.
Please try to implement the client_credentials grant type flow and post here if you encounter any issues, I will try to assist you. Alternatively, you can add me on Skype (it is in my profile information).

Related

Discord API - UserID Request in PHP

I am currently attempting to query the user information for any given discord account. Its pretty simple, I give the website a Discord User ID and it outputs that specific users account information.
I believe my issue is related directly to how discord authorizes their bots and after about an hour of google searching I figured it would be better to ask here.
Any help much appreciated!
Current Code:
$IDURL = "https://discord.com/api/v8/users/" . $UserID;
$CurlInitID = curl_init();
curl_setopt_array( $CurlInitID, [
CURLOPT_URL => $IDURL,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bot *private key removed*"
]
]);
$Return = curl_exec($CurlInitID);
curl_close($CurlInitID);
die($Return);
Return From Website:
{"message": "405: Method Not Allowed", "code": 0}

Sage Pay / Opayo Credential on File ERROR 3370 : The RelatedVPSTxId cannot be repeated (PHP/cURL solution)

QUESTION
I get an ERROR 3370 from Sage Pay when trying to repeat transactions of type AUTHORISE (but not PAYMENT). I am using Server Integration with PHP/cURL.
ANSWER
This is most likely because you need to send CoF values during your initial AUTHENTICATE transaction. This establishes the initial record as a valid "Credentital on File" and allows you to carry out REPEAT transactions later.
In a nutshell, the initial AUTHENTICATE record must be created with:
COFUsage = FIRST
InitiatedType = CIT
MITType = UNSCHEDULED
HERE IS THE FULL PHP/CURL CODE THAT IS NOW WORKING FOR ME:
STEP 1: AUTHENTICATE
Assuming you are using Server Integration and the customer is "in session" your initial cURL code will look something like this:
// Initialise cURL
$curl = curl_init();
// Set the Sage Pay server URL
$serverLive="https://live.sagepay.com/gateway/service/authorise.vsp";
// Connect to the Sage Pay server
curl_setopt($curl, CURLOPT_URL, $serverLive);
// Set cURL to post variables
curl_setopt($curl, CURLOPT_POST, 1);
// Declare account variables for posting to the Sage Pay server
$VPSProtocol="4.0"; // Must be 4.0 for CoF usage
$Vendor="......."; // Your Sage Pay Vendor Name
// Declare product variables for posting to the Sage Pay server
$Amount=0.01; // This transaction will be for 1 pence
$Currency="GBP";
$Description="......."; // Product description
// Declare URL of your callback page for posting to the Sage Pay server
$NotificationURL="https://www.......";
// Create a unique 16-character VendorTxCode for posting to the Sage Pay server
$UserID=9999; // Unique user ID
$salt="d5s63ffd6s7fgdhs55377yrwesr24553"; // Encryption key
$VendorTxCode=substr(strtoupper(md5(date("U").$UserID.$salt)), 0, 16);
// Declare other variables to pass to Sage Pay (ie. customer name, email, billing address etc)
// These will have been entered via a form on your website
$CustomerName=".......";
$CustomerEmail=".......";
$BillingFirstnames=".......";
$BillingSurname=".......";
$BillingAddress1=".......";
$BillingCity=".......";
$BillingPostCode=".......";
$BillingCountry="GB";
$BillingPhone=".......";
$DeliveryFirstnames=".......";
$DeliverySurname=".......";
$DeliveryAddress1=".......";
$DeliveryCity=".......";
$DeliveryPostCode=".......";
$DeliveryCountry="GB";
$DeliveryPhone=".......";
Now is probably a good time to INSERT these variables into your MySQL database. Create a table called "sagepay" with field/values as follows:
userID = $UserID
VendorTxCode = $VendorTxCode
TxType = AUTHENTICATE
Amount = $Amount
Description = $Description
You should also have the following fields in your sagepay database table. These will start off empty and will be UPDATE(d) later:
SecurityKey
VPSTxId
TxAuthNo
RelatedVendorTxCode
RelatedSecurityKey
RelatedVPSTxId
RelatedTxAuthNo
SchemeTraceID
ACSTransID
DSTransID
Status
Now post your variables to the Sage Pay server via cURL. Your cURL post should send a $COFUsage value of FIRST to correspond with this being an initial AUTHENTICATE transaction and $InitiatedType must be set to CIT to indicate the customer is "in session" (ie. they are going to enter their payment details on your website in a moment):
// Post the variables to the Sage Pay server
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array('Profile' => 'LOW', 'VPSProtocol' => $VPSProtocol, 'Vendor' => $Vendor, 'TxType' => 'AUTHENTICATE', 'VendorTxCode' => $VendorTxCode, **'Apply3DSecure' => '1', 'COFUsage' => 'FIRST', 'InitiatedType' => 'CIT',** 'Amount' => $Amount, 'Currency' => $Currency, 'Description' => $Description, 'CustomerName' => $CustomerName, 'CustomerEMail' => $CustomerEmail, 'BillingFirstnames' => $BillingFirstnames, 'BillingSurname' => $BillingSurname, 'BillingAddress1' => $BillingAddress1, 'BillingCity' => $BillingCity, 'BillingPostCode' => $BillingPostCode, 'BillingCountry' => $BillingCountry, 'BillingPhone' => $BillingPhone, 'DeliveryFirstnames' => $DeliveryFirstnames, 'DeliverySurname' => $DeliverySurname, 'DeliveryAddress1' => $DeliveryAddress1, 'DeliveryCity' => $DeliveryCity, 'DeliveryPostCode' => $DeliveryPostCode, 'DeliveryCountry' => $DeliveryCountry, 'DeliveryPhone' => $DeliveryPhone, 'NotificationURL' => $NotificationURL', 'Status' => 'OK'
)));
// This is supposed to speed things up (not sure if it does!)
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
// Request a response from cURL
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
The above code will create an AUTHENTICATE record on the Sage Pay server and return a cURL string containing values that you will use to UPDATE your previously created database record. These variables will be reused when you create the AUTHORISE transaction (see Step 2):
// Get server response
$response = curl_exec($curl);
// Close cURL
curl_close ($curl);
Convert the $response string into an array called $results[]:
// Convert $response string into an array called $results[]
$results = [];
foreach (explode("\n", $response) as $line)
{
list ($key, $value) = explode('=', $line, 2);
$results[$key] = trim($value); // Trim to remove white space
}
The following variables are contained in the $results[] array. Make sure you UPDATE your initial AUTHENTICATE database record with these values. You will need to recall them when you come to AUTHORISE the transaction and take the first payment:
$SecurityKey=$results['SecurityKey']; // Save this to your database
$VPSTxId=$results['VPSTxId']; // Save this to your database
$results[] will also contain the following variable:
$NextURL=$results['NextURL'];
Once an AUTHENTICATE record is created on the Sage Pay server, you can display a card payment page to your customer using an iFrame with the source URL set to $NextURL
<iframe name="my_iframe" src="<?= $NextURL ?>" width='100%' height='520'></iframe>
At this point the customer will enter their card details and, if everything is in order, the transaction will be completed and the iFrame will update with your $NotificationURL
Sage Pay will pass the following variables to your $NotificationURL in the $_REQUEST[] array. It is a good idea to "trim" these values to ensure no white space creeps in:
$Status=trim($_REQUEST['Status']); // This should be "OK"
$TxAuthNo=trim($_REQUEST['TxAuthNo']);
$ACSTransID=trim($_REQUEST['ACSTransID']);
$DSTransID=trim($_REQUEST['DSTransID']);
UPDATE your "sagepay" database table with these values and then display your "Thank You" message.
STEP 2: AUTHORISE
Now you have an AUTHENTICATE record on the Sage Pay server, and a corresponding record in your MySQL database table, you must AUTHORISE the transaction to take the initial payment. This involves creating a new AUTHORISE record on the Sage Pay server and in your MySQL database.
First, create a new 16-character $VendorTxCode for the AUTHORISE record.
Then, SELECT and transfer the values from the original AUTHENTICATE record into "related" variables for resubmission to Sage Pay:
// Declare "related" variables
$RelatedVendorTxCode = $VendorTxCode; // The original VendorTxCode you created
$RelatedVPSTxId = $VPSTxId; // The $VPSTxId returned in $results[] array
$RelatedSecurityKey = $SecurityKey; // The $SecurityKey returned in $results[] array
Now is a good time to INSERT the $VendorTxCode and these "related" variables as a new record in your MySQL database. Set the TxType field for this new record to AUTHORISE.
Next, pass your variables to Sage Pay via cURL to create an AUTHORISE record on the Sage Pay server. Note, the $InitiatedType is now MIT to indicate the customer is no longer "in session", but the $COFUsage value still needs to be FIRST:
// Create an AUTHORISE record
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array('VPSProtocol' => $VPSProtocol, 'VendorTxCode' => $VendorTxCode, 'Vendor' => $Vendor, 'TxType' => 'AUTHORISE', **'Apply3DSecure' => '1', 'COFUsage' => 'FIRST', 'InitiatedType' => 'MIT', 'MITType' => 'UNSCHEDULED',** 'Amount' => $Amount, 'Description' => $Description, 'RelatedVPSTxId' => $RelatedVPSTxId, 'RelatedVendorTxCode' => $RelatedVendorTxCode, 'RelatedSecurityKey' => $RelatedSecurityKey, 'RelatedTxAuthNo' => $RelatedTxAuthNo)));
Sage Pay will respond again with a string ($response). Convert $response into a $results[] array as before. These are some of the variables you will end up with:
$TxAuthNo
$VPSTxId
$SecurityKey
$SchemeTraceID
$ACSTransID
$DSTransID
$Status
UPDATE the AUTHORISE record in your MySQL database table with these variables. You will need these variables for when you come to REPEAT the transaction.
$TxAuthNo is an authorisation code which is only returned if the AUTHORISE record is successfully created on the Sage Pay server (ie. if $Status is "OK").
$SchemeTraceID is your CoF "token" for repeating successful AUTHORISE transactions.
STEP 3: REPEAT
You can REPEAT against AUTHORISE transactions using the following cURL code. Note, the $COFUsage value now changes from FIRST to SUBSEQUENT and you must send the $SchemeTraceID (token) to verify the transaction as a valid "Credential on File". The "related" variables are those of the original AUTHORISE record (ie. $VendorTxCode, $TxAuthNo, $VPSTxId, and $SecurityKey):
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array('VPSProtocol' => $VPSProtocol, 'Vendor' => $Vendor, 'TxType' => 'REPEAT', 'VendorTxCode' => $VendorTxCode, **'Apply3DSecure' => '1', 'COFUsage' => 'SUBSEQUENT', 'InitiatedType' => 'MIT', 'MITType' => 'UNSCHEDULED', 'SchemeTraceID'=> $SchemeTraceID,** 'Amount' => $Amount, 'Currency' => $Currency, 'Description' => $Description, 'RelatedVPSTxId' => $RelatedVPSTxId, 'RelatedVendorTxCode' => $RelatedVendorTxCode, 'RelatedSecurityKey' => $RelatedSecurityKey, 'RelatedTxAuthNo' => $RelatedTxAuthNo )));
I was also facing same issue. But I have used this library and reason behind this issue is in the first transaction request they(Sagepay server) are getting blank COFUsage, InitiatedType, MITType params
https://github.com/thephpleague/omnipay-sagepay
I installed 4.0 version of omnipay-sagepay library rather then 3.0
{
"require": {
"omnipay/sagepay": "~4.0"
}
}
and in the first transaction, I have passed these extra parameters.
$gateway->setCOFUsage("FIRST");
$gateway->setInitiatedType("CIT");
$gateway->setMITType("UNSCHEDULED");
And for repeat transactions, I have passed these params
$gateway->setCOFUsage('SUBSEQUENT');
$gateway->setInitiatedType('MIT');
$gateway->setMITType('UNSCHEDULED');
$gateway->setSchemeTraceID($TransactionReference['scheme_trace_Id']);
and it's working fine for me. Response from sagepay team

Adyen ERROR: [status] => 403 [errorCode] => 010 [message] => Not allowed [errorType] => security

I'm trying to use JSON API in order to make a (test) payment via ADYEN.
Here's the code (I got this example from Github -> Adyen ->adyen-php-sample-code:
<?php
/**
* Create Payment through the API (HTTP Post)
*
*
* Please note: using our API requires a web service user. Set up your Webservice
* user: Adyen Test CA >> Settings >> Users >> ws#Company. >> Generate Password >> Submit
*
* #author Created by Adyen - Payments Made Easy
*/
/**
* A payment can be submitted by sending a PaymentRequest
* to the authorise action of the web service, the request should
* contain the following variables:
*
* - merchantAccount: The merchant account the payment was processed with.
* - amount: The amount of the payment
* - currency: the currency of the payment
* - amount: the amount of the payment
* - reference: Your reference
* - shopperIP: The IP address of the shopper (optional/recommended)
* - shopperEmail: The e-mail address of the shopper
* - shopperReference: The shopper reference, i.e. the shopper ID
* - fraudOffset: Numeric value that will be added to the fraud score (optional)
* - card
* - expiryMonth: The expiration date's month written as a 2-digit string, padded with 0 if required (e.g. 03 or 12).
* - expiryYear: The expiration date's year written as in full. e.g. 2016.
* - holderName: The card holder's name, aas embossed on the card.
* - number: The card number.
* - cvc: The card validation code. This is the the CVC2 code (for MasterCard), CVV2 (for Visa) or CID (for American Express).
* - billingAddress: we advice you to submit billingAddress data if available for risk checks;
* - street: The street name
* - postalCode: The postal/zip code.
* - city: The city
* - houseNumberOrName:
* - stateOrProvince: The house number
* - country: The country
*/
$request =array(
"merchantAccount" => "[YourMerchantAccount]",
"amount" => array(
"currency" => "EUR",
"value" => "199"
),
"reference" => "TEST-PAYMENT-" . date("Y-m-d-H:i:s"),
"shopperIP" => "2.207.255.255",
"shopperReference" => "YourReference",
"billingAddress" => array(
"street" => "Simon Carmiggeltstraat",
"postalCode" => "1011DJ",
"city" => "Amsterdam",
"houseNumberOrName" => "6-60",
"stateOrProvince" => "NH",
"country" => "NL"
),
"card" => array(
"expiryMonth" => "08",
"expiryYear" => "2018",
"holderName" => "Test Card Holder",
"number" => "4111111111111111",
"cvc" => "737"
),
"browserInfo"=>array(
"acceptHeader"=>$_SERVER['HTTP_USER_AGENT'],
"userAgent"=>$_SERVER['HTTP_ACCEPT']
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://pal-test.adyen.com/pal/servlet/Payment/v25/authorise");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt($ch, CURLOPT_USERPWD, "YourWSUser:YourWSUserPassword");
curl_setopt($ch, CURLOPT_POST,count(json_encode($request)));
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,array("Content-type: application/json"));
$result = curl_exec($ch);
if($result === false)
echo "Error: " . curl_error($ch);
else{
/**
* If the payment passes validation a risk analysis will be done and, depending on the
* outcome, an authorisation will be attempted. You receive a
* payment response with the following fields:
* - pspReference: The reference we assigned to the payment;
* - resultCode: The result of the payment. One of Authorised, Refused or Error;
* - authCode: An authorisation code if the payment was successful, or blank otherwise;
* - refusalReason: If the payment was refused, the refusal reason.
*/
print_r(json_decode($result));
}
curl_close($ch);
?>
Has anyone faced this problem before? How may I fix this?
I've used almost any example in github, but there are just a few error which are documented, the rest....nothing..
Please help me on this. Thank you
Often this problem occurs when your user doesn't have permission to processes raw card details. Handling the raw card information requires full PCI compliance (SAQ D). If this is you, reach out to support#adyen.com to request that permission to be enabled on your account.
If not, you can use Adyen's CSE solution. Docs here. PHP example here.

Where to find FCM Firebase registration ID's (in PHP, for Ionic framework)?

We have build an app with the Ionic framework (we're beginners to Ionic etc), and we register the device to our Firebase account so that we can sent push messages.
I've now found a PHP snippet which connects to fcm via cURL. I can set a message and title, perfect.
My problem is that I can't get it to work, it requires something called "registration id's". Everything I find about this makes it seem like this is super easy to find, but I can't.
Where to I find these registration ID's? All I want is to send all registered users a notification.
I have tried about every code I could find, none work. The most obvious IMO is in the Firebase dashboard->authorisation where I find a list with User Id's (which occur after I've registered my device via the app).
However, this results in {"error":"InvalidRegistration"}. When I remove the 'to' all together, the result it "to" (not as JSON, those two characters only).
When I send messages from the Firebase console get send almost instantly
I've done user.getToken() which results in quite a long string. This doesn't work either
I've got a token provided by the FCMPlugin, but thats still not the right registration id
The code I am using can be found here. I've changed 'registration_ids'-> 'to' and the 'android.googleapis.com' to 'fcm.googleapis.com' , I've read somewhere that is the new version. Other that that, the code is identical.
I couldn't get it to work with registration id's, I've tried about every possible value I've encountered in Firebase, FCM, my app, or any token.
I've fixed my problem with the FCMPlugin and using topics, quite simple really.
In the app (simplefied):
In your main controller, follow the steps of FCMPlugin:
FCMPlugin.getToken();
FCMPlugin.subscribeToTopic('topicExample');
In your push code:
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'ASDSADASDASDASd........................' );
$fields = array(
'to' => "/topics/topicExample",
'data' => array(
'Extra value1' => 'Foo',
'Extra value2' => 'Bar'
),
'notification' => array(
"title" => "Example title", //Any value
"body" => "Example content", //Any value
"color" => "#666666",
"sound" => "default", //If you want notification sound
"click_action" => "FCM_PLUGIN_ACTIVITY", // Must be present for Android
"icon" => "fcm_push_icon" // White icon Android resource
)
);
$headers = array(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
//~ curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
Note:
When you register a user to a topic (the 2nd line in my app code), give it some time. I've read a few hours before a new topic is registered, in my case it worked after an hour (didnt check sooner).

Could any one explain What is FEDEX ACC # and Meter # in FEDEX Integration

ship file is:
include('fedexdc.php');
// create new fedex object
//$fed = new FedExDC('FedEx ACC #','Meter #');
$fed = new FedExDC('...','...'); // removed possible personal data
$ship_data = array(
75=> 'LBS'
,16=> 'Ma'
,13=> ''
,5=> ''
,1273=> '01'
,1274=> '01'
,18=> ''
,15=> 'Boston'
,23=> '1'
,9=> '02134'
,183=> ''
,8=> 'MA'
,117=> 'US'
,17=> ''
,50=> 'US'
,4=> 'Vermonster LLC'
,7=> 'Boston'
,1369=> '1'
,12=> ''
,1333=> '1'
,1401=> '1.0'
,116 => 1
,68 => 'USD'
,1368 => 1
,1369 => 1
,1370 => 5
,3025 => 'FDXG' // This I have added
);
// Ship example
$ship_Ret = $fed->ship_express($ship_data);
if ($error = $fed->getError()) {
echo "ERROR :". $error;
} else {
// Save the label to disk
$fed->label('mylabel.png');
}
/* tracking example
$track_Ret = $fed->track(
array(
29 => 790344664540,
));
*/
echo $fed->debug_str. "\n<BR>";
echo "Price ".$ship_Ret[1419];
Could any one explain What is FEDEX ACC # and Meter #
Any help will appreciable...
Thanks in Advance
Fero
It looks like you are trying to implement the old school Fedex API method of communication. The type of string you are using is called Tagged format. That is going away at some point in the next couple of years and Fedex will not provide a meter for that type of application. Fedex has implemented and new API solution called Fedex Web Services It uses XML formatted strings. Take a look at the new Fedex Web Services # www.fedex.com/developer. You can get a Web Services meter there and also some sample code to get you started. You want to navigate to the technical Resources section of the Developer Resource Center. Find the "Get Started" page.
Acc# is your fedex account number and meter number is a unique identifier for a given account.
What about adding something like this to your _sendCurl() function :
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
After the call to curl_init, and before curl_exec -- should be the easiest way to get rid of that kind of error ; even if probably not the most secure one...
This article might be a good read : Curl: SSL certificate problem, verify that the CA cert is OK : it explains why the error, and also gives some explanations on the kind of security risk the two lines I posted imply -- and also gives some probably safer solution.

Categories