diff --git a/src/Message/AuthorizeRequest.php b/src/Message/AuthorizeRequest.php index 703a1b56..cef086d0 100644 --- a/src/Message/AuthorizeRequest.php +++ b/src/Message/AuthorizeRequest.php @@ -316,7 +316,7 @@ public function getData() } if ($this->getApplicationFee()) { - $data['application_fee'] = $this->getApplicationFeeInteger(); + $data['application_fee_amount'] = $this->getApplicationFeeInteger(); } if ($this->getTransferGroup()) { diff --git a/src/Message/PaymentIntents/AuthorizeRequest.php b/src/Message/PaymentIntents/AuthorizeRequest.php index 5154042f..0a83be54 100644 --- a/src/Message/PaymentIntents/AuthorizeRequest.php +++ b/src/Message/PaymentIntents/AuthorizeRequest.php @@ -391,7 +391,7 @@ public function getData() } if ($this->getApplicationFee()) { - $data['application_fee'] = $this->getApplicationFeeInteger(); + $data['application_fee_amount'] = $this->getApplicationFeeInteger(); } if ($this->getTransferGroup()) { diff --git a/src/Message/PaymentIntents/CaptureRequest.php b/src/Message/PaymentIntents/CaptureRequest.php index 9baa3cdd..44788440 100644 --- a/src/Message/PaymentIntents/CaptureRequest.php +++ b/src/Message/PaymentIntents/CaptureRequest.php @@ -5,6 +5,8 @@ */ namespace Omnipay\Stripe\Message\PaymentIntents; +use Money\Formatter\DecimalMoneyFormatter; + /** * Stripe Capture Request. * @@ -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'; diff --git a/tests/Message/AuthorizeRequestTest.php b/tests/Message/AuthorizeRequestTest.php index 438e1b03..cf6a8039 100644 --- a/tests/Message/AuthorizeRequestTest.php +++ b/tests/Message/AuthorizeRequestTest.php @@ -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() diff --git a/tests/Message/PaymentIntents/AuthorizeRequestTest.php b/tests/Message/PaymentIntents/AuthorizeRequestTest.php index 5081eb01..28344ad5 100644 --- a/tests/Message/PaymentIntents/AuthorizeRequestTest.php +++ b/tests/Message/PaymentIntents/AuthorizeRequestTest.php @@ -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']); } diff --git a/tests/Message/PaymentIntents/PurchaseRequestTest.php b/tests/Message/PaymentIntents/PurchaseRequestTest.php index 09af7fae..2f0dda5d 100644 --- a/tests/Message/PaymentIntents/PurchaseRequestTest.php +++ b/tests/Message/PaymentIntents/PurchaseRequestTest.php @@ -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()