PHP code example of sfolador / heidipay
1. Go to this page and download the library: Download sfolador/heidipay 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/ */
sfolador / heidipay example snippets
return [
'api_url' => 'https://sandbox-origination.heidipay.com/',
'merchant_key' => 'your merchant key',
];
$product = CreditInitProduct::from(sku: null, name: "Test", quantity: 1, price: 100, imageThumbnailUrl: null, imageOriginalUrl: null, description: "");
$amount = Amount::from(currency: "EUR", amount: 100, format: AmountFormat::DECIMAL);
$products = [$product];
$consumer = Customer::from(email: "[email protected] ", title: null, firstname: "simone", lastname: "folador", dateOfBirth: null, contactNumber: null, companyName: null, residence: null);
$webhooks = Webhooks::from(
success: "https://www.example.com/heidi-success",
failure: "https://www.example.com/heidi-failure",
cancel: "https://www.example.com/heidi-cancel",
status: "https://www.example.com/heidi-status",
mappingScheme: "default"
);
$webhooks->setToken(str()->random(32));
$contractInitDto = ContractInitDto::from(amount: $amount, customer: $consumer, webhooks: $webhooks, products: $products);
$hp =\Sfolador\Heidipay\Facades\Heidipay::contract($contractInitDto);
dd($hp->dto());
/**
*
* Sfolador\HeidiPaySaloon\Dto\Response\ContractDto {#479 ▼ // routes/web.php:201
+action: "REDIRECT"
+redirect_url: "https://sandbox-checkout.heidipay.com?otc=f8952b8c-919d-4d7f-a54c-70027d5f0a55&fallback=https%3A%2F%2Flaravel-10.test%2Fheidi-failure"
+external_contract_uuid: "b3df38c4-6cdb-4224-adb9-6878922721ff"
+application_uuid: "07ef7950-3189-4a11-be6e-98b1d88a9340"
}
*/
bash
php artisan vendor:publish --tag="heidipay-config"