GetRecurringPaymentsProfileDetails - ACK=Failure - paypal

I have code GetRecurringPaymentsProfileDetails...where it wrong?
//--------------------------------------------------------------------------------------------------------------------------------------------------------
public function callNVP($profileId) {
$api_request = '&USER=' . urlencode('bestlifeXXXXX.gmaill.com')
. '&PWD=' . urlencode('136XXXXXXX')
. '&SIGNATURE=' . urlencode('XXXXXXXXJJJ4qi4-ASVptjmiE8Sqp4tXXXXXXCa')
. '&VERSION=76.0'
. '&METHOD =GetRecurringPaymentsProfileDetails'
. '&PROFILEID=' . urlencode($profileId);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp'); // For live transactions, change to 'https://api-3t.paypal.com/nvp'
curl_setopt($ch, CURLOPT_VERBOSE, 1);
//curl_setopt($ch, CURLOPT_HEADER, FALSE);
// Uncomment these to turn off server and peer verification
//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);
// Set the API parameters for this transaction
//curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $api_request);
// Request response from PayPal
$response = curl_exec($ch);
// If no response was received from PayPal there is no point parsing the response
if (!$response)
die('Calling PayPal to change_subscription_status failed: ' . curl_error($ch) . '(' . curl_errno($ch) . ')');
curl_close($ch);
// An associative array is more usable than a parameter string
parse_str($response, $parsed_response);
return $parsed_response;
}
But it's return result:
Array
(
[0] => Array
(
[TIMESTAMP] => 2015-12-10T03:49:09Z
[CORRELATIONID] => cb2489449e84c
[ACK] => Failure
[L_ERRORCODE0] => 10001
[L_SHORTMESSAGE0] => Internal Error
[L_LONGMESSAGE0] => Timeout processing request
)
)
What I want is:
(
[PROFILEID] => I-CL7Kxxx
[STATUS] => Active
[AUTOBILLOUTAMT] => AddToNextBilling
[DESC] => xxx
[MAXFAILEDPAYMENTS] => 2
[SUBSCRIBERNAME] => Dan
[PROFILESTARTDATE] => 2013-05-15T07:00:00Z
[PROFILEREFERENCE] => 31571
[NEXTBILLINGDATE] => 2013-05-16T10:00:00Z
[NUMCYCLESCOMPLETED] => 1
[NUMCYCLESREMAINING] => 18446744073709551615
[OUTSTANDINGBALANCE] => 0.00
[FAILEDPAYMENTCOUNT] => 0
[LASTPAYMENTDATE] => 2013-05-15T14:52:04Z
[LASTPAYMENTAMT] => 0.10
[TRIALAMTPAID] => 0.00
[REGULARAMTPAID] => 0.10
[AGGREGATEAMT] => 0.10
[AGGREGATEOPTIONALAMT] => 0.00
[FINALPAYMENTDUEDATE] => 1970-01-01T00:00:00Z
[TIMESTAMP] => 2013-05-15T14:55:58Z
[CORRELATIONID] => 225681xxx
[ACK] => Success
[VERSION] => 64
[BUILD] => 5908853
[SHIPTOSTREET] => xxx
[SHIPTOCITY] => xxx
[SHIPTOSTATE] => CA
[SHIPTOZIP] => xxx
[SHIPTOCOUNTRYCODE] => US
[SHIPTOCOUNTRY] => US
[SHIPTOCOUNTRYNAME] => United States
[SHIPADDRESSOWNER] => PayPal
[SHIPADDRESSSTATUS] => Unconfirmed
[BILLINGPERIOD] => Day
[BILLINGFREQUENCY] => 1
[TOTALBILLINGCYCLES] => 0
[CURRENCYCODE] => USD
[AMT] => 0.10
[SHIPPINGAMT] => 0.00
[TAXAMT] => 0.00
[REGULARBILLINGPERIOD] => Day
[REGULARBILLINGFREQUENCY] => 1
[REGULARTOTALBILLINGCYCLES] => 0
[REGULARCURRENCYCODE] => USD
[REGULARAMT] => 0.10
[REGULARSHIPPINGAMT] => 0.00
[REGULARTAXAMT] => 0.00
)
Who can help me? Please...

You've got this:
'&METHOD =GetRecurringPaymentsProfileDetails'
I think that space in there is causing an invalid request. Try this:
'&METHOD=GetRecurringPaymentsProfileDetails'

