PHP code example of triverla / laravel-opay
1. Go to this page and download the library: Download triverla/laravel-opay 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/ */
triverla / laravel-opay example snippets
'providers' => [
...
Triverla\LaravelOpay\OpayServiceProvider::class,
...
]
'aliases' => [
...
'Opay' => Triverla\LaravelOPay\Facades\Opay::class,
...
]
return [
'base_url' => env('OPAY_BASE_URL', 'https://cashierapi.opayweb.com'),
'secret_key' => env('OPAY_SECRET_KEY', ''),
'public_key' => env('OPAY_PUBLIC_KEY', ''),
'merchant_id' => env('OPAY_MERCHANT_ID', '')
];
OPAY_BASE_URL=https://cashierapi.opayweb.com
OPAY_SECRET_KEY=XXXXXXXXXX
OPAY_PUBLIC_KEY=XXXXXXXXXX
OPAY_MERCHANT_ID=XXXXXXXXXX
...
use Triverla\LaravelOpay\Facades\Opay;
use Triverla\LaravelOpay\Exceptions\FailedRequestException;
...
use Triverla\LaravelOpay\Facades\Opay;
//Bank Endpoints
$response = Opay::bank()->countries();
$response = Opay::bank()->banks();
//Wallet
$response = Opay::wallet()->initiateTransaction(string $reference, string $userPhone, float $amount, string $userRequestIp, string $productName, string $productDesc, int $expiresAt = 30, string $currency = 'NGN');
$response = Opay::wallet()->authorizeTransaction(string $reference, string $orderNo, string $userPhone, string $pin);
$response = Opay::wallet()->sendOTP(string $reference, string $orderNo, string $payMethod);
$response = Opay::wallet()->verifyOTP(string $reference, string $orderNo, string $payMethod, string $otp);
$response = Opay::wallet()->closeTransaction(string $reference, string $orderNo);
$response = Opay::wallet()->initializeRefund(string $reference, string $refundReference, float $refundAmount, string $orderNo, string $currency = 'NGN');
$response = Opay::wallet()->verifyRefundStatus(string $reference, string $refundReference, float $refundAmount, string $refundOrderNo);
//Account
$response = Opay::account()->createUserAccount(string $phoneNumber, string $email, string $firstName, string $lastName, string $password, string $address, string $otp);
$response = Opay::account()->sendOTP(string $phoneNumber);
//Inquiry
$response = Opay::inquiry()->balance();
$response = Opay::inquiry()->validateOPayUser(string $phoneNumber);
$response = Opay::inquiry()->validateOPayMerchant(string $email);
$response = Opay::inquiry()->validateBankAccountNumber(string $bankCode, string $bankAccountNumber, string $countryCode = 'NG');
//Transfer
$response = Opay::transfer()->opayWallet(WalletTransferPayload $payload);
$response = Opay::transfer()->queryWalletTransferStatus(string $reference, string $orderNo);
$response = Opay::transfer()->opayWalletBatch(WalletTransferPayloadList $payloadList);
$response = Opay::transfer()->bankAccount(BankTransferPayload $payload);
$response = Opay::transfer()->queryBankTransferStatus(string $reference, string $orderNo);
$response = Opay::transfer()->bankAccountBatch(BankTransferPayloadList $payloadList);
//Transactions
$response = Opay::transaction()->initializeCardTransaction(string $reference, float $amount, string $firstName, string $lastName, string $customerEmail, string $cardNumber,
string $cardDateMonth, string $cardDateYear, string $cardCVC, string $return3dsUrl, string $bankAccountNumber,
string $bankCode, string $reason, string $callbackUrl, string $expiresAt, string $billingZip = null, string $billingCity = null,
string $billingAddress = null, string $billingState = null, string $billingCountry = null,
string $currency = 'NGN', string $country = 'NG');
$response = Opay::transaction()->initializeTokenTransaction(string $reference, float $amount, string $customerPhone, string $customerEmail, string $reason, string $callbackUrl, string $expiresAt, string $token,
string $currency = 'NGN', string $country = 'NG');
$response = Opay::transaction()->initializeBankAccountTransaction(string $reference, float $amount, string $customerPhone, string $return3dsUrl, string $bankAccountNumber,
string $bankCode, string $reason, string $bvn, string $dobDay, string $dobMonth, string $dobYear,
string $currency = 'NGN', string $country = 'NG');
$response = Opay::transaction()->checkTransactionStatus(string $reference, string $orderNo);
$response = Opay::transaction()->transactionInputPIN(string $reference, string $orderNo, string $pin);
$response = Opay::transaction()->transactionInputOTP(string $reference, string $orderNo, string $otp);
$response = Opay::transaction()->transactionInputPhone(string $reference, string $orderNo, string $phone);
$response = Opay::transaction()->transactionInputDob(string $reference, string $orderNo, string $dob);
$response = Opay::transaction()->initiateBankTransferTransaction(string $reference, string $userPhone, float $amount, string $userRequestIp, string $productName, string $productDesc, int $expiresAt = 30, string $currency = 'NGN');
$response = Opay::transaction()->getBankTransferTransactionStatus(string $reference, string $orderNo);
$response = Opay::transaction()->initiateUSSDTransaction(string $reference, string $userPhone, float $amount, string $userRequestIp, string $productName, string $productDesc, int $expiresAt = 30, string $currency = 'NGN');
$response = Opay::transaction()->getUSSDTransactionStatus(string $reference, string $orderNo);
//Bills
$response = Opay::bills()->bettingProviders();
$response = Opay::bills()->validate(string $serviceType, string $provider, string $customerId);
$response = Opay::bills()->bulkBills(BulkBillsListPayload $billsListPayload, string $callbackUrl, string $serviceType);
$response = Opay::bills()->bulkStatus(BulkStatusRequest $bulkStatusRequest, string $serviceType);
bash
php artisan vendor:publish --provider="Triverla\LaravelOpay\OpayServiceProvider"