paypal api:无需送货地址即可立即付款
paypal api: take immediate payment without a shipping address
在这个问题上我已经扯了好几个小时了...
我找不到在不指定送货地址的情况下通过贝宝 api 接收 immediate payment 的方法。我卖的是通过电子邮件发送的门票,不需要运费。
那里有信息指定您必须创建一个 'web experience profile'。但是,一是我不知道如何将 'WebProfile()' 传递给付款,二是这不是我想要做的,因为用户随后必须 return 主机网站授权接受付款在我的结帐中添加了一个不必要的步骤。
我发现的一件事是,如果您指定送货地址,用户一旦到达 paypal 就无法更改,他们必须 return 到托管网站才能更改地址。所以目前,我使用的是公司的邮政地址,但这并不理想...
我只想在没有送货地址的情况下使用 paypal 付款,return 到我的网站并付款!
这可能吗?!非常确定 was/is 可以使用快递付款?
为了加分,如果有人还可以告诉我如何删除'你快完成了。您将在考试协调员的考试商店确认您的付款。消息(当用户 return 访问我的网站时我正在付款)那将是惊人的 ;)
使用 PayPal 付款不需要填写送货地址。我建议您查看 PayPal .NET SDK samples, which includes a Payment with PayPal 示例,该示例在 运行 时向您展示了创建、授权和执行付款的流程。
关于Web Experience Profile,当您付款时,您可以选择使用先前创建的配置文件的 ID 设置 experience_profile_id
。
以下是您要完成所有这些工作所需遵循的步骤:
第 1 步: 创建新的网络体验配置文件。此调用返回的 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 link 将买家重定向到 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 });
在这个问题上我已经扯了好几个小时了...
我找不到在不指定送货地址的情况下通过贝宝 api 接收 immediate payment 的方法。我卖的是通过电子邮件发送的门票,不需要运费。
那里有信息指定您必须创建一个 'web experience profile'。但是,一是我不知道如何将 'WebProfile()' 传递给付款,二是这不是我想要做的,因为用户随后必须 return 主机网站授权接受付款在我的结帐中添加了一个不必要的步骤。
我发现的一件事是,如果您指定送货地址,用户一旦到达 paypal 就无法更改,他们必须 return 到托管网站才能更改地址。所以目前,我使用的是公司的邮政地址,但这并不理想...
我只想在没有送货地址的情况下使用 paypal 付款,return 到我的网站并付款!
这可能吗?!非常确定 was/is 可以使用快递付款?
为了加分,如果有人还可以告诉我如何删除'你快完成了。您将在考试协调员的考试商店确认您的付款。消息(当用户 return 访问我的网站时我正在付款)那将是惊人的 ;)
使用 PayPal 付款不需要填写送货地址。我建议您查看 PayPal .NET SDK samples, which includes a Payment with PayPal 示例,该示例在 运行 时向您展示了创建、授权和执行付款的流程。
关于Web Experience Profile,当您付款时,您可以选择使用先前创建的配置文件的 ID 设置 experience_profile_id
。
以下是您要完成所有这些工作所需遵循的步骤:
第 1 步: 创建新的网络体验配置文件。此调用返回的 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 link 将买家重定向到 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 });