GithubHelp home page GithubHelp logo

paypal / paypal-net-sdk Goto Github PK

View Code? Open in Web Editor NEW
533.0 115.0 460.0 24.23 MB

.NET SDK for PayPal's RESTful APIs

Home Page: https://developer.paypal.com

License: Other

C# 99.47% PowerShell 0.42% Batchfile 0.11%

paypal-net-sdk's Introduction

PayPal .NET SDK

Home Image

Build Status NuGet

The PayPal .NET SDK makes it easy to add PayPal support to your .NET web application and is built on PayPal's REST APIs.

TLSv1.2 Update

The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, PayPal is updating its services to require TLS 1.2 for all HTTPS connections. At this time, PayPal will also require HTTP/1.1 for all connections. Click here for more information

Connections to the sandbox environment use only TLS 1.2.

Prerequisites

  • .NET 4.0 or later

Documentation

General documentation regarding the PayPal REST API and related payment flows can be found on the PayPal Developer site.

License

Bitdeli Badge

paypal-net-sdk's People

Contributors

andregrohmann avatar avidas avatar avijit6399 avatar aydiv avatar bluk avatar braebot avatar braintreeps avatar buntyjoshi avatar chris03 avatar jaypatel512 avatar jziaja avatar kumaravel-jayakumar avatar lathavairamani avatar lvairamani avatar maherjendoubi avatar migajek avatar mmikirtumov avatar neilrees avatar randstraw avatar samueldjack avatar sankarbhavanib avatar shawnzxx avatar siddick avatar sychevigor avatar theobourikos avatar valgen avatar wunpac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paypal-net-sdk's Issues

Method not found: 'System.String PayPal.Manager.ConfigManager.GetProperty(System.String)'

File: OAuthTokenCredential.cs
Method: private string GenerateOAuthToken(string base64ClientID)

In PaypalCoreSDK.dl, v1.1.1.0, ConfigManager is defined as:

public sealed class ConfigManager
{
public static ConfigManager Instance { get; }

    public Account GetAccount(int index);
    public Account GetAccount(string apiUserName);
    public string GetProperty(string key);
}

However, in PaypalCoreSDK.dl, v1.1.1.0, ConfigManager is defined as:

public sealed class ConfigManager
{
public static ConfigManager Instance { get; }

    public static Dictionary<string, string> getConfigWithDefaults(Dictionary<string, string> config);
    public static string getDefault(string configKey);
    public Dictionary<string, string> GetProperties();
}

You should change the code:

Line 138: if (ConfigManager.Instance.GetProperty("oauth.EndPoint")!=null)
Line 139: {
Line 140: baseUri = new Uri(ConfigManager.Instance.GetProperty("oauth.EndPoint"));
Line 141: }
Line 142: else
Line 143: {
Line 144: baseUri = new Uri(ConfigManager.Instance.GetProperty("endpoint"));
Line 145: }

to:

Dictionary<string, string> properties = ConfigManager.Instance.GetProperties();

if (properties["oauth.EndPoint"]!=null)
{
baseUri = new Uri(properties["oauth.EndPoint"]);
}
else
{
baseUri = new Uri(properties["endpoint"]);
}

Provide more user-friendly error messages in PaymentsErrorDetails

The PayPalException namespace and containing classes return details and message but even the field/message are very unuser friendly (namely PayPal.Exception.PaymentsErrorDetails).
i.e.
payer.funding_instruments[0].credit_card.number - Value is invalid
payer.funding_instruments[0].credit_card - Invalid expiration

Do we need to handle these errors ourselves to display to the user, or does the REST service return any other information? Save us having to go through https://developer.paypal.com/docs/api/#validation-issues and parse the exception messages. Currently in a production environment we're simply checking the type of exception, if exception is of type PaymentsError the user sees a message saying 'there was a problem with your card details'. Preferably in the instances above it needs to say

There was a problem with your card details:
Your credit card number was invalid
Your credit card expiration was invalid.

Is there existing functionality in the REST service/wrapper to get this kind of user friendly output or do we need to write our own error parser for user messages?

