Money is not being sent or received when using PayPal REST SDK and PayPal-Python-SDK -


i've integrated paypal payment process in following way using paypal-python-sdk.

  1. order made on our website. @ point know how charge visitor.
  2. i configure paypalrestsdk module passing mode argument live (not sandbox), client id , client secret live settings.
  3. i create payment using paypalrestsdk.payment pass tons of parameters including return_url, cancel_url, price, currency, quantity , others.
  4. if payment created without errors, redirect_url created payment.
  5. user clicks link redirects him redirect_url, paypal page fills in either paypal details or credit card details.
  6. user pays amount of money , being redirected our site.
  7. as last step check if there record in db payment id came in or post parameters , if there 1 in db, i'm marking paid.

now, problem whole process works fine , expected, money not going out paypal account used payment. money not going out credit card either. , of course money not received account used receiving.

here's code generates payment:

# configure sdk. paypalrestsdk.configure({     'mode': settings.paypal_mode, # 1 set 'live'.     'client_id': settings.paypal_client_id,     'client_secret': settings.paypal_secret, })  # create payment. payment = paypalrestsdk.payment({     "intent": "sale",     "payer": {         "payment_method": "paypal"     },     "redirect_urls": {         "return_url": '...', # here's return url.         "cancel_url": '...', # here's cancel url.     },     "transactions": [{         "item_list": {             "items": [{                 "name": "invoice payment #1",                 "sku": "item",                 "price": "1.00", # set 1 testing only.                 "currency": "aud",                 "quantity": 1             }]         },         "amount": {             "total": "1.00", # same above.             "currency": "aud"         },         "description": "invoice payment #1"     }] })  # payment url if successful. if payment.create():     link in payment.links:         if link.method == "redirect":             redirect_url = str(link.href)             "..."             # pass variable html template context. else:     "..."     # handle error. 

so, redirect_url pass user. user initiates payment. payment handled correctly money not transferred or received.

am doing wrong?

ps: here's similar question i've found — “paypal app not receive money via rest”.

answering own question.

after paypal redirects redirect url, have “paymentid” , “payerid” in or post parameters.

after use them successful payment.

payment_id = request.get.get('paymentid', none) or request.post.get('paymentid', none) payer_id = request.get.get('payerid', none) or request.post.get('payerid', none) payment = paypalrestsdk.payment.find(payment_id) 

then need execute payment.

payment_response = payment.execute({'payer_id': payer_id}) 

and if payment executed successfully, rest of stuff need:

if payment_response:     # payment successful.     ... else:     # went wrong.     ... 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -