脊髓炎911 2018-11-17
123! 2018-11-13
阳光政要 2018-11-6
※设为首页※
※收藏网站※
【用户登录】【用户注册】【在线反馈】【问你首页】
热门问答: 手机 考试 美国 奥运会 地震 计划 天气
∏百科知识网关于“a”的类似问题
·速珂电动的APP对于电池是如何管理的
·速珂APP现在有远程锁车的功能吗?
·速珂电动CU左车把那个AUTO按钮是
·速珂电动CU车的VA屏对比于普通TN
·速珂cu绑定APP的编码怎么看,车辆
·速珂cu钥匙丢了,能用APP能解锁吗
·速珂cuECU固件升级后车辆在手机a
·速珂app登录过一段时间账号自动下线
·速珂电动的VA屏和普通TN屏有什么区
·不是说SOCO CU屏幕都是VA智能
·速珂app里定位不准,电量也不对,是
·SOCO的这个app一定要下吗?
相关问题
·赶快找他治疗痉挛性斜颈去,早
·脖子前段时间睡觉的时候感觉落
·和女朋友亲吻的时候脖子歪了
·斜颈病这个病要打针还是吃药
·你知道斜颈病吗
·中医治疗斜颈病 治疗疑难杂症
相关知识
·重庆同济整形美容医院网站上线
·岁月如梭,我们慢慢淹没在历史
·爱情是什么,爱情是个X?
·分享下大家SEO的工作时间分
·tina的世界是什么样的?
·有不良信用记录可以申请信用卡
技术编程 更多..  
·天宫神八组合体16日…(11-16)
·刘翔复出跑出13秒1…(9-21)
·《建国大业》冲击票房…(9-18)
·两岁网球天才成英国新…(9-17)
·网易《魔兽世界》开服…(9-17)
·中国7月增持241亿…(9-17)
技术资讯 更多..  
·Win2003主机播…(7-9)
·使用无线路由器建设无…(7-5)
·一些无线猫的问题!(7-5)
·中国名牌与中国驰名商…(12-28)
·购买双色球选号秘诀(11-8)
·帮你吹散卫浴市场迷雾…(9-30)
用户积分排行榜 积 分
1 贾博浩 [状元] 134786
2 qq9060082是 [榜眼] 85094
3 yang999 [探花] 64572
4 yang989 51614
5 yang987 40878
6 草泥巴巴 27688
7 熊猫 21672
8 nangka01 18930
9 yang9898 13978
  
问题人气排行榜 浏览次数
1 超级QQ怎么用手机修 6675
2 淘宝规则频道左侧栏目 5865
3 游戏天龙八部中丐帮, 5075
4 插在电脑上的耳机一个 3781
5 二十四节气是怎么来的 3648
  
  信息阅读 收藏本页 我要提问 返回首页
Paypal在各种编程语言下的支付示例代码
浏览次数:1410次 知识来源:未知 发布时间:2008-10-17 贡献人:小小

ASP/VBScript


<%@LANGUAGE="VBScript"%>
<%

Dim authToken, txToken
Dim query
Dim objHttp
Dim sQuerystring
Dim sParts, iParts, aParts
Dim sResults, sKey, sValue
Dim i, result
Dim firstName, lastName, itemName, mcGross, mcCurrency

authToken = "Dc7P6f0ZadXW-U1X8oxf8_vUK09EHBMD7_53IiTT-CfTpfzkN0nipFKUPYy"
txToken = Request.Querystring("tx")

query = "cmd=_notify-synch&tx=" & txToken &
"&at=" & authToken

set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
' set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objHttp.open "POST", "http://www.paypal.com/cgi-bin/webscr", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send query

sQuerystring = objHttp.responseText

If Mid(sQuerystring,1,7) = "SUCCESS" Then
sQuerystring = Mid(sQuerystring,9)
sParts = Split(sQuerystring, vbLf)
iParts = UBound(sParts) - 1
ReDim sResults(iParts, 1)
For i = 0 To iParts
aParts = Split(sParts(i), "=")
sKey = aParts(0)
sValue = aParts(1)
sResults(i, 0) = sKey
sResults(i, 1) = sValue

Select Case sKey
Case "first_name"
firstName = sValue
Case "last_name"
lastName = sValue
Case "item_name"
itemName = sValue
Case "mc_gross"
mcGross = sValue
Case "mc_currency"
mcCurrency = sValue
End Select
Next

Response.Write("<p><h3>Your order has been received.</h3></p>")
Response.Write("<b>Details</b><br>")
Response.Write("<li>Name: " & firstName & " " & lastName & "</li>")
Response.Write("<li>Description: " & itemName & "</li>")
Response.Write("<li>Amount: " & mcCurrency & " " & mcGross & "</li>")
Response.Write("<hr>")
Else
'log for manual investigation
Response.Write("ERROR")
End If

%>

返回页首


Cold Fusion


<cfset
authToken="Dc7P6f0ZadXW-U1X8oxf8_vUK09EHBMD7_53IiTT-CfTpfzkN0nipFKUPYy">
<cfset txToken = url.tx>
<cfset query="cmd=_notify-synch&tx=" & txToken &
"&at=" & authToken>

<CFHTTP url="https://www.paypal.com/cgi-bin/webscr?#query#"
method="GET"
resolveurl="false">
</CFHTTP>