Custom Payment Form

How do I build a custom payment form without requiring my customers to enter their card details?

PaymentWithPayPal.aspx Missing Order Details

Howdy All,
Just like to say that I just started testing with your API SDK and so far it all looks great. I have already hit an issue thought, and I apologize if the mistake is on my part. However, when I use the PaymentWithPayPal.aspx test page, it shows the transaction information in the posting page, but not in the paypal landing page. So there are no purchase line-items or prices. Despite there being no visible costs, the transaction is able to be completed, and I can see the transaction (with the price) in my sandbox dashboard.

I've included a screenshot to help display my issue. Should I happen to resolve this issue before I hear back, I'll be sure to update this post. If the mistake is not mine, which I would assume it most likely is, I'll be sure to include the coding resolution.

Thanks for your efforts,
Alex

PaymentWithPayPal Missing Data

Can a Payment object include discount details for an item?

Hi SDK Team,

Since there is no option for me to set the Discount amount in the Payment object, I created an additional item with price = Discount * -1. Now when attempting to create Payment object, I 'm getting the following issue. I have made sure there are only 2 digits after the decimal point.

Currency amount must be non-negative number, may optionally contain exactly 2 decimal places separated by '.', optional thousands separator ',', limited to 7 digits before the decimal point

The negative discount amount has only two decimal places. The value is like "-2.00". Can you please address this issue or guide me if I 'm missing anything here?

My Items

Item 1

{
    "currency": "GBP",
    "name": "item abc",
    "price": "38.99",
    "quantity": "1",
    "sku": "item abc"
}

Item 2

{
    "currency": "GBP",
    "name": "Discount 10 %",
    "price": "-2.00",
    "quantity": "1",
    "sku": "Discount:10%"
}

Note: Total is matching subtotal + shipping. Tax is 0.

SDK: Sale.Refund()

Line 130 of Sale.cs
var resourcePath = "v1/payments/sale/{0}/refund";

saleId is missing/not set in resourcePath.

This results a POST to: https://api.sandbox.paypal.com/v1/payments/sale/%7B0%7D/refund

Sample (via Fiddler):

POST https://api.sandbox.paypal.com/v1/payments/sale/%7B0%7D/refund HTTP/1.1
Content-Type: application/json
User-Agent: PayPalSDK/PayPal-NET-SDK 1.2.0 (lang=DOTNET;v=4.5.1;clr=4.0.30319.34209;bit=64;os=Microsoft Windows NT 6.2.9200.0)
Authorization: Bearer [the token]
PayPal-Request-Id: d9f6d5ec-14e9-4553-bd8e-c2ac651cc8fc
Host: api.sandbox.paypal.com
Content-Length: 45
Expect: 100-continue
Connection: Keep-Alive

{"amount":{"currency":"USD","total":"25.87"}}

sandbox Payment.Get returns 404

When I call Payment.Get() in sandbox using a payment ID from a recent transaction (today) I get a 404 error. Using the payment ID from an older transaction works fine.

REST API and Azure

Hi,

There is an Exception calling OAuthTokenCredentials from a webpage on Azure

The type initializer for 'PayPal.UserAgentHeader' threw an exception. ---> System.TypeInitializationException: The type initializer for 'PayPal.UserAgentHeader' threw an exception. ---> System.MethodAccessException: Attempt by security transparent method 'PayPal.UserAgentHeader.get_OperatingSystemFriendlyName()' to access security critical method 'System.Management.ManagementObjectSearcher..ctor(System.String)' failed. Assembly 'PayPalCoreSDK, Version=1.4.1.0, Culture=neutral, PublicKeyToken=null' is partially trusted, which causes the CLR to make it entirely security transparent regardless of any transparency annotations in the assembly itself. In order to access security critical code, this assembly must be fully trusted. at PayPal.UserAgentHeader.get_OperatingSystemFriendlyName() at PayPal.UserAgentHeader.GetOSHeader() at PayPal.UserAgentHeader..cctor() --- End of inner exception stack trace --- at PayPal.UserAgentHeader..ctor(String productId, String productVersion) at PayPal.OAuthTokenCredential.GenerateOAuthToken(String base64ClientId) at PayPal.OAuthTokenCredential.GenerateAccessToken() at PayPal.OAuthTokenCredential.GetAccessToken()

