9 posts / 0 new
Last post
mattmilunic8583
Sample purchase payload

Hand coded shopping cart and my first go at real-time CC processing. I'm not a heavily experienced coder.

I took the sample purchase payload from the sandbox and I can populate the {string} sections with PHP. The problem is I don't understand what to surround this with so it can be submitted to get a response. Form tag? Something else? Is there a fully coded example somewhere that I can look at? The sandbox assumes I know what I'm doing.

How does a rookie get help? Level 2 can only be reached by email and has a 24-48 hour lag.

Very frustrating...

{
"merchant_ref": "{Moda Home Elements}",
"transaction_type": "{purchase}",
"method": "{credit_card}",
"amount": "{1.00}",
"partial_redemption": "{false}",
"split_tender_id": "{string}",
"currency_code": "{USD}",
"credit_card": {
"type": "{visa}",
"cardholder_name": "{Matt Milunic}",
"card_number": "{4012 0000 3333 0026}",
"exp_date": "{0217}",
"cvv": "{123}"
},
"billing_address": {
"city": "{Testville}",
"country": "{US}",
"email": "{matt@bluemandolin.com}",
"phone": {
"type": "{string}",
"number": "{336-854-8599}"
},
"street": "{123 Test St}",
"state_province": "{NC}",
"zip_postal_code": "{27407}"
}
}


rohitrajagopal3538
Re: Sample purchase payload

Matt,

Here is a PHP sample - 

<?php

 

#require_once('payeezy-include.php');

 

$apiKey = "";

$apiSecret = "";

$token = "fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6";

$nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))));

$timestamp = strval(time()*1000); //time stamp in milli seconds

 

$payload = getPayload();

 

  /**

   * Generate Payload

   */

 

   function getPayload($args = array())

  {

    $data = "";

   

    $data = array(

              'merchant_ref'=> 'sample txn',

              'transaction_type'=> "authorize",

              'method'=> 'credit_card',

              'amount'=> '200',

              'currency_code'=> 'USD',

              'credit_card'=> array(

                      'type'=> 'visa',

                      'cardholder_name'=> 'JohnSmith',

                      'card_number'=> '4788250000028291',

                      'exp_date'=> '1030',

                      'cvv'=> '123',

                    )

    );

  

    return json_encode($data, JSON_FORCE_OBJECT);

  }

 

$data = $apiKey . $nonce . $timestamp . $token . $payload;

 

$hashAlgorithm = "sha256";

 

### Make sure the HMAC hash is in hex -->

$hmac = hash_hmac ( $hashAlgorithm , $data , $apiSecret, false );

 

### Authorization : base64 of hmac hash -->

$hmac_enc = base64_encode($hmac);

 

$curl = curl_init('https://api-cert.payeezy.com/v1/transactions');

 

$headers = array(

      'Content-Type: application/json',

      'apikey:'.strval($apiKey),

      'token:'.strval($token),

      'Authorization:'.$hmac_enc,

      'nonce:'.$nonce,

      'timestamp:'.$timestamp,

    );

 

curl_setopt($curl, CURLOPT_HEADER, false);

curl_setopt($curl, CURLOPT_POST, true);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);

 

curl_setopt($curl, CURLOPT_VERBOSE, true);

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

 

$json_response = curl_exec($curl);

 

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

 

$response = json_decode($json_response, true);

 

if ( $status != 201 ) {

die("Error: call to URL $serviceURL failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));

}

 

curl_close($curl);

 

echo "JSON response is: ".$json_response."\n";

?>


mattmilunic8583
Re: Sample purchase payload

Thank you for the quick reply!

So, this would be placed on my "Please Wait While We Process Your Transaction" page? And populate it using inputs from my form?


rohitrajagopal3538
Re: Sample purchase payload

Matt,

This code should run on the merchant's server. Using the client side code, you gather the customer's card information. Then you pass on the card details to the merchant server. From the merchant server, you send us the transaction by making the API call (my sample code demonstrates this).

Typically merchants do not like card information flowing through their server because it adds PCI burden. So, you have the option of using  Payeezy JS on the client side which replaces the card number with a random number (token). The rest of the flow remains the same where you pass the token number to the merchant server and execute the transaction.

Please reach out to support@payeezy.com if you have further questions and our implementations team will guide you.


mattmilunic8583
Re: Sample purchase payload

I am having trouble seeding the getPayload function. Can you show me how you would insert these variables into the function?

$merchant_ref="Example Business";
$transaction_type="purchase";
$amount=$_POST['amount'];
$card_type=$_POST['cardtype'];
$card_holder_name=$_POST['card_holder_name'];
$card_number=$_POST['card_number'];
$cvv=$_POST['cvv'];
$exp_date=$_POST['expdate'];
$auth="true";
$card_holder_name=$_POST['billingname'];
$billingaddress=$_POST['billingaddress'];
$billingcity=$_POST['billingcity'];
$billingstate=$_POST['billingstate'];
$billingzip=$_POST['billingzip'];
$billingemail=$_POST['billingemail'];
$billingphone=$_POST['billingphone'];

$nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4,
$cstrong))));

$timestamp = strval(time()*1000); //time stamp in milli seconds

$payload = getPayload();

/**

* Generate Payload

*/

function getPayload($args = array())

{

$data = "";

$data = array(

'merchant_ref'=> 'sample txn',
'transaction_type'=> "authorize",
'method'=> 'credit_card',
'amount'=> '200',
'currency_code'=> 'USD',
'credit_card'=> array(
'type'=> 'visa',
'cardholder_name'=> 'JohnSmith',
'card_number'=> '4788250000028291',
'exp_date'=> '1030',
'cvv'=> '123',

)

);


rohitrajagopal3538
Re: Sample purchase payload

Matt - I have forwarded your question to our implementations team and copied you. PLease check your inbox.


judykomaromi19236
Re: Sample purchase payload

I have the same problem as the original post. I am trying to set up the First Data module for ZenCart ecommerce, however I cannot figure out where to obtain the payload script that is needed for the certification form. The PHP sample provided here does not appear to be complete (it references an include file.. where do we obtain payeezy-include.php?) Is this really the simplest way to generate the payload for the certification form, to run some PHP script on our eCommerce server? Isn't there a more straightforward method? Where is this documented so we can do it correctly? Payeezy really needs to work on their documentation for this process.


christopherlord730
Re: Sample purchase payload

Hello Judy,

The payload is pre-filled although there were some issues with the Payeezy Developer website yesterday. You can also copy/paste the credit card sale transaction referenced in the Docs & Sandbox. If you receive a 401 error during certification please provide the correlation ID and email payeezyboarding@firstdata.com so the appropriate corrections can be made.


judykomaromi19236
Re: Sample purchase payload

Thanks for the response Christopher. Since it wasn't working, I had assumed this is some kind of payload "certification test" that requires running something on the merchant's server to generate a payload. But I'm glad you clarified that the pre-populated script (and sandbox examples) are ok to get past the form. Do you have an idea when this will be fixed? I emailed boarding with the correlation ID info, and they've been aware that I've been stuck on this part for the past few days, but I'm in the dark about when it will be working. We are hoping to go live soon.