sfolador/heidipay

Use HeidiPay services easy with Laravel

1.0 2023-04-17 20:02 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require sfolador/heidipay

You can publish the config file with:

php artisan vendor:publish --tag="heidipay-config"

This is the contents of the published config file:

return [
    'api_url' => 'https://sandbox-origination.heidipay.com/',
    'merchant_key' => 'your merchant key',
];

Usage

 $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: "sfolador@gmail.com", 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"
}
 */

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.