An item with the same key has already been added.

This error occurs when you are calling:

public PayPal.Api.Payments.Capture Capture(APIContext apiContext, PayPal.Api.Payments.Capture capture);

The HTTP header is added to the apiContext but it already exists.

To fix:
Replace line below:

                apiContext.HTTPHeaders.Add("Content-Type", "application/json");

With the following lines:

            if (apiContext.HTTPHeaders["Content-Type"] == null) {
                apiContext.HTTPHeaders.Add("Content-Type", "application/json");
            }

PayPal-NET-SDK and GoDaddy ~ Not working together

Hi Team,

I have used PayPal-NET-SDK in my ASP.NET Web application and is working fine locally with both sandbox and live account. But when I upload my application to GoDaddy and start the payment process with PayPal, I get the following exception:

"System.Security.SecurityException: That assembly does not allow partially trusted callers.".

On googling, I found that the AssemblyInfo.cs file needs to include the following assembly as first reference:

[assembly: AllowPartiallyTrustedCallers]

and also set Trust level to "Full" in the web.config.

So, can you please include this as part of your assembly?

Likely bug in expiration check in OAuthTokenCredential.GetAccessToken

When checking the expiration of the access token in OAuthTokenCredential.GetAccessToken:
if ((this.accessToken != null) && (((DateTime.Now.Millisecond - this.timeInMilliseconds) / 0x3e8L) > (this.secondsToExpire - 120)))

DateTime.Now.Millisecond is used. This is used also in GenerateOAuthToken to update timeInMilliseconds. Problem here is that DateTime.Now.Millisecond only stores the milliseconds component of the time. 10:00:00.500 results in 500 for example. This seems to be wrong since the Millisecond value stores only 0 to 999 while secondsToExpire stores a much larger value (in seconds of course). I suppose instead of timeInMilliseconds the DateTime at the creation time should be stored and the comparison should more be like:
(DateTime.Now - this.lastCreationDate).TotalSeconds) > (this.secondsToExpire - 120)

SDK doesn't compile when target framework is selected as 4.0

Our application targets 4.0 network which is supported in Windows XP. XP is still used by a significant amount of business computers all around the world. Our setup application requires and installs 4.0 framework in case of its absence. Unfortunately PayPal SDK provided here doesn't compile and work correctly when its target framework is changed to 4.0. Is there a workaround on that problem?

noshipping flag

I can not find this option in api, can someone help me?

Thanks

Question: allow_note

While one can toggle the ability for a user to allow_note in a web_profile there doesn't seem to be a way to get this data (the note) back from any response in a "normal" payment flow (or "extra" call that I've tried so far - e.g.Payment.Get.). Is there a way to do so?

Unsure if this is the right forum for such, if not, just let me know, I'll remove it.

Shipping Address

Hi,
Thank you for the great api support.
I have a question about shipping address.
If user pay with paypal method and not with credit card,
how can I obtain his shipping address from paypal?
I didn't find this in api.
Thanks,
Miriam

Working with .NET 3.5 on web server... Can this work?

Hi,

I have been battling with PayPal trying to make a web request to get an access token for going on 9 hours straight, with no luck. I am using C# in a .NET 3.5 environment (that unfortunately, I have no control over to change or upgrade to 4.0).

Is there ANY way that this library can work with .NET 3.5? If I have to make adjustments, I will... but I don't want to waste a ton of time just to find out that there isn't a way of making it work.

Thanks so much! I appreciate any future response!

Jason

Throw timeout exception when exceeding connectionTimeout

When calling Payment.List(...) with a connectionTimeout of 3000 I get a NullReferenceException.
I took me quite a while to figure out that the exception was thrown because my connectionTimeout value was too low. It would be much better that when the timout is exceeded that some sort of timeout exception is thrown instead of this:

