paypal pay now and returned variables - database

I am making a paypal pay now button for my website to add credits that can be used.
I understand the whole buy now and ipn thing but I what I would like to do is that when the user finishes his pay, there should be a way for the IPN to get the username so that I could add the credits into the database.
Is there a way to have the username sent together with the transaction so that it is returned, too? Thank you.

Please do not rely on the notify url.
You can send a 'custom' parameter in your dictionary object to paypal as listed in the Paypal IPN Docs.
paypal_dict = {
"business": "yourpaypalemail#example.com",
"amount": "10000000.00",
"item_name": "name of the item",
"invoice": "unique-invoice-id",
"notify_url": "http://www.example.com/your-ipn-location/",
"return_url": "http://www.example.com/your-return-location/",
"cancel_return": "http://www.example.com/your-cancel-location/",
"custom": request.user.username, #or you can use request.user.pk
}
The 'custom' value will be saved on paypal's server with the transaction and in your IPN object. This is a much better option than having payments with no customer identified.

In the button params, set the notify_url variable to an URL of maximum 255 characters.
PayPal will HTTP POST to this URL with the IPN details (payment_status, payment_date, etc.).
When creating the button, add params to this URL, such as http://yourwebsite.com?username_for_credits=john%20doe
.
When PayPal will make the IPN HTTP POST, you will get back the username you want.

Related

How to create a case in a Salesforce Account using REST API and python Script

