paypal api:无需送货地址即可立即付款 [英] paypal api: take immediate payment without a shipping address

查看:46
本文介绍了paypal api:无需送货地址即可立即付款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

been pulling my hair out for hours on this one...

我找不到立即付款的方法 通过 paypal api 而不指定送货地址.我出售的门票是通过电子邮件发送的,不需要运送.

i can't find a way to take an immediate payment via the paypal api without specifying a shipping address. i'm selling tickets that are delivered via email, no shipping is required.

有信息表明您必须创建网络体验配置文件".但是,一个我不知道如何将WebProfile()"传递给付款,第二个,这不是我想要做的,因为用户必须返回主机网站以授权进行付款,增加了不必要的步骤到我的结帐处.

there is info out there specifying you have to create a 'web experience profile'. however, one i can't find out how to pass the 'WebProfile()' to the payment and two, it's not what i want to do because the user then has to return the host website to authorise taking the payment adding an unnecessary step to my checkout.

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

one thing i have found is that if you specify the shipping address, the user can't change it once they get to paypal, they have to return to the host website to change the address. so for the moment, i'm using the postal address of the company but it's not ideal...

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

i just wanna take a payment in paypal without a shipping address, return to my website and take the payment!

这甚至可能吗?!很确定它是/正在使用付款快递?

is this even possible?! pretty sure it was/is with payment express?

如果有人还可以告诉我如何删除你快完成了.您将在测试协调员的测试商店中确认您的付款.消息(因为我在用户返回我的网站时正在付款)这将是令人惊奇的 ;)

for a bonus point, if someone can also tell me how to remove the 'You're almost done. You will confirm your payment on test facilitator's Test Store.' message (as i'm taking the payment the moment the user returns to my website) that would be amazin ;)

推荐答案

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

Payments with PayPal do not require a shipping address to be completed. I'd recommend taking a look at the PayPal .NET SDK samples, which includes a Payment with PayPal sample that, when run, shows you the flow of creating, authorizing, and executing the payment.

关于网络体验配置文件,当您付款时,您可以选择使用之前创建的配置文件的 ID 设置 experience_profile_id.

Concerning the Web Experience Profile, when you make the payment you can optionally set an experience_profile_id with the ID of a previously-created profile.

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

Here's the steps you'll want to follow to get all this working:

第 1 步:创建新的网络体验配置文件.此调用返回的 ID 可以在每次 PayPal 付款时重复使用,因此您只需执行一次.

Step 1: Create a new web experience profile. The ID returned from this call can be re-used with every PayPal payment, so you should only need to do this once.

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.

Step 3: Redirect the buyer to PayPal using the approval_url HATEOAS link included with the created payment.

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

第 4 步:在买家批准付款并重定向回您的网站后,执行付款.

Step 4: Once the buyer approves the payment and is redirected back to your site, execute the payment.

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 });

这篇关于paypal api:无需送货地址即可立即付款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