Skip to content

Commit 83ef970

Browse files
authored
Add files via upload
1 parent 9ea6a95 commit 83ef970

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

admin.sumup/sumup.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function get_sumup_token($fields) {
7878
$authresponse=sumup_query($authurl, $tokenpayload, "=", "POST","");
7979
// do we have access_token?
8080
$dresponse=json_decode($authresponse);
81-
/* echo "<pre>"; print_r($dresponse); echo "</pre>"; */
81+
/* echo "<pre>"; print_r($dresponse); echo "</pre>"; */
8282
$accesstoken=$dresponse->access_token; // this worked to here
8383
return $accesstoken;
8484
}
@@ -180,10 +180,10 @@ function sumup_query($url, $params, $delim, $postorget, $at) {
180180
if (curl_errno($curl)) { $result = Array('success' => 'false', 'result' => curl_errno($curl).' - '.curl_error($curl)); }
181181
curl_close($curl);
182182

183-
// echo var_dump($headr) . " those were the headers<br/><br/>";
184-
// echo var_dump($paramfields) . " those were the paramfields<br/><br/>";
185-
// echo var_dump($jresult) . " and that was the result</br></br>";
186-
// echo var_dump($result) . " this is the raw result";
183+
// echo var_dump($headr) . " those were the headers<br/><br/>";
184+
// echo var_dump($paramfields) . " those were the paramfields<br/><br/>";
185+
// echo var_dump($jresult) . " and that was the result</br></br>";
186+
// echo var_dump($result) . " this is the raw result";
187187
return $result;
188188
}
189189

@@ -254,24 +254,30 @@ function sumup_query($url, $params, $delim, $postorget, $at) {
254254
// change from redirect so both are notify
255255
//$redirecturl=$this->config['redirect_url'] . "&currency=" . $data['currency'] . "&amount=" . $data[totaltopay] . "&pay_to_email=" . $payto;
256256
// $returnurl=$this->config['notify_url'] . "&currency=" . $data['currency'] . "&amount=" . $data[totaltopay] . "&pay_to_email=" . $payto;;
257+
$err="";
258+
if ($accesstoken != "") {
259+
$mycheckout=Array('checkout_reference'=>$myuniqueid,'amount'=>$data['totaltopay'],'currency'=>$data['currency'],'pay_to_email'=>$payto,'description'=>$data['itemname'], 'merchant_code'=>$mcode, 'redirect_url'=>$redirecturl,'return-url'=>$returnurl);
257260

258-
$mycheckout=Array('checkout_reference'=>$myuniqueid,'amount'=>$data['totaltopay'],'currency'=>$data['currency'],'pay_to_email'=>$payto,'description'=>$data['itemname'], 'merchant_code'=>$mcode, 'redirect_url'=>$redirecturl,'return-url'=>$returnurl);
261+
$sumupresult=sumup_query($checkout_url,$mycheckout,":","POST",$accesstoken);
259262

260-
$sumupresult=sumup_query($checkout_url,$mycheckout,":","POST",$accesstoken);
263+
// do we now have an id of the checkout resource?
261264
262-
// do we now have an id of the checkout resource?
263-
264-
$idt=json_decode($sumupresult);
265-
$idtoken=$idt->id;
265+
$idt=json_decode($sumupresult);
266+
$idtoken=$idt->id;
267+
} else {
268+
// we have an empty access token so there was a problem
269+
$err.="<p class='alert alert-danger'>We were not able to gain an access token with SumUp. Please check your gateway configuration for correct URLs. You could also double check that your currency code matches the expected currency to be processed in your merchant account.</p>";
270+
$idtoken="";
271+
}
266272

267273
if ($testing == true) {
268-
$test="<h1>You are in test mode - providing you are using test credentials in the payment module settings your card will not be charged.</h1>";
274+
$test.="<h1>You are in test mode - providing you are using test credentials in the payment module settings your card will not be charged.</h1>";
269275
} else {
270276
$test="";
271277
}
272278
// new addition to prevent displaying the form if there is no checkout tokenid - this could be because the 'payments' scope has not been enabled
273279

274-
if ($idtoken != "") {
280+
if ($idtoken != "") {
275281
$form = '';
276282
$form .= $test;
277283
$form .= "<p class='alert alert-danger'>" . $data['itemname'] . "</p>";
@@ -300,10 +306,11 @@ function sumup_query($url, $params, $delim, $postorget, $at) {
300306
// end of my boxbilling bits MVB end
301307

302308
echo $form;
309+
303310
} else {
304311

305312
echo "<p class='alert alert-danger'>At the present time it is not possible to process your payment using SumUp. Please contact the site owner.</p>";
306-
if ($testing == true) { echo "<p class='alert alert-warning'>Please double check that you have enabled the <i>payments</i> scope with SumUp"; }
313+
if ($testing == true) { $err.="<p class='alert alert-warning'>Please double check that you have enabled the <i>payments</i> scope with SumUp"; echo $err; }
307314

308315
}
309316
$abort = true; //Don't redirect to success page yet!

0 commit comments

Comments
 (0)