SlideShare a Scribd company logo
Saferpay Checkout Page - PHP Sample (Hosting)
<?
/* get the web server’s self URL */
$self_url = "http://" . $SERVER_NAME . $SCRIPT_NAME;
$self_url = substr($self_url, 0, strrpos($self_url, '/')) . "/";

/* the hosting gateway URL to create pay init URL */
$gateway = "http://support.saferpay.de/scripts/CreatePayInit.asp";

/* set the payment attributes */
$accountid = "99867-94913159"; /* saferpay account id */
$orderid = "4711"; /* use your own order or basket identifier */
$amount = "1295"; /* 12.95 */
$currency = "EUR";
$description = urlencode(""Test Purchase - saferpay PHP sample"");
$successlink = $self_url."success.php"; /* return URL if payment successful */
$faillink = $self_url."failed.php";     /* return URL if payment failed */
$backlink = $self_url."checkout.php";   /* return URL if user cancelled */

/* put all attributes together and create hosting URL */
$attributes =
"ACCOUNTID=$accountid&AMOUNT=$amount&CURRENCY=$currency&DESCRIPTION=$descripti
on&SUCCESSLINK=$successlink&FAILLINK=$faillink&BACKLINK=$backlink";
$url = "$gateway?$attributes";

/* get the PayInit URL from the hosting server */
$payinit_url = join("", file($url));
?>

<html><head>
<title>Saferpay Checkout Sample for PHP (Hosting)</title>
<script src="http://www.saferpay.com/OpenSaferpayScript.js"></script>
</head><body>
<h1>saferpay Checkout Sample Page for PHP (Hosting)</h1>
<h2>Order ID: <? print $orderid; ?><br></h2>
<h2>Click <a href="<? print $payinit_url; ?>"
onclick="OpenSaferpayTerminal('<? print $payinit_url; ?>', this, 'LINK');">
here</a>
to purchase for <? printf("%s %d.%02d", $currency, $amount / 100, $amount %
100); ?>!
</h2>
</body>
</html>
Saferpay Success Page and Capture - PHP Sample (Hosting)
<?

/* parse the query string and get DATA and SIGNATURE */
parse_str($QUERY_STRING);
urldecode($DATA);
urldecode($SIGNATURE);

/* the hosting gateway URL to verify pay confirm */
$gateway = "http://support.saferpay.de/scripts/VerifyPayConfirm.asp";
$accountid = "99867-94913159"; /* saferpay account id */

/* put it all together */
$url = "$gateway?DATA=".urlencode($DATA)."&SIGNATURE=".urlencode($SIGNATURE);

/* verify pay confirm message at hosting server */
$result = join("", file($url));

/* check if result is OK... */
if (substr($result, 0, 3) == "OK:")
{
      print("Your Order has been successfully processed.");

     parse_str(substr($result, 3));
     /* $ID    = saferpay transaction identifier, store in DBMS */
     /* $TOKEN = token of transaction, store in DBMS */


     /***** Optional: Finalize payment by capture of transaction *****/

     /* the hosting gateway URL to complete payment */
     $gateway = "http://support.saferpay.de/scripts/PayComplete.asp";
     /* put it all together */
     $url = "$gateway?ACCOUNTID=$accountid&ID=".urlencode($ID).
            "&TOKEN=".urlencode($TOKEN);
     /* complete payment by hosting server */
     $result = join("", file($url));

     if (substr($result, 0, 2) == "OK")
           print("Capture has been done successfully");
     else
           print("Error: retry capture later...");
}
else /* ...or if an error happened */
{
      print $result;
}

More Related Content

What's hot

Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答
琛琳 饶
 
Rails GUI Development with Ext JS
Rails GUI Development with Ext JSRails GUI Development with Ext JS
Rails GUI Development with Ext JS
Martin Rehfeld
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
Marcus Ramberg
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
Tudor Constantin
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
Anatoly Sharifulin
 
TICT #11
TICT #11 TICT #11
TICT #11
azman_awan9
 
M.php
M.phpM.php
Codigo
CodigoCodigo
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
Peter Baylies
 
How to count money using PHP and not lose money
How to count money using PHP and not lose moneyHow to count money using PHP and not lose money
How to count money using PHP and not lose money
Piotr Horzycki
 
TICT #13
TICT #13TICT #13
TICT #13
azman_awan9
 
Php talk
Php talkPhp talk
Php talk
Jamil Ramsey
 
Urban Sprawl - European vision
Urban Sprawl - European vision Urban Sprawl - European vision
Urban Sprawl - European vision
Emm. Verigos
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
Hung-yu Lin
 
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
Yusuke Wada
 
Php Tutorial | Introduction Demo | Basics
 Php Tutorial | Introduction Demo | Basics Php Tutorial | Introduction Demo | Basics
Php Tutorial | Introduction Demo | Basics
Shubham Kumar Singh
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
Yusuke Wada
 

What's hot (17)

Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答Perl调用微博API实现自动查询应答
Perl调用微博API实现自动查询应答
 
Rails GUI Development with Ext JS
Rails GUI Development with Ext JSRails GUI Development with Ext JS
Rails GUI Development with Ext JS
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
RESTful web services
RESTful web servicesRESTful web services
RESTful web services
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
TICT #11
TICT #11 TICT #11
TICT #11
 
M.php
M.phpM.php
M.php
 
Codigo
CodigoCodigo
Codigo
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
How to count money using PHP and not lose money
How to count money using PHP and not lose moneyHow to count money using PHP and not lose money
How to count money using PHP and not lose money
 
TICT #13
TICT #13TICT #13
TICT #13
 
Php talk
Php talkPhp talk
Php talk
 
Urban Sprawl - European vision
Urban Sprawl - European vision Urban Sprawl - European vision
Urban Sprawl - European vision
 
2014 database - course 2 - php
2014 database - course 2 - php2014 database - course 2 - php
2014 database - course 2 - php
 
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
 
Php Tutorial | Introduction Demo | Basics
 Php Tutorial | Introduction Demo | Basics Php Tutorial | Introduction Demo | Basics
Php Tutorial | Introduction Demo | Basics
 
Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
 

Similar to Saferpay Checkout Page - PHP Sample (Hosting)

Kphpug beginners-2
Kphpug beginners-2Kphpug beginners-2
Kphpug beginners-2
Hisateru Tanaka
 
Twitter codeigniter library
Twitter codeigniter libraryTwitter codeigniter library
Twitter codeigniter library
Navaneeswar Reddy
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
Vic Metcalfe
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
Andréia Bohner
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
Andréia Bohner
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
Nate Abele
 
Mobile Patrons: Better Services on the Go (For Techie)
Mobile Patrons: Better Services on the Go (For Techie)Mobile Patrons: Better Services on the Go (For Techie)
Mobile Patrons: Better Services on the Go (For Techie)
Vincci Kwong
 
Daily notes
Daily notesDaily notes
Daily notes
meghendra168
 
Php mail program
Php mail programPhp mail program
Php mail program
pyingkodi maran
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
Hugo Hamon
 
Xmpp prebind
Xmpp prebindXmpp prebind
Xmpp prebind
Syed Arshad
 
An introduction to Laravel Passport
An introduction to Laravel PassportAn introduction to Laravel Passport
An introduction to Laravel Passport
Michael Peacock
 
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Francois Marier
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
Dave Cross
 
Unit 3 - for php application Sessions.pptx
Unit 3  -  for php  application Sessions.pptxUnit 3  -  for php  application Sessions.pptx
Unit 3 - for php application Sessions.pptx
mythili213835
 
CakePHP workshop
CakePHP workshopCakePHP workshop
CakePHP workshop
Walther Lalk
 
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Francois Marier
 
Google 2
Google 2Google 2
Google 2
Sy Buenavista
 
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 TokyoIntroduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Masahiro Nagano
 
Barcelona Developers Conference 2011
Barcelona Developers Conference 2011Barcelona Developers Conference 2011
Barcelona Developers Conference 2011
PayPal
 

Similar to Saferpay Checkout Page - PHP Sample (Hosting) (20)

Kphpug beginners-2
Kphpug beginners-2Kphpug beginners-2
Kphpug beginners-2
 
Twitter codeigniter library
Twitter codeigniter libraryTwitter codeigniter library
Twitter codeigniter library
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Mobile Patrons: Better Services on the Go (For Techie)
Mobile Patrons: Better Services on the Go (For Techie)Mobile Patrons: Better Services on the Go (For Techie)
Mobile Patrons: Better Services on the Go (For Techie)
 
Daily notes
Daily notesDaily notes
Daily notes
 
Php mail program
Php mail programPhp mail program
Php mail program
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
Xmpp prebind
Xmpp prebindXmpp prebind
Xmpp prebind
 
