6

在这个上拉了几个小时我的头发......

如果不指定送货地址,我找不到通过 paypal api立即付款的方法。我正在销售通过电子邮件发送的门票,不需要运输。

那里有信息指定您必须创建“网络体验配置文件”。但是,一个我不知道如何将“WebProfile()”传递给付款,两个,这不是我想要做的,因为用户必须返回主机网站以授权接受付款,这增加了不必要的步骤到我的结帐处。

我发现的一件事是,如果您指定了送货地址,用户一旦到达贝宝就无法更改它,他们必须返回主机网站更改地址。所以目前,我正在使用公司的邮政地址,但这并不理想......

我只想在没有收货地址的情况下用贝宝付款,返回我的网站并付款!

这甚至可能吗?很确定它是/是付款快递?

加分,如果有人也可以告诉我如何删除“你快完成了”。您将在测试服务商的测试商店确认您的付款。消息(因为我在用户返回我的网站的那一刻付款),这将是惊人的;)

4

1 回答 1

15

使用 PayPal 付款不需要填写送货地址。我建议您查看PayPal .NET SDK 示例,其中包括使用 PayPal 支付的示例,该示例在运行时会向您显示创建、授权和执行支付的流程。

关于Web Experience Profile,当您付款时,您可以选择experience_profile_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);

第 3 步:approval_url使用创建的付款中包含的 HATEOAS 链接将买家重定向到 PayPal 。

// Redirect buyer to PayPal to approve the payment...
var approvalUrl = createdPayment.GetApprovalUrl();

第 4 步:一旦买家批准付款并被重定向回您的网站,请执行付款。

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 });
于 2015-03-09T21:40:18.390 回答