PayPal-NET-SDK GetTransaction from a sale on eBay - c#

I was trying to get the paypal transaction's details from an eBay sale. I'm using Paypal-NET-SDK built on PayPal's REST APIs.
Here is the code:
Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
sdkConfig.Add("mode", "sandbox");
string accessToken = new OAuthTokenCredential(clientID, secret, sdkConfig).GetAccessToken();
string transactionID = "98395731SM1933421";
APIContext apiContext = new APIContext(accessToken);
apiContext.Config = sdkConfig;
Sale sale = Sale.Get(apiContext, transactionID );
But I'm getting this error:
The remote server returned an error: (404) Not Found.
And this is the response:
{"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":"8a0a9ae305a35"}
It looks like I have to use another transaction ID, but this is the transaction ID I'm getting from the eBay API, and also when I enter into my account in paypal this is the transaction ID I'm seeing.
I want to know if I can use this API to get this transaction's details, if not, any suggestions.

Transaction IDs from PayPal's REST APIs and from PayPal's classic APIs are completely unrelated. eBay uses PayPal classic transaction IDs.
Or to put it another way: you cannot use PayPal's REST APIs with eBay transactions. Use PayPal's classic APIs, namely GetTransactionDetails.

Related

"Cannot create payouts with an OAuth key" exception when creating payout for Stripe custom account

We have our master Stripe account, and custom / connected accounts which we eventually want to transfer funds to, and then payout to their external bank accounts.
I have some code that works without issue in test mode, but on production we get an exception when doing the payout step. The error details are:
Stripe.StripeException: Cannot create payouts with an OAuth key.
at Stripe.Infrastructure.Requestor.ExecuteRequest(HttpRequestMessage requestMessage)
at Stripe.Infrastructure.Requestor.PostString(String url, StripeRequestOptions requestOptions)
As far as I know, we are not using an OAuth key for this request, as I set up the StripeAPI with the secret key in Startup.cs of our MVC web application:
StripeConfiguration.SetApiKey("sk_live_**************");
And the actual code to attempt the payout:
StripePayoutService sps = new StripePayoutService();
StripeRequestOptions connectRequest = new StripeRequestOptions();
connectRequest.StripeConnectAccountId = stripeConnectID; //"acct_*********"
StripePayoutCreateOptions spco = new StripePayoutCreateOptions();
spco.Amount = (int)(amount * 100);
spco.Currency = "GBP";
spco.StatementDescriptor = reference;
StripePayout result = sps.Create(spco, connectRequest);
I've specified the connected account id on the stripe request options and the Api Key in initialization, so what is causing the request to complain about OAuth credentials, or what am I missing / doing wrong in this scenario?
It turns out due to an edge case, as the wrong Stripe key was being used, so the OAuth key error message was a red herring. I would recommend anyone investigating an issue similar to this to check:
the request details (via the request id) in the api/logs section on the stripe dashboard, and that a request exists against the appropriate Stripe account
there are enough funds / the transfer succeeded, prior to the payout being requested
You are not doing anything wrong here. Its completely correct just available amount for payout is not available in test data of connect account. Do a test transaction and add amount to stripe test account. It should work fine.

Azure: getting invoice data with the BillingManagementClient class

The last line of the following code results in an "Operation returned an invalid status code 'BadRequest'" exception and I don't understand why:
Given the following code :
var tenantDomain = ConfigurationManager.AppSettings["TenantDomain"];
var clientId = ConfigurationManager.AppSettings["ClientID"];
var secret = ConfigurationManager.AppSettings["ClientSecret"];
var subscriptionId = ConfigurationManager.AppSettings["SubscriptionID"];
var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantDomain, clientId, secret);
var bmc = new BillingManagementClient(serviceCreds);
bmc.SubscriptionId = subscriptionId;
List<Invoice> allInvoices = bmc.Invoices.List().ToList();
Suggestions anyone ? Should I specify a date period explicitly ? How?
Suggestions anyone ? Should I specify a date period explicitly ? How?
If we want to access Billing we need to assign the Billing Reader role to someone that needs access to the subscription billing. We could get the detail steps for the azure official tutorials. I also test the code you mentioned, there is no issue with code, if it is supported. The following is the snippet from the official tutorials.
The Billing Reader feature is in preview, and does not yet support enterprise (EA) subscriptions or non-global clouds.
Please have a try to login Azure Portal to check whether have access to Access to invoice. If you see the Access to invoice is disabled, it seems that the subscription type is not supported.
If you still have further questions, could contact support to get your issue resolved quickly.

