Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic support of Stripe Connect #972

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion app/Http/Controllers/EventCheckoutController.php
Expand Up @@ -425,7 +425,7 @@ public function postCreateOrder(Request $request, $event_id)
$order_total = $order_service->getGrandTotal();
$order_email = $ticket_order['request_data'][0]['order_email'];

$response = $gateway->startTransaction($order_total, $order_email, $event);
$response = $gateway->startTransaction($order_total, $order_email, $event, $ticket_order);

if ($response->isSuccessful()) {

Expand Down
56 changes: 43 additions & 13 deletions app/Services/PaymentGateway/StripeSCA.php
Expand Up @@ -19,30 +19,60 @@ public function __construct($gateway)
$this->options = [];
}

private function createTransactionData($order_total, $order_email, $event)
private function createTransactionData($order_total, $order_email, $event, $ticket_order)
{

$returnUrl = route('showEventCheckoutPaymentReturn', [
'event_id' => $event->id,
'is_payment_successful' => 1,
]);

$this->transaction_data = [
'amount' => $order_total,
'currency' => $event->currency->code,
'description' => 'Order for customer: ' . $order_email,
'paymentMethod' => $this->options['paymentMethod'],
'receipt_email' => $order_email,
'returnUrl' => $returnUrl,
'confirm' => true
];
// fetching the payment gateway config
$account_payment_gateway = $ticket_order['account_payment_gateway']->config;
// get the booking fees configured for that order
$fees = $ticket_order['total_booking_fee'];

/**
* If an account is configured in the payment gateway as a transfer destination, use it.
*/
if (array_key_exists('transfer_data_destination_id',$account_payment_gateway) || !empty($account_payment_gateway['transfer_data_destination_id'])) {
if (array_key_exists('application_fee_amount', $account_payment_gateway) || !empty($account_payment_gateway['application_fee_amount'])){
$gateway_fees = floatval($account_payment_gateway['application_fee_amount']);
}else {
$gateway_fees = 0;
}
$this->transaction_data = [
'amount' => $order_total,
'currency' => $event->currency->code,
'description' => 'Order for customer: ' . $order_email,
'paymentMethod' => $this->options['paymentMethod'],
'receipt_email' => $order_email,
'returnUrl' => $returnUrl,
'confirm' => true,
// Add the configured payment gateway fees to the existing fees.
'application_fee_amount' => $gateway_fees + $fees ,
// Pass the destination ID
'destination' => $account_payment_gateway['transfer_data_destination_id']
];
}else{
$this->transaction_data = [
'amount' => $order_total,
'currency' => $event->currency->code,
'description' => 'Order for customer: ' . $order_email,
'paymentMethod' => $this->options['paymentMethod'],
'receipt_email' => $order_email,
'returnUrl' => $returnUrl,
'confirm' => true
];
}


return $this->transaction_data;
}

