Null reference exception in PayPal DoDirectPayment - paypal

In the DoDirectPayment method of PayPal, I am facing null reference exception. Trying to fix this issue, additional properties were set to the object being passed to the method as per the updated API.
Dummy credit card is being used to make the payment. As per PayPal documentation, the DoDirectPayment method is available only to Website Payments Pro subscription.
On learning this, I tried using a pro subscription of sandbox account but the same exception arises. The main thing about the issue is that the same code is working in a live version of the site but not in the development server.
The exception is as below
An exception of type 'System.NullReferenceException' occurred in
PayPalCoreSDK.dll but was not handled in user code
Object reference not set to an instance of an object.
The stack trace is as below.
at PayPal.APIService.MakeRequestUsing(IAPICallPreHandler apiCallHandler)
at PayPal.BasePayPalService.Call(IAPICallPreHandler apiCallHandler)
at
PayPal.PayPalAPIInterfaceService.PayPalAPIInterfaceServiceService
.DoDirectPayment(DoDirectPaymentReq doDirectPaymentReq, String apiUserName)
at
PayPal.PayPalAPIInterfaceService.PayPalAPIInterfaceServiceService
.DoDirectPayment(DoDirectPaymentReq doDirectPaymentReq)
The PayPalCoreSDK version being used is 1.3.0.0.

Related

error while posting payment record to QBO via the IPP API - BILL_PAYMENT_REQUEST_BAD

while posting payments to QBO via the IPP SDK API, we notice that some of the payment records we are posting are failing with the following message,
errorCode: BILL_PAYMENT_REQUEST_BAD
reason: BILL_PAYMENT_INVALID_VENDOR_ID
we looked up this error code in the intuit error code list, but do not find it. Also as per the error, it seems the vendor to which we are posting the payments are not present in QBO, but on further research we found that the vendors are indeed present in QBO.
Has anyone encountered this error or has any clues as to what this error means.
Is the Vendor Id in BillPayment same as that of the Bill?If not, you will get an error. I believe that might be the issue with your request.

Paypal "SetExpressCheckout" API method has stopped working with sandbox seller account

My application uses the SetExpressCheckout paypal classic API method. It is working fine when I use real accounts in a live environment.
It used to work fine using test accounts, but some weeks ago it has stopped working right. At some point, my application calls the "SetExpressCheckout" API method using curl in PHP. When I use the test seller account that I've always used for my tests, I always get the following error:
SetExpressCheckout API call failed.
Detailed Error Message: Security header is not valid
Short Error Message: Security error
Error Code: 10002
Error Severity Code: Error
I know that paypal has recently restructured its "developer network", and the issue seems to be caused by this but I have no proof of that. The API I used is now called the "classic" API.
I've read the documentation, and it says that I now have to create a new "real" paypal account, and then use it to log to https://developer.paypal.com. I did that.
Once logged to the developer website, there is a feature allowing us to import all the test buyer and seller accounts used in an old sandbox account. I did that, and my old test accounts appeared in a list.
One of them is the test seller account I used to test. When I check the details of this account, the username, password and signature used to authenticate to the paypal API are there. If I use them, it still returns the previous error.
There is also a feature allowing me to create test accounts. I've created a new seller, and still, I get the same error message.
When I search on google about this issue, most answers says that the username, password or signature are wrong or have hidden white spaces in them. That's not my case.
I don't know how to solve that problem. I am wondering if the API endpoint has changed. I currently use "https://api-3t.paypal.com/nvp" for tests. I am using the NVP API, version 64.
To make it short:
1) My test account used to work
2) The code has not been modified
3) Real accounts used to work and still work.
4) But test buyer account has stopped working
5) The issue chronologically coincide with paypal "developer network" restructuring.
6) I don't know what has changed exactly and might cause this.
7) Does anyone know what has changed and might has caused this (a new parameter in the query string? Endpoint URL changed?)?
8) According to my previous description, do I seem to have misunderstood something, and what?
I currently use "https://api-3t.paypal.com/nvp" for tests.
That's your problem. You're using test credentials, but the live API endpoint.
Change your endpoint to https://api-3t.sandbox.paypal.com/nvp and all should be fine.
Security header is not valid means that your credentials are incorrect. I've never once seen that error where this wasn't the case.
You need to make sure that if you're using sandbox credentials for testing that you're hitting the correct endpoint and using the correct credentials.
Lots of times people accidentally have sandbox credentials set but then send them to the live endpoint or visa versa. If you're hitting the correct endpoint and your credentials are indeed correct you won't get this error.

