Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ichaykin/430523b9a83abef93737a0108255a7b2 to your computer and use it in GitHub Desktop.
Save ichaykin/430523b9a83abef93737a0108255a7b2 to your computer and use it in GitHub Desktop.
diff --git a/app/addons/stripe_connect/Tygh/Addons/StripeConnect/Payments/StripeConnect.php b/app/addons/stripe_connect/Tygh/Addons/StripeConnect/Payments/StripeConnect.php
index 9001807f26..8aa8f1f07c 100644
--- a/app/addons/stripe_connect/Tygh/Addons/StripeConnect/Payments/StripeConnect.php
+++ b/app/addons/stripe_connect/Tygh/Addons/StripeConnect/Payments/StripeConnect.php
@@ -423,27 +423,30 @@ class StripeConnect
protected function getWithdrawalAmount(array $order_info, PayoutsManager $payouts_manager, Charge $charge = null)
{
$application_fee = $payouts_manager->getOrderFee($order_info['order_id']);
-
+ Logger::log(Logger::ACTION_INFO, 'transfer_withdrawal_start', ['o_id' => $order_info['order_id'], 'app_fee' => $application_fee]);
// hold back vendor payouts
if ($this->addon_settings['collect_payouts']) {
$application_fee += $payouts_manager->getPendingPayoutsFee();
+ Logger::log(Logger::ACTION_INFO, 'transfer_withdrawal_coll_pay', ['o_id' => $order_info['order_id'], 'app_fee' => $application_fee]);
}
$application_fee = min($application_fee, $order_info['total']);
-
+ Logger::log(Logger::ACTION_INFO, 'transfer_withdrawal_min_app_fee', ['o_id' => $order_info['order_id'], 'app_fee' => $application_fee]);
// the withdrawal that will be displayed in the Accounting
$accounting_withdrawal = $order_info['total'] - $application_fee;
$transfer_withdrawal = $accounting_withdrawal;
-
+ Logger::log(Logger::ACTION_INFO, 'transfer_withdrawal_new_t_w', ['o_id' => $order_info['order_id'], 'total' => $order_info['total'], 't_w' => $transfer_withdrawal]);
if ($charge) {
$net = $this->getChargeNet($charge);
+ Logger::log(Logger::ACTION_INFO, 'transfer_withdrawal_charge_net', ['o_id' => $order_info['order_id'], 'net' => $net]);
// the withdrawal that will be sent as the Transfer to vendor
$transfer_withdrawal *= $net / $charge->amount;
+ Logger::log(Logger::ACTION_INFO, 'transfer_withdrawal_t_w', ['o_id' => $order_info['order_id'], 't_w' => $transfer_withdrawal]);
}
$transfer_withdrawal = $this->formatAmount($transfer_withdrawal);
$application_fee = $this->formatAmount($application_fee);
-
+ Logger::log(Logger::ACTION_INFO, 'transfer_withdrawal_end', ['o_id' => $order_info['order_id'], 'a_w' => $accounting_withdrawal, 't_w' => $transfer_withdrawal, 'app_fee' => $application_fee]);
return [$accounting_withdrawal, $transfer_withdrawal, $application_fee];
}
@@ -670,6 +673,7 @@ class StripeConnect
protected function transferFunds(array $order_info, PayoutsManager $payouts_manager, Charge $charge)
{
[$accounting_withdrawal, $transfer_amount] = $this->getWithdrawalAmount($order_info, $payouts_manager, $charge);
+ Logger::log(Logger::ACTION_INFO, 'transfer_func_start', ['o_id' => $order_info['order_id'], 'acc_w' => $accounting_withdrawal, 't_amount' => $transfer_amount]);
if (!$transfer_amount) {
return null;
}
@@ -977,26 +981,30 @@ class StripeConnect
{
$transfers = [];
foreach ($orders as $order_id => $company_id) {
+ Logger::log(Logger::ACTION_INFO, 'transfer_start', ['o_id' => $order_id, 'c_id' => $company_id]);
if (!$company_id) {
// fallback for Vendor debt payout
+ Logger::log(Logger::ACTION_INFO, 'transfer_fallback_vendor_debt_payout', ['o_id' => $order_id, 'c_id' => $company_id]);
continue;
}
$suborder_info = fn_get_order_info($order_id);
if (!$suborder_info) {
+ Logger::log(Logger::ACTION_INFO, 'transfer_suborder_empty', ['o_id' => $order_id, 'subo_id' => $suborder_info]);
continue;
}
if (!$charge->refunds->isEmpty()) {
+ Logger::log(Logger::ACTION_INFO, 'transfer_refund_not_empty', ['o_id' => $order_id]);
$refund_ids = isset($suborder_info['payment_info']['stripe_connect.refund_id'])
? explode(', ', $suborder_info['payment_info']['stripe_connect.refund_id'])
: [];
-
+ Logger::log(Logger::ACTION_INFO, 'transfer_refund_ids', ['o_id' => $order_id, 'or_ids' => $refund_ids]);
foreach ($charge->refunds as $refund) {
$refund_ids[] = $refund->id;
}
-
+ Logger::log(Logger::ACTION_INFO, 'transfer_refund_ids', ['o_id' => $order_id, 'sr_ids' => $refund_ids]);
fn_update_order_payment_info(
$order_id,
[
@@ -1015,14 +1023,17 @@ class StripeConnect
}
if (!$this->formatAmount($suborder_info['total'])) {
+ Logger::log(Logger::ACTION_INFO, 'transfer_format_amount_error', ['o_id' => $order_id, 'total' => $suborder_info['total'], 'curr' => $this->processor_params['currency']]);
continue;
}
if (!empty($suborder_info['use_gift_certificates'])) {
+ Logger::log(Logger::ACTION_INFO, 'transfer_use_gift_certificates', ['o_id' => $order_id]);
continue;
}
$transfer = $this->transferFunds($suborder_info, $payouts_manager, $charge);
+ Logger::log(Logger::ACTION_INFO, 'transfer_created', ['o_id' => $order_id, 't_id' => $transfer->id]);
if (!$transfer) {
continue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment