Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PaymentsV4 implementation #34

Open
wants to merge 111 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
940e84c
Add payments V4 api version and example code for it
andra-simionov Mar 23, 2020
ea4e782
Format code
andra-simionov Mar 23, 2020
3fb504b
Add logic for PaymentsV4 authorization flow
andra-simionov Mar 23, 2020
76da5af
Merge branch 'add_api_v4' into payments_v4
andra-simionov Mar 23, 2020
8837f3f
Merge branch 'add_api_v4' into payments_v4
andra-simionov Apr 3, 2020
ec8620c
Merge branch 'add_api_v4' into payments_v4
andra-simionov Apr 8, 2020
3d4075c
Remove unnecessary $aluUrlHostname field
andra-simionov Apr 8, 2020
4a4f537
Add case for PaymentAPI v4
andra-simionov Apr 8, 2020
a38478d
Remove logic for signature computation and headers to HttpClient
andra-simionov Apr 8, 2020
fdab894
Handle case when authorization response cannot be decoded
andra-simionov Apr 8, 2020
0a43ca6
Merge branch 'add_api_v4' into payments_v4
andra-simionov Apr 8, 2020
2f61f33
Merge branch 'add_api_v4' into payments_v4
andra-simionov Apr 8, 2020
e769178
refactor namespaces
spopawdodo Apr 8, 2020
960e108
refactor namespace
spopawdodo Apr 8, 2020
1bae0c9
add AirlineInfo object to PaymentsV4
spopawdodo Apr 8, 2020
5b1f0e3
change is_null to null comparison
spopawdodo Apr 8, 2020
7a76a6a
add AirlineInfoData in RequestBuilder.php
spopawdodo Apr 8, 2020
61f34b3
Merge remote-tracking branch 'origin/payments_v4' into payments_v4
spopawdodo Apr 8, 2020
6ecb734
add StoredCredentialsData.php
spopawdodo Apr 8, 2020
66a9376
set date format and api version
spopawdodo Apr 8, 2020
dc0db6a
make entities final
spopawdodo Apr 8, 2020
baa0c6d
remove unused hashService param
spopawdodo Apr 8, 2020
c9c106a
Merge remote-tracking branch 'origin/add_api_v4' into payments_v4
spopawdodo Apr 10, 2020
fe3a471
Merge branch 'add_api_v4' into payments_v4
andra-simionov Apr 10, 2020
b57dc22
add FieldMapper
spopawdodo Apr 10, 2020
20ec0ed
add ResponseBuilderException
spopawdodo Apr 10, 2020
6afcc33
add exception handling
spopawdodo Apr 10, 2020
f4cae66
Merge remote-tracking branch 'origin/payments_v4' into payments_v4
spopawdodo Apr 10, 2020
509e37d
reformat code
spopawdodo Apr 10, 2020
06c1fac
reformat code
spopawdodo Apr 10, 2020
6a5d7ff
reformat code
spopawdodo Apr 10, 2020
adb92ab
add ConnectionException.php
spopawdodo Apr 10, 2020
b7ea7ba
Merge remote-tracking branch 'origin/add_api_v4' into payments_v4
spopawdodo Apr 22, 2020
731f946
add RequestBuilderTest.php
spopawdodo Apr 22, 2020
a4660e8
add AirlineInfo and StoredCredentials fields
spopawdodo Apr 22, 2020
2816a2f
remove TimeSpentTypingOwner/Card params
spopawdodo Apr 22, 2020
24b1c1e
remove TimeSpentTypingOwner/Card fields
spopawdodo Apr 22, 2020
836f72c
add HashServiceTest.php
spopawdodo Apr 22, 2020
3ba1880
reformat code
spopawdodo Apr 22, 2020
2232527
Merge remote-tracking branch 'origin/add_api_v4' into payments_v4
spopawdodo Apr 22, 2020
a9e4104
map 'message' to 'RETURN_MESSAGE'
spopawdodo Apr 24, 2020
3e186b0
update phpDocs
spopawdodo Apr 24, 2020
c9c1ea9
add ResponseParserTest.php
spopawdodo Apr 24, 2020
b13ce36
reformat code
spopawdodo Apr 24, 2020
519908e
split jsonString
spopawdodo Apr 24, 2020
e2a0fe2
remove todo
spopawdodo Apr 24, 2020
0c38292
correct attributions
spopawdodo Apr 24, 2020
3cb7816
reformat code
spopawdodo Apr 27, 2020
02432da
remove unused class
spopawdodo Apr 27, 2020
8b561e8
add PaymentsV4Test.php
spopawdodo Apr 27, 2020
e743f98
add ApplePayToken entity
spopawdodo Apr 27, 2020
186622c
add ThreeDSecure.php
spopawdodo Apr 27, 2020
c5df83e
make classes final
spopawdodo Apr 27, 2020
0bc38eb
add ApplyPayToken to Request class
spopawdodo Apr 27, 2020
5225906
add RequestBuilderException.php for cases where there are both card a…
spopawdodo Apr 27, 2020
0937147
update imports and phpDocs
spopawdodo Apr 27, 2020
624cb7c
manage RequestBuilderException
spopawdodo Apr 27, 2020
5759638
add example scripts for PaymentsApi
spopawdodo Apr 27, 2020
481384e
add Marketplace object
spopawdodo Apr 27, 2020
6c93323
update applePayToken: add ApplePayToken.php and ApplePayTokenHeader.p…
spopawdodo Apr 27, 2020
7a76335
remove unused cardToken
spopawdodo Apr 27, 2020
0ac4cfe
add marketplace classes and example
spopawdodo Apr 27, 2020
cce3417
remove var_dump
spopawdodo Apr 27, 2020
1d3c62c
add marketplace param for testing
spopawdodo Apr 27, 2020
beb1292
reformat code
spopawdodo Apr 27, 2020
ac44a54
set Mpi params via setters instead of constructor
spopawdodo Apr 27, 2020
4bb2681
add ThreeDs params to alu/request
spopawdodo Apr 27, 2020
64d3626
remove unused import
spopawdodo Apr 27, 2020
8aaae4b
add ThreeDs params to RequestBuilderTest.php
spopawdodo Apr 27, 2020
a9d27ca
add ThreeDSecure mapping
spopawdodo Apr 27, 2020
68cb4b8
reformat code
spopawdodo Apr 27, 2020
9c51efa
Merge remote-tracking branch 'origin/master' into payments_v4
spopawdodo Apr 29, 2020
2fc65ce
add PaymentsV4.php to factory class
spopawdodo Apr 30, 2020
d7b0463
modify implemented class
spopawdodo Apr 30, 2020
dddd396
remove RequestBuilderException.php and create separate cases for each…
spopawdodo Apr 30, 2020
1be2b3c
add applePayToken
spopawdodo Apr 30, 2020
8d93e09
change url from local to secure
spopawdodo Apr 30, 2020
58ac76f
remove unused functions and add constants for parameter name
spopawdodo Apr 30, 2020
6d22024
remove owner param from MerchantTokenData.php
spopawdodo Apr 30, 2020
1ae9e4c
add usePaymentPage param in Alu/Order.php
spopawdodo Apr 30, 2020
5c93ba5
add communicationLanguage param to Alu/User.php
spopawdodo Apr 30, 2020
f44bc5a
remove PosCode from request and delete MerchantData.php class
spopawdodo Apr 30, 2020
65031c8
add airlineName param to Alu/AirlineInfo flightSegment array
spopawdodo Apr 30, 2020
9b8dd37
add RequestBuilderException.php for cases where there are too many pa…
spopawdodo Apr 30, 2020
6b408ec
remove comment
spopawdodo Apr 30, 2020
77c5e1b
remove ResponseBuilderException.php and all its uses
spopawdodo Apr 30, 2020
9363923
reformat code
spopawdodo Apr 30, 2020
acab041
add airlineName
spopawdodo May 4, 2020
0ea3aa5
move airlineName param at the end of flight segments array
spopawdodo May 4, 2020
50f349b
update date format
spopawdodo May 7, 2020
fe87c19
change date format for V4 requests
spopawdodo May 7, 2020
42a473a
have HttpClient throw HttpClientException.php instead of Authorizatio…
spopawdodo May 7, 2020
3b4634b
refactor directory structure of entities and update namespaces
spopawdodo May 7, 2020
6dc46f2
add break
spopawdodo May 7, 2020
5f5e7e6
change date format
spopawdodo May 7, 2020
a995610
change null comparison to isset() so there won't be notices
spopawdodo May 7, 2020
4d23b1b
change cardExpirationDate
spopawdodo May 7, 2020
687e257
reformat code
spopawdodo May 7, 2020
b0a238a
remove mockHashService
spopawdodo May 11, 2020
7e5642e
add isset() for all response fields
spopawdodo May 15, 2020
8cfb866
update ApplePay example script
spopawdodo May 18, 2020
ee3fc81
reformat code
spopawdodo May 18, 2020
9ff4a6c
Add more details on marketplace script example
andra-simionov May 27, 2020
d6290e1
Small fix
andra-simionov May 27, 2020
43c057d
create separate methods for setting payment instrument and airlineInfo
spopawdodo Jun 16, 2020
774997e
delete method 'buildResponse' and change it with 'build'
spopawdodo Jun 16, 2020
b293a16
throw RequestBuilderException when json_encode returns false
spopawdodo Jun 16, 2020
aa4c813
remove createArray function and the processResponse method directly
spopawdodo Jun 16, 2020
353fabc
make HashService::generateSignature() method more general by adding $…
spopawdodo Jun 16, 2020
ad69dbd
remove todo: array_walk_recursive cannot unset values
spopawdodo Jun 16, 2020
783941b
Merge branch 'master' into payments_v4
drealecs Jul 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions examples/basicExampleV4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
<?php
/**
* Include composer class autoloader
*/
require_once dirname(__FILE__) . '/../vendor/autoload.php';


