• Hi Team ,

    I currently have a project where i need to integrate with a local payment processor “interpay” in Ghana “Africa”. will need help to integrate the php code sample below with any form in wordpress for applicants to make payment.

    
     <?php
    
    $url='https://test.interpayafrica.com/interapi/ProcessPayment';
    
    //GetValues From Another Page on this Processing Page
    //1. Name   $_POST["Name"]
    //2. Email  $_POST["Email"]
    //3. Mobile $_POST["Mobile"]
    //4. Currency Type  $_POST["CurrencyType"]
    //5. Amount        $_POST["Amount"]
    //6. OrderId      $_POST["OrderId"]
    //7. OrderDesc    $_POST["OrderDesc"]
    
    $app_id="2452015009";
    $app_key="test";
    $name="Yasir";
    $email="Test@Test";
    $mobile="0122545";
    $currency="GHS";
    $amount=10;
    $order_id="1212012454";
    $order_desc="test";
    //////////////////// AppID //// AppKey ////////////////////////
    $signature=$app_id.$app_key.$order_id.$amount.$currency; //Concatinate String to make encrypted signature
    
    //$HashValuemd5=md5($ConvertableString);  //Md5 Signature Method
    $signature = sha1($signature);  
    $base64= base64_encode(pack("H*",$signature));
    
    $data=(array(
       "app_id" => $app_id,
        "app_key" =>$app_key,
        "name"=>$name,
        "email"=>$email,
        "mobile"=>$mobile,
        "currency"=>$currency,
        "amount"=>$amount,
        "order_id"=>$order_id,
        "order_desc"=>$order_desc,
        "signature"=>$base64,
       // "signature"=>$HashValue
    ));
    $options = array(
        'http' => array(
            'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
            'method'  => 'POST',
            'content' => http_build_query($data),
        ),
    );
    $context  = stream_context_create($options);
    
    $result=file_get_contents($url, false, $context);
    
    $ParseJson=json_decode($result, TRUE);  //Parse The Json Response 
    
    header("LOCATION: https://test.interpayafrica.com/interapi/confirmpayment?Token=".urlencode($ParseJson['Token'])."&");
    
    ?>
    
    

    Brgds

    • This topic was modified 7 years, 1 month ago by Jan Dembowski. Reason: Fixed formatting
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I suggest making a custom page template that contains the form and processes the form submittal (the code you posted). Because the code calls header(), your page template cannot call get_header() until after that snippet runs, thus the snippet needs to be the very first executable code on the template. To ensure the snippet only executes upon form submit, wrap the entire thing in a conditional that checks if (‘POST’ == strtoupper( $_SERVER[‘REQUEST_METHOD’]))

    The form may be a standard HTML form. The form tag action attribute is empty, method is POST. Be sure the field names match the example $_POST key names. The form processing code needs to be modified so submitted values are validated and sanitized before being used. It’s a good idea to also add a nonce check and maybe verify the user is logged in before continuing to process the form.

Viewing 1 replies (of 1 total)
  • The topic ‘Payment Integration’ is closed to new replies.