Payee account is invalid issue

Tarlok
Contributor
Contributor

Hi, 

 

 

I am using PayPal REST API 1.9.1 in my dotnet core project. I have created sandbox account and when I am trying to make any payment getting "Payee account is invalid." error.

Api endpoint is "/v1/payments/payment" and payment method is "credit_card". Below is code snippet:

string accessToken = new PayPal.Api.OAuthTokenCredential(config).GetAccessToken();
var apiContext = new PayPal.Api.APIContext(accessToken);
// A transaction defines the contract of a payment.
var transaction = new PayPal.Api.Transaction()
{
amount = new PayPal.Api.Amount()
{
currency = "USD",
total = totalAmount,
details = new PayPal.Api.Details()
{
shipping = shipping,
subtotal = subTotal,
tax = tax
}
},
description = description,
item_list = new PayPal.Api.ItemList()
{
items = new List<PayPal.Api.Item>()
{
new PayPal.Api.Item()
{
name = itemName,
currency = "USD",
price = "1",
quantity = "5",
sku = "sku"
}
},
shipping_address = new PayPal.Api.ShippingAddress
{
city = "Johnstown",
country_code = "US",
line1 = "52 N Main ST",
postal_code = "43210",
state = "OH",
recipient_name = "Basher Buyer"
}
},
invoice_number = invoice_number
};
// A resource representing a Payer that funds a payment.
var payer = new PayPal.Api.Payer()
{
payment_method = "credit_card",
funding_instruments = new List<PayPal.Api.FundingInstrument>()
{
new PayPal.Api.FundingInstrument()
{
credit_card = new PayPal.Api.CreditCard()
{
billing_address = new PayPal.Api.Address()
{
city = "Johnstown",
country_code = "US",
line1 = "52 N Main ST",
postal_code = "43210",
state = "OH"
},
cvv2 = card.CVV,
expire_month = Convert.ToInt32(card.ExpirationMonth),
expire_year = Convert.ToInt32(card.ExpirationYear),
first_name = firstName,
last_name =lastName,
number = card.CardNumber,
type = card.CardType
}
}
},
payer_info = new PayPal.Api.PayerInfo
{
email = "payermail"
},
};
// A Payment resource; create one using the above types and intent as `sale`, 'order', 'none' or `authorize`
var payment = new PayPal.Api.Payment()
{
intent = "sale",
payer = payer,
transactions = new List<PayPal.Api.Transaction>() { transaction }
};
// Create a payment using a valid APIContext
var createdPayment = payment.Create(apiContext);

 

Same code is working fine with payment method "paypal" by making minor changes in request.

Please let me know how to make it working for card payments. It is urgent.

 

Thanks

Login to Me Too
2 REPLIES 2

Kavyar
Moderator
Moderator

Good day @Tarlok 

 

Thank you for posting to the PayPal community.

 

I would suggest to please contact our PayPal Customer service via link -  https://www.paypal.com/smarthelp/contact-us (then choose at the bottom one of the contact methods - email or phone) who should be able to help you regarding the request.

 

They will be able to assist you further as they are specially trained to address this type of account inquiry.

 

Sincerely,

Kavya

PayPal MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

Tarlok
Contributor
Contributor

@Kavyar The issue is resolved. SDK was using v1 version of Api. I am able to fix issue using v2 version with direct https call.

 

Thanks

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.