[英]PayPal Recurring Payments for Installment Donations
我想在我的.NET网站上开始捐赠活动,要求人们同意向我的组织捐赠200.00美元。 由于有些人可能没有预先支付所有的钱,我想让他们现在可以选择捐赠50美元或更多,然后将剩余的金额分摊到每月1-3次之间。
我是否需要为每种可能的方案设置定期付款按钮,然后使用一些脚本来确定我应该将用户引导到哪个PayPal表单按钮? 或者有更灵活的方式吗?
我认为你必须制定一个计费方案。 以下代码段来自PayPal SDK 。 我根据您的需要对其进行了一些修改,但您仍需要对其进行自定义。
var plan = new Plan
{
name = "Donation Split Payment",
description = "Monthly plan for the less fortunate.",
type = "fixed",
// Define the merchant preferences.
// More Information: https://developer.paypal.com/webapps/developer/docs/api/#merchantpreferences-object
merchant_preferences = new MerchantPreferences()
{
setup_fee = GetCurrency("0"),
return_url = httpContext.Request.Url.ToString(),
cancel_url = httpContext.Request.Url.ToString() + "?cancel",
auto_bill_amount = "YES",
initial_fail_amount_action = "CONTINUE",
max_fail_attempts = "0"
},
payment_definitions = new List<PaymentDefinition>
{
// Define a trial plan that will only charge $50 for the first
// month. After that, the standard plan will take over for the
// remaining 4 months.
new PaymentDefinition()
{
name = "First Payment",
type = "REGULAR",
frequency = "MONTH",
frequency_interval = "1",
amount = GetCurrency("50.00"),
cycles = "1",
charge_models = new List<ChargeModel>
{
new ChargeModel()
{
type = "TAX",
amount = GetCurrency("9.99")
}
}
},
// Define the standard payment plan. It will represent a monthly
// plan for $50 USD that charges once month for 3 months.
new PaymentDefinition
{
name = "Other payment",
type = "REGULAR",
frequency = "MONTH",
frequency_interval = "1",
amount = GetCurrency("50.00"),
// > NOTE: For `IFNINITE` type plans, `cycles` should be 0 for a `REGULAR` `PaymentDefinition` object.
cycles = "3",
charge_models = new List<ChargeModel>
{
new ChargeModel
{
type = "TAX",
amount = GetCurrency("9.99")
}
}
}
}
};
我不熟悉“PayPal-Button”本身,但我想,这只是一些参数的变化。 最有可能在URL本身。 (GET请求)
因此,您可以在网站上放置带有选项的下拉列表,将付款分成n个相等的部分,然后使用此按钮重定向到相应的PayPal-URL,而不是创建多个按钮。
我不知道你的堆栈,但使用MVC(Razor)和一些Javascript,它似乎没有太大的努力。
因此,要么在页面上使用JS来重定向,只需单击按钮,或者在服务器端进行评估后返回重定向。
如果PayPal使用POST,那么您可以使用Form,在其中使用Form 外部的其他INPUT的某些事件更改INPUT的值。 这需要JavaScript。
所以在Select-Click-Event上:设置input-element的值,“PayPal-button”用于POST请求。 像下面这样的东西。
<script>
function SetValue(){
buttonValue.value = selector.value;
}
</script>
<SELECT id="selector" onClick="SetValue()">
... options
</SELECT>
<Form ...>
<input id="buttonValue" ... />
<button...>Send</button>
</Form>
检查此工作流程https://developer.paypal.com/docs/subscriptions/
https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription
我没有完整的代码,之前称之为计费协议。 Paypal .net sdk已经两年了。 https://github.com/paypal/PayPal-NET-SDK/blob/develop/Samples/Source/BillingAgreementCreateAndExecute.aspx.cs在paypal网站上提到了这一点。 帐单协议API弃用通知:不推荐使用/ v1 / billing-agreements端点。 请改用/ v1 / billing / subscriptions端点。 有关详细信息,请参阅订阅集成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.