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

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

问题描述

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

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

我找不到立即付款,但不指定送货地址.我正在出售通过电子邮件发送的票,不需要运送.

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.

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

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...

我只想在没有送货地址的情况下在Paypal中付款,返回我的网站并付款!

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?

如果有一个人还可以告诉我如何删除您快完成了,这是奖励积分".您将在测试服务商的Test Store上确认您的付款."消息(当用户返回我的网站时我正在付款),这将是amazin;)

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.

关于 Web体验配置文件,当您付款时,可以选择设置具有先前创建的配置文件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:创建一个新的Web体验配置文件.此呼叫返回的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天全站免登陆