Simple Commodore BASIC 2.0 Disk Command Programs

The COBLOG

Simple Commodore BASIC 2.0 Disk Command Programs

2/9/2020 11:50:00 AM

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:

10 INPUT"ENTER DIRECTORY";S$
20 INPUT"ENTER DISK IMAGE NAME";F$
30 A$="CD//"+S$+"/:"+F$
40 PRINT A$
50 OPEN1,9,15,A$:CLOSE1
60 END

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:

ENTER DIRECTORY? C64/MANIAC
ENTER DISK IMAGE NAME? MANIAC1.D64

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.

10 INPUT"ENTER OLD FILENAME";S$
20 INPUT"ENTER NEW FILENAME";F$
30 A$="R:" + F$ + "=" + S$
40 PRINT "RENAMING " + S$ + " TO " + F$
50 OPEN1,10,15,A$:CLOSE1
60 END

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:

50 OPEN1,8,15,A$:CLOSE1

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:

SAVE "RENAMER",8

Adding a Customer to Braintree Using Coldfusion

8/18/2019 9:44:19 AM

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.

<!--- DECLARE JAVA OBJECTS --->
<cfobject type="java" class="com.braintreegateway.Environment" name="environment" />
<cfobject type="java" class="com.braintreegateway.CustomerRequest" name="customerReq" />
<cfobject type="java" class="com.braintreegateway.PaymentMethodRequest" name="paymentMethod" />
<cfobject type="java" class="com.braintreegateway.SubscriptionRequest" name="subscriptionRequest" />
<cfobject type="java" class="com.braintreegateway.BraintreeGateway" name="gateway" />

The following example shows how to add a customer to the Braintree Vault with a credit card:

<!--- MERCHANT INFO --->
<cfset variables.BTMerchantID = "1q2w3e4r" />
<cfset variables.BTPuclicKey = "0p9o8i7u" />
<cfset variables.BTPrivateKey = "5g6h7j8k" />

<!--- CUSTOMER DATA --->
<cfset variables.firstName = "Gerry" />
<cfset variables.lastName = "Mandering" />
<cfset variables.email = "gerrym@fakedomain.com" />
<cfset variables.phone = "843-555-4444" />
<cfset variables.planType = "Better" />

<!--- CARD DATA --->
<cfset variables.tempID = CreateUUID() />
<cfset variables.tAmount = 0.11 />
<cfset variables.tCC = 4111111111111111 />
<cfset variables.tExp = "09/2020" />
<cfset variables.tCVV = 400 />
<cfset variables.tbillAddr = "1234 Wallaby Way" />
<cfset variables.tPostalCode = 40000 />
<cfset variables.city = "Florence" />
<cfset variables.state = "SC" />

<!--- INITIALIZE MERCHANT GATEWAY --->
<cfset j = gateway.init(Environment.SANDBOX, '#variables.BTMerchantID#', '#variables.BTPublicKey#', '#variables.BTPrivateKey#')>

<!--- ADD CUSTOMER AND PAYMENT METHOD --->
<cfset variables.newCustomer = customerReq.firstName("#variables.firstName#").lastName("#variables.lastName#").email("#variables.email#").phone("#variables.phone#").creditCard().number('#variables.tCC#').expirationDate('#variables.tExp#').cvv('#variables.tCVV#').billingAddress().postalCode("#variables.tPostalCode#").streetAddress("#variables.tbillAddr#").locality("#variables.city#").region("#variables.state#").done().done() />

<cfset variables.newCReq = gateway.customer().create(variables.newCustomer) />

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:

<!--- ADD CUSTOMER AND PAYMENT METHOD --->
<cfset variables.newCustomer = customerReq.firstName("#variables.firstName#").lastName("#variables.lastName#").email("#variables.email#").phone("#variables.phone#").paymentMethodNonce("#variables.payNonce#") />

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:

