Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 09/23/2020 in all areas

  1. 2 points
    lynkfs

    Facebook or Google OAuth

    Works from server only, the one specified in the credentials page var document external 'document': variant; var console external 'console': variant; var gapi external 'gapi': variant; implementation { TForm1 } procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components var Script := document.createElement('script'); Script.src := 'https://apis.google.com/js/api.js'; Script.setAttribute('async',''); Script.setAttribute('defer',''); document.head.appendChild(Script); Script.onload := procedure begin writeln('loaded'); // // Load the API client and auth2 library gapi.load('auth2', procedure begin var mypromise : variant; mypromise := gapi.auth2.init(class clientId = '..........s0m9qrp8u2m6dcivi8p09tu5se.apps.googleusercontent.com'; end); mypromise.then(procedure begin console.log(mypromise.isSignedIn.get()); end, procedure begin console.log('error'); end); end); end; end; logs 'loaded' and 'true' your other link does specify useful functions which can be added to the above
  2. 2 points
    jarto

    Facebook or Google OAuth

    Yep, got it working nicely. I'm in the process of writing this into a non-visual component, which can be added to the component palette.
  3. 2 points
    jarto

    Facebook or Google OAuth

    I thought I'd test this. When I try to compile, I get an error in FaceBook.SDK.pas: Syntax Error: Class "JFBUIParams" isn't defined completely [line: 15, column: 35, file: FaceBook.SDK] Edit: Got the SDK to compile by changing into this: JFBUIParams = class external end;
  4. 1 point
    jarto

    Facebook or Google OAuth

    @lynkfs Oh, that helped so much! I've struggled at the concept of calling these external js apis when class references don't exists and also had no experience with using promises. But you helped me get going and now I'm making very good progress 🙂 Now I have TW3FacebookLogin- and TW3GoogleLogin-classes that both work. I'll have to read up a bit to add the necessary parameters (besides ClientId of the app), but I should be able to get them into alpha and component palette next week.
  5. 1 point
    lynkfs

    Integrating Paypal Payment Script

    Your code should work, except for the script placement. The below code is pretty much the same as yours, just embedded in a button click handler (which you might have done too) var W3Button : TW3Button := TW3Button.Create(W3Panel); W3Button.SetBounds(580,-10+160*(cartitems.length+1),200,40); W3Button.Caption := 'Make Payment'; W3Button.OnClick := procedure(sender:TObject) begin var PayPal : TW3Panel := TW3Panel.Create(W3Panel); Paypal.SetBounds(140,100 + 160*(cartitems.length+1),400,800); //position below cart Paypal.StyleClass := 'DIV'; //removes all smart's style info Paypal.handle.id := 'paypal-button-container'; Paypal.NativeScrolling := true; var paypalamount : string := StrAfter(currencytotal,'A$'); asm paypal.Buttons({ createOrder: function(data, actions) { // This function sets up the details of the transaction, including the amount and line item details. return actions.order.create({ purchase_units: [{ amount: { value: @paypalamount } }] }); }, onApprove: function(data, actions) { // This function captures the funds from the transaction. return actions.order.capture().then(function(details) { // This function shows a transaction success message to your buyer. alert('Transaction completed by ' + details.payer.name.given_name); }); } }).render('#paypal-button-container'); //This function displays Smart Payment Buttons on your web page. end; as for the script, put it in the body of your custom template <body> <script src="https://www.paypal.com/sdk/js?client-id=xxx&currency=AUD">
×
×
  • Create New...