如何在PHP中实现PayPal Express Checkout

时间:2016-08-05 21:41:37

标签: php curl paypal

除了让用户走过PayPal结账流程外,我首先需要做一些数据库工作。然后我需要使用cURL发布' https://www.paypal.com/cgi-bin/webscr/,但收到错误:

  

错误请求。您的浏览器发送了PayPal无法理解的请求。

我已按照PayPal文档的说明将以下证书添加到我的共享服务器:

COMODO ECC证书颁发机构

-----开始证书----- MIICiTCCAg + gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH + X 4QokPB0BBO490o0JlwzgdeT6 + 3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4 / bC8vCVlbpVsLM5ni wz2J + Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E BAMCAQYwDwYDVR0TAQH / BAUwAwEB / zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf / 7VG FAkK + qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG + FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA U / 7dIOA1mjbRxwG55tzd8 / 8dLDoWV9mSOdY = -----结束证书-----

以下是相关的PHP代码:

function post2PayPal() {
    $url = 'https://www.paypal.com/cgi-bin/webscr';

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $response = curl_exec($ch);
    echo 'pp=' . $response;
    exit();
}
post2PayPal();

我缺少什么?

0 个答案:

没有答案