Its definitely because of your API request(I am guessing its Incorrect Profile ID)
Can you try(click) the following link in your browser(substitute API credentials,Profile ID)
https://api-3t.sandbox.paypal.com/nvp?&user=xxxxxxxxxx&pwd=xxxxxxxxxx&signature=xxxxxxxxxx&VERSION=109.0&METHOD=GetRecurringPaymentsProfileDetails&PROFILEID=I-XXXXXXXXXXXX
And see what response you get.
I get Internal Error, when I used "I-XXXXXXXXXXXX" as profile id.

Related

Get customer details after transaction

I'm struggling to decide between Paypal NVP and REST APIs.
The REST API seems to be newer and better but I can't find a way to get customer details after a transaction occured.
Basically I want to set up a billing plan for recurring payments and then get customer details via API so they do not have to enter them through my website.
Paypal Express checkout seems to be what I should use here.
The NVP API offers a GetExpressCheckoutDetails method to get these details.
I didn't find something similar for the REST API.
Since the REST API seems to go through Express Checkout as well there should be a solution.
How can I get customer details after activating the billing agreement?
I ran into this same problem a month ago and after reading the docs, there's currently no way to accomplish this with the REST API. If there is a way, it's not documented.
The only way I found to do this is with the NVP API and possibly the SOAP API. The NVP API will give you back most of the fields that you want but if you've stored custom fields for a transaction, it will only give you 3 of the custom fields but not all of them (weird).
I haven't tried the NVP method GetExpressCheckoutDetails but I have used the GetTransactionDetails method. It will give you back the transaction details. It returns a text block that you must parse. Each field is URL encoded and separated by an ampersand. Here's an example in PHP:
<?php
// Get cURL resource
$ch = curl_init();
// Set url
curl_setopt($ch, CURLOPT_URL, 'https://api-3t.paypal.com/nvp/');
// Set method
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
// Set options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set headers
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/x-www-form-urlencoded; charset=utf-8",
]
);
// Create body
$body = [
"VERSION" => "204.0",
"METHOD" => "GetTransactionDetails",
"USER" => "nvp_api_username_here",
"PWD" => "nvp_api_password_here",
"SIGNATURE" => "nvp_api_signature_here",
"TRANSACTIONID" => "some_paypal_transaction_id_here",
];
$body = http_build_query($body);
// Set body
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
// Send the request and save response to $resp
$resp = curl_exec($ch);
if(!$resp) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
} else {
parse_str($resp, $formated_response);
print_r($formated_response);
}
// Close request to clear up some resources
curl_close($ch);
Here's the formatted return body:
Array
(
[RECEIVERBUSINESS] => paypal_account_owner_email_address_here#test.com
[RECEIVEREMAIL] => paypal_account_owner_email_address_here#test.com
[RECEIVERID] => 1111111111111
[EMAIL] => buyers_email_address_here#test.com
[PAYERID] => 55551
[PAYERSTATUS] => verified
[COUNTRYCODE] => US
[BUSINESS] => buyers_business_name_here
[ADDRESSOWNER] => PayPal
[ADDRESSSTATUS] => None
[SALESTAX] => 0.00
[SHIPAMOUNT] => 0.00
[SHIPHANDLEAMOUNT] => 0.00
[SHIPDISCOUNT] => 0.00
[INSURANCEAMOUNT] => 0.00
[GIFTRECEIPT] => 0
[TIMESTAMP] => 2016-08-02T17:04:58Z
[CORRELATIONID] => 55552
[ACK] => Success
[VERSION] => 204.0
[BUILD] => 22386173
[FIRSTNAME] => Foo
[LASTNAME] => Bar
[TRANSACTIONID] => 55553
[TRANSACTIONTYPE] => webaccept
[PAYMENTTYPE] => instant
[ORDERTIME] => 2016-08-01T20:49:28Z
[AMT] => 1.00
[TAXAMT] => 0.00
[CURRENCYCODE] => USD
[PAYMENTSTATUS] => Completed
[PENDINGREASON] => None
[REASONCODE] => None
[SHIPPINGMETHOD] => Default
[PROTECTIONELIGIBILITY] => Ineligible
[PROTECTIONELIGIBILITYTYPE] => None
[L_QTY0] => 0
[L_TAXAMT0] => 0.00
[L_SHIPPINGAMT0] => 0.00
[L_HANDLINGAMT0] => 0.00
[L_CURRENCYCODE0] => USD
[L_OPTIONSNAME0] => first_custom_field_label_here
[L_OPTIONSVALUE0] => first_custom_field_value_here
[L_OPTIONSNAME1] => second_custom_field_label_here
[L_OPTIONSVALUE1] => second_custom_field_value_here
[L_OPTIONS1NAME0] => second_custom_field_label_here_duplicate
[L_OPTIONS1VALUE0] => second_custom_field_value_here_duplicate
[L_TAXABLE0] => false
[L_TAXRATE0] => 0.0
[L_AMT0] => 1.00
[INSURANCEOPTIONSELECTED] => 0
[SHIPPINGOPTIONISDEFAULT] => 0
)
Warning:
This only applies if you're storing custom fields in a PayPal transaction.
PayPal's NVP API only returns up to 3 custom fields for a transaction, even though you can store up to 7 custom fields in a transaction. Even crazier, one of the custom fields it returns is a duplicate of the second custom field. At least that's the case when I try to retrieve a custom fields from a transaction.

PayPal DPRP is Disabled for This Merchant

I want to create recurring profile using Direct Payment Method.
I have enabled Business Pro account in sandbox accounts like as shown below.
And here are the API Credentials.
And below is my source code that I am using to create a Recurring Profile.
$data = array(
'USER' => urlencode('tahir.jumpstart-facilitator_api1.nxvt.com'),
'PWD' => urlencode('BHVM3E9XSLAJP9PX'),
'SIGNATURE' => urlencode('AAYoJuE-6E-mj5oERynM8zN4s4OrAvfUS7h9g45hGPQmxWb5RJxdJEBp'),
'VERSION' => '69.0',
'METHOD' => urlencode('CreateRecurringPaymentsProfile'),
'PROFILESTARTDATE' => gmdate("Y-m-d\TH:i:s\Z"),
'DESC' => urlencode('RacquetClubMembership'),
'BILLINGPERIOD' => 'Month',
'BILLINGFREQUENCY' => 1,
'AMT' => 10,
'MAXFAILEDPAYMENTS' => 3,
'ACCT' => '4032030239913727',
'CREDITCARDTYPE' => 'VISA',
'CVV2' => '123',
'FIRSTNAME' => 'James',
'LASTNAME' => 'Smith',
'STREET' => 'FirstStreet',
'CITY' => 'SanJose',
'STATE' => 'CA',
'ZIP' => '95131',
'COUNTRYCODE' => 'US',
'CURRENCYCODE' => 'USD',
'EXPDATE' => '072021'
);
$fields_string = http_build_query($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields_string);
$response = curl_exec($curl);
echo '<pre>';
print_r($response);
die;
$err = curl_error($curl);
curl_close($curl);
But when I run above code it shows me below error message.
TIMESTAMP=2016%2d06%2d09T13%3a52%3a39Z&CORRELATIONID=77466c4ec86e5&ACK=Failure&VERSION=69%2e0&BUILD=22204133&L_ERRORCODE0=11586&L_SHORTMESSAGE0=DPRP is disabled&L_LONGMESSAGE0=DPRP is disabled for this merchant&L_SEVERITYCODE0=Error
I have searched all over the internet and only thing that they suggest is to enable Business Pro account that is already enabled and you can clearly see this in above screenshot.
I am now lost, would really appreciate if someone can tell me if there is some issue with above code or I am missing something?
Many Thanks!
Please submit a PayPal MTS ticket to help you grant the DPRP access.

making Order in Paypal Parallel Express Checkout

