简体   繁体   English

如何从控制台应用程序汇款到贝宝账户?

[英]How send money to paypal account from console app?

I use PayPal-NET-SDK for interact with PayPal system (sanbox).我使用PayPal-NET-SDK与 PayPal 系统(sanbox)进行交互。 I have next code:我有下一个代码:

    static void Main(string[] args)
    {
        try
        {
            var config = ConfigManager.Instance.GetProperties();
            var accessToken = new OAuthTokenCredential(config).GetAccessToken();
            var apiContext = new APIContext(accessToken);

            var payment = Payment.Create(apiContext, new Payment
            {
                intent = "order",
                payer = new Payer
                {
                    payment_method = "paypal"
                },
                transactions = new List<Transaction>
                {
                    new Transaction
                    {
                        description = "Transaction description.",
                        invoice_number = "002",
                        amount = new Amount
                        {
                            currency = "USD",
                            total = "15.00",
                        },
                        payee = new Payee
                        {
                            email = "test1@gmail.com"
                        }
                    }
                },
                redirect_urls = new RedirectUrls
                {
                    return_url = "site for redirect", // in my code there is normal url
                    cancel_url = "site for redirect""
                }
            });

            var approval = payment.GetTokenFromApprovalUrl();

            var url = payment.GetApprovalUrl();


            payment.token = approval;

            var response = payment.Execute(apiContext, new PaymentExecution {payer_id = "C598R54Q6P39G" });
        }
        catch (PaymentsException e)
        {
            Console.WriteLine(e.Response);
        }
    }

After executing this code i receive bad request error from PayPal ("Payer has not approved payment").执行此代码后,我收到来自 PayPal 的错误请求错误(“付款人未批准付款”)。 If go to link in url in debug, i get to PayPal confirm page, and after push continue button, payment executing withoue exceptions (but funds still same, money is not sending).如果在调试中转到 url 中的链接,我将进入 PayPal 确认页面,并在按下继续按钮后,付款执行无异常(但资金仍然相同,资金未发送)。 How i can send money to other paypal wallet without redirect to PayPal aproving page?如何在不重定向到 PayPal 批准页面的情况下向其他贝宝钱包汇款?

Resolved by using payout (as i uderstand, payments use for client to merchant transfer).通过使用付款解决(正如我所理解的,付款用于客户到商家的转账)。

    static void Main(string[] args)
    {
        try
        {
            // Authenticate with PayPal
            var config = ConfigManager.Instance.GetProperties();
            var accessToken = new OAuthTokenCredential(config).GetAccessToken();
            var apiContext = new APIContext(accessToken);

            var payout = Payout.Create(apiContext, new Payout
            {
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    email_subject = "Hello payout",
                    sender_batch_id = "ilab_Payout002",
                    recipient_type = PayoutRecipientType.EMAIL
                },
                items = new List<PayoutItem>
                {
                    new PayoutItem
                    {
                        amount = new Currency
                        {
                            currency = "USD",
                            value = "17.5"
                        },
                        note = "Exchange is done!",
                        receiver = "ilab-test1@gmail.com",
                        recipient_type = PayoutRecipientType.EMAIL,
                        sender_item_id = "121341"
                    }
                },
            });
        }
        catch (PaymentsException e)
        {
            Console.WriteLine(e.Response);
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从贝宝账户获取交易信息 - how to get transaction information from paypal account 如何使用stripe.net从关联的托管帐户向平台帐户转移资金 - How to transfer money from a connected managed account to the platform account using stripe.net 从[SomePaymentProcesingCompany]汇款到银行账户 - Sending money from [SomePaymentProcesingCompany] to bank account 从OSX(Mac)上的控制台应用程序访问Azure存储帐户 - Accessing Azure storage account from console app on OSX (Mac) 如何在系统 Windows 用户帐户下启动控制台应用程序? - How to start a Console App as running under the System Windows user account? 如何从.NET 2.0+发送请求-PayPal WSDL - How to send a Request - PayPal WSDL from .NET 2.0+ 无法从控制台应用程序向Web API发送/接收客户端证书 - Fail to send/receive Client Certificate from Console App to web api 从一个正在运行的控制台应用程序发送消息 - Send message from one running console app to another TWILIO无法从C#控制台应用发送短信 - TWILIO cannot send sms from C# console app 强制控制台应用程序使用特定帐户运行 - Force console app to run using specific account
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM