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
Top comments (1)
Hey @oliverpyon mind that the API for SumUp does not have payment links. That's a product that SumUp offers (sumup.com/en-gb/payment-links/), but not via API at this moment.
The docs in developer.sumup.com/docs/online-pa... apply to "online payments" - but you still need to build and host the page where the payment widget would be hosted (developer.sumup.com/docs/online-pa...) -- or building that functionality yourself too.