I am trying to place Order with Parallel Paypal Express Checkout. Here is the API implementation.
I am using PAYMENTREQUEST_0_PAYMENTACTION => Order in SetExpressCheckout and in DoExpressChecoutPayment and it gives error (this is required).
When I use PAYMENTREQUEST_0_PAYMENTACTION => Order in SetExpressCheckout and PAYMENTREQUEST_0_PAYMENTACTION => Sale in DoExpressChecoutPayment it works.
All goes well until DoExpressChecoutPayment. Please check this
DoExpressCheckoutPayment Request
(
[TOKEN] => EC-4U931568VK402050F
[PAYERID] => BFSU67Z2LX5FJ
[VERSION] => 97.0
[METHOD] => DoExpressCheckoutPayment
[USER] => 'user'
[PWD] => 'pwd'
[SIGNATURE] => 'sig'
[PAYMENTREQUEST_0_PAYMENTACTION] => ORDER
[PAYMENTREQUEST_0_AMT] => 200.00
[PAYMENTREQUEST_0_CURRENCYCODE] => EUR
[PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID] => vendortwo2#yhaoo.com
[PAYMENTREQUEST_0_PAYMENTREQUESTID] => 25935
[PAYMENTREQUEST_1_PAYMENTACTION] => ORDER
[PAYMENTREQUEST_1_AMT] => 22.00
[PAYMENTREQUEST_1_CURRENCYCODE] => EUR
[PAYMENTREQUEST_1_SELLERPAYPALACCOUNTID] => vendorone#yahoo.com
[PAYMENTREQUEST_1_PAYMENTREQUESTID] => 25934
)
and response from this is:
(
[TOKEN] => EC-4U931568VK402050F
[SUCCESSPAGEREDIRECTREQUESTED] => false
[TIMESTAMP] => 2013-09-26T10:08:27Z
[CORRELATIONID] => 2381c85a926e3
[ACK] => Failure
[VERSION] => 97.0
[BUILD] => 7882219
[INSURANCEOPTIONSELECTED] => false
[SHIPPINGOPTIONISDEFAULT] => false
[PAYMENTINFO_0_PAYMENTSTATUS] => Failed
[PAYMENTINFO_0_SELLERPAYPALACCOUNTID] => vendortwo2#yhaoo.com
[PAYMENTINFO_0_SECUREMERCHANTACCOUNTID] => DRM9QQUAG9UNC
[PAYMENTINFO_0_PAYMENTREQUESTID] => 25935
[PAYMENTINFO_0_ERRORCODE] => 10001
[PAYMENTINFO_0_SHORTMESSAGE] => Internal Error
[PAYMENTINFO_0_LONGMESSAGE] => Internal Error
[PAYMENTINFO_0_SEVERITYCODE] => Error
[PAYMENTINFO_0_ACK] => Failure
[PAYMENTINFO_1_PAYMENTSTATUS] => Failed
[PAYMENTINFO_1_SELLERPAYPALACCOUNTID] => vendorone#yahoo.com
[PAYMENTINFO_1_SECUREMERCHANTACCOUNTID] => M7HT95CA3PUCE
[PAYMENTINFO_1_PAYMENTREQUESTID] => 25934
[PAYMENTINFO_1_ERRORCODE] => 10001
[PAYMENTINFO_1_SHORTMESSAGE] => Internal Error
[PAYMENTINFO_1_LONGMESSAGE] => Internal Error
[PAYMENTINFO_1_SEVERITYCODE] => Error
[PAYMENTINFO_1_ACK] => Failure
)
I have asked same question here.
Internal error came because wrong type of account ids are assigned to PAYMENTINFO_0_SELLERPAYPALACCOUNTID and PAYMENTINFO_1_SELLERPAYPALACCOUNTID in DoExpressCheckoutPayment request. Accounts assigned are personal, they should be paypal Business Accounts instead. that was the reason of "Internal Error". Thanks

Paypal API Recurring Payments Balance

Sure it's just something I'm missing. Fairly new to the Paypal API, especially the classic one! Basically, I'm using the following code to generate a subscription to my site at £2.50 per month. I can get the subscription to appear in the Recurring Payments Dashboard on Paypal Sandbox, but it doesn't change the balance and seems to be missing things to do with the initial payment. I tried INITAMT too, which filled in some fields, but still doesn't change the Sandbox balance of my account. Any ideas guys? Here's the code:
<?php
// Set PayPal API version and credentials.
$api_version = '85.0';
$api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
$api_username = 'MY_SANDBOX_USERNAME';
$api_password = 'MY_SANDBOX_PASSWORD';
$api_signature = 'MY_SANDBOX_SIGNATURE';
$startdate = gmdate('Y-m-d')."T00:00:00Z";
$request_params = array
(
'USER' => $api_username,
'PWD' => $api_password,
'SIGNATURE' => $api_signature,
'VERSION' => $api_version,
'METHOD' => 'CreateRecurringPaymentsProfile',
'PROFILESTARTDATE' => $startdate,
'DESC' => 'Membership',
'BILLINGPERIOD' => 'Month',
'BILLINGFREQUENCY' => '1',
'TOTALBILLINGCYCLES' => '0',
'AMT' => '2.50',
'MAXFAILEDPAYMENTS' => '12',
'ACCT' => '4641631486853053',
'CREDITCARDTYPE' => 'VISA',
'CVV2' => '123',
'FIRSTNAME' => 'James',
'LASTNAME' => 'Smith',
'STREET' => 'FirstStreet',
'CITY' => 'London',
'STATE' => 'G London',
'ZIP' => 'W2 1NE',
'COUNTRYCODE' => 'GB',
'CURRENCYCODE' => 'GBP',
'EXPDATE' => '052015'
);
// Loop through $request_params array to generate the NVP string.
$nvp_string = '';
foreach($request_params as $var=>$val)
{
$nvp_string .= '&'.$var.'='.urlencode($val);
}
// Send NVP string to PayPal and store response
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_URL, $api_endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);
$result = curl_exec($curl);
curl_close($curl);
$nvp_response_array = parse_str($result);
print_r($result);
?>
I took your code and used my own sandbox credentials. It seems to have worked just fine for me.
It came through as unclaimed since my account is USD, but you can see it did work just fine. Are you sure you're checking the correct sandbox account after you run it yourself?

Paypal : invalid token only in DoExpressCheckoutPayment method

I'm starting to work with PayPal and my first work is to debug it on our website.
Actually when we go to the end of an order, it works fine but we get a stack in the logs : "Invalid token (#10410: Invalid Token)".
This happens when the doExpressCheckoutPayment is called and it seems like there's no token and no payerid so an error is thrown. All other information seem to be correctly filled.
Here's the debug result calling doExpressCheckoutPayment :
[DoExpressCheckoutPayment] => Array
(
[TOKEN] =>
[PAYERID] =>
[PAYMENTACTION] => Sale
[AMT] => 4.16
[CURRENCYCODE] => EUR
[BUTTONSOURCE] => Varien_Cart_EC_FR
[NOTIFYURL] => *
[RETURNFMFDETAILS] => 1
[ITEMAMT] => 3.36
[TAXAMT] => 0.80
[SHIPPINGAMT] => 0.00
[L_NUMBER0] => *
[L_NAME0] => *
[L_QTY0] => 1
[L_AMT0] => 4.10
[L_NUMBER1] =>
[L_NAME1] => Discount
[L_QTY1] => 1
[L_AMT1] => -0.74
[BUSINESS] =>
[EMAIL] => *
[FIRSTNAME] => *
[LASTNAME] => *
[MIDDLENAME] =>
[SALUTATION] =>
[SUFFIX] =>
[COUNTRYCODE] => *
[STATE] => *
[CITY] => *
[STREET] => *
[ZIP] => *
[PHONENUM] => *
[SHIPTOCOUNTRYCODE] => *
[SHIPTOSTATE] => *
[SHIPTOCITY] => *
[SHIPTOSTREET] => *
[SHIPTOZIP] => *
[SHIPTOPHONENUM] => *
[SHIPTOSTREET2] =>
[STREET2] =>
[SHIPTONAME] => *
[ADDROVERRIDE] => 1
[METHOD] => DoExpressCheckoutPayment
[VERSION] => 72.0
[USER] => ****
[PWD] => ****
[SIGNATURE] => ****
)
[response] => Array
(
[TIMESTAMP] => 2013-03-07T15:01:45Z
[CORRELATIONID] => 64adbc2375f59
[ACK] => Failure
[VERSION] => 72.0
[BUILD] => 5331358
[L_ERRORCODE0] => 10410
[L_SHORTMESSAGE0] => Invalid token
[L_LONGMESSAGE0] => Invalid token.
[L_SEVERITYCODE0] => Error
)
Problem is that just after this method is called, setExpressCheckout is called and it's a success so the order is correctly placed.
Here's the success response when calling setExpressCheckout :
[response] => Array
(
[TOKEN] => EC-5UG654898R029060W
[TIMESTAMP] => 2013-03-07T15:01:48Z
[CORRELATIONID] => 348b58c6200c1
[ACK] => Success
[VERSION] => 72.0
[BUILD] => 5331358
)
I don't understand why when doing a doExpressCheckoutPayment, a failure is thrown and when doing setExpressCheckout, no error is detected and the sale is accepted anyway....
Is there a problem in the order of the method call ? I mean, should setExpressCheckout not be called before doExpressCheckoutPayment ?
We're facing an other problem with PayPal and I hope that solving this problem will solve the other one....
Thanks you very much for your help guys !
Seb
The SetExpressCheckout should happen first -- the token you get back is what you redirect the customer's browser with, and when they return they'll have the token in the URL and that is when you can getExpressCheckoutDetails if you need to see their shipping address and associated info, and finally you run doExpressCheckoutPayment to commit the transactions.
To reiterate: You get a valid token from the setEC, you use this token in the redirect, you get this token back appended to the RETURNURL the customer returns to, and you reference this token in any subsequent getEC and doEC calls.