Skip to content

Commit 6748be8

Browse files
author
Randy
authored
Added an example for how to update a payment using payment.replace
Merge pull request #193 from pp-randy/master
2 parents 1f7b2a2 + db0b179 commit 6748be8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

samples/payment/update_payment.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from paypalrestsdk import Payment
2+
import logging
3+
4+
logging.basicConfig(level=logging.INFO)
5+
6+
payment = Payment.find("<PAYMENT_ID>")
7+
8+
# e.g. Update the amount, shipping address, invoice ID, or custom data after payment creation
9+
# You cannot update a payment after the payment executes.
10+
# https://developer.paypal.com/docs/api/payments/#payment_update
11+
update_payment_json = [
12+
{
13+
"op": "replace",
14+
"path": "/transactions/0/amount",
15+
"value": {
16+
"total": "4.50",
17+
"currency": "USD",
18+
"details": {
19+
"subtotal": "5.00",
20+
"shipping_discount": "-0.50"
21+
}
22+
}
23+
}
24+
];
25+
26+
27+
if payment.replace(update_payment_json):
28+
print("Payment[%s] updated successfully"%(payment.id))
29+
else:
30+
print(payment.error)
31+

0 commit comments

Comments
 (0)