Giter Club home page Giter Club logo

cfpayment's Introduction

CFPAYMENT

โš ๏ธ After 16 years, our team is moving on to stripe-cfml and I am retiring CFPAYMENT. A sincere thank you goes out to the users and contributors, specifically @cybersonic, @chrismayes, @phillipsenn, @philcruz, @penhorwood, @mark-hetherington, @gpickin, and @capedcoder!

Overview

ColdFusion payment processing library makes plumbing e-commerce apps easy.

Rather than roll your own credit card, ACH or alternative payment gateway with error, currency and money handling, leverage one of our production-tested gateways or extend our base gateway and write only the code necessary to create requests and parse responses for your gateway. Eliminates writing boilerplate code and handling esoteric CFHTTP errors that only seem to happen in production.

Tens of millions of dollars have been processed successfully. Inspired by Ruby's ActiveMerchant.

Compatibility Note

Effort has been made to keep cfpayment compatible with ACF at least as far back as CF8. However, with the widespread elimination of SSL 3.0 and TLS 1.0 in response to security issues and the introduction of SAN/SNI and SHA-256 certificates, versions of (Adobe) ColdFusion as recent as 10 are becoming increasingly unable to make secure CFHTTP calls to remote gateways. As of 5/26/15, Authorize.net uses SHA-256 certificates which Java 1.6 (part of CF7/CF8) does not support. Other gateways such as Paypal are making similar upgrades and more are expected to follow.

If you are using an older version, you should consider upgrading, trying another engine such as Railo/Lucee, or using a the customer tag CFX_HTTP5 if you are on Windows.

Install

A "/cfpayment" mapping is required to the cfpayment root folder. Either add it via the Admin or on CF8+, create a per-application mapping in the Application.cfc:

this.mappings["/cfpayment"] = "/path/to/your/cfpayment/folder";

Charge an Account in 6 Lines of Code

// initialize gateway
cfg = { path = "gateway.stripe.stripe", TestSecretKey = "tGN0bIwXnHdwOa85VABjPdSn8nWY7G7I" };
svc = createObject("component", "cfpayment.api.core").init(cfg);
gw = svc.getGateway();


// create the account
account = svc.createCreditCard().setAccount(4242424242424242).setMonth(10).setYear(year(now())+1)
             .setFirstName("John").setLastName("Doe");

// in cents = $50.00, defaults to USD but can take any ISO currency code
money = svc.createMoney(5000); 

// charge the card
response = gw.purchase(money = money, account = account);

// did we succeed?
if (response.getSuccess()) {
  // yay!  look at response.getResult() or response.getParsedResult()
  // verify response.isValidAVS() or response.isValidCVV()
} else {
  // check response.getStatus(), output response.getMessage()
}

cfpayment's People

Contributors

chrismayes avatar cybersonic avatar ghidinelli avatar gpickin avatar mark-hetherington avatar penhorwood avatar phil-insightfulscience avatar philcruz avatar phillipsenn avatar

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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cfpayment's Issues

the trustAnchors parameter must be non-empty

In early Feb 2016, We updated to the latest Windows 2012 updates and CFPayment quit working (it's actually more of an Adobe bug). We use ColdFusion 10,0,17,295085 (Java 1.8.0_66) and the latest CFPayments + Stripe and started getting this error:

I/O Exception: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

getSuccess() is false. getStatusCode() returns "99" (This status indicates an exception we don't know how to handle (yet)), but getMessage() returns an empty string... no message. So the customer (and developer) don't have any idea regarding what happened.

My personal workaround for this is going to be to rewrite base.cfc to use CFX_HTTP5 so that it will continue to work regardless of the version of ColdFusion or third-party SSL Certificate used. Let me know if you are interested and I can provide you with the modified template.

Hardcoded path to gateway subdirectory makes extending gateways impossible

The current gateway instantiation looks like:

<cfset variables.instance.gateway = createObject("component", "gateway.#lCase(variables.instance.config.path)#").init(config = variables.instance.config, service = this) />

There are circumstances where you want to extend a gateway to override a particular method, like perhaps for error messages or custom response additions, etc. We have a working build with this instead:

<cfset variables.instance.gateway = createObject("component", variables.instance.config.path).init(config = variables.instance.config, service = this) />

That allows configuration like (coldspring example):

<bean id="cfpaymentStripe" class="cfpayment.api.core"> <constructor-arg name="config"> <map> <entry key="path"><value>stripe.stripe</value></entry> <entry key="path"><value>gateway.stripe.stripe</value></entry> <entry key="LiveSecretKey"><value>${STRIPE_LIVE_SECRET_KEY}</value></entry> <entry key="LivePublishableKey"><value>${STRIPE_LIVE_PUB_KEY}</value></entry> <entry key="TestSecretKey"><value>${STRIPE_TEST_SECRET_KEY}</value></entry> <entry key="TestPublishableKey"><value>${STRIPE_TEST_PUB_KEY}</value></entry> <entry key="GatewayID"><value>2</value></entry> <entry key="TestMode"><value>true</value></entry> </map> </constructor-arg> </bean>

But gateway.stripe.stripe could also be model.payment.customstripe which defines an alternative response.

Method chaining is a bit confusing for a proof-of-concept

Can

account = svc.createCreditCard().setAccount(4242424242424242).setMonth(10).setYear(year(now())+1))
             .setFirstName("John").setLastName("Doe");

be rewritten so that one line of code does 1 thing? If I were to break this down into 6 lines, I wouldn't know which one to make an assignment statement to assign account to.

Make Stripe marketplace methods more idiomatic

Review of marketplace appears to have multiple highly-overlapping methods where just the arguments change:

purchase()
charge()
marketplaceDirectCharge()
marketplaceDestinationCharge()

The behavior, depending on the parameters, is quite different but this more clearly matches the Stripe API too so collapsing them into the cfpayment-standard methods makes sense.

invalid ammount

I am using the CFC "payflowGateway.cfc" and when I change the "partner" - "MerchantAccount" - "userName" and "userName" the answer is "INVALID AMOUNT"

I don't understand why it shows this message. I have tried with differents values but the answer always is the same.

Can someone help me please ?

Stripe "address_city" missing.

All our Stripe transactions were processing, but "city" information wasn't being logged by Stripe. In the Stripe gateway CFC (/api/gateway/stripe/stripe.cfc), all address parameters are being configured except "City.

post["card[address_city]"] = arguments.account.getCity();

Improve Stripe object-specific parsing in process()

In post-http process(), I think we should switch from looking for keys like card or sources and instead look at the "object" value. These are valid values:

customer (with default_source and array of sources )
charge (with source )
token (with type = card|bank_account)
card
bank_account
refund
application_fee
transfer
transfer_reversal
account
list (of one of the other types)
file_upload

stripe.cfc - getToken function name causes CF error

If I implement the example exactly "as is" on Coldfusion 8, I get the following CF error;

The names of user-defined functions cannot be the same as built-in ColdFusion functions.
The name getToken is the name of a built-in ColdFusion function.
The CFML compiler was processing:

A cffunction tag beginning on line 216, column 10.

The error occurred in C:\inetpub\wwwroot\cfpayment\api\gateway\stripe\stripe.cfc: line 216
Called from C:\inetpub\wwwroot\cfpayment\api\core.cfc: line 52

Stripe addCreateManagedAccountData() has hardcoded account data

marketplaceCreateConnectedAccount() calls the above method which has hardcoded test data and will not work in real scenarios:

<cfscript>
    arguments.post["managed"] = true;
    arguments.post["country"] = 'CA';
    arguments.post["email"] = 'test#dateFormat(now(),"yyyymmdd")##timeFormat(now(),"HHmmss")#@test.tst';
    arguments.post["default_currency"] = 'CAD';
    //These properties can be set when creating the account, and changed later if the account is managed, but are only relevant if the account has charges being made directly on it:
    //arguments.post["statement_descriptor"] = '';
    //arguments.post["business_name"] = '';
    //arguments.post["support_phone"] = '';
</cfscript>

Stripe upgrades

Hi
Stripe recently upgraded their APIs to be SCA-Ready. I see that the last code commit for CFPayment was December-2017, so does that mean that the code as it stands will not work with the new Stripe API?

Update stripe to latest 2015-04-07 api version

See differences here:

https://stripe.com/docs/upgrades

In post-http process(), I think we should switch from looking for keys like card or sources and instead look at the "object" value. These are valid values:

customer (with default_source and array of sources )
charge (with source )
token (with type = card|bank_account)
card
bank_account

Then we can pass that key to a helper function which knows how to pull out AVS/CVV/etc details.

Stripe CVVS is optional, but shouldn't be passed if not being used (or it will fail)

The CFPayment library allows an empty CVV2 value to be posted to Stripe, but Stripe requires that the parameter not be passed if it's not being used. Excluding setVerificationValue() still caused an empty value to be set and passed. I added the following logic to api/gateway/base.cfc in order to exclude the empty parameter from being passed.

<CFIF NOT Findnocase("cvc", key) OR (Findnocase("cvc", key) AND LEN(trim(arguments.payload[key])))>
    <!--- CFHTTParam --->
</CFIF>

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.