<!--- VERIFY CUSTOMER AND PAYMENT METHOD IS SUCCESSFULL --->
<cfif variables.newCReq.isSuccess()>
    <cfset variables.custID = variables.newCReq.getTarget().getId() />
    <cfset variables.payToken = variables.newCReq.getTarget().getPaymentMethods() />
    <cfif ArrayIsDefined(variables.payToken,1)>
        <cfset variables.payTokenID = variables.payToken[1].getToken() />
    <cfelse>
        Payment Method Failed.
        <cfabort/>
    </cfif>
    Success, BT Customer ID: <cfoutput>#variables.custID# <br/>
    Payment Token: #variables.payTokenID#<br/>
    </cfoutput>
<cfelse>
    Unable to create customer account.
</cfif>

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:

<!--- CC OBJECT --->
<cfobject type="java" class="com.braintreegateway.CreditCard" name="ccReq" />
<cfset variables.addCreditCard = ccreq().customerId("#variables.custID#").cvv("#variables.tCVV#").number("#variables.tCC#").expirationDate("#variables.tExp#") />
<cfset variables.addCC = gateway.creditCard().create(variables.addCreditCard) />

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.

<!--- ADD MEMBERSHIP SUBSCRIPTION --->
<cfif variables.planType IS "Good">
    <cfset variables.planID = "453g" />
<cfelseif variables.planType IS "Better">
    <cfset variables.planID = "dmp2" />
<cfelse>
    <cfset variables.planID = "" />
</cfif>
<cfif Len(variables.planID)>
    <!--- CREATE SUBSCRIPTION USING PLAN ID AND PAYMENT TOKEN ID --->
    <cfset variables.setSubscription = subscriptionRequest.paymentMethodToken("#variables.payTokenID#").planId("#variables.planID#") />
    <cfset variables.setSubResult = gateway.subscription().create(variables.setSubscription) />
    <cfif variables.setSubResult.isSuccess()>
        <cfset variables.getSubInfo = variables.setSubResult.getTarget().getId() />
        Subscription ID: <cfoutput>#variables.getSubInfo#</cfoutput>
    <cfelse>
        Subscription Failed
    </cfif>
</cfif>

That's about it. Feel free to try this code out in your sandbox account. Here's a complete example:

<!--- DECLARE JAVA OBJECTS --->
<cfobject type="java" class="com.braintreegateway.Environment" name="environment" />
<cfobject type="java" class="com.braintreegateway.CustomerRequest" name="customerReq" />
<cfobject type="java" class="com.braintreegateway.PaymentMethodRequest" name="paymentMethod" />
<cfobject type="java" class="com.braintreegateway.SubscriptionRequest" name="subscriptionRequest" />
<cfobject type="java" class="com.braintreegateway.BraintreeGateway" name="gateway" />

<!--- MERCHANT INFO --->
<cfset variables.BTMerchantID = "1q2w3e4r" />
<cfset variables.BTPuclicKey = "0p9o8i7u" />
<cfset variables.BTPrivateKey = "5g6h7j8k" />

<!--- CUSTOMER DATA --->
<cfset variables.firstName = "Gerry" />
<cfset variables.lastName = "Mandering" />
<cfset variables.email = "gerrym@fakedomain.com" />
<cfset variables.phone = "843-555-4444" />
<cfset variables.planType = "Better" />

<!--- CARD DATA --->
<cfset variables.tempID = CreateUUID() />
<cfset variables.tAmount = 0.11 />
<cfset variables.tCC = 4111111111111111 />
<cfset variables.tExp = "09/2020" />
<cfset variables.tCVV = 400 />
<cfset variables.tbillAddr = "1234 Wallaby Way" />
<cfset variables.tPostalCode = 40000 />
<cfset variables.city = "Florence" />
<cfset variables.state = "SC" />

<!--- INITIALIZE MERCHANT GATEWAY --->
<cfset j = gateway.init(Environment.SANDBOX, '#variables.BTMerchantID#', '#variables.BTPublicKey#', '#variables.BTPrivateKey#')>

<!--- ADD CUSTOMER AND PAYMENT METHOD --->
<cfset variables.newCustomer = customerReq.firstName("#variables.firstName#").lastName("#variables.lastName#").email("#variables.email#").phone("#variables.phone#").creditCard().number('#variables.tCC#').expirationDate('#variables.tExp#').cvv('#variables.tCVV#').billingAddress().postalCode("#variables.tPostalCode#").streetAddress("#variables.tbillAddr#").locality("#variables.city#").region("#variables.state#").done().done() />

<cfset variables.newCReq = gateway.customer().create(variables.newCustomer) />

<!--- VERIFY CUSTOMER AND PAYMENT METHOD IS SUCCESSFULL --->
<cfif variables.newCReq.isSuccess()>
    <cfset variables.custID = variables.newCReq.getTarget().getId() />
    <cfset variables.payToken = variables.newCReq.getTarget().getPaymentMethods() />
    <cfif ArrayIsDefined(variables.payToken,1)>
        <cfset variables.payTokenID = variables.payToken[1].getToken() />
    <cfelse>
        Payment Method Failed.
        <cfabort/>
    </cfif>
    Success, BT Customer ID: <cfoutput>#variables.custID# <br/>
    Payment Token: #variables.payTokenID#<br/>
    </cfoutput>
    <!--- ADD MEMBERSHIP SUBSCRIPTION --->
    <cfif variables.planType IS "Good">
        <cfset variables.planID = "453g" />
    <cfelseif variables.planType IS "Better">
        <cfset variables.planID = "dmp2" />
    <cfelse>
        <cfset variables.planID = "" />
    </cfif>
    <cfif Len(variables.planID)>
        <!--- CREATE SUBSCRIPTION USING PLAN ID AND PAYMENT TOKEN ID --->
        <cfset variables.setSubscription = subscriptionRequest.paymentMethodToken("#variables.payTokenID#").planId("#variables.planID#") />
        <cfset variables.setSubResult = gateway.subscription().create(variables.setSubscription) />
        <cfif variables.setSubResult.isSuccess()>
            <cfset variables.getSubInfo = variables.setSubResult.getTarget().getId() />
            Subscription ID: <cfoutput>#variables.getSubInfo#</cfoutput>
        <cfelse>
            Subscription Failed
        </cfif>
    </cfif>
<cfelse>
    Unable to create customer account.
</cfif>


Creating a PayPal Transaction in Braintree Using Coldfusion

6/2/2019 10:58:38 AM

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:

  • A client token for Braintree that will need to be generated by your server
  • The token will need to be passed into the JavaScript code for the Braintree Client
  • A successful authorization through the payment method interface generates a payment nonce from Braintree
  • That payment nonce is passed into the transaction sale and Braintree handles the rest

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:

<cfobject type="java" class="com.braintreegateway.Environment" name="environment" />
<cfobject type="java" class="com.braintreegateway.BraintreeGateway" name="gateway" />

The Briantree Gateway will need to be initialized.

<cfset j = gateway.init(Environment.SANDBOX, '#variables.merchantID#', '#variables.publicKey#', '#variables.privateKey#')>

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.

<cfset variables.clientToken = gateway.clientToken().generate() />

Include the Braintree libraries provided in the above documentation.

<!-- Load PayPal's checkout.js Library. -->
<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4 log-level="warn"></script>

<!-- Load the client component. -->
<script src="https://js.braintreegateway.com/web/3.44.2/js/client.min.js"></script>

<!-- Load the PayPal Checkout component. -->
<script src="https://js.braintreegateway.com/web/3.44.2/js/paypal-checkout.min.js"></script>

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.

<div id="paypal-button"></div>

<form id="ppFrm" method="post" action="ppBTFinal.cfm">
    <input type="hidden" id="ppNonce" name="ppNonce" />
    <input type="hidden" id="ppTr" name="ppTr" />
</form>

The following JavaScript code handles the Braintree client for PayPal and is modified to receive the client token generated by the server.