Pay Pal - bad request error

I am trying to get pay pal user info once he login to paypal and get authenticated by paypal.
At first step I get the Authorization code. But when the execution reach to get the access token of the user that will help me to get user info in next step gives me the following error.
"Invalid Http rsponse The remote server returned an error : (400) bad
request."
I refer the paypal documentation and sdk for donet
Fowlling is my code
Dictionary<string, string> configurationMap = new Dictionary<string,
string>(); configurationMap.Add("mode", "sandbox"); APIContext
apiContext = new APIContext(); apiContext.Config = configurationMap;
CreateFromAuthorizationCodeParameters param = new
CreateFromAuthorizationCodeParameters(); param.setClientId("**My
ClientID goes here**");
param.setClientSecret("**My Client Secert
goes here**");
param.SetCode(code); // **Authorization code
goes here**
Tokeninfo info =
Tokeninfo.CreateFromAuthorizationCode(apiContext, param);
GetUserInfor(info);
Please guide me where I am lacking or how can i solve this.

RestAPISDK .Net Execute Payment

I'm trying to implement Paypal in an ASP.Net website. I've installed the RestAPISDK and I've been following this guide by Paypal (https://devtools-paypal.com/guide/pay_paypal/dotnet) as well as looking at the references located here (https://developer.paypal.com/webapps/developer/docs/api/#execute-an-approved-paypal-payment)
So far it's going well, but upon returning from Paypal's website, I'm not able to execute the payment as per their documentation.
The Guide says to use the following code
Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
sdkConfig.Add("mode", "sandbox");
string accessToken = "TOKEN";
APIContext apiContext = new APIContext(accessToken);
apiContext.Config = sdkConfig;
Payment payment = new Payment("PAYMENT ID");
PaymentExecution pymntExecution = new PaymentExecution();
pymntExecution.payer_id = ("DYRNAJP829GTN");
Payment executedPayment = pymnt.Execute(apiContext,pymntExecution);
But Payment has no constructor that take in the Payment ID.
The Rest API Reference says to use the following method
Payment payment = Payment.Get(accessToken, "Payment ID");
However, Payment.Get is depreciated. If I use it anyway I just get an Exception saying the server responded with a 404.
What are we supposed to use instead? I can't find any up to date documentation to point me in the right direction.
I'm thinking I may have to use HttpClient to send the Request myself but surely I shouldn't have to do that.
I agree, the C# samples do not work and produce the same 404 exception when you try to Execute a payment with your own sandbox store.
What you need to do is:
Payment payment = Payment.Get(context, paymentID);
where context is your apiContext and paymentID is the id passed back in by the return url from PayPal.
you then need:
var paymentExecution = new PaymentExecution
{
payer_id = payerId
};
finally you can then call:
payment.Execute(context, paymentExecution);
this returns a payment object, which should have the 'state' of approved...
It is the PaymentHistory retrieval method that is deprecated in favor of the Payment.List() method. To retrieve a single payment, you still use the Payment.Get method.
Are you sure you are passing in a valid payment id for the second parameter here? A 404 (Not Found) error is thrown when a payment with the passed in ID does not exist.

How to get friends list from facebook? (Desktop application)

As per this link code from stack overflow i have try this code for getting
friendslist but after login i got this error "requires valid signature"
string APIKey = ConfigurationManager.AppSettings["API_Key"];
string APISecret = ConfigurationManager.AppSettings["API_Secret"];
Facebook.Session.ConnectSession connectsession = new Facebook.Session.ConnectSession(APIKey, APISecret);
Facebook.Rest.Api api = new Facebook.Rest.Api(connectsession);
var friends = api.Friends.GetLists();
foreach (var friend in friends)
{
System.Console.WriteLine(friend.name);
}
guide me to find out the solution
Thanks
ash
If you are starting with a new application, you should definitely use the Graph API and not the old Rest API. The Rest API has been deprecated for quite a while now and there is no guarantee how much longer Facebook will support it.
For an example on using the Graph API try http://csharpsdk.org/docs/web/getting-started
You can obtain the friends list by making a request to me/friends
You can test other requests using the Graph API explorer.

Categories

Resources