Escrow Payment

hi, i am using stripe connect for payments.

I want to hold the payment until customer mark product as delivered. so how can i make a delay for the payment to go to the vendor until customer is satisfied with the product delivered.?

I think, in the chargeCustomer function (app/addons/stripe_connect/Tygh/Addons/StripeConnect/Payments/StripeConnect.php) you should comment out the "$charge->capture();" part and call it for example on specific order status change

(!) Not tested

The Stripe Connect add-on already has option to delay transfer of funds, starting from version 4.13.1. Please check the Delay transfer of funds option in the payment method's settings.

https://docs.cs-cart.com/latest/user_guide/payment_methods/stripe_connect.html

I think, in the chargeCustomer function (app/addons/stripe_connect/Tygh/Addons/StripeConnect/Payments/StripeConnect.php) you should comment out the "$charge->capture();" part and call it for example on specific order status change

(!) Not tested

I will try this and let you know if it works.


The Stripe Connect add-on already has option to delay transfer of funds, starting from version 4.13.1. Please check the Delay transfer of funds option in the payment method's settings.

https://docs.cs-cart.com/latest/user_guide/payment_methods/stripe_connect.html

i think with this option we can delay payment for specific number of days what i want is to delay the payment until an action occurs from customer sides.

I think, in the chargeCustomer function (app/addons/stripe_connect/Tygh/Addons/StripeConnect/Payments/StripeConnect.php) you should comment out the "$charge->capture();" part and call it for example on specific order status change

(!) Not tested

i cant find your described function call i.e, "$charge->capture() in the following method

but it is present in the chargeWithout3DSecure function.

 protected function chargeCustomer(array $order_info, Customer $customer, PayoutsManager $payouts_manager)
    {
        $amount = $this->formatAmount($order_info['total']);
        $params = [
            'amount'      => $amount,
            'currency'    => $this->processor_params['currency'],
            'customer'    => $customer->id,
            'metadata'    => [
                'order_id'   => $order_info['order_id'],
                'withdrawal' => 0,
            ],
            'capture'     => false,
            'description' => $this->getChargeDescription($order_info),
        ];
        $options = null;
    if ($order_info['company_id'] && empty($order_info['use_gift_certificates'])) {
        $receiver = static::getChargeReceiver($order_info['company_id']);
        list($accounting_withdrawal,, $application_fee) = $this->getWithdrawalAmount($order_info, $payouts_manager);
        $params['application_fee'] = $application_fee;
        $params['metadata']['withdrawal'] = $accounting_withdrawal;

        // payment receiver must be specified in options to perform Direct charge
        $options = ['stripe_account' => $receiver];

        // customer account must be shared to a connected account by converting it into a payment token
        $params['source'] = $this->shareCustomer($customer, $receiver);
        unset($params['customer']);
    }

    try {
        $charger = Charge::create($params, $options);
    } catch (Exception $e) {
        throw new StripeException(
            __('stripe_connect.charge_creating_error', ['[error]' => $e->getMessage()]),
            $params
        );
    }

    return $charger;
}

You are right. I meant the chargeWithout3DSecure function

You are right. I meant the chargeWithout3DSecure function

Hi i tried something different.

I added transfer_funds method in frontend/stripe_connect.pre.php

and called it from the customer end.

Can you tell me if its the correct approach.

and secondly can you tell me how i can confirm that payment is transferred to the vendor stripe account ?

here is the transfer_funds methods.

 if (
        $mode === 'transfer_funds'
        && !empty($_REQUEST['order_id'])
    ) {
    $order_info = fn_get_order_info($_REQUEST['order_id']);

    if (!$order_info || !fn_stripe_connect_is_allowed_transfer_funds_by_order_info($order_info)) {
        return [CONTROLLER_STATUS_NO_CONTENT];
    }
    $processor = ServiceProvider::getProcessorFactory()->getByPaymentId($order_info['payment_id']);

    try {
        /** @var \Tygh\Common\OperationResult $result */
        $result = $processor->manuallyTransferFunds($order_info);
        $processor->updatePaymentsDescriptions($order_info);

        $result->showNotifications();
        $result->getData() && fn_set_notification(NotificationSeverity::NOTICE, __('notice'), __('stripe_connect.funds_transferred_successfully'));
    } catch (Exception $e) {
        fn_set_notification(
            NotificationSeverity::ERROR,
            __('error'),
            __('stripe_connect.transfer_funds_error')
            . ' '
            . __(
                'stripe_connect.reason_with_error_text',
                ['[error_text]' => $e->getMessage()]
            )
        );
    }

    if (isset($_REQUEST['redirect_url'])) {
        return [CONTROLLER_STATUS_REDIRECT, $_REQUEST['redirect_url']];
    } else {
        return [CONTROLLER_STATUS_REDIRECT, 'orders.details?order_id=' . $order_info['order_id']];
    }
}

return [CONTROLLER_STATUS_OK];