<cfif left(#cfhttp.FileContent#,7) is "SUCCESS">
<cfloop list="#cfhttp.FileContent#"
index="curLine"
delimiters="#chr(10)#">
<cfif listGetAt(curLine,1,"=") is "first_name">
<cfset firstName=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "last_name">
<cfset lastName=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "item_name">
<cfset itemName=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "mc_gross">
<cfset mcGross=listGetAt(curLine,2,"=")>
</cfif>
<cfif listGetAt(curLine,1,"=") is "mc_currency">
<cfset mcCurrency=listGetAt(curLine,2,"=")>
</cfif>
</cfloop>

<cfoutput>
<p><h3>Your order has been received.</h3></p>
<b>Details</b><br>
<li>Name: #firstName# #lastName#</li>
<li>Description: #itemName#</li>
<li>Amount: #mcCurrency# #mcGross#</li>
<hr>
</cfoutput>

<cfelse>
ERROR
</cfif>

返回页首


PERL




#!/usr/bin/perl -w


###

#

# PayPal PDT (Payment Data Transfer) CGI

#

###


use strict;

use CGI qw(:all unescape);

use CGI::Carp qw(fatalsToBrowser);


# These modules are required to make the secure HTTP request to PayPal.

use LWP::UserAgent;

use Crypt::SSLeay;


###

# CUSTOMIZE THIS: This is the seller's Payment Data Transfer authorization token.

#                  Replace this with the PDT token in "Website Payment Preferences"

under your account.

###


my $auth_token = "VUDGCF2EA5huqlEqbSLPbg0JY3F-Pokyf-99r2sZWPR4x7GkWZEa-zIG49O";


sub done_text {

    return (p('Your transaction has been completed, and a receipt for your purchase has been
emailed to you. You may log into your account at <a
href="https://www.paypal.com/">www.paypal.com</a> to view details of this transaction.'),
end_html());

}


print header(), start_html("Thank you for your purchase!");


# Set up the secure request to the PayPal server to fetch the transaction info

my $paypal_server = "www.paypal.com";


my $transaction = param("tx");


if (not $transaction) {

    print (h2("The transaction ID was not found."), done_text());


    exit();

}


my $paypal_url = "https://$paypal_server/cgi-bin/webscr";

my $query = join("&", "cmd=_notify-synch", "tx=$transaction", "at=$auth_token");


my $user_agent = new LWP::UserAgent;

my $request = new HTTP::Request("POST", $paypal_url);


$request->content_type("application/x-www-form-urlencoded");

$request->content($query);

# Make the request


my $result = $user_agent->request($request);


if ($result->is_error) {

    print(h1("An error was encountered"), br(), p("An error was encountered contacting the PayPal
server:"),

        $result->error_as_HTML, done_text());

    exit();

}


# Decode the response into individual lines and unescape any HTML escapes

my @response = split("\n", unescape($result->content));


# The status is always the first line of the response.

my $status = shift @response;


if ($status eq "SUCCESS") {

    # success

    my %transaction;


    foreach my $response_line (@response) {

      my ($key, $value) = split "=", $response_line;

      $transaction{$key} = $value;

    }

    # These are only some of the transaction details available; there are others.

    # You should print all the transaction details appropriate.

    print(h2("Here are the details of your purchase:"),

      ul(li("Customer Name: " . $transaction{'first_name'} . " " . $transaction{'last_name'}),

          li("Item: " . $transaction{'item_name'}),

          li("Amount: " . $transaction{'payment_gross'})));


} elsif ($status eq "FAIL") {

    print(h2("Unable to retrieve transaction details."));

    # failure

} else {

    # unknown error

    print(h2("Error retrieving transaction details."));

}


print done_text();



返回页首





PHP


<?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';

$tx_token = $_GET['tx'];
$auth_token = "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0";
$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}

// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];

echo ("<p><h3>Thank you for your purchase!</h3></p>");

echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}

}

fclose ($fp);

?>

您的交易已完成,而且您所购买的物品收据也已经通过电子邮件发送给您。<br> 您可以前往<a href='
https://www.paypal.com'>;www.paypal.com</a>登录到自己的账户以查看该交易的详情。<br>


标签:知识:Paypal在各种编程语言下的支付示例代码

∏百科知识网关于“a”的类似知识
·tina的世界是什么样的?
·母亲节(Mothers Day)
·A5站长论坛开始启动第四届搜索引擎优化大赛之博百优!
·关于奥斯卡和柯达剧院(Kodak Theatre)
·A记录、MX记录、CNAME记录和NS记录等域名管理常识
·请问什么是TD-CDMA网络?
·新型涡扇支线飞机ARJ21的性能怎样?
·什么是无线CMWAP
·APEC的相关知识!
·Paypal在各种编程语言下的支付示例代码
·Apache+php+mysql在windows下的安装与配置图解(最新版)
·2008-09赛季NBA10月份季前赛赛程表
比特币亨氏饼干上火牙疼吃什么药脚扭伤肿了怎么办亨氏果泥电竞馆
Copyright By weniwa.com(问你哇)©2008- 2018 All Rights Reserved.
[问你哇(Ask You Wa)知识问答网]问答改变生活—特别合作伙伴和网站赞助:链接平台
客服QQ:982182402 客服Email:weniwa@qq.com 知识问答网-问 答改变生活,知识改变命运!
哇,问你哇,知识问答网,六年问答与您相伴
www.weniwa.com
渝ICP备08004120-1号