Skip to content
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 changes: 1 addition & 1 deletion src/Message/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public function getData()
}

if ($this->getApplicationFee()) {
$data['application_fee'] = $this->getApplicationFeeInteger();
$data['application_fee_amount'] = $this->getApplicationFeeInteger();
}

if ($this->getTransferGroup()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Message/PaymentIntents/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public function getData()
}

if ($this->getApplicationFee()) {
$data['application_fee'] = $this->getApplicationFeeInteger();
$data['application_fee_amount'] = $this->getApplicationFeeInteger();
}

if ($this->getTransferGroup()) {
Expand Down
49 changes: 49 additions & 0 deletions src/Message/PaymentIntents/CaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Omnipay\Stripe\Message\PaymentIntents;

use Money\Formatter\DecimalMoneyFormatter;

/**
* Stripe Capture Request.
*
Expand Down Expand Up @@ -39,9 +41,56 @@ public function getData()
$data['amount_to_capture'] = $amount;
}

if ($this->getApplicationFee()) {
$data['application_fee_amount'] = $this->getApplicationFeeInteger();
}

return $data;
}

/**
* @return string
* @throws \Omnipay\Common\Exception\InvalidRequestException
*/
public function getApplicationFee()
{
$money = $this->getMoney('applicationFee');

if ($money !== null) {
return (new DecimalMoneyFormatter($this->getCurrencies()))->format($money);
}

return '';
}

/**
* Get the payment amount as an integer.
*
* @return integer
* @throws \Omnipay\Common\Exception\InvalidRequestException
*/
public function getApplicationFeeInteger()
{
$money = $this->getMoney('applicationFee');

if ($money !== null) {
return (integer) $money->getAmount();
}

return 0;
}

/**
* @param string $value
*
* @return AbstractRequest provides a fluent interface.
*/
public function setApplicationFee($value)
{
return $this->setParameter('applicationFee', $value);
}


public function getEndpoint()
{
return $this->endpoint.'/payment_intents/'.$this->getPaymentIntentReference().'/capture';
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testGetData()
$this->assertSame('Order #42', $data['description']);
$this->assertSame('false', $data['capture']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
$this->assertSame(100, $data['application_fee']);
$this->assertSame(100, $data['application_fee_amount']);
}

public function testDataWithLevel3()
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/PaymentIntents/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testGetData()
$this->assertSame('manual', $data['confirmation_method']);
$this->assertSame('pm_valid_payment_method', $data['payment_method']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
$this->assertSame(100, $data['application_fee']);
$this->assertSame(100, $data['application_fee_amount']);
$this->assertSame('off_session', $data['setup_future_usage']);
$this->assertSame('false', $data['off_session']);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/PaymentIntents/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testGetData()
$this->assertSame('manual', $data['confirmation_method']);
$this->assertSame('pm_valid_payment_method', $data['payment_method']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
$this->assertSame(100, $data['application_fee']);
$this->assertSame(100, $data['application_fee_amount']);
}

public function testSendSuccessAndRequireConfirmation()
Expand Down