Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
451 views
in Technique[技术] by (71.8m points)

php - Laravel cashier subscription with initial setup fee SCA problem

Recently because of the new SCA regulations being enforced here in europe i am having trouble with our payment system.

I think the problem lies in that the customer needs to do a 3DS on subscription creation but also on the one time fee transaction which breaks the payment.

The code

 public function course(CourseWizardStoreRequest $request)
{

    // Update user details
    $request->user()->update($request->only('phone'));

    // Store user address
    if ($request->user()->address()) {
        $request->user()->address()->delete();
    }

    $request->user()->address()->save(
        new Address($request->address)
    );

    // Get course details matching plan
    $course = Course::where('gateway_id', $request->plan)->firstOrFail();

    // Get plan details
    $plan = Plan::where('gateway_id', $request->plan)->firstOrFail();

    // Recurring fees
    $subscription = $request->user()->newSubscription('default', $request->plan);

    $subscription->create($request->token, [
        'email' => $request->email
    ]);

    $totalAmount = $plan->fee;

    if ($request->coupon !== null) {

        $totalAmount = $this->couponPrice($request->coupon, $totalAmount);

        $request->user()->invoiceFor($plan->name, $totalAmount . '00');

        CourseUsers::create([
            'course_id' => $course->id,
            'user_id' => $request->user()->id,
            'active' => 1
        ]);

    } else {

        $request->user()->invoiceFor($plan->name, $plan->formattedFee->getAmount() . '00');

        CourseUsers::create([
            'course_id' => $course->id,
            'user_id' => $request->user()->id,
            'active' => 1
        ]);
    }

    return $request;
}

This example used to work before. But does not function now. Is there a way to charge a sign up fee together with the subscription using Laravel cashier? or do i need to switch entirely to stripes own SDK

question from:https://stackoverflow.com/questions/65832113/laravel-cashier-subscription-with-initial-setup-fee-sca-problem

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...