Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 6, 2023 05:14 pm GMT

How to get payment Link From SumUp using sumup-ecom-php-sdk?

I am looking to get a payment link for our invoice using sumup-ecom-php-sdk. How can I implement my idea?

$sumup = new \SumUp\SumUp([    'app_id' => '...',    'app_secret' => '...',    'grant_type' => 'client_credentials',]);$checkoutService = $sumup->getCheckoutService();$amount =$invoice->amount;$currency = $invoice->currency;$checkoutRef = $invoice->number;$payToEmail = $invoice->recipient;$description = $invoice->description;$checkoutResponse = $checkoutService->create($amount, $currency, $checkoutRef, $payToEmail, $description);$checkoutId = $checkoutResponse->getBody()->id;

How can I get a payment link using $checkoutService? There's no payment link in the response of $checkoutResponse->getBody();

So I created payment link myself using $checkoutId like the following.

$redirectUrl = 'http://127.0.0.1:8000/sumup/checkout?ref='.$checkoutRef.'&token='.$checkoutId

web.php

Route::get('/sumup/checkout', [SumupPayController::class, 'index']);

SumUpController.php

public function index(Request $request){    $invoiceNumber = $request->query('ref');    $checkoutId = $request->query('token');    return view('sumup_checkout', compact('invoiceNumber','checkoutId'));}

sumup_checkout.blade.php

<script src="https://gateway.sumup.com/gateway/ecom/card/v2/sdk.js"></script>
@extends('layout.app_layout_client')@section('body')    <div id="sumup-card"></div>@endsection@push('post-body-script')    <script>        const checkoutId = @json($checkoutId);        const invoiceNumber = @json($invoiceNumber);        console.log(checkoutId, invoiceNumber);        var sumupCard = SumUpCard.mount({            checkoutId: checkoutId,            showFooter: true,            currency: "EUR",            locale: "de-DE",            onResponse: function (type, body) {                switch(type) {                    case "sent":                        break;                    case "invalid":                        break;                    case "auth-screen":                        break;                    case "error":                        break;                    case "success":                        break;                    default:                        break;                }            },        });    </script>@endpush

As you can see, I developed front-end page using sumup-card-sdk. But I don't know where the request including card information that I input is sent when I click submit button of sumup-card. So I can't connect to backend. And I want to know how I can get input data including card information from sumup-card.

How can I get payment link using sumup-ecom-php-sdk and payment widget provided by SumUp?

Thanks in advice


Original Link: https://dev.to/oliverpyon/how-to-get-payment-link-from-sumup-using-sumup-ecom-php-sdk-22gk

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To