NetTalk Central

Author Topic: Linking to credit card API  (Read 3434 times)

rupertvz

  • Sr. Member
  • ****
  • Posts: 323
    • View Profile
    • Email
Linking to credit card API
« on: February 07, 2012, 05:06:52 AM »
Hi Guys,

Following my previous post re "linking to credit card API";

I want to be able to communicate from my server to the CC API transparently.
And receive the CC API response back into my database.

I have a NetWebForm(Wizard), collecting data from the user.
And a NetWebClient() procedure in the same app.

The post to the CC API should look like this, as an example:
<form method="POST" action="https://their_url/ccform.asp">
<input type="hidden" name="p1" value="a">
<input type="hidden" name="Budget" value="n">
<input type="hidden" name="NextOccurDate" value="o">
<input type="hidden" name="m_10" value="z">
<input type="submit" value="Proceed to Payment">
</form>


I watched the Webinar on NetWebClient() and inserted the following lines of code:

RequestNumber = 1
ThisClient = FreeFieldsQueue()
ThisClient.SetValue('P1',CLIP(LOC:TerminalID)
ThisClient.SetValue('P2',CLIP(LOC:CCTrReferenceNo)
ThisClient.SetValue('P3',CLIP(LOC:Description)
ThisClient.ContentType='application/x-www-form-urlencoded'
ThisClient.POST('https://their_url/ccform.asp','')


* I did not specific any .SSLCertificateOptions, as it is not required by the API.

Back to my procedures:

My NetWebForm(Wizard) procedure, is memory-based and does not automatically insert / update the record.  When the user clicks "Finish" in the wizard, I'd like to insert / update the record and call the NetWebClient procedure.

1.  Which is the best embed to use "after completing the form-wizard" to do any record inserts /  updates and call the NetWebClient procedure for the CC API auth?

2.  I have quite a number of variables to pass between the NetWebForm and the NetWebClient, is the best way to first save the record from the NetWebForm(Wizard) and then to FETCH the record in the NetWebClient() for submission to the CC API?


The CC API makes provision for the following:
URL for cancelled transactions
URL for declined transactions
URL for authorised transactions

3.  I am not too sure how to handle the response coming-back from the CC-API.
What they have indicated:  If we use HTTP method "POST", the parameters will be embedded into the HTTP header.

How could I save the returned values from the reply?

Regards
Rupert

« Last Edit: February 07, 2012, 05:15:13 AM by rupertvz »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Linking to credit card API
« Reply #1 on: February 07, 2012, 07:42:47 AM »
>> 1.  Which is the best embed to use "after completing the form-wizard" to do any record inserts /  updates and call the NetWebClient procedure for the CC API auth?

ValidateRecord routine

>> 2.  I have quite a number of variables to pass between the NetWebForm and the NetWebClient, is the best way to first save the record from the NetWebForm(Wizard) and then to FETCH the record in the NetWebClient() for submission to the CC API?

whatever you prefer.

>> 3.  I am not too sure how to handle the response coming-back from the CC-API.

in .PageReceived method in your Webclient procedure.

>> What they have indicated:  If we use HTTP method "POST", the parameters will be embedded into the HTTP header.
>> How could I save the returned values from the reply?

parse the reply page, and do what you like with the reply.

>> ThisClient.SetValue('P1',CLIP(LOC:TerminalID)
>> ThisClient.SetValue('P2',CLIP(LOC:CCTrReferenceNo)
>> ThisClient.SetValue('P3',CLIP(LOC:Description)

they don't have fields P1, P2, P3. so wy are you setting these values?

bruce


cheers
Bruce


rupertvz

  • Sr. Member
  • ****
  • Posts: 323
    • View Profile
    • Email
Re: Linking to credit card API
« Reply #2 on: February 09, 2012, 04:29:33 AM »
Hi Bruce,

>> 1.  Which is the best embed to use "after completing the form-wizard" to do any record inserts /  updates and call the NetWebClient procedure for the CC API auth?

ValidateRecord routine

I have added some code in the "ValidateRecord" routine,
BEFORE  p_web.DeleteSessionValue('fWizard_ChainTo') in the embeditor
The code however is NOT executed when the wizard FINISH button is clicked, not sure what I am missing here ...


>> 3.  I am not too sure how to handle the response coming-back from the CC-API.

in .PageReceived method in your Webclient procedure.

>> ThisClient.SetValue('P1',CLIP(LOC:TerminalID)
>> ThisClient.SetValue('P2',CLIP(LOC:CCTrReferenceNo)
>> ThisClient.SetValue('P3',CLIP(LOC:Description)

they don't have fields P1, P2, P3. so wy are you setting these values?

Their documentation indicate field names P1 .. P12
For example:  P1 = Terminal ID.
So I guess I have to set these values:
ThisClient.SetValue('P1',CLIP(LOC:TerminalID) ... before posting?


Regards
Rupert

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Linking to credit card API
« Reply #3 on: February 09, 2012, 07:59:44 AM »
>> The code however is NOT executed when the wizard FINISH button is clicked, not sure what I am missing here ...

don't know, but that's the routine that gets called when they press the wizard Finish button.
You can use _trace statements if you like to follow the flow through the Form when the Finish button is pressed.

cheers
Bruce


rupertvz

  • Sr. Member
  • ****
  • Posts: 323
    • View Profile
    • Email
Re: Linking to credit card API
« Reply #4 on: February 10, 2012, 05:24:17 AM »
Thanks Bruce,

The problem was that I was redirecting to another page and need to save the record values, before redirecting.
My problem was caused by "URL ON SAVE" bypassing the Validation Routine.