PHP code example of girosolution / girocheckout-sdk

1. Go to this page and download the library: Download girosolution/girocheckout-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

girosolution / girocheckout-sdk example snippets



use girosolution\GiroCheckout_SDK\GiroCheckout_SDK_Request;

$merchantID = xxx;
$projectID = xxx;
$projectPassword = xxx;

$request = new GiroCheckout_SDK_Request('giropayTransaction');
$request->setSecret($projectPassword);
$request->addParam('merchantId',$merchantID)
	->addParam('projectId',$projectID)
	->addParam('merchantTxId',1234567890)
	->addParam('amount',100)
	->addParam('currency','EUR')
	->addParam('purpose','Beispieltransaktion')
	->addParam('bic','TESTDETT421')
	->addParam('info1Label','Ihre Kundennummer')
	->addParam('info1Text','0815')
	->addParam('urlRedirect','https://www.my-domain.de/girocheckout/redirect-giropay')
	->addParam('urlNotify','https://www.my-domain.de/girocheckout/notify-giropay')
	//the hash field is auto generated by the SDK
	->submit();

if($request->requestHasSucceeded()) {
  $request->getResponseParam('rc');
  $request->getResponseParam('msg');
  $request->getResponseParam('reference');
  $request->getResponseParam('redirect');
  $request->redirectCustomerToPaymentProvider();
}
/* if the transaction did not succeed, update your local system, get the responsecode and notify the customer */
else {
  $request->getResponseParam('rc');
  $request->getResponseParam('msg');
  $request->getResponseMessage($request->getResponseParam('rc'),'DE');
}


use girosolution\GiroCheckout_SDK\GiroCheckout_SDK_Request;

$projectPassword = xxx;

$notify = new GiroCheckout_SDK_Notify('giropayTransaction');
$notify->setSecret($projectPassword);
$notify->parseNotification($_GET);

if($notify->paymentSuccessful()) {
  $notify->getResponseParam('gcReference');
  $notify->getResponseParam('gcMerchantTxId');
  $notify->getResponseParam('gcBackendTxId');
  $notify->getResponseParam('gcAmount');
  $notify->getResponseParam('gcCurrency');
  $notify->getResponseParam('gcResultPayment');

  if($notify->avsSuccessful()) {
    $notify->getResponseParam('gcResultAVS');
  }
  
  $notify->sendOkStatus();
  exit;
}
else {
  $notify->getResponseParam('gcReference');
  $notify->getResponseParam('gcMerchantTxId');
  $notify->getResponseParam('gcBackendTxId');
  $notify->getResponseParam('gcResultPayment');

  $notify->sendOkStatus();
  exit;
}

apache_setenv( "GIROCHECKOUT_SERVER", "https://other.endpoint.de" );

$Config = GiroCheckout_SDK_Config::getInstance();
$Config->setConfig('CURLOPT_PROXY', 'http://myproxy.com'):
$Config->setConfig('CURLOPT_PROXYPORT', 9090);
$Config->setConfig('CURLOPT_PROXYUSERPWD', 'myuser:mypasswd');

define('__GIROCHECKOUT_SDK_DEBUG__',true);

$request->setSslCertFile('path/to/certificate');

$request->setSslVerifyDisabled();
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php