2009-11-02 11 views
2

Désolé pour mon mauvais anglais.Saferpay Mise en œuvre

Je dois mettre en place un programme de paiement sécurisé dans mon projet. J'ai deux fichiers php pour l'instant

  1. checkout.php
  2. success.php

Quand j'exécuter le fichier checkout.php redirige vers success.php puis il affiche une erreur.

J'ai essayé d'enlever cette erreur mais je suis incapable de l'enlever. S'il vous plaît dites-moi des solutions par lesquelles je peux supprimer l'erreur.

Voici le code pour checkout.php

<? 
/* get the web server’s self URL */ 
$SERVER_NAME = 'localhost/'; 
$SCRIPT_NAME = 'saferpay/test.php'; 
$self_url = "http://" . $SERVER_NAME . $SCRIPT_NAME; 
//print_r($self_url); 
$self_url = substr($self_url, 0, strrpos($self_url, '/')) . "/"; 
//print_r($self_url); 
/* the hosting gateway URL to create pay init URL */ 
$gateway = "https://www.saferpay.com/hosting/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 */ 
//print_r($successlink); 
$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)); 
//print_r($payinit_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> 

et Success.php

<?php 
/* parse the query string and get DATA and SIGNATURE */ 
//print_r() 
$a = ($_SERVER['QUERY_STRING']); 
$array=array(); 
parse_str($a,$array); 
$DATA = $array['DATA']; 
$SIGNATURE = $array['SIGNATURE']; 
/* 
foreach($array as &$value){ 
    print_r($value); 
} 
*/ 
urldecode($DATA); 
urldecode($SIGNATURE); 

/* the hosting gateway URL to verify pay confirm */ 
$gateway = "https://www.saferpay.com/hosting/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)); 
     echo '<br/>'; 
     print_r($result); 

     /* $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 = "https://www.saferpay.com/hosting/PayComplete.asp"; 
     /* put it all together */ 
     $url = "$gateway?ACCOUNTID=$accountid&ID=".urlencode($ID). 
      "&TOKEN=".urlencode($TOKEN); 
     /* complete payment by hosting server */ 
     echo '<br/>'; 
     print_r($url); 
     echo '<br/>'; 
     $result = join("", file($url)); 
     print_r($result); 
     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; 
} 

?> 
+0

Et l'erreur serait ...? –

+0

Avez-vous trouvé une solution? J'ai le même problème avec l'intégration de saferpay. – belgiums

Répondre

2
$spPassword = "&spPassword=XAjc3Kna"; 

$url = "$gateway?ACCOUNTID=$accountid&ID=".urlencode($ID)."&TOKEN=".urlencode($TOKEN).$spPassword; 

XAjc3Kna est le mot de passe du compte de test

0

Si vous avez besoin d'un nettoyage mise en œuvre de la solution de sécurité pour php jeter un oeil à: https://github.com/payment/saferpay

+2

Fournir un exemple est plus utile tout simplement un lien vers une bibliothèque. – cpburnz