Last active
December 2, 2022 09:37
-
-
Save mdobydullah/8b0399c5c6368c05d98239837a20fb19 to your computer and use it in GitHub Desktop.
Skrill IPN by Md Obydullah - Extension for LaraSkrill (https://github.com/mdobydullah/laraskrill)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by: Md Obydullah | |
* File: skrill-ipn.php | |
* Created: March 18, 2019 | |
* Description: If you want to receive and store data from 'status_url' instead of receiving email, then use this code to your IPN listener. | |
*/ | |
// routes - web | |
use App\Http\Controllers\SkrillPaymentController; | |
Route::post('/ipn', [SkrillPaymentController::class, 'ipn']); | |
/** | |
* Instant Payment Notification (IPN) from Skrill | |
*/ | |
public function ipn(Request $request) | |
{ | |
// skrill data - get more fields from Skrill Quick Checkout Integration Guide 7.9 (page 23) | |
$transaction_id = $request->transaction_id; | |
$mb_transaction_id = $request->mb_transaction_id; | |
$biller_email = $request->pay_from_email; | |
$amount = $request->amount; | |
$currency = $request->currency; | |
$status = $request->status; | |
$invoice_id = $request->invoice_id ?? null; // custom field | |
$order_from = $request->site_name ?? null; // custom field | |
$customer_id = $request->customer_id ?? null; // custom field | |
$customer_email = $request->customer_email ?? null; // custom field | |
// status message | |
if ($status == '-2') { | |
$status_message = 'Failed'; | |
} else if ($status == '2') { | |
$status_message = 'Processed'; | |
} else if ($status == '0') { | |
$status_message = 'Pending'; | |
} else if ($status == '-1') { | |
$status_message = 'Cancelled'; | |
} | |
// now store data to database | |
$skrill_ipn = new SkrillPayment(); | |
$skrill_ipn->transaction_id = $transaction_id; | |
$skrill_ipn->mb_transaction_id = $mb_transaction_id; | |
$skrill_ipn->invoice_id = $invoice_id; | |
$skrill_ipn->order_from = $order_from; | |
$skrill_ipn->customer_email = $customer_email; | |
$skrill_ipn->biller_email = $biller_email; | |
$skrill_ipn->customer_id = $customer_id; | |
$skrill_ipn->amount = $amount; | |
$skrill_ipn->currency = $currency; | |
$skrill_ipn->status = $status_message; | |
$skrill_ipn->created_at = Carbon::now(); | |
$skrill_ipn->updated_at = Carbon::now(); | |
$skrill_ipn->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment