I want to accept money through paypal. I need to send the user a link and get paid. The approval_link link is being created successfully. But it is not possible to pay using the link. I log in using this link, click pay, but I am redirected to return_url. I don't want this, I want the user not to be redirected anywhere. You just need to take the money from him and that's it. My project is not a website and I don't have any pages where you can redirect the client. Help to create a payment form without redirecting the client to other pages. I thank you in advance for the attention you paid to my problem and I apologize for my English.
I will repeat briefly: we need a payment form without redirecting to other pages. Just get the money. Please help to configure the parameters of paypalrestsdk.Payment()
import paypalrestsdk
api = paypalrestsdk.set_config(
mode="sandbox",
client_id="XXX",
client_secret="XXX")
token = api.get_access_token()
print(token)
payment = paypalrestsdk.Payment({
"intent": "sale",
"payer": {
"payment_method": "paypal"},
"redirect_urls": {
"return_url": "http://localhost:3000/process",
"cancel_url": "http://localhost:3000/cancel"
},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "1.00",
"currency": "RUB",
"quantity": 1}]},
"amount": {
"total": "1.00",
"currency": "RUB"},
"description": "This is the payment transaction description."}]})
create = payment.create()
if create:
print("Payment created successfully")
else:
print(payment.error)
for link in payment.links:
if link.rel == "approval_url":
# Convert to str to avoid Google App Engine Unicode issue
# https://github.com/paypal/rest-api-sdk-python/pull/58
approval_url = str(link.href)
print("Redirect for approval: %s" % (approval_url))
I tried not to specify links for redirects. If they are not present, the payment is not created.
First of all you are using a deprecated v1/payments API and corresponding SDK. If you were going to implement a website checkout, you should use the current v2/checkout/orders API and its SDK instead; such an integration is documented here.
But your invoice use case is not a normal website checkout, as you've noted. Indeed there is a separate Invoicing API for it, see the invoicing integration guide.
There's no SDK for invoicing APIs--use direct HTTPS API calls to first obtain an oauth2 access token and then create your invoice.
Related
In my application, after user register, it creates a docusign document and send in an envelope to user's email for signature.
My question is how do I also provide a link to the document from my application? I want it to be the same link that user would access in their email. I have tried to construct url from envelope_id which i get from the result of create_envelope, but that seems to be wrong. Is there actually a way to do this? Or the it has to be accessed from user's email?
An envelope uri: envelopes/ids
The flow you might be looking for is called Embedded Signing. With embedded signing, you can redirect your users to sign DocuSign envelopes instead of having them sign via email.
Two steps process:
First, you will create your envelope. Be sure to include clientUserId for each recipient object. This will be used when you want to generate unique signing URLs in the next step.
POST /accounts/{accountId}/envelopes
{
"status": "sent",
"emailSubject": "Envelope with Embedded Signer",
"documents": [{
"documentId": "1",
"name": "contract.pdf",
"documentBase64": "base64 document bytes...",
}],
"recipients": {
"signers": [{
"email": "john#email.com",
"name": "John Doe",
"recipientId": "1",
"clientUserId": "1234"
}]
}
}
Second, you will generate the RecipientViewURL for a given user.
POST /accounts/{accountId}/envelopes/{envelopeId}/views/recipient
{
"userName": "John Doe",
"email": "johndoe#email.com",
"recipientId": "1",
"clientUserId": "1234",
"authenticationMethod": "email",
"returnUrl": "https://www.docusign.com/devcenter"
}
Here is a guide that provides a more thorough background on the feature.
I am trying to integrate Paypal REST SDK where user is redirected to Paypal website for payment and returns after success(or failure). The documentation page says(in red box)
that "use of PayPal REST is restricted for credit cards"
On reading online discussions, somewhere it is mentioned that "direct credit cards" can't be accepted. Firstly, what is "direct credit card"? Then is it true that normal credit cards can pay via this SDK. Also, does direct credit card holders can pay via normal route too.
Note: I can't use Braintree Direct as advised in docs as it is still not available in India
The solution for the above question is called PayPal Guest Checkout.
Guest Checkout [hosted checkout solution on PayPal servers] is an option for buyers who don't have PayPal Account but can make a Payment using Credit Card which will redirect them to the PayPal website.
FLOW:
Checkout Page -> Checkout with PP(PayPal) -> No PP Account -> Guest Checkout -> Use Credit Card for Payment.
This is how Guest Checkout looks like.
Guest Checkout
Direct Credit Card[DCC]: It is seamless checkout using Credit Card on the website without being redirected to PayPal.
FLOW:
Checkout Page -> Select Pay using Credit Card -> Enter Card Details -> Submit
Here is how the DCC looks like.
Direct Credit Card Payment
Does this help?
Card Payment with Paypal
step-1 Add card Details
from paypalrestsdk import CreditCard
from paypalrestsdk import Payment
def card_payemnt(request):
paypalrestsdk.configure({
"mode": "sandbox", # sandbox or live
'client_id' :"",
'client_secret':"",
})
credit_card = CreditCard({
"type": "visa",
"number": "4024007185826731",
"expire_month": "12",
"expire_year": "2022",
"cvv2": "874",
"first_name": "Joe",
"last_name": "Shopper",
})
if credit_card.create():
print("CreditCard[%s] created successfully" % (credit_card.id ))
return HttpResponse('good')
else:
print("Error while creating CreditCard:")
print(credit_card.error)
step2 Complete Payment by using Card ID
def credit_card_payment(request):
paypalrestsdk.configure({
"mode": "sandbox", # sandbox or live
'client_id': "",
'client_secret': "",
})
payment = paypalrestsdk.Payment(
{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card_token": {
"credit_card_id": "CARD-7MH68586JW7132142LXWASJI",
}
}]
},
"transactions": [
{
"amount": {
"total": "6.70",
"currency": "USD"
},
"description": "Payment by vaulted credit card."
}]
}
)
if payment.create():
print(payment.id)
print("Payment created successfully")
else:
print(payment.error)
I followed this tutorial for the authentification with google account in the flask.
As was written in this tutorial the response as the JSON is:
{
"family_name": "Doe",
"name": "John Doe",
"picture": "https://lh3.googleusercontent.com/-asdasdas/asdasdad/asdasd/daadsas/photo.jpg",
"locale": "en",
"gender": "male",
"email": "john#gmail.com",
"link": "https://plus.google.com/+JohnDoe",
"given_name": "John",
"id": "1109367330250025112153346",
"verified_email": true
}
I fetch this JSON response to my database and trying to login in offline mode. In other words, I added one more "group" column to the response and base that column redirect users to the different pages. When I try to log in again with this credentials after login page it opens a blank page without any error. My question how can I keep google user credentials in the flask at offline mode. Thank you for reading
You can't keep it by this way because oath token will update each time. But you can update user data, at the base of the email. Read this guide
I'm using the paypal-python-sdk.
Currently, I'm redirecting the user to paypal where they log in, click confirm, and are redirected back to my site. No issues there. However, I have no idea how to get the authorization id so I can capture the amount authorized (or smaller). According to the docs its supposed to exist under related_resources but the list is always empty.
Will authorizations completed by logging into paypal return an authorization id?
Clarification: I know I can execute the payment with the payment_id. However, executing the payment is out of the question because I must be able to capture less than authorized.
request = {
"intent": "authorize",
"redirect_urls": {
"return_url": PAYPAL_RETURN_URL,
"cancel_url": PAYPAL_CANCEL_URL
},
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"total": str(self.order.total),
"currency": "USD"
},
"description": "Lorem lipsum"
}]
}
payment = Payment(request, api=self._connection())
I want to test it on the side of the functionality of the subscription payment gateway Braintree - for my application using Django (python).
Your code I have only one py file. (without front-end). When I want to create a subscription I get an error:
<ErrorResult 'Payment method token is invalid.' at 7f101d301390>
How can I get token payment method?
Here is all my code:
import braintree
braintree.Configuration.configure(braintree.Environment.Sandbox,
merchant_id="myMechrantId",
public_key="myPublicKey",
private_key="myPrivateKey")
client_token = braintree.ClientToken.generate()
client = braintree.Customer.create({
"first_name": 'Mike',
"last_name": "Smith",
"company": "Braintree",
"email": "jen#example.com",
"phone": "312.555.1234",
"fax": "614.555.5678",
"website": "www.example.com"
})
result = braintree.Subscription.create({
"payment_method_token": "the_token",
"plan_id": "Here is my plan ID"
})
I work at Braintree. Please get in touch with our support team if you have more questions.
In general, one of the main benefits of a service like Braintree is that you never have to handle credit card numbers, so you're better off following the Braintree recurring billing guide instead, which will better match a real integration with Braintree.
That said, if you do want to test it without a front-end, you can test it like this:
result = braintree.Customer.create({
"credit_card": {
"number": "4111111111111111",
"expiration_date": "12/16"
}
})
result = braintree.Subscription.create({
"payment_method_token": result.customer.credit_cards[0].token,
"plan_id": "my_plan_id"
})
It's late but I got stuck on this problem recently, this is the solution that helped me
customer_create_result = gateway.customer.create({
"first_name": user.first_name,
"last_name": user.middle_name + '' + user.last_name,
"payment_method_nonce": payment_method_nonce
})
subscription_create_result = gateway.subscription.create({
"payment_method_token":
customer_create_result.customer.payment_methods[0].token,
"plan_id": braintree_plan_id
})
where payment_method_nonce can be obtained from payload.nonce on payment button click and braintree_plan_id is the id for the plan you create in braintree control panel
here is the braintree reference that helped me
https://developer.paypal.com/braintree/docs/guides/customers#create-with-payment-method