payfabric / payment-gateway-provider
1.0.0
2023-12-27 06:45 UTC
Requires
- globalpayments/php-sdk: ^11.0
Requires (Dev)
- phpstan/phpstan: ^0.12.69
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
README
Installation
composer require payfabric/payment-gateway-provider
Examples
<?php /** * Autoload SDK. */ $autoloader = __DIR__ . '/vendor/autoload.php'; if ( is_readable( $autoloader ) ) { include_once $autoloader; } use GlobalPayments\Api\PaymentMethods\CreditCardData; use GlobalPayments\Api\ServiceConfigs\Gateways\PorticoConfig; use GlobalPayments\Api\ServicesContainer; use GlobalPayments\Api\Entities\Address; $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); $_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING); $config = new PorticoConfig(); $config->secretApiKey = 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A'; ServicesContainer::configureService($config); // Manual Entry credit card data or a credit card token $card = new CreditCardData(); $card->number = "4111111111111111"; $card->expMonth = "12"; $card->expYear = "2025"; $card->cvn = "123"; //$card->token = $_GET['token_value']; //$address = new Address(); //$address->streetAddress1 = $_GET["Address"]; //$address->city = $_GET["City"]; //$address->state = $_GET["State"]; //$address->postalCode = preg_replace('/[^0-9]/', '', $_GET["Zip"]); //$address->country = "United States"; try { $response = $card->charge(15) ->withCurrency('USD') ->withAllowDuplicates(true) ->execute(); echo "<b>Transaction Success your transaction Id is: </b>" . $response->transactionId; } catch (Exception $e) { echo 'Failure: ' . $e->getMessage(); exit; }