CreateRecurringPaymentsProfile giving Error 11502: Invalid Token - paypal

I keep getting the Invalid Token Error when i call the CreateRecurringPaymentsProfile NVP API.
Please find the sequence of my API calls below:
SetExpressCheckout
METHOD = SetExpressCheckout
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
ReturnUrl = http://google.com
CANCELURL = http://google.com
PAYMENTREQUEST_0_PAYMENTACTION = Authorization
PAYMENTREQUEST_0_AMT = 100.00
PAYMENTREQUEST_0_CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID = rahul.katikineni#sap.com
LOCALECODE = US
L_BILLINGTYPE0 = RecurringPayments
L_BILLINGAGREEMENTDESCRIPTION0 = SameEveryTime
I get back a token with ACK=*Success* as response. I then navigate to the paypal website using the URL [https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=token] and login with a paypal account and click on "Agree and Continue".
After agreeing and successfully redirecting to the redirect URL, I make the GetExpressCheckoutDetails API call with the following parameters
METHOD = GetExpressCheckoutDetails
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>
After successfully getting the the payer details as response, i make the DoExpressCheckoutPayment API call
METHOD = DoExpressCheckoutPayment
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>
PAYERID = <payer ID from the GetExpressCheckoutDetails response>
PAYMENTREQUEST_0_AMT = 100
PAYMENTREQUEST_0_PAYMENTACTION = Sale
PAYMENTREQUEST_0_CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID = rahul.katikineni#sap.com
I now make the CreateRecurringPaymentsProfile API call
METHOD = CreateRecurringPaymentsProfile
VERSION = 98
PWD = <pwd>
USER = <user>
SIGNATURE = <signature>
TOKEN = <token from the SetExpressCheckout response>
PAYERID = <payer ID from the GetExpressCheckoutDetails response>
DESC = SameEveryTime
BILLINGPERIOD = Month
BILLINGFREQUENCY = 1
PROFILESTARTDATE = 2013-05-16T00:00:00Z
MAXFAILEDPAYMENTS = 1
AMT = 100.00
CURRENCYCODE = USD
L_PAYMENTREQUEST_0_NAME0 = Item1
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_AMT0 = 100.00
AUTOBILLAMT = AddToNextBilling
I keep getting the following response
TIMESTAMP = 2013-04-17T05:31:24Z
CORRELATIONID = d2c1d30c1d31
ACK = Failure
VERSION = 98
BUILD = 5650305
L_ERRORCODE0 = 11502
L_SHORTMESSAGE0 = Invalid Token
L_LONGMESSAGE0 = The token is invalid
L_SEVERITYCODE0 = Error
I have tried looking for a solution in many forums but could not figure out if i have missed any parameters.
Can anyone help me on this?
Thanks in advance,
Rahul

This error returned by Paypal is vague. Most common reason for this error is discrepancy between BillingDescription value in SetExpressCheckout call and ScheduleDEtails.Description in CreateRecurringprofile call. Make sure these two are exactly the same for this to work.
Eg:
public CreateRecurringPaymentsProfileResponseType createRecurringProfile(string tokenin){
var scheduleDetails = new ScheduleDetailsType();
scheduleDetails.PaymentPeriod = paymentPeriod;
scheduleDetails.Description = "RecurringBilling";
}
public SetExpressCheckoutResponseType setExpressCheckout()
{
....
var billingAgreement = new BillingAgreementDetailsType();
billingAgreement.BillingAgreementDescription = "RecurringBilling";
billingAgreement.BillingType = BillingCodeType.RECURRINGPAYMENTS;
billingAgreement.PaymentType = MerchantPullPaymentCodeType.ANY;
ecDetails.BillingAgreementDetails.Add(billingAgreement);
...
}

Related

How to Yahoo ads conversion tracker name through yahoo api

