2017 © Pedro Peláez
 

library worldpay

WorldPay's PHP SDK for REST APIs

image

alvee/worldpay

WorldPay's PHP SDK for REST APIs

  • Tuesday, March 21, 2017
  • by Sheikh-Alvee
  • Repository
  • 3 Watchers
  • 2 Stars
  • 1,028 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 30 % Grown

The README.md

Laravel WorldPay Payment

Laravel WorldPay Payment is a simple package that helps you to process WorldPay direct credit card payments, create orders and get orders with your Laravel 5 projects., (*1)

Install

Install this package through Composer. To your composer.json file, add:, (*2)

``` bash "require": { "alvee/worldpay": "@dev" } $ composer update, (*3)


Or ``` bash $ composer require alvee/worldpay:@dev

Then add the service provider in config/app.php:, (*4)

``` bash Alvee\WorldPay\WorldPayServiceProvider::class,, (*5)


Finally Publish the package configuration by running this CMD ``` bash php artisan vendor:publish

Configuration

Now go to config/worldpay.php., (*6)

Set your SDK configuration., (*7)

``` bash server = sandbox or live, (*8)

Account credentials from developer portal [Test Account] sandbox.service = T_C_8b253cda-26d5-4917-bc39-6224c07d63tc sandbox.client = T_C_8b253cda-26d5-4917-bc39-6224c07d63tc, (*9)

[Live Account] live.service = T_C_8b253cda-26d5-4917-bc39-6224c07d63tc live.client = T_C_8b253cda-26d5-4917-bc39-6224c07d63tc, (*10)


## Usage Copy routes and paste in your route file ```php Route::get('/worldpay', function () { return view('vendor/alvee/worldpay'); }); Route::post('/charge', function (\Illuminate\Http\Request $request) { $token = $request->input( 'token' ); $total = 50; $key = config('worldpay.sandbox.client'); $worldPay = new Alvee\WorldPay\lib\Worldpay($key); $billing_address = array( 'address1' => 'Address 1 here', 'address2' => 'Address 2 here', 'address3' => 'Address 3 here', 'postalCode' => 'postal code here', 'city' => 'city here', 'state' => 'state here', 'countryCode' => 'GB', ); try { $response = $worldPay->createOrder(array( 'token' => $token, 'amount' => (int)($total . "00"), 'currencyCode' => 'GBP', 'name' => "Name on Card", 'billingAddress' => $billing_address, 'orderDescription' => 'Order description', 'customerOrderCode' => 'Order code' )); if ($response['paymentStatus'] === 'SUCCESS') { $worldpayOrderCode = $response['orderCode']; echo "<pre>"; print_r($response); } else { // The card has been declined throw new \Alvee\WorldPay\lib\WorldpayException(print_r($response, true)); } } catch (Alvee\WorldPay\lib\WorldpayException $e) { echo 'Error code: ' . $e->getCustomCode() . ' HTTP status code:' . $e->getHttpStatusCode() . ' Error description: ' . $e->getDescription() . ' Error message: ' . $e->getMessage(); // The card has been declined } catch (\Exception $e) { // The card has been declined echo 'Error message: ' . $e->getMessage(); } });

Change log

Please see CHANGELOG for more information what has changed recently., (*11)

Security

If you discover any security related issues, please email imran.sheikh834@gmail.com instead of using the issue tracker., (*12)

Credits

The Versions

21/03 2017

dev-master

9999999-dev https://github.com/Sheikh-Alvee/laravel-worldpay

WorldPay's PHP SDK for REST APIs

  Sources   Download

MIT

The Requires

 

laravel rest sdk payments worldpay alvee