About Subscriptions-paypal.php

Started by Stanyy, June 21, 2015, 10:30:23 AM

Previous topic - Next topic

Stanyy

Hi,
There are numerous functions in this file with descriptive comments above them. A few comments are not clear to me:
//Is this a subscription?
and
//Is this a normal payment?

My question is, what's the difference between 'subscription' and 'normal payment'? I may be wrong but isn't everything done inside smf paid subscriptions supposed to be a 'subscription'? since the user would be paying for something which would last for the specified number of days.

Illori

i have not looked at the code but i believe a subscription would be an auto renewal, and a payment would be a one time thing.

Sir Osis of Liver

I believe Illori's correct.  The PayPal API calls a recurring payment 'subscription', and posts two ipn's to subscriptions.php when a member subscribes with recurring payment checked.  PayPal treats it as two separate transactions, the first creates the subscription, the second confirms first payment.  A web_accept is a one time payment with recurring payment unchecked (or disabled in Paid Subs settings). 
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Stanyy

Ok. Thanks for the explanation. Maybe "recurring payment" would have been a more descriptive comment for people like me trying to integrate their own gateway.

Concerning my gateway, I have been able to change the values in the file to match that of my gateway, but after payment, the subscription does not take effect. I get an error report in my email saying: Unknown paod subscriptions transaction type.
The thing is my gateway does not have this value and I don't intend to use recurring subscriptions. Is there a way I can eliminate the code that handles transaction type? Will paid subs work without it?

Thanks in advance.

Kindred

so, you changed values/variables in the SMF source file?    That is a particularly poor idea....
There are ways to integrate SMF without changing things that are likely (and apparently) used elsewhere...

(and moving this to coding, since it is not actually a support request)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Stanyy

Quote from: Kindred on June 22, 2015, 06:36:27 AM
so, you changed values/variables in the SMF source file?    That is a particularly poor idea....
There are ways to integrate SMF without changing things that are likely (and apparently) used elsewhere...

(and moving this to coding, since it is not actually a support request)

Pardon me for not mentioning that I actually made a new copy of the file which then became Subscriptions-mygateway.php
Thanks for moving the topic.

Kindred

hrm....    still - you are attempting to use standard SMF coding, which you have changed...

why not just tie into the EXISTING code and leave the variable names, etc alone?  I swear we have hooks for that sort of tie-in
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Illori

as far as i know SMF supports out of the box other payment systems if the files exist. you dont need to use hooks to add a new payment system.

Kindred

I don't think he is looking to add new payment systems -- from his writing, I believe he is looking to link the SMF subscription system into an existing/external script...

or maybe we're both misunderstanding his use of the term "gateway"
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Stanyy

I am trying to add a new payment system. SMF describes payment systems as "gateway".

From Subscriptions-PayPal.php
// This won't be dedicated without this - this must exist in each gateway!
// SMF Payment Gateway: paypal

Kindred

Sorry, my misunderstanding of terminology....

Ok...  so, adding a new gateway --

Which gateway/service?
What is the expected send to trigger a payment?
What is the expected receive when a payment is confirmed?

If your gateway does not have a specific argument, then you may have to pass a defined/fixed value in the code (e.g. "1")
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Sir Osis of Liver

The txn_type parameter is sent by the gateway, and Paid Subs must conform to the gateway API.  Subscriptions-PayPal.php is built around the data posted by the PayPal ipn.  If you use a different gateway, you'd have to rewrite the code to accept and process the specific data posted by the gateway so that it validates payment and activates subscription.  PayPal calls a recurring payment 'subscription', which would be confusing in SMF, that's why the code/comment is written the way it is.  Just a matter of different terminology.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Stanyy

Quote from: Krash on June 22, 2015, 01:53:37 PM
The txn_type parameter is sent by the gateway, and Paid Subs must conform to the gateway API.  Subscriptions-PayPal.php is built around the data posted by the PayPal ipn.  If you use a different gateway, you'd have to rewrite the code to accept and process the specific data posted by the gateway so that it validates payment and activates subscription.  PayPal calls a recurring payment 'subscription', which would be confusing in SMF, that's why the code/comment is written the way it is.  Just a matter of different terminology.

True.
The thing is, my gateway seems to only do one off payments and does not have a transaction type or anything that could stand for txn_type. They do have a payment_status which returns "Approved", not sure if they're related.
Looking at the code, it seems txn_type is only used for recurring subscriptions (which I am not interested in). My concern is whether removing that part of the code will stop the error or if it is required for smf paid subs to work.
Thank you.

Quote from: Kindred on June 22, 2015, 12:23:56 PM
Sorry, my misunderstanding of terminology....

Ok...  so, adding a new gateway --

Which gateway/service?
What is the expected send to trigger a payment?
What is the expected receive when a payment is confirmed?

If your gateway does not have a specific argument, then you may have to pass a defined/fixed value in the code (e.g. "1")
It's a local gateway for my country.
If i understand, i think i already have this working
I think a payment_status that returns 'Approved'
How do i do this? "you may have to pass a defined/fixed value in the code (e.g. "1")"
Thank you.

Sir Osis of Liver

PayPal API includes many transaction types, SMF only recognizes the couple it needs to process a member subscription.  Sounds like all you need is payment_status to confirm that payment was successful.



// Is this a normal payment?
public function isPayment()
{
if ($_POST['payment_status'] == 'Completed' && $_POST['txn_type'] == 'web_accept')
return true;
else
return false;
}



You should be able to eliminate txn_type, and just change 'Completed' to 'Approved', or whatever your gateway returns when payment is completed.  You want it to return true when payment is received, so subscription will be activated.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Advertisement: