Download the PHP package beinmedia/payment without Composer
On this page you can find all versions of the php package beinmedia/payment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download beinmedia/payment
More information about beinmedia/payment
Files in beinmedia/payment
Package payment
Short Description Laravel package to implement MyFatoorah, Tap, PayPal payment gatways and paypal recurring billing.
License proprietary
Homepage https://github.com/AlaaNaser95/payment_package
Informations about the package payment
payment_package
laravel package, that implements MyFatoorah, Tap , PayPal payment gatways and paypal recurring billing.
Features
- Laravel 5.7.* | 6.x | 7.x are supported.
Requirements
- laravel/framework 5.7.*
- PHP 7.2.5
Installation
Via Composer
Database Configuration
Update the .env configurations below:
Migrate:
Autoload:
Pyment Gatways
In order to make online payment gatway you need the following:
- Create the payment gatway link.
- Redirect the customer to the pyment link.
- User will pay.
- Recieve and validate the payment in the redirect URL you specified in the created payment gatway.
Paypal payment Gateway
Configuration
In the .evn file add Paypal credentials as the following example:
Usage
Methods:
- generatePaymentURL($paymentParameters)
This method will return the payment gateway url where the user should be redirected to in order to complete payment process.
You need to specify the amount , currency, where the user should be redirected after successful payment and the cancel url where the user shoul be redirected after failed or canceled payment.
-
isPayementExecuted() This method should be called in the redirect url to validate the payment.
-
isPayementExecuted($paymentId) This method validate the payment on specific payment_id.
- getPayment($payment_id) This method returns the related paypal payment details according to the given payment_id.
MyFatoorah payment Gateway
Configuration
In the .evn file add MyFatoorah api key as the following:
-
Add the api key from myFatoorah.
- If you are still testing and not live set the testing mode to true, else set it to false.
Usage
- getMyFatoorahPaymentMethods($currency,$iso_Code)
Returns all payment methods for your account with the related fees for each method according to the amount.
- generatePaymentURL($paymentParameters)
This method will return the payment gateway url where the user should be redirected to in order to complete payment process. bash bash bash { success: false, errors: [ { Name: "Amount", Error: "Insufficient Balance for vendor" } ], refund: null } bash use MyFatoorahPayment;
$refunds = MyFatoorahPayment::refundsList(); bash TAP_API_KEY = sk_test_XKokBfNWv6FIYuTMg5sLPjhJ bash FAWRY_TESTING_MODE=true bash FAWRY_TESTING_PUBLISHED_BASE_URL=https://789fbf71.ngrok.io bash */ bash bash use beinmedia\payment\Services\TapGateway; use beinmedia\payment\Parameters\SubscriptionCharge; use beinmedia\payment\Parameters\SubscriptionParameters; use beinmedia\payment\Parameters\SubscriptionTerm;
public function createSubscription(){ $term = new SubscriptionTerm(); $term->interval = "DAILY"; //("DAILY","YEARLY","MONTHLY",...etc) $term->period = 10; //How many times you want to charge the customer card $term->from = "2020-11-12 16:08:00"; "the start time for the charge $term->due = 0; $term->auto_renew = true; //true if you want to renew the subscription automatically $term->timezone = "Asia/Kuwait"; //the timezone for which the start time for ythe charge is specified
$charge = new SubscriptionCharge();
$charge->amount = 10; //thre amount to be charged
$charge->currency = "KWD"; //the currency of charge amount
$charge->description = "This is a test subscription";
$charge->metadata->track_id = "123456789910"; //A custom reference_id
$charge->reciept->email = true; //optional
$charge->reciept->sms = true; //optional
$charge->customer->id = 'cus_TS024820201200n5X50811060'; //customer_id returned from ChargeCard() method
$charge->source->id = 'card_CFlTu1311012JanD527931'; //card_id returned from ChargeCard() method
$charge->post->url = 'https://3b2429fb7e8b.ngrok.io/api/handle'; // post url where you want to be notified once a periodic payment is done.
//Create subscription and get the subscription_id and status
$data = new SubscriptionParameters($term,$charge);
$response = app(TapGateway::class)->createSubscription($data);
return response()->json(['response'=>$response]);
}
/ Response Eample { "status" : "active", "id" : "sub_43465789", } / bash use beinmedia\payment\Services\TapGateway;
public function handleRecurring(){ $response = app(TapGateway::class)->verifySubscriptionPayment();
//you can call this for more verificattion:
//$response = app(TapGateway::class)->isPaymentExecuted();
if($response->status == true){
return 'success';
}
return 'failed';
}
bash public function cancelSubscription(){ return app(TapGateway::class)->cancelSubscription('sub_Xr8s3820200900r5L51211982')]); } bash TAP_MARKETPLACE_API_KEY = sk_test_fEZYI3X1P7865rtsoGpbvw4qBm bash public function getSectors(){ return app(TapGateway::class)->getSectors($fileParameters); } bash public function createFile(){ $filename = time().'.'.request('file')->getClientOriginalExtension(); request('file')->move('storage', $filename); $filePath = "storage/$filename"; $purpose = 'identifcation_document'; $fileParameters = new FileParameters($filePath, $filename, $purpose); return app(TapGateway::class)->createFile($fileParameters); } bash
use beinmedia\payment\Services\TapGateway;
public function createBusiness(){
$civil_id = new \stdClass();
$civil_id->type = 'civil id';
$civil_id->issuing_country = 'KW';
$civil_id->issuing_date = '2020-01-01';
$civil_id->expiry_date = '2021-01-01';
$civil_id->images = ['file_773153834221826048']; //the file_id returned from createFile method as array
$civil_id->number = '295102500437'; //civil_id number
$contact_person = new ContactPerson('Alaa','Naser',new Phone('965','65080631'),'[email protected]', [$civil_id]);
$authorization = new \stdClass();
$authorization->type = 'authorized_signature';
$authorization->issuing_country = 'KW';
$authorization->issuing_date = '2020-01-01';
$authorization->expiry_date = '2021-01-01';
$authorization->images = ['file_773150399938293760']; //the file_id returned from createFile method as array
$authorization->number = '295102500437'; //authorized signature number
$license = new \stdClass();
$license->type = 'license';
$license->issuing_country = 'KW';
$license->issuing_date = '2020-01-01';
$license->expiry_date = '2021-01-01';
$license->images = ['file_773155798586355712']; //the file_id returned from createFile method as array
$license->number = '295102500437'; //commercial license number
$parameters = new BusinessParameters();
$parameters->business_name = 'test12121';
$parameters->type = 'corp';
$parameters->business_legal_name = 'test company for testing21212';
$parameters->business_country = 'KW';
$parameters->iban = 'erj54r73658647246928724'; //if iban is not added then swift_code and account_number are required
$parameters->swift_code = '1234567890'; //optinal if iban is provided
$parameters->account_number = 'acc_12345567890'; //optional if iban is provided
$parameters->contact_person = $contact_person;
$parameters->sector = ['sector_Vi2Dy828EgUeDVJ']; //returned from getSetors() method
$parameters->website = 'https://oktabletmenu1.com';
$parameters->documents = [$authorization, $license];
return app(TapGateway::class)->createBusiness($fileParameters);
- Add your webhook URL where you will get notified once a subscrbtion is canceled or recurring payment is completed (you can use ngrok for testing.
Create webhook
This webhook needs to be created only once while live to allow the package recieve notifications from paypal.
If you are using ngrok for testing you need to reset the related data at env file and recreate the webhook every 7 hours.
Usage
In order to create agreement for recurring payment you need the followuing:
- Create a plan to be assigned to the agreement. (Multible agreements can be assigned to the same plan)
- Create agreement and get the approval link where the user should be redirectred to accept that agreement.
- Execute agreement to process the agreement acceptance and validate agreement acceptance.
- Get the post notification whenever payment is completed for any agreement or whenever any agreement is cancelled, so you can give or remove licence to the payer.
Available Methods:
-
createPlan()
-
createAgreement($plan_id, $agreement_name, $agreement_description, $payer_info, $reference_id))
-
executeAgreement()
-
cancelAgreement($agreement_id)
-
cancelAgreement($agreement_id)
- checkAgreementPayed($agreement_id)
Getting Payment lists
At some point you may need to get all completed payments for the sake of statistics. The package offers this feature by getAllPayments()
method.
Usage
Samples
isPaymentExecuted();
Fawry
isPaymentExecuted();
- Paypal Recurring payment
Once Recurring payment is completed:
Once Recurring payment is cancelled: