Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# paypal api:无需发货地址即可立即付款_C#_Paypal_Paypal Rest Sdk - Fatal编程技术网

C# paypal api:无需发货地址即可立即付款

C# paypal api:无需发货地址即可立即付款,c#,paypal,paypal-rest-sdk,C#,Paypal,Paypal Rest Sdk,在这件事上花了我好几个小时 如果不指定发货地址,我无法找到通过paypal api获取邮件的方法。我卖的票是通过电子邮件发送的,不需要运输 有一些信息指定你必须创建一个“网络体验档案”。然而,一个是我无法找到如何将“WebProfile()”传递给付款,另一个是,我不想这样做,因为用户随后必须返回主机网站以授权付款,并在我的结帐中添加不必要的步骤 我发现的一件事是,如果你指定了发货地址,用户一旦进入paypal就无法更改地址,他们必须返回主机网站更改地址。所以目前,我使用的是公司的邮政地址,但并

在这件事上花了我好几个小时

如果不指定发货地址,我无法找到通过paypal api获取邮件的方法。我卖的票是通过电子邮件发送的,不需要运输

有一些信息指定你必须创建一个“网络体验档案”。然而,一个是我无法找到如何将“WebProfile()”传递给付款,另一个是,我不想这样做,因为用户随后必须返回主机网站以授权付款,并在我的结帐中添加不必要的步骤

我发现的一件事是,如果你指定了发货地址,用户一旦进入paypal就无法更改地址,他们必须返回主机网站更改地址。所以目前,我使用的是公司的邮政地址,但并不理想

我只想在贝宝没有送货地址的付款,返回我的网站,并采取付款

这可能吗?!很确定这是/正在使用支付快递


另外,如果有人能告诉我如何删除“You's Every done”(你几乎完成了)。您将在测试服务商的测试商店中确认您的付款。“消息(当用户返回我的网站时,我正在接受付款)将是amazin;)

使用贝宝付款不需要填写发货地址。我建议看一下,其中包括一个示例,在运行时,它向您展示了创建、授权和执行付款的流程

// Create the payment
var payment = new Payment
{
    intent = "sale",
    experience_profile_id = createdProfile.id,
    payer = new Payer
    {
        payment_method = "paypal"
    },
    transactions = new List<Transaction>
    {
        new Transaction
        {
            description = "Ticket information.",
            item_list = new ItemList
            {
                items = new List<Item>
                {
                    new Item
                    {
                        name = "Concert ticket",
                        currency = "USD",
                        price = "20.00",
                        quantity = "2",
                        sku = "ticket_sku"
                    }
                }
            },
            amount = new Amount
            {
                currency = "USD",
                total = "45.00",
                details = new Details
                {
                    tax = "5.00",
                    subtotal = "40.00"
                }
            }
        }
    },
    redirect_urls = new RedirectUrls
    {
        return_url = "http://www.somesite.com/order.aspx?return=true",
        cancel_url = "http://www.somesite.com/order.aspx?cancel=true"
    }
};

var createdPayment = payment.Create(apiContext);
var payerId = Request.Params["PayerID"];
var paymentId = Request.Params["paymentId"];
var paymentToExecute = new Payment { id = paymentId };
var executedPayment = paymentToExecute.Execute(apiContext, new PaymentExecution { payer_id = payerId });
关于网络体验档案,当您付款时,您可以选择使用先前创建的档案id设置
体验档案id

以下是使所有这些工作正常进行所需的步骤:

步骤1:创建新的web体验档案。此呼叫返回的ID可以在每次PayPal付款中重复使用,因此您只需执行一次。

var apiContext = new APIContext(); // APIContext with config info & credentials

// Create the web experience profile
var profile = new WebProfile
{
    name = "My web experience profile",
    presentation = new Presentation
    {
        brand_name = "My brand name",
        locale_code = "US",
        logo_image = "https://www.somesite.com/my_logo.png"
    },
    input_fields = new InputFields
    {
        no_shipping = 1
    }
};

var createdProfile = profile.Create(apiContext);
步骤2:创建付款

// Create the payment
var payment = new Payment
{
    intent = "sale",
    experience_profile_id = createdProfile.id,
    payer = new Payer
    {
        payment_method = "paypal"
    },
    transactions = new List<Transaction>
    {
        new Transaction
        {
            description = "Ticket information.",
            item_list = new ItemList
            {
                items = new List<Item>
                {
                    new Item
                    {
                        name = "Concert ticket",
                        currency = "USD",
                        price = "20.00",
                        quantity = "2",
                        sku = "ticket_sku"
                    }
                }
            },
            amount = new Amount
            {
                currency = "USD",
                total = "45.00",
                details = new Details
                {
                    tax = "5.00",
                    subtotal = "40.00"
                }
            }
        }
    },
    redirect_urls = new RedirectUrls
    {
        return_url = "http://www.somesite.com/order.aspx?return=true",
        cancel_url = "http://www.somesite.com/order.aspx?cancel=true"
    }
};

var createdPayment = payment.Create(apiContext);
var payerId = Request.Params["PayerID"];
var paymentId = Request.Params["paymentId"];
var paymentToExecute = new Payment { id = paymentId };
var executedPayment = paymentToExecute.Execute(apiContext, new PaymentExecution { payer_id = payerId });
第4步:一旦买方批准付款并重定向回您的网站,执行付款

// Create the payment
var payment = new Payment
{
    intent = "sale",
    experience_profile_id = createdProfile.id,
    payer = new Payer
    {
        payment_method = "paypal"
    },
    transactions = new List<Transaction>
    {
        new Transaction
        {
            description = "Ticket information.",
            item_list = new ItemList
            {
                items = new List<Item>
                {
                    new Item
                    {
                        name = "Concert ticket",
                        currency = "USD",
                        price = "20.00",
                        quantity = "2",
                        sku = "ticket_sku"
                    }
                }
            },
            amount = new Amount
            {
                currency = "USD",
                total = "45.00",
                details = new Details
                {
                    tax = "5.00",
                    subtotal = "40.00"
                }
            }
        }
    },
    redirect_urls = new RedirectUrls
    {
        return_url = "http://www.somesite.com/order.aspx?return=true",
        cancel_url = "http://www.somesite.com/order.aspx?cancel=true"
    }
};

var createdPayment = payment.Create(apiContext);
var payerId = Request.Params["PayerID"];
var paymentId = Request.Params["paymentId"];
var paymentToExecute = new Payment { id = paymentId };
var executedPayment = paymentToExecute.Execute(apiContext, new PaymentExecution { payer_id = payerId });

从代码来看,我认为你已经搞定了,我欠你一杯啤酒;)我认为行'experience\u profile\u id=createdProfile.id'是将'payer\u id'传递给execute的键。我现在把这个放进去试试,真是太感谢你了!有趣的。。。我的代码基于您提到的“Paypal支付”(Paypal Payment)示例代码,因此很容易访问。第一次运行时,一切都很顺利。后续付款尝试给我错误“具有此名称的配置文件已存在”。从错误和sdk中的“PaymentExperienceCreate.aspx.cs”页面来看,一旦使用web配置文件,您是否需要将其吹走?再试试看!是的,一旦您创建了web体验配置文件ID,您就不需要继续创建它了。只需缓存ID,然后将其用于您创建的每次付款。我将看看是否可以使用此特定用例更新示例项目。:)嘿,我设法让它工作了——快乐的日子!有趣的是,您只需创建一次web配置文件?它似乎没有存储在我的贝宝沙箱帐户中查看。。。但我认为我在那里;)再次感谢你的帮助,这让生活变得轻松了很多(我现在还有满头的头发……)@jakewilliamson很高兴听到这个消息!配置文件存储在PayPal端,永远不会过期。通过调用
WebProfile.GetList()
并在其中搜索,您始终可以获得您创建的体验配置文件列表。