PHP code example of elad / cardcom

1. Go to this page and download the library: Download elad/cardcom 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/ */

    

elad / cardcom example snippets


use Cardcom\Iframe;
use Cardcom\Invoice;
use Cardcom\InvoiceProduct;
use Cardcom\Setting;


$iframe = new Iframe();
$iframe->setPrice(15);
$iframe->docTypeToCreate = 400;
//$iframe->setGoodUrl("http://secure.Cardcom.co.il/DealWasSuccessful.aspx");
$iframe->setGoodUrl("http://cardcom.try/response2.php");
$iframe->setErrorUrl("http://cardcom.try/error.php");

$invoice = new Invoice("elad gasner", "[email protected]");
$product = new InvoiceProduct("מעיל", 5, 1);
$product2 = new InvoiceProduct("מעיל רוח", 5, 2);
$invoice->setProducts([$product, $product2]);
$iframe->setInvoice($invoice);

$iframe = new Iframe();
$iframe->setPrice(15);
$iframe->setInvoice($invoice);
//you can any property from the cardcom api
$iframe->docTypeToCreate = 400;

$iframe->setGoodUrl("http://cardcom.try/response2.php");
$iframe->setErrorUrl("http://cardcom.try/error.php");

// get iframe link
$result = $iframe->getIframe();



if ($result->isSuccess()) {
  $link =  $result->getUrl();
}else{
	$result->getError();
}