use PayU\Alu\Billing;
use PayU\Alu\Card;
use PayU\Alu\Client;
use PayU\Alu\Delivery;
use PayU\Alu\MerchantConfig;
use PayU\Alu\Order;
use PayU\Alu\Product;
use PayU\Alu\Request;
use PayU\Alu\User;
use PayU\Alu\Exceptions\ConnectionException;
use PayU\Alu\Exceptions\ClientException;
use PayU\PaymentsApi\PaymentsV4\PaymentsV4;

/**
* Create configuration with params:
*
* Merchant Code - Your PayU Merchant Code
* Secret Key - Your PayU Secret Key
* Platform - RO | RU | UA | TR | HU
*/
//todo modify merchantCode back to MERCHANT_CODE
$cfg = new MerchantConfig('PAYU_2', 'SECRET_KEY', 'RO');

/**
* Create user with params:
*
* User IP - User's IP address
* User Time - Time of user computer - optional
*
*/
$user = new User('127.0.0.1');

/**
* Create new order
*/
$order = new Order();

/**
* Setup the order params
*
* Full params available in the documentation
*/

/**
* todo remove $merchantOrderRef when pushing to master
* also date format has been modified
*/

$merchantOrderRef = strval(rand(1000, 9999));
$order->withBackRef('http://path/to/your/returnUrlScript')
->withOrderRef($merchantOrderRef)
//->withOrderRef('MerchantOrderRef')
->withCurrency('RON')
->withOrderDate(gmdate('Y-m-d\TH:i:sP'))
->withOrderTimeout(1000)
->withPayMethod('CCVISAMC');

/**
* Create new product
*/
$product = new Product();

/**
* Setup the product params
*
* Full params available in the documentation
*/
$product->withCode('PCODE01')
->withName('PNAME01')
->withPrice(100.0)
->withVAT(24.0)
->withQuantity(1);

/**
* Add the product to the order
*/
$order->addProduct($product);

/**
* Create another product
*/
$product = new Product();

/**
* Setup the product params
*
* Full params available in the documentation
*/
$product->withCode('PCODE02')
->withName('PNAME02')
->withPrice(200.0)
->withVAT(24.0)
->withQuantity(1);

/**
* Add the second product to the same order
*/
$order->addProduct($product);

/**
* Create new billing address
*/
$billing = new Billing();

/**
* Setup the billing address params
*
* Full params available in the documentation
*/
$billing->withAddressLine1('Address1')
->withAddressLine2('Address2')
->withCity('City')
->withCountryCode('RO')
->withEmail('john.doe@mail.com')
->withFirstName('FirstName')
->withLastName('LastName')
->withPhoneNumber('40123456789')
->withIdentityCardNumber('111222');


/**
* Create new delivery address
*
* If you want to have the same delivery as billing, skip these two steps
* and pass the Billing $billing object to the request twice
*/
$delivery = new Delivery();

/**
* Setup the delivery address params
*
* Full params available in the documentation
*/
$delivery->withAddressLine1('Address1')
->withAddressLine2('Address2')
->withCity('City')
->withCountryCode('RO')
->withEmail('john.doe@mail.com')
->withFirstName('FirstName')
->withLastName('LastName')
->withPhoneNumber('40123456789');

/**
* Create new Card with params:
*
* Credit Card Number
* Credit Card Expiration Month
* Credit Card Expiration Year
* Credit Card CVV (Security Code)
* Credit Card Owner
*/
$card = new Card('4111111111111111', '01', '2026', '123', 'Card Owner Name');

/**
* Create new Request with params:
*
* Config object
* Order object
* Billing object
* Delivery (or Billing object again, if you want to have the delivery address the same as the billing address)
* User object
*/
$request = new Request($cfg, $order, $billing, $delivery, $user, PaymentsV4::API_VERSION_V4);
//$request = new Request($cfg, $order, $billing, $delivery, $user);

/**
* Add the Credit Card to the Request
*/
$request->setCard($card);

/**
* Create new API Client, passing the Config object as parameter
*/
$client = new Client($cfg);

/**
* Will throw different Exceptions on errors
*/
try {
/**
* Sends the Request to ALU and returns a Response
*
* See documentation for Response params
*/
$response = $client->pay($request);

/**
* In case of 3DS enrolled cards, PayU will return the URL_3DS that contains a unique url for each
* transaction. The merchant must redirect the browser to this url to allow user to authenticate.
* After the authentication process ends the user will be redirected to BACK_REF url
* with payment result in a HTTP POST request
*/
if ($response->isThreeDs()) {
header("Location:" . $response->getThreeDsUrl());
die();
}

echo $response->getCode()
. ' ' . $response->getStatus()
. ' ' . $response->getReturnCode()
. ' ' . $response->getReturnMessage();
} catch (ConnectionException $exception) {
echo $exception->getMessage();
} catch (ClientException $exception) {
echo $exception->getErrorMessage();
}
Loading