I am trying to initiate a recurring payment in Adyen but I am unable to figure out how to do so. I have tried sending a request up receipt of payment results:
$request = array(
'amount.currency' => $this->currency,
'amount.value' => $sepaSubmission->amount,
'merchantAccount' => $this->merchantAccount,
'recurring.contract' => "RECURRING,ONECLICK",
'reference' => $sepaSubmission->psp_reference,
'shopperEmail' => $account->email,
'shopperReference' => $account->email,
"selectedRecurringDetailReference" => "LATEST",
"skinCode" => env('ADYEN_SKIN_CODE'),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_USERPWD, env('ADYEN_USERNAME') . ":" . env('ADYEN_PASSWORD'));
curl_setopt($ch, CURLOPT_URL, "https://test.adyen.com/hpp/pay.shtml");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST,count($request));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
I get the following error: Error: Skin null does not exist
I have verified a valid skinCode is included.
I am using SepaDirect as payment.
I have also just tried attaching the above fields to the initial payment submission form I am using and they are essentially ignored, the payment is processed as a one off.
Any assistance would be appreciated, I have been combing through the documents for several days to get this going to no avail.
It seems you are trying to redirect to the skin in order to do a followup Sepa transaction. This because you are making the call to "https://test.adyen.com/hpp/pay.shtml".
Sepa direct debit can be processed directly via the API, there is no need to send the shopper to the HPP
You can do the following:
$request = array(
'amount.currency' => $this->currency,
'amount.value' => $sepaSubmission->amount,
'merchantAccount' => $this->merchantAccount,
'recurring.contract' => "RECURRING",
'reference' => $sepaSubmission->psp_reference,
'shopperEmail' => $account->email,
'shopperReference' => $account->email,
"selectedRecurringDetailReference" => "LATEST",
"shopperInteraction" : "ContAuth",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_USERPWD, env('ADYEN_USERNAME') . ":" . env('ADYEN_PASSWORD'));
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_POST,count($request));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
Please note the change in URL, the removal of the skincode and the addition of "shopperInteraction" : "ContAuth", and the removal of one click in
recurring.contract' => "RECURRING",
So when you want to charge a shopper again, you just do this call from your end, there is no need to send him to the HPP.
Hope this helps,
Cheers,
Andrew
Related
I'm working on InfusionSoft API (documentation here) and making request by using CURL (no API SDK) but getting the following error.
Failed to parse XML-RPC request: Premature end of file.
any help would be appreciated. Below is the CURL code that I'm using.
$url_token = 'http://api.infusionsoft.com/crm/xmlrpc/v1/?access_token='.$access_token;
$curlPost = array(
'access_token' => $access_token,
'privateKey' => $api_key,
'contactId' => 6171,
'selectedFields' => array('email')
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_token);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($curlPost));
$res = curl_exec($ch);
echo $res;
I am polling live prices from the Skyscanner API. Although I receive the session_key and although I am immediately polling the results I am getting a 410 (Gone) response header with an empty body. It used to work fine from my localhost environment but not on my live server anymore.
Has anybody experienced this before and can maybe give me a hint what the issue could be?
$url_api = "http://partners.api.skyscanner.net/apiservices/pricing/v1.0/";
$api_key = "XXX"; // Not shown here
$data = array('apiKey' => $api_key, 'country' => 'DE', 'currency' => 'EUR',
'locale' => 'de-DE', 'originplace' => 'HAM', 'destinationplace' => 'AMS', 'cabinclass' => 'economy', 'outbounddate' => '2017-01-27',
'inbounddate' => '2017-01-30' , 'locationschema' => 'Iata', 'groupPricing' => true);
$httpdata = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_api);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $httpdata);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Accept: application/json'));
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
$response = curl_exec($ch);
curl_close($ch);
$headers = get_headers_from_curl_response($response);
$url = $headers['Location']."?apiKey=".$api_key."&stops=0";
echo $url;
return;
I created a little app which uses Pushbullet's API.
It is writtent in PhP and uses cURL to proceed the different requests.
At first, I use oauth2 to recieve an access token.
Then it is /v2/pushes/ to send a push to the registred account.
The message is recieved on the Pusbullet account but nothing shows up on the smartphone. There is no notification.
I hope someone can help me.
Thanks.
My function which sends the push:
function send_push($token){
$data = array(
'type' => 'note',
'title' => 'Alert',
'body' => 'My body :)!'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.pushbullet.com/v2/pushes');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer '.$token
));
$data = curl_exec($ch);
curl_close($ch);
}
I did everything right, all seem legit, but i don't see any payments made by my dummy user to the merchant:
Is it something in my code:
creating plan:
$req = array(
'USER' => 'bennyrefaelov-facilitator_api1.gmail.com',
'PWD' => 'YWKQ3M3NXBTZQ78U',
'SIGNATURE' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AuVEFUpBu6N8yXkmFksuwwSiQOW8',
'VERSION' => '98.0',
'METHOD' => 'SetExpressCheckout',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Mark',
'REQCONFIRMSHIPPING'=>'0',
'NOSHIPPING'=>'1',
'ALLOWNOTE'=>'0',
'SOLUTIONTYPE'=>'Sole',
'LANDINGPAGE'=>'Billing',
'BRANDNAME'=>'MisterSurvey',
'PAYMENTREQUEST_0_AMT'=>'100.00',
'MAXAMT' => '100.00',
'L_BILLINGAGREEMENTDESCRIPTION0' => 'Pay up',
'PAYMENTREQUEST_0_TAXAMT'=>'0',
'PAYMENTREQUEST_0_ITEMAMT'=>'100.00',
'L_BILLINGTYPE0' => 'RecurringPayments',
'PAYMENTREQUEST_0_DESC'=>'An awesome package',
'PAYMENTREQUEST_0_CUSTOM'=>'This is just for fun',
'PAYMENTREQUEST_0_CURRENCYCODE'=>'USD',
'L_PAYMENTREQUEST_0_NUMBER0'=>'itemid1',
'L_PAYMENTREQUEST_0_NAME0'=>'MyItem1',
'L_PAYMENTREQUEST_0_DESC0'=>'basic package',
'L_PAYMENTREQUEST_0_QTY0'=>'1',
'L_PAYMENTREQUEST_0_AMT0'=>'100.00',
'L_PAYMENTREQUEST_0_TAXAMT0'=>'0',
'RETURNURL'=>'http://mistersurveylocal.com:8080/#/pricing',
'CANCELURL'=>'http://mistersurveylocal.com:8080/#/'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($req));
$return = curl_exec($ch);
curl_close($ch);
excute plan (after user agrees)
$token = Input::get('token');
$payerId = Input::get('payerId');
$req = array(
'USER' => 'bennyrefaelov-facilitator_api1.gmail.com',
'PWD' => 'YWKQ3M3NXBTZQ78U',
'SIGNATURE' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AuVEFUpBu6N8yXkmFksuwwSiQOW8',
'VERSION' => '98.0',
'METHOD' => 'CreateRecurringPaymentsProfile',
'TOKEN'=>$token,
'payerid'=>$payerId,
'PROFILESTARTDATE' =>date('Y-m-d\TH:i:s\Z'),
'TOTALBILLINGCYCLES'=>'12',
'DESC'=>'Pay up',
'BILLINGPERIOD'=>'Month',
'BILLINGFREQUENCY'=>'1',
'AMT'=>'100',
'CURRENCYCODE'=>'USD',
'COUNTRYCODE'=>'US',
'MAXFAILEDPAYMENTS'=>'3'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($req));
$return = curl_exec($ch);
curl_close($ch);
return urldecode($return);
It says it's active, and verified, and the start date is at this moment, why there is no payment made?
is there something missing?
I had the exact same problem. As it turns out, it was an issue with the Sandbox being very slow. After 2 days of troubleshooting and debugging, all the transactions completed and I received all IPN messages related to them.
It's unfortunate, but the solution is simply to wait for them to process. Hopefully live will be much faster.
In the PayPal tutorial on making your first call it gives you a JSON string that I've found impossible to post. I've exhausted Google and I just can't seem to figure out how to post this data to PayPal. The code below gives me a 415 error code ("unsupported media type"). I've been stuck on the error for hours and am growing tired of it. I'll be grateful to anyone that can help me. I've tried to make my description clear in case we do find an answer others in the future will be able to find it easily.
$post_data = array (
'intent' => 'sale',
'redirect_urls' => array (
'return_url' => 'http://example.com/return',
'cancel_url' => 'http://example.com/cancel'
),
'payer' => array (
'payment_mehod' => 'paypal'
),
'transactions' => array (
'amount' => array (
'total' => '7.47',
'currency' => 'USD'
)
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $result_array['access_token']]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
$result = curl_exec($ch);
Edit: In the second to last line of provided code I have also used http_build_query and I've also tried just simply sending it as a multidimensional array. The error code 415 returns for both of these.
curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'Content-Type: application/json',
'Authorization: Bearer ' . $result_array['access_token']
)
);