Custom Form sending POST information as JSON


(Ryan Archer) #1

We are changing ecommerce payment gateways from SecurePay over to BPoint (SecurePay is no longer supported by our organisation's bank, CBA).

 

So I have been asked to find out how to integrate a custom donation form with the CBA's BPoint system. It has it's own API available here https://www.bpoint.com.au/developers/v2/#but it would appear that I need to get a session generated AuthKey before I can pass over the form details to their secure payment form using the "3rd Party Redirect" method.

 

I have checked this out using Postman application and to make this happen, I need to POST the form information as a JSON object to https://www.bpoint.com.au/webapi/v2/txns/processtxnauthkey to retrieve the AuthKey first (https://www.bpoint.com.au/developers/v2/#threepartypayment) to get an AuthKey. Then I need to use this AuthKey and insert it into third party redirect script to then direct the user to the CBA hosted BPoint form:


<a href="https://www.bpoint.com.au/payments/{MerchantShortName}?in_pay_token={authKey}">Proceed to payment</a>

Heaps of other stuff I am trying to find out. Obviously Squiz Matrix does not yet have any BPoint integration so it appears as though I am doing this one alone.

My big question is, what options do I have for sending form data in JSON format as a POST request? As all the components are

prebuilt in the Squiz environment, I'd assume it's fairly abstracted and I'm not sure what control I have over it.


(Ryan Archer) #2

Have more information about this topic. Apparently custom forms have a "Call REST Resource" submission action. This appears to be what I need to encode the form data into a JSON format. Possible issue is that I need an additional field for the Basic Auth - the merchant ID number, then the username+password+merchantID will need to be encoded in Base 64. I also need to have the form data JSON be formatted in a specific way for BPoint to recognise and process,

 

For example:

{
  "HppParameters" : {
    "TokeniseTxnCheckBoxDefaultValue" : true
  },
  "ProcessTxnData" : {
    "Action" : "payment",
    "Amount" : 0, 
    "Currency" : "AUD",
    "Customer" : {
      "Address" : {
        "AddressLine1" : "123 Fake Street",
        "AddressLine2" : "",
        "AddressLine3" : "",
        "City" : "Melbourne",
        "CountryCode" : "AUS",
        "PostCode" : "3000",
        "State" : "VIC"
      },
      "ContactDetails" : {
        "EmailAddress" : "john.smith@email.com",
        "FaxNumber" : "",
        "HomePhoneNumber" : "",
        "MobilePhoneNumber" : "",
        "WorkPhoneNumber" : ""
      },
      "CustomerNumber" : "1234",
      "PersonalDetails" : {
        "DateOfBirth" : "",
        "FirstName" : "John",
        "LastName" : "Smith",
        "MiddleName" : "",
        "Salutation" : "Mr"
      }
    },
    "MerchantReference" : "test merchant ref",
    "Order" : {
      "BillingAddress" : {
        "Address" : {
          "AddressLine1" : "",
          "AddressLine2" : "",
          "AddressLine3" : "",
          "City" : "",
          "CountryCode" : "",
          "PostCode" : "",
          "State" : ""
        },
        "ContactDetails" : {
          "EmailAddress" : "",
          "FaxNumber" : "",
          "HomePhoneNumber" : "",
          "MobilePhoneNumber" : "",
          "WorkPhoneNumber" : ""
        },
        "PersonalDetails" : {
          "DateOfBirth" : "",
          "FirstName" : "",
          "LastName" : "",
          "MiddleName" : "",
          "Salutation" : ""
        }
      },
      "OrderItems" : [{
        "Comments" : "",
        "Description" : "",
        "GiftMessage" : "",
        "PartNumber" : "",
        "ProductCode" : "",
        "Quantity" : 1,
        "SKU" : "",
        "ShippingMethod" : "",
        "ShippingNumber" : "",
        "UnitPrice" : 100
      }, {
        "Comments" : "",
        "Description" : "",
        "GiftMessage" : "",
        "PartNumber" : "",
        "ProductCode" : "",
        "Quantity" : 1,
        "SKU" : "",
        "ShippingMethod" : "",
        "ShippingNumber" : "",
        "UnitPrice" : 100
      }],
      "ShippingAddress" : {
        "Address" : {
          "AddressLine1" : "",
          "AddressLine2" : "",
          "AddressLine3" : "",
          "City" : "",
          "CountryCode" : "",
          "PostCode" : "",
          "State" : ""
        },
        "ContactDetails" : {
          "EmailAddress" : "",
          "FaxNumber" : "",
          "HomePhoneNumber" : "",
          "MobilePhoneNumber" : "",
          "WorkPhoneNumber" : ""
        },
        "PersonalDetails" : {
          "DateOfBirth" : "",
          "FirstName" : "",
          "LastName" : "",
          "MiddleName" : "",
          "Salutation" : ""
        }
      }
    },
    "Crn1" : "test Crn1",
    "Crn2" : "test Crn2",
    "Crn3" : "test Crn3",
    "BillerCode" : null,
    "TokenisationMode" : 3,
    "TestMode" : false,
    "SubType" : "single",
    "Type" : "internet",
    "FraudScreeningDeviceFingerPrint" : null,
    "EmailAddress" : null,   
    "AmexExpressCheckout" : false
  },
  "RedirectionUrl" : "http://www.slq.qld.gov.au",
  "WebHookUrl" : null 
}

Specifically the parameters of HppParameters, ProcessTxnData, MerchantReference, BillerCode, RedirectionUrl and a few more. I assume I could set up hidden form fields to contain this information to push into the JSON object. Would the process involve collecting the form field data as an array and then making a JSON object from it, i.e. 

var formData = JSON.stringify($("#myForm").serializeArray());

(Bart Banda) #3

Could you hardcode the form values into the POST textarea field of the Call REST resource submission action? Then on the next step of the form (the confrmation screen perhaps, or maybe just a step 2 so that a form submission asset is created) you could do the redirect to BPOINT with the authkey result from the REST call?