<script>
// Create a client.
braintree.client.create({
authorization: '<cfoutput>#variables.clientToken#</cfoutput>'
}, function (clientErr, clientInstance) {

// Stop if there was a problem creating the client.
// This could happen if there is a network error or if the authorization
// is invalid.
if (clientErr) {
console.error('Error creating client:', clientErr);
return;
}

// Create a PayPal Checkout component.
braintree.paypalCheckout.create({
client: clientInstance
}, function (paypalCheckoutErr, paypalCheckoutInstance) {

// Stop if there was a problem creating PayPal Checkout.
// This could happen if there was a network error or if it's incorrectly
// configured.
if (paypalCheckoutErr) {
console.error('Error creating PayPal Checkout:', paypalCheckoutErr);
return;
}

// Set up PayPal with the checkout.js library
paypal.Button.render({
env: 'sandbox', //'production' when live

payment: function () {
return paypalCheckoutInstance.createPayment({
flow: 'checkout',
amount: '1.99',
currency: 'USD',
intent: 'authorize' // this value must either be `capture` or match the intent passed into the PayPal SDK intent query parameter
});
},

onAuthorize: function (data, actions) {
return paypalCheckoutInstance.tokenizePayment(data, function (err, payload) {
// Submit `payload.nonce` to your server.
document.getElementById("ppNonce").value=payload.nonce;
document.getElementById("ppTr").value=data.orderID;
document.getElementById("ppFrm").submit();

});
},

onCancel: function (data) {
console.log('checkout.js payment cancelled', JSON.stringify(data, 0, 2));
},

onError: function (err) {
console.error('checkout.js error', err);
}
}, '#paypal-button').then(function () {
// The PayPal button will be rendered in an html element with the id
// `paypal-button`. This function will be called when the PayPal button
// is set up and ready to be used.
});

});

});

</script>

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):

<!--- DECLARE JAVA OBJECTS --->
<cfobject type="java" class="com.braintreegateway.Environment" name="environment" />
<cfobject type="java" class="com.braintreegateway.BraintreeGateway" name="gateway" />

<cfset variables.merchantID = "1z2y3x4w5v" />
<cfset variables.publicKey = "9a8b7c6d5e" />
<cfset variables.privateKey = "1q2w3e4r5t" />

<!--- SANDBOX INITIALIZATION FOR TEST TRANSACTIONS --->
<cfset j = gateway.init(Environment.SANDBOX, '#variables.merchantID#', '#variables.publicKey#', '#variables.privateKey#')>

<cfset variables.clientToken = gateway.clientToken().generate() />

<!-- Load PayPal's checkout.js Library. -->
<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4 log-level="warn"></script>

<!-- Load the client component. -->
<script src="https://js.braintreegateway.com/web/3.44.2/js/client.min.js"></script>

<!-- Load the PayPal Checkout component. -->
<script src="https://js.braintreegateway.com/web/3.44.2/js/paypal-checkout.min.js"></script>

<div id="paypal-button"></div>

<form id="ppFrm" method="post" action="ppBTFinal.cfm">
    <input type="hidden" id="ppNonce" name="ppNonce" />
    <input type="hidden" id="ppTr" name="ppTr" />
</form>
<script>
    // Create a client.
    braintree.client.create({
     authorization: '<cfoutput>#variables.clientToken#</cfoutput>'
    }, function (clientErr, clientInstance) {
    
     // Stop if there was a problem creating the client.
     // This could happen if there is a network error or if the authorization
     // is invalid.
     if (clientErr) {
     console.error('Error creating client:', clientErr);
     return;
     }
    
     // Create a PayPal Checkout component.
     braintree.paypalCheckout.create({
     client: clientInstance
     }, function (paypalCheckoutErr, paypalCheckoutInstance) {
    
    // Stop if there was a problem creating PayPal Checkout.
    // This could happen if there was a network error or if it's incorrectly
    // configured.
    if (paypalCheckoutErr) {
     console.error('Error creating PayPal Checkout:', paypalCheckoutErr);
     return;
    }
    
    // Set up PayPal with the checkout.js library
    paypal.Button.render({
     env: 'sandbox', //'production' when live
    
     payment: function () {
     return paypalCheckoutInstance.createPayment({
     flow: 'checkout',
     amount: '1.99',
     currency: 'USD',
     intent: 'authorize' // this value must either be `capture` or match the intent passed into the PayPal SDK intent query parameter
     });
     },
    
     onAuthorize: function (data, actions) {
     return paypalCheckoutInstance.tokenizePayment(data, function (err, payload) {
     // Submit `payload.nonce` to your server.
     document.getElementById("ppNonce").value=payload.nonce;
     document.getElementById("ppTr").value=data.orderID;
     document.getElementById("ppFrm").submit();
    
     });
     },
    
     onCancel: function (data) {
     console.log('checkout.js payment cancelled', JSON.stringify(data, 0, 2));
     },
    
     onError: function (err) {
     console.error('checkout.js error', err);
     }
    }, '#paypal-button').then(function () {
     // The PayPal button will be rendered in an html element with the id
     // `paypal-button`. This function will be called when the PayPal button
     // is set up and ready to be used.
    });
    
     });
    
    });
    
</script>

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:

<cfobject type="java" class="com.braintreegateway.Environment" name="environment" />
<cfobject type="java" class="com.braintreegateway.TransactionRequest" name="transactionRequest" />
<cfobject type="java" class="com.braintreegateway.BraintreeGateway" name="gateway" />

<cfset j = gateway.init(Environment.SANDBOX, '#variables.merchantID#', '#variables.publicKey#', '#variables.privateKey#')>

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:

<cfif structKeyExists(form, 'ppNonce') And structKeyExists(form, 'ppTr') And structKeyExists(Session, 'amt')>
    <cfset variables.request = transactionRequest.amount(JavaCast('bigdecimal','#Session.amt#')).paymentMethodNonce("#form.ppNonce#").orderID('#form.ppTr#').options().submitForSettlement(true).storeInVaultOnSuccess(false).done()>
    <cfset variables.zed = gateway.transaction().sale(variables.request)>
</cfif>

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.

<cfif variables.zed.isSuccess()>
    <cfset variables.TransID = variables.zed.getTarget().getId() />
    <cfoutput>Transaction ID: #variables.TransID#</cfoutput>
</cfif>

Here's the transaction in it's entirety with the amount stored as Session.amt (ppBTFinal.cfm):

<!--- DECLARE JAVA OBJECTS --->
<cfobject type="java" class="com.braintreegateway.Environment" name="environment" />
<cfobject type="java" class="com.braintreegateway.TransactionRequest" name="transactionRequest" />
<cfobject type="java" class="com.braintreegateway.BraintreeGateway" name="gateway" />

<cfset variables.merchantID = "1z2y3x4w5v" />
<cfset variables.publicKey = "9a8b7c6d5e" />
<cfset variables.privateKey = "1q2w3e4r5t" />

<!--- SANDBOX INITIALIZATION FOR TEST TRANSACTIONS --->
<cfset j = gateway.init(Environment.SANDBOX, '#variables.merchantID#', '#variables.publicKey#', '#variables.privateKey#')>

<cfif structKeyExists(form, 'ppNonce') And structKeyExists(form, 'ppTr') And structKeyExists(Session, 'amt')>
    <!--- ADD TRANSACTION --->
    <cfset variables.request = transactionRequest.amount(JavaCast('bigdecimal','#Session.amt#')).paymentMethodNonce("#form.ppNonce#").orderID('#form.ppTr#').options().submitForSettlement(true).storeInVaultOnSuccess(false).done()>
    <cfset variables.zed = gateway.transaction().sale(variables.request)>
    <cfif variables.zed.isSuccess()>
        <cfset variables.TransID = variables.zed.getTarget().getId() />
        <cfoutput>Transaction ID: #variables.TransID#</cfoutput>
    </cfif>
</cfif>

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.


END OF LINE.
DISCLAIMER: The recommendations posted here may not be the best solutions. Please feel free to make your own adjustments which may be better than what I posted.
© 2021 Openshaw Ltd. Productions