I need some help. I need to create a case in a Account with all the details basically, all the fields, using REST API but it I am not able to figure out, how to insert a record for creating a case.
Could you please guide me, how to create a case using REST API in Salesforce?
Do you use a library such as https://pypi.org/project/simple-salesforce/0.3/ or do you need to craft the REST messages manually?
You'd need to do it in 2 calls, login first (unless you have session id already) and then
POST to
https://yourinstance.my.salesforce.com/services/data/v48.0/sobjects/Case
with header
Authorization Bearer <session id goes here, sometimes called "access token" too>
and body
{
"Subject": "Hello world",
"Description": "Lorem ipsum dolor sit amet...",
"Origin":"Web",
"AccountId" :"0010g00001mbqU4"
}
should work like a charm (pass an account id value right for your org and you might have more fields to fill in).
So now "only" how to log in. That's a bigger topic and depends if it's a backend thing or you'll have a human interacting with it, maybe logging in to SF and then coming back to your org. There's bit of reading on that (simpler if you'd use SOAP API to log in)
For example this would work if I didn't redact all sensitive stuff
POST to
https://login.salesforce.com/services/oauth2/token
with header
Content-Type application/x-www-form-urlencoded
and body
grant_type=password
&client_id=(ask your admin for "connected app")
&client_secret=(ask your admin for "connected app")
&username=redacted%40example.com
&password=redacted
Should return
{
"access_token": "<session id here, use it as Authorization header in next calls>",
"instance_url": "<use this as base url of all next calls>",
"id": "<call GET to this (with the Auth header) to learn more about user",
"token_type": "Bearer",
"issued_at": "1593684589157",
"signature": "redacted"
}
Again - don't do it all by hand if you can, use one of Python libraries for Salesforce.
from simple_salesforce import Salesforce
sf = Salesforce(
username='user name of salesforce account',
password='password',
security_token='token')
Sample data
data ={
"Name" : "ABCD",
"Contact" : "123456789",
"Description":"Radio has damaged because of handling."
}
create record
x = sf.Account.create(data)

Converting from BTC to another currency

From Coinbase API can you convert from Bitcoin to, for example, USDC? I cannot see any reference but I have this feature on the app. I wonder if API supports (or expects support for) this operation, or it just that I'm missing something.
Looking at the Coinbase API PRO Documentation you can create a conversion by:
HTTP REQUEST
POST /conversions
API KEY PERMISSIONS
This endpoint requires the “trade” permission.
Request
{
"from": "USD",
"to": "USDC",
"amount": "10000.00"}
PARAMETERS
from: A valid currency id
to: A valid currency id
amount: Amount of from to convert to to
Probably more of a question of what the valid currencies are
There is a reference for this in the Coinbase API documentation:
https://developers.coinbase.com/api/v2#transfer-money-between-accounts
But as I stated in my question, it unfortunately doesn't seem to work:
Coinbase transfer between accounts returns "Not found"
Without using CoinbasePro API but only Coinbase API from webapp that are the endpoints you need to call:
Have to know base_id of crypto that you want to sell and base_id of
crypto want to buy. You can know it by call GET
"https://api.coinbase.com/v2/
/assets/prices?base=USD&filter=holdable&resolution=latest" and get
from response the "base_id" of your currencies.
Make an order by calling POST "https://api.coinbase.com/v2/trade"
with a request body in json like this:
{ 'amount': [amount that you want to convert], 'amount_asset':
[currency of amount that you want to convert], 'amount_from':
'input', 'source_asset': ["base_id" of crypto that you want to
sell], 'target_asset': ["base_id" of crypto that you want to buy] }
If previous POST "/trade" response code is 201, you have to get the
"id" value of response's json and do a commit of your order by
calling POST "https://api.coinbase.com/v2/trades/[id of json
response of previous https://api.coinbase.com/v2/trade POST"]/commit". If
the response code of this POST commit is 201, your exchange is
started and if there are not error in coinbase, your conversion is
done!

Can we update payment method for braintree subscription?

I'm new to braintree. Can we update payment method to an existing subscription. Is their any way to update payment method. So
user can change their cards for subscription ?
From braintree documentation will this work ?
$result = $gateway->subscription()->update('old_subscription_id', [
'id' => 'old_subscription_id',
'paymentMethodToken' => 'new_payment_method_token'
]);
Full disclosure, I work at Braintree. If you have any additional questions, contact Support
You can update an existing subscription to use any other payment method that is stored in your Vault. You can do this with an existing payment method, or by creating a new payment method with a paymentMethod()->create() API request.
With that said, the request you provided may work, but I recommend not including the id parameter, as that is reserved for setting a new subscription ID. The subscription ID you are hoping to edit will be placed in the first argument, as you've included in your code. You can simplify the request to look something more like this:
$result = $gateway->subscription()->update('old_subscription_id', [
'paymentMethodToken' => 'new_payment_method_token'
]);

How to Develop alexa to speak latest response again

In Details:
Example:
user:- asks About Cricket News.
Alexa:- Reads about the new.
If users says come again or replay
user: Come again.
Alexa: Must read it again what it spoke earlier.
How to handle this situation using webhooks.
Thanks in advance.
You can make use of sessionAttributes to keep track of the last response that Alexa spoke. Whenever you return a response just store the speech and re-prompt in sessionAttributes and whenever a ComeAgainIntent is triggered, take the value from the sessionAttributes and respond accordingly.
Ex:
...
"sessionAttributes": {
"lastResponse": {
"speech": "This was my last speech",
"reprompt": "This was my lst reprompt"
}
}
...
Every time before building the response store the response as lastSpeech in session attributes and write a comeAgainIntent or use amazon.REPEAT intent to repeat the response by getting lastSpeech from session attributes.

Meteor sendVerificationEmail

I'm currently working on revising the registration procedure of our recruitment ATS, made with AngularJS and Meteor, and I need to verify the new user's email during the registration procedure.
The logic would go as followed:
1- User fills in a form on the 'get-started' page and when clicking on 'sumbit', the ATS sends a verification email(I'll be using 'sendVerificationEmail' from Meteor)
2- After the user clicks on the link from the email, they'll get redirected to the 'register' page where additional information is required and the registration procedure is concluded.
As mentioned above, I'm planning to use 'sendVerificationEmail' to verify the user but I also want to use it to send back the userID.
From what I read on the Meteor API, I can pass extra data to the token with 'extraTokenData'
Accounts.sendVerificationEmail(userId, [email], [extraTokenData])
Now how do I declare the 'extraTokenData' object?
Could I do it like this: Accounts.sendVerificationEmail(userId, "", { _id: userId })
And how do I retrieve the 'userId' with 'Accounts.onEmailVerificationLink'?
your help will be greatly appreciated.
The email and the extra tokens are optionals, but if you want to send them send it as a string.
If you want to send the extra token but no emails you can try using Accounts.sendVerificationEmail(userId, undefined, "extra token") or if it doesn't work you can request the user's deatil user Meteor.user(). then call user.emails[0].address.
To retrieve information you have to get user by token and all data are there on user document under services.password.reset field. Look here how Accounts.generateResetToken is implemented https://github.com/meteor/meteor/blob/1e7e56eec8414093cd0c1c70750b894069fc972a/packages/accounts-password/password_server.js#L609.

Resources