mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-08-07 10:01:47 -04:00
Add SOFORT support on Stripe
This commit is contained in:
parent
00d96fc0a8
commit
4c6031d1a3
@ -352,12 +352,27 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
public function createSource()
|
public function createSource()
|
||||||
{
|
{
|
||||||
$amount = intval($this->invoice()->getRequestedAmount() * 100);
|
$amount = intval($this->invoice()->getRequestedAmount() * 100);
|
||||||
|
$invoiceNumber = $this->invoice()->invoice_number;
|
||||||
$currency = $this->client()->getCurrencyCode();
|
$currency = $this->client()->getCurrencyCode();
|
||||||
$gatewayType = GatewayType::getAliasFromId($this->gatewayType);
|
$gatewayType = GatewayType::getAliasFromId($this->gatewayType);
|
||||||
$redirect = url("/complete_source/{$this->invitation->invitation_key}/{$gatewayType}");
|
$redirect = url("/complete_source/{$this->invitation->invitation_key}/{$gatewayType}");
|
||||||
$email = $this->contact()->email;
|
$country = $this->client()->country ? $this->client()->country->iso_3166_2 : ($this->account()->country ? $this->account()->country->iso_3166_2 : '');
|
||||||
|
$extra = '';
|
||||||
|
|
||||||
$data = "type=alipay&amount={$amount}¤cy={$currency}&redirect[return_url]={$redirect}";
|
if ($this->gatewayType == GATEWAY_TYPE_ALIPAY) {
|
||||||
|
if (! $this->accountGateway->getAlipayEnabled()) {
|
||||||
|
throw new Exception('Alipay is not enabled');
|
||||||
|
}
|
||||||
|
$type = 'alipay';
|
||||||
|
} else {
|
||||||
|
if (! $this->accountGateway->getSofortEnabled()) {
|
||||||
|
throw new Exception('Sofort is not enabled');
|
||||||
|
}
|
||||||
|
$type = 'sofort';
|
||||||
|
$extra = "&sofort[country]={$country}&statement_descriptor={$invoiceNumber}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = "type={$type}&amount={$amount}¤cy={$currency}&redirect[return_url]={$redirect}{$extra}";
|
||||||
$response = $this->makeStripeCall('POST', 'sources', $data);
|
$response = $this->makeStripeCall('POST', 'sources', $data);
|
||||||
|
|
||||||
if (is_array($response) && isset($response['id'])) {
|
if (is_array($response) && isset($response['id'])) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user