GithubHelp home page GithubHelp logo

stripeforce's Introduction

Stripe SDK for Force.com

Stripe is a fantastic developer-friendly payment processing platform. This SDK was originally developed by Cirruspath in 2012. Please send comments, pull requests, and questions here on github.

Stripe API Documentation

Read up: https://stripe.com/docs/api

Listening for Webhooks

To implement a listener for Stripe webhooks, start with the ExampleWebhookListener.cls class. This class isn't included in the 'src' directory to help avoid contributors' own webhook implementations from unintentionally gettting committed to this public repo or from being overwritten when they pull in the latest code.

Note that not ALL Stripe webhooks are currently supported. However, support for additional webhooks can easily be added to the StripeWebhookListener class. If you make changes to it, please also include the corresponding updates to this webhook implementation class.

WebhookDelayedProcessor

There is often an "indexing delay" after inserting (or updating) records in Salesforce. If your Webhook implementation relies on finding existing records to complete its task (i.e. searching for the account that corresponds to a new Stripe customer), you may find the WebhookDelayedProcessor job useful.

In the example below, after searching for a 'license', we're unable to find one. We check to ensure that delayed processing is allowed (an implementation choice), and we create a Stripe_Webhook__c record with the webhook details. A scheduled job will then re-run the appropriate webhook handler up to 3 times, waiting 5 minutes beteween attempts -- adequate time for Salesforce indexing to catch up.

public void handle_ChargeSucceeded(StripeCharge charge, Boolean allowDelayedProcessing) {
...
		if (license == null) {
			if (allowDelayedProcessing) {
				System.debug(System.LoggingLevel.INFO, '\n**** License Not Found; Delay Webhook Processing'); 
				Stripe_Webhook__c webhook = new Stripe_Webhook__c(
					Webhook_Type__c = 'charge.succeeded',
					Webhook_Data__c = JSON.serializePretty(charge)
				);
				insert webhook;
				return;
			} 
				
			throw new WebhookDelayedProcessor.WebhookDelayedProcessorException();
		}
...
}

Note that delayed processing is currently only implemented for the charge.succeeded webhook, but extending the concept to other webhooks (or making it generic) is not difficult.

stripeforce's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stripeforce's Issues

Save error: Stripe_Settings__c : Property 'customSettingsVisibility' not valid in version 35.0

Description Resource Path Location Type
Save error: Stripe_Settings__c : Property 'customSettingsVisibility' not valid in version 35.0 Stripe_Settings__c.object /ocegSalesforce/src/objects line 0 Force.com save problem

To fix this according to documentation:
http://releasenotes.docs.salesforce.com/en-us/summer15/release-notes/rn_api_meta.htm

Replace 'customSettingsVisibility' with 'visibility', in the Stripe_Settings__c.object

Just hope it helps others.

Invalid field Event_ID__c for SObject Stripe_Webhook__c

Description Resource Path Location Type
Save error: Invalid field Event_ID__c for SObject Stripe_Webhook__c StripeWebhookListener.cls /ocegSalesforce/src/classes line 101 Force.com save problem

In line 101 of StripeWebhookListener.cls, there's use of Event_ID__c:
} catch (WebhookDelayedProcessor.WebhookDelayedProcessorException e) {
Stripe_Webhook__c webhook = new Stripe_Webhook__c(
Webhook_Data__c = RestContext.request.requestBody.toString(),
Webhook_Type__c = event.stripeType,
Event_ID__c = event.id
);

But the problem is that Event_ID__c is not defined/declared in the Stripe_Webhook__c.object. Commenting it out made the error go away.

Same goes with Error_Message__c.

Code Doesnt Deploy?

Im trying to deploy the code using ant and im getting a number of errors. See full error list below.

So i tried to copy up the code manually and still getting tons errors... Like the class is Called StripeWebhookListener and there are places in the code that call it just WebhookListener?

Trying to go through it all and get it to work but are you guys planning to release as a package that will deploy?

Screen shot from developer tools
https://www.dropbox.com/s/pxytcwpv6cs011l/Screenshot%202014-01-26%2011.17.10.png

Deployment Started
Status: Queued
Status: InProgress
Status: InProgress
Status: InProgress
Status: InProgress
Status: InProgress
Status: InProgress
Status: InProgress
Status: InProgress
Status: Completed
Deployment Complete
Failures:
classes/WebhookListener.cls-meta.xml(WebhookListener):Must specify both the source file & the metadata file
classes/StripeAPI.cls(50,39):Dependent class is invalid and needs recompilation:
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeCharge.cls(42,79):Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeChargeTests.cls(31,3):Dependent class is invalid and needs recompilation:
StripeCharge: line 42, column 79: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeCoupon.cls(18,56):Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeCouponTests.cls(24,3):Dependent class is invalid and needs recompilation:
StripeCoupon: line 18, column 56: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeCustomer.cls(151,62):Dependent class is invalid and needs recompilation:
StripeCoupon: line 18, column 56: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeCustomerTests.cls(108,3):Dependent class is invalid and needs recompilation:
Class.StripeCustomer: line 151, column 62
StripeCoupon: line 18, column 56: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeEvent.cls(24,10):Dependent class is invalid and needs recompilation:
StripeCharge: line 42, column 79: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeEventTests.cls(5,3):Dependent class is invalid and needs recompilation:
Class.StripeEvent: line 24, column 10
StripeCharge: line 42, column 79: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeInvoice.cls(20,9):Dependent class is invalid and needs recompilation:
Class.StripeCustomer: line 151, column 62
StripeCoupon: line 18, column 56: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeInvoiceTests.cls(151,3):Dependent class is invalid and needs recompilation:
Class.StripeInvoice: line 20, column 9
Class.StripeCustomer: line 151, column 62
StripeCoupon: line 18, column 56: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeToken.cls(14,51):Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeTokenTests.cls(8,3):Dependent class is invalid and needs recompilation:
StripeToken: line 14, column 51: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeWebhookListener.cls(2,9):Dependent class is invalid and needs recompilation:
Class.StripeEvent: line 24, column 10
StripeCharge: line 42, column 79: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/StripeWebhookListenerTests.cls(7,40):Dependent class is invalid and needs recompilation:
Class.StripeWebhookListener: line 2, column 9
Class.StripeEvent: line 24, column 10
StripeCharge: line 42, column 79: Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/TestStripe.cls(22,49):Dependent class is invalid and needs recompilation:
Class.StripeAPI.startWebhookProcessor: line 50, column 39
WebhookDelayedProcessor: line 19, column 36: Invalid type: WebhookListener
classes/WebhookDelayedProcessor.cls(19,36):Invalid type: WebhookListener

Stripe Webhook Setup Documentation

How does one configure a webhook within stripe such that it hits the WebhookListener.cls? I've created a new webhook to /services/apexrest/stripe/webhooks/v1 and am only getting INVALID SESSION errors. Am I missing something, or was this built before Salesforce implemented OAuth?

StripeInvoice addLineItem not working

Hi,

I'm quite new to salesforce and got a task using your Stripe Client.
I've been trying to do the following.

Once an invoice is created on stripe, to use the webhook invoice.created and then add a line item to the invoice that was just created before process the invoice on Salesforce.

I'm trying now to use the addLineItem method but nothing gets added, and get nothing on the logs.

I've tried calling it like this

            StripeInvoiceItemResponse li = invoice.addLineItem(3);
            System.debug('### Invoice Line Item invoice: ' + li.invoice_id);
            System.debug('### Invoice line item id: ' + li.id);   

or simply

    invoice.addLineItem(3);

Nothing gets added to the invoice on stripe so I don't know exactly what am I missing.

Thanks in advance

Tokenize card through REST API

I do not want to get token through checkout.js or any JS .
Can I use stripeforce to create token with Server side script (i.e Apex class)?

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.