paypal / PayPal-NET-SDK

.NET SDK for PayPal's RESTful APIs
https://developer.paypal.com
Other
536 stars 462 forks source link

PayPal.HttpException: The remote server returned an error: (404) Not Found. #442

Open vanessa1290 opened 4 years ago

vanessa1290 commented 4 years ago

Goodmornig, I have some problems with the integration of SDK paypal, I have the IPN that works nice, now I was trying to do the first request, instead of the form client side, the call server side, to be more safe. I have put in my bin folder Paypal.dll and Newtonsoft.Json.dll then I have configurated the web.config

This is what I have read when I downloaded the Paypal nuget from Visual. ATTENTION: This package replaces the RestApiSDK package (https://www.nuget.org/packages/restapisdk). You do not need to include the RestApiSdk package in your project if you are using this, the PayPal .NET SDK, package.

The PayPal REST API uses HTTP verbs and a RESTful endpoint structure. OAuth2.0 is used as the API Authorization framework. Request and response payloads are formatted as JSON.

I usually dont use editor, I have downloaded Visual just to get out these dll. Then I have copied them inside my Web ASP.NET application.

And then I have translated the c#.net script sample to vb.net, this is the code

<%@ Page Language="VB" Debug="true" aspcompat=true%> <%@ Import Namespace="MySql.Data.MySqlClient" %> <%@ Import Namespace="PayPal.Api" %>

<% ' Initialize an APIContext object with a fresh access token. ' The config will be populated with values set in the Web.config file. Dim config = ConfigManager.Instance.GetProperties() Dim accessToken = New OAuthTokenCredential(config).GetAccessToken() Dim apiContext = New APIContext(accessToken) Dim abc = Payment.Get(apiContext, "6N135681R73257100") %> I have put the ID of the transaction and I have this kind of error

PayPal.HttpException: The remote server returned an error: (404) Not Found.

If I try to do a payment so to do like this

<%@ Page Language="VB" Debug="true" aspcompat=true%> <%@ Import Namespace="MySql.Data.MySqlClient" %> <%@ Import Namespace="PayPal.Api" %>

<% ' Initialize an APIContext object with a fresh access token. ' The config will be populated with values set in the Web.config file. Dim config = ConfigManager.Instance.GetProperties() Dim accessToken = New OAuthTokenCredential(config).GetAccessToken() Dim apiContext = New APIContext(accessToken)

    ' Initialize Payout object
    Dim payout = New Payout() With { _
    .sender_batch_header = New PayoutSenderBatchHeader() With { _
        .sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8), _
        .email_subject = "You have a payment" _
    }, _
    .items = New List(Of PayoutItem)({ _
        New PayoutItem() With { _
            .recipient_type = PayoutRecipientType.EMAIL, _
            .amount = New Currency() With { _
            .value = "0.99", _
            .currency = "USD" _
        }, _
        .receiver = "shirt-supplier-one@mail.com", _
        .note = "Thank you.", _
        .sender_item_id = "item_1" _
        }, _
        New PayoutItem() With { _
            .recipient_type = PayoutRecipientType.EMAIL, _
            .amount = New Currency() With { _
            .value = "0.90", _
            .currency = "USD" _
        }, _
            .receiver = "shirt-supplier-two@mail.com", _
            .note = "Thank you.", _
            .sender_item_id = "item_2" _
        }, _
        New PayoutItem() With { _
            .recipient_type = PayoutRecipientType.EMAIL, _
            .amount = New Currency() With { _
            .value = "2.00", _
            .currency = "USD" _
        }, _
            .receiver = "shirt-supplier-three@mail.com", _
            .note = "Thank you.", _
            .sender_item_id = "item_3" _
        } _
    }) _
    }

    ' Create the payout
    Dim createdPayout = payout.Create(apiContext, False)

%> I have this kind of error, Did I forgot to copy inside my project anything? How could I fix it? Thank you very much

PayPal.HttpException: The remote server returned an error: (403) Forbidden.