Comments (15)
thanks a lot! that helped!
from laravel-crypto-payment-gateway.
Please see https://github.com/victorybiz/laravel-crypto-payment-gateway#the-callback
Ensure to define your Callback Controller, Callback Route and IPN (Instant Payment Notification).
Update the published config/laravel-crypto-payment-gateway.php
and set value for hook_ipn
key to hook IPN (Instant Payment Notification) function to the static class method defined.
// config/laravel-crypto-payment-gateway.php
/**
* Hook IPN (Instant payment notification) to the following static class method.
* In this static class method, you can add your custom logic and give value to the user once your confirmed payment box status.
* You can also add payment notification logic.
* This can be a static class method defined anywhere in your application.
* This can also be static method/action defined in controller class but route must not be defined for the action.
*
* The Static Method Definition in your class:
* @param \Victorybiz\LaravelCryptoPaymentGateway\Models\CryptoPaymentModel $cryptoPaymentModel
* @param array $payment_details
* @param string $box_status
* @return bool
* public static function ipn($cryptoPaymentModel, $payment_details, $box_status)
* {
* // Add your custom logic here.
* return true;
* }
*
* Example: [\Victorybiz\LaravelCryptoPaymentGateway\Http\Controllers\CryptoPaymentController::class, 'ipn']
*/
'hook_ipn' => [\App\Http\Controllers\Payment\PaymentController, 'ipn'],
from laravel-crypto-payment-gateway.
yes, I've made all steps on clean Laravel 9 and still have this error
from laravel-crypto-payment-gateway.
Check your routes/web.php
if you defined the routes to the controller in the error.
// routes/web.php
// You can protect the 'payments.crypto.pay' route with `auth` middleware to allow access by only authenticated user
Route::match(['get', 'post'], '/payments/crypto/pay', Victorybiz\LaravelCryptoPaymentGateway\Http\Controllers\CryptoPaymentController::class)
->name('payments.crypto.pay');
// You you need to create your own callback controller and define the route below
// The callback route should be a publicly accessible route with no auth
// However, you may also exclude the route from CSRF Protection by adding their URIs to the $except property of the VerifyCsrfToken middleware.
Route::post('/payments/crypto/callback', [App\Http\Controllers\Payment\PaymentController::class, 'callback'])
->withoutMiddleware(['web', 'auth']);
from laravel-crypto-payment-gateway.
Hi @victorybiz I still get this error despite having set my routes.
from laravel-crypto-payment-gateway.
@isaacongoma Can you please share the content of your routes where it was declared and the hook_ipn in your config?
from laravel-crypto-payment-gateway.
`Route::group(['prefix' => 'payment'], function(){
Route::any('/{gateway}/pay', [PaymentController::class,'payment_initialize']);
// stripe
Route::any('/stripe/create-session', [StripePaymentController::class,'create_checkout_session'])->name('stripe.get_token');
Route::get('/stripe/success', [StripePaymentController::class,'success'])->name('stripe.success');
Route::get('/stripe/cancel', [StripePaymentController::class,'cancel'])->name('stripe.cancel');
// paypal
Route::get('/paypal/success', [PaypalPaymentController::class,'success'])->name('paypal.success');
Route::get('/paypal/cancel', [PaypalPaymentController::class,'cancel'])->name('paypal.cancel');
//sslcommerz
Route::any('/sslcommerz/success', [SSLCommerzPaymentController::class,'success'])->name('sslcommerz.success');
Route::any('/sslcommerz/fail', [SSLCommerzPaymentController::class,'fail'])->name('sslcommerz.fail');
Route::any('/sslcommerz/cancel', [SSLCommerzPaymentController::class,'cancel'])->name('sslcommerz.cancel');
//paystack
Route::any('/paystack/callback', [PaystackPaymentController::class,'return'])->name('paystack.return');
//paytm
Route::any('/paytm/callback', [PaytmPaymentController::class,'callback'])->name('paytm.callback');
//flutterwave
Route::any('/flutterwave/callback', [FlutterwavePaymentController::class,'callback'])->name('flutterwave.callback');
// razorpay
Route::post('razorpay/payment', [RazorpayPaymentController::class,'payment'])->name('razorpay.payment');
// mpesa
Route::any('/validate', [MpesaController::class, 'validation']);
Route::any('/confirm', [MpesaController::class, 'confirmation']);
Route::any('/results', [MpesaController::class, 'results']);
Route::any('/register', [MpesaController::class, 'register']);
Route::any('/timeout', [MpesaController::class, 'timeout']);
Route::any('/reconcile', [MpesaController::class, 'reconcile']);
// crypto
Route::any('/crypto/pay', CryptoPaymentController::class)->name('payments.crypto.pay');
Route::any('/crypto/callback', [CryptoPaymentController::class, 'callback']);
});`
from laravel-crypto-payment-gateway.
` 'hook_ipn' => [App\Http\Controllers\Payment\CryptoPaymentController::class, 'ipn'],
/**
* Default coin
*/
'default_coin' => 'bitcoin',`
from laravel-crypto-payment-gateway.
Hi @victorybiz I have shared the snip of the code
from laravel-crypto-payment-gateway.
The callback url is working fine but am having a problem once I hit https://thinkorganic.co.ke/payment/crypto/pay
from laravel-crypto-payment-gateway.
PaymentController.php
`class PaymentController extends Controller
{
public function payment_initialize(Request $request, $gateway){
session()->put('redirect_to', $request->redirect_to);
session()->put('amount', $request->amount);
session()->put('payment_method', $request->payment_method);
session()->put('payment_type', $request->payment_type);
session()->put('user_id', $request->user_id);
session()->put('order_code', $request->order_code);
session()->put('seller_package_id', $request->seller_package_id ?? null);
if($gateway == 'paypal'){
return ( new PaypalPaymentController )->index();
}
elseif ($gateway == 'stripe') {
return ( new StripePaymentController )->index();
}
elseif ($gateway == 'sslcommerz') {
return ( new SSLCommerzPaymentController )->index();
}
elseif ($gateway == 'paystack') {
return ( new PaystackPaymentController )->index($request);
}
elseif ($gateway == 'flutterwave') {
return ( new FlutterwavePaymentController )->index();
}
elseif ($gateway == 'paytm') {
return ( new PaytmPaymentController )->index();
}
elseif ($gateway == 'razorpay') {
return ( new RazorpayPaymentController )->index();
}
elseif ($gateway == 'mpesa') {
return ( new MpesaController )->index();
}
elseif ($gateway == 'crypto') {
return (new CryptoPaymentController)->index($request);
}
}`
from laravel-crypto-payment-gateway.
Hello @victorybiz
from laravel-crypto-payment-gateway.
@isaacongoma
Sorry for the late response, I have been busy with work.
For seamless configuration, define the following route with the route map to the CryptoPaymentController.
// routes/web.php
// You can protect the 'payments.crypto.pay' route with `auth` middleware to allow access by only authenticated user
Route::match(['get', 'post'], '/payments/crypto/pay', Victorybiz\LaravelCryptoPaymentGateway\Http\Controllers\CryptoPaymentController::class)
->name('payments.crypto.pay');
You will need to post data via ajax with data like the following to the above route to generate the payment link;
data: {
amountUSD: 20.50,
userID: 1,
orderID: 101,
redirect: 'https://domain.com/redirect-url',
},
Alternatively you can also generate the payment link from your controller or anywhere in your app by call LaravelCryptoPaymentGateway::startPaymentSession($paymentData)
e.g
// This could be in a controller method or livewire component method
use Victorybiz\LaravelCryptoPaymentGateway\LaravelCryptoPaymentGateway;
$payment_url = LaravelCryptoPaymentGateway::startPaymentSession([
'amountUSD' => $validatedData['amount'], // OR 'amount' when sending BTC value
'orderID' => $product->id,
'userID' => Auth::user()->id,
'redirect' => url()->full(),
]);
// redirect to the payment page
redirect()->to($payment_url);
Then you can have your own call back like below.
// You need to create your own callback controller and define the route below
// The callback route should be a publicly accessible route with no auth
// However, you may also exclude the route from CSRF Protection by adding their URIs to the $except property of the VerifyCsrfToken middleware.
Route::post('/payments/crypto/callback', [App\Http\Controllers\Payment\PaymentController::class, 'callback'])
->withoutMiddleware(['web', 'auth']);
Take a minute or two to go through the README step by step, you will get it set up without any issues.
from laravel-crypto-payment-gateway.
Thanks so much for your support
from laravel-crypto-payment-gateway.
Please see https://github.com/victorybiz/laravel-crypto-payment-gateway#the-callback Ensure to define your Callback Controller, Callback Route and IPN (Instant Payment Notification).
Update the published
config/laravel-crypto-payment-gateway.php
and set value forhook_ipn
key to hook IPN (Instant Payment Notification) function to the static class method defined.// config/laravel-crypto-payment-gateway.php /** * Hook IPN (Instant payment notification) to the following static class method. * In this static class method, you can add your custom logic and give value to the user once your confirmed payment box status. * You can also add payment notification logic. * This can be a static class method defined anywhere in your application. * This can also be static method/action defined in controller class but route must not be defined for the action. * * The Static Method Definition in your class: * @param \Victorybiz\LaravelCryptoPaymentGateway\Models\CryptoPaymentModel $cryptoPaymentModel * @param array $payment_details * @param string $box_status * @return bool * public static function ipn($cryptoPaymentModel, $payment_details, $box_status) * { * // Add your custom logic here. * return true; * } * * Example: [\Victorybiz\LaravelCryptoPaymentGateway\Http\Controllers\CryptoPaymentController::class, 'ipn'] */ 'hook_ipn' => [\App\Http\Controllers\Payment\PaymentController, 'ipn'],
/** 'hook_ipn' => [\App\Http\Controllers\Payment\PaymentController::class, 'ipn'], */
from laravel-crypto-payment-gateway.
Related Issues (9)
- Your requirements could not be resolved to an installable set of packages. HOT 2
- Route Not defined HOT 2
- Action is not definited HOT 1
- Can not install in laravel 8.0!!
- Invalid Order ID - . Max: 50 symbols HOT 1
- No hint path defined for [laravel-crypto-payment-gateway]. HOT 1
- Some column were not filled
- Not working with Laravel 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-crypto-payment-gateway.