Bonsoir tout le monde!

Comment allez-vous?

Si je vous écris aujourd'hui, c'est qu'après avoir fait de multiples recherches sur Internet je ne trouve pas de solution à mon problème, et j'en profite pour vous poser quelques questions! :p

J'ai consulté le tutoriel de Grafikart concernant le "Paypal Express Checkout".

Cependant, lorsque je modifie une simple valeur sur la page principale (index.php), bam: La page s'affiche avec l'array et donc une erreur, pourquoi?

Si je laisse par défaut: "count"=> 2

Rien à signaler, la page s'affiche parfaîtement, cependant si j'ai le malheur de modifier le "2" par un "1", j'obtiens une erreur.

J'ai fais quelques modifications mineures sur la page, et, franchement je ne vois pas vraiment pourquoi j'obtiens les erreurs.

Voici le débug:

array (size=9)
  'TIMESTAMP' => string '2015-11-22T19:46:30Z' (length=20)
  'CORRELATIONID' => string '997274046061d' (length=13)
  'ACK' => string 'Failure' (length=7)
  'VERSION' => string '74.0' (length=4)
  'BUILD' => string '18308778' (length=8)
  'L_ERRORCODE0' => string '10413' (length=5)
  'L_SHORTMESSAGE0' => string 'Transaction refused because of an invalid argument. See additional error messages for details.' (length=94)
  'L_LONGMESSAGE0' => string 'The totals of the cart item amounts do not match order amounts.' (length=63)
  'L_SEVERITYCODE0' => string 'Error' (length=5)

Erreur

Et voici ma page index.php:

<?php
require 'paypal.php';
$products = array(
    array(
        "name" => "Pack 1",
        "price"=> 10.0,
        "count"=> 1
    ),
    array(
        "name"=> "Pack 2",
        "price"=> 25.0,
        "count"=> 2
    )
);
$total = 61.0;
$totalttc = 73.0;
$paypal = "#";
$paypal = new Paypal();
$params = array(
    'RETURNURL' => 'http://localhost/Lab/process.php',
    'CANCELURL' => 'http://localhost/Lab/cancel.php',
    'PAYMENTREQUEST_0_AMT' => $totalttc, // TTC
    'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR', // La monnaie utilisée, $ != €
    'PAYMENTREQUEST_0_ITEMAMT' => $totalttc,
);

foreach($products as $k => $product)
{
    $params["L_PAYMENTREQUEST_0_NAME$k"] = $product['name'];
    $params["L_PAYMENTREQUEST_0_DESC$k"] = '';
    $params["L_PAYMENTREQUEST_0_AMT$k"] = $product['price'];
    $params["L_PAYMENTREQUEST_0_QTY$k"] = $product['count'];
}

$response = $paypal->request('SetExpressCheckout', $params);

if($response)
{
    $paypal = 'https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=' . $response['TOKEN'];
}
else
{
    var_dump($paypal->errors);
    die('Erreur');
}
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
    </head>
    <body>
        <div class="navbar navbar-fixed">
          <div class="navbar-inner">
            <div class="container">
              <a class="btn btn-navbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </a>
              <a class="brand" href="#">Paypal Express checkout</a>
            </div>
          </div>
        </div>

        <div class="container-fluid main">

          <div class="row-fluid">
            <div class="span12">
                <table class="table table-striped table-hover">
                    <thead>
                      <tr>
                        <th>Produit</th>
                        <th>Quantité</th>
                        <th>Prix HT</th>
                        <th>Prix TTC</th>
                      </tr>
                    </thead>
                    <tbody>
                        <?php foreach ( $products as $k => $product ): ?>
                            <tr>
                                <td><?= $product['name']; ?></td>
                                <td><?= $product['count']; ?></td>
                                <td><?= $product['price']; ?> €</td>
                                <td><?= $product['price'] * 1.196; ?> €</td>
                            </tr>
                        <?php endforeach ?>
                        <tr>
                            <td colspan="2"></td>
                            <td><strong>Total</strong></td>
                            <td><?= $total; ?> €</td>
                        </tr>
                    </tbody>
                 </table>

                 <p>
                    <a href="<?= $paypal; ?>" class="btn btn-primary">Payer</a>
                 </p>
            </div>
          </div>

        </div>

    </body>
</html>

Merci à ceux qui pourraient m'éclairer!

Bonne soirée.

1 réponse


Le problème me semble assez explicite 10 + 2*25 ne font pas 61 et encore moins 73 ^^
Pour appliquer une taxe utilise PAYMENTREQUEST_0_TAXAMT

https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/