allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s

This commit is contained in:
2026-03-30 14:54:57 +07:00
parent 66aed7c4e8
commit b5e3a778ce
21316 changed files with 2777892 additions and 13 deletions

View File

@@ -0,0 +1,91 @@
<?php
namespace Omnipay\Stripe\Message\Transfers;
use Guzzle\Http\Message\Response;
use Omnipay\Tests\TestCase;
class CreateTransferRequestTest extends TestCase
{
/**
* @var CreateTransferRequest
*/
protected $request;
/**
* @var string
*/
protected $mockDir;
public function setUp()
{
$this->mockDir = __DIR__.'/../../Mock/Transfers';
$this->request = new CreateTransferRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'amount' => '12.00',
'currency' => 'USD',
'destination' => 'STRIPE_ACCOUNT_ID',
'transferGroup' => 'Order42',
'metadata' => array(
'foo' => 'bar',
),
)
);
}
public function testGetData()
{
$data = $this->request->getData();
$this->assertSame(1200, $data['amount']);
$this->assertSame('usd', $data['currency']);
$this->assertSame('STRIPE_ACCOUNT_ID', $data['destination']);
$this->assertSame('Order42', $data['transfer_group']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
}
/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
* @expectedExceptionMessage The sourceTransaction or transferGroup parameter is required
*/
public function testReferenceRequired()
{
$this->request->setTransferGroup(null);
$this->request->getData();
}
public function testDataWithSourceTransactionReference()
{
$this->request->setTransferGroup(null);
$this->request->setSourceTransaction('abc');
$data = $this->request->getData();
$this->assertSame('abc', $data['source_transaction']);
}
public function testSendSuccess()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/CreateTransferRequestSuccess.txt')))
);
$response = $this->request->send();
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('tr_164xRv2eZvKYlo2CZxJZWm1E', $response->getTransferReference());
$this->assertNull($response->getMessage());
}
public function testSendError()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/CreateTransferRequestFailure.txt')))
);
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('Transfer does not have available funds', $response->getMessage());
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace Omnipay\Stripe\Message\Transfers;
use Guzzle\Http\Message\Response;
use Omnipay\Tests\TestCase;
class CreateTransferReversalRequestTest extends TestCase
{
/**
* @var CreateTransferReversalRequest
*/
protected $request;
/**
* @var string
*/
protected $mockDir;
public function setUp()
{
$this->mockDir = __DIR__.'/../../Mock/Transfers';
$this->request = new CreateTransferReversalRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'transferReference' => 'REVERSAL_ID',
'amount' => '12.00',
'description' => 'Reversing Order 42',
'metadata' => array(
'foo' => 'bar',
),
)
);
}
public function testGetData()
{
$data = $this->request->getData();
$this->assertSame(1200, $data['amount']);
$this->assertSame('Reversing Order 42', $data['description']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
}
public function testSendSuccess()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/CreateTransferReversalRequestSuccess.txt')))
);
/** @var \Omnipay\Stripe\Message\Response $response */
$response = $this->request->send();
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('trr_1ARKQ22eZvKYlo2Cv5APdtKF', $response->getTransferReversalReference());
$this->assertNull($response->getMessage());
}
public function testSendFailure()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/FetchTransferReversalFailure.txt')))
);
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('No such transfer reversal: trr_1ARKQ22eZvKYlo2Cv5APdtKF', $response->getMessage());
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace Omnipay\Stripe\Message\Transfers;
use Guzzle\Http\Message\Response;
use Omnipay\Tests\TestCase;
class FetchTransferRequestTest extends TestCase
{
/**
* @var FetchTransferRequest
*/
protected $request;
/**
* @var string
*/
protected $mockDir;
public function setUp()
{
$this->mockDir = __DIR__.'/../../Mock/Transfers';
$this->request = new FetchTransferRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->setTransferReference('tr_164xRv2eZvKYlo2CZxJZWm1E');
}
public function testEndpoint()
{
$this->assertSame(
'https://api.stripe.com/v1/transfers/tr_164xRv2eZvKYlo2CZxJZWm1E',
$this->request->getEndpoint()
);
}
public function testSendSuccess()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/FetchTransferSuccess.txt')))
);
/** @var \Omnipay\Stripe\Message\Response $response */
$response = $this->request->send();
$this->assertTrue($response->isSuccessful());
$this->assertSame('tr_164xRv2eZvKYlo2CZxJZWm1E', $response->getTransferReference());
$this->assertFalse($response->isRedirect());
$this->assertNull($response->getMessage());
}
public function testSendFailure()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/FetchTransferFailure.txt')))
);
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('No such transfer: tr_164xRv2eZvKYlo2CZxJZWm1E', $response->getMessage());
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Omnipay\Stripe\Message\Transfers;
use Guzzle\Http\Message\Response;
use Omnipay\Tests\TestCase;
class FetchTransferReversalRequestTest extends TestCase
{
/**
* @var FetchTransferReversalRequest
*/
protected $request;
/**
* @var string
*/
protected $mockDir;
public function setUp()
{
$this->mockDir = __DIR__.'/../../Mock/Transfers';
$this->request = new FetchTransferReversalRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->setTransferReference('tr_1ARKPl2eZvKYlo2CsNTKWIOO');
$this->request->setReversalReference('trr_1ARKQ22eZvKYlo2Cv5APdtKF');
}
public function testEndpoint()
{
$this->assertSame(
'https://api.stripe.com/v1/transfers/tr_1ARKPl2eZvKYlo2CsNTKWIOO/reversals/trr_1ARKQ22eZvKYlo2Cv5APdtKF',
$this->request->getEndpoint()
);
}
public function testSendSuccess()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/FetchTransferReversalSuccess.txt')))
);
/** @var \Omnipay\Stripe\Message\Response $response */
$response = $this->request->send();
$this->assertTrue($response->isSuccessful());
$this->assertSame('trr_1ARKQ22eZvKYlo2Cv5APdtKF', $response->getTransferReversalReference());
$this->assertFalse($response->isRedirect());
$this->assertNull($response->getMessage());
}
public function testSendFailure()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/FetchTransferReversalFailure.txt')))
);
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('No such transfer reversal: trr_1ARKQ22eZvKYlo2Cv5APdtKF', $response->getMessage());
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Omnipay\Stripe\Message\Transfers;
use Guzzle\Http\Message\Response;
use Omnipay\Tests\TestCase;
class ListTransferReversalsRequestTest extends TestCase
{
/**
* @var ListTransferReversalsRequest
*/
protected $request;
/**
* @var string
*/
protected $mockDir;
public function setUp()
{
$this->mockDir = __DIR__.'/../../Mock/Transfers';
$this->request = new ListTransferReversalsRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->setTransferReference('tr_164xRv2eZvKYlo2CZxJZWm1E');
}
public function testEndpoint()
{
$this->assertSame(
'https://api.stripe.com/v1/transfers/tr_164xRv2eZvKYlo2CZxJZWm1E/reversals',
$this->request->getEndpoint()
);
}
public function testSendSuccess()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/ListTransferReversalsSuccess.txt')))
);
/** @var \Omnipay\Stripe\Message\Response $response */
$response = $this->request->send();
$data = $response->getData();
$this->assertTrue($response->isSuccessful());
$this->assertNotNull($response->getList());
$this->assertNull($response->getMessage());
$this->assertSame('/v1/transfers/tr_164xRv2eZvKYlo2CZxJZWm1E/reversals', $data['url']);
$this->assertFalse($response->isRedirect());
}
public function testSendFailure()
{
$this->request->setTransferReference('NOTFOUND');
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/ListTransferReversalsFailure.txt')))
);
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('No such transfer: NOTFOUND', $response->getMessage());
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Omnipay\Stripe\Message\Transfers;
use Guzzle\Http\Message\Response;
use Omnipay\Tests\TestCase;
class ListTransfersRequestTest extends TestCase
{
/**
* @var ListTransfersRequest
*/
protected $request;
/**
* @var string
*/
protected $mockDir;
public function setUp()
{
$this->mockDir = __DIR__.'/../../Mock/Transfers';
$this->request = new ListTransfersRequest($this->getHttpClient(), $this->getHttpRequest());
}
public function testEndpoint()
{
$this->assertSame('https://api.stripe.com/v1/transfers', $this->request->getEndpoint());
}
public function testSendSuccess()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/ListTransfersSuccess.txt')))
);
/** @var \Omnipay\Stripe\Message\Response $response */
$response = $this->request->send();
$data = $response->getData();
$this->assertTrue($response->isSuccessful());
$this->assertNotNull($response->getList());
$this->assertNull($response->getMessage());
$this->assertSame('/v1/transfers', $data['url']);
$this->assertFalse($response->isRedirect());
}
public function testSendFailure()
{
$this->request->setTransferGroup('NOTFOUND');
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/ListTransfersFailure.txt')))
);
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('No such transfer group: NOTFOUND', $response->getMessage());
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace Omnipay\Stripe\Message\Transfers;
use Guzzle\Http\Message\Response;
use Omnipay\Tests\TestCase;
class UpdateTransferRequestTest extends TestCase
{
/**
* @var UpdateTransferRequest
*/
protected $request;
/**
* @var string
*/
protected $mockDir;
public function setUp()
{
$this->mockDir = __DIR__.'/../../Mock/Transfers';
$this->request = new UpdateTransferRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->setTransferReference('tr_164xRv2eZvKYlo2CZxJZWm1E');
}
public function testEndpoint()
{
$this->assertSame(
'https://api.stripe.com/v1/transfers/tr_164xRv2eZvKYlo2CZxJZWm1E',
$this->request->getEndpoint()
);
}
public function testData()
{
$this->request->setMetadata(array('field' => 'value'));
$data = $this->request->getData();
$this->assertArrayHasKey('field', $data['metadata']);
$this->assertSame('value', $data['metadata']['field']);
}
public function testSendSuccess()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/CreateTransferRequestSuccess.txt')))
);
/** @var \Omnipay\Stripe\Message\Response $response */
$response = $this->request->send();
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('tr_164xRv2eZvKYlo2CZxJZWm1E', $response->getTransferReference());
$this->assertNull($response->getMessage());
}
public function testSendFailure()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/FetchTransferFailure.txt')))
);
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('No such transfer: tr_164xRv2eZvKYlo2CZxJZWm1E', $response->getMessage());
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace Omnipay\Stripe\Message\Transfers;
use Guzzle\Http\Message\Response;
use Omnipay\Tests\TestCase;
class UpdateTransferReversalRequestTest extends TestCase
{
/**
* @var UpdateTransferReversalRequest
*/
protected $request;
/**
* @var string
*/
protected $mockDir;
public function setUp()
{
$this->mockDir = __DIR__.'/../../Mock/Transfers';
$this->request = new UpdateTransferReversalRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->setTransferReference('tr_164xRv2eZvKYlo2CZxJZWm1E');
$this->request->setReversalReference('trr_1ARKQ22eZvKYlo2Cv5APdtKF');
}
public function testEndpoint()
{
$this->assertSame(
'https://api.stripe.com/v1/transfers/tr_164xRv2eZvKYlo2CZxJZWm1E/reversals/trr_1ARKQ22eZvKYlo2Cv5APdtKF',
$this->request->getEndpoint()
);
}
public function testData()
{
$this->request->setMetadata(array('field' => 'value'));
$this->request->setDescription('This is a reversal becuase of that');
$data = $this->request->getData();
$this->assertSame('This is a reversal becuase of that', $data['description']);
$this->assertArrayHasKey('field', $data['metadata']);
$this->assertSame('value', $data['metadata']['field']);
}
public function testSendSuccess()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/CreateTransferReversalRequestSuccess.txt')))
);
/** @var \Omnipay\Stripe\Message\Response $response */
$response = $this->request->send();
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('trr_1ARKQ22eZvKYlo2Cv5APdtKF', $response->getTransferReversalReference());
$this->assertNull($response->getMessage());
}
public function testSendFailure()
{
$this->setMockHttpResponse(
array(\GuzzleHttp\Psr7\parse_response(file_get_contents($this->mockDir.'/FetchTransferReversalFailure.txt')))
);
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('No such transfer reversal: trr_1ARKQ22eZvKYlo2Cv5APdtKF', $response->getMessage());
}
}