Skip to content

Commit

Permalink
BrainTreePorgress
Browse files Browse the repository at this point in the history
  • Loading branch information
cs14rendra authored and ios committed Nov 16, 2017
1 parent eccaf92 commit 166a6a6
Show file tree
Hide file tree
Showing 504 changed files with 40,097 additions and 44 deletions.
43 changes: 43 additions & 0 deletions ApplePaySwagServer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import stripe
from flask import Flask
from flask import request
from flask import json

app = Flask(__name__)

#1
@app.route('/pay', methods=['POST'])
def pay():

#2
# Set this to your Stripe secret key (use your test key!)
stripe.api_key = "sk_test_4HKKLEaGa6YweA50gknGDYEf"

#3
# Parse the request as JSON
json = request.get_json(force=True)

# Get the credit card details
token = json['stripeToken']
amount = json['amount']
description = json['description']

# Create the charge on Stripe's servers - this will charge the user's card
try:
#4
charge = stripe.Charge.create(
amount=amount,
currency="usd",
card=token,
description=description
)
except stripe.CardError, e:
# The card has been declined
pass

#5
return "Success!"

if __name__ == '__main__':
# Set as 0.0.0.0 to be accessible outside your local machine
app.run(debug=True, host= '0.0.0.0')
81 changes: 81 additions & 0 deletions BrainTree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import braintree
import stripe
from flask import Flask
from flask import request
from flask import json

braintree.Configuration.configure(
braintree.Environment.Sandbox,
'8vcr8hbq5yknmx7p',
'68wxydkzwpxms2vp',
'3ff43ddfcc2e2b97718917952d19c070'
)
app = Flask(__name__)

@app.route("/client_token", methods=["GET"])
def client_token():
return braintree.ClientToken.generate()
@app.route("/checkout", methods=["POST"])
def create_purchase():
# def f(nonce_from_the_client):
# nonce_from_the_client = request.form["sandbox_4mpg9vyr_8vcr8hbq5yknmx7p"]
# Use payment method nonce here...
json = request.get_json(force=True)
nonce = json["payment_method_nonce"]
ammount = json["amount"]
result = braintree.Transaction.sale({
"amount": ammount,
"payment_method_nonce": nonce,
"options": {
"submit_for_settlement": True
}
})
if result.is_success:
print("success!: " + result.transaction.id)
elif result.transaction:
print("Error processing transaction:")
print(" code: " + result.transaction.processor_response_code)
print(" text: " + result.transaction.processor_response_text)
else:
for error in result.errors.deep_errors:
print("attribute: " + error.attribute)
print(" code: " + error.code)
print(" message: " + error.message)
return "success"

#1
@app.route('/pay', methods=['POST'])
def pay():

#2
# Set this to your Stripe secret key (use your test key!)
stripe.api_key = "sk_test_4HKKLEaGa6YweA50gknGDYEf"

#3
# Parse the request as JSON
json = request.get_json(force=True)

# Get the credit card details
token = json['stripeToken']
amount = json['amount']
description = json['description']

# Create the charge on Stripe's servers - this will charge the user's card
try:
#4
charge = stripe.Charge.create(
amount=amount,
currency="usd",
card=token,
description=description
)
except stripe.CardError, e:
# The card has been declined
pass

#5
return "Success!"

if __name__ == '__main__':
# Set as 0.0.0.0 to be accessible outside your local machine
app.run(debug=True, host= '0.0.0.0')
24 changes: 24 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'e-shop' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
#pod 'Stripe/ApplePay'
#pod 'Stripe'
pod "SwiftSpinner"
pod 'Braintree', '~> 3.9'

# Pods for e-shop

target 'e-shopTests' do
inherit! :search_paths
# Pods for testing
end

target 'e-shopUITests' do
inherit! :search_paths
# Pods for testing
end

end
44 changes: 44 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PODS:
- Braintree (3.9.9):
- Braintree/API (= 3.9.9)
- Braintree/Coinbase (= 3.9.9)
- Braintree/Drop-In (= 3.9.9)
- Braintree/Payments (= 3.9.9)
- Braintree/PayPal (= 3.9.9)
- Braintree/UI (= 3.9.9)
- Braintree/Venmo (= 3.9.9)
- Braintree/API (3.9.9)
- Braintree/Coinbase (3.9.9):
- Braintree/API
- Braintree/Drop-In (3.9.9):
- Braintree/API
- Braintree/Coinbase
- Braintree/Payments
- Braintree/PayPal
- Braintree/UI
- Braintree/Venmo
- Braintree/Payments (3.9.9):
- Braintree/API
- Braintree/Coinbase
- Braintree/PayPal
- Braintree/Venmo
- Braintree/PayPal (3.9.9):
- Braintree/API
- Braintree/UI
- Braintree/UI (3.9.9):
- Braintree/API
- Braintree/Venmo (3.9.9):
- Braintree/API
- SwiftSpinner (1.5.0)

DEPENDENCIES:
- Braintree (~> 3.9)
- SwiftSpinner

SPEC CHECKSUMS:
Braintree: a9d35b7d5a8d76267adcb5795d32c20ca5f39a99
SwiftSpinner: 4c058c7a1d6b444dd2e1d70988ead40783097133

PODFILE CHECKSUM: f9c29c30105959c35827399e9176ba1f78769ee6

COCOAPODS: 1.3.1
38 changes: 38 additions & 0 deletions Pods/Braintree/Braintree/API/@Public/BTAppSwitchErrors.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions Pods/Braintree/Braintree/API/@Public/BTAppSwitching.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Pods/Braintree/Braintree/API/@Public/BTAppSwitchingDelegate.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Pods/Braintree/Braintree/API/@Public/BTApplePayPaymentMethod.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions Pods/Braintree/Braintree/API/@Public/BTCardPaymentMethod.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 166a6a6

Please sign in to comment.