PHP code example of digitickets / omnipay.paymentsense
1. Go to this page and download the library: Download digitickets/omnipay.paymentsense 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/ */
digitickets / omnipay.paymentsense example snippets
// Gateway setup
$gateway = $this->gatewayFactory('PaymentSense');
// Pluigns specific parameters
gateway->setMerchantId('00000001');
$gateway->setPassword('#asPdasd_asd');
$gateway->setPreSharedKey('asdqweasdzxc');
// Create or fetch your product transaction
$transaction = $this->createTransaction($request);
// Get the data ready for the payment
// Please note that even off-site gateways make use of the CreditCard object,
// because often you need to pass customer billing or shipping details through to the gateway.
$cardData = $transaction->asOmniPay;
$itemsBag = $this->requestItemsBag($request);
// Authorize request
$request = $gateway->purchase(array(
'amount' => $transaction->amount,
'currency' => $transaction->currency,
'card' => $cardData,
'returnUrl' => $this->generateCallbackUrl(
'PaymentSense',
$transaction->id
),
'transactionId' => $transaction->id,
'description' => $transaction->description,
'items' => $itemsBag,
));
// Send request
$response = $request->send();
// Process response
$this->processResponse($response);
// Fetch transaction details
$transaction = Transaction::findOrFail($transactionId);
// Gateway setup
$gateway = $this->gatewayFactory('PaymentSense');
// Pluigns specific parameters
gateway->setMerchantId('00000001');
$gateway->setPassword('#asPdasd_asd');
$gateway->setPreSharedKey('asdqweasdzxc');
// Get the data ready to complete the payment. Since this is typically a stateless callback
// we need to first retrieve our original product transaction details
$params = [
"amount" => $transaction->amount,
"currency" => $transaction->currency,
'returnUrl' => $this->generateCallbackUrl(
'PaymentSense',
$transaction->id
),
'transactionId' => $transaction->id,
'transactionReference' => $transaction->ref,
];
// Complete purchase request
$request = $gateway->completePurchase($params);
// Send request
$response = $request->send();
// Process response
$this->processResponse($response);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.