本文介绍了如何更好地整合Paypal的“立即购买"第三方卖家的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的网站中找到集成 Paypal立即购买"按钮的最佳方法,但是我对所有各种Paypal集成技术(托管按钮,动态按钮)一无所知,IPN,PDT和其他各种API)

I'm trying to find the best way to integrate Paypal "Buy Now" buttons in my website, but I'm quite lost with all the various Paypal integration techniques (hosted buttons, dynamic buttons, IPN, PDT, and other various APIs)

我想集成更好/最简单的解决方案以满足我的需要,并且还集成安全一个...

I would like to integrate the better/easiest solution for my need and also a secure one...

我真的不知道该去哪里...
在此先感谢您的帮助!

I don't really know where to go...
Many thanks in advance for your help!

我拥有一个旨在成为销售数字商品的市场"的网站.

I own a website that aims to be a "marketplace" to sell digital goods.

有些人(我们称他们为卖方)以卖方"身份注册到我的网站,并上传了他们想出售的一些数字商品.我为他们销售的每个"产品"生成在线页面.

Some people (let's call them SELLERS) register to my website as "sellers" and upload some digital goods they want to sell. I generate for them online pages for each "product" they sell.

其他一些人(我们称他们为 BUYERS )也仅以买方"身份注册到我的网站:他们只是想从各个卖方那里购买这些数字商品.

Some other people (let's call them BUYERS) also register to my websites as "buyers" only: they just want to buy these digital goods from various sellers.

我想在每个产品页面上集成卖方的贝宝按钮,因此将直接向他付款.我不想成为付款的中间人.

I want to integrate on each product page the paypal button of the SELLER, so he will be paid directly. I don't want to be intermediate in the payment.

因此,我需要在每个产品页面上集成一个不同的按钮,具体取决于该产品的卖方.

So I need to integrate on each product page a different button, depending on the seller for this product.

我还需要为每种产品动态指定一个不同的价格,具体取决于所售产品(价格将由卖家在其网站的后台确定)

I also need for each product to specify dynamically a different price, depending on the product sold (price will be fixed by sellers on their back-office on my website)

交易完成后(买方付款),我需要为该买方解锁产品页面上的产品下载.实际上,我需要更新数据库以将产品与该买家相关联,因此,当他稍后返回我的网站时,他总是拥有自己购买的产品解锁".

When the transaction is complete (payment done by the buyer), I need to unlock the download of the product on the product page for this buyer. In fact I need to update my database to associate the product to this buyer, so when he come back on my website later, he always have the product he bought "unlocked".

<form name="_xclick" action="https://www.paypal.com/fr/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="Digital good 1">
<input type="hidden" name="amount" value="12.99">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="item_number" value="internal_user_and_product_id">
<input type="hidden" name="business" value="seller@abusiness.com">
<input type="hidden" name="notify_url" value="https://mywebsite.com/paypal-ipn.php">
<input type="image" src="http://www.paypal.com/fr_FR/i/btn/x-click-but01.gif" border="0" name="submit">
</form>

在这里,我似乎只需要询问卖方其Paypal商业电子邮件或ID,并为他和他的产品动态生成一个按钮即可.我还可以提供IPN侦听器URL,以便在收到完整交易后使用通过"item_number"传递的数据为我的数据库中的购买者解锁产品.非常简单.

It seems here that I just need to ask the seller its Paypal business email or ID, and dynamically generate a button for him and his product. I can also provide my IPN listener URL to unlock the product for the buyer in my database using the data passed through "item_number" upon complete transaction received. Quite simple.

但是:
-这不安全
(任何人都可以在购买前更改HTML中的金额或贝宝ID)
-如果卖方提供的电子邮件地址不正确(拼写错误)会怎样?
(我尝试使用测试按钮和假的电子邮件地址"djfhsgfshdgfsd@dghe.com"进行购买,因此能够处理付款!!这不是使用错误的公司ID的情况...)

BUT:
- this is NOT secure
(anybody can change the amount or paypal ID in HTML before to make the purchase)
- what happens if the seller provide an incorrect (mispelled) email address ?
(I tried to make a purchase with a test button and the fake email address "djfhsgfshdgfsd@dghe.com" and I was able to process the payment !! That was not te case with an incorrect business ID...)

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="PJM2WY8H648ZK">
<input type="hidden" name="item_name" value="Digital good 2">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="item_number" value="internal_user_and_product_id">
<input type="hidden" name="notify_url" value="https://mywebsite.com/paypal-ipn.php">
<input type="image" src="http://www.paypal.com/fr_FR/i/btn/x-click-but01.gif" border="0" name="submit">
<input type="image" src="https://www.paypalobjects.com/fr_FR/FR/i/btn/btn_buynow_LG.gif" border="0" name="submit">
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>

这可以避免使用Paypal上托管的按钮进行欺诈.

This would avoid fraud with the button hosted on Paypal.

但是:
-我无法动态生成按钮(如金额和货币).
这意味着我将不得不要求卖方为他们要出售的每种商品生成一个托管按钮,并设置正确的价格.
这还意味着我将无法在我的网站上显示产品的价格?确实,如果卖家在其Paypal托管按钮中设置了2USD但在我的后台设置了1USD,则我将在我的网站上显示1USD,而实际价格是2USD ...

BUT:
- I can't generate dynamically the button (like amount and currency).
This means that I will have to ask for sellers to generate themselves an hosted button for each item they want to sell, and set the correct price.
This also means that I will not be able to display on my website the price of the product ? Indeed, if the seller set 2USD in his Paypal hosted button but 1USD in my back-office, I will display 1USD in my website whereas the real price is 2USD...

  • 我不确定我可以提供哪些变量来覆盖托管按钮.
    我至少需要"notify_url"(IPN侦听器URL)和"item_number"(我的产品/买方技术ID)
  • I'm not sure of which variables I can provide to override the hosted button.
    I need at least the "notify_url" (IPN listener URL) and "item_number" (my product/buyer technical IDs)

对于下一步,我也有很多疑问,例如IPN/PDT以及我可以做些什么.但让我们先回答一下我可以使用并集成的按钮类型!

I also have many interrogations for next steps, like IPN/PDT and what I can really do with these. but let's answer first the type of button I can use and integrate first!

推荐答案

为此,您最好的解决方案是不使用PayPal按钮.您可能要使用PayPal Express Checkout解决方案.这里有一个例子:

Your best solution for this is to not use the PayPal Buttons. You would want to use the PayPal Express Checkout solution. There is an example here:

http://marshalcurrier.com/paypal/ExpressCheckout/SetDo.php

此过程需要更多编程,但可以解决所有问题.该金额直接从您的服务器传递到PayPal,无法通过HTML进行修改.另外,完成付款后,您会立即收到付款确认.这样,您就不必依赖IPN.

This process is a little more programming but it will resolve all of your issues. The amount is passed from your server to PayPal directly and cannot be modified through the HTML. Also, when you complete the payment you receive a payment confirmation immediately. This way you don't have to rely on the IPN.

以下是指向简介页面的直接链接:

Here is a direct link to the intro page:

https://developer.paypal.com/docs/classic/express -checkout/gs_expresscheckout/

这是上面的Express Checkout示例链接的代码:

Here is the code for the Express Checkout example link above:

买方电子邮件:buyer@clubcovert.com

Buyer email: buyer@clubcovert.com

买方pwd:test1234

Buyer pwd: test1234

<a href='http://marshalcurrier.com/paypal/ExpressCheckout/custom/SetDo.php'>RESET</a><br>
<form method='post'><input type="text" name="CHARGE" value="1"/><input type="submit" value="Pay Now"/><form>

<?php
session_start();

$PPUSER = 'marshal_api1.clubcovert.com';
$PPPWD = 'LL6NV7TDRB9RFXQ5';
$PPSIG = 'ANc3YRaMB1Tgm9TediH0gENHB02JAksSKWD08wVNN3w3pwHqdBW8Im6y';
function url(){                 //PayPal Payment URL (TEST or LIVE)
    $url = "https://api-3t.sandbox.paypal.com/nvp"; //Test Server
    //$url = "https://api-3t.paypal.com/nvp"; //Live Server
    return $url;
}
function curlCall($nvp){        // Function for Curl Call to PayPal.
    $url = url();
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($nvp) );
    //echo http_build_query($nvp);  //Print String
    curl_setopt($ch, CURLOPT_URL, $url);
    $server_output = curl_exec($ch);
    mb_parse_str($server_output, $arr);
    return $arr;
}
if(isset($_POST['CHARGE'])){    // SetExpressCheckout Call
    $_SESSION['AMT'] = $_POST['CHARGE'];
    $nvp = array(
        'USER'    => $PPUSER,
        'PWD'   => $PPPWD,
        'SIGNATURE' => $PPSIG,
        'METHOD' => 'SetExpressCheckout',
        'VERSION' => '123',
        'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE',
        'PAYMENTREQUEST_0_AMT' => $_POST['CHARGE'],
        'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
        'RETURNURL' => 'http://marshalcurrier.com/paypal/ExpressCheckout/SetDo.php',
        'CANCELURL' => 'http://marshalcurrier.com/paypal/ExpressCheckout/SetDo.php',
    );
    $arr = curlCall($nvp);
    echo '<br><br>SetExpressCheckout Call to PayPal:<br><pre>';
    print_r ($nvp);
    echo '</pre>';
    echo 'SetExpressCheckout Server Response:<br><pre>';
    print_r ($arr);
    echo '</pre>';
    echo '<a href="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='.($arr['TOKEN']).'">Go To PayPal</a>';
}
if(isset($_GET['PayerID'])){    // DoExpressCheckoutPayment Call
    if (isset($_SESSION['AMT'])){
        $AMT = $_SESSION['AMT'];
    }else{
        $AMT = null;
    }
    $nvp = array(
        'METHOD' => 'DoExpressCheckoutPayment',
        'VERSION' => '123',
        'USER'    => $PPUSER,
        'PWD'   => $PPPWD,
        'SIGNATURE' => $PPSIG,
        'PAYERID' => $_GET['PayerID'],
        'TOKEN' => $_GET['token'],
        'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE',
        'PAYMENTREQUEST_0_AMT' => $AMT,
        'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
    );
    $arr = curlCall($nvp);
    echo '<br><br>DoExpressCheckoutPayment Call to PayPal:<br><pre>';
    print_r ($nvp);
    echo '</pre>';
    echo 'DoExpressCheckoutPayment Server Response:<br><pre>';
    print_r ($arr);
    echo '</pre>';
    unset($_SESSION['AMT']);
}
?>

这篇关于如何更好地整合Paypal的“立即购买"第三方卖家的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 13:40
查看更多