Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions blockchain_integration/pi_network/payment_gateways/paypal.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import paypalrestsdk


class PayPalPaymentGateway:
def __init__(self, client_id, client_secret, mode='sandbox'):
def __init__(self, client_id, client_secret, mode="sandbox"):
self.client_id = client_id
self.client_secret = client_secret
self.mode = mode
paypalrestsdk.configure({
'mode': mode,
'client_id': client_id,
'client_secret': client_secret
})
paypalrestsdk.configure(
{"mode": mode, "client_id": client_id, "client_secret": client_secret}
)

def create_payment(self, amount, currency, intent='sale'):
payment = paypalrestsdk.Payment({
'intent': intent,
'payer': {
'payment_method': 'paypal'
},
'redirect_urls': {
'return_url': 'http://return.url',
'cancel_url': 'http://cancel.url'
},
'transactions': [{
'item_list': {
'items': [{
'name': 'Item Name',
'sku': 'Item SKU',
'price': str(amount),
'currency': currency,
'quantity': 1
}]
},
'amount': {
'currency': currency,
'total': str(amount)
def create_payment(self, amount, currency, intent="sale"):
payment = paypalrestsdk.Payment(
{
"intent": intent,
"payer": {"payment_method": "paypal"},
"redirect_urls": {
"return_url": "http://return.url",
"cancel_url": "http://cancel.url",
},
'description': 'This is the payment description.'
}]
})
"transactions": [
{
"item_list": {
"items": [
{
"name": "Item Name",
"sku": "Item SKU",
"price": str(amount),
"currency": currency,
"quantity": 1,
}
]
},
"amount": {"currency": currency, "total": str(amount)},
"description": "This is the payment description.",
}
],
}
)
return payment

def execute_payment(self, payment_id, payer_id):
payment = paypalrestsdk.Payment.find(payment_id)
payment.execute({'payer_id': payer_id})
payment.execute({"payer_id": payer_id})
return payment