vicky-dev-9 / payments-api
1.1.3
2023-08-21 20:50 UTC
Requires
- php: ^8.2
- srmklive/paypal: ~3.0
- stripe/stripe-php: ^10.19
This package is auto-updated.
Last update: 2024-10-21 23:08:52 UTC
README
Laravel Usage
Create file config/payments_api.php
with content:
return [ 'paypal' => [ 'client_id' => env('PAYPAL_CLIENT_ID', ''), 'client_secret' => env('PAYPAL_CLIENT_SECRET', ''), 'app_id' => env('PAYPAL_APP_ID', ''), 'mode' => env('PAYPAL_MODE', ''), ], 'stripe' => [ 'secret_key' => env('STRIPE_SECRET_KEY', null), 'publishable_key' => env('STRIPE_PUBLISHABLE_KEY', null), ], 'liqpay' => [ 'private_key' => env('LIQPAY_PRIVATE_KEY', null), 'public_key' => env('LIQPAY_PUBLIC_KEY', null), ], ];
For get orderId use:
public function __construct( protected PaymentFactory $paymentFactory ) { } public function getOrderId(int $system) { $paymentService = $this->paymentFactory->getInstance( Payments::from($system), config('payments_api') ); $makePaymentDTO = new MakePaymentDTO( 15.25, Currency::USD ); $orderId = $paymentService->createPayment($makePaymentDTO); return $orderId; }
For get payment result info use:
public function __construct( protected PaymentFactory $paymentFactory ) { } public function getPaymentResult(int $system, string $paymentId) { $paymentService = $this->paymentFactory->getInstance( Payments::from($system), config('payments_api') ); $paymentResult = $paymentService->getPaymentInfo($paymentId); return $paymentResult;