I’m trying to create payment links for invoices using the SumUp PHP SDK. Here’s what I’ve done so far:
$sumup = new \PaymentGateway\Setup([
'client_id' => 'xxx',
'client_secret' => 'yyy',
'auth_type' => 'app_credentials',
]);
$paymentService = $sumup->getPaymentService();
$total = $bill->total;
$currencyCode = $bill->currencyCode;
$billReference = $bill->reference;
$customerEmail = $bill->customerEmail;
$billSummary = $bill->summary;
$paymentResponse = $paymentService->initiate($total, $currencyCode, $billReference, $customerEmail, $billSummary);
$paymentId = $paymentResponse->getResult()->paymentId;
The response doesn’t include a payment link. I’ve tried creating one myself:
$paymentUrl = 'https://example.com/pay?ref='.$billReference.'&id='.$paymentId;
I’ve set up a route and controller to handle this, and I’m using the SumUp Card SDK on the frontend. But I’m unsure how to properly connect the frontend with the backend to process payments securely.
How can I generate a proper payment link using the SDK? And how should I handle the payment data from the frontend?
hey Sky_Dreamer, i’ve used SumUp before. The SDK doesn’t generate payment links directly. You’ll need to create a custom endpoint that handles the payment process. On your frontend, use the SumUp Card SDK to collect card details, then send them securely to your backend. Your backend should use the SDK to process the payment with those details. Remember to follow PCI compliance guidelines!
Hey there Sky_Dreamer! 
I’ve been tinkering with SumUp recently too, and I totally get your confusion. It’s not super straightforward, is it?
Have you considered using webhooks? They’re pretty nifty for handling the payment flow. You could set up a webhook endpoint on your server that SumUp can ping when a payment status changes. That way, you’re always in the loop about what’s happening with each transaction.
Also, I’m curious - have you looked into SumUp’s Checkout API? It might be a simpler solution if you’re just looking to generate payment links without dealing with all the nitty-gritty details.
What’s your main goal with this integration? Are you trying to build a full-fledged payment system, or just need a quick way to accept payments? Knowing that might help figure out the best approach for your specific use case.
Oh, and one more thing - how are you handling error scenarios? Like what happens if a payment fails or times out? That’s always a tricky bit to get right!
I’ve implemented SumUp payments in a few projects, and here’s what I’ve found works well:
Instead of generating a payment link, create a dedicated payment page on your server. This page should render the SumUp Card SDK elements and handle the payment flow.
On your backend, store the payment details (amount, currency, reference) in a session or temporary database entry. When the user accesses the payment page, retrieve these details and pass them to the frontend.
Use the SumUp Card SDK on the frontend to securely collect card information. Then, send a request to your backend with the payment token. Your backend should use the SDK’s charge()
method to process the payment.
This approach keeps sensitive data off your servers and maintains a seamless user experience. Just ensure your implementation follows SumUp’s security guidelines and PCI DSS requirements.