Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Create base connector #2

Merged
merged 9 commits into from
Jan 27, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/Njogu Amos/laravel-cash-app/discussions/new?category=q-a
url: https://github.com/Njogu Amos/laravel-cashapp/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/Njogu Amos/laravel-cash-app/discussions/new?category=ideas
url: https://github.com/Njogu Amos/laravel-cashapp/discussions/new?category=ideas
about: Share ideas for new features
- name: Report a security issue
url: https://github.com/Njogu Amos/laravel-cash-app/security/policy
url: https://github.com/Njogu Amos/laravel-cashapp/security/policy
about: Learn how to notify us for sensitive bugs
28 changes: 0 additions & 28 deletions .github/workflows/fix-php-code-style-issues.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/format-php-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Fix PHP code style issues

on: [pull_request]

env:
PR_NUMBER: '${{ github.event.number }}'
SOURCE_BRANCH: '$GITHUB_HEAD_REF'
FIXER_BRANCH: 'auto-fixed/$GITHUB_HEAD_REF'
TITLE: 'Format PHP code'
DESCRIPTION: 'This merge request applies code style fixes from an analysis carried out through GitHub Actions.'

permissions:
contents: write

jobs:
php-code-styling:
if: github.event_name == 'pull_request' && ! startsWith(github.ref, 'refs/heads/auto-fixed/')
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Prepare Git User
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -B "${{ env.FIXER_BRANCH }}"

- name: Fix PHP code style issues
uses: aglipanci/[email protected]

- name: Create Fixer PR
run: |
if [[ -z $(git status --porcelain) ]]; then
echo "Nothing to fix.. Exiting."
exit 0
fi
OPEN_PRS=`curl --silent -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open"`
OPEN_FIXER_PRS=`echo ${OPEN_PRS} | grep -o "\"ref\": \"${{ env.FIXER_BRANCH }}\"" | wc -l`
git commit -am "${{ env.TITLE }}"
git push origin "${{ env.FIXER_BRANCH }}" --force
if [ ${OPEN_FIXER_PRS} -eq "0" ]; then
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/pulls" \
-d "{ \"head\":\"${{ env.FIXER_BRANCH }}\", \"base\":\"${{ env.SOURCE_BRANCH }}\", \"title\":\"${{ env.TITLE }}\", \"body\":\"${{ env.DESCRIPTION }}\n\nTriggered by #${{ env.PR_NUMBER }}\" }"
fi
13 changes: 3 additions & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
name: run-tests

on:
push:
paths:
- '**.php'
- '.github/workflows/run-tests.yml'
- 'phpunit.xml.dist'
- 'composer.json'
- 'composer.lock'
on: [pull_request]

jobs:
test:
Expand All @@ -16,7 +9,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
php: [8.3, 8.2, 8.1]
laravel: [10.*]
stability: [prefer-lowest, prefer-stable]
Expand Down Expand Up @@ -51,5 +44,5 @@ jobs:
- name: List Installed Dependencies
run: composer show -D

- name: Execute tests
- name: Run tests
run: vendor/bin/pest --ci
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
# A laravel package scaforlding Cash App API.

[![Latest Version on Packagist](https://img.shields.io/packagist/v/njoguamos/laravel-cash-app.svg?style=flat-square)](https://packagist.org/packages/njoguamos/laravel-cash-app)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/njoguamos/laravel-cash-app/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/njoguamos/laravel-cash-app/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/njoguamos/laravel-cash-app/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/njoguamos/laravel-cash-app/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/njoguamos/laravel-cash-app.svg?style=flat-square)](https://packagist.org/packages/njoguamos/laravel-cash-app)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/njoguamos/laravel-cashapp.svg?style=flat-square)](https://packagist.org/packages/njoguamos/laravel-cashapp)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/njoguamos/laravel-cashapp/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/njoguamos/laravel-cashapp/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/njoguamos/laravel-cashapp/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/njoguamos/laravel-cashapp/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/njoguamos/laravel-cashapp.svg?style=flat-square)](https://packagist.org/packages/njoguamos/laravel-cashapp)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

## Support us

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/laravel-cash-app.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/laravel-cash-app)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

## Installation

You can install the package via composer:

```bash
composer require njoguamos/laravel-cash-app
composer require njoguamos/laravel-cashapp
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag="laravel-cash-app-migrations"
php artisan vendor:publish --tag="laravel-cashapp-migrations"
php artisan migrate
```

You can publish the config file with:

```bash
php artisan vendor:publish --tag="laravel-cash-app-config"
php artisan vendor:publish --tag="laravel-cashapp-config"
```

This is the contents of the published config file:
Expand All @@ -46,7 +38,7 @@ return [
Optionally, you can publish the views using

```bash
php artisan vendor:publish --tag="laravel-cash-app-views"
php artisan vendor:publish --tag="laravel-cashapp-views"
```

## Usage
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "njoguamos/laravel-cash-app",
"name": "njoguamos/laravel-cashapp",
"description": "A laravel package scaffolding Cash App API.",
"keywords": [
"NjoguAmos",
"Laravel",
"Cash App"
],
"homepage": "https://github.com/njoguamos/laravel-cash-app",
"homepage": "https://github.com/njoguamos/laravel-cashapp",
"license": "MIT",
"authors": [
{
Expand All @@ -17,8 +17,9 @@
],
"require": {
"php": "^8.1 | ^8.2 | ^8.3",
"spatie/laravel-package-tools": "^1.14.0",
"illuminate/contracts": "^10.0"
"illuminate/contracts": "^10.0",
"saloonphp/saloon": "^3.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down Expand Up @@ -46,7 +47,7 @@
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
"clear": "@php vendor/bin/testbench package:purge-laravel-cash-app --ansi",
"clear": "@php vendor/bin/testbench package:purge-laravel-cashapp --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
"@composer run prepare",
Expand Down
6 changes: 0 additions & 6 deletions config/cash-app.php

This file was deleted.

35 changes: 35 additions & 0 deletions config/cashapp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Cash APP Environment
|--------------------------------------------------------------------------
|
| Here, you specify whether your Cash App integration is in production.
| When the value is false, the application uses sandbox a which
| allows Cash App API integration without moving any money.
|
| @see https://developers.cash.app/docs/api/partner-onboarding/integrating-with-cash-app-pay/comparison
|
*/

'production' => env(key: 'CASH_PRODUCTION', default: false),

/*
|--------------------------------------------------------------------------
| Cash APP Base Urls
|--------------------------------------------------------------------------
|
| Here, you specify either "sandbox" or "production." The "sandbox" is used
| for testing API integration without moving any money. The "production"
| means your application is live, using Pay Kit for the production.
|
|
*/

'urls' => [
'sandbox' => env(key: 'CASH_APP_SANDBOX_URL', default: 'https://sandbox.api.cash.app'),
'production' => env(key: 'CASH_APP_PRODUCTION_URL', default: 'https://api.cash.app'),
]
];
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Njogu Amos Test Suite">
<testsuite name="Application Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
12 changes: 11 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"preset": "psr12"
"preset": "psr12",
"rules": {
"binary_operator_spaces": {
"operators": {
"=>": "align_single_space_minimal"
}
},
"array_syntax": {
"syntax": "short"
}
}
}
8 changes: 4 additions & 4 deletions src/CashAppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public function configurePackage(Package $package): void
* More info: https://github.com/spatie/laravel-package-tools
*/
$package
->name('laravel-cash-app')
->hasConfigFile()
->name(name: 'laravel-cashapp')
->hasConfigFile(configFileName: 'cashapp')
->hasViews()
->hasMigration('create_laravel-cash-app_table')
->hasCommand(CashAppCommand::class);
->hasMigration(migrationFileName: 'create_laravel-cashapp_table')
->hasCommand(commandClassName: CashAppCommand::class);
}
}
2 changes: 1 addition & 1 deletion src/Commands/CashAppCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class CashAppCommand extends Command
{
public $signature = 'laravel-cash-app';
public $signature = 'laravel-cashapp';

public $description = 'My command';

Expand Down
17 changes: 17 additions & 0 deletions src/Connectors/CashAppBaseConnector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace NjoguAmos\CashApp\Connectors;

use Saloon\Http\Connector;

class CashAppBaseConnector extends Connector
{
public function resolveBaseUrl(): string
{
if (config(key: 'cashapp.production')) {
return config(key: 'cashapp.urls.production') ;
}

return config(key: 'cashapp.urls.sandbox');
}
}
5 changes: 0 additions & 5 deletions tests/ArchTest.php

This file was deleted.

File renamed without changes.
6 changes: 3 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ protected function setUp(): void
);
}

protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [
CashAppServiceProvider::class,
];
}

public function getEnvironmentSetUp($app)
public function getEnvironmentSetUp($app): void
{
config()->set('database.default', 'testing');

/*
$migration = include __DIR__.'/../database/migrations/create_laravel-cash-app_table.php.stub';
$migration = include __DIR__.'/../database/migrations/create_laravel-cashapp_table.php.stub';
$migration->up();
*/
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/ArchTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

//arch(description: 'it will not use debugging functions')
// ->expect(value: ['dd', 'dump', 'ray'])
// ->each->not->toBeUsed();
20 changes: 20 additions & 0 deletions tests/Unit/Connectors/CashAppBaseConnectorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Njoguamos\CashApp\Tests;

use NjoguAmos\CashApp\Connectors\CashAppBaseConnector;

it(description: 'resolves to the correct base url', closure: function (bool $isProduction, string $baseUrl) {
config()->set(
key: 'cashapp.production',
value: $isProduction
);

$connector = new CashAppBaseConnector();

expect(value: $connector->resolveBaseUrl())
->toBe(expected: $baseUrl);
})->with([
'production' => [true, 'https://api.cash.app'],
'staging' => [false, 'https://sandbox.api.cash.app']
]);
Loading