1. Go to this page and download the library: Download givepay/givepay-gateway 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/ */
givepay / givepay-gateway example snippets
use \GivePay\Gateway\GivePayGatewayClient;
use \GivePay\Gateway\Transactions\Address;
use \GivePay\Gateway\Transactions\Card;
use \GivePay\Gateway\Transactions\Sale;
use \GivePay\Gateway\Transactions\TerminalType;
// Get configuration information
$client_id = getenv("CLIENT_ID");
$client_secret = getenv("CLIENT_SECRET");
$merchant_id = getenv("MERCHANT_ID");
$terminal_id = getenv("TERMINAL_ID");
// Create the credit/debit card object
$card = Card::withCard(
"411111111111", // Test Visa PAN
"331", // CVV/CVV2
"09", // Expiration month (MM)
"23" // Expiration year (YY)
);
// Collect the payer's billing address
$payer_address = new Address(
"1 N Main St.",
"",
"Fort Worth",
"TX",
"76104"
);
$sale = new Sale(
17.00, // Transaction amount in dollars
TerminalType::$ECommerce,
$payer_address,
"[email protected]", // Billing email address
"5555555555", // Billing phone number
$card
);
// Create the client. You may use this globally within your application
$client = new GivePayGatewayClient(
$client_id, $client_secret
);
// Make the transaction
$transaction_result = $client->chargeAmount($merchant_id, $terminal_id, $sale);
if (true == $transaction_result->getSuccess()) {
echo "Transaction ID: " . $transaction_result->getTransactionId();
} else {
echo "Transaction failed with message: " . $transaction_result->getErrorMessage();
}
use \GivePay\Gateway\GivePayGatewayClient;
use \GivePay\Gateway\Transactions\V0id;
use \GivePay\Gateway\Transactions\TerminalType;
/**
* @var GivePayGatewayClient $client The client
*/
$client;
/**
* @var string $merchant_id Your merchant ID
*/
$merchant_id;
/**
* @var string $terminal_id Your terminal ID
*/
$terminal_id;
// The transaction ID of the transaction to void
$transaction_id = "<transaction id>";
$void = new V0id(
TerminalType::$ECommerce,
$transaction_id // The transaction ID
);
// Make the void transaction
$void_result = $client->voidTransaction(
$transaction_id,
$merchant_id,
$terminal_id
);
if (true == $void_result->getSuccess()) {
echo "Transaction ID: " . $void_result->getTransactionId();
} else {
echo "Transaction failed with message: " . $void_result->getErrorMessage();
}
use \GivePay\Gateway\GivePayGatewayClient;
use \GivePay\Gateway\Transactions\Address;
use \GivePay\Gateway\Transactions\Card;
use \GivePay\Gateway\Transactions\Sale;
use \GivePay\Gateway\Transactions\TerminalType;
/**
* @var GivePayGatewayClient $client The client
*/
$client;
/**
* @var string $merchant_id Your merchant ID
*/
$merchant_id;
/**
* @var string $terminal_id Your terminal ID
*/
$terminal_id;
/**
* @var Address $payer_address The payer's billing address
*/
$payer_address;
// Create the credit/debit card object
$card_to_store = Card::withCard(
"411111111111", // Test Visa PAN
"331", // CVV/CVV2
"09", // Expiration month (MM)
"23" // Expiration year (YY)
);
// Store the card in the gateway and retrieve a payment token string
$token = $client->storeCard(
$merchant_id,
$terminal_id,
$card_to_store
);
// Create a card from a token string
$payment_card = Card::withToken($token);
// Create the Sale request
$sale = new Sale(
17.50,
TerminalType::$ECommerce,
$payer_address,
"[email protected]",
"5555555555",
$payment_card
);
// Make the transaction
$sale_result = $client->chargeAmount(
$merchant_id,
$terminal_id,
$sale
);
if (true == $sale_result->getSuccess()) {
echo "Transaction ID: " . $sale_result->getTransactionId();
} else {
echo "Transaction failed with message: " . $sale_result->getErrorMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.