I want to change Yahoo ads conversion tracker name through API automatically.
But, when I run the following code, that returned an error.
access_token = XXXXXXXXXXXXX
account_id = XXXXXX
conversion_id = XXXXXXX
new_name = "new_name"
header = {"Content-Type": "application/json",\
"Accept": "application/json",\
"Authorization": "Bearer " + access_token}
url = "https://ads-search.yahooapis.jp/api/v8/ConversionTrackerService/set"
data = {'accountId':account_id, 'operand':[{'accountId': account_id, 'conversionTrackerId': conversion_id, "conversionTrackerName": new_name}]}
data = json.dumps(data).encode()
req = urllib.request.Request(url, data=data, method='POST', headers=header)
try:
with urllib.request.urlopen(req) as response:
body = json.loads(response.read())
headers = response.getheaders()
status = response.getcode()
print(headers)
print(status)
print(body)
except urllib.error.URLError as e:
print(e.reason)`
Retuened error is:
{'errors': [{'code': 'L0001', 'message': 'Lower list size.', 'details': [{'requestKey': 'operand', 'requestValue': None}]}], 'rid': '6fab0e1ac60dd2a871831484791976bf', 'rval': None}
I guess the length of "operand" field is 1 and it is right length according to yahoo api document. What I shuold do to fix this error?
I tryied to make length of "operand" field 2. But the result was same.

Not receiving ipn response from PayPal

Im having problems with PayPal and IPN on my website and have tried loads of things with no joy.
What i am attempting to do:
Receive notification of payment from PayPal and then update database with details from variables.
Whats working:
Using the IPN simulator from PayPal sandbox to simulate a transaction and sending the information to my listener WORKS and database gets updated.
purchasing items through the website works on sandbox and with out sandbox.
what does not work:
after purchase on website, listener does not receive information back from PayPal either using sandbox or normal and there for database does not get updated.
What i am using:
I am using simpleCartjs for my cart
Listener file is:
$p = new paypal_class;
if ($p->validate_ipn() && !empty($p->ipn_data['payment_status']) && $p->ipn_data['payment_status'] == 'Completed') {
$mc_gross = $_POST['mc_gross'];
$payer_id = $_POST['payer_id'];
$payment_date = $_POST['payment_date'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$payer_email = $_POST['payer_email'];
$payment_status = $_POST['payment_status'];
$payer_status = $_POST['payer_status'];
$address_name = $_POST['address_name'];
$address_country = $_POST['address_country'];
$address_zip = $_POST['address_zip'];
$address_state = $_POST['address_state'];
$address_city = $_POST['address_city'];
$address_street = $_POST['address_street'];
$mc_shipping = $_POST['mc_shipping'];
$mc_currency = $_POST['mc_currency'];
$ipn_track_id = $_POST['ipn_track_id'];
$stmt = $con->prepare("INSERT into orders (mc_gross, payer_id, payment_date, first_name, last_name, payer_email, payment_status, payer_status, address_name, address_country, address_zip, address_state, address_city, address_street, mc_shipping, mc_currency, ipn_track_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bind_param("sssssssssssssssss", $mc_gross, $payer_id, $payment_date, $first_name, $last_name, $payer_email, $payment_status, $payer_status,
$address_name, $address_country, $address_zip, $address_state,
$address_city,
$address_street, $mc_shipping, $mc_currency, $ipn_track_id);
$stmt->execute();
$stmt->close();
}
Does anyone know what could be the issue please? cant seem to get this working no matter what i try. I have IPN enabled in my business paypal account.
Thank you

PayPal Sandbox new certificate giving Timeout processing request error

PayPal Sandbox upgraded to provide more secured API certificate with SHA-256, 2048 bit. This was verified using the openssl command provided in
https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1915&viewlocale=en_US
Now when I tested using the existing old (SHA-1, 1024 bit) API certificate on sandbox, it worked properly.
But when a new API certificate (SHA-256, 2048 bit) was created and used for testing on sandbox then it started giving error response from sandbox,
ACK=Failure
L_ERRORCODE0=10001
L_SHORTMESSAGE0=Internal Error
L_LONGMESSAGE0=Timeout processing request
Please anyone can point out what might be the cause of this error?
For reference PayPal request (modified) sent to sandbox endpoint,
METHOD = SetExpressCheckout
RETURNURL = https://local/ReturnPage
CANCELURL = https://local/ProcessCancel
ALLOWNOTE = 0
LOGOIMG = https://local/img/logo.png
ADDROVERRIDE = 1
EMAIL = xxx#xxx.com
SOLUTIONTYPE = Mark
BUTTONSOURCE = BtnSrc
BRANDNAME = My Brand
PAYMENTREQUEST_0_SHIPTONAME = Mr Joshi
PAYMENTREQUEST_0_SHIPTOSTREET = 300 Oxford Street
PAYMENTREQUEST_0_SHIPTOCITY = London
PAYMENTREQUEST_0_SHIPTOZIP = TE45 6ST
PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE = GB
PAYMENTREQUEST_0_SHIPTOPHONENUM = 09824112345
NOSHIPPING = 1
PAYMENTREQUEST_0_PAYMENTACTION = Sale
PAYMENTREQUEST_0_CURRENCYCODE = GBP
L_PAYMENTREQUEST_0_NAME0 = 101-Jeans
L_PAYMENTREQUEST_0_DESC0 = Jeans
L_PAYMENTREQUEST_0_AMT0 = 59.0
L_PAYMENTREQUEST_0_QTY0 = 1
L_PAYMENTREQUEST_0_NAME1 = Other payments
L_PAYMENTREQUEST_0_DESC1 = Other payments
L_PAYMENTREQUEST_0_AMT1 = -8.02
L_PAYMENTREQUEST_0_QTY1 = 1
PAYMENTREQUEST_0_ITEMAMT = 50.98
PAYMENTREQUEST_0_AMT = 53.97
PAYMENTREQUEST_0_SHIPPINGAMT = 2.99
MAXAMT = 53.97
VERSION = 112.0
I have double verified the API username and API passowrd. As well as the API certificate. Even re-created the API certificate from cert_key_pem.txt obtained by downloading it from sandbox account.

401 when adding customer with QB Online API v3

I keep getting a 401 when I try to add a customer with QB Online API v3. The xml works in the API Explorer, and I'm able to query customers from my program. I just can't POST. What am I doing wrong?
string reqBody = "<Customer xmlns=\"http://schema.intuit.com/finance/v3\" domain=\"QBO\" sparse=\"false\"><DisplayName>Empire Records</DisplayName>"
+ "<BillAddr><Line1>201 S King St</Line1><City>Seattle</City><CountrySubDivisionCode>WA</CountrySubDivisionCode><PostalCode>98104</PostalCode></BillAddr>"
+ "<PrimaryPhone><FreeFormNumber>425-867-5309</FreeFormNumber></PrimaryPhone><PrimaryEmailAddr><Address>helpme#thefly.con</Address></PrimaryEmailAddr></Customer>";
IConsumerRequest req = session.Request();
req = req.Post().WithRawContentType("application/xml").WithRawContent(System.Text.Encoding.ASCII.GetBytes(reqBody));
req.AcceptsType = "application/xml";
string response = req.Post().ForUrl("https://quickbooks.api.intuit.com/v3/company/" + realmID + "/customer").ToString()
OAuthConsumerContext consumerContext1 = new OAuthConsumerContext
{
ConsumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(),
SignatureMethod = SignatureMethod.HmacSha1,
ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"].ToString()
};
OAuthSession oSession1 = new OAuthSession(consumerContext1, "https://oauth.intuit.com/oauth/v1/get_request_token",
"https://workplace.intuit.com/Connect/Begin",
"https://oauth.intuit.com/oauth/v1/get_access_token");
oSession1.ConsumerContext.UseHeaderForOAuthParameters = true;

Working with authorized .net payment gateway in ios

i am working with authorized .net payement gateway in ios
In the following method
(void) createTransaction {
AuthNet *an = [AuthNet getInstance];
[an setDelegate:self];
CreditCardType *creditCardType = [CreditCardType creditCardType];
creditCardType.cardNumber = #"4111111111111111";
NSLog(#"babul cardNumber is %#",creditCardType.cardNumber);
creditCardType.cardCode = #"100";
NSLog(#"babul cardCode is %#",creditCardType.cardCode);
creditCardType.expirationDate = #"1212";
NSLog(#"babul expirationDate is %#",creditCardType.expirationDate);
PaymentType *paymentType = [PaymentType paymentType];
paymentType.creditCard = creditCardType;
ExtendedAmountType *extendedAmountTypeTax = [ExtendedAmountType extendedAmountType];
extendedAmountTypeTax.amount = #"0";
extendedAmountTypeTax.name = #"Tax";
ExtendedAmountType *extendedAmountTypeShipping = [ExtendedAmountType extendedAmountType];
extendedAmountTypeShipping.amount = #"0";
extendedAmountTypeShipping.name = #"Shipping";
LineItemType *lineItem = [LineItemType lineItem];
lineItem.itemName = #"Soda";
lineItem.itemDescription = #"Soda";
lineItem.itemQuantity = #"1";
lineItem.itemPrice = #"1.00";
lineItem.itemID = #"1";
TransactionRequestType *requestType = [TransactionRequestType transactionRequest];
requestType.lineItems = [NSArray arrayWithObject:lineItem];
requestType.amount = #"1.00";
requestType.payment = paymentType;
requestType.tax = extendedAmountTypeTax;
requestType.shipping = extendedAmountTypeShipping;
CreateTransactionRequest *request = [CreateTransactionRequest createTransactionRequest];
request.transactionRequest = requestType;
request.transactionType = AUTH_ONLY;
request.anetApiRequest.merchantAuthentication.mobileDeviceId =
[[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]
stringByReplacingOccurrencesOfString:#"-" withString:#"_"];
request.anetApiRequest.merchantAuthentication.sessionToken = sessionToken;
[an purchaseWithRequest:request];
}
i am getting the response as
Create Transaction response
2012-07-26 19:14:00.131 Authorized[2355:207] ErrorE00003The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'mobileDeviceId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'name, transactionKey, sessionToken, password' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
namespace warning : xmlns: URI AnetApi/xml/v1/schema/AnetApiSchema.xsd is not absolute
ttp://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"
^
2012-07-26 19:14:00.131 Authorized[2355:207] Error = (null)
2012-07-26 19:14:00.247 Authorized[2355:207] babul output is Message.code = E00003
Message.text = The element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'mobileDeviceId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'name, transactionKey, sessionToken, password' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
Is there any alternative to the above problem and how the transactions are going to be stored in authorized .net
(i created my test account, i am giving those credentials, i approved my device but later i am getting the above error)
Thanks in advance
I think you need to go for in app purchase because Apple will not approve application payment through any web service or API.