Ejemplo n.º 1
0
<?php

/**
 * @file
 * Get the Sermepa feedback from GET + POST parameters.
 */
// Load settings and class.
include_once "settings.php";
include_once "../src/SermepaException.php";
include_once "../src/SermepaInterface.php";
include_once "../src/Sermepa.php";
use CommerceRedsys\Payment\Sermepa;
try {
    // Create a new instance and initialize it.
    $gateway = new Sermepa($settings['titular'], $settings['merchantCode'], $settings['terminal'], $settings['merchantPassword'], $settings['environment']);
    // Get response data.
    if ($feedback = $gateway->getFeedback()) {
        // Check if the signatures are valid.
        if ($gateway->checkFeedback($feedback)) {
            // Load the payment from ???? and store the necessary values.
            $payment_id = $gateway->getFeedbackValue('Ds_MerchantData');
            $response_code = (int) $gateway->getFeedbackValue('Ds_Response');
            if ($response_code <= 99) {
                // Transaction valid. Save your data here.
                $transaction_remote_id = $gateway->getFeedbackValue('Ds_AuthorisationCode');
                $transaction_message = $gateway->handleResponse($response_code);
            } else {
                // Transaction no valid. Save your data here.
                $transaction_message = $gateway->handleResponse($response_code);
            }
        } else {
Ejemplo n.º 2
0
<?php

/**
 * @file
 * Get the Sermepa feedback from GET + POST parameters.
 */
// Load settings and class.
include_once "settings.php";
include_once "../src/SermepaException.php";
include_once "../src/SermepaInterface.php";
include_once "../src/Sermepa.php";
use CommerceRedsys\Payment\Sermepa;
try {
    // Create a new instance and initialize it.
    $gateway = new Sermepa($settings['name'], $settings['merchantCode'], $settings['terminal'], $settings['merchantPassword'], $settings['environment']);
    // Get response data.
    if (!($feedback = $gateway->getFeedback())) {
        // No feedback response.
        return;
    }
    $encoded_parameters = $feedback['Ds_MerchantParameters'];
    $decoded_parameters = $gateway->decodeMerchantParameters($encoded_parameters);
    $feedback_signature = $feedback['Ds_Signature'];
    $composed_signature = $gateway->composeMerchantSignatureFromFeedback($encoded_parameters);
    // Check if the signatures are valid.
    if ($feedback_signature != $composed_signature) {
        // Or...
        //if (!$gateway->areValidSignatures($feedback)) {
        // Signatures don't match.
        return;
    }
Ejemplo n.º 3
0
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="content">
<?php 
// Load settings and class.
include_once "settings.php";
include_once "../src/SermepaException.php";
include_once "../src/SermepaInterface.php";
include_once "../src/Sermepa.php";
use CommerceRedsys\Payment\Sermepa;
try {
    // Create a new instance and initialize it.
    $gateway = new Sermepa($settings['name'], $settings['merchantCode'], $settings['terminal'], $settings['merchantPassword'], $settings['environment']);
    // Load the payment from ???? and set the necessary values.
    $amount = 15050;
    $currency = 978;
    $payment_id = 1;
    $product_description = 'My example!';
    $consumer_language = '001';
    $transaction_type = 0;
    $feedback_url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . 'getFeedback.php';
    $ko_url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . 'ko.php';
    $ok_url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . 'ok.php';
    $gateway->setAmount($amount)->setCurrency($currency)->setOrder(substr(date('ymdHis') . 'Id' . $payment_id, -12, 12))->setProductDescription($product_description)->setConsumerLanguage($consumer_language)->setMerchantData($payment_id)->setTransactionType($transaction_type)->setMerchantURL($feedback_url)->setUrlKO($ko_url)->setUrlOK($ok_url);
    // Get the trasaction fields for the sermepa form.
    $parameters = $gateway->composeMerchantParameters();
    if ($parameters) {
        $languages = $gateway->getAvailableConsumerLanguages();