#mathersdis

1 messages · Page 1 of 1 (latest)

untold wrenBOT
whole sluice
#

Yep, that is how that flow goes. Are you running in to some issue when implimenting this?

fresh canopy
#

yes i am

#

it is not working

#

this is my function ```php
private function handlePaymentIntentSucceeded($paymentIntent,$tid)
{

    $transactionAmount = $paymentIntent->amount;
    $mainAmount = $paymentIntent->metadata->mainAmount;
    $member_id = $paymentIntent->metadata->mid;
    $member = User::findOrFail($member_id);
    $referrerId = $member->referredBy;

    if ($referrerId) {
        $referrer = User::findOrFail($referrerId);
        $referrerFee = $transactionAmount * 0.01; // 1% for the member who referred
        $amount = $referrerFee * 100;
        $referrerFees = intval($amount);

        $aid =  $referrer->account->customer_id;

        $referrerOfReferrerId = $referrer->referredBy;

        // Check if the referrer has a referee
        if ($referrerOfReferrerId) {
            $referrerOfReferrer = User::findOrFail($referrerOfReferrerId);
            $referrerOfReferrerFee = $transactionAmount * 0.01; // 1% for the member above the referrer
            $amount2 = $referrerOfReferrerFee * 100;
            $referrerOfReferrerFees = intval($amount2);
            $total = $referrerFees + $referrerOfReferrerFees;

            $aid2 = $referrerOfReferrer->account->customer_id;

            // Create payment intent with combined fees
            $this->createTransferIntent($total, $tid);

            // Create transfer intents for referrer and referrer of referrer
            $this->createTransfer($referrerFees, $tid, $aid);
            $this->createTransfer($referrerOfReferrerFees, $tid, $aid2);
        } 
      
    }

}```
#

this is the rough version of my code

#

ideally i create the payment intent first which is the createTransferIntent function

#

then run the createTransfer function twice for the two connected accounts

whole sluice
#

Can you tell me more about what exactly isn't working?

#

Are you getting an error on some call?