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 Visa success card to test card registry #4

Open
wants to merge 4 commits into
base: pr-3-test-cards
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
26 changes: 26 additions & 0 deletions .github/workflow/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHPUnit Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
run-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2' # Adjust PHP version as needed

- name: Install dependencies
run: composer install

- name: Run PHPUnit tests
run: vendor/bin/phpunit -c tests/phpunit.xml

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# About this project

This is a fork of `readdle/stripe-httpclient-mock`. Kudos to them for most of the hard work!

This is pretty raw library which is aimed to provide full HTTP client mock for `stripe-php` library in order to
perform tests without actually sending HTTP requests to Stripe.

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
"description": "Mock of Stripe's HttpClient which can be used in testing purposes in order to test your code and not to perform actual HTTP requests",
"type": "library",
"license": "MIT",
"version": "1.3.1",
"php": ">=8.0",
"autoload": {
"psr-4": {
"Readdle\\StripeHttpClientMock\\": "src/"
}
},
"require": {
"php": ">=8.0",
"ext-json": "*",
"stripe/stripe-php": ">=7.56"
"stripe/stripe-php": ">=7.56,<17.0.0"
},
"require-dev": {
"phpunit/phpunit": "^9"
Expand Down
1 change: 1 addition & 0 deletions src/Entity/PaymentIntent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PaymentIntent extends AbstractEntity
'cancellation_reason' => null,
'capture_method' => '',
'charges' => [],
'latest_charge' => null,
'client_secret' => '',
'confirmation_method' => '',
'created' => 0,
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static function extractApiKey(array $headers): string
return '';
}

final public function request($method, $absUrl, $headers, $params, $hasFile): array
final public function request($method, $absUrl, $headers, $params, $hasFile, $apiMode = 'v1'): array
{
self::printf('HttpClient: %s %s', strtoupper($method), $absUrl);

Expand Down
4 changes: 3 additions & 1 deletion src/TestCards/TestCardRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Readdle\StripeHttpClientMock\TestCards\TestCard\ScaVerificationFlowRequired;
use Readdle\StripeHttpClientMock\TestCards\TestCard\TestCardInterface;
use Readdle\StripeHttpClientMock\TestCards\TestCard\VisaChargeDeclined;
use Readdle\StripeHttpClientMock\TestCards\TestCard\VisaSuccess;

/**
* User: tarjei
Expand All @@ -20,7 +21,8 @@ public function __construct()
{
$this->cards = [
new VisaChargeDeclined(),
new ScaVerificationFlowRequired()
new ScaVerificationFlowRequired(),
new VisaSuccess()
];
}

Expand Down