Now for something other than Coldfusion. For the vintage computer folks, odds are that this isn't for you since you already know how to do this. For me and other enthusiasts, this may be helpful.
Recently, I acquired a Commodore 128 Personal Computer that I used to use in my earlier years. Back then and even today, Commodore BASIC wasn’t my strongest language as I only knew the simplest disk commands to run a program. Now with an SD2IEC drive and a CMD FD-2000, cartridge-based utilities including Epyx Fastload Reloaded and Cinemaware Warp Speed, although great for many utilities and additional uses, don't cooperate fully with these disk drives.
This first Commodore BASIC 2.0 program allows the user to mount a Commodore D64 Disk Image from a sub-folder to be used to load programs from. The command for this, found at https://www.thefuturewas8bit.com/index.php/sd2iec-info is useful but complex to type. I simplified into the following code:
On Line 50, the number '9' is the drive number. If the SD2IEC is your primary drive, then odds are that it's '8.' This program will allow you to enter the directory and sub-directory, followed by the name of the disk image file. Make sure to include the extension, likely '.d64.' Sub-directories may be entered by a simple forward slash. For example, if the file is in 'c64/maniac/maniac1.d64,' you enter the following when prompted:
If the SD2IEC blinks consistently after running it, then there was likely a typo somewhere on the inputs. You'll likely need to reset the SD2IEC drive and try again.
The next program here is a simple file renaming program. This was built once I received my CMD FD-2000 disk drive for 3.5" floppy disks. The Epyx Fastload Reloaded Cartridge usually works with the primary drive, not so much with separate drives and the Cinemaware Warp Speed Cartridge doesn’t appear to have a file renaming function. This program is a simple file renamer based off of reference found at https://www.c64-wiki.com/wiki/Drive_command.
Similar to the last program example, the number '10' in Line 50 is the drive number. The CMD FD-2000 by default is set to drive 10. Again, if your drive is the primary drive, even when it’s not the FD-2000, then you may substitute '10' with '8.' Example:
Hope some of you find this helpful. Feel free to experiment with this if you want. Please note that the variables with the '$' suffix are string variables and unlike in Visual Basic and many other programming languages, I had to keep the variable names to single characters. I noticed in Commodore BASIC 2.0 that when I entered two variables starting with the same character, the first variable gets overwritten. For example, it interpreted STRA$ also as STRB$; so if I entered 'STRA$="TESTA"' followed by 'STRB$="TESTB",' STRA$ gets 'TESTB' so I’m guessing it thinks STRA$ and STRB$ is really S$; so it would be best to stick with single character variable names.
To keep these programs, as usual, simply use the SAVE disk command to save it your drive.
Example:
I'll briefly go over adding customers and recurring payment subscriptions in Coldfusion using Java. The basic documentation for Customers can be found at:
https://developers.braintreepayments.com/guides/customers/java
The following objects, including those previously mentioned in earlier posts, are required.
The following example shows how to add a customer to the Braintree Vault with a credit card:
A payment nonce is more secure, but there's no reasonable documentation from Braintree for credit card nonce generators. In this example, however, here's how to pass a nonce when creating the customer in the vault:
For examples on getting a payment nonce with PayPal, visit the previous post at:
http://www.openshawltdpro.com/coblog.aspx?cb=8
Nonces for other payment methods including Apple Pay and Google Pay have similar processes, but different scripts. Luckily, Braintree has decent examples in their documentation and require client tokens similar to how they're generated in examples from the previous post.
Once a customer is created with a payment method, you can get it to return a payment token. This token may be used to attach a subscription. Please note that when a customer is added to the vault with a payment method, the method is saved as a default and can't be overridden when the customer is first added. Here's how to retrieve the payment token:
This method looks at all payment methods and grabs the first. Another process can be used to get the default by substituting getPaymentMethods() with getDefaultPaymentMethod(), which should only return only one value so an array lookup isn't needed. The default payment token can only be removed from default status when another payment method is added. Here's a basic example of adding a credit card to a customer account along with the object required to add the credit card request:
Adding a subscription is very simple once you have the subscription ID and payment token provided. The Braintree Control Panel is the best place to add subscriptions, set up recurring payments, and can get a subscription ID. The final example shows adding a subscription to the customer's account in Coldfusion.
That's about it. Feel free to try this code out in your sandbox account. Here's a complete example:
This post will cover alternate payment methods in Braintree. The example in this post will focus specifically with PayPal, though other payment methods follow similar processes. In this case, at least PayPal, ApplePay, and Google Pay have the following in common:
The examples provided here will be in two parts, the client interface page and the transaction page. The client interface page has the server generate a client token and is passed into a JavaScript function that generates the PayPal checkout button which brings up the PayPal Checkout Page when clicked on. Also included is a form that contains the payment nonce generated when the PayPal Checkout is authorized. The transaction page then takes the payment nonce and finalizes the transaction.
Basic documentation for the client interface is at https://developers.braintreepayments.com/guides/paypal/checkout-with-paypal/javascript/v3.
You'll need to have a PayPal Merchant ID Account and have that account linked to your Braintree Account which can be done via your Braintree Control Panel. The same would need to be done for your sandbox environments for both PayPal and Braintree as well as get a PayPal sandbox test buyer. After that is setup, you'll be able to set-up your test pages.
To start, the following cfobjects will need to be declared:
The Briantree Gateway will need to be initialized.
Remember that when going live to replace 'Environment.SANDBOX' with 'Environment.PRODUCTION' and use the correct merchant ID and keys with those from your Braintree Production Control Panel.
The next step is to generate the client token.
Include the Braintree libraries provided in the above documentation.
Here's the code for the PayPal button div tag and the form with the payment nonce and transaction ID that would be submitted to the transaction page.
The following JavaScript code handles the Braintree client for PayPal and is modified to receive the client token generated by the server.
Please note that "intent: 'authorize'" can be used as long as you submit the PayPal transaction for settlement along with the payment nonce.
Here is the code for the client interface in it's entirety (ppTest.cfm):
Basic documentation for the transaction page is at https://developers.braintreepayments.com/guides/paypal/server-side/java.
The following cfobjects would need to be declared for the transaction page followed by the Environment initialization:
Similar to the credit card transactions, the function process a transaction for PayPal is similar, but all is needed is the payment nonce. The PayPal Transaction/Order ID isn't required but could be useful in storing for reference.
Here's the transaction request followed by the sale provided that the nonce and other fields necessary for the transaction exist:
You'll notice that the amount is passed into the function as a Session variable. This would be better so that the user doesn't try to sneak a different amount into the form submission. You won't have to be concerned about the user changing the amount in the javascript as Braintree encodes the amount into the checkout button that it generates.
For 'options()', 'submitForSettlement(true)' will settle the payment at the same time as the sale is processed. ' storeInVaultOnSuccess(false)' keeps that transaction out of the vault since a customer account wasn't created. I'll cover creating a customer account in a future post.
The following code will check the transaction for success and return the Braintree transaction ID. This is useful to store in your database for referencing.
Here's the transaction in it's entirety with the amount stored as Session.amt (ppBTFinal.cfm):
In a future post, I'll go over creating a Customer Account in Braintree using Coldfusion and setting up a recurring payment plan via Braintree Subscription.