简体   繁体   English

PayPal NVP API-获取Express Checkout令牌

[英]PayPal NVP API - Getting Express Checkout Token

I am trying to get the express checkout token for a PayPal one time purchase integration . 我正在尝试获取PayPal 一次性购买集成的快速结帐令牌。 I get this error when trying to make the cURL request: 尝试提出cURL请求时出现此错误:

ACK=Failure&L_ERRORCODE0=81002&L_SHORTMESSAGE0=Unspecified%20Method&L_LONGMESSAGE0=Method%20Specified%20is%20not%20Supported&L_SEVERITYCODE0=Error1 ACK = Failure&L_ERRORCODE0 = 81002&L_SHORTMESSAGE0 =未指定%20Method&L_LONGMESSAGE0 =方法%20指定的%20is%20not%20Supported&L_SEVERITYCODE0 =错误1

Here is my code 这是我的代码

  <?php
if(!isset($_GET['id'])) {
    header("Location: index.php");
    exit();
}

//Get paypal express checkout token

$ch = curl_init("https://api-3t.sandbox.paypal.com/nvp");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "USER: seller-v3rm_api1.test.com",
        "PWD: <snip>",
        "SIGNATURE: <snip>",
        "METHOD: SetExpressCheckout",
        "VERSION: 93",
        "PAYMENTREQUEST_0_PAYMENTACTION: SALE",
        "PAYMENTREQUEST_0_AMT: 25",
        "PAYMENTREQUEST_0_CURRENCYCODE: USD",
        "RETURNURL: http://test/buy.php",
        "CANCELURL: http://test.com",
    ));
$token = curl_exec($ch);
echo $token;

Am i missing something? 我想念什么吗?

You aren't setting up the request string correctly. 您没有正确设置请求字符串。 I would really recommend taking a look at this PayPal PHP SDK . 我真的建议您看一下此PayPal PHP SDK

First, it will eliminate your need to even mess with this sort of code because it handles it all for you. 首先,由于它可以为您处理所有代码,因此您甚至无需弄乱此类代码。 All you would need to do is open the SetExpressCheckout.php template file that it comes with and fill out the parameters, and then the same for the other calls you might use. 您所需要做的就是打开它附带的SetExpressCheckout.php模板文件并填写参数,然后对其他可能使用的调用进行相同的操作。

Also, though, if you want you could study the code to see how it's handling the cURL request. 另外,尽管如此,如果您愿意,您可以研究代码以查看其如何处理cURL请求。 You need to build an actual NVP string (ie. &something=like&this=example). 您需要构建实际的NVP字符串(即&something = like&this = example)。 Then that is what you send to PayPal via cURL. 然后,这就是您通过cURL发送到PayPal的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM