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

Tweaks and fixes #11

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2,760 changes: 1,889 additions & 871 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions config/peachpayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
'authorisation_header' => env('PEACH_PAYMENTS_AUTHORIZATION_HEADER'),
'entity_id_once_off' => env('PEACH_PAYMENTS_ENTITY_ID_ONCE_OFF'),
'entity_id_once_recurring' => env('PEACH_PAYMENTS_ENTITY_ID_RECURRING'),
'test_mode' => env('PEACH_PAYMENTS_TEST_MODE'),
'test_mode' => env('PEACH_PAYMENTS_TEST_MODE', true),
'notification_url' => env('PEACH_PAYMENTS_NOTIFICATION_URL'),
'api_uri' => env('PEACH_PAYMENTS_API_URI'),
'api_uri' => env('PEACH_PAYMENTS_API_URI', 'https://test.oppwa.com/v1/'),
'api_uri_version' => env('PEACH_PAYMENTS_API_VERSION'),
'client_version' => '1.0.0',
'skip_3ds_for_stored_cards' => true,
Expand Down
1 change: 0 additions & 1 deletion src/Api/Factory/PaymentScheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ abstract class PaymentScheme

public function __construct(Setting $settings)
{

$this->settings = $settings;
$this->client = new Client([
'base_uri' => $this->getApiUri(),
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PaymentMethods/CopyAndPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function oneClickPayment(PaymentCard $card, int $amount)
'amount' => Currency::paymentFriendlyNumber($amount),
'currency' => 'ZAR',
'paymentType' => self::DEBIT,
'registrations[0].id' => $registrationId,
'registrations[0].id' => $card->registration_id,
],
]
)->getBody()->getContents();
Expand All @@ -236,7 +236,7 @@ public function paymentStatus(string $checkoutId)
try {
return $this->client->request(
'GET',
"checkouts/$checkoutId/payments",
"checkouts/$checkoutId/payment",
[
'form_params' => [
'entityId' => $this->settings->getEntityIdOnceRecurring(),
Expand Down
6 changes: 3 additions & 3 deletions src/Models/PaymentCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function results()
}

public function saveResult($results, $owner)
{
{
$result = $this->results()->create([
'transaction_id' => $results['merchantTransactionId'] ?? null,
'registration_id' => $results['id'] ?? null,
Expand All @@ -77,7 +77,7 @@ public static function create(array $attributes = [])
$result = $attributes['result'];

$formattedAttrs = [
'brand' => $result['paymentBrand'],
'brand' => $result['paymentBrand'] ?? '',
'last_four' => $result['card']['last4Digits'],
'holder' => $result['card']['holder'],
'expiry_month' => $result['card']['expiryMonth'],
Expand All @@ -92,7 +92,7 @@ public static function create(array $attributes = [])
}

$model->save();

return $model;
}
}
6 changes: 5 additions & 1 deletion tests/Unit/ServerToServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use IoDigital\PeachPayment\Api\CardBuilder;
use IoDigital\PeachPayment\Api\Response;
use IoDigital\PeachPayment\Api\Setting;
use IoDigital\PeachPayment\Models\PaymentCard;
use IoDigital\PeachPayment\PeachPayment;
use IoDigital\PeachPayment\Tests\TestCase;
use VCR\VCR;
Expand Down Expand Up @@ -115,7 +116,10 @@ public function it_can_do_a_one_click_payment()

$this->settings->setEntityIdOnceRecurring('8a8294174e735d0c014e78cf26461790');

$response = $client->oneClickPayment($registrationId, 2000);
$paymentCard = PaymentCard::create([
'result' => $responseData,
]);
$response = $client->oneClickPayment($paymentCard, 2000);
$responseData = json_decode($response, true);
$this->assertTrue($responseCheck->isSuccessfulResponse($responseData['result']['code']));

Expand Down
71 changes: 71 additions & 0 deletions tests/fixtures/copy_and_pay_can_prepare_checkout
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,74 @@
Content-Length: '310'
Vary: Accept-Encoding
body: '{"result":{"code":"000.200.100","description":"successfully created checkout"},"buildNumber":"e3cfe9278811a4408f2396757139bf151bfadb22@2020-04-14 03:42:29 +0000","timestamp":"2020-04-14 12:14:33+0000","ndc":"01BE6C69143EA1BBCA89C79182DD1C0C.uat01-vm-tx02","id":"01BE6C69143EA1BBCA89C79182DD1C0C.uat01-vm-tx02"}'
-
request:
method: POST
url: 'https://test.oppwa.com/v1/checkouts'
headers:
Host: test.oppwa.com
Expect: ''
Accept-Encoding: ''
Authorization: 'Bearer OGE4Mjk0MTc0ZTczNWQwYzAxNGU3OGNmMjY2YjE3OTR8cXl5ZkhDTjgzZQ=='
User-Agent: 'GuzzleHttp/6.5.5 curl/7.74.0 PHP/7.4.14'
Content-Type: application/x-www-form-urlencoded
Accept: ''
body: 'entityId=8a8294174e735d0c014e78cf26461790&amount=20.00&currency=ZAR&paymentType=DB'
response:
status:
http_version: '1.1'
code: '200'
message: OK
headers:
Date: 'Wed, 13 Jan 2021 08:36:15 GMT'
Server: Apache-Coyote/1.1
Strict-Transport-Security: 'max-age=63072000; includeSubdomains; preload'
X-Content-Type-Options: [nosniff, nosniff]
X-XSS-Protection: '1; mode=block'
Cache-Control: 'private, no-cache, no-store'
Pragma: no-cache
X-Application-WAF-Action: allow
Access-Control-Allow-Origin: '*'
Access-Control-Allow-Credentials: 'true'
Content-Type: application/json;charset=UTF-8
Content-Length: '310'
Vary: Accept-Encoding
body: '{"result":{"code":"000.200.100","description":"successfully created checkout"},"buildNumber":"c87b65b5cb4319398317315da7427570b84cdb55@2021-01-08 13:09:29 +0000","timestamp":"2021-01-13 08:36:16+0000","ndc":"F81BA998610AD1BEDC6F292DD81F29E7.uat01-vm-tx03","id":"F81BA998610AD1BEDC6F292DD81F29E7.uat01-vm-tx03"}'
curl_info:
url: 'https://test.oppwa.com/v1/checkouts'
content_type: application/json;charset=UTF-8
http_code: 200
header_size: 512
request_size: 341
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0.573607
namelookup_time: 0.033888
connect_time: 0.202207
pretransfer_time: 0.392701
size_upload: !!float 82
size_download: !!float 310
speed_download: !!float 541
speed_upload: !!float 143
download_content_length: !!float 310
upload_content_length: !!float 82
starttransfer_time: 0.573535
redirect_time: !!float 0
redirect_url: ''
primary_ip: 185.147.172.99
certinfo: { }
primary_port: 443
local_ip: 192.168.1.60
local_port: 64879
http_version: 2
protocol: 2
ssl_verifyresult: 0
scheme: HTTPS
appconnect_time_us: 392635
connect_time_us: 202207
namelookup_time_us: 33888
pretransfer_time_us: 392701
redirect_time_us: 0
starttransfer_time_us: 573535
total_time_us: 573607
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,73 @@
Content-Length: '261'
Vary: Accept-Encoding
body: '{"result":{"code":"800.900.300","description":"invalid authentication information"},"buildNumber":"e3cfe9278811a4408f2396757139bf151bfadb22@2020-04-14 03:42:29 +0000","timestamp":"2020-04-14 12:20:00+0000","ndc":"BDC46B14D62C8208BBBBBDD13073D607.uat01-vm-tx02"}'
-
request:
method: POST
url: 'https://test.oppwa.com/v1/checkouts'
headers:
Host: test.oppwa.com
Expect: ''
Accept-Encoding: ''
Authorization: 'Bearer lorem ipsum'
User-Agent: 'GuzzleHttp/6.5.5 curl/7.74.0 PHP/7.4.14'
Content-Type: application/x-www-form-urlencoded
Accept: ''
body: 'entityId=8a8294174e735d0c014e78cf26461790&amount=20.00&currency=ZAR&paymentType=DB'
response:
status:
http_version: '1.1'
code: '401'
message: Unauthorized
headers:
Date: 'Wed, 13 Jan 2021 08:36:16 GMT'
Server: Apache-Coyote/1.1
Strict-Transport-Security: 'max-age=63072000; includeSubdomains; preload'
X-Content-Type-Options: [nosniff, nosniff]
X-XSS-Protection: '1; mode=block'
Cache-Control: 'private, no-cache, no-store'
Pragma: no-cache
X-Application-WAF-Action: allow
WWW-Authenticate: 'Bearer token, error="invalid_token", error_description="Invalid Authorization header!""'
Content-Type: application/json;charset=UTF-8
Content-Length: '261'
Vary: Accept-Encoding
body: '{"result":{"code":"800.900.300","description":"invalid authentication information"},"buildNumber":"c87b65b5cb4319398317315da7427570b84cdb55@2021-01-08 13:09:29 +0000","timestamp":"2021-01-13 08:36:17+0000","ndc":"89C146D08F3CC9795BEE4D49CFE18AD7.uat01-vm-tx04"}'
curl_info:
url: 'https://test.oppwa.com/v1/checkouts'
content_type: application/json;charset=UTF-8
http_code: 401
header_size: 557
request_size: 292
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0.531583
namelookup_time: 0.001484
connect_time: 0.172083
pretransfer_time: 0.36016
size_upload: !!float 82
size_download: !!float 261
speed_download: !!float 491
speed_upload: !!float 154
download_content_length: !!float 261
upload_content_length: !!float 82
starttransfer_time: 0.531541
redirect_time: !!float 0
redirect_url: ''
primary_ip: 185.147.172.99
certinfo: { }
primary_port: 443
local_ip: 192.168.1.60
local_port: 64880
http_version: 2
protocol: 2
ssl_verifyresult: 0
scheme: HTTPS
appconnect_time_us: 360112
connect_time_us: 172083
namelookup_time_us: 1484
pretransfer_time_us: 360160
redirect_time_us: 0
starttransfer_time_us: 531541
total_time_us: 531583
71 changes: 71 additions & 0 deletions tests/fixtures/copy_and_pay_can_register_a_card
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,74 @@
Content-Length: '310'
Vary: Accept-Encoding
body: '{"result":{"code":"000.200.100","description":"successfully created checkout"},"buildNumber":"e3cfe9278811a4408f2396757139bf151bfadb22@2020-04-14 03:42:29 +0000","timestamp":"2020-04-16 13:56:44+0000","ndc":"645E833E7199236F4695F307A343A5C8.uat01-vm-tx04","id":"645E833E7199236F4695F307A343A5C8.uat01-vm-tx04"}'
-
request:
method: POST
url: 'https://test.oppwa.com/v1/checkouts'
headers:
Host: test.oppwa.com
Expect: ''
Accept-Encoding: ''
Authorization: 'Bearer OGE4Mjk0MTc0ZTczNWQwYzAxNGU3OGNmMjY2YjE3OTR8cXl5ZkhDTjgzZQ=='
User-Agent: 'GuzzleHttp/6.5.5 curl/7.74.0 PHP/7.4.14'
Content-Type: application/x-www-form-urlencoded
Accept: ''
body: 'entityId=8a8294174e735d0c014e78cf26461790&createRegistration=true'
response:
status:
http_version: '1.1'
code: '200'
message: OK
headers:
Date: 'Wed, 13 Jan 2021 08:36:16 GMT'
Server: Apache-Coyote/1.1
Strict-Transport-Security: 'max-age=63072000; includeSubdomains; preload'
X-Content-Type-Options: [nosniff, nosniff]
X-XSS-Protection: '1; mode=block'
Cache-Control: 'private, no-cache, no-store'
Pragma: no-cache
X-Application-WAF-Action: allow
Access-Control-Allow-Origin: '*'
Access-Control-Allow-Credentials: 'true'
Content-Type: application/json;charset=UTF-8
Content-Length: '310'
Vary: Accept-Encoding
body: '{"result":{"code":"000.200.100","description":"successfully created checkout"},"buildNumber":"c87b65b5cb4319398317315da7427570b84cdb55@2021-01-08 13:09:29 +0000","timestamp":"2021-01-13 08:36:17+0000","ndc":"5BC5E3C7977534C27C8BEDC760AD33F0.uat01-vm-tx02","id":"5BC5E3C7977534C27C8BEDC760AD33F0.uat01-vm-tx02"}'
curl_info:
url: 'https://test.oppwa.com/v1/checkouts'
content_type: application/json;charset=UTF-8
http_code: 200
header_size: 512
request_size: 324
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0.529204
namelookup_time: 0.002262
connect_time: 0.172011
pretransfer_time: 0.358713
size_upload: !!float 65
size_download: !!float 310
speed_download: !!float 586
speed_upload: !!float 122
download_content_length: !!float 310
upload_content_length: !!float 65
starttransfer_time: 0.529089
redirect_time: !!float 0
redirect_url: ''
primary_ip: 185.147.172.66
certinfo: { }
primary_port: 443
local_ip: 192.168.1.60
local_port: 64881
http_version: 2
protocol: 2
ssl_verifyresult: 0
scheme: HTTPS
appconnect_time_us: 358662
connect_time_us: 172011
namelookup_time_us: 2262
pretransfer_time_us: 358713
redirect_time_us: 0
starttransfer_time_us: 529089
total_time_us: 529204
71 changes: 71 additions & 0 deletions tests/fixtures/server_to_server_can_do_one_click_payment
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,74 @@
Vary: Accept-Encoding
Connection: close
body: '{"result":{"code":"200.300.404","description":"invalid or missing parameter","parameterErrors":[{"name":"shopperResultUrl","value":null,"message":"must be present so the shopper''s browser can be redirected back to you after being redirected to the third party''s website"}]},"buildNumber":"e3cfe9278811a4408f2396757139bf151bfadb22@2020-04-14 03:42:29 +0000","timestamp":"2020-04-15 12:31:17+0000","ndc":"8a8294174e735d0c014e78cf26461790_ba2fd7e20dd04032995171304a48070f"}'
-
request:
method: POST
url: 'https://test.oppwa.com/v1/registrations'
headers:
Host: test.oppwa.com
Expect: ''
Accept-Encoding: ''
Authorization: 'Bearer OGE4Mjk0MTc0ZTczNWQwYzAxNGU3OGNmMjY2YjE3OTR8cXl5ZkhDTjgzZQ=='
User-Agent: 'GuzzleHttp/6.5.5 curl/7.74.0 PHP/7.4.14'
Content-Type: application/x-www-form-urlencoded
Accept: ''
body: 'entityId=8a8294174e735d0c014e78cf26461790&paymentBrand=VISA&card.number=4711100000000000&card.holder=Jane+Jones&card.expiryMonth=05&card.expiryYear=2021&card.cvv=123'
response:
status:
http_version: '1.1'
code: '200'
message: OK
headers:
Date: 'Wed, 13 Jan 2021 08:36:19 GMT'
Server: Apache-Coyote/1.1
Strict-Transport-Security: 'max-age=63072000; includeSubdomains; preload'
X-Content-Type-Options: [nosniff, nosniff]
X-XSS-Protection: '1; mode=block'
Cache-Control: 'private, no-cache, no-store'
Pragma: no-cache
X-Application-WAF-Action: allow
Access-Control-Allow-Origin: '*'
Access-Control-Allow-Credentials: 'true'
Content-Type: application/json;charset=UTF-8
Content-Length: '460'
Vary: Accept-Encoding
body: '{"id":"8ac7a4a176e3d0a60176fae37a48034d","result":{"code":"000.100.110","description":"Request successfully processed in ''Merchant in Integrator Test Mode''"},"card":{"bin":"471110","last4Digits":"0000","holder":"Jane Jones","expiryMonth":"05","expiryYear":"2021"},"buildNumber":"c87b65b5cb4319398317315da7427570b84cdb55@2021-01-08 13:09:29 +0000","timestamp":"2021-01-13 08:36:20+0000","ndc":"8a8294174e735d0c014e78cf26461790_0f2c76ef561e4d9bad694e25195ac131"}'
curl_info:
url: 'https://test.oppwa.com/v1/registrations'
content_type: application/json;charset=UTF-8
http_code: 200
header_size: 512
request_size: 429
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0.670769
namelookup_time: 0.001486
connect_time: 0.16836
pretransfer_time: 0.353357
size_upload: !!float 165
size_download: !!float 460
speed_download: !!float 686
speed_upload: !!float 246
download_content_length: !!float 460
upload_content_length: !!float 165
starttransfer_time: 0.670701
redirect_time: !!float 0
redirect_url: ''
primary_ip: 185.147.172.99
certinfo: { }
primary_port: 443
local_ip: 192.168.1.60
local_port: 64884
http_version: 2
protocol: 2
ssl_verifyresult: 0
scheme: HTTPS
appconnect_time_us: 353309
connect_time_us: 168360
namelookup_time_us: 1486
pretransfer_time_us: 353357
redirect_time_us: 0
starttransfer_time_us: 670701
total_time_us: 670769
Loading