Make your own rebilling of a customer

If you want to capture money based on a previous payment, using a CCRG key, you can do so by using the documentation below.

Be aware that it is required of the previous payment to have a CCRG key in order to make a rebilling. This can be activated in admin.

In order to do this, the code below should be run, with the values changed accordingly.

Please make note that event thoug you may previously have made use of our Rebilling API without defining Card ID, it is important to add this value.

Code example:

$request = array();
$request['function'] = 'rebilling_customer';
$request['MerchantID'] = 'MERCHANTID'; //replace the last merchantID with the one in your admin
$request['subscriptioncode'] = 'CCRG'; //replace ccrg with the ccrg key you want rebilling on
$request['amount'] = 'AMOUNT'; //replace AMOUNT with the amount you want to get from the customer
$request['cartid']='CARTID'; //replace CARTID the the order id you want

$result = json_decode(json_decode(v4requestresponse($request)));

if (trim($result->textresponse) == "ACK") {

    echo "Success";

} else {
    echo "False";


function v4requestresponse($data) {

    $url = "https://webservice.yourpay.dk/v4/".$data['function'];
    $fields_string = [];
    foreach($data as $key=>$value){
        $fields_string[$key] = urlencode($value);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields_string));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec ($ch);
    curl_close ($ch);

    return json_encode($server_output);



Didn't find what you were searching for?

Was this article helpful?
Dislike 0
Views: 12

Fandt du ikke svar på det du søgte?