Mass Pay API 可让您一次调用最多发送 250 笔付款。使用电子邮件地址、PayPal 用户 ID 或手机号码识别收款人。
1.设置呼叫和认证
指定端点、调用名称、API 凭据以及您调用的 API 版本:
https://api-3t.sandbox.paypal.com/nvp # Sandbox endpoint
USER=<Caller_ID> # the PayPal User ID of the caller account
PWD=<Caller_Pswd> # the caller account Password
SIGNATURE=<Caller_Sig> # the caller account Signature
METHOD=MassPay # API operation
VERSION=93 # API version
2.设置全局调用值
设置 RECEIVERTYPE 和 CURRENCYCODE 值,以及自定义的 EMAILSUBJECT(每次调用只能有一个值):
RECEIVERTYPE=EmailAddress # set to EmailAddress, UserID, or PhoneNumber
CURRENCYCODE=USD # currency code for all payouts
EMAILSUBJECT=You have a payment from TEST # custom e-mail subject for all payouts
3.设置付款
指定每笔付款的详细信息。您可以为每次付款添加自定义消息和跟踪号,如下所示:
L_AMT0=1.23 # 1st txn amount, starting at "0"
L_EMAIL0=e-mail_1@example.com # e-dress of 1st payee
L_NOTE0= Thank you for our catered lunch. # custom e-mail msg for 1st payee
L_UNIQUEID0=TxnNo123 # unique ID for txn
L_AMT1=4.56 # 2nd txn amount
L_EMAIL1=e-mail_2@example.com
L_NOTE1= Thank you the Balloons!
L_UNIQUEID1=TxnNo456
4.发送请求
以下 cURL 命令显示了如何使用单个 Mass Pay 调用进行三笔支付的完整示例:
curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d
"USER=<Caller_ID>
&PWD=<Caller_Pswd>
&SIGNATURE=<Caller_Sig>
&METHOD=MassPay
&VERSION=93
&RECEIVERTYPE=EmailAddress
&CURRENCYCODE=USD
&EMAILSUBJECT= You have a new payment from TEST
&L_EMAIL0=e-mail_1@example.com
&L_AMT0=1.23
&L_NOTE0= Thank you for our catered lunch.
&L_UNIQUEID0=TxnNo123
&L_EMAIL1=e-mail_2@example.com
&L_AMT1=4.56
&L_NOTE1= Thank you for the Balloons!
&L_UNIQUEID1=TxnNo456
&L_EMAIL2=e-mail_3@example.com
&L_AMT2=7.89
&L_NOTE2= Thank you for your cleaning service.
&L_UNIQUEID2=TxnNo789"