public function startTransaction($order_total, $order_email, $event)
public function startTransaction($order_total, $order_email, $event, $ticket_order)
{
$this->createTransactionData($order_total, $order_email, $event);
$this->createTransactionData($order_total, $order_email, $event, $ticket_order);
$response = $this->gateway->authorize($this->transaction_data)->send();

return $response;
Expand Down Expand Up @@ -123,4 +153,4 @@ public function refundTransaction($order, $refund_amount, $refund_application_fe
return $refundResponse;
}

}
}
2 changes: 2 additions & 0 deletions resources/lang/de/ManageAccount.php
Expand Up @@ -39,6 +39,8 @@
'save_payment_details_submit' => 'Zahlungseinstellungen speichern',
'secret_code' => 'Geheimcode',
'secure_hash_code' => 'Sicherer Hash Code',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'Öffentlicher Stripe Schlüssel',
'stripe_secret_key' => 'Stripe secret key',
'stripe_settings' => 'Stripe Einstellungen',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en/ManageAccount.php
Expand Up @@ -39,6 +39,8 @@
'save_payment_details_submit' => 'Save payment details',
'secret_code' => 'Secret code',
'secure_hash_code' => 'Secure hash code',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'Stripe publishable key',
'stripe_secret_key' => 'Stripe secret key',
'stripe_settings' => 'Stripe Settings',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/es/ManageAccount.php
Expand Up @@ -38,6 +38,8 @@
'save_payment_details_submit' => 'Guardar los datos de pago',
'secret_code' => 'Código secreto',
'secure_hash_code' => 'Código hash de seguridad',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'Clave publicable de Stripe',
'stripe_secret_key' => 'Clave secreta de Stripe',
'stripe_settings' => 'Configuración de Stripe',
Expand Down
4 changes: 3 additions & 1 deletion resources/lang/fr/ManageAccount.php
Expand Up @@ -39,14 +39,16 @@
'save_payment_details_submit' => 'Sauvegarder les détails du paiement',
'secret_code' => 'Code secret',
'secure_hash_code' => 'Code de hachage sécurisé',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'Clef publique Stripe',
'stripe_secret_key' => 'Clef secrète Stripe',
'stripe_settings' => 'Paramètres Stripe',
'timezone' => 'Fuseau horaire',
'users' => 'Utilisateurs',
'version_info' => 'Informations de version',
'version_out_of_date' => 'Votre version (<b>:installed</b>) d\'Attendize n\'est pas à jour. La dernière version (<b>:latest</b>) peut être <a href=":url" target="_blank">téléchargée ici</a>',
'version_up_to_date' => 'Votre version d\'Attendize (<b>:installed</b>) est à jour !',
'version_up_to_date' => 'Votre version d\'Attendize (<b>:installed</b>) est à jour&nbsp;!',
'account_payment' => 'Compte / Paiement',
'event_attendees' => 'Participants de l\'événément',
);
2 changes: 2 additions & 0 deletions resources/lang/it/ManageAccount.php
Expand Up @@ -36,6 +36,8 @@
'save_payment_details_submit' => 'Salva i dettagli di pagamento',
'secret_code' => 'Codice segreto',
'secure_hash_code' => 'Codice hash',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'Chiave pubblica Stripe',
'stripe_secret_key' => 'Chiave segreta Stripe',
'stripe_settings' => 'Impostazioni Stripe',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/ja/ManageAccount.php
Expand Up @@ -36,6 +36,8 @@
'save_payment_details_submit' => 'Save payment details',
'secret_code' => 'Secret code',
'secure_hash_code' => 'Secure hash code',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'Stripe publishable key',
'stripe_secret_key' => 'Stripe secret key',
'stripe_settings' => 'Stripe Settings',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/nl/ManageAccount.php
Expand Up @@ -39,6 +39,8 @@
'save_payment_details_submit' => 'Save payment details',
'secret_code' => 'Secret code',
'secure_hash_code' => 'Secure hash code',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'Stripe publishable key',
'stripe_secret_key' => 'Stripe secret key',
'stripe_settings' => 'Stripe Settings',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/pl/ManageAccount.php
Expand Up @@ -39,6 +39,8 @@
'save_payment_details_submit' => 'Zapisz płatność',
'secret_code' => 'Sekretny kod',
'secure_hash_code' => 'Sekretny kod hash',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'Publikowalny klucz Stripe',
'stripe_secret_key' => 'Sekretny klucz Stripe',
'stripe_settings' => 'Ustawienia Stripe',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/ru/ManageAccount.php
Expand Up @@ -39,6 +39,8 @@
'save_payment_details_submit' => 'Сохранить настройки оплаты',
'secret_code' => 'Секретный код',
'secure_hash_code' => 'Код безопасного хеша',
'stripe_connect_application_fee' => 'Stripe Connect Application Fee',
'stripe_connect_transfer_data_destination_id' => 'Stripe Connected Account ID',
'stripe_publishable_key' => 'публичный ключ Stripe ',
'stripe_secret_key' => 'секретный ключ Stripe',
'stripe_settings' => 'настройки Stripe',
Expand Down
12 changes: 12 additions & 0 deletions resources/views/ManageAccount/Partials/StripeSCA.blade.php
Expand Up @@ -14,4 +14,16 @@
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{!! Form::label('stripe_sca[application_fee_amount]', trans("ManageAccount.stripe_connect_application_fee"), array('class'=>'control-label ')) !!}
{!! Form::text('stripe_sca[application_fee_amount]', $account->getGatewayConfigVal($payment_gateway['id'], 'application_fee_amount'),[ 'class'=>'form-control']) !!}
</div>
</div>
<div class="col-md-6">
{!! Form::label('stripe_sca[transfer_data_destination_id]', trans("ManageAccount.stripe_connect_transfer_data_destination_id"), array('class'=>'control-label ')) !!}
{!! Form::text('stripe_sca[transfer_data_destination_id]', $account->getGatewayConfigVal($payment_gateway['id'], 'transfer_data_destination_id'),[ 'class'=>'form-control']) !!}
</div>
</div>
</section>