XF 2.0 Some questions about xF2 purchasable items

Scandal

Well-known member
Hello all!
I'm building my first purchasable item for the xF2 payment system. I have one question and one issue.

A.
I have insert on the xf_purchasable table the info of this new purchasable item. Let's say that the purchasable_type_id is "sc_account_recovery".
I have this template code:
HTML:
<xf:form action="{{ link('purchase', {'purchasable_type_id': 'sc_account_recovery'}) }}" ajax="true" data-xf-init="payment-provider-container" class="block">
                                <xf:foreach loop="$profiles" key="$profileId" value="$profile">
                                    <xf:if is="$profile">
                                            <xf:button type="submit" name="payment_profile_id" value="{$profileId}" class="button--fullWidth" style="margin:0 auto;">
                                                Order Using {$profile.title}
                                            </xf:button>
                                    </xf:if>
                                </xf:foreach>
                                <div class="js-paymentProviderReply-sc_account_recovery"></div>
</xf:form>
while PHP code is:
PHP:
            $paymentRepo = $this->repository('XF:Payment');
            $profiles = $paymentRepo->findPaymentProfilesForList()->fetch();
            $viewparams =  ['profiles' => $profiles];
            return $this->view('', 'mytemplate', $viewparams);
The problem:
When I click the button "Order Using X" I'm getting this on my browser console:
199835
Any idea?

Of course I have place the relative class on my /src/addons/Scandals/MyAddonId/Purchasable/ folder.

B. As I can see, xF2 purchase system is based on the logged in user. Here I'm trying to build an account recovery process by guests.
Is there any way to use the purchase system by a guest?
Let's say that I'm verifying some information via a guest page that ends up with a $user entity (= the final verified's user info like $user->user_id etc). Then I need to use the purchase system like the user $user is logged in (but in reality he is not logged in).
Any idea or advices how to achieve it? :)
 
I was able to fix #A. As for #B, it seems that the purchase system is working normal also for guests.

I have a new question while I'm investigating too by myself: when we click the "order with PayPal" button, it sends the user to paypal via a new page visit (it leaves the forum board). Do you know if that's possible the paypal page to load on a popup instead of the new page? That is the PayPal express checkout. Is that compatible with XF2? :)
 
Last edited:
I was able to find a solution also for the PayPal express checkout. :)

ok, xF2 purchase system is not supporting it, but I did this which has the same result:
I opening a page as popup of 600x800 pixels via a "Pay Now" button. This new page / popup is in reality a xF2 purchase page which has as content a "Please wait..." and the <xf:form id="sc_paypal_submit" action="{{ link('purchase', {'purchasable_type_id': 'sc_account_recovery'}) }}" ajax="true" data-xf-init="payment-provider-container" class="block"> of the purchasable item. This page has an onload submit form:
JavaScript:
jQuery(document).ready(function(){
     jQuery("#sc_paypal_submit").submit();
});
So immediately after the page load, the purchasable item form is submitted and redirects user to PayPal. This is the reason I applied to the end user the "Please wait" and as hidden value, the payment_profile_id of paypal.
paypal.com is of course a responsive page, so ta taaaaaa. :)
 
Top Bottom