PayPal certificate invalid or not found

For the last couple of days, I have been working on realising a payment integration using the PayPal SDK for PHP (which uses the REST API). However, I have been experiencing some issues.
When a payer is redirected to the PayPal site for approving his payment and redirected back to the return URL, PayPal returns a HTTP 400 status code upon executing the approved payment. The code for executing the payment is as follows. Note that $paymentId is the ID returned after creating the payment and $payerId is the PayerID sent along with the approval.
$payment = Payment::get($paymentId);
$paymentExecution = new PaymentExecution();
$paymentExecution->setPayer_id($payerId);
$payment->execute($paymentExecution);
It says the payment is invalid:
{"name":"PAYMENT_STATE_INVALID","message":"This request is invalid due to the current state of the payment","information_link":"https://developer.paypal.com/docs/api/#PAYMENT_STATE_INVALID","debug_id":"223647e6e42fb"}
While figuring out where all goes wrong (note that the samples included with the API also give the same error), I stumbled across the following line in my log files:
PPHttpConnection: Invalid or no certificate authority found - Retrying using bundled CA certs file
I checked to make sure that the SDK locates the certificate included with the SDK. So my guess is that it's an invalid certificate. I'm kind of lost now about what to do. Does anybody have an idea how to fix this issue?
You should always check your payments state before running an execute. The error indicates that the payment already was executed
Payment state. Must be set to one of the one of the following:
created; approved; failed; canceled; expired; pending. Value assigned
by PayPal.
You probably ran the method Create on your payment, and the Create method executes the same submethods as Execute.

PayPal Pro NVP API Error Localization

I am creating an english and french website that will be using paypal for payment processing.
I have all of the PayPal API working properly, and currently I am just outputting any error messages to the user (L_LONGMESSAGEX). However this is always english, is there a way to output the error messages as french?
I saw a LOCALECODE parameter but that seems to be something else.
Or am I going to have to setup my own lookup table based off the error codes?
No. This is not possible.
The PayPal API error messages are intended for your use only; you're supposed to properly handle these exceptions within your own application, and output a more meaningful message to the buyer.
(For example; "L_LONGMESSAGE0=This transaction has already been approved" means nothing to your buyers. Yet "This transaction has been processed previously. Did you order twice? Give our support team a call if you have any questions regarding your order!" is a lot clearer.)

Pass Custom Variable to PayPal server via IPN Message and Response

I had successfully integrated Paypal with my iPhone application, but I got stuck over passing the Custom variable via SOAP to Pay pal using IPN Message.
Has anyone pass the Custom Variable to Pay-pal Server????I am making an application for a restaurant,user can make payment using Pay-pal server.
I need to pass the Custom variable (i.e Bucket Id) to Paypal. I get this Bucket Id via web service which I call before making request to pay pal server. Now I need to pass this Bucket Id as Custom Variable to Paypal Server so that it returns the Message Notification.
Note: - I need to make payment using this Bucket Id.
At last when I will get this Notification , I will again call web-service which is going to update the server database of client.
I used this reference:
https://cms.paypal.com/cms_content/US/en_US/files/developer/IPNGuide.pdf
Any kind of help is welcomed.....
Please suggest me with some sample code as I had googled alot about this or other reference....
I find out the solution. But for Android, but I think it can be applied to iOS:
PayPalPayment payment = new PayPalPayment();
payment.setCurrencyType("USD");
payment.setSubtotal(3.30);
payment.setRecipient("test_seller11#gmail.com");
payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
payment.setCustomID("7982");
payment.setIpnUrl("some.site.com/PaymentCallback");
payment.setDescription("Buy 300 coins");
So this is the solution, to pass your extra params to IPN, and to get them back in callback on your server:
payment.setCustomID("7982");