Exception in PayPal.HttpConnection.Execute(): Object reference not set to an instance of an object
   at PayPal.HttpConnection.Execute(String payLoad, HttpWebRequest httpRequest)
   at PayPal.PayPalResource.ConfigureAndExecute[T](Dictionary`2 config, IAPICallPreHandler apiCallPreHandler, HttpMethod httpMethod, String resourcePath)
   at PayPal.PayPalResource.ConfigureAndExecute[T](APIContext apiContext, HttpMethod httpMethod, String resource, String payload)
   at PayPal.Api.Payments.Payment.List(APIContext apiContext, Dictionary`2 containerDictionary)
   at PayPalTest.Program.Main(String[] args) in c:\Users\chris\Documents\Visual Studio 2013\Projects\PayPalTest\PayPalTest\Program.cs:line 27
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Missing .csproj

Downloaded the repository tried opening the samples using the .SLN and am unable to open it due to missing .csproj

Plan details missing from Agreement order summary page

Everything seems to work in the above example, up until the redirecturl is followed, when arriving at the PayPal site, none of the agreement financial details are displayed, just the following:

Your order summary
Description
Agreement for T-Shirt of the Month Club

Once the transaction has been completed, which seems to run smoothly, a bad request 400 error is returned. Any ideas?

Payment.Create() time out when passing a card token

Hi,

It may not be a bug but definitely needs improvement as I have been struggling on this for 20hours with no sleep and no clue of what's gone wrong.

have tried hundreds of time so believe it must be some issues there--- I tried sample code as well, returning same error (but seems to work using demo code without payer ID, is my developer account haunted?!):

  1. when using a saved credit card that does not have a payer ID, or
  2. when using a saved credit card that has a payer ID

When I use the same code on my project, it returns "time out" exception; when using the sample code, it throws "object not referenced" exception: Exception in PayPal.HttpConnection.Execute(): Object reference not set to an instance of an object.

Cheers.

Lida

ERROR PayPal.Exception.PayPalException [(null)] Exception in HttpConnection Execute: The request was aborted: The request was canceled.

I'm seeing this exception in the logs when trying to make a payment. Here is the full stack trace. Any tips/hints would be helpful. By the way, this is happening occasionally and not all the time.

2013-10-21 10:12:59,968 [2024] ERROR PayPal.Exception.PayPalException [(null)] Exception in HttpConnection Execute: The request was aborted: The request was canceled.
PayPal.Exception.PayPalException: Exception in HttpConnection Execute: The request was aborted: The request was canceled. ---> System.Net.WebException: The request was aborted: The request was canceled. ---> System.IO.IOException: Cannot close stream until all bytes are written.
at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
--- End of inner exception stack trace ---
at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)
at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState)
at System.Net.ConnectStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at PayPal.HttpConnection.Execute(String payLoad, HttpWebRequest httpRequest)
--- End of inner exception stack trace ---

