2
votes

I'm trying to integrate the paypal rest api to my web application. After digging through all available sources I'm stuck.

I'm using the paypal rest api example from here: GitHub-PayPal-DotNet-Sample

I updated the nuget to the latest sdk version and replaced the cliendId and secret with my own live keys.

Now my problem is, always I choose "credit_card" I get an 401 error response:

{ "name": "UNAUTHORIZED_PAYMENT", "message": "Unauthorized payment", "information_link": "https://developer.paypal.com/webapps/developer/docs/api/#UNAUTHORIZED_PAYMENT", "debug_id": "1d25a990be5db" }

I set the currency to "CHF" (application runs in Switzerland) and the amount to "0.05" for testing purposes. I also retrieve a valid access token!

Tried various credit cards some belongs to my merchant account some not, still the same error.

With the option "paypal" it seems to work, but I want to offer credit cards directly within the application.

Is something not available in Switzerland? Any suggestions for this problem? Did I overlook something?

Thanks in advance!

Sample Code:

        Payment pay = null;

        Amount amount = new Amount();
        amount.currency = "CHF";
        amount.total = "0.05";

        Transaction transaction = new Transaction();
        transaction.amount = amount;
        transaction.description = orderDescription;

        List<Transaction> transactions = new List<Transaction>();
        transactions.Add(transaction);

        FundingInstrument fundingInstrument = new FundingInstrument();
        CreditCardToken creditCardToken = new CreditCardToken();
        creditCardToken.credit_card_id = GetSignedInUserCreditCardID(email);
        fundingInstrument.credit_card_token = creditCardToken;

        List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
        fundingInstrumentList.Add(fundingInstrument);

        Payer payer = new Payer();
        payer.funding_instruments = fundingInstrumentList;
        payer.payment_method = paymntMethod.ToString(); //credit_card

        Payment pyment = new Payment();
        pyment.intent = "sale";
        pyment.payer = payer;
        pyment.transactions = transactions;

        pay = pyment.Create(AccessToken);

        return pay;
1

1 Answers

0
votes

Per this Direct card payment is only supported in the US, UK (look at the page for further requirements for UK).