I'm using Python and Braintree with the Drop-In. I try to not store a credit card in the vault, but the option seems to get ignored.
Here is my code:
result = gateway.transaction.sale({
"amount": order.total_amount,
"payment_method_nonce": request.data.get('nonce', 'none'),
"options": {
"submit_for_settlement": True,
"store_in_vault_on_success": False
},
})
Although the option is set to false after a successful payment (sandbox) and a page refresh the payment method is stored.
That's what you're looking for: https://github.com/braintree/braintree-web-drop-in/issues/470
In your Drop-In config on the client, you need the following config for not saving the credit card with a customer_id:
card: {
vault: {
vaultCard: false
},
},
Related
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.
I want to add account, which has some information readable by all users. According to documentation the user needs to have permissions can_get_all_acc_detail. So I'm trying to add those with creating new role:
tx = self.iroha.transaction([
self.iroha.command('CreateRole', role_name='info', permissions=[primitive_pb2.can_get_all_acc_detail])
])
tx = IrohaCrypto.sign_transaction(tx, account_private_key)
net.send_tx(tx)
Unfortunately after sending transaction I see status:
status_name:ENOUGH_SIGNATURES_COLLECTED, status_code:9, error_code:0(OK)
But then it is taking 5 minutes until timeout.
I've notices that transaction json has different way of embedding permissions than in generic block:
payload {
reduced_payload {
commands {
create_role {
role_name: "info_account"
permissions: can_get_all_acc_detail
}
}
creator_account_id: "admin#example"
created_time: 1589408498074
quorum: 1
}
}
signatures {
public_key: "92f9f9e10ce34905636faff41404913802dfce9cd8c00e7879e8a72085309f4f"
signature: "568b69348aa0e9360ea1293efd895233cb5a211409067776a36e6647b973280d2d0d97a9146144b9894faeca572d240988976f0ed224c858664e76416a138901"
}
In compare in genesis.block it is:
{
"createRole": {
"roleName": "money_creator",
"permissions": [
"can_add_asset_qty",
"can_create_asset",
"can_receive",
"can_transfer"
]
}
},
I'm using iroha version 1.1.3 (but also tested on 1.1.1), python iroha sdh version is 0.0.5.5.
does the account you used to execute the 'Create Role' command have the "can_create_role" permission?
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'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