XF 2.0 First Attempt At Add On -- Questions From n00b

sip

Active member
Reading through document on Add On, I did understand a bit of it so thought of doing an Add On to get some real time feel, so I may have many questions as learning. Thanks in advance for all the help.
Trying to do a Payment Provider Add on.

Understand the following:
  1. From CLI generate the add on and then work with code.
  2. Have to extend the class AbstractPayment -- this is being done.
  3. In development mode have to add class extensions from ACP.
Say my Add On is Sip/SomeProvider
Questions at First Step:

Question1: This add on will need to insert (or delete) in the table xf_payment_provider (both during install and uninstall) to insert (or delete)
with
provider_id (someprovider)
provider_class(Sip:SomeProvider)
addon_id (Sip).
Is the above correct?

Question 2: what would be the insert/delete XF syntax (during install/uninstall) to update the table xf_payment_provider in Setup.php or just the conventional mysql insert command would be fine? Or there's something more to it wrt inserting record in xf_payment_provider for a new provider?

TIA
 
Last edited:
I've not attempted to insert a new payment provider, but in the Setup.php file you can use $this->query() with an INSERT IGNORE statement (so that it doesn't error if the setup was halted and restarted).

Using $this->query() in Setup.php is better than going directly to the database adapter, because it contains automatic exception handling. For more information on this, see protected function query($sql, $bind = [], $suppressAll = false) in XF\AddOn\AbstractSetup

Hope this helps :)


Fillip
 
  • Like
Reactions: sip
I've not attempted to insert a new payment provider, but in the Setup.php file you can use $this->query() with an INSERT IGNORE statement (so that it doesn't error if the setup was halted and restarted).

Using $this->query() in Setup.php is better than going directly to the database adapter, because it contains automatic exception handling. For more information on this, see protected function query($sql, $bind = [], $suppressAll = false) in XF\AddOn\AbstractSetup

Hope this helps :)


Fillip
Thanks!
So going thru Setup will also take care of two columns in that table being hex and not clear text?
 
You can insert the data as clear text, or as hex.

This is how I do an insert with hex in Setup.php:
PHP:
        $this->query("
            INSERT IGNORE INTO `xf_purchasable`
                (`purchasable_type_id`, `purchasable_class`, `addon_id`)
            VALUES
                ('dbtech_credits_currency', 'DBTech\\\Credits\\\XF:Currency', X'4442546563682F43726564697473')
        ");
Pay special attention to the triple escaping of the backslash as well, otherwise the data you insert isn't going to display.


Fillip
 
  • Like
Reactions: sip
xf_payment_provider -- This is the table where we would be adding for a new Provider, if I am not wrong?
 
Ok, almost there. Integrating payumoney.com/payubiz.in
Checked in test environment with a test card details provided by them.
  1. Payment provider can be configured in XF2
  2. Upgrade plan can be attached (non recurring only as provider doesn't support recurring) in XF2
  3. Payment goes through fine.
  4. The configured group gets allocated. in XF2
However, there's one nagging issue that I see in the logs, although everything else goes thru fine:
Verification of Secure Hash Failed: E700

The log also mentions no error subsequently.
I know this is provider specific, but posting here just in case someone worked on same provider.
Have emailed their support but being weekends, can only get reply after Monday.

array(2) {
["_GET"] => array(3) {
["purchase/process"] => string(0) ""
["request_key"] => string(32) "fH7E7nFkquhkAykM29UYKt_q04UcVsVP"
["_xfredirect"] => string(7) "account"
}
["_POST"] => array(52) {
["mihpayid"] => string(18) "403993715516949968"
["mode"] => string(2) "CC"
["status"] => string(7) "success"
["unmappedstatus"] => string(8) "captured"
["key"] => string(8) "[EDITED]"
["txnid"] => string(32) "fH7E7nFkquhkAykM29UYKt_q04UcVsVP"
["amount"] => string(3) "5.0"
["addedon"] => string(19) "2017-12-03 00:03:28"
["productinfo"] => string(49) "Account upgrade: One year subscription (admin) , "
["firstname"] => string(5) "admin"
["lastname"] => string(0) ""
["address1"] => string(0) ""
["address2"] => string(0) ""
["city"] => string(0) ""
["state"] => string(0) ""
["country"] => string(0) ""
["zipcode"] => string(0) ""
["email"] => string(26) "[EDITED]"
["phone"] => string(10) "[EDITED]"
["udf1"] => string(0) ""
["udf2"] => string(0) ""
["udf3"] => string(0) ""
["udf4"] => string(0) ""
["udf5"] => string(0) ""
["udf6"] => string(0) ""
["udf7"] => string(0) ""
["udf8"] => string(0) ""
["udf9"] => string(0) ""
["udf10"] => string(0) ""
["hash"] => string(128) "abdedb1a4a3d1cf68862f1412206d7287e9f8751959b7afd34d55b6059c9a77c0dea8f637e28e4fffb5d064ce044174280c2241e9d9aaa37bd688bae75abcf03"
["field1"] => string(6) "273950"
["field2"] => string(6) "184873"
["field3"] => string(6) "202903"
["field4"] => string(2) "MC"
["field5"] => string(12) "231867966009"
["field6"] => string(2) "00"
["field7"] => string(1) "0"
["field8"] => string(3) "3DS"
["field9"] => string(112) " Verification of Secure Hash Failed: E700 -- Approved -- Transaction Successful -- Unable to be determined--E000"
["PG_TYPE"] => string(6) "AXISPG"
["encryptedPaymentId"] => string(32) "6C3C0C8B60DAACB335784BBA252BBBDB"
["bank_ref_num"] => string(6) "273950"
["bankcode"] => string(2) "CC"
["error"] => string(4) "E000"
["error_Message"] => string(8) "No Error"

["name_on_card"] => string(4) "payu"
["cardnum"] => string(16) "512345XXXXXX2346"
["cardhash"] => string(53) "This field is no longer supported in postback params."
["amount_split"] => string(14) "{"PAYU":"5.0"}"
["payuMoneyId"] => string(10) "1111490699"
["discount"] => string(4) "0.00"
["net_amount_debit"] => string(1) "5"
}
}
 
Top Bottom