In reviewing my own logs here is where the exception gets created:
Exception in HttpConnection Execute: The request was aborted: The request was canceled.
at PayPal.PayPalResource.ConfigureAndExecute[T](APIContext apiContext, HttpMethod httpMethod, String resource, Dictionary`2 headersMap, String payLoad)
at PayPal.PayPalResource.ConfigureAndExecute[T](APIContext apiContext, HttpMethod httpMethod, String resource, String payLoad)
at PayPal.Api.Payments.Payment.Create(APIContext apiContext) in C:\RestApiSDK\PayPal\Api\Payments\Payment.cs:line 128

Here is the line this exception is occurring at:
return PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.POST, resourcePath, payLoad);

HTTP 500: INTERNAL_SERVICE_ERROR on credit_card with item_list

Perhaps related to this closed issue?

This error is (so far for me) returned 100% of the time if I include item_list in the transaction. Removing theitem_list will complete successfully (so far 100% of the time).

Sounds simple enough (then don't include item_list), but the error is "cosmetic". The transaction in fact succeeds as shown:

creditcarditemdetail

I can even "Print a packing slip" - re: shipping_address is included in item_list

packslip

Thanks for any input and happy new year!

Missing Reference to RESTApiSDK

When I try to compile the sample application (RestApiSample.VS.2012) I get a bunch of errors, apparently because the reference to RestApiSDK is invalid. Is this supposed to be in the solution or do we need to add it from somewhere else?

RestApiSdk 0.7.3 NuGet package does not work with PayPalCoreSDK 1.41

When I upgraded the PayPalCoreSDK to 1.4.1 to avoid a log4net 1.2.10 strong name issue in my application, the RestApiSdk stopped working -- it looks like the PayPalCoreSDK added a HEAD to the HttpMethod enumeration but didn't specify the values, causing all of the values in the RestApiSdk (which is compiled against the old version) to shift by one. So it sends HEAD instead of POST on Create(), POST instead of DELETE on Delete(), etc.

Fixing this should be as simple as rebuilding the RestApiSdk against the current PayPalCoreSDK and releasing an updated NuGet package, but it looks like the RestApiSdk NuGet package hasn't changed in a while. Thanks!

Seamless checkout using REST API

Hi there :)

I am using the paypal REST API for a project and I need to use paypal seamless-checkout. The docs on the link below suggest that REST API support for seamless-checkout is coming soon. What is the time-frame expected?
https://developer.paypal.com/docs/integration/direct/identity/seamless-checkout/

My use case is as follows:
User authenticates to my website using Paypal login. User browse the cart. User makes a purchase using paypal without the need to login again to paypal. (I do not want the user to login again to paypal to complete the purchase) . My understanding is that seamless checkout is the way to go. Please correct me if I am wrong.

Thanks,
Moataz

PaymentWithPayPal Doesn't Work Live

If you take the "PaymentWithPayPal" page, it works in the sandbox, but when trying with Live credentials, throws the following error: "Exception in HttpConnection Execute: Stream was not readable."

Authorize Order

Hi there,

when I do this,

curl -v POST https://api.sandbox.paypal.com/v1/payments/orders/O-2X244976WE7548840/authorization \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access-Token>' \

It will return *404 Not Found *

and on the other hand, when I did the Execute Order:

this is what I got from the link:-

{
  "href": "https://api.sandbox.paypal.com/v1/payments/orders/O-2X244976WE7548840/authorize",
  "rel": "authorization",
  "method": "POST"
},

but if I post to this link, it will show FORMAT error.

Which is the correct link to do Order authorization?

how do i get the 'Unique Transaction ID' after executing a payment?

been googling this for hours and still can't get a concrete answer or any code that works...

how do i get the 'Unique Transaction ID' after executing a payment? the json that comes back seems to contain everything other than the transaction id?!

i get an 'id', a 'payer_id', a 'related_resources > sale > id' and a 'parent_payment' (which is odd as i'm not doing anything with parent payments?).

but no transaction id...

any ideas?!

cheers,

jake

Payment execution (Step 4) System.ArgumentNullException: Value cannot be null.

Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
sdkConfig.Add("mode", "sandbox");
string accessToken = "Bearer Op3BTXEkL-WIiND.DOS.A7akI4VasDTJhdlqc3pNij0";
APIContext apiContext = new APIContext(accessToken);
apiContext.Config = sdkConfig;

Payment payment = Payment.Get(apiContext, "PAY-3C789089WM9417436KLU4ARA");

PaymentExecution pymntExecution = new PaymentExecution();
pymntExecution.payer_id = ("9Y6KKCEM4EUT4");
Payment executedPayment = pymnt.Execute(apiContext,pymntExecution);

It got message error :
System.ArgumentNullException: Value cannot be null.
Parameter name: Id cannot be null

Where:
Payment executedPayment = pymnt.Execute(apiContext,pymntExecution);

Anyways : It can not call constructor:
Payment payment = new Payment("PAY-3AH256338L456474LKLU3TNI");
it doesn't contain a constructor that take 1 arguments.

Thanks for your help.

Not able to install with new version of SDK (1.5.0)

Your version has the sdk version of 4.1 expected, making 1. 5.0 of the base sdk not able to be installed (updated) via nuget. I was not sure if this was on purpose or not but wanted to let someone know.

Proposed improvement to paypal catch exception response in sample codes in github

I have been testing the REST API for VAULT and I was experiencing some coding issues while using payment API using the vault as the fundInstrument, when using the sample code on: https://github.com/paypal/rest-api-sdk-dotnet/blob/master/Samples/RestApiSample/PaymentWithSavedCard.aspx.cs.
All the response error codes I was getting was the standard 400,404 etc. as is expected from the sample code
I then changed the exception response within the sample code on my test site to the following:

           if (ex.InnerException is PayPal.Exception.ConnectionException)
           {
            Textbox1.Text = (((PayPal.Exception.ConnectionException)ex.InnerException).Response);
           }
           else
           {
             TextBox1.Text = (ex.Message);
           }

I found it on http://stackoverflow.com/questions/15581314/paypal-rest-api-net-sdk-400-bad-requests, I feel this is valuable for Vault responses it was to me as I fixed my issue in seconds. If you agree can we get the sample code to include it?

Before my change in the exception response:

    Exception in HttpConnection Execute: Invalid HTTP response
The remote server returned an error: (400) Bad Request
Since the change:   {"name":"INVALID_RESOURCE_ID","message":"The requested resource ID was not found","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID","debug_id":"5a652da4b066c"}

The error for this was because I 2 digit year not a 4 digit.

Http 500 error using payments with stored credit card

The server is returing HTTP 500 error when paying with store credit card, even your example code at /PaymentWithSavedCard.aspx

is having this issue, the response: Exception in HttpConnection Execute: Invalid HTTP response The remote server returned an error: (500) Internal Server Error.

PayPal.OAuthTokenCredential.GenerateOAuthToken has exception

If you've NOT english Windows OS you got the System.ArgumentException
in the this code:

foreach (KeyValuePair<string, string> header in (new UserAgentHeader((this.SdkVersion == null ? "" : this.SdkVersion.GetSDKId()), (this.SdkVersion == null ? "" : this.SdkVersion.GetSDKVersion()))).GetHeader())
{
connection.UserAgent = header.Value;
}

KeyValuePair recive the next text:
PayPalSDK/paypal-core-dotnet 1.4.2 ;lang=DOTNET;v=4.0.30319.18449;bit=64;os=Майкрософт Windows 8 Профессиональная 6.2.9200.0;

I sure, we got the System.ArgumentException because text had a cyriclic characters.

Please, fix it.

Payment.Get(accessToken, PaymentID) returns 404

VS says Payment.Get is deprecated. What are we supposed to use instead in cases like this?

Payment payment = Payment.Get(accessToken, "PAY-34629814WL663112AKEE3AWQ");

PaymentExecution paymentExecution = new PaymentExecution();
paymentExecution.setPayerId("7E7MGXCWTTKK2");

Payment newPayment = payment.Execute(accessToken, paymentExecution);

The Documentation differs everywhere you go on the PayPal Developer website but none of the multiple ways it shows actually works.
You need to update your documentation and samples....

Payment token is not available in the Payment creation API call, must be parsed from the approval_url link

When we create a payment with the Payment.Create method, the response object doesn't contain the token value out of the box. In order to get the token, we have to parse the link with the ref="approval_url".

Example:

{
      "href": "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-60U79048BN7719609",
      "rel": "approval_url",
      "method": "REDIRECT"
    },

In the return URL, PayPal gives us this token as the query parameter and that's the only way to link the approval with our back end system.

I suggest to make a dedicated property for this or an extension method that will parse the approval_url and get the token.

This is the first time for me to work with the PayPal Rest SDK, so apologizes if I understood something wrong :)

Thanks!

ArgumentException when calling Payment.Execute() with previously created APIContext object

an "An item with the same key has already been added" error at "payment.Execute" with 0.7.7 does not happen with 0.7.6

From stack trace
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at PayPal.Api.Payments.Payment.Execute(APIContext apiContext, PaymentExecution paymentExecution)

Payment.Create() error codes...

When testing an expired credit card, I get a general exception. How can I get the actual error code? I'm following the PaymentWithCreditCard example:

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

try
{
    APIContext apiContext = Configuration.GetAPIContext();
    Payment createdPayment = pymnt.Create(apiContext);
catch (Exception Ex)
{
    // how can I get the actual problem??
}           

Thanks!

Using the SDK without dependency on settings in web.config?

Is there a way to use the REST API SDK without requiring me to configure settings (ClientID, Secret & Endpoint) via web.config? I'd like to store these settings in a database instead (use case: I'm writing an Orchard CMS module).

I could obviously talk with the REST API directly via HttpClient, but it saves a lot of time being able to use your dot net SDK instead.

PayPal.Checkout: NotFound

When i do a payment it return me NotFound error is sandbox is enabled. Here you are code:

 // Create a new instance of the BuyNow object to represent a purchase
        // The BuyNow constructor takes your PayPal merchant account email address as argument.
        PayPal.Checkout.BuyNow purchase = new PayPal.Checkout.BuyNow("[email protected]");
        // Configure it to use the SandBox environment.
        purchase.UseSandbox = true;
        // Set the currency to use Euro
        purchase.Currency = "EUR";
        purchase.Locale = "IT";

        // Use the ItemBuilder to create a new example item
        PayPal.Checkout.ItemBuilder itemBuilder = new PayPal.Checkout.ItemBuilder(this.Name)
            .ID(this.Id)
            //.Price(this.FinalPrice.ToString().Replace(",","."))
            .Price("0.01")
            .Description(this.Name)
            .Quantity(1);

        // Add the item to the purchase,
        purchase.AddItem(itemBuilder.Build());

        // Attach event handlers so you will be notified of important events
        // The BuyNow interface provides 5 events - Start, Auth, Cancel, Complete and Error
        // See http://paypal.github.io/Windows8SDK/csharp.html#Events for more
        purchase.Error += new EventHandler<PayPal.Checkout.Event.ErrorEventArgs>((source, eventArg) =>
        {
            this.TransactionResult = "C'è stato un errore nel tuo acquisto: " + eventArg.Message;
            Debug.WriteLine("There was an error processing your payment: " + eventArg.Message);
            //this.PurchaseStatus.Text = "There was an error processing your payment: " + eventArg.Message;
        });
        purchase.Complete += new EventHandler<PayPal.Checkout.Event.CompleteEventArgs>((source, eventArg) =>
        {
            this.TransactionResult = "Acquisto effettuato con successo. Transaction id: " + eventArg.TransactionID;
            this.Comprata = true;
            Debug.WriteLine("Payment is complete. Transaction id: " + eventArg.TransactionID);
            //this.PurchaseStatus.Text = "Payment is complete. Transaction id: " + eventArg.TransactionID;
        });
        purchase.Cancel += new EventHandler<PayPal.Checkout.Event.CancelEventArgs>((source, eventArg) =>
        {
            this.TransactionResult = "Pagamento annullato dall'utente";
            Debug.WriteLine("Payment was canceled by the user.");
            //this.PurchaseStatus.Text = "Payment was canceled by the user.";
        });

        // Launch the secure PayPal interface. This is an asynchronous method
        await purchase.Execute();

Execute Order, missing order from related_resources

I had done the following:-

PaymentExecution pymntExecution = new PaymentExecution();
pymntExecution.payer_id = Request.Params["PayerID"];

Payment executedPayment = pymnt.Execute(apiContext, pymntExecution);

It did go through, but related_resources do only have 4 row, Sale, Authorization, Capture and Refund, while the Order is missing out from here? and Order is not included in the SDK. Is this something we need to dealt with or a fix will be implemented?

Project Name

I'd just like to suggest that the API SDK's project be renamed to include PayPal.
As the project is, the resulting .dll's name is not very intuitive as to what it an SDK for.
I'm sure you've come aboard projects just like I have, where it takes a bit to get started on a project because classes and .dll aren't clearly labeled as to their purpose.
I just thought it would be a nice thing to do for some future developers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.