Coder Social home page Coder Social logo

passtripe's Introduction

pasStripe

Important! Please Read!

These interfaces are far from complete and only expose the properties/methods I have required for my project.

These classes/interfaces barely scratch the surface of the Stripe API but it help others get a head start with integrating with Stripe.

I've just converted this to use System.Json from JsonDataObjects (which is awesome and my prefered json library) via the use of a class helper which mimicks some of the JsonDataObjects property conventions.
Hopefully this will make it easier for others to use, but is also likely to have introduced a few bugs which I may have missed.

To use, add the pasStripe.pas file to your uses clause, then use the TpsFactory class to create the pasStripe interface.

Examples

Create a checkout page...

procedure TForm1.btnCreateCheckoutSessionClick(Sender: TObject);
var
  AStripe: IpasStripe;
  AParams: psCreateCheckoutParams;
  AUrl: string;
begin
  AStripe := TpsFactory.PasStripe('sk_test_fFt5YRlBI*********', 'acct_1O2AWuQ********');

  AParams := TpsFactory.CreateCheckoutParams(cmPayment, scGbp);
  AParams.CustomerEmail := '[email protected]';
  AParams.PaymentMethods := [pmCard];
  AParams.SuccessUrl := 'https://www.success_url.com';
  AParams.CancelUrl := 'https://www.cancel_url.com';
  AParams.LineItems.AddLineItem('Product 1', 500, 2, '', TpsRecurring.None);
  AParams.LineItems.AddLineItem('Another product', 250, 3, '', TpsRecurring.None);
  AUrl := AStripe.GenerateCheckoutSession(AParams).Url;
end;

Display the account name...

procedure TForm1.btnShowAccountName(Sender: TObject);
var
  AStripe: IPasStripe;
  AAccount: IpsAccount;
begin
  AStripe := TpsFactory.PasStripe('sk_test_fFt5YRlBI*********', 'acct_1O2AWuQ********');
  if AStripe.TestCredentials then
  begin
    AAccount := AStripe.GetAccount;
    ShowMessage(AAccount.Name);
  end;
end;

Load an invoice and show the URL...


procedure TForm1.btnGetInvoiceUrl(Sender: TObject);
var
  AStripe: IPasStripe;
  AInvoice: IpsInvoice;
begin
  AStripe := TpsFactory.PasStripe('sk_test_fFt5YRlBI*********', 'acct_1O2AWuQ********');
  AInvoice := AStripe.GetInvoice('in_1OyXC4QppGf99akRBlkO2E8f');
  showmessage(AInvoice.PdfUrl);
end;

passtripe's People

Contributors

gmurt avatar shaunroselt avatar

Stargazers

 avatar randydom avatar Marco Breveglieri avatar Yosof avatar Mauro Botta avatar Ian Barker avatar Dan avatar George Birbilis avatar Salvador Díaz Fau avatar  avatar 球球 avatar Miguel Henrique avatar Geoffrey Smith avatar Edwin Yip avatar Gustavo 'Gus' Carreno avatar  avatar

Watchers

 avatar randydom avatar Yosof avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.