This repository has been archived by the owner on May 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update release notes, sample for security test TLS endpoint, and readme
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Create Payment Using PayPal Sample against endpoint | ||
# that only allows an acceptable highest TLS version | ||
from paypalrestsdk as paypal | ||
import logging | ||
logging.basicConfig(level=logging.INFO) | ||
|
||
paypal.configure({ | ||
"mode": "security-test-sandbox", # sandbox or live | ||
"client_id": "<CLIENT_ID>", | ||
"client_secret": "<CLIENT_SECRET>" }) | ||
|
||
# Payment | ||
# A Payment Resource; create one using | ||
# the above types and intent as 'sale' | ||
payment = paypal.Payment({ | ||
"intent": "sale", | ||
|
||
# Payer | ||
# A resource representing a Payer that funds a payment | ||
# Payment Method as 'paypal' | ||
"payer": { | ||
"payment_method": "paypal"}, | ||
|
||
# Redirect URLs | ||
"redirect_urls": { | ||
"return_url": "http://localhost:3000/payment/execute", | ||
"cancel_url": "http://localhost:3000/"}, | ||
|
||
# Transaction | ||
# A transaction defines the contract of a | ||
# payment - what is the payment for and who | ||
# is fulfilling it. | ||
"transactions": [{ | ||
|
||
# ItemList | ||
"item_list": { | ||
"items": [{ | ||
"name": "item", | ||
"sku": "item", | ||
"price": "5.00", | ||
"currency": "USD", | ||
"quantity": 1}]}, | ||
|
||
# Amount | ||
# Let's you specify a payment amount. | ||
"amount": { | ||
"total": "5.00", | ||
"currency": "USD"}, | ||
"description": "This is the payment transaction description."}]}) | ||
|
||
# Create Payment and return status | ||
if payment.create(): | ||
print("Payment[%s] created successfully" % (payment.id)) | ||
# Redirect the user to given approval url | ||
for link in payment.links: | ||
if link.method == "REDIRECT": | ||
# Convert to str to avoid google appengine unicode issue | ||
# https://github.com/paypal/rest-api-sdk-python/pull/58 | ||
redirect_url = str(link.href) | ||
print("Redirect for approval: %s" % (redirect_url)) | ||
else: | ||
print("Error while creating payment:") | ||
print(payment.error) |