apple pay in payfrort return Failed to execute service?

927 views Asked by At

i integrate apple pay with amazon payfort Gate and test operation using sandbox account my request is :

$arrData = array(
        'digital_wallet'=>'APPLE_PAY',
        'command' => 'PURCHASE',
        'access_code' => 'xxxxxxx',
        'merchant_identifier' => 'xxxxxx',
        'merchant_reference' =>$data->merchant_refrence,
        'amount' => 100,
        'currency' => 'SAR',
        'language' => 'en',
        'customer_email' =>$data->user->email != "" ? $data->user->email :"[email protected]",
        'customer_name' =>$data->user->name!= "" ? $data->user->name :"test",
        'phone_number' =>$data->user->mobile,
        'order_description' => 'Package payment',
        'return_url' => route('subscripe.return',["lang"=>$lang]),
        'merchant_extra' => str_replace('=', '@', base64_encode(json_encode($data))),
        'apple_data'            => $token['paymentData']['data'],
        'apple_signature'       => $token['paymentData']['signature'],
        'apple_header'          => [
            'apple_transactionId'=> $token['paymentData']['header']['transactionId'],
            'apple_ephemeralPublicKey'=> $token['paymentData']['header']['ephemeralPublicKey'],
            'apple_publicKeyHash'=> $token['paymentData']['header']['publicKeyHash'],
        ],

        'apple_paymentMethod'   => [
            'apple_displayName'=> $token['paymentMethod']['displayName'],
            'apple_network'=> $token['paymentMethod']['network'],
            'apple_type'=> $token['paymentMethod']['type'],
        ],
    );
    $shaString = '';
    ksort($arrData);
    foreach ($arrData as $key => $value) {
        if(is_array($value)){
            $shaSubString = '{';
            foreach ($value as $k => $v) {
                $shaSubString .= "$k=$v, ";
            }
            $shaSubString = substr($shaSubString, 0, -2).'}';
            $shaString .= "$key=$shaSubString";
        }else{
            $shaString .= "$key=$value";
        }
    }
    $shaString = $SHA_Request_Phrase . $shaString . $SHA_Request_Phrase;
    $signature = hash('sha256', $shaString);
    $arrData['signature'] = $signature;
    $arrData=json_encode($arrData);
    $url="https://sbpaymentservices.payfort.com/FortAPI/paymentApi";
    $response= $this->sent_request($url,"POST",$arrData);

before this response i get "invalid parameter type : apple_header " i was sent it as json value then i get mismatch signature and i fixed it by new calculation And then I get This Response

{
"error": "",
"result": {
    "amount": "100",
    "response_code": "00099",
    "digital_wallet": "APPLE_PAY",
    "signature": "20b4790c7e63d65c5abdefa3e30fd58d90669e3ba361279adef1abf51c4fb317",
    "merchant_identifier": "xxxxxx",
    "access_code": "xxxxxxx",
    "order_description": "Package payment",
    "language": "en",
    "command": "PURCHASE",
    "merchant_extra": "eyJpZCI6MTg3LCJtZXJjaGFudF9yZWZyZW5jZSI6InRpc3RhaGVsLXBheWZvcnQtc3Vic2NyaXBlXzE2MjkzNzQ1NzYiLCJ0cmFuc2FjdGlvbl9yZWYiOm51bGwsImFwcF9tb2RhbF90eXBlIjoic3Vic2NyaXBlIiwiYXBwX21vZGFsX2lkIjpudWxsLCJhbW91bnQiOiIxMDAiLCJkZXNjcmlwdGlvbiI6bnVsbCwicGFpZCI6MCwiY2hlY2tlZCI6MCwicGF5bWVudF9kYXRlIjpudWxsLCJwYXltZW50X3Jlc3BvbnNlIjpudWxsLCJwYXltZW50X3N0YXR1cyI6bnVsbCwidXNlcl9pZCI6OSwiY3JlYXRlZF9hdCI6IjIwMjEtMDgtMTkgMTI6MDI6NTYiLCJ1cGRhdGVkX2F0IjoiMjAyMS0wOC0xOSAxMjowMjo1NiIsInBheW1lbnRfbWV0aG9kIjoiYXBwbGVfcGF5IiwidXNlciI6eyJpZCI6OSwicm9sZV9pZCI6MiwibmFtZSI6Ik1NTU1NIiwiZW1haWwiOiIiLCJhdmF0YXIiOiJ1c2Vyc1wvZGVmYXVsdC5wbmciLCJjcmVhdGVkX2F0IjoiMjAyMS0wNi0xMyAxMzoxNDozNyIsInVwZGF0ZWRfYXQiOiIyMDIxLTA4LTE5IDEyOjAyOjQ0IiwibW9iaWxlIjoiMDExNTUwMzM5MzIiLCJzdGF0dXMiOjB9fQ@@",
    "response_message": "Failed to execute service",
    "merchant_reference": "xxxxxx",
    "customer_email": "[email protected]",
    "currency": "SAR",
    "phone_number": "01155033932",
    "customer_name": "MMMMM",
    "status": "00"
}

}

i know that "099" mean invalid request but what is the wrong ?

1

There are 1 answers

0
Tariq Mahmood On

For us it turned out Apple pay certificate issue. That certificate which we uploaded in payfort settings was not active in the Apple developer portal.

But here are other possible reasons as indicated by payfort team: Cause could be:

  1. Error in the certificate
  2. Error in the password used for the certificate
  3. Mismatch in the certificate used for signing & the one uploaded in the PayFort BackOffice
  4. Expired certificate