This content originally appeared on DEV Community and was authored by oliver-pyon
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
This content originally appeared on DEV Community and was authored by oliver-pyon
oliver-pyon | Sciencx (2023-04-06T17:14:39+00:00) How to get payment Link From SumUp using sumup-ecom-php-sdk?. Retrieved from https://www.scien.cx/2023/04/06/how-to-get-payment-link-from-sumup-using-sumup-ecom-php-sdk/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.