An introduction to Laravel Passport
An introduction to Laravel PassportAn introduction to Laravel Passport
An introduction to Laravel Passport
 
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
Building Persona: federated and privacy-sensitive identity for the Web (LCA 2...
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Unit 3 - for php application Sessions.pptx
Unit 3  -  for php  application Sessions.pptxUnit 3  -  for php  application Sessions.pptx
Unit 3 - for php application Sessions.pptx
 
CakePHP workshop
CakePHP workshopCakePHP workshop
CakePHP workshop
 
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
 
Google 2
Google 2Google 2
Google 2
 
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 TokyoIntroduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
 
Barcelona Developers Conference 2011
Barcelona Developers Conference 2011Barcelona Developers Conference 2011
Barcelona Developers Conference 2011
 

More from webhostingguy

File Upload
File UploadFile Upload
File Upload
webhostingguy
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
webhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
webhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
webhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
webhostingguy
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
webhostingguy
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
webhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreementwebhostingguy
 
Notes8
Notes8Notes8
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
webhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
webhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
webhostingguy
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
webhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
webhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
webhostingguy
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
webhostingguy
 

More from webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
 
Notes8
Notes8Notes8
Notes8
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
 

Saferpay Checkout Page - PHP Sample (Hosting)

  • 1. Saferpay Checkout Page - PHP Sample (Hosting) <? /* get the web server’s self URL */ $self_url = "http://" . $SERVER_NAME . $SCRIPT_NAME; $self_url = substr($self_url, 0, strrpos($self_url, '/')) . "/"; /* the hosting gateway URL to create pay init URL */ $gateway = "http://support.saferpay.de/scripts/CreatePayInit.asp"; /* set the payment attributes */ $accountid = "99867-94913159"; /* saferpay account id */ $orderid = "4711"; /* use your own order or basket identifier */ $amount = "1295"; /* 12.95 */ $currency = "EUR"; $description = urlencode(""Test Purchase - saferpay PHP sample""); $successlink = $self_url."success.php"; /* return URL if payment successful */ $faillink = $self_url."failed.php"; /* return URL if payment failed */ $backlink = $self_url."checkout.php"; /* return URL if user cancelled */ /* put all attributes together and create hosting URL */ $attributes = "ACCOUNTID=$accountid&AMOUNT=$amount&CURRENCY=$currency&DESCRIPTION=$descripti on&SUCCESSLINK=$successlink&FAILLINK=$faillink&BACKLINK=$backlink"; $url = "$gateway?$attributes"; /* get the PayInit URL from the hosting server */ $payinit_url = join("", file($url)); ?> <html><head> <title>Saferpay Checkout Sample for PHP (Hosting)</title> <script src="http://www.saferpay.com/OpenSaferpayScript.js"></script> </head><body> <h1>saferpay Checkout Sample Page for PHP (Hosting)</h1> <h2>Order ID: <? print $orderid; ?><br></h2> <h2>Click <a href="<? print $payinit_url; ?>" onclick="OpenSaferpayTerminal('<? print $payinit_url; ?>', this, 'LINK');"> here</a> to purchase for <? printf("%s %d.%02d", $currency, $amount / 100, $amount % 100); ?>! </h2> </body> </html>
  • 2. Saferpay Success Page and Capture - PHP Sample (Hosting) <? /* parse the query string and get DATA and SIGNATURE */ parse_str($QUERY_STRING); urldecode($DATA); urldecode($SIGNATURE); /* the hosting gateway URL to verify pay confirm */ $gateway = "http://support.saferpay.de/scripts/VerifyPayConfirm.asp"; $accountid = "99867-94913159"; /* saferpay account id */ /* put it all together */ $url = "$gateway?DATA=".urlencode($DATA)."&SIGNATURE=".urlencode($SIGNATURE); /* verify pay confirm message at hosting server */ $result = join("", file($url)); /* check if result is OK... */ if (substr($result, 0, 3) == "OK:") { print("Your Order has been successfully processed."); parse_str(substr($result, 3)); /* $ID = saferpay transaction identifier, store in DBMS */ /* $TOKEN = token of transaction, store in DBMS */ /***** Optional: Finalize payment by capture of transaction *****/ /* the hosting gateway URL to complete payment */ $gateway = "http://support.saferpay.de/scripts/PayComplete.asp"; /* put it all together */ $url = "$gateway?ACCOUNTID=$accountid&ID=".urlencode($ID). "&TOKEN=".urlencode($TOKEN); /* complete payment by hosting server */ $result = join("", file($url)); if (substr($result, 0, 2) == "OK") print("Capture has been done successfully"); else print("Error: retry capture later..."); } else /* ...or if an error happened */ { print $result; }