paypal / PayPal-NET-SDK

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

Payout error 403 REQUIRED_SCOPE_MISSING #401

Closed killemth closed 5 years ago

killemth commented 5 years ago

Issue description

When attempting to initiate a batch Payout operation, I am getting a 403 response with code REQUIRED_SCOPE_MISSING.

The account has Payout enabled for sandbox and live/production, and is based out of Australia (had to be manually enabled by PayPal Account Representative).

Cross-referenced same issue on API board at https://github.com/paypal/PayPal-REST-API-issues/issues/287

The testing integration code is as follows:

                String accessToken = new OAuthTokenCredential(
                    PayPalApiClientId,
                    PayPalApiSecretKey,
                    SystemConfig.IsStagingEnvironment
                        ? new Dictionary<String, String> {{"mode", "sandbox"}}
                        : null).GetAccessToken();

                String batchId = GenerateBatchId();
                List<PayoutItem> payoutItems = new List<PayoutItem>
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        receiver = emailAddress,
                        amount = new Currency {currency = "USD", value = amount.ToString("F2")},
                        note = note
                    }
                };

                PayoutBatch resp = Payout.Create(
                    new APIContext(accessToken), 
                    new Payout
                    {
                        items = payoutItems,
                        sender_batch_header = new PayoutSenderBatchHeader
                        {
                            email_subject = "Withdraw",
                            recipient_type = PayoutRecipientType.EMAIL,
                            sender_batch_id = batchId
                        }
                    });