Html 在paypal中支付多个项目
我正在做以下工作,以添加多个项目到贝宝,但它不工作。没有添加任何项目。然而,如果我只添加了一个项目,而没有在项目名称中添加“_1”、“_2”等,那么一切都可以完美地工作。在这种情况下,我做错了什么 表格Html 在paypal中支付多个项目,html,paypal,Html,Paypal,我正在做以下工作,以添加多个项目到贝宝,但它不工作。没有添加任何项目。然而,如果我只添加了一个项目,而没有在项目名称中添加“_1”、“_2”等,那么一切都可以完美地工作。在这种情况下,我做错了什么 表格 <form name="paypal_auto_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" value="2" name="r
<form name="paypal_auto_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" value="2" name="rm">
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" value="USD" name="currency_code">
<input type="hidden" value="myname@gmail.com" name="business">
<input type="hidden" value="http://[::1]/d/paypal/success" name="return">
<input type="hidden" value="http://[::1]/d/paypal/cancel" name="cancel_return">
<input type="hidden" value="http://[::1]/d/paypal/ipn" name="notify_url">
<input type="hidden" value="Laptop" name="item_name_1">
<input type="hidden" value="1" name="custom_1">
<input type="hidden" value="1" name="item_number_1">
<input type="hidden" value="500.00" name="amount_1">
<input type="hidden" value="1" name="quantity_1">
<input type="hidden" value="Laptop" name="item_name_2">
<input type="hidden" value="1" name="custom_2">
<input type="hidden" value="1" name="item_number_2">
<input type="hidden" value="500.00" name="amount_2">
<input type="hidden" value="1" name="quantity_2">
<p><input type="submit" value="Click here" name="pp_submit"></p></form>
结果
请检查Paypal Api文档中的所有必填字段。可能有什么东西不见了。您的数据中应该有项的数组。项目(名称、货币、价格、数量)。您还应该有一个对象付款人(它是付款方式),重定向Url,详细信息对象(税务、装运、小计),金额对象(货币、总额),交易对象(描述、发票号、金额、项目)。我做了,但是用了C。您可以使用可用的库
使用PayPal.Api;
使用System.Collections.Generic;
名称空间PayPal.Sample
{
使用信用卡支付公共部分课程:BaseSamplePage
{
受保护的重写void RunSample()
{
//####Api上下文
//传入'APIContext'对象以进行身份验证
//调用并发送唯一的请求id
//(这确保了幂等性)
//如果未显式传递请求id,则为请求id。
//请参阅[Configuration.cs](/Source/Configuration.html)了解有关APIContext的更多信息。
var apiContext=Configuration.GetAPIContext();
//交易定义了付款合同——付款的目的和履行人。
var事务=新事务()
{
金额=新金额()
{
货币=“美元”,
total=“7”,
详细信息=新的详细信息()
{
shipping=“1”,
小计=“5”,
tax=“1”
}
},
description=“这是付款交易描述。”,
项目列表=新项目列表()
{
items=新列表()
{
新项目()
{
name=“项目名称”,
货币=“美元”,
price=“1”,
数量=“5”,
sku=“sku”
}
},
发货地址=新发货地址
{
city=“约翰斯顿”,
国家/地区代码=“美国”,
line1=“北面大街52号”,
邮政编码=“43210”,
state=“噢”,
收件人\u name=“Joe买家”
}
},
发票编号=通用。GetRandomInvoiceNumber()
};
//一种资源,表示为付款提供资金的付款人。
var付款人=新付款人()
{
付款方式=“信用卡”,
融资工具=新列表()
{
新基金仪器()
{
信用卡=新信用卡()
{
账单地址=新地址()
{
city=“约翰斯顿”,
国家/地区代码=“美国”,
line1=“北面大街52号”,
邮政编码=“43210”,
state=“噢”
},
cvv2=“874”,
到期月份=11,
到期年=2018年,
first_name=“Joe”,
last_name=“购物者”,
number=“4877274905927862”,
type=“visa”
}
}
},
付款人信息=新付款人信息
{
电子邮件=”test@email.com"
}
};
//支付资源;使用上述类型和意图创建一个“销售”或“授权”`
var付款=新付款()
{
intent=“销售”,
付款人=付款人,
事务=新列表(){transaction}
};
//^忽略工作流代码段
#区域跟踪工作流
this.flow.AddNewRequest(“创建信用卡支付”,支付);
#端区
//使用有效的APIContext创建付款
var createdPayment=payment.Create(apiContext);
//^忽略工作流代码段
#区域跟踪工作流
this.flow.RecordResponse(createdPayment);
#端区
//有关更多信息,请访问[PayPal开发者REST API参考](https://developer.paypal.com/docs/api/).
}
}
}
我不完全确定我是否看到了任何PHP代码,html表单也没有竞争……我刚刚在问题中添加了相关代码。表单实际上是完整的,它是PHP代码。编辑:现在我也添加了表单代码。
添加它,看看它是否工作它的HTML不是PHP,是一个打字错误。嘿,Farkie,我添加了表单代码,但结果是一样的。
using PayPal.Api;
using System.Collections.Generic;
namespace PayPal.Sample
{
public partial class PaymentWithCreditCard : BaseSamplePage
{
protected override void RunSample()
{
// ### Api Context
// Pass in a `APIContext` object to authenticate
// the call and to send a unique request id
// (that ensures idempotency). The SDK generates
// a request id if you do not pass one explicitly.
// See [Configuration.cs](/Source/Configuration.html) to know more about APIContext.
var apiContext = Configuration.GetAPIContext();
// A transaction defines the contract of a payment - what is the payment for and who is fulfilling it.
var transaction = new Transaction()
{
amount = new Amount()
{
currency = "USD",
total = "7",
details = new Details()
{
shipping = "1",
subtotal = "5",
tax = "1"
}
},
description = "This is the payment transaction description.",
item_list = new ItemList()
{
items = new List<Item>()
{
new Item()
{
name = "Item Name",
currency = "USD",
price = "1",
quantity = "5",
sku = "sku"
}
},
shipping_address = new ShippingAddress
{
city = "Johnstown",
country_code = "US",
line1 = "52 N Main ST",
postal_code = "43210",
state = "OH",
recipient_name = "Joe Buyer"
}
},
invoice_number = Common.GetRandomInvoiceNumber()
};
// A resource representing a Payer that funds a payment.
var payer = new Payer()
{
payment_method = "credit_card",
funding_instruments = new List<FundingInstrument>()
{
new FundingInstrument()
{
credit_card = new CreditCard()
{
billing_address = new Address()
{
city = "Johnstown",
country_code = "US",
line1 = "52 N Main ST",
postal_code = "43210",
state = "OH"
},
cvv2 = "874",
expire_month = 11,
expire_year = 2018,
first_name = "Joe",
last_name = "Shopper",
number = "4877274905927862",
type = "visa"
}
}
},
payer_info = new PayerInfo
{
email = "test@email.com"
}
};
// A Payment resource; create one using the above types and intent as `sale` or `authorize`
var payment = new Payment()
{
intent = "sale",
payer = payer,
transactions = new List<Transaction>() { transaction }
};
// ^ Ignore workflow code segment
#region Track Workflow
this.flow.AddNewRequest("Create credit card payment", payment);
#endregion
// Create a payment using a valid APIContext
var createdPayment = payment.Create(apiContext);
// ^ Ignore workflow code segment
#region Track Workflow
this.flow.RecordResponse(createdPayment);
#endregion
// For more information, please visit [PayPal Developer REST API Reference](https://developer.paypal.com